@travisennis/acai 0.0.6 → 0.0.8
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 +225 -39
- package/dist/agent/index.d.ts +30 -21
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +237 -198
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -18
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/add-directory/index.js +50 -0
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +1 -7
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/copy/index.js +39 -0
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/exit/index.d.ts +10 -0
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +65 -147
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/handoff/utils.js +123 -0
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/help/index.d.ts +3 -0
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +6 -14
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +40 -200
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +17 -27
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +2 -15
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/list-tools/index.js +89 -0
- package/dist/commands/manager.d.ts +2 -9
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +38 -83
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/model/index.js +182 -0
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/paste/index.d.ts +3 -0
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/paste/index.js +94 -0
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +126 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +3 -35
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +8 -11
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -10
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +4 -51
- package/dist/commands/types.d.ts +2 -5
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +36 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -60
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +18 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +119 -81
- package/dist/formatting.d.ts +46 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +94 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -177
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +0 -7
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -28
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +148 -139
- package/dist/models/providers.d.ts +6 -16
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +8 -58
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +8 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +155 -177
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +15 -6
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +266 -83
- package/dist/{messages.d.ts → sessions/manager.d.ts} +13 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +126 -16
- package/dist/skills.d.ts +16 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +233 -0
- package/dist/terminal/control.d.ts +56 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +111 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -26
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -53
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -101
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -464
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +11 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +189 -81
- package/dist/tools/directory-tree.d.ts +9 -13
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +90 -60
- package/dist/tools/dynamic-tool-loader.d.ts +22 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +41 -46
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +22 -66
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +78 -109
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -93
- package/dist/tools/index.d.ts +202 -167
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -273
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +52 -76
- package/dist/tools/save-file.d.ts +8 -8
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +42 -53
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -32
- package/dist/tools/types.d.ts +5 -21
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/assistant-message.js +1 -1
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +87 -0
- package/dist/tui/components/editor.d.ts +61 -7
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +630 -127
- package/dist/tui/components/footer.d.ts +19 -18
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +90 -185
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +6 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +8 -3
- package/dist/tui/components/markdown.d.ts +31 -27
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +131 -67
- package/dist/tui/components/modal.d.ts +0 -11
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -37
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +63 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +66 -0
- package/dist/tui/components/select-list.d.ts +12 -1
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +73 -32
- package/dist/tui/components/spacer.d.ts +1 -1
- package/dist/tui/components/spacer.d.ts.map +1 -1
- package/dist/tui/components/spacer.js +2 -2
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +4 -1
- package/dist/tui/components/tool-execution.d.ts +7 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +81 -85
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +6 -4
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/index.d.ts +12 -6
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +7 -3
- package/dist/tui/terminal.d.ts +4 -3
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +43 -49
- package/dist/tui/tui.d.ts +3 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +58 -43
- package/dist/tui/utils.d.ts +5 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +80 -1
- package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +2 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +24 -0
- package/package.json +31 -29
- package/dist/agent/manual-loop.d.ts +0 -41
- package/dist/agent/manual-loop.d.ts.map +0 -1
- package/dist/agent/manual-loop.js +0 -278
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/add-directory-command.js +0 -85
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -79
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -64
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -183
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/copy-command.js +0 -80
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -88
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -61
- package/dist/commands/exit-command.d.ts +0 -13
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -46
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -121
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.js +0 -202
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -213
- package/dist/commands/help-command.d.ts +0 -3
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -98
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.js +0 -124
- package/dist/commands/model-command.d.ts +0 -25
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/model-command.js +0 -340
- package/dist/commands/paste-command.d.ts +0 -3
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/paste-command.js +0 -277
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -161
- package/dist/commands/prompt-command.d.ts +0 -3
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -280
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -135
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -42
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -58
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -9
- package/dist/repl/project-status-line.d.ts +0 -2
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -31
- package/dist/repl/prompt.d.ts +0 -21
- package/dist/repl/prompt.d.ts.map +0 -1
- package/dist/repl/prompt.js +0 -244
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/repl.d.ts +0 -29
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -218
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -368
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -17
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -118
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -280
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/tokens/threshold.d.ts +0 -35
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -85
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -281
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -103
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -167
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -70
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.d.ts +0 -25
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -150
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -58
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -139
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -133
- package/dist/tui/components/prompt-status.d.ts +0 -16
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -21
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- package/dist/utils/zod-utils.js +0 -7
- /package/dist/{terminal → commands/add-directory}/types.js +0 -0
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
export function parseYaml(input) {
|
|
2
|
+
const lines = input.split("\n");
|
|
3
|
+
const result = {};
|
|
4
|
+
let i = 0;
|
|
5
|
+
while (i < lines.length) {
|
|
6
|
+
const line = lines[i];
|
|
7
|
+
const trimmed = line.trim();
|
|
8
|
+
// Skip empty lines and comments
|
|
9
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
10
|
+
i++;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
// Check for key-value pair
|
|
14
|
+
const colonIndex = line.indexOf(":");
|
|
15
|
+
if (colonIndex === -1) {
|
|
16
|
+
i++;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const indent = getIndent(line);
|
|
20
|
+
const key = line.slice(0, colonIndex).trim();
|
|
21
|
+
const afterColon = line.slice(colonIndex + 1).trim();
|
|
22
|
+
if (afterColon) {
|
|
23
|
+
// Inline value
|
|
24
|
+
result[key] = parseValue(afterColon);
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Check next line for nested content
|
|
29
|
+
i++;
|
|
30
|
+
if (i < lines.length) {
|
|
31
|
+
const nextLine = lines[i];
|
|
32
|
+
const nextIndent = getIndent(nextLine);
|
|
33
|
+
const nextTrimmed = nextLine.trim();
|
|
34
|
+
if (nextTrimmed.startsWith("-")) {
|
|
35
|
+
// Array
|
|
36
|
+
const [arr, newIndex] = parseArray(lines, i, nextIndent);
|
|
37
|
+
result[key] = arr;
|
|
38
|
+
i = newIndex;
|
|
39
|
+
}
|
|
40
|
+
else if (nextIndent > indent && nextTrimmed.includes(":")) {
|
|
41
|
+
// Nested object
|
|
42
|
+
const [obj, newIndex] = parseObject(lines, i, nextIndent);
|
|
43
|
+
result[key] = obj;
|
|
44
|
+
i = newIndex;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
result[key] = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
result[key] = null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
function parseObject(lines, start, baseIndent) {
|
|
58
|
+
const obj = {};
|
|
59
|
+
let i = start;
|
|
60
|
+
while (i < lines.length) {
|
|
61
|
+
const line = lines[i];
|
|
62
|
+
const indent = getIndent(line);
|
|
63
|
+
const trimmed = line.trim();
|
|
64
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
65
|
+
i++;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (indent < baseIndent) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
if (indent === baseIndent) {
|
|
72
|
+
const colonIndex = line.indexOf(":");
|
|
73
|
+
if (colonIndex === -1) {
|
|
74
|
+
i++;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const key = line.slice(0, colonIndex).trim();
|
|
78
|
+
const afterColon = line.slice(colonIndex + 1).trim();
|
|
79
|
+
if (afterColon) {
|
|
80
|
+
obj[key] = parseValue(afterColon);
|
|
81
|
+
i++;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
i++;
|
|
85
|
+
if (i < lines.length) {
|
|
86
|
+
const nextLine = lines[i];
|
|
87
|
+
const nextIndent = getIndent(nextLine);
|
|
88
|
+
const nextTrimmed = nextLine.trim();
|
|
89
|
+
if (nextTrimmed.startsWith("-")) {
|
|
90
|
+
const [arr, newIndex] = parseArray(lines, i, nextIndent);
|
|
91
|
+
obj[key] = arr;
|
|
92
|
+
i = newIndex;
|
|
93
|
+
}
|
|
94
|
+
else if (nextIndent > indent && nextTrimmed.includes(":")) {
|
|
95
|
+
const [nested, newIndex] = parseObject(lines, i, nextIndent);
|
|
96
|
+
obj[key] = nested;
|
|
97
|
+
i = newIndex;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
obj[key] = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
obj[key] = null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
i++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return [obj, i];
|
|
113
|
+
}
|
|
114
|
+
function parseArray(lines, start, baseIndent) {
|
|
115
|
+
const arr = [];
|
|
116
|
+
let i = start;
|
|
117
|
+
while (i < lines.length) {
|
|
118
|
+
const line = lines[i];
|
|
119
|
+
const indent = getIndent(line);
|
|
120
|
+
const trimmed = line.trim();
|
|
121
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
122
|
+
i++;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (indent < baseIndent) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (indent === baseIndent && trimmed.startsWith("-")) {
|
|
129
|
+
const afterDash = trimmed.slice(1).trim();
|
|
130
|
+
if (afterDash) {
|
|
131
|
+
// Inline array item
|
|
132
|
+
arr.push(parseValue(afterDash));
|
|
133
|
+
i++;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// Check next line for nested content
|
|
137
|
+
i++;
|
|
138
|
+
if (i < lines.length) {
|
|
139
|
+
const nextLine = lines[i];
|
|
140
|
+
const nextIndent = getIndent(nextLine);
|
|
141
|
+
const nextTrimmed = nextLine.trim();
|
|
142
|
+
if (nextTrimmed.includes(":")) {
|
|
143
|
+
const [obj, newIndex] = parseObject(lines, i, nextIndent);
|
|
144
|
+
arr.push(obj);
|
|
145
|
+
i = newIndex;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
i++;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
i++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return [arr, i];
|
|
158
|
+
}
|
|
159
|
+
function parseValue(value) {
|
|
160
|
+
// Handle quoted strings
|
|
161
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
162
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
163
|
+
return value.slice(1, -1);
|
|
164
|
+
}
|
|
165
|
+
// Handle booleans
|
|
166
|
+
if (value === "true")
|
|
167
|
+
return true;
|
|
168
|
+
if (value === "false")
|
|
169
|
+
return false;
|
|
170
|
+
// Handle null
|
|
171
|
+
if (value === "null" || value === "~")
|
|
172
|
+
return null;
|
|
173
|
+
// Handle numbers
|
|
174
|
+
if (/^-?\d+$/.test(value)) {
|
|
175
|
+
return Number.parseInt(value, 10);
|
|
176
|
+
}
|
|
177
|
+
if (/^-?\d+\.\d+$/.test(value)) {
|
|
178
|
+
return Number.parseFloat(value);
|
|
179
|
+
}
|
|
180
|
+
// Default to string
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
function getIndent(line) {
|
|
184
|
+
const match = line.match(/^(\s*)/);
|
|
185
|
+
return match ? match[1].length : 0;
|
|
186
|
+
}
|
|
187
|
+
// Helper function to extract and parse Yaml front matter from markdown
|
|
188
|
+
export function parseFrontMatter(markdown) {
|
|
189
|
+
const lines = markdown.split("\n");
|
|
190
|
+
if (lines[0] !== "---") {
|
|
191
|
+
return { data: {}, content: markdown };
|
|
192
|
+
}
|
|
193
|
+
let endIndex = -1;
|
|
194
|
+
for (let i = 1; i < lines.length; i++) {
|
|
195
|
+
if (lines[i] === "---" || lines[i] === "...") {
|
|
196
|
+
endIndex = i;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (endIndex === -1) {
|
|
201
|
+
return { data: {}, content: markdown };
|
|
202
|
+
}
|
|
203
|
+
const yamlContent = lines.slice(1, endIndex).join("\n");
|
|
204
|
+
const data = parseYaml(yamlContent);
|
|
205
|
+
const content = lines.slice(endIndex + 1).join("\n");
|
|
206
|
+
return { data, content };
|
|
207
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ZodType } from "zod";
|
|
2
2
|
export declare function isZodSchema(obj: unknown): obj is ZodType<unknown>;
|
|
3
3
|
export declare function zodToJsonSchema(schema: ZodType<unknown>): Record<string, unknown>;
|
|
4
|
-
|
|
4
|
+
export declare const convertNullString: (value: unknown) => unknown;
|
|
5
|
+
//# sourceMappingURL=zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../source/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEjC,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAEjE;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAID,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,OAgBlD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import z, { ZodType } from "zod";
|
|
2
|
+
export function isZodSchema(obj) {
|
|
3
|
+
return obj instanceof ZodType;
|
|
4
|
+
}
|
|
5
|
+
export function zodToJsonSchema(schema) {
|
|
6
|
+
return z.toJSONSchema(schema);
|
|
7
|
+
}
|
|
8
|
+
// Many models do not reliably pass null to optional tool fields. Instead they pass "null", "None", "undefined", or empty strings.
|
|
9
|
+
// This function will coerce all of those values into null.
|
|
10
|
+
export const convertNullString = (value) => {
|
|
11
|
+
if (typeof value === "undefined") {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === "string") {
|
|
15
|
+
const trimmed = value.trim();
|
|
16
|
+
if (trimmed.toLowerCase() === "null" ||
|
|
17
|
+
trimmed.toLowerCase() === "none" ||
|
|
18
|
+
trimmed.toLowerCase() === "undefined" ||
|
|
19
|
+
trimmed === "") {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travisennis/acai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "An AI assistant for developing software.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
|
+
"bin",
|
|
14
15
|
"README.md",
|
|
15
16
|
"LICENSE"
|
|
16
17
|
],
|
|
@@ -33,57 +34,58 @@
|
|
|
33
34
|
"format:staged": "biome check --staged --formatter-enabled=true --linter-enabled=false --no-errors-on-unmatched",
|
|
34
35
|
"prepack": "npm run clean && npm run build",
|
|
35
36
|
"prepare": "husky",
|
|
36
|
-
"test": "node --no-warnings --test test/**/*.test.ts",
|
|
37
|
-
"test:minimal": "node --no-warnings --test --test-reporter=dot test/**/*.test.ts",
|
|
38
|
-
"test:coverage": "c8 node --no-warnings --test test/**/*.test.ts",
|
|
39
|
-
"test:full-coverage": "c8 --all node --no-warnings --test test/**/*.test.ts",
|
|
37
|
+
"test": "node --no-warnings --require ./test/setup.js --test test/**/*.test.ts",
|
|
38
|
+
"test:minimal": "node --no-warnings --require ./test/setup.js --test --test-reporter=dot test/**/*.test.ts",
|
|
39
|
+
"test:coverage": "c8 node --no-warnings --require ./test/setup.js --test test/**/*.test.ts",
|
|
40
|
+
"test:full-coverage": "c8 --all node --no-warnings --require ./test/setup.js --test test/**/*.test.ts",
|
|
40
41
|
"pretest": "npm run typecheck",
|
|
41
42
|
"format": "biome check --formatter-enabled=true --linter-enabled=false --write ./ && biome format --write",
|
|
42
43
|
"dev": "node --no-warnings --env-file=.env ./source/index.ts",
|
|
43
|
-
"oxlint": "
|
|
44
|
+
"oxlint": "npm run oxlint:single -- ./source",
|
|
45
|
+
"oxlint:single": "oxlint --type-aware --ignore-path .gitignore -A all -c .oxlintrc.json",
|
|
44
46
|
"knip": "npx knip",
|
|
45
|
-
"
|
|
47
|
+
"knip:prod": "npx knip --production",
|
|
48
|
+
"update": "npx npm-check-updates --interactive --format group",
|
|
46
49
|
"cpd": "npx jscpd ./source",
|
|
47
50
|
"typecheck": "tsc --noEmit --pretty -p tsconfig.json",
|
|
48
|
-
"typecheck:staged": "npm run typecheck"
|
|
51
|
+
"typecheck:staged": "npm run typecheck",
|
|
52
|
+
"check": "npm run typecheck && npm run lint:fix && npm run format"
|
|
49
53
|
},
|
|
50
54
|
"dependencies": {
|
|
51
|
-
"@ai-sdk/anthropic": "^
|
|
52
|
-
"@ai-sdk/deepseek": "^
|
|
53
|
-
"@ai-sdk/google": "^
|
|
54
|
-
"@ai-sdk/groq": "^
|
|
55
|
-
"@ai-sdk/openai": "^
|
|
56
|
-
"@ai-sdk/openai-compatible": "^
|
|
55
|
+
"@ai-sdk/anthropic": "^3.0.12",
|
|
56
|
+
"@ai-sdk/deepseek": "^2.0.5",
|
|
57
|
+
"@ai-sdk/google": "^3.0.7",
|
|
58
|
+
"@ai-sdk/groq": "^3.0.6",
|
|
59
|
+
"@ai-sdk/openai": "^3.0.9",
|
|
60
|
+
"@ai-sdk/openai-compatible": "^2.0.8",
|
|
57
61
|
"@crosscopy/clipboard": "^0.2.8",
|
|
58
|
-
"@openrouter/ai-sdk-provider": "^1.2.5",
|
|
59
62
|
"@travisennis/stdlib": "^0.0.14",
|
|
60
|
-
"ai": "^
|
|
61
|
-
"
|
|
62
|
-
"cli-table3": "^0.6.5",
|
|
63
|
-
"diff": "^8.0.2",
|
|
64
|
-
"duck-duck-scrape": "^2.2.7",
|
|
63
|
+
"ai": "^6.0.33",
|
|
64
|
+
"diff": "^8.0.3",
|
|
65
65
|
"fast-glob": "^3.3.3",
|
|
66
|
+
"fdir": "^6.5.0",
|
|
66
67
|
"highlight.js": "^11.11.1",
|
|
67
|
-
"jsonrepair": "^3.13.1",
|
|
68
68
|
"marked": "17.0.1",
|
|
69
69
|
"p-throttle": "^8.1.0",
|
|
70
70
|
"parse5": "^8.0.0",
|
|
71
71
|
"parse5-htmlparser2-tree-adapter": "^8.0.0",
|
|
72
|
-
"pino": "^10.1.
|
|
73
|
-
"pino-pretty": "^13.1.
|
|
72
|
+
"pino": "^10.1.1",
|
|
73
|
+
"pino-pretty": "^13.1.3",
|
|
74
74
|
"pino-roll": "^4.0.0",
|
|
75
75
|
"tiktoken": "^1.0.22",
|
|
76
|
-
"zod": "^4.
|
|
76
|
+
"zod": "^4.3.5"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@ai-sdk/provider": "^
|
|
80
|
-
"@biomejs/biome": "2.3.
|
|
81
|
-
"@commitlint/config-conventional": "^20.
|
|
82
|
-
"@types/node": "^
|
|
79
|
+
"@ai-sdk/provider": "^3.0.2",
|
|
80
|
+
"@biomejs/biome": "2.3.11",
|
|
81
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
82
|
+
"@types/node": "^25.0.8",
|
|
83
83
|
"c8": "^10.1.3",
|
|
84
|
-
"commitlint": "^20.1
|
|
84
|
+
"commitlint": "^20.3.1",
|
|
85
85
|
"domhandler": "^5.0.3",
|
|
86
86
|
"husky": "^9.1.7",
|
|
87
|
+
"oxlint": "^1.39.0",
|
|
88
|
+
"oxlint-tsgolint": "^0.11.0",
|
|
87
89
|
"typescript": "^5.9.3"
|
|
88
90
|
},
|
|
89
91
|
"engines": {
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { LanguageModelUsage, ToolExecuteFunction } from "ai";
|
|
2
|
-
import { type ToolCallRepairFunction } from "ai";
|
|
3
|
-
import type { MessageHistory } from "../messages.ts";
|
|
4
|
-
import type { ModelManager } from "../models/manager.ts";
|
|
5
|
-
import type { Terminal } from "../terminal/index.ts";
|
|
6
|
-
import type { CompleteToolSet } from "../tools/index.ts";
|
|
7
|
-
type ManualLoopOptions = {
|
|
8
|
-
modelManager: ModelManager;
|
|
9
|
-
terminal: Terminal;
|
|
10
|
-
messageHistory: MessageHistory;
|
|
11
|
-
systemPrompt: string;
|
|
12
|
-
input: string;
|
|
13
|
-
toolDefs: CompleteToolSet;
|
|
14
|
-
executors: Map<keyof CompleteToolSet, ToolExecuteFunction<unknown, string>>;
|
|
15
|
-
maxIterations?: number;
|
|
16
|
-
maxRetries?: number;
|
|
17
|
-
abortSignal?: AbortSignal;
|
|
18
|
-
toolCallRepair?: ToolCallRepairFunction<CompleteToolSet>;
|
|
19
|
-
};
|
|
20
|
-
type ManualLoopResult = {
|
|
21
|
-
steps: {
|
|
22
|
-
toolResults: Array<{
|
|
23
|
-
toolName: string;
|
|
24
|
-
}>;
|
|
25
|
-
toolCalls: Array<{
|
|
26
|
-
toolName: string;
|
|
27
|
-
}>;
|
|
28
|
-
}[];
|
|
29
|
-
usage: {
|
|
30
|
-
[K in keyof LanguageModelUsage]-?: number;
|
|
31
|
-
};
|
|
32
|
-
totalUsage: {
|
|
33
|
-
[K in keyof LanguageModelUsage]-?: number;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export declare function runManualLoop(opts: ManualLoopOptions): Promise<ManualLoopResult>;
|
|
37
|
-
export declare function consumeToolAsyncIterable(iterable: AsyncIterable<unknown>, terminal?: Terminal): Promise<{
|
|
38
|
-
finalValue: unknown;
|
|
39
|
-
}>;
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=manual-loop.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manual-loop.d.ts","sourceRoot":"","sources":["../../source/agent/manual-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,IAAI,CAAC;AAEZ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,GAAG,CAAC,MAAM,eAAe,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,cAAc,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC,CAAC;CAC1D,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE;QACL,WAAW,EAAE,KAAK,CAAC;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACzC,SAAS,EAAE,KAAK,CAAC;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACxC,EAAE,CAAC;IACJ,KAAK,EAAE;SAAG,CAAC,IAAI,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM;KAAE,CAAC;IACrD,UAAU,EAAE;SAAG,CAAC,IAAI,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM;KAAE,CAAC;CAC3D,CAAC;AAEF,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAoS3B;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,EAChC,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAuBlC"}
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { NoOutputGeneratedError, streamText, } from "ai";
|
|
2
|
-
import { logger } from "../logger.js";
|
|
3
|
-
import { AiConfig } from "../models/ai-config.js";
|
|
4
|
-
import { displayToolMessages } from "../repl/display-tool-messages.js";
|
|
5
|
-
import style from "../terminal/style.js";
|
|
6
|
-
import { isToolMessage } from "../tools/types.js";
|
|
7
|
-
import { isAsyncIterable } from "../utils/iterables.js";
|
|
8
|
-
export async function runManualLoop(opts) {
|
|
9
|
-
const { modelManager, messageHistory, systemPrompt, input, toolDefs, executors, maxIterations = 90, maxRetries = 2, abortSignal, toolCallRepair, } = opts;
|
|
10
|
-
const terminal = opts.terminal;
|
|
11
|
-
const langModel = modelManager.getModel("repl");
|
|
12
|
-
const modelConfig = modelManager.getModelMetadata("repl");
|
|
13
|
-
const aiConfig = new AiConfig({
|
|
14
|
-
modelMetadata: modelConfig,
|
|
15
|
-
prompt: input,
|
|
16
|
-
});
|
|
17
|
-
const loopResult = {
|
|
18
|
-
usage: {
|
|
19
|
-
inputTokens: 0,
|
|
20
|
-
outputTokens: 0,
|
|
21
|
-
totalTokens: 0,
|
|
22
|
-
reasoningTokens: 0,
|
|
23
|
-
cachedInputTokens: 0,
|
|
24
|
-
},
|
|
25
|
-
totalUsage: {
|
|
26
|
-
inputTokens: 0,
|
|
27
|
-
outputTokens: 0,
|
|
28
|
-
totalTokens: 0,
|
|
29
|
-
reasoningTokens: 0,
|
|
30
|
-
cachedInputTokens: 0,
|
|
31
|
-
},
|
|
32
|
-
steps: [],
|
|
33
|
-
};
|
|
34
|
-
let iter = 0;
|
|
35
|
-
let consecutiveErrors = 0;
|
|
36
|
-
while (iter < maxIterations) {
|
|
37
|
-
if (abortSignal?.aborted) {
|
|
38
|
-
logger.warn("The agent loop was aborted by the user.");
|
|
39
|
-
terminal.warn("Operation aborted by user.");
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const result = streamText({
|
|
44
|
-
model: langModel,
|
|
45
|
-
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
46
|
-
system: systemPrompt,
|
|
47
|
-
messages: messageHistory.get(),
|
|
48
|
-
temperature: aiConfig.temperature(),
|
|
49
|
-
topP: aiConfig.topP(),
|
|
50
|
-
maxRetries: 2,
|
|
51
|
-
providerOptions: aiConfig.providerOptions(),
|
|
52
|
-
tools: toolDefs,
|
|
53
|
-
// biome-ignore lint/style/useNamingConvention: third-party code
|
|
54
|
-
experimental_repairToolCall: toolCallRepair,
|
|
55
|
-
abortSignal,
|
|
56
|
-
});
|
|
57
|
-
let accumulatedText = "";
|
|
58
|
-
let lastType = null;
|
|
59
|
-
for await (const chunk of result.fullStream) {
|
|
60
|
-
if (chunk.type === "reasoning-delta" || chunk.type === "text-delta") {
|
|
61
|
-
if (chunk.type === "reasoning-delta") {
|
|
62
|
-
if (lastType !== "reasoning") {
|
|
63
|
-
terminal.writeln(style.dim("<think>"));
|
|
64
|
-
}
|
|
65
|
-
terminal.write(style.dim(chunk.text));
|
|
66
|
-
lastType = "reasoning";
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
terminal.stopProgress();
|
|
70
|
-
if (lastType === "reasoning") {
|
|
71
|
-
terminal.writeln(style.dim("\n</think>\n"));
|
|
72
|
-
}
|
|
73
|
-
accumulatedText += chunk.text;
|
|
74
|
-
lastType = "text";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// finish off this step
|
|
79
|
-
if (lastType === "reasoning") {
|
|
80
|
-
terminal.write(style.dim("\n</think>\n\n"));
|
|
81
|
-
}
|
|
82
|
-
terminal.stopProgress();
|
|
83
|
-
if (accumulatedText.trim()) {
|
|
84
|
-
terminal.writeln(`${style.blue.bold("● Response:")}`);
|
|
85
|
-
terminal.display(accumulatedText, true);
|
|
86
|
-
terminal.lineBreak();
|
|
87
|
-
}
|
|
88
|
-
accumulatedText = "";
|
|
89
|
-
lastType = null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// Get response and tool calls
|
|
93
|
-
const response = await result.response;
|
|
94
|
-
const responseMessages = response.messages;
|
|
95
|
-
messageHistory.appendResponseMessages(responseMessages);
|
|
96
|
-
const toolCalls = await result.toolCalls;
|
|
97
|
-
const thisStepToolCalls = [];
|
|
98
|
-
const thisStepToolResults = [];
|
|
99
|
-
loopResult.steps.push({
|
|
100
|
-
toolCalls: thisStepToolCalls,
|
|
101
|
-
toolResults: thisStepToolResults,
|
|
102
|
-
});
|
|
103
|
-
// If finishReason is not tool-calls, break
|
|
104
|
-
const finishReason = await result.finishReason;
|
|
105
|
-
if (finishReason !== "tool-calls") {
|
|
106
|
-
const lastStepUsage = await result.usage;
|
|
107
|
-
loopResult.usage.inputTokens = lastStepUsage.inputTokens ?? 0;
|
|
108
|
-
loopResult.usage.outputTokens = lastStepUsage.outputTokens ?? 0;
|
|
109
|
-
loopResult.usage.totalTokens = lastStepUsage.totalTokens ?? 0;
|
|
110
|
-
loopResult.usage.cachedInputTokens =
|
|
111
|
-
lastStepUsage.cachedInputTokens ?? 0;
|
|
112
|
-
loopResult.usage.reasoningTokens = lastStepUsage.reasoningTokens ?? 0;
|
|
113
|
-
loopResult.totalUsage.inputTokens += lastStepUsage.inputTokens ?? 0;
|
|
114
|
-
loopResult.totalUsage.outputTokens += lastStepUsage.outputTokens ?? 0;
|
|
115
|
-
loopResult.totalUsage.totalTokens += lastStepUsage.totalTokens ?? 0;
|
|
116
|
-
loopResult.totalUsage.cachedInputTokens +=
|
|
117
|
-
lastStepUsage.cachedInputTokens ?? 0;
|
|
118
|
-
loopResult.totalUsage.reasoningTokens +=
|
|
119
|
-
lastStepUsage.reasoningTokens ?? 0;
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
// Execute tools in parallel (order not guaranteed)
|
|
123
|
-
// Check response.messages for already-processed tool results
|
|
124
|
-
const alreadyProcessedToolCallIds = new Set();
|
|
125
|
-
// Look for tool results and tool errors in the response messages
|
|
126
|
-
for (const message of responseMessages) {
|
|
127
|
-
if (message.role === "tool" && Array.isArray(message.content)) {
|
|
128
|
-
for (const content of message.content) {
|
|
129
|
-
if ((content.type === "tool-result" ||
|
|
130
|
-
content.type === "tool-error") &&
|
|
131
|
-
content.toolCallId) {
|
|
132
|
-
alreadyProcessedToolCallIds.add(content.toolCallId);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// Filter out tool calls that have already been processed or are invalid
|
|
138
|
-
const validToolCalls = toolCalls.filter((call) => !alreadyProcessedToolCallIds.has(call.toolCallId) &&
|
|
139
|
-
// Also check if the tool call is marked as invalid by the AI SDK
|
|
140
|
-
!call.invalid);
|
|
141
|
-
if (validToolCalls.length === 0) {
|
|
142
|
-
// All tool calls were already processed by the AI SDK
|
|
143
|
-
logger.debug(`All ${toolCalls.length} tool calls were already processed by AI SDK, skipping manual execution`);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (validToolCalls.length < toolCalls.length) {
|
|
147
|
-
logger.debug(`Filtered out ${toolCalls.length - validToolCalls.length} already-processed tool calls, executing ${validToolCalls.length} remaining`);
|
|
148
|
-
}
|
|
149
|
-
// Process all tools concurrently
|
|
150
|
-
const toolMessagesPromise = Promise.allSettled(validToolCalls.map(async (call) => {
|
|
151
|
-
const toolName = call.toolName;
|
|
152
|
-
let resultOutput = "Unknown result.";
|
|
153
|
-
try {
|
|
154
|
-
thisStepToolCalls.push({ toolName });
|
|
155
|
-
thisStepToolResults.push({ toolName });
|
|
156
|
-
const exec = executors.get(toolName);
|
|
157
|
-
if (!exec) {
|
|
158
|
-
resultOutput = `No executor for tool ${toolName}`;
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
try {
|
|
162
|
-
const output = await exec(call.input, {
|
|
163
|
-
toolCallId: call.toolCallId,
|
|
164
|
-
messages: messageHistory.get(),
|
|
165
|
-
abortSignal,
|
|
166
|
-
});
|
|
167
|
-
if (isAsyncIterable(output)) {
|
|
168
|
-
const { finalValue } = await consumeToolAsyncIterable(output, terminal);
|
|
169
|
-
resultOutput = formatToolResult(finalValue);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
resultOutput = formatToolResult(output);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
catch (err) {
|
|
176
|
-
resultOutput = `Tool error: ${err instanceof Error ? err.message : String(err)}`;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
catch (error) {
|
|
181
|
-
resultOutput = `Tool error: ${error instanceof Error ? error.message : String(error)}`;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
role: "tool",
|
|
185
|
-
content: [
|
|
186
|
-
{
|
|
187
|
-
type: "tool-result",
|
|
188
|
-
toolName,
|
|
189
|
-
toolCallId: call.toolCallId,
|
|
190
|
-
output: {
|
|
191
|
-
type: "text",
|
|
192
|
-
value: resultOutput,
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
};
|
|
197
|
-
}));
|
|
198
|
-
const toolMessages = (await toolMessagesPromise)
|
|
199
|
-
.filter((result) => result.status === "fulfilled")
|
|
200
|
-
.map((result) => result.value);
|
|
201
|
-
messageHistory.appendToolMessages(toolMessages);
|
|
202
|
-
// Calculate usage for the current step/iteration
|
|
203
|
-
const stepUsage = await result.usage;
|
|
204
|
-
loopResult.totalUsage.inputTokens += stepUsage.inputTokens ?? 0;
|
|
205
|
-
loopResult.totalUsage.outputTokens += stepUsage.outputTokens ?? 0;
|
|
206
|
-
loopResult.totalUsage.totalTokens += stepUsage.totalTokens ?? 0;
|
|
207
|
-
loopResult.totalUsage.cachedInputTokens +=
|
|
208
|
-
stepUsage.cachedInputTokens ?? 0;
|
|
209
|
-
loopResult.totalUsage.reasoningTokens += stepUsage.reasoningTokens ?? 0;
|
|
210
|
-
// Consume the rest of the team if necessary
|
|
211
|
-
// await result.consumeStream();
|
|
212
|
-
// continue iterations
|
|
213
|
-
iter += 1;
|
|
214
|
-
}
|
|
215
|
-
catch (error) {
|
|
216
|
-
consecutiveErrors += 1;
|
|
217
|
-
logger.error(error, // Log the full error object
|
|
218
|
-
`Error on manual agent loop streamText (attempt ${consecutiveErrors}/${maxRetries + 1})`);
|
|
219
|
-
terminal.error("Error in manual agent loop.");
|
|
220
|
-
terminal.error(error.message.length > 100
|
|
221
|
-
? `${error.message.slice(0, 100)}...`
|
|
222
|
-
: error.message);
|
|
223
|
-
if (NoOutputGeneratedError.isInstance(error)) {
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
// Break loop if we exceed max retries
|
|
227
|
-
if (consecutiveErrors > maxRetries) {
|
|
228
|
-
terminal.error(`Exceeded maximum retry attempts (${maxRetries}). Stopping manual loop.`);
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return loopResult;
|
|
234
|
-
}
|
|
235
|
-
export async function consumeToolAsyncIterable(iterable, terminal) {
|
|
236
|
-
const iterator = iterable[Symbol.asyncIterator]();
|
|
237
|
-
const toolResultValues = [];
|
|
238
|
-
let next = await iterator.next();
|
|
239
|
-
while (!next.done) {
|
|
240
|
-
const value = next.value;
|
|
241
|
-
if (isToolMessage(value)) {
|
|
242
|
-
if (terminal) {
|
|
243
|
-
displayToolMessages(value, terminal);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
toolResultValues.push(value);
|
|
248
|
-
}
|
|
249
|
-
next = await iterator.next();
|
|
250
|
-
}
|
|
251
|
-
const finalValue = next.value ??
|
|
252
|
-
(toolResultValues.length > 0 ? toolResultValues.at(-1) : undefined);
|
|
253
|
-
return { finalValue };
|
|
254
|
-
}
|
|
255
|
-
function formatToolResult(value) {
|
|
256
|
-
if (typeof value === "string") {
|
|
257
|
-
return value;
|
|
258
|
-
}
|
|
259
|
-
if (value === undefined) {
|
|
260
|
-
return "";
|
|
261
|
-
}
|
|
262
|
-
if (value === null) {
|
|
263
|
-
return "null";
|
|
264
|
-
}
|
|
265
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
266
|
-
return String(value);
|
|
267
|
-
}
|
|
268
|
-
try {
|
|
269
|
-
const serialized = JSON.stringify(value);
|
|
270
|
-
if (typeof serialized === "string") {
|
|
271
|
-
return serialized;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
catch {
|
|
275
|
-
// noop - fallback below
|
|
276
|
-
}
|
|
277
|
-
return String(value);
|
|
278
|
-
}
|