plugsuits 1.0.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/cli.js +3 -0
- package/dist/agent-reasoning-default.test.d.ts +2 -0
- package/dist/agent-reasoning-default.test.d.ts.map +1 -0
- package/dist/agent-reasoning-default.test.js +38 -0
- package/dist/agent-reasoning-default.test.js.map +1 -0
- package/dist/agent.d.ts +61 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +308 -0
- package/dist/agent.js.map +1 -0
- package/dist/agent.test.d.ts +2 -0
- package/dist/agent.test.d.ts.map +1 -0
- package/dist/agent.test.js +38 -0
- package/dist/agent.test.js.map +1 -0
- package/dist/cli-args.d.ts +15 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +63 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli-args.test.d.ts +2 -0
- package/dist/cli-args.test.d.ts.map +1 -0
- package/dist/cli-args.test.js +105 -0
- package/dist/cli-args.test.js.map +1 -0
- package/dist/commands/aliases-and-tool-fallback.test.d.ts +2 -0
- package/dist/commands/aliases-and-tool-fallback.test.d.ts.map +1 -0
- package/dist/commands/aliases-and-tool-fallback.test.js +132 -0
- package/dist/commands/aliases-and-tool-fallback.test.js.map +1 -0
- package/dist/commands/clear.d.ts +3 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +12 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/factories/create-toggle-command.d.ts +13 -0
- package/dist/commands/factories/create-toggle-command.d.ts.map +1 -0
- package/dist/commands/factories/create-toggle-command.js +38 -0
- package/dist/commands/factories/create-toggle-command.js.map +1 -0
- package/dist/commands/help.d.ts +3 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +23 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/index.d.ts +18 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +82 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/model.d.ts +15 -0
- package/dist/commands/model.d.ts.map +1 -0
- package/dist/commands/model.js +100 -0
- package/dist/commands/model.js.map +1 -0
- package/dist/commands/reasoning-mode.d.ts +3 -0
- package/dist/commands/reasoning-mode.d.ts.map +1 -0
- package/dist/commands/reasoning-mode.js +47 -0
- package/dist/commands/reasoning-mode.js.map +1 -0
- package/dist/commands/render.d.ts +19 -0
- package/dist/commands/render.d.ts.map +1 -0
- package/dist/commands/render.js +140 -0
- package/dist/commands/render.js.map +1 -0
- package/dist/commands/render.test.d.ts +2 -0
- package/dist/commands/render.test.d.ts.map +1 -0
- package/dist/commands/render.test.js +36 -0
- package/dist/commands/render.test.js.map +1 -0
- package/dist/commands/tool-fallback.d.ts +3 -0
- package/dist/commands/tool-fallback.d.ts.map +1 -0
- package/dist/commands/tool-fallback.js +38 -0
- package/dist/commands/tool-fallback.js.map +1 -0
- package/dist/commands/translate.d.ts +3 -0
- package/dist/commands/translate.d.ts.map +1 -0
- package/dist/commands/translate.js +12 -0
- package/dist/commands/translate.js.map +1 -0
- package/dist/commands/translate.test.d.ts +2 -0
- package/dist/commands/translate.test.d.ts.map +1 -0
- package/dist/commands/translate.test.js +49 -0
- package/dist/commands/translate.test.js.map +1 -0
- package/dist/commands/types.d.ts +17 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/context/environment-context.d.ts +2 -0
- package/dist/context/environment-context.d.ts.map +1 -0
- package/dist/context/environment-context.js +11 -0
- package/dist/context/environment-context.js.map +1 -0
- package/dist/context/paths.d.ts +3 -0
- package/dist/context/paths.d.ts.map +1 -0
- package/dist/context/paths.js +3 -0
- package/dist/context/paths.js.map +1 -0
- package/dist/context/session.d.ts +4 -0
- package/dist/context/session.d.ts.map +1 -0
- package/dist/context/session.js +16 -0
- package/dist/context/session.js.map +1 -0
- package/dist/context/skill-command-prefix.d.ts +4 -0
- package/dist/context/skill-command-prefix.d.ts.map +1 -0
- package/dist/context/skill-command-prefix.js +15 -0
- package/dist/context/skill-command-prefix.js.map +1 -0
- package/dist/context/skills-integration.test.d.ts +2 -0
- package/dist/context/skills-integration.test.d.ts.map +1 -0
- package/dist/context/skills-integration.test.js +87 -0
- package/dist/context/skills-integration.test.js.map +1 -0
- package/dist/context/skills.d.ts +18 -0
- package/dist/context/skills.d.ts.map +1 -0
- package/dist/context/skills.js +431 -0
- package/dist/context/skills.js.map +1 -0
- package/dist/context/skills.test.d.ts +2 -0
- package/dist/context/skills.test.d.ts.map +1 -0
- package/dist/context/skills.test.js +20 -0
- package/dist/context/skills.test.js.map +1 -0
- package/dist/context/system-prompt.d.ts +2 -0
- package/dist/context/system-prompt.d.ts.map +1 -0
- package/dist/context/system-prompt.js +100 -0
- package/dist/context/system-prompt.js.map +1 -0
- package/dist/context/translation-integration.test.d.ts +2 -0
- package/dist/context/translation-integration.test.d.ts.map +1 -0
- package/dist/context/translation-integration.test.js +138 -0
- package/dist/context/translation-integration.test.js.map +1 -0
- package/dist/context/translation.d.ts +21 -0
- package/dist/context/translation.d.ts.map +1 -0
- package/dist/context/translation.js +82 -0
- package/dist/context/translation.js.map +1 -0
- package/dist/context/translation.test.d.ts +2 -0
- package/dist/context/translation.test.d.ts.map +1 -0
- package/dist/context/translation.test.js +129 -0
- package/dist/context/translation.test.js.map +1 -0
- package/dist/entrypoints/cli-input-rendering.test.d.ts +2 -0
- package/dist/entrypoints/cli-input-rendering.test.d.ts.map +1 -0
- package/dist/entrypoints/cli-input-rendering.test.js +192 -0
- package/dist/entrypoints/cli-input-rendering.test.js.map +1 -0
- package/dist/entrypoints/cli.d.ts +3 -0
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/entrypoints/cli.js +1268 -0
- package/dist/entrypoints/cli.js.map +1 -0
- package/dist/entrypoints/headless-agent-config.d.ts +21 -0
- package/dist/entrypoints/headless-agent-config.d.ts.map +1 -0
- package/dist/entrypoints/headless-agent-config.js +15 -0
- package/dist/entrypoints/headless-agent-config.js.map +1 -0
- package/dist/entrypoints/headless-agent-config.test.d.ts +2 -0
- package/dist/entrypoints/headless-agent-config.test.d.ts.map +1 -0
- package/dist/entrypoints/headless-agent-config.test.js +63 -0
- package/dist/entrypoints/headless-agent-config.test.js.map +1 -0
- package/dist/entrypoints/headless.d.ts +3 -0
- package/dist/entrypoints/headless.d.ts.map +1 -0
- package/dist/entrypoints/headless.js +396 -0
- package/dist/entrypoints/headless.js.map +1 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +14 -0
- package/dist/env.js.map +1 -0
- package/dist/friendli-models.d.ts +21 -0
- package/dist/friendli-models.d.ts.map +1 -0
- package/dist/friendli-models.js +57 -0
- package/dist/friendli-models.js.map +1 -0
- package/dist/friendli-reasoning.d.ts +10 -0
- package/dist/friendli-reasoning.d.ts.map +1 -0
- package/dist/friendli-reasoning.js +181 -0
- package/dist/friendli-reasoning.js.map +1 -0
- package/dist/friendli-reasoning.test.d.ts +2 -0
- package/dist/friendli-reasoning.test.d.ts.map +1 -0
- package/dist/friendli-reasoning.test.js +77 -0
- package/dist/friendli-reasoning.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/colors.d.ts +22 -0
- package/dist/interaction/colors.d.ts.map +1 -0
- package/dist/interaction/colors.js +24 -0
- package/dist/interaction/colors.js.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.d.ts +19 -0
- package/dist/interaction/pi-tui-stream-renderer.d.ts.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.js +1509 -0
- package/dist/interaction/pi-tui-stream-renderer.js.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.test.d.ts +2 -0
- package/dist/interaction/pi-tui-stream-renderer.test.d.ts.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.test.js +1314 -0
- package/dist/interaction/pi-tui-stream-renderer.test.js.map +1 -0
- package/dist/interaction/spinner.d.ts +13 -0
- package/dist/interaction/spinner.d.ts.map +1 -0
- package/dist/interaction/spinner.js +51 -0
- package/dist/interaction/spinner.js.map +1 -0
- package/dist/middleware/index.d.ts +7 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +15 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/todo-continuation.d.ts +11 -0
- package/dist/middleware/todo-continuation.d.ts.map +1 -0
- package/dist/middleware/todo-continuation.js +103 -0
- package/dist/middleware/todo-continuation.js.map +1 -0
- package/dist/middleware/trim-leading-newlines.d.ts +3 -0
- package/dist/middleware/trim-leading-newlines.d.ts.map +1 -0
- package/dist/middleware/trim-leading-newlines.js +49 -0
- package/dist/middleware/trim-leading-newlines.js.map +1 -0
- package/dist/reasoning-mode.d.ts +5 -0
- package/dist/reasoning-mode.d.ts.map +1 -0
- package/dist/reasoning-mode.js +30 -0
- package/dist/reasoning-mode.js.map +1 -0
- package/dist/reasoning-mode.test.d.ts +2 -0
- package/dist/reasoning-mode.test.d.ts.map +1 -0
- package/dist/reasoning-mode.test.js +22 -0
- package/dist/reasoning-mode.test.js.map +1 -0
- package/dist/tool-fallback-mode.d.ts +6 -0
- package/dist/tool-fallback-mode.d.ts.map +1 -0
- package/dist/tool-fallback-mode.js +25 -0
- package/dist/tool-fallback-mode.js.map +1 -0
- package/dist/tools/execute/shell-execute.d.ts +17 -0
- package/dist/tools/execute/shell-execute.d.ts.map +1 -0
- package/dist/tools/execute/shell-execute.js +55 -0
- package/dist/tools/execute/shell-execute.js.map +1 -0
- package/dist/tools/execute/shell-execute.test.d.ts +2 -0
- package/dist/tools/execute/shell-execute.test.d.ts.map +1 -0
- package/dist/tools/execute/shell-execute.test.js +86 -0
- package/dist/tools/execute/shell-execute.test.js.map +1 -0
- package/dist/tools/execute/shell-interact.d.ts +10 -0
- package/dist/tools/execute/shell-interact.d.ts.map +1 -0
- package/dist/tools/execute/shell-interact.js +122 -0
- package/dist/tools/execute/shell-interact.js.map +1 -0
- package/dist/tools/execute/shell-interact.test.d.ts +2 -0
- package/dist/tools/execute/shell-interact.test.d.ts.map +1 -0
- package/dist/tools/execute/shell-interact.test.js +175 -0
- package/dist/tools/execute/shell-interact.test.js.map +1 -0
- package/dist/tools/explore/glob.d.ts +15 -0
- package/dist/tools/explore/glob.d.ts.map +1 -0
- package/dist/tools/explore/glob.js +107 -0
- package/dist/tools/explore/glob.js.map +1 -0
- package/dist/tools/explore/glob.test.d.ts +2 -0
- package/dist/tools/explore/glob.test.d.ts.map +1 -0
- package/dist/tools/explore/glob.test.js +183 -0
- package/dist/tools/explore/glob.test.js.map +1 -0
- package/dist/tools/explore/grep.d.ts +27 -0
- package/dist/tools/explore/grep.d.ts.map +1 -0
- package/dist/tools/explore/grep.js +203 -0
- package/dist/tools/explore/grep.js.map +1 -0
- package/dist/tools/explore/grep.test.d.ts +2 -0
- package/dist/tools/explore/grep.test.d.ts.map +1 -0
- package/dist/tools/explore/grep.test.js +132 -0
- package/dist/tools/explore/grep.test.js.map +1 -0
- package/dist/tools/explore/read-file.d.ts +23 -0
- package/dist/tools/explore/read-file.d.ts.map +1 -0
- package/dist/tools/explore/read-file.js +84 -0
- package/dist/tools/explore/read-file.js.map +1 -0
- package/dist/tools/explore/read-file.test.d.ts +2 -0
- package/dist/tools/explore/read-file.test.d.ts.map +1 -0
- package/dist/tools/explore/read-file.test.js +278 -0
- package/dist/tools/explore/read-file.test.js.map +1 -0
- package/dist/tools/index.d.ts +71 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +26 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/modify/delete-file.d.ts +19 -0
- package/dist/tools/modify/delete-file.d.ts.map +1 -0
- package/dist/tools/modify/delete-file.js +71 -0
- package/dist/tools/modify/delete-file.js.map +1 -0
- package/dist/tools/modify/delete-file.test.d.ts +2 -0
- package/dist/tools/modify/delete-file.test.d.ts.map +1 -0
- package/dist/tools/modify/delete-file.test.js +136 -0
- package/dist/tools/modify/delete-file.test.js.map +1 -0
- package/dist/tools/modify/edit-file-diagnostics.d.ts +17 -0
- package/dist/tools/modify/edit-file-diagnostics.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-diagnostics.js +157 -0
- package/dist/tools/modify/edit-file-diagnostics.js.map +1 -0
- package/dist/tools/modify/edit-file-repair.d.ts +13 -0
- package/dist/tools/modify/edit-file-repair.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-repair.js +135 -0
- package/dist/tools/modify/edit-file-repair.js.map +1 -0
- package/dist/tools/modify/edit-file-stress.test.d.ts +2 -0
- package/dist/tools/modify/edit-file-stress.test.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-stress.test.js +163 -0
- package/dist/tools/modify/edit-file-stress.test.js.map +1 -0
- package/dist/tools/modify/edit-file-validation.d.ts +9 -0
- package/dist/tools/modify/edit-file-validation.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-validation.js +86 -0
- package/dist/tools/modify/edit-file-validation.js.map +1 -0
- package/dist/tools/modify/edit-file-whitespace.test.d.ts +2 -0
- package/dist/tools/modify/edit-file-whitespace.test.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-whitespace.test.js +90 -0
- package/dist/tools/modify/edit-file-whitespace.test.js.map +1 -0
- package/dist/tools/modify/edit-file.d.ts +33 -0
- package/dist/tools/modify/edit-file.d.ts.map +1 -0
- package/dist/tools/modify/edit-file.js +177 -0
- package/dist/tools/modify/edit-file.js.map +1 -0
- package/dist/tools/modify/edit-file.test.d.ts +2 -0
- package/dist/tools/modify/edit-file.test.d.ts.map +1 -0
- package/dist/tools/modify/edit-file.test.js +948 -0
- package/dist/tools/modify/edit-file.test.js.map +1 -0
- package/dist/tools/modify/write-file.d.ts +17 -0
- package/dist/tools/modify/write-file.d.ts.map +1 -0
- package/dist/tools/modify/write-file.js +39 -0
- package/dist/tools/modify/write-file.js.map +1 -0
- package/dist/tools/modify/write-file.test.d.ts +2 -0
- package/dist/tools/modify/write-file.test.d.ts.map +1 -0
- package/dist/tools/modify/write-file.test.js +168 -0
- package/dist/tools/modify/write-file.test.js.map +1 -0
- package/dist/tools/planning/load-skill.d.ts +13 -0
- package/dist/tools/planning/load-skill.d.ts.map +1 -0
- package/dist/tools/planning/load-skill.js +101 -0
- package/dist/tools/planning/load-skill.js.map +1 -0
- package/dist/tools/planning/load-skill.test.d.ts +2 -0
- package/dist/tools/planning/load-skill.test.d.ts.map +1 -0
- package/dist/tools/planning/load-skill.test.js +37 -0
- package/dist/tools/planning/load-skill.test.js.map +1 -0
- package/dist/tools/planning/todo-write.d.ts +49 -0
- package/dist/tools/planning/todo-write.d.ts.map +1 -0
- package/dist/tools/planning/todo-write.js +118 -0
- package/dist/tools/planning/todo-write.js.map +1 -0
- package/dist/tools/planning/todo-write.test.d.ts +2 -0
- package/dist/tools/planning/todo-write.test.d.ts.map +1 -0
- package/dist/tools/planning/todo-write.test.js +82 -0
- package/dist/tools/planning/todo-write.test.js.map +1 -0
- package/dist/tools/utils/execute/format-utils.d.ts +4 -0
- package/dist/tools/utils/execute/format-utils.d.ts.map +1 -0
- package/dist/tools/utils/execute/format-utils.js +31 -0
- package/dist/tools/utils/execute/format-utils.js.map +1 -0
- package/dist/tools/utils/execute/format-utils.test.d.ts +2 -0
- package/dist/tools/utils/execute/format-utils.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/format-utils.test.js +40 -0
- package/dist/tools/utils/execute/format-utils.test.js.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.d.ts +12 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.d.ts.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.js +269 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.js.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.d.ts +2 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.js +233 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.js.map +1 -0
- package/dist/tools/utils/execute/output-handler.d.ts +14 -0
- package/dist/tools/utils/execute/output-handler.d.ts.map +1 -0
- package/dist/tools/utils/execute/output-handler.js +71 -0
- package/dist/tools/utils/execute/output-handler.js.map +1 -0
- package/dist/tools/utils/execute/output-handler.test.d.ts +2 -0
- package/dist/tools/utils/execute/output-handler.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/output-handler.test.js +58 -0
- package/dist/tools/utils/execute/output-handler.test.js.map +1 -0
- package/dist/tools/utils/execute/process-manager.d.ts +17 -0
- package/dist/tools/utils/execute/process-manager.d.ts.map +1 -0
- package/dist/tools/utils/execute/process-manager.js +229 -0
- package/dist/tools/utils/execute/process-manager.js.map +1 -0
- package/dist/tools/utils/execute/process-manager.test.d.ts +2 -0
- package/dist/tools/utils/execute/process-manager.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/process-manager.test.js +139 -0
- package/dist/tools/utils/execute/process-manager.test.js.map +1 -0
- package/dist/tools/utils/execute/shell-detection.d.ts +3 -0
- package/dist/tools/utils/execute/shell-detection.d.ts.map +1 -0
- package/dist/tools/utils/execute/shell-detection.js +56 -0
- package/dist/tools/utils/execute/shell-detection.js.map +1 -0
- package/dist/tools/utils/execute/shell-detection.test.d.ts +2 -0
- package/dist/tools/utils/execute/shell-detection.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/shell-detection.test.js +86 -0
- package/dist/tools/utils/execute/shell-detection.test.js.map +1 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.d.ts +5 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.d.ts.map +1 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.js +113 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.js.map +1 -0
- package/dist/tools/utils/hashline/constants.d.ts +5 -0
- package/dist/tools/utils/hashline/constants.d.ts.map +1 -0
- package/dist/tools/utils/hashline/constants.js +11 -0
- package/dist/tools/utils/hashline/constants.js.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.d.ts +7 -0
- package/dist/tools/utils/hashline/diff-utils.d.ts.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.js +50 -0
- package/dist/tools/utils/hashline/diff-utils.js.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.test.d.ts +2 -0
- package/dist/tools/utils/hashline/diff-utils.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.test.js +46 -0
- package/dist/tools/utils/hashline/diff-utils.test.js.map +1 -0
- package/dist/tools/utils/hashline/edit-deduplication.d.ts +6 -0
- package/dist/tools/utils/hashline/edit-deduplication.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-deduplication.js +32 -0
- package/dist/tools/utils/hashline/edit-deduplication.js.map +1 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.d.ts +11 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.js +93 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.js.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.d.ts +9 -0
- package/dist/tools/utils/hashline/edit-operations.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.js +101 -0
- package/dist/tools/utils/hashline/edit-operations.js.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.test.d.ts +2 -0
- package/dist/tools/utils/hashline/edit-operations.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.test.js +135 -0
- package/dist/tools/utils/hashline/edit-operations.test.js.map +1 -0
- package/dist/tools/utils/hashline/edit-ordering.d.ts +5 -0
- package/dist/tools/utils/hashline/edit-ordering.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-ordering.js +54 -0
- package/dist/tools/utils/hashline/edit-ordering.js.map +1 -0
- package/dist/tools/utils/hashline/edit-text-normalization.d.ts +9 -0
- package/dist/tools/utils/hashline/edit-text-normalization.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-text-normalization.js +135 -0
- package/dist/tools/utils/hashline/edit-text-normalization.js.map +1 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.d.ts +8 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.d.ts.map +1 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.js +42 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.js.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.d.ts +14 -0
- package/dist/tools/utils/hashline/hash-computation.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.js +158 -0
- package/dist/tools/utils/hashline/hash-computation.js.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.test.d.ts +2 -0
- package/dist/tools/utils/hashline/hash-computation.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.test.js +63 -0
- package/dist/tools/utils/hashline/hash-computation.test.js.map +1 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.d.ts +11 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.js +41 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.js.map +1 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.d.ts +2 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.js +27 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.js.map +1 -0
- package/dist/tools/utils/hashline/index.d.ts +14 -0
- package/dist/tools/utils/hashline/index.d.ts.map +1 -0
- package/dist/tools/utils/hashline/index.js +11 -0
- package/dist/tools/utils/hashline/index.js.map +1 -0
- package/dist/tools/utils/hashline/merge-expansion.d.ts +4 -0
- package/dist/tools/utils/hashline/merge-expansion.d.ts.map +1 -0
- package/dist/tools/utils/hashline/merge-expansion.js +105 -0
- package/dist/tools/utils/hashline/merge-expansion.js.map +1 -0
- package/dist/tools/utils/hashline/normalize-edits.d.ts +11 -0
- package/dist/tools/utils/hashline/normalize-edits.d.ts.map +1 -0
- package/dist/tools/utils/hashline/normalize-edits.js +81 -0
- package/dist/tools/utils/hashline/normalize-edits.js.map +1 -0
- package/dist/tools/utils/hashline/types.d.ts +18 -0
- package/dist/tools/utils/hashline/types.d.ts.map +1 -0
- package/dist/tools/utils/hashline/types.js +2 -0
- package/dist/tools/utils/hashline/types.js.map +1 -0
- package/dist/tools/utils/hashline/validation.d.ts +19 -0
- package/dist/tools/utils/hashline/validation.d.ts.map +1 -0
- package/dist/tools/utils/hashline/validation.js +161 -0
- package/dist/tools/utils/hashline/validation.js.map +1 -0
- package/dist/tools/utils/hashline/validation.test.d.ts +2 -0
- package/dist/tools/utils/hashline/validation.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/validation.test.js +86 -0
- package/dist/tools/utils/hashline/validation.test.js.map +1 -0
- package/dist/tools/utils/safety-utils.d.ts +66 -0
- package/dist/tools/utils/safety-utils.d.ts.map +1 -0
- package/dist/tools/utils/safety-utils.js +681 -0
- package/dist/tools/utils/safety-utils.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +16 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +257 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/package.json +49 -0
- package/src/AGENTS.md +52 -0
- package/src/agent-reasoning-default.test.ts +48 -0
- package/src/agent.test.ts +49 -0
- package/src/agent.ts +455 -0
- package/src/cli-args.test.ts +152 -0
- package/src/cli-args.ts +90 -0
- package/src/commands/aliases-and-tool-fallback.test.ts +172 -0
- package/src/commands/clear.ts +14 -0
- package/src/commands/factories/create-toggle-command.ts +68 -0
- package/src/commands/help.ts +30 -0
- package/src/commands/index.ts +125 -0
- package/src/commands/model.ts +146 -0
- package/src/commands/reasoning-mode.ts +55 -0
- package/src/commands/render.test.ts +47 -0
- package/src/commands/render.ts +205 -0
- package/src/commands/tool-fallback.ts +47 -0
- package/src/commands/translate.test.ts +62 -0
- package/src/commands/translate.ts +14 -0
- package/src/commands/types.ts +18 -0
- package/src/context/environment-context.ts +11 -0
- package/src/context/paths.ts +2 -0
- package/src/context/session.ts +18 -0
- package/src/context/skill-command-prefix.ts +18 -0
- package/src/context/skills-integration.test.ts +113 -0
- package/src/context/skills.test.ts +25 -0
- package/src/context/skills.ts +566 -0
- package/src/context/system-prompt.ts +100 -0
- package/src/context/translation-integration.test.ts +194 -0
- package/src/context/translation.test.ts +186 -0
- package/src/context/translation.ts +122 -0
- package/src/entrypoints/AGENTS.md +33 -0
- package/src/entrypoints/cli-input-rendering.test.ts +236 -0
- package/src/entrypoints/cli.ts +1845 -0
- package/src/entrypoints/headless-agent-config.test.ts +82 -0
- package/src/entrypoints/headless-agent-config.ts +42 -0
- package/src/entrypoints/headless.ts +622 -0
- package/src/env.ts +14 -0
- package/src/friendli-models.ts +81 -0
- package/src/friendli-reasoning.test.ts +147 -0
- package/src/friendli-reasoning.ts +280 -0
- package/src/index.ts +3 -0
- package/src/interaction/colors.ts +24 -0
- package/src/interaction/pi-tui-stream-renderer.test.ts +1471 -0
- package/src/interaction/pi-tui-stream-renderer.ts +2150 -0
- package/src/interaction/spinner.ts +61 -0
- package/src/middleware/index.ts +32 -0
- package/src/middleware/todo-continuation.ts +128 -0
- package/src/middleware/trim-leading-newlines.ts +66 -0
- package/src/reasoning-mode.test.ts +24 -0
- package/src/reasoning-mode.ts +40 -0
- package/src/skills/example/SKILL.md +44 -0
- package/src/skills/example/references/api.md +37 -0
- package/src/skills/example/scripts/setup.sh +13 -0
- package/src/skills/git-workflow.md +405 -0
- package/src/tool-fallback-mode.ts +34 -0
- package/src/tools/AGENTS.md +44 -0
- package/src/tools/execute/shell-execute.test.ts +114 -0
- package/src/tools/execute/shell-execute.ts +74 -0
- package/src/tools/execute/shell-execute.txt +27 -0
- package/src/tools/execute/shell-interact.test.ts +236 -0
- package/src/tools/execute/shell-interact.ts +151 -0
- package/src/tools/execute/shell-interact.txt +15 -0
- package/src/tools/explore/glob-files.txt +8 -0
- package/src/tools/explore/glob.test.ts +217 -0
- package/src/tools/explore/glob.ts +137 -0
- package/src/tools/explore/grep-files.txt +12 -0
- package/src/tools/explore/grep.test.ts +183 -0
- package/src/tools/explore/grep.ts +266 -0
- package/src/tools/explore/read-file.test.ts +355 -0
- package/src/tools/explore/read-file.ts +102 -0
- package/src/tools/explore/read-file.txt +24 -0
- package/src/tools/index.ts +29 -0
- package/src/tools/modify/AGENTS.md +38 -0
- package/src/tools/modify/delete-file.test.ts +200 -0
- package/src/tools/modify/delete-file.ts +95 -0
- package/src/tools/modify/delete-file.txt +9 -0
- package/src/tools/modify/edit-file-diagnostics.ts +210 -0
- package/src/tools/modify/edit-file-repair.ts +183 -0
- package/src/tools/modify/edit-file-stress.test.ts +200 -0
- package/src/tools/modify/edit-file-validation.ts +134 -0
- package/src/tools/modify/edit-file-whitespace.test.ts +117 -0
- package/src/tools/modify/edit-file.test.ts +1231 -0
- package/src/tools/modify/edit-file.ts +252 -0
- package/src/tools/modify/edit-file.txt +73 -0
- package/src/tools/modify/write-file.test.ts +240 -0
- package/src/tools/modify/write-file.ts +56 -0
- package/src/tools/modify/write-file.txt +9 -0
- package/src/tools/planning/load-skill.test.ts +48 -0
- package/src/tools/planning/load-skill.ts +136 -0
- package/src/tools/planning/load-skill.txt +6 -0
- package/src/tools/planning/todo-write.test.ts +91 -0
- package/src/tools/planning/todo-write.ts +141 -0
- package/src/tools/planning/todo-write.txt +7 -0
- package/src/tools/utils/execute/format-utils.test.ts +53 -0
- package/src/tools/utils/execute/format-utils.ts +37 -0
- package/src/tools/utils/execute/noninteractive-wrapper.test.ts +306 -0
- package/src/tools/utils/execute/noninteractive-wrapper.ts +314 -0
- package/src/tools/utils/execute/output-handler.test.ts +72 -0
- package/src/tools/utils/execute/output-handler.ts +101 -0
- package/src/tools/utils/execute/process-manager.test.ts +175 -0
- package/src/tools/utils/execute/process-manager.ts +310 -0
- package/src/tools/utils/execute/shell-detection.test.ts +112 -0
- package/src/tools/utils/execute/shell-detection.ts +72 -0
- package/src/tools/utils/hashline/autocorrect-replacement-lines.ts +159 -0
- package/src/tools/utils/hashline/constants.ts +13 -0
- package/src/tools/utils/hashline/diff-utils.test.ts +61 -0
- package/src/tools/utils/hashline/diff-utils.ts +64 -0
- package/src/tools/utils/hashline/edit-deduplication.ts +40 -0
- package/src/tools/utils/hashline/edit-operation-primitives.ts +149 -0
- package/src/tools/utils/hashline/edit-operations.test.ts +154 -0
- package/src/tools/utils/hashline/edit-operations.ts +132 -0
- package/src/tools/utils/hashline/edit-ordering.ts +60 -0
- package/src/tools/utils/hashline/edit-text-normalization.ts +180 -0
- package/src/tools/utils/hashline/file-text-canonicalization.ts +58 -0
- package/src/tools/utils/hashline/hash-computation.test.ts +82 -0
- package/src/tools/utils/hashline/hash-computation.ts +199 -0
- package/src/tools/utils/hashline/hashline-chunk-formatter.ts +61 -0
- package/src/tools/utils/hashline/hashline-edit-diff.ts +35 -0
- package/src/tools/utils/hashline/index.ts +55 -0
- package/src/tools/utils/hashline/merge-expansion.ts +120 -0
- package/src/tools/utils/hashline/normalize-edits.ts +127 -0
- package/src/tools/utils/hashline/types.ts +20 -0
- package/src/tools/utils/hashline/validation.test.ts +109 -0
- package/src/tools/utils/hashline/validation.ts +212 -0
- package/src/tools/utils/safety-utils.ts +938 -0
- package/src/utils/tools-manager.ts +353 -0
package/src/agent.ts
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
|
+
import type { ProviderOptions as AiProviderOptions } from "@ai-sdk/provider-utils";
|
|
3
|
+
import {
|
|
4
|
+
createAgent,
|
|
5
|
+
type AgentStreamOptions as HarnessAgentStreamOptions,
|
|
6
|
+
type AgentStreamResult as HarnessAgentStreamResult,
|
|
7
|
+
} from "@ai-sdk-tool/harness";
|
|
8
|
+
import { createFriendli } from "@friendliai/ai-provider";
|
|
9
|
+
import {
|
|
10
|
+
InvalidToolInputError,
|
|
11
|
+
type ModelMessage,
|
|
12
|
+
NoSuchToolError,
|
|
13
|
+
wrapLanguageModel,
|
|
14
|
+
} from "ai";
|
|
15
|
+
import { getEnvironmentContext } from "./context/environment-context";
|
|
16
|
+
import { loadSkillsMetadata } from "./context/skills";
|
|
17
|
+
import { SYSTEM_PROMPT } from "./context/system-prompt";
|
|
18
|
+
import type { TranslationModelConfig } from "./context/translation";
|
|
19
|
+
import { env } from "./env";
|
|
20
|
+
import {
|
|
21
|
+
applyFriendliInterleavedField,
|
|
22
|
+
buildFriendliChatTemplateKwargs,
|
|
23
|
+
getFriendliSelectableReasoningModes,
|
|
24
|
+
} from "./friendli-reasoning";
|
|
25
|
+
import { buildMiddlewares } from "./middleware";
|
|
26
|
+
import {
|
|
27
|
+
buildTodoContinuationPrompt,
|
|
28
|
+
getIncompleteTodos,
|
|
29
|
+
} from "./middleware/todo-continuation";
|
|
30
|
+
import { DEFAULT_REASONING_MODE, type ReasoningMode } from "./reasoning-mode";
|
|
31
|
+
import {
|
|
32
|
+
DEFAULT_TOOL_FALLBACK_MODE,
|
|
33
|
+
LEGACY_ENABLED_TOOL_FALLBACK_MODE,
|
|
34
|
+
type ToolFallbackMode,
|
|
35
|
+
} from "./tool-fallback-mode";
|
|
36
|
+
import { createTools, type ToolRegistry } from "./tools";
|
|
37
|
+
|
|
38
|
+
export const DEFAULT_MODEL_ID = "MiniMaxAI/MiniMax-M2.5";
|
|
39
|
+
export const DEFAULT_ANTHROPIC_MODEL_ID = "claude-sonnet-4-6";
|
|
40
|
+
const OUTPUT_TOKEN_MAX = 64_000;
|
|
41
|
+
const TRANSLATION_MAX_OUTPUT_TOKENS = 4000;
|
|
42
|
+
|
|
43
|
+
type ProviderOptions = AiProviderOptions | undefined;
|
|
44
|
+
|
|
45
|
+
export type AgentStreamOptions = Pick<HarnessAgentStreamOptions, "abortSignal">;
|
|
46
|
+
export type AgentStreamResult = HarnessAgentStreamResult;
|
|
47
|
+
|
|
48
|
+
export type ProviderType = "friendli" | "anthropic";
|
|
49
|
+
|
|
50
|
+
export const ANTHROPIC_MODELS = [
|
|
51
|
+
{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6 (Latest)" },
|
|
52
|
+
{ id: "claude-opus-4-6", name: "Claude Opus 4.6 (Latest)" },
|
|
53
|
+
] as const;
|
|
54
|
+
|
|
55
|
+
const friendli = env.FRIENDLI_TOKEN
|
|
56
|
+
? createFriendli({
|
|
57
|
+
apiKey: env.FRIENDLI_TOKEN,
|
|
58
|
+
includeUsage: true,
|
|
59
|
+
})
|
|
60
|
+
: null;
|
|
61
|
+
|
|
62
|
+
const anthropic = env.ANTHROPIC_API_KEY
|
|
63
|
+
? createAnthropic({
|
|
64
|
+
apiKey: env.ANTHROPIC_API_KEY,
|
|
65
|
+
})
|
|
66
|
+
: null;
|
|
67
|
+
|
|
68
|
+
const getModel = (modelId: string, provider: ProviderType) => {
|
|
69
|
+
if (provider === "anthropic") {
|
|
70
|
+
if (!anthropic) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
"ANTHROPIC_API_KEY is not set. Please set it in your environment."
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return anthropic(modelId);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!friendli) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"FRIENDLI_TOKEN is not set. Please set it in your environment."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return friendli(modelId);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const ANTHROPIC_THINKING_BUDGET_TOKENS = 10_000;
|
|
87
|
+
const ANTHROPIC_MAX_OUTPUT_TOKENS = 64_000;
|
|
88
|
+
const ANTHROPIC_SELECTABLE_REASONING_MODES: ReasoningMode[] = ["off", "on"];
|
|
89
|
+
const REASONING_MODE_PRIORITY: readonly ReasoningMode[] = [
|
|
90
|
+
"preserved",
|
|
91
|
+
"interleaved",
|
|
92
|
+
"on",
|
|
93
|
+
"off",
|
|
94
|
+
];
|
|
95
|
+
const TRANSLATION_REASONING_MODE_PRIORITY: readonly ReasoningMode[] = [
|
|
96
|
+
"off",
|
|
97
|
+
"on",
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const selectBestReasoningMode = (
|
|
101
|
+
modes: readonly ReasoningMode[]
|
|
102
|
+
): ReasoningMode => {
|
|
103
|
+
for (const mode of REASONING_MODE_PRIORITY) {
|
|
104
|
+
if (modes.includes(mode)) {
|
|
105
|
+
return mode;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return DEFAULT_REASONING_MODE;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const selectTranslationReasoningMode = (
|
|
113
|
+
modes: readonly ReasoningMode[]
|
|
114
|
+
): ReasoningMode => {
|
|
115
|
+
for (const mode of TRANSLATION_REASONING_MODE_PRIORITY) {
|
|
116
|
+
if (modes.includes(mode)) {
|
|
117
|
+
return mode;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return selectBestReasoningMode(modes);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const isAnthropicWithReasoning = (
|
|
125
|
+
modelId: string,
|
|
126
|
+
provider: ProviderType,
|
|
127
|
+
reasoningMode: ReasoningMode
|
|
128
|
+
): boolean => {
|
|
129
|
+
const thinkingEnabled = reasoningMode !== "off";
|
|
130
|
+
return (
|
|
131
|
+
provider === "anthropic" && thinkingEnabled && !modelId.includes("opus")
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const getProviderOptions = (
|
|
136
|
+
modelId: string,
|
|
137
|
+
provider: ProviderType,
|
|
138
|
+
reasoningMode: ReasoningMode
|
|
139
|
+
): { options: ProviderOptions; maxOutputTokens: number } => {
|
|
140
|
+
const thinkingEnabled = reasoningMode !== "off";
|
|
141
|
+
|
|
142
|
+
const getAnthropicProviderOptions = () => {
|
|
143
|
+
if (!thinkingEnabled) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const isOpus = modelId.includes("opus");
|
|
148
|
+
if (isOpus) {
|
|
149
|
+
return { anthropic: { effort: "high" } };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
anthropic: {
|
|
154
|
+
thinking: {
|
|
155
|
+
type: "enabled",
|
|
156
|
+
budgetTokens: ANTHROPIC_THINKING_BUDGET_TOKENS,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
if (provider === "anthropic") {
|
|
163
|
+
return {
|
|
164
|
+
options: getAnthropicProviderOptions(),
|
|
165
|
+
maxOutputTokens: isAnthropicWithReasoning(
|
|
166
|
+
modelId,
|
|
167
|
+
provider,
|
|
168
|
+
reasoningMode
|
|
169
|
+
)
|
|
170
|
+
? ANTHROPIC_MAX_OUTPUT_TOKENS - ANTHROPIC_THINKING_BUDGET_TOKENS
|
|
171
|
+
: OUTPUT_TOKEN_MAX,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const chatTemplateKwargs = buildFriendliChatTemplateKwargs(
|
|
176
|
+
modelId,
|
|
177
|
+
reasoningMode
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
options: chatTemplateKwargs
|
|
182
|
+
? {
|
|
183
|
+
friendli: {
|
|
184
|
+
chat_template_kwargs: chatTemplateKwargs,
|
|
185
|
+
},
|
|
186
|
+
}
|
|
187
|
+
: undefined,
|
|
188
|
+
maxOutputTokens: OUTPUT_TOKEN_MAX,
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const createBaseModel = (
|
|
193
|
+
modelId: string,
|
|
194
|
+
provider: ProviderType,
|
|
195
|
+
toolFallbackMode: ToolFallbackMode,
|
|
196
|
+
reasoningMode: ReasoningMode
|
|
197
|
+
) => {
|
|
198
|
+
const model = getModel(modelId, provider);
|
|
199
|
+
const { options, maxOutputTokens } = getProviderOptions(
|
|
200
|
+
modelId,
|
|
201
|
+
provider,
|
|
202
|
+
reasoningMode
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const wrappedModel = wrapLanguageModel({
|
|
206
|
+
model,
|
|
207
|
+
middleware: buildMiddlewares({
|
|
208
|
+
toolFallbackMode,
|
|
209
|
+
}),
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return { model: wrappedModel, providerOptions: options, maxOutputTokens };
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const defaultToolRegistry = createTools();
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Repair malformed tool calls from weak models.
|
|
219
|
+
* Cleans hashline artifacts (e.g. `42#AB|content42#AB`) that models
|
|
220
|
+
* sometimes embed in JSON arguments.
|
|
221
|
+
*/
|
|
222
|
+
const repairToolCall: Parameters<
|
|
223
|
+
typeof import("ai").streamText
|
|
224
|
+
>[0]["experimental_repairToolCall"] = ({ toolCall, error }) => {
|
|
225
|
+
if (NoSuchToolError.isInstance(error)) {
|
|
226
|
+
return Promise.resolve(null);
|
|
227
|
+
}
|
|
228
|
+
if (!InvalidToolInputError.isInstance(error)) {
|
|
229
|
+
return Promise.resolve(null);
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
const raw =
|
|
233
|
+
typeof toolCall.input === "string"
|
|
234
|
+
? toolCall.input
|
|
235
|
+
: JSON.stringify(toolCall.input);
|
|
236
|
+
const cleaned = raw
|
|
237
|
+
.replace(
|
|
238
|
+
/(\d+#[A-Z]{2})(?:[|=-][^"{}[\]]*?)\1(?:[|=-][^"{}[\]]*?)*/g,
|
|
239
|
+
"$1"
|
|
240
|
+
)
|
|
241
|
+
.replace(/(\d+#[A-Z]{2})(?:-\1)+/g, "$1");
|
|
242
|
+
const parsed = JSON.parse(cleaned);
|
|
243
|
+
return Promise.resolve({ ...toolCall, input: JSON.stringify(parsed) });
|
|
244
|
+
} catch {
|
|
245
|
+
return Promise.resolve(null);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export type ModelType = "serverless" | "dedicated";
|
|
250
|
+
|
|
251
|
+
export class AgentManager {
|
|
252
|
+
private modelId: string = DEFAULT_MODEL_ID;
|
|
253
|
+
private modelType: ModelType = "serverless";
|
|
254
|
+
private provider: ProviderType = "friendli";
|
|
255
|
+
private headlessMode = false;
|
|
256
|
+
private reasoningMode: ReasoningMode = DEFAULT_REASONING_MODE;
|
|
257
|
+
private toolRegistry: ToolRegistry = defaultToolRegistry;
|
|
258
|
+
private toolFallbackMode: ToolFallbackMode = DEFAULT_TOOL_FALLBACK_MODE;
|
|
259
|
+
private translationEnabled = true;
|
|
260
|
+
|
|
261
|
+
constructor() {
|
|
262
|
+
this.applyBestReasoningModeForCurrentModel();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
resetForTesting(): void {
|
|
266
|
+
this.modelId = DEFAULT_MODEL_ID;
|
|
267
|
+
this.modelType = "serverless";
|
|
268
|
+
this.provider = "friendli";
|
|
269
|
+
this.headlessMode = false;
|
|
270
|
+
this.reasoningMode = DEFAULT_REASONING_MODE;
|
|
271
|
+
this.toolRegistry = defaultToolRegistry;
|
|
272
|
+
this.toolFallbackMode = DEFAULT_TOOL_FALLBACK_MODE;
|
|
273
|
+
this.translationEnabled = true;
|
|
274
|
+
this.applyBestReasoningModeForCurrentModel();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private applyBestReasoningModeForCurrentModel(): void {
|
|
278
|
+
this.reasoningMode = selectBestReasoningMode(
|
|
279
|
+
this.getSelectableReasoningModes()
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private buildModel(reasoningMode: ReasoningMode = this.reasoningMode) {
|
|
284
|
+
return createBaseModel(
|
|
285
|
+
this.modelId,
|
|
286
|
+
this.provider,
|
|
287
|
+
this.toolFallbackMode,
|
|
288
|
+
reasoningMode
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
getModelId(): string {
|
|
293
|
+
return this.modelId;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
setModelId(modelId: string): void {
|
|
297
|
+
this.modelId = modelId;
|
|
298
|
+
this.applyBestReasoningModeForCurrentModel();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
getModelType(): ModelType {
|
|
302
|
+
return this.modelType;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
setModelType(type: ModelType): void {
|
|
306
|
+
this.modelType = type;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
getProvider(): ProviderType {
|
|
310
|
+
return this.provider;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
setProvider(provider: ProviderType): void {
|
|
314
|
+
this.provider = provider;
|
|
315
|
+
if (provider === "anthropic") {
|
|
316
|
+
this.modelId = DEFAULT_ANTHROPIC_MODEL_ID;
|
|
317
|
+
} else {
|
|
318
|
+
this.modelId = DEFAULT_MODEL_ID;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
this.applyBestReasoningModeForCurrentModel();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
setHeadlessMode(enabled: boolean): void {
|
|
325
|
+
this.headlessMode = enabled;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
isHeadlessMode(): boolean {
|
|
329
|
+
return this.headlessMode;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
setReasoningMode(mode: ReasoningMode): void {
|
|
333
|
+
this.reasoningMode = mode;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
getReasoningMode(): ReasoningMode {
|
|
337
|
+
return this.reasoningMode;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
getSelectableReasoningModes(): ReasoningMode[] {
|
|
341
|
+
if (this.provider === "friendli") {
|
|
342
|
+
return getFriendliSelectableReasoningModes(this.modelId);
|
|
343
|
+
}
|
|
344
|
+
return [...ANTHROPIC_SELECTABLE_REASONING_MODES];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
setThinkingEnabled(enabled: boolean): void {
|
|
348
|
+
this.reasoningMode = enabled ? "on" : DEFAULT_REASONING_MODE;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
isThinkingEnabled(): boolean {
|
|
352
|
+
return this.reasoningMode !== DEFAULT_REASONING_MODE;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
getToolFallbackMode(): ToolFallbackMode {
|
|
356
|
+
return this.toolFallbackMode;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
setToolFallbackMode(mode: ToolFallbackMode): void {
|
|
360
|
+
this.toolFallbackMode = mode;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
setToolFallbackEnabled(enabled: boolean): void {
|
|
364
|
+
this.toolFallbackMode = enabled
|
|
365
|
+
? LEGACY_ENABLED_TOOL_FALLBACK_MODE
|
|
366
|
+
: DEFAULT_TOOL_FALLBACK_MODE;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
isToolFallbackEnabled(): boolean {
|
|
370
|
+
return this.toolFallbackMode !== DEFAULT_TOOL_FALLBACK_MODE;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
setTranslationEnabled(enabled: boolean): void {
|
|
374
|
+
this.translationEnabled = enabled;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
isTranslationEnabled(): boolean {
|
|
378
|
+
return this.translationEnabled;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
getTranslationReasoningMode(): ReasoningMode {
|
|
382
|
+
return selectTranslationReasoningMode(this.getSelectableReasoningModes());
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
getTranslationModelConfig(): TranslationModelConfig {
|
|
386
|
+
const translationReasoningMode = this.getTranslationReasoningMode();
|
|
387
|
+
const { model, providerOptions } = this.buildModel(
|
|
388
|
+
translationReasoningMode
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
return {
|
|
392
|
+
model,
|
|
393
|
+
providerOptions,
|
|
394
|
+
maxOutputTokens: TRANSLATION_MAX_OUTPUT_TOKENS,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async getInstructions(): Promise<string> {
|
|
399
|
+
let instructions = SYSTEM_PROMPT + getEnvironmentContext();
|
|
400
|
+
|
|
401
|
+
const skillMetadata = await loadSkillsMetadata();
|
|
402
|
+
if (skillMetadata) {
|
|
403
|
+
instructions += skillMetadata;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const incompleteTodos = await getIncompleteTodos();
|
|
407
|
+
if (incompleteTodos.length > 0) {
|
|
408
|
+
instructions += `
|
|
409
|
+
|
|
410
|
+
${buildTodoContinuationPrompt(incompleteTodos)}`;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return instructions;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
getTools(): ToolRegistry {
|
|
417
|
+
return this.toolRegistry;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
setTools(toolRegistry: ToolRegistry): void {
|
|
421
|
+
this.toolRegistry = toolRegistry;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
async stream(
|
|
425
|
+
messages: ModelMessage[],
|
|
426
|
+
options: AgentStreamOptions = {}
|
|
427
|
+
): Promise<AgentStreamResult> {
|
|
428
|
+
const { model, providerOptions, maxOutputTokens } = this.buildModel();
|
|
429
|
+
const preparedMessages =
|
|
430
|
+
this.provider === "friendli"
|
|
431
|
+
? applyFriendliInterleavedField(
|
|
432
|
+
messages,
|
|
433
|
+
this.modelId,
|
|
434
|
+
this.reasoningMode
|
|
435
|
+
)
|
|
436
|
+
: messages;
|
|
437
|
+
|
|
438
|
+
const agent = createAgent({
|
|
439
|
+
model,
|
|
440
|
+
tools: this.toolRegistry,
|
|
441
|
+
instructions: await this.getInstructions(),
|
|
442
|
+
maxStepsPerTurn: 1,
|
|
443
|
+
experimental_repairToolCall: repairToolCall,
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
return agent.stream({
|
|
447
|
+
messages: preparedMessages,
|
|
448
|
+
...options,
|
|
449
|
+
providerOptions,
|
|
450
|
+
maxOutputTokens,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export const agentManager = new AgentManager();
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
parseProviderArg,
|
|
4
|
+
parseReasoningCliOption,
|
|
5
|
+
parseToolFallbackCliOption,
|
|
6
|
+
parseTranslateCliOption,
|
|
7
|
+
} from "./cli-args";
|
|
8
|
+
|
|
9
|
+
describe("parseProviderArg", () => {
|
|
10
|
+
it("returns 'anthropic' for valid anthropic arg", () => {
|
|
11
|
+
expect(parseProviderArg("anthropic")).toBe("anthropic");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("returns 'friendli' for valid friendli arg", () => {
|
|
15
|
+
expect(parseProviderArg("friendli")).toBe("friendli");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns null for unknown provider", () => {
|
|
19
|
+
expect(parseProviderArg("openai")).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("returns null for undefined", () => {
|
|
23
|
+
expect(parseProviderArg(undefined)).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("returns null for empty string", () => {
|
|
27
|
+
expect(parseProviderArg("")).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("parseTranslateCliOption", () => {
|
|
32
|
+
it("returns true for --translate", () => {
|
|
33
|
+
expect(parseTranslateCliOption("--translate")).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("returns false for --no-translate", () => {
|
|
37
|
+
expect(parseTranslateCliOption("--no-translate")).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("returns null for unrecognized args", () => {
|
|
41
|
+
expect(parseTranslateCliOption("--other")).toBeNull();
|
|
42
|
+
expect(parseTranslateCliOption("translate")).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("parseReasoningCliOption", () => {
|
|
47
|
+
it("returns mode 'on' for --think", () => {
|
|
48
|
+
const result = parseReasoningCliOption(["--think"], 0);
|
|
49
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "on" });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("returns null for unrelated args", () => {
|
|
53
|
+
expect(parseReasoningCliOption(["--model"], 0)).toBeNull();
|
|
54
|
+
expect(parseReasoningCliOption(["foo"], 0)).toBeNull();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("parses --reasoning-mode with valid value", () => {
|
|
58
|
+
const result = parseReasoningCliOption(
|
|
59
|
+
["--reasoning-mode", "interleaved"],
|
|
60
|
+
0
|
|
61
|
+
);
|
|
62
|
+
expect(result).toEqual({ consumedArgs: 1, mode: "interleaved" });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("falls back to default when --reasoning-mode value is missing", () => {
|
|
66
|
+
const result = parseReasoningCliOption(["--reasoning-mode"], 0);
|
|
67
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "off" });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("falls back to default when --reasoning-mode is followed by another flag", () => {
|
|
71
|
+
const result = parseReasoningCliOption(["--reasoning-mode", "--model"], 0);
|
|
72
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "off" });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("falls back to default for invalid reasoning mode value", () => {
|
|
76
|
+
const result = parseReasoningCliOption(["--reasoning-mode", "garbage"], 0);
|
|
77
|
+
expect(result).toEqual({ consumedArgs: 1, mode: "off" });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("handles valid aliases like 'enable' → 'on'", () => {
|
|
81
|
+
const result = parseReasoningCliOption(["--reasoning-mode", "enable"], 0);
|
|
82
|
+
expect(result).toEqual({ consumedArgs: 1, mode: "on" });
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("parseToolFallbackCliOption", () => {
|
|
87
|
+
it("returns null for unrelated args", () => {
|
|
88
|
+
expect(parseToolFallbackCliOption(["--model"], 0)).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("parses --toolcall-mode with valid value", () => {
|
|
92
|
+
const result = parseToolFallbackCliOption(
|
|
93
|
+
["--toolcall-mode", "morphxml"],
|
|
94
|
+
0
|
|
95
|
+
);
|
|
96
|
+
expect(result).toEqual({ consumedArgs: 1, mode: "morphxml" });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("uses DEFAULT_TOOL_FALLBACK_MODE when --toolcall-mode has no value", () => {
|
|
100
|
+
const result = parseToolFallbackCliOption(["--toolcall-mode"], 0);
|
|
101
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "disable" });
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("uses DEFAULT_TOOL_FALLBACK_MODE when --toolcall-mode is followed by a flag", () => {
|
|
105
|
+
const result = parseToolFallbackCliOption(
|
|
106
|
+
["--toolcall-mode", "--model"],
|
|
107
|
+
0
|
|
108
|
+
);
|
|
109
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "disable" });
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("parses --tool-fallback with valid value", () => {
|
|
113
|
+
const result = parseToolFallbackCliOption(["--tool-fallback", "hermes"], 0);
|
|
114
|
+
expect(result).toEqual({ consumedArgs: 1, mode: "hermes" });
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("uses LEGACY_ENABLED mode when --tool-fallback has no value", () => {
|
|
118
|
+
const result = parseToolFallbackCliOption(["--tool-fallback"], 0);
|
|
119
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "morphxml" });
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("uses LEGACY_ENABLED mode when --tool-fallback is followed by a flag", () => {
|
|
123
|
+
const result = parseToolFallbackCliOption(
|
|
124
|
+
["--tool-fallback", "--other"],
|
|
125
|
+
0
|
|
126
|
+
);
|
|
127
|
+
expect(result).toEqual({ consumedArgs: 0, mode: "morphxml" });
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("falls back to appropriate default for invalid value", () => {
|
|
131
|
+
const toolcall = parseToolFallbackCliOption(
|
|
132
|
+
["--toolcall-mode", "garbage"],
|
|
133
|
+
0
|
|
134
|
+
);
|
|
135
|
+
expect(toolcall).toEqual({ consumedArgs: 1, mode: "disable" });
|
|
136
|
+
|
|
137
|
+
const fallback = parseToolFallbackCliOption(
|
|
138
|
+
["--tool-fallback", "garbage"],
|
|
139
|
+
0
|
|
140
|
+
);
|
|
141
|
+
expect(fallback).toEqual({ consumedArgs: 1, mode: "morphxml" });
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("handles correct index in multi-arg arrays", () => {
|
|
145
|
+
const args = ["--model", "gpt-4", "--toolcall-mode", "hermes"];
|
|
146
|
+
expect(parseToolFallbackCliOption(args, 0)).toBeNull();
|
|
147
|
+
expect(parseToolFallbackCliOption(args, 2)).toEqual({
|
|
148
|
+
consumedArgs: 1,
|
|
149
|
+
mode: "hermes",
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
package/src/cli-args.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ProviderType } from "./agent";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_REASONING_MODE,
|
|
4
|
+
parseReasoningMode,
|
|
5
|
+
type ReasoningMode,
|
|
6
|
+
} from "./reasoning-mode";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_TOOL_FALLBACK_MODE,
|
|
9
|
+
LEGACY_ENABLED_TOOL_FALLBACK_MODE,
|
|
10
|
+
parseToolFallbackMode,
|
|
11
|
+
type ToolFallbackMode,
|
|
12
|
+
} from "./tool-fallback-mode";
|
|
13
|
+
|
|
14
|
+
export type { ProviderType };
|
|
15
|
+
|
|
16
|
+
export const parseProviderArg = (
|
|
17
|
+
providerArg: string | undefined
|
|
18
|
+
): ProviderType | null => {
|
|
19
|
+
if (providerArg === "anthropic" || providerArg === "friendli") {
|
|
20
|
+
return providerArg;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const parseTranslateCliOption = (arg: string): boolean | null => {
|
|
26
|
+
if (arg === "--translate") {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (arg === "--no-translate") {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const parseReasoningCliOption = (
|
|
36
|
+
args: string[],
|
|
37
|
+
index: number
|
|
38
|
+
): { consumedArgs: number; mode: ReasoningMode } | null => {
|
|
39
|
+
const arg = args[index];
|
|
40
|
+
if (arg === "--think") {
|
|
41
|
+
return { consumedArgs: 0, mode: "on" };
|
|
42
|
+
}
|
|
43
|
+
if (arg !== "--reasoning-mode") {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const candidate = args[index + 1];
|
|
47
|
+
if (candidate && !candidate.startsWith("--")) {
|
|
48
|
+
const parsedMode = parseReasoningMode(candidate);
|
|
49
|
+
return {
|
|
50
|
+
consumedArgs: 1,
|
|
51
|
+
mode: parsedMode ?? DEFAULT_REASONING_MODE,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
consumedArgs: 0,
|
|
56
|
+
mode: DEFAULT_REASONING_MODE,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const parseToolFallbackCliOption = (
|
|
61
|
+
args: string[],
|
|
62
|
+
index: number
|
|
63
|
+
): { consumedArgs: number; mode: ToolFallbackMode } | null => {
|
|
64
|
+
const arg = args[index];
|
|
65
|
+
|
|
66
|
+
const parseCandidate = (
|
|
67
|
+
fallbackMode: ToolFallbackMode
|
|
68
|
+
): { consumedArgs: number; mode: ToolFallbackMode } => {
|
|
69
|
+
const candidate = args[index + 1];
|
|
70
|
+
if (!candidate || candidate.startsWith("--")) {
|
|
71
|
+
return {
|
|
72
|
+
consumedArgs: 0,
|
|
73
|
+
mode: fallbackMode,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const parsedMode = parseToolFallbackMode(candidate);
|
|
77
|
+
return {
|
|
78
|
+
consumedArgs: 1,
|
|
79
|
+
mode: parsedMode ?? fallbackMode,
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (arg === "--toolcall-mode") {
|
|
84
|
+
return parseCandidate(DEFAULT_TOOL_FALLBACK_MODE);
|
|
85
|
+
}
|
|
86
|
+
if (arg === "--tool-fallback") {
|
|
87
|
+
return parseCandidate(LEGACY_ENABLED_TOOL_FALLBACK_MODE);
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
};
|