@ai-setting/roy-agent-core 1.3.9 → 1.3.11
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/config/index.js +1647 -0
- package/dist/index.js +12579 -89691
- package/package.json +19 -56
- package/src/config/config-component.test.ts +0 -627
- package/src/config/config-component.ts +0 -906
- package/src/config/config-parser.test.ts +0 -319
- package/src/config/config-parser.ts +0 -203
- package/src/config/decentralized-config.test.ts +0 -740
- package/src/config/env-key.ts +0 -210
- package/src/config/env-source.test.ts +0 -252
- package/src/config/env-source.ts +0 -301
- package/src/config/file-source.test.ts +0 -357
- package/src/config/file-source.ts +0 -421
- package/src/config/index.ts +0 -24
- package/src/config/protocol-resolver.test.ts +0 -217
- package/src/config/protocol-resolver.ts +0 -228
- package/src/env/agent/agent-component.abort.test.ts +0 -511
- package/src/env/agent/agent-component.record-session.test.ts +0 -349
- package/src/env/agent/agent-component.test.ts +0 -1389
- package/src/env/agent/agent-component.tool-error.test.ts +0 -327
- package/src/env/agent/agent-component.ts +0 -1711
- package/src/env/agent/agent-config-registration.test.ts +0 -226
- package/src/env/agent/agent-config-registration.ts +0 -46
- package/src/env/agent/agent-reminder-plugin.integration.test.ts +0 -243
- package/src/env/agent/index.ts +0 -10
- package/src/env/agent/summary-agent.parse-hint.test.ts +0 -360
- package/src/env/agent/summary-agent.ts +0 -508
- package/src/env/agent/types.ts +0 -536
- package/src/env/commands/commands-component.test.ts +0 -364
- package/src/env/commands/commands-component.ts +0 -604
- package/src/env/commands/commands-config-registration.test.ts +0 -198
- package/src/env/commands/commands-config-registration.ts +0 -38
- package/src/env/commands/index.ts +0 -21
- package/src/env/commands/parser.test.ts +0 -203
- package/src/env/commands/parser.ts +0 -115
- package/src/env/commands/types.ts +0 -184
- package/src/env/commands-prompt-integration.test.ts +0 -243
- package/src/env/component-env.test.ts +0 -119
- package/src/env/component.ts +0 -335
- package/src/env/constants.test.ts +0 -72
- package/src/env/constants.ts +0 -123
- package/src/env/debug/debug-component.test.ts +0 -114
- package/src/env/debug/debug-component.ts +0 -547
- package/src/env/debug/formatters/index.ts +0 -9
- package/src/env/debug/formatters/repl-formatter.test.ts +0 -139
- package/src/env/debug/formatters/repl-formatter.ts +0 -358
- package/src/env/debug/formatters/trace-formatter.test.ts +0 -119
- package/src/env/debug/formatters/trace-formatter.ts +0 -191
- package/src/env/debug/formatters/tree-formatter.test.ts +0 -107
- package/src/env/debug/formatters/tree-formatter.ts +0 -325
- package/src/env/debug/index.ts +0 -38
- package/src/env/debug/parser/regex-parser.test.ts +0 -201
- package/src/env/debug/parser/regex-parser.ts +0 -196
- package/src/env/debug/parser/span-builder.test.ts +0 -241
- package/src/env/debug/parser/span-builder.ts +0 -386
- package/src/env/debug/reader/log-reader.test.ts +0 -170
- package/src/env/debug/reader/log-reader.ts +0 -186
- package/src/env/debug/reader/span-db-reader.test.ts +0 -118
- package/src/env/debug/reader/span-db-reader.ts +0 -201
- package/src/env/debug/types.test.ts +0 -187
- package/src/env/debug/types.ts +0 -171
- package/src/env/environment-init.test.ts +0 -183
- package/src/env/environment-lifecycle.test.ts +0 -516
- package/src/env/environment-service.test.ts +0 -332
- package/src/env/environment.handle-query.test.ts +0 -96
- package/src/env/environment.test.ts +0 -232
- package/src/env/environment.ts +0 -708
- package/src/env/errors.test.ts +0 -165
- package/src/env/errors.ts +0 -157
- package/src/env/event-source/event-source-agent-handler.test.ts +0 -193
- package/src/env/event-source/event-source-agent-handler.ts +0 -111
- package/src/env/event-source/event-source-component.process-cleanup.test.ts +0 -236
- package/src/env/event-source/event-source-component.stop.test.ts +0 -346
- package/src/env/event-source/event-source-component.test.ts +0 -1207
- package/src/env/event-source/event-source-component.ts +0 -1379
- package/src/env/event-source/event-source-config-registration.test.ts +0 -242
- package/src/env/event-source/event-source-config-registration.ts +0 -37
- package/src/env/event-source/event-source-integration.test.ts +0 -320
- package/src/env/event-source/event-source-platform.test.ts +0 -630
- package/src/env/event-source/types.ts +0 -298
- package/src/env/hook/global-hook-manager.ts +0 -162
- package/src/env/hook/hook-manager.test.ts +0 -374
- package/src/env/hook/hook-manager.ts +0 -309
- package/src/env/hook/index.ts +0 -38
- package/src/env/hook/types.ts +0 -138
- package/src/env/index.ts +0 -144
- package/src/env/interface.ts +0 -203
- package/src/env/llm/hooks.test.ts +0 -293
- package/src/env/llm/hooks.ts +0 -316
- package/src/env/llm/index.ts +0 -61
- package/src/env/llm/invoke-threshold-check.test.ts +0 -88
- package/src/env/llm/invoke-timeout.test.ts +0 -54
- package/src/env/llm/invoke.test.ts +0 -71
- package/src/env/llm/invoke.ts +0 -1039
- package/src/env/llm/llm-config.test.ts +0 -523
- package/src/env/llm/llm.test.ts +0 -233
- package/src/env/llm/llm.ts +0 -568
- package/src/env/llm/provider.test.ts +0 -182
- package/src/env/llm/provider.ts +0 -108
- package/src/env/llm/transform.test.ts +0 -251
- package/src/env/llm/transform.ts +0 -286
- package/src/env/llm/types.test.ts +0 -580
- package/src/env/llm/types.ts +0 -424
- package/src/env/log-trace/decorator-otel.test.ts +0 -182
- package/src/env/log-trace/decorator.ts +0 -230
- package/src/env/log-trace/index.ts +0 -79
- package/src/env/log-trace/log-trace-component.test.ts +0 -242
- package/src/env/log-trace/log-trace-component.ts +0 -497
- package/src/env/log-trace/log-trace-config-registration.test.ts +0 -348
- package/src/env/log-trace/log-trace-config-registration.ts +0 -45
- package/src/env/log-trace/logger.test.ts +0 -149
- package/src/env/log-trace/logger.ts +0 -522
- package/src/env/log-trace/opentelemetry/cli-propagation.test.ts +0 -147
- package/src/env/log-trace/opentelemetry/cli-propagation.ts +0 -194
- package/src/env/log-trace/opentelemetry/integration.test.ts +0 -668
- package/src/env/log-trace/opentelemetry/mod.ts +0 -25
- package/src/env/log-trace/opentelemetry/propagation-env.test.ts +0 -181
- package/src/env/log-trace/opentelemetry/propagation-env.ts +0 -136
- package/src/env/log-trace/opentelemetry/propagation.test.ts +0 -259
- package/src/env/log-trace/opentelemetry/propagation.ts +0 -215
- package/src/env/log-trace/opentelemetry/tracer-provider-context.test.ts +0 -166
- package/src/env/log-trace/opentelemetry/tracer-provider.test.ts +0 -379
- package/src/env/log-trace/opentelemetry/tracer-provider.ts +0 -612
- package/src/env/log-trace/span-storage.test.ts +0 -145
- package/src/env/log-trace/span-storage.ts +0 -230
- package/src/env/log-trace/trace-context.test.ts +0 -187
- package/src/env/log-trace/trace-context.ts +0 -162
- package/src/env/log-trace/types.test.ts +0 -63
- package/src/env/log-trace/types.ts +0 -172
- package/src/env/mcp/README.md +0 -244
- package/src/env/mcp/__integration__/mcp-component.integration.test.ts +0 -373
- package/src/env/mcp/config.test.ts +0 -74
- package/src/env/mcp/config.ts +0 -116
- package/src/env/mcp/index.ts +0 -41
- package/src/env/mcp/loader.test.ts +0 -161
- package/src/env/mcp/loader.ts +0 -209
- package/src/env/mcp/mcp-component.test.ts +0 -111
- package/src/env/mcp/mcp-component.ts +0 -358
- package/src/env/mcp/mcp-config-registration.test.ts +0 -304
- package/src/env/mcp/mcp-config-registration.ts +0 -50
- package/src/env/mcp/scanner.test.ts +0 -170
- package/src/env/mcp/scanner.ts +0 -246
- package/src/env/mcp/tool/adapter.test.ts +0 -520
- package/src/env/mcp/tool/adapter.ts +0 -521
- package/src/env/mcp/tool/index.ts +0 -5
- package/src/env/mcp/types.test.ts +0 -171
- package/src/env/mcp/types.ts +0 -79
- package/src/env/memory/README.md +0 -177
- package/src/env/memory/built-in/index.ts +0 -59
- package/src/env/memory/built-in/recall-memory.ts +0 -103
- package/src/env/memory/built-in/record-memory.ts +0 -148
- package/src/env/memory/index.ts +0 -20
- package/src/env/memory/memory-component.test.ts +0 -239
- package/src/env/memory/memory-component.ts +0 -503
- package/src/env/memory/memory-config-registration.test.ts +0 -67
- package/src/env/memory/memory-config-registration.ts +0 -48
- package/src/env/memory/memory-config.ts +0 -45
- package/src/env/memory/memory-file.test.ts +0 -268
- package/src/env/memory/plugin/index.ts +0 -48
- package/src/env/memory/plugin/memory-agent.test.ts +0 -249
- package/src/env/memory/plugin/memory-agent.ts +0 -365
- package/src/env/memory/plugin/memory-manager.ts +0 -198
- package/src/env/memory/plugin/memory-plugin-agent.test.ts +0 -145
- package/src/env/memory/plugin/memory-plugin.ts +0 -210
- package/src/env/memory/plugin/plugin-simplified.test.ts +0 -51
- package/src/env/memory/plugin/recall-memory.test.ts +0 -106
- package/src/env/memory/plugin/recall-memory.ts +0 -53
- package/src/env/memory/plugin/types.ts +0 -101
- package/src/env/memory/tools/memory-agent-tools.ts +0 -228
- package/src/env/memory/types.ts +0 -85
- package/src/env/paths.ts +0 -118
- package/src/env/prompt/index.ts +0 -18
- package/src/env/prompt/memory-prompts.test.ts +0 -91
- package/src/env/prompt/prompt-component.test.ts +0 -491
- package/src/env/prompt/prompt-component.ts +0 -619
- package/src/env/prompt/prompt-config-registration.test.ts +0 -213
- package/src/env/prompt/prompt-config-registration.ts +0 -39
- package/src/env/prompt/prompts-index.ts +0 -504
- package/src/env/prompt/renderer.ts +0 -67
- package/src/env/prompt/types.ts +0 -136
- package/src/env/session/hooks.ts +0 -18
- package/src/env/session/index.ts +0 -37
- package/src/env/session/search-query-parser.test.ts +0 -425
- package/src/env/session/search-query-parser.ts +0 -171
- package/src/env/session/session-checkpoint.test.ts +0 -523
- package/src/env/session/session-component.extract-recent-messages.test.ts +0 -209
- package/src/env/session/session-component.test.ts +0 -132
- package/src/env/session/session-component.ts +0 -1249
- package/src/env/session/session-config-registration.test.ts +0 -138
- package/src/env/session/session-config-registration.ts +0 -52
- package/src/env/session/session-message-converter.test.ts +0 -763
- package/src/env/session/session-message-converter.ts +0 -415
- package/src/env/session/session-message-e2e.test.ts +0 -448
- package/src/env/session/session-search.test.ts +0 -391
- package/src/env/session/session-store.test.ts +0 -362
- package/src/env/session/session-store.ts +0 -141
- package/src/env/session/storage/index.ts +0 -6
- package/src/env/session/storage/memory.ts +0 -502
- package/src/env/session/storage/sqlite.ts +0 -794
- package/src/env/session/types.ts +0 -742
- package/src/env/skill/config.ts +0 -39
- package/src/env/skill/index.ts +0 -6
- package/src/env/skill/parser.test.ts +0 -116
- package/src/env/skill/parser.ts +0 -77
- package/src/env/skill/scanner.test.ts +0 -211
- package/src/env/skill/scanner.ts +0 -119
- package/src/env/skill/skill-component.test.ts +0 -234
- package/src/env/skill/skill-component.ts +0 -352
- package/src/env/skill/skill-config-registration.test.ts +0 -60
- package/src/env/skill/skill-config-registration.ts +0 -43
- package/src/env/skill/tool/index.ts +0 -1
- package/src/env/skill/tool/skill-tool.test.ts +0 -100
- package/src/env/skill/tool/skill-tool.ts +0 -72
- package/src/env/skill/types.ts +0 -64
- package/src/env/task/delegate/delegate-tool.test.ts +0 -498
- package/src/env/task/delegate/delegate-tool.ts +0 -1014
- package/src/env/task/delegate/index.ts +0 -18
- package/src/env/task/delegate/stop-tool.test.ts +0 -140
- package/src/env/task/delegate/stop-tool.ts +0 -119
- package/src/env/task/delegate/task-events.test.ts +0 -178
- package/src/env/task/delegate/task-events.ts +0 -143
- package/src/env/task/hooks/contexts.test.ts +0 -92
- package/src/env/task/hooks/contexts.ts +0 -192
- package/src/env/task/hooks/index.ts +0 -23
- package/src/env/task/hooks/task-hook-points.test.ts +0 -32
- package/src/env/task/hooks/task-hook-points.ts +0 -54
- package/src/env/task/index.ts +0 -7
- package/src/env/task/plugins/index.ts +0 -13
- package/src/env/task/plugins/task-plugin.test.ts +0 -74
- package/src/env/task/plugins/task-plugin.ts +0 -89
- package/src/env/task/plugins/task-tag-plugin.test.ts +0 -377
- package/src/env/task/plugins/task-tag-plugin.ts +0 -319
- package/src/env/task/plugins/task-workflow-extractor.integration.test.ts +0 -226
- package/src/env/task/plugins/workflow-extractor-agent.test.ts +0 -107
- package/src/env/task/plugins/workflow-extractor-agent.ts +0 -225
- package/src/env/task/storage/index.ts +0 -6
- package/src/env/task/storage/sqlite-task-store.test.ts +0 -283
- package/src/env/task/storage/sqlite-task-store.ts +0 -903
- package/src/env/task/storage/task-search.test.ts +0 -291
- package/src/env/task/tag-service.test.ts +0 -198
- package/src/env/task/tag-service.ts +0 -264
- package/src/env/task/task-component.test.ts +0 -193
- package/src/env/task/task-component.ts +0 -658
- package/src/env/task/task-config-registration.test.ts +0 -57
- package/src/env/task/task-config-registration.ts +0 -37
- package/src/env/task/task-types.test.ts +0 -137
- package/src/env/task/tools/complete-tool.ts +0 -44
- package/src/env/task/tools/create-tool.ts +0 -49
- package/src/env/task/tools/delete-tool.ts +0 -43
- package/src/env/task/tools/get-tool.ts +0 -59
- package/src/env/task/tools/index.ts +0 -10
- package/src/env/task/tools/list-tool.ts +0 -40
- package/src/env/task/tools/operation/create-tool.ts +0 -48
- package/src/env/task/tools/operation/delete-tool.ts +0 -43
- package/src/env/task/tools/operation/get-tool.ts +0 -43
- package/src/env/task/tools/operation/index.ts +0 -9
- package/src/env/task/tools/operation/list-tool.ts +0 -40
- package/src/env/task/tools/operation/operation-tools.test.ts +0 -274
- package/src/env/task/tools/operation/operation-types.ts +0 -75
- package/src/env/task/tools/operation/update-tool.ts +0 -47
- package/src/env/task/tools/task-tools.test.ts +0 -203
- package/src/env/task/tools/task-types.test.ts +0 -75
- package/src/env/task/tools/task-types.ts +0 -68
- package/src/env/task/tools/update-tool.ts +0 -70
- package/src/env/task/types.ts +0 -160
- package/src/env/tool/built-in/bash.ts +0 -201
- package/src/env/tool/built-in/echo.ts +0 -29
- package/src/env/tool/built-in/edit-file.test.ts +0 -136
- package/src/env/tool/built-in/edit-file.ts +0 -92
- package/src/env/tool/built-in/glob.test.ts +0 -94
- package/src/env/tool/built-in/glob.ts +0 -65
- package/src/env/tool/built-in/grep.test.ts +0 -122
- package/src/env/tool/built-in/grep.ts +0 -108
- package/src/env/tool/built-in/index.ts +0 -44
- package/src/env/tool/built-in/read-file.test.ts +0 -84
- package/src/env/tool/built-in/read-file.ts +0 -75
- package/src/env/tool/built-in/write-file.test.ts +0 -119
- package/src/env/tool/built-in/write-file.ts +0 -68
- package/src/env/tool/index.ts +0 -24
- package/src/env/tool/registry.test.ts +0 -257
- package/src/env/tool/registry.ts +0 -167
- package/src/env/tool/tool-component.test.ts +0 -559
- package/src/env/tool/tool-component.ts +0 -563
- package/src/env/tool/tool-config-registration.test.ts +0 -249
- package/src/env/tool/tool-config-registration.ts +0 -46
- package/src/env/tool/types.ts +0 -267
- package/src/env/tool/validator.test.ts +0 -143
- package/src/env/tool/validator.ts +0 -44
- package/src/env/types.ts +0 -180
- package/src/env/workflow/ask-user-tool-registration.test.ts +0 -216
- package/src/env/workflow/complex-workflow.integration.test.ts +0 -1900
- package/src/env/workflow/decorators/decorator-node.ts +0 -229
- package/src/env/workflow/decorators/decorator.test.ts +0 -196
- package/src/env/workflow/decorators/edge.ts +0 -82
- package/src/env/workflow/decorators/index.ts +0 -31
- package/src/env/workflow/decorators/node-as.ts +0 -98
- package/src/env/workflow/decorators/workflow.ts +0 -54
- package/src/env/workflow/engine/dag-manager.test.ts +0 -570
- package/src/env/workflow/engine/dag-manager.ts +0 -594
- package/src/env/workflow/engine/engine.ts +0 -1422
- package/src/env/workflow/engine/event-bus.test.ts +0 -359
- package/src/env/workflow/engine/event-bus.ts +0 -156
- package/src/env/workflow/engine/executor-agent-session.test.ts +0 -84
- package/src/env/workflow/engine/executor.test.ts +0 -619
- package/src/env/workflow/engine/executor.ts +0 -593
- package/src/env/workflow/engine/index.ts +0 -24
- package/src/env/workflow/engine/node-registry.test.ts +0 -560
- package/src/env/workflow/engine/node-registry.ts +0 -289
- package/src/env/workflow/engine/resume-removed.test.ts +0 -22
- package/src/env/workflow/engine/scheduler.test.ts +0 -715
- package/src/env/workflow/engine/scheduler.ts +0 -318
- package/src/env/workflow/engine/workflow-engine.test.ts +0 -815
- package/src/env/workflow/extractor/workflow-converter.ts +0 -306
- package/src/env/workflow/fixtures.ts +0 -380
- package/src/env/workflow/index.ts +0 -38
- package/src/env/workflow/integration/run-resume-unified.test.ts +0 -186
- package/src/env/workflow/integration/service-integration.test.ts +0 -267
- package/src/env/workflow/metadata/keys.ts +0 -12
- package/src/env/workflow/nodes/agent-component-adapter.test.ts +0 -318
- package/src/env/workflow/nodes/agent-component-adapter.ts +0 -448
- package/src/env/workflow/nodes/agent-node.test.ts +0 -371
- package/src/env/workflow/nodes/agent-node.ts +0 -598
- package/src/env/workflow/nodes/ask-user-node.ts +0 -113
- package/src/env/workflow/nodes/condition-node.ts +0 -200
- package/src/env/workflow/nodes/index.ts +0 -9
- package/src/env/workflow/nodes/merge-node.ts +0 -141
- package/src/env/workflow/nodes/skill-node.test.ts +0 -253
- package/src/env/workflow/nodes/skill-node.ts +0 -393
- package/src/env/workflow/nodes/tool-node.test.ts +0 -251
- package/src/env/workflow/nodes/tool-node.ts +0 -493
- package/src/env/workflow/nodes/workflow-llm-history.test.ts +0 -455
- package/src/env/workflow/nodes/workflow-node.test.ts +0 -315
- package/src/env/workflow/nodes/workflow-node.ts +0 -311
- package/src/env/workflow/service/index.ts +0 -27
- package/src/env/workflow/service/registry.test.ts +0 -133
- package/src/env/workflow/service/registry.ts +0 -71
- package/src/env/workflow/service/workflow-service.test.ts +0 -310
- package/src/env/workflow/service/workflow-service.ts +0 -393
- package/src/env/workflow/storage/index.ts +0 -28
- package/src/env/workflow/storage/mock-repositories.ts +0 -385
- package/src/env/workflow/storage/sqlite.test.ts +0 -179
- package/src/env/workflow/storage/sqlite.ts +0 -163
- package/src/env/workflow/storage/workflow-repo.test.ts +0 -780
- package/src/env/workflow/storage/workflow-repo.ts +0 -342
- package/src/env/workflow/tools/ask-user-tool.ts +0 -82
- package/src/env/workflow/tools/index.ts +0 -26
- package/src/env/workflow/tools/run-workflow.test.ts +0 -352
- package/src/env/workflow/tools/run-workflow.ts +0 -214
- package/src/env/workflow/types/context.ts +0 -18
- package/src/env/workflow/types/decorators-types.ts +0 -198
- package/src/env/workflow/types/event.test.ts +0 -515
- package/src/env/workflow/types/event.ts +0 -193
- package/src/env/workflow/types/index.ts +0 -49
- package/src/env/workflow/types/run.test.ts +0 -437
- package/src/env/workflow/types/run.ts +0 -173
- package/src/env/workflow/types/workflow-hil.ts +0 -114
- package/src/env/workflow/types/workflow-message.test.ts +0 -138
- package/src/env/workflow/types/workflow-message.ts +0 -196
- package/src/env/workflow/types/workflow-session.test.ts +0 -95
- package/src/env/workflow/types/workflow-session.ts +0 -59
- package/src/env/workflow/types/workflow.test.ts +0 -495
- package/src/env/workflow/types/workflow.ts +0 -195
- package/src/env/workflow/types_compat.ts +0 -51
- package/src/env/workflow/utils/create-workflow.ts +0 -47
- package/src/env/workflow/utils/execution-state.ts +0 -245
- package/src/env/workflow/utils/index.ts +0 -18
- package/src/env/workflow/utils/node-registry-helper.ts +0 -58
- package/src/env/workflow/utils/recovery-validator.test.ts +0 -460
- package/src/env/workflow/utils/recovery-validator.ts +0 -377
- package/src/env/workflow/utils/session-parser.test.ts +0 -111
- package/src/env/workflow/utils/session-parser.ts +0 -94
- package/src/env/workflow/utils/session-recovery.test.ts +0 -334
- package/src/env/workflow/utils/session-recovery.ts +0 -188
- package/src/env/workflow/utils/template-resolver.test.ts +0 -258
- package/src/env/workflow/utils/template-resolver.ts +0 -436
- package/src/env/workflow/utils/validation-rules.ts +0 -149
- package/src/env/workflow/workflow-component.ts +0 -544
- package/src/index.ts +0 -422
- package/src/utils/id.ts +0 -21
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// ==================== 基础事件 ====================
|
|
4
|
-
|
|
5
|
-
export const BaseEventSchema = z.object({
|
|
6
|
-
type: z.string(),
|
|
7
|
-
run_id: z.string(),
|
|
8
|
-
timestamp: z.number(),
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export type BaseEvent = z.infer<typeof BaseEventSchema>;
|
|
12
|
-
|
|
13
|
-
// ==================== Workflow 生命周期事件 ====================
|
|
14
|
-
|
|
15
|
-
export const WorkflowStartedEventSchema = BaseEventSchema.extend({
|
|
16
|
-
type: z.literal('workflow.started'),
|
|
17
|
-
workflow_name: z.string(),
|
|
18
|
-
input: z.record(z.string(), z.unknown()).optional(),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const WorkflowPausedEventSchema = BaseEventSchema.extend({
|
|
22
|
-
type: z.literal('workflow.paused'),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const WorkflowResumedEventSchema = BaseEventSchema.extend({
|
|
26
|
-
type: z.literal('workflow.resumed'),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const WorkflowStoppedEventSchema = BaseEventSchema.extend({
|
|
30
|
-
type: z.literal('workflow.stopped'),
|
|
31
|
-
reason: z.string(),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export const WorkflowCompletedEventSchema = BaseEventSchema.extend({
|
|
35
|
-
type: z.literal('workflow.completed'),
|
|
36
|
-
result: z.record(z.string(), z.unknown()).optional(),
|
|
37
|
-
duration_ms: z.number(),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const WorkflowFailedEventSchema = BaseEventSchema.extend({
|
|
41
|
-
type: z.literal('workflow.failed'),
|
|
42
|
-
error: z.object({
|
|
43
|
-
message: z.string(),
|
|
44
|
-
stack: z.string().optional(),
|
|
45
|
-
}),
|
|
46
|
-
failed_at: z.string(),
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const WorkflowOutputEventSchema = BaseEventSchema.extend({
|
|
50
|
-
type: z.literal('workflow.output'),
|
|
51
|
-
output: z.record(z.string(), z.unknown()),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// ==================== Node 生命周期事件 ====================
|
|
55
|
-
|
|
56
|
-
export const NodeScheduledEventSchema = BaseEventSchema.extend({
|
|
57
|
-
type: z.literal('node.scheduled'),
|
|
58
|
-
node_id: z.string(),
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export const NodeStartedEventSchema = BaseEventSchema.extend({
|
|
62
|
-
type: z.literal('node.started'),
|
|
63
|
-
node_id: z.string(),
|
|
64
|
-
input: z.any(),
|
|
65
|
-
agentSessionId: z.string().optional(),
|
|
66
|
-
userResponse: z.string().optional(),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export const NodeProgressEventSchema = BaseEventSchema.extend({
|
|
70
|
-
type: z.literal('node.progress'),
|
|
71
|
-
node_id: z.string(),
|
|
72
|
-
progress: z.number(),
|
|
73
|
-
message: z.string().optional(),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
export const NodeCompletedEventSchema = BaseEventSchema.extend({
|
|
77
|
-
type: z.literal('node.completed'),
|
|
78
|
-
node_id: z.string(),
|
|
79
|
-
output: z.any(),
|
|
80
|
-
duration_ms: z.number(),
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
export const NodeFailedEventSchema = BaseEventSchema.extend({
|
|
84
|
-
type: z.literal('node.failed'),
|
|
85
|
-
node_id: z.string(),
|
|
86
|
-
error: z.object({
|
|
87
|
-
message: z.string(),
|
|
88
|
-
stack: z.string().optional(),
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export const NodeSkippedEventSchema = BaseEventSchema.extend({
|
|
93
|
-
type: z.literal('node.skipped'),
|
|
94
|
-
node_id: z.string(),
|
|
95
|
-
reason: z.string(),
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// ==================== 节点间数据流事件 ====================
|
|
99
|
-
|
|
100
|
-
export const NodeDataEventSchema = BaseEventSchema.extend({
|
|
101
|
-
type: z.literal('node.data'),
|
|
102
|
-
from_node: z.string(),
|
|
103
|
-
to_node: z.string(),
|
|
104
|
-
data: z.any(),
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// ==================== 动态节点事件 ====================
|
|
108
|
-
|
|
109
|
-
export const NodeAddedEventSchema = BaseEventSchema.extend({
|
|
110
|
-
type: z.literal('node.added'),
|
|
111
|
-
node_id: z.string(),
|
|
112
|
-
node: z.any(),
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
export const NodeRemovedEventSchema = BaseEventSchema.extend({
|
|
116
|
-
type: z.literal('node.removed'),
|
|
117
|
-
node_id: z.string(),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// ==================== 控制事件 ====================
|
|
121
|
-
|
|
122
|
-
export const ControlPauseEventSchema = BaseEventSchema.extend({
|
|
123
|
-
type: z.literal('control.pause'),
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
export const ControlResumeEventSchema = BaseEventSchema.extend({
|
|
127
|
-
type: z.literal('control.resume'),
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
export const ControlStopEventSchema = BaseEventSchema.extend({
|
|
131
|
-
type: z.literal('control.stop'),
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// ==================== 人工交互事件 (Schemas only) ====================
|
|
135
|
-
|
|
136
|
-
export const NodeInterruptEventSchema = BaseEventSchema.extend({
|
|
137
|
-
type: z.literal('node.interrupt'),
|
|
138
|
-
node_id: z.string(),
|
|
139
|
-
node_type: z.string(),
|
|
140
|
-
query: z.string(),
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
export const WorkflowAskUserEventSchema = BaseEventSchema.extend({
|
|
144
|
-
type: z.literal('workflow.ask-user'),
|
|
145
|
-
session_id: z.string(),
|
|
146
|
-
node_id: z.string(),
|
|
147
|
-
node_type: z.string(),
|
|
148
|
-
query: z.string(),
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// ==================== 联合事件类型 ====================
|
|
152
|
-
|
|
153
|
-
export const WorkflowEventSchema = z.union([
|
|
154
|
-
WorkflowStartedEventSchema,
|
|
155
|
-
WorkflowPausedEventSchema,
|
|
156
|
-
WorkflowResumedEventSchema,
|
|
157
|
-
WorkflowStoppedEventSchema,
|
|
158
|
-
WorkflowCompletedEventSchema,
|
|
159
|
-
WorkflowFailedEventSchema,
|
|
160
|
-
WorkflowOutputEventSchema,
|
|
161
|
-
NodeScheduledEventSchema,
|
|
162
|
-
NodeStartedEventSchema,
|
|
163
|
-
NodeProgressEventSchema,
|
|
164
|
-
NodeCompletedEventSchema,
|
|
165
|
-
NodeFailedEventSchema,
|
|
166
|
-
NodeSkippedEventSchema,
|
|
167
|
-
NodeDataEventSchema,
|
|
168
|
-
NodeAddedEventSchema,
|
|
169
|
-
NodeRemovedEventSchema,
|
|
170
|
-
ControlPauseEventSchema,
|
|
171
|
-
ControlResumeEventSchema,
|
|
172
|
-
ControlStopEventSchema,
|
|
173
|
-
NodeInterruptEventSchema,
|
|
174
|
-
WorkflowAskUserEventSchema,
|
|
175
|
-
]);
|
|
176
|
-
|
|
177
|
-
export type WorkflowEvent = z.infer<typeof WorkflowEventSchema>;
|
|
178
|
-
|
|
179
|
-
// ==================== Event 工厂函数 ====================
|
|
180
|
-
|
|
181
|
-
export function createWorkflowEvent<T extends WorkflowEvent['type']>(
|
|
182
|
-
type: T,
|
|
183
|
-
runId: string,
|
|
184
|
-
data: Omit<Extract<WorkflowEvent, { type: T }>, 'type' | 'run_id' | 'timestamp'>
|
|
185
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
186
|
-
): any {
|
|
187
|
-
return {
|
|
188
|
-
type,
|
|
189
|
-
run_id: runId,
|
|
190
|
-
timestamp: Date.now(),
|
|
191
|
-
...data,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Re-export all types
|
|
2
|
-
export * from './workflow';
|
|
3
|
-
export * from './workflow-message';
|
|
4
|
-
export * from './workflow-session';
|
|
5
|
-
export * from './context';
|
|
6
|
-
export * from './workflow-hil';
|
|
7
|
-
export * from './event';
|
|
8
|
-
export * from './run';
|
|
9
|
-
|
|
10
|
-
// Export AgentSessionInfo
|
|
11
|
-
export type { AgentSessionInfo } from './workflow-message';
|
|
12
|
-
|
|
13
|
-
// Export AgentSessionRef from workflow-session (avoid duplicate with workflow-message)
|
|
14
|
-
export type { AgentSessionRef } from './workflow-session';
|
|
15
|
-
|
|
16
|
-
// Re-export from run.ts for convenience (includes NodeExecutionContext, NodeExecutionResult)
|
|
17
|
-
export type {
|
|
18
|
-
RunStatus,
|
|
19
|
-
NodeStatus,
|
|
20
|
-
WorkflowRun,
|
|
21
|
-
NodeRun,
|
|
22
|
-
RunOptions,
|
|
23
|
-
RunResult,
|
|
24
|
-
NodeExecutionContext,
|
|
25
|
-
NodeExecutionResult,
|
|
26
|
-
} from './run';
|
|
27
|
-
|
|
28
|
-
export { createNodeExecutionContext } from './run';
|
|
29
|
-
|
|
30
|
-
// Re-export from workflow.ts for convenience (includes Node, RetryConfig, TemplateResolver)
|
|
31
|
-
export type {
|
|
32
|
-
WorkflowDefinition,
|
|
33
|
-
WorkflowDefinitionExtended,
|
|
34
|
-
Workflow,
|
|
35
|
-
WorkflowConfig,
|
|
36
|
-
WorkflowMetadata,
|
|
37
|
-
RetryConfig,
|
|
38
|
-
Node,
|
|
39
|
-
NodeDefinition,
|
|
40
|
-
NodeDefinitionSchema,
|
|
41
|
-
DependsOn,
|
|
42
|
-
DependsOnSchema,
|
|
43
|
-
OutputDefinition,
|
|
44
|
-
OutputDefinitionSchema,
|
|
45
|
-
} from './workflow';
|
|
46
|
-
|
|
47
|
-
// Re-export Node and TemplateResolver from their actual locations
|
|
48
|
-
// Note: Node type should be imported from '../nodes' directly
|
|
49
|
-
export type { TemplateResolver } from '../utils/template-resolver';
|
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
describe('Run Types', () => {
|
|
5
|
-
describe('RunStatus', () => {
|
|
6
|
-
it('should accept all valid run statuses', () => {
|
|
7
|
-
const validStatuses = ['idle', 'running', 'paused', 'stopped', 'completed', 'failed'];
|
|
8
|
-
const schema = z.enum(['idle', 'running', 'paused', 'stopped', 'completed', 'failed']);
|
|
9
|
-
|
|
10
|
-
for (const status of validStatuses) {
|
|
11
|
-
expect(() => schema.parse(status)).not.toThrow();
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should reject invalid run status', () => {
|
|
16
|
-
const schema = z.enum(['idle', 'running', 'paused', 'stopped', 'completed', 'failed']);
|
|
17
|
-
expect(() => schema.parse('invalid')).toThrow();
|
|
18
|
-
expect(() => schema.parse('pending')).toThrow();
|
|
19
|
-
expect(() => schema.parse('')).toThrow();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('NodeStatus', () => {
|
|
24
|
-
it('should accept all valid node statuses', () => {
|
|
25
|
-
const validStatuses = ['pending', 'scheduled', 'started', 'running', 'completed', 'failed', 'skipped'];
|
|
26
|
-
const schema = z.enum(['pending', 'scheduled', 'started', 'running', 'completed', 'failed', 'skipped']);
|
|
27
|
-
|
|
28
|
-
for (const status of validStatuses) {
|
|
29
|
-
expect(() => schema.parse(status)).not.toThrow();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should reject invalid node status', () => {
|
|
34
|
-
const schema = z.enum(['pending', 'scheduled', 'started', 'running', 'completed', 'failed', 'skipped']);
|
|
35
|
-
expect(() => schema.parse('invalid')).toThrow();
|
|
36
|
-
expect(() => schema.parse('idle')).toThrow();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('WorkflowRun', () => {
|
|
41
|
-
it('should accept minimal workflow run', () => {
|
|
42
|
-
const run = {
|
|
43
|
-
id: 'run_123',
|
|
44
|
-
workflowId: 'wf_456',
|
|
45
|
-
workflowName: 'test-workflow',
|
|
46
|
-
status: 'idle',
|
|
47
|
-
debugMode: false,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
expect(run.id).toBe('run_123');
|
|
51
|
-
expect(run.workflowId).toBe('wf_456');
|
|
52
|
-
expect(run.status).toBe('idle');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should accept full workflow run', () => {
|
|
56
|
-
const run = {
|
|
57
|
-
id: 'run_123',
|
|
58
|
-
workflowId: 'wf_456',
|
|
59
|
-
workflowName: 'test-workflow',
|
|
60
|
-
status: 'completed',
|
|
61
|
-
input: { param1: 'value1' },
|
|
62
|
-
output: { result: 'success' },
|
|
63
|
-
error: undefined,
|
|
64
|
-
startedAt: new Date('2024-01-01T10:00:00Z'),
|
|
65
|
-
completedAt: new Date('2024-01-01T10:05:00Z'),
|
|
66
|
-
durationMs: 300000,
|
|
67
|
-
debugMode: true,
|
|
68
|
-
parentRunId: 'run_000',
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
expect(run.id).toBe('run_123');
|
|
72
|
-
expect(run.status).toBe('completed');
|
|
73
|
-
expect(run.input).toEqual({ param1: 'value1' });
|
|
74
|
-
expect(run.output).toEqual({ result: 'success' });
|
|
75
|
-
expect(run.startedAt).toBeInstanceOf(Date);
|
|
76
|
-
expect(run.durationMs).toBe(300000);
|
|
77
|
-
expect(run.debugMode).toBe(true);
|
|
78
|
-
expect(run.parentRunId).toBe('run_000');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should accept running state workflow run', () => {
|
|
82
|
-
const run = {
|
|
83
|
-
id: 'run_123',
|
|
84
|
-
workflowId: 'wf_456',
|
|
85
|
-
workflowName: 'test-workflow',
|
|
86
|
-
status: 'running',
|
|
87
|
-
startedAt: new Date(),
|
|
88
|
-
debugMode: false,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
expect(run.status).toBe('running');
|
|
92
|
-
expect(run.startedAt).toBeInstanceOf(Date);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should accept paused state workflow run', () => {
|
|
96
|
-
const run = {
|
|
97
|
-
id: 'run_123',
|
|
98
|
-
workflowId: 'wf_456',
|
|
99
|
-
workflowName: 'test-workflow',
|
|
100
|
-
status: 'paused',
|
|
101
|
-
startedAt: new Date(),
|
|
102
|
-
pausedAt: new Date(),
|
|
103
|
-
debugMode: false,
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
expect(run.status).toBe('paused');
|
|
107
|
-
expect(run.pausedAt).toBeInstanceOf(Date);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should accept failed state workflow run', () => {
|
|
111
|
-
const run = {
|
|
112
|
-
id: 'run_123',
|
|
113
|
-
workflowId: 'wf_456',
|
|
114
|
-
workflowName: 'test-workflow',
|
|
115
|
-
status: 'failed',
|
|
116
|
-
error: 'Node execution failed: tool not found',
|
|
117
|
-
startedAt: new Date(),
|
|
118
|
-
completedAt: new Date(),
|
|
119
|
-
durationMs: 5000,
|
|
120
|
-
debugMode: false,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
expect(run.status).toBe('failed');
|
|
124
|
-
expect(run.error).toBe('Node execution failed: tool not found');
|
|
125
|
-
expect(run.durationMs).toBe(5000);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe('NodeRun', () => {
|
|
130
|
-
it('should accept minimal node run', () => {
|
|
131
|
-
const nodeRun = {
|
|
132
|
-
id: 'nr_123',
|
|
133
|
-
runId: 'run_456',
|
|
134
|
-
nodeId: 'node1',
|
|
135
|
-
nodeType: 'tool',
|
|
136
|
-
status: 'pending',
|
|
137
|
-
retryCount: 0,
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
expect(nodeRun.id).toBe('nr_123');
|
|
141
|
-
expect(nodeRun.nodeId).toBe('node1');
|
|
142
|
-
expect(nodeRun.status).toBe('pending');
|
|
143
|
-
expect(nodeRun.retryCount).toBe(0);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should accept full node run', () => {
|
|
147
|
-
const nodeRun = {
|
|
148
|
-
id: 'nr_123',
|
|
149
|
-
runId: 'run_456',
|
|
150
|
-
nodeId: 'node1',
|
|
151
|
-
nodeType: 'tool',
|
|
152
|
-
status: 'completed',
|
|
153
|
-
input: { operation: 'add', a: 1, b: 2 },
|
|
154
|
-
output: { result: 3 },
|
|
155
|
-
error: undefined,
|
|
156
|
-
startedAt: new Date('2024-01-01T10:00:00Z'),
|
|
157
|
-
completedAt: new Date('2024-01-01T10:00:01Z'),
|
|
158
|
-
durationMs: 1000,
|
|
159
|
-
retryCount: 0,
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
expect(nodeRun.status).toBe('completed');
|
|
163
|
-
expect(nodeRun.input).toEqual({ operation: 'add', a: 1, b: 2 });
|
|
164
|
-
expect(nodeRun.output).toEqual({ result: 3 });
|
|
165
|
-
expect(nodeRun.durationMs).toBe(1000);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should accept failed node run with error', () => {
|
|
169
|
-
const nodeRun = {
|
|
170
|
-
id: 'nr_123',
|
|
171
|
-
runId: 'run_456',
|
|
172
|
-
nodeId: 'node1',
|
|
173
|
-
nodeType: 'tool',
|
|
174
|
-
status: 'failed',
|
|
175
|
-
input: { tool: 'nonexistent' },
|
|
176
|
-
error: 'Tool not found: nonexistent',
|
|
177
|
-
startedAt: new Date(),
|
|
178
|
-
completedAt: new Date(),
|
|
179
|
-
durationMs: 100,
|
|
180
|
-
retryCount: 3,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
expect(nodeRun.status).toBe('failed');
|
|
184
|
-
expect(nodeRun.error).toBe('Tool not found: nonexistent');
|
|
185
|
-
expect(nodeRun.retryCount).toBe(3);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('should accept running node run', () => {
|
|
189
|
-
const nodeRun = {
|
|
190
|
-
id: 'nr_123',
|
|
191
|
-
runId: 'run_456',
|
|
192
|
-
nodeId: 'node1',
|
|
193
|
-
nodeType: 'agent',
|
|
194
|
-
status: 'running',
|
|
195
|
-
input: { prompt: 'Do something' },
|
|
196
|
-
startedAt: new Date(),
|
|
197
|
-
retryCount: 0,
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
expect(nodeRun.status).toBe('running');
|
|
201
|
-
expect(nodeRun.startedAt).toBeInstanceOf(Date);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('should accept skipped node run', () => {
|
|
205
|
-
const nodeRun = {
|
|
206
|
-
id: 'nr_123',
|
|
207
|
-
runId: 'run_456',
|
|
208
|
-
nodeId: 'node1',
|
|
209
|
-
nodeType: 'tool',
|
|
210
|
-
status: 'skipped',
|
|
211
|
-
reason: 'Previous dependency failed',
|
|
212
|
-
retryCount: 0,
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
expect(nodeRun.status).toBe('skipped');
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('should accept scheduled node run', () => {
|
|
219
|
-
const nodeRun = {
|
|
220
|
-
id: 'nr_123',
|
|
221
|
-
runId: 'run_456',
|
|
222
|
-
nodeId: 'node1',
|
|
223
|
-
nodeType: 'tool',
|
|
224
|
-
status: 'scheduled',
|
|
225
|
-
retryCount: 0,
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
expect(nodeRun.status).toBe('scheduled');
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
describe('RunOptions', () => {
|
|
233
|
-
it('should accept minimal run options', () => {
|
|
234
|
-
const options = {};
|
|
235
|
-
expect(options).toEqual({});
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('should accept full run options', () => {
|
|
239
|
-
const options = {
|
|
240
|
-
input: { key: 'value' },
|
|
241
|
-
sync: true,
|
|
242
|
-
debug: true,
|
|
243
|
-
parallelLimit: 5,
|
|
244
|
-
timeout: 300000,
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
expect(options.input).toEqual({ key: 'value' });
|
|
248
|
-
expect(options.sync).toBe(true);
|
|
249
|
-
expect(options.debug).toBe(true);
|
|
250
|
-
expect(options.parallelLimit).toBe(5);
|
|
251
|
-
expect(options.timeout).toBe(300000);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should accept null parallelLimit for unlimited', () => {
|
|
255
|
-
const options = {
|
|
256
|
-
parallelLimit: null,
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
expect(options.parallelLimit).toBeNull();
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('should accept null timeout for no timeout', () => {
|
|
263
|
-
const options = {
|
|
264
|
-
timeout: null,
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
expect(options.timeout).toBeNull();
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('should accept undefined input', () => {
|
|
271
|
-
const options = {
|
|
272
|
-
input: undefined,
|
|
273
|
-
sync: false,
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
expect(options.input).toBeUndefined();
|
|
277
|
-
expect(options.sync).toBe(false);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
describe('RunResult', () => {
|
|
282
|
-
it('should accept successful run result', () => {
|
|
283
|
-
const result = {
|
|
284
|
-
runId: 'run_123',
|
|
285
|
-
status: 'completed' as const,
|
|
286
|
-
output: { result: 'success' },
|
|
287
|
-
durationMs: 5000,
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
expect(result.runId).toBe('run_123');
|
|
291
|
-
expect(result.status).toBe('completed');
|
|
292
|
-
expect(result.output).toEqual({ result: 'success' });
|
|
293
|
-
expect(result.durationMs).toBe(5000);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('should accept failed run result', () => {
|
|
297
|
-
const result = {
|
|
298
|
-
runId: 'run_123',
|
|
299
|
-
status: 'failed' as const,
|
|
300
|
-
error: 'Workflow execution failed',
|
|
301
|
-
durationMs: 5000,
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
expect(result.status).toBe('failed');
|
|
305
|
-
expect(result.error).toBe('Workflow execution failed');
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('should accept running run result', () => {
|
|
309
|
-
const result = {
|
|
310
|
-
runId: 'run_123',
|
|
311
|
-
status: 'running' as const,
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
expect(result.status).toBe('running');
|
|
315
|
-
expect(result.output).toBeUndefined();
|
|
316
|
-
expect(result.error).toBeUndefined();
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
describe('NodeExecutionContext', () => {
|
|
321
|
-
it('should accept valid execution context', () => {
|
|
322
|
-
const context = {
|
|
323
|
-
runId: 'run_123',
|
|
324
|
-
workflowName: 'test-workflow',
|
|
325
|
-
nodeId: 'node1',
|
|
326
|
-
input: { param: 'value' },
|
|
327
|
-
previousOutputs: new Map([['prev_node', { result: 42 }]]),
|
|
328
|
-
config: { tool: 'calculator' },
|
|
329
|
-
debug: false,
|
|
330
|
-
eventBus: {
|
|
331
|
-
publish: () => {},
|
|
332
|
-
},
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
expect(context.runId).toBe('run_123');
|
|
336
|
-
expect(context.nodeId).toBe('node1');
|
|
337
|
-
expect(context.previousOutputs).toBeInstanceOf(Map);
|
|
338
|
-
expect(context.config).toEqual({ tool: 'calculator' });
|
|
339
|
-
expect(context.debug).toBe(false);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('should accept empty previousOutputs', () => {
|
|
343
|
-
const context = {
|
|
344
|
-
runId: 'run_123',
|
|
345
|
-
workflowName: 'test-workflow',
|
|
346
|
-
nodeId: 'node1',
|
|
347
|
-
input: {},
|
|
348
|
-
previousOutputs: new Map(),
|
|
349
|
-
config: {},
|
|
350
|
-
debug: false,
|
|
351
|
-
eventBus: {},
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
expect(context.previousOutputs.size).toBe(0);
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('should accept context with multiple previous outputs', () => {
|
|
358
|
-
const context = {
|
|
359
|
-
runId: 'run_123',
|
|
360
|
-
workflowName: 'test-workflow',
|
|
361
|
-
nodeId: 'node3',
|
|
362
|
-
input: {},
|
|
363
|
-
previousOutputs: new Map([
|
|
364
|
-
['node1', { result: 'step1' }],
|
|
365
|
-
['node2', { result: 'step2' }],
|
|
366
|
-
]),
|
|
367
|
-
config: {},
|
|
368
|
-
debug: false,
|
|
369
|
-
eventBus: {},
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
expect(context.previousOutputs.size).toBe(2);
|
|
373
|
-
expect(context.previousOutputs.get('node1')).toEqual({ result: 'step1' });
|
|
374
|
-
expect(context.previousOutputs.get('node2')).toEqual({ result: 'step2' });
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it('should accept debug mode context', () => {
|
|
378
|
-
const context = {
|
|
379
|
-
runId: 'run_123',
|
|
380
|
-
workflowName: 'test-workflow',
|
|
381
|
-
nodeId: 'node1',
|
|
382
|
-
input: {},
|
|
383
|
-
previousOutputs: new Map(),
|
|
384
|
-
config: {},
|
|
385
|
-
debug: true,
|
|
386
|
-
eventBus: {},
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
expect(context.debug).toBe(true);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe('NodeExecutionResult', () => {
|
|
394
|
-
it('should accept successful execution result', () => {
|
|
395
|
-
const result = {
|
|
396
|
-
output: { result: 'success', data: [1, 2, 3] },
|
|
397
|
-
error: undefined,
|
|
398
|
-
durationMs: 1500,
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
expect(result.output).toEqual({ result: 'success', data: [1, 2, 3] });
|
|
402
|
-
expect(result.error).toBeUndefined();
|
|
403
|
-
expect(result.durationMs).toBe(1500);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
it('should accept failed execution result', () => {
|
|
407
|
-
const error = new Error('Execution failed');
|
|
408
|
-
const result = {
|
|
409
|
-
output: undefined,
|
|
410
|
-
error,
|
|
411
|
-
durationMs: 500,
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
expect(result.output).toBeUndefined();
|
|
415
|
-
expect(result.error).toBe(error);
|
|
416
|
-
expect(result.error.message).toBe('Execution failed');
|
|
417
|
-
expect(result.durationMs).toBe(500);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it('should accept result with complex output', () => {
|
|
421
|
-
const result = {
|
|
422
|
-
output: {
|
|
423
|
-
files: [
|
|
424
|
-
{ name: 'file1.txt', size: 1024 },
|
|
425
|
-
{ name: 'file2.txt', size: 2048 },
|
|
426
|
-
],
|
|
427
|
-
summary: { total: 2, totalSize: 3072 },
|
|
428
|
-
},
|
|
429
|
-
error: undefined,
|
|
430
|
-
durationMs: 3000,
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
expect(result.output.files).toHaveLength(2);
|
|
434
|
-
expect(result.output.summary.total).toBe(2);
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
});
|