@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,349 +0,0 @@
1
- import {
2
- createLogger,
3
- init_logger
4
- } from "./roy-agent-core-44hnfb02.js";
5
-
6
- // src/env/mcp/tool/adapter.ts
7
- init_logger();
8
- import { z } from "zod";
9
- var logger = createLogger("mcp-adapter");
10
- function validateRequiredParams(inputSchema, args) {
11
- if (!inputSchema) {
12
- return { valid: true, missing: [] };
13
- }
14
- const schema = inputSchema;
15
- const required = schema.required ?? [];
16
- if (required.length === 0) {
17
- return { valid: true, missing: [] };
18
- }
19
- const missing = [];
20
- for (const param of required) {
21
- const value = args[param];
22
- if (value === undefined || value === null) {
23
- missing.push(param);
24
- }
25
- }
26
- if (missing.length > 0) {
27
- return {
28
- valid: false,
29
- missing,
30
- error: `Missing required parameter${missing.length > 1 ? "s" : ""}: ${missing.join(", ")}`
31
- };
32
- }
33
- return { valid: true, missing: [] };
34
- }
35
- function adaptMcpTool(mcpTool, mcpClient, serverName) {
36
- const toolName = `mcp_${serverName}_${mcpTool.name}`;
37
- const description = `MCP tool [${serverName}/${mcpTool.name}]: ${mcpTool.description ?? ""}`;
38
- const paramsSchema = convertInputSchemaToZod(mcpTool.inputSchema);
39
- return {
40
- name: toolName,
41
- description,
42
- parameters: paramsSchema,
43
- execute: async (args, _ctx) => {
44
- const toolArgs = args ?? {};
45
- const validation = validateRequiredParams(mcpTool.inputSchema, toolArgs);
46
- if (!validation.valid) {
47
- logger.warn(`[McpAdapter] Tool call skipped: ${toolName}`, {
48
- reason: "missing_required_params",
49
- missing: validation.missing
50
- });
51
- return {
52
- success: false,
53
- output: "",
54
- error: validation.error
55
- };
56
- }
57
- try {
58
- const result = await mcpClient.callTool({
59
- name: mcpTool.name,
60
- arguments: toolArgs
61
- });
62
- return convertMcpCallResult(result);
63
- } catch (error) {
64
- const errorMessage = error instanceof Error ? error.message : String(error);
65
- const errorCode = error?.code;
66
- logger.error(`[McpAdapter] Tool call failed: ${toolName}`, {
67
- error: errorMessage,
68
- errorCode,
69
- receivedArgs: toolArgs
70
- });
71
- let userMessage = errorMessage;
72
- if (errorCode === -32602) {
73
- userMessage = `Invalid parameters for tool "${mcpTool.name}": ${errorMessage}`;
74
- }
75
- return {
76
- success: false,
77
- output: "",
78
- error: userMessage
79
- };
80
- }
81
- },
82
- metadata: {
83
- category: "mcp",
84
- tags: ["mcp", serverName],
85
- mcpTool: {
86
- originalName: mcpTool.name,
87
- originalDescription: mcpTool.description || "",
88
- inputSchema: mcpTool.inputSchema
89
- }
90
- }
91
- };
92
- }
93
- function convertInputSchemaToZod(inputSchema) {
94
- if (!inputSchema) {
95
- return z.unknown();
96
- }
97
- const schema = inputSchema;
98
- const properties = schema.properties ?? {};
99
- const required = schema.required ?? [];
100
- if (schema.anyOf || schema.oneOf) {
101
- const unions = schema.anyOf || schema.oneOf || [];
102
- const zodUnions = unions.map((s) => jsonSchemaToZod(s, false)).filter((t) => t);
103
- if (zodUnions.length > 0) {
104
- return z.union(zodUnions);
105
- }
106
- }
107
- if (schema.allOf) {
108
- const schemas = [];
109
- for (const subSchema of schema.allOf) {
110
- const sub = jsonSchemaToZod(subSchema, false);
111
- schemas.push(sub);
112
- }
113
- if (schemas.length === 1) {
114
- return schemas[0];
115
- }
116
- let combined = schemas[0];
117
- for (let i = 1;i < schemas.length; i++) {
118
- combined = z.intersection(combined, schemas[i]);
119
- }
120
- return combined;
121
- }
122
- const zodFields = {};
123
- const fieldDescriptions = {};
124
- for (const [key, prop] of Object.entries(properties)) {
125
- const isRequired = required.includes(key);
126
- const fieldResult = jsonSchemaToZod(prop, !isRequired);
127
- const propSchema = prop;
128
- if (propSchema.description) {
129
- fieldDescriptions[key] = propSchema.description;
130
- }
131
- if (!isRequired) {
132
- zodFields[key] = fieldResult.optional();
133
- } else {
134
- zodFields[key] = fieldResult;
135
- }
136
- }
137
- if (Object.keys(zodFields).length === 0) {
138
- return schema.description ? z.unknown().describe(schema.description) : z.unknown();
139
- }
140
- const result = z.object(zodFields);
141
- if (schema.description) {
142
- return result.describe(schema.description);
143
- }
144
- return result;
145
- }
146
- function jsonSchemaToZod(prop, isOptional) {
147
- const description = prop.description;
148
- let baseType;
149
- if (prop.nullable === true) {
150
- const innerType = jsonSchemaToZod({ ...prop, nullable: undefined }, isOptional);
151
- baseType = z.union([innerType, z.null()]);
152
- if (description) {
153
- return baseType.describe(description);
154
- }
155
- return baseType;
156
- }
157
- if (prop.anyOf || prop.oneOf) {
158
- const unions = prop.anyOf || prop.oneOf || [];
159
- const zodUnions = unions.map((s) => jsonSchemaToZod(s, false)).filter((t) => t);
160
- if (zodUnions.length > 0) {
161
- baseType = z.union(zodUnions);
162
- if (description) {
163
- return baseType.describe(description);
164
- }
165
- return baseType;
166
- }
167
- }
168
- if (prop.allOf) {
169
- const schemas = [];
170
- for (const subSchema of prop.allOf) {
171
- const sub = jsonSchemaToZod(subSchema, false);
172
- schemas.push(sub);
173
- }
174
- if (schemas.length === 1) {
175
- baseType = schemas[0];
176
- } else {
177
- baseType = z.intersection(schemas[0], schemas[1]);
178
- for (let i = 2;i < schemas.length; i++) {
179
- baseType = z.intersection(baseType, schemas[i]);
180
- }
181
- }
182
- if (description) {
183
- return baseType.describe(description);
184
- }
185
- return baseType;
186
- }
187
- const types = prop.types || (prop.type ? [prop.type] : []);
188
- if (types.length > 1) {
189
- const zodTypes = types.map((t) => getZodTypeForBasicType(t, prop)).filter((t) => t);
190
- if (zodTypes.length > 0) {
191
- baseType = z.union(zodTypes);
192
- if (description) {
193
- return baseType.describe(description);
194
- }
195
- return baseType;
196
- }
197
- }
198
- const type = types[0];
199
- if (!type) {
200
- if (prop.enum) {
201
- return handleEnum(prop, description);
202
- }
203
- baseType = z.unknown();
204
- if (description) {
205
- return baseType.describe(description);
206
- }
207
- return baseType;
208
- }
209
- baseType = getZodTypeForBasicType(type, prop);
210
- if (description) {
211
- const schemaDescription = baseType._def?.description;
212
- if (schemaDescription) {
213
- return baseType.describe(`${schemaDescription}. ${description}`);
214
- }
215
- return baseType.describe(description);
216
- }
217
- return baseType;
218
- }
219
- function getZodTypeForBasicType(type, prop) {
220
- switch (type) {
221
- case "string": {
222
- if (prop.enum && prop.enum.length > 0 && prop.enum.every((v) => typeof v === "string")) {
223
- return handleEnum(prop, prop.description);
224
- }
225
- let schema = z.string();
226
- if (typeof prop.minLength === "number") {
227
- schema = schema.min(prop.minLength);
228
- }
229
- if (typeof prop.maxLength === "number") {
230
- schema = schema.max(prop.maxLength);
231
- }
232
- if (prop.pattern) {
233
- try {
234
- schema = schema.regex(new RegExp(prop.pattern));
235
- } catch {}
236
- }
237
- if (prop.format) {
238
- schema = schema.describe(`Format: ${prop.format}`);
239
- }
240
- if (prop.default !== undefined) {
241
- schema = schema.default(prop.default);
242
- }
243
- return schema;
244
- }
245
- case "number":
246
- case "integer": {
247
- let schema = type === "integer" ? z.number().int() : z.number();
248
- if (typeof prop.minimum === "number") {
249
- schema = schema.min(prop.minimum);
250
- }
251
- if (typeof prop.maximum === "number") {
252
- schema = schema.max(prop.maximum);
253
- }
254
- if (prop.default !== undefined) {
255
- schema = schema.default(prop.default);
256
- }
257
- return schema;
258
- }
259
- case "boolean": {
260
- let schema = z.boolean();
261
- if (prop.default !== undefined) {
262
- schema = schema.default(prop.default);
263
- }
264
- return schema;
265
- }
266
- case "array": {
267
- let itemSchema = z.unknown();
268
- if (prop.items) {
269
- itemSchema = jsonSchemaToZod(prop.items, false);
270
- }
271
- let schema = z.array(itemSchema);
272
- if (prop.additionalProperties && typeof prop.additionalProperties !== "boolean") {
273
- const additionalItems = jsonSchemaToZod(prop.additionalProperties, false);
274
- schema = z.array(z.union([itemSchema, additionalItems]));
275
- }
276
- return schema;
277
- }
278
- case "object": {
279
- if (prop.properties) {
280
- const fields = {};
281
- const required = prop.required ?? [];
282
- for (const [key, value] of Object.entries(prop.properties)) {
283
- const isRequired = required.includes(key);
284
- fields[key] = isRequired ? jsonSchemaToZod(value, false) : jsonSchemaToZod(value, true).optional();
285
- }
286
- return z.object(fields);
287
- }
288
- if (prop.additionalProperties) {
289
- if (typeof prop.additionalProperties === "boolean") {
290
- return z.record(z.string(), z.unknown());
291
- }
292
- return z.record(z.string(), jsonSchemaToZod(prop.additionalProperties, false));
293
- }
294
- return z.record(z.string(), z.unknown());
295
- }
296
- case "null":
297
- return z.null();
298
- case "null | string":
299
- case "string | null":
300
- return z.union([z.string(), z.null()]);
301
- case "null | number":
302
- case "number | null":
303
- return z.union([z.number(), z.null()]);
304
- default:
305
- if (prop.enum) {
306
- return handleEnum(prop);
307
- }
308
- return z.unknown();
309
- }
310
- }
311
- function handleEnum(prop, existingDescription) {
312
- if (!prop.enum || prop.enum.length === 0) {
313
- return z.unknown();
314
- }
315
- const stringValues = prop.enum.filter((v) => typeof v === "string");
316
- if (stringValues.length === 0) {
317
- return z.any();
318
- }
319
- let schema;
320
- if (stringValues.length === 1) {
321
- schema = z.literal(stringValues[0]);
322
- } else {
323
- schema = z.enum([stringValues[0], ...stringValues.slice(1)]);
324
- }
325
- const valuesList = stringValues.map((v) => `"${v}"`).join(", ");
326
- const valuesDescription = `Valid values: ${valuesList}`;
327
- if (existingDescription) {
328
- return schema.describe(`${existingDescription}. ${valuesDescription}`);
329
- }
330
- return schema.describe(valuesDescription);
331
- }
332
- function convertMcpCallResult(result) {
333
- const content = result.content;
334
- const textContent = content?.filter((c) => c.type === "text")?.map((c) => c.text)?.join("") ?? "";
335
- return {
336
- success: !result.isError,
337
- output: textContent,
338
- error: result.isError ? textContent : undefined
339
- };
340
- }
341
- function createMcpToolsDescription(tools) {
342
- if (tools.length === 0) {
343
- return " No MCP tools currently available.";
344
- }
345
- return tools.map((t) => ` - ${t.name}: ${t.description}`).join(`
346
- `);
347
- }
348
-
349
- export { adaptMcpTool, convertInputSchemaToZod, createMcpToolsDescription };
@@ -1,117 +0,0 @@
1
- import {
2
- __esm
3
- } from "./roy-agent-core-fs0mn2jk.js";
4
-
5
- // src/env/workflow/decorators/decorator-node.ts
6
- class DecoratorNode {
7
- type = "decorator";
8
- id;
9
- methodName;
10
- instance;
11
- dependsOn;
12
- timeout;
13
- retryConfig;
14
- constructor(definition) {
15
- const config = definition.config;
16
- this.id = definition.id;
17
- this.methodName = config._methodName;
18
- this.instance = config._instance;
19
- this.dependsOn = definition.depends_on || [];
20
- this.timeout = definition.timeout;
21
- this.retryConfig = definition.retry;
22
- }
23
- async execute(context) {
24
- const startTime = Date.now();
25
- const method = this.instance[this.methodName];
26
- if (typeof method !== "function") {
27
- return {
28
- success: false,
29
- error: `Method '${this.methodName}' is not a function`,
30
- duration: Date.now() - startTime
31
- };
32
- }
33
- const input = this.prepareInput(context);
34
- const result = await this.executeWithRetry(input, context.abort);
35
- return {
36
- success: !result.error,
37
- output: result.output,
38
- error: result.error,
39
- duration: Date.now() - startTime,
40
- metadata: {
41
- methodName: this.methodName
42
- }
43
- };
44
- }
45
- prepareInput(context) {
46
- const nodeOutputs = context.nodeOutputs;
47
- if (this.dependsOn.length === 0) {
48
- return context.input || {};
49
- }
50
- const input = {};
51
- for (const depId of this.dependsOn) {
52
- const depOutput = nodeOutputs instanceof Map ? nodeOutputs.get(depId) : nodeOutputs?.[depId];
53
- if (depOutput && typeof depOutput === "object") {
54
- if ("output" in depOutput) {
55
- input[depId] = depOutput.output;
56
- } else {
57
- input[depId] = depOutput;
58
- }
59
- }
60
- }
61
- return input;
62
- }
63
- async executeWithRetry(input, abort) {
64
- const maxAttempts = this.retryConfig?.max_attempts ?? 1;
65
- const backoff = this.retryConfig?.backoff ?? "exponential";
66
- const initialDelay = this.retryConfig?.initial_delay ?? 1000;
67
- let lastError;
68
- for (let attempt = 1;attempt <= maxAttempts; attempt++) {
69
- if (abort?.aborted) {
70
- return { error: "Execution aborted" };
71
- }
72
- try {
73
- const output = await this.executeWithTimeout(input, abort);
74
- return { output };
75
- } catch (error) {
76
- lastError = error instanceof Error ? error : new Error(String(error));
77
- if (attempt < maxAttempts) {
78
- const delay = this.calculateBackoff(backoff, initialDelay, attempt - 1);
79
- await this.sleep(delay, abort);
80
- }
81
- }
82
- }
83
- return { error: lastError?.message || "Unknown error" };
84
- }
85
- async executeWithTimeout(input, abort) {
86
- if (!this.timeout) {
87
- return this.instance[this.methodName](input);
88
- }
89
- const timeoutPromise = new Promise((_, reject) => {
90
- setTimeout(() => {
91
- reject(new Error(`Execution timeout after ${this.timeout}ms`));
92
- }, this.timeout);
93
- });
94
- return Promise.race([
95
- this.instance[this.methodName](input),
96
- timeoutPromise
97
- ]);
98
- }
99
- calculateBackoff(backoff, initialDelay, attempt) {
100
- if (backoff === "exponential") {
101
- return initialDelay * Math.pow(2, attempt);
102
- }
103
- return initialDelay;
104
- }
105
- sleep(ms, abort) {
106
- return new Promise((resolve) => {
107
- const timeout = setTimeout(resolve, ms);
108
- abort?.addEventListener("abort", () => {
109
- clearTimeout(timeout);
110
- resolve();
111
- });
112
- });
113
- }
114
- }
115
- var init_decorator_node = () => {};
116
-
117
- export { DecoratorNode, init_decorator_node };
@@ -1,11 +0,0 @@
1
- // src/env/hook/types.ts
2
- function createHook(meta, fn) {
3
- return {
4
- ...meta,
5
- execute: fn
6
- };
7
- }
8
- function createPriorityHook(name, fn, priority) {
9
- return createHook({ name, priority }, fn);
10
- }
11
- export { createHook, createPriorityHook };