@dexto/core 1.1.11 → 1.2.0
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/README.md +24 -4
- package/dist/Dexto.cjs +4 -14
- package/dist/Dexto.d.ts +8 -29
- package/dist/Dexto.d.ts.map +1 -1
- package/dist/Dexto.js +4 -12
- package/dist/agent/DextoAgent.cjs +92 -3
- package/dist/agent/DextoAgent.d.ts +12 -4
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +52 -3
- package/dist/agent/agentCard.js +1 -0
- package/dist/agent/error-codes.cjs +1 -0
- package/dist/agent/error-codes.d.ts +1 -0
- package/dist/agent/error-codes.d.ts.map +1 -1
- package/dist/agent/error-codes.js +2 -0
- package/dist/agent/errors.cjs +13 -0
- package/dist/agent/errors.d.ts +4 -0
- package/dist/agent/errors.d.ts.map +1 -1
- package/dist/agent/errors.js +14 -0
- package/dist/agent/index.js +1 -0
- package/dist/agent/registry/error-codes.js +1 -0
- package/dist/agent/registry/errors.js +1 -0
- package/dist/agent/registry/registry.js +1 -0
- package/dist/agent/registry/types.js +1 -0
- package/dist/agent/registry/user-registry.js +1 -0
- package/dist/agent/schemas.cjs +6 -1
- package/dist/agent/schemas.d.ts +113 -3
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +7 -1
- package/dist/agent/state-manager.js +1 -0
- package/dist/approval/error-codes.js +1 -0
- package/dist/approval/errors.js +1 -0
- package/dist/approval/index.js +1 -0
- package/dist/approval/manager.cjs +30 -0
- package/dist/approval/manager.d.ts +23 -1
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +31 -0
- package/dist/approval/providers/event-based-approval-provider.js +1 -0
- package/dist/approval/providers/factory.js +1 -0
- package/dist/approval/providers/noop-approval-provider.js +1 -0
- package/dist/approval/schemas.cjs +36 -0
- package/dist/approval/schemas.d.ts +173 -0
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +33 -0
- package/dist/approval/types.cjs +1 -0
- package/dist/approval/types.d.ts +27 -1
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/approval/types.js +2 -0
- package/dist/chunk-C6A6W6XS.js +53 -0
- package/dist/config/agent-resolver.js +1 -0
- package/dist/config/error-codes.js +1 -0
- package/dist/config/errors.js +1 -0
- package/dist/config/loader.js +1 -0
- package/dist/config/writer.js +1 -0
- package/dist/context/compression/middle-removal.js +1 -0
- package/dist/context/compression/oldest-removal.js +1 -0
- package/dist/context/error-codes.js +1 -0
- package/dist/context/errors.js +1 -0
- package/dist/context/index.js +1 -0
- package/dist/context/manager.cjs +36 -1
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +27 -1
- package/dist/context/media-helpers.js +1 -0
- package/dist/context/utils.cjs +102 -6
- package/dist/context/utils.d.ts +35 -2
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +100 -6
- package/dist/errors/DextoBaseError.js +1 -0
- package/dist/errors/DextoRuntimeError.js +1 -0
- package/dist/errors/DextoValidationError.js +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/result-bridge.js +1 -0
- package/dist/errors/types.cjs +3 -0
- package/dist/errors/types.d.ts +7 -2
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +4 -0
- package/dist/events/index.cjs +1 -0
- package/dist/events/index.d.ts +6 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -0
- package/dist/filesystem/error-codes.cjs +53 -0
- package/dist/filesystem/error-codes.d.ts +31 -0
- package/dist/filesystem/error-codes.d.ts.map +1 -0
- package/dist/filesystem/error-codes.js +30 -0
- package/dist/filesystem/errors.cjs +303 -0
- package/dist/filesystem/errors.d.ts +109 -0
- package/dist/filesystem/errors.d.ts.map +1 -0
- package/dist/filesystem/errors.js +280 -0
- package/dist/filesystem/filesystem-service.cjs +482 -0
- package/dist/filesystem/filesystem-service.d.ts +57 -0
- package/dist/filesystem/filesystem-service.d.ts.map +1 -0
- package/dist/filesystem/filesystem-service.js +449 -0
- package/dist/filesystem/index.cjs +37 -0
- package/dist/filesystem/index.d.ts +11 -0
- package/dist/filesystem/index.d.ts.map +1 -0
- package/dist/filesystem/index.js +11 -0
- package/dist/filesystem/path-validator.cjs +172 -0
- package/dist/filesystem/path-validator.d.ts +53 -0
- package/dist/filesystem/path-validator.d.ts.map +1 -0
- package/dist/filesystem/path-validator.js +139 -0
- package/dist/filesystem/types.cjs +16 -0
- package/dist/filesystem/types.d.ts +171 -0
- package/dist/filesystem/types.d.ts.map +1 -0
- package/dist/filesystem/types.js +0 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/llm/error-codes.js +1 -0
- package/dist/llm/errors.js +1 -0
- package/dist/llm/formatters/anthropic.js +1 -0
- package/dist/llm/formatters/factory.js +1 -0
- package/dist/llm/formatters/openai.js +1 -0
- package/dist/llm/formatters/vercel.js +1 -0
- package/dist/llm/registry.cjs +15 -15
- package/dist/llm/registry.d.ts +1 -1
- package/dist/llm/registry.js +16 -15
- package/dist/llm/resolver.js +1 -0
- package/dist/llm/schemas.cjs +6 -2
- package/dist/llm/schemas.d.ts +10 -0
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +7 -2
- package/dist/llm/services/anthropic.cjs +67 -0
- package/dist/llm/services/anthropic.d.ts +6 -0
- package/dist/llm/services/anthropic.d.ts.map +1 -1
- package/dist/llm/services/anthropic.js +27 -0
- package/dist/llm/services/factory.js +1 -0
- package/dist/llm/services/openai.cjs +87 -0
- package/dist/llm/services/openai.d.ts +6 -0
- package/dist/llm/services/openai.d.ts.map +1 -1
- package/dist/llm/services/openai.js +47 -0
- package/dist/llm/services/test-utils.integration.cjs +1 -1
- package/dist/llm/services/test-utils.integration.js +2 -1
- package/dist/llm/services/vercel.cjs +144 -97
- package/dist/llm/services/vercel.d.ts +6 -1
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +105 -98
- package/dist/llm/tokenizer/anthropic.js +1 -0
- package/dist/llm/tokenizer/default.js +1 -0
- package/dist/llm/tokenizer/factory.js +1 -0
- package/dist/llm/tokenizer/google.js +1 -0
- package/dist/llm/tokenizer/openai.cjs +1 -1
- package/dist/llm/tokenizer/openai.d.ts +1 -1
- package/dist/llm/tokenizer/openai.js +2 -1
- package/dist/llm/tokenizer/types.js +1 -0
- package/dist/llm/types.d.ts +2 -2
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +1 -0
- package/dist/llm/validation.js +1 -0
- package/dist/logger/browser.js +1 -0
- package/dist/logger/logger.d.ts +42 -0
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +1 -0
- package/dist/mcp/error-codes.cjs +1 -0
- package/dist/mcp/error-codes.d.ts +1 -0
- package/dist/mcp/error-codes.d.ts.map +1 -1
- package/dist/mcp/error-codes.js +2 -0
- package/dist/mcp/errors.cjs +12 -0
- package/dist/mcp/errors.d.ts +7 -0
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/errors.js +13 -0
- package/dist/mcp/manager.cjs +66 -16
- package/dist/mcp/manager.d.ts +7 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +67 -16
- package/dist/mcp/mcp-client.js +1 -0
- package/dist/mcp/resolver.js +1 -0
- package/dist/mcp/schemas.js +1 -0
- package/dist/mcp/types.d.ts +1 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/memory/error-codes.js +1 -0
- package/dist/memory/errors.js +1 -0
- package/dist/memory/index.js +1 -0
- package/dist/memory/manager.js +1 -0
- package/dist/memory/schemas.js +1 -0
- package/dist/plugins/builtins/content-policy.js +1 -0
- package/dist/plugins/builtins/response-sanitizer.js +1 -0
- package/dist/plugins/error-codes.js +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/loader.js +1 -0
- package/dist/plugins/manager.js +1 -0
- package/dist/plugins/registrations/builtins.js +1 -0
- package/dist/plugins/schemas.js +1 -0
- package/dist/preferences/constants.js +1 -0
- package/dist/preferences/error-codes.js +1 -0
- package/dist/preferences/errors.js +1 -0
- package/dist/preferences/index.js +1 -0
- package/dist/preferences/loader.cjs +3 -1
- package/dist/preferences/loader.d.ts +10 -1
- package/dist/preferences/loader.d.ts.map +1 -1
- package/dist/preferences/loader.js +4 -1
- package/dist/preferences/schemas.cjs +2 -1
- package/dist/preferences/schemas.d.ts +8 -0
- package/dist/preferences/schemas.d.ts.map +1 -1
- package/dist/preferences/schemas.js +3 -1
- package/dist/process/command-validator.cjs +544 -0
- package/dist/process/command-validator.d.ts +46 -0
- package/dist/process/command-validator.d.ts.map +1 -0
- package/dist/process/command-validator.js +521 -0
- package/dist/process/error-codes.cjs +47 -0
- package/dist/process/error-codes.d.ts +25 -0
- package/dist/process/error-codes.d.ts.map +1 -0
- package/dist/process/error-codes.js +24 -0
- package/dist/process/errors.cjs +244 -0
- package/dist/process/errors.d.ts +87 -0
- package/dist/process/errors.d.ts.map +1 -0
- package/dist/process/errors.js +221 -0
- package/dist/process/index.cjs +37 -0
- package/dist/process/index.d.ts +11 -0
- package/dist/process/index.d.ts.map +1 -0
- package/dist/process/index.js +11 -0
- package/dist/process/process-service.cjs +443 -0
- package/dist/process/process-service.d.ts +62 -0
- package/dist/process/process-service.d.ts.map +1 -0
- package/dist/process/process-service.js +410 -0
- package/dist/process/types.cjs +16 -0
- package/dist/process/types.d.ts +107 -0
- package/dist/process/types.d.ts.map +1 -0
- package/dist/process/types.js +0 -0
- package/dist/prompts/error-codes.js +1 -0
- package/dist/prompts/errors.js +1 -0
- package/dist/prompts/index.js +1 -0
- package/dist/prompts/name-validation.js +1 -0
- package/dist/prompts/prompt-manager.js +1 -0
- package/dist/prompts/providers/custom-prompt-provider.js +1 -0
- package/dist/prompts/providers/file-prompt-provider.js +1 -0
- package/dist/prompts/providers/mcp-prompt-provider.js +1 -0
- package/dist/prompts/providers/starter-prompt-provider.js +1 -0
- package/dist/prompts/schemas.js +1 -0
- package/dist/prompts/utils.js +1 -0
- package/dist/resources/error-codes.js +1 -0
- package/dist/resources/errors.js +1 -0
- package/dist/resources/handlers/blob-handler.js +1 -0
- package/dist/resources/handlers/factory.js +1 -0
- package/dist/resources/handlers/filesystem-handler.cjs +1 -1
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +2 -1
- package/dist/resources/index.js +1 -0
- package/dist/resources/internal-provider.js +1 -0
- package/dist/resources/manager.js +1 -0
- package/dist/resources/reference-parser.js +1 -0
- package/dist/resources/schemas.js +1 -0
- package/dist/search/index.js +1 -0
- package/dist/search/search-service.js +1 -0
- package/dist/session/chat-session.cjs +2 -2
- package/dist/session/chat-session.d.ts +2 -2
- package/dist/session/chat-session.js +3 -2
- package/dist/session/error-codes.js +1 -0
- package/dist/session/errors.js +1 -0
- package/dist/session/history/database.js +1 -0
- package/dist/session/history/factory.js +1 -0
- package/dist/session/history/memory.js +1 -0
- package/dist/session/index.js +1 -0
- package/dist/session/schemas.js +1 -0
- package/dist/session/session-manager.d.ts +6 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +1 -0
- package/dist/session/title-generator.js +1 -0
- package/dist/storage/blob/factory.cjs +3 -3
- package/dist/storage/blob/factory.d.ts +3 -1
- package/dist/storage/blob/factory.d.ts.map +1 -1
- package/dist/storage/blob/factory.js +4 -3
- package/dist/storage/blob/local-blob-store.cjs +18 -2
- package/dist/storage/blob/local-blob-store.d.ts +2 -1
- package/dist/storage/blob/local-blob-store.d.ts.map +1 -1
- package/dist/storage/blob/local-blob-store.js +19 -2
- package/dist/storage/blob/schemas.js +1 -0
- package/dist/storage/cache/factory.js +1 -0
- package/dist/storage/cache/memory-cache-store.js +1 -0
- package/dist/storage/cache/redis-store.js +1 -0
- package/dist/storage/cache/schemas.js +1 -0
- package/dist/storage/database/factory.cjs +7 -5
- package/dist/storage/database/factory.d.ts +3 -1
- package/dist/storage/database/factory.d.ts.map +1 -1
- package/dist/storage/database/factory.js +8 -5
- package/dist/storage/database/memory-database-store.js +1 -0
- package/dist/storage/database/postgres-store.js +1 -0
- package/dist/storage/database/schemas.cjs +1 -1
- package/dist/storage/database/schemas.js +2 -1
- package/dist/storage/database/sqlite-store.cjs +20 -2
- package/dist/storage/database/sqlite-store.d.ts +2 -1
- package/dist/storage/database/sqlite-store.d.ts.map +1 -1
- package/dist/storage/database/sqlite-store.js +21 -2
- package/dist/storage/error-codes.cjs +1 -0
- package/dist/storage/error-codes.d.ts +1 -0
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +2 -0
- package/dist/storage/errors.cjs +15 -0
- package/dist/storage/errors.d.ts +4 -0
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +16 -0
- package/dist/storage/index.js +1 -0
- package/dist/storage/schemas.js +1 -0
- package/dist/storage/storage-manager.cjs +7 -5
- package/dist/storage/storage-manager.d.ts +5 -2
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +8 -5
- package/dist/systemPrompt/contributors.js +1 -0
- package/dist/systemPrompt/error-codes.js +1 -0
- package/dist/systemPrompt/errors.js +1 -0
- package/dist/systemPrompt/in-built-prompts.js +1 -0
- package/dist/systemPrompt/index.js +1 -0
- package/dist/systemPrompt/manager.js +1 -0
- package/dist/systemPrompt/registry.js +1 -0
- package/dist/systemPrompt/schemas.js +1 -0
- package/dist/telemetry/decorators.cjs +175 -0
- package/dist/telemetry/decorators.d.ts +17 -0
- package/dist/telemetry/decorators.d.ts.map +1 -0
- package/dist/telemetry/decorators.js +157 -0
- package/dist/telemetry/exporters.cjs +108 -0
- package/dist/telemetry/exporters.d.ts +29 -0
- package/dist/telemetry/exporters.d.ts.map +1 -0
- package/dist/telemetry/exporters.js +85 -0
- package/dist/telemetry/index.cjs +28 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/schemas.cjs +71 -0
- package/dist/telemetry/schemas.d.ts +54 -0
- package/dist/telemetry/schemas.d.ts.map +1 -0
- package/dist/telemetry/schemas.js +48 -0
- package/dist/telemetry/telemetry.cjs +228 -0
- package/dist/telemetry/telemetry.d.ts +74 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/telemetry/telemetry.js +205 -0
- package/dist/telemetry/types.cjs +16 -0
- package/dist/telemetry/types.d.ts +22 -0
- package/dist/telemetry/types.d.ts.map +1 -0
- package/dist/telemetry/types.js +0 -0
- package/dist/telemetry/utils.cjs +87 -0
- package/dist/telemetry/utils.d.ts +21 -0
- package/dist/telemetry/utils.d.ts.map +1 -0
- package/dist/telemetry/utils.js +62 -0
- package/dist/tools/confirmation/allowed-tools-provider/factory.js +1 -0
- package/dist/tools/confirmation/allowed-tools-provider/in-memory.js +1 -0
- package/dist/tools/confirmation/allowed-tools-provider/storage.js +1 -0
- package/dist/tools/error-codes.js +1 -0
- package/dist/tools/errors.js +1 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/internal-tools/constants.cjs +39 -0
- package/dist/tools/internal-tools/constants.d.ts +12 -0
- package/dist/tools/internal-tools/constants.d.ts.map +1 -0
- package/dist/tools/internal-tools/constants.js +16 -0
- package/dist/tools/internal-tools/implementations/ask-user-tool.js +1 -0
- package/dist/tools/internal-tools/implementations/bash-exec-tool.cjs +106 -0
- package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts +13 -0
- package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/bash-exec-tool.js +73 -0
- package/dist/tools/internal-tools/implementations/bash-output-tool.cjs +49 -0
- package/dist/tools/internal-tools/implementations/bash-output-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/bash-output-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/bash-output-tool.js +26 -0
- package/dist/tools/internal-tools/implementations/edit-file-tool.cjs +62 -0
- package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/edit-file-tool.js +39 -0
- package/dist/tools/internal-tools/implementations/glob-files-tool.cjs +57 -0
- package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/glob-files-tool.js +34 -0
- package/dist/tools/internal-tools/implementations/grep-content-tool.cjs +71 -0
- package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/grep-content-tool.js +48 -0
- package/dist/tools/internal-tools/implementations/kill-process-tool.cjs +47 -0
- package/dist/tools/internal-tools/implementations/kill-process-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/kill-process-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/kill-process-tool.js +24 -0
- package/dist/tools/internal-tools/implementations/read-file-tool.cjs +55 -0
- package/dist/tools/internal-tools/implementations/read-file-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/read-file-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/read-file-tool.js +32 -0
- package/dist/tools/internal-tools/implementations/search-history-tool.js +1 -0
- package/dist/tools/internal-tools/implementations/write-file-tool.cjs +56 -0
- package/dist/tools/internal-tools/implementations/write-file-tool.d.ts +12 -0
- package/dist/tools/internal-tools/implementations/write-file-tool.d.ts.map +1 -0
- package/dist/tools/internal-tools/implementations/write-file-tool.js +33 -0
- package/dist/tools/internal-tools/index.cjs +3 -1
- package/dist/tools/internal-tools/index.d.ts +1 -0
- package/dist/tools/internal-tools/index.d.ts.map +1 -1
- package/dist/tools/internal-tools/index.js +1 -0
- package/dist/tools/internal-tools/provider.js +1 -0
- package/dist/tools/internal-tools/registry.cjs +40 -4
- package/dist/tools/internal-tools/registry.d.ts +5 -9
- package/dist/tools/internal-tools/registry.d.ts.map +1 -1
- package/dist/tools/internal-tools/registry.js +41 -3
- package/dist/tools/schemas.cjs +18 -5
- package/dist/tools/schemas.d.ts +30 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +15 -2
- package/dist/tools/tool-manager.cjs +158 -19
- package/dist/tools/tool-manager.d.ts +48 -2
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +118 -19
- package/dist/utils/api-key-resolver.js +1 -0
- package/dist/utils/api-key-store.js +1 -0
- package/dist/utils/async-context.js +1 -0
- package/dist/utils/debug.js +1 -0
- package/dist/utils/env.js +1 -0
- package/dist/utils/error-conversion.js +1 -0
- package/dist/utils/execution-context.js +1 -0
- package/dist/utils/fs-walk.js +1 -0
- package/dist/utils/path.js +1 -0
- package/dist/utils/port-utils.js +1 -0
- package/dist/utils/redactor.js +1 -0
- package/dist/utils/result.js +1 -0
- package/dist/utils/safe-stringify.js +1 -0
- package/dist/utils/schema-metadata.js +1 -0
- package/dist/utils/schema.js +1 -0
- package/dist/utils/service-initializer.cjs +42 -4
- package/dist/utils/service-initializer.d.ts +2 -1
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +33 -4
- package/dist/utils/user-info.js +1 -0
- package/dist/utils/zod-schema-converter.js +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var filesystem_service_exports = {};
|
|
30
|
+
__export(filesystem_service_exports, {
|
|
31
|
+
FileSystemService: () => FileSystemService
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(filesystem_service_exports);
|
|
34
|
+
var fs = __toESM(require("node:fs/promises"), 1);
|
|
35
|
+
var path = __toESM(require("node:path"), 1);
|
|
36
|
+
var import_glob = require("glob");
|
|
37
|
+
var import_path_validator = require("./path-validator.js");
|
|
38
|
+
var import_errors = require("./errors.js");
|
|
39
|
+
var import_logger = require("../logger/index.js");
|
|
40
|
+
const DEFAULT_ENCODING = "utf-8";
|
|
41
|
+
const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
42
|
+
const DEFAULT_MAX_RESULTS = 1e3;
|
|
43
|
+
const DEFAULT_MAX_SEARCH_RESULTS = 100;
|
|
44
|
+
class FileSystemService {
|
|
45
|
+
config;
|
|
46
|
+
pathValidator;
|
|
47
|
+
initialized = false;
|
|
48
|
+
constructor(config = {}) {
|
|
49
|
+
this.config = {
|
|
50
|
+
allowedPaths: config.allowedPaths || ["."],
|
|
51
|
+
blockedPaths: config.blockedPaths || [".git", "node_modules/.bin", ".env"],
|
|
52
|
+
blockedExtensions: config.blockedExtensions || [".exe", ".dll", ".so"],
|
|
53
|
+
maxFileSize: config.maxFileSize || DEFAULT_MAX_FILE_SIZE,
|
|
54
|
+
enableBackups: config.enableBackups ?? true,
|
|
55
|
+
backupPath: config.backupPath || ".dexto/backups",
|
|
56
|
+
backupRetentionDays: config.backupRetentionDays || 7,
|
|
57
|
+
workingDirectory: config.workingDirectory
|
|
58
|
+
};
|
|
59
|
+
this.pathValidator = new import_path_validator.PathValidator(this.config);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Initialize the service
|
|
63
|
+
*/
|
|
64
|
+
async initialize() {
|
|
65
|
+
if (this.initialized) {
|
|
66
|
+
import_logger.logger.debug("FileSystemService already initialized");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (this.config.enableBackups) {
|
|
70
|
+
try {
|
|
71
|
+
const backupDir = path.resolve(
|
|
72
|
+
this.config.workingDirectory || process.cwd(),
|
|
73
|
+
this.config.backupPath
|
|
74
|
+
);
|
|
75
|
+
await fs.mkdir(backupDir, { recursive: true });
|
|
76
|
+
import_logger.logger.debug(`Backup directory created/verified: ${backupDir}`);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
import_logger.logger.warn(
|
|
79
|
+
`Failed to create backup directory: ${error instanceof Error ? error.message : String(error)}`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.initialized = true;
|
|
84
|
+
import_logger.logger.info("FileSystemService initialized successfully");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Read a file with validation and size limits
|
|
88
|
+
*/
|
|
89
|
+
async readFile(filePath, options = {}) {
|
|
90
|
+
if (!this.initialized) {
|
|
91
|
+
throw import_errors.FileSystemError.notInitialized();
|
|
92
|
+
}
|
|
93
|
+
const validation = this.pathValidator.validatePath(filePath);
|
|
94
|
+
if (!validation.isValid || !validation.normalizedPath) {
|
|
95
|
+
throw import_errors.FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
96
|
+
}
|
|
97
|
+
const normalizedPath = validation.normalizedPath;
|
|
98
|
+
try {
|
|
99
|
+
const stats = await fs.stat(normalizedPath);
|
|
100
|
+
if (!stats.isFile()) {
|
|
101
|
+
throw import_errors.FileSystemError.invalidPath(normalizedPath, "Path is not a file");
|
|
102
|
+
}
|
|
103
|
+
if (stats.size > this.config.maxFileSize) {
|
|
104
|
+
throw import_errors.FileSystemError.fileTooLarge(
|
|
105
|
+
normalizedPath,
|
|
106
|
+
stats.size,
|
|
107
|
+
this.config.maxFileSize
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (error.code === "ENOENT") {
|
|
112
|
+
throw import_errors.FileSystemError.fileNotFound(normalizedPath);
|
|
113
|
+
}
|
|
114
|
+
if (error.code === "EACCES") {
|
|
115
|
+
throw import_errors.FileSystemError.permissionDenied(normalizedPath, "read");
|
|
116
|
+
}
|
|
117
|
+
throw import_errors.FileSystemError.readFailed(
|
|
118
|
+
normalizedPath,
|
|
119
|
+
error instanceof Error ? error.message : String(error)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const encoding = options.encoding || DEFAULT_ENCODING;
|
|
124
|
+
const content = await fs.readFile(normalizedPath, encoding);
|
|
125
|
+
const lines = content.split("\n");
|
|
126
|
+
const limit = options.limit;
|
|
127
|
+
const offset1 = options.offset;
|
|
128
|
+
let selectedLines;
|
|
129
|
+
let truncated = false;
|
|
130
|
+
if (offset1 && offset1 > 0 || limit !== void 0) {
|
|
131
|
+
const start = offset1 && offset1 > 0 ? Math.max(0, offset1 - 1) : 0;
|
|
132
|
+
const end = limit !== void 0 ? start + limit : lines.length;
|
|
133
|
+
selectedLines = lines.slice(start, end);
|
|
134
|
+
truncated = end < lines.length;
|
|
135
|
+
} else {
|
|
136
|
+
selectedLines = lines;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
content: selectedLines.join("\n"),
|
|
140
|
+
lines: selectedLines.length,
|
|
141
|
+
encoding,
|
|
142
|
+
truncated,
|
|
143
|
+
size: Buffer.byteLength(content, encoding)
|
|
144
|
+
};
|
|
145
|
+
} catch (error) {
|
|
146
|
+
throw import_errors.FileSystemError.readFailed(
|
|
147
|
+
normalizedPath,
|
|
148
|
+
error instanceof Error ? error.message : String(error)
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Find files matching a glob pattern
|
|
154
|
+
*/
|
|
155
|
+
async globFiles(pattern, options = {}) {
|
|
156
|
+
if (!this.initialized) {
|
|
157
|
+
throw import_errors.FileSystemError.notInitialized();
|
|
158
|
+
}
|
|
159
|
+
const cwd = options.cwd || this.config.workingDirectory || process.cwd();
|
|
160
|
+
const maxResults = options.maxResults || DEFAULT_MAX_RESULTS;
|
|
161
|
+
try {
|
|
162
|
+
const files = await (0, import_glob.glob)(pattern, {
|
|
163
|
+
cwd,
|
|
164
|
+
absolute: true,
|
|
165
|
+
nodir: true,
|
|
166
|
+
// Only files
|
|
167
|
+
follow: false
|
|
168
|
+
// Don't follow symlinks
|
|
169
|
+
});
|
|
170
|
+
const validFiles = [];
|
|
171
|
+
for (const file of files) {
|
|
172
|
+
const validation = this.pathValidator.validatePath(file);
|
|
173
|
+
if (!validation.isValid || !validation.normalizedPath) {
|
|
174
|
+
import_logger.logger.debug(`Skipping invalid path: ${file}`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (options.includeMetadata !== false) {
|
|
178
|
+
try {
|
|
179
|
+
const stats = await fs.stat(validation.normalizedPath);
|
|
180
|
+
validFiles.push({
|
|
181
|
+
path: validation.normalizedPath,
|
|
182
|
+
size: stats.size,
|
|
183
|
+
modified: stats.mtime,
|
|
184
|
+
isDirectory: stats.isDirectory()
|
|
185
|
+
});
|
|
186
|
+
} catch (error) {
|
|
187
|
+
import_logger.logger.debug(
|
|
188
|
+
`Failed to stat file ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
validFiles.push({
|
|
193
|
+
path: validation.normalizedPath,
|
|
194
|
+
size: 0,
|
|
195
|
+
modified: /* @__PURE__ */ new Date(),
|
|
196
|
+
isDirectory: false
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (validFiles.length >= maxResults) {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const limited = validFiles.length >= maxResults;
|
|
204
|
+
return {
|
|
205
|
+
files: validFiles,
|
|
206
|
+
truncated: limited,
|
|
207
|
+
totalFound: validFiles.length
|
|
208
|
+
};
|
|
209
|
+
} catch (error) {
|
|
210
|
+
throw import_errors.FileSystemError.globFailed(
|
|
211
|
+
pattern,
|
|
212
|
+
error instanceof Error ? error.message : String(error)
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Search for content in files (grep-like functionality)
|
|
218
|
+
*/
|
|
219
|
+
async searchContent(pattern, options = {}) {
|
|
220
|
+
if (!this.initialized) {
|
|
221
|
+
throw import_errors.FileSystemError.notInitialized();
|
|
222
|
+
}
|
|
223
|
+
const searchPath = options.path || this.config.workingDirectory || process.cwd();
|
|
224
|
+
const globPattern = options.glob || "**/*";
|
|
225
|
+
const maxResults = options.maxResults || DEFAULT_MAX_SEARCH_RESULTS;
|
|
226
|
+
const contextLines = options.contextLines || 0;
|
|
227
|
+
try {
|
|
228
|
+
const flags = options.caseInsensitive ? "i" : "";
|
|
229
|
+
const regex = new RegExp(pattern, flags);
|
|
230
|
+
const globResult = await this.globFiles(globPattern, {
|
|
231
|
+
cwd: searchPath,
|
|
232
|
+
maxResults: 1e4
|
|
233
|
+
// Search more files, but limit results
|
|
234
|
+
});
|
|
235
|
+
const matches = [];
|
|
236
|
+
let filesSearched = 0;
|
|
237
|
+
for (const fileInfo of globResult.files) {
|
|
238
|
+
try {
|
|
239
|
+
const fileContent = await this.readFile(fileInfo.path);
|
|
240
|
+
const lines = fileContent.content.split("\n");
|
|
241
|
+
filesSearched++;
|
|
242
|
+
for (let i = 0; i < lines.length; i++) {
|
|
243
|
+
const line = lines[i];
|
|
244
|
+
if (regex.test(line)) {
|
|
245
|
+
let context;
|
|
246
|
+
if (contextLines > 0) {
|
|
247
|
+
const before = [];
|
|
248
|
+
const after = [];
|
|
249
|
+
for (let j = Math.max(0, i - contextLines); j < i; j++) {
|
|
250
|
+
before.push(lines[j]);
|
|
251
|
+
}
|
|
252
|
+
for (let j = i + 1; j < Math.min(lines.length, i + contextLines + 1); j++) {
|
|
253
|
+
after.push(lines[j]);
|
|
254
|
+
}
|
|
255
|
+
context = { before, after };
|
|
256
|
+
}
|
|
257
|
+
matches.push({
|
|
258
|
+
file: fileInfo.path,
|
|
259
|
+
lineNumber: i + 1,
|
|
260
|
+
// 1-based line numbers
|
|
261
|
+
line,
|
|
262
|
+
...context !== void 0 && { context }
|
|
263
|
+
});
|
|
264
|
+
if (matches.length >= maxResults) {
|
|
265
|
+
return {
|
|
266
|
+
matches,
|
|
267
|
+
totalMatches: matches.length,
|
|
268
|
+
truncated: true,
|
|
269
|
+
filesSearched
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
} catch (error) {
|
|
275
|
+
import_logger.logger.debug(
|
|
276
|
+
`Skipping file ${fileInfo.path}: ${error instanceof Error ? error.message : String(error)}`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
matches,
|
|
282
|
+
totalMatches: matches.length,
|
|
283
|
+
truncated: false,
|
|
284
|
+
filesSearched
|
|
285
|
+
};
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (error instanceof Error && error.message.includes("Invalid regular expression")) {
|
|
288
|
+
throw import_errors.FileSystemError.invalidPattern(pattern, "Invalid regular expression syntax");
|
|
289
|
+
}
|
|
290
|
+
throw import_errors.FileSystemError.searchFailed(
|
|
291
|
+
pattern,
|
|
292
|
+
error instanceof Error ? error.message : String(error)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Write content to a file
|
|
298
|
+
*/
|
|
299
|
+
async writeFile(filePath, content, options = {}) {
|
|
300
|
+
if (!this.initialized) {
|
|
301
|
+
throw import_errors.FileSystemError.notInitialized();
|
|
302
|
+
}
|
|
303
|
+
const validation = this.pathValidator.validatePath(filePath);
|
|
304
|
+
if (!validation.isValid || !validation.normalizedPath) {
|
|
305
|
+
throw import_errors.FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
306
|
+
}
|
|
307
|
+
const normalizedPath = validation.normalizedPath;
|
|
308
|
+
const encoding = options.encoding || DEFAULT_ENCODING;
|
|
309
|
+
let backupPath;
|
|
310
|
+
let fileExists = false;
|
|
311
|
+
try {
|
|
312
|
+
await fs.access(normalizedPath);
|
|
313
|
+
fileExists = true;
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
if (fileExists && (options.backup ?? this.config.enableBackups)) {
|
|
317
|
+
backupPath = await this.createBackup(normalizedPath);
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
if (options.createDirs) {
|
|
321
|
+
const dir = path.dirname(normalizedPath);
|
|
322
|
+
await fs.mkdir(dir, { recursive: true });
|
|
323
|
+
}
|
|
324
|
+
await fs.writeFile(normalizedPath, content, encoding);
|
|
325
|
+
const bytesWritten = Buffer.byteLength(content, encoding);
|
|
326
|
+
import_logger.logger.debug(`File written: ${normalizedPath} (${bytesWritten} bytes)`);
|
|
327
|
+
return {
|
|
328
|
+
success: true,
|
|
329
|
+
path: normalizedPath,
|
|
330
|
+
bytesWritten,
|
|
331
|
+
backupPath
|
|
332
|
+
};
|
|
333
|
+
} catch (error) {
|
|
334
|
+
throw import_errors.FileSystemError.writeFailed(
|
|
335
|
+
normalizedPath,
|
|
336
|
+
error instanceof Error ? error.message : String(error)
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Edit a file by replacing text
|
|
342
|
+
*/
|
|
343
|
+
async editFile(filePath, operation, options = {}) {
|
|
344
|
+
if (!this.initialized) {
|
|
345
|
+
throw import_errors.FileSystemError.notInitialized();
|
|
346
|
+
}
|
|
347
|
+
const validation = this.pathValidator.validatePath(filePath);
|
|
348
|
+
if (!validation.isValid || !validation.normalizedPath) {
|
|
349
|
+
throw import_errors.FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
350
|
+
}
|
|
351
|
+
const normalizedPath = validation.normalizedPath;
|
|
352
|
+
const fileContent = await this.readFile(normalizedPath);
|
|
353
|
+
let content = fileContent.content;
|
|
354
|
+
const occurrences = (content.match(
|
|
355
|
+
new RegExp(operation.oldString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g")
|
|
356
|
+
) || []).length;
|
|
357
|
+
if (occurrences === 0) {
|
|
358
|
+
throw import_errors.FileSystemError.stringNotFound(normalizedPath, operation.oldString);
|
|
359
|
+
}
|
|
360
|
+
if (!operation.replaceAll && occurrences > 1) {
|
|
361
|
+
throw import_errors.FileSystemError.stringNotUnique(normalizedPath, operation.oldString, occurrences);
|
|
362
|
+
}
|
|
363
|
+
let backupPath;
|
|
364
|
+
if (options.backup ?? this.config.enableBackups) {
|
|
365
|
+
backupPath = await this.createBackup(normalizedPath);
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
if (operation.replaceAll) {
|
|
369
|
+
content = content.replace(
|
|
370
|
+
new RegExp(operation.oldString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
|
|
371
|
+
operation.newString
|
|
372
|
+
);
|
|
373
|
+
} else {
|
|
374
|
+
content = content.replace(operation.oldString, operation.newString);
|
|
375
|
+
}
|
|
376
|
+
await fs.writeFile(normalizedPath, content, options.encoding || DEFAULT_ENCODING);
|
|
377
|
+
import_logger.logger.debug(`File edited: ${normalizedPath} (${occurrences} replacements)`);
|
|
378
|
+
return {
|
|
379
|
+
success: true,
|
|
380
|
+
path: normalizedPath,
|
|
381
|
+
changesCount: occurrences,
|
|
382
|
+
backupPath
|
|
383
|
+
};
|
|
384
|
+
} catch (error) {
|
|
385
|
+
throw import_errors.FileSystemError.editFailed(
|
|
386
|
+
normalizedPath,
|
|
387
|
+
error instanceof Error ? error.message : String(error)
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Create a backup of a file
|
|
393
|
+
*/
|
|
394
|
+
async createBackup(filePath) {
|
|
395
|
+
const backupDir = path.resolve(
|
|
396
|
+
this.config.workingDirectory || process.cwd(),
|
|
397
|
+
this.config.backupPath
|
|
398
|
+
);
|
|
399
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
400
|
+
const basename = path.basename(filePath);
|
|
401
|
+
const backupFilename = `${basename}.${timestamp}.backup`;
|
|
402
|
+
const backupPath = path.join(backupDir, backupFilename);
|
|
403
|
+
try {
|
|
404
|
+
await fs.mkdir(backupDir, { recursive: true });
|
|
405
|
+
await fs.copyFile(filePath, backupPath);
|
|
406
|
+
import_logger.logger.debug(`Backup created: ${backupPath}`);
|
|
407
|
+
await this.cleanupOldBackups();
|
|
408
|
+
return backupPath;
|
|
409
|
+
} catch (error) {
|
|
410
|
+
throw import_errors.FileSystemError.backupFailed(
|
|
411
|
+
filePath,
|
|
412
|
+
error instanceof Error ? error.message : String(error)
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Clean up old backup files based on retention policy
|
|
418
|
+
*/
|
|
419
|
+
async cleanupOldBackups() {
|
|
420
|
+
if (!this.config.enableBackups) {
|
|
421
|
+
return 0;
|
|
422
|
+
}
|
|
423
|
+
const backupDir = path.resolve(
|
|
424
|
+
this.config.workingDirectory || process.cwd(),
|
|
425
|
+
this.config.backupPath
|
|
426
|
+
);
|
|
427
|
+
try {
|
|
428
|
+
await fs.access(backupDir);
|
|
429
|
+
} catch {
|
|
430
|
+
return 0;
|
|
431
|
+
}
|
|
432
|
+
const cutoffDate = new Date(
|
|
433
|
+
Date.now() - this.config.backupRetentionDays * 24 * 60 * 60 * 1e3
|
|
434
|
+
);
|
|
435
|
+
let deletedCount = 0;
|
|
436
|
+
try {
|
|
437
|
+
const files = await fs.readdir(backupDir);
|
|
438
|
+
const backupFiles = files.filter((file) => file.endsWith(".backup"));
|
|
439
|
+
for (const file of backupFiles) {
|
|
440
|
+
const filePath = path.join(backupDir, file);
|
|
441
|
+
try {
|
|
442
|
+
const stats = await fs.stat(filePath);
|
|
443
|
+
if (stats.mtime < cutoffDate) {
|
|
444
|
+
await fs.unlink(filePath);
|
|
445
|
+
deletedCount++;
|
|
446
|
+
import_logger.logger.debug(`Cleaned up old backup: ${file}`);
|
|
447
|
+
}
|
|
448
|
+
} catch (error) {
|
|
449
|
+
import_logger.logger.warn(
|
|
450
|
+
`Failed to process backup file ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (deletedCount > 0) {
|
|
455
|
+
import_logger.logger.info(`Backup cleanup: removed ${deletedCount} old backup files`);
|
|
456
|
+
}
|
|
457
|
+
return deletedCount;
|
|
458
|
+
} catch (error) {
|
|
459
|
+
import_logger.logger.warn(
|
|
460
|
+
`Failed to cleanup backup directory: ${error instanceof Error ? error.message : String(error)}`
|
|
461
|
+
);
|
|
462
|
+
return 0;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Get service configuration
|
|
467
|
+
*/
|
|
468
|
+
getConfig() {
|
|
469
|
+
return { ...this.config };
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Check if a path is allowed
|
|
473
|
+
*/
|
|
474
|
+
isPathAllowed(filePath) {
|
|
475
|
+
const validation = this.pathValidator.validatePath(filePath);
|
|
476
|
+
return validation.isValid;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
480
|
+
0 && (module.exports = {
|
|
481
|
+
FileSystemService
|
|
482
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileSystem Service
|
|
3
|
+
*
|
|
4
|
+
* Secure file system operations for Dexto internal tools
|
|
5
|
+
*/
|
|
6
|
+
import { FileSystemConfig, FileContent, ReadFileOptions, GlobOptions, GlobResult, GrepOptions, SearchResult, WriteFileOptions, WriteResult, EditFileOptions, EditResult, EditOperation } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* FileSystemService - Handles all file system operations with security checks
|
|
9
|
+
* TODO: Add tests for this class
|
|
10
|
+
*/
|
|
11
|
+
export declare class FileSystemService {
|
|
12
|
+
private config;
|
|
13
|
+
private pathValidator;
|
|
14
|
+
private initialized;
|
|
15
|
+
constructor(config?: Partial<FileSystemConfig>);
|
|
16
|
+
/**
|
|
17
|
+
* Initialize the service
|
|
18
|
+
*/
|
|
19
|
+
initialize(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Read a file with validation and size limits
|
|
22
|
+
*/
|
|
23
|
+
readFile(filePath: string, options?: ReadFileOptions): Promise<FileContent>;
|
|
24
|
+
/**
|
|
25
|
+
* Find files matching a glob pattern
|
|
26
|
+
*/
|
|
27
|
+
globFiles(pattern: string, options?: GlobOptions): Promise<GlobResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Search for content in files (grep-like functionality)
|
|
30
|
+
*/
|
|
31
|
+
searchContent(pattern: string, options?: GrepOptions): Promise<SearchResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Write content to a file
|
|
34
|
+
*/
|
|
35
|
+
writeFile(filePath: string, content: string, options?: WriteFileOptions): Promise<WriteResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Edit a file by replacing text
|
|
38
|
+
*/
|
|
39
|
+
editFile(filePath: string, operation: EditOperation, options?: EditFileOptions): Promise<EditResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Create a backup of a file
|
|
42
|
+
*/
|
|
43
|
+
private createBackup;
|
|
44
|
+
/**
|
|
45
|
+
* Clean up old backup files based on retention policy
|
|
46
|
+
*/
|
|
47
|
+
cleanupOldBackups(): Promise<number>;
|
|
48
|
+
/**
|
|
49
|
+
* Get service configuration
|
|
50
|
+
*/
|
|
51
|
+
getConfig(): Readonly<FileSystemConfig>;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a path is allowed
|
|
54
|
+
*/
|
|
55
|
+
isPathAllowed(filePath: string): boolean;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=filesystem-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-service.d.ts","sourceRoot":"","sources":["../../src/filesystem/filesystem-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACH,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EAEZ,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,EAGhB,MAAM,YAAY,CAAC;AAUpB;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,WAAW,CAAkB;gBAEzB,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM;IAgBlD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BjC;;OAEG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IA+ErF;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwEhF;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;IAqGtF;;OAEG;IACG,SAAS,CACX,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC/B,OAAO,CAAC,WAAW,CAAC;IA0DvB;;OAEG;IACG,QAAQ,CACV,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,aAAa,EACxB,OAAO,GAAE,eAAoB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAoEtB;;OAEG;YACW,YAAY;IA6B1B;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAwD1C;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,gBAAgB,CAAC;IAIvC;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAI3C"}
|