aws-runtime-bridge 1.9.78 → 1.9.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/AcodeSdkAdapter.d.ts +0 -1
- package/dist/adapter/AcodeSdkAdapter.js +11 -1986
- package/dist/adapter/AdapterRegistry.d.ts +0 -1
- package/dist/adapter/AdapterRegistry.js +2 -100
- package/dist/adapter/ClaudeSdkAdapter.d.ts +0 -1
- package/dist/adapter/ClaudeSdkAdapter.js +4 -1300
- package/dist/adapter/CodexSdkAdapter.d.ts +0 -1
- package/dist/adapter/CodexSdkAdapter.js +4 -836
- package/dist/adapter/OpencodeSdkAdapter.d.ts +0 -1
- package/dist/adapter/OpencodeSdkAdapter.js +4 -879
- package/dist/adapter/SdkProviderSpi.d.ts +0 -1
- package/dist/adapter/SdkProviderSpi.js +2 -55
- package/dist/adapter/acode-tool-names.d.ts +0 -1
- package/dist/adapter/acode-tool-names.js +2 -37
- package/dist/adapter/idle-poll-loop.d.ts +0 -1
- package/dist/adapter/idle-poll-loop.js +2 -59
- package/dist/adapter/index.d.ts +0 -1
- package/dist/adapter/index.js +2 -11
- package/dist/adapter/instance-ai-config-resolver.d.ts +0 -1
- package/dist/adapter/instance-ai-config-resolver.js +2 -46
- package/dist/adapter/types.d.ts +0 -1
- package/dist/adapter/types.js +2 -443
- package/dist/adapters/cc-switch/common.d.ts +0 -1
- package/dist/adapters/cc-switch/common.js +2 -61
- package/dist/adapters/cc-switch/index.d.ts +0 -1
- package/dist/adapters/cc-switch/index.js +2 -57
- package/dist/adapters/cc-switch/mcp-acode.d.ts +0 -1
- package/dist/adapters/cc-switch/mcp-acode.js +2 -71
- package/dist/adapters/cc-switch/mcp-claude.d.ts +0 -1
- package/dist/adapters/cc-switch/mcp-claude.js +2 -89
- package/dist/adapters/cc-switch/mcp-claudecode.d.ts +0 -1
- package/dist/adapters/cc-switch/mcp-claudecode.js +2 -77
- package/dist/adapters/cc-switch/mcp-codex.d.ts +0 -1
- package/dist/adapters/cc-switch/mcp-codex.js +11 -249
- package/dist/adapters/cc-switch/mcp-opencode.d.ts +0 -1
- package/dist/adapters/cc-switch/mcp-opencode.js +2 -97
- package/dist/adapters/cc-switch/mcp-placeholder.d.ts +0 -1
- package/dist/adapters/cc-switch/mcp-placeholder.js +2 -19
- package/dist/adapters/cc-switch/skill-acode.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-acode.js +2 -12
- package/dist/adapters/cc-switch/skill-claude.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-claude.js +2 -11
- package/dist/adapters/cc-switch/skill-claudecode.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-claudecode.js +2 -11
- package/dist/adapters/cc-switch/skill-codex.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-codex.js +2 -6
- package/dist/adapters/cc-switch/skill-directory.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-directory.js +3 -137
- package/dist/adapters/cc-switch/skill-opencode.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-opencode.js +2 -11
- package/dist/adapters/cc-switch/skill-placeholder.d.ts +0 -1
- package/dist/adapters/cc-switch/skill-placeholder.js +2 -19
- package/dist/config.d.ts +0 -1
- package/dist/config.js +2 -290
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -573
- package/dist/middleware/auth.d.ts +0 -1
- package/dist/middleware/auth.js +2 -98
- package/dist/routes/acode-todos.d.ts +0 -1
- package/dist/routes/acode-todos.js +2 -75
- package/dist/routes/ai-sources.d.ts +0 -1
- package/dist/routes/ai-sources.js +2 -132
- package/dist/routes/dashboard.d.ts +0 -1
- package/dist/routes/dashboard.js +182 -649
- package/dist/routes/events.d.ts +0 -1
- package/dist/routes/events.js +2 -22
- package/dist/routes/file-browser.d.ts +0 -1
- package/dist/routes/file-browser.js +2 -781
- package/dist/routes/file-diff-rollback.d.ts +0 -1
- package/dist/routes/file-diff-rollback.js +2 -301
- package/dist/routes/file-snapshot.d.ts +0 -1
- package/dist/routes/file-snapshot.js +2 -156
- package/dist/routes/git.d.ts +0 -1
- package/dist/routes/git.js +28 -1900
- package/dist/routes/instance.d.ts +0 -1
- package/dist/routes/instance.js +3 -748
- package/dist/routes/mcp.d.ts +0 -1
- package/dist/routes/mcp.js +2 -196
- package/dist/routes/processes.d.ts +0 -1
- package/dist/routes/processes.js +2 -252
- package/dist/routes/properties.d.ts +0 -1
- package/dist/routes/properties.js +2 -72
- package/dist/routes/pty.d.ts +0 -1
- package/dist/routes/pty.js +6 -560
- package/dist/routes/runtime-binding.d.ts +0 -1
- package/dist/routes/runtime-binding.js +2 -263
- package/dist/routes/sessions.d.ts +0 -1
- package/dist/routes/sessions.js +2 -758
- package/dist/routes/skills.d.ts +0 -1
- package/dist/routes/skills.js +2 -187
- package/dist/routes/sub-agents.d.ts +0 -1
- package/dist/routes/sub-agents.js +20 -279
- package/dist/routes/system-metrics.d.ts +0 -1
- package/dist/routes/system-metrics.js +2 -20
- package/dist/routes/task-context.d.ts +0 -1
- package/dist/routes/task-context.js +2 -78
- package/dist/routes/terminal.d.ts +0 -1
- package/dist/routes/terminal.js +54 -2882
- package/dist/routes/yml.d.ts +0 -1
- package/dist/routes/yml.js +2 -223
- package/dist/services/acode-package.d.ts +0 -1
- package/dist/services/acode-package.js +2 -111
- package/dist/services/agent-event-store.d.ts +0 -1
- package/dist/services/agent-event-store.js +2 -81
- package/dist/services/agent-process-manager.d.ts +0 -1
- package/dist/services/agent-process-manager.js +2 -796
- package/dist/services/ai-source-apply.d.ts +0 -1
- package/dist/services/ai-source-apply.js +2 -83
- package/dist/services/auto-register.d.ts +0 -1
- package/dist/services/auto-register.js +2 -1053
- package/dist/services/aws-client-agent-mcp.d.ts +0 -1
- package/dist/services/aws-client-agent-mcp.js +3 -337
- package/dist/services/bridge-package-publish-hooks.d.ts +0 -1
- package/dist/services/bridge-package-publish-hooks.js +2 -115
- package/dist/services/cc-switch-sdk.d.ts +0 -1
- package/dist/services/cc-switch-sdk.js +2 -135
- package/dist/services/cli-commands.d.ts +6 -1
- package/dist/services/cli-commands.js +6 -645
- package/dist/services/event-delta-pusher.d.ts +0 -1
- package/dist/services/event-delta-pusher.js +2 -95
- package/dist/services/fileSnapshotStore.d.ts +0 -1
- package/dist/services/fileSnapshotStore.js +2 -500
- package/dist/services/instance-ai-config-service.d.ts +0 -1
- package/dist/services/instance-ai-config-service.js +2 -174
- package/dist/services/instance-init-service.d.ts +0 -1
- package/dist/services/instance-init-service.js +2 -193
- package/dist/services/instance-service.d.ts +0 -1
- package/dist/services/instance-service.js +2 -237
- package/dist/services/instance-state.d.ts +0 -1
- package/dist/services/instance-state.js +2 -94
- package/dist/services/legacy-path-migration.d.ts +0 -1
- package/dist/services/legacy-path-migration.js +2 -66
- package/dist/services/lifecycle-state.d.ts +0 -1
- package/dist/services/lifecycle-state.js +3 -110
- package/dist/services/mcp-launch-binding-queue.d.ts +0 -1
- package/dist/services/mcp-launch-binding-queue.js +2 -175
- package/dist/services/orphan-monitor.d.ts +0 -1
- package/dist/services/orphan-monitor.js +2 -382
- package/dist/services/panel-auth.d.ts +0 -1
- package/dist/services/panel-auth.js +2 -168
- package/dist/services/process-detector.d.ts +0 -1
- package/dist/services/process-detector.js +18 -1019
- package/dist/services/process-registry.d.ts +0 -1
- package/dist/services/process-registry.js +2 -375
- package/dist/services/ring-buffer.d.ts +0 -1
- package/dist/services/ring-buffer.js +2 -103
- package/dist/services/runtime-binding.d.ts +0 -1
- package/dist/services/runtime-binding.js +6 -363
- package/dist/services/runtime-lifecycle-policy.d.ts +0 -1
- package/dist/services/runtime-lifecycle-policy.js +2 -35
- package/dist/services/session-output.d.ts +0 -1
- package/dist/services/session-output.js +5 -539
- package/dist/services/startup-config-wizard.d.ts +0 -1
- package/dist/services/startup-config-wizard.js +14 -258
- package/dist/services/sub-agent-manager-instance.d.ts +0 -1
- package/dist/services/sub-agent-manager-instance.js +2 -12
- package/dist/services/system-metrics.d.ts +0 -1
- package/dist/services/system-metrics.js +2 -252
- package/dist/services/terminal-persistence.d.ts +0 -1
- package/dist/services/terminal-persistence.js +2 -176
- package/dist/services/tool-installer.d.ts +0 -1
- package/dist/services/tool-installer.js +5 -751
- package/dist/services/tunnel-client.d.ts +0 -1
- package/dist/services/tunnel-client.js +2 -402
- package/dist/services/windows-service-manager.d.ts +3 -2
- package/dist/services/windows-service-manager.js +2 -54
- package/dist/services/workspace-files.d.ts +0 -1
- package/dist/services/workspace-files.js +2 -1275
- package/dist/services/workspace-watch.d.ts +0 -1
- package/dist/services/workspace-watch.js +2 -123
- package/dist/services/workspaceTaskChangeWatcher.d.ts +0 -1
- package/dist/services/workspaceTaskChangeWatcher.js +2 -483
- package/dist/types.d.ts +0 -1
- package/dist/types.js +1 -1
- package/dist/utils/file-utils.d.ts +0 -1
- package/dist/utils/file-utils.js +3 -208
- package/dist/utils/instance-ai-config-debug-logger.d.ts +0 -1
- package/dist/utils/instance-ai-config-debug-logger.js +4 -63
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/logger.js +2 -154
- package/dist/utils/mcp-utils.d.ts +0 -1
- package/dist/utils/mcp-utils.js +2 -187
- package/dist/utils/path-utils.d.ts +0 -1
- package/dist/utils/path-utils.js +2 -44
- package/dist/utils/sdk-package-loader.d.ts +0 -1
- package/dist/utils/sdk-package-loader.js +2 -78
- package/dist/utils/validation.d.ts +0 -1
- package/dist/utils/validation.js +2 -53
- package/dist/utils/yaml-utils.d.ts +0 -1
- package/dist/utils/yaml-utils.js +2 -312
- package/node_modules/@cc-switch/sdk/dist/constants.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/constants.js +2 -63
- package/node_modules/@cc-switch/sdk/dist/errors.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/errors.js +2 -8
- package/node_modules/@cc-switch/sdk/dist/index.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/index.js +2 -9
- package/node_modules/@cc-switch/sdk/dist/schemas.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/schemas.js +2 -38
- package/node_modules/@cc-switch/sdk/dist/sdk.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/sdk.js +2 -470
- package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.js +4 -307
- package/node_modules/@cc-switch/sdk/dist/services/mcp-model.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/mcp-model.js +2 -37
- package/node_modules/@cc-switch/sdk/dist/services/mcp-service.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/mcp-service.js +2 -9
- package/node_modules/@cc-switch/sdk/dist/services/skill-model.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/skill-model.js +2 -41
- package/node_modules/@cc-switch/sdk/dist/services/skill-service.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/skill-service.js +2 -9
- package/node_modules/@cc-switch/sdk/dist/state.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/state.js +2 -19
- package/node_modules/@cc-switch/sdk/dist/types.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/types.js +1 -1
- package/node_modules/@cc-switch/sdk/dist/utils/fs.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/utils/fs.js +3 -114
- package/node_modules/@cc-switch/sdk/dist/utils/id.d.ts +0 -1
- package/node_modules/@cc-switch/sdk/dist/utils/id.js +2 -12
- package/node_modules/@cc-switch/sdk/package.json +1 -1
- package/package/acode/dist/ask-user-question-tool.d.ts +0 -1
- package/package/acode/dist/ask-user-question-tool.js +4 -233
- package/package/acode/dist/built-in-file-tools.d.ts +0 -1
- package/package/acode/dist/built-in-file-tools.js +4 -966
- package/package/acode/dist/built-in-symbols-tool.d.ts +0 -1
- package/package/acode/dist/built-in-symbols-tool.js +2 -117
- package/package/acode/dist/builtins/commandArtifacts.d.ts +0 -1
- package/package/acode/dist/builtins/commandArtifacts.js +9 -97
- package/package/acode/dist/builtins/commandOutputEvents.d.ts +0 -1
- package/package/acode/dist/builtins/commandOutputEvents.js +2 -56
- package/package/acode/dist/builtins/shellCommandPreparation.d.ts +0 -1
- package/package/acode/dist/builtins/shellCommandPreparation.js +5 -44
- package/package/acode/dist/builtins/shellCommandResult.d.ts +0 -1
- package/package/acode/dist/builtins/shellCommandResult.js +2 -71
- package/package/acode/dist/builtins/shellCommandRunner.d.ts +0 -1
- package/package/acode/dist/builtins/shellCommandRunner.js +2 -115
- package/package/acode/dist/builtins/shellOutputDecoder.d.ts +0 -1
- package/package/acode/dist/builtins/shellOutputDecoder.js +2 -94
- package/package/acode/dist/cli.d.ts +0 -1
- package/package/acode/dist/cli.js +4 -38
- package/package/acode/dist/commands/commandLoader.d.ts +0 -1
- package/package/acode/dist/commands/commandLoader.js +2 -33
- package/package/acode/dist/commands/commandParser.d.ts +0 -1
- package/package/acode/dist/commands/commandParser.js +3 -77
- package/package/acode/dist/commands/commandRegistry.d.ts +0 -1
- package/package/acode/dist/commands/commandRegistry.js +2 -30
- package/package/acode/dist/compaction.d.ts +0 -1
- package/package/acode/dist/compaction.js +7 -919
- package/package/acode/dist/config.d.ts +0 -1
- package/package/acode/dist/config.js +5 -105
- package/package/acode/dist/fs-utils.d.ts +0 -1
- package/package/acode/dist/fs-utils.js +2 -79
- package/package/acode/dist/hooks/hookBus.d.ts +0 -1
- package/package/acode/dist/hooks/hookBus.js +2 -40
- package/package/acode/dist/index.d.ts +0 -1
- package/package/acode/dist/index.js +2 -19
- package/package/acode/dist/mcpToolNames.d.ts +0 -1
- package/package/acode/dist/mcpToolNames.js +2 -17
- package/package/acode/dist/parsers/ast-cache.d.ts +0 -1
- package/package/acode/dist/parsers/ast-cache.js +2 -76
- package/package/acode/dist/parsers/language-detector.d.ts +0 -1
- package/package/acode/dist/parsers/language-detector.js +2 -44
- package/package/acode/dist/parsers/language-queries.d.ts +0 -1
- package/package/acode/dist/parsers/language-queries.js +12 -602
- package/package/acode/dist/parsers/symbol-extractor.d.ts +0 -1
- package/package/acode/dist/parsers/symbol-extractor.js +3 -164
- package/package/acode/dist/parsers/tree-sitter-loader.d.ts +0 -1
- package/package/acode/dist/parsers/tree-sitter-loader.js +2 -64
- package/package/acode/dist/parsers/types.d.ts +0 -1
- package/package/acode/dist/parsers/types.js +1 -7
- package/package/acode/dist/runtime.d.ts +0 -1
- package/package/acode/dist/runtime.js +86 -3771
- package/package/acode/dist/skill-tool.d.ts +0 -1
- package/package/acode/dist/skill-tool.js +5 -174
- package/package/acode/dist/sub-agent-manager.d.ts +0 -1
- package/package/acode/dist/sub-agent-manager.js +2 -1159
- package/package/acode/dist/sub-agent-store.d.ts +0 -1
- package/package/acode/dist/sub-agent-store.js +4 -236
- package/package/acode/dist/sub-agent-tools.d.ts +0 -1
- package/package/acode/dist/sub-agent-tools.js +15 -369
- package/package/acode/dist/sub-agent-types.d.ts +0 -1
- package/package/acode/dist/sub-agent-types.js +1 -8
- package/package/acode/dist/todo-store.d.ts +0 -1
- package/package/acode/dist/todo-store.js +2 -73
- package/package/acode/dist/todo-tool.d.ts +0 -1
- package/package/acode/dist/todo-tool.js +5 -121
- package/package/acode/dist/types.d.ts +0 -1
- package/package/acode/dist/types.js +1 -1
- package/package/acode/package.json +2 -2
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/agent-client.js +2 -890
- package/package/aws-client-agent-mcp/dist/agent-client.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/agent-client.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/config.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/config.js +2 -243
- package/package/aws-client-agent-mcp/dist/config.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/config.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/constants.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/constants.js +2 -24
- package/package/aws-client-agent-mcp/dist/context-manager.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/context-manager.js +2 -477
- package/package/aws-client-agent-mcp/dist/context-manager.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/context-manager.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.js +2 -446
- package/package/aws-client-agent-mcp/dist/http-client.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/index.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/index.js +2 -34
- package/package/aws-client-agent-mcp/dist/logger.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/logger.js +3 -178
- package/package/aws-client-agent-mcp/dist/logger.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/logger.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.js +38 -2709
- package/package/aws-client-agent-mcp/dist/mcp-server.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.js +22 -562
- package/package/aws-client-agent-mcp/dist/mcp-tools.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.js +4 -826
- package/package/aws-client-agent-mcp/dist/memory-store.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.js +31 -294
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.js +2 -288
- package/package/aws-client-agent-mcp/dist/message-buffer.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/messageContent.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/messageContent.js +2 -125
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.js +2 -103
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.js +2 -96
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.js +3 -327
- package/package/aws-client-agent-mcp/dist/status-reporter.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.test.js +0 -1
- package/package/aws-client-agent-mcp/dist/types.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/types.js +2 -9
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.js +2 -677
- package/package/aws-client-agent-mcp/dist/websocket-client.test.d.ts +0 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.test.js +0 -1
- package/package/aws-client-agent-mcp/package.json +1 -1
- package/package/cc-switch-sdk/dist/constants.d.ts +0 -1
- package/package/cc-switch-sdk/dist/constants.js +2 -63
- package/package/cc-switch-sdk/dist/errors.d.ts +0 -1
- package/package/cc-switch-sdk/dist/errors.js +2 -8
- package/package/cc-switch-sdk/dist/index.d.ts +0 -1
- package/package/cc-switch-sdk/dist/index.js +2 -9
- package/package/cc-switch-sdk/dist/schemas.d.ts +0 -1
- package/package/cc-switch-sdk/dist/schemas.js +2 -38
- package/package/cc-switch-sdk/dist/sdk.d.ts +0 -1
- package/package/cc-switch-sdk/dist/sdk.js +2 -470
- package/package/cc-switch-sdk/dist/services/ai-config-service.d.ts +0 -1
- package/package/cc-switch-sdk/dist/services/ai-config-service.js +4 -307
- package/package/cc-switch-sdk/dist/services/mcp-model.d.ts +0 -1
- package/package/cc-switch-sdk/dist/services/mcp-model.js +2 -37
- package/package/cc-switch-sdk/dist/services/mcp-service.d.ts +0 -1
- package/package/cc-switch-sdk/dist/services/mcp-service.js +2 -9
- package/package/cc-switch-sdk/dist/services/skill-model.d.ts +0 -1
- package/package/cc-switch-sdk/dist/services/skill-model.js +2 -41
- package/package/cc-switch-sdk/dist/services/skill-service.d.ts +0 -1
- package/package/cc-switch-sdk/dist/services/skill-service.js +2 -9
- package/package/cc-switch-sdk/dist/state.d.ts +0 -1
- package/package/cc-switch-sdk/dist/state.js +2 -19
- package/package/cc-switch-sdk/dist/types.d.ts +0 -1
- package/package/cc-switch-sdk/dist/types.js +1 -1
- package/package/cc-switch-sdk/dist/utils/fs.d.ts +0 -1
- package/package/cc-switch-sdk/dist/utils/fs.js +3 -114
- package/package/cc-switch-sdk/dist/utils/id.d.ts +0 -1
- package/package/cc-switch-sdk/dist/utils/id.js +2 -12
- package/package/cc-switch-sdk/package.json +1 -1
- package/package.json +4 -2
- package/dist/adapter/AcodeSdkAdapter.d.ts.map +0 -1
- package/dist/adapter/AdapterRegistry.d.ts.map +0 -1
- package/dist/adapter/ClaudeSdkAdapter.d.ts.map +0 -1
- package/dist/adapter/CodexSdkAdapter.d.ts.map +0 -1
- package/dist/adapter/OpencodeSdkAdapter.d.ts.map +0 -1
- package/dist/adapter/SdkProviderSpi.d.ts.map +0 -1
- package/dist/adapter/acode-tool-names.d.ts.map +0 -1
- package/dist/adapter/idle-poll-loop.d.ts.map +0 -1
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapter/instance-ai-config-resolver.d.ts.map +0 -1
- package/dist/adapter/types.d.ts.map +0 -1
- package/dist/adapters/cc-switch/common.d.ts.map +0 -1
- package/dist/adapters/cc-switch/index.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-acode.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-claude.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-claudecode.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-codex.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-opencode.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-placeholder.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-acode.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-claude.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-claudecode.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-codex.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-directory.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-opencode.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-placeholder.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/middleware/auth.d.ts.map +0 -1
- package/dist/routes/acode-todos.d.ts.map +0 -1
- package/dist/routes/ai-sources.d.ts.map +0 -1
- package/dist/routes/dashboard.d.ts.map +0 -1
- package/dist/routes/events.d.ts.map +0 -1
- package/dist/routes/file-browser.d.ts.map +0 -1
- package/dist/routes/file-diff-rollback.d.ts.map +0 -1
- package/dist/routes/file-snapshot.d.ts.map +0 -1
- package/dist/routes/git.d.ts.map +0 -1
- package/dist/routes/instance.d.ts.map +0 -1
- package/dist/routes/mcp.d.ts.map +0 -1
- package/dist/routes/processes.d.ts.map +0 -1
- package/dist/routes/properties.d.ts.map +0 -1
- package/dist/routes/pty.d.ts.map +0 -1
- package/dist/routes/runtime-binding.d.ts.map +0 -1
- package/dist/routes/sessions.d.ts.map +0 -1
- package/dist/routes/skills.d.ts.map +0 -1
- package/dist/routes/sub-agents.d.ts.map +0 -1
- package/dist/routes/system-metrics.d.ts.map +0 -1
- package/dist/routes/task-context.d.ts.map +0 -1
- package/dist/routes/terminal.d.ts.map +0 -1
- package/dist/routes/yml.d.ts.map +0 -1
- package/dist/services/acode-package.d.ts.map +0 -1
- package/dist/services/agent-event-store.d.ts.map +0 -1
- package/dist/services/agent-process-manager.d.ts.map +0 -1
- package/dist/services/ai-source-apply.d.ts.map +0 -1
- package/dist/services/auto-register.d.ts.map +0 -1
- package/dist/services/aws-client-agent-mcp.d.ts.map +0 -1
- package/dist/services/bridge-package-publish-hooks.d.ts.map +0 -1
- package/dist/services/cc-switch-sdk.d.ts.map +0 -1
- package/dist/services/cli-commands.d.ts.map +0 -1
- package/dist/services/event-delta-pusher.d.ts.map +0 -1
- package/dist/services/fileSnapshotStore.d.ts.map +0 -1
- package/dist/services/instance-ai-config-service.d.ts.map +0 -1
- package/dist/services/instance-init-service.d.ts.map +0 -1
- package/dist/services/instance-service.d.ts.map +0 -1
- package/dist/services/instance-state.d.ts.map +0 -1
- package/dist/services/legacy-path-migration.d.ts.map +0 -1
- package/dist/services/lifecycle-state.d.ts.map +0 -1
- package/dist/services/mcp-launch-binding-queue.d.ts.map +0 -1
- package/dist/services/orphan-monitor.d.ts.map +0 -1
- package/dist/services/panel-auth.d.ts.map +0 -1
- package/dist/services/process-detector.d.ts.map +0 -1
- package/dist/services/process-registry.d.ts.map +0 -1
- package/dist/services/ring-buffer.d.ts.map +0 -1
- package/dist/services/runtime-binding.d.ts.map +0 -1
- package/dist/services/runtime-lifecycle-policy.d.ts.map +0 -1
- package/dist/services/session-output.d.ts.map +0 -1
- package/dist/services/startup-config-wizard.d.ts.map +0 -1
- package/dist/services/sub-agent-manager-instance.d.ts.map +0 -1
- package/dist/services/system-metrics.d.ts.map +0 -1
- package/dist/services/terminal-persistence.d.ts.map +0 -1
- package/dist/services/tool-installer.d.ts.map +0 -1
- package/dist/services/tunnel-client.d.ts.map +0 -1
- package/dist/services/windows-service-manager.d.ts.map +0 -1
- package/dist/services/workspace-files.d.ts.map +0 -1
- package/dist/services/workspace-watch.d.ts.map +0 -1
- package/dist/services/workspaceTaskChangeWatcher.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/file-utils.d.ts.map +0 -1
- package/dist/utils/instance-ai-config-debug-logger.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/mcp-utils.d.ts.map +0 -1
- package/dist/utils/path-utils.d.ts.map +0 -1
- package/dist/utils/sdk-package-loader.d.ts.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/yaml-utils.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/constants.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/errors.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/index.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/schemas.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/sdk.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/mcp-model.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/mcp-service.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/skill-model.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/services/skill-service.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/state.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/types.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/utils/fs.d.ts.map +0 -1
- package/node_modules/@cc-switch/sdk/dist/utils/id.d.ts.map +0 -1
- package/package/acode/dist/ask-user-question-tool.d.ts.map +0 -1
- package/package/acode/dist/built-in-file-tools.d.ts.map +0 -1
- package/package/acode/dist/built-in-symbols-tool.d.ts.map +0 -1
- package/package/acode/dist/builtins/commandArtifacts.d.ts.map +0 -1
- package/package/acode/dist/builtins/commandOutputEvents.d.ts.map +0 -1
- package/package/acode/dist/builtins/shellCommandPreparation.d.ts.map +0 -1
- package/package/acode/dist/builtins/shellCommandResult.d.ts.map +0 -1
- package/package/acode/dist/builtins/shellCommandRunner.d.ts.map +0 -1
- package/package/acode/dist/builtins/shellOutputDecoder.d.ts.map +0 -1
- package/package/acode/dist/cli.d.ts.map +0 -1
- package/package/acode/dist/commands/commandLoader.d.ts.map +0 -1
- package/package/acode/dist/commands/commandParser.d.ts.map +0 -1
- package/package/acode/dist/commands/commandRegistry.d.ts.map +0 -1
- package/package/acode/dist/compaction.d.ts.map +0 -1
- package/package/acode/dist/config.d.ts.map +0 -1
- package/package/acode/dist/fs-utils.d.ts.map +0 -1
- package/package/acode/dist/hooks/hookBus.d.ts.map +0 -1
- package/package/acode/dist/index.d.ts.map +0 -1
- package/package/acode/dist/mcpToolNames.d.ts.map +0 -1
- package/package/acode/dist/parsers/ast-cache.d.ts.map +0 -1
- package/package/acode/dist/parsers/language-detector.d.ts.map +0 -1
- package/package/acode/dist/parsers/language-queries.d.ts.map +0 -1
- package/package/acode/dist/parsers/symbol-extractor.d.ts.map +0 -1
- package/package/acode/dist/parsers/tree-sitter-loader.d.ts.map +0 -1
- package/package/acode/dist/parsers/types.d.ts.map +0 -1
- package/package/acode/dist/runtime.d.ts.map +0 -1
- package/package/acode/dist/skill-tool.d.ts.map +0 -1
- package/package/acode/dist/sub-agent-manager.d.ts.map +0 -1
- package/package/acode/dist/sub-agent-store.d.ts.map +0 -1
- package/package/acode/dist/sub-agent-tools.d.ts.map +0 -1
- package/package/acode/dist/sub-agent-types.d.ts.map +0 -1
- package/package/acode/dist/todo-store.d.ts.map +0 -1
- package/package/acode/dist/todo-tool.d.ts.map +0 -1
- package/package/acode/dist/types.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/agent-client.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/agent-client.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/agent-client.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/config.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/config.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/config.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/config.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/constants.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/constants.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/context-manager.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/context-manager.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/context-manager.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/context-manager.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/http-client.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/index.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/index.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/logger.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/logger.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/logger.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/logger.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/memory-store.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/messageContent.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/messageContent.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.test.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/types.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/types.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.js.map +0 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.test.d.ts.map +0 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.test.js.map +0 -1
- package/package/cc-switch-sdk/dist/constants.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/errors.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/index.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/schemas.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/sdk.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/services/ai-config-service.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/services/mcp-model.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/services/mcp-service.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/services/skill-model.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/services/skill-service.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/state.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/types.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/utils/fs.d.ts.map +0 -1
- package/package/cc-switch-sdk/dist/utils/id.d.ts.map +0 -1
|
@@ -1,781 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 提供文件系统浏览功能
|
|
5
|
-
*/
|
|
6
|
-
import { createReadStream, promises as fs } from 'node:fs';
|
|
7
|
-
import os from 'node:os';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { Router } from 'express';
|
|
10
|
-
import multer from 'multer';
|
|
11
|
-
import { allowHostFileBrowser } from '../config.js';
|
|
12
|
-
import { validateToken } from '../middleware/auth.js';
|
|
13
|
-
import { chmodWorkspaceEntry, createWorkspaceEntry, deleteWorkspaceEntry, extractWorkspaceArchive, getWorkspaceEntryProperties, listWorkspaceDirectory, moveWorkspaceEntry, previewWorkspaceDocument, readWorkspaceFile, renameWorkspaceEntry, replaceWorkspaceFiles, resolveWorkspaceDownloadTarget, searchWorkspaceFiles, streamWorkspaceDirectoryZip, uploadWorkspaceFiles, writeWorkspaceFile, } from '../services/workspace-files.js';
|
|
14
|
-
import { unwatchWorkspaceFile, watchWorkspaceFile } from '../services/workspace-watch.js';
|
|
15
|
-
import { createLogger } from '../utils/logger.js';
|
|
16
|
-
const log = createLogger('file-browser');
|
|
17
|
-
export const fileBrowserRouter = Router();
|
|
18
|
-
export const WORKSPACE_UPLOAD_FILE_LIMIT = 2000;
|
|
19
|
-
const upload = multer({
|
|
20
|
-
dest: path.join(os.tmpdir(), 'agentswork-runtime-bridge-uploads'),
|
|
21
|
-
limits: {
|
|
22
|
-
files: WORKSPACE_UPLOAD_FILE_LIMIT,
|
|
23
|
-
fileSize: 512 * 1024 * 1024
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
// 不限制层数和每层项数,仅根据 .gitignore 排除文件
|
|
27
|
-
const DIRECTORY_TREE_MAX_DEPTH = Number.MAX_SAFE_INTEGER;
|
|
28
|
-
const DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY = Number.MAX_SAFE_INTEGER;
|
|
29
|
-
function toBoolean(value) {
|
|
30
|
-
return value === true || value === 'true' || value === '1';
|
|
31
|
-
}
|
|
32
|
-
function contentDispositionFileName(fileName) {
|
|
33
|
-
const fallbackName = fileName
|
|
34
|
-
.replace(/[\\"\r\n]/g, '_')
|
|
35
|
-
.replace(/[^\x20-\x7E]/g, '_');
|
|
36
|
-
return `attachment; filename="${fallbackName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`;
|
|
37
|
-
}
|
|
38
|
-
async function cleanupUploadedFiles(files = []) {
|
|
39
|
-
await Promise.all(files.map((file) => fs.rm(file.path, { force: true }).catch(() => undefined)));
|
|
40
|
-
}
|
|
41
|
-
export function createWorkspaceUploadLimitResponse(error) {
|
|
42
|
-
return {
|
|
43
|
-
status: 400,
|
|
44
|
-
body: {
|
|
45
|
-
error: error.code === 'LIMIT_FILE_COUNT'
|
|
46
|
-
? `一次最多上传 ${WORKSPACE_UPLOAD_FILE_LIMIT} 个文件,请拆分文件夹后重试。`
|
|
47
|
-
: error.message,
|
|
48
|
-
code: error.code
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export function parseWorkspaceUploadRelativePaths(body) {
|
|
53
|
-
const relativePathsJson = body.relativePathsJson;
|
|
54
|
-
if (typeof relativePathsJson === 'string' && relativePathsJson.trim()) {
|
|
55
|
-
const parsed = JSON.parse(relativePathsJson);
|
|
56
|
-
if (!Array.isArray(parsed)) {
|
|
57
|
-
throw new Error('relativePathsJson must be an array');
|
|
58
|
-
}
|
|
59
|
-
return parsed.map((relativePath) => String(relativePath || ''));
|
|
60
|
-
}
|
|
61
|
-
const relativePaths = body.relativePaths;
|
|
62
|
-
return Array.isArray(relativePaths)
|
|
63
|
-
? relativePaths.map((relativePath) => String(relativePath || ''))
|
|
64
|
-
: typeof relativePaths === 'string'
|
|
65
|
-
? [relativePaths]
|
|
66
|
-
: [];
|
|
67
|
-
}
|
|
68
|
-
function workspaceUploadMiddleware(req, res, next) {
|
|
69
|
-
upload.array('files')(req, res, (error) => {
|
|
70
|
-
if (!error) {
|
|
71
|
-
next();
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (error instanceof multer.MulterError) {
|
|
75
|
-
const response = createWorkspaceUploadLimitResponse(error);
|
|
76
|
-
res.status(response.status).json(response.body);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
next(error);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
async function listHostDirectories(requestPath = '') {
|
|
83
|
-
const platform = process.platform;
|
|
84
|
-
const isWindows = platform === 'win32';
|
|
85
|
-
if (!requestPath || requestPath === '') {
|
|
86
|
-
if (isWindows) {
|
|
87
|
-
// 并行检测所有盘符(C-Z),避免串行 access 累加延迟
|
|
88
|
-
const driveLetters = Array.from({ length: 24 }, (_, i) => String.fromCharCode(67 + i) + ':\\');
|
|
89
|
-
const driveChecks = await Promise.all(driveLetters.map(async (drive) => {
|
|
90
|
-
try {
|
|
91
|
-
await fs.access(drive);
|
|
92
|
-
return { name: drive, path: drive, isDirectory: true };
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
}));
|
|
98
|
-
const drives = driveChecks.filter((d) => d !== null);
|
|
99
|
-
return {
|
|
100
|
-
isWindows: true,
|
|
101
|
-
currentPath: '',
|
|
102
|
-
items: drives
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
const entries = await fs.readdir('/', { withFileTypes: true });
|
|
106
|
-
const items = entries
|
|
107
|
-
.filter(entry => entry.isDirectory())
|
|
108
|
-
.map(entry => ({
|
|
109
|
-
name: entry.name,
|
|
110
|
-
path: '/' + entry.name,
|
|
111
|
-
isDirectory: true
|
|
112
|
-
}));
|
|
113
|
-
return {
|
|
114
|
-
isWindows: false,
|
|
115
|
-
currentPath: '/',
|
|
116
|
-
items
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const normalizedPath = path.normalize(requestPath);
|
|
120
|
-
let stat;
|
|
121
|
-
try {
|
|
122
|
-
stat = await fs.stat(normalizedPath);
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
throw new Error('Path not found: ' + normalizedPath);
|
|
126
|
-
}
|
|
127
|
-
if (!stat.isDirectory()) {
|
|
128
|
-
throw new Error('Path is not a directory: ' + normalizedPath);
|
|
129
|
-
}
|
|
130
|
-
const entries = await fs.readdir(normalizedPath, { withFileTypes: true });
|
|
131
|
-
const items = entries
|
|
132
|
-
.filter(entry => entry.isDirectory())
|
|
133
|
-
.map(entry => ({
|
|
134
|
-
name: entry.name,
|
|
135
|
-
path: path.join(normalizedPath, entry.name),
|
|
136
|
-
isDirectory: true
|
|
137
|
-
}));
|
|
138
|
-
return {
|
|
139
|
-
isWindows,
|
|
140
|
-
currentPath: normalizedPath,
|
|
141
|
-
items
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 主流程:从选中的工作目录生成目录树,根据 .gitignore 规则排除文件,不限制层数和项数。
|
|
146
|
-
*/
|
|
147
|
-
export async function listHostDirectoryTree(requestPath = '') {
|
|
148
|
-
const root = await listHostDirectories(requestPath);
|
|
149
|
-
const ignoreRules = root.currentPath ? await loadGitIgnoreRules(root.currentPath) : [];
|
|
150
|
-
if (!root.currentPath) {
|
|
151
|
-
return {
|
|
152
|
-
...root,
|
|
153
|
-
maxDepth: DIRECTORY_TREE_MAX_DEPTH,
|
|
154
|
-
maxItemsPerDirectory: DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY,
|
|
155
|
-
tree: root.items.slice(0, DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY),
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
...root,
|
|
160
|
-
maxDepth: DIRECTORY_TREE_MAX_DEPTH,
|
|
161
|
-
maxItemsPerDirectory: DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY,
|
|
162
|
-
tree: await buildDirectoryTree(root.currentPath, root.currentPath, 1, ignoreRules),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
async function buildDirectoryTree(rootPath, directoryPath, depth, ignoreRules) {
|
|
166
|
-
if (depth > DIRECTORY_TREE_MAX_DEPTH) {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
const entries = await fs.readdir(directoryPath, { withFileTypes: true });
|
|
170
|
-
const directories = entries
|
|
171
|
-
.filter((entry) => entry.isDirectory())
|
|
172
|
-
.filter((entry) => !isIgnoredDirectory(rootPath, path.join(directoryPath, entry.name), ignoreRules))
|
|
173
|
-
.sort((left, right) => left.name.localeCompare(right.name))
|
|
174
|
-
.slice(0, DIRECTORY_TREE_MAX_ITEMS_PER_DIRECTORY);
|
|
175
|
-
const nodes = [];
|
|
176
|
-
for (const entry of directories) {
|
|
177
|
-
const childPath = path.join(directoryPath, entry.name);
|
|
178
|
-
const node = {
|
|
179
|
-
name: entry.name,
|
|
180
|
-
path: childPath.replace(/\\/g, '/'),
|
|
181
|
-
isDirectory: true,
|
|
182
|
-
};
|
|
183
|
-
if (depth < DIRECTORY_TREE_MAX_DEPTH) {
|
|
184
|
-
try {
|
|
185
|
-
node.children = await buildDirectoryTree(rootPath, childPath, depth + 1, ignoreRules);
|
|
186
|
-
}
|
|
187
|
-
catch {
|
|
188
|
-
node.children = [];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
node.truncated = true;
|
|
193
|
-
}
|
|
194
|
-
nodes.push(node);
|
|
195
|
-
}
|
|
196
|
-
return nodes;
|
|
197
|
-
}
|
|
198
|
-
export function parseGitIgnoreRules(content) {
|
|
199
|
-
return String(content || '')
|
|
200
|
-
.split(/\r?\n/)
|
|
201
|
-
.map((line) => line.trim())
|
|
202
|
-
.filter((line) => line && !line.startsWith('#'))
|
|
203
|
-
.map((line) => {
|
|
204
|
-
const negated = line.startsWith('!');
|
|
205
|
-
const rawPattern = negated ? line.slice(1).trim() : line;
|
|
206
|
-
const anchored = rawPattern.startsWith('/');
|
|
207
|
-
const directoryOnly = rawPattern.endsWith('/');
|
|
208
|
-
const pattern = rawPattern
|
|
209
|
-
.replace(/^\/+/, '')
|
|
210
|
-
.replace(/\/+$/, '')
|
|
211
|
-
.replace(/\\/g, '/');
|
|
212
|
-
return {
|
|
213
|
-
pattern,
|
|
214
|
-
negated,
|
|
215
|
-
directoryOnly,
|
|
216
|
-
anchored,
|
|
217
|
-
hasSlash: pattern.includes('/'),
|
|
218
|
-
};
|
|
219
|
-
})
|
|
220
|
-
.filter((rule) => rule.pattern.length > 0);
|
|
221
|
-
}
|
|
222
|
-
async function loadGitIgnoreRules(rootPath) {
|
|
223
|
-
const allRules = [];
|
|
224
|
-
let currentPath = rootPath;
|
|
225
|
-
// 向上遍历目录树,收集所有 .gitignore 文件
|
|
226
|
-
while (true) {
|
|
227
|
-
try {
|
|
228
|
-
const gitignorePath = path.join(currentPath, '.gitignore');
|
|
229
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
230
|
-
const rules = parseGitIgnoreRules(content);
|
|
231
|
-
// 将新规则插入到前面,因为上层目录的规则优先级更高
|
|
232
|
-
allRules.unshift(...rules);
|
|
233
|
-
}
|
|
234
|
-
catch {
|
|
235
|
-
// 没有 .gitignore 文件,继续向上查找
|
|
236
|
-
}
|
|
237
|
-
// 到达根目录则停止
|
|
238
|
-
const parentPath = path.dirname(currentPath);
|
|
239
|
-
if (parentPath === currentPath) {
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
currentPath = parentPath;
|
|
243
|
-
}
|
|
244
|
-
return allRules;
|
|
245
|
-
}
|
|
246
|
-
export function isIgnoredByGitIgnore(relativePath, isDirectory, rules) {
|
|
247
|
-
const normalizedPath = normalizeRelativePath(relativePath);
|
|
248
|
-
if (!normalizedPath)
|
|
249
|
-
return false;
|
|
250
|
-
let ignored = false;
|
|
251
|
-
for (const rule of rules) {
|
|
252
|
-
if (rule.directoryOnly && !isDirectory)
|
|
253
|
-
continue;
|
|
254
|
-
if (matchesGitIgnoreRule(normalizedPath, rule)) {
|
|
255
|
-
ignored = !rule.negated;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return ignored;
|
|
259
|
-
}
|
|
260
|
-
function isIgnoredDirectory(rootPath, directoryPath, ignoreRules) {
|
|
261
|
-
if (ignoreRules.length === 0)
|
|
262
|
-
return false;
|
|
263
|
-
const relativePath = path.relative(rootPath, directoryPath).replace(/\\/g, '/');
|
|
264
|
-
return isIgnoredByGitIgnore(relativePath, true, ignoreRules);
|
|
265
|
-
}
|
|
266
|
-
function matchesGitIgnoreRule(relativePath, rule) {
|
|
267
|
-
if (!rule.hasSlash && !rule.anchored) {
|
|
268
|
-
return relativePath.split('/').some((segment) => matchesGlobSegment(segment, rule.pattern));
|
|
269
|
-
}
|
|
270
|
-
const pattern = rule.pattern;
|
|
271
|
-
if (rule.anchored) {
|
|
272
|
-
return matchesGlobPath(relativePath, pattern) || relativePath.startsWith(pattern + '/');
|
|
273
|
-
}
|
|
274
|
-
return matchesGlobPath(relativePath, pattern)
|
|
275
|
-
|| relativePath.endsWith('/' + pattern)
|
|
276
|
-
|| relativePath.includes('/' + pattern + '/');
|
|
277
|
-
}
|
|
278
|
-
function matchesGlobPath(relativePath, pattern) {
|
|
279
|
-
const regex = new RegExp('^' + globToRegex(pattern) + '(?:/.*)?$');
|
|
280
|
-
return regex.test(relativePath);
|
|
281
|
-
}
|
|
282
|
-
function matchesGlobSegment(segment, pattern) {
|
|
283
|
-
const regex = new RegExp('^' + globToRegex(pattern) + '$');
|
|
284
|
-
return regex.test(segment);
|
|
285
|
-
}
|
|
286
|
-
function globToRegex(pattern) {
|
|
287
|
-
return pattern
|
|
288
|
-
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
289
|
-
.replace(/\*\*/g, '.*')
|
|
290
|
-
.replace(/\*/g, '[^/]*')
|
|
291
|
-
.replace(/\?/g, '[^/]');
|
|
292
|
-
}
|
|
293
|
-
function normalizeRelativePath(relativePath) {
|
|
294
|
-
return String(relativePath || '')
|
|
295
|
-
.replace(/\\/g, '/')
|
|
296
|
-
.replace(/^\.\//, '')
|
|
297
|
-
.replace(/^\/+/, '')
|
|
298
|
-
.replace(/\/+$/, '');
|
|
299
|
-
}
|
|
300
|
-
async function resolveHostDirectoryPath(targetPath) {
|
|
301
|
-
const normalizedPath = path.normalize(String(targetPath || ''));
|
|
302
|
-
const stat = await fs.stat(normalizedPath);
|
|
303
|
-
if (!stat.isDirectory()) {
|
|
304
|
-
throw new Error('Path is not a directory: ' + normalizedPath);
|
|
305
|
-
}
|
|
306
|
-
return normalizedPath;
|
|
307
|
-
}
|
|
308
|
-
function assertSafeDirectoryEntryName(entryName) {
|
|
309
|
-
const trimmedName = String(entryName || '').trim();
|
|
310
|
-
if (!trimmedName) {
|
|
311
|
-
throw new Error('Folder name is required');
|
|
312
|
-
}
|
|
313
|
-
if (trimmedName.includes('/') || trimmedName.includes('\\') || trimmedName === '.' || trimmedName === '..') {
|
|
314
|
-
throw new Error('Folder name must not contain path separators');
|
|
315
|
-
}
|
|
316
|
-
return trimmedName;
|
|
317
|
-
}
|
|
318
|
-
async function createHostDirectory(parentPath, entryName) {
|
|
319
|
-
const parentDirectory = await resolveHostDirectoryPath(parentPath);
|
|
320
|
-
const safeEntryName = assertSafeDirectoryEntryName(entryName);
|
|
321
|
-
const targetPath = path.join(parentDirectory, safeEntryName);
|
|
322
|
-
await fs.mkdir(targetPath);
|
|
323
|
-
return {
|
|
324
|
-
ok: true,
|
|
325
|
-
parentPath,
|
|
326
|
-
targetPath: targetPath.replace(/\\/g, '/'),
|
|
327
|
-
entryName: safeEntryName
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
async function renameHostDirectory(targetPath, newName) {
|
|
331
|
-
const sourcePath = await resolveHostDirectoryPath(targetPath);
|
|
332
|
-
const safeNewName = assertSafeDirectoryEntryName(newName);
|
|
333
|
-
const destinationPath = path.join(path.dirname(sourcePath), safeNewName);
|
|
334
|
-
await fs.rename(sourcePath, destinationPath);
|
|
335
|
-
return {
|
|
336
|
-
ok: true,
|
|
337
|
-
sourcePath: sourcePath.replace(/\\/g, '/'),
|
|
338
|
-
targetPath: destinationPath.replace(/\\/g, '/'),
|
|
339
|
-
newName: safeNewName
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* 列出目录内容
|
|
344
|
-
* POST /api/file-browser/list
|
|
345
|
-
*/
|
|
346
|
-
fileBrowserRouter.post('/list', validateToken, async (req, res) => {
|
|
347
|
-
try {
|
|
348
|
-
if (!allowHostFileBrowser) {
|
|
349
|
-
return res.status(403).json({
|
|
350
|
-
error: 'Host filesystem browsing is disabled. Use /api/file-browser/workspace/list with a registered workspace, or set AWS_ALLOW_HOST_FILE_BROWSER=true for isolated local debugging.'
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
const { path: requestPath = '' } = req.body || {};
|
|
354
|
-
res.json(await listHostDirectories(String(requestPath || '')));
|
|
355
|
-
}
|
|
356
|
-
catch (error) {
|
|
357
|
-
const err = error;
|
|
358
|
-
res.status(500).json({ error: err.message });
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
/**
|
|
362
|
-
* 列出目录选择器内容。
|
|
363
|
-
* POST /api/file-browser/directory-picker/list
|
|
364
|
-
*
|
|
365
|
-
* 该接口只返回目录,用于选择工作目录;不同于 /list,它不暴露文件条目。
|
|
366
|
-
*/
|
|
367
|
-
fileBrowserRouter.post('/directory-picker/list', validateToken, async (req, res) => {
|
|
368
|
-
try {
|
|
369
|
-
const { path: requestPath = '' } = req.body || {};
|
|
370
|
-
res.json(await listHostDirectories(String(requestPath || '')));
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
373
|
-
const err = error;
|
|
374
|
-
res.status(400).json({ error: err.message });
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
fileBrowserRouter.post('/directory-picker/tree', validateToken, async (req, res) => {
|
|
378
|
-
try {
|
|
379
|
-
const { path: requestPath = '' } = req.body || {};
|
|
380
|
-
res.json(await listHostDirectoryTree(String(requestPath || '')));
|
|
381
|
-
}
|
|
382
|
-
catch (error) {
|
|
383
|
-
const err = error;
|
|
384
|
-
res.status(400).json({ error: err.message });
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
/**
|
|
388
|
-
* 列出工作区目录内容
|
|
389
|
-
* POST /api/file-browser/workspace/list
|
|
390
|
-
*/
|
|
391
|
-
fileBrowserRouter.post('/workspace/list', validateToken, async (req, res) => {
|
|
392
|
-
try {
|
|
393
|
-
const { workspacePath, path: requestPath = '' } = req.body || {};
|
|
394
|
-
const result = await listWorkspaceDirectory({
|
|
395
|
-
workspacePath: String(workspacePath || ''),
|
|
396
|
-
targetPath: String(requestPath || '')
|
|
397
|
-
});
|
|
398
|
-
res.json({
|
|
399
|
-
isWindows: process.platform === 'win32',
|
|
400
|
-
currentPath: result.currentPath,
|
|
401
|
-
workspacePath: result.workspacePath,
|
|
402
|
-
items: result.items
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
catch (error) {
|
|
406
|
-
const err = error;
|
|
407
|
-
console.error('[file-browser] failed to list workspace directory:', err);
|
|
408
|
-
res.status(400).json({ error: err.message });
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
/**
|
|
412
|
-
* 读取工作区文件内容
|
|
413
|
-
* POST /api/file-browser/workspace/read
|
|
414
|
-
*/
|
|
415
|
-
fileBrowserRouter.post('/workspace/read', validateToken, async (req, res) => {
|
|
416
|
-
try {
|
|
417
|
-
const { workspacePath, filePath } = req.body || {};
|
|
418
|
-
const result = await readWorkspaceFile({
|
|
419
|
-
workspacePath: String(workspacePath || ''),
|
|
420
|
-
filePath: String(filePath || '')
|
|
421
|
-
});
|
|
422
|
-
res.json(result);
|
|
423
|
-
}
|
|
424
|
-
catch (error) {
|
|
425
|
-
const err = error;
|
|
426
|
-
console.error('[file-browser] failed to read workspace file:', err);
|
|
427
|
-
res.status(400).json({ error: err.message });
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
/**
|
|
431
|
-
* 读取工作区文件或目录属性。
|
|
432
|
-
* POST /api/file-browser/workspace/properties
|
|
433
|
-
*/
|
|
434
|
-
fileBrowserRouter.post('/workspace/properties', validateToken, async (req, res) => {
|
|
435
|
-
try {
|
|
436
|
-
const { workspacePath, targetPath } = req.body || {};
|
|
437
|
-
res.json(await getWorkspaceEntryProperties({
|
|
438
|
-
workspacePath: String(workspacePath || ''),
|
|
439
|
-
targetPath: String(targetPath || '')
|
|
440
|
-
}));
|
|
441
|
-
}
|
|
442
|
-
catch (error) {
|
|
443
|
-
const err = error;
|
|
444
|
-
log.error('failed to get workspace entry properties:', err);
|
|
445
|
-
res.status(400).json({ error: err.message });
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
/**
|
|
449
|
-
* 修改工作区文件或目录权限。
|
|
450
|
-
* POST /api/file-browser/workspace/chmod
|
|
451
|
-
*/
|
|
452
|
-
fileBrowserRouter.post('/workspace/chmod', validateToken, async (req, res) => {
|
|
453
|
-
try {
|
|
454
|
-
const { workspacePath, targetPath, mode, recursive } = req.body || {};
|
|
455
|
-
res.json(await chmodWorkspaceEntry({
|
|
456
|
-
workspacePath: String(workspacePath || ''),
|
|
457
|
-
targetPath: String(targetPath || ''),
|
|
458
|
-
mode: String(mode || ''),
|
|
459
|
-
recursive: Boolean(recursive)
|
|
460
|
-
}));
|
|
461
|
-
}
|
|
462
|
-
catch (error) {
|
|
463
|
-
const err = error;
|
|
464
|
-
log.error('failed to chmod workspace entry:', err);
|
|
465
|
-
res.status(400).json({ error: err.message });
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
/**
|
|
469
|
-
* 在目录选择器当前位置创建文件夹。
|
|
470
|
-
* POST /api/file-browser/directory-picker/create
|
|
471
|
-
*/
|
|
472
|
-
fileBrowserRouter.post('/directory-picker/create', validateToken, async (req, res) => {
|
|
473
|
-
try {
|
|
474
|
-
const { path: requestPath = '', entryName } = req.body || {};
|
|
475
|
-
res.json(await createHostDirectory(String(requestPath || ''), String(entryName || '')));
|
|
476
|
-
}
|
|
477
|
-
catch (error) {
|
|
478
|
-
const err = error;
|
|
479
|
-
log.error('failed to create directory from directory picker:', err);
|
|
480
|
-
res.status(400).json({ error: err.message });
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
/**
|
|
484
|
-
* 重命名目录选择器中的文件夹。
|
|
485
|
-
* POST /api/file-browser/directory-picker/rename
|
|
486
|
-
*/
|
|
487
|
-
fileBrowserRouter.post('/directory-picker/rename', validateToken, async (req, res) => {
|
|
488
|
-
try {
|
|
489
|
-
const { targetPath, newName } = req.body || {};
|
|
490
|
-
res.json(await renameHostDirectory(String(targetPath || ''), String(newName || '')));
|
|
491
|
-
}
|
|
492
|
-
catch (error) {
|
|
493
|
-
const err = error;
|
|
494
|
-
log.error('failed to rename directory from directory picker:', err);
|
|
495
|
-
res.status(400).json({ error: err.message });
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
/**
|
|
499
|
-
* 预览工作区文档内容。
|
|
500
|
-
* POST /api/file-browser/workspace/preview
|
|
501
|
-
*/
|
|
502
|
-
fileBrowserRouter.post('/workspace/preview', validateToken, async (req, res) => {
|
|
503
|
-
try {
|
|
504
|
-
const { workspacePath, filePath } = req.body || {};
|
|
505
|
-
const result = await previewWorkspaceDocument({
|
|
506
|
-
workspacePath: String(workspacePath || ''),
|
|
507
|
-
filePath: String(filePath || '')
|
|
508
|
-
});
|
|
509
|
-
res.json(result);
|
|
510
|
-
}
|
|
511
|
-
catch (error) {
|
|
512
|
-
const err = error;
|
|
513
|
-
log.error('failed to preview workspace document:', err);
|
|
514
|
-
res.status(400).json({ error: err.message });
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
/**
|
|
518
|
-
* 监听工作区文件变化,用于文档预览自动刷新。
|
|
519
|
-
* POST /api/file-browser/workspace/watch
|
|
520
|
-
*/
|
|
521
|
-
fileBrowserRouter.post('/workspace/watch', validateToken, async (req, res) => {
|
|
522
|
-
try {
|
|
523
|
-
const { workspacePath, filePath } = req.body || {};
|
|
524
|
-
res.json(await watchWorkspaceFile({
|
|
525
|
-
workspacePath: String(workspacePath || ''),
|
|
526
|
-
filePath: String(filePath || '')
|
|
527
|
-
}));
|
|
528
|
-
}
|
|
529
|
-
catch (error) {
|
|
530
|
-
const err = error;
|
|
531
|
-
log.error('failed to watch workspace file:', err);
|
|
532
|
-
res.status(400).json({ error: err.message });
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
/**
|
|
536
|
-
* 取消监听工作区文件变化。
|
|
537
|
-
* POST /api/file-browser/workspace/unwatch
|
|
538
|
-
*/
|
|
539
|
-
fileBrowserRouter.post('/workspace/unwatch', validateToken, async (req, res) => {
|
|
540
|
-
try {
|
|
541
|
-
const { workspacePath, filePath } = req.body || {};
|
|
542
|
-
res.json(await unwatchWorkspaceFile({
|
|
543
|
-
workspacePath: String(workspacePath || ''),
|
|
544
|
-
filePath: String(filePath || '')
|
|
545
|
-
}));
|
|
546
|
-
}
|
|
547
|
-
catch (error) {
|
|
548
|
-
const err = error;
|
|
549
|
-
log.error('failed to unwatch workspace file:', err);
|
|
550
|
-
res.status(400).json({ error: err.message });
|
|
551
|
-
}
|
|
552
|
-
});
|
|
553
|
-
/**
|
|
554
|
-
* 保存工作区文件内容
|
|
555
|
-
* POST /api/file-browser/workspace/write
|
|
556
|
-
*/
|
|
557
|
-
fileBrowserRouter.post('/workspace/write', validateToken, async (req, res) => {
|
|
558
|
-
try {
|
|
559
|
-
const { workspacePath, filePath, content } = req.body || {};
|
|
560
|
-
const result = await writeWorkspaceFile({
|
|
561
|
-
workspacePath: String(workspacePath || ''),
|
|
562
|
-
filePath: String(filePath || ''),
|
|
563
|
-
content: String(content ?? '')
|
|
564
|
-
});
|
|
565
|
-
res.json(result);
|
|
566
|
-
}
|
|
567
|
-
catch (error) {
|
|
568
|
-
const err = error;
|
|
569
|
-
console.error('[file-browser] failed to write workspace file:', err);
|
|
570
|
-
res.status(400).json({ error: err.message });
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
/**
|
|
574
|
-
* 在工作区目录下创建文件或目录
|
|
575
|
-
* POST /api/file-browser/workspace/create
|
|
576
|
-
*/
|
|
577
|
-
fileBrowserRouter.post('/workspace/create', validateToken, async (req, res) => {
|
|
578
|
-
try {
|
|
579
|
-
const { workspacePath, path: requestPath = '', entryName, isDirectory } = req.body || {};
|
|
580
|
-
const result = await createWorkspaceEntry({
|
|
581
|
-
workspacePath: String(workspacePath || ''),
|
|
582
|
-
targetPath: String(requestPath || ''),
|
|
583
|
-
entryName: String(entryName || ''),
|
|
584
|
-
isDirectory: Boolean(isDirectory)
|
|
585
|
-
});
|
|
586
|
-
res.json(result);
|
|
587
|
-
}
|
|
588
|
-
catch (error) {
|
|
589
|
-
const err = error;
|
|
590
|
-
log.error('failed to create workspace entry:', err);
|
|
591
|
-
res.status(400).json({ error: err.message });
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
/**
|
|
595
|
-
* 重命名工作区中的文件或目录
|
|
596
|
-
* POST /api/file-browser/workspace/rename
|
|
597
|
-
*/
|
|
598
|
-
fileBrowserRouter.post('/workspace/rename', validateToken, async (req, res) => {
|
|
599
|
-
try {
|
|
600
|
-
const { workspacePath, targetPath, newName } = req.body || {};
|
|
601
|
-
const result = await renameWorkspaceEntry({
|
|
602
|
-
workspacePath: String(workspacePath || ''),
|
|
603
|
-
targetPath: String(targetPath || ''),
|
|
604
|
-
newName: String(newName || '')
|
|
605
|
-
});
|
|
606
|
-
res.json(result);
|
|
607
|
-
}
|
|
608
|
-
catch (error) {
|
|
609
|
-
const err = error;
|
|
610
|
-
log.error('failed to rename workspace entry:', err);
|
|
611
|
-
res.status(400).json({ error: err.message });
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
/**
|
|
615
|
-
* 移动工作区中的文件或目录到另一个工作区目录
|
|
616
|
-
* POST /api/file-browser/workspace/move
|
|
617
|
-
*/
|
|
618
|
-
fileBrowserRouter.post('/workspace/move', validateToken, async (req, res) => {
|
|
619
|
-
try {
|
|
620
|
-
const { workspacePath, targetPath, destinationPath } = req.body || {};
|
|
621
|
-
const result = await moveWorkspaceEntry({
|
|
622
|
-
workspacePath: String(workspacePath || ''),
|
|
623
|
-
targetPath: String(targetPath || ''),
|
|
624
|
-
destinationPath: String(destinationPath || '')
|
|
625
|
-
});
|
|
626
|
-
res.json(result);
|
|
627
|
-
}
|
|
628
|
-
catch (error) {
|
|
629
|
-
const err = error;
|
|
630
|
-
log.error('failed to move workspace entry:', err);
|
|
631
|
-
res.status(400).json({ error: err.message });
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
/**
|
|
635
|
-
* 删除工作区中的文件或目录
|
|
636
|
-
* POST /api/file-browser/workspace/delete
|
|
637
|
-
*/
|
|
638
|
-
fileBrowserRouter.post('/workspace/delete', validateToken, async (req, res) => {
|
|
639
|
-
try {
|
|
640
|
-
const { workspacePath, targetPath } = req.body || {};
|
|
641
|
-
const result = await deleteWorkspaceEntry({
|
|
642
|
-
workspacePath: String(workspacePath || ''),
|
|
643
|
-
targetPath: String(targetPath || '')
|
|
644
|
-
});
|
|
645
|
-
res.json(result);
|
|
646
|
-
}
|
|
647
|
-
catch (error) {
|
|
648
|
-
const err = error;
|
|
649
|
-
log.error('failed to delete workspace entry:', err);
|
|
650
|
-
res.status(400).json({ error: err.message });
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
/**
|
|
654
|
-
* 上传文件到工作区指定目录,可选自动解压常见压缩包。
|
|
655
|
-
* POST /api/file-browser/workspace/upload
|
|
656
|
-
*/
|
|
657
|
-
fileBrowserRouter.post('/workspace/upload', validateToken, workspaceUploadMiddleware, async (req, res) => {
|
|
658
|
-
const files = (req.files || []);
|
|
659
|
-
try {
|
|
660
|
-
const { workspacePath, path: requestPath = '', extractArchives } = req.body || {};
|
|
661
|
-
const relativePaths = parseWorkspaceUploadRelativePaths(req.body || {});
|
|
662
|
-
const result = await uploadWorkspaceFiles({
|
|
663
|
-
workspacePath: String(workspacePath || ''),
|
|
664
|
-
targetPath: String(requestPath || ''),
|
|
665
|
-
extractArchives: toBoolean(extractArchives),
|
|
666
|
-
files: files.map((file, index) => ({
|
|
667
|
-
originalname: file.originalname,
|
|
668
|
-
relativePath: relativePaths[index],
|
|
669
|
-
path: file.path,
|
|
670
|
-
size: file.size
|
|
671
|
-
}))
|
|
672
|
-
});
|
|
673
|
-
res.json(result);
|
|
674
|
-
}
|
|
675
|
-
catch (error) {
|
|
676
|
-
const err = error;
|
|
677
|
-
log.error('failed to upload workspace files:', err);
|
|
678
|
-
res.status(400).json({ error: err.message });
|
|
679
|
-
}
|
|
680
|
-
finally {
|
|
681
|
-
await cleanupUploadedFiles(files);
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
-
/**
|
|
685
|
-
* 下载工作区文件或目录;目录会实时打包为 zip。
|
|
686
|
-
* POST /api/file-browser/workspace/download
|
|
687
|
-
*/
|
|
688
|
-
fileBrowserRouter.post('/workspace/download', validateToken, async (req, res) => {
|
|
689
|
-
try {
|
|
690
|
-
const { workspacePath, targetPath } = req.body || {};
|
|
691
|
-
const target = await resolveWorkspaceDownloadTarget({
|
|
692
|
-
workspacePath: String(workspacePath || ''),
|
|
693
|
-
targetPath: String(targetPath || '')
|
|
694
|
-
});
|
|
695
|
-
res.setHeader('Content-Type', target.contentType);
|
|
696
|
-
res.setHeader('Content-Disposition', contentDispositionFileName(target.fileName));
|
|
697
|
-
res.setHeader('X-Workspace-Path', encodeURIComponent(target.workspacePath));
|
|
698
|
-
res.setHeader('X-Workspace-Target-Path', encodeURIComponent(target.targetPath));
|
|
699
|
-
if (target.isDirectory) {
|
|
700
|
-
await streamWorkspaceDirectoryZip(target.resolvedTargetPath, res);
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
createReadStream(target.resolvedTargetPath).pipe(res);
|
|
704
|
-
}
|
|
705
|
-
catch (error) {
|
|
706
|
-
const err = error;
|
|
707
|
-
log.error('failed to download workspace entry:', err);
|
|
708
|
-
if (!res.headersSent) {
|
|
709
|
-
res.status(400).json({ error: err.message });
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
res.destroy(err);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
/**
|
|
717
|
-
* 解压工作区内的压缩包到指定目录。
|
|
718
|
-
* POST /api/file-browser/workspace/extract
|
|
719
|
-
*/
|
|
720
|
-
fileBrowserRouter.post('/workspace/extract', validateToken, async (req, res) => {
|
|
721
|
-
try {
|
|
722
|
-
const { workspacePath, archivePath, outputPath = '' } = req.body || {};
|
|
723
|
-
const result = await extractWorkspaceArchive({
|
|
724
|
-
workspacePath: String(workspacePath || ''),
|
|
725
|
-
archivePath: String(archivePath || ''),
|
|
726
|
-
outputPath: String(outputPath || '')
|
|
727
|
-
});
|
|
728
|
-
res.json(result);
|
|
729
|
-
}
|
|
730
|
-
catch (error) {
|
|
731
|
-
const err = error;
|
|
732
|
-
log.error('failed to extract workspace archive:', err);
|
|
733
|
-
res.status(400).json({ error: err.message });
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
/**
|
|
737
|
-
* 在工作区范围内搜索文件内容。
|
|
738
|
-
* POST /api/file-browser/workspace/search
|
|
739
|
-
*/
|
|
740
|
-
fileBrowserRouter.post('/workspace/search', validateToken, async (req, res) => {
|
|
741
|
-
try {
|
|
742
|
-
const { workspacePath, keyword, fileMask, ignoreCase, maxResults, mode } = req.body || {};
|
|
743
|
-
const result = await searchWorkspaceFiles({
|
|
744
|
-
workspacePath: String(workspacePath || ''),
|
|
745
|
-
keyword: String(keyword || ''),
|
|
746
|
-
fileMask: fileMask !== undefined ? String(fileMask) : undefined,
|
|
747
|
-
ignoreCase: toBoolean(ignoreCase),
|
|
748
|
-
maxResults: typeof maxResults === 'number' ? maxResults : undefined,
|
|
749
|
-
mode: mode === 'filename' ? 'filename' : 'content'
|
|
750
|
-
});
|
|
751
|
-
res.json(result);
|
|
752
|
-
}
|
|
753
|
-
catch (error) {
|
|
754
|
-
const err = error;
|
|
755
|
-
log.error('failed to search workspace files:', err);
|
|
756
|
-
res.status(400).json({ error: err.message });
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
/**
|
|
760
|
-
* 在工作区范围内批量替换文件内容。
|
|
761
|
-
* POST /api/file-browser/workspace/replace
|
|
762
|
-
*/
|
|
763
|
-
fileBrowserRouter.post('/workspace/replace', validateToken, async (req, res) => {
|
|
764
|
-
try {
|
|
765
|
-
const { workspacePath, keyword, replacement, fileMask, ignoreCase, filePath } = req.body || {};
|
|
766
|
-
const result = await replaceWorkspaceFiles({
|
|
767
|
-
workspacePath: String(workspacePath || ''),
|
|
768
|
-
keyword: String(keyword || ''),
|
|
769
|
-
replacement: String(replacement ?? ''),
|
|
770
|
-
fileMask: fileMask !== undefined ? String(fileMask) : undefined,
|
|
771
|
-
ignoreCase: toBoolean(ignoreCase),
|
|
772
|
-
filePath: filePath !== undefined ? String(filePath) : undefined
|
|
773
|
-
});
|
|
774
|
-
res.json(result);
|
|
775
|
-
}
|
|
776
|
-
catch (error) {
|
|
777
|
-
const err = error;
|
|
778
|
-
log.error('failed to replace workspace files:', err);
|
|
779
|
-
res.status(400).json({ error: err.message });
|
|
780
|
-
}
|
|
781
|
-
});
|
|
1
|
+
import{createReadStream as T,promises as w}from"node:fs";import v from"node:os";import d from"node:path";import{Router as x}from"express";import P from"multer";import{allowHostFileBrowser as I}from"../config.js";import{validateToken as n}from"../middleware/auth.js";import{chmodWorkspaceEntry as _,createWorkspaceEntry as F,deleteWorkspaceEntry as N,extractWorkspaceArchive as C,getWorkspaceEntryProperties as A,listWorkspaceDirectory as H,moveWorkspaceEntry as M,previewWorkspaceDocument as O,readWorkspaceFile as L,renameWorkspaceEntry as U,replaceWorkspaceFiles as z,resolveWorkspaceDownloadTarget as $,searchWorkspaceFiles as G,streamWorkspaceDirectoryZip as B,uploadWorkspaceFiles as X,writeWorkspaceFile as q}from"../services/workspace-files.js";import{unwatchWorkspaceFile as J,watchWorkspaceFile as Y}from"../services/workspace-watch.js";import{createLogger as K}from"../utils/logger.js";const l=K("file-browser"),c=x(),S=2e3,Z=P({dest:d.join(v.tmpdir(),"agentswork-runtime-bridge-uploads"),limits:{files:S,fileSize:512*1024*1024}}),g=Number.MAX_SAFE_INTEGER,f=Number.MAX_SAFE_INTEGER;function y(a){return a===!0||a==="true"||a==="1"}function Q(a){return`attachment; filename="${a.replace(/[\\"\r\n]/g,"_").replace(/[^\x20-\x7E]/g,"_")}"; filename*=UTF-8''${encodeURIComponent(a)}`}async function V(a=[]){await Promise.all(a.map(t=>w.rm(t.path,{force:!0}).catch(()=>{})))}function tt(a){return{status:400,body:{error:a.code==="LIMIT_FILE_COUNT"?`\u4E00\u6B21\u6700\u591A\u4E0A\u4F20 ${S} \u4E2A\u6587\u4EF6\uFF0C\u8BF7\u62C6\u5206\u6587\u4EF6\u5939\u540E\u91CD\u8BD5\u3002`:a.message,code:a.code}}}function rt(a){const t=a.relativePathsJson;if(typeof t=="string"&&t.trim()){const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("relativePathsJson must be an array");return r.map(o=>String(o||""))}const e=a.relativePaths;return Array.isArray(e)?e.map(r=>String(r||"")):typeof e=="string"?[e]:[]}function et(a,t,e){Z.array("files")(a,t,r=>{if(!r){e();return}if(r instanceof P.MulterError){const o=tt(r);t.status(o.status).json(o.body);return}e(r)})}async function k(a=""){const e=process.platform==="win32";if(!a||a===""){if(e){const u=Array.from({length:24},(m,R)=>String.fromCharCode(67+R)+":\\");return{isWindows:!0,currentPath:"",items:(await Promise.all(u.map(async m=>{try{return await w.access(m),{name:m,path:m,isDirectory:!0}}catch{return null}}))).filter(m=>m!==null)}}return{isWindows:!1,currentPath:"/",items:(await w.readdir("/",{withFileTypes:!0})).filter(u=>u.isDirectory()).map(u=>({name:u.name,path:"/"+u.name,isDirectory:!0}))}}const r=d.normalize(a);let o;try{o=await w.stat(r)}catch{throw new Error("Path not found: "+r)}if(!o.isDirectory())throw new Error("Path is not a directory: "+r);const p=(await w.readdir(r,{withFileTypes:!0})).filter(i=>i.isDirectory()).map(i=>({name:i.name,path:d.join(r,i.name),isDirectory:!0}));return{isWindows:e,currentPath:r,items:p}}async function at(a=""){const t=await k(a),e=t.currentPath?await st(t.currentPath):[];return t.currentPath?{...t,maxDepth:g,maxItemsPerDirectory:f,tree:await j(t.currentPath,t.currentPath,1,e)}:{...t,maxDepth:g,maxItemsPerDirectory:f,tree:t.items.slice(0,f)}}async function j(a,t,e,r){if(e>g)return[];const s=(await w.readdir(t,{withFileTypes:!0})).filter(i=>i.isDirectory()).filter(i=>!ct(a,d.join(t,i.name),r)).sort((i,h)=>i.name.localeCompare(h.name)).slice(0,f),p=[];for(const i of s){const h=d.join(t,i.name),u={name:i.name,path:h.replace(/\\/g,"/"),isDirectory:!0};if(e<g)try{u.children=await j(a,h,e+1,r)}catch{u.children=[]}else u.truncated=!0;p.push(u)}return p}function ot(a){return String(a||"").split(/\r?\n/).map(t=>t.trim()).filter(t=>t&&!t.startsWith("#")).map(t=>{const e=t.startsWith("!"),r=e?t.slice(1).trim():t,o=r.startsWith("/"),s=r.endsWith("/"),p=r.replace(/^\/+/,"").replace(/\/+$/,"").replace(/\\/g,"/");return{pattern:p,negated:e,directoryOnly:s,anchored:o,hasSlash:p.includes("/")}}).filter(t=>t.pattern.length>0)}async function st(a){const t=[];let e=a;for(;;){try{const o=d.join(e,".gitignore"),s=await w.readFile(o,"utf8"),p=ot(s);t.unshift(...p)}catch{}const r=d.dirname(e);if(r===e)break;e=r}return t}function nt(a,t,e){const r=lt(a);if(!r)return!1;let o=!1;for(const s of e)s.directoryOnly&&!t||it(r,s)&&(o=!s.negated);return o}function ct(a,t,e){if(e.length===0)return!1;const r=d.relative(a,t).replace(/\\/g,"/");return nt(r,!0,e)}function it(a,t){if(!t.hasSlash&&!t.anchored)return a.split("/").some(r=>pt(r,t.pattern));const e=t.pattern;return t.anchored?b(a,e)||a.startsWith(e+"/"):b(a,e)||a.endsWith("/"+e)||a.includes("/"+e+"/")}function b(a,t){return new RegExp("^"+E(t)+"(?:/.*)?$").test(a)}function pt(a,t){return new RegExp("^"+E(t)+"$").test(a)}function E(a){return a.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]")}function lt(a){return String(a||"").replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}async function D(a){const t=d.normalize(String(a||""));if(!(await w.stat(t)).isDirectory())throw new Error("Path is not a directory: "+t);return t}function W(a){const t=String(a||"").trim();if(!t)throw new Error("Folder name is required");if(t.includes("/")||t.includes("\\")||t==="."||t==="..")throw new Error("Folder name must not contain path separators");return t}async function ht(a,t){const e=await D(a),r=W(t),o=d.join(e,r);return await w.mkdir(o),{ok:!0,parentPath:a,targetPath:o.replace(/\\/g,"/"),entryName:r}}async function ut(a,t){const e=await D(a),r=W(t),o=d.join(d.dirname(e),r);return await w.rename(e,o),{ok:!0,sourcePath:e.replace(/\\/g,"/"),targetPath:o.replace(/\\/g,"/"),newName:r}}c.post("/list",n,async(a,t)=>{try{if(!I)return t.status(403).json({error:"Host filesystem browsing is disabled. Use /api/file-browser/workspace/list with a registered workspace, or set AWS_ALLOW_HOST_FILE_BROWSER=true for isolated local debugging."});const{path:e=""}=a.body||{};t.json(await k(String(e||"")))}catch(e){const r=e;t.status(500).json({error:r.message})}}),c.post("/directory-picker/list",n,async(a,t)=>{try{const{path:e=""}=a.body||{};t.json(await k(String(e||"")))}catch(e){const r=e;t.status(400).json({error:r.message})}}),c.post("/directory-picker/tree",n,async(a,t)=>{try{const{path:e=""}=a.body||{};t.json(await at(String(e||"")))}catch(e){const r=e;t.status(400).json({error:r.message})}}),c.post("/workspace/list",n,async(a,t)=>{try{const{workspacePath:e,path:r=""}=a.body||{},o=await H({workspacePath:String(e||""),targetPath:String(r||"")});t.json({isWindows:process.platform==="win32",currentPath:o.currentPath,workspacePath:o.workspacePath,items:o.items})}catch(e){const r=e;console.error("[file-browser] failed to list workspace directory:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/read",n,async(a,t)=>{try{const{workspacePath:e,filePath:r}=a.body||{},o=await L({workspacePath:String(e||""),filePath:String(r||"")});t.json(o)}catch(e){const r=e;console.error("[file-browser] failed to read workspace file:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/properties",n,async(a,t)=>{try{const{workspacePath:e,targetPath:r}=a.body||{};t.json(await A({workspacePath:String(e||""),targetPath:String(r||"")}))}catch(e){const r=e;l.error("failed to get workspace entry properties:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/chmod",n,async(a,t)=>{try{const{workspacePath:e,targetPath:r,mode:o,recursive:s}=a.body||{};t.json(await _({workspacePath:String(e||""),targetPath:String(r||""),mode:String(o||""),recursive:!!s}))}catch(e){const r=e;l.error("failed to chmod workspace entry:",r),t.status(400).json({error:r.message})}}),c.post("/directory-picker/create",n,async(a,t)=>{try{const{path:e="",entryName:r}=a.body||{};t.json(await ht(String(e||""),String(r||"")))}catch(e){const r=e;l.error("failed to create directory from directory picker:",r),t.status(400).json({error:r.message})}}),c.post("/directory-picker/rename",n,async(a,t)=>{try{const{targetPath:e,newName:r}=a.body||{};t.json(await ut(String(e||""),String(r||"")))}catch(e){const r=e;l.error("failed to rename directory from directory picker:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/preview",n,async(a,t)=>{try{const{workspacePath:e,filePath:r}=a.body||{},o=await O({workspacePath:String(e||""),filePath:String(r||"")});t.json(o)}catch(e){const r=e;l.error("failed to preview workspace document:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/watch",n,async(a,t)=>{try{const{workspacePath:e,filePath:r}=a.body||{};t.json(await Y({workspacePath:String(e||""),filePath:String(r||"")}))}catch(e){const r=e;l.error("failed to watch workspace file:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/unwatch",n,async(a,t)=>{try{const{workspacePath:e,filePath:r}=a.body||{};t.json(await J({workspacePath:String(e||""),filePath:String(r||"")}))}catch(e){const r=e;l.error("failed to unwatch workspace file:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/write",n,async(a,t)=>{try{const{workspacePath:e,filePath:r,content:o}=a.body||{},s=await q({workspacePath:String(e||""),filePath:String(r||""),content:String(o??"")});t.json(s)}catch(e){const r=e;console.error("[file-browser] failed to write workspace file:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/create",n,async(a,t)=>{try{const{workspacePath:e,path:r="",entryName:o,isDirectory:s}=a.body||{},p=await F({workspacePath:String(e||""),targetPath:String(r||""),entryName:String(o||""),isDirectory:!!s});t.json(p)}catch(e){const r=e;l.error("failed to create workspace entry:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/rename",n,async(a,t)=>{try{const{workspacePath:e,targetPath:r,newName:o}=a.body||{},s=await U({workspacePath:String(e||""),targetPath:String(r||""),newName:String(o||"")});t.json(s)}catch(e){const r=e;l.error("failed to rename workspace entry:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/move",n,async(a,t)=>{try{const{workspacePath:e,targetPath:r,destinationPath:o}=a.body||{},s=await M({workspacePath:String(e||""),targetPath:String(r||""),destinationPath:String(o||"")});t.json(s)}catch(e){const r=e;l.error("failed to move workspace entry:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/delete",n,async(a,t)=>{try{const{workspacePath:e,targetPath:r}=a.body||{},o=await N({workspacePath:String(e||""),targetPath:String(r||"")});t.json(o)}catch(e){const r=e;l.error("failed to delete workspace entry:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/upload",n,et,async(a,t)=>{const e=a.files||[];try{const{workspacePath:r,path:o="",extractArchives:s}=a.body||{},p=rt(a.body||{}),i=await X({workspacePath:String(r||""),targetPath:String(o||""),extractArchives:y(s),files:e.map((h,u)=>({originalname:h.originalname,relativePath:p[u],path:h.path,size:h.size}))});t.json(i)}catch(r){const o=r;l.error("failed to upload workspace files:",o),t.status(400).json({error:o.message})}finally{await V(e)}}),c.post("/workspace/download",n,async(a,t)=>{try{const{workspacePath:e,targetPath:r}=a.body||{},o=await $({workspacePath:String(e||""),targetPath:String(r||"")});if(t.setHeader("Content-Type",o.contentType),t.setHeader("Content-Disposition",Q(o.fileName)),t.setHeader("X-Workspace-Path",encodeURIComponent(o.workspacePath)),t.setHeader("X-Workspace-Target-Path",encodeURIComponent(o.targetPath)),o.isDirectory){await B(o.resolvedTargetPath,t);return}T(o.resolvedTargetPath).pipe(t)}catch(e){const r=e;l.error("failed to download workspace entry:",r),t.headersSent?t.destroy(r):t.status(400).json({error:r.message})}}),c.post("/workspace/extract",n,async(a,t)=>{try{const{workspacePath:e,archivePath:r,outputPath:o=""}=a.body||{},s=await C({workspacePath:String(e||""),archivePath:String(r||""),outputPath:String(o||"")});t.json(s)}catch(e){const r=e;l.error("failed to extract workspace archive:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/search",n,async(a,t)=>{try{const{workspacePath:e,keyword:r,fileMask:o,ignoreCase:s,maxResults:p,mode:i}=a.body||{},h=await G({workspacePath:String(e||""),keyword:String(r||""),fileMask:o!==void 0?String(o):void 0,ignoreCase:y(s),maxResults:typeof p=="number"?p:void 0,mode:i==="filename"?"filename":"content"});t.json(h)}catch(e){const r=e;l.error("failed to search workspace files:",r),t.status(400).json({error:r.message})}}),c.post("/workspace/replace",n,async(a,t)=>{try{const{workspacePath:e,keyword:r,replacement:o,fileMask:s,ignoreCase:p,filePath:i}=a.body||{},h=await z({workspacePath:String(e||""),keyword:String(r||""),replacement:String(o??""),fileMask:s!==void 0?String(s):void 0,ignoreCase:y(p),filePath:i!==void 0?String(i):void 0});t.json(h)}catch(e){const r=e;l.error("failed to replace workspace files:",r),t.status(400).json({error:r.message})}});export{S as WORKSPACE_UPLOAD_FILE_LIMIT,tt as createWorkspaceUploadLimitResponse,c as fileBrowserRouter,nt as isIgnoredByGitIgnore,at as listHostDirectoryTree,ot as parseGitIgnoreRules,rt as parseWorkspaceUploadRelativePaths};
|
|
2
|
+
|