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
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MANUAL_TOOL_LOOP_MAX_STEPS,
|
|
5
|
+
MessageHistory,
|
|
6
|
+
shouldContinueManualToolLoop,
|
|
7
|
+
} from "@ai-sdk-tool/harness";
|
|
8
|
+
import { agentManager, type ProviderType } from "../agent";
|
|
9
|
+
import {
|
|
10
|
+
parseProviderArg,
|
|
11
|
+
parseReasoningCliOption,
|
|
12
|
+
parseToolFallbackCliOption,
|
|
13
|
+
parseTranslateCliOption,
|
|
14
|
+
} from "../cli-args";
|
|
15
|
+
import { initializeSession } from "../context/session";
|
|
16
|
+
import { translateToEnglish } from "../context/translation";
|
|
17
|
+
import {
|
|
18
|
+
buildTodoContinuationUserMessage,
|
|
19
|
+
getIncompleteTodos,
|
|
20
|
+
} from "../middleware/todo-continuation";
|
|
21
|
+
import {
|
|
22
|
+
type ReasoningMode,
|
|
23
|
+
} from "../reasoning-mode";
|
|
24
|
+
import {
|
|
25
|
+
DEFAULT_TOOL_FALLBACK_MODE,
|
|
26
|
+
type ToolFallbackMode,
|
|
27
|
+
} from "../tool-fallback-mode";
|
|
28
|
+
import { cleanup } from "../tools/utils/execute/process-manager";
|
|
29
|
+
import { initializeTools } from "../utils/tools-manager";
|
|
30
|
+
import { applyHeadlessAgentConfig } from "./headless-agent-config";
|
|
31
|
+
|
|
32
|
+
interface BaseEvent {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
timestamp: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface UserEvent extends BaseEvent {
|
|
38
|
+
content: string;
|
|
39
|
+
type: "user";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface AssistantEvent extends BaseEvent {
|
|
43
|
+
content: string;
|
|
44
|
+
model: string;
|
|
45
|
+
reasoning_content?: string;
|
|
46
|
+
type: "assistant";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface ToolCallEvent extends BaseEvent {
|
|
50
|
+
model: string;
|
|
51
|
+
reasoning_content?: string;
|
|
52
|
+
tool_call_id: string;
|
|
53
|
+
tool_input: Record<string, unknown>;
|
|
54
|
+
tool_name: string;
|
|
55
|
+
type: "tool_call";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface ToolResultEvent extends BaseEvent {
|
|
59
|
+
error?: string;
|
|
60
|
+
exit_code?: number;
|
|
61
|
+
output: string;
|
|
62
|
+
tool_call_id: string;
|
|
63
|
+
type: "tool_result";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface ErrorEvent extends BaseEvent {
|
|
67
|
+
error: string;
|
|
68
|
+
type: "error";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type TrajectoryEvent =
|
|
72
|
+
| UserEvent
|
|
73
|
+
| AssistantEvent
|
|
74
|
+
| ToolCallEvent
|
|
75
|
+
| ToolResultEvent
|
|
76
|
+
| ErrorEvent;
|
|
77
|
+
|
|
78
|
+
const sessionId = initializeSession();
|
|
79
|
+
|
|
80
|
+
const cleanupExecutionResources = (): void => {
|
|
81
|
+
cleanup();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const exitWithCleanup = (code: number): never => {
|
|
85
|
+
cleanup(true);
|
|
86
|
+
process.exit(code);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
process.once("exit", () => {
|
|
90
|
+
cleanupExecutionResources();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
process.once("SIGINT", () => {
|
|
94
|
+
exitWithCleanup(0);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
process.once("SIGTERM", () => {
|
|
98
|
+
exitWithCleanup(143);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
process.once("SIGHUP", () => {
|
|
102
|
+
exitWithCleanup(129);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
process.once("SIGQUIT", () => {
|
|
106
|
+
exitWithCleanup(131);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
process.once("uncaughtException", (error: unknown) => {
|
|
110
|
+
console.error("Fatal error:", error);
|
|
111
|
+
exitWithCleanup(1);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
process.once("unhandledRejection", (reason: unknown) => {
|
|
115
|
+
console.error("Unhandled rejection:", reason);
|
|
116
|
+
exitWithCleanup(1);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const startTime = Date.now();
|
|
120
|
+
|
|
121
|
+
const emitEvent = (event: TrajectoryEvent): void => {
|
|
122
|
+
console.log(JSON.stringify(event));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const parsePromptOrModelOption = (
|
|
126
|
+
args: string[],
|
|
127
|
+
index: number
|
|
128
|
+
): { consumedArgs: number; kind: "prompt" | "model"; value: string } | null => {
|
|
129
|
+
const arg = args[index];
|
|
130
|
+
const value = args[index + 1] || "";
|
|
131
|
+
|
|
132
|
+
if (arg === "-p" || arg === "--prompt") {
|
|
133
|
+
return { consumedArgs: 1, kind: "prompt", value };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (arg === "-m" || arg === "--model") {
|
|
137
|
+
return { consumedArgs: 1, kind: "model", value };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const parseArgs = (): {
|
|
144
|
+
prompt: string;
|
|
145
|
+
model?: string;
|
|
146
|
+
provider: ProviderType | null;
|
|
147
|
+
reasoningMode: ReasoningMode | null;
|
|
148
|
+
toolFallbackMode: ToolFallbackMode;
|
|
149
|
+
translateUserPrompts: boolean;
|
|
150
|
+
} => {
|
|
151
|
+
const args = process.argv.slice(2);
|
|
152
|
+
let prompt = "";
|
|
153
|
+
let model: string | undefined;
|
|
154
|
+
let provider: ProviderType | null = null;
|
|
155
|
+
let reasoningMode: ReasoningMode | null = null;
|
|
156
|
+
let toolFallbackMode: ToolFallbackMode = DEFAULT_TOOL_FALLBACK_MODE;
|
|
157
|
+
let translateUserPrompts = true;
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < args.length; i++) {
|
|
160
|
+
const promptOrModelOption = parsePromptOrModelOption(args, i);
|
|
161
|
+
if (promptOrModelOption) {
|
|
162
|
+
if (promptOrModelOption.kind === "prompt") {
|
|
163
|
+
prompt = promptOrModelOption.value;
|
|
164
|
+
} else {
|
|
165
|
+
model = promptOrModelOption.value || undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
i += promptOrModelOption.consumedArgs;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const reasoningOption = parseReasoningCliOption(args, i);
|
|
173
|
+
if (reasoningOption) {
|
|
174
|
+
reasoningMode = reasoningOption.mode;
|
|
175
|
+
i += reasoningOption.consumedArgs;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (args[i] === "--provider" && i + 1 < args.length) {
|
|
180
|
+
provider = parseProviderArg(args[i + 1]) ?? provider;
|
|
181
|
+
i += 1;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const translateOption = parseTranslateCliOption(args[i]);
|
|
186
|
+
if (translateOption !== null) {
|
|
187
|
+
translateUserPrompts = translateOption;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const toolFallbackOption = parseToolFallbackCliOption(args, i);
|
|
192
|
+
if (toolFallbackOption) {
|
|
193
|
+
toolFallbackMode = toolFallbackOption.mode;
|
|
194
|
+
i += toolFallbackOption.consumedArgs;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!prompt) {
|
|
199
|
+
console.error(
|
|
200
|
+
"Usage: bun run src/entrypoints/headless.ts -p <prompt> [-m <model>] [--provider anthropic|friendli] [--translate|--no-translate] [--think] [--reasoning-mode <off|on|interleaved|preserved>] [--tool-fallback [mode]] [--toolcall-mode <mode>]"
|
|
201
|
+
);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
prompt,
|
|
207
|
+
model,
|
|
208
|
+
provider,
|
|
209
|
+
reasoningMode,
|
|
210
|
+
toolFallbackMode,
|
|
211
|
+
translateUserPrompts,
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const extractToolOutput = (
|
|
216
|
+
output: unknown
|
|
217
|
+
): { stdout: string; error?: string; exitCode?: number } => {
|
|
218
|
+
if (typeof output === "object" && output !== null && "output" in output) {
|
|
219
|
+
const result = output as {
|
|
220
|
+
output: string;
|
|
221
|
+
error?: string;
|
|
222
|
+
exit_code?: number;
|
|
223
|
+
};
|
|
224
|
+
return {
|
|
225
|
+
stdout: result.output || "",
|
|
226
|
+
error: result.error,
|
|
227
|
+
exitCode: result.exit_code,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return { stdout: String(output) };
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const getToolInputChunk = (part: {
|
|
234
|
+
delta?: unknown;
|
|
235
|
+
inputTextDelta?: unknown;
|
|
236
|
+
}): string | null => {
|
|
237
|
+
if (typeof part.delta === "string") {
|
|
238
|
+
return part.delta;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (typeof part.inputTextDelta === "string") {
|
|
242
|
+
return part.inputTextDelta;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return null;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const getToolInputId = (part: {
|
|
249
|
+
id?: string;
|
|
250
|
+
toolCallId?: string;
|
|
251
|
+
}): string | undefined => part.id ?? part.toolCallId;
|
|
252
|
+
|
|
253
|
+
interface PendingToolCall {
|
|
254
|
+
arguments: string;
|
|
255
|
+
id: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const handleToolInputStart = (
|
|
259
|
+
pendingToolCalls: Map<string, PendingToolCall>,
|
|
260
|
+
part: {
|
|
261
|
+
id?: string;
|
|
262
|
+
toolCallId?: string;
|
|
263
|
+
}
|
|
264
|
+
): void => {
|
|
265
|
+
const id = getToolInputId(part);
|
|
266
|
+
if (!id) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
pendingToolCalls.set(id, {
|
|
271
|
+
id,
|
|
272
|
+
arguments: "",
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const handleToolInputDelta = (
|
|
277
|
+
pendingToolCalls: Map<string, PendingToolCall>,
|
|
278
|
+
part: {
|
|
279
|
+
delta?: unknown;
|
|
280
|
+
id?: string;
|
|
281
|
+
inputTextDelta?: unknown;
|
|
282
|
+
toolCallId?: string;
|
|
283
|
+
}
|
|
284
|
+
): void => {
|
|
285
|
+
const toolCallId = getToolInputId(part);
|
|
286
|
+
const toolCallDelta = getToolInputChunk(part);
|
|
287
|
+
|
|
288
|
+
if (!toolCallId || toolCallDelta === null) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const existing = pendingToolCalls.get(toolCallId);
|
|
293
|
+
if (existing) {
|
|
294
|
+
existing.arguments += toolCallDelta;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
pendingToolCalls.set(toolCallId, {
|
|
299
|
+
id: toolCallId,
|
|
300
|
+
arguments: toolCallDelta,
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const emitToolCallEvent = (
|
|
305
|
+
completedToolCallIds: Set<string>,
|
|
306
|
+
modelId: string,
|
|
307
|
+
reasoningContent: string,
|
|
308
|
+
part: {
|
|
309
|
+
input: unknown;
|
|
310
|
+
toolCallId: string;
|
|
311
|
+
toolName: string;
|
|
312
|
+
}
|
|
313
|
+
): string => {
|
|
314
|
+
completedToolCallIds.add(part.toolCallId);
|
|
315
|
+
emitEvent({
|
|
316
|
+
timestamp: new Date().toISOString(),
|
|
317
|
+
type: "tool_call",
|
|
318
|
+
sessionId,
|
|
319
|
+
tool_call_id: part.toolCallId,
|
|
320
|
+
tool_name: part.toolName,
|
|
321
|
+
tool_input: part.input as Record<string, unknown>,
|
|
322
|
+
model: modelId,
|
|
323
|
+
reasoning_content: reasoningContent || undefined,
|
|
324
|
+
});
|
|
325
|
+
return "";
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const emitToolResultEvent = (part: {
|
|
329
|
+
output: unknown;
|
|
330
|
+
toolCallId: string;
|
|
331
|
+
}): void => {
|
|
332
|
+
const toolOutput = extractToolOutput(part.output);
|
|
333
|
+
emitEvent({
|
|
334
|
+
timestamp: new Date().toISOString(),
|
|
335
|
+
type: "tool_result",
|
|
336
|
+
sessionId,
|
|
337
|
+
tool_call_id: part.toolCallId,
|
|
338
|
+
output: toolOutput.stdout,
|
|
339
|
+
error: toolOutput.error,
|
|
340
|
+
exit_code: toolOutput.exitCode,
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const emitToolErrorEvent = (part: {
|
|
345
|
+
error: unknown;
|
|
346
|
+
toolCallId: string;
|
|
347
|
+
}): void => {
|
|
348
|
+
emitEvent({
|
|
349
|
+
timestamp: new Date().toISOString(),
|
|
350
|
+
type: "tool_result",
|
|
351
|
+
sessionId,
|
|
352
|
+
tool_call_id: part.toolCallId,
|
|
353
|
+
output: "",
|
|
354
|
+
error:
|
|
355
|
+
part.error instanceof Error ? part.error.message : String(part.error),
|
|
356
|
+
exit_code: 1,
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const emitMalformedToolCallErrors = (
|
|
361
|
+
completedToolCallIds: Set<string>,
|
|
362
|
+
pendingToolCalls: Map<string, PendingToolCall>
|
|
363
|
+
): void => {
|
|
364
|
+
for (const [id, pending] of pendingToolCalls) {
|
|
365
|
+
if (completedToolCallIds.has(id)) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
emitEvent({
|
|
370
|
+
timestamp: new Date().toISOString(),
|
|
371
|
+
type: "error",
|
|
372
|
+
sessionId,
|
|
373
|
+
error: `Tool call failed: malformed JSON in tool arguments (id: ${id}). Raw arguments: ${pending.arguments.slice(0, 500)}`,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const emitMalformedToolCallsSummary = (
|
|
379
|
+
completedToolCallIds: Set<string>,
|
|
380
|
+
lastFinishReason: string | undefined,
|
|
381
|
+
pendingToolCalls: Map<string, PendingToolCall>
|
|
382
|
+
): void => {
|
|
383
|
+
if (
|
|
384
|
+
lastFinishReason !== "tool-calls" ||
|
|
385
|
+
pendingToolCalls.size === 0 ||
|
|
386
|
+
completedToolCallIds.size > 0
|
|
387
|
+
) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
emitEvent({
|
|
392
|
+
timestamp: new Date().toISOString(),
|
|
393
|
+
type: "error",
|
|
394
|
+
sessionId,
|
|
395
|
+
error:
|
|
396
|
+
"Model attempted tool calls but all failed due to malformed JSON. This is likely a model bug with JSON escaping in tool arguments.",
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const processAgentResponse = async (
|
|
401
|
+
messageHistory: MessageHistory
|
|
402
|
+
): Promise<void> => {
|
|
403
|
+
const modelId = agentManager.getModelId();
|
|
404
|
+
let manualToolLoopCount = 0;
|
|
405
|
+
|
|
406
|
+
while (true) {
|
|
407
|
+
const stream = await agentManager.stream(messageHistory.toModelMessages());
|
|
408
|
+
|
|
409
|
+
let currentText = "";
|
|
410
|
+
let currentReasoning = "";
|
|
411
|
+
const pendingToolCalls = new Map<string, PendingToolCall>();
|
|
412
|
+
const completedToolCallIds = new Set<string>();
|
|
413
|
+
let lastFinishReason: string | undefined;
|
|
414
|
+
|
|
415
|
+
for await (const part of stream.fullStream) {
|
|
416
|
+
switch (part.type) {
|
|
417
|
+
case "text-delta":
|
|
418
|
+
currentText += part.text;
|
|
419
|
+
break;
|
|
420
|
+
case "reasoning-delta":
|
|
421
|
+
currentReasoning += part.text;
|
|
422
|
+
break;
|
|
423
|
+
case "tool-input-start":
|
|
424
|
+
handleToolInputStart(pendingToolCalls, part);
|
|
425
|
+
break;
|
|
426
|
+
case "tool-input-delta":
|
|
427
|
+
handleToolInputDelta(pendingToolCalls, part);
|
|
428
|
+
break;
|
|
429
|
+
case "tool-input-end":
|
|
430
|
+
break;
|
|
431
|
+
case "tool-call":
|
|
432
|
+
currentReasoning = emitToolCallEvent(
|
|
433
|
+
completedToolCallIds,
|
|
434
|
+
modelId,
|
|
435
|
+
currentReasoning,
|
|
436
|
+
part
|
|
437
|
+
);
|
|
438
|
+
break;
|
|
439
|
+
case "tool-result":
|
|
440
|
+
emitToolResultEvent(part);
|
|
441
|
+
break;
|
|
442
|
+
case "tool-error":
|
|
443
|
+
emitToolErrorEvent(part);
|
|
444
|
+
break;
|
|
445
|
+
case "finish-step": {
|
|
446
|
+
const finishPart = part as Extract<
|
|
447
|
+
typeof part,
|
|
448
|
+
{ type: "finish-step" }
|
|
449
|
+
>;
|
|
450
|
+
lastFinishReason = finishPart.finishReason;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
default:
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
emitMalformedToolCallErrors(completedToolCallIds, pendingToolCalls);
|
|
459
|
+
emitMalformedToolCallsSummary(
|
|
460
|
+
completedToolCallIds,
|
|
461
|
+
lastFinishReason,
|
|
462
|
+
pendingToolCalls
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
const [response, finishReason] = await Promise.all([
|
|
466
|
+
stream.response,
|
|
467
|
+
stream.finishReason,
|
|
468
|
+
]);
|
|
469
|
+
messageHistory.addModelMessages(response.messages);
|
|
470
|
+
|
|
471
|
+
if (currentText.trim()) {
|
|
472
|
+
emitEvent({
|
|
473
|
+
timestamp: new Date().toISOString(),
|
|
474
|
+
type: "assistant",
|
|
475
|
+
sessionId,
|
|
476
|
+
content: currentText,
|
|
477
|
+
model: modelId,
|
|
478
|
+
reasoning_content: currentReasoning || undefined,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Release map contents eagerly so tool-argument strings can be GC'd before next iteration
|
|
483
|
+
pendingToolCalls.clear();
|
|
484
|
+
completedToolCallIds.clear();
|
|
485
|
+
|
|
486
|
+
if (!shouldContinueManualToolLoop(finishReason)) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
manualToolLoopCount += 1;
|
|
491
|
+
if (manualToolLoopCount >= MANUAL_TOOL_LOOP_MAX_STEPS) {
|
|
492
|
+
emitEvent({
|
|
493
|
+
timestamp: new Date().toISOString(),
|
|
494
|
+
type: "error",
|
|
495
|
+
sessionId,
|
|
496
|
+
error: `Manual tool loop safety cap reached (${MANUAL_TOOL_LOOP_MAX_STEPS}).`,
|
|
497
|
+
});
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const run = async (): Promise<void> => {
|
|
504
|
+
await initializeTools();
|
|
505
|
+
|
|
506
|
+
const {
|
|
507
|
+
prompt,
|
|
508
|
+
model,
|
|
509
|
+
provider,
|
|
510
|
+
reasoningMode,
|
|
511
|
+
toolFallbackMode,
|
|
512
|
+
translateUserPrompts,
|
|
513
|
+
} = parseArgs();
|
|
514
|
+
|
|
515
|
+
applyHeadlessAgentConfig(agentManager, {
|
|
516
|
+
model,
|
|
517
|
+
provider,
|
|
518
|
+
reasoningMode,
|
|
519
|
+
toolFallbackMode,
|
|
520
|
+
translateUserPrompts,
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
const messageHistory = new MessageHistory();
|
|
524
|
+
const preparedPrompt = agentManager.isTranslationEnabled()
|
|
525
|
+
? await translateToEnglish(prompt, agentManager)
|
|
526
|
+
: {
|
|
527
|
+
translated: false,
|
|
528
|
+
text: prompt,
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
emitEvent({
|
|
532
|
+
timestamp: new Date().toISOString(),
|
|
533
|
+
type: "user",
|
|
534
|
+
sessionId,
|
|
535
|
+
content: prompt,
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
if (preparedPrompt.error) {
|
|
539
|
+
emitEvent({
|
|
540
|
+
timestamp: new Date().toISOString(),
|
|
541
|
+
type: "error",
|
|
542
|
+
sessionId,
|
|
543
|
+
error: `[translation] Failed to translate input: ${preparedPrompt.error}. Using original text.`,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
messageHistory.addUserMessage(
|
|
548
|
+
preparedPrompt.text,
|
|
549
|
+
preparedPrompt.originalText
|
|
550
|
+
);
|
|
551
|
+
try {
|
|
552
|
+
await processAgentResponse(messageHistory);
|
|
553
|
+
|
|
554
|
+
const MAX_TODO_REMINDER_ITERATIONS = 20;
|
|
555
|
+
let todoReminderCount = 0;
|
|
556
|
+
|
|
557
|
+
while (true) {
|
|
558
|
+
const incompleteTodos = await getIncompleteTodos();
|
|
559
|
+
if (incompleteTodos.length === 0) {
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
todoReminderCount += 1;
|
|
564
|
+
if (todoReminderCount > MAX_TODO_REMINDER_ITERATIONS) {
|
|
565
|
+
emitEvent({
|
|
566
|
+
timestamp: new Date().toISOString(),
|
|
567
|
+
type: "error",
|
|
568
|
+
sessionId,
|
|
569
|
+
error: `Todo continuation safety cap reached (${MAX_TODO_REMINDER_ITERATIONS} reminders). Incomplete todos: ${incompleteTodos.map((t) => t.id).join(", ")}`,
|
|
570
|
+
});
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const reminder = buildTodoContinuationUserMessage(incompleteTodos);
|
|
575
|
+
emitEvent({
|
|
576
|
+
timestamp: new Date().toISOString(),
|
|
577
|
+
type: "user",
|
|
578
|
+
sessionId,
|
|
579
|
+
content: reminder,
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
const preparedReminder = agentManager.isTranslationEnabled()
|
|
583
|
+
? await translateToEnglish(reminder, agentManager)
|
|
584
|
+
: {
|
|
585
|
+
translated: false,
|
|
586
|
+
text: reminder,
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
if (preparedReminder.error) {
|
|
590
|
+
emitEvent({
|
|
591
|
+
timestamp: new Date().toISOString(),
|
|
592
|
+
type: "error",
|
|
593
|
+
sessionId,
|
|
594
|
+
error: `[translation] Failed to translate todo reminder: ${preparedReminder.error}. Using original text.`,
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
messageHistory.addUserMessage(
|
|
599
|
+
preparedReminder.text,
|
|
600
|
+
preparedReminder.originalText
|
|
601
|
+
);
|
|
602
|
+
await processAgentResponse(messageHistory);
|
|
603
|
+
}
|
|
604
|
+
} catch (error) {
|
|
605
|
+
emitEvent({
|
|
606
|
+
timestamp: new Date().toISOString(),
|
|
607
|
+
type: "error",
|
|
608
|
+
sessionId,
|
|
609
|
+
error: error instanceof Error ? error.message : String(error),
|
|
610
|
+
});
|
|
611
|
+
exitWithCleanup(1);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
cleanupExecutionResources();
|
|
615
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
616
|
+
console.error(`[headless] Completed in ${elapsed}s`);
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
run().catch((error: unknown) => {
|
|
620
|
+
console.error("Fatal error:", error);
|
|
621
|
+
exitWithCleanup(1);
|
|
622
|
+
});
|
package/src/env.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const env = createEnv({
|
|
5
|
+
server: {
|
|
6
|
+
FRIENDLI_TOKEN: z.string().min(1).optional(),
|
|
7
|
+
ANTHROPIC_API_KEY: z.string().min(1).optional(),
|
|
8
|
+
DEBUG_SHOW_FINISH_REASON: z.stringbool().default(false),
|
|
9
|
+
DEBUG_SHOW_TOOL_RESULTS: z.stringbool().default(false),
|
|
10
|
+
DEBUG_SHOW_RAW_TOOL_IO: z.stringbool().default(false),
|
|
11
|
+
},
|
|
12
|
+
runtimeEnv: process.env,
|
|
13
|
+
emptyStringAsUndefined: true,
|
|
14
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface FriendliReasoningToggleOnValueConfig {
|
|
2
|
+
preserved_toggle: boolean;
|
|
3
|
+
reasoning_toggle: boolean;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface FriendliReasoningModelConfig {
|
|
7
|
+
interleaved_field: string | null;
|
|
8
|
+
on_value: FriendliReasoningToggleOnValueConfig;
|
|
9
|
+
preserved_toggle: string | null;
|
|
10
|
+
reasoning_toggle: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FriendliModelInfo {
|
|
14
|
+
id: string;
|
|
15
|
+
masked?: boolean;
|
|
16
|
+
name?: string;
|
|
17
|
+
provider: "friendli";
|
|
18
|
+
reasoning: FriendliReasoningModelConfig | null;
|
|
19
|
+
type?: "serverless" | "dedicated";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DEFAULT_FRIENDLI_REASONING: FriendliReasoningModelConfig = {
|
|
23
|
+
reasoning_toggle: "enable_thinking",
|
|
24
|
+
preserved_toggle: "clear_thinking",
|
|
25
|
+
interleaved_field: "reasoning_content",
|
|
26
|
+
on_value: {
|
|
27
|
+
reasoning_toggle: true,
|
|
28
|
+
preserved_toggle: false,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const FRIENDLI_MODELS: readonly FriendliModelInfo[] = [
|
|
33
|
+
{
|
|
34
|
+
id: "MiniMaxAI/MiniMax-M2.5",
|
|
35
|
+
name: "MiniMax M2.5",
|
|
36
|
+
provider: "friendli",
|
|
37
|
+
type: "serverless",
|
|
38
|
+
reasoning: {
|
|
39
|
+
...DEFAULT_FRIENDLI_REASONING,
|
|
40
|
+
reasoning_toggle: null,
|
|
41
|
+
preserved_toggle: null,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "MiniMaxAI/MiniMax-M2.1",
|
|
46
|
+
name: "MiniMax M2.1",
|
|
47
|
+
provider: "friendli",
|
|
48
|
+
type: "serverless",
|
|
49
|
+
reasoning: {
|
|
50
|
+
...DEFAULT_FRIENDLI_REASONING,
|
|
51
|
+
reasoning_toggle: null,
|
|
52
|
+
preserved_toggle: null,
|
|
53
|
+
},
|
|
54
|
+
masked: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "zai-org/GLM-5",
|
|
58
|
+
name: "GLM 5",
|
|
59
|
+
provider: "friendli",
|
|
60
|
+
type: "serverless",
|
|
61
|
+
reasoning: {
|
|
62
|
+
...DEFAULT_FRIENDLI_REASONING,
|
|
63
|
+
},
|
|
64
|
+
masked: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "zai-org/GLM-4.7",
|
|
68
|
+
name: "GLM 4.7",
|
|
69
|
+
provider: "friendli",
|
|
70
|
+
type: "serverless",
|
|
71
|
+
reasoning: {
|
|
72
|
+
...DEFAULT_FRIENDLI_REASONING,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
] as const;
|
|
76
|
+
|
|
77
|
+
export const getFriendliModelById = (
|
|
78
|
+
modelId: string
|
|
79
|
+
): FriendliModelInfo | undefined => {
|
|
80
|
+
return FRIENDLI_MODELS.find((model) => model.id === modelId);
|
|
81
|
+
};
|