@ebowwa/coder 0.7.63 → 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/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 -52192
- 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 +159 -52768
- 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/package.json +4 -2
- 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
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission System - Interactive permission prompts
|
|
3
|
+
*/
|
|
4
|
+
import * as readline from "readline";
|
|
5
|
+
// ============================================
|
|
6
|
+
// RISK LEVEL ASSESSMENT
|
|
7
|
+
// ============================================
|
|
8
|
+
const TOOL_RISK_LEVELS = {
|
|
9
|
+
// Low risk - read-only, non-destructive
|
|
10
|
+
Read: "low",
|
|
11
|
+
Glob: "low",
|
|
12
|
+
Grep: "low",
|
|
13
|
+
Task: "low",
|
|
14
|
+
// Medium risk - modifies files but reversible
|
|
15
|
+
Write: "medium",
|
|
16
|
+
Edit: "medium",
|
|
17
|
+
NotebookEdit: "medium",
|
|
18
|
+
// Bash is assessed dynamically based on command
|
|
19
|
+
// Default to medium, elevated to high/critical by assessRiskLevel
|
|
20
|
+
Bash: "medium",
|
|
21
|
+
// Critical risk - irreversible operations
|
|
22
|
+
// (handled by input analysis)
|
|
23
|
+
};
|
|
24
|
+
// Read-only commands that are safe to auto-approve
|
|
25
|
+
const READ_ONLY_COMMANDS = [
|
|
26
|
+
/^date\b/,
|
|
27
|
+
/^ls\b/,
|
|
28
|
+
/^cat\b/,
|
|
29
|
+
/^head\b/,
|
|
30
|
+
/^tail\b/,
|
|
31
|
+
/^echo\b/,
|
|
32
|
+
/^pwd\b/,
|
|
33
|
+
/^whoami\b/,
|
|
34
|
+
/^which\b/,
|
|
35
|
+
/^uname\b/,
|
|
36
|
+
/^hostname\b/,
|
|
37
|
+
/^id\b/,
|
|
38
|
+
/^printenv\b/,
|
|
39
|
+
/^env\b/,
|
|
40
|
+
/^git\s+status\b/,
|
|
41
|
+
/^git\s+log\b/,
|
|
42
|
+
/^git\s+diff\b/,
|
|
43
|
+
/^git\s+branch\b/,
|
|
44
|
+
/^git\s+remote\b/,
|
|
45
|
+
/^git\s+rev-parse\b/,
|
|
46
|
+
/^git\s+show\b/,
|
|
47
|
+
/^npm\s+list\b/,
|
|
48
|
+
/^bun\s+--version\b/,
|
|
49
|
+
/^bun\s+-v\b/,
|
|
50
|
+
/^node\s+--version\b/,
|
|
51
|
+
/^node\s+-v\b/,
|
|
52
|
+
/^python\s+--version\b/,
|
|
53
|
+
/^python3\s+--version\b/,
|
|
54
|
+
/^uv\s+--version\b/,
|
|
55
|
+
/^doppler\s+\w+\s+--help\b/,
|
|
56
|
+
];
|
|
57
|
+
const CRITICAL_PATTERNS = [
|
|
58
|
+
/\brm\s+-rf\b/,
|
|
59
|
+
/\brm\s+-r\b/,
|
|
60
|
+
/\brm\s+[^-]/,
|
|
61
|
+
/\bgit\s+push\s+--force\b/,
|
|
62
|
+
/\bgit\s+reset\s+--hard\b/,
|
|
63
|
+
/\bgit\s+clean\s+-fd\b/,
|
|
64
|
+
/\bdrop\b/i,
|
|
65
|
+
/\bdelete\b/i,
|
|
66
|
+
/\btruncate\b/i,
|
|
67
|
+
/\bformat\b/i,
|
|
68
|
+
/\bdd\s+if=/,
|
|
69
|
+
/\bshred\b/,
|
|
70
|
+
/\b:\(\)\{\s*:\|:\s*&\s*\};\s*:\b/, // Fork bomb
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Assess risk level for a tool operation
|
|
74
|
+
*/
|
|
75
|
+
export function assessRiskLevel(toolName, toolInput) {
|
|
76
|
+
// Start with base risk level
|
|
77
|
+
let riskLevel = TOOL_RISK_LEVELS[toolName] ?? "medium";
|
|
78
|
+
// Check for critical patterns in Bash commands
|
|
79
|
+
if (toolName === "Bash") {
|
|
80
|
+
const command = String(toolInput.command ?? "");
|
|
81
|
+
for (const pattern of CRITICAL_PATTERNS) {
|
|
82
|
+
if (pattern.test(command)) {
|
|
83
|
+
return "critical";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Elevated commands increase risk
|
|
87
|
+
if (/\bsudo\b/.test(command) || /\bchmod\b/.test(command)) {
|
|
88
|
+
riskLevel = "high";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Write to sensitive files increases risk
|
|
92
|
+
if (toolName === "Write" || toolName === "Edit") {
|
|
93
|
+
const filePath = String(toolInput.file_path ?? toolInput.path ?? "");
|
|
94
|
+
if (/\.(env|pem|key|secret|credentials)/.test(filePath)) {
|
|
95
|
+
riskLevel = "high";
|
|
96
|
+
}
|
|
97
|
+
if (/\/\.ssh\//.test(filePath) || /\/\.gnupg\//.test(filePath)) {
|
|
98
|
+
riskLevel = "critical";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return riskLevel;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Generate a human-readable description of the tool operation
|
|
105
|
+
*/
|
|
106
|
+
export function generateDescription(toolName, toolInput) {
|
|
107
|
+
switch (toolName) {
|
|
108
|
+
case "Read":
|
|
109
|
+
return `Read file: ${toolInput.file_path ?? "unknown"}`;
|
|
110
|
+
case "Write":
|
|
111
|
+
return `Write file: ${toolInput.file_path ?? "unknown"} (${String(toolInput.content ?? "").length} chars)`;
|
|
112
|
+
case "Edit":
|
|
113
|
+
return `Edit file: ${toolInput.file_path ?? "unknown"}`;
|
|
114
|
+
case "Bash":
|
|
115
|
+
return `Execute: ${String(toolInput.command ?? "").slice(0, 100)}${String(toolInput.command ?? "").length > 100 ? "..." : ""}`;
|
|
116
|
+
case "Glob":
|
|
117
|
+
return `Find files: ${toolInput.pattern ?? "*"}`;
|
|
118
|
+
case "Grep":
|
|
119
|
+
return `Search: "${toolInput.pattern ?? ""}" in ${toolInput.path ?? "."}`;
|
|
120
|
+
case "Task":
|
|
121
|
+
return `Spawn agent: ${toolInput.subagent_type ?? "unknown"}`;
|
|
122
|
+
default:
|
|
123
|
+
return `Use tool: ${toolName}`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// ============================================
|
|
127
|
+
// PERMISSION MANAGER
|
|
128
|
+
// ============================================
|
|
129
|
+
export class PermissionManager {
|
|
130
|
+
cache = {};
|
|
131
|
+
cacheTimeout = 5 * 60 * 1000; // 5 minutes
|
|
132
|
+
promptCallback;
|
|
133
|
+
mode;
|
|
134
|
+
constructor(mode = "default", promptCallback) {
|
|
135
|
+
this.mode = mode;
|
|
136
|
+
this.promptCallback = promptCallback ?? this.defaultPrompt.bind(this);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if a tool operation is permitted
|
|
140
|
+
*/
|
|
141
|
+
async checkPermission(toolName, toolInput) {
|
|
142
|
+
// Bypass mode - always allow
|
|
143
|
+
if (this.mode === "bypassPermissions") {
|
|
144
|
+
return { decision: "allow" };
|
|
145
|
+
}
|
|
146
|
+
// DontAsk mode - always deny
|
|
147
|
+
if (this.mode === "dontAsk") {
|
|
148
|
+
return { decision: "deny", reason: "Permission mode is dontAsk" };
|
|
149
|
+
}
|
|
150
|
+
// AcceptEdits mode - allow file operations and non-critical Bash commands
|
|
151
|
+
if (this.mode === "acceptEdits") {
|
|
152
|
+
const fileTools = ["Read", "Write", "Edit", "Glob", "Grep"];
|
|
153
|
+
if (fileTools.includes(toolName)) {
|
|
154
|
+
return { decision: "allow" };
|
|
155
|
+
}
|
|
156
|
+
// Also allow non-critical Bash commands (low/medium risk)
|
|
157
|
+
if (toolName === "Bash") {
|
|
158
|
+
const riskLevel = assessRiskLevel(toolName, toolInput);
|
|
159
|
+
if (riskLevel === "low" || riskLevel === "medium") {
|
|
160
|
+
return { decision: "allow" };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Plan mode - deny all write operations
|
|
165
|
+
if (this.mode === "plan") {
|
|
166
|
+
const readOnlyTools = ["Read", "Glob", "Grep", "Task"];
|
|
167
|
+
if (readOnlyTools.includes(toolName)) {
|
|
168
|
+
return { decision: "allow" };
|
|
169
|
+
}
|
|
170
|
+
return { decision: "deny", reason: "Plan mode - write operations disabled" };
|
|
171
|
+
}
|
|
172
|
+
// Check cache for "always" decisions
|
|
173
|
+
const cacheKey = this.getCacheKey(toolName, toolInput);
|
|
174
|
+
const cached = this.cache[cacheKey];
|
|
175
|
+
if (cached && Date.now() - cached.timestamp < this.cacheTimeout) {
|
|
176
|
+
if (cached.decision === "allowAlways") {
|
|
177
|
+
return { decision: "allow", reason: "Previously approved (always)" };
|
|
178
|
+
}
|
|
179
|
+
if (cached.decision === "denyAlways") {
|
|
180
|
+
return { decision: "deny", reason: "Previously denied (always)" };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Assess risk level
|
|
184
|
+
const riskLevel = assessRiskLevel(toolName, toolInput);
|
|
185
|
+
const description = generateDescription(toolName, toolInput);
|
|
186
|
+
// Create permission request
|
|
187
|
+
const request = {
|
|
188
|
+
toolName,
|
|
189
|
+
toolInput,
|
|
190
|
+
riskLevel,
|
|
191
|
+
description,
|
|
192
|
+
file: (toolInput.file_path ?? toolInput.path),
|
|
193
|
+
command: toolName === "Bash" ? toolInput.command : undefined,
|
|
194
|
+
};
|
|
195
|
+
// Prompt user for interactive/default modes
|
|
196
|
+
if (this.mode === "interactive" || this.mode === "default") {
|
|
197
|
+
const result = await this.promptCallback(request);
|
|
198
|
+
// Cache "always" decisions
|
|
199
|
+
if (result.decision === "allowAlways" || result.decision === "denyAlways") {
|
|
200
|
+
this.cache[cacheKey] = {
|
|
201
|
+
decision: result.decision,
|
|
202
|
+
timestamp: Date.now(),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
// Default to allow for unknown modes
|
|
208
|
+
return { decision: "allow" };
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Generate cache key for permission
|
|
212
|
+
*/
|
|
213
|
+
getCacheKey(toolName, toolInput) {
|
|
214
|
+
// For file operations, key on file path
|
|
215
|
+
if (["Read", "Write", "Edit"].includes(toolName)) {
|
|
216
|
+
return `${toolName}:${toolInput.file_path ?? toolInput.path ?? "unknown"}`;
|
|
217
|
+
}
|
|
218
|
+
// For bash, key on command (first 100 chars)
|
|
219
|
+
if (toolName === "Bash") {
|
|
220
|
+
const cmd = String(toolInput.command ?? "").slice(0, 100);
|
|
221
|
+
return `${toolName}:${cmd}`;
|
|
222
|
+
}
|
|
223
|
+
// Default: key on tool name only
|
|
224
|
+
return toolName;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Default prompt implementation using readline
|
|
228
|
+
*/
|
|
229
|
+
async defaultPrompt(request) {
|
|
230
|
+
return new Promise((resolve) => {
|
|
231
|
+
const rl = readline.createInterface({
|
|
232
|
+
input: process.stdin,
|
|
233
|
+
output: process.stdout,
|
|
234
|
+
});
|
|
235
|
+
// Format risk level with color
|
|
236
|
+
const riskColors = {
|
|
237
|
+
low: "\x1b[32m", // Green
|
|
238
|
+
medium: "\x1b[33m", // Yellow
|
|
239
|
+
high: "\x1b[31m", // Red
|
|
240
|
+
critical: "\x1b[35m", // Magenta
|
|
241
|
+
};
|
|
242
|
+
const riskColor = riskColors[request.riskLevel] ?? "\x1b[0m";
|
|
243
|
+
const reset = "\x1b[0m";
|
|
244
|
+
console.log("");
|
|
245
|
+
console.log(`\x1b[36m━━━ Permission Required ━━━\x1b[0m`);
|
|
246
|
+
console.log(`Tool: \x1b[1m${request.toolName}\x1b[0m`);
|
|
247
|
+
console.log(`Risk: ${riskColor}${request.riskLevel.toUpperCase()}${reset}`);
|
|
248
|
+
console.log(`Action: ${request.description}`);
|
|
249
|
+
if (request.file) {
|
|
250
|
+
console.log(`File: ${request.file}`);
|
|
251
|
+
}
|
|
252
|
+
if (request.command) {
|
|
253
|
+
console.log(`Command: ${request.command.slice(0, 200)}${request.command.length > 200 ? "..." : ""}`);
|
|
254
|
+
}
|
|
255
|
+
console.log("");
|
|
256
|
+
const options = "[y]es / [n]o / [a]lways / [d]eny always";
|
|
257
|
+
rl.question(`Allow? ${options}: `, (answer) => {
|
|
258
|
+
rl.close();
|
|
259
|
+
const input = answer.trim().toLowerCase();
|
|
260
|
+
switch (input) {
|
|
261
|
+
case "y":
|
|
262
|
+
case "yes":
|
|
263
|
+
resolve({ decision: "allow" });
|
|
264
|
+
break;
|
|
265
|
+
case "a":
|
|
266
|
+
case "always":
|
|
267
|
+
resolve({ decision: "allowAlways" });
|
|
268
|
+
break;
|
|
269
|
+
case "d":
|
|
270
|
+
case "deny":
|
|
271
|
+
case "deny always":
|
|
272
|
+
resolve({ decision: "denyAlways" });
|
|
273
|
+
break;
|
|
274
|
+
case "n":
|
|
275
|
+
case "no":
|
|
276
|
+
default:
|
|
277
|
+
resolve({ decision: "deny" });
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Clear permission cache
|
|
285
|
+
*/
|
|
286
|
+
clearCache() {
|
|
287
|
+
this.cache = {};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Set permission mode
|
|
291
|
+
*/
|
|
292
|
+
setMode(mode) {
|
|
293
|
+
this.mode = mode;
|
|
294
|
+
// Clear cache when mode changes
|
|
295
|
+
this.clearCache();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// ============================================
|
|
299
|
+
// PERMISSION CATEGORIES
|
|
300
|
+
// ============================================
|
|
301
|
+
/**
|
|
302
|
+
* Tool categories for permission decisions
|
|
303
|
+
*/
|
|
304
|
+
export const TOOL_CATEGORIES = {
|
|
305
|
+
readOnly: ["Read", "Glob", "Grep", "Task"],
|
|
306
|
+
fileEdit: ["Write", "Edit", "NotebookEdit"],
|
|
307
|
+
system: ["Bash"],
|
|
308
|
+
network: [], // Future: HTTP requests, etc.
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Check if tool is read-only
|
|
312
|
+
*/
|
|
313
|
+
export function isReadOnlyTool(toolName) {
|
|
314
|
+
return TOOL_CATEGORIES.readOnly.includes(toolName);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Check if tool modifies files
|
|
318
|
+
*/
|
|
319
|
+
export function isFileEditTool(toolName) {
|
|
320
|
+
return TOOL_CATEGORIES.fileEdit.includes(toolName);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Check if tool executes system commands
|
|
324
|
+
*/
|
|
325
|
+
export function isSystemTool(toolName) {
|
|
326
|
+
return TOOL_CATEGORIES.system.includes(toolName);
|
|
327
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry Logic - Exponential backoff with jitter for API failures
|
|
3
|
+
* Handles rate limits, network errors, and transient failures
|
|
4
|
+
*/
|
|
5
|
+
export interface RetryOptions {
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
baseDelayMs?: number;
|
|
8
|
+
maxDelayMs?: number;
|
|
9
|
+
jitterFactor?: number;
|
|
10
|
+
retryableStatusCodes?: number[];
|
|
11
|
+
onRetry?: (attempt: number, error: Error, delayMs: number) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Execute a function with retry logic
|
|
15
|
+
*/
|
|
16
|
+
export declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a retry wrapper for fetch
|
|
19
|
+
*/
|
|
20
|
+
export declare function createFetchWithRetry(options?: RetryOptions): (url: string, init?: RequestInit) => Promise<Response>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse retry-after header from rate limit response
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseRetryAfter(response: Response): number | null;
|
|
25
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../packages/src/core/retry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpE;AA4ED;;GAEG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CAqCZ;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,YAAiB,GACzB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAiBxD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CASjE"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry Logic - Exponential backoff with jitter for API failures
|
|
3
|
+
* Handles rate limits, network errors, and transient failures
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_RETRY_OPTIONS = {
|
|
6
|
+
maxRetries: 3,
|
|
7
|
+
baseDelayMs: 1000,
|
|
8
|
+
maxDelayMs: 30000,
|
|
9
|
+
jitterFactor: 0.2,
|
|
10
|
+
retryableStatusCodes: [429, 500, 502, 503, 504, 529],
|
|
11
|
+
onRetry: undefined,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Calculate delay with exponential backoff and jitter
|
|
15
|
+
*/
|
|
16
|
+
function calculateDelay(attempt, baseDelayMs, maxDelayMs, jitterFactor) {
|
|
17
|
+
// Exponential backoff: baseDelay * 2^attempt
|
|
18
|
+
const exponentialDelay = baseDelayMs * Math.pow(2, attempt);
|
|
19
|
+
// Add jitter to prevent thundering herd
|
|
20
|
+
const jitter = exponentialDelay * jitterFactor * (Math.random() * 2 - 1);
|
|
21
|
+
// Cap at max delay
|
|
22
|
+
return Math.min(exponentialDelay + jitter, maxDelayMs);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if an error is retryable
|
|
26
|
+
*/
|
|
27
|
+
function isRetryableError(error, retryableStatusCodes) {
|
|
28
|
+
// Check for rate limit errors
|
|
29
|
+
if (error.message.includes("429") || error.message.includes("rate limit")) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
// Check for server errors
|
|
33
|
+
if (error.message.includes("500") ||
|
|
34
|
+
error.message.includes("502") ||
|
|
35
|
+
error.message.includes("503") ||
|
|
36
|
+
error.message.includes("504")) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
// Check for network errors
|
|
40
|
+
if (error.message.includes("ECONNREFUSED") ||
|
|
41
|
+
error.message.includes("ENOTFOUND") ||
|
|
42
|
+
error.message.includes("ETIMEDOUT") ||
|
|
43
|
+
error.message.includes("network") ||
|
|
44
|
+
error.message.includes("fetch failed")) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
// Check for specific status codes in error message
|
|
48
|
+
for (const code of retryableStatusCodes) {
|
|
49
|
+
if (error.message.includes(String(code))) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sleep for a given number of milliseconds
|
|
57
|
+
*/
|
|
58
|
+
function sleep(ms) {
|
|
59
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute a function with retry logic
|
|
63
|
+
*/
|
|
64
|
+
export async function withRetry(fn, options = {}) {
|
|
65
|
+
const opts = { ...DEFAULT_RETRY_OPTIONS, ...options };
|
|
66
|
+
let lastError = null;
|
|
67
|
+
for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
|
|
68
|
+
try {
|
|
69
|
+
return await fn();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
73
|
+
// Check if we should retry
|
|
74
|
+
if (attempt < opts.maxRetries && isRetryableError(lastError, opts.retryableStatusCodes)) {
|
|
75
|
+
const delayMs = calculateDelay(attempt, opts.baseDelayMs, opts.maxDelayMs, opts.jitterFactor);
|
|
76
|
+
// Log retry attempt
|
|
77
|
+
if (opts.onRetry) {
|
|
78
|
+
opts.onRetry(attempt + 1, lastError, delayMs);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.warn(`\x1b[33mRetry ${attempt + 1}/${opts.maxRetries} after ${delayMs}ms: ${lastError.message}\x1b[0m`);
|
|
82
|
+
}
|
|
83
|
+
await sleep(delayMs);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Non-retryable error or max retries reached
|
|
87
|
+
throw lastError;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
throw lastError || new Error("Max retries exceeded");
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a retry wrapper for fetch
|
|
95
|
+
*/
|
|
96
|
+
export function createFetchWithRetry(options = {}) {
|
|
97
|
+
return async (url, init) => {
|
|
98
|
+
return withRetry(async () => {
|
|
99
|
+
const response = await fetch(url, init);
|
|
100
|
+
// Check for retryable status codes
|
|
101
|
+
if (options.retryableStatusCodes?.includes(response.status)) {
|
|
102
|
+
const text = await response.text();
|
|
103
|
+
throw new Error(`API error: ${response.status} - ${text}`);
|
|
104
|
+
}
|
|
105
|
+
return response;
|
|
106
|
+
}, options);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parse retry-after header from rate limit response
|
|
111
|
+
*/
|
|
112
|
+
export function parseRetryAfter(response) {
|
|
113
|
+
const retryAfter = response.headers.get("retry-after");
|
|
114
|
+
if (retryAfter) {
|
|
115
|
+
const seconds = parseInt(retryAfter, 10);
|
|
116
|
+
if (!isNaN(seconds)) {
|
|
117
|
+
return seconds * 1000; // Convert to milliseconds
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Store - Backward compatibility layer
|
|
3
|
+
* Re-exports from composable sessions module
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Import from "./sessions/index.js" instead for composable access
|
|
6
|
+
*/
|
|
7
|
+
export { SessionStore, SessionPersistence, SessionMetadataManager, SessionExporter, formatSessionSummary, printSessionsList, type SessionMetadata, type SessionMessage, type SessionToolUse, type SessionMetrics, type SessionContext, type SessionCheckpoint, type SessionEntry, type LoadedSession, type SessionSummary, type SessionFilter, type SessionEvent, type SessionEventType, type SessionEventHandler, type ExportFormat, type ISessionPersistence, type ISessionExporter, } from "./sessions/index.js";
|
|
8
|
+
export { SessionStore as default } from "./sessions/index.js";
|
|
9
|
+
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../packages/src/core/session-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EAEjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Store - Backward compatibility layer
|
|
3
|
+
* Re-exports from composable sessions module
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Import from "./sessions/index.js" instead for composable access
|
|
6
|
+
*/
|
|
7
|
+
// Re-export everything from the new composable module
|
|
8
|
+
export { SessionStore, SessionPersistence, SessionMetadataManager, SessionExporter, formatSessionSummary, printSessionsList, } from "./sessions/index.js";
|
|
9
|
+
// Default export
|
|
10
|
+
export { SessionStore as default } from "./sessions/index.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Export - Export sessions to various formats
|
|
3
|
+
* Supports JSONL, JSON, and Markdown
|
|
4
|
+
*/
|
|
5
|
+
import type { LoadedSession, SessionSummary, ExportFormat, ISessionExporter } from "./types.js";
|
|
6
|
+
import { SessionPersistence } from "./persistence.js";
|
|
7
|
+
export declare class SessionExporter implements ISessionExporter {
|
|
8
|
+
private persistence;
|
|
9
|
+
constructor(persistence: SessionPersistence);
|
|
10
|
+
/**
|
|
11
|
+
* Export a loaded session to the specified format
|
|
12
|
+
*/
|
|
13
|
+
export(session: LoadedSession, format: ExportFormat): string;
|
|
14
|
+
/**
|
|
15
|
+
* Export a session to a file
|
|
16
|
+
*/
|
|
17
|
+
exportToFile(sessionId: string, format: ExportFormat, outputPath?: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Export to JSONL format (raw session file)
|
|
20
|
+
*/
|
|
21
|
+
private toJsonl;
|
|
22
|
+
/**
|
|
23
|
+
* Export to JSON format (pretty-printed)
|
|
24
|
+
*/
|
|
25
|
+
private toJson;
|
|
26
|
+
/**
|
|
27
|
+
* Export to Markdown format
|
|
28
|
+
*/
|
|
29
|
+
private toMarkdown;
|
|
30
|
+
/**
|
|
31
|
+
* Format a content block for markdown
|
|
32
|
+
*/
|
|
33
|
+
private formatBlock;
|
|
34
|
+
/**
|
|
35
|
+
* Format a session summary for display
|
|
36
|
+
*/
|
|
37
|
+
static formatSummary(session: SessionSummary): string;
|
|
38
|
+
/**
|
|
39
|
+
* Format relative time
|
|
40
|
+
*/
|
|
41
|
+
static formatRelativeTime(date: Date): string;
|
|
42
|
+
/**
|
|
43
|
+
* Print sessions list for CLI
|
|
44
|
+
*/
|
|
45
|
+
static printList(sessions: SessionSummary[]): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../packages/src/core/sessions/export.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,OAAO,CAAC,WAAW,CAAqB;gBAE5B,WAAW,EAAE,kBAAkB;IAI3C;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM;IAa5D;;OAEG;IACG,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAgBlB;;OAEG;IACH,OAAO,CAAC,OAAO;IAkCf;;OAEG;IACH,OAAO,CAAC,MAAM;IAId;;OAEG;IACH,OAAO,CAAC,UAAU;IA8FlB;;OAEG;IACH,OAAO,CAAC,WAAW;IA8CnB;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;IAmCrD;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAe7C;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI;CAiBnD"}
|