zerg-ztc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +361 -0
- package/dist/App.d.ts +4 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +499 -0
- package/dist/App.js.map +1 -0
- package/dist/agent/agent.d.ts +54 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +347 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/backends/anthropic.d.ts +13 -0
- package/dist/agent/backends/anthropic.d.ts.map +1 -0
- package/dist/agent/backends/anthropic.js +54 -0
- package/dist/agent/backends/anthropic.js.map +1 -0
- package/dist/agent/backends/gemini.d.ts +13 -0
- package/dist/agent/backends/gemini.d.ts.map +1 -0
- package/dist/agent/backends/gemini.js +71 -0
- package/dist/agent/backends/gemini.js.map +1 -0
- package/dist/agent/backends/inception.d.ts +12 -0
- package/dist/agent/backends/inception.d.ts.map +1 -0
- package/dist/agent/backends/inception.js +15 -0
- package/dist/agent/backends/inception.js.map +1 -0
- package/dist/agent/backends/index.d.ts +7 -0
- package/dist/agent/backends/index.d.ts.map +1 -0
- package/dist/agent/backends/index.js +6 -0
- package/dist/agent/backends/index.js.map +1 -0
- package/dist/agent/backends/openai.d.ts +12 -0
- package/dist/agent/backends/openai.d.ts.map +1 -0
- package/dist/agent/backends/openai.js +15 -0
- package/dist/agent/backends/openai.js.map +1 -0
- package/dist/agent/backends/openai_compatible.d.ts +17 -0
- package/dist/agent/backends/openai_compatible.d.ts.map +1 -0
- package/dist/agent/backends/openai_compatible.js +95 -0
- package/dist/agent/backends/openai_compatible.js.map +1 -0
- package/dist/agent/backends/types.d.ts +49 -0
- package/dist/agent/backends/types.d.ts.map +1 -0
- package/dist/agent/backends/types.js +2 -0
- package/dist/agent/backends/types.js.map +1 -0
- package/dist/agent/commands/clipboard.d.ts +3 -0
- package/dist/agent/commands/clipboard.d.ts.map +1 -0
- package/dist/agent/commands/clipboard.js +72 -0
- package/dist/agent/commands/clipboard.js.map +1 -0
- package/dist/agent/commands/config.d.ts +3 -0
- package/dist/agent/commands/config.d.ts.map +1 -0
- package/dist/agent/commands/config.js +120 -0
- package/dist/agent/commands/config.js.map +1 -0
- package/dist/agent/commands/debug.d.ts +3 -0
- package/dist/agent/commands/debug.d.ts.map +1 -0
- package/dist/agent/commands/debug.js +23 -0
- package/dist/agent/commands/debug.js.map +1 -0
- package/dist/agent/commands/emulation.d.ts +3 -0
- package/dist/agent/commands/emulation.d.ts.map +1 -0
- package/dist/agent/commands/emulation.js +78 -0
- package/dist/agent/commands/emulation.js.map +1 -0
- package/dist/agent/commands/execution.d.ts +3 -0
- package/dist/agent/commands/execution.d.ts.map +1 -0
- package/dist/agent/commands/execution.js +8 -0
- package/dist/agent/commands/execution.js.map +1 -0
- package/dist/agent/commands/help.d.ts +3 -0
- package/dist/agent/commands/help.d.ts.map +1 -0
- package/dist/agent/commands/help.js +19 -0
- package/dist/agent/commands/help.js.map +1 -0
- package/dist/agent/commands/history.d.ts +3 -0
- package/dist/agent/commands/history.d.ts.map +1 -0
- package/dist/agent/commands/history.js +12 -0
- package/dist/agent/commands/history.js.map +1 -0
- package/dist/agent/commands/index.d.ts +4 -0
- package/dist/agent/commands/index.d.ts.map +1 -0
- package/dist/agent/commands/index.js +19 -0
- package/dist/agent/commands/index.js.map +1 -0
- package/dist/agent/commands/model.d.ts +3 -0
- package/dist/agent/commands/model.d.ts.map +1 -0
- package/dist/agent/commands/model.js +10 -0
- package/dist/agent/commands/model.js.map +1 -0
- package/dist/agent/commands/models.d.ts +3 -0
- package/dist/agent/commands/models.d.ts.map +1 -0
- package/dist/agent/commands/models.js +110 -0
- package/dist/agent/commands/models.js.map +1 -0
- package/dist/agent/commands/permissions.d.ts +3 -0
- package/dist/agent/commands/permissions.d.ts.map +1 -0
- package/dist/agent/commands/permissions.js +58 -0
- package/dist/agent/commands/permissions.js.map +1 -0
- package/dist/agent/commands/retry.d.ts +3 -0
- package/dist/agent/commands/retry.d.ts.map +1 -0
- package/dist/agent/commands/retry.js +8 -0
- package/dist/agent/commands/retry.js.map +1 -0
- package/dist/agent/commands/shell.d.ts +4 -0
- package/dist/agent/commands/shell.d.ts.map +1 -0
- package/dist/agent/commands/shell.js +66 -0
- package/dist/agent/commands/shell.js.map +1 -0
- package/dist/agent/commands/skills.d.ts +3 -0
- package/dist/agent/commands/skills.d.ts.map +1 -0
- package/dist/agent/commands/skills.js +50 -0
- package/dist/agent/commands/skills.js.map +1 -0
- package/dist/agent/commands/status.d.ts +3 -0
- package/dist/agent/commands/status.d.ts.map +1 -0
- package/dist/agent/commands/status.js +18 -0
- package/dist/agent/commands/status.js.map +1 -0
- package/dist/agent/commands/types.d.ts +70 -0
- package/dist/agent/commands/types.d.ts.map +1 -0
- package/dist/agent/commands/types.js +2 -0
- package/dist/agent/commands/types.js.map +1 -0
- package/dist/agent/factory.d.ts +13 -0
- package/dist/agent/factory.d.ts.map +1 -0
- package/dist/agent/factory.js +46 -0
- package/dist/agent/factory.js.map +1 -0
- package/dist/agent/index.d.ts +14 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +10 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/runtime/capabilities.d.ts +7 -0
- package/dist/agent/runtime/capabilities.d.ts.map +1 -0
- package/dist/agent/runtime/capabilities.js +8 -0
- package/dist/agent/runtime/capabilities.js.map +1 -0
- package/dist/agent/runtime/memory.d.ts +13 -0
- package/dist/agent/runtime/memory.d.ts.map +1 -0
- package/dist/agent/runtime/memory.js +13 -0
- package/dist/agent/runtime/memory.js.map +1 -0
- package/dist/agent/runtime/policy.d.ts +22 -0
- package/dist/agent/runtime/policy.d.ts.map +1 -0
- package/dist/agent/runtime/policy.js +29 -0
- package/dist/agent/runtime/policy.js.map +1 -0
- package/dist/agent/runtime/session.d.ts +11 -0
- package/dist/agent/runtime/session.d.ts.map +1 -0
- package/dist/agent/runtime/session.js +10 -0
- package/dist/agent/runtime/session.js.map +1 -0
- package/dist/agent/runtime/tracing.d.ts +13 -0
- package/dist/agent/runtime/tracing.d.ts.map +1 -0
- package/dist/agent/runtime/tracing.js +6 -0
- package/dist/agent/runtime/tracing.js.map +1 -0
- package/dist/agent/tools/file.d.ts +5 -0
- package/dist/agent/tools/file.d.ts.map +1 -0
- package/dist/agent/tools/file.js +162 -0
- package/dist/agent/tools/file.js.map +1 -0
- package/dist/agent/tools/index.d.ts +13 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +34 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/search.d.ts +3 -0
- package/dist/agent/tools/search.d.ts.map +1 -0
- package/dist/agent/tools/search.js +124 -0
- package/dist/agent/tools/search.js.map +1 -0
- package/dist/agent/tools/shell.d.ts +3 -0
- package/dist/agent/tools/shell.d.ts.map +1 -0
- package/dist/agent/tools/shell.js +60 -0
- package/dist/agent/tools/shell.js.map +1 -0
- package/dist/agent/tools/skills.d.ts +3 -0
- package/dist/agent/tools/skills.d.ts.map +1 -0
- package/dist/agent/tools/skills.js +27 -0
- package/dist/agent/tools/skills.js.map +1 -0
- package/dist/agent/tools/types.d.ts +8 -0
- package/dist/agent/tools/types.d.ts.map +1 -0
- package/dist/agent/tools/types.js +2 -0
- package/dist/agent/tools/types.js.map +1 -0
- package/dist/agent/tools/zerg.d.ts +3 -0
- package/dist/agent/tools/zerg.d.ts.map +1 -0
- package/dist/agent/tools/zerg.js +47 -0
- package/dist/agent/tools/zerg.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +75 -0
- package/dist/cli.js.map +1 -0
- package/dist/components/FullScreen.d.ts +28 -0
- package/dist/components/FullScreen.d.ts.map +1 -0
- package/dist/components/FullScreen.js +40 -0
- package/dist/components/FullScreen.js.map +1 -0
- package/dist/components/Header.d.ts +10 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +14 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/InputArea.d.ts +24 -0
- package/dist/components/InputArea.d.ts.map +1 -0
- package/dist/components/InputArea.js +476 -0
- package/dist/components/InputArea.js.map +1 -0
- package/dist/components/MessageList.d.ts +12 -0
- package/dist/components/MessageList.d.ts.map +1 -0
- package/dist/components/MessageList.js +9 -0
- package/dist/components/MessageList.js.map +1 -0
- package/dist/components/StatusBar.d.ts +18 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/StatusBar.js +21 -0
- package/dist/components/StatusBar.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +7 -0
- package/dist/components/index.js.map +1 -0
- package/dist/config/types.d.ts +12 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +155 -0
- package/dist/config.js.map +1 -0
- package/dist/debug/logger.d.ts +2 -0
- package/dist/debug/logger.d.ts.map +1 -0
- package/dist/debug/logger.js +15 -0
- package/dist/debug/logger.js.map +1 -0
- package/dist/emulation/catalog.d.ts +4 -0
- package/dist/emulation/catalog.d.ts.map +1 -0
- package/dist/emulation/catalog.js +68 -0
- package/dist/emulation/catalog.js.map +1 -0
- package/dist/emulation/trace_style.d.ts +3 -0
- package/dist/emulation/trace_style.d.ts.map +1 -0
- package/dist/emulation/trace_style.js +10 -0
- package/dist/emulation/trace_style.js.map +1 -0
- package/dist/emulation/types.d.ts +8 -0
- package/dist/emulation/types.d.ts.map +1 -0
- package/dist/emulation/types.js +2 -0
- package/dist/emulation/types.js.map +1 -0
- package/dist/skills/index.d.ts +5 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +36 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/loader.d.ts +3 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +137 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/registry.d.ts +3 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +5 -0
- package/dist/skills/registry.js.map +1 -0
- package/dist/skills/types.d.ts +11 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +2 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/core/factory.d.ts +4 -0
- package/dist/ui/core/factory.d.ts.map +1 -0
- package/dist/ui/core/factory.js +7 -0
- package/dist/ui/core/factory.js.map +1 -0
- package/dist/ui/core/index.d.ts +5 -0
- package/dist/ui/core/index.d.ts.map +1 -0
- package/dist/ui/core/index.js +4 -0
- package/dist/ui/core/index.js.map +1 -0
- package/dist/ui/core/input.d.ts +22 -0
- package/dist/ui/core/input.d.ts.map +1 -0
- package/dist/ui/core/input.js +15 -0
- package/dist/ui/core/input.js.map +1 -0
- package/dist/ui/core/input_segments.d.ts +19 -0
- package/dist/ui/core/input_segments.d.ts.map +1 -0
- package/dist/ui/core/input_segments.js +367 -0
- package/dist/ui/core/input_segments.js.map +1 -0
- package/dist/ui/core/input_state.d.ts +24 -0
- package/dist/ui/core/input_state.d.ts.map +1 -0
- package/dist/ui/core/input_state.js +2 -0
- package/dist/ui/core/input_state.js.map +1 -0
- package/dist/ui/core/layout_yoga.d.ts +11 -0
- package/dist/ui/core/layout_yoga.d.ts.map +1 -0
- package/dist/ui/core/layout_yoga.js +102 -0
- package/dist/ui/core/layout_yoga.js.map +1 -0
- package/dist/ui/core/style.d.ts +3 -0
- package/dist/ui/core/style.d.ts.map +1 -0
- package/dist/ui/core/style.js +37 -0
- package/dist/ui/core/style.js.map +1 -0
- package/dist/ui/core/types.d.ts +50 -0
- package/dist/ui/core/types.d.ts.map +1 -0
- package/dist/ui/core/types.js +2 -0
- package/dist/ui/core/types.js.map +1 -0
- package/dist/ui/ink/index.d.ts +2 -0
- package/dist/ui/ink/index.d.ts.map +1 -0
- package/dist/ui/ink/index.js +2 -0
- package/dist/ui/ink/index.js.map +1 -0
- package/dist/ui/ink/render.d.ts +6 -0
- package/dist/ui/ink/render.d.ts.map +1 -0
- package/dist/ui/ink/render.js +14 -0
- package/dist/ui/ink/render.js.map +1 -0
- package/dist/ui/views/app.d.ts +28 -0
- package/dist/ui/views/app.d.ts.map +1 -0
- package/dist/ui/views/app.js +59 -0
- package/dist/ui/views/app.js.map +1 -0
- package/dist/ui/views/header.d.ts +11 -0
- package/dist/ui/views/header.d.ts.map +1 -0
- package/dist/ui/views/header.js +28 -0
- package/dist/ui/views/header.js.map +1 -0
- package/dist/ui/views/input_area.d.ts +45 -0
- package/dist/ui/views/input_area.d.ts.map +1 -0
- package/dist/ui/views/input_area.js +183 -0
- package/dist/ui/views/input_area.js.map +1 -0
- package/dist/ui/views/message_list.d.ts +12 -0
- package/dist/ui/views/message_list.d.ts.map +1 -0
- package/dist/ui/views/message_list.js +381 -0
- package/dist/ui/views/message_list.js.map +1 -0
- package/dist/ui/views/status_bar.d.ts +18 -0
- package/dist/ui/views/status_bar.d.ts.map +1 -0
- package/dist/ui/views/status_bar.js +72 -0
- package/dist/ui/views/status_bar.js.map +1 -0
- package/dist/ui/vue/index.d.ts +5 -0
- package/dist/ui/vue/index.d.ts.map +1 -0
- package/dist/ui/vue/index.js +50 -0
- package/dist/ui/vue/index.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +39 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/clipboard_image.d.ts +2 -0
- package/dist/utils/clipboard_image.d.ts.map +1 -0
- package/dist/utils/clipboard_image.js +37 -0
- package/dist/utils/clipboard_image.js.map +1 -0
- package/dist/utils/diff.d.ts +2 -0
- package/dist/utils/diff.d.ts.map +1 -0
- package/dist/utils/diff.js +49 -0
- package/dist/utils/diff.js.map +1 -0
- package/dist/utils/image_preview.d.ts +2 -0
- package/dist/utils/image_preview.d.ts.map +1 -0
- package/dist/utils/image_preview.js +37 -0
- package/dist/utils/image_preview.js.map +1 -0
- package/dist/utils/models.d.ts +8 -0
- package/dist/utils/models.d.ts.map +1 -0
- package/dist/utils/models.js +85 -0
- package/dist/utils/models.js.map +1 -0
- package/dist/utils/shell.d.ts +4 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +57 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/tool_summary.d.ts +3 -0
- package/dist/utils/tool_summary.d.ts.map +1 -0
- package/dist/utils/tool_summary.js +54 -0
- package/dist/utils/tool_summary.js.map +1 -0
- package/dist/utils/tool_trace.d.ts +9 -0
- package/dist/utils/tool_trace.d.ts.map +1 -0
- package/dist/utils/tool_trace.js +183 -0
- package/dist/utils/tool_trace.js.map +1 -0
- package/package.json +41 -0
- package/src/App.tsx +576 -0
- package/src/agent/agent.ts +407 -0
- package/src/agent/backends/anthropic.ts +76 -0
- package/src/agent/backends/gemini.ts +107 -0
- package/src/agent/backends/inception.ts +23 -0
- package/src/agent/backends/index.ts +16 -0
- package/src/agent/backends/openai.ts +23 -0
- package/src/agent/backends/openai_compatible.ts +131 -0
- package/src/agent/backends/types.ts +59 -0
- package/src/agent/commands/clipboard.ts +77 -0
- package/src/agent/commands/config.ts +130 -0
- package/src/agent/commands/debug.ts +23 -0
- package/src/agent/commands/emulation.ts +80 -0
- package/src/agent/commands/execution.ts +9 -0
- package/src/agent/commands/help.ts +20 -0
- package/src/agent/commands/history.ts +13 -0
- package/src/agent/commands/index.ts +40 -0
- package/src/agent/commands/model.ts +11 -0
- package/src/agent/commands/models.ts +116 -0
- package/src/agent/commands/permissions.ts +64 -0
- package/src/agent/commands/retry.ts +9 -0
- package/src/agent/commands/shell.ts +68 -0
- package/src/agent/commands/skills.ts +54 -0
- package/src/agent/commands/status.ts +19 -0
- package/src/agent/commands/types.ts +78 -0
- package/src/agent/factory.ts +60 -0
- package/src/agent/index.ts +20 -0
- package/src/agent/runtime/capabilities.ts +6 -0
- package/src/agent/runtime/memory.ts +23 -0
- package/src/agent/runtime/policy.ts +48 -0
- package/src/agent/runtime/session.ts +18 -0
- package/src/agent/runtime/tracing.ts +23 -0
- package/src/agent/tools/file.ts +173 -0
- package/src/agent/tools/index.ts +46 -0
- package/src/agent/tools/search.ts +137 -0
- package/src/agent/tools/shell.ts +65 -0
- package/src/agent/tools/skills.ts +28 -0
- package/src/agent/tools/types.ts +10 -0
- package/src/agent/tools/zerg.ts +50 -0
- package/src/cli.tsx +80 -0
- package/src/components/FullScreen.tsx +73 -0
- package/src/components/Header.tsx +27 -0
- package/src/components/InputArea.tsx +551 -0
- package/src/components/MessageList.tsx +25 -0
- package/src/components/StatusBar.tsx +49 -0
- package/src/components/index.tsx +6 -0
- package/src/config/types.ts +11 -0
- package/src/config.ts +178 -0
- package/src/debug/logger.ts +14 -0
- package/src/emulation/README.md +24 -0
- package/src/emulation/catalog.ts +82 -0
- package/src/emulation/trace_style.ts +8 -0
- package/src/emulation/types.ts +7 -0
- package/src/skills/index.ts +36 -0
- package/src/skills/loader.ts +135 -0
- package/src/skills/registry.ts +6 -0
- package/src/skills/types.ts +10 -0
- package/src/types.ts +83 -0
- package/src/ui/README.md +44 -0
- package/src/ui/core/factory.ts +9 -0
- package/src/ui/core/index.ts +4 -0
- package/src/ui/core/input.ts +38 -0
- package/src/ui/core/input_segments.ts +375 -0
- package/src/ui/core/input_state.ts +17 -0
- package/src/ui/core/layout_yoga.ts +122 -0
- package/src/ui/core/style.ts +38 -0
- package/src/ui/core/types.ts +53 -0
- package/src/ui/ink/index.tsx +1 -0
- package/src/ui/ink/render.tsx +49 -0
- package/src/ui/views/app.ts +99 -0
- package/src/ui/views/header.ts +42 -0
- package/src/ui/views/input_area.ts +244 -0
- package/src/ui/views/message_list.ts +427 -0
- package/src/ui/views/status_bar.ts +104 -0
- package/src/ui/vue/index.ts +53 -0
- package/src/utils/clipboard.ts +39 -0
- package/src/utils/clipboard_image.ts +40 -0
- package/src/utils/diff.ts +52 -0
- package/src/utils/image_preview.ts +36 -0
- package/src/utils/models.ts +98 -0
- package/src/utils/shell.ts +63 -0
- package/src/utils/tool_summary.ts +56 -0
- package/src/utils/tool_trace.ts +206 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +363 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
interface DiffLine {
|
|
2
|
+
type: 'context' | 'add' | 'remove';
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function buildSimpleDiff(before: string, after: string, maxLines = 120, context = 2): string {
|
|
7
|
+
const beforeLines = before.split('\n');
|
|
8
|
+
const afterLines = after.split('\n');
|
|
9
|
+
const maxLen = Math.max(beforeLines.length, afterLines.length);
|
|
10
|
+
|
|
11
|
+
const changes = new Set<number>();
|
|
12
|
+
for (let i = 0; i < maxLen; i += 1) {
|
|
13
|
+
const b = beforeLines[i];
|
|
14
|
+
const a = afterLines[i];
|
|
15
|
+
if (b !== a) {
|
|
16
|
+
changes.add(i);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const include = new Set<number>();
|
|
21
|
+
for (const idx of changes) {
|
|
22
|
+
for (let i = Math.max(0, idx - context); i <= idx + context; i += 1) {
|
|
23
|
+
include.add(i);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const lines: DiffLine[] = [];
|
|
28
|
+
for (let i = 0; i < maxLen; i += 1) {
|
|
29
|
+
if (!include.has(i)) continue;
|
|
30
|
+
const b = beforeLines[i];
|
|
31
|
+
const a = afterLines[i];
|
|
32
|
+
if (b === a) {
|
|
33
|
+
lines.push({ type: 'context', text: b || '' });
|
|
34
|
+
} else {
|
|
35
|
+
if (b !== undefined) lines.push({ type: 'remove', text: b || '' });
|
|
36
|
+
if (a !== undefined) lines.push({ type: 'add', text: a || '' });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const clipped = lines.slice(0, maxLines);
|
|
41
|
+
if (lines.length > maxLines) {
|
|
42
|
+
clipped.push({ type: 'context', text: '... diff truncated ...' });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return clipped
|
|
46
|
+
.map(line => {
|
|
47
|
+
if (line.type === 'add') return `+ ${line.text}`;
|
|
48
|
+
if (line.type === 'remove') return `- ${line.text}`;
|
|
49
|
+
return ` ${line.text}`;
|
|
50
|
+
})
|
|
51
|
+
.join('\n');
|
|
52
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
const cache = new Map<string, string[]>();
|
|
6
|
+
|
|
7
|
+
async function hasCommand(command: string): Promise<boolean> {
|
|
8
|
+
try {
|
|
9
|
+
await execFileAsync('which', [command]);
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function renderImagePreview(path: string, width = 40, height = 20): Promise<string[] | null> {
|
|
17
|
+
const key = `${path}:${width}x${height}`;
|
|
18
|
+
const cached = cache.get(key);
|
|
19
|
+
if (cached) return cached;
|
|
20
|
+
if (!(await hasCommand('chafa'))) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const { stdout } = await execFileAsync('chafa', [
|
|
25
|
+
'--colors=none',
|
|
26
|
+
'--symbols=block',
|
|
27
|
+
`--size=${width}x${height}`,
|
|
28
|
+
path
|
|
29
|
+
]);
|
|
30
|
+
const lines = stdout.split('\n').filter(line => line.length > 0);
|
|
31
|
+
cache.set(key, lines);
|
|
32
|
+
return lines;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
interface ListModelsOptions {
|
|
2
|
+
provider: string;
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async function parseList(response: Response): Promise<string[]> {
|
|
8
|
+
const data = await response.json() as Record<string, unknown>;
|
|
9
|
+
const array =
|
|
10
|
+
(Array.isArray(data.data) && data.data) ||
|
|
11
|
+
(Array.isArray(data.models) && data.models) ||
|
|
12
|
+
(Array.isArray(data.items) && data.items) ||
|
|
13
|
+
[];
|
|
14
|
+
|
|
15
|
+
const models = array
|
|
16
|
+
.map(item => {
|
|
17
|
+
if (typeof item === 'string') return item;
|
|
18
|
+
if (item && typeof item === 'object') {
|
|
19
|
+
const obj = item as Record<string, unknown>;
|
|
20
|
+
if (typeof obj.id === 'string') return obj.id;
|
|
21
|
+
if (typeof obj.name === 'string') return obj.name;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
})
|
|
25
|
+
.filter((value): value is string => typeof value === 'string');
|
|
26
|
+
|
|
27
|
+
return models;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function listModels(options: ListModelsOptions): Promise<string[]> {
|
|
31
|
+
const provider = options.provider;
|
|
32
|
+
const apiKey = options.apiKey || '';
|
|
33
|
+
|
|
34
|
+
if (!apiKey) {
|
|
35
|
+
throw new Error(`No API key configured for ${provider}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (provider === 'anthropic') {
|
|
39
|
+
const res = await fetch('https://api.anthropic.com/v1/models', {
|
|
40
|
+
headers: {
|
|
41
|
+
'x-api-key': apiKey,
|
|
42
|
+
'anthropic-version': '2023-06-01'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
if (!res.ok) {
|
|
46
|
+
throw new Error(`Anthropic error (${res.status})`);
|
|
47
|
+
}
|
|
48
|
+
return parseList(res);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (provider === 'openai') {
|
|
52
|
+
const res = await fetch('https://api.openai.com/v1/models', {
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: `Bearer ${apiKey}`
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
throw new Error(`OpenAI error (${res.status})`);
|
|
59
|
+
}
|
|
60
|
+
return parseList(res);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (provider === 'openai_compatible') {
|
|
64
|
+
const baseUrl = options.baseUrl || 'https://api.openai.com/v1';
|
|
65
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, '')}/models`, {
|
|
66
|
+
headers: {
|
|
67
|
+
Authorization: `Bearer ${apiKey}`
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (!res.ok) {
|
|
71
|
+
throw new Error(`OpenAI-compatible error (${res.status})`);
|
|
72
|
+
}
|
|
73
|
+
return parseList(res);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (provider === 'gemini') {
|
|
77
|
+
const res = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`);
|
|
78
|
+
if (!res.ok) {
|
|
79
|
+
throw new Error(`Gemini error (${res.status})`);
|
|
80
|
+
}
|
|
81
|
+
return parseList(res);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (provider === 'inception') {
|
|
85
|
+
const baseUrl = options.baseUrl || 'https://api.inception.ai/v1';
|
|
86
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, '')}/models`, {
|
|
87
|
+
headers: {
|
|
88
|
+
Authorization: `Bearer ${apiKey}`
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
throw new Error(`Inception error (${res.status})`);
|
|
93
|
+
}
|
|
94
|
+
return parseList(res);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
throw new Error(`Unknown provider: ${provider}`);
|
|
98
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { exec, ExecException } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { stat } from 'fs/promises';
|
|
5
|
+
|
|
6
|
+
import type { ShellResult } from '../agent/commands/types.js';
|
|
7
|
+
|
|
8
|
+
const execAsync = promisify(exec);
|
|
9
|
+
|
|
10
|
+
const MAX_BUFFER = 1024 * 1024;
|
|
11
|
+
const MAX_OUTPUT = 10000;
|
|
12
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
13
|
+
const DANGEROUS = ['rm -rf /', 'mkfs', ':(){:|:&};:'];
|
|
14
|
+
|
|
15
|
+
export async function runShellCommand(command: string, cwd: string): Promise<ShellResult> {
|
|
16
|
+
if (DANGEROUS.some(entry => command.includes(entry))) {
|
|
17
|
+
throw new Error('Command rejected for safety reasons');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const resolvedCwd = resolve(cwd);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
24
|
+
cwd: resolvedCwd,
|
|
25
|
+
timeout: DEFAULT_TIMEOUT_MS,
|
|
26
|
+
maxBuffer: MAX_BUFFER
|
|
27
|
+
});
|
|
28
|
+
const clippedStdout = stdout.slice(0, MAX_OUTPUT);
|
|
29
|
+
const clippedStderr = stderr.slice(0, MAX_OUTPUT);
|
|
30
|
+
return {
|
|
31
|
+
command,
|
|
32
|
+
cwd: resolvedCwd,
|
|
33
|
+
stdout: clippedStdout,
|
|
34
|
+
stderr: clippedStderr,
|
|
35
|
+
exitCode: 0,
|
|
36
|
+
truncated: stdout.length > MAX_OUTPUT || stderr.length > MAX_OUTPUT
|
|
37
|
+
};
|
|
38
|
+
} catch (err) {
|
|
39
|
+
const error = err as ExecException & { stdout?: string; stderr?: string; code?: number };
|
|
40
|
+
const stdout = String(error.stdout || '');
|
|
41
|
+
const stderr = String(error.stderr || error.message || '');
|
|
42
|
+
const clippedStdout = stdout.slice(0, MAX_OUTPUT);
|
|
43
|
+
const clippedStderr = stderr.slice(0, MAX_OUTPUT);
|
|
44
|
+
return {
|
|
45
|
+
command,
|
|
46
|
+
cwd: resolvedCwd,
|
|
47
|
+
stdout: clippedStdout,
|
|
48
|
+
stderr: clippedStderr,
|
|
49
|
+
exitCode: typeof error.code === 'number' ? error.code : 1,
|
|
50
|
+
truncated: stdout.length > MAX_OUTPUT || stderr.length > MAX_OUTPUT
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function resolveWorkingDir(current: string, target?: string): Promise<string> {
|
|
56
|
+
const base = current || process.cwd();
|
|
57
|
+
const next = target && target.trim().length > 0 ? resolve(base, target) : base;
|
|
58
|
+
const info = await stat(next);
|
|
59
|
+
if (!info.isDirectory()) {
|
|
60
|
+
throw new Error('Not a directory');
|
|
61
|
+
}
|
|
62
|
+
return next;
|
|
63
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
type ParsedResult = Record<string, unknown>;
|
|
2
|
+
|
|
3
|
+
function parseResult(raw: string): ParsedResult | null {
|
|
4
|
+
try {
|
|
5
|
+
const data = JSON.parse(raw) as ParsedResult;
|
|
6
|
+
if (data && typeof data === 'object') return data;
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function summarizeToolResult(tool: string, raw: string): string {
|
|
14
|
+
const parsed = parseResult(raw);
|
|
15
|
+
if (!parsed) {
|
|
16
|
+
const trimmed = raw.trim();
|
|
17
|
+
return trimmed.length > 140 ? `${trimmed.slice(0, 140)}...` : trimmed || 'Done';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (tool === 'read_file') {
|
|
21
|
+
const path = String(parsed.path || '');
|
|
22
|
+
const size = parsed.size ? ` (${parsed.size} bytes)` : '';
|
|
23
|
+
return `Read ${path}${size}`;
|
|
24
|
+
}
|
|
25
|
+
if (tool === 'write_file') {
|
|
26
|
+
const path = String(parsed.path || '');
|
|
27
|
+
const action = String(parsed.action || 'written');
|
|
28
|
+
return `Wrote ${path} (${action})`;
|
|
29
|
+
}
|
|
30
|
+
if (tool === 'list_directory') {
|
|
31
|
+
const path = String(parsed.path || '');
|
|
32
|
+
const entries = Array.isArray(parsed.entries) ? parsed.entries.length : 0;
|
|
33
|
+
return `Listed ${path} (${entries} items)`;
|
|
34
|
+
}
|
|
35
|
+
if (tool === 'run_command') {
|
|
36
|
+
const cwd = String(parsed.cwd || '');
|
|
37
|
+
const cmd = String(parsed.command || '');
|
|
38
|
+
return `Ran ${cmd}${cwd ? ` (cwd ${cwd})` : ''}`;
|
|
39
|
+
}
|
|
40
|
+
if (tool === 'search') {
|
|
41
|
+
const count = parsed.count ? String(parsed.count) : '0';
|
|
42
|
+
const path = String(parsed.path || '');
|
|
43
|
+
return `Found ${count} matches${path ? ` in ${path}` : ''}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const fallback = raw.trim();
|
|
47
|
+
return fallback.length > 140 ? `${fallback.slice(0, 140)}...` : fallback || 'Done';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function summarizeToolArgs(args: Record<string, unknown>): string {
|
|
51
|
+
const entries = Object.entries(args)
|
|
52
|
+
.map(([key, value]) => `${key}=${String(value)}`)
|
|
53
|
+
.slice(0, 3);
|
|
54
|
+
if (entries.length === 0) return '';
|
|
55
|
+
return `(${entries.join(', ')}${Object.keys(args).length > 3 ? ', ...' : ''})`;
|
|
56
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { getTraceStyle, TraceStyle } from '../emulation/trace_style.js';
|
|
2
|
+
|
|
3
|
+
const toolLabels: Record<string, string> = {
|
|
4
|
+
run_command: 'Bash',
|
|
5
|
+
read_file: 'Read',
|
|
6
|
+
write_file: 'Update',
|
|
7
|
+
list_directory: 'List',
|
|
8
|
+
search: 'Search'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function formatValue(value: unknown): string {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
const escaped = value.replace(/\n/g, '\\n');
|
|
14
|
+
return `"${escaped}"`;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
17
|
+
return String(value);
|
|
18
|
+
}
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function formatArgs(tool: string, args: Record<string, unknown>): string {
|
|
23
|
+
if (tool === 'run_command') {
|
|
24
|
+
const command = args.command ? String(args.command) : '';
|
|
25
|
+
const cwd = args.cwd ? `, cwd: ${formatValue(args.cwd)}` : '';
|
|
26
|
+
const timeout = args.timeout ? `, timeout: ${formatValue(args.timeout)}` : '';
|
|
27
|
+
return `(${command}${cwd}${timeout})`;
|
|
28
|
+
}
|
|
29
|
+
if (tool === 'search') {
|
|
30
|
+
const pattern = args.pattern ? `pattern: ${formatValue(args.pattern)}` : '';
|
|
31
|
+
const path = args.path ? `path: ${formatValue(args.path)}` : '';
|
|
32
|
+
const output = args.output_mode ? `output_mode: ${formatValue(args.output_mode)}` : '';
|
|
33
|
+
const parts = [pattern, path, output].filter(Boolean);
|
|
34
|
+
return parts.length ? `(${parts.join(', ')})` : '';
|
|
35
|
+
}
|
|
36
|
+
if (tool === 'read_file' || tool === 'write_file' || tool === 'list_directory') {
|
|
37
|
+
const path = args.path ? formatValue(args.path) : '""';
|
|
38
|
+
return `(${path})`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const entries = Object.entries(args).map(([key, value]) => `${key}: ${formatValue(value)}`);
|
|
42
|
+
return entries.length ? `(${entries.join(', ')})` : '';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseResult(raw: string): Record<string, unknown> | null {
|
|
46
|
+
try {
|
|
47
|
+
const data = JSON.parse(raw) as Record<string, unknown>;
|
|
48
|
+
if (data && typeof data === 'object') return data;
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function formatOutcome(tool: string, result: string, durationMs?: number): string {
|
|
56
|
+
const parsed = parseResult(result);
|
|
57
|
+
const duration = typeof durationMs === 'number' ? ` in ${(durationMs / 1000).toFixed(1)}s` : '';
|
|
58
|
+
|
|
59
|
+
if (parsed && tool === 'search') {
|
|
60
|
+
const count = typeof parsed.count === 'number' ? parsed.count : 0;
|
|
61
|
+
const label = count === 1 ? 'match' : 'matches';
|
|
62
|
+
return `Found ${count} ${label}${duration}`;
|
|
63
|
+
}
|
|
64
|
+
if (parsed && tool === 'run_command') {
|
|
65
|
+
const stdout = String(parsed.stdout || '');
|
|
66
|
+
const stderr = String(parsed.stderr || '');
|
|
67
|
+
const lines = (stdout || stderr).trim().split('\n').filter(Boolean).length;
|
|
68
|
+
const label = lines === 1 ? 'line' : 'lines';
|
|
69
|
+
return lines > 0 ? `Output ${lines} ${label}${duration}` : `Command finished${duration}`;
|
|
70
|
+
}
|
|
71
|
+
if (parsed && tool === 'read_file') {
|
|
72
|
+
const path = String(parsed.path || '');
|
|
73
|
+
const size = parsed.size ? `${parsed.size} bytes` : 'unknown size';
|
|
74
|
+
const truncated = parsed.truncated ? ' (truncated)' : '';
|
|
75
|
+
return `Read ${path} (${size})${duration}${truncated}`;
|
|
76
|
+
}
|
|
77
|
+
if (parsed && tool === 'write_file') {
|
|
78
|
+
const path = String(parsed.path || '');
|
|
79
|
+
const action = String(parsed.action || 'written');
|
|
80
|
+
return `Updated ${path} (${action})${duration}`;
|
|
81
|
+
}
|
|
82
|
+
if (parsed && tool === 'list_directory') {
|
|
83
|
+
const path = String(parsed.path || '');
|
|
84
|
+
const entries = Array.isArray(parsed.entries) ? parsed.entries.length : 0;
|
|
85
|
+
return `Listed ${path} (${entries} items)${duration}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return `Done${duration}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function buildOutputLines(tool: string, result: string): { lines: string[]; truncated: boolean } {
|
|
92
|
+
const parsed = parseResult(result);
|
|
93
|
+
if (!parsed) {
|
|
94
|
+
return { lines: [], truncated: false };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (tool === 'run_command') {
|
|
98
|
+
const stdout = String(parsed.stdout || '');
|
|
99
|
+
const stderr = String(parsed.stderr || '');
|
|
100
|
+
const combined = [stdout, stderr].filter(Boolean).join('\n');
|
|
101
|
+
const lines = combined.split('\n').filter(Boolean);
|
|
102
|
+
return { lines, truncated: Boolean(parsed.truncated) };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (tool === 'search') {
|
|
106
|
+
const matches = Array.isArray(parsed.matches) ? parsed.matches : [];
|
|
107
|
+
const lines = matches.map((entry: unknown) => {
|
|
108
|
+
if (!entry || typeof entry !== 'object') return '';
|
|
109
|
+
const row = entry as Record<string, unknown>;
|
|
110
|
+
const file = String(row.path || '');
|
|
111
|
+
const line = row.line ? `:${row.line}` : '';
|
|
112
|
+
const text = String(row.text || '');
|
|
113
|
+
return `${file}${line} ${text}`.trim();
|
|
114
|
+
}).filter(Boolean);
|
|
115
|
+
return { lines, truncated: Boolean(parsed.truncated) };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (tool === 'read_file') {
|
|
119
|
+
const content = String(parsed.content || '');
|
|
120
|
+
const lines = content.split('\n');
|
|
121
|
+
return { lines, truncated: Boolean(parsed.truncated) };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (tool === 'write_file') {
|
|
125
|
+
const diff = typeof parsed.diff === 'string' ? parsed.diff : '';
|
|
126
|
+
const lines = diff ? diff.split('\n') : [];
|
|
127
|
+
return { lines, truncated: Boolean(parsed.truncated) };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { lines: [], truncated: false };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function formatToolStart(tool: string, args: Record<string, unknown>, emulationId?: string): string {
|
|
134
|
+
const style = getTraceStyle(emulationId);
|
|
135
|
+
const label = toolLabels[tool] || tool;
|
|
136
|
+
const argsText = formatArgs(tool, args);
|
|
137
|
+
if (style === 'claude_code') {
|
|
138
|
+
return `⏺ ${label}${argsText}`;
|
|
139
|
+
}
|
|
140
|
+
if (style === 'codex') {
|
|
141
|
+
return `• ${label}${argsText}`;
|
|
142
|
+
}
|
|
143
|
+
return `> ${label}${argsText}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function formatToolEnd(tool: string, result: string, durationMs?: number, emulationId?: string): string {
|
|
147
|
+
const style = getTraceStyle(emulationId);
|
|
148
|
+
const summary = formatOutcome(tool, result, durationMs);
|
|
149
|
+
if (style === 'claude_code') {
|
|
150
|
+
return `⎿ ${summary}`;
|
|
151
|
+
}
|
|
152
|
+
if (style === 'codex') {
|
|
153
|
+
return ` ${summary}`;
|
|
154
|
+
}
|
|
155
|
+
return `< ${summary}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function formatToolError(tool: string, error: string, emulationId?: string): string {
|
|
159
|
+
const style = getTraceStyle(emulationId);
|
|
160
|
+
if (style === 'claude_code') {
|
|
161
|
+
return `⎿ ${tool} failed: ${error}`;
|
|
162
|
+
}
|
|
163
|
+
if (style === 'codex') {
|
|
164
|
+
return ` ${tool} failed: ${error}`;
|
|
165
|
+
}
|
|
166
|
+
return `< ${tool} failed: ${error}`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function buildToolOutputMessage(
|
|
170
|
+
tool: string,
|
|
171
|
+
result: string,
|
|
172
|
+
durationMs?: number,
|
|
173
|
+
emulationId?: string
|
|
174
|
+
): { preview: string; full: string; truncated: boolean } {
|
|
175
|
+
const { lines, truncated } = buildOutputLines(tool, result);
|
|
176
|
+
if (lines.length === 0) {
|
|
177
|
+
const summary = formatToolEnd(tool, result, durationMs, emulationId);
|
|
178
|
+
return { preview: summary, full: summary, truncated: false };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const maxLines = 8;
|
|
182
|
+
const previewLines = lines.slice(0, maxLines);
|
|
183
|
+
const remaining = lines.length - previewLines.length;
|
|
184
|
+
const expandHint = truncated || remaining > 0 ? ' (ctrl+o to expand)' : '';
|
|
185
|
+
|
|
186
|
+
const summary = formatToolEnd(tool, result, durationMs, emulationId);
|
|
187
|
+
const previewBlock = [
|
|
188
|
+
summary,
|
|
189
|
+
...previewLines.map(line => ` ${line}`)
|
|
190
|
+
];
|
|
191
|
+
if (expandHint) {
|
|
192
|
+
const extraLabel = remaining > 0 ? `… +${remaining} lines` : '…';
|
|
193
|
+
previewBlock.push(` ${extraLabel}${expandHint}`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const fullBlock = [
|
|
197
|
+
summary,
|
|
198
|
+
...lines.map(line => ` ${line}`)
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
preview: previewBlock.join('\n'),
|
|
203
|
+
full: fullBlock.join('\n'),
|
|
204
|
+
truncated: Boolean(expandHint)
|
|
205
|
+
};
|
|
206
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"jsx": "react-jsx",
|
|
18
|
+
"jsxImportSource": "react"
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*"],
|
|
21
|
+
"exclude": ["node_modules", "dist"]
|
|
22
|
+
}
|