@ai-setting/roy-agent-cli 1.3.18 → 1.3.22
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/package.json +17 -39
- package/dist/bin/roy +0 -0
- package/dist/bin/roy.js +0 -127298
- package/dist/cli/src/bin/roy.d.ts +0 -6
- package/dist/cli/src/bin/roy.js +0 -10
- package/dist/cli/src/cli.d.ts +0 -5
- package/dist/cli/src/cli.js +0 -96
- package/dist/cli/src/commands/act.d.ts +0 -44
- package/dist/cli/src/commands/act.js +0 -415
- package/dist/cli/src/commands/commands-add.d.ts +0 -17
- package/dist/cli/src/commands/commands-add.js +0 -90
- package/dist/cli/src/commands/commands-dirs.d.ts +0 -12
- package/dist/cli/src/commands/commands-dirs.js +0 -58
- package/dist/cli/src/commands/commands-info.d.ts +0 -12
- package/dist/cli/src/commands/commands-info.js +0 -76
- package/dist/cli/src/commands/commands-list.d.ts +0 -13
- package/dist/cli/src/commands/commands-list.js +0 -132
- package/dist/cli/src/commands/commands-remove.d.ts +0 -14
- package/dist/cli/src/commands/commands-remove.js +0 -136
- package/dist/cli/src/commands/commands.d.ts +0 -27
- package/dist/cli/src/commands/commands.js +0 -39
- package/dist/cli/src/commands/config/config-service.d.ts +0 -70
- package/dist/cli/src/commands/config/config-service.js +0 -233
- package/dist/cli/src/commands/config/deep-merge.d.ts +0 -22
- package/dist/cli/src/commands/config/deep-merge.js +0 -33
- package/dist/cli/src/commands/config/export.d.ts +0 -15
- package/dist/cli/src/commands/config/export.js +0 -83
- package/dist/cli/src/commands/config/import.d.ts +0 -16
- package/dist/cli/src/commands/config/import.js +0 -102
- package/dist/cli/src/commands/config/index.d.ts +0 -13
- package/dist/cli/src/commands/config/index.js +0 -29
- package/dist/cli/src/commands/config/list.d.ts +0 -18
- package/dist/cli/src/commands/config/list.js +0 -233
- package/dist/cli/src/commands/config/types.d.ts +0 -21
- package/dist/cli/src/commands/config/types.js +0 -49
- package/dist/cli/src/commands/debug/index.d.ts +0 -19
- package/dist/cli/src/commands/debug/index.js +0 -34
- package/dist/cli/src/commands/debug/log.d.ts +0 -29
- package/dist/cli/src/commands/debug/log.js +0 -102
- package/dist/cli/src/commands/debug/span.d.ts +0 -24
- package/dist/cli/src/commands/debug/span.js +0 -187
- package/dist/cli/src/commands/debug/trace.d.ts +0 -27
- package/dist/cli/src/commands/debug/trace.js +0 -111
- package/dist/cli/src/commands/eventsource/add.d.ts +0 -19
- package/dist/cli/src/commands/eventsource/add.js +0 -108
- package/dist/cli/src/commands/eventsource/index.d.ts +0 -20
- package/dist/cli/src/commands/eventsource/index.js +0 -35
- package/dist/cli/src/commands/eventsource/list.d.ts +0 -13
- package/dist/cli/src/commands/eventsource/list.js +0 -159
- package/dist/cli/src/commands/eventsource/remove.d.ts +0 -13
- package/dist/cli/src/commands/eventsource/remove.js +0 -74
- package/dist/cli/src/commands/eventsource/start.d.ts +0 -13
- package/dist/cli/src/commands/eventsource/start.js +0 -81
- package/dist/cli/src/commands/eventsource/status.d.ts +0 -13
- package/dist/cli/src/commands/eventsource/status.js +0 -149
- package/dist/cli/src/commands/eventsource/stop.d.ts +0 -13
- package/dist/cli/src/commands/eventsource/stop.js +0 -69
- package/dist/cli/src/commands/index.d.ts +0 -15
- package/dist/cli/src/commands/index.js +0 -14
- package/dist/cli/src/commands/input-handler.d.ts +0 -27
- package/dist/cli/src/commands/input-handler.js +0 -38
- package/dist/cli/src/commands/interactive.d.ts +0 -141
- package/dist/cli/src/commands/interactive.js +0 -854
- package/dist/cli/src/commands/lsp/check.d.ts +0 -9
- package/dist/cli/src/commands/lsp/check.js +0 -79
- package/dist/cli/src/commands/lsp/index.d.ts +0 -12
- package/dist/cli/src/commands/lsp/index.js +0 -26
- package/dist/cli/src/commands/lsp/install.d.ts +0 -9
- package/dist/cli/src/commands/lsp/install.js +0 -114
- package/dist/cli/src/commands/lsp/list.d.ts +0 -9
- package/dist/cli/src/commands/lsp/list.js +0 -53
- package/dist/cli/src/commands/mcp/index.d.ts +0 -11
- package/dist/cli/src/commands/mcp/index.js +0 -23
- package/dist/cli/src/commands/mcp/list.d.ts +0 -14
- package/dist/cli/src/commands/mcp/list.js +0 -100
- package/dist/cli/src/commands/mcp/reload.d.ts +0 -12
- package/dist/cli/src/commands/mcp/reload.js +0 -54
- package/dist/cli/src/commands/mcp/tools.d.ts +0 -15
- package/dist/cli/src/commands/mcp/tools.js +0 -101
- package/dist/cli/src/commands/memory/index.d.ts +0 -11
- package/dist/cli/src/commands/memory/index.js +0 -11
- package/dist/cli/src/commands/memory/memory.d.ts +0 -10
- package/dist/cli/src/commands/memory/memory.js +0 -21
- package/dist/cli/src/commands/memory/organize.d.ts +0 -48
- package/dist/cli/src/commands/memory/organize.js +0 -233
- package/dist/cli/src/commands/memory/recall.d.ts +0 -10
- package/dist/cli/src/commands/memory/recall.js +0 -69
- package/dist/cli/src/commands/memory/record.d.ts +0 -11
- package/dist/cli/src/commands/memory/record.js +0 -268
- package/dist/cli/src/commands/plugin.d.ts +0 -112
- package/dist/cli/src/commands/plugin.js +0 -186
- package/dist/cli/src/commands/sessions/active.d.ts +0 -14
- package/dist/cli/src/commands/sessions/active.js +0 -79
- package/dist/cli/src/commands/sessions/add-message.d.ts +0 -8
- package/dist/cli/src/commands/sessions/add-message.js +0 -78
- package/dist/cli/src/commands/sessions/checkpoints.d.ts +0 -8
- package/dist/cli/src/commands/sessions/checkpoints.js +0 -133
- package/dist/cli/src/commands/sessions/compact.d.ts +0 -16
- package/dist/cli/src/commands/sessions/compact.js +0 -240
- package/dist/cli/src/commands/sessions/delete.d.ts +0 -14
- package/dist/cli/src/commands/sessions/delete.js +0 -214
- package/dist/cli/src/commands/sessions/get.d.ts +0 -8
- package/dist/cli/src/commands/sessions/get.js +0 -129
- package/dist/cli/src/commands/sessions/grep.d.ts +0 -15
- package/dist/cli/src/commands/sessions/grep.js +0 -210
- package/dist/cli/src/commands/sessions/index.d.ts +0 -42
- package/dist/cli/src/commands/sessions/index.js +0 -93
- package/dist/cli/src/commands/sessions/list.d.ts +0 -21
- package/dist/cli/src/commands/sessions/list.js +0 -163
- package/dist/cli/src/commands/sessions/messages.d.ts +0 -8
- package/dist/cli/src/commands/sessions/messages.js +0 -228
- package/dist/cli/src/commands/sessions/mock.d.ts +0 -10
- package/dist/cli/src/commands/sessions/mock.js +0 -172
- package/dist/cli/src/commands/sessions/new.d.ts +0 -16
- package/dist/cli/src/commands/sessions/new.js +0 -66
- package/dist/cli/src/commands/sessions/rename.d.ts +0 -8
- package/dist/cli/src/commands/sessions/rename.js +0 -82
- package/dist/cli/src/commands/shared/event-handler.d.ts +0 -91
- package/dist/cli/src/commands/shared/event-handler.js +0 -167
- package/dist/cli/src/commands/shared/event-message-formatter.d.ts +0 -150
- package/dist/cli/src/commands/shared/event-message-formatter.js +0 -198
- package/dist/cli/src/commands/shared/index.d.ts +0 -10
- package/dist/cli/src/commands/shared/index.js +0 -8
- package/dist/cli/src/commands/shared/query-executor.d.ts +0 -81
- package/dist/cli/src/commands/shared/query-executor.js +0 -254
- package/dist/cli/src/commands/shared/session-manager.d.ts +0 -49
- package/dist/cli/src/commands/shared/session-manager.js +0 -93
- package/dist/cli/src/commands/skills/get.d.ts +0 -14
- package/dist/cli/src/commands/skills/get.js +0 -76
- package/dist/cli/src/commands/skills/index.d.ts +0 -18
- package/dist/cli/src/commands/skills/index.js +0 -36
- package/dist/cli/src/commands/skills/list.d.ts +0 -8
- package/dist/cli/src/commands/skills/list.js +0 -112
- package/dist/cli/src/commands/skills/reload.d.ts +0 -12
- package/dist/cli/src/commands/skills/reload.js +0 -46
- package/dist/cli/src/commands/skills/search.d.ts +0 -15
- package/dist/cli/src/commands/skills/search.js +0 -110
- package/dist/cli/src/commands/skills/show-config.d.ts +0 -12
- package/dist/cli/src/commands/skills/show-config.js +0 -74
- package/dist/cli/src/commands/tasks/complete.d.ts +0 -15
- package/dist/cli/src/commands/tasks/complete.js +0 -72
- package/dist/cli/src/commands/tasks/create.d.ts +0 -19
- package/dist/cli/src/commands/tasks/create.js +0 -93
- package/dist/cli/src/commands/tasks/delete.d.ts +0 -14
- package/dist/cli/src/commands/tasks/delete.js +0 -71
- package/dist/cli/src/commands/tasks/get.d.ts +0 -15
- package/dist/cli/src/commands/tasks/get.js +0 -98
- package/dist/cli/src/commands/tasks/index.d.ts +0 -20
- package/dist/cli/src/commands/tasks/index.js +0 -50
- package/dist/cli/src/commands/tasks/list.d.ts +0 -18
- package/dist/cli/src/commands/tasks/list.js +0 -116
- package/dist/cli/src/commands/tasks/operations.d.ts +0 -8
- package/dist/cli/src/commands/tasks/operations.js +0 -95
- package/dist/cli/src/commands/tasks/update.d.ts +0 -20
- package/dist/cli/src/commands/tasks/update.js +0 -93
- package/dist/cli/src/commands/tools/exec-tool.d.ts +0 -14
- package/dist/cli/src/commands/tools/exec-tool.js +0 -103
- package/dist/cli/src/commands/tools/get.d.ts +0 -14
- package/dist/cli/src/commands/tools/get.js +0 -97
- package/dist/cli/src/commands/tools/index.d.ts +0 -16
- package/dist/cli/src/commands/tools/index.js +0 -30
- package/dist/cli/src/commands/tools/list.d.ts +0 -14
- package/dist/cli/src/commands/tools/list.js +0 -92
- package/dist/cli/src/commands/tools/shared/index.d.ts +0 -7
- package/dist/cli/src/commands/tools/shared/index.js +0 -7
- package/dist/cli/src/commands/tools/shared/schema-helper.d.ts +0 -53
- package/dist/cli/src/commands/tools/shared/schema-helper.js +0 -74
- package/dist/cli/src/commands/workflow/commands/add.d.ts +0 -22
- package/dist/cli/src/commands/workflow/commands/add.js +0 -271
- package/dist/cli/src/commands/workflow/commands/get.d.ts +0 -20
- package/dist/cli/src/commands/workflow/commands/get.js +0 -169
- package/dist/cli/src/commands/workflow/commands/list.d.ts +0 -21
- package/dist/cli/src/commands/workflow/commands/list.js +0 -117
- package/dist/cli/src/commands/workflow/commands/nodes.d.ts +0 -34
- package/dist/cli/src/commands/workflow/commands/nodes.js +0 -465
- package/dist/cli/src/commands/workflow/commands/remove.d.ts +0 -16
- package/dist/cli/src/commands/workflow/commands/remove.js +0 -77
- package/dist/cli/src/commands/workflow/commands/run.d.ts +0 -32
- package/dist/cli/src/commands/workflow/commands/run.js +0 -335
- package/dist/cli/src/commands/workflow/commands/status.d.ts +0 -17
- package/dist/cli/src/commands/workflow/commands/status.js +0 -125
- package/dist/cli/src/commands/workflow/commands/stop.d.ts +0 -15
- package/dist/cli/src/commands/workflow/commands/stop.js +0 -70
- package/dist/cli/src/commands/workflow/commands/update.d.ts +0 -19
- package/dist/cli/src/commands/workflow/commands/update.js +0 -105
- package/dist/cli/src/commands/workflow/commands/validate.d.ts +0 -14
- package/dist/cli/src/commands/workflow/commands/validate.js +0 -118
- package/dist/cli/src/commands/workflow/index.d.ts +0 -28
- package/dist/cli/src/commands/workflow/index.js +0 -44
- package/dist/cli/src/commands/workflow/renderers.d.ts +0 -60
- package/dist/cli/src/commands/workflow/renderers.js +0 -320
- package/dist/cli/src/commands/workflow/validators/index.d.ts +0 -8
- package/dist/cli/src/commands/workflow/validators/index.js +0 -8
- package/dist/cli/src/commands/workflow/validators/node-validator-factory.d.ts +0 -13
- package/dist/cli/src/commands/workflow/validators/node-validator-factory.js +0 -35
- package/dist/cli/src/commands/workflow/validators/node-validator.d.ts +0 -37
- package/dist/cli/src/commands/workflow/validators/node-validator.js +0 -89
- package/dist/cli/src/commands/workflow/validators/nodes/agent-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/agent-node-validator.js +0 -50
- package/dist/cli/src/commands/workflow/validators/nodes/condition-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/condition-node-validator.js +0 -28
- package/dist/cli/src/commands/workflow/validators/nodes/decorator-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/decorator-node-validator.js +0 -38
- package/dist/cli/src/commands/workflow/validators/nodes/merge-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/merge-node-validator.js +0 -41
- package/dist/cli/src/commands/workflow/validators/nodes/skill-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/skill-node-validator.js +0 -27
- package/dist/cli/src/commands/workflow/validators/nodes/tool-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/tool-node-validator.js +0 -45
- package/dist/cli/src/commands/workflow/validators/nodes/workflow-node-validator.d.ts +0 -11
- package/dist/cli/src/commands/workflow/validators/nodes/workflow-node-validator.js +0 -27
- package/dist/cli/src/commands/workflow/validators/types.d.ts +0 -74
- package/dist/cli/src/commands/workflow/validators/types.js +0 -18
- package/dist/cli/src/commands/workflow/validators/workflow-validator.d.ts +0 -37
- package/dist/cli/src/commands/workflow/validators/workflow-validator.js +0 -284
- package/dist/cli/src/index.d.ts +0 -16
- package/dist/cli/src/index.js +0 -18
- package/dist/cli/src/plugin/apply.d.ts +0 -51
- package/dist/cli/src/plugin/apply.js +0 -85
- package/dist/cli/src/plugin/discover.d.ts +0 -29
- package/dist/cli/src/plugin/discover.js +0 -187
- package/dist/cli/src/plugin/index.d.ts +0 -16
- package/dist/cli/src/plugin/index.js +0 -18
- package/dist/cli/src/plugin/registry.d.ts +0 -109
- package/dist/cli/src/plugin/registry.js +0 -226
- package/dist/cli/src/plugin/types.d.ts +0 -145
- package/dist/cli/src/plugin/types.js +0 -7
- package/dist/cli/src/services/context-handler.service.d.ts +0 -72
- package/dist/cli/src/services/context-handler.service.js +0 -312
- package/dist/cli/src/services/environment.service.d.ts +0 -129
- package/dist/cli/src/services/environment.service.js +0 -544
- package/dist/cli/src/services/output.service.d.ts +0 -68
- package/dist/cli/src/services/output.service.js +0 -104
- package/dist/cli/src/services/quiet-mode.service.d.ts +0 -58
- package/dist/cli/src/services/quiet-mode.service.js +0 -74
- package/dist/cli/src/services/stream-output.service.d.ts +0 -116
- package/dist/cli/src/services/stream-output.service.js +0 -242
- package/dist/cli/src/util/which.d.ts +0 -13
- package/dist/cli/src/util/which.js +0 -50
- package/dist/coder-harness/src/index.d.ts +0 -32
- package/dist/coder-harness/src/index.js +0 -36
- package/dist/coder-harness/src/lsp/client.d.ts +0 -104
- package/dist/coder-harness/src/lsp/client.js +0 -490
- package/dist/coder-harness/src/lsp/client.test.d.ts +0 -5
- package/dist/coder-harness/src/lsp/client.test.js +0 -154
- package/dist/coder-harness/src/lsp/language-map.d.ts +0 -42
- package/dist/coder-harness/src/lsp/language-map.js +0 -105
- package/dist/coder-harness/src/lsp/language-map.test.d.ts +0 -5
- package/dist/coder-harness/src/lsp/language-map.test.js +0 -95
- package/dist/coder-harness/src/lsp/manager.d.ts +0 -166
- package/dist/coder-harness/src/lsp/manager.js +0 -457
- package/dist/coder-harness/src/lsp/manager.test.d.ts +0 -11
- package/dist/coder-harness/src/lsp/manager.test.js +0 -121
- package/dist/coder-harness/src/lsp/preload.integration.test.d.ts +0 -5
- package/dist/coder-harness/src/lsp/preload.integration.test.js +0 -125
- package/dist/coder-harness/src/lsp/server.d.ts +0 -72
- package/dist/coder-harness/src/lsp/server.js +0 -271
- package/dist/coder-harness/src/lsp/server.test.d.ts +0 -5
- package/dist/coder-harness/src/lsp/server.test.js +0 -78
- package/dist/coder-harness/src/lsp-deps/config.d.ts +0 -84
- package/dist/coder-harness/src/lsp-deps/config.js +0 -123
- package/dist/coder-harness/src/lsp-deps/index.d.ts +0 -10
- package/dist/coder-harness/src/lsp-deps/index.js +0 -8
- package/dist/coder-harness/src/lsp-deps/installer.d.ts +0 -101
- package/dist/coder-harness/src/lsp-deps/installer.js +0 -207
- package/dist/coder-harness/src/plugins/code-check-manager.d.ts +0 -43
- package/dist/coder-harness/src/plugins/code-check-manager.js +0 -238
- package/dist/coder-harness/src/plugins/code-check-manager.test.d.ts +0 -2
- package/dist/coder-harness/src/plugins/code-check-manager.test.js +0 -45
- package/dist/coder-harness/src/plugins/code-check-plugin.d.ts +0 -79
- package/dist/coder-harness/src/plugins/code-check-plugin.js +0 -181
- package/dist/coder-harness/src/plugins/code-check-plugin.test.d.ts +0 -2
- package/dist/coder-harness/src/plugins/code-check-plugin.test.js +0 -94
- package/dist/coder-harness/src/plugins/lsp-plugin.d.ts +0 -131
- package/dist/coder-harness/src/plugins/lsp-plugin.js +0 -253
- package/dist/coder-harness/src/plugins/lsp-plugin.test.d.ts +0 -9
- package/dist/coder-harness/src/plugins/lsp-plugin.test.js +0 -304
- package/dist/coder-harness/src/plugins/plugin-hook-adapter.d.ts +0 -192
- package/dist/coder-harness/src/plugins/plugin-hook-adapter.js +0 -294
- package/dist/coder-harness/src/plugins/plugin-hook-adapter.test.d.ts +0 -5
- package/dist/coder-harness/src/plugins/plugin-hook-adapter.test.js +0 -312
- package/dist/coder-harness/src/plugins/reminder-plugin.d.ts +0 -69
- package/dist/coder-harness/src/plugins/reminder-plugin.js +0 -92
- package/dist/coder-harness/src/plugins/reminder-plugin.test.d.ts +0 -5
- package/dist/coder-harness/src/plugins/reminder-plugin.test.js +0 -132
- package/dist/coder-harness/src/types/linter.d.ts +0 -263
- package/dist/coder-harness/src/types/linter.js +0 -18
- package/dist/coder-harness/src/util/glob.d.ts +0 -22
- package/dist/coder-harness/src/util/glob.js +0 -31
- package/dist/coder-harness/src/util/glob.test.d.ts +0 -5
- package/dist/coder-harness/src/util/glob.test.js +0 -63
- package/dist/coder-harness/src/util/which.d.ts +0 -13
- package/dist/coder-harness/src/util/which.js +0 -46
- package/dist/core/src/config/config-component.d.ts +0 -323
- package/dist/core/src/config/config-component.js +0 -686
- package/dist/core/src/config/config-component.test.d.ts +0 -2
- package/dist/core/src/config/config-component.test.js +0 -486
- package/dist/core/src/config/config-parser.d.ts +0 -46
- package/dist/core/src/config/config-parser.js +0 -173
- package/dist/core/src/config/config-parser.test.d.ts +0 -2
- package/dist/core/src/config/config-parser.test.js +0 -252
- package/dist/core/src/config/decentralized-config.test.d.ts +0 -2
- package/dist/core/src/config/decentralized-config.test.js +0 -602
- package/dist/core/src/config/env-key.d.ts +0 -93
- package/dist/core/src/config/env-key.js +0 -189
- package/dist/core/src/config/env-source.d.ts +0 -83
- package/dist/core/src/config/env-source.js +0 -240
- package/dist/core/src/config/env-source.test.d.ts +0 -2
- package/dist/core/src/config/env-source.test.js +0 -196
- package/dist/core/src/config/file-source.d.ts +0 -87
- package/dist/core/src/config/file-source.js +0 -349
- package/dist/core/src/config/file-source.test.d.ts +0 -2
- package/dist/core/src/config/file-source.test.js +0 -275
- package/dist/core/src/config/index.d.ts +0 -5
- package/dist/core/src/config/index.js +0 -5
- package/dist/core/src/config/protocol-resolver.d.ts +0 -95
- package/dist/core/src/config/protocol-resolver.js +0 -175
- package/dist/core/src/config/protocol-resolver.test.d.ts +0 -2
- package/dist/core/src/config/protocol-resolver.test.js +0 -167
- package/dist/core/src/env/agent/agent-component.abort.test.d.ts +0 -11
- package/dist/core/src/env/agent/agent-component.abort.test.js +0 -440
- package/dist/core/src/env/agent/agent-component.d.ts +0 -349
- package/dist/core/src/env/agent/agent-component.js +0 -1481
- package/dist/core/src/env/agent/agent-component.record-session.test.d.ts +0 -14
- package/dist/core/src/env/agent/agent-component.record-session.test.js +0 -280
- package/dist/core/src/env/agent/agent-component.test.d.ts +0 -7
- package/dist/core/src/env/agent/agent-component.test.js +0 -1169
- package/dist/core/src/env/agent/agent-component.tool-error.test.d.ts +0 -25
- package/dist/core/src/env/agent/agent-component.tool-error.test.js +0 -272
- package/dist/core/src/env/agent/agent-config-registration.d.ts +0 -19
- package/dist/core/src/env/agent/agent-config-registration.js +0 -41
- package/dist/core/src/env/agent/agent-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/agent/agent-config-registration.test.js +0 -193
- package/dist/core/src/env/agent/agent-reminder-plugin.integration.test.d.ts +0 -7
- package/dist/core/src/env/agent/agent-reminder-plugin.integration.test.js +0 -206
- package/dist/core/src/env/agent/index.d.ts +0 -10
- package/dist/core/src/env/agent/index.js +0 -9
- package/dist/core/src/env/agent/summary-agent.d.ts +0 -101
- package/dist/core/src/env/agent/summary-agent.js +0 -473
- package/dist/core/src/env/agent/summary-agent.parse-hint.test.d.ts +0 -12
- package/dist/core/src/env/agent/summary-agent.parse-hint.test.js +0 -267
- package/dist/core/src/env/agent/types.d.ts +0 -394
- package/dist/core/src/env/agent/types.js +0 -9
- package/dist/core/src/env/commands/commands-component.d.ts +0 -98
- package/dist/core/src/env/commands/commands-component.js +0 -517
- package/dist/core/src/env/commands/commands-component.test.d.ts +0 -2
- package/dist/core/src/env/commands/commands-component.test.js +0 -304
- package/dist/core/src/env/commands/commands-config-registration.d.ts +0 -20
- package/dist/core/src/env/commands/commands-config-registration.js +0 -33
- package/dist/core/src/env/commands/commands-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/commands/commands-config-registration.test.js +0 -164
- package/dist/core/src/env/commands/index.d.ts +0 -8
- package/dist/core/src/env/commands/index.js +0 -8
- package/dist/core/src/env/commands/parser.d.ts +0 -19
- package/dist/core/src/env/commands/parser.js +0 -97
- package/dist/core/src/env/commands/parser.test.d.ts +0 -2
- package/dist/core/src/env/commands/parser.test.js +0 -155
- package/dist/core/src/env/commands/types.d.ts +0 -134
- package/dist/core/src/env/commands/types.js +0 -7
- package/dist/core/src/env/commands-prompt-integration.test.d.ts +0 -2
- package/dist/core/src/env/commands-prompt-integration.test.js +0 -205
- package/dist/core/src/env/component-env.test.d.ts +0 -2
- package/dist/core/src/env/component-env.test.js +0 -101
- package/dist/core/src/env/component.d.ts +0 -187
- package/dist/core/src/env/component.js +0 -160
- package/dist/core/src/env/constants.d.ts +0 -99
- package/dist/core/src/env/constants.js +0 -107
- package/dist/core/src/env/constants.test.d.ts +0 -2
- package/dist/core/src/env/constants.test.js +0 -55
- package/dist/core/src/env/debug/debug-component.d.ts +0 -161
- package/dist/core/src/env/debug/debug-component.js +0 -441
- package/dist/core/src/env/debug/debug-component.test.d.ts +0 -2
- package/dist/core/src/env/debug/debug-component.test.js +0 -89
- package/dist/core/src/env/debug/formatters/index.d.ts +0 -9
- package/dist/core/src/env/debug/formatters/index.js +0 -9
- package/dist/core/src/env/debug/formatters/repl-formatter.d.ts +0 -81
- package/dist/core/src/env/debug/formatters/repl-formatter.js +0 -309
- package/dist/core/src/env/debug/formatters/repl-formatter.test.d.ts +0 -2
- package/dist/core/src/env/debug/formatters/repl-formatter.test.js +0 -119
- package/dist/core/src/env/debug/formatters/trace-formatter.d.ts +0 -44
- package/dist/core/src/env/debug/formatters/trace-formatter.js +0 -157
- package/dist/core/src/env/debug/formatters/trace-formatter.test.d.ts +0 -2
- package/dist/core/src/env/debug/formatters/trace-formatter.test.js +0 -102
- package/dist/core/src/env/debug/formatters/tree-formatter.d.ts +0 -73
- package/dist/core/src/env/debug/formatters/tree-formatter.js +0 -252
- package/dist/core/src/env/debug/formatters/tree-formatter.test.d.ts +0 -2
- package/dist/core/src/env/debug/formatters/tree-formatter.test.js +0 -91
- package/dist/core/src/env/debug/index.d.ts +0 -16
- package/dist/core/src/env/debug/index.js +0 -18
- package/dist/core/src/env/debug/parser/regex-parser.d.ts +0 -50
- package/dist/core/src/env/debug/parser/regex-parser.js +0 -167
- package/dist/core/src/env/debug/parser/regex-parser.test.d.ts +0 -2
- package/dist/core/src/env/debug/parser/regex-parser.test.js +0 -147
- package/dist/core/src/env/debug/parser/span-builder.d.ts +0 -80
- package/dist/core/src/env/debug/parser/span-builder.js +0 -321
- package/dist/core/src/env/debug/parser/span-builder.test.d.ts +0 -2
- package/dist/core/src/env/debug/parser/span-builder.test.js +0 -207
- package/dist/core/src/env/debug/reader/log-reader.d.ts +0 -56
- package/dist/core/src/env/debug/reader/log-reader.js +0 -163
- package/dist/core/src/env/debug/reader/log-reader.test.d.ts +0 -2
- package/dist/core/src/env/debug/reader/log-reader.test.js +0 -132
- package/dist/core/src/env/debug/reader/span-db-reader.d.ts +0 -71
- package/dist/core/src/env/debug/reader/span-db-reader.js +0 -167
- package/dist/core/src/env/debug/reader/span-db-reader.test.d.ts +0 -5
- package/dist/core/src/env/debug/reader/span-db-reader.test.js +0 -96
- package/dist/core/src/env/debug/types.d.ts +0 -146
- package/dist/core/src/env/debug/types.js +0 -7
- package/dist/core/src/env/debug/types.test.d.ts +0 -2
- package/dist/core/src/env/debug/types.test.js +0 -160
- package/dist/core/src/env/environment-init.test.d.ts +0 -2
- package/dist/core/src/env/environment-init.test.js +0 -142
- package/dist/core/src/env/environment-lifecycle.test.d.ts +0 -16
- package/dist/core/src/env/environment-lifecycle.test.js +0 -391
- package/dist/core/src/env/environment-service.test.d.ts +0 -7
- package/dist/core/src/env/environment-service.test.js +0 -265
- package/dist/core/src/env/environment.d.ts +0 -163
- package/dist/core/src/env/environment.handle-query.test.d.ts +0 -5
- package/dist/core/src/env/environment.handle-query.test.js +0 -74
- package/dist/core/src/env/environment.js +0 -607
- package/dist/core/src/env/environment.test.d.ts +0 -5
- package/dist/core/src/env/environment.test.js +0 -188
- package/dist/core/src/env/errors.d.ts +0 -96
- package/dist/core/src/env/errors.js +0 -123
- package/dist/core/src/env/errors.test.d.ts +0 -2
- package/dist/core/src/env/errors.test.js +0 -110
- package/dist/core/src/env/event-source/event-source-agent-handler.d.ts +0 -45
- package/dist/core/src/env/event-source/event-source-agent-handler.js +0 -80
- package/dist/core/src/env/event-source/event-source-agent-handler.test.d.ts +0 -2
- package/dist/core/src/env/event-source/event-source-agent-handler.test.js +0 -165
- package/dist/core/src/env/event-source/event-source-component.d.ts +0 -197
- package/dist/core/src/env/event-source/event-source-component.js +0 -1155
- package/dist/core/src/env/event-source/event-source-component.process-cleanup.test.d.ts +0 -9
- package/dist/core/src/env/event-source/event-source-component.process-cleanup.test.js +0 -207
- package/dist/core/src/env/event-source/event-source-component.stop.test.d.ts +0 -7
- package/dist/core/src/env/event-source/event-source-component.stop.test.js +0 -293
- package/dist/core/src/env/event-source/event-source-component.test.d.ts +0 -2
- package/dist/core/src/env/event-source/event-source-component.test.js +0 -1036
- package/dist/core/src/env/event-source/event-source-config-registration.d.ts +0 -19
- package/dist/core/src/env/event-source/event-source-config-registration.js +0 -32
- package/dist/core/src/env/event-source/event-source-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/event-source/event-source-config-registration.test.js +0 -208
- package/dist/core/src/env/event-source/event-source-integration.test.d.ts +0 -2
- package/dist/core/src/env/event-source/event-source-integration.test.js +0 -275
- package/dist/core/src/env/event-source/event-source-platform.test.d.ts +0 -12
- package/dist/core/src/env/event-source/event-source-platform.test.js +0 -536
- package/dist/core/src/env/event-source/types.d.ts +0 -213
- package/dist/core/src/env/event-source/types.js +0 -57
- package/dist/core/src/env/hook/global-hook-manager.d.ts +0 -74
- package/dist/core/src/env/hook/global-hook-manager.js +0 -126
- package/dist/core/src/env/hook/hook-manager.d.ts +0 -133
- package/dist/core/src/env/hook/hook-manager.js +0 -249
- package/dist/core/src/env/hook/hook-manager.test.d.ts +0 -2
- package/dist/core/src/env/hook/hook-manager.test.js +0 -275
- package/dist/core/src/env/hook/index.d.ts +0 -10
- package/dist/core/src/env/hook/index.js +0 -12
- package/dist/core/src/env/hook/types.d.ts +0 -104
- package/dist/core/src/env/hook/types.js +0 -33
- package/dist/core/src/env/index.d.ts +0 -23
- package/dist/core/src/env/index.js +0 -26
- package/dist/core/src/env/interface.d.ts +0 -156
- package/dist/core/src/env/interface.js +0 -19
- package/dist/core/src/env/llm/hooks.d.ts +0 -151
- package/dist/core/src/env/llm/hooks.js +0 -209
- package/dist/core/src/env/llm/hooks.test.d.ts +0 -2
- package/dist/core/src/env/llm/hooks.test.js +0 -233
- package/dist/core/src/env/llm/index.d.ts +0 -12
- package/dist/core/src/env/llm/index.js +0 -16
- package/dist/core/src/env/llm/invoke-threshold-check.test.d.ts +0 -11
- package/dist/core/src/env/llm/invoke-threshold-check.test.js +0 -76
- package/dist/core/src/env/llm/invoke-timeout.test.d.ts +0 -2
- package/dist/core/src/env/llm/invoke-timeout.test.js +0 -31
- package/dist/core/src/env/llm/invoke.d.ts +0 -118
- package/dist/core/src/env/llm/invoke.js +0 -755
- package/dist/core/src/env/llm/invoke.test.d.ts +0 -2
- package/dist/core/src/env/llm/invoke.test.js +0 -62
- package/dist/core/src/env/llm/llm-config.test.d.ts +0 -2
- package/dist/core/src/env/llm/llm-config.test.js +0 -453
- package/dist/core/src/env/llm/llm.d.ts +0 -164
- package/dist/core/src/env/llm/llm.js +0 -461
- package/dist/core/src/env/llm/llm.test.d.ts +0 -2
- package/dist/core/src/env/llm/llm.test.js +0 -197
- package/dist/core/src/env/llm/provider.d.ts +0 -41
- package/dist/core/src/env/llm/provider.js +0 -90
- package/dist/core/src/env/llm/provider.test.d.ts +0 -2
- package/dist/core/src/env/llm/provider.test.js +0 -152
- package/dist/core/src/env/llm/transform.d.ts +0 -58
- package/dist/core/src/env/llm/transform.js +0 -254
- package/dist/core/src/env/llm/transform.test.d.ts +0 -2
- package/dist/core/src/env/llm/transform.test.js +0 -215
- package/dist/core/src/env/llm/types.d.ts +0 -771
- package/dist/core/src/env/llm/types.js +0 -67
- package/dist/core/src/env/llm/types.test.d.ts +0 -2
- package/dist/core/src/env/llm/types.test.js +0 -520
- package/dist/core/src/env/log-trace/decorator-otel.test.d.ts +0 -7
- package/dist/core/src/env/log-trace/decorator-otel.test.js +0 -204
- package/dist/core/src/env/log-trace/decorator.d.ts +0 -47
- package/dist/core/src/env/log-trace/decorator.js +0 -190
- package/dist/core/src/env/log-trace/index.d.ts +0 -15
- package/dist/core/src/env/log-trace/index.js +0 -20
- package/dist/core/src/env/log-trace/log-trace-component.d.ts +0 -262
- package/dist/core/src/env/log-trace/log-trace-component.js +0 -405
- package/dist/core/src/env/log-trace/log-trace-component.test.d.ts +0 -7
- package/dist/core/src/env/log-trace/log-trace-component.test.js +0 -212
- package/dist/core/src/env/log-trace/log-trace-config-registration.d.ts +0 -20
- package/dist/core/src/env/log-trace/log-trace-config-registration.js +0 -40
- package/dist/core/src/env/log-trace/log-trace-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/log-trace/log-trace-config-registration.test.js +0 -295
- package/dist/core/src/env/log-trace/logger.d.ts +0 -84
- package/dist/core/src/env/log-trace/logger.js +0 -445
- package/dist/core/src/env/log-trace/logger.test.d.ts +0 -2
- package/dist/core/src/env/log-trace/logger.test.js +0 -118
- package/dist/core/src/env/log-trace/opentelemetry/cli-propagation.d.ts +0 -106
- package/dist/core/src/env/log-trace/opentelemetry/cli-propagation.js +0 -149
- package/dist/core/src/env/log-trace/opentelemetry/cli-propagation.test.d.ts +0 -9
- package/dist/core/src/env/log-trace/opentelemetry/cli-propagation.test.js +0 -122
- package/dist/core/src/env/log-trace/opentelemetry/integration.test.d.ts +0 -19
- package/dist/core/src/env/log-trace/opentelemetry/integration.test.js +0 -535
- package/dist/core/src/env/log-trace/opentelemetry/mod.d.ts +0 -25
- package/dist/core/src/env/log-trace/opentelemetry/mod.js +0 -25
- package/dist/core/src/env/log-trace/opentelemetry/propagation-env.d.ts +0 -82
- package/dist/core/src/env/log-trace/opentelemetry/propagation-env.js +0 -109
- package/dist/core/src/env/log-trace/opentelemetry/propagation-env.test.d.ts +0 -9
- package/dist/core/src/env/log-trace/opentelemetry/propagation-env.test.js +0 -143
- package/dist/core/src/env/log-trace/opentelemetry/propagation.d.ts +0 -80
- package/dist/core/src/env/log-trace/opentelemetry/propagation.js +0 -163
- package/dist/core/src/env/log-trace/opentelemetry/propagation.test.d.ts +0 -11
- package/dist/core/src/env/log-trace/opentelemetry/propagation.test.js +0 -197
- package/dist/core/src/env/log-trace/opentelemetry/tracer-provider-context.test.d.ts +0 -8
- package/dist/core/src/env/log-trace/opentelemetry/tracer-provider-context.test.js +0 -127
- package/dist/core/src/env/log-trace/opentelemetry/tracer-provider.d.ts +0 -143
- package/dist/core/src/env/log-trace/opentelemetry/tracer-provider.js +0 -451
- package/dist/core/src/env/log-trace/opentelemetry/tracer-provider.test.d.ts +0 -11
- package/dist/core/src/env/log-trace/opentelemetry/tracer-provider.test.js +0 -291
- package/dist/core/src/env/log-trace/span-storage.d.ts +0 -38
- package/dist/core/src/env/log-trace/span-storage.js +0 -185
- package/dist/core/src/env/log-trace/span-storage.test.d.ts +0 -5
- package/dist/core/src/env/log-trace/span-storage.test.js +0 -121
- package/dist/core/src/env/log-trace/trace-context.d.ts +0 -29
- package/dist/core/src/env/log-trace/trace-context.js +0 -133
- package/dist/core/src/env/log-trace/trace-context.test.d.ts +0 -2
- package/dist/core/src/env/log-trace/trace-context.test.js +0 -149
- package/dist/core/src/env/log-trace/types.d.ts +0 -128
- package/dist/core/src/env/log-trace/types.js +0 -21
- package/dist/core/src/env/log-trace/types.test.d.ts +0 -2
- package/dist/core/src/env/log-trace/types.test.js +0 -53
- package/dist/core/src/env/mcp/__integration__/mcp-component.integration.test.d.ts +0 -2
- package/dist/core/src/env/mcp/__integration__/mcp-component.integration.test.js +0 -322
- package/dist/core/src/env/mcp/config.d.ts +0 -104
- package/dist/core/src/env/mcp/config.js +0 -65
- package/dist/core/src/env/mcp/config.test.d.ts +0 -2
- package/dist/core/src/env/mcp/config.test.js +0 -56
- package/dist/core/src/env/mcp/index.d.ts +0 -12
- package/dist/core/src/env/mcp/index.js +0 -14
- package/dist/core/src/env/mcp/loader.d.ts +0 -67
- package/dist/core/src/env/mcp/loader.js +0 -163
- package/dist/core/src/env/mcp/loader.test.d.ts +0 -2
- package/dist/core/src/env/mcp/loader.test.js +0 -128
- package/dist/core/src/env/mcp/mcp-component.d.ts +0 -55
- package/dist/core/src/env/mcp/mcp-component.js +0 -296
- package/dist/core/src/env/mcp/mcp-component.test.d.ts +0 -2
- package/dist/core/src/env/mcp/mcp-component.test.js +0 -92
- package/dist/core/src/env/mcp/mcp-config-registration.d.ts +0 -20
- package/dist/core/src/env/mcp/mcp-config-registration.js +0 -45
- package/dist/core/src/env/mcp/mcp-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/mcp/mcp-config-registration.test.js +0 -258
- package/dist/core/src/env/mcp/scanner.d.ts +0 -39
- package/dist/core/src/env/mcp/scanner.js +0 -206
- package/dist/core/src/env/mcp/scanner.test.d.ts +0 -2
- package/dist/core/src/env/mcp/scanner.test.js +0 -115
- package/dist/core/src/env/mcp/tool/adapter.d.ts +0 -33
- package/dist/core/src/env/mcp/tool/adapter.js +0 -413
- package/dist/core/src/env/mcp/tool/adapter.test.d.ts +0 -2
- package/dist/core/src/env/mcp/tool/adapter.test.js +0 -436
- package/dist/core/src/env/mcp/tool/index.d.ts +0 -5
- package/dist/core/src/env/mcp/tool/index.js +0 -5
- package/dist/core/src/env/mcp/types.d.ts +0 -122
- package/dist/core/src/env/mcp/types.js +0 -33
- package/dist/core/src/env/mcp/types.test.d.ts +0 -2
- package/dist/core/src/env/mcp/types.test.js +0 -136
- package/dist/core/src/env/memory/built-in/index.d.ts +0 -42
- package/dist/core/src/env/memory/built-in/index.js +0 -24
- package/dist/core/src/env/memory/built-in/recall-memory.d.ts +0 -30
- package/dist/core/src/env/memory/built-in/recall-memory.js +0 -79
- package/dist/core/src/env/memory/built-in/record-memory.d.ts +0 -45
- package/dist/core/src/env/memory/built-in/record-memory.js +0 -111
- package/dist/core/src/env/memory/index.d.ts +0 -11
- package/dist/core/src/env/memory/index.js +0 -16
- package/dist/core/src/env/memory/memory-component.d.ts +0 -115
- package/dist/core/src/env/memory/memory-component.js +0 -406
- package/dist/core/src/env/memory/memory-component.test.d.ts +0 -5
- package/dist/core/src/env/memory/memory-component.test.js +0 -183
- package/dist/core/src/env/memory/memory-config-registration.d.ts +0 -19
- package/dist/core/src/env/memory/memory-config-registration.js +0 -43
- package/dist/core/src/env/memory/memory-config-registration.test.d.ts +0 -5
- package/dist/core/src/env/memory/memory-config-registration.test.js +0 -48
- package/dist/core/src/env/memory/memory-config.d.ts +0 -19
- package/dist/core/src/env/memory/memory-config.js +0 -41
- package/dist/core/src/env/memory/memory-file.test.d.ts +0 -7
- package/dist/core/src/env/memory/memory-file.test.js +0 -222
- package/dist/core/src/env/memory/plugin/index.d.ts +0 -17
- package/dist/core/src/env/memory/plugin/index.js +0 -17
- package/dist/core/src/env/memory/plugin/memory-agent.d.ts +0 -127
- package/dist/core/src/env/memory/plugin/memory-agent.js +0 -250
- package/dist/core/src/env/memory/plugin/memory-agent.test.d.ts +0 -11
- package/dist/core/src/env/memory/plugin/memory-agent.test.js +0 -207
- package/dist/core/src/env/memory/plugin/memory-manager.d.ts +0 -72
- package/dist/core/src/env/memory/plugin/memory-manager.js +0 -166
- package/dist/core/src/env/memory/plugin/memory-plugin-agent.test.d.ts +0 -7
- package/dist/core/src/env/memory/plugin/memory-plugin-agent.test.js +0 -114
- package/dist/core/src/env/memory/plugin/memory-plugin.d.ts +0 -104
- package/dist/core/src/env/memory/plugin/memory-plugin.js +0 -155
- package/dist/core/src/env/memory/plugin/plugin-simplified.test.d.ts +0 -13
- package/dist/core/src/env/memory/plugin/plugin-simplified.test.js +0 -44
- package/dist/core/src/env/memory/plugin/recall-memory.d.ts +0 -17
- package/dist/core/src/env/memory/plugin/recall-memory.js +0 -44
- package/dist/core/src/env/memory/plugin/recall-memory.test.d.ts +0 -7
- package/dist/core/src/env/memory/plugin/recall-memory.test.js +0 -86
- package/dist/core/src/env/memory/plugin/types.d.ts +0 -76
- package/dist/core/src/env/memory/plugin/types.js +0 -16
- package/dist/core/src/env/memory/tools/memory-agent-tools.d.ts +0 -110
- package/dist/core/src/env/memory/tools/memory-agent-tools.js +0 -157
- package/dist/core/src/env/memory/types.d.ts +0 -81
- package/dist/core/src/env/memory/types.js +0 -25
- package/dist/core/src/env/paths.d.ts +0 -47
- package/dist/core/src/env/paths.js +0 -91
- package/dist/core/src/env/prompt/index.d.ts +0 -8
- package/dist/core/src/env/prompt/index.js +0 -7
- package/dist/core/src/env/prompt/memory-prompts.test.d.ts +0 -7
- package/dist/core/src/env/prompt/memory-prompts.test.js +0 -78
- package/dist/core/src/env/prompt/prompt-component.d.ts +0 -163
- package/dist/core/src/env/prompt/prompt-component.js +0 -489
- package/dist/core/src/env/prompt/prompt-component.test.d.ts +0 -7
- package/dist/core/src/env/prompt/prompt-component.test.js +0 -397
- package/dist/core/src/env/prompt/prompt-config-registration.d.ts +0 -19
- package/dist/core/src/env/prompt/prompt-config-registration.js +0 -34
- package/dist/core/src/env/prompt/prompt-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/prompt/prompt-config-registration.test.js +0 -172
- package/dist/core/src/env/prompt/prompts-index.d.ts +0 -27
- package/dist/core/src/env/prompt/prompts-index.js +0 -498
- package/dist/core/src/env/prompt/renderer.d.ts +0 -22
- package/dist/core/src/env/prompt/renderer.js +0 -47
- package/dist/core/src/env/prompt/types.d.ts +0 -159
- package/dist/core/src/env/prompt/types.js +0 -48
- package/dist/core/src/env/session/hooks.d.ts +0 -15
- package/dist/core/src/env/session/hooks.js +0 -5
- package/dist/core/src/env/session/index.d.ts +0 -19
- package/dist/core/src/env/session/index.js +0 -13
- package/dist/core/src/env/session/search-query-parser.d.ts +0 -42
- package/dist/core/src/env/session/search-query-parser.js +0 -141
- package/dist/core/src/env/session/search-query-parser.test.d.ts +0 -14
- package/dist/core/src/env/session/search-query-parser.test.js +0 -332
- package/dist/core/src/env/session/session-checkpoint.test.d.ts +0 -7
- package/dist/core/src/env/session/session-checkpoint.test.js +0 -455
- package/dist/core/src/env/session/session-component.d.ts +0 -290
- package/dist/core/src/env/session/session-component.extract-recent-messages.test.d.ts +0 -7
- package/dist/core/src/env/session/session-component.extract-recent-messages.test.js +0 -166
- package/dist/core/src/env/session/session-component.js +0 -981
- package/dist/core/src/env/session/session-component.test.d.ts +0 -7
- package/dist/core/src/env/session/session-component.test.js +0 -107
- package/dist/core/src/env/session/session-config-registration.d.ts +0 -19
- package/dist/core/src/env/session/session-config-registration.js +0 -47
- package/dist/core/src/env/session/session-config-registration.test.d.ts +0 -5
- package/dist/core/src/env/session/session-config-registration.test.js +0 -115
- package/dist/core/src/env/session/session-message-converter.d.ts +0 -125
- package/dist/core/src/env/session/session-message-converter.js +0 -354
- package/dist/core/src/env/session/session-message-converter.test.d.ts +0 -8
- package/dist/core/src/env/session/session-message-converter.test.js +0 -623
- package/dist/core/src/env/session/session-message-e2e.test.d.ts +0 -8
- package/dist/core/src/env/session/session-message-e2e.test.js +0 -376
- package/dist/core/src/env/session/session-search.test.d.ts +0 -7
- package/dist/core/src/env/session/session-search.test.js +0 -338
- package/dist/core/src/env/session/session-store.d.ts +0 -103
- package/dist/core/src/env/session/session-store.js +0 -5
- package/dist/core/src/env/session/session-store.test.d.ts +0 -2
- package/dist/core/src/env/session/session-store.test.js +0 -291
- package/dist/core/src/env/session/storage/index.d.ts +0 -6
- package/dist/core/src/env/session/storage/index.js +0 -6
- package/dist/core/src/env/session/storage/memory.d.ts +0 -44
- package/dist/core/src/env/session/storage/memory.js +0 -404
- package/dist/core/src/env/session/storage/sqlite.d.ts +0 -64
- package/dist/core/src/env/session/storage/sqlite.js +0 -616
- package/dist/core/src/env/session/types.d.ts +0 -613
- package/dist/core/src/env/session/types.js +0 -32
- package/dist/core/src/env/skill/config.d.ts +0 -14
- package/dist/core/src/env/skill/config.js +0 -36
- package/dist/core/src/env/skill/index.d.ts +0 -7
- package/dist/core/src/env/skill/index.js +0 -7
- package/dist/core/src/env/skill/parser.d.ts +0 -10
- package/dist/core/src/env/skill/parser.js +0 -64
- package/dist/core/src/env/skill/parser.test.d.ts +0 -2
- package/dist/core/src/env/skill/parser.test.js +0 -92
- package/dist/core/src/env/skill/scanner.d.ts +0 -26
- package/dist/core/src/env/skill/scanner.js +0 -98
- package/dist/core/src/env/skill/scanner.test.d.ts +0 -2
- package/dist/core/src/env/skill/scanner.test.js +0 -166
- package/dist/core/src/env/skill/skill-component.d.ts +0 -90
- package/dist/core/src/env/skill/skill-component.js +0 -266
- package/dist/core/src/env/skill/skill-component.test.d.ts +0 -2
- package/dist/core/src/env/skill/skill-component.test.js +0 -187
- package/dist/core/src/env/skill/skill-config-registration.d.ts +0 -19
- package/dist/core/src/env/skill/skill-config-registration.js +0 -38
- package/dist/core/src/env/skill/skill-config-registration.test.d.ts +0 -5
- package/dist/core/src/env/skill/skill-config-registration.test.js +0 -44
- package/dist/core/src/env/skill/tool/index.d.ts +0 -2
- package/dist/core/src/env/skill/tool/index.js +0 -2
- package/dist/core/src/env/skill/tool/skill-tool.d.ts +0 -16
- package/dist/core/src/env/skill/tool/skill-tool.js +0 -64
- package/dist/core/src/env/skill/tool/skill-tool.test.d.ts +0 -2
- package/dist/core/src/env/skill/tool/skill-tool.test.js +0 -77
- package/dist/core/src/env/skill/types.d.ts +0 -62
- package/dist/core/src/env/skill/types.js +0 -8
- package/dist/core/src/env/task/delegate/delegate-tool.d.ts +0 -141
- package/dist/core/src/env/task/delegate/delegate-tool.js +0 -767
- package/dist/core/src/env/task/delegate/delegate-tool.test.d.ts +0 -7
- package/dist/core/src/env/task/delegate/delegate-tool.test.js +0 -386
- package/dist/core/src/env/task/delegate/index.d.ts +0 -9
- package/dist/core/src/env/task/delegate/index.js +0 -8
- package/dist/core/src/env/task/delegate/stop-tool.d.ts +0 -13
- package/dist/core/src/env/task/delegate/stop-tool.js +0 -108
- package/dist/core/src/env/task/delegate/stop-tool.test.d.ts +0 -7
- package/dist/core/src/env/task/delegate/stop-tool.test.js +0 -103
- package/dist/core/src/env/task/delegate/task-events.d.ts +0 -81
- package/dist/core/src/env/task/delegate/task-events.js +0 -67
- package/dist/core/src/env/task/delegate/task-events.test.d.ts +0 -5
- package/dist/core/src/env/task/delegate/task-events.test.js +0 -149
- package/dist/core/src/env/task/hooks/contexts.d.ts +0 -165
- package/dist/core/src/env/task/hooks/contexts.js +0 -5
- package/dist/core/src/env/task/hooks/contexts.test.d.ts +0 -5
- package/dist/core/src/env/task/hooks/contexts.test.js +0 -73
- package/dist/core/src/env/task/hooks/index.d.ts +0 -8
- package/dist/core/src/env/task/hooks/index.js +0 -8
- package/dist/core/src/env/task/hooks/task-hook-points.d.ts +0 -32
- package/dist/core/src/env/task/hooks/task-hook-points.js +0 -37
- package/dist/core/src/env/task/hooks/task-hook-points.test.d.ts +0 -5
- package/dist/core/src/env/task/hooks/task-hook-points.test.js +0 -28
- package/dist/core/src/env/task/index.d.ts +0 -7
- package/dist/core/src/env/task/index.js +0 -7
- package/dist/core/src/env/task/plugins/index.d.ts +0 -7
- package/dist/core/src/env/task/plugins/index.js +0 -7
- package/dist/core/src/env/task/plugins/task-plugin.d.ts +0 -67
- package/dist/core/src/env/task/plugins/task-plugin.js +0 -40
- package/dist/core/src/env/task/plugins/task-plugin.test.d.ts +0 -5
- package/dist/core/src/env/task/plugins/task-plugin.test.js +0 -60
- package/dist/core/src/env/task/plugins/task-tag-plugin.d.ts +0 -79
- package/dist/core/src/env/task/plugins/task-tag-plugin.js +0 -250
- package/dist/core/src/env/task/plugins/task-tag-plugin.test.d.ts +0 -9
- package/dist/core/src/env/task/plugins/task-tag-plugin.test.js +0 -310
- package/dist/core/src/env/task/plugins/task-workflow-extractor.integration.test.d.ts +0 -5
- package/dist/core/src/env/task/plugins/task-workflow-extractor.integration.test.js +0 -198
- package/dist/core/src/env/task/plugins/workflow-extractor-agent.d.ts +0 -36
- package/dist/core/src/env/task/plugins/workflow-extractor-agent.js +0 -197
- package/dist/core/src/env/task/plugins/workflow-extractor-agent.test.d.ts +0 -8
- package/dist/core/src/env/task/plugins/workflow-extractor-agent.test.js +0 -88
- package/dist/core/src/env/task/storage/index.d.ts +0 -6
- package/dist/core/src/env/task/storage/index.js +0 -6
- package/dist/core/src/env/task/storage/sqlite-task-store.d.ts +0 -127
- package/dist/core/src/env/task/storage/sqlite-task-store.js +0 -718
- package/dist/core/src/env/task/storage/sqlite-task-store.test.d.ts +0 -5
- package/dist/core/src/env/task/storage/sqlite-task-store.test.js +0 -235
- package/dist/core/src/env/task/storage/task-search.test.d.ts +0 -5
- package/dist/core/src/env/task/storage/task-search.test.js +0 -236
- package/dist/core/src/env/task/tag-service.d.ts +0 -139
- package/dist/core/src/env/task/tag-service.js +0 -123
- package/dist/core/src/env/task/tag-service.test.d.ts +0 -5
- package/dist/core/src/env/task/tag-service.test.js +0 -157
- package/dist/core/src/env/task/task-component.d.ts +0 -171
- package/dist/core/src/env/task/task-component.js +0 -519
- package/dist/core/src/env/task/task-component.test.d.ts +0 -5
- package/dist/core/src/env/task/task-component.test.js +0 -163
- package/dist/core/src/env/task/task-config-registration.d.ts +0 -20
- package/dist/core/src/env/task/task-config-registration.js +0 -32
- package/dist/core/src/env/task/task-config-registration.test.d.ts +0 -5
- package/dist/core/src/env/task/task-config-registration.test.js +0 -43
- package/dist/core/src/env/task/task-types.test.d.ts +0 -5
- package/dist/core/src/env/task/task-types.test.js +0 -117
- package/dist/core/src/env/task/tools/complete-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/complete-tool.js +0 -40
- package/dist/core/src/env/task/tools/create-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/create-tool.js +0 -45
- package/dist/core/src/env/task/tools/delete-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/delete-tool.js +0 -39
- package/dist/core/src/env/task/tools/get-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/get-tool.js +0 -57
- package/dist/core/src/env/task/tools/index.d.ts +0 -10
- package/dist/core/src/env/task/tools/index.js +0 -10
- package/dist/core/src/env/task/tools/list-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/list-tool.js +0 -36
- package/dist/core/src/env/task/tools/operation/create-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/operation/create-tool.js +0 -44
- package/dist/core/src/env/task/tools/operation/delete-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/operation/delete-tool.js +0 -39
- package/dist/core/src/env/task/tools/operation/get-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/operation/get-tool.js +0 -39
- package/dist/core/src/env/task/tools/operation/index.d.ts +0 -9
- package/dist/core/src/env/task/tools/operation/index.js +0 -9
- package/dist/core/src/env/task/tools/operation/list-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/operation/list-tool.js +0 -36
- package/dist/core/src/env/task/tools/operation/operation-tools.test.d.ts +0 -5
- package/dist/core/src/env/task/tools/operation/operation-tools.test.js +0 -159
- package/dist/core/src/env/task/tools/operation/operation-types.d.ts +0 -92
- package/dist/core/src/env/task/tools/operation/operation-types.js +0 -58
- package/dist/core/src/env/task/tools/operation/update-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/operation/update-tool.js +0 -42
- package/dist/core/src/env/task/tools/task-tools.test.d.ts +0 -5
- package/dist/core/src/env/task/tools/task-tools.test.js +0 -142
- package/dist/core/src/env/task/tools/task-types.d.ts +0 -114
- package/dist/core/src/env/task/tools/task-types.js +0 -53
- package/dist/core/src/env/task/tools/task-types.test.d.ts +0 -5
- package/dist/core/src/env/task/tools/task-types.test.js +0 -63
- package/dist/core/src/env/task/tools/update-tool.d.ts +0 -7
- package/dist/core/src/env/task/tools/update-tool.js +0 -64
- package/dist/core/src/env/task/types.d.ts +0 -129
- package/dist/core/src/env/task/types.js +0 -39
- package/dist/core/src/env/tool/built-in/bash.d.ts +0 -11
- package/dist/core/src/env/tool/built-in/bash.js +0 -182
- package/dist/core/src/env/tool/built-in/echo.d.ts +0 -8
- package/dist/core/src/env/tool/built-in/echo.js +0 -27
- package/dist/core/src/env/tool/built-in/edit-file.d.ts +0 -7
- package/dist/core/src/env/tool/built-in/edit-file.js +0 -86
- package/dist/core/src/env/tool/built-in/edit-file.test.d.ts +0 -2
- package/dist/core/src/env/tool/built-in/edit-file.test.js +0 -84
- package/dist/core/src/env/tool/built-in/glob.d.ts +0 -7
- package/dist/core/src/env/tool/built-in/glob.js +0 -60
- package/dist/core/src/env/tool/built-in/glob.test.d.ts +0 -2
- package/dist/core/src/env/tool/built-in/glob.test.js +0 -61
- package/dist/core/src/env/tool/built-in/grep.d.ts +0 -7
- package/dist/core/src/env/tool/built-in/grep.js +0 -96
- package/dist/core/src/env/tool/built-in/grep.test.d.ts +0 -2
- package/dist/core/src/env/tool/built-in/grep.test.js +0 -74
- package/dist/core/src/env/tool/built-in/index.d.ts +0 -28
- package/dist/core/src/env/tool/built-in/index.js +0 -41
- package/dist/core/src/env/tool/built-in/read-file.d.ts +0 -6
- package/dist/core/src/env/tool/built-in/read-file.js +0 -73
- package/dist/core/src/env/tool/built-in/read-file.test.d.ts +0 -2
- package/dist/core/src/env/tool/built-in/read-file.test.js +0 -63
- package/dist/core/src/env/tool/built-in/write-file.d.ts +0 -6
- package/dist/core/src/env/tool/built-in/write-file.js +0 -65
- package/dist/core/src/env/tool/built-in/write-file.test.d.ts +0 -2
- package/dist/core/src/env/tool/built-in/write-file.test.js +0 -74
- package/dist/core/src/env/tool/index.d.ts +0 -14
- package/dist/core/src/env/tool/index.js +0 -19
- package/dist/core/src/env/tool/registry.d.ts +0 -62
- package/dist/core/src/env/tool/registry.js +0 -137
- package/dist/core/src/env/tool/registry.test.d.ts +0 -2
- package/dist/core/src/env/tool/registry.test.js +0 -219
- package/dist/core/src/env/tool/tool-component.d.ts +0 -160
- package/dist/core/src/env/tool/tool-component.js +0 -411
- package/dist/core/src/env/tool/tool-component.test.d.ts +0 -2
- package/dist/core/src/env/tool/tool-component.test.js +0 -461
- package/dist/core/src/env/tool/tool-config-registration.d.ts +0 -19
- package/dist/core/src/env/tool/tool-config-registration.js +0 -41
- package/dist/core/src/env/tool/tool-config-registration.test.d.ts +0 -7
- package/dist/core/src/env/tool/tool-config-registration.test.js +0 -202
- package/dist/core/src/env/tool/types.d.ts +0 -226
- package/dist/core/src/env/tool/types.js +0 -2
- package/dist/core/src/env/tool/validator.d.ts +0 -15
- package/dist/core/src/env/tool/validator.js +0 -43
- package/dist/core/src/env/tool/validator.test.d.ts +0 -2
- package/dist/core/src/env/tool/validator.test.js +0 -102
- package/dist/core/src/env/types.d.ts +0 -154
- package/dist/core/src/env/types.js +0 -9
- package/dist/core/src/env/workflow/ask-user-tool-registration.test.d.ts +0 -13
- package/dist/core/src/env/workflow/ask-user-tool-registration.test.js +0 -185
- package/dist/core/src/env/workflow/complex-workflow.integration.test.d.ts +0 -14
- package/dist/core/src/env/workflow/complex-workflow.integration.test.js +0 -1588
- package/dist/core/src/env/workflow/decorators/decorator-node.d.ts +0 -77
- package/dist/core/src/env/workflow/decorators/decorator-node.js +0 -176
- package/dist/core/src/env/workflow/decorators/decorator.test.d.ts +0 -5
- package/dist/core/src/env/workflow/decorators/decorator.test.js +0 -212
- package/dist/core/src/env/workflow/decorators/edge.d.ts +0 -43
- package/dist/core/src/env/workflow/decorators/edge.js +0 -68
- package/dist/core/src/env/workflow/decorators/index.d.ts +0 -14
- package/dist/core/src/env/workflow/decorators/index.js +0 -15
- package/dist/core/src/env/workflow/decorators/node-as.d.ts +0 -41
- package/dist/core/src/env/workflow/decorators/node-as.js +0 -85
- package/dist/core/src/env/workflow/decorators/workflow.d.ts +0 -31
- package/dist/core/src/env/workflow/decorators/workflow.js +0 -49
- package/dist/core/src/env/workflow/engine/dag-manager.d.ts +0 -129
- package/dist/core/src/env/workflow/engine/dag-manager.js +0 -471
- package/dist/core/src/env/workflow/engine/dag-manager.test.d.ts +0 -2
- package/dist/core/src/env/workflow/engine/dag-manager.test.js +0 -488
- package/dist/core/src/env/workflow/engine/engine.d.ts +0 -218
- package/dist/core/src/env/workflow/engine/engine.js +0 -1122
- package/dist/core/src/env/workflow/engine/event-bus.d.ts +0 -55
- package/dist/core/src/env/workflow/engine/event-bus.js +0 -137
- package/dist/core/src/env/workflow/engine/event-bus.test.d.ts +0 -2
- package/dist/core/src/env/workflow/engine/event-bus.test.js +0 -274
- package/dist/core/src/env/workflow/engine/executor-agent-session.test.d.ts +0 -2
- package/dist/core/src/env/workflow/engine/executor-agent-session.test.js +0 -46
- package/dist/core/src/env/workflow/engine/executor.d.ts +0 -106
- package/dist/core/src/env/workflow/engine/executor.js +0 -458
- package/dist/core/src/env/workflow/engine/executor.test.d.ts +0 -11
- package/dist/core/src/env/workflow/engine/executor.test.js +0 -274
- package/dist/core/src/env/workflow/engine/index.d.ts +0 -16
- package/dist/core/src/env/workflow/engine/index.js +0 -10
- package/dist/core/src/env/workflow/engine/node-registry.d.ts +0 -160
- package/dist/core/src/env/workflow/engine/node-registry.js +0 -195
- package/dist/core/src/env/workflow/engine/node-registry.test.d.ts +0 -8
- package/dist/core/src/env/workflow/engine/node-registry.test.js +0 -439
- package/dist/core/src/env/workflow/engine/resume-removed.test.d.ts +0 -2
- package/dist/core/src/env/workflow/engine/resume-removed.test.js +0 -19
- package/dist/core/src/env/workflow/engine/scheduler.d.ts +0 -133
- package/dist/core/src/env/workflow/engine/scheduler.js +0 -253
- package/dist/core/src/env/workflow/engine/scheduler.test.d.ts +0 -2
- package/dist/core/src/env/workflow/engine/scheduler.test.js +0 -575
- package/dist/core/src/env/workflow/engine/workflow-engine.test.d.ts +0 -11
- package/dist/core/src/env/workflow/engine/workflow-engine.test.js +0 -640
- package/dist/core/src/env/workflow/extractor/workflow-converter.d.ts +0 -56
- package/dist/core/src/env/workflow/extractor/workflow-converter.js +0 -252
- package/dist/core/src/env/workflow/fixtures.d.ts +0 -402
- package/dist/core/src/env/workflow/fixtures.js +0 -369
- package/dist/core/src/env/workflow/index.d.ts +0 -31
- package/dist/core/src/env/workflow/index.js +0 -35
- package/dist/core/src/env/workflow/integration/run-resume-unified.test.d.ts +0 -2
- package/dist/core/src/env/workflow/integration/run-resume-unified.test.js +0 -161
- package/dist/core/src/env/workflow/integration/service-integration.test.d.ts +0 -8
- package/dist/core/src/env/workflow/integration/service-integration.test.js +0 -223
- package/dist/core/src/env/workflow/metadata/keys.d.ts +0 -7
- package/dist/core/src/env/workflow/metadata/keys.js +0 -10
- package/dist/core/src/env/workflow/nodes/agent-component-adapter.d.ts +0 -163
- package/dist/core/src/env/workflow/nodes/agent-component-adapter.js +0 -333
- package/dist/core/src/env/workflow/nodes/agent-component-adapter.test.d.ts +0 -2
- package/dist/core/src/env/workflow/nodes/agent-component-adapter.test.js +0 -257
- package/dist/core/src/env/workflow/nodes/agent-node.d.ts +0 -217
- package/dist/core/src/env/workflow/nodes/agent-node.js +0 -419
- package/dist/core/src/env/workflow/nodes/agent-node.test.d.ts +0 -13
- package/dist/core/src/env/workflow/nodes/agent-node.test.js +0 -296
- package/dist/core/src/env/workflow/nodes/ask-user-node.d.ts +0 -69
- package/dist/core/src/env/workflow/nodes/ask-user-node.js +0 -67
- package/dist/core/src/env/workflow/nodes/condition-node.d.ts +0 -48
- package/dist/core/src/env/workflow/nodes/condition-node.js +0 -185
- package/dist/core/src/env/workflow/nodes/index.d.ts +0 -7
- package/dist/core/src/env/workflow/nodes/index.js +0 -5
- package/dist/core/src/env/workflow/nodes/merge-node.d.ts +0 -41
- package/dist/core/src/env/workflow/nodes/merge-node.js +0 -126
- package/dist/core/src/env/workflow/nodes/skill-node.d.ts +0 -118
- package/dist/core/src/env/workflow/nodes/skill-node.js +0 -322
- package/dist/core/src/env/workflow/nodes/skill-node.test.d.ts +0 -2
- package/dist/core/src/env/workflow/nodes/skill-node.test.js +0 -189
- package/dist/core/src/env/workflow/nodes/tool-node.d.ts +0 -121
- package/dist/core/src/env/workflow/nodes/tool-node.js +0 -415
- package/dist/core/src/env/workflow/nodes/tool-node.test.d.ts +0 -2
- package/dist/core/src/env/workflow/nodes/tool-node.test.js +0 -181
- package/dist/core/src/env/workflow/nodes/workflow-llm-history.test.d.ts +0 -7
- package/dist/core/src/env/workflow/nodes/workflow-llm-history.test.js +0 -377
- package/dist/core/src/env/workflow/nodes/workflow-node.d.ts +0 -119
- package/dist/core/src/env/workflow/nodes/workflow-node.js +0 -215
- package/dist/core/src/env/workflow/nodes/workflow-node.test.d.ts +0 -2
- package/dist/core/src/env/workflow/nodes/workflow-node.test.js +0 -255
- package/dist/core/src/env/workflow/service/index.d.ts +0 -10
- package/dist/core/src/env/workflow/service/index.js +0 -8
- package/dist/core/src/env/workflow/service/registry.d.ts +0 -38
- package/dist/core/src/env/workflow/service/registry.js +0 -58
- package/dist/core/src/env/workflow/service/registry.test.d.ts +0 -5
- package/dist/core/src/env/workflow/service/registry.test.js +0 -90
- package/dist/core/src/env/workflow/service/workflow-service.d.ts +0 -162
- package/dist/core/src/env/workflow/service/workflow-service.js +0 -244
- package/dist/core/src/env/workflow/service/workflow-service.test.d.ts +0 -5
- package/dist/core/src/env/workflow/service/workflow-service.test.js +0 -228
- package/dist/core/src/env/workflow/storage/index.d.ts +0 -11
- package/dist/core/src/env/workflow/storage/index.js +0 -13
- package/dist/core/src/env/workflow/storage/mock-repositories.d.ts +0 -89
- package/dist/core/src/env/workflow/storage/mock-repositories.js +0 -286
- package/dist/core/src/env/workflow/storage/sqlite.d.ts +0 -56
- package/dist/core/src/env/workflow/storage/sqlite.js +0 -135
- package/dist/core/src/env/workflow/storage/sqlite.test.d.ts +0 -2
- package/dist/core/src/env/workflow/storage/sqlite.test.js +0 -152
- package/dist/core/src/env/workflow/storage/workflow-repo.d.ts +0 -108
- package/dist/core/src/env/workflow/storage/workflow-repo.js +0 -252
- package/dist/core/src/env/workflow/storage/workflow-repo.test.d.ts +0 -2
- package/dist/core/src/env/workflow/storage/workflow-repo.test.js +0 -447
- package/dist/core/src/env/workflow/tools/ask-user-tool.d.ts +0 -36
- package/dist/core/src/env/workflow/tools/ask-user-tool.js +0 -50
- package/dist/core/src/env/workflow/tools/index.d.ts +0 -8
- package/dist/core/src/env/workflow/tools/index.js +0 -10
- package/dist/core/src/env/workflow/tools/run-workflow.d.ts +0 -61
- package/dist/core/src/env/workflow/tools/run-workflow.js +0 -180
- package/dist/core/src/env/workflow/tools/run-workflow.test.d.ts +0 -5
- package/dist/core/src/env/workflow/tools/run-workflow.test.js +0 -235
- package/dist/core/src/env/workflow/types/context.d.ts +0 -18
- package/dist/core/src/env/workflow/types/context.js +0 -2
- package/dist/core/src/env/workflow/types/decorators-types.d.ts +0 -178
- package/dist/core/src/env/workflow/types/decorators-types.js +0 -9
- package/dist/core/src/env/workflow/types/event.d.ts +0 -864
- package/dist/core/src/env/workflow/types/event.js +0 -154
- package/dist/core/src/env/workflow/types/event.test.d.ts +0 -2
- package/dist/core/src/env/workflow/types/event.test.js +0 -484
- package/dist/core/src/env/workflow/types/index.d.ts +0 -14
- package/dist/core/src/env/workflow/types/index.js +0 -10
- package/dist/core/src/env/workflow/types/run.d.ts +0 -123
- package/dist/core/src/env/workflow/types/run.js +0 -23
- package/dist/core/src/env/workflow/types/run.test.d.ts +0 -2
- package/dist/core/src/env/workflow/types/run.test.js +0 -381
- package/dist/core/src/env/workflow/types/workflow-hil.d.ts +0 -58
- package/dist/core/src/env/workflow/types/workflow-hil.js +0 -76
- package/dist/core/src/env/workflow/types/workflow-message.d.ts +0 -139
- package/dist/core/src/env/workflow/types/workflow-message.js +0 -15
- package/dist/core/src/env/workflow/types/workflow-message.test.d.ts +0 -2
- package/dist/core/src/env/workflow/types/workflow-message.test.js +0 -87
- package/dist/core/src/env/workflow/types/workflow-session.d.ts +0 -18
- package/dist/core/src/env/workflow/types/workflow-session.js +0 -41
- package/dist/core/src/env/workflow/types/workflow-session.test.d.ts +0 -2
- package/dist/core/src/env/workflow/types/workflow-session.test.js +0 -80
- package/dist/core/src/env/workflow/types/workflow.d.ts +0 -387
- package/dist/core/src/env/workflow/types/workflow.js +0 -124
- package/dist/core/src/env/workflow/types/workflow.test.d.ts +0 -2
- package/dist/core/src/env/workflow/types/workflow.test.js +0 -455
- package/dist/core/src/env/workflow/types_compat.d.ts +0 -11
- package/dist/core/src/env/workflow/types_compat.js +0 -8
- package/dist/core/src/env/workflow/utils/create-workflow.d.ts +0 -36
- package/dist/core/src/env/workflow/utils/create-workflow.js +0 -36
- package/dist/core/src/env/workflow/utils/execution-state.d.ts +0 -47
- package/dist/core/src/env/workflow/utils/execution-state.js +0 -228
- package/dist/core/src/env/workflow/utils/index.d.ts +0 -9
- package/dist/core/src/env/workflow/utils/index.js +0 -9
- package/dist/core/src/env/workflow/utils/node-registry-helper.d.ts +0 -37
- package/dist/core/src/env/workflow/utils/node-registry-helper.js +0 -48
- package/dist/core/src/env/workflow/utils/recovery-validator.d.ts +0 -31
- package/dist/core/src/env/workflow/utils/recovery-validator.js +0 -325
- package/dist/core/src/env/workflow/utils/recovery-validator.test.d.ts +0 -2
- package/dist/core/src/env/workflow/utils/recovery-validator.test.js +0 -401
- package/dist/core/src/env/workflow/utils/session-parser.d.ts +0 -22
- package/dist/core/src/env/workflow/utils/session-parser.js +0 -72
- package/dist/core/src/env/workflow/utils/session-parser.test.d.ts +0 -2
- package/dist/core/src/env/workflow/utils/session-parser.test.js +0 -89
- package/dist/core/src/env/workflow/utils/session-recovery.d.ts +0 -62
- package/dist/core/src/env/workflow/utils/session-recovery.js +0 -138
- package/dist/core/src/env/workflow/utils/session-recovery.test.d.ts +0 -2
- package/dist/core/src/env/workflow/utils/session-recovery.test.js +0 -263
- package/dist/core/src/env/workflow/utils/template-resolver.d.ts +0 -161
- package/dist/core/src/env/workflow/utils/template-resolver.js +0 -359
- package/dist/core/src/env/workflow/utils/template-resolver.test.d.ts +0 -2
- package/dist/core/src/env/workflow/utils/template-resolver.test.js +0 -216
- package/dist/core/src/env/workflow/utils/validation-rules.d.ts +0 -104
- package/dist/core/src/env/workflow/utils/validation-rules.js +0 -44
- package/dist/core/src/env/workflow/workflow-component.d.ts +0 -135
- package/dist/core/src/env/workflow/workflow-component.js +0 -376
- package/dist/core/src/index.d.ts +0 -54
- package/dist/core/src/index.js +0 -66
- package/dist/core/src/utils/id.d.ts +0 -12
- package/dist/core/src/utils/id.js +0 -20
- package/dist/roy-agent-darwin-arm64/bin/roy.js +0 -127298
- package/dist/roy-agent-darwin-x64/bin/roy.js +0 -127298
- package/dist/roy-agent-linux-arm64/bin/roy.js +0 -127298
- package/dist/roy-agent-linux-x64/bin/roy.js +0 -127298
- package/dist/roy-agent-windows-x64/bin/roy.js +0 -127298
- package/src/bin/roy.ts +0 -12
- package/src/cli.ts +0 -101
- package/src/commands/act.ts +0 -480
- package/src/commands/commands-add.ts +0 -110
- package/src/commands/commands-dirs.ts +0 -70
- package/src/commands/commands-info.ts +0 -90
- package/src/commands/commands-list.ts +0 -161
- package/src/commands/commands-remove.ts +0 -147
- package/src/commands/commands.ts +0 -55
- package/src/commands/config/config-service.test.ts +0 -449
- package/src/commands/config/config-service.ts +0 -312
- package/src/commands/config/deep-merge.test.ts +0 -168
- package/src/commands/config/deep-merge.ts +0 -63
- package/src/commands/config/export.ts +0 -97
- package/src/commands/config/filter-history-e2e.test.ts +0 -141
- package/src/commands/config/import-preserve-refs.test.ts +0 -212
- package/src/commands/config/import.ts +0 -119
- package/src/commands/config/index.ts +0 -35
- package/src/commands/config/list.ts +0 -281
- package/src/commands/config/roy-config-e2e.test.ts +0 -297
- package/src/commands/config/types.ts +0 -54
- package/src/commands/debug/index.ts +0 -38
- package/src/commands/debug/log.test.ts +0 -233
- package/src/commands/debug/log.ts +0 -123
- package/src/commands/debug/span.test.ts +0 -297
- package/src/commands/debug/span.ts +0 -211
- package/src/commands/debug/trace.test.ts +0 -254
- package/src/commands/debug/trace.ts +0 -140
- package/src/commands/eventsource/add.ts +0 -133
- package/src/commands/eventsource/index.ts +0 -48
- package/src/commands/eventsource/list.ts +0 -194
- package/src/commands/eventsource/remove.ts +0 -95
- package/src/commands/eventsource/start.ts +0 -103
- package/src/commands/eventsource/status.ts +0 -185
- package/src/commands/eventsource/stop.ts +0 -89
- package/src/commands/index.ts +0 -22
- package/src/commands/input-handler.test.ts +0 -76
- package/src/commands/input-handler.ts +0 -43
- package/src/commands/interactive-esc.test.ts +0 -254
- package/src/commands/interactive.shutdown.test.ts +0 -122
- package/src/commands/interactive.test.ts +0 -221
- package/src/commands/interactive.ts +0 -1015
- package/src/commands/lsp/check.ts +0 -92
- package/src/commands/lsp/index.ts +0 -32
- package/src/commands/lsp/install.ts +0 -126
- package/src/commands/lsp/list.ts +0 -64
- package/src/commands/mcp/index.ts +0 -27
- package/src/commands/mcp/list.ts +0 -116
- package/src/commands/mcp/reload.ts +0 -70
- package/src/commands/mcp/tools.ts +0 -121
- package/src/commands/memory/extract-e2e.test.ts +0 -388
- package/src/commands/memory/index.ts +0 -11
- package/src/commands/memory/memory-simplified.test.ts +0 -58
- package/src/commands/memory/memory.ts +0 -25
- package/src/commands/memory/organize.ts +0 -300
- package/src/commands/memory/recall.test.ts +0 -120
- package/src/commands/memory/recall.ts +0 -88
- package/src/commands/memory/record-extract-handle-query.test.ts +0 -385
- package/src/commands/memory/record-prompt-component.test.ts +0 -343
- package/src/commands/memory/record.test.ts +0 -92
- package/src/commands/memory/record.ts +0 -332
- package/src/commands/plugin.test.ts +0 -292
- package/src/commands/plugin.ts +0 -267
- package/src/commands/sessions/active.ts +0 -96
- package/src/commands/sessions/add-message.ts +0 -96
- package/src/commands/sessions/checkpoints.ts +0 -154
- package/src/commands/sessions/compact.test.ts +0 -215
- package/src/commands/sessions/compact.ts +0 -269
- package/src/commands/sessions/delete.ts +0 -236
- package/src/commands/sessions/get.ts +0 -165
- package/src/commands/sessions/grep.ts +0 -233
- package/src/commands/sessions/index.ts +0 -95
- package/src/commands/sessions/list.ts +0 -210
- package/src/commands/sessions/messages.test.ts +0 -333
- package/src/commands/sessions/messages.ts +0 -248
- package/src/commands/sessions/mock.ts +0 -194
- package/src/commands/sessions/new.ts +0 -82
- package/src/commands/sessions/rename.ts +0 -98
- package/src/commands/shared/event-handler.ts +0 -213
- package/src/commands/shared/event-message-formatter.ts +0 -295
- package/src/commands/shared/index.ts +0 -11
- package/src/commands/shared/query-executor.test.ts +0 -434
- package/src/commands/shared/query-executor.ts +0 -324
- package/src/commands/shared/repl-engine.test.ts +0 -354
- package/src/commands/shared/session-manager.test.ts +0 -212
- package/src/commands/shared/session-manager.ts +0 -114
- package/src/commands/skills/get.ts +0 -90
- package/src/commands/skills/index.ts +0 -39
- package/src/commands/skills/list.ts +0 -129
- package/src/commands/skills/reload.ts +0 -59
- package/src/commands/skills/search.ts +0 -132
- package/src/commands/skills/show-config.ts +0 -93
- package/src/commands/tasks/complete.ts +0 -92
- package/src/commands/tasks/create.ts +0 -118
- package/src/commands/tasks/delete.ts +0 -86
- package/src/commands/tasks/get.ts +0 -116
- package/src/commands/tasks/index.ts +0 -53
- package/src/commands/tasks/list.ts +0 -140
- package/src/commands/tasks/operations.ts +0 -120
- package/src/commands/tasks/update.ts +0 -122
- package/src/commands/tools/exec-tool.ts +0 -128
- package/src/commands/tools/get.ts +0 -114
- package/src/commands/tools/index.ts +0 -35
- package/src/commands/tools/list.ts +0 -107
- package/src/commands/tools/shared/index.ts +0 -7
- package/src/commands/tools/shared/schema-helper.ts +0 -111
- package/src/commands/workflow/commands/add.ts +0 -315
- package/src/commands/workflow/commands/get.ts +0 -193
- package/src/commands/workflow/commands/list.ts +0 -137
- package/src/commands/workflow/commands/nodes.ts +0 -528
- package/src/commands/workflow/commands/remove.ts +0 -94
- package/src/commands/workflow/commands/run.ts +0 -398
- package/src/commands/workflow/commands/status.ts +0 -147
- package/src/commands/workflow/commands/stop.ts +0 -91
- package/src/commands/workflow/commands/update.ts +0 -130
- package/src/commands/workflow/commands/validate.ts +0 -139
- package/src/commands/workflow/commands/workflow-cli.test.ts +0 -196
- package/src/commands/workflow/index.ts +0 -65
- package/src/commands/workflow/renderers.ts +0 -358
- package/src/commands/workflow/validators/index.ts +0 -8
- package/src/commands/workflow/validators/node-validator-factory.ts +0 -40
- package/src/commands/workflow/validators/node-validator.ts +0 -125
- package/src/commands/workflow/validators/nodes/agent-node-validator.ts +0 -58
- package/src/commands/workflow/validators/nodes/condition-node-validator.ts +0 -34
- package/src/commands/workflow/validators/nodes/decorator-node-validator.ts +0 -45
- package/src/commands/workflow/validators/nodes/merge-node-validator.ts +0 -46
- package/src/commands/workflow/validators/nodes/skill-node-validator.ts +0 -33
- package/src/commands/workflow/validators/nodes/tool-node-validator.ts +0 -54
- package/src/commands/workflow/validators/nodes/workflow-node-validator.ts +0 -33
- package/src/commands/workflow/validators/types.ts +0 -78
- package/src/commands/workflow/validators/workflow-validator.test.ts +0 -273
- package/src/commands/workflow/validators/workflow-validator.ts +0 -320
- package/src/index.ts +0 -19
- package/src/plugin/apply.ts +0 -103
- package/src/plugin/discover.ts +0 -219
- package/src/plugin/index.ts +0 -45
- package/src/plugin/registry.ts +0 -272
- package/src/plugin/types.ts +0 -165
- package/src/services/context-handler.service.test.ts +0 -501
- package/src/services/context-handler.service.ts +0 -372
- package/src/services/environment.service.commands-prompt.test.ts +0 -167
- package/src/services/environment.service.ts +0 -656
- package/src/services/output.service.test.ts +0 -92
- package/src/services/output.service.ts +0 -122
- package/src/services/quiet-mode.service.test.ts +0 -114
- package/src/services/quiet-mode.service.ts +0 -81
- package/src/services/stream-output.service.test.ts +0 -214
- package/src/services/stream-output.service.ts +0 -323
- package/src/util/which.test.ts +0 -101
- package/src/util/which.ts +0 -55
|
@@ -1,1481 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview AgentComponent - Agent执行核心组件
|
|
3
|
-
*
|
|
4
|
-
* 基于 roy-agent docs/agent-component-design.md
|
|
5
|
-
* 参考 agent-core Agent.run 实现
|
|
6
|
-
*
|
|
7
|
-
* 核心功能:
|
|
8
|
-
* - ReAct 循环编排
|
|
9
|
-
* - Hook 机制和 Plugin 扩展
|
|
10
|
-
* - 多 Agent 管理
|
|
11
|
-
* - 工具调用
|
|
12
|
-
*
|
|
13
|
-
* 依赖:
|
|
14
|
-
* - ../llm - LLMComponent 用于 LLM 调用
|
|
15
|
-
* - ../log-trace/logger - createLogger 用于日志
|
|
16
|
-
*/
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
import { BaseComponent } from "../component.js";
|
|
27
|
-
import { createLogger } from "../log-trace/logger.js";
|
|
28
|
-
import { z } from "zod";
|
|
29
|
-
import { envKeyToConfigKey } from "../../config/env-key.js";
|
|
30
|
-
import { AGENT_CONFIG_REGISTRATION, AGENT_DEFAULTS } from "./agent-config-registration.js";
|
|
31
|
-
import { TracedAs } from "../log-trace/decorator.js";
|
|
32
|
-
// Session Message 转换器
|
|
33
|
-
import { SessionMessageConverter } from "../session/session-message-converter.js";
|
|
34
|
-
// AskUserError - 用于工作流暂停的特定错误
|
|
35
|
-
import { AskUserError } from "../workflow/types/workflow-hil.js";
|
|
36
|
-
// ============================================================================
|
|
37
|
-
// Logger
|
|
38
|
-
// ============================================================================
|
|
39
|
-
const logger = createLogger("agent:component");
|
|
40
|
-
// ============================================================================
|
|
41
|
-
// Type Conversion Utilities
|
|
42
|
-
// ============================================================================
|
|
43
|
-
/**
|
|
44
|
-
* 将 ModelMessage 转换为 LLMMessage
|
|
45
|
-
*
|
|
46
|
-
* ModelMessage 来自 ai SDK,LLMMessage 是内部格式
|
|
47
|
-
*/
|
|
48
|
-
function toLLMMessage(msg) {
|
|
49
|
-
// 处理 content 字段
|
|
50
|
-
let content;
|
|
51
|
-
let toolCallId;
|
|
52
|
-
let toolName;
|
|
53
|
-
// 使用 any 类型避免 ai SDK 和内部 ToolCall 类型不兼容
|
|
54
|
-
let toolCalls;
|
|
55
|
-
if (typeof msg.content === "string") {
|
|
56
|
-
content = msg.content;
|
|
57
|
-
// 对于 tool 消息,提取 toolCallId 和 toolName
|
|
58
|
-
if (msg.role === "tool") {
|
|
59
|
-
toolCallId = msg.toolCallId;
|
|
60
|
-
toolName = msg.toolName;
|
|
61
|
-
}
|
|
62
|
-
// assistant 消息可能包含 toolCalls(ai SDK v6 格式)
|
|
63
|
-
if (msg.role === "assistant" && msg.toolCalls) {
|
|
64
|
-
toolCalls = msg.toolCalls;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else if (Array.isArray(msg.content)) {
|
|
68
|
-
// 处理 tool 消息(AI SDK v6 格式)
|
|
69
|
-
if (msg.role === "tool") {
|
|
70
|
-
// 提取 tool-result 的 output
|
|
71
|
-
const toolResult = msg.content.find((part) => part.type === "tool-result");
|
|
72
|
-
// output 可能是 { type: 'text', value: '...' } 或纯字符串
|
|
73
|
-
const output = toolResult?.output;
|
|
74
|
-
if (typeof output === "string") {
|
|
75
|
-
content = output;
|
|
76
|
-
}
|
|
77
|
-
else if (output && typeof output === "object" && "value" in output) {
|
|
78
|
-
content = output.value?.toString() || "";
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
content = JSON.stringify(output) || "";
|
|
82
|
-
}
|
|
83
|
-
toolCallId = toolResult?.toolCallId;
|
|
84
|
-
toolName = toolResult?.toolName;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
// 处理多模态内容,提取文本和 toolCalls
|
|
88
|
-
const textParts = msg.content.filter((part) => part.type === "text");
|
|
89
|
-
const toolCallParts = msg.content.filter((part) => part.type === "tool-call");
|
|
90
|
-
// 提取文本内容
|
|
91
|
-
content = textParts.map((part) => part.text || "").join("");
|
|
92
|
-
// 对于 assistant 消息,从 tool-call part 中提取 toolCalls
|
|
93
|
-
// 注意:toModelMessage 生成的格式是扁平的 { toolCallId, toolName, input }
|
|
94
|
-
// 不是嵌套的 { toolCall: { name, arguments } }
|
|
95
|
-
if (msg.role === "assistant" && toolCallParts.length > 0) {
|
|
96
|
-
toolCalls = toolCallParts.map((part) => {
|
|
97
|
-
// input 是已解析的参数对象,需要转回字符串给 convertToSDKMessages
|
|
98
|
-
const argsString = typeof part.input === "string"
|
|
99
|
-
? part.input
|
|
100
|
-
: JSON.stringify(part.input || {});
|
|
101
|
-
const toolName = part.toolName || "unknown";
|
|
102
|
-
return {
|
|
103
|
-
id: part.toolCallId,
|
|
104
|
-
name: toolName,
|
|
105
|
-
arguments: argsString,
|
|
106
|
-
function: {
|
|
107
|
-
name: toolName,
|
|
108
|
-
arguments: argsString,
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
content = "";
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
role: msg.role,
|
|
120
|
-
content,
|
|
121
|
-
...(toolCallId ? { toolCallId } : {}),
|
|
122
|
-
...(toolName ? { name: toolName } : {}),
|
|
123
|
-
...(toolCalls && toolCalls.length > 0 ? { toolCalls } : {}),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
// ============================================================================
|
|
127
|
-
// Config Schema
|
|
128
|
-
// ============================================================================
|
|
129
|
-
/**
|
|
130
|
-
* AgentComponent 默认配置
|
|
131
|
-
*/
|
|
132
|
-
const DEFAULT_AGENT_CONFIG = {
|
|
133
|
-
type: "primary",
|
|
134
|
-
maxIterations: 200,
|
|
135
|
-
maxErrorRetries: 3,
|
|
136
|
-
doomLoopThreshold: 5,
|
|
137
|
-
toolTimeout: 60000,
|
|
138
|
-
toolRetries: 3,
|
|
139
|
-
/** 是否过滤 history 中的 tool 消息(默认不过滤,保留完整上下文) */
|
|
140
|
-
filterHistory: false,
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Agent 实例配置 Schema
|
|
144
|
-
*/
|
|
145
|
-
const AgentInstanceSchema = z.object({
|
|
146
|
-
type: z.enum(["primary", "sub"]).default("primary"),
|
|
147
|
-
systemPrompt: z.string().optional(),
|
|
148
|
-
behaviorSpecId: z.string().optional(),
|
|
149
|
-
model: z.string().optional(),
|
|
150
|
-
maxIterations: z.number().default(200),
|
|
151
|
-
maxErrorRetries: z.number().default(3),
|
|
152
|
-
doomLoopThreshold: z.number().default(5),
|
|
153
|
-
allowedTools: z.array(z.string()).optional(),
|
|
154
|
-
deniedTools: z.array(z.string()).optional(),
|
|
155
|
-
toolTimeout: z.number().default(60000),
|
|
156
|
-
toolRetries: z.number().default(3),
|
|
157
|
-
/** 是否过滤 history 中的 tool 消息(默认不过滤,保留完整上下文) */
|
|
158
|
-
filterHistory: z.boolean().default(false),
|
|
159
|
-
});
|
|
160
|
-
/**
|
|
161
|
-
* AgentComponent 配置 Schema
|
|
162
|
-
*/
|
|
163
|
-
export const AgentComponentConfigSchema = z.object({
|
|
164
|
-
defaultAgent: AgentInstanceSchema,
|
|
165
|
-
});
|
|
166
|
-
// ============================================================================
|
|
167
|
-
// AgentComponent
|
|
168
|
-
// ============================================================================
|
|
169
|
-
/**
|
|
170
|
-
* AgentComponent
|
|
171
|
-
*
|
|
172
|
-
* 提供 Agent 执行能力和 Hook 扩展机制
|
|
173
|
-
*/
|
|
174
|
-
export class AgentComponent extends BaseComponent {
|
|
175
|
-
name = "agent";
|
|
176
|
-
version = "1.0.0";
|
|
177
|
-
agents = new Map();
|
|
178
|
-
config;
|
|
179
|
-
llmComponent = null;
|
|
180
|
-
toolComponent = null;
|
|
181
|
-
aborted = new Map();
|
|
182
|
-
abortControllers = new Map(); // Agent Run 的 AbortController,使用 runId 作为 key
|
|
183
|
-
defaultTools = [];
|
|
184
|
-
// Doom loop detection cache (per-agent for isolation)
|
|
185
|
-
doomLoopCaches = new Map();
|
|
186
|
-
/** ConfigComponent 用于配置管理 */
|
|
187
|
-
configComponent;
|
|
188
|
-
/** 配置变更 watcher 清理函数 */
|
|
189
|
-
configWatcher;
|
|
190
|
-
/** Session 消息转换器 */
|
|
191
|
-
messageConverter = new SessionMessageConverter();
|
|
192
|
-
/** 构造函数传入的配置(最高优先级) */
|
|
193
|
-
_constructorConfig;
|
|
194
|
-
/** Run ID 计数器(用于生成唯一的 runId) */
|
|
195
|
-
runCounter = 0;
|
|
196
|
-
constructor(options = {}) {
|
|
197
|
-
super();
|
|
198
|
-
// 保存构造函数传入的配置(最高优先级)
|
|
199
|
-
this._constructorConfig = options.config;
|
|
200
|
-
this.config = {
|
|
201
|
-
defaultAgent: {
|
|
202
|
-
...DEFAULT_AGENT_CONFIG,
|
|
203
|
-
...options.config?.defaultAgent,
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* 初始化组件
|
|
209
|
-
*
|
|
210
|
-
* 配置加载优先级(从高到低):
|
|
211
|
-
* 1. Object - 直接传入的 config 对象
|
|
212
|
-
* 2. Env - 环境变量(通过 envPrefix 配置前缀)
|
|
213
|
-
* 3. File - 配置文件(通过 configPath 指定)
|
|
214
|
-
*/
|
|
215
|
-
async init(config) {
|
|
216
|
-
// 调用基类 init,注入 env
|
|
217
|
-
await super.init(config);
|
|
218
|
-
// 从 options 获取 ConfigComponent
|
|
219
|
-
const options = config.options;
|
|
220
|
-
if (!options?.configComponent) {
|
|
221
|
-
throw new Error("ConfigComponent is required for AgentComponent initialization");
|
|
222
|
-
}
|
|
223
|
-
this.configComponent = options.configComponent;
|
|
224
|
-
await this.registerConfig(options);
|
|
225
|
-
this.setStatus("running");
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* 注册配置到 ConfigComponent
|
|
229
|
-
*
|
|
230
|
-
* 配置加载顺序(优先级从低到高):
|
|
231
|
-
* 1. Defaults - 默认值(最低)
|
|
232
|
-
* 2. FileSource - 从配置文件加载
|
|
233
|
-
* 3. EnvSource - 从环境变量加载
|
|
234
|
-
* 4. config 对象 - 直接传入的配置(最高)
|
|
235
|
-
*/
|
|
236
|
-
async registerConfig(options) {
|
|
237
|
-
const configComponent = options.configComponent;
|
|
238
|
-
if (!configComponent)
|
|
239
|
-
return;
|
|
240
|
-
const { configPath, envPrefix, config } = options;
|
|
241
|
-
const prefix = envPrefix ?? "AGENT";
|
|
242
|
-
// 1. 使用 registerComponent 注册配置结构(keys 和 sources,不含 defaults)
|
|
243
|
-
configComponent.registerComponent(AGENT_CONFIG_REGISTRATION);
|
|
244
|
-
// 2. 注册 FileSource(如果提供了 configPath)
|
|
245
|
-
if (configPath) {
|
|
246
|
-
configComponent.registerSource({
|
|
247
|
-
type: "file",
|
|
248
|
-
relativePath: configPath,
|
|
249
|
-
optional: true,
|
|
250
|
-
watch: false
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
// 3. 注册 EnvSource
|
|
254
|
-
configComponent.registerSource({
|
|
255
|
-
type: "env",
|
|
256
|
-
envPrefix: prefix,
|
|
257
|
-
priority: 20,
|
|
258
|
-
watch: false
|
|
259
|
-
});
|
|
260
|
-
// 4. 从 sources 加载配置(FileSource 和 EnvSource)
|
|
261
|
-
await configComponent.load("agent");
|
|
262
|
-
// 5. 后备方案:直接读取环境变量(确保所有环境变量都被处理)
|
|
263
|
-
for (const envKey of Object.keys(process.env)) {
|
|
264
|
-
const configKey = envKeyToConfigKey(envKey, prefix, "agent");
|
|
265
|
-
if (!configKey)
|
|
266
|
-
continue;
|
|
267
|
-
const value = process.env[envKey];
|
|
268
|
-
if (value !== undefined) {
|
|
269
|
-
await configComponent.set(configKey, value);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
// 6. 设置默认值(只有当配置不存在时)
|
|
273
|
-
for (const [key, value] of Object.entries(AGENT_DEFAULTS)) {
|
|
274
|
-
if (configComponent.get(key) === undefined) {
|
|
275
|
-
await configComponent.set(key, value);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
// 7. 直接配置对象(最高优先级)
|
|
279
|
-
if (config) {
|
|
280
|
-
const flatConfig = this.flattenConfig(config);
|
|
281
|
-
for (const [key, value] of Object.entries(flatConfig)) {
|
|
282
|
-
await configComponent.set(key, value);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
// 8. 从 ConfigComponent 同步配置到 this.config
|
|
286
|
-
// 重要:配置文件/环境变量的值必须同步回实例配置,供 registerAgent() 使用
|
|
287
|
-
// 注意:构造函数传入的配置优先级最高
|
|
288
|
-
const constructorDefaultAgent = this._constructorConfig?.defaultAgent;
|
|
289
|
-
// 从 ConfigComponent 读取值,并设置默认值
|
|
290
|
-
// 构造函数传入的值优先级最高,会覆盖从 ConfigComponent 读取的值
|
|
291
|
-
this.config.defaultAgent = {
|
|
292
|
-
maxIterations: constructorDefaultAgent?.maxIterations
|
|
293
|
-
?? configComponent.get("agent.defaultAgent.maxIterations")
|
|
294
|
-
?? 200,
|
|
295
|
-
maxErrorRetries: constructorDefaultAgent?.maxErrorRetries
|
|
296
|
-
?? configComponent.get("agent.defaultAgent.maxErrorRetries")
|
|
297
|
-
?? 3,
|
|
298
|
-
doomLoopThreshold: constructorDefaultAgent?.doomLoopThreshold
|
|
299
|
-
?? configComponent.get("agent.defaultAgent.doomLoopThreshold")
|
|
300
|
-
?? 5,
|
|
301
|
-
toolTimeout: constructorDefaultAgent?.toolTimeout
|
|
302
|
-
?? configComponent.get("agent.defaultAgent.toolTimeout")
|
|
303
|
-
?? 60000,
|
|
304
|
-
toolRetries: constructorDefaultAgent?.toolRetries
|
|
305
|
-
?? configComponent.get("agent.defaultAgent.toolRetries")
|
|
306
|
-
?? 3,
|
|
307
|
-
filterHistory: constructorDefaultAgent?.filterHistory
|
|
308
|
-
?? configComponent.get("agent.defaultAgent.filterHistory")
|
|
309
|
-
?? false,
|
|
310
|
-
type: constructorDefaultAgent?.type
|
|
311
|
-
?? configComponent.get("agent.defaultAgent.type")
|
|
312
|
-
?? "primary",
|
|
313
|
-
systemPrompt: constructorDefaultAgent?.systemPrompt
|
|
314
|
-
?? configComponent.get("agent.defaultAgent.systemPrompt"),
|
|
315
|
-
model: constructorDefaultAgent?.model
|
|
316
|
-
?? configComponent.get("agent.defaultAgent.model"),
|
|
317
|
-
behaviorSpecId: constructorDefaultAgent?.behaviorSpecId
|
|
318
|
-
?? configComponent.get("agent.defaultAgent.behaviorSpecId"),
|
|
319
|
-
};
|
|
320
|
-
logger.info(`[registerConfig] Synced config from ConfigComponent: maxIterations=${this.config.defaultAgent.maxIterations}`);
|
|
321
|
-
// 9. 注册配置热更新监听
|
|
322
|
-
this.registerConfigWatcher(configComponent);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* 将配置对象展平为点号路径
|
|
326
|
-
*/
|
|
327
|
-
flattenConfig(obj, prefix = "agent") {
|
|
328
|
-
const result = {};
|
|
329
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
330
|
-
const fullKey = `${prefix}.${key}`;
|
|
331
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
332
|
-
Object.assign(result, this.flattenConfig(value, fullKey));
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
result[fullKey] = value;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return result;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* 注册配置热更新监听
|
|
342
|
-
*/
|
|
343
|
-
registerConfigWatcher(configComponent) {
|
|
344
|
-
if (typeof configComponent.watch !== "function") {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
this.configWatcher = configComponent.watch("agent.*", (event) => {
|
|
348
|
-
this.onConfigChange(event);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* 处理配置变更
|
|
353
|
-
*/
|
|
354
|
-
onConfigChange(event) {
|
|
355
|
-
logger.info(`Agent config changed: ${event.key}`, {
|
|
356
|
-
oldValue: event.oldValue,
|
|
357
|
-
newValue: event.newValue
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* 组件停止时的清理逻辑
|
|
362
|
-
*
|
|
363
|
-
* 清理内容:
|
|
364
|
-
* 1. 终止所有正在运行的 Agent(调用 abort() 以中断 LLM 调用)
|
|
365
|
-
* 2. 清空 AbortController 注册表
|
|
366
|
-
* 3. 清空 Doom Loop 缓存
|
|
367
|
-
* 4. 取消配置变更监听
|
|
368
|
-
* 5. 清空 Agent 注册表
|
|
369
|
-
*/
|
|
370
|
-
async onStop() {
|
|
371
|
-
logger.info("[AgentComponent] Stopping and cleaning up resources...");
|
|
372
|
-
// 1. 终止所有正在运行的 Agent(调用 abort() 以中断 LLM 调用)
|
|
373
|
-
for (const [name, agent] of this.agents) {
|
|
374
|
-
if (agent.status === "running" || agent.status === "idle") {
|
|
375
|
-
// 调用 abort() 方法会触发 AbortController.abort(),从而中断正在进行的 LLM 调用
|
|
376
|
-
this.abort(name);
|
|
377
|
-
logger.debug(`[AgentComponent] Aborted agent: ${name}`);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
// 2. 清空 AbortController 注册表
|
|
381
|
-
this.abortControllers.clear();
|
|
382
|
-
// 3. 清空 Doom Loop 缓存
|
|
383
|
-
this.doomLoopCaches.clear();
|
|
384
|
-
// 4. 取消配置变更监听
|
|
385
|
-
if (this.configWatcher) {
|
|
386
|
-
this.configWatcher();
|
|
387
|
-
this.configWatcher = undefined;
|
|
388
|
-
}
|
|
389
|
-
// 5. 清空 Agent 注册表
|
|
390
|
-
this.agents.clear();
|
|
391
|
-
this.setStatus("stopped");
|
|
392
|
-
logger.info("[AgentComponent] Cleanup completed");
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* 刷新依赖组件引用
|
|
396
|
-
*
|
|
397
|
-
* 当组件被添加到 Environment 后调用,以确保获取到最新的组件引用
|
|
398
|
-
*/
|
|
399
|
-
refreshDependencies() {
|
|
400
|
-
if (this.env) {
|
|
401
|
-
const llm = this.env.getComponent("llm");
|
|
402
|
-
const tool = this.env.getComponent("tool");
|
|
403
|
-
this.llmComponent = llm ? llm : null;
|
|
404
|
-
this.toolComponent = tool ? tool : null;
|
|
405
|
-
logger.debug("[refreshDependencies] AgentComponent refreshed", {
|
|
406
|
-
hasLLM: !!this.llmComponent,
|
|
407
|
-
hasTool: !!this.toolComponent,
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* 获取 Agent 实例
|
|
413
|
-
*/
|
|
414
|
-
getAgent(agentName) {
|
|
415
|
-
return this.agents.get(agentName);
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* 获取所有 Agent 实例
|
|
419
|
-
*/
|
|
420
|
-
listAgents() {
|
|
421
|
-
return Array.from(this.agents.values());
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Add placeholder tool results for remaining unprocessed tool calls
|
|
425
|
-
*
|
|
426
|
-
* This ensures that the message history maintains a 1:1 correspondence
|
|
427
|
-
* between tool-calls and tool-results, which is required by AI SDK v6.
|
|
428
|
-
*
|
|
429
|
-
* @param ctx - Hook context containing messages
|
|
430
|
-
* @param allToolCalls - All tool calls from the LLM response
|
|
431
|
-
* @param processedCount - Number of tool calls that have been processed
|
|
432
|
-
* @param reason - Reason for the abort/interruption
|
|
433
|
-
*/
|
|
434
|
-
addRemainingToolResults(ctx, allToolCalls, processedCount, reason) {
|
|
435
|
-
const remainingToolCalls = allToolCalls.slice(processedCount);
|
|
436
|
-
for (const tc of remainingToolCalls) {
|
|
437
|
-
const tcName = tc.function?.name || tc.name || "unknown";
|
|
438
|
-
this.pushMessage(ctx, {
|
|
439
|
-
role: "tool",
|
|
440
|
-
content: [{
|
|
441
|
-
type: "tool-result",
|
|
442
|
-
toolCallId: tc.id,
|
|
443
|
-
toolName: tcName,
|
|
444
|
-
output: JSON.stringify({ error: reason }),
|
|
445
|
-
}],
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* 注册 Agent
|
|
451
|
-
*
|
|
452
|
-
* 配置优先级(从高到低):
|
|
453
|
-
* 1. registerAgent 传入的 config(来自 PromptComponent)
|
|
454
|
-
* 2. defaultAgent 配置(来自 ConfigComponent,作为 fallback)
|
|
455
|
-
*/
|
|
456
|
-
registerAgent(name, config) {
|
|
457
|
-
// 合并配置:defaultAgent 填充默认值,传入的 config 覆盖
|
|
458
|
-
// 注意:需要显式设置每个字段,避免 spread 操作导致默认值被覆盖的问题
|
|
459
|
-
const mergedConfig = {
|
|
460
|
-
// 基础字段
|
|
461
|
-
type: config.type ?? this.config.defaultAgent.type,
|
|
462
|
-
name,
|
|
463
|
-
// 数值类型字段(显式设置以避免被覆盖)
|
|
464
|
-
maxIterations: config.maxIterations ?? this.config.defaultAgent.maxIterations,
|
|
465
|
-
maxErrorRetries: config.maxErrorRetries ?? this.config.defaultAgent.maxErrorRetries,
|
|
466
|
-
doomLoopThreshold: config.doomLoopThreshold ?? this.config.defaultAgent.doomLoopThreshold,
|
|
467
|
-
toolTimeout: config.toolTimeout ?? this.config.defaultAgent.toolTimeout,
|
|
468
|
-
toolRetries: config.toolRetries ?? this.config.defaultAgent.toolRetries,
|
|
469
|
-
// 字符串类型字段
|
|
470
|
-
systemPrompt: config.systemPrompt ?? this.config.defaultAgent.systemPrompt,
|
|
471
|
-
model: config.model ?? this.config.defaultAgent.model,
|
|
472
|
-
behaviorSpecId: config.behaviorSpecId ?? this.config.defaultAgent.behaviorSpecId,
|
|
473
|
-
// 工具过滤字段
|
|
474
|
-
allowedTools: config.allowedTools ?? this.config.defaultAgent.allowedTools,
|
|
475
|
-
deniedTools: config.deniedTools ?? this.config.defaultAgent.deniedTools,
|
|
476
|
-
// History 过滤字段
|
|
477
|
-
filterHistory: config.filterHistory ?? this.config.defaultAgent.filterHistory,
|
|
478
|
-
};
|
|
479
|
-
const instance = {
|
|
480
|
-
name,
|
|
481
|
-
config: mergedConfig,
|
|
482
|
-
status: "idle",
|
|
483
|
-
plugins: new Map(),
|
|
484
|
-
};
|
|
485
|
-
this.agents.set(name, instance);
|
|
486
|
-
logger.info(`Agent registered: ${name}`, { type: instance.config.type });
|
|
487
|
-
return instance;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* 注销 Agent
|
|
491
|
-
*/
|
|
492
|
-
unregisterAgent(name) {
|
|
493
|
-
const deleted = this.agents.delete(name);
|
|
494
|
-
if (deleted) {
|
|
495
|
-
logger.info(`Agent unregistered: ${name}`);
|
|
496
|
-
}
|
|
497
|
-
return deleted;
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* 注册 Plugin 到指定 Agent
|
|
501
|
-
*/
|
|
502
|
-
registerPlugin(agentName, plugin) {
|
|
503
|
-
const agent = this.agents.get(agentName);
|
|
504
|
-
if (!agent) {
|
|
505
|
-
throw new Error(`Agent not found: ${agentName}`);
|
|
506
|
-
}
|
|
507
|
-
agent.plugins.set(plugin.name, plugin);
|
|
508
|
-
logger.info(`Plugin registered: ${plugin.name} to ${agentName}`, {
|
|
509
|
-
hooks: plugin.hooks.map(h => h.point),
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* 注销 Plugin
|
|
514
|
-
*/
|
|
515
|
-
unregisterPlugin(agentName, pluginName) {
|
|
516
|
-
const agent = this.agents.get(agentName);
|
|
517
|
-
if (!agent) {
|
|
518
|
-
return false;
|
|
519
|
-
}
|
|
520
|
-
const deleted = agent.plugins.delete(pluginName);
|
|
521
|
-
if (deleted) {
|
|
522
|
-
logger.info(`Plugin unregistered: ${pluginName} from ${agentName}`);
|
|
523
|
-
}
|
|
524
|
-
return deleted;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* 设置默认工具列表
|
|
528
|
-
*/
|
|
529
|
-
setDefaultTools(tools) {
|
|
530
|
-
this.defaultTools = tools;
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* 获取可用工具
|
|
534
|
-
*/
|
|
535
|
-
getAvailableTools(agent, context) {
|
|
536
|
-
// 首先添加 defaultTools(来自 setDefaultTools 的 Memory Agent tools)
|
|
537
|
-
let tools = [...this.defaultTools];
|
|
538
|
-
logger.debug(`[getAvailableTools] After defaultTools: ${tools.length} tools`, {
|
|
539
|
-
toolNames: tools.map(t => t.name)
|
|
540
|
-
});
|
|
541
|
-
// 如果有 ToolComponent,从组件获取
|
|
542
|
-
if (this.toolComponent?.listTools) {
|
|
543
|
-
// 类型转换:ToolComponent 的 Tool 与 AgentComponent 的 Tool 兼容
|
|
544
|
-
const componentTools = this.toolComponent.listTools();
|
|
545
|
-
tools = [...tools, ...componentTools];
|
|
546
|
-
logger.debug(`[getAvailableTools] After adding componentTools: ${tools.length} tools`, {
|
|
547
|
-
componentToolNames: componentTools.map(t => t.name)
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
// 获取工具过滤配置(context 优先于 agent 配置)
|
|
551
|
-
const allowedTools = context?.allowedTools ?? agent.config.allowedTools;
|
|
552
|
-
const deniedTools = context?.deniedTools ?? agent.config.deniedTools;
|
|
553
|
-
logger.debug(`[getAvailableTools] Filtering: allowed=${allowedTools}, denied=${deniedTools}`);
|
|
554
|
-
// 应用 allowedTools 过滤
|
|
555
|
-
if (allowedTools?.length) {
|
|
556
|
-
tools = tools.filter(t => allowedTools.includes(t.name));
|
|
557
|
-
logger.debug(`[getAvailableTools] After allowedTools filter: ${tools.length} tools`, {
|
|
558
|
-
toolNames: tools.map(t => t.name)
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
// 应用 deniedTools 过滤
|
|
562
|
-
if (deniedTools?.length) {
|
|
563
|
-
tools = tools.filter(t => !deniedTools.includes(t.name));
|
|
564
|
-
logger.debug(`[getAvailableTools] After deniedTools filter: ${tools.length} tools`, {
|
|
565
|
-
toolNames: tools.map(t => t.name)
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
logger.debug(`[getAvailableTools] Final tools: ${tools.length}`, {
|
|
569
|
-
toolNames: tools.map(t => t.name)
|
|
570
|
-
});
|
|
571
|
-
return tools;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* 执行 Agent
|
|
575
|
-
*
|
|
576
|
-
* @param agentName Agent 名称
|
|
577
|
-
* @param query 用户查询
|
|
578
|
-
* @param context 执行上下文
|
|
579
|
-
* @returns Agent 执行结果
|
|
580
|
-
*/
|
|
581
|
-
async run(agentName, query, context) {
|
|
582
|
-
return this._run(agentName, query, context);
|
|
583
|
-
}
|
|
584
|
-
pushMessage(hookCtx, message) {
|
|
585
|
-
hookCtx.messages.push(message);
|
|
586
|
-
this.notifyMessageAdded(message);
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* 执行 Agent(核心方法,内部实现)
|
|
590
|
-
*/
|
|
591
|
-
async _run(agentName, query, context) {
|
|
592
|
-
// 刷新依赖组件引用(确保获取到最新的组件)
|
|
593
|
-
this.refreshDependencies();
|
|
594
|
-
const agent = this.getAgent(agentName);
|
|
595
|
-
if (!agent) {
|
|
596
|
-
throw new Error(`Agent not found: ${agentName}`);
|
|
597
|
-
}
|
|
598
|
-
// 生成唯一的 runId(支持并发调用同一个 agent)
|
|
599
|
-
const runId = `${agentName}:${++this.runCounter}`;
|
|
600
|
-
logger.info(`Starting agent run: ${agentName} (runId=${runId})`, { query: query.substring(0, 100) });
|
|
601
|
-
// Mark agent as running
|
|
602
|
-
agent.status = "running";
|
|
603
|
-
this.aborted.set(runId, false);
|
|
604
|
-
// Create AbortController for this agent run
|
|
605
|
-
const abortController = new AbortController();
|
|
606
|
-
this.abortControllers.set(runId, abortController);
|
|
607
|
-
// Initialize doom loop cache for this agent
|
|
608
|
-
if (!this.doomLoopCaches.has(runId)) {
|
|
609
|
-
this.doomLoopCaches.set(runId, new Map());
|
|
610
|
-
}
|
|
611
|
-
// Merge context
|
|
612
|
-
const effectiveContext = {
|
|
613
|
-
...context,
|
|
614
|
-
agentType: agent.config.type,
|
|
615
|
-
model: agent.config.model,
|
|
616
|
-
// 设置 abort signal(支持通过 abort() 方法中断 LLM 调用)
|
|
617
|
-
abort: abortController.signal,
|
|
618
|
-
};
|
|
619
|
-
// Initialize result
|
|
620
|
-
const result = {
|
|
621
|
-
iterations: 0,
|
|
622
|
-
toolCalls: [],
|
|
623
|
-
};
|
|
624
|
-
// Create HookContext
|
|
625
|
-
const hookCtx = {
|
|
626
|
-
agent,
|
|
627
|
-
iteration: 0,
|
|
628
|
-
maxIterations: agent.config.maxIterations,
|
|
629
|
-
messages: [],
|
|
630
|
-
tools: this.getAvailableTools(agent, effectiveContext),
|
|
631
|
-
systemPrompt: agent.config.systemPrompt || "You are a helpful assistant.",
|
|
632
|
-
context: effectiveContext,
|
|
633
|
-
};
|
|
634
|
-
// Load session history messages
|
|
635
|
-
let historyMessageCount = 0;
|
|
636
|
-
if (effectiveContext.sessionId) {
|
|
637
|
-
try {
|
|
638
|
-
const sessionComponent = this.env.getComponent("session");
|
|
639
|
-
if (sessionComponent) {
|
|
640
|
-
// Get conversation history starting from the N-th latest user message
|
|
641
|
-
// This ensures we have complete conversation context
|
|
642
|
-
// Determine filterHistory: context > agent config > default (false)
|
|
643
|
-
const filterHistory = effectiveContext.filterHistory ?? agent.config.filterHistory ?? false;
|
|
644
|
-
const messages = await this.getConversationHistory(sessionComponent, effectiveContext.sessionId, { minUserMessages: 100, filterHistory });
|
|
645
|
-
hookCtx.messages = messages.map(msg => this.messageConverter.toModelMessage(msg));
|
|
646
|
-
historyMessageCount = hookCtx.messages.length;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
catch (err) {
|
|
650
|
-
logger.warn(`Failed to load session history: ${err}`);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
// Send start event via env
|
|
654
|
-
this.pushEnvEvent({
|
|
655
|
-
type: "agent.start",
|
|
656
|
-
payload: {
|
|
657
|
-
sessionId: effectiveContext.sessionId,
|
|
658
|
-
model: effectiveContext.model,
|
|
659
|
-
},
|
|
660
|
-
});
|
|
661
|
-
// Always add user query to messages
|
|
662
|
-
// History messages are already loaded above, this is the new user input
|
|
663
|
-
this.pushMessage(hookCtx, {
|
|
664
|
-
role: "user",
|
|
665
|
-
content: query,
|
|
666
|
-
});
|
|
667
|
-
// before.start hook
|
|
668
|
-
await this.executePluginHooks(agent, "agent:before.start", hookCtx);
|
|
669
|
-
if (hookCtx._stopped) {
|
|
670
|
-
return this.finalizeResult(result, hookCtx);
|
|
671
|
-
}
|
|
672
|
-
// ReAct Loop
|
|
673
|
-
let iteration = 0;
|
|
674
|
-
let finalText;
|
|
675
|
-
while (iteration < agent.config.maxIterations) {
|
|
676
|
-
// Check _stopped state (may be set by previous iteration's hooks)
|
|
677
|
-
if (hookCtx._stopped) {
|
|
678
|
-
break;
|
|
679
|
-
}
|
|
680
|
-
// Check abort
|
|
681
|
-
if (this.aborted.get(runId)) {
|
|
682
|
-
hookCtx._stopped = true;
|
|
683
|
-
hookCtx._stopReason = "aborted";
|
|
684
|
-
break;
|
|
685
|
-
}
|
|
686
|
-
// Check abort signal
|
|
687
|
-
if (effectiveContext.abort?.aborted) {
|
|
688
|
-
hookCtx._stopped = true;
|
|
689
|
-
hookCtx._stopReason = "abort_signal";
|
|
690
|
-
break;
|
|
691
|
-
}
|
|
692
|
-
iteration++;
|
|
693
|
-
hookCtx.iteration = iteration;
|
|
694
|
-
result.iterations = iteration;
|
|
695
|
-
logger.debug(`Iteration ${iteration} started`);
|
|
696
|
-
// Reset doom loop cache at the start of each iteration
|
|
697
|
-
// Doom loop detection should only apply within a single LLM response cycle
|
|
698
|
-
this.doomLoopCaches.set(runId, new Map());
|
|
699
|
-
// 设置迭代信息,供 before.llm hook 使用(如 ReminderPlugin)
|
|
700
|
-
hookCtx.maxIterations = agent.config.maxIterations;
|
|
701
|
-
try {
|
|
702
|
-
// 记录消息构建结果
|
|
703
|
-
logger.debug(`[ReAct] Iteration ${iteration} buildMessages result: ${hookCtx.messages.length} messages`);
|
|
704
|
-
// before.llm hook
|
|
705
|
-
await this.executePluginHooks(agent, "agent:before.llm", hookCtx);
|
|
706
|
-
if (hookCtx._stopped)
|
|
707
|
-
break;
|
|
708
|
-
// Call LLM
|
|
709
|
-
const llmOutput = await this.invokeLLM(hookCtx);
|
|
710
|
-
hookCtx.llmOutput = llmOutput;
|
|
711
|
-
// Check abort after LLM call (important: abort might have interrupted the call)
|
|
712
|
-
if (this.aborted.get(runId) || effectiveContext.abort?.aborted) {
|
|
713
|
-
hookCtx._stopped = true;
|
|
714
|
-
hookCtx._stopReason = "aborted";
|
|
715
|
-
break;
|
|
716
|
-
}
|
|
717
|
-
// after.llm hook
|
|
718
|
-
await this.executePluginHooks(agent, "agent:after.llm", hookCtx);
|
|
719
|
-
if (hookCtx._stopped)
|
|
720
|
-
break;
|
|
721
|
-
// Process LLM output
|
|
722
|
-
if (llmOutput.content && !llmOutput.toolCalls?.length) {
|
|
723
|
-
// Text response - complete
|
|
724
|
-
// Check abort before adding message and breaking
|
|
725
|
-
if (this.aborted.get(runId) || effectiveContext.abort?.aborted) {
|
|
726
|
-
hookCtx._stopped = true;
|
|
727
|
-
hookCtx._stopReason = "aborted";
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
finalText = llmOutput.content;
|
|
731
|
-
this.pushMessage(hookCtx, {
|
|
732
|
-
role: "assistant",
|
|
733
|
-
content: llmOutput.content,
|
|
734
|
-
});
|
|
735
|
-
break;
|
|
736
|
-
}
|
|
737
|
-
if (llmOutput.toolCalls?.length) {
|
|
738
|
-
// Add assistant message with tool calls to messages (CRITICAL: must be before tool results)
|
|
739
|
-
// AI SDK v6 format: assistant message with content array containing text/reasoning/tool-call parts
|
|
740
|
-
// Build assistant message content parts: text/reasoning + tool-call parts
|
|
741
|
-
const assistantParts = [];
|
|
742
|
-
// 1. Add text content if present
|
|
743
|
-
if (llmOutput.content) {
|
|
744
|
-
assistantParts.push({
|
|
745
|
-
type: "text",
|
|
746
|
-
text: llmOutput.content,
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
// 2. Add reasoning content if present (for reasoning models)
|
|
750
|
-
if (llmOutput.reasoning) {
|
|
751
|
-
assistantParts.push({
|
|
752
|
-
type: "reasoning",
|
|
753
|
-
text: llmOutput.reasoning,
|
|
754
|
-
reasoningType: "core",
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
// 3. Add tool-call parts
|
|
758
|
-
for (const tc of llmOutput.toolCalls) {
|
|
759
|
-
let argsStr = "";
|
|
760
|
-
let argsObj = {};
|
|
761
|
-
// 提取参数:优先从 function.arguments 获取
|
|
762
|
-
if (tc.function?.arguments) {
|
|
763
|
-
if (typeof tc.function.arguments === "string") {
|
|
764
|
-
argsStr = tc.function.arguments;
|
|
765
|
-
try {
|
|
766
|
-
argsObj = JSON.parse(argsStr);
|
|
767
|
-
}
|
|
768
|
-
catch {
|
|
769
|
-
argsObj = { _raw: argsStr };
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
else {
|
|
773
|
-
argsObj = tc.function.arguments;
|
|
774
|
-
argsStr = JSON.stringify(argsObj);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
else if (tc.arguments) {
|
|
778
|
-
if (typeof tc.arguments === "string") {
|
|
779
|
-
argsStr = tc.arguments;
|
|
780
|
-
try {
|
|
781
|
-
argsObj = JSON.parse(argsStr);
|
|
782
|
-
}
|
|
783
|
-
catch {
|
|
784
|
-
argsObj = { _raw: argsStr };
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
argsObj = tc.arguments;
|
|
789
|
-
argsStr = JSON.stringify(argsObj);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
assistantParts.push({
|
|
793
|
-
type: "tool-call",
|
|
794
|
-
toolCallId: tc.id,
|
|
795
|
-
toolName: tc.function?.name || tc.name || "unknown",
|
|
796
|
-
// 关键修复:添加 input 字段供 session-message-converter 读取和存储
|
|
797
|
-
input: argsObj,
|
|
798
|
-
// 保留 toolCall 以兼容某些依赖此结构的代码
|
|
799
|
-
toolCall: {
|
|
800
|
-
name: tc.function?.name || tc.name || "unknown",
|
|
801
|
-
arguments: argsStr,
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
// 记录添加 assistant 消息
|
|
806
|
-
const assistantContent = llmOutput.content?.substring(0, 80) || "(no text)";
|
|
807
|
-
const toolCallNames = llmOutput.toolCalls?.map(tc => tc.function?.name || tc.name).join(", ") || "none";
|
|
808
|
-
logger.debug(`[ReAct] Iteration ${iteration} Adding assistant message: text="${assistantContent}" toolCalls=[${toolCallNames}]`);
|
|
809
|
-
this.pushMessage(hookCtx, {
|
|
810
|
-
role: "assistant",
|
|
811
|
-
content: assistantParts,
|
|
812
|
-
});
|
|
813
|
-
// Tool calls
|
|
814
|
-
const allToolCalls = llmOutput.toolCalls;
|
|
815
|
-
let processedCount = 0; // Track number of successfully processed tool calls
|
|
816
|
-
for (const toolCall of allToolCalls) {
|
|
817
|
-
// Check abort before tool execution
|
|
818
|
-
if (this.aborted.get(runId) || effectiveContext.abort?.aborted) {
|
|
819
|
-
hookCtx._stopped = true;
|
|
820
|
-
hookCtx._stopReason = "aborted";
|
|
821
|
-
// Add placeholder results for remaining unprocessed tool calls
|
|
822
|
-
this.addRemainingToolResults(hookCtx, allToolCalls, processedCount, "Execution aborted");
|
|
823
|
-
break;
|
|
824
|
-
}
|
|
825
|
-
// 优先使用 function.name,兼容旧格式
|
|
826
|
-
const func = toolCall.function;
|
|
827
|
-
const tcName = func?.name || toolCall.name || "unknown";
|
|
828
|
-
const tcArgs = func?.arguments
|
|
829
|
-
? (typeof func.arguments === "string" ? JSON.parse(func.arguments) : func.arguments)
|
|
830
|
-
: toolCall.arguments;
|
|
831
|
-
hookCtx.currentToolCall = {
|
|
832
|
-
id: toolCall.id,
|
|
833
|
-
name: tcName,
|
|
834
|
-
arguments: tcArgs,
|
|
835
|
-
};
|
|
836
|
-
// Doom loop detection
|
|
837
|
-
const doomKey = `${tcName}:${JSON.stringify(tcArgs)}`;
|
|
838
|
-
const agentCache = this.doomLoopCaches.get(runId) || new Map();
|
|
839
|
-
const doomCount = agentCache.get(doomKey) || 0;
|
|
840
|
-
if (doomCount >= agent.config.doomLoopThreshold) {
|
|
841
|
-
hookCtx.error = new Error(`Doom loop detected: ${tcName}`);
|
|
842
|
-
await this.executePluginHooks(agent, "on.error", hookCtx);
|
|
843
|
-
result.error = hookCtx.error.message;
|
|
844
|
-
// Add placeholder results for remaining unprocessed tool calls
|
|
845
|
-
this.addRemainingToolResults(hookCtx, allToolCalls, processedCount, "Execution aborted: Doom loop detected");
|
|
846
|
-
break;
|
|
847
|
-
}
|
|
848
|
-
agentCache.set(doomKey, doomCount + 1);
|
|
849
|
-
this.doomLoopCaches.set(runId, agentCache);
|
|
850
|
-
// before.tool hook
|
|
851
|
-
await this.executePluginHooks(agent, "agent:before.tool", hookCtx);
|
|
852
|
-
if (hookCtx._stopped) {
|
|
853
|
-
// Add placeholder results for remaining unprocessed tool calls
|
|
854
|
-
this.addRemainingToolResults(hookCtx, allToolCalls, processedCount, "Execution aborted by plugin hook");
|
|
855
|
-
break;
|
|
856
|
-
}
|
|
857
|
-
// Execute tool
|
|
858
|
-
const toolResult = await this.executeTool(hookCtx);
|
|
859
|
-
hookCtx.toolResult = toolResult;
|
|
860
|
-
// after.tool hook
|
|
861
|
-
await this.executePluginHooks(agent, "agent:after.tool", hookCtx);
|
|
862
|
-
if (hookCtx._stopped) {
|
|
863
|
-
// Add placeholder results for remaining unprocessed tool calls
|
|
864
|
-
this.addRemainingToolResults(hookCtx, allToolCalls, processedCount + 1, "Execution aborted by plugin hook");
|
|
865
|
-
break;
|
|
866
|
-
}
|
|
867
|
-
// Add tool result to messages (AI SDK v6 format)
|
|
868
|
-
const toolOutput = toolResult.success ? toolResult.result.output || "" : toolResult.result.error || "Unknown error";
|
|
869
|
-
const toolOutputPreview = typeof toolOutput === "string" ? toolOutput.substring(0, 50) : JSON.stringify(toolOutput).substring(0, 50);
|
|
870
|
-
logger.debug(`[ReAct] Iteration ${iteration} Adding tool message: tool=${toolResult.name} output="${toolOutputPreview}..."`);
|
|
871
|
-
this.pushMessage(hookCtx, {
|
|
872
|
-
role: "tool",
|
|
873
|
-
content: [{
|
|
874
|
-
type: "tool-result",
|
|
875
|
-
toolCallId: hookCtx.currentToolCall.id,
|
|
876
|
-
toolName: toolResult.name,
|
|
877
|
-
output: toolOutput,
|
|
878
|
-
}],
|
|
879
|
-
});
|
|
880
|
-
// Record tool call
|
|
881
|
-
result.toolCalls.push(hookCtx.currentToolCall);
|
|
882
|
-
processedCount++;
|
|
883
|
-
}
|
|
884
|
-
// on.iteration hook
|
|
885
|
-
await this.executePluginHooks(agent, "agent:on.iteration", hookCtx);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
catch (error) {
|
|
889
|
-
logger.error(`Iteration ${iteration} error`, { error });
|
|
890
|
-
hookCtx.error = error instanceof Error ? error : new Error(String(error));
|
|
891
|
-
await this.executePluginHooks(agent, "agent:on.error", hookCtx);
|
|
892
|
-
// 设置 _stopped 标志(如果还没有被设置)
|
|
893
|
-
if (!hookCtx._stopped) {
|
|
894
|
-
hookCtx._stopped = true;
|
|
895
|
-
// 如果是 AskUserError,特殊处理
|
|
896
|
-
if (error instanceof AskUserError) {
|
|
897
|
-
hookCtx._stopReason = "ask-user";
|
|
898
|
-
// ✅ 关键修复:当 ask_user 抛出异常时,也需要添加 tool result 消息
|
|
899
|
-
// 这样可以保证 session 中有完整的 tool-call + tool-result 配对
|
|
900
|
-
// Resume 时可以用用户响应替换这个 tool result
|
|
901
|
-
if (hookCtx.currentToolCall) {
|
|
902
|
-
this.pushMessage(hookCtx, {
|
|
903
|
-
role: "tool",
|
|
904
|
-
content: [{
|
|
905
|
-
type: "tool-result",
|
|
906
|
-
toolCallId: hookCtx.currentToolCall.id,
|
|
907
|
-
toolName: "ask_user",
|
|
908
|
-
output: JSON.stringify({
|
|
909
|
-
error: "AskUserError",
|
|
910
|
-
query: error.query,
|
|
911
|
-
message: error.message,
|
|
912
|
-
}),
|
|
913
|
-
}],
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
// 将 AskUserError 信息编码到 result.error 中,供 AgentComponentAdapter 检测和恢复抛出
|
|
917
|
-
// 使用 JSON 编码避免 query 中包含冒号导致解析错误
|
|
918
|
-
const errorInfo = {
|
|
919
|
-
query: error.query,
|
|
920
|
-
sessionId: error.sessionId,
|
|
921
|
-
nodeId: error.nodeId,
|
|
922
|
-
nodeType: error.nodeType,
|
|
923
|
-
};
|
|
924
|
-
result.error = `__ASK_USER_ERROR__:${JSON.stringify(errorInfo)}`;
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
// 其他错误 - 也需要添加 tool result 消息保持配对完整
|
|
928
|
-
result.error = hookCtx.error.message;
|
|
929
|
-
// 如果是 AbortError,保留 abort 相关的 reason
|
|
930
|
-
if (error?.name === "AbortError") {
|
|
931
|
-
hookCtx._stopReason = hookCtx._stopReason || "aborted";
|
|
932
|
-
}
|
|
933
|
-
else {
|
|
934
|
-
hookCtx._stopReason = "error";
|
|
935
|
-
}
|
|
936
|
-
// ✅ 添加 tool result 消息(包含错误信息)
|
|
937
|
-
if (hookCtx.currentToolCall) {
|
|
938
|
-
this.pushMessage(hookCtx, {
|
|
939
|
-
role: "tool",
|
|
940
|
-
content: [{
|
|
941
|
-
type: "tool-result",
|
|
942
|
-
toolCallId: hookCtx.currentToolCall.id,
|
|
943
|
-
toolName: hookCtx.currentToolCall.name,
|
|
944
|
-
output: JSON.stringify({ error: hookCtx.error.message }),
|
|
945
|
-
}],
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
// 如果 _stopped 已经被设置为 true(例如在 executeTool 中),保留错误信息
|
|
952
|
-
result.error = hookCtx.error.message;
|
|
953
|
-
// ✅ 即使 _stopped 已为 true,也需要添加 tool result 消息
|
|
954
|
-
// 这确保即使在 abort/doom-loop 等场景下,消息配对也是完整的
|
|
955
|
-
if (hookCtx.currentToolCall) {
|
|
956
|
-
const errorMsg = hookCtx.error?.message || "Execution interrupted";
|
|
957
|
-
this.pushMessage(hookCtx, {
|
|
958
|
-
role: "tool",
|
|
959
|
-
content: [{
|
|
960
|
-
type: "tool-result",
|
|
961
|
-
toolCallId: hookCtx.currentToolCall.id,
|
|
962
|
-
toolName: hookCtx.currentToolCall.name,
|
|
963
|
-
output: JSON.stringify({ error: errorMsg }),
|
|
964
|
-
}],
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
break;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
// Update result
|
|
972
|
-
result.finalText = finalText;
|
|
973
|
-
if (iteration >= agent.config.maxIterations && !result.finalText) {
|
|
974
|
-
result.finalText = "Maximum iterations reached.";
|
|
975
|
-
}
|
|
976
|
-
// ✅ agent:after.react hook - React 循环结束后,用于记忆提取
|
|
977
|
-
// 传递 reactContext 包含 messages, sessionId, summary
|
|
978
|
-
const reactContext = {
|
|
979
|
-
messages: hookCtx.messages,
|
|
980
|
-
sessionId: effectiveContext.sessionId,
|
|
981
|
-
summary: result.finalText,
|
|
982
|
-
};
|
|
983
|
-
await this.executePluginHooks(agent, "agent:after.react", {
|
|
984
|
-
...hookCtx,
|
|
985
|
-
...reactContext,
|
|
986
|
-
});
|
|
987
|
-
// after.complete hook
|
|
988
|
-
await this.executePluginHooks(agent, "agent:after.complete", hookCtx);
|
|
989
|
-
// Finalize - 根据 abort 状态设置 agent 状态
|
|
990
|
-
if (this.aborted.get(runId) === true || hookCtx._stopped) {
|
|
991
|
-
agent.status = "stopped";
|
|
992
|
-
}
|
|
993
|
-
else {
|
|
994
|
-
agent.status = "idle";
|
|
995
|
-
}
|
|
996
|
-
this.aborted.delete(runId);
|
|
997
|
-
// 清理 AbortController
|
|
998
|
-
this.abortControllers.delete(runId);
|
|
999
|
-
// 发送 agent.completed 或 agent.error 事件
|
|
1000
|
-
if (result.error) {
|
|
1001
|
-
this.pushEnvEvent({
|
|
1002
|
-
type: "agent.error",
|
|
1003
|
-
payload: {
|
|
1004
|
-
error: result.error,
|
|
1005
|
-
iterations: result.iterations,
|
|
1006
|
-
stopReason: result.stopReason,
|
|
1007
|
-
},
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
else {
|
|
1011
|
-
this.pushEnvEvent({
|
|
1012
|
-
type: "agent.completed",
|
|
1013
|
-
payload: {
|
|
1014
|
-
finalText: result.finalText,
|
|
1015
|
-
iterations: result.iterations,
|
|
1016
|
-
stopReason: result.stopReason,
|
|
1017
|
-
},
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
let newMessages = hookCtx.messages.slice(historyMessageCount);
|
|
1021
|
-
logger.info(`Agent run completed: ${agentName}`, {
|
|
1022
|
-
iterations: result.iterations,
|
|
1023
|
-
hasError: !!result.error,
|
|
1024
|
-
hookCtxMessages: hookCtx.messages.length,
|
|
1025
|
-
historyMessageCount: historyMessageCount,
|
|
1026
|
-
sessionId: effectiveContext.sessionId,
|
|
1027
|
-
});
|
|
1028
|
-
await this.recordSessionMessages(effectiveContext.sessionId, newMessages);
|
|
1029
|
-
return this.finalizeResult(result, hookCtx);
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* 中止 Agent
|
|
1033
|
-
*
|
|
1034
|
-
* 调用此方法会:
|
|
1035
|
-
* 1. 设置 aborted 标志(用于 ReAct 循环检查)
|
|
1036
|
-
* 2. 触发 AbortController.abort()(用于中断正在进行的 LLM 调用)
|
|
1037
|
-
*
|
|
1038
|
-
* 注意:不直接修改 agent.status,由 _run() 的 finally 统一处理
|
|
1039
|
-
*/
|
|
1040
|
-
abort(agentName) {
|
|
1041
|
-
// 设置 aborted 标志 - 遍历所有该 agent 的 runId
|
|
1042
|
-
for (const key of this.aborted.keys()) {
|
|
1043
|
-
if (key.startsWith(agentName + ":")) {
|
|
1044
|
-
this.aborted.set(key, true);
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
// 触发 AbortController 中断正在进行的 LLM 调用
|
|
1048
|
-
for (const [key, controller] of this.abortControllers) {
|
|
1049
|
-
if (key.startsWith(agentName + ":")) {
|
|
1050
|
-
controller.abort();
|
|
1051
|
-
logger.debug(`[abort] AbortController.abort() called for run: ${key}`);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
logger.info(`Agent aborted: ${agentName}`);
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* 构建消息列表
|
|
1058
|
-
*
|
|
1059
|
-
* 注意:ctx.messages 已经包含了历史消息(包括 system prompt 和 user query)
|
|
1060
|
-
* 这里只需要构建当前请求的消息,不重复添加
|
|
1061
|
-
*/
|
|
1062
|
-
async buildMessages(ctx) {
|
|
1063
|
-
const messages = [];
|
|
1064
|
-
if (ctx.systemPrompt) {
|
|
1065
|
-
messages.push({
|
|
1066
|
-
role: "system",
|
|
1067
|
-
content: ctx.systemPrompt,
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
// Addition info (temporary context) - 也需要检查是否已存在
|
|
1071
|
-
if (ctx.additionInfo) {
|
|
1072
|
-
messages.push({
|
|
1073
|
-
role: "user",
|
|
1074
|
-
content: `额外信息:\n${ctx.additionInfo}`,
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
// History messages(包含之前的所有消息)
|
|
1078
|
-
messages.push(...ctx.messages);
|
|
1079
|
-
return messages;
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* 调用 LLM
|
|
1083
|
-
*
|
|
1084
|
-
* 流式事件由 LLMComponent 通过 env.pushEnvEvent() 发布
|
|
1085
|
-
*/
|
|
1086
|
-
async invokeLLM(ctx) {
|
|
1087
|
-
logger.debug("[invokeLLM] Starting LLM invocation");
|
|
1088
|
-
// 如果有 LLMComponent,使用它
|
|
1089
|
-
if (this.llmComponent?.invoke) {
|
|
1090
|
-
const messages = await this.buildMessages(ctx);
|
|
1091
|
-
const convertedMessages = messages.map(toLLMMessage);
|
|
1092
|
-
logger.debug(`[invokeLLM] Calling LLMComponent.invoke with ${convertedMessages.length} messages`);
|
|
1093
|
-
try {
|
|
1094
|
-
const result = await this.llmComponent.invoke({
|
|
1095
|
-
// 类型转换:ModelMessage[] -> LLMMessage[]
|
|
1096
|
-
messages: convertedMessages,
|
|
1097
|
-
// 类型转换:Tool[] -> ToolInfo[]
|
|
1098
|
-
// 注意:Tool.parameters 是 ZodType,需要提取其 JSON schema
|
|
1099
|
-
tools: ctx.tools.map(t => ({
|
|
1100
|
-
name: t.name,
|
|
1101
|
-
description: t.description || "",
|
|
1102
|
-
parameters: t.parameters ?? {},
|
|
1103
|
-
})),
|
|
1104
|
-
model: ctx.context.model,
|
|
1105
|
-
// 传递上下文用于事件元数据
|
|
1106
|
-
context: {
|
|
1107
|
-
sessionId: ctx.context.sessionId,
|
|
1108
|
-
messageId: ctx.context.messageId,
|
|
1109
|
-
},
|
|
1110
|
-
// 传递 abort signal 以支持 Agent 的优雅终止
|
|
1111
|
-
abortSignal: ctx.context.abort,
|
|
1112
|
-
});
|
|
1113
|
-
logger.debug("[invokeLLM] LLMComponent.invoke returned successfully");
|
|
1114
|
-
return {
|
|
1115
|
-
content: result.output?.content || "",
|
|
1116
|
-
reasoning: result.output?.reasoning,
|
|
1117
|
-
toolCalls: result.output?.toolCalls?.map((tc) => ({
|
|
1118
|
-
id: tc.id,
|
|
1119
|
-
function: tc.function ? {
|
|
1120
|
-
name: tc.function.name,
|
|
1121
|
-
arguments: typeof tc.function.arguments === "string"
|
|
1122
|
-
? tc.function.arguments
|
|
1123
|
-
: JSON.stringify(tc.function.arguments),
|
|
1124
|
-
} : undefined,
|
|
1125
|
-
name: tc.name,
|
|
1126
|
-
arguments: tc.arguments,
|
|
1127
|
-
})),
|
|
1128
|
-
finishReason: result.output?.finishReason,
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
catch (error) {
|
|
1132
|
-
logger.error("[invokeLLM] LLMComponent.invoke threw an error:", error);
|
|
1133
|
-
throw error;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
// Fallback: Mock response for testing
|
|
1137
|
-
logger.warn("[invokeLLM] No LLMComponent available, using mock");
|
|
1138
|
-
return {
|
|
1139
|
-
content: "Mock response: Hello!",
|
|
1140
|
-
finishReason: "stop",
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1143
|
-
/**
|
|
1144
|
-
* 执行工具
|
|
1145
|
-
*/
|
|
1146
|
-
async executeTool(ctx) {
|
|
1147
|
-
const toolCall = ctx.currentToolCall;
|
|
1148
|
-
// 获取工具名称:优先使用 function.name(AI SDK v6 格式),兼容 toolCall.name
|
|
1149
|
-
// AI SDK v6 格式: { id, name, function: { name, arguments } }
|
|
1150
|
-
const toolName = toolCall.function?.name || toolCall.name || "unknown";
|
|
1151
|
-
// Debug: 打印工具查找信息
|
|
1152
|
-
logger.debug(`[executeTool] Looking for tool: "${toolName}"`);
|
|
1153
|
-
logger.debug(`[executeTool] Available tools: [${ctx.tools.map(t => t.name).join(", ")}]`);
|
|
1154
|
-
// Find tool
|
|
1155
|
-
const tool = ctx.tools.find(t => t.name === toolName);
|
|
1156
|
-
if (!tool) {
|
|
1157
|
-
// 发送错误事件
|
|
1158
|
-
this.pushEnvEvent({
|
|
1159
|
-
type: "tool.error",
|
|
1160
|
-
payload: {
|
|
1161
|
-
error: `Tool not found: ${toolName}`,
|
|
1162
|
-
toolName: toolName,
|
|
1163
|
-
},
|
|
1164
|
-
});
|
|
1165
|
-
return {
|
|
1166
|
-
id: toolCall.id,
|
|
1167
|
-
name: toolName,
|
|
1168
|
-
success: false,
|
|
1169
|
-
result: {
|
|
1170
|
-
success: false,
|
|
1171
|
-
output: "",
|
|
1172
|
-
error: `Tool not found: ${toolName}`,
|
|
1173
|
-
},
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
try {
|
|
1177
|
-
// Convert AgentContext to ToolContext format
|
|
1178
|
-
// AgentContext uses sessionId (camelCase), ToolContext uses session_id (snake_case)
|
|
1179
|
-
const toolContext = {
|
|
1180
|
-
session_id: ctx.context.sessionId,
|
|
1181
|
-
message_id: ctx.context.messageId,
|
|
1182
|
-
abort: ctx.context.abort,
|
|
1183
|
-
workdir: ctx.context.metadata?.workdir,
|
|
1184
|
-
metadata: ctx.context.metadata,
|
|
1185
|
-
};
|
|
1186
|
-
// Build ToolExecuteRequest
|
|
1187
|
-
const request = {
|
|
1188
|
-
name: toolName,
|
|
1189
|
-
args: toolCall.arguments,
|
|
1190
|
-
context: toolContext,
|
|
1191
|
-
};
|
|
1192
|
-
// Use ToolComponent.execute() to trigger tool hooks
|
|
1193
|
-
// Check if we have a ToolComponent reference (via refreshDependencies)
|
|
1194
|
-
let result;
|
|
1195
|
-
if (this.toolComponent?.execute) {
|
|
1196
|
-
result = await this.toolComponent.execute(request);
|
|
1197
|
-
}
|
|
1198
|
-
else {
|
|
1199
|
-
// Fallback to direct tool execution (for backwards compatibility / testing)
|
|
1200
|
-
logger.debug(`[executeTool] No ToolComponent available, executing tool directly`);
|
|
1201
|
-
result = await tool.execute(toolCall.arguments, toolContext);
|
|
1202
|
-
}
|
|
1203
|
-
// 发送工具结果事件
|
|
1204
|
-
this.pushEnvEvent({
|
|
1205
|
-
type: "tool.result",
|
|
1206
|
-
payload: {
|
|
1207
|
-
id: toolCall.id,
|
|
1208
|
-
name: toolName,
|
|
1209
|
-
result: result,
|
|
1210
|
-
success: result.success,
|
|
1211
|
-
},
|
|
1212
|
-
});
|
|
1213
|
-
return {
|
|
1214
|
-
id: toolCall.id,
|
|
1215
|
-
name: toolName,
|
|
1216
|
-
success: result.success,
|
|
1217
|
-
result,
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
catch (error) {
|
|
1221
|
-
// 检测 AskUserError - 这是用于工作流暂停的特殊错误,需要向上传播
|
|
1222
|
-
if (error instanceof AskUserError) {
|
|
1223
|
-
throw error; // 重新抛出,让调用栈上层(AgentComponentAdapter)处理
|
|
1224
|
-
}
|
|
1225
|
-
// 发送错误事件
|
|
1226
|
-
this.pushEnvEvent({
|
|
1227
|
-
type: "tool.error",
|
|
1228
|
-
payload: {
|
|
1229
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1230
|
-
toolName: toolName,
|
|
1231
|
-
},
|
|
1232
|
-
});
|
|
1233
|
-
return {
|
|
1234
|
-
id: toolCall.id,
|
|
1235
|
-
name: toolName,
|
|
1236
|
-
success: false,
|
|
1237
|
-
result: {
|
|
1238
|
-
success: false,
|
|
1239
|
-
output: "",
|
|
1240
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1241
|
-
},
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
/**
|
|
1246
|
-
* 执行 Plugin Hooks (Agent 特有的 Hook 执行机制)
|
|
1247
|
-
*/
|
|
1248
|
-
async executePluginHooks(agent, point, ctx) {
|
|
1249
|
-
// Collect all hooks for this point
|
|
1250
|
-
const hooks = [];
|
|
1251
|
-
for (const [name, plugin] of agent.plugins) {
|
|
1252
|
-
for (const hook of plugin.hooks) {
|
|
1253
|
-
if (hook.point === point) {
|
|
1254
|
-
hooks.push({
|
|
1255
|
-
plugin,
|
|
1256
|
-
priority: hook.priority ?? 0,
|
|
1257
|
-
execute: plugin.execute,
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
// Sort by priority (higher first)
|
|
1263
|
-
hooks.sort((a, b) => b.priority - a.priority);
|
|
1264
|
-
// Execute hooks
|
|
1265
|
-
for (const { plugin, execute } of hooks) {
|
|
1266
|
-
try {
|
|
1267
|
-
const result = await execute(ctx);
|
|
1268
|
-
if (!result.continue) {
|
|
1269
|
-
ctx._stopped = true;
|
|
1270
|
-
ctx._stopReason = `Plugin ${plugin.name} stopped execution`;
|
|
1271
|
-
logger.info(`Hook ${point} stopped by plugin ${plugin.name}`);
|
|
1272
|
-
break;
|
|
1273
|
-
}
|
|
1274
|
-
// Handle actions
|
|
1275
|
-
if (result.action) {
|
|
1276
|
-
await this.handleHookAction(result.action, ctx);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
catch (error) {
|
|
1280
|
-
logger.error(`Hook ${point} error in plugin ${plugin.name}`, { error });
|
|
1281
|
-
ctx._errors = ctx._errors || [];
|
|
1282
|
-
ctx._errors.push({
|
|
1283
|
-
plugin: plugin.name,
|
|
1284
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
/**
|
|
1290
|
-
* 处理 Hook 动作
|
|
1291
|
-
*/
|
|
1292
|
-
async handleHookAction(action, ctx) {
|
|
1293
|
-
switch (action.type) {
|
|
1294
|
-
case "stop":
|
|
1295
|
-
ctx._stopped = true;
|
|
1296
|
-
ctx._stopReason = "stopped_by_hook";
|
|
1297
|
-
break;
|
|
1298
|
-
case "inject_message":
|
|
1299
|
-
if (action.payload && typeof action.payload === "object") {
|
|
1300
|
-
const msg = action.payload;
|
|
1301
|
-
ctx.messages.push(msg);
|
|
1302
|
-
}
|
|
1303
|
-
break;
|
|
1304
|
-
case "skip_tool":
|
|
1305
|
-
// Skip current tool execution
|
|
1306
|
-
ctx._pendingAction = action;
|
|
1307
|
-
break;
|
|
1308
|
-
// Other actions can be extended
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* 通知消息添加(扩展点)
|
|
1313
|
-
*/
|
|
1314
|
-
notifyMessageAdded(message) {
|
|
1315
|
-
// 可被子类或插件覆盖
|
|
1316
|
-
logger.debug(`Message added: ${message.role}`);
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
* 结束结果
|
|
1320
|
-
*/
|
|
1321
|
-
finalizeResult(result, ctx) {
|
|
1322
|
-
return {
|
|
1323
|
-
...result,
|
|
1324
|
-
stopped: ctx._stopped,
|
|
1325
|
-
stopReason: ctx._stopReason,
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
/**
|
|
1329
|
-
* Record messages to session
|
|
1330
|
-
*
|
|
1331
|
-
* 存储策略:
|
|
1332
|
-
* 1. 存储 allMessages 中的所有 user、assistant、tool 消息
|
|
1333
|
-
* 2. 跳过 system 消息
|
|
1334
|
-
* 3. 跳过空内容的 assistant/tool 消息
|
|
1335
|
-
*/
|
|
1336
|
-
async recordSessionMessages(sessionId, allMessages = []) {
|
|
1337
|
-
if (!sessionId) {
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
try {
|
|
1341
|
-
const sessionComponent = this.env.getComponent("session");
|
|
1342
|
-
if (!sessionComponent) {
|
|
1343
|
-
logger.warn("SessionComponent not found, skipping session recording");
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
|
-
for (const msg of allMessages) {
|
|
1347
|
-
// 跳过 system 消息
|
|
1348
|
-
if (msg.role === "system") {
|
|
1349
|
-
continue;
|
|
1350
|
-
}
|
|
1351
|
-
// 跳过空内容的 assistant/tool 消息
|
|
1352
|
-
if (msg.role === "assistant" || msg.role === "tool") {
|
|
1353
|
-
if (this.isEmptyMessage(msg.content)) {
|
|
1354
|
-
continue;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
await sessionComponent.addMessage(sessionId, this.messageConverter.fromModelMessage(msg, { sessionID: sessionId }));
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
catch (err) {
|
|
1361
|
-
logger.warn(`Failed to record session messages: ${err}`);
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
/**
|
|
1365
|
-
* 检查消息内容是否为空
|
|
1366
|
-
*
|
|
1367
|
-
* 空内容定义:
|
|
1368
|
-
* - 空字符串 ""
|
|
1369
|
-
* - 空数组 []
|
|
1370
|
-
* - null
|
|
1371
|
-
* - undefined
|
|
1372
|
-
*
|
|
1373
|
-
* @param content - 消息内容
|
|
1374
|
-
* @returns 是否为空
|
|
1375
|
-
*/
|
|
1376
|
-
isEmptyMessage(content) {
|
|
1377
|
-
if (content === null || content === undefined) {
|
|
1378
|
-
return true;
|
|
1379
|
-
}
|
|
1380
|
-
if (typeof content === "string" && content.trim() === "") {
|
|
1381
|
-
return true;
|
|
1382
|
-
}
|
|
1383
|
-
if (Array.isArray(content) && content.length === 0) {
|
|
1384
|
-
return true;
|
|
1385
|
-
}
|
|
1386
|
-
return false;
|
|
1387
|
-
}
|
|
1388
|
-
/**
|
|
1389
|
-
* 通过 Environment 发送事件
|
|
1390
|
-
*/
|
|
1391
|
-
pushEnvEvent(event) {
|
|
1392
|
-
if (this.env && "pushEnvEvent" in this.env) {
|
|
1393
|
-
try {
|
|
1394
|
-
const fullEvent = {
|
|
1395
|
-
id: `evt_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
1396
|
-
type: event.type,
|
|
1397
|
-
timestamp: Date.now(),
|
|
1398
|
-
metadata: {
|
|
1399
|
-
source: "agent",
|
|
1400
|
-
agent_name: this.name,
|
|
1401
|
-
},
|
|
1402
|
-
payload: event.payload,
|
|
1403
|
-
};
|
|
1404
|
-
this.env?.pushEnvEvent(fullEvent);
|
|
1405
|
-
}
|
|
1406
|
-
catch (err) {
|
|
1407
|
-
logger.warn(`[pushEnvEvent] Failed to push event: ${err}`);
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* 获取会话对话历史
|
|
1413
|
-
*
|
|
1414
|
-
* 核心逻辑:
|
|
1415
|
-
* 1. 使用 sessionComponent.getContext() 获取消息(自动从 checkpoint 开始)
|
|
1416
|
-
* 2. 根据 messageLimit 限制消息数量(向后兼容 minUserMessages)
|
|
1417
|
-
* 3. 过滤掉 tool_call/tool_result 消息(如果 filterHistory=true)
|
|
1418
|
-
*
|
|
1419
|
-
* 关键改进:利用 checkpoint 概念,避免重复获取已压缩的历史消息,
|
|
1420
|
-
* 从而减少重复触发压缩的问题。
|
|
1421
|
-
*
|
|
1422
|
-
* @param sessionComponent - SessionComponent 实例
|
|
1423
|
-
* @param sessionId - 会话 ID
|
|
1424
|
-
* @param options - 配置选项
|
|
1425
|
-
* @param options.minUserMessages - 最少包含的 user 消息数量(默认 100)
|
|
1426
|
-
* @param options.filterHistory - 是否过滤 tool 消息(默认 true)
|
|
1427
|
-
* @returns 过滤后的会话消息列表
|
|
1428
|
-
*/
|
|
1429
|
-
async getConversationHistory(sessionComponent, sessionId, options = {}) {
|
|
1430
|
-
const minUserMessages = options.minUserMessages ?? 100;
|
|
1431
|
-
const filterHistory = options.filterHistory ?? false;
|
|
1432
|
-
// 使用 getContext 获取消息,自动从最新 checkpoint 开始
|
|
1433
|
-
// 且确保从 user 消息边界截取,避免 tool_call/tool_result 配对被截断
|
|
1434
|
-
const ctx = await sessionComponent.getContext(sessionId, {
|
|
1435
|
-
fullHistory: false,
|
|
1436
|
-
minUserMessages,
|
|
1437
|
-
});
|
|
1438
|
-
let messages = ctx.messages;
|
|
1439
|
-
// 根据 filterHistory 配置决定是否过滤 tool 消息
|
|
1440
|
-
if (filterHistory) {
|
|
1441
|
-
messages = messages.filter(msg => {
|
|
1442
|
-
if (msg.metadata?.type === "tool_call" || msg.metadata?.type === "tool_result") {
|
|
1443
|
-
return false;
|
|
1444
|
-
}
|
|
1445
|
-
return msg.role === "user" || msg.role === "assistant";
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
return messages;
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
__decorate([
|
|
1452
|
-
TracedAs("agent.component.run", { recordParams: true, recordResult: true, log: true }),
|
|
1453
|
-
__metadata("design:type", Function),
|
|
1454
|
-
__metadata("design:paramtypes", [String, String, Object]),
|
|
1455
|
-
__metadata("design:returntype", Promise)
|
|
1456
|
-
], AgentComponent.prototype, "_run", null);
|
|
1457
|
-
__decorate([
|
|
1458
|
-
TracedAs("agent.component.invokeLLM", { recordParams: true, recordResult: true, log: true }),
|
|
1459
|
-
__metadata("design:type", Function),
|
|
1460
|
-
__metadata("design:paramtypes", [Object]),
|
|
1461
|
-
__metadata("design:returntype", Promise)
|
|
1462
|
-
], AgentComponent.prototype, "invokeLLM", null);
|
|
1463
|
-
__decorate([
|
|
1464
|
-
TracedAs("agent.component.executeTool", { recordParams: true, recordResult: true, log: true }),
|
|
1465
|
-
__metadata("design:type", Function),
|
|
1466
|
-
__metadata("design:paramtypes", [Object]),
|
|
1467
|
-
__metadata("design:returntype", Promise)
|
|
1468
|
-
], AgentComponent.prototype, "executeTool", null);
|
|
1469
|
-
__decorate([
|
|
1470
|
-
TracedAs("agent.component.recordSessionMessages", { recordParams: true, recordResult: true, log: true }),
|
|
1471
|
-
__metadata("design:type", Function),
|
|
1472
|
-
__metadata("design:paramtypes", [String, Array]),
|
|
1473
|
-
__metadata("design:returntype", Promise)
|
|
1474
|
-
], AgentComponent.prototype, "recordSessionMessages", null);
|
|
1475
|
-
__decorate([
|
|
1476
|
-
TracedAs("agent.component.getConversationHistory", { recordParams: true, recordResult: true, log: true }),
|
|
1477
|
-
__metadata("design:type", Function),
|
|
1478
|
-
__metadata("design:paramtypes", [Function, String, Object]),
|
|
1479
|
-
__metadata("design:returntype", Promise)
|
|
1480
|
-
], AgentComponent.prototype, "getConversationHistory", null);
|
|
1481
|
-
//# sourceMappingURL=agent-component.js.map
|