@strands-agents/sdk 0.0.1
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/LICENSE +175 -0
- package/README.md +185 -0
- package/dist/__fixtures__/model-test-helpers.d.ts +56 -0
- package/dist/__fixtures__/model-test-helpers.d.ts.map +1 -0
- package/dist/__fixtures__/model-test-helpers.js +85 -0
- package/dist/__fixtures__/model-test-helpers.js.map +1 -0
- package/dist/__fixtures__/tool-helpers.d.ts +15 -0
- package/dist/__fixtures__/tool-helpers.d.ts.map +1 -0
- package/dist/__fixtures__/tool-helpers.js +22 -0
- package/dist/__fixtures__/tool-helpers.js.map +1 -0
- package/dist/__tests__/errors.test.d.ts +2 -0
- package/dist/__tests__/errors.test.d.ts.map +1 -0
- package/dist/__tests__/errors.test.js +20 -0
- package/dist/__tests__/errors.test.js.map +1 -0
- package/dist/__tests__/index.test.d.ts +2 -0
- package/dist/__tests__/index.test.d.ts.map +1 -0
- package/dist/__tests__/index.test.js +27 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/models/__tests__/bedrock.test.d.ts +2 -0
- package/dist/models/__tests__/bedrock.test.d.ts.map +1 -0
- package/dist/models/__tests__/bedrock.test.js +1161 -0
- package/dist/models/__tests__/bedrock.test.js.map +1 -0
- package/dist/models/__tests__/model.test.d.ts +2 -0
- package/dist/models/__tests__/model.test.d.ts.map +1 -0
- package/dist/models/__tests__/model.test.js +297 -0
- package/dist/models/__tests__/model.test.js.map +1 -0
- package/dist/models/__tests__/openai.test.d.ts +2 -0
- package/dist/models/__tests__/openai.test.d.ts.map +1 -0
- package/dist/models/__tests__/openai.test.js +1016 -0
- package/dist/models/__tests__/openai.test.js.map +1 -0
- package/dist/models/__tests__/test-utils.d.ts +10 -0
- package/dist/models/__tests__/test-utils.d.ts.map +1 -0
- package/dist/models/__tests__/test-utils.js +17 -0
- package/dist/models/__tests__/test-utils.js.map +1 -0
- package/dist/models/bedrock.d.ts +272 -0
- package/dist/models/bedrock.d.ts.map +1 -0
- package/dist/models/bedrock.js +679 -0
- package/dist/models/bedrock.js.map +1 -0
- package/dist/models/model.d.ts +89 -0
- package/dist/models/model.d.ts.map +1 -0
- package/dist/models/model.js +122 -0
- package/dist/models/model.js.map +1 -0
- package/dist/models/openai.d.ts +262 -0
- package/dist/models/openai.d.ts.map +1 -0
- package/dist/models/openai.js +625 -0
- package/dist/models/openai.js.map +1 -0
- package/dist/models/streaming.d.ts +226 -0
- package/dist/models/streaming.d.ts.map +1 -0
- package/dist/models/streaming.js +2 -0
- package/dist/models/streaming.js.map +1 -0
- package/dist/src/__fixtures__/agent-helpers.d.ts +29 -0
- package/dist/src/__fixtures__/agent-helpers.d.ts.map +1 -0
- package/dist/src/__fixtures__/agent-helpers.js +19 -0
- package/dist/src/__fixtures__/agent-helpers.js.map +1 -0
- package/dist/src/__fixtures__/environment.d.ts +12 -0
- package/dist/src/__fixtures__/environment.d.ts.map +1 -0
- package/dist/src/__fixtures__/environment.js +12 -0
- package/dist/src/__fixtures__/environment.js.map +1 -0
- package/dist/src/__fixtures__/mock-hook-provider.d.ts +14 -0
- package/dist/src/__fixtures__/mock-hook-provider.d.ts.map +1 -0
- package/dist/src/__fixtures__/mock-hook-provider.js +33 -0
- package/dist/src/__fixtures__/mock-hook-provider.js.map +1 -0
- package/dist/src/__fixtures__/mock-message-model.d.ts +93 -0
- package/dist/src/__fixtures__/mock-message-model.d.ts.map +1 -0
- package/dist/src/__fixtures__/mock-message-model.js +226 -0
- package/dist/src/__fixtures__/mock-message-model.js.map +1 -0
- package/dist/src/__fixtures__/model-test-helpers.d.ts +56 -0
- package/dist/src/__fixtures__/model-test-helpers.d.ts.map +1 -0
- package/dist/src/__fixtures__/model-test-helpers.js +85 -0
- package/dist/src/__fixtures__/model-test-helpers.js.map +1 -0
- package/dist/src/__fixtures__/tool-helpers.d.ts +37 -0
- package/dist/src/__fixtures__/tool-helpers.d.ts.map +1 -0
- package/dist/src/__fixtures__/tool-helpers.js +78 -0
- package/dist/src/__fixtures__/tool-helpers.js.map +1 -0
- package/dist/src/__tests__/errors.test.d.ts +2 -0
- package/dist/src/__tests__/errors.test.d.ts.map +1 -0
- package/dist/src/__tests__/errors.test.js +64 -0
- package/dist/src/__tests__/errors.test.js.map +1 -0
- package/dist/src/__tests__/index.test.d.ts +2 -0
- package/dist/src/__tests__/index.test.d.ts.map +1 -0
- package/dist/src/__tests__/index.test.js +27 -0
- package/dist/src/__tests__/index.test.js.map +1 -0
- package/dist/src/__tests__/mcp.test.d.ts +2 -0
- package/dist/src/__tests__/mcp.test.d.ts.map +1 -0
- package/dist/src/__tests__/mcp.test.js +166 -0
- package/dist/src/__tests__/mcp.test.js.map +1 -0
- package/dist/src/agent/__tests__/agent.hook.test.d.ts +2 -0
- package/dist/src/agent/__tests__/agent.hook.test.d.ts.map +1 -0
- package/dist/src/agent/__tests__/agent.hook.test.js +250 -0
- package/dist/src/agent/__tests__/agent.hook.test.js.map +1 -0
- package/dist/src/agent/__tests__/agent.test.d.ts +2 -0
- package/dist/src/agent/__tests__/agent.test.d.ts.map +1 -0
- package/dist/src/agent/__tests__/agent.test.js +414 -0
- package/dist/src/agent/__tests__/agent.test.js.map +1 -0
- package/dist/src/agent/__tests__/printer.test.d.ts +2 -0
- package/dist/src/agent/__tests__/printer.test.d.ts.map +1 -0
- package/dist/src/agent/__tests__/printer.test.js +152 -0
- package/dist/src/agent/__tests__/printer.test.js.map +1 -0
- package/dist/src/agent/__tests__/state.test.d.ts +2 -0
- package/dist/src/agent/__tests__/state.test.d.ts.map +1 -0
- package/dist/src/agent/__tests__/state.test.js +231 -0
- package/dist/src/agent/__tests__/state.test.js.map +1 -0
- package/dist/src/agent/agent.d.ts +207 -0
- package/dist/src/agent/agent.d.ts.map +1 -0
- package/dist/src/agent/agent.js +481 -0
- package/dist/src/agent/agent.js.map +1 -0
- package/dist/src/agent/printer.d.ts +73 -0
- package/dist/src/agent/printer.d.ts.map +1 -0
- package/dist/src/agent/printer.js +145 -0
- package/dist/src/agent/printer.js.map +1 -0
- package/dist/src/agent/state.d.ts +102 -0
- package/dist/src/agent/state.d.ts.map +1 -0
- package/dist/src/agent/state.js +73 -0
- package/dist/src/agent/state.js.map +1 -0
- package/dist/src/agent/streaming.d.ts +91 -0
- package/dist/src/agent/streaming.d.ts.map +1 -0
- package/dist/src/agent/streaming.js +2 -0
- package/dist/src/agent/streaming.js.map +1 -0
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.d.ts +2 -0
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.d.ts.map +1 -0
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.js +10 -0
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.js.map +1 -0
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.d.ts +2 -0
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.d.ts.map +1 -0
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.js +35 -0
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.js.map +1 -0
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.d.ts +2 -0
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.d.ts.map +1 -0
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js +553 -0
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js.map +1 -0
- package/dist/src/conversation-manager/conversation-manager.d.ts +73 -0
- package/dist/src/conversation-manager/conversation-manager.d.ts.map +1 -0
- package/dist/src/conversation-manager/conversation-manager.js +24 -0
- package/dist/src/conversation-manager/conversation-manager.js.map +1 -0
- package/dist/src/conversation-manager/index.d.ts +8 -0
- package/dist/src/conversation-manager/index.d.ts.map +1 -0
- package/dist/src/conversation-manager/index.js +8 -0
- package/dist/src/conversation-manager/index.js.map +1 -0
- package/dist/src/conversation-manager/null-conversation-manager.d.ts +23 -0
- package/dist/src/conversation-manager/null-conversation-manager.d.ts.map +1 -0
- package/dist/src/conversation-manager/null-conversation-manager.js +23 -0
- package/dist/src/conversation-manager/null-conversation-manager.js.map +1 -0
- package/dist/src/conversation-manager/sliding-window-conversation-manager.d.ts +105 -0
- package/dist/src/conversation-manager/sliding-window-conversation-manager.d.ts.map +1 -0
- package/dist/src/conversation-manager/sliding-window-conversation-manager.js +212 -0
- package/dist/src/conversation-manager/sliding-window-conversation-manager.js.map +1 -0
- package/dist/src/errors.d.ts +83 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +97 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/hooks/__tests__/events.test.d.ts +2 -0
- package/dist/src/hooks/__tests__/events.test.d.ts.map +1 -0
- package/dist/src/hooks/__tests__/events.test.js +347 -0
- package/dist/src/hooks/__tests__/events.test.js.map +1 -0
- package/dist/src/hooks/__tests__/registry.test.d.ts +2 -0
- package/dist/src/hooks/__tests__/registry.test.d.ts.map +1 -0
- package/dist/src/hooks/__tests__/registry.test.js +154 -0
- package/dist/src/hooks/__tests__/registry.test.js.map +1 -0
- package/dist/src/hooks/events.d.ts +199 -0
- package/dist/src/hooks/events.d.ts.map +1 -0
- package/dist/src/hooks/events.js +191 -0
- package/dist/src/hooks/events.js.map +1 -0
- package/dist/src/hooks/index.d.ts +11 -0
- package/dist/src/hooks/index.d.ts.map +1 -0
- package/dist/src/hooks/index.js +11 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/registry.d.ts +65 -0
- package/dist/src/hooks/registry.d.ts.map +1 -0
- package/dist/src/hooks/registry.js +65 -0
- package/dist/src/hooks/registry.js.map +1 -0
- package/dist/src/hooks/types.d.ts +49 -0
- package/dist/src/hooks/types.d.ts.map +1 -0
- package/dist/src/hooks/types.js +2 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp.d.ts +51 -0
- package/dist/src/mcp.d.ts.map +1 -0
- package/dist/src/mcp.js +91 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/models/__tests__/bedrock.test.d.ts +2 -0
- package/dist/src/models/__tests__/bedrock.test.d.ts.map +1 -0
- package/dist/src/models/__tests__/bedrock.test.js +1388 -0
- package/dist/src/models/__tests__/bedrock.test.js.map +1 -0
- package/dist/src/models/__tests__/model.test.d.ts +2 -0
- package/dist/src/models/__tests__/model.test.d.ts.map +1 -0
- package/dist/src/models/__tests__/model.test.js +342 -0
- package/dist/src/models/__tests__/model.test.js.map +1 -0
- package/dist/src/models/__tests__/openai.test.d.ts +2 -0
- package/dist/src/models/__tests__/openai.test.d.ts.map +1 -0
- package/dist/src/models/__tests__/openai.test.js +1189 -0
- package/dist/src/models/__tests__/openai.test.js.map +1 -0
- package/dist/src/models/__tests__/test-utils.d.ts +10 -0
- package/dist/src/models/__tests__/test-utils.d.ts.map +1 -0
- package/dist/src/models/__tests__/test-utils.js +17 -0
- package/dist/src/models/__tests__/test-utils.js.map +1 -0
- package/dist/src/models/bedrock.d.ts +289 -0
- package/dist/src/models/bedrock.d.ts.map +1 -0
- package/dist/src/models/bedrock.js +804 -0
- package/dist/src/models/bedrock.js.map +1 -0
- package/dist/src/models/model.d.ts +99 -0
- package/dist/src/models/model.d.ts.map +1 -0
- package/dist/src/models/model.js +169 -0
- package/dist/src/models/model.js.map +1 -0
- package/dist/src/models/openai.d.ts +262 -0
- package/dist/src/models/openai.d.ts.map +1 -0
- package/dist/src/models/openai.js +752 -0
- package/dist/src/models/openai.js.map +1 -0
- package/dist/src/models/streaming.d.ts +318 -0
- package/dist/src/models/streaming.d.ts.map +1 -0
- package/dist/src/models/streaming.js +122 -0
- package/dist/src/models/streaming.js.map +1 -0
- package/dist/src/registry/registry.d.ts +117 -0
- package/dist/src/registry/registry.d.ts.map +1 -0
- package/dist/src/registry/registry.js +298 -0
- package/dist/src/registry/registry.js.map +1 -0
- package/dist/src/registry/tool-registry.d.ts +34 -0
- package/dist/src/registry/tool-registry.d.ts.map +1 -0
- package/dist/src/registry/tool-registry.js +178 -0
- package/dist/src/registry/tool-registry.js.map +1 -0
- package/dist/src/tools/__tests__/tool.test.d.ts +2 -0
- package/dist/src/tools/__tests__/tool.test.d.ts.map +1 -0
- package/dist/src/tools/__tests__/tool.test.js +877 -0
- package/dist/src/tools/__tests__/tool.test.js.map +1 -0
- package/dist/src/tools/__tests__/zod-tool.test-d.d.ts +2 -0
- package/dist/src/tools/__tests__/zod-tool.test-d.d.ts.map +1 -0
- package/dist/src/tools/__tests__/zod-tool.test-d.js +227 -0
- package/dist/src/tools/__tests__/zod-tool.test-d.js.map +1 -0
- package/dist/src/tools/__tests__/zod-tool.test.d.ts +2 -0
- package/dist/src/tools/__tests__/zod-tool.test.d.ts.map +1 -0
- package/dist/src/tools/__tests__/zod-tool.test.js +372 -0
- package/dist/src/tools/__tests__/zod-tool.test.js.map +1 -0
- package/dist/src/tools/function-tool.d.ts +146 -0
- package/dist/src/tools/function-tool.d.ts.map +1 -0
- package/dist/src/tools/function-tool.js +188 -0
- package/dist/src/tools/function-tool.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +36 -0
- package/dist/src/tools/mcp-tool.d.ts.map +1 -0
- package/dist/src/tools/mcp-tool.js +78 -0
- package/dist/src/tools/mcp-tool.js.map +1 -0
- package/dist/src/tools/tool.d.ts +167 -0
- package/dist/src/tools/tool.d.ts.map +1 -0
- package/dist/src/tools/tool.js +68 -0
- package/dist/src/tools/tool.js.map +1 -0
- package/dist/src/tools/types.d.ts +62 -0
- package/dist/src/tools/types.d.ts.map +1 -0
- package/dist/src/tools/types.js +2 -0
- package/dist/src/tools/types.js.map +1 -0
- package/dist/src/tools/zod-tool.d.ts +70 -0
- package/dist/src/tools/zod-tool.d.ts.map +1 -0
- package/dist/src/tools/zod-tool.js +149 -0
- package/dist/src/tools/zod-tool.js.map +1 -0
- package/dist/src/types/__tests__/agent.test.d.ts +2 -0
- package/dist/src/types/__tests__/agent.test.d.ts.map +1 -0
- package/dist/src/types/__tests__/agent.test.js +155 -0
- package/dist/src/types/__tests__/agent.test.js.map +1 -0
- package/dist/src/types/__tests__/json.test.d.ts +2 -0
- package/dist/src/types/__tests__/json.test.d.ts.map +1 -0
- package/dist/src/types/__tests__/json.test.js +298 -0
- package/dist/src/types/__tests__/json.test.js.map +1 -0
- package/dist/src/types/__tests__/media.test.d.ts +2 -0
- package/dist/src/types/__tests__/media.test.d.ts.map +1 -0
- package/dist/src/types/__tests__/media.test.js +257 -0
- package/dist/src/types/__tests__/media.test.js.map +1 -0
- package/dist/src/types/__tests__/messages.test.d.ts +2 -0
- package/dist/src/types/__tests__/messages.test.d.ts.map +1 -0
- package/dist/src/types/__tests__/messages.test.js +364 -0
- package/dist/src/types/__tests__/messages.test.js.map +1 -0
- package/dist/src/types/__tests__/validation.test.d.ts +2 -0
- package/dist/src/types/__tests__/validation.test.d.ts.map +1 -0
- package/dist/src/types/__tests__/validation.test.js +30 -0
- package/dist/src/types/__tests__/validation.test.js.map +1 -0
- package/dist/src/types/agent.d.ts +57 -0
- package/dist/src/types/agent.d.ts.map +1 -0
- package/dist/src/types/agent.js +47 -0
- package/dist/src/types/agent.js.map +1 -0
- package/dist/src/types/json.d.ts +55 -0
- package/dist/src/types/json.d.ts.map +1 -0
- package/dist/src/types/json.js +72 -0
- package/dist/src/types/json.js.map +1 -0
- package/dist/src/types/media.d.ts +249 -0
- package/dist/src/types/media.d.ts.map +1 -0
- package/dist/src/types/media.js +173 -0
- package/dist/src/types/media.js.map +1 -0
- package/dist/src/types/messages.d.ts +438 -0
- package/dist/src/types/messages.d.ts.map +1 -0
- package/dist/src/types/messages.js +286 -0
- package/dist/src/types/messages.js.map +1 -0
- package/dist/src/types/validation.d.ts +10 -0
- package/dist/src/types/validation.d.ts.map +1 -0
- package/dist/src/types/validation.js +15 -0
- package/dist/src/types/validation.js.map +1 -0
- package/dist/tools/__tests__/registry.test.d.ts +2 -0
- package/dist/tools/__tests__/registry.test.d.ts.map +1 -0
- package/dist/tools/__tests__/registry.test.js +253 -0
- package/dist/tools/__tests__/registry.test.js.map +1 -0
- package/dist/tools/__tests__/tool.test.d.ts +2 -0
- package/dist/tools/__tests__/tool.test.d.ts.map +1 -0
- package/dist/tools/__tests__/tool.test.js +761 -0
- package/dist/tools/__tests__/tool.test.js.map +1 -0
- package/dist/tools/__tests__/zod-tool.test-d.d.ts +2 -0
- package/dist/tools/__tests__/zod-tool.test-d.d.ts.map +1 -0
- package/dist/tools/__tests__/zod-tool.test-d.js +227 -0
- package/dist/tools/__tests__/zod-tool.test-d.js.map +1 -0
- package/dist/tools/__tests__/zod-tool.test.d.ts +2 -0
- package/dist/tools/__tests__/zod-tool.test.d.ts.map +1 -0
- package/dist/tools/__tests__/zod-tool.test.js +342 -0
- package/dist/tools/__tests__/zod-tool.test.js.map +1 -0
- package/dist/tools/function-tool.d.ts +156 -0
- package/dist/tools/function-tool.d.ts.map +1 -0
- package/dist/tools/function-tool.js +237 -0
- package/dist/tools/function-tool.js.map +1 -0
- package/dist/tools/registry.d.ts +43 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +82 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/tool.d.ts +157 -0
- package/dist/tools/tool.d.ts.map +1 -0
- package/dist/tools/tool.js +2 -0
- package/dist/tools/tool.js.map +1 -0
- package/dist/tools/types.d.ts +119 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/zod-tool.d.ts +70 -0
- package/dist/tools/zod-tool.d.ts.map +1 -0
- package/dist/tools/zod-tool.js +96 -0
- package/dist/tools/zod-tool.js.map +1 -0
- package/dist/types/__tests__/json.test.d.ts +2 -0
- package/dist/types/__tests__/json.test.d.ts.map +1 -0
- package/dist/types/__tests__/json.test.js +129 -0
- package/dist/types/__tests__/json.test.js.map +1 -0
- package/dist/types/__tests__/validation.test.d.ts +2 -0
- package/dist/types/__tests__/validation.test.d.ts.map +1 -0
- package/dist/types/__tests__/validation.test.js +30 -0
- package/dist/types/__tests__/validation.test.js.map +1 -0
- package/dist/types/json.d.ts +45 -0
- package/dist/types/json.d.ts.map +1 -0
- package/dist/types/json.js +17 -0
- package/dist/types/json.js.map +1 -0
- package/dist/types/messages.d.ts +160 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +2 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/validation.d.ts +10 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/dist/types/validation.js +15 -0
- package/dist/types/validation.js.map +1 -0
- package/dist/vended_tools/bash/__tests__/bash.test.d.ts +2 -0
- package/dist/vended_tools/bash/__tests__/bash.test.d.ts.map +1 -0
- package/dist/vended_tools/bash/__tests__/bash.test.js +333 -0
- package/dist/vended_tools/bash/__tests__/bash.test.js.map +1 -0
- package/dist/vended_tools/bash/bash.d.ts +33 -0
- package/dist/vended_tools/bash/bash.d.ts.map +1 -0
- package/dist/vended_tools/bash/bash.js +264 -0
- package/dist/vended_tools/bash/bash.js.map +1 -0
- package/dist/vended_tools/bash/index.d.ts +7 -0
- package/dist/vended_tools/bash/index.d.ts.map +1 -0
- package/dist/vended_tools/bash/index.js +6 -0
- package/dist/vended_tools/bash/index.js.map +1 -0
- package/dist/vended_tools/bash/types.d.ts +65 -0
- package/dist/vended_tools/bash/types.d.ts.map +1 -0
- package/dist/vended_tools/bash/types.js +22 -0
- package/dist/vended_tools/bash/types.js.map +1 -0
- package/dist/vended_tools/file_editor/__tests__/file-editor.test.d.ts +2 -0
- package/dist/vended_tools/file_editor/__tests__/file-editor.test.d.ts.map +1 -0
- package/dist/vended_tools/file_editor/__tests__/file-editor.test.js +359 -0
- package/dist/vended_tools/file_editor/__tests__/file-editor.test.js.map +1 -0
- package/dist/vended_tools/file_editor/file-editor.d.ts +31 -0
- package/dist/vended_tools/file_editor/file-editor.d.ts.map +1 -0
- package/dist/vended_tools/file_editor/file-editor.js +353 -0
- package/dist/vended_tools/file_editor/file-editor.js.map +1 -0
- package/dist/vended_tools/file_editor/index.d.ts +6 -0
- package/dist/vended_tools/file_editor/index.d.ts.map +1 -0
- package/dist/vended_tools/file_editor/index.js +5 -0
- package/dist/vended_tools/file_editor/index.js.map +1 -0
- package/dist/vended_tools/file_editor/types.d.ts +61 -0
- package/dist/vended_tools/file_editor/types.d.ts.map +1 -0
- package/dist/vended_tools/file_editor/types.js +2 -0
- package/dist/vended_tools/file_editor/types.js.map +1 -0
- package/dist/vended_tools/http_request/__tests__/http-request.test.d.ts +2 -0
- package/dist/vended_tools/http_request/__tests__/http-request.test.d.ts.map +1 -0
- package/dist/vended_tools/http_request/__tests__/http-request.test.js +189 -0
- package/dist/vended_tools/http_request/__tests__/http-request.test.js.map +1 -0
- package/dist/vended_tools/http_request/http-request.d.ts +35 -0
- package/dist/vended_tools/http_request/http-request.d.ts.map +1 -0
- package/dist/vended_tools/http_request/http-request.js +95 -0
- package/dist/vended_tools/http_request/http-request.js.map +1 -0
- package/dist/vended_tools/http_request/index.d.ts +6 -0
- package/dist/vended_tools/http_request/index.d.ts.map +1 -0
- package/dist/vended_tools/http_request/index.js +5 -0
- package/dist/vended_tools/http_request/index.js.map +1 -0
- package/dist/vended_tools/http_request/types.d.ts +47 -0
- package/dist/vended_tools/http_request/types.d.ts.map +1 -0
- package/dist/vended_tools/http_request/types.js +2 -0
- package/dist/vended_tools/http_request/types.js.map +1 -0
- package/dist/vended_tools/notebook/__tests__/notebook.test.d.ts +2 -0
- package/dist/vended_tools/notebook/__tests__/notebook.test.d.ts.map +1 -0
- package/dist/vended_tools/notebook/__tests__/notebook.test.js +371 -0
- package/dist/vended_tools/notebook/__tests__/notebook.test.js.map +1 -0
- package/dist/vended_tools/notebook/index.d.ts +6 -0
- package/dist/vended_tools/notebook/index.d.ts.map +1 -0
- package/dist/vended_tools/notebook/index.js +5 -0
- package/dist/vended_tools/notebook/index.js.map +1 -0
- package/dist/vended_tools/notebook/notebook.d.ts +29 -0
- package/dist/vended_tools/notebook/notebook.d.ts.map +1 -0
- package/dist/vended_tools/notebook/notebook.js +215 -0
- package/dist/vended_tools/notebook/notebook.js.map +1 -0
- package/dist/vended_tools/notebook/types.d.ts +79 -0
- package/dist/vended_tools/notebook/types.d.ts.map +1 -0
- package/dist/vended_tools/notebook/types.js +2 -0
- package/dist/vended_tools/notebook/types.js.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
+
import { bash } from '../index.js';
|
|
3
|
+
import { BashTimeoutError, BashSessionError } from '../index.js';
|
|
4
|
+
import { AgentState } from '../../../src/agent/state.js';
|
|
5
|
+
import { isNode } from '../../../src/__fixtures__/environment.js';
|
|
6
|
+
// Skip all tests if not in Node.js environment
|
|
7
|
+
describe.skipIf(!isNode || process.platform === 'win32')('bash tool', () => {
|
|
8
|
+
// Helper to create fresh context
|
|
9
|
+
const createFreshContext = () => {
|
|
10
|
+
const state = new AgentState({});
|
|
11
|
+
const context = {
|
|
12
|
+
toolUse: {
|
|
13
|
+
name: 'bash',
|
|
14
|
+
toolUseId: 'test-id',
|
|
15
|
+
input: {},
|
|
16
|
+
},
|
|
17
|
+
agent: { state, messages: [] },
|
|
18
|
+
};
|
|
19
|
+
return { state, context };
|
|
20
|
+
};
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
vi.restoreAllMocks();
|
|
23
|
+
});
|
|
24
|
+
describe('input validation', () => {
|
|
25
|
+
it('accepts valid execute command', async () => {
|
|
26
|
+
const { context } = createFreshContext();
|
|
27
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "test"' }, context);
|
|
28
|
+
expect(result).toHaveProperty('output');
|
|
29
|
+
expect(result).toHaveProperty('error');
|
|
30
|
+
});
|
|
31
|
+
it('accepts valid restart command', async () => {
|
|
32
|
+
const { context } = createFreshContext();
|
|
33
|
+
const result = await bash.invoke({ mode: 'restart' }, context);
|
|
34
|
+
expect(result).toBe('Bash session restarted');
|
|
35
|
+
});
|
|
36
|
+
it('rejects invalid mode', async () => {
|
|
37
|
+
const { context } = createFreshContext();
|
|
38
|
+
await expect(
|
|
39
|
+
// @ts-expect-error - Testing invalid input
|
|
40
|
+
bash.invoke({ mode: 'invalid' }, context)).rejects.toThrow();
|
|
41
|
+
});
|
|
42
|
+
it('rejects execute without command', async () => {
|
|
43
|
+
const { context } = createFreshContext();
|
|
44
|
+
await expect(bash.invoke({ mode: 'execute' }, context)).rejects.toThrow();
|
|
45
|
+
});
|
|
46
|
+
it('accepts valid timeout configuration', async () => {
|
|
47
|
+
const { context } = createFreshContext();
|
|
48
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "fast"', timeout: 300 }, context);
|
|
49
|
+
expect(result).toHaveProperty('output');
|
|
50
|
+
});
|
|
51
|
+
it('rejects negative timeout', async () => {
|
|
52
|
+
const { context } = createFreshContext();
|
|
53
|
+
await expect(bash.invoke({ mode: 'execute', command: 'echo test', timeout: -1 }, context)).rejects.toThrow();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('session lifecycle', () => {
|
|
57
|
+
it('creates session on first execute', async () => {
|
|
58
|
+
const { context } = createFreshContext();
|
|
59
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "test"' }, context);
|
|
60
|
+
expect(result).toHaveProperty('output');
|
|
61
|
+
expect(result.output).toContain('test');
|
|
62
|
+
});
|
|
63
|
+
it('creates new session after restart', async () => {
|
|
64
|
+
const { context } = createFreshContext();
|
|
65
|
+
// Set variable
|
|
66
|
+
await bash.invoke({ mode: 'execute', command: 'TEST_RESTART="exists"' }, context);
|
|
67
|
+
// Restart
|
|
68
|
+
const restartResult = await bash.invoke({ mode: 'restart' }, context);
|
|
69
|
+
expect(restartResult).toBe('Bash session restarted');
|
|
70
|
+
// Variable should be gone
|
|
71
|
+
const afterRestart = await bash.invoke({ mode: 'execute', command: 'echo $TEST_RESTART' }, context);
|
|
72
|
+
expect(afterRestart.output.trim()).not.toContain('exists');
|
|
73
|
+
});
|
|
74
|
+
it('restarts existing session when restart is called', async () => {
|
|
75
|
+
const { context } = createFreshContext();
|
|
76
|
+
// First create a session by executing a command
|
|
77
|
+
await bash.invoke({ mode: 'execute', command: 'TEST_VAR="initial"' }, context);
|
|
78
|
+
// Now restart the existing session
|
|
79
|
+
const restartResult = await bash.invoke({ mode: 'restart' }, context);
|
|
80
|
+
expect(restartResult).toBe('Bash session restarted');
|
|
81
|
+
// Verify the variable is gone after restart
|
|
82
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "${TEST_VAR:-empty}"' }, context);
|
|
83
|
+
expect(result.output.trim()).toBe('empty');
|
|
84
|
+
});
|
|
85
|
+
it('provides isolated sessions for different agents', async () => {
|
|
86
|
+
const { context: context1 } = createFreshContext();
|
|
87
|
+
const { context: context2 } = createFreshContext();
|
|
88
|
+
// Set variable in first agent
|
|
89
|
+
await bash.invoke({ mode: 'execute', command: 'AGENT_VAR="agent1"' }, context1);
|
|
90
|
+
// Check it's not in second agent
|
|
91
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo $AGENT_VAR' }, context2);
|
|
92
|
+
expect(result.output.trim()).not.toContain('agent1');
|
|
93
|
+
});
|
|
94
|
+
it('handles session restart with no existing session gracefully', async () => {
|
|
95
|
+
const { context } = createFreshContext();
|
|
96
|
+
// Restart when no session exists
|
|
97
|
+
const result = await bash.invoke({ mode: 'restart' }, context);
|
|
98
|
+
expect(result).toBe('Bash session restarted');
|
|
99
|
+
// Should still be able to execute commands
|
|
100
|
+
const execResult = await bash.invoke({ mode: 'execute', command: 'echo "works"' }, context);
|
|
101
|
+
expect(execResult.output.trim()).toBe('works');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe('command execution', () => {
|
|
105
|
+
it('executes command and returns output', async () => {
|
|
106
|
+
const { context } = createFreshContext();
|
|
107
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "Hello World"' }, context);
|
|
108
|
+
expect(result.output).toContain('Hello World');
|
|
109
|
+
expect(result.error).toBe('');
|
|
110
|
+
});
|
|
111
|
+
it('returns empty stderr on success', async () => {
|
|
112
|
+
const { context } = createFreshContext();
|
|
113
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "success"' }, context);
|
|
114
|
+
expect(result.error).toBe('');
|
|
115
|
+
});
|
|
116
|
+
it('captures stderr on command error', async () => {
|
|
117
|
+
const { context } = createFreshContext();
|
|
118
|
+
const result = await bash.invoke({ mode: 'execute', command: 'nonexistent_command_xyz' }, context);
|
|
119
|
+
expect(result.error).toContain('not found');
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('timeout handling', () => {
|
|
123
|
+
it('completes command before timeout', async () => {
|
|
124
|
+
const { context } = createFreshContext();
|
|
125
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "fast"', timeout: 5 }, context);
|
|
126
|
+
expect(result.output).toContain('fast');
|
|
127
|
+
});
|
|
128
|
+
it('throws BashTimeoutError when command times out', async () => {
|
|
129
|
+
const { context } = createFreshContext();
|
|
130
|
+
await expect(bash.invoke({ mode: 'execute', command: 'sleep 10', timeout: 0.1 }, context)).rejects.toThrow(BashTimeoutError);
|
|
131
|
+
});
|
|
132
|
+
it('uses default timeout of 120 seconds', async () => {
|
|
133
|
+
const { context } = createFreshContext();
|
|
134
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "test"' }, context);
|
|
135
|
+
expect(result).toHaveProperty('output');
|
|
136
|
+
});
|
|
137
|
+
it('respects custom timeout for new session', async () => {
|
|
138
|
+
const { context } = createFreshContext();
|
|
139
|
+
// Create session with custom timeout
|
|
140
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "custom"', timeout: 10 }, context);
|
|
141
|
+
expect(result.output).toContain('custom');
|
|
142
|
+
});
|
|
143
|
+
it('handles timeout during command with large output', async () => {
|
|
144
|
+
const { context } = createFreshContext();
|
|
145
|
+
// Command that generates output continuously
|
|
146
|
+
await expect(bash.invoke({ mode: 'execute', command: 'while true; do echo "spam"; done', timeout: 0.1 }, context)).rejects.toThrow(BashTimeoutError);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('error handling', () => {
|
|
150
|
+
it('requires context for bash operations', async () => {
|
|
151
|
+
await expect(bash.invoke({ mode: 'execute', command: 'echo "test"' })).rejects.toThrow('Tool context is required');
|
|
152
|
+
});
|
|
153
|
+
it('validates command is required for execute mode', async () => {
|
|
154
|
+
const { context } = createFreshContext();
|
|
155
|
+
await expect(bash.invoke({ mode: 'execute' }, context)).rejects.toThrow('command is required when mode is "execute"');
|
|
156
|
+
});
|
|
157
|
+
it('validates command is required with undefined command', async () => {
|
|
158
|
+
const { context } = createFreshContext();
|
|
159
|
+
await expect(bash.invoke({ mode: 'execute', command: undefined }, context)).rejects.toThrow('command is required when mode is "execute"');
|
|
160
|
+
});
|
|
161
|
+
it('validates command is required with empty string', async () => {
|
|
162
|
+
const { context } = createFreshContext();
|
|
163
|
+
await expect(bash.invoke({ mode: 'execute', command: '' }, context)).rejects.toThrow('command is required when mode is "execute"');
|
|
164
|
+
});
|
|
165
|
+
it('handles command execution in a session without proper initialization', async () => {
|
|
166
|
+
const { context } = createFreshContext();
|
|
167
|
+
// Create a session first
|
|
168
|
+
await bash.invoke({ mode: 'execute', command: 'echo "init"' }, context);
|
|
169
|
+
// Then restart to clear it
|
|
170
|
+
await bash.invoke({ mode: 'restart' }, context);
|
|
171
|
+
// Try to execute another command - should work as it creates a new session
|
|
172
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "after restart"' }, context);
|
|
173
|
+
expect(result.output).toContain('after restart');
|
|
174
|
+
});
|
|
175
|
+
it('creates new session when none exists', async () => {
|
|
176
|
+
const { context } = createFreshContext();
|
|
177
|
+
// First command should create a new session
|
|
178
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "first"' }, context);
|
|
179
|
+
expect(result.output).toContain('first');
|
|
180
|
+
});
|
|
181
|
+
it('handles restart when no session exists', async () => {
|
|
182
|
+
const { context } = createFreshContext();
|
|
183
|
+
// Restart without existing session should not throw
|
|
184
|
+
const result = await bash.invoke({ mode: 'restart' }, context);
|
|
185
|
+
expect(result).toBe('Bash session restarted');
|
|
186
|
+
});
|
|
187
|
+
it('properly cleans up session on restart', async () => {
|
|
188
|
+
const { context } = createFreshContext();
|
|
189
|
+
// Create session with variable
|
|
190
|
+
await bash.invoke({ mode: 'execute', command: 'CLEANUP_TEST="should_be_gone"' }, context);
|
|
191
|
+
// Restart should clear the session
|
|
192
|
+
await bash.invoke({ mode: 'restart' }, context);
|
|
193
|
+
// Variable should not exist in new session
|
|
194
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "${CLEANUP_TEST:-empty}"' }, context);
|
|
195
|
+
expect(result.output.trim()).toBe('empty');
|
|
196
|
+
});
|
|
197
|
+
it('handles multiple restarts in sequence', async () => {
|
|
198
|
+
const { context } = createFreshContext();
|
|
199
|
+
// Restart without existing session
|
|
200
|
+
const result1 = await bash.invoke({ mode: 'restart' }, context);
|
|
201
|
+
expect(result1).toBe('Bash session restarted');
|
|
202
|
+
// Restart again
|
|
203
|
+
const result2 = await bash.invoke({ mode: 'restart' }, context);
|
|
204
|
+
expect(result2).toBe('Bash session restarted');
|
|
205
|
+
// Should still be able to execute
|
|
206
|
+
const execResult = await bash.invoke({ mode: 'execute', command: 'echo "still works"' }, context);
|
|
207
|
+
expect(execResult.output).toContain('still works');
|
|
208
|
+
});
|
|
209
|
+
it('handles command with empty output gracefully', async () => {
|
|
210
|
+
const { context } = createFreshContext();
|
|
211
|
+
const result = await bash.invoke({ mode: 'execute', command: 'true' }, context);
|
|
212
|
+
expect(result.output).toBe('');
|
|
213
|
+
expect(result.error).toBe('');
|
|
214
|
+
});
|
|
215
|
+
it('handles command with only whitespace output', async () => {
|
|
216
|
+
const { context } = createFreshContext();
|
|
217
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo " "' }, context);
|
|
218
|
+
expect(result.output.trim()).toBe('');
|
|
219
|
+
});
|
|
220
|
+
it('handles very long command output', async () => {
|
|
221
|
+
const { context } = createFreshContext();
|
|
222
|
+
// Generate a long string
|
|
223
|
+
const result = await bash.invoke({
|
|
224
|
+
mode: 'execute',
|
|
225
|
+
command: 'for i in {1..100}; do echo "Line $i of output"; done',
|
|
226
|
+
}, context);
|
|
227
|
+
expect(result.output).toContain('Line 1 of output');
|
|
228
|
+
expect(result.output).toContain('Line 100 of output');
|
|
229
|
+
});
|
|
230
|
+
it('creates session with default timeout when not specified', async () => {
|
|
231
|
+
const { context } = createFreshContext();
|
|
232
|
+
// Execute without timeout parameter
|
|
233
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "default"' }, context);
|
|
234
|
+
expect(result.output).toContain('default');
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
describe('working directory', () => {
|
|
238
|
+
it('starts in process.cwd()', async () => {
|
|
239
|
+
const { context } = createFreshContext();
|
|
240
|
+
const expectedCwd = process.cwd();
|
|
241
|
+
const result = await bash.invoke({ mode: 'execute', command: 'pwd' }, context);
|
|
242
|
+
expect(result.output).toContain(expectedCwd);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
describe('tool properties', () => {
|
|
246
|
+
it('has correct tool name', () => {
|
|
247
|
+
expect(bash.name).toBe('bash');
|
|
248
|
+
});
|
|
249
|
+
it('has description', () => {
|
|
250
|
+
expect(bash.description).toBeDefined();
|
|
251
|
+
expect(bash.description.length).toBeGreaterThan(0);
|
|
252
|
+
});
|
|
253
|
+
it('has toolSpec', () => {
|
|
254
|
+
expect(bash.toolSpec).toBeDefined();
|
|
255
|
+
expect(bash.toolSpec.name).toBe('bash');
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
describe('error classes', () => {
|
|
259
|
+
it('BashTimeoutError has correct properties', () => {
|
|
260
|
+
const error = new BashTimeoutError('timeout message');
|
|
261
|
+
expect(error.name).toBe('BashTimeoutError');
|
|
262
|
+
expect(error.message).toBe('timeout message');
|
|
263
|
+
expect(error instanceof Error).toBe(true);
|
|
264
|
+
});
|
|
265
|
+
it('BashSessionError has correct properties', () => {
|
|
266
|
+
const error = new BashSessionError('session error message');
|
|
267
|
+
expect(error.name).toBe('BashSessionError');
|
|
268
|
+
expect(error.message).toBe('session error message');
|
|
269
|
+
expect(error instanceof Error).toBe(true);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
describe('module exports', () => {
|
|
273
|
+
it('exports bash tool from index', () => {
|
|
274
|
+
expect(bash).toBeDefined();
|
|
275
|
+
expect(bash.name).toBe('bash');
|
|
276
|
+
});
|
|
277
|
+
it('exports error classes from index', () => {
|
|
278
|
+
expect(BashTimeoutError).toBeDefined();
|
|
279
|
+
expect(BashSessionError).toBeDefined();
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe('bash session edge cases', () => {
|
|
283
|
+
it('handles process close during command execution', async () => {
|
|
284
|
+
const { context } = createFreshContext();
|
|
285
|
+
// Use a command that will make the bash process exit - this should throw an error
|
|
286
|
+
await expect(bash.invoke({ mode: 'execute', command: 'exit 0' }, context)).rejects.toThrow(BashSessionError);
|
|
287
|
+
// Next command should work with a new session
|
|
288
|
+
const newResult = await bash.invoke({ mode: 'execute', command: 'echo "new session"' }, context);
|
|
289
|
+
expect(newResult.output).toContain('new session');
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
describe('process cleanup', () => {
|
|
293
|
+
it('cleans up on beforeExit event', async () => {
|
|
294
|
+
const { context } = createFreshContext();
|
|
295
|
+
// Create a session
|
|
296
|
+
await bash.invoke({ mode: 'execute', command: 'echo "test"' }, context);
|
|
297
|
+
// Simulate beforeExit event
|
|
298
|
+
process.emit('beforeExit', 0);
|
|
299
|
+
// Session should be cleaned up, next command creates new session
|
|
300
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "after exit"' }, context);
|
|
301
|
+
expect(result.output).toContain('after exit');
|
|
302
|
+
});
|
|
303
|
+
it('cleans up on exit event', async () => {
|
|
304
|
+
const { context } = createFreshContext();
|
|
305
|
+
// Create a session
|
|
306
|
+
await bash.invoke({ mode: 'execute', command: 'echo "test"' }, context);
|
|
307
|
+
// Simulate exit event
|
|
308
|
+
process.emit('exit', 0);
|
|
309
|
+
// Session should be cleaned up
|
|
310
|
+
const result = await bash.invoke({ mode: 'execute', command: 'echo "after exit"' }, context);
|
|
311
|
+
expect(result.output).toContain('after exit');
|
|
312
|
+
});
|
|
313
|
+
it('cleans up on SIGINT', async () => {
|
|
314
|
+
const { context } = createFreshContext();
|
|
315
|
+
// Mock process.exit to prevent actual exit
|
|
316
|
+
const exitMock = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
317
|
+
throw new Error('process.exit called');
|
|
318
|
+
});
|
|
319
|
+
// Create a session
|
|
320
|
+
await bash.invoke({ mode: 'execute', command: 'echo "test"' }, context);
|
|
321
|
+
// Simulate SIGINT
|
|
322
|
+
try {
|
|
323
|
+
process.emit('SIGINT');
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
// Expected to throw due to our mock
|
|
327
|
+
}
|
|
328
|
+
expect(exitMock).toHaveBeenCalledWith(0);
|
|
329
|
+
exitMock.mockRestore();
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
//# sourceMappingURL=bash.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.test.js","sourceRoot":"","sources":["../../../../vended_tools/bash/__tests__/bash.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,M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AO,CAAC,CAAA;YAC5F,MAAM,CAAE,MAAqB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;QAC/D,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YACnC,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAA;YAExC,2CAA2C;YAC3C,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE;gBACjE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;YACxC,CAAC,CAAC,CAAA;YAEF,mBAAmB;YACnB,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,CAAA;YAEvE,kBAAkB;YAClB,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,oCAAoC;YACtC,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAA;YACxC,QAAQ,CAAC,WAAW,EAAE,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BashOutput } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bash tool for executing shell commands in Node.js environments.
|
|
4
|
+
*
|
|
5
|
+
* This tool provides a persistent bash session that can execute commands and maintain state
|
|
6
|
+
* across multiple invocations within the same agent session.
|
|
7
|
+
*
|
|
8
|
+
* **Security Warning**: This tool executes arbitrary bash commands without sandboxing.
|
|
9
|
+
* Only use with trusted input and consider sandboxing for production deployments.
|
|
10
|
+
*
|
|
11
|
+
* **Node.js Only**: This tool requires Node.js and the `child_process` module.
|
|
12
|
+
* It will not work in browser environments.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // With agent
|
|
17
|
+
* const agent = new Agent({ tools: [bash] })
|
|
18
|
+
* await agent.invoke('List files in the current directory')
|
|
19
|
+
*
|
|
20
|
+
* // Direct usage
|
|
21
|
+
* const result = await bash.invoke(
|
|
22
|
+
* { mode: 'execute', command: 'echo "Hello"' },
|
|
23
|
+
* context
|
|
24
|
+
* )
|
|
25
|
+
* console.log(result.output) // "Hello"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const bash: import("../../src/index.js").InvokableTool<{
|
|
29
|
+
mode: "execute" | "restart";
|
|
30
|
+
command?: string | undefined;
|
|
31
|
+
timeout?: number | undefined;
|
|
32
|
+
}, BashOutput | "Bash session restarted">;
|
|
33
|
+
//# sourceMappingURL=bash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../vended_tools/bash/bash.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AA2N5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI;;;;yCA8Cf,CAAA"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
import { tool } from '../../src/tools/zod-tool.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
6
|
+
import { BashTimeoutError, BashSessionError } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for bash input validation.
|
|
9
|
+
*
|
|
10
|
+
* Note: Uses a single object schema instead of discriminated union for AWS Bedrock compatibility.
|
|
11
|
+
*/
|
|
12
|
+
const bashInputSchema = z.object({
|
|
13
|
+
mode: z
|
|
14
|
+
.enum(['execute', 'restart'])
|
|
15
|
+
.describe('Operation mode: "execute" to run a command, "restart" to restart the session'),
|
|
16
|
+
command: z.string().optional().describe('The bash command to execute (required when mode is "execute")'),
|
|
17
|
+
timeout: z.number().positive().optional().describe('Timeout in seconds (default: 120, applies only to execute mode)'),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Internal class for managing a bash session.
|
|
21
|
+
*/
|
|
22
|
+
class BashSession {
|
|
23
|
+
_process = null;
|
|
24
|
+
_started = false;
|
|
25
|
+
_timeout;
|
|
26
|
+
_sentinel;
|
|
27
|
+
constructor(timeout = 120) {
|
|
28
|
+
this._timeout = timeout;
|
|
29
|
+
this._sentinel = `__BASH_DONE_${Date.now()}_${Math.random().toString(36).slice(2)}__`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Starts the bash process if not already started.
|
|
33
|
+
*/
|
|
34
|
+
start() {
|
|
35
|
+
if (this._started) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
this._process = spawn('bash', [], {
|
|
40
|
+
cwd: process.cwd(),
|
|
41
|
+
env: { ...process.env, PS1: '', PS2: '' },
|
|
42
|
+
});
|
|
43
|
+
if (!this._process.stdin || !this._process.stdout || !this._process.stderr) {
|
|
44
|
+
throw new BashSessionError('Failed to create bash process streams');
|
|
45
|
+
}
|
|
46
|
+
this._started = true;
|
|
47
|
+
// Handle unexpected process exits
|
|
48
|
+
this._process.on('close', () => {
|
|
49
|
+
this._process = null;
|
|
50
|
+
this._started = false;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new BashSessionError(`Failed to start bash session: ${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Stops the bash process.
|
|
59
|
+
*/
|
|
60
|
+
stop() {
|
|
61
|
+
if (this._process) {
|
|
62
|
+
this._process.kill();
|
|
63
|
+
this._process = null;
|
|
64
|
+
this._started = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Runs a command in the bash session.
|
|
69
|
+
*/
|
|
70
|
+
async run(command, timeout) {
|
|
71
|
+
this.start();
|
|
72
|
+
if (!this._process || !this._process.stdin || !this._process.stdout || !this._process.stderr) {
|
|
73
|
+
throw new BashSessionError('Bash session not properly initialized');
|
|
74
|
+
}
|
|
75
|
+
const effectiveTimeout = timeout ?? this._timeout;
|
|
76
|
+
let stdoutData = '';
|
|
77
|
+
let stderrData = '';
|
|
78
|
+
// eslint-disable-next-line no-undef
|
|
79
|
+
let timeoutHandle = null;
|
|
80
|
+
let isTimedOut = false;
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
const stdout = this._process.stdout;
|
|
83
|
+
const stderr = this._process.stderr;
|
|
84
|
+
const stdin = this._process.stdin;
|
|
85
|
+
// Handlers for stdout
|
|
86
|
+
const onStdoutData = (chunk) => {
|
|
87
|
+
const data = Buffer.from(chunk).toString('utf-8');
|
|
88
|
+
stdoutData += data;
|
|
89
|
+
// Check for sentinel
|
|
90
|
+
if (stdoutData.includes(this._sentinel)) {
|
|
91
|
+
cleanup();
|
|
92
|
+
// Remove sentinel from output
|
|
93
|
+
const output = stdoutData.replace(this._sentinel, '').trim();
|
|
94
|
+
const error = stderrData.trim();
|
|
95
|
+
resolve({ output, error });
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
// Handlers for stderr
|
|
99
|
+
const onStderrData = (chunk) => {
|
|
100
|
+
stderrData += Buffer.from(chunk).toString('utf-8');
|
|
101
|
+
};
|
|
102
|
+
// Handler for process close
|
|
103
|
+
const onClose = (code) => {
|
|
104
|
+
if (!isTimedOut) {
|
|
105
|
+
cleanup();
|
|
106
|
+
reject(new BashSessionError(`Bash process exited unexpectedly with code ${code ?? 'unknown'}`));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
// Handler for process errors
|
|
110
|
+
const onError = (err) => {
|
|
111
|
+
cleanup();
|
|
112
|
+
reject(new BashSessionError(`Bash process error: ${err.message}`));
|
|
113
|
+
};
|
|
114
|
+
// Cleanup function
|
|
115
|
+
const cleanup = () => {
|
|
116
|
+
if (timeoutHandle !== null) {
|
|
117
|
+
// eslint-disable-next-line no-undef
|
|
118
|
+
clearTimeout(timeoutHandle);
|
|
119
|
+
timeoutHandle = null;
|
|
120
|
+
}
|
|
121
|
+
stdout.off('data', onStdoutData);
|
|
122
|
+
stderr.off('data', onStderrData);
|
|
123
|
+
// Check if process still exists before removing listeners
|
|
124
|
+
if (this._process) {
|
|
125
|
+
this._process.off('close', onClose);
|
|
126
|
+
this._process.off('error', onError);
|
|
127
|
+
}
|
|
128
|
+
// Kill the process after command completes to allow clean exit
|
|
129
|
+
// This is important for one-shot scripts that need to terminate
|
|
130
|
+
this.stop();
|
|
131
|
+
activeSessions.delete(this);
|
|
132
|
+
};
|
|
133
|
+
// Set up timeout
|
|
134
|
+
// eslint-disable-next-line no-undef
|
|
135
|
+
timeoutHandle = setTimeout(() => {
|
|
136
|
+
isTimedOut = true;
|
|
137
|
+
cleanup();
|
|
138
|
+
// Check if process still exists before killing
|
|
139
|
+
if (this._process) {
|
|
140
|
+
this._process.kill();
|
|
141
|
+
}
|
|
142
|
+
this._started = false;
|
|
143
|
+
reject(new BashTimeoutError(`Command timed out after ${effectiveTimeout} seconds`));
|
|
144
|
+
}, effectiveTimeout * 1000);
|
|
145
|
+
// Attach listeners
|
|
146
|
+
stdout.on('data', onStdoutData);
|
|
147
|
+
stderr.on('data', onStderrData);
|
|
148
|
+
this._process.on('close', onClose);
|
|
149
|
+
this._process.on('error', onError);
|
|
150
|
+
// Send command with sentinel
|
|
151
|
+
try {
|
|
152
|
+
stdin.write(`${command}\necho "${this._sentinel}"\n`);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
cleanup();
|
|
156
|
+
reject(new BashSessionError(`Failed to write command: ${err.message}`));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* WeakMap to store bash sessions per agent instance.
|
|
163
|
+
*/
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
+
const sessions = new WeakMap();
|
|
166
|
+
/**
|
|
167
|
+
* Track all active sessions for cleanup on process exit.
|
|
168
|
+
*/
|
|
169
|
+
const activeSessions = new Set();
|
|
170
|
+
/**
|
|
171
|
+
* Clean up all active bash sessions.
|
|
172
|
+
*/
|
|
173
|
+
function cleanupAllSessions() {
|
|
174
|
+
for (const session of activeSessions) {
|
|
175
|
+
session.stop();
|
|
176
|
+
}
|
|
177
|
+
activeSessions.clear();
|
|
178
|
+
}
|
|
179
|
+
// Register cleanup handlers for process exit
|
|
180
|
+
process.on('beforeExit', () => {
|
|
181
|
+
// beforeExit fires when event loop is empty but process is still alive
|
|
182
|
+
// This is our chance to clean up bash processes before they prevent exit
|
|
183
|
+
cleanupAllSessions();
|
|
184
|
+
});
|
|
185
|
+
process.on('exit', cleanupAllSessions);
|
|
186
|
+
process.on('SIGINT', () => {
|
|
187
|
+
cleanupAllSessions();
|
|
188
|
+
/* c8 ignore next */
|
|
189
|
+
process.exit(0);
|
|
190
|
+
});
|
|
191
|
+
/* c8 ignore start */
|
|
192
|
+
process.on('SIGTERM', () => {
|
|
193
|
+
cleanupAllSessions();
|
|
194
|
+
process.exit(0);
|
|
195
|
+
});
|
|
196
|
+
/* c8 ignore stop */
|
|
197
|
+
/**
|
|
198
|
+
* Bash tool for executing shell commands in Node.js environments.
|
|
199
|
+
*
|
|
200
|
+
* This tool provides a persistent bash session that can execute commands and maintain state
|
|
201
|
+
* across multiple invocations within the same agent session.
|
|
202
|
+
*
|
|
203
|
+
* **Security Warning**: This tool executes arbitrary bash commands without sandboxing.
|
|
204
|
+
* Only use with trusted input and consider sandboxing for production deployments.
|
|
205
|
+
*
|
|
206
|
+
* **Node.js Only**: This tool requires Node.js and the `child_process` module.
|
|
207
|
+
* It will not work in browser environments.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // With agent
|
|
212
|
+
* const agent = new Agent({ tools: [bash] })
|
|
213
|
+
* await agent.invoke('List files in the current directory')
|
|
214
|
+
*
|
|
215
|
+
* // Direct usage
|
|
216
|
+
* const result = await bash.invoke(
|
|
217
|
+
* { mode: 'execute', command: 'echo "Hello"' },
|
|
218
|
+
* context
|
|
219
|
+
* )
|
|
220
|
+
* console.log(result.output) // "Hello"
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export const bash = tool({
|
|
224
|
+
name: 'bash',
|
|
225
|
+
description: 'Executes bash shell commands in a persistent session. Supports execute and restart modes. ' +
|
|
226
|
+
'Commands persist state (variables, directory) within the session. Node.js only.',
|
|
227
|
+
inputSchema: bashInputSchema,
|
|
228
|
+
callback: async (input, context) => {
|
|
229
|
+
if (!context) {
|
|
230
|
+
throw new Error('Tool context is required for bash operations');
|
|
231
|
+
}
|
|
232
|
+
const agent = context.agent;
|
|
233
|
+
// Validate execute mode has command
|
|
234
|
+
if (input.mode === 'execute' && !input.command) {
|
|
235
|
+
throw new Error('command is required when mode is "execute"');
|
|
236
|
+
}
|
|
237
|
+
// Handle restart mode
|
|
238
|
+
if (input.mode === 'restart') {
|
|
239
|
+
const existingSession = sessions.get(agent);
|
|
240
|
+
if (existingSession) {
|
|
241
|
+
existingSession.stop();
|
|
242
|
+
activeSessions.delete(existingSession);
|
|
243
|
+
sessions.delete(agent);
|
|
244
|
+
}
|
|
245
|
+
// Create new session
|
|
246
|
+
const newSession = new BashSession(120);
|
|
247
|
+
sessions.set(agent, newSession);
|
|
248
|
+
activeSessions.add(newSession);
|
|
249
|
+
return 'Bash session restarted';
|
|
250
|
+
}
|
|
251
|
+
// Handle execute mode
|
|
252
|
+
// Get or create session
|
|
253
|
+
let session = sessions.get(agent);
|
|
254
|
+
if (!session) {
|
|
255
|
+
session = new BashSession(input.timeout ?? 120);
|
|
256
|
+
sessions.set(agent, session);
|
|
257
|
+
activeSessions.add(session);
|
|
258
|
+
}
|
|
259
|
+
// Execute command
|
|
260
|
+
const result = await session.run(input.command, input.timeout);
|
|
261
|
+
return result;
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
//# sourceMappingURL=bash.js.map
|