@ai-setting/roy-agent-core 1.7.51 → 1.7.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config-component.d.ts +346 -0
- package/dist/config/config-parser.d.ts +45 -0
- package/dist/config/env-key.d.ts +97 -0
- package/dist/config/env-source.d.ts +113 -0
- package/dist/config/file-source.d.ts +90 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/protocol-resolver.d.ts +94 -0
- package/dist/env/agent/agent-component.d.ts +646 -0
- package/dist/env/agent/agent-config-registration.d.ts +18 -0
- package/dist/env/agent/agent-registry.d.ts +500 -0
- package/dist/env/agent/index.d.ts +9 -0
- package/dist/env/agent/summary-agent.d.ts +44 -0
- package/dist/env/agent/types.d.ts +503 -0
- package/dist/env/commands/commands-component.d.ts +97 -0
- package/dist/env/commands/commands-config-registration.d.ts +19 -0
- package/dist/env/commands/index.d.ts +7 -0
- package/dist/env/commands/parser.d.ts +18 -0
- package/dist/env/commands/types.d.ts +133 -0
- package/dist/env/component.d.ts +186 -0
- package/dist/env/constants.d.ts +112 -0
- package/dist/env/context/env-context.d.ts +420 -0
- package/dist/env/context/env-event.d.ts +144 -0
- package/dist/env/context/index.d.ts +13 -0
- package/dist/env/debug/debug-component.d.ts +160 -0
- package/dist/env/debug/formatters/index.d.ts +8 -0
- package/dist/env/debug/formatters/repl-formatter.d.ts +80 -0
- package/dist/env/debug/formatters/trace-formatter.d.ts +43 -0
- package/dist/env/debug/formatters/tree-formatter.d.ts +72 -0
- package/dist/env/debug/index.d.ts +15 -0
- package/dist/env/debug/index.js +1 -1
- package/dist/env/debug/parser/regex-parser.d.ts +49 -0
- package/dist/env/debug/parser/span-builder.d.ts +79 -0
- package/dist/env/debug/reader/log-reader.d.ts +55 -0
- package/dist/env/debug/reader/span-db-reader.d.ts +70 -0
- package/dist/env/debug/types.d.ts +145 -0
- package/dist/env/environment.d.ts +185 -0
- package/dist/env/errors.d.ts +120 -0
- package/dist/env/event-source/bounty-cli-handler.d.ts +42 -0
- package/dist/env/event-source/bounty-im-handler.d.ts +232 -0
- package/dist/env/event-source/event-source-component.d.ts +177 -0
- package/dist/env/event-source/event-source-config-registration.d.ts +18 -0
- package/dist/env/event-source/event-source-handlers.d.ts +486 -0
- package/dist/env/event-source/event-store.d.ts +110 -0
- package/dist/env/event-source/idempotency-key.d.ts +19 -0
- package/dist/env/event-source/index.d.ts +15 -0
- package/dist/env/event-source/index.js +4 -4
- package/dist/env/event-source/timer-handler.d.ts +74 -0
- package/dist/env/event-source/types.d.ts +803 -0
- package/dist/env/hook/global-hook-manager.d.ts +73 -0
- package/dist/env/hook/hook-manager.d.ts +139 -0
- package/dist/env/hook/index.d.ts +9 -0
- package/dist/env/hook/types.d.ts +107 -0
- package/dist/env/index.d.ts +24 -0
- package/dist/env/index.js +6 -6
- package/dist/env/interface.d.ts +156 -0
- package/dist/env/lark-mention-utils.d.ts +59 -0
- package/dist/env/llm/adapter-ai-sdk.d.ts +10 -0
- package/dist/env/llm/adapter-pi-ai.d.ts +39 -0
- package/dist/env/llm/adapter.d.ts +80 -0
- package/dist/env/llm/factory.d.ts +13 -0
- package/dist/env/llm/hooks.d.ts +150 -0
- package/dist/env/llm/index.d.ts +16 -0
- package/dist/env/llm/invoke.d.ts +264 -0
- package/dist/env/llm/llm-cache.d.ts +38 -0
- package/dist/env/llm/llm.d.ts +238 -0
- package/dist/env/llm/opencode-session.d.ts +79 -0
- package/dist/env/llm/provider.d.ts +40 -0
- package/dist/env/llm/tool-args-parser.d.ts +77 -0
- package/dist/env/llm/tool-schema.d.ts +54 -0
- package/dist/env/llm/transform.d.ts +57 -0
- package/dist/env/llm/types.d.ts +818 -0
- package/dist/env/log-trace/decorator.d.ts +88 -0
- package/dist/env/log-trace/index.d.ts +14 -0
- package/dist/env/log-trace/log-trace-component.d.ts +268 -0
- package/dist/env/log-trace/log-trace-config-registration.d.ts +25 -0
- package/dist/env/log-trace/logger.d.ts +83 -0
- package/dist/env/log-trace/opentelemetry/cli-propagation.d.ts +105 -0
- package/dist/env/log-trace/opentelemetry/mod.d.ts +24 -0
- package/dist/env/log-trace/opentelemetry/propagation-env.d.ts +81 -0
- package/dist/env/log-trace/opentelemetry/propagation.d.ts +79 -0
- package/dist/env/log-trace/opentelemetry/tracer-provider.d.ts +157 -0
- package/dist/env/log-trace/span-storage.d.ts +37 -0
- package/dist/env/log-trace/trace-context.d.ts +28 -0
- package/dist/env/log-trace/types.d.ts +127 -0
- package/dist/env/mcp/command-resolver.d.ts +12 -0
- package/dist/env/mcp/config.d.ts +103 -0
- package/dist/env/mcp/index.d.ts +13 -0
- package/dist/env/mcp/loader.d.ts +78 -0
- package/dist/env/mcp/mcp-component.d.ts +54 -0
- package/dist/env/mcp/mcp-config-registration.d.ts +19 -0
- package/dist/env/mcp/npm-prefix/index.d.ts +17 -0
- package/dist/env/mcp/scanner.d.ts +38 -0
- package/dist/env/mcp/tool/adapter.d.ts +32 -0
- package/dist/env/mcp/tool/index.d.ts +4 -0
- package/dist/env/mcp/types.d.ts +131 -0
- package/dist/env/memory/built-in/index.d.ts +41 -0
- package/dist/env/memory/built-in/recall-memory.d.ts +29 -0
- package/dist/env/memory/built-in/record-memory.d.ts +44 -0
- package/dist/env/memory/index.d.ts +10 -0
- package/dist/env/memory/memory-component.d.ts +114 -0
- package/dist/env/memory/memory-config-registration.d.ts +18 -0
- package/dist/env/memory/memory-config.d.ts +18 -0
- package/dist/env/memory/plugin/index.d.ts +16 -0
- package/dist/env/memory/plugin/memory-agent.d.ts +126 -0
- package/dist/env/memory/plugin/memory-manager.d.ts +71 -0
- package/dist/env/memory/plugin/memory-plugin.d.ts +103 -0
- package/dist/env/memory/plugin/recall-memory.d.ts +16 -0
- package/dist/env/memory/plugin/types.d.ts +75 -0
- package/dist/env/memory/tools/memory-agent-tools.d.ts +109 -0
- package/dist/env/memory/types.d.ts +80 -0
- package/dist/env/paths.d.ts +46 -0
- package/dist/env/plugin/bounty-cli-notification-channel.d.ts +60 -0
- package/dist/env/plugin/event-bus-notification-channel.d.ts +50 -0
- package/dist/env/plugin/index.d.ts +13 -0
- package/dist/env/plugin/lark-cli-notification-channel.d.ts +61 -0
- package/dist/env/plugin/notification-channel.d.ts +143 -0
- package/dist/env/plugin/plugin-component.d.ts +232 -0
- package/dist/env/plugin/types.d.ts +146 -0
- package/dist/env/prompt/index.d.ts +7 -0
- package/dist/env/prompt/prompt-component.d.ts +194 -0
- package/dist/env/prompt/prompt-config-registration.d.ts +18 -0
- package/dist/env/prompt/prompt-store.d.ts +26 -0
- package/dist/env/prompt/prompts-index.d.ts +146 -0
- package/dist/env/prompt/renderer.d.ts +21 -0
- package/dist/env/prompt/types.d.ts +176 -0
- package/dist/env/session/hooks.d.ts +14 -0
- package/dist/env/session/index.d.ts +19 -0
- package/dist/env/session/search-query-parser.d.ts +41 -0
- package/dist/env/session/session-component.d.ts +464 -0
- package/dist/env/session/session-config-registration.d.ts +18 -0
- package/dist/env/session/session-id.d.ts +26 -0
- package/dist/env/session/session-message-converter.d.ts +142 -0
- package/dist/env/session/session-store.d.ts +188 -0
- package/dist/env/session/storage/index.d.ts +5 -0
- package/dist/env/session/storage/memory.d.ts +119 -0
- package/dist/env/session/storage/sqlite.d.ts +108 -0
- package/dist/env/session/types.d.ts +705 -0
- package/dist/env/session-tree-stopper.d.ts +79 -0
- package/dist/env/skill/config.d.ts +13 -0
- package/dist/env/skill/index.d.ts +6 -0
- package/dist/env/skill/parser.d.ts +9 -0
- package/dist/env/skill/scanner.d.ts +25 -0
- package/dist/env/skill/skill-component.d.ts +89 -0
- package/dist/env/skill/skill-config-registration.d.ts +18 -0
- package/dist/env/skill/tool/index.d.ts +1 -0
- package/dist/env/skill/tool/skill-tool.d.ts +15 -0
- package/dist/env/skill/types.d.ts +61 -0
- package/dist/env/task/backend/index.d.ts +24 -0
- package/dist/env/task/backend/index.js +704 -0
- package/dist/env/task/backend/roy-sidecar-task-port.d.ts +148 -0
- package/dist/env/task/backend/sqlite-task-port.d.ts +28 -0
- package/dist/env/task/backend/task-store-backend.d.ts +107 -0
- package/dist/env/task/backend/types.d.ts +293 -0
- package/dist/env/task/delegate/bg-task-id-storage.d.ts +9 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +681 -0
- package/dist/env/task/delegate/index.d.ts +8 -0
- package/dist/env/task/delegate/process-registry.d.ts +58 -0
- package/dist/env/task/delegate/stop-tool.d.ts +12 -0
- package/dist/env/task/delegate/subagent-resolver.d.ts +25 -0
- package/dist/env/task/events/index.d.ts +7 -0
- package/dist/env/task/events/task-event-payloads.d.ts +101 -0
- package/dist/env/task/events/task-event-types.d.ts +23 -0
- package/dist/env/task/hooks/contexts.d.ts +191 -0
- package/dist/env/task/hooks/index.d.ts +7 -0
- package/dist/env/task/hooks/task-hook-points.d.ts +42 -0
- package/dist/env/task/index.d.ts +7 -0
- package/dist/env/task/plugins/auto-task-plugin.d.ts +38 -0
- package/dist/env/task/plugins/card-chat-routing.d.ts +135 -0
- package/dist/env/task/plugins/fake-user-message-helper.d.ts +90 -0
- package/dist/env/task/plugins/index.d.ts +8 -0
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +651 -0
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +248 -0
- package/dist/env/task/plugins/max-iteration-reminder-plugin.d.ts +112 -0
- package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +561 -0
- package/dist/env/task/plugins/task-tag-plugin.d.ts +70 -0
- package/dist/env/task/plugins/workflow-extractor-agent.d.ts +43 -0
- package/dist/env/task/registry-hook-installer.d.ts +43 -0
- package/dist/env/task/storage/index.d.ts +5 -0
- package/dist/env/task/storage/migrations/001_add_project_path_context.d.ts +14 -0
- package/dist/env/task/storage/migrations/002_add_task_type.d.ts +14 -0
- package/dist/env/task/storage/migrations/003_add_process_description.d.ts +20 -0
- package/dist/env/task/storage/migrations/004_rename_action_to_milestone.d.ts +37 -0
- package/dist/env/task/storage/migrations/005_convert_blob_description_to_text.d.ts +51 -0
- package/dist/env/task/storage/sqlite-task-store.d.ts +241 -0
- package/dist/env/task/tag-service.d.ts +138 -0
- package/dist/env/task/task-child-context.d.ts +70 -0
- package/dist/env/task/task-component.d.ts +270 -0
- package/dist/env/task/task-config-registration.d.ts +19 -0
- package/dist/env/task/task-creation-registry.d.ts +181 -0
- package/dist/env/task/task-reuse-context.d.ts +52 -0
- package/dist/env/task/task-reuse-registry.d.ts +31 -0
- package/dist/env/task/tools/batch-archive-tool.d.ts +9 -0
- package/dist/env/task/tools/batch-delete-tool.d.ts +9 -0
- package/dist/env/task/tools/complete-tool.d.ts +12 -0
- package/dist/env/task/tools/create-tool.d.ts +6 -0
- package/dist/env/task/tools/delete-tool.d.ts +6 -0
- package/dist/env/task/tools/get-tool.d.ts +6 -0
- package/dist/env/task/tools/index.d.ts +13 -0
- package/dist/env/task/tools/list-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/create-tool.d.ts +12 -0
- package/dist/env/task/tools/operation/delete-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/get-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/index.d.ts +8 -0
- package/dist/env/task/tools/operation/list-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/operation-types.d.ts +225 -0
- package/dist/env/task/tools/operation/update-tool.d.ts +6 -0
- package/dist/env/task/tools/search-tool.d.ts +9 -0
- package/dist/env/task/tools/task-tree-tool.d.ts +65 -0
- package/dist/env/task/tools/task-types.d.ts +255 -0
- package/dist/env/task/tools/update-tool.d.ts +6 -0
- package/dist/env/task/types.d.ts +290 -0
- package/dist/env/tool/built-in/bash-effect.d.ts +36 -0
- package/dist/env/tool/built-in/bash.d.ts +16 -0
- package/dist/env/tool/built-in/echo.d.ts +7 -0
- package/dist/env/tool/built-in/edit-file.d.ts +6 -0
- package/dist/env/tool/built-in/glob.d.ts +6 -0
- package/dist/env/tool/built-in/grep.d.ts +6 -0
- package/dist/env/tool/built-in/index.d.ts +39 -0
- package/dist/env/tool/built-in/query-background-process-tool.d.ts +113 -0
- package/dist/env/tool/built-in/read-file.d.ts +5 -0
- package/dist/env/tool/built-in/understand-image.d.ts +59 -0
- package/dist/env/tool/built-in/write-file.d.ts +5 -0
- package/dist/env/tool/index.d.ts +16 -0
- package/dist/env/tool/registry.d.ts +61 -0
- package/dist/env/tool/tool-component.d.ts +242 -0
- package/dist/env/tool/tool-config-registration.d.ts +18 -0
- package/dist/env/tool/types.d.ts +274 -0
- package/dist/env/tool/validator.d.ts +14 -0
- package/dist/env/types.d.ts +184 -0
- package/dist/env/workflow/decorators/decorator-node.d.ts +76 -0
- package/dist/env/workflow/decorators/edge.d.ts +42 -0
- package/dist/env/workflow/decorators/index.d.ts +13 -0
- package/dist/env/workflow/decorators/node-as.d.ts +40 -0
- package/dist/env/workflow/decorators/workflow.d.ts +30 -0
- package/dist/env/workflow/engine/dag-manager.d.ts +176 -0
- package/dist/env/workflow/engine/engine.d.ts +375 -0
- package/dist/env/workflow/engine/event-bus.d.ts +54 -0
- package/dist/env/workflow/engine/executor.d.ts +122 -0
- package/dist/env/workflow/engine/index.d.ts +15 -0
- package/dist/env/workflow/engine/node-registry.d.ts +159 -0
- package/dist/env/workflow/engine/scheduler.d.ts +164 -0
- package/dist/env/workflow/extractor/workflow-converter.d.ts +55 -0
- package/dist/env/workflow/fixtures.d.ts +401 -0
- package/dist/env/workflow/hooks/index.d.ts +4 -0
- package/dist/env/workflow/hooks/workflow-hook-points.d.ts +161 -0
- package/dist/env/workflow/index.d.ts +30 -0
- package/dist/env/workflow/index.js +1 -1
- package/dist/env/workflow/metadata/keys.d.ts +6 -0
- package/dist/env/workflow/nodes/agent-component-adapter.d.ts +175 -0
- package/dist/env/workflow/nodes/agent-node.d.ts +206 -0
- package/dist/env/workflow/nodes/ask-user-node.d.ts +66 -0
- package/dist/env/workflow/nodes/condition-node.d.ts +39 -0
- package/dist/env/workflow/nodes/index.d.ts +8 -0
- package/dist/env/workflow/nodes/merge-node.d.ts +40 -0
- package/dist/env/workflow/nodes/python-call-node.d.ts +95 -0
- package/dist/env/workflow/nodes/skill-node.d.ts +29 -0
- package/dist/env/workflow/nodes/tool-node.d.ts +58 -0
- package/dist/env/workflow/nodes/workflow-node.d.ts +118 -0
- package/dist/env/workflow/plugins/index.d.ts +6 -0
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
- package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
- package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
- package/dist/env/workflow/service/index.d.ts +9 -0
- package/dist/env/workflow/service/registry.d.ts +37 -0
- package/dist/env/workflow/service/workflow-service.d.ts +422 -0
- package/dist/env/workflow/storage/index.d.ts +11 -0
- package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
- package/dist/env/workflow/storage/safe-json.d.ts +62 -0
- package/dist/env/workflow/storage/sqlite.d.ts +57 -0
- package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
- package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
- package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
- package/dist/env/workflow/tools/index.d.ts +16 -0
- package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
- package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
- package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
- package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
- package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
- package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
- package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
- package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
- package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
- package/dist/env/workflow/tools/workflow-validate-tool.d.ts +60 -0
- package/dist/env/workflow/types/context.d.ts +17 -0
- package/dist/env/workflow/types/decorators-types.d.ts +182 -0
- package/dist/env/workflow/types/edge.d.ts +33 -0
- package/dist/env/workflow/types/event.d.ts +869 -0
- package/dist/env/workflow/types/index.d.ts +16 -0
- package/dist/env/workflow/types/run.d.ts +235 -0
- package/dist/env/workflow/types/workflow-error.d.ts +79 -0
- package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
- package/dist/env/workflow/types/workflow-message.d.ts +193 -0
- package/dist/env/workflow/types/workflow-session.d.ts +17 -0
- package/dist/env/workflow/types/workflow.d.ts +654 -0
- package/dist/env/workflow/types_compat.d.ts +10 -0
- package/dist/env/workflow/utils/agent-session-metadata.d.ts +35 -0
- package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
- package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
- package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
- package/dist/env/workflow/utils/execution-state.d.ts +46 -0
- package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
- package/dist/env/workflow/utils/index.d.ts +14 -0
- package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
- package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
- package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
- package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
- package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
- package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
- package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
- package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
- package/dist/env/workflow/utils/session-parser.d.ts +23 -0
- package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
- package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
- package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
- package/dist/env/workflow/utils/validate-workflow-definition.d.ts +57 -0
- package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
- package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
- package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
- package/dist/env/workflow/workflow-component.d.ts +138 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-9faekt5n.js → roy-agent-core-4sx6sdb2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wxsgay02.js → roy-agent-core-brwzs8wf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-kyasfzeh.js → roy-agent-core-hch2geta.js} +45 -14
- package/dist/shared/@ai-setting/{roy-agent-core-zd077w51.js → roy-agent-core-j8e92gj8.js} +43 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wwytg8rv.js → roy-agent-core-ph5qbqcx.js} +566 -78
- package/dist/util/process/process-tree-killer.d.ts +67 -0
- package/dist/utils/id.d.ts +11 -0
- package/dist/utils/loose-json.d.ts +30 -0
- package/dist/utils/media.d.ts +70 -0
- package/dist/utils/temp-file-manager/index.d.ts +99 -0
- package/package.json +4 -2
- /package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-4vpk40ss.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { BaseComponent, type ComponentConfig } from "../component";
|
|
2
|
+
import type { Tool, ToolContext, ToolResult, ToolResultMetadata, ToolExecuteRequest, ToolListFilter, ToolRegistration } from "./types";
|
|
3
|
+
import type { ConfigComponent } from "../../config/config-component";
|
|
4
|
+
/**
|
|
5
|
+
* 设置 ConfigComponent 实例
|
|
6
|
+
*/
|
|
7
|
+
export declare function setToolConfigComponent(component: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* 获取工具输出最大长度配置(支持热更新)
|
|
10
|
+
*
|
|
11
|
+
* 配置路径: tool.execution.maxOutputSize
|
|
12
|
+
* 默认值: 5120 (5KB) — 与 LLM Token 窗口匹配,避免工具输出过大占用上下文
|
|
13
|
+
*
|
|
14
|
+
* @returns 最大输出大小(字节),0 表示不限制
|
|
15
|
+
*/
|
|
16
|
+
export declare function getMaxOutputSize(): number;
|
|
17
|
+
/**
|
|
18
|
+
* 截断工具输出
|
|
19
|
+
*
|
|
20
|
+
* v5.0: 移除了 v4.6.0 的 ITERATION_TASK_TRIGGER_BEGIN/END marker 识别逻辑。
|
|
21
|
+
* AutoTaskPlugin v5.0 不再向 tool result 注入 metadata,
|
|
22
|
+
* 而是推送 user 消息,因此 truncateOutput 不需要识别任何 plugin-specific marker。
|
|
23
|
+
* 按原行为截断:保留前 maxSize 字符 + 添加截断通知。
|
|
24
|
+
*
|
|
25
|
+
* @param output 原始输出
|
|
26
|
+
* @param maxSize 最大输出大小
|
|
27
|
+
* @returns 截断后的输出和元数据更新
|
|
28
|
+
*/
|
|
29
|
+
export declare function truncateOutput(output: string, maxSize: number): {
|
|
30
|
+
output: string;
|
|
31
|
+
metadata: Partial<ToolResultMetadata>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Per-tool default overrides for maxOutputSize.
|
|
35
|
+
*
|
|
36
|
+
* Most tools share the global `tool.execution.maxOutputSize` limit (5KB by
|
|
37
|
+
* default) — but a handful of tools routinely produce much larger outputs and
|
|
38
|
+
* benefit from a larger ceiling. The map below gives those tools a sensible
|
|
39
|
+
* per-tool cap while keeping the default conservative for everything else.
|
|
40
|
+
*
|
|
41
|
+
* The map is intentionally small. New entries should be added only with a
|
|
42
|
+
* clear reason (e.g. "always reads full files of any size").
|
|
43
|
+
*/
|
|
44
|
+
export declare const TOOL_MAX_OUTPUT_SIZE_OVERRIDES: Record<string, number>;
|
|
45
|
+
/**
|
|
46
|
+
* Look up the effective maxOutputSize for a given tool. Resolution order:
|
|
47
|
+
* 1. explicit `overrideMaxSize` (used by tests & Power Users)
|
|
48
|
+
* 2. `TOOL_MAX_OUTPUT_SIZE_OVERRIDES[toolName]`
|
|
49
|
+
* 3. global `tool.execution.maxOutputSize` via config component
|
|
50
|
+
* 4. fallback default 5120
|
|
51
|
+
*/
|
|
52
|
+
export declare function getMaxOutputSizeForTool(toolName?: string, overrideMaxSize?: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Inline truncation helper for execution paths that bypass `ToolComponent.execute()`.
|
|
55
|
+
*
|
|
56
|
+
* Two production code paths currently call `tool.execute()` directly instead of
|
|
57
|
+
* routing through `ToolComponent`:
|
|
58
|
+
* (A) `AgentComponent.executeTool` `isExtraTool` branch
|
|
59
|
+
* (B) `AgentComponent.executeTool` fallback branch (no ToolComponent)
|
|
60
|
+
*
|
|
61
|
+
* Each of those paths previously skipped truncation entirely. This helper replicates
|
|
62
|
+
* the truncation step that `ToolComponent.execute()` performs, so the two bypass
|
|
63
|
+
* paths re-enter the same safety net without restructuring the call sites.
|
|
64
|
+
*
|
|
65
|
+
* Resolution precedence for the cap:
|
|
66
|
+
* 1. `maxSize` argument (explicit call-site override, wins)
|
|
67
|
+
* 2. `TOOL_MAX_OUTPUT_SIZE_OVERRIDES[toolName]` if `toolName` is supplied
|
|
68
|
+
* 3. global `tool.execution.maxOutputSize` via config component
|
|
69
|
+
* 4. fallback default 5120
|
|
70
|
+
*
|
|
71
|
+
* Tool authors can also opt out of truncation entirely by setting
|
|
72
|
+
* `metadata.skipTruncation === true` on their Tool. When the optional
|
|
73
|
+
* `tool` argument is supplied and carries that flag, the helper returns
|
|
74
|
+
* a shallow clone of the source result without touching `output` or
|
|
75
|
+
* `error` — mirroring the central `ToolComponent.execute()` short-circuit.
|
|
76
|
+
* WorkflowToolNode no longer calls this helper (it deliberately preserves
|
|
77
|
+
* raw payloads for the workflow data layer); only the two AgentComponent
|
|
78
|
+
* bypass paths above use it now.
|
|
79
|
+
*
|
|
80
|
+
* `truncateOutputInline` returns a new ToolResult (the input is shallow-cloned)
|
|
81
|
+
* to avoid surprising downstream mutators that reuse the original object.
|
|
82
|
+
*/
|
|
83
|
+
export declare function truncateOutputInline(result: ToolResult, maxSize?: number, overrideMaxSize?: number, toolName?: string, tool?: Tool): ToolResult;
|
|
84
|
+
/**
|
|
85
|
+
* ToolComponent 配置选项(通过 options 传递)
|
|
86
|
+
*
|
|
87
|
+
* 配置加载顺序(优先级从低到高):
|
|
88
|
+
* 1. File - 配置文件(通过 configPath 指定)
|
|
89
|
+
* 2. Env - 环境变量(通过 envPrefix 配置前缀)
|
|
90
|
+
* 3. Object - 直接传入的 config 对象(最高优先级)
|
|
91
|
+
*/
|
|
92
|
+
export interface ToolComponentOptions {
|
|
93
|
+
/** ConfigComponent 实例(必填) */
|
|
94
|
+
configComponent: ConfigComponent;
|
|
95
|
+
/** 配置文件相对路径(可选,基于 XDG_DATA_HOME) */
|
|
96
|
+
configPath?: string;
|
|
97
|
+
/** 环境变量前缀(可选,默认 "TOOL") */
|
|
98
|
+
envPrefix?: string;
|
|
99
|
+
/** 直接传入的配置对象(可选,优先级最高) */
|
|
100
|
+
config?: Partial<ToolComponentConfig>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Tool Hook 上下文
|
|
104
|
+
*/
|
|
105
|
+
export interface ToolHookContext {
|
|
106
|
+
tool?: Tool;
|
|
107
|
+
args?: Record<string, unknown>;
|
|
108
|
+
context?: ToolContext;
|
|
109
|
+
result?: ToolResult;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* ToolComponent 配置
|
|
113
|
+
*/
|
|
114
|
+
export interface ToolComponentConfig {
|
|
115
|
+
/** 工具目录 */
|
|
116
|
+
toolsDir?: string;
|
|
117
|
+
/** 内置工具 */
|
|
118
|
+
builtInTools?: {
|
|
119
|
+
enabled: boolean;
|
|
120
|
+
loadAll?: boolean;
|
|
121
|
+
names?: string[];
|
|
122
|
+
};
|
|
123
|
+
/** 沙箱配置 */
|
|
124
|
+
sandbox?: {
|
|
125
|
+
enabled: boolean;
|
|
126
|
+
type: "native" | "docker";
|
|
127
|
+
defaultConfig?: Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
/** 执行配置 */
|
|
130
|
+
execution?: {
|
|
131
|
+
timeout?: number;
|
|
132
|
+
maxConcurrency?: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* ToolComponent
|
|
137
|
+
* 工具管理核心组件
|
|
138
|
+
*/
|
|
139
|
+
export declare class ToolComponent extends BaseComponent {
|
|
140
|
+
readonly name = "tool";
|
|
141
|
+
readonly version = "1.0.0";
|
|
142
|
+
private registry;
|
|
143
|
+
private validator;
|
|
144
|
+
private config?;
|
|
145
|
+
/** ConfigComponent 用于配置管理 */
|
|
146
|
+
private configComponent?;
|
|
147
|
+
/** 配置变更 watcher 清理函数 */
|
|
148
|
+
private configWatcher?;
|
|
149
|
+
constructor();
|
|
150
|
+
/**
|
|
151
|
+
* 初始化组件
|
|
152
|
+
*
|
|
153
|
+
* 配置加载优先级(从高到低):
|
|
154
|
+
* 1. Object - 直接传入的 config 对象
|
|
155
|
+
* 2. Env - 环境变量(通过 envPrefix 配置前缀)
|
|
156
|
+
* 3. File - 配置文件(通过 configPath 指定)
|
|
157
|
+
*/
|
|
158
|
+
init(config?: ComponentConfig): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* 注册配置到 ConfigComponent
|
|
161
|
+
*
|
|
162
|
+
* 配置加载顺序(优先级从低到高):
|
|
163
|
+
* 1. FileSource - 从配置文件加载(最低)
|
|
164
|
+
* 2. EnvSource - 从环境变量加载(中等)
|
|
165
|
+
* 3. MemorySource - 直接配置对象(最高)
|
|
166
|
+
*
|
|
167
|
+
* 实现步骤:
|
|
168
|
+
* 1. 使用 registerComponent(TOOL_CONFIG_REGISTRATION) 注册配置
|
|
169
|
+
* 2. 使用 load("tool") 加载已注册的配置
|
|
170
|
+
* 3. 设置 TOOL_DEFAULTS 默认值
|
|
171
|
+
* 4. 处理环境变量后备方案
|
|
172
|
+
* 5. 处理 config 对象(最高优先级)
|
|
173
|
+
*/
|
|
174
|
+
private registerConfig;
|
|
175
|
+
/**
|
|
176
|
+
* 将配置对象展平为点号路径
|
|
177
|
+
*/
|
|
178
|
+
private flattenConfig;
|
|
179
|
+
/**
|
|
180
|
+
* 注册配置热更新监听
|
|
181
|
+
*/
|
|
182
|
+
private registerConfigWatcher;
|
|
183
|
+
/**
|
|
184
|
+
* 处理配置变更
|
|
185
|
+
*/
|
|
186
|
+
protected onConfigChange(event: {
|
|
187
|
+
key: string;
|
|
188
|
+
oldValue?: unknown;
|
|
189
|
+
newValue?: unknown;
|
|
190
|
+
}): void;
|
|
191
|
+
/**
|
|
192
|
+
* 停止组件
|
|
193
|
+
*/
|
|
194
|
+
onStop(): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* 注册工具
|
|
197
|
+
*/
|
|
198
|
+
register(tool: Tool, source?: ToolRegistration["source"]): void;
|
|
199
|
+
/**
|
|
200
|
+
* 批量注册工具
|
|
201
|
+
*/
|
|
202
|
+
registerMany(tools: Tool[], source?: ToolRegistration["source"]): void;
|
|
203
|
+
/**
|
|
204
|
+
* 注销工具
|
|
205
|
+
*/
|
|
206
|
+
unregister(name: string): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* 获取工具
|
|
209
|
+
*/
|
|
210
|
+
getTool(name: string): Tool | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* 列出工具
|
|
213
|
+
*/
|
|
214
|
+
listTools(filter?: ToolListFilter): Tool[];
|
|
215
|
+
/**
|
|
216
|
+
* 获取工具数量
|
|
217
|
+
*/
|
|
218
|
+
getToolCount(): number;
|
|
219
|
+
/**
|
|
220
|
+
* 检查工具是否存在
|
|
221
|
+
*/
|
|
222
|
+
hasTool(name: string): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* 按分类获取工具
|
|
225
|
+
*/
|
|
226
|
+
getToolsByCategory(category: string): Tool[];
|
|
227
|
+
/**
|
|
228
|
+
* 执行工具
|
|
229
|
+
*
|
|
230
|
+
* errorIf:与 AgentComponent.executeTool 对齐 —— 只有「工具不存在 / 被禁用」
|
|
231
|
+
* 才标 ERROR(配置错误),工具自身的运行时失败保持 OK 以免噪音淹没真问题。
|
|
232
|
+
*/
|
|
233
|
+
execute(request: ToolExecuteRequest): Promise<ToolResult>;
|
|
234
|
+
/**
|
|
235
|
+
* 加载内置工具
|
|
236
|
+
*/
|
|
237
|
+
loadBuiltInTools(): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* 获取 Tool Hook 点列表
|
|
240
|
+
*/
|
|
241
|
+
getHookPoints(): string[];
|
|
242
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool Component 配置注册
|
|
3
|
+
*
|
|
4
|
+
* 使用 ConfigComponent.registerComponent() 机制统一管理配置
|
|
5
|
+
*/
|
|
6
|
+
import type { ComponentRegistration } from "../../config/config-component";
|
|
7
|
+
/**
|
|
8
|
+
* Tool Component 默认配置值
|
|
9
|
+
*
|
|
10
|
+
* 注意:键使用完整格式(带 "tool." 前缀),在 registerConfig 中手动设置
|
|
11
|
+
*/
|
|
12
|
+
export declare const TOOL_DEFAULTS: Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Tool Component 配置注册常量
|
|
15
|
+
*
|
|
16
|
+
* 定义了所有 Tool 相关的配置项和来源
|
|
17
|
+
*/
|
|
18
|
+
export declare const TOOL_CONFIG_REGISTRATION: ComponentRegistration;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { z, ZodType, ZodError } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* 沙箱配置
|
|
4
|
+
*/
|
|
5
|
+
export interface SandboxConfig {
|
|
6
|
+
/** 是否启用沙箱 */
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
/** 沙箱类型 */
|
|
9
|
+
type: "native" | "docker";
|
|
10
|
+
/** 动作过滤 */
|
|
11
|
+
actionFilter?: {
|
|
12
|
+
/** 包含的动作 */
|
|
13
|
+
include?: string[];
|
|
14
|
+
/** 排除的动作 */
|
|
15
|
+
exclude?: string[];
|
|
16
|
+
};
|
|
17
|
+
/** 文件系统限制 */
|
|
18
|
+
filesystem?: {
|
|
19
|
+
/** 允许读取 */
|
|
20
|
+
allowRead?: string[];
|
|
21
|
+
/** 禁止读取 */
|
|
22
|
+
denyRead?: string[];
|
|
23
|
+
/** 允许写入 */
|
|
24
|
+
allowWrite?: string[];
|
|
25
|
+
/** 禁止写入 */
|
|
26
|
+
denyWrite?: string[];
|
|
27
|
+
};
|
|
28
|
+
/** 网络限制 */
|
|
29
|
+
network?: {
|
|
30
|
+
/** 允许的域名 */
|
|
31
|
+
allowedDomains?: string[];
|
|
32
|
+
/** 禁止的域名 */
|
|
33
|
+
deniedDomains?: string[];
|
|
34
|
+
};
|
|
35
|
+
/** Docker 配置 */
|
|
36
|
+
docker?: {
|
|
37
|
+
/** 镜像 */
|
|
38
|
+
image?: string;
|
|
39
|
+
/** 网络模式 */
|
|
40
|
+
networkMode?: "bridge" | "host" | "none";
|
|
41
|
+
/** 卷挂载 */
|
|
42
|
+
volumes?: Record<string, string>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 工具执行上下文
|
|
47
|
+
*/
|
|
48
|
+
export interface ToolContext {
|
|
49
|
+
/** 工作目录 */
|
|
50
|
+
workdir?: string;
|
|
51
|
+
/** 用户 ID */
|
|
52
|
+
user_id?: string;
|
|
53
|
+
/** 会话 ID */
|
|
54
|
+
session_id?: string;
|
|
55
|
+
/** 消息 ID */
|
|
56
|
+
message_id?: string;
|
|
57
|
+
/** 中断信号 */
|
|
58
|
+
abort?: AbortSignal;
|
|
59
|
+
/** 额外元数据 */
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
/** 沙箱配置 */
|
|
62
|
+
sandbox?: SandboxConfig;
|
|
63
|
+
/** 沙箱 Provider */
|
|
64
|
+
sandboxProvider?: unknown | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 工具结果元数据
|
|
68
|
+
*/
|
|
69
|
+
export interface ToolResultMetadata {
|
|
70
|
+
/** 执行时间(毫秒) */
|
|
71
|
+
execution_time_ms: number;
|
|
72
|
+
/** 输出大小(字节) */
|
|
73
|
+
output_size?: number;
|
|
74
|
+
/** 标准输出 */
|
|
75
|
+
stdout?: string;
|
|
76
|
+
/** 标准错误 */
|
|
77
|
+
stderr?: string;
|
|
78
|
+
/** 退出码 */
|
|
79
|
+
exit_code?: number;
|
|
80
|
+
/** Token 使用量 */
|
|
81
|
+
usage?: {
|
|
82
|
+
inputTokens: number;
|
|
83
|
+
outputTokens: number;
|
|
84
|
+
totalTokens?: number;
|
|
85
|
+
};
|
|
86
|
+
/** 输出是否被截断 */
|
|
87
|
+
output_truncated?: boolean;
|
|
88
|
+
/** 原始输出大小(截断前,单位:字符) */
|
|
89
|
+
original_output_size?: number;
|
|
90
|
+
/** 截断后输出大小(单位:字符) */
|
|
91
|
+
truncated_output_size?: number;
|
|
92
|
+
/** 额外元数据 */
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 工具执行结果
|
|
97
|
+
*/
|
|
98
|
+
export interface ToolResult {
|
|
99
|
+
/** 是否成功 */
|
|
100
|
+
success: boolean;
|
|
101
|
+
/** 输出内容 */
|
|
102
|
+
output: string | Record<string, unknown>;
|
|
103
|
+
/** 错误信息 */
|
|
104
|
+
error?: string;
|
|
105
|
+
/** 结果元数据 */
|
|
106
|
+
metadata?: ToolResultMetadata;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 工具元数据
|
|
110
|
+
*/
|
|
111
|
+
export interface ToolMetadata {
|
|
112
|
+
/** 分类 */
|
|
113
|
+
category?: string;
|
|
114
|
+
/** 标签 */
|
|
115
|
+
tags?: string[];
|
|
116
|
+
/** 版本 */
|
|
117
|
+
version?: string;
|
|
118
|
+
/** 作者 */
|
|
119
|
+
author?: string;
|
|
120
|
+
/** 是否实验性 */
|
|
121
|
+
experimental?: boolean;
|
|
122
|
+
/** MCP 工具信息(MCP adapter 使用) */
|
|
123
|
+
mcpTool?: {
|
|
124
|
+
originalName: string;
|
|
125
|
+
originalDescription: string;
|
|
126
|
+
inputSchema?: unknown;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* 允许使用该工具的 agent 名称白名单(2026-07 新增)。
|
|
130
|
+
*
|
|
131
|
+
* 设计目标:让某些"工具仅对特定 agent 可见",例如:
|
|
132
|
+
* - `query_background_process`:只给 default 接待员 agent 使用(因为只有它会委托任务)
|
|
133
|
+
* - 其他 agent(roy / strict-task-agent / explore 等)看不到这个工具,行为不变
|
|
134
|
+
*
|
|
135
|
+
* 匹配规则(listTools filter `allowedAgent` 时):
|
|
136
|
+
* - `undefined` 或空数组:所有 agent 可见(向后兼容)
|
|
137
|
+
* - 非空数组:当 `allowedAgent` 命中数组中任一元素时可见
|
|
138
|
+
* - 字符串精确匹配,大小写敏感
|
|
139
|
+
*
|
|
140
|
+
* 注意:这是**工具自身的可见性声明**,与 agent 配置中的 `allowedTools`(白名单)、
|
|
141
|
+
* `deniedTools`(黑名单)是**正交**的。两者共同决定最终可见工具集:
|
|
142
|
+
* 1. 工具声明自己允许的 agent(这里)
|
|
143
|
+
* 2. agent 自己声明 allowedTools / deniedTools
|
|
144
|
+
* 3. ToolComponent.listTools({ allowedAgent }) 一次过滤;agent-component 再做 allowedTools/deniedTools 二次过滤
|
|
145
|
+
*/
|
|
146
|
+
allowedAgentTypes?: string[];
|
|
147
|
+
/**
|
|
148
|
+
* Whether this tool explicitly opts out of string output truncation.
|
|
149
|
+
*
|
|
150
|
+
* `true` preserves the complete string output, including the temp-file
|
|
151
|
+
* fallback path in `ToolComponent.execute()`. Use this for tools whose
|
|
152
|
+
* output IS the deliverable (e.g. metadata readers like `workflow_get`):
|
|
153
|
+
* silently truncating their payload defeats the user's intent.
|
|
154
|
+
*
|
|
155
|
+
* `false` or `undefined` preserves the default 5KB cap and truncation
|
|
156
|
+
* notice for backward compatibility.
|
|
157
|
+
*/
|
|
158
|
+
skipTruncation?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 工具沙箱配置
|
|
162
|
+
*/
|
|
163
|
+
export interface ToolSandboxConfig {
|
|
164
|
+
/** 是否启用沙箱 */
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
/** 沙箱配置 */
|
|
167
|
+
config?: Partial<SandboxConfig>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 工具权限配置
|
|
171
|
+
*/
|
|
172
|
+
export interface ToolPermissionConfig {
|
|
173
|
+
/** 是否需要用户确认 */
|
|
174
|
+
requireConfirmation?: boolean;
|
|
175
|
+
/** 权限级别 */
|
|
176
|
+
level?: "safe" | "dangerous" | "critical";
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 工具信息
|
|
180
|
+
*/
|
|
181
|
+
export interface ToolInfo<Parameters extends ZodType = ZodType> {
|
|
182
|
+
/** 工具名称 */
|
|
183
|
+
name: string;
|
|
184
|
+
/** 工具描述 */
|
|
185
|
+
description: string;
|
|
186
|
+
/** 参数 Schema */
|
|
187
|
+
parameters: Parameters;
|
|
188
|
+
/** 初始化函数(可选) */
|
|
189
|
+
init?: (ctx?: ToolContext) => Promise<void>;
|
|
190
|
+
/** 执行函数 */
|
|
191
|
+
execute: (args: z.infer<Parameters>, ctx: ToolContext) => Promise<ToolResult>;
|
|
192
|
+
/** 参数验证错误格式化(可选) */
|
|
193
|
+
formatValidationError?: (error: ZodError) => string;
|
|
194
|
+
/** 沙箱配置 */
|
|
195
|
+
sandbox?: ToolSandboxConfig;
|
|
196
|
+
/** 权限配置 */
|
|
197
|
+
permission?: ToolPermissionConfig;
|
|
198
|
+
/** 工具元数据 */
|
|
199
|
+
metadata?: ToolMetadata;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 工具类型别名
|
|
203
|
+
*/
|
|
204
|
+
export type Tool = ToolInfo;
|
|
205
|
+
/**
|
|
206
|
+
* 工具注册来源
|
|
207
|
+
*/
|
|
208
|
+
export type ToolSource = "built-in" | "plugin" | "dynamic";
|
|
209
|
+
/**
|
|
210
|
+
* 工具注册信息
|
|
211
|
+
*/
|
|
212
|
+
export interface ToolRegistration {
|
|
213
|
+
/** 工具实例 */
|
|
214
|
+
tool: Tool;
|
|
215
|
+
/** 注册时间 */
|
|
216
|
+
registeredAt: number;
|
|
217
|
+
/** 注册来源 */
|
|
218
|
+
source: ToolSource;
|
|
219
|
+
/** 是否启用 */
|
|
220
|
+
enabled: boolean;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 工具执行请求
|
|
224
|
+
*/
|
|
225
|
+
export interface ToolExecuteRequest {
|
|
226
|
+
/** 工具名称 */
|
|
227
|
+
name: string;
|
|
228
|
+
/** 参数 */
|
|
229
|
+
args: Record<string, unknown>;
|
|
230
|
+
/** 上下文 */
|
|
231
|
+
context: ToolContext;
|
|
232
|
+
/** 是否跳过 Hook */
|
|
233
|
+
skipHooks?: boolean;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 工具列表过滤器
|
|
237
|
+
*/
|
|
238
|
+
export interface ToolListFilter {
|
|
239
|
+
/** 按名称过滤(支持 glob) */
|
|
240
|
+
name?: string | string[];
|
|
241
|
+
/** 按分类过滤 */
|
|
242
|
+
category?: string;
|
|
243
|
+
/** 按标签过滤 */
|
|
244
|
+
tags?: string[];
|
|
245
|
+
/** 按来源过滤 */
|
|
246
|
+
source?: ToolSource;
|
|
247
|
+
/** 只返回启用的工具 */
|
|
248
|
+
enabledOnly?: boolean;
|
|
249
|
+
/** 排除的工具 */
|
|
250
|
+
exclude?: string[];
|
|
251
|
+
/**
|
|
252
|
+
* 按 agent 名称过滤(2026-07 新增,工具级 agent-可见性过滤)
|
|
253
|
+
*
|
|
254
|
+
* 工作原理:
|
|
255
|
+
* - 若 tool.metadata.allowedAgentTypes 为 undefined 或 [] → 该工具对所有 agent 可见
|
|
256
|
+
* - 若 tool.metadata.allowedAgentTypes 非空 → 仅当 allowedAgent 命中数组中任一字符串时返回
|
|
257
|
+
* - 字符串精确匹配,大小写敏感
|
|
258
|
+
*
|
|
259
|
+
* 调用方传入 agent.name(如 "default"、"roy"、"strict-task-agent"),
|
|
260
|
+
* 通常由 AgentComponent.getAvailableTools(agent) 内部传入。
|
|
261
|
+
*/
|
|
262
|
+
allowedAgent?: string;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 参数验证结果
|
|
266
|
+
*/
|
|
267
|
+
export interface ValidationResult {
|
|
268
|
+
/** 是否成功 */
|
|
269
|
+
success: boolean;
|
|
270
|
+
/** 验证后的数据 */
|
|
271
|
+
data?: Record<string, unknown>;
|
|
272
|
+
/** 错误信息 */
|
|
273
|
+
error?: string;
|
|
274
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Tool, ValidationResult } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 工具参数验证器
|
|
4
|
+
*/
|
|
5
|
+
export declare class ToolValidator {
|
|
6
|
+
/**
|
|
7
|
+
* 验证参数
|
|
8
|
+
*/
|
|
9
|
+
validate(tool: Tool, args: Record<string, unknown>): Promise<ValidationResult>;
|
|
10
|
+
/**
|
|
11
|
+
* 格式化 Zod 错误
|
|
12
|
+
*/
|
|
13
|
+
private formatError;
|
|
14
|
+
}
|