@ebowwa/coder 0.2.1 → 0.7.64
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 +31 -32
- package/dist/core/__tests__/permissions.test.d.ts +12 -0
- package/dist/core/__tests__/permissions.test.d.ts.map +1 -0
- package/dist/core/__tests__/permissions.test.js +851 -0
- package/dist/core/agent-loop/__tests__/compaction.test.d.ts +5 -0
- package/dist/core/agent-loop/__tests__/compaction.test.d.ts.map +1 -0
- package/dist/core/agent-loop/__tests__/compaction.test.js +209 -0
- package/dist/core/agent-loop/__tests__/formatters.test.d.ts +5 -0
- package/dist/core/agent-loop/__tests__/formatters.test.d.ts.map +1 -0
- package/dist/core/agent-loop/__tests__/formatters.test.js +195 -0
- package/dist/core/agent-loop/__tests__/index.test.d.ts +5 -0
- package/dist/core/agent-loop/__tests__/index.test.d.ts.map +1 -0
- package/dist/core/agent-loop/__tests__/index.test.js +121 -0
- package/dist/core/agent-loop/__tests__/loop-state.test.d.ts +5 -0
- package/dist/core/agent-loop/__tests__/loop-state.test.d.ts.map +1 -0
- package/dist/core/agent-loop/__tests__/loop-state.test.js +340 -0
- package/dist/core/agent-loop/__tests__/message-builder.test.d.ts +5 -0
- package/dist/core/agent-loop/__tests__/message-builder.test.d.ts.map +1 -0
- package/dist/core/agent-loop/__tests__/message-builder.test.js +178 -0
- package/dist/core/agent-loop/__tests__/tool-executor.test.d.ts +5 -0
- package/dist/core/agent-loop/__tests__/tool-executor.test.d.ts.map +1 -0
- package/dist/core/agent-loop/__tests__/tool-executor.test.js +331 -0
- package/dist/core/agent-loop/compaction.d.ts +39 -0
- package/dist/core/agent-loop/compaction.d.ts.map +1 -0
- package/dist/core/agent-loop/compaction.js +51 -0
- package/dist/core/agent-loop/formatters.d.ts +21 -0
- package/dist/core/agent-loop/formatters.d.ts.map +1 -0
- package/dist/core/agent-loop/formatters.js +42 -0
- package/dist/core/agent-loop/index.d.ts +25 -0
- package/dist/core/agent-loop/index.d.ts.map +1 -0
- package/dist/core/agent-loop/index.js +83 -0
- package/dist/core/agent-loop/loop-state.d.ts +74 -0
- package/dist/core/agent-loop/loop-state.d.ts.map +1 -0
- package/dist/core/agent-loop/loop-state.js +147 -0
- package/dist/core/agent-loop/message-builder.d.ts +13 -0
- package/dist/core/agent-loop/message-builder.d.ts.map +1 -0
- package/dist/core/agent-loop/message-builder.js +49 -0
- package/dist/core/agent-loop/tool-executor.d.ts +23 -0
- package/dist/core/agent-loop/tool-executor.d.ts.map +1 -0
- package/dist/core/agent-loop/tool-executor.js +152 -0
- package/dist/core/agent-loop/turn-executor.d.ts +57 -0
- package/dist/core/agent-loop/turn-executor.d.ts.map +1 -0
- package/dist/core/agent-loop/turn-executor.js +124 -0
- package/dist/core/agent-loop/types.d.ts +141 -0
- package/dist/core/agent-loop/types.d.ts.map +1 -0
- package/dist/core/agent-loop/types.js +4 -0
- package/dist/core/agent-loop.d.ts +17 -0
- package/dist/core/agent-loop.d.ts.map +1 -0
- package/dist/core/agent-loop.js +16 -0
- package/dist/core/api-client-impl.d.ts +62 -0
- package/dist/core/api-client-impl.d.ts.map +1 -0
- package/dist/core/api-client-impl.js +479 -0
- package/dist/core/api-client.d.ts +6 -0
- package/dist/core/api-client.d.ts.map +1 -0
- package/dist/core/api-client.js +5 -0
- package/dist/core/checkpoints.d.ts +128 -0
- package/dist/core/checkpoints.d.ts.map +1 -0
- package/dist/core/checkpoints.js +438 -0
- package/dist/core/claude-md.d.ts +71 -0
- package/dist/core/claude-md.d.ts.map +1 -0
- package/dist/core/claude-md.js +198 -0
- package/dist/core/cognitive-security/hooks.d.ts +138 -0
- package/dist/core/cognitive-security/hooks.d.ts.map +1 -0
- package/dist/core/cognitive-security/hooks.js +389 -0
- package/dist/core/cognitive-security/index.d.ts +751 -0
- package/dist/core/cognitive-security/index.d.ts.map +1 -0
- package/dist/core/cognitive-security/index.js +1123 -0
- package/dist/core/cognitive-security/middleware.d.ts +136 -0
- package/dist/core/cognitive-security/middleware.d.ts.map +1 -0
- package/dist/core/cognitive-security/middleware.js +376 -0
- package/dist/core/config-loader.d.ts +127 -0
- package/dist/core/config-loader.d.ts.map +1 -0
- package/dist/core/config-loader.js +219 -0
- package/dist/core/context-compaction.d.ts +87 -0
- package/dist/core/context-compaction.d.ts.map +1 -0
- package/dist/core/context-compaction.js +428 -0
- package/dist/core/git-status.d.ts +25 -0
- package/dist/core/git-status.d.ts.map +1 -0
- package/dist/core/git-status.js +204 -0
- package/dist/core/image.d.ts +69 -0
- package/dist/core/image.d.ts.map +1 -0
- package/dist/core/image.js +290 -0
- package/dist/core/image.test.d.ts +2 -0
- package/dist/core/image.test.d.ts.map +1 -0
- package/dist/core/image.test.js +149 -0
- package/dist/core/models.d.ts +123 -0
- package/dist/core/models.d.ts.map +1 -0
- package/dist/core/models.js +325 -0
- package/dist/core/permissions.d.ts +81 -0
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/core/permissions.js +327 -0
- package/dist/core/retry.d.ts +25 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +121 -0
- package/dist/core/session-store.d.ts +9 -0
- package/dist/core/session-store.d.ts.map +1 -0
- package/dist/core/session-store.js +10 -0
- package/dist/core/sessions/export.d.ts +47 -0
- package/dist/core/sessions/export.d.ts.map +1 -0
- package/dist/core/sessions/export.js +256 -0
- package/dist/core/sessions/index.d.ts +132 -0
- package/dist/core/sessions/index.d.ts.map +1 -0
- package/dist/core/sessions/index.js +442 -0
- package/dist/core/sessions/metadata.d.ts +77 -0
- package/dist/core/sessions/metadata.d.ts.map +1 -0
- package/dist/core/sessions/metadata.js +233 -0
- package/dist/core/sessions/persistence.d.ts +72 -0
- package/dist/core/sessions/persistence.d.ts.map +1 -0
- package/dist/core/sessions/persistence.js +201 -0
- package/dist/core/sessions/types.d.ts +110 -0
- package/dist/core/sessions/types.d.ts.map +1 -0
- package/dist/core/sessions/types.js +4 -0
- package/dist/core/stream-highlighter.d.ts +18 -0
- package/dist/core/stream-highlighter.d.ts.map +1 -0
- package/dist/core/stream-highlighter.js +916 -0
- package/dist/core/system-reminders.d.ts +89 -0
- package/dist/core/system-reminders.d.ts.map +1 -0
- package/dist/core/system-reminders.js +285 -0
- package/dist/ecosystem/hooks/__tests__/index.test.d.ts +5 -0
- package/dist/ecosystem/hooks/__tests__/index.test.d.ts.map +1 -0
- package/dist/ecosystem/hooks/__tests__/index.test.js +458 -0
- package/dist/ecosystem/hooks/index.d.ts +59 -0
- package/dist/ecosystem/hooks/index.d.ts.map +1 -0
- package/dist/ecosystem/hooks/index.js +294 -0
- package/dist/ecosystem/hooks/prompt-evaluator.d.ts +32 -0
- package/dist/ecosystem/hooks/prompt-evaluator.d.ts.map +1 -0
- package/dist/ecosystem/hooks/prompt-evaluator.js +229 -0
- package/dist/ecosystem/skills/index.d.ts +55 -0
- package/dist/ecosystem/skills/index.d.ts.map +1 -0
- package/dist/ecosystem/skills/index.js +258 -0
- package/dist/ecosystem/tools/__tests__/index.test.d.ts +7 -0
- package/dist/ecosystem/tools/__tests__/index.test.d.ts.map +1 -0
- package/dist/ecosystem/tools/__tests__/index.test.js +856 -0
- package/dist/ecosystem/tools/index.d.ts +24 -0
- package/dist/ecosystem/tools/index.d.ts.map +1 -0
- package/dist/ecosystem/tools/index.js +1709 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -2
- package/dist/interfaces/mcp/client.d.ts +40 -0
- package/dist/interfaces/mcp/client.d.ts.map +1 -0
- package/dist/interfaces/mcp/client.js +309 -0
- package/dist/interfaces/ui/index.d.ts +36 -0
- package/dist/interfaces/ui/index.d.ts.map +1 -0
- package/dist/interfaces/ui/index.js +61 -0
- package/dist/interfaces/ui/spinner.d.ts +140 -0
- package/dist/interfaces/ui/spinner.d.ts.map +1 -0
- package/dist/interfaces/ui/spinner.js +342 -0
- package/dist/interfaces/ui/terminal/cli/index.d.ts +12 -0
- package/dist/interfaces/ui/terminal/cli/index.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/cli/index.js +167 -0
- package/dist/interfaces/ui/terminal/shared/args.d.ts +39 -0
- package/dist/interfaces/ui/terminal/shared/args.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/args.js +176 -0
- package/dist/interfaces/ui/terminal/shared/index.d.ts +11 -0
- package/dist/interfaces/ui/terminal/shared/index.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/index.js +16 -0
- package/dist/interfaces/ui/terminal/shared/loading-state.d.ts +124 -0
- package/dist/interfaces/ui/terminal/shared/loading-state.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/loading-state.js +246 -0
- package/dist/interfaces/ui/terminal/shared/query.d.ts +22 -0
- package/dist/interfaces/ui/terminal/shared/query.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/query.js +100 -0
- package/dist/interfaces/ui/terminal/shared/setup.d.ts +33 -0
- package/dist/interfaces/ui/terminal/shared/setup.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/setup.js +226 -0
- package/dist/interfaces/ui/terminal/shared/status-line.d.ts +117 -0
- package/dist/interfaces/ui/terminal/shared/status-line.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/status-line.js +267 -0
- package/dist/interfaces/ui/terminal/shared/system-prompt.d.ts +38 -0
- package/dist/interfaces/ui/terminal/shared/system-prompt.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/shared/system-prompt.js +102 -0
- package/dist/interfaces/ui/terminal/tui/HelpPanel.d.ts +39 -0
- package/dist/interfaces/ui/terminal/tui/HelpPanel.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/HelpPanel.js +215 -0
- package/dist/interfaces/ui/terminal/tui/InputContext.d.ts +91 -0
- package/dist/interfaces/ui/terminal/tui/InputContext.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/InputContext.js +154 -0
- package/dist/interfaces/ui/terminal/tui/InputField.d.ts +18 -0
- package/dist/interfaces/ui/terminal/tui/InputField.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/InputField.js +41 -0
- package/dist/interfaces/ui/terminal/tui/InteractiveTUI.d.ts +16 -0
- package/dist/interfaces/ui/terminal/tui/InteractiveTUI.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/InteractiveTUI.js +451 -0
- package/dist/interfaces/ui/terminal/tui/MessageArea.d.ts +10 -0
- package/dist/interfaces/ui/terminal/tui/MessageArea.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/MessageArea.js +91 -0
- package/dist/interfaces/ui/terminal/tui/MessageStore.d.ts +48 -0
- package/dist/interfaces/ui/terminal/tui/MessageStore.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/MessageStore.js +151 -0
- package/dist/interfaces/ui/terminal/tui/StatusBar.d.ts +9 -0
- package/dist/interfaces/ui/terminal/tui/StatusBar.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/StatusBar.js +36 -0
- package/dist/interfaces/ui/terminal/tui/commands.d.ts +21 -0
- package/dist/interfaces/ui/terminal/tui/commands.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/commands.js +359 -0
- package/dist/interfaces/ui/terminal/tui/components/InteractiveElements.d.ts +115 -0
- package/dist/interfaces/ui/terminal/tui/components/InteractiveElements.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/components/InteractiveElements.js +306 -0
- package/dist/interfaces/ui/terminal/tui/components/MultilineInput.d.ts +92 -0
- package/dist/interfaces/ui/terminal/tui/components/MultilineInput.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/components/MultilineInput.js +399 -0
- package/dist/interfaces/ui/terminal/tui/components/PaneManager.d.ts +59 -0
- package/dist/interfaces/ui/terminal/tui/components/PaneManager.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/components/PaneManager.js +139 -0
- package/dist/interfaces/ui/terminal/tui/components/Sidebar.d.ts +68 -0
- package/dist/interfaces/ui/terminal/tui/components/Sidebar.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/components/Sidebar.js +340 -0
- package/dist/interfaces/ui/terminal/tui/components/index.d.ts +23 -0
- package/dist/interfaces/ui/terminal/tui/components/index.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/components/index.js +51 -0
- package/dist/interfaces/ui/terminal/tui/console.d.ts +20 -0
- package/dist/interfaces/ui/terminal/tui/console.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/console.js +46 -0
- package/dist/interfaces/ui/terminal/tui/index.d.ts +20 -0
- package/dist/interfaces/ui/terminal/tui/index.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/index.js +28 -0
- package/dist/interfaces/ui/terminal/tui/run.d.ts +13 -0
- package/dist/interfaces/ui/terminal/tui/run.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/run.js +31 -0
- package/dist/interfaces/ui/terminal/tui/spinner.d.ts +44 -0
- package/dist/interfaces/ui/terminal/tui/spinner.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/spinner.js +59 -0
- package/dist/interfaces/ui/terminal/tui/tui-app.d.ts +39 -0
- package/dist/interfaces/ui/terminal/tui/tui-app.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/tui-app.js +198 -0
- package/dist/interfaces/ui/terminal/tui/tui-footer.d.ts +167 -0
- package/dist/interfaces/ui/terminal/tui/tui-footer.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/tui-footer.js +330 -0
- package/dist/interfaces/ui/terminal/tui/types.d.ts +165 -0
- package/dist/interfaces/ui/terminal/tui/types.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/types.js +5 -0
- package/dist/interfaces/ui/terminal/tui/useInputHandler.d.ts +23 -0
- package/dist/interfaces/ui/terminal/tui/useInputHandler.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/useInputHandler.js +72 -0
- package/dist/interfaces/ui/terminal/tui/useNativeInput.d.ts +90 -0
- package/dist/interfaces/ui/terminal/tui/useNativeInput.d.ts.map +1 -0
- package/dist/interfaces/ui/terminal/tui/useNativeInput.js +188 -0
- package/dist/native/index.d.ts +480 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +1625 -0
- package/dist/teammates/index.d.ts +161 -0
- package/dist/teammates/index.d.ts.map +1 -0
- package/dist/teammates/index.js +827 -0
- package/dist/types/index.d.ts +482 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +52 -0
- package/native/README.md +5 -5
- package/native/index.darwin-arm64.node +0 -0
- package/native/index.node +0 -0
- package/native/package.json +4 -4
- package/package.json +33 -16
- package/packages/src/core/__tests__/permissions.test.ts +1091 -0
- package/packages/src/core/agent-loop/__tests__/compaction.test.ts +280 -0
- package/packages/src/core/agent-loop/__tests__/formatters.test.ts +234 -0
- package/packages/src/core/agent-loop/__tests__/index.test.ts +162 -0
- package/packages/src/core/agent-loop/__tests__/loop-state.test.ts +413 -0
- package/packages/src/core/agent-loop/__tests__/message-builder.test.ts +229 -0
- package/packages/src/core/agent-loop/__tests__/tool-executor.test.ts +457 -0
- package/packages/src/core/agent-loop/compaction.ts +88 -0
- package/packages/src/core/agent-loop/formatters.ts +50 -0
- package/packages/src/core/agent-loop/index.ts +135 -0
- package/packages/src/core/agent-loop/loop-state.ts +187 -0
- package/packages/src/core/agent-loop/message-builder.ts +62 -0
- package/packages/src/core/agent-loop/tool-executor.ts +211 -0
- package/packages/src/core/agent-loop/turn-executor.ts +222 -0
- package/packages/src/core/agent-loop/types.ts +148 -0
- package/packages/src/core/agent-loop.ts +18 -0
- package/packages/src/core/api-client-impl.ts +619 -0
- package/packages/src/core/api-client.ts +6 -0
- package/packages/src/core/checkpoints.ts +606 -0
- package/packages/src/core/claude-md.ts +272 -0
- package/packages/src/core/cognitive-security/hooks.ts +590 -0
- package/packages/src/core/cognitive-security/index.ts +2041 -0
- package/packages/src/core/cognitive-security/middleware.ts +536 -0
- package/packages/src/core/config-loader.ts +324 -0
- package/packages/src/core/context-compaction.ts +578 -0
- package/packages/src/core/git-status.ts +262 -0
- package/packages/src/core/image.test.ts +180 -0
- package/packages/src/core/image.ts +350 -0
- package/packages/src/core/lmdb.db +0 -0
- package/packages/src/core/lmdb.db-lock +0 -0
- package/packages/src/core/models.ts +430 -0
- package/packages/src/core/normalizers/todo +4 -0
- package/packages/src/core/permissions.ts +431 -0
- package/packages/src/core/retry.ts +170 -0
- package/packages/src/core/session-store.ts +36 -0
- package/packages/src/core/sessions/export.ts +329 -0
- package/packages/src/core/sessions/index.ts +587 -0
- package/packages/src/core/sessions/metadata.ts +309 -0
- package/packages/src/core/sessions/persistence.ts +244 -0
- package/packages/src/core/sessions/types.ts +169 -0
- package/packages/src/core/stream-highlighter.ts +1123 -0
- package/packages/src/core/system-reminders.ts +402 -0
- package/packages/src/core/todo +8 -0
- package/packages/src/ecosystem/hooks/__tests__/index.test.ts +561 -0
- package/packages/src/ecosystem/hooks/index.ts +341 -0
- package/packages/src/ecosystem/hooks/prompt-evaluator.ts +300 -0
- package/packages/src/ecosystem/skills/index.ts +295 -0
- package/packages/src/ecosystem/tools/__tests__/index.test.ts +1335 -0
- package/packages/src/ecosystem/tools/index.ts +1877 -0
- package/packages/src/index.ts +120 -0
- package/packages/src/interfaces/mcp/client.ts +389 -0
- package/packages/src/interfaces/ui/Screenshot 2026-03-02 at 9.23.10/342/200/257PM.png +0 -0
- package/packages/src/interfaces/ui/Screenshot 2026-03-03 at 10.55.11/342/200/257AM.png +0 -0
- package/packages/src/interfaces/ui/index.ts +161 -0
- package/packages/src/interfaces/ui/lmdb.db +0 -0
- package/packages/src/interfaces/ui/lmdb.db-lock +0 -0
- package/packages/src/interfaces/ui/spinner.ts +451 -0
- package/packages/src/interfaces/ui/terminal/cli/index.ts +228 -0
- package/packages/src/interfaces/ui/terminal/lmdb.db +0 -0
- package/packages/src/interfaces/ui/terminal/lmdb.db-lock +0 -0
- package/packages/src/interfaces/ui/terminal/shared/args.ts +222 -0
- package/packages/src/interfaces/ui/terminal/shared/index.ts +71 -0
- package/packages/src/interfaces/ui/terminal/shared/loading-state.ts +322 -0
- package/packages/src/interfaces/ui/terminal/shared/query.ts +146 -0
- package/packages/src/interfaces/ui/terminal/shared/setup.ts +295 -0
- package/packages/src/interfaces/ui/terminal/shared/status-line.ts +358 -0
- package/packages/src/interfaces/ui/terminal/shared/system-prompt.ts +146 -0
- package/packages/src/interfaces/ui/terminal/tui/HelpPanel.tsx +262 -0
- package/packages/src/interfaces/ui/terminal/tui/InputContext.tsx +232 -0
- package/packages/src/interfaces/ui/terminal/tui/InputField.tsx +62 -0
- package/packages/src/interfaces/ui/terminal/tui/InteractiveTUI.tsx +537 -0
- package/packages/src/interfaces/ui/terminal/tui/MessageArea.tsx +107 -0
- package/packages/src/interfaces/ui/terminal/tui/MessageStore.tsx +240 -0
- package/packages/src/interfaces/ui/terminal/tui/StatusBar.tsx +54 -0
- package/packages/src/interfaces/ui/terminal/tui/commands.ts +438 -0
- package/packages/src/interfaces/ui/terminal/tui/components/InteractiveElements.tsx +584 -0
- package/packages/src/interfaces/ui/terminal/tui/components/MultilineInput.tsx +614 -0
- package/packages/src/interfaces/ui/terminal/tui/components/PaneManager.tsx +333 -0
- package/packages/src/interfaces/ui/terminal/tui/components/Sidebar.tsx +604 -0
- package/packages/src/interfaces/ui/terminal/tui/components/index.ts +118 -0
- package/packages/src/interfaces/ui/terminal/tui/console.ts +49 -0
- package/packages/src/interfaces/ui/terminal/tui/index.ts +90 -0
- package/packages/src/interfaces/ui/terminal/tui/run.tsx +42 -0
- package/packages/src/interfaces/ui/terminal/tui/spinner.ts +69 -0
- package/packages/src/interfaces/ui/terminal/tui/tui-app.tsx +390 -0
- package/packages/src/interfaces/ui/terminal/tui/tui-footer.ts +422 -0
- package/packages/src/interfaces/ui/terminal/tui/types.ts +186 -0
- package/packages/src/interfaces/ui/terminal/tui/useInputHandler.ts +104 -0
- package/packages/src/interfaces/ui/terminal/tui/useNativeInput.ts +239 -0
- package/packages/src/lmdb.db +0 -0
- package/packages/src/lmdb.db-lock +0 -0
- package/packages/src/native/index.ts +2345 -0
- package/packages/src/teammates/index.ts +982 -0
- package/packages/src/types/index.ts +722 -0
- package/dist/cli.js +0 -148
- package/dist/index-0pkak453.js +0 -136
- package/dist/index-0qd0x8b4.js +0 -110
- package/dist/index-0x3kprq6.js +0 -240
- package/dist/index-1eawy937.js +0 -308
- package/dist/index-24m2aygy.js +0 -240
- package/dist/index-29xcjnne.js +0 -280
- package/dist/index-2avyytn5.js +0 -349
- package/dist/index-4ms367ey.js +0 -136
- package/dist/index-4w2t3b0m.js +0 -240
- package/dist/index-4xfgd8nz.js +0 -261
- package/dist/index-5acjp9gc.js +0 -157
- package/dist/index-5s15hr56.js +0 -136
- package/dist/index-6e4wf341.js +0 -349
- package/dist/index-6fvnkedw.js +0 -240
- package/dist/index-6rqpmd4g.js +0 -128
- package/dist/index-77ckwnbm.js +0 -280
- package/dist/index-9knxy49k.js +0 -128
- package/dist/index-9zrnw4zx.js +0 -128
- package/dist/index-bk21w99v.js +0 -280
- package/dist/index-c41n76fv.js +0 -240
- package/dist/index-cb4ppjdt.js +0 -255
- package/dist/index-cfb2edt6.js +0 -240
- package/dist/index-cmfa38hh.js +0 -308
- package/dist/index-datjz8q1.js +0 -257
- package/dist/index-eadf4wvn.js +0 -240
- package/dist/index-em5k0m3z.js +0 -345
- package/dist/index-gh8r333a.js +0 -110
- package/dist/index-gkx6k2tr.js +0 -261
- package/dist/index-h5cabfks.js +0 -155
- package/dist/index-hcrpwyy3.js +0 -261
- package/dist/index-hk7fwwa8.js +0 -257
- package/dist/index-jb8cw7f8.js +0 -136
- package/dist/index-kbyw4th1.js +0 -347
- package/dist/index-kgj5gqnm.js +0 -345
- package/dist/index-mdf6xp1z.js +0 -255
- package/dist/index-mrhv8kvc.js +0 -280
- package/dist/index-mt4743dd.js +0 -161
- package/dist/index-qnwsg97q.js +0 -240
- package/dist/index-qwdy6x44.js +0 -261
- package/dist/index-rmj77261.js +0 -157
- package/dist/index-sbbw1a61.js +0 -349
- package/dist/index-svy5bcpn.js +0 -345
- package/dist/index-tvmy7tm9.js +0 -261
- package/dist/index-tzz4vzkj.js +0 -312
- package/dist/index-vz80zmhe.js +0 -110
- package/dist/index-wed2fk67.js +0 -240
- package/dist/index-wksgzz8e.js +0 -280
- package/dist/index-wn2m4wma.js +0 -240
- package/dist/index-xha05vjc.js +0 -257
- package/dist/index-yc6eh8p8.js +0 -136
- package/dist/index-ycjxx9ft.js +0 -240
- package/dist/index-z0gzd0fc.js +0 -110
- package/dist/index-z8cwtf8j.js +0 -240
- package/dist/index-zy5mtt00.js +0 -128
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coder - AI-powered terminal coding assistant
|
|
3
|
+
* Main entry point
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Types
|
|
7
|
+
export * from "./types/index.js";
|
|
8
|
+
|
|
9
|
+
// Core
|
|
10
|
+
export {
|
|
11
|
+
createMessageStream,
|
|
12
|
+
calculateCost,
|
|
13
|
+
buildSystemPrompt,
|
|
14
|
+
buildCachedMessages,
|
|
15
|
+
calculateCacheMetrics,
|
|
16
|
+
} from "./core/api-client.js";
|
|
17
|
+
export type { StreamOptionsType as StreamOptions, StreamResultType as StreamResult } from "./core/api-client.js";
|
|
18
|
+
export {
|
|
19
|
+
agentLoop,
|
|
20
|
+
formatCost,
|
|
21
|
+
formatMetrics,
|
|
22
|
+
formatCostBrief,
|
|
23
|
+
formatCacheMetrics,
|
|
24
|
+
} from "./core/agent-loop.js";
|
|
25
|
+
export type { AgentLoopOptions, AgentLoopResult } from "./core/agent-loop.js";
|
|
26
|
+
|
|
27
|
+
// Permissions (types are re-exported via ./types/index.js)
|
|
28
|
+
export {
|
|
29
|
+
PermissionManager,
|
|
30
|
+
assessRiskLevel,
|
|
31
|
+
generateDescription,
|
|
32
|
+
isReadOnlyTool,
|
|
33
|
+
isFileEditTool,
|
|
34
|
+
isSystemTool,
|
|
35
|
+
TOOL_CATEGORIES,
|
|
36
|
+
} from "./core/permissions.js";
|
|
37
|
+
|
|
38
|
+
// Session Store
|
|
39
|
+
export {
|
|
40
|
+
SessionStore,
|
|
41
|
+
formatSessionSummary,
|
|
42
|
+
printSessionsList,
|
|
43
|
+
} from "./core/session-store.js";
|
|
44
|
+
export type {
|
|
45
|
+
SessionMetadata,
|
|
46
|
+
SessionMessage,
|
|
47
|
+
SessionToolUse,
|
|
48
|
+
SessionMetrics,
|
|
49
|
+
SessionContext,
|
|
50
|
+
SessionEntry,
|
|
51
|
+
SessionSummary,
|
|
52
|
+
LoadedSession,
|
|
53
|
+
} from "./core/session-store.js";
|
|
54
|
+
|
|
55
|
+
// Tools
|
|
56
|
+
export * from "./ecosystem/tools/index.js";
|
|
57
|
+
|
|
58
|
+
// MCP (renamed to avoid conflict with MCPClient type)
|
|
59
|
+
export { MCPClientImpl } from "./interfaces/mcp/client.js";
|
|
60
|
+
export { MCPClientImpl as MCPClient } from "./interfaces/mcp/client.js";
|
|
61
|
+
|
|
62
|
+
// Hooks
|
|
63
|
+
export * from "./ecosystem/hooks/index.js";
|
|
64
|
+
|
|
65
|
+
// Skills
|
|
66
|
+
export * from "./ecosystem/skills/index.js";
|
|
67
|
+
|
|
68
|
+
// Teammates
|
|
69
|
+
export * from "./teammates/index.js";
|
|
70
|
+
|
|
71
|
+
// Cognitive Security
|
|
72
|
+
export * from "./core/cognitive-security/index.js";
|
|
73
|
+
|
|
74
|
+
// UI Components (exclude types that are already in types/index.js)
|
|
75
|
+
export {
|
|
76
|
+
Spinner,
|
|
77
|
+
getSpinner,
|
|
78
|
+
resetSpinner,
|
|
79
|
+
defaultFrames,
|
|
80
|
+
dotFrames,
|
|
81
|
+
arrowFrames,
|
|
82
|
+
defaultTips,
|
|
83
|
+
toolTips,
|
|
84
|
+
streamingTips,
|
|
85
|
+
type SpinnerOptions,
|
|
86
|
+
type SpinnerColor,
|
|
87
|
+
type SpinnerState,
|
|
88
|
+
LoadingState,
|
|
89
|
+
getLoadingState,
|
|
90
|
+
setLoading,
|
|
91
|
+
stopLoading,
|
|
92
|
+
updateLoading,
|
|
93
|
+
startTool,
|
|
94
|
+
endTool,
|
|
95
|
+
type LoadingStateEvents,
|
|
96
|
+
type ProgressUpdate,
|
|
97
|
+
type ProgressCallback,
|
|
98
|
+
createProgressCallback,
|
|
99
|
+
formatElapsedTime,
|
|
100
|
+
formatLoadingMessage,
|
|
101
|
+
} from "./interfaces/ui/index.js";
|
|
102
|
+
|
|
103
|
+
// Native module (Rust)
|
|
104
|
+
export * from "./native/index.js";
|
|
105
|
+
|
|
106
|
+
// Context Compaction
|
|
107
|
+
export {
|
|
108
|
+
estimateTokens,
|
|
109
|
+
estimateMessagesTokens,
|
|
110
|
+
compactMessages,
|
|
111
|
+
needsCompaction,
|
|
112
|
+
summarizeMessages,
|
|
113
|
+
summarizeWithLLM,
|
|
114
|
+
getCompactionStats,
|
|
115
|
+
} from "./core/context-compaction.js";
|
|
116
|
+
export type {
|
|
117
|
+
CompactionOptions,
|
|
118
|
+
CompactionResult,
|
|
119
|
+
LLMSummarizationOptions,
|
|
120
|
+
} from "./core/context-compaction.js";
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client - Model Context Protocol implementation
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
MCPServerConfig,
|
|
7
|
+
MCPTool,
|
|
8
|
+
JSONRPCRequest,
|
|
9
|
+
JSONRPCResponse,
|
|
10
|
+
JSONRPCNotification,
|
|
11
|
+
JSONSchema,
|
|
12
|
+
ToolResult,
|
|
13
|
+
} from "../../types/index.js";
|
|
14
|
+
import { spawn, type ChildProcess } from "child_process";
|
|
15
|
+
import WebSocket from "ws";
|
|
16
|
+
|
|
17
|
+
export interface MCPClientOptions {
|
|
18
|
+
name: string;
|
|
19
|
+
config: MCPServerConfig;
|
|
20
|
+
onLog?: (message: string) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class MCPClientImpl {
|
|
24
|
+
// Alias for backwards compatibility
|
|
25
|
+
static readonly MCPClient = MCPClientImpl;
|
|
26
|
+
name: string;
|
|
27
|
+
config: MCPServerConfig;
|
|
28
|
+
connected = false;
|
|
29
|
+
tools: MCPTool[] = [];
|
|
30
|
+
|
|
31
|
+
private process: ChildProcess | null = null;
|
|
32
|
+
private websocket: WebSocket | null = null;
|
|
33
|
+
private requestId = 0;
|
|
34
|
+
private pendingRequests = new Map<
|
|
35
|
+
string | number,
|
|
36
|
+
{
|
|
37
|
+
resolve: (value: unknown) => void;
|
|
38
|
+
reject: (error: Error) => void;
|
|
39
|
+
}
|
|
40
|
+
>();
|
|
41
|
+
private buffer = "";
|
|
42
|
+
private onLog?: (message: string) => void;
|
|
43
|
+
|
|
44
|
+
constructor(options: MCPClientOptions) {
|
|
45
|
+
this.name = options.name;
|
|
46
|
+
this.config = options.config;
|
|
47
|
+
this.onLog = options.onLog;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async connect(): Promise<void> {
|
|
51
|
+
if (this.config.type === "stdio") {
|
|
52
|
+
await this.connectStdio();
|
|
53
|
+
} else if (this.config.type === "http" || this.config.type === "sse") {
|
|
54
|
+
await this.connectHttp();
|
|
55
|
+
} else if (this.config.type === "ws") {
|
|
56
|
+
await this.connectWebSocket();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private async connectStdio(): Promise<void> {
|
|
61
|
+
if (!this.config.command) {
|
|
62
|
+
throw new Error("No command specified for stdio transport");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.log(`Starting stdio transport: ${this.config.command}`);
|
|
66
|
+
|
|
67
|
+
this.process = spawn(this.config.command, this.config.args || [], {
|
|
68
|
+
env: { ...process.env, ...this.config.env },
|
|
69
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
this.process.stdout?.on("data", (data: Buffer) => {
|
|
73
|
+
this.handleData(data.toString());
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
this.process.stderr?.on("data", (data: Buffer) => {
|
|
77
|
+
this.log(`stderr: ${data.toString()}`);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
this.process.on("error", (error: Error) => {
|
|
81
|
+
this.log(`Process error: ${error.message}`);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
this.process.on("close", (code: number) => {
|
|
85
|
+
this.log(`Process closed with code ${code}`);
|
|
86
|
+
this.connected = false;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Wait for process to start
|
|
90
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
91
|
+
|
|
92
|
+
// Initialize connection
|
|
93
|
+
await this.initialize();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private async connectHttp(): Promise<void> {
|
|
97
|
+
if (!this.config.url) {
|
|
98
|
+
throw new Error("No URL specified for HTTP transport");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.log(`Starting HTTP transport: ${this.config.url}`);
|
|
102
|
+
|
|
103
|
+
// For HTTP transport, we just validate the endpoint
|
|
104
|
+
try {
|
|
105
|
+
const response = await fetch(this.config.url, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: {
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
...this.config.headers,
|
|
110
|
+
},
|
|
111
|
+
body: JSON.stringify({
|
|
112
|
+
jsonrpc: "2.0",
|
|
113
|
+
id: 1,
|
|
114
|
+
method: "initialize",
|
|
115
|
+
params: {
|
|
116
|
+
protocolVersion: "2024-11-05",
|
|
117
|
+
capabilities: {},
|
|
118
|
+
clientInfo: {
|
|
119
|
+
name: "coder",
|
|
120
|
+
version: "0.1.0",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
throw new Error(`HTTP error: ${response.status}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const result = (await response.json()) as JSONRPCResponse;
|
|
131
|
+
this.connected = true;
|
|
132
|
+
|
|
133
|
+
// Get tools
|
|
134
|
+
await this.loadTools();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
137
|
+
throw new Error(`Failed to connect to HTTP server: ${errorMessage}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private async connectWebSocket(): Promise<void> {
|
|
142
|
+
if (!this.config.url) {
|
|
143
|
+
throw new Error("No URL specified for WebSocket transport");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const url = this.config.url;
|
|
147
|
+
this.log(`Starting WebSocket transport: ${url}`);
|
|
148
|
+
|
|
149
|
+
return new Promise((resolve, reject) => {
|
|
150
|
+
const headers: Record<string, string> = {
|
|
151
|
+
...this.config.headers,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const ws = new WebSocket(url, {
|
|
155
|
+
headers,
|
|
156
|
+
handshakeTimeout: this.config.timeout || 30000,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
ws.on("open", () => {
|
|
160
|
+
this.log("WebSocket connection established");
|
|
161
|
+
this.websocket = ws;
|
|
162
|
+
this.connected = true;
|
|
163
|
+
|
|
164
|
+
// Initialize the MCP connection
|
|
165
|
+
this.initialize()
|
|
166
|
+
.then(() => resolve())
|
|
167
|
+
.catch((error) => {
|
|
168
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
169
|
+
this.log(`Initialization failed: ${errorMessage}`);
|
|
170
|
+
reject(error);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
ws.on("message", (data: WebSocket.RawData, isBinary: boolean) => {
|
|
175
|
+
const message = isBinary ? data.toString() : data.toString();
|
|
176
|
+
this.handleData(message);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
ws.on("error", (error: Error) => {
|
|
180
|
+
this.log(`WebSocket error: ${error.message}`);
|
|
181
|
+
if (!this.connected) {
|
|
182
|
+
reject(new Error(`WebSocket connection failed: ${error.message}`));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
ws.on("close", (code: number, reason: Buffer) => {
|
|
187
|
+
this.log(`WebSocket closed: code=${code}, reason=${reason.toString()}`);
|
|
188
|
+
this.connected = false;
|
|
189
|
+
this.websocket = null;
|
|
190
|
+
|
|
191
|
+
// Reject any pending requests
|
|
192
|
+
for (const [id, pending] of this.pendingRequests) {
|
|
193
|
+
this.pendingRequests.delete(id);
|
|
194
|
+
pending.reject(new Error(`WebSocket closed: ${reason.toString()}`));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
ws.on("ping", () => {
|
|
199
|
+
ws.pong();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private async initialize(): Promise<void> {
|
|
205
|
+
const result = await this.request("initialize", {
|
|
206
|
+
protocolVersion: "2024-11-05",
|
|
207
|
+
capabilities: {
|
|
208
|
+
tools: {},
|
|
209
|
+
resources: {},
|
|
210
|
+
prompts: {},
|
|
211
|
+
},
|
|
212
|
+
clientInfo: {
|
|
213
|
+
name: "coder",
|
|
214
|
+
version: "0.1.0",
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
this.log(`Initialized with: ${JSON.stringify(result)}`);
|
|
219
|
+
this.connected = true;
|
|
220
|
+
|
|
221
|
+
// Send initialized notification
|
|
222
|
+
this.notify("notifications/initialized", {});
|
|
223
|
+
|
|
224
|
+
// Load tools
|
|
225
|
+
await this.loadTools();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private async loadTools(): Promise<void> {
|
|
229
|
+
try {
|
|
230
|
+
const result = (await this.request("tools/list", {})) as {
|
|
231
|
+
tools: Array<{
|
|
232
|
+
name: string;
|
|
233
|
+
description: string;
|
|
234
|
+
inputSchema: JSONSchema;
|
|
235
|
+
}>;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
this.tools = result.tools.map((tool) => ({
|
|
239
|
+
name: tool.name,
|
|
240
|
+
description: tool.description,
|
|
241
|
+
inputSchema: tool.inputSchema,
|
|
242
|
+
}));
|
|
243
|
+
|
|
244
|
+
this.log(`Loaded ${this.tools.length} tools`);
|
|
245
|
+
} catch (error) {
|
|
246
|
+
this.log(`Failed to load tools: ${error}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async callTool(name: string, args: Record<string, unknown>): Promise<ToolResult> {
|
|
251
|
+
const result = (await this.request("tools/call", {
|
|
252
|
+
name,
|
|
253
|
+
arguments: args,
|
|
254
|
+
})) as { content: Array<{ type: string; text?: string }> };
|
|
255
|
+
|
|
256
|
+
const text = result.content
|
|
257
|
+
.filter((c) => c.type === "text")
|
|
258
|
+
.map((c) => c.text || "")
|
|
259
|
+
.join("\n");
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
content: text,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async request(method: string, params: unknown): Promise<unknown> {
|
|
267
|
+
const id = ++this.requestId;
|
|
268
|
+
|
|
269
|
+
const request: JSONRPCRequest = {
|
|
270
|
+
jsonrpc: "2.0",
|
|
271
|
+
id,
|
|
272
|
+
method,
|
|
273
|
+
params,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
return new Promise((resolve, reject) => {
|
|
277
|
+
this.pendingRequests.set(id, { resolve, reject });
|
|
278
|
+
|
|
279
|
+
const message = JSON.stringify(request);
|
|
280
|
+
|
|
281
|
+
// Send via WebSocket or stdio depending on transport type
|
|
282
|
+
if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
|
|
283
|
+
this.websocket.send(message);
|
|
284
|
+
} else if (this.process?.stdin?.writable) {
|
|
285
|
+
this.process.stdin.write(message + "\n");
|
|
286
|
+
} else {
|
|
287
|
+
this.pendingRequests.delete(id);
|
|
288
|
+
reject(new Error("No active connection to send request"));
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Timeout
|
|
293
|
+
setTimeout(() => {
|
|
294
|
+
if (this.pendingRequests.has(id)) {
|
|
295
|
+
this.pendingRequests.delete(id);
|
|
296
|
+
reject(new Error(`Request timeout for ${method}`));
|
|
297
|
+
}
|
|
298
|
+
}, this.config.timeout || 120000);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
notify(method: string, params: unknown): void {
|
|
303
|
+
const notification: JSONRPCNotification = {
|
|
304
|
+
jsonrpc: "2.0",
|
|
305
|
+
method,
|
|
306
|
+
params,
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const message = JSON.stringify(notification);
|
|
310
|
+
|
|
311
|
+
// Send via WebSocket or stdio depending on transport type
|
|
312
|
+
if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
|
|
313
|
+
this.websocket.send(message);
|
|
314
|
+
} else if (this.process?.stdin?.writable) {
|
|
315
|
+
this.process.stdin.write(message + "\n");
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private handleData(data: string): void {
|
|
320
|
+
this.buffer += data;
|
|
321
|
+
|
|
322
|
+
const lines = this.buffer.split("\n");
|
|
323
|
+
this.buffer = lines.pop() || "";
|
|
324
|
+
|
|
325
|
+
for (const line of lines) {
|
|
326
|
+
if (!line.trim()) continue;
|
|
327
|
+
|
|
328
|
+
try {
|
|
329
|
+
const response = JSON.parse(line) as JSONRPCResponse;
|
|
330
|
+
|
|
331
|
+
if (response.id !== undefined) {
|
|
332
|
+
const pending = this.pendingRequests.get(response.id);
|
|
333
|
+
if (pending) {
|
|
334
|
+
this.pendingRequests.delete(response.id);
|
|
335
|
+
if (response.error) {
|
|
336
|
+
pending.reject(new Error(response.error.message));
|
|
337
|
+
} else {
|
|
338
|
+
pending.resolve(response.result);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
} catch (error) {
|
|
343
|
+
this.log(`Parse error: ${error}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async close(): Promise<void> {
|
|
349
|
+
if (this.websocket) {
|
|
350
|
+
this.websocket.close();
|
|
351
|
+
this.websocket = null;
|
|
352
|
+
}
|
|
353
|
+
if (this.process) {
|
|
354
|
+
this.process.kill();
|
|
355
|
+
this.process = null;
|
|
356
|
+
}
|
|
357
|
+
this.connected = false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private log(message: string): void {
|
|
361
|
+
this.onLog?.(`[MCP:${this.name}] ${message}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Create MCP clients from config
|
|
367
|
+
*/
|
|
368
|
+
export async function createMCPClients(
|
|
369
|
+
servers: Record<string, MCPServerConfig>,
|
|
370
|
+
onLog?: (message: string) => void
|
|
371
|
+
): Promise<Map<string, MCPClientImpl>> {
|
|
372
|
+
const clients = new Map<string, MCPClientImpl>();
|
|
373
|
+
|
|
374
|
+
for (const [name, config] of Object.entries(servers)) {
|
|
375
|
+
if (config.disabled) continue;
|
|
376
|
+
|
|
377
|
+
const client = new MCPClientImpl({ name, config, onLog });
|
|
378
|
+
|
|
379
|
+
try {
|
|
380
|
+
await client.connect();
|
|
381
|
+
clients.set(name, client);
|
|
382
|
+
} catch (error) {
|
|
383
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
384
|
+
onLog?.(`[MCP:${name}] Failed to connect: ${errorMessage}`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return clients;
|
|
389
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Components for Coder CLI
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Spinner
|
|
6
|
+
export {
|
|
7
|
+
Spinner,
|
|
8
|
+
getSpinner,
|
|
9
|
+
resetSpinner,
|
|
10
|
+
defaultFrames,
|
|
11
|
+
dotFrames,
|
|
12
|
+
arrowFrames,
|
|
13
|
+
defaultTips,
|
|
14
|
+
toolTips,
|
|
15
|
+
streamingTips,
|
|
16
|
+
type SpinnerOptions,
|
|
17
|
+
type SpinnerColor,
|
|
18
|
+
type SpinnerState,
|
|
19
|
+
} from "./spinner.js";
|
|
20
|
+
|
|
21
|
+
// Loading State (from shared)
|
|
22
|
+
export {
|
|
23
|
+
LoadingState,
|
|
24
|
+
getLoadingState,
|
|
25
|
+
setLoading,
|
|
26
|
+
stopLoading,
|
|
27
|
+
updateLoading,
|
|
28
|
+
startTool,
|
|
29
|
+
endTool,
|
|
30
|
+
type LoadingPhase,
|
|
31
|
+
type LoadingStateData,
|
|
32
|
+
type LoadingStateEvents,
|
|
33
|
+
} from "./terminal/shared/loading-state.js";
|
|
34
|
+
|
|
35
|
+
// Status Line (from shared)
|
|
36
|
+
export {
|
|
37
|
+
VERSION,
|
|
38
|
+
BUILD_TIME,
|
|
39
|
+
renderStatusLine,
|
|
40
|
+
renderCompactStatusLine,
|
|
41
|
+
renderMinimalStatusLine,
|
|
42
|
+
renderFooterStatus,
|
|
43
|
+
renderAutoCompactWarning,
|
|
44
|
+
calculateContextInfo,
|
|
45
|
+
formatPermissionMode,
|
|
46
|
+
formatTokenCount,
|
|
47
|
+
formatContextPercent,
|
|
48
|
+
getContextWindow,
|
|
49
|
+
shouldShowAutoCompactWarning,
|
|
50
|
+
getModelDisplayName,
|
|
51
|
+
getPermissionModeDisplay,
|
|
52
|
+
type StatusLineOptions,
|
|
53
|
+
type ContextInfo,
|
|
54
|
+
} from "./terminal/shared/status-line.js";
|
|
55
|
+
|
|
56
|
+
// TUI Footer (from tui)
|
|
57
|
+
export {
|
|
58
|
+
TUIFooter,
|
|
59
|
+
getTUIFooter,
|
|
60
|
+
enableTUIFooter,
|
|
61
|
+
disableTUIFooter,
|
|
62
|
+
renderTUIFooter,
|
|
63
|
+
clearTUIFooter,
|
|
64
|
+
ANSI,
|
|
65
|
+
type TUIFooterOptions,
|
|
66
|
+
type TUIFooterState,
|
|
67
|
+
} from "./terminal/tui/tui-footer.js";
|
|
68
|
+
|
|
69
|
+
// TUI App (Ink-based, from tui)
|
|
70
|
+
export {
|
|
71
|
+
createTUIApp,
|
|
72
|
+
type TUIAppProps,
|
|
73
|
+
type TUIAppHandle,
|
|
74
|
+
type Message as TUIMessage,
|
|
75
|
+
} from "./terminal/tui/tui-app.js";
|
|
76
|
+
export { default as TUIApp } from "./terminal/tui/tui-app.js";
|
|
77
|
+
|
|
78
|
+
// ============================================
|
|
79
|
+
// PROGRESS CALLBACK TYPES
|
|
80
|
+
// ============================================
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Progress update for tool execution
|
|
84
|
+
*/
|
|
85
|
+
export interface ProgressUpdate {
|
|
86
|
+
toolName: string;
|
|
87
|
+
status: "pending" | "running" | "complete" | "error";
|
|
88
|
+
message?: string;
|
|
89
|
+
progress?: number; // 0-100
|
|
90
|
+
timestamp: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Progress callback type for tool context
|
|
95
|
+
*/
|
|
96
|
+
export type ProgressCallback = (update: ProgressUpdate) => void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Create a progress callback for a specific tool
|
|
100
|
+
*/
|
|
101
|
+
export function createProgressCallback(
|
|
102
|
+
toolName: string,
|
|
103
|
+
onProgress?: (message: string) => void
|
|
104
|
+
): ProgressCallback {
|
|
105
|
+
return (update: ProgressUpdate) => {
|
|
106
|
+
if (onProgress) {
|
|
107
|
+
const message = update.message || `${update.toolName}: ${update.status}`;
|
|
108
|
+
onProgress(message);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ============================================
|
|
114
|
+
// UTILITY FUNCTIONS
|
|
115
|
+
// ============================================
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Format elapsed time for display
|
|
119
|
+
*/
|
|
120
|
+
export function formatElapsedTime(ms: number): string {
|
|
121
|
+
if (ms < 1000) {
|
|
122
|
+
return `${ms}ms`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const seconds = Math.floor(ms / 1000);
|
|
126
|
+
if (seconds < 60) {
|
|
127
|
+
return `${seconds}s`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const minutes = Math.floor(seconds / 60);
|
|
131
|
+
const remainingSeconds = seconds % 60;
|
|
132
|
+
|
|
133
|
+
if (minutes < 60) {
|
|
134
|
+
return `${minutes}m${remainingSeconds}s`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const hours = Math.floor(minutes / 60);
|
|
138
|
+
const remainingMinutes = minutes % 60;
|
|
139
|
+
return `${hours}h${remainingMinutes}m`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Format a loading message with optional phase
|
|
144
|
+
*/
|
|
145
|
+
export function formatLoadingMessage(
|
|
146
|
+
phase: string,
|
|
147
|
+
message?: string,
|
|
148
|
+
elapsedTime?: number
|
|
149
|
+
): string {
|
|
150
|
+
let result = phase;
|
|
151
|
+
|
|
152
|
+
if (message) {
|
|
153
|
+
result = `${result}: ${message}`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (elapsedTime !== undefined && elapsedTime > 0) {
|
|
157
|
+
result = `${result} [${formatElapsedTime(elapsedTime)}]`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
Binary file
|
|
Binary file
|