tarsk 0.3.43 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agent/agent.error-utils.d.ts +14 -0
- package/dist/agent/agent.error-utils.js +52 -0
- package/dist/agent/agent.event-transformer.d.ts +55 -0
- package/dist/agent/agent.event-transformer.js +175 -0
- package/dist/agent/agent.executor.d.ts +26 -0
- package/dist/agent/agent.executor.js +286 -0
- package/dist/agent/agent.model-resolver.d.ts +22 -0
- package/dist/agent/agent.model-resolver.js +67 -0
- package/dist/agent/agent.process-manager.d.ts +57 -0
- package/dist/agent/agent.process-manager.js +262 -0
- package/dist/agent/agent.processing-state-manager.d.ts +74 -0
- package/dist/agent/agent.processing-state-manager.js +87 -0
- package/dist/agent/agent.prompt-loader.d.ts +16 -0
- package/dist/agent/agent.prompt-loader.js +227 -0
- package/dist/agent/agent.subagent-executor.d.ts +35 -0
- package/dist/agent/agent.subagent-executor.js +135 -0
- package/dist/bun/index.d.ts +2 -0
- package/dist/bun/index.js +165 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +22 -0
- package/dist/core/crypto.d.ts +29 -0
- package/dist/core/crypto.js +166 -0
- package/dist/core/dev-server-cache.d.ts +46 -0
- package/dist/core/dev-server-cache.js +59 -0
- package/dist/core/env-manager.d.ts +3 -0
- package/dist/core/env-manager.js +60 -0
- package/dist/core/error-responses.d.ts +61 -0
- package/dist/core/error-responses.js +64 -0
- package/dist/core/logger.d.ts +10 -0
- package/dist/core/logger.js +47 -0
- package/dist/core/paths.d.ts +22 -0
- package/dist/core/paths.js +26 -0
- package/dist/core/random-words.d.ts +18 -0
- package/dist/core/random-words.js +135 -0
- package/dist/core/response-builder.d.ts +50 -0
- package/dist/core/response-builder.js +56 -0
- package/dist/core/route-helpers.d.ts +47 -0
- package/dist/core/route-helpers.js +54 -0
- package/dist/core/run-command-detector.d.ts +26 -0
- package/dist/core/run-command-detector.js +98 -0
- package/dist/core/stream-helper.d.ts +44 -0
- package/dist/core/stream-helper.js +50 -0
- package/dist/core/utils.d.ts +43 -0
- package/dist/core/utils.js +113 -0
- package/dist/core/validation.d.ts +10 -0
- package/dist/core/validation.js +20 -0
- package/dist/database/database.d.ts +40 -0
- package/dist/database/database.encryption.d.ts +33 -0
- package/dist/database/database.encryption.js +62 -0
- package/dist/database/database.js +480 -0
- package/dist/database/database.state.d.ts +52 -0
- package/dist/database/database.state.js +119 -0
- package/dist/database/database.test-utils.d.ts +22 -0
- package/dist/database/database.test-utils.js +39 -0
- package/dist/database/database.types.d.ts +3 -0
- package/dist/database/database.types.js +2 -0
- package/dist/features/agents/agents.manager.d.ts +24 -0
- package/dist/features/agents/agents.manager.js +200 -0
- package/dist/features/ask-user/ask-user.routes.d.ts +9 -0
- package/dist/features/ask-user/ask-user.routes.js +35 -0
- package/dist/features/chat/chat-delete.route.d.ts +15 -0
- package/dist/features/chat/chat-delete.route.js +36 -0
- package/dist/features/chat/chat-post.route.d.ts +11 -0
- package/dist/features/chat/chat-post.route.js +270 -0
- package/dist/features/chat/chat-stop.route.d.ts +21 -0
- package/dist/features/chat/chat-stop.route.js +22 -0
- package/dist/features/chat/chat-subscribe.route.d.ts +9 -0
- package/dist/features/chat/chat-subscribe.route.js +71 -0
- package/dist/features/chat/chat.routes.d.ts +22 -0
- package/dist/features/chat/chat.routes.js +29 -0
- package/dist/features/conversations/conversations-delete.route.d.ts +16 -0
- package/dist/features/conversations/conversations-delete.route.js +34 -0
- package/dist/features/conversations/conversations-get-all.route.d.ts +16 -0
- package/dist/features/conversations/conversations-get-all.route.js +39 -0
- package/dist/features/conversations/conversations-get-by-id.route.d.ts +16 -0
- package/dist/features/conversations/conversations-get-by-id.route.js +38 -0
- package/dist/features/conversations/conversations-get-deleted.route.d.ts +15 -0
- package/dist/features/conversations/conversations-get-deleted.route.js +34 -0
- package/dist/features/conversations/conversations-get-messages.route.d.ts +16 -0
- package/dist/features/conversations/conversations-get-messages.route.js +49 -0
- package/dist/features/conversations/conversations.content.d.ts +28 -0
- package/dist/features/conversations/conversations.content.js +142 -0
- package/dist/features/conversations/conversations.database.d.ts +108 -0
- package/dist/features/conversations/conversations.database.js +373 -0
- package/dist/features/conversations/conversations.manager.d.ts +130 -0
- package/dist/features/conversations/conversations.manager.js +162 -0
- package/dist/features/conversations/conversations.routes.d.ts +21 -0
- package/dist/features/conversations/conversations.routes.js +38 -0
- package/dist/features/conversations/token-usage.route.d.ts +41 -0
- package/dist/features/conversations/token-usage.route.js +419 -0
- package/dist/features/git/git-commit.route.d.ts +12 -0
- package/dist/features/git/git-commit.route.js +39 -0
- package/dist/features/git/git-create-branch.route.d.ts +28 -0
- package/dist/features/git/git-create-branch.route.js +119 -0
- package/dist/features/git/git-create-pr.route.d.ts +13 -0
- package/dist/features/git/git-create-pr.route.js +50 -0
- package/dist/features/git/git-create-repo.route.d.ts +14 -0
- package/dist/features/git/git-create-repo.route.js +108 -0
- package/dist/features/git/git-diff.route.d.ts +30 -0
- package/dist/features/git/git-diff.route.js +189 -0
- package/dist/features/git/git-fetch.route.d.ts +12 -0
- package/dist/features/git/git-fetch.route.js +31 -0
- package/dist/features/git/git-generate-commit-message.route.d.ts +12 -0
- package/dist/features/git/git-generate-commit-message.route.js +76 -0
- package/dist/features/git/git-generate-pr-info.route.d.ts +13 -0
- package/dist/features/git/git-generate-pr-info.route.js +147 -0
- package/dist/features/git/git-github-status.route.d.ts +16 -0
- package/dist/features/git/git-github-status.route.js +68 -0
- package/dist/features/git/git-log.route.d.ts +17 -0
- package/dist/features/git/git-log.route.js +33 -0
- package/dist/features/git/git-pr-status.route.d.ts +15 -0
- package/dist/features/git/git-pr-status.route.js +33 -0
- package/dist/features/git/git-pull.route.d.ts +12 -0
- package/dist/features/git/git-pull.route.js +35 -0
- package/dist/features/git/git-push.route.d.ts +12 -0
- package/dist/features/git/git-push.route.js +46 -0
- package/dist/features/git/git-status-cache.database.d.ts +7 -0
- package/dist/features/git/git-status-cache.database.js +53 -0
- package/dist/features/git/git-status.route.d.ts +15 -0
- package/dist/features/git/git-status.route.js +62 -0
- package/dist/features/git/git-sync-branch.route.d.ts +4 -0
- package/dist/features/git/git-sync-branch.route.js +208 -0
- package/dist/features/git/git-unified-status.route.d.ts +30 -0
- package/dist/features/git/git-unified-status.route.js +165 -0
- package/dist/features/git/git-username.route.d.ts +3 -0
- package/dist/features/git/git-username.route.js +24 -0
- package/dist/features/git/git.manager.d.ts +139 -0
- package/dist/features/git/git.manager.js +352 -0
- package/dist/features/git/git.routes.d.ts +4 -0
- package/dist/features/git/git.routes.js +116 -0
- package/dist/features/git/git.utils.d.ts +82 -0
- package/dist/features/git/git.utils.js +1040 -0
- package/dist/features/mcp/mcp.config.d.ts +27 -0
- package/dist/features/mcp/mcp.config.js +148 -0
- package/dist/features/mcp/mcp.manager.d.ts +61 -0
- package/dist/features/mcp/mcp.manager.js +254 -0
- package/dist/features/mcp/mcp.popular.json +103 -0
- package/dist/features/mcp/mcp.routes.d.ts +13 -0
- package/dist/features/mcp/mcp.routes.js +159 -0
- package/dist/features/mcp/mcp.types.d.ts +80 -0
- package/dist/features/mcp/mcp.types.js +8 -0
- package/dist/features/metadata/metadata.manager.d.ts +126 -0
- package/dist/features/metadata/metadata.manager.js +423 -0
- package/dist/features/models/model-info-aihubmix.d.ts +25 -0
- package/dist/features/models/model-info-aihubmix.js +117 -0
- package/dist/features/models/model-info-openrouter.d.ts +25 -0
- package/dist/features/models/model-info-openrouter.js +104 -0
- package/dist/features/models/model-info.d.ts +37 -0
- package/dist/features/models/model-info.js +39 -0
- package/dist/features/models/models-catalog.d.ts +49 -0
- package/dist/features/models/models-catalog.js +80 -0
- package/dist/features/models/models-catalog.route.d.ts +43 -0
- package/dist/features/models/models-catalog.route.js +15 -0
- package/dist/features/models/models-get-available.route.d.ts +36 -0
- package/dist/features/models/models-get-available.route.js +66 -0
- package/dist/features/models/models-get-enabled.route.d.ts +33 -0
- package/dist/features/models/models-get-enabled.route.js +45 -0
- package/dist/features/models/models-get-model-info.route.d.ts +31 -0
- package/dist/features/models/models-get-model-info.route.js +84 -0
- package/dist/features/models/models-model-disable.route.d.ts +15 -0
- package/dist/features/models/models-model-disable.route.js +20 -0
- package/dist/features/models/models-model-enable.route.d.ts +13 -0
- package/dist/features/models/models-model-enable.route.js +20 -0
- package/dist/features/models/models-provider-refresh.route.d.ts +17 -0
- package/dist/features/models/models-provider-refresh.route.js +20 -0
- package/dist/features/models/models.manager.d.ts +58 -0
- package/dist/features/models/models.manager.js +138 -0
- package/dist/features/models/models.routes.d.ts +18 -0
- package/dist/features/models/models.routes.js +83 -0
- package/dist/features/models/open-router-models.d.ts +38 -0
- package/dist/features/models/open-router-models.js +73 -0
- package/dist/features/models/openai-models.d.ts +63 -0
- package/dist/features/models/openai-models.js +150 -0
- package/dist/features/onboarding/onboarding-get-git-check.route.d.ts +11 -0
- package/dist/features/onboarding/onboarding-get-git-check.route.js +28 -0
- package/dist/features/onboarding/onboarding-get-status.route.d.ts +12 -0
- package/dist/features/onboarding/onboarding-get-status.route.js +15 -0
- package/dist/features/onboarding/onboarding-post-complete.route.d.ts +12 -0
- package/dist/features/onboarding/onboarding-post-complete.route.js +15 -0
- package/dist/features/onboarding/onboarding-post-reset.route.d.ts +12 -0
- package/dist/features/onboarding/onboarding-post-reset.route.js +15 -0
- package/dist/features/onboarding/onboarding.routes.d.ts +18 -0
- package/dist/features/onboarding/onboarding.routes.js +28 -0
- package/dist/features/project-todos/project-todos.database.d.ts +38 -0
- package/dist/features/project-todos/project-todos.database.js +91 -0
- package/dist/features/project-todos/project-todos.routes.d.ts +4 -0
- package/dist/features/project-todos/project-todos.routes.js +94 -0
- package/dist/features/projects/projects-ai-files.route.d.ts +148 -0
- package/dist/features/projects/projects-ai-files.route.js +425 -0
- package/dist/features/projects/projects-commands.route.d.ts +27 -0
- package/dist/features/projects/projects-commands.route.js +39 -0
- package/dist/features/projects/projects-create.route.d.ts +19 -0
- package/dist/features/projects/projects-create.route.js +37 -0
- package/dist/features/projects/projects-delete.route.d.ts +24 -0
- package/dist/features/projects/projects-delete.route.js +34 -0
- package/dist/features/projects/projects-get.route.d.ts +47 -0
- package/dist/features/projects/projects-get.route.js +36 -0
- package/dist/features/projects/projects-list.route.d.ts +58 -0
- package/dist/features/projects/projects-list.route.js +59 -0
- package/dist/features/projects/projects-open-folder.route.d.ts +10 -0
- package/dist/features/projects/projects-open-folder.route.js +11 -0
- package/dist/features/projects/projects-open.route.d.ts +26 -0
- package/dist/features/projects/projects-open.route.js +49 -0
- package/dist/features/projects/projects-package-scripts.route.d.ts +15 -0
- package/dist/features/projects/projects-package-scripts.route.js +96 -0
- package/dist/features/projects/projects-run-command.route.d.ts +8 -0
- package/dist/features/projects/projects-run-command.route.js +21 -0
- package/dist/features/projects/projects-run.route.d.ts +51 -0
- package/dist/features/projects/projects-run.route.js +74 -0
- package/dist/features/projects/projects-update.route.d.ts +24 -0
- package/dist/features/projects/projects-update.route.js +81 -0
- package/dist/features/projects/projects.creator.d.ts +33 -0
- package/dist/features/projects/projects.creator.js +555 -0
- package/dist/features/projects/projects.database.d.ts +61 -0
- package/dist/features/projects/projects.database.js +212 -0
- package/dist/features/projects/projects.manager.d.ts +291 -0
- package/dist/features/projects/projects.manager.js +426 -0
- package/dist/features/projects/projects.open-with.d.ts +27 -0
- package/dist/features/projects/projects.open-with.js +156 -0
- package/dist/features/projects/projects.routes.d.ts +20 -0
- package/dist/features/projects/projects.routes.js +255 -0
- package/dist/features/projects/terminal-session-manager.d.ts +55 -0
- package/dist/features/projects/terminal-session-manager.js +90 -0
- package/dist/features/providers/provider-resolver.d.ts +13 -0
- package/dist/features/providers/provider-resolver.js +22 -0
- package/dist/features/providers/providers-get-credits.route.d.ts +15 -0
- package/dist/features/providers/providers-get-credits.route.js +51 -0
- package/dist/features/providers/providers-get.route.d.ts +16 -0
- package/dist/features/providers/providers-get.route.js +32 -0
- package/dist/features/providers/providers-open-external.route.d.ts +15 -0
- package/dist/features/providers/providers-open-external.route.js +49 -0
- package/dist/features/providers/providers-post-bulk-keys.route.d.ts +14 -0
- package/dist/features/providers/providers-post-bulk-keys.route.js +31 -0
- package/dist/features/providers/providers-post-keys.route.d.ts +14 -0
- package/dist/features/providers/providers-post-keys.route.js +25 -0
- package/dist/features/providers/providers.routes.d.ts +19 -0
- package/dist/features/providers/providers.routes.js +31 -0
- package/dist/features/rules/rules-post.route.d.ts +43 -0
- package/dist/features/rules/rules-post.route.js +89 -0
- package/dist/features/rules/rules.manager.d.ts +36 -0
- package/dist/features/rules/rules.manager.js +203 -0
- package/dist/features/rules/rules.routes.d.ts +12 -0
- package/dist/features/rules/rules.routes.js +13 -0
- package/dist/features/run/run-get-running.route.d.ts +15 -0
- package/dist/features/run/run-get-running.route.js +21 -0
- package/dist/features/run/run-post-start.route.d.ts +8 -0
- package/dist/features/run/run-post-start.route.js +21 -0
- package/dist/features/run/run-post-stop.route.d.ts +15 -0
- package/dist/features/run/run-post-stop.route.js +24 -0
- package/dist/features/run/run-post-suggest.route.d.ts +15 -0
- package/dist/features/run/run-post-suggest.route.js +21 -0
- package/dist/features/run/run-put-command.route.d.ts +15 -0
- package/dist/features/run/run-put-command.route.js +24 -0
- package/dist/features/run/run.routes.d.ts +19 -0
- package/dist/features/run/run.routes.js +31 -0
- package/dist/features/scaffold/index.d.ts +7 -0
- package/dist/features/scaffold/index.js +5 -0
- package/dist/features/scaffold/scaffold-get-templates.route.d.ts +27 -0
- package/dist/features/scaffold/scaffold-get-templates.route.js +17 -0
- package/dist/features/scaffold/scaffold-post.route.d.ts +8 -0
- package/dist/features/scaffold/scaffold-post.route.js +30 -0
- package/dist/features/scaffold/scaffold.routes.d.ts +10 -0
- package/dist/features/scaffold/scaffold.routes.js +16 -0
- package/dist/features/scaffold/scaffold.runner.d.ts +48 -0
- package/dist/features/scaffold/scaffold.runner.js +475 -0
- package/dist/features/scaffold/scaffold.types.d.ts +26 -0
- package/dist/features/scaffold/scaffold.types.js +5 -0
- package/dist/features/skills/skills.activation.d.ts +31 -0
- package/dist/features/skills/skills.activation.js +155 -0
- package/dist/features/skills/skills.manager.d.ts +35 -0
- package/dist/features/skills/skills.manager.js +251 -0
- package/dist/features/slash-commands/slash-commands-delete.route.d.ts +23 -0
- package/dist/features/slash-commands/slash-commands-delete.route.js +36 -0
- package/dist/features/slash-commands/slash-commands-get.route.d.ts +53 -0
- package/dist/features/slash-commands/slash-commands-get.route.js +54 -0
- package/dist/features/slash-commands/slash-commands-post.route.d.ts +39 -0
- package/dist/features/slash-commands/slash-commands-post.route.js +70 -0
- package/dist/features/slash-commands/slash-commands-put.route.d.ts +23 -0
- package/dist/features/slash-commands/slash-commands-put.route.js +36 -0
- package/dist/features/slash-commands/slash-commands.manager.d.ts +46 -0
- package/dist/features/slash-commands/slash-commands.manager.js +265 -0
- package/dist/features/slash-commands/slash-commands.routes.d.ts +13 -0
- package/dist/features/slash-commands/slash-commands.routes.js +20 -0
- package/dist/features/threads/threads-ai-files.route.d.ts +153 -0
- package/dist/features/threads/threads-ai-files.route.js +287 -0
- package/dist/features/threads/threads-conversation-folder-path.route.d.ts +14 -0
- package/dist/features/threads/threads-conversation-folder-path.route.js +23 -0
- package/dist/features/threads/threads-create.route.d.ts +22 -0
- package/dist/features/threads/threads-create.route.js +60 -0
- package/dist/features/threads/threads-delete.route.d.ts +25 -0
- package/dist/features/threads/threads-delete.route.js +35 -0
- package/dist/features/threads/threads-files.route.d.ts +15 -0
- package/dist/features/threads/threads-files.route.js +20 -0
- package/dist/features/threads/threads-fix-comments.route.d.ts +26 -0
- package/dist/features/threads/threads-fix-comments.route.js +45 -0
- package/dist/features/threads/threads-get.route.d.ts +30 -0
- package/dist/features/threads/threads-get.route.js +38 -0
- package/dist/features/threads/threads-list.route.d.ts +56 -0
- package/dist/features/threads/threads-list.route.js +58 -0
- package/dist/features/threads/threads-messages.route.d.ts +28 -0
- package/dist/features/threads/threads-messages.route.js +110 -0
- package/dist/features/threads/threads-open.route.d.ts +26 -0
- package/dist/features/threads/threads-open.route.js +62 -0
- package/dist/features/threads/threads-select.route.d.ts +25 -0
- package/dist/features/threads/threads-select.route.js +35 -0
- package/dist/features/threads/threads-update.route.d.ts +15 -0
- package/dist/features/threads/threads-update.route.js +30 -0
- package/dist/features/threads/threads.database.d.ts +68 -0
- package/dist/features/threads/threads.database.js +215 -0
- package/dist/features/threads/threads.manager.d.ts +204 -0
- package/dist/features/threads/threads.manager.js +505 -0
- package/dist/features/threads/threads.routes.d.ts +20 -0
- package/dist/features/threads/threads.routes.js +230 -0
- package/dist/features/todos/todos.database.d.ts +14 -0
- package/dist/features/todos/todos.database.js +31 -0
- package/dist/features/updates/updates.routes.d.ts +13 -0
- package/dist/features/updates/updates.routes.js +40 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +37 -10022
- package/dist/project-analyzer.d.ts +26 -0
- package/dist/project-analyzer.js +307 -0
- package/dist/public/assets/add-agent-view-B9IQjAwU.js +1 -0
- package/dist/public/assets/add-rule-view-BdZHurB3.js +7 -0
- package/dist/public/assets/add-skill-view-Cuu6Z0fr.js +1 -0
- package/dist/public/assets/add-slash-command-view-uW75Jvbh.js +1 -0
- package/dist/public/assets/conversation-history-view-D0OBxJMC.js +1 -0
- package/dist/public/assets/dialogs-config-DiFQjCeA.js +46 -0
- package/dist/public/assets/diff-view-B5XBM5UZ.js +3 -0
- package/dist/public/assets/file-tree-sidebar-DMX7fHi7.js +1 -0
- package/dist/public/assets/files-view-CUZn7G0o.js +1 -0
- package/dist/public/assets/history-view-B8HM78Wa.js +1 -0
- package/dist/public/assets/index-C-p81QYw.js +17 -0
- package/dist/public/assets/index-DhVMb7D6.css +1 -0
- package/dist/public/assets/mcp-manager-CEm1L3dn.js +1 -0
- package/dist/public/assets/mcp-server-edit-view-BAwMNOAH.js +5 -0
- package/dist/public/assets/mcp-servers-sidebar-Ncxq9Oj5.js +1 -0
- package/dist/public/assets/mcp-view-Cz7nelGQ.js +1 -0
- package/dist/public/assets/monaco-DvsnxTfD.js +11 -0
- package/dist/public/assets/onboarding-CvpvkF3X.js +1 -0
- package/dist/public/assets/onboarding-dialog-CKJw0ULj.js +1 -0
- package/dist/public/assets/project-settings-view-DJ1uvrTL.js +1 -0
- package/dist/public/assets/provider-details-view-CkS6WbnK.js +1 -0
- package/dist/public/assets/providers-sidebar-C4MF6i9d.js +1 -0
- package/dist/public/assets/radio-group-BItFbSTw.js +1 -0
- package/dist/public/assets/react-vendor-DkKo9QGO.js +17 -0
- package/dist/public/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
- package/dist/public/assets/settings-view-C45kmAGH.js +2 -0
- package/dist/public/assets/store-BVVGurzl.js +2 -0
- package/dist/public/assets/use-toast-DEJkXPN4.js +1 -0
- package/dist/public/assets/utils-DY_quHB8.js +1 -0
- package/dist/public/fonts/google-sans.ttf +0 -0
- package/dist/public/fonts/zalando.ttf +0 -0
- package/dist/public/ide/android-studio.svg +1 -0
- package/dist/public/ide/cursor.svg +12 -0
- package/dist/public/ide/kiro.svg +11 -0
- package/dist/public/ide/terminal.svg +7 -0
- package/dist/public/ide/vscode.svg +2 -0
- package/dist/public/ide/windsurf.svg +3 -0
- package/dist/public/ide/xcode.svg +2 -0
- package/dist/public/index.html +13 -9
- package/dist/scaffold-templates.json +3 -12
- package/dist/server.d.ts +12 -0
- package/dist/server.js +142 -0
- package/dist/tools/agent-tool.d.ts +49 -0
- package/dist/tools/agent-tool.js +131 -0
- package/dist/tools/ask-user.d.ts +25 -0
- package/dist/tools/ask-user.js +74 -0
- package/dist/tools/ast-grep.d.ts +28 -0
- package/dist/tools/ast-grep.js +273 -0
- package/dist/tools/bash.d.ts +33 -0
- package/dist/tools/bash.js +186 -0
- package/dist/tools/edit-diff.d.ts +24 -0
- package/dist/tools/edit-diff.js +136 -0
- package/dist/tools/edit.d.ts +28 -0
- package/dist/tools/edit.js +78 -0
- package/dist/tools/find.d.ts +31 -0
- package/dist/tools/find.js +117 -0
- package/dist/tools/grep.d.ts +37 -0
- package/dist/tools/grep.js +231 -0
- package/dist/tools/index.d.ts +93 -0
- package/dist/tools/index.js +110 -0
- package/dist/tools/ls.d.ts +31 -0
- package/dist/tools/ls.js +108 -0
- package/dist/tools/mcp-tools.d.ts +31 -0
- package/dist/tools/mcp-tools.js +59 -0
- package/dist/tools/path-utils.d.ts +14 -0
- package/dist/tools/path-utils.js +87 -0
- package/dist/tools/read.d.ts +27 -0
- package/dist/tools/read.js +86 -0
- package/dist/tools/resolve-bin.d.ts +5 -0
- package/dist/tools/resolve-bin.js +28 -0
- package/dist/tools/shell.d.ts +7 -0
- package/dist/tools/shell.js +143 -0
- package/dist/tools/skill-reference-tool.d.ts +30 -0
- package/dist/tools/skill-reference-tool.js +171 -0
- package/dist/tools/skill-tool.d.ts +33 -0
- package/dist/tools/skill-tool.js +213 -0
- package/dist/tools/todo.d.ts +20 -0
- package/dist/tools/todo.js +168 -0
- package/dist/tools/tool-helpers.d.ts +78 -0
- package/dist/tools/tool-helpers.js +109 -0
- package/dist/tools/truncate.d.ts +31 -0
- package/dist/tools/truncate.js +164 -0
- package/dist/tools/write.d.ts +21 -0
- package/dist/tools/write.js +65 -0
- package/package.json +33 -27
- package/dist/public/assets/index-6jySngUQ.css +0 -1
- package/dist/public/assets/index-BjFpLTSj.js +0 -18
- package/dist/public/assets/monaco-w6PwaWGP.js +0 -11
- package/dist/public/assets/radix-ui-e1yigncZ.js +0 -1
- package/dist/public/assets/react-vendor-B6JfXZmN.js +0 -59
- package/dist/public/assets/ui-styling-CyCIFleB.js +0 -1
- package/dist/public/assets/utils-Dd_itR7L.js +0 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Script Tool
|
|
3
|
+
*
|
|
4
|
+
* Executes scripts from activated skills' scripts/ directories.
|
|
5
|
+
* Scripts can be written in any supported language (.sh, .py, .js, etc.)
|
|
6
|
+
*/
|
|
7
|
+
import { readdir } from "fs/promises";
|
|
8
|
+
import { join, extname } from "path";
|
|
9
|
+
import { existsSync, statSync } from "fs";
|
|
10
|
+
import { Type } from "@sinclair/typebox";
|
|
11
|
+
import { spawnProcess } from "../core/utils.js";
|
|
12
|
+
/**
|
|
13
|
+
* Get the interpreter for a script based on its extension
|
|
14
|
+
*/
|
|
15
|
+
function getInterpreter(scriptPath) {
|
|
16
|
+
const ext = extname(scriptPath);
|
|
17
|
+
switch (ext) {
|
|
18
|
+
case ".sh":
|
|
19
|
+
case ".bash":
|
|
20
|
+
return { command: "bash", args: [scriptPath] };
|
|
21
|
+
case ".py":
|
|
22
|
+
return { command: "python3", args: [scriptPath] };
|
|
23
|
+
case ".js":
|
|
24
|
+
return { command: "node", args: [scriptPath] };
|
|
25
|
+
case ".ts":
|
|
26
|
+
// Use bun to run TypeScript directly
|
|
27
|
+
return { command: "bun", args: ["run", scriptPath] };
|
|
28
|
+
default:
|
|
29
|
+
// Try to execute directly if it's executable
|
|
30
|
+
try {
|
|
31
|
+
const stats = statSync(scriptPath);
|
|
32
|
+
if (stats.mode & 0o111) {
|
|
33
|
+
// File is executable
|
|
34
|
+
return { command: scriptPath, args: [] };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Ignore stat errors
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Execute a skill script
|
|
45
|
+
*/
|
|
46
|
+
async function executeScript(scriptPath, args, cwd, timeout = 30) {
|
|
47
|
+
const interpreter = getInterpreter(scriptPath);
|
|
48
|
+
if (!interpreter) {
|
|
49
|
+
throw new Error(`Unsupported script type: ${scriptPath}`);
|
|
50
|
+
}
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
const child = spawnProcess(interpreter.command, [...interpreter.args, ...args], {
|
|
53
|
+
cwd,
|
|
54
|
+
timeout: timeout * 1000,
|
|
55
|
+
});
|
|
56
|
+
let stdout = "";
|
|
57
|
+
let stderr = "";
|
|
58
|
+
let timedOut = false;
|
|
59
|
+
if (child.stdout) {
|
|
60
|
+
child.stdout.on("data", (data) => {
|
|
61
|
+
stdout += data.toString();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (child.stderr) {
|
|
65
|
+
child.stderr.on("data", (data) => {
|
|
66
|
+
stderr += data.toString();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const timeoutHandle = setTimeout(() => {
|
|
70
|
+
timedOut = true;
|
|
71
|
+
child.kill("SIGTERM");
|
|
72
|
+
}, timeout * 1000);
|
|
73
|
+
child.on("error", (err) => {
|
|
74
|
+
clearTimeout(timeoutHandle);
|
|
75
|
+
reject(err);
|
|
76
|
+
});
|
|
77
|
+
child.on("close", (code) => {
|
|
78
|
+
clearTimeout(timeoutHandle);
|
|
79
|
+
if (timedOut) {
|
|
80
|
+
reject(new Error(`Script execution timed out after ${timeout}s`));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
resolve({ stdout, stderr, exitCode: code });
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Schema for skill script tool input
|
|
89
|
+
*/
|
|
90
|
+
const skillScriptSchema = Type.Object({
|
|
91
|
+
skillName: Type.String({ description: "Name of the skill" }),
|
|
92
|
+
scriptName: Type.String({ description: "Name of the script to execute (without path)" }),
|
|
93
|
+
args: Type.Optional(Type.Array(Type.String(), { description: "Arguments to pass to the script" })),
|
|
94
|
+
timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (default: 30)" })),
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Create a skill script executor tool
|
|
98
|
+
*/
|
|
99
|
+
export function createSkillScriptTool(skills, cwd) {
|
|
100
|
+
return {
|
|
101
|
+
name: "execute_skill_script",
|
|
102
|
+
label: "execute_skill_script",
|
|
103
|
+
description: "Execute a script from an activated skill. Skills provide executable scripts in their scripts/ directory.",
|
|
104
|
+
parameters: skillScriptSchema,
|
|
105
|
+
execute: async (_toolCallId, { skillName, scriptName, args = [], timeout = 30 }) => {
|
|
106
|
+
// Find the skill
|
|
107
|
+
const skill = skills.find((s) => s.name === skillName);
|
|
108
|
+
if (!skill) {
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: "text",
|
|
113
|
+
text: `Skill not found: ${skillName}. Available skills: ${skills.map((s) => s.name).join(", ")}`,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
details: undefined,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// Check if scripts directory exists
|
|
120
|
+
const scriptsDir = join(skill.skillPath, "scripts");
|
|
121
|
+
if (!existsSync(scriptsDir)) {
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{ type: "text", text: `Skill '${skillName}' has no scripts directory` },
|
|
125
|
+
],
|
|
126
|
+
details: undefined,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Find the script
|
|
130
|
+
const scriptPath = join(scriptsDir, scriptName);
|
|
131
|
+
if (!existsSync(scriptPath)) {
|
|
132
|
+
// List available scripts for better error message
|
|
133
|
+
try {
|
|
134
|
+
const availableScripts = await readdir(scriptsDir);
|
|
135
|
+
return {
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
type: "text",
|
|
139
|
+
text: `Script '${scriptName}' not found in skill '${skillName}'. Available scripts: ${availableScripts.join(", ")}`,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
details: undefined,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return {
|
|
147
|
+
content: [
|
|
148
|
+
{
|
|
149
|
+
type: "text",
|
|
150
|
+
text: `Script '${scriptName}' not found in skill '${skillName}'`,
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
details: undefined,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const result = await executeScript(scriptPath, args, cwd, timeout);
|
|
159
|
+
// Format output
|
|
160
|
+
let output = "";
|
|
161
|
+
if (result.stdout) {
|
|
162
|
+
output += `STDOUT:\n${result.stdout}\n`;
|
|
163
|
+
}
|
|
164
|
+
if (result.stderr) {
|
|
165
|
+
output += `STDERR:\n${result.stderr}\n`;
|
|
166
|
+
}
|
|
167
|
+
output += `Exit code: ${result.exitCode}\n`;
|
|
168
|
+
return {
|
|
169
|
+
content: [{ type: "text", text: output }],
|
|
170
|
+
details: undefined,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: "text",
|
|
178
|
+
text: `Failed to execute script: ${error instanceof Error ? error.message : String(error)}`,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
details: undefined,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* List all available skill scripts
|
|
189
|
+
*/
|
|
190
|
+
export async function listSkillScripts(skills) {
|
|
191
|
+
const scripts = [];
|
|
192
|
+
for (const skill of skills) {
|
|
193
|
+
const scriptsDir = join(skill.skillPath, "scripts");
|
|
194
|
+
if (!existsSync(scriptsDir))
|
|
195
|
+
continue;
|
|
196
|
+
try {
|
|
197
|
+
const files = await readdir(scriptsDir);
|
|
198
|
+
for (const file of files) {
|
|
199
|
+
const fullPath = join(scriptsDir, file);
|
|
200
|
+
scripts.push({
|
|
201
|
+
skillName: skill.name,
|
|
202
|
+
scriptName: file,
|
|
203
|
+
path: fullPath,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
console.error(`Failed to list scripts for skill ${skill.name}:`, error);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return scripts;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=skill-tool.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
declare const todoSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"update">, import("@sinclair/typebox").TLiteral<"list">, import("@sinclair/typebox").TLiteral<"delete">]>;
|
|
5
|
+
descriptions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
6
|
+
ids: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
7
|
+
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"pending">, import("@sinclair/typebox").TLiteral<"working">, import("@sinclair/typebox").TLiteral<"done">]>>;
|
|
8
|
+
assignedTo: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
|
+
}>;
|
|
10
|
+
export type TodoToolInput = Static<typeof todoSchema>;
|
|
11
|
+
export declare function createTodoTool(threadId: string): AgentTool<typeof todoSchema>;
|
|
12
|
+
export declare const todoTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
13
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"update">, import("@sinclair/typebox").TLiteral<"list">, import("@sinclair/typebox").TLiteral<"delete">]>;
|
|
14
|
+
descriptions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
15
|
+
ids: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
16
|
+
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"pending">, import("@sinclair/typebox").TLiteral<"working">, import("@sinclair/typebox").TLiteral<"done">]>>;
|
|
17
|
+
assignedTo: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
|
+
}>, any>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=todo.d.ts.map
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { getDatabase } from "../database/database.js";
|
|
3
|
+
import { fetchAllTodos, addTodos } from "../features/todos/todos.database.js";
|
|
4
|
+
const todoSchema = Type.Object({
|
|
5
|
+
action: Type.Union([Type.Literal("add"), Type.Literal("update"), Type.Literal("list"), Type.Literal("delete")], {
|
|
6
|
+
description: "Operation to perform: 'add' creates new items, 'update' changes status, 'list' returns all items, 'delete' removes items.",
|
|
7
|
+
}),
|
|
8
|
+
descriptions: Type.Optional(Type.Array(Type.String(), {
|
|
9
|
+
description: "Todo item descriptions. Required for 'add'. Provide one or more descriptions to create multiple items at once.",
|
|
10
|
+
})),
|
|
11
|
+
ids: Type.Optional(Type.Array(Type.String(), {
|
|
12
|
+
description: "Todo item IDs. Required for 'update' and 'delete'. Provide one or more IDs to update or delete multiple items at once.",
|
|
13
|
+
})),
|
|
14
|
+
status: Type.Optional(Type.Union([Type.Literal("pending"), Type.Literal("working"), Type.Literal("done")], {
|
|
15
|
+
description: "New status for 'update'. Applied to all specified IDs. 'pending' = not started, 'working' = in progress, 'done' = complete.",
|
|
16
|
+
})),
|
|
17
|
+
assignedTo: Type.Optional(Type.String({
|
|
18
|
+
description: "Who items are assigned to. Defaults to 'agent'. Applied to all specified items.",
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
21
|
+
export function createTodoTool(threadId) {
|
|
22
|
+
return {
|
|
23
|
+
name: "todo",
|
|
24
|
+
label: "todo",
|
|
25
|
+
description: "Manage todo items to break down the current task into 2 more items. Use 'add' to create items when planning work, 'update' to change an item's status as you progress (pending → working → done), 'list' to see all current items, and 'delete' to remove one. Marking an item done does not end the conversation — continue working on remaining items. Call 'list' at the end so the user sees a completion checklist.",
|
|
26
|
+
parameters: todoSchema,
|
|
27
|
+
execute: async (_toolCallId, { action, descriptions, ids, status, assignedTo }) => {
|
|
28
|
+
const db = await getDatabase();
|
|
29
|
+
const now = new Date().toISOString();
|
|
30
|
+
switch (action) {
|
|
31
|
+
case "add": {
|
|
32
|
+
const validDescriptions = descriptions?.filter((d) => d.trim());
|
|
33
|
+
if (!validDescriptions?.length) {
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{ type: "text", text: "Error: descriptions is required for 'add'" },
|
|
37
|
+
],
|
|
38
|
+
details: undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const todosAfterAdd = await addTodos(threadId, validDescriptions, assignedTo ?? "agent");
|
|
42
|
+
return {
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: "text",
|
|
46
|
+
text: JSON.stringify({ todos: todosAfterAdd }),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
details: undefined,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
case "update": {
|
|
53
|
+
if (!ids?.length) {
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: "text", text: "Error: ids is required for 'update'" }],
|
|
56
|
+
details: undefined,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const notFound = [];
|
|
60
|
+
for (const id of ids) {
|
|
61
|
+
const existing = await db.execute({
|
|
62
|
+
sql: `SELECT id FROM todos WHERE id = ? AND threadId = ?`,
|
|
63
|
+
args: [id, threadId],
|
|
64
|
+
});
|
|
65
|
+
if (existing.rows.length === 0) {
|
|
66
|
+
notFound.push(id);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const updates = [];
|
|
70
|
+
const args = [];
|
|
71
|
+
if (status) {
|
|
72
|
+
updates.push("status = ?");
|
|
73
|
+
args.push(status);
|
|
74
|
+
}
|
|
75
|
+
if (assignedTo !== undefined) {
|
|
76
|
+
updates.push("assignedTo = ?");
|
|
77
|
+
args.push(assignedTo);
|
|
78
|
+
}
|
|
79
|
+
updates.push("updatedAt = ?");
|
|
80
|
+
args.push(now);
|
|
81
|
+
args.push(id, threadId);
|
|
82
|
+
await db.execute({
|
|
83
|
+
sql: `UPDATE todos SET ${updates.join(", ")} WHERE id = ? AND threadId = ?`,
|
|
84
|
+
args,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (notFound.length > 0) {
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: `Error: todos not found: ${notFound.join(", ")}`,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
details: undefined,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const todosAfterUpdate = await fetchAllTodos(db, threadId);
|
|
99
|
+
// If all items are now done, delete them all
|
|
100
|
+
const allDone = todosAfterUpdate.length > 0 && todosAfterUpdate.every((t) => t.status === "done");
|
|
101
|
+
if (allDone) {
|
|
102
|
+
await db.execute({
|
|
103
|
+
sql: `DELETE FROM todos WHERE threadId = ?`,
|
|
104
|
+
args: [threadId],
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: "text",
|
|
111
|
+
text: JSON.stringify({ todos: allDone ? [] : todosAfterUpdate }),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
details: undefined,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
case "list": {
|
|
118
|
+
const todos = await fetchAllTodos(db, threadId);
|
|
119
|
+
return {
|
|
120
|
+
content: [
|
|
121
|
+
{
|
|
122
|
+
type: "text",
|
|
123
|
+
text: JSON.stringify({ todos }),
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
details: undefined,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
case "delete": {
|
|
130
|
+
if (!ids?.length) {
|
|
131
|
+
return {
|
|
132
|
+
content: [{ type: "text", text: "Error: ids is required for 'delete'" }],
|
|
133
|
+
details: undefined,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
for (const id of ids) {
|
|
137
|
+
await db.execute({
|
|
138
|
+
sql: `DELETE FROM todos WHERE id = ? AND threadId = ?`,
|
|
139
|
+
args: [id, threadId],
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const todosAfterDelete = await fetchAllTodos(db, threadId);
|
|
143
|
+
return {
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
type: "text",
|
|
147
|
+
text: JSON.stringify({ todos: todosAfterDelete }),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
details: undefined,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
return {
|
|
155
|
+
content: [
|
|
156
|
+
{
|
|
157
|
+
type: "text",
|
|
158
|
+
text: `Unknown action: ${String(action)}`,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
details: undefined,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export const todoTool = createTodoTool("");
|
|
168
|
+
//# sourceMappingURL=todo.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool helper utilities for reducing duplication in tool implementations
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Abort signal handling wrapper to eliminate boilerplate in tool execute functions
|
|
6
|
+
* - Tool result formatting utilities for consistent output across tools
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Wraps an async operation with abort signal handling
|
|
10
|
+
*
|
|
11
|
+
* Eliminates the need for each tool to implement the same abort signal
|
|
12
|
+
* setup, cleanup, and error handling logic.
|
|
13
|
+
*
|
|
14
|
+
* @param signal - Optional abort signal from the tool execution
|
|
15
|
+
* @param operation - The async operation to perform, receives an abort check function
|
|
16
|
+
* @returns Promise that resolves with the operation result or rejects if aborted
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* execute: async (_toolCallId, { path, content }, signal) => {
|
|
21
|
+
* return withAbortSignal(signal, async (isAborted) => {
|
|
22
|
+
* await ops.mkdir(dir);
|
|
23
|
+
* if (isAborted()) return { content: [], details: undefined };
|
|
24
|
+
* await ops.writeFile(absolutePath, content);
|
|
25
|
+
* return {
|
|
26
|
+
* content: [{ type: "text", text: `Successfully wrote ${content.length} bytes to ${path}` }],
|
|
27
|
+
* details: undefined,
|
|
28
|
+
* };
|
|
29
|
+
* });
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function withAbortSignal<T>(signal: AbortSignal | undefined, operation: (abortCheck: () => boolean) => Promise<T>): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Represents a notice message to be appended to tool output
|
|
36
|
+
*/
|
|
37
|
+
export interface ToolNotice {
|
|
38
|
+
/** Human-readable notice message */
|
|
39
|
+
message: string;
|
|
40
|
+
/** Key for the details object */
|
|
41
|
+
detailKey: string;
|
|
42
|
+
/** Value to include in details */
|
|
43
|
+
detailValue: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Formats tool output with optional notices appended
|
|
47
|
+
*
|
|
48
|
+
* Creates a consistent format for tool results that include notices
|
|
49
|
+
* (e.g., truncation warnings, result limits reached) and details metadata.
|
|
50
|
+
*
|
|
51
|
+
* @param baseOutput - The primary tool output text
|
|
52
|
+
* @param notices - Array of notices to append to the output
|
|
53
|
+
* @returns Object containing formatted output and optional details
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const notices: ToolNotice[] = [];
|
|
58
|
+
*
|
|
59
|
+
* if (resultLimitReached) {
|
|
60
|
+
* notices.push({
|
|
61
|
+
* message: `${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more`,
|
|
62
|
+
* detailKey: 'resultLimitReached',
|
|
63
|
+
* detailValue: effectiveLimit,
|
|
64
|
+
* });
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* const { output, details } = formatToolOutput(truncation.content, notices);
|
|
68
|
+
* return {
|
|
69
|
+
* content: [{ type: "text", text: output }],
|
|
70
|
+
* details,
|
|
71
|
+
* };
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function formatToolOutput(baseOutput: string, notices: ToolNotice[]): {
|
|
75
|
+
output: string;
|
|
76
|
+
details: Record<string, unknown> | undefined;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=tool-helpers.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool helper utilities for reducing duplication in tool implementations
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Abort signal handling wrapper to eliminate boilerplate in tool execute functions
|
|
6
|
+
* - Tool result formatting utilities for consistent output across tools
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Wraps an async operation with abort signal handling
|
|
10
|
+
*
|
|
11
|
+
* Eliminates the need for each tool to implement the same abort signal
|
|
12
|
+
* setup, cleanup, and error handling logic.
|
|
13
|
+
*
|
|
14
|
+
* @param signal - Optional abort signal from the tool execution
|
|
15
|
+
* @param operation - The async operation to perform, receives an abort check function
|
|
16
|
+
* @returns Promise that resolves with the operation result or rejects if aborted
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* execute: async (_toolCallId, { path, content }, signal) => {
|
|
21
|
+
* return withAbortSignal(signal, async (isAborted) => {
|
|
22
|
+
* await ops.mkdir(dir);
|
|
23
|
+
* if (isAborted()) return { content: [], details: undefined };
|
|
24
|
+
* await ops.writeFile(absolutePath, content);
|
|
25
|
+
* return {
|
|
26
|
+
* content: [{ type: "text", text: `Successfully wrote ${content.length} bytes to ${path}` }],
|
|
27
|
+
* details: undefined,
|
|
28
|
+
* };
|
|
29
|
+
* });
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export async function withAbortSignal(signal, operation) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
if (signal?.aborted) {
|
|
36
|
+
reject(new Error("Operation aborted"));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let aborted = false;
|
|
40
|
+
const onAbort = () => {
|
|
41
|
+
aborted = true;
|
|
42
|
+
reject(new Error("Operation aborted"));
|
|
43
|
+
};
|
|
44
|
+
if (signal) {
|
|
45
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
46
|
+
}
|
|
47
|
+
const cleanup = () => {
|
|
48
|
+
if (signal)
|
|
49
|
+
signal.removeEventListener("abort", onAbort);
|
|
50
|
+
};
|
|
51
|
+
const abortCheck = () => aborted;
|
|
52
|
+
operation(abortCheck)
|
|
53
|
+
.then((result) => {
|
|
54
|
+
cleanup();
|
|
55
|
+
if (!aborted)
|
|
56
|
+
resolve(result);
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
cleanup();
|
|
60
|
+
if (!aborted)
|
|
61
|
+
reject(error);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Formats tool output with optional notices appended
|
|
67
|
+
*
|
|
68
|
+
* Creates a consistent format for tool results that include notices
|
|
69
|
+
* (e.g., truncation warnings, result limits reached) and details metadata.
|
|
70
|
+
*
|
|
71
|
+
* @param baseOutput - The primary tool output text
|
|
72
|
+
* @param notices - Array of notices to append to the output
|
|
73
|
+
* @returns Object containing formatted output and optional details
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const notices: ToolNotice[] = [];
|
|
78
|
+
*
|
|
79
|
+
* if (resultLimitReached) {
|
|
80
|
+
* notices.push({
|
|
81
|
+
* message: `${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more`,
|
|
82
|
+
* detailKey: 'resultLimitReached',
|
|
83
|
+
* detailValue: effectiveLimit,
|
|
84
|
+
* });
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* const { output, details } = formatToolOutput(truncation.content, notices);
|
|
88
|
+
* return {
|
|
89
|
+
* content: [{ type: "text", text: output }],
|
|
90
|
+
* details,
|
|
91
|
+
* };
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function formatToolOutput(baseOutput, notices) {
|
|
95
|
+
let output = baseOutput;
|
|
96
|
+
const details = {};
|
|
97
|
+
if (notices.length > 0) {
|
|
98
|
+
const messages = notices.map((n) => n.message);
|
|
99
|
+
output += `\n\n[${messages.join(". ")}]`;
|
|
100
|
+
for (const notice of notices) {
|
|
101
|
+
details[notice.detailKey] = notice.detailValue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
output,
|
|
106
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=tool-helpers.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared truncation utilities for tool outputs.
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_MAX_LINES = 2000;
|
|
5
|
+
export declare const DEFAULT_MAX_BYTES: number;
|
|
6
|
+
export declare const GREP_MAX_LINE_LENGTH = 500;
|
|
7
|
+
export interface TruncationResult {
|
|
8
|
+
content: string;
|
|
9
|
+
truncated: boolean;
|
|
10
|
+
truncatedBy: "lines" | "bytes" | null;
|
|
11
|
+
totalLines: number;
|
|
12
|
+
totalBytes: number;
|
|
13
|
+
outputLines: number;
|
|
14
|
+
outputBytes: number;
|
|
15
|
+
lastLinePartial: boolean;
|
|
16
|
+
firstLineExceedsLimit: boolean;
|
|
17
|
+
maxLines: number;
|
|
18
|
+
maxBytes: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TruncationOptions {
|
|
21
|
+
maxLines?: number;
|
|
22
|
+
maxBytes?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function formatSize(bytes: number): string;
|
|
25
|
+
export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
|
|
26
|
+
export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
|
|
27
|
+
export declare function truncateLine(line: string, maxChars?: number): {
|
|
28
|
+
text: string;
|
|
29
|
+
wasTruncated: boolean;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=truncate.d.ts.map
|