Changesets · Branches · Tags · Compare
| Changeset | df04de9d7ffe87078a1f0f7e57fd48a7122bc28ebace634903b6af63c8f768c5 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-25 16:54 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-09-25 16:54 -07:00 |
| Parents | ece2990dc091, 5314170e5809 |
101 files changed
| @@ -0,0 +1,3 @@ | ||
| 1 | +{ | |
| 2 | + "install": "npm i" | |
| 3 | +} |
| @@ -1,11 +1,17 @@ | ||
| 1 | 1 | name: Release @continuedev/llm-info |
| 2 | - | |
| 3 | 2 | on: |
| 4 | 3 | push: |
| 5 | 4 | branches: |
| 6 | 5 | - main |
| 7 | 6 | paths: |
| 8 | 7 | - "packages/llm-info/**" |
| 8 | + - ".github/workflows/release-llm-info.yml" | |
| 9 | + - ".github/workflows/reusable-release.yml" | |
| 10 | + | |
| 11 | +permissions: | |
| 12 | + contents: write | |
| 13 | + issues: write | |
| 14 | + pull-requests: write | |
| 9 | 15 | |
| 10 | 16 | jobs: |
| 11 | 17 | release: |
| @@ -16,14 +22,3 @@ | ||
| 16 | 22 | secrets: |
| 17 | 23 | SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} |
| 18 | 24 | SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} |
| 19 | - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| 20 | - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| 21 | - GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| 22 | - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} | |
| 23 | - AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} | |
| 24 | - AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} | |
| 25 | - AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} | |
| 26 | - AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} | |
| 27 | - VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} | |
| 28 | - RELACE_API_KEY: ${{ secrets.RELACE_API_KEY }} | |
| 29 | - INCEPTION_API_KEY: ${{ secrets.INCEPTION_API_KEY }} |
| @@ -1,302 +0,0 @@ | ||
| 1 | -name: Respond to @continuedev Comments | |
| 2 | - | |
| 3 | -on: | |
| 4 | - issue_comment: | |
| 5 | - types: [created] | |
| 6 | - pull_request_review_comment: | |
| 7 | - types: [created] | |
| 8 | - | |
| 9 | -permissions: | |
| 10 | - contents: write | |
| 11 | - pull-requests: write | |
| 12 | - issues: write | |
| 13 | - | |
| 14 | -jobs: | |
| 15 | - respond-to-comment: | |
| 16 | - # Only run on pull request comments | |
| 17 | - if: github.event_name == 'issue_comment' && github.event.issue.pull_request | |
| 18 | - runs-on: ubuntu-latest | |
| 19 | - | |
| 20 | - steps: | |
| 21 | - - name: Check if comment contains @continuedev | |
| 22 | - id: check-mention | |
| 23 | - run: | | |
| 24 | - # Create a temporary file to safely handle comment body with special characters | |
| 25 | - cat > /tmp/comment.txt << 'COMMENT_EOF' | |
| 26 | - ${{ github.event.comment.body }} | |
| 27 | - COMMENT_EOF | |
| 28 | - | |
| 29 | - if grep -q "@continuedev" /tmp/comment.txt; then | |
| 30 | - echo "contains_mention=true" >> $GITHUB_OUTPUT | |
| 31 | - else | |
| 32 | - echo "contains_mention=false" >> $GITHUB_OUTPUT | |
| 33 | - fi | |
| 34 | - | |
| 35 | - - name: Add eyes reaction to comment | |
| 36 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 37 | - uses: actions/github-script@v8 | |
| 38 | - with: | |
| 39 | - script: | | |
| 40 | - await github.rest.reactions.createForIssueComment({ | |
| 41 | - owner: context.repo.owner, | |
| 42 | - repo: context.repo.repo, | |
| 43 | - comment_id: ${{ github.event.comment.id }}, | |
| 44 | - content: 'eyes' | |
| 45 | - }); | |
| 46 | - | |
| 47 | - - name: Checkout PR branch | |
| 48 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 49 | - uses: actions/checkout@v5 | |
| 50 | - with: | |
| 51 | - token: ${{ secrets.GITHUB_TOKEN }} | |
| 52 | - fetch-depth: 0 | |
| 53 | - | |
| 54 | - - name: Get PR information | |
| 55 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 56 | - id: pr-info | |
| 57 | - uses: actions/github-script@v8 | |
| 58 | - with: | |
| 59 | - script: | | |
| 60 | - const { data: pr } = await github.rest.pulls.get({ | |
| 61 | - owner: context.repo.owner, | |
| 62 | - repo: context.repo.repo, | |
| 63 | - pull_number: context.issue.number | |
| 64 | - }); | |
| 65 | - | |
| 66 | - core.setOutput('head_ref', pr.head.ref); | |
| 67 | - core.setOutput('head_sha', pr.head.sha); | |
| 68 | - return pr; | |
| 69 | - | |
| 70 | - - name: Checkout PR branch | |
| 71 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 72 | - run: | | |
| 73 | - git checkout ${{ steps.pr-info.outputs.head_ref }} | |
| 74 | - | |
| 75 | - - name: Setup Node.js | |
| 76 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 77 | - uses: actions/setup-node@v5 | |
| 78 | - with: | |
| 79 | - node-version: "20" | |
| 80 | - | |
| 81 | - - name: Install Continue CLI globally | |
| 82 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 83 | - run: npm i -g @continuedev/cli | |
| 84 | - | |
| 85 | - - name: Start remote session | |
| 86 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 87 | - id: remote-session | |
| 88 | - env: | |
| 89 | - CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} | |
| 90 | - run: | | |
| 91 | - # Create a temporary file for the prompt to handle special characters and newlines properly | |
| 92 | - cat > /tmp/prompt.txt << 'PROMPT_EOF' | |
| 93 | - Please help with the following request from @${{ github.event.comment.user.login }} on PR #${{ github.event.issue.number }}: | |
| 94 | - | |
| 95 | - ${{ github.event.comment.body }} | |
| 96 | - | |
| 97 | - Please analyze the current PR, understand the request, implement the necessary changes, and commit them to this branch. | |
| 98 | - PROMPT_EOF | |
| 99 | - | |
| 100 | - # Debug output | |
| 101 | - echo "PROMPT content:" | |
| 102 | - cat /tmp/prompt.txt | |
| 103 | - | |
| 104 | - # Start remote session and capture JSON output | |
| 105 | - echo "Starting cn with prompt..." | |
| 106 | - SESSION_OUTPUT=$(cat /tmp/prompt.txt | cn remote -s --config continuedev/address-code-review --branch ${{ steps.pr-info.outputs.head_ref }}) | |
| 107 | - echo "Raw session output: $SESSION_OUTPUT" | |
| 108 | - | |
| 109 | - # Extract URL from JSON output | |
| 110 | - SESSION_URL=$(echo "$SESSION_OUTPUT" | jq -r '.url // empty') | |
| 111 | - | |
| 112 | - if [ -z "$SESSION_URL" ] || [ "$SESSION_URL" = "null" ]; then | |
| 113 | - echo "Failed to extract session URL from output: $SESSION_OUTPUT" | |
| 114 | - exit 1 | |
| 115 | - fi | |
| 116 | - | |
| 117 | - echo "session_url=$SESSION_URL" >> $GITHUB_OUTPUT | |
| 118 | - echo "✅ Started remote session: $SESSION_URL" | |
| 119 | - | |
| 120 | - - name: Comment with session URL | |
| 121 | - if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url | |
| 122 | - uses: actions/github-script@v8 | |
| 123 | - env: | |
| 124 | - ORIGINAL_COMMENT: ${{ github.event.comment.body }} | |
| 125 | - with: | |
| 126 | - script: | | |
| 127 | - const sessionUrl = '${{ steps.remote-session.outputs.session_url }}'; | |
| 128 | - const originalComment = process.env.ORIGINAL_COMMENT; | |
| 129 | - const commentBody = "I've started [a remote session](" + sessionUrl + ") to help with your request:\n> " + originalComment; | |
| 130 | - | |
| 131 | - await github.rest.issues.createComment({ | |
| 132 | - owner: context.repo.owner, | |
| 133 | - repo: context.repo.repo, | |
| 134 | - issue_number: context.issue.number, | |
| 135 | - body: commentBody | |
| 136 | - }); | |
| 137 | - | |
| 138 | - - name: Log session details | |
| 139 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 140 | - run: | | |
| 141 | - echo "✅ Successfully started remote session for comment from ${{ github.event.comment.user.login }} on PR #${{ github.event.issue.number }}" | |
| 142 | - echo "Session URL: ${{ steps.remote-session.outputs.session_url }}" | |
| 143 | - echo "Original comment:" | |
| 144 | - cat /tmp/comment.txt | |
| 145 | - | |
| 146 | - respond-to-review-comment: | |
| 147 | - # Only run on pull request review comments | |
| 148 | - if: github.event_name == 'pull_request_review_comment' | |
| 149 | - runs-on: ubuntu-latest | |
| 150 | - | |
| 151 | - steps: | |
| 152 | - - name: Check if comment contains @continuedev | |
| 153 | - id: check-mention | |
| 154 | - run: | | |
| 155 | - # Create a temporary file to safely handle comment body with special characters | |
| 156 | - cat > /tmp/review_comment.txt << 'COMMENT_EOF' | |
| 157 | - ${{ github.event.comment.body }} | |
| 158 | - COMMENT_EOF | |
| 159 | - | |
| 160 | - if grep -q "@continuedev" /tmp/review_comment.txt; then | |
| 161 | - echo "contains_mention=true" >> $GITHUB_OUTPUT | |
| 162 | - else | |
| 163 | - echo "contains_mention=false" >> $GITHUB_OUTPUT | |
| 164 | - fi | |
| 165 | - | |
| 166 | - - name: Add eyes reaction to comment | |
| 167 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 168 | - uses: actions/github-script@v8 | |
| 169 | - with: | |
| 170 | - script: | | |
| 171 | - await github.rest.reactions.createForPullRequestReviewComment({ | |
| 172 | - owner: context.repo.owner, | |
| 173 | - repo: context.repo.repo, | |
| 174 | - comment_id: ${{ github.event.comment.id }}, | |
| 175 | - content: 'eyes' | |
| 176 | - }); | |
| 177 | - | |
| 178 | - - name: Checkout PR branch | |
| 179 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 180 | - uses: actions/checkout@v5 | |
| 181 | - with: | |
| 182 | - token: ${{ secrets.GITHUB_TOKEN }} | |
| 183 | - fetch-depth: 0 | |
| 184 | - ref: ${{ github.event.pull_request.head.ref }} | |
| 185 | - | |
| 186 | - - name: Setup Node.js | |
| 187 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 188 | - uses: actions/setup-node@v5 | |
| 189 | - with: | |
| 190 | - node-version: "20" | |
| 191 | - | |
| 192 | - - name: Install Continue CLI globally | |
| 193 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 194 | - run: npm i -g @continuedev/cli | |
| 195 | - | |
| 196 | - - name: Get review context | |
| 197 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 198 | - id: review-context | |
| 199 | - uses: actions/github-script@v8 | |
| 200 | - with: | |
| 201 | - script: | | |
| 202 | - let reviewContext = ''; | |
| 203 | - | |
| 204 | - // Check if this comment is a reply to another review comment | |
| 205 | - if (context.payload.comment.in_reply_to_id) { | |
| 206 | - try { | |
| 207 | - const { data: originalComment } = await github.rest.pulls.getReviewComment({ | |
| 208 | - owner: context.repo.owner, | |
| 209 | - repo: context.repo.repo, | |
| 210 | - comment_id: context.payload.comment.in_reply_to_id | |
| 211 | - }); | |
| 212 | - | |
| 213 | - reviewContext = `**Original review comment by @${originalComment.user.login}:** | |
| 214 | - ${originalComment.body} | |
| 215 | - | |
| 216 | - **Reply by @${{ github.event.comment.user.login }}:** | |
| 217 | - ${{ github.event.comment.body }}`; | |
| 218 | - } catch (error) { | |
| 219 | - console.log('Could not fetch original comment, using current comment only'); | |
| 220 | - reviewContext = `**Review comment by @${{ github.event.comment.user.login }}:** | |
| 221 | - ${{ github.event.comment.body }}`; | |
| 222 | - } | |
| 223 | - } else { | |
| 224 | - reviewContext = `**Review comment by @${{ github.event.comment.user.login }}:** | |
| 225 | - ${{ github.event.comment.body }}`; | |
| 226 | - } | |
| 227 | - | |
| 228 | - core.setOutput('context', reviewContext); | |
| 229 | - | |
| 230 | - - name: Start remote session | |
| 231 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 232 | - id: remote-session | |
| 233 | - env: | |
| 234 | - CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} | |
| 235 | - run: | | |
| 236 | - # Debug: Echo the branch we're starting the session on | |
| 237 | - echo "Starting remote session on branch: ${{ github.event.pull_request.head.ref }}" | |
| 238 | - | |
| 239 | - # Create a temporary file for the prompt to handle special characters and newlines properly | |
| 240 | - cat > /tmp/prompt.txt << 'PROMPT_EOF' | |
| 241 | - Please help with the following code review discussion from PR #${{ github.event.pull_request.number }}: | |
| 242 | - | |
| 243 | - **File:** ${{ github.event.comment.path }} | |
| 244 | - **Line:** ${{ github.event.comment.line || github.event.comment.original_line || 'N/A' }} | |
| 245 | - | |
| 246 | - ${{ steps.review-context.outputs.context }} | |
| 247 | - | |
| 248 | - Please analyze the specific file and line mentioned, understand the review feedback and any discussion context, implement the necessary changes, and commit them to this branch. | |
| 249 | - PROMPT_EOF | |
| 250 | - | |
| 251 | - # Debug output | |
| 252 | - echo "PROMPT content:" | |
| 253 | - cat /tmp/prompt.txt | |
| 254 | - | |
| 255 | - # Start remote session and capture JSON output | |
| 256 | - echo "Starting cn with prompt..." | |
| 257 | - SESSION_OUTPUT=$(cat /tmp/prompt.txt | cn remote -s --config continuedev/address-code-review --branch ${{ github.event.pull_request.head.ref }}) | |
| 258 | - echo "Raw session output: $SESSION_OUTPUT" | |
| 259 | - | |
| 260 | - # Extract URL from JSON output | |
| 261 | - SESSION_URL=$(echo "$SESSION_OUTPUT" | jq -r '.url // empty') | |
| 262 | - | |
| 263 | - if [ -z "$SESSION_URL" ] || [ "$SESSION_URL" = "null" ]; then | |
| 264 | - echo "Failed to extract session URL from output: $SESSION_OUTPUT" | |
| 265 | - exit 1 | |
| 266 | - fi | |
| 267 | - | |
| 268 | - echo "session_url=$SESSION_URL" >> $GITHUB_OUTPUT | |
| 269 | - echo "✅ Started remote session: $SESSION_URL" | |
| 270 | - | |
| 271 | - - name: Comment with session URL | |
| 272 | - if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url | |
| 273 | - uses: actions/github-script@v8 | |
| 274 | - env: | |
| 275 | - ORIGINAL_COMMENT: ${{ github.event.comment.body }} | |
| 276 | - with: | |
| 277 | - script: | | |
| 278 | - const sessionUrl = '${{ steps.remote-session.outputs.session_url }}'; | |
| 279 | - const originalComment = process.env.ORIGINAL_COMMENT; | |
| 280 | - const commentBody = "I've started [a remote session](" + sessionUrl + ") to help with your request:\n> " + originalComment; | |
| 281 | - | |
| 282 | - const commentParams = { | |
| 283 | - owner: context.repo.owner, | |
| 284 | - repo: context.repo.repo, | |
| 285 | - pull_number: ${{ github.event.pull_request.number }}, | |
| 286 | - body: commentBody, | |
| 287 | - commit_id: '${{ github.event.pull_request.head.sha }}', | |
| 288 | - path: '${{ github.event.comment.path }}', | |
| 289 | - in_reply_to: ${{ github.event.comment.id }} | |
| 290 | - }; | |
| 291 | - | |
| 292 | - await github.rest.pulls.createReviewComment(commentParams); | |
| 293 | - | |
| 294 | - - name: Log session details | |
| 295 | - if: steps.check-mention.outputs.contains_mention == 'true' | |
| 296 | - run: | | |
| 297 | - echo "✅ Successfully started remote session for review comment from ${{ github.event.comment.user.login }} on PR #${{ github.event.pull_request.number }}" | |
| 298 | - echo "Session URL: ${{ steps.remote-session.outputs.session_url }}" | |
| 299 | - echo "File: ${{ github.event.comment.path }}" | |
| 300 | - echo "Line: ${{ github.event.comment.line }}" | |
| 301 | - echo "Original comment:" | |
| 302 | - cat /tmp/review_comment.txt |
| @@ -172,4 +172,7 @@ | ||
| 172 | 172 | .continuerules |
| 173 | 173 | **/.continue/assistants/ |
| 174 | 174 | **/.continue/agents/ |
| 175 | -keys | |
| No newline at the end of the file | ||
| 175 | +keys | |
| 176 | + | |
| 177 | +.channels_cache.json | |
| 178 | +.users_cache.json |
| @@ -0,0 +1,1 @@ | ||
| 1 | +npx lint-staged |
| @@ -11,9 +11,13 @@ | ||
| 11 | 11 | extensions/vscode/bin |
| 12 | 12 | extensions/vscode/build |
| 13 | 13 | extensions/vscode/out |
| 14 | +extensions/vscode/textmate-syntaxes | |
| 14 | 15 | extensions/vscode/gui |
| 15 | 16 | extensions/vscode/e2e/.test-extensions |
| 16 | 17 | extensions/vscode/e2e/test-continue |
| 18 | +extensions/vscode/e2e/_output | |
| 19 | +extensions/vscode/e2e/storage | |
| 20 | +extensions/vscode/e2e/vsix | |
| 17 | 21 | extensions/vscode/models |
| 18 | 22 | extensions/intellij/src/main/resources |
| 19 | 23 | gui/dist |
| @@ -26,4 +30,5 @@ | ||
| 26 | 30 | core/vendor |
| 27 | 31 | coverage |
| 28 | 32 | # e2e |
| 29 | -packages/continue-sdk | |
| No newline at the end of the file | ||
| 33 | +packages/continue-sdk | |
| 34 | +.conductor | |
| No newline at the end of the file |
| @@ -252,7 +252,7 @@ | ||
| 252 | 252 | 3. If your provider supports images, add it to the `PROVIDER_SUPPORTS_IMAGES` array |
| 253 | 253 | in [core/llm/autodetect.ts](./core/llm/autodetect.ts). |
| 254 | 254 | 4. Add a documentation page for your provider in [ |
| 255 | - `docs/docs/customize/model-providers/more`](./docs/docs/customize/model-providers/more). This should show an example | |
| 255 | + `docs/customize/model-providers/more`](./docs/customize/model-providers/more). This should show an example | |
| 256 | 256 | of configuring your provider in `config.yaml` and explain what options are available. |
| 257 | 257 | |
| 258 | 258 | ### Adding Models |
| @@ -4,6 +4,15 @@ | ||
| 4 | 4 | } from "@continuedev/config-yaml"; |
| 5 | 5 | import { joinPathsToUri } from "../../util/uri"; |
| 6 | 6 | |
| 7 | +function createRelativeRuleFilePathParts(ruleName: string): string[] { | |
| 8 | + const safeRuleName = sanitizeRuleName(ruleName); | |
| 9 | + return [".continue", "rules", `${safeRuleName}.${RULE_FILE_EXTENSION}`]; | |
| 10 | +} | |
| 11 | + | |
| 12 | +export function createRelativeRuleFilePath(ruleName: string): string { | |
| 13 | + return createRelativeRuleFilePathParts(ruleName).join("/"); | |
| 14 | +} | |
| 15 | + | |
| 7 | 16 | /** |
| 8 | 17 | * Creates the file path for a rule in the workspace .continue/rules directory |
| 9 | 18 | */ |
| @@ -11,11 +20,8 @@ | ||
| 11 | 20 | workspaceDir: string, |
| 12 | 21 | ruleName: string, |
| 13 | 22 | ): string { |
| 14 | - const safeRuleName = sanitizeRuleName(ruleName); | |
| 15 | 23 | return joinPathsToUri( |
| 16 | 24 | workspaceDir, |
| 17 | - ".continue", | |
| 18 | - "rules", | |
| 19 | - `${safeRuleName}.${RULE_FILE_EXTENSION}`, | |
| 25 | + ...createRelativeRuleFilePathParts(ruleName), | |
| 20 | 26 | ); |
| 21 | 27 | } |
| @@ -85,6 +85,7 @@ | ||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | async disconnect() { |
| 88 | + this.status = "not-connected"; | |
| 88 | 89 | this.abortController.abort(); |
| 89 | 90 | await this.client.close(); |
| 90 | 91 | await this.transport.close(); |
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | |
| 14 | 14 | public onConnectionsRefreshed?: () => void; |
| 15 | 15 | public connections: Map<string, MCPConnection> = new Map(); |
| 16 | + private disconnectedServers: string[] = []; | |
| 16 | 17 | |
| 17 | 18 | private abortController: AbortController = new AbortController(); |
| 18 | 19 | |
| @@ -25,6 +26,18 @@ | ||
| 25 | 26 | return MCPManagerSingleton.instance; |
| 26 | 27 | } |
| 27 | 28 | |
| 29 | + addDisconnectedServer(serverId: string) { | |
| 30 | + this.disconnectedServers.push(serverId); | |
| 31 | + } | |
| 32 | + removeDisconnectedServer(serverId: string) { | |
| 33 | + this.disconnectedServers = this.disconnectedServers.filter( | |
| 34 | + (server) => server !== serverId, | |
| 35 | + ); | |
| 36 | + } | |
| 37 | + getDisconnectedServers() { | |
| 38 | + return this.disconnectedServers; | |
| 39 | + } | |
| 40 | + | |
| 28 | 41 | createConnection(id: string, options: MCPOptions): MCPConnection { |
| 29 | 42 | if (this.connections.has(id)) { |
| 30 | 43 | return this.connections.get(id)!; |
| @@ -163,9 +176,19 @@ | ||
| 163 | 176 | }), |
| 164 | 177 | (async () => { |
| 165 | 178 | await Promise.all( |
| 166 | - Array.from(this.connections.values()).map(async (connection) => { | |
| 167 | - await connection.connectClient(force, this.abortController.signal); | |
| 168 | - }), | |
| 179 | + Array.from(this.connections.values()) | |
| 180 | + .filter( | |
| 181 | + (connection) => | |
| 182 | + !this.disconnectedServers.some( | |
| 183 | + (s) => s === connection.options.id, | |
| 184 | + ), | |
| 185 | + ) | |
| 186 | + .map(async (connection) => { | |
| 187 | + await connection.connectClient( | |
| 188 | + force, | |
| 189 | + this.abortController.signal, | |
| 190 | + ); | |
| 191 | + }), | |
| 169 | 192 | ); |
| 170 | 193 | if (this.onConnectionsRefreshed) { |
| 171 | 194 | this.onConnectionsRefreshed(); |
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | |
| 13 | 13 | import http from "http"; |
| 14 | 14 | import url from "url"; |
| 15 | -import crypto from "crypto"; | |
| 15 | +import { v4 as uuidv4 } from "uuid"; | |
| 16 | 16 | import { GlobalContext, GlobalContextType } from "../../util/GlobalContext"; |
| 17 | 17 | |
| 18 | 18 | // Use a Map to support concurrent authentications for different servers |
| @@ -249,7 +249,7 @@ | ||
| 249 | 249 | await authProvider.ensureRedirectUrl(); |
| 250 | 250 | |
| 251 | 251 | // Generate a unique state parameter for this auth flow |
| 252 | - const state = crypto.randomUUID(); | |
| 252 | + const state = uuidv4(); | |
| 253 | 253 | |
| 254 | 254 | // Store context for this specific server with state |
| 255 | 255 | authenticatingContexts.set(mcpServerUrl, { |
| @@ -492,6 +492,20 @@ | ||
| 492 | 492 | |
| 493 | 493 | on("mcp/reloadServer", async (msg) => { |
| 494 | 494 | await MCPManagerSingleton.getInstance().refreshConnection(msg.data.id); |
| 495 | + MCPManagerSingleton.getInstance().removeDisconnectedServer(msg.data.id); | |
| 496 | + }); | |
| 497 | + on("mcp/disconnectServer", async (msg) => { | |
| 498 | + const mcpConnection = MCPManagerSingleton.getInstance().getConnection( | |
| 499 | + msg.data.id, | |
| 500 | + ); | |
| 501 | + if (!mcpConnection) | |
| 502 | + throw new Error(`MCP connection with id ${msg.data.id} not found`); | |
| 503 | + MCPManagerSingleton.getInstance().addDisconnectedServer(msg.data.id); | |
| 504 | + await mcpConnection.disconnect(); | |
| 505 | + await this.configHandler.refreshAll("MCP Servers disconnected"); | |
| 506 | + }); | |
| 507 | + on("mcp/getDisconnectedServers", async (_msg) => { | |
| 508 | + return MCPManagerSingleton.getInstance().getDisconnectedServers(); | |
| 495 | 509 | }); |
| 496 | 510 | on("mcp/getPrompt", async (msg) => { |
| 497 | 511 | const { serverName, promptName, args } = msg.data; |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | const DEFAULT_CONTEXT_LENGTH = 32_768; |
| 3 | 3 | const DEFAULT_TEMPERATURE = 0.5; |
| 4 | 4 | const DEFAULT_PRUNING_LENGTH = 128000; |
| 5 | +const DEFAULT_REASONING_TOKENS = 2048; | |
| 5 | 6 | |
| 6 | 7 | const DEFAULT_ARGS = { |
| 7 | 8 | maxTokens: DEFAULT_MAX_TOKENS, |
| @@ -31,5 +32,6 @@ | ||
| 31 | 32 | DEFAULT_MAX_CHUNK_SIZE, |
| 32 | 33 | DEFAULT_MAX_TOKENS, |
| 33 | 34 | DEFAULT_PRUNING_LENGTH, |
| 35 | + DEFAULT_REASONING_TOKENS, | |
| 34 | 36 | PROXY_URL, |
| 35 | 37 | }; |
| @@ -65,7 +65,6 @@ | ||
| 65 | 65 | toCompleteBody, |
| 66 | 66 | toFimBody, |
| 67 | 67 | } from "./openaiTypeConverters.js"; |
| 68 | - | |
| 69 | 68 | export class LLMError extends Error { |
| 70 | 69 | constructor( |
| 71 | 70 | message: string, |
| @@ -214,7 +213,7 @@ | ||
| 214 | 213 | this.providerName === "continue-proxy" |
| 215 | 214 | ? this.model?.split("/").pop() || this.model |
| 216 | 215 | : this.model; |
| 217 | - const llmInfo = findLlmInfo(modelSearchString); | |
| 216 | + const llmInfo = findLlmInfo(modelSearchString, this.underlyingProviderName); | |
| 218 | 217 | |
| 219 | 218 | const templateType = |
| 220 | 219 | options.template ?? autodetectTemplateType(options.model); |
| @@ -558,12 +557,14 @@ | ||
| 558 | 557 | private _formatChatMessage(msg: ChatMessage): string { |
| 559 | 558 | let contentToShow = renderChatMessage(msg); |
| 560 | 559 | if (msg.role === "assistant" && msg.toolCalls?.length) { |
| 561 | - contentToShow += msg.toolCalls | |
| 562 | - ?.map( | |
| 563 | - (toolCall) => | |
| 564 | - `${toolCall.function?.name}(${toolCall.function?.arguments})`, | |
| 565 | - ) | |
| 566 | - .join("\n"); | |
| 560 | + contentToShow += | |
| 561 | + "\n" + | |
| 562 | + msg.toolCalls | |
| 563 | + ?.map( | |
| 564 | + (toolCall) => | |
| 565 | + `${toolCall.function?.name}(${toolCall.function?.arguments})`, | |
| 566 | + ) | |
| 567 | + .join("\n"); | |
| 567 | 568 | } |
| 568 | 569 | |
| 569 | 570 | return `<${msg.role}>\n${contentToShow}\n\n`; |
| @@ -58,6 +58,10 @@ | ||
| 58 | 58 | describe("LLM Pre-fetch", () => { |
| 59 | 59 | beforeEach(() => { |
| 60 | 60 | vi.resetAllMocks(); |
| 61 | + // Mock getAnthropicHeaders to return fake headers | |
| 62 | + vi.mocked(openAiAdapters.getAnthropicHeaders).mockReturnValue({ | |
| 63 | + fake: "headers", | |
| 64 | + }); | |
| 61 | 65 | // Log to verify the mock is properly set up |
| 62 | 66 | console.log("Mock setup:", openAiAdapters); |
| 63 | 67 | }); |
| @@ -1,30 +1,36 @@ | ||
| 1 | +import { | |
| 2 | + Tool as AnthropicTool, | |
| 3 | + ContentBlockParam, | |
| 4 | + MessageCreateParams, | |
| 5 | + MessageParam, | |
| 6 | + RawContentBlockDeltaEvent, | |
| 7 | + RawContentBlockStartEvent, | |
| 8 | + RawMessageDeltaEvent, | |
| 9 | + RawMessageStartEvent, | |
| 10 | + RawMessageStreamEvent, | |
| 11 | + ToolUseBlock, | |
| 12 | +} from "@anthropic-ai/sdk/resources/messages.mjs"; | |
| 1 | 13 | import { streamSse } from "@continuedev/fetch"; |
| 14 | +import { | |
| 15 | + addCacheControlToLastTwoUserMessages, | |
| 16 | + getAnthropicErrorMessage, | |
| 17 | + getAnthropicHeaders, | |
| 18 | + getAnthropicMediaTypeFromDataUrl, | |
| 19 | +} from "@continuedev/openai-adapters"; | |
| 2 | 20 | import { |
| 3 | 21 | ChatMessage, |
| 4 | 22 | CompletionOptions, |
| 5 | 23 | LLMOptions, |
| 24 | + MessageContent, | |
| 25 | + Tool, | |
| 26 | + ToolCallDelta, | |
| 6 | 27 | Usage, |
| 7 | 28 | } from "../../index.js"; |
| 8 | 29 | import { safeParseToolCallArgs } from "../../tools/parseArgs.js"; |
| 9 | 30 | import { renderChatMessage, stripImages } from "../../util/messageContent.js"; |
| 31 | +import { DEFAULT_REASONING_TOKENS } from "../constants.js"; | |
| 10 | 32 | import { BaseLLM } from "../index.js"; |
| 11 | 33 | |
| 12 | -const errorMessages = { | |
| 13 | - invalid_request_error: | |
| 14 | - "There was an issue with the format or content of your request.", | |
| 15 | - authentication_error: "There's an issue with your API key.", | |
| 16 | - permission_error: | |
| 17 | - "Your API key does not have permission to use the specified resource.", | |
| 18 | - not_found_error: "The requested resource was not found.", | |
| 19 | - request_too_large: | |
| 20 | - "Request exceeds the maximum allowed number of bytes (32 MB limit).", | |
| 21 | - rate_limit_error: "Your account has hit a rate limit.", | |
| 22 | - api_error: | |
| 23 | - "An unexpected error has occurred internal to Anthropic's systems.", | |
| 24 | - overloaded_error: | |
| 25 | - "Anthropic's API is temporarily overloaded. Please check their status page: https://status.anthropic.com/#past-incidents", | |
| 26 | -}; | |
| 27 | - | |
| 28 | 34 | class Anthropic extends BaseLLM { |
| 29 | 35 | static providerName = "anthropic"; |
| 30 | 36 | static defaultOptions: Partial<LLMOptions> = { |
| @@ -36,8 +42,21 @@ | ||
| 36 | 42 | apiBase: "https://api.anthropic.com/v1/", |
| 37 | 43 | }; |
| 38 | 44 | |
| 39 | - public convertArgs(options: CompletionOptions) { | |
| 40 | - // should be public for use within VertexAI | |
| 45 | + private convertToolToAnthropicTool(tool: Tool): AnthropicTool { | |
| 46 | + return { | |
| 47 | + name: tool.function.name, | |
| 48 | + description: tool.function.description, | |
| 49 | + input_schema: (tool.function.parameters as AnthropicTool.InputSchema) ?? { | |
| 50 | + // TODO unsafe tool.function.parameters casting | |
| 51 | + type: "object", | |
| 52 | + }, | |
| 53 | + }; | |
| 54 | + } | |
| 55 | + | |
| 56 | + // Public for use within VertexAI | |
| 57 | + public convertArgs( | |
| 58 | + options: CompletionOptions, | |
| 59 | + ): Omit<MessageCreateParams, "messages"> { | |
| 41 | 60 | const finalOptions = { |
| 42 | 61 | top_k: options.topK, |
| 43 | 62 | top_p: options.topP, |
| @@ -46,20 +65,17 @@ | ||
| 46 | 65 | model: options.model === "claude-2" ? "claude-2.1" : options.model, |
| 47 | 66 | stop_sequences: options.stop?.filter((x) => x.trim() !== ""), |
| 48 | 67 | stream: options.stream ?? true, |
| 49 | - tools: options.tools?.map((tool) => ({ | |
| 50 | - name: tool.function.name, | |
| 51 | - description: tool.function.description, | |
| 52 | - input_schema: tool.function.parameters, | |
| 53 | - })), | |
| 68 | + tools: options.tools?.map(this.convertToolToAnthropicTool), | |
| 54 | 69 | thinking: options.reasoning |
| 55 | 70 | ? { |
| 56 | - type: "enabled", | |
| 57 | - budget_tokens: options.reasoningBudgetTokens, | |
| 71 | + type: "enabled" as const, | |
| 72 | + budget_tokens: | |
| 73 | + options.reasoningBudgetTokens ?? DEFAULT_REASONING_TOKENS, | |
| 58 | 74 | } |
| 59 | 75 | : undefined, |
| 60 | 76 | tool_choice: options.toolChoice |
| 61 | 77 | ? { |
| 62 | - type: "tool", | |
| 78 | + type: "tool" as const, | |
| 63 | 79 | name: options.toolChoice.function.name, |
| 64 | 80 | } |
| 65 | 81 | : undefined, |
| @@ -68,138 +84,146 @@ | ||
| 68 | 84 | return finalOptions; |
| 69 | 85 | } |
| 70 | 86 | |
| 71 | - private buildTextPart(text: string, addCaching: boolean) { | |
| 72 | - const part: any = { | |
| 73 | - type: "text", | |
| 74 | - text, | |
| 75 | - }; | |
| 76 | - if (addCaching) { | |
| 77 | - part.cache_control = { type: "ephemeral" }; | |
| 87 | + private convertMessageContentToBlocks( | |
| 88 | + content: MessageContent, | |
| 89 | + ): ContentBlockParam[] { | |
| 90 | + if (typeof content === "string") { | |
| 91 | + return [ | |
| 92 | + { | |
| 93 | + type: "text", | |
| 94 | + text: content, | |
| 95 | + }, | |
| 96 | + ]; | |
| 78 | 97 | } |
| 79 | - return part; | |
| 98 | + return content.map((part) => { | |
| 99 | + if (part.type === "text") { | |
| 100 | + return { | |
| 101 | + type: "text", | |
| 102 | + text: part.text, | |
| 103 | + }; | |
| 104 | + } | |
| 105 | + return { | |
| 106 | + type: "image", | |
| 107 | + source: { | |
| 108 | + type: "base64", | |
| 109 | + media_type: getAnthropicMediaTypeFromDataUrl(part.imageUrl.url), | |
| 110 | + data: part.imageUrl.url.split(",")[1], | |
| 111 | + }, | |
| 112 | + }; | |
| 113 | + }); | |
| 80 | 114 | } |
| 81 | 115 | |
| 82 | - private convertMessage(message: ChatMessage, addCaching: boolean): any { | |
| 83 | - if (message.role === "tool") { | |
| 116 | + private convertToolCallsToBlocks( | |
| 117 | + toolCall: ToolCallDelta, | |
| 118 | + ): ToolUseBlock | undefined { | |
| 119 | + const toolCallId = toolCall.id; | |
| 120 | + const toolName = toolCall.function?.name; | |
| 121 | + if (toolCallId && toolName) { | |
| 84 | 122 | return { |
| 85 | - role: "user", | |
| 86 | - content: [ | |
| 123 | + type: "tool_use", | |
| 124 | + id: toolCallId, | |
| 125 | + name: toolName, | |
| 126 | + input: safeParseToolCallArgs(toolCall), | |
| 127 | + }; | |
| 128 | + } | |
| 129 | + } | |
| 130 | + | |
| 131 | + private getContentBlocksFromChatMessage( | |
| 132 | + message: ChatMessage, | |
| 133 | + ): ContentBlockParam[] { | |
| 134 | + switch (message.role) { | |
| 135 | + // One tool message = one tool_result block | |
| 136 | + case "tool": | |
| 137 | + return [ | |
| 87 | 138 | { |
| 88 | 139 | type: "tool_result", |
| 89 | 140 | tool_use_id: message.toolCallId, |
| 90 | 141 | content: renderChatMessage(message) || undefined, |
| 91 | 142 | }, |
| 92 | - ], | |
| 93 | - }; | |
| 94 | - } else if (message.role === "assistant" && message.toolCalls) { | |
| 95 | - const parts: any[] = []; | |
| 96 | - if (message.content) { | |
| 143 | + ]; | |
| 144 | + case "user": | |
| 145 | + return this.convertMessageContentToBlocks(message.content); | |
| 146 | + case "thinking": | |
| 147 | + if (message.redactedThinking) { | |
| 148 | + return [ | |
| 149 | + { | |
| 150 | + type: "redacted_thinking", | |
| 151 | + data: message.redactedThinking, | |
| 152 | + }, | |
| 153 | + ]; | |
| 154 | + } | |
| 97 | 155 | if (typeof message.content === "string") { |
| 98 | - parts.push(this.buildTextPart(message.content, addCaching)); | |
| 99 | - } else if (message.content.length > 0) { | |
| 100 | - const textContent = message.content.filter((p) => p.type === "text"); | |
| 101 | - const textParts = textContent.map((part, idx) => { | |
| 102 | - const cache = idx === textContent.length - 1 && addCaching; | |
| 103 | - return this.buildTextPart(part.text, cache); | |
| 104 | - }); | |
| 105 | - parts.push(...textParts); | |
| 156 | + return [ | |
| 157 | + { | |
| 158 | + type: "thinking", | |
| 159 | + thinking: message.content, | |
| 160 | + signature: message.signature ?? "", // TODO - unsafe signature | |
| 161 | + }, | |
| 162 | + ]; | |
| 106 | 163 | } |
| 107 | - } | |
| 108 | - parts.push( | |
| 109 | - ...message.toolCalls.map((toolCall) => ({ | |
| 110 | - type: "tool_use", | |
| 111 | - id: toolCall.id, | |
| 112 | - name: toolCall.function?.name, | |
| 113 | - input: safeParseToolCallArgs(toolCall), | |
| 114 | - })), | |
| 115 | - ); | |
| 116 | - return { | |
| 117 | - role: "assistant", | |
| 118 | - content: parts, | |
| 119 | - }; | |
| 120 | - } else if (message.role === "thinking" && !message.redactedThinking) { | |
| 121 | - return { | |
| 122 | - role: "assistant", | |
| 123 | - content: [ | |
| 124 | - { | |
| 125 | - type: "thinking", | |
| 126 | - thinking: message.content, | |
| 127 | - signature: message.signature, | |
| 128 | - }, | |
| 129 | - ], | |
| 130 | - }; | |
| 131 | - } else if (message.role === "thinking" && message.redactedThinking) { | |
| 132 | - return { | |
| 133 | - role: "assistant", | |
| 134 | - content: [ | |
| 135 | - { | |
| 136 | - type: "redacted_thinking", | |
| 137 | - data: message.redactedThinking, | |
| 138 | - }, | |
| 139 | - ], | |
| 140 | - }; | |
| 164 | + const textParts = message.content.filter((p) => p.type === "text"); | |
| 165 | + return textParts.map((part) => ({ | |
| 166 | + type: "thinking", | |
| 167 | + thinking: part.text, | |
| 168 | + signature: message.signature ?? "", // TODO - unsafe signature | |
| 169 | + })); | |
| 170 | + case "assistant": | |
| 171 | + const blocks: ContentBlockParam[] = this.convertMessageContentToBlocks( | |
| 172 | + message.content, | |
| 173 | + ); | |
| 174 | + // If any tool calls are present, always put them last | |
| 175 | + // Loses order vs what was originally sent, but they typically come last | |
| 176 | + for (const toolCall of message.toolCalls ?? []) { | |
| 177 | + const block = this.convertToolCallsToBlocks(toolCall); | |
| 178 | + if (block) { | |
| 179 | + blocks.push(block); | |
| 180 | + } | |
| 181 | + } | |
| 182 | + return blocks; | |
| 183 | + // system, etc. | |
| 184 | + default: | |
| 185 | + return []; | |
| 141 | 186 | } |
| 187 | + } | |
| 142 | 188 | |
| 143 | - if (typeof message.content === "string") { | |
| 144 | - var chatMessage = { | |
| 145 | - role: message.role, | |
| 146 | - content: [ | |
| 147 | - { | |
| 148 | - type: "text", | |
| 149 | - text: message.content, | |
| 150 | - ...(addCaching ? { cache_control: { type: "ephemeral" } } : {}), | |
| 151 | - }, | |
| 152 | - ], | |
| 153 | - }; | |
| 154 | - return chatMessage; | |
| 189 | + public convertMessages( | |
| 190 | + msgs: ChatMessage[], | |
| 191 | + cachePrompt: boolean, | |
| 192 | + ): MessageParam[] { | |
| 193 | + const nonSystemMessages = msgs.filter((m) => m.role !== "system"); | |
| 194 | + | |
| 195 | + const convertedMessages: MessageParam[] = []; | |
| 196 | + let currentRole: "user" | "assistant" | undefined = undefined; | |
| 197 | + let currentParts: ContentBlockParam[] = []; | |
| 198 | + | |
| 199 | + const flushCurrentMessage = () => { | |
| 200 | + if (currentRole && currentParts.length > 0) { | |
| 201 | + convertedMessages.push({ | |
| 202 | + role: currentRole, | |
| 203 | + content: currentParts, | |
| 204 | + }); | |
| 205 | + currentParts = []; | |
| 206 | + } | |
| 207 | + }; | |
| 208 | + | |
| 209 | + for (const message of nonSystemMessages) { | |
| 210 | + const newRole = | |
| 211 | + message.role === "user" || message.role === "tool" | |
| 212 | + ? "user" | |
| 213 | + : "assistant"; | |
| 214 | + if (currentRole !== newRole) { | |
| 215 | + flushCurrentMessage(); | |
| 216 | + currentRole = newRole; | |
| 217 | + } | |
| 218 | + currentParts.push(...this.getContentBlocksFromChatMessage(message)); | |
| 155 | 219 | } |
| 220 | + flushCurrentMessage(); | |
| 156 | 221 | |
| 157 | - return { | |
| 158 | - role: message.role, | |
| 159 | - content: message.content.map((part, contentIdx) => { | |
| 160 | - if (part.type === "text") { | |
| 161 | - const newpart = { | |
| 162 | - ...part, | |
| 163 | - // If multiple text parts, only add cache_control to the last one | |
| 164 | - ...(addCaching && contentIdx === message.content.length - 1 | |
| 165 | - ? { cache_control: { type: "ephemeral" } } | |
| 166 | - : {}), | |
| 167 | - }; | |
| 168 | - return newpart; | |
| 169 | - } | |
| 170 | - return { | |
| 171 | - type: "image", | |
| 172 | - source: { | |
| 173 | - type: "base64", | |
| 174 | - media_type: "image/jpeg", | |
| 175 | - data: part.imageUrl?.url.split(",")[1], | |
| 176 | - }, | |
| 177 | - }; | |
| 178 | - }), | |
| 179 | - }; | |
| 180 | - } | |
| 222 | + if (cachePrompt) { | |
| 223 | + addCacheControlToLastTwoUserMessages(convertedMessages); | |
| 224 | + } | |
| 181 | 225 | |
| 182 | - public convertMessages(msgs: ChatMessage[]): any[] { | |
| 183 | - // should be public for use within VertexAI | |
| 184 | - const filteredmessages = msgs.filter((m) => m.role !== "system"); | |
| 185 | - const lastTwoUserMsgIndices = filteredmessages | |
| 186 | - .map((msg, index) => (msg.role === "user" ? index : -1)) | |
| 187 | - .filter((index) => index !== -1) | |
| 188 | - .slice(-2); | |
| 189 | - | |
| 190 | - const messages = filteredmessages.map((message, filteredMsgIdx) => { | |
| 191 | - // Add cache_control parameter to the last two user messages | |
| 192 | - // The second-to-last because it retrieves potentially already cached contents, | |
| 193 | - // The last one because we want it cached for later retrieval. | |
| 194 | - // See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching | |
| 195 | - const addCaching = | |
| 196 | - this.cacheBehavior?.cacheConversation && | |
| 197 | - lastTwoUserMsgIndices.includes(filteredMsgIdx); | |
| 198 | - | |
| 199 | - const chatMessage = this.convertMessage(message, !!addCaching); | |
| 200 | - return chatMessage; | |
| 201 | - }); | |
| 202 | - return messages; | |
| 226 | + return convertedMessages; | |
| 203 | 227 | } |
| 204 | 228 | |
| 205 | 229 | protected async *_streamComplete( |
| @@ -224,12 +248,7 @@ | ||
| 224 | 248 | if (!response.ok) { |
| 225 | 249 | const json = await response.json(); |
| 226 | 250 | if (json.type === "error") { |
| 227 | - if (json.error?.type in errorMessages) { | |
| 228 | - throw new Error( | |
| 229 | - errorMessages[json.error.type as keyof typeof errorMessages], | |
| 230 | - ); | |
| 231 | - } | |
| 232 | - throw new Error(json.message); | |
| 251 | + throw new Error(getAnthropicErrorMessage(json)); | |
| 233 | 252 | } |
| 234 | 253 | throw new Error( |
| 235 | 254 | `Anthropic API sent back ${response.status}: ${JSON.stringify(json)}`, |
| @@ -237,17 +256,17 @@ | ||
| 237 | 256 | } |
| 238 | 257 | |
| 239 | 258 | if (stream === false) { |
| 240 | - const data = await response.json(); | |
| 241 | - const cost = data.usage | |
| 259 | + const json = await response.json(); | |
| 260 | + const cost = json.usage | |
| 242 | 261 | ? { |
| 243 | - inputTokens: data.usage.input_tokens, | |
| 244 | - outputTokens: data.usage.output_tokens, | |
| 245 | - totalTokens: data.usage.input_tokens + data.usage.output_tokens, | |
| 262 | + inputTokens: json.usage.input_tokens, | |
| 263 | + outputTokens: json.usage.output_tokens, | |
| 264 | + totalTokens: json.usage.input_tokens + json.usage.output_tokens, | |
| 246 | 265 | } |
| 247 | 266 | : {}; |
| 248 | 267 | yield { |
| 249 | 268 | role: "assistant", |
| 250 | - content: data.content[0].text, | |
| 269 | + content: json.content[0].text, | |
| 251 | 270 | ...(Object.keys(cost).length > 0 ? { cost } : {}), |
| 252 | 271 | }; |
| 253 | 272 | return; |
| @@ -264,51 +283,59 @@ | ||
| 264 | 283 | }, |
| 265 | 284 | }; |
| 266 | 285 | |
| 267 | - for await (const value of streamSse(response)) { | |
| 286 | + for await (const event of streamSse(response)) { | |
| 268 | 287 | // https://docs.anthropic.com/en/api/messages-streaming#event-types |
| 269 | - switch (value.type) { | |
| 288 | + const rawEvent = event as RawMessageStreamEvent; | |
| 289 | + switch (event.type) { | |
| 270 | 290 | case "message_start": |
| 271 | 291 | // Capture initial usage information |
| 272 | - usage.promptTokens = value.message.usage.input_tokens; | |
| 292 | + const startEvent = rawEvent as RawMessageStartEvent; | |
| 293 | + usage.promptTokens = startEvent.message.usage.input_tokens; | |
| 273 | 294 | usage.promptTokensDetails!.cachedTokens = |
| 274 | - value.message.usage.cache_read_input_tokens; | |
| 295 | + startEvent.message.usage.cache_read_input_tokens ?? undefined; | |
| 275 | 296 | usage.promptTokensDetails!.cacheWriteTokens = |
| 276 | - value.message.usage.cache_creation_input_tokens; | |
| 297 | + startEvent.message.usage.cache_creation_input_tokens ?? undefined; | |
| 277 | 298 | break; |
| 278 | 299 | case "message_delta": |
| 279 | 300 | // Update usage information during streaming |
| 280 | - if (value.usage) { | |
| 281 | - usage.completionTokens = value.usage.output_tokens; | |
| 301 | + const deltaEvent = rawEvent as RawMessageDeltaEvent; | |
| 302 | + if (deltaEvent.usage) { | |
| 303 | + usage.completionTokens = deltaEvent.usage.output_tokens; | |
| 282 | 304 | } |
| 283 | 305 | break; |
| 284 | 306 | case "content_block_start": |
| 285 | - if (value.content_block.type === "tool_use") { | |
| 286 | - lastToolUseId = value.content_block.id; | |
| 287 | - lastToolUseName = value.content_block.name; | |
| 307 | + const blockStartEvent = rawEvent as RawContentBlockStartEvent; | |
| 308 | + if (blockStartEvent.content_block.type === "tool_use") { | |
| 309 | + lastToolUseId = blockStartEvent.content_block.id; | |
| 310 | + lastToolUseName = blockStartEvent.content_block.name; | |
| 288 | 311 | } |
| 289 | 312 | // handle redacted thinking |
| 290 | - if (value.content_block.type === "redacted_thinking") { | |
| 313 | + if (blockStartEvent.content_block.type === "redacted_thinking") { | |
| 291 | 314 | yield { |
| 292 | 315 | role: "thinking", |
| 293 | 316 | content: "", |
| 294 | - redactedThinking: value.content_block.data, | |
| 317 | + redactedThinking: blockStartEvent.content_block.data, | |
| 295 | 318 | }; |
| 296 | 319 | } |
| 297 | 320 | break; |
| 298 | 321 | case "content_block_delta": |
| 299 | 322 | // https://docs.anthropic.com/en/api/messages-streaming#delta-types |
| 300 | - switch (value.delta.type) { | |
| 323 | + const blockDeltaEvent = rawEvent as RawContentBlockDeltaEvent; | |
| 324 | + switch (blockDeltaEvent.delta.type) { | |
| 301 | 325 | case "text_delta": |
| 302 | - yield { role: "assistant", content: value.delta.text }; | |
| 326 | + yield { role: "assistant", content: blockDeltaEvent.delta.text }; | |
| 303 | 327 | break; |
| 304 | 328 | case "thinking_delta": |
| 305 | - yield { role: "thinking", content: value.delta.thinking }; | |
| 329 | + yield { | |
| 330 | + role: "thinking", | |
| 331 | + content: blockDeltaEvent.delta.thinking, | |
| 332 | + }; | |
| 306 | 333 | break; |
| 307 | 334 | case "signature_delta": |
| 308 | 335 | yield { |
| 309 | 336 | role: "thinking", |
| 310 | 337 | content: "", |
| 311 | - signature: value.delta.signature, | |
| 338 | + signature: blockDeltaEvent.delta.signature, | |
| 312 | 339 | }; |
| 313 | 340 | break; |
| 314 | 341 | case "input_json_delta": |
| @@ -324,7 +351,7 @@ | ||
| 324 | 351 | type: "function", |
| 325 | 352 | function: { |
| 326 | 353 | name: lastToolUseName, |
| 327 | - arguments: value.delta.partial_json, | |
| 354 | + arguments: blockDeltaEvent.delta.partial_json, | |
| 328 | 355 | }, |
| 329 | 356 | }, |
| 330 | 357 | ], |
| @@ -365,32 +392,35 @@ | ||
| 365 | 392 | const shouldCacheSystemMessage = !!( |
| 366 | 393 | this.cacheBehavior?.cacheSystemMessage && systemMessage |
| 367 | 394 | ); |
| 395 | + const shouldCachePrompt = !!( | |
| 396 | + this.cacheBehavior?.cacheConversation || | |
| 397 | + this.completionOptions.promptCaching | |
| 398 | + ); | |
| 399 | + | |
| 400 | + const msgs = this.convertMessages(messages, shouldCachePrompt); | |
| 401 | + const headers = getAnthropicHeaders( | |
| 402 | + this.apiKey, | |
| 403 | + shouldCacheSystemMessage || shouldCachePrompt, | |
| 404 | + ); | |
| 405 | + | |
| 406 | + const body: MessageCreateParams = { | |
| 407 | + ...this.convertArgs(options), | |
| 408 | + messages: msgs, | |
| 409 | + system: shouldCacheSystemMessage | |
| 410 | + ? [ | |
| 411 | + { | |
| 412 | + type: "text", | |
| 413 | + text: systemMessage, | |
| 414 | + cache_control: { type: "ephemeral" }, | |
| 415 | + }, | |
| 416 | + ] | |
| 417 | + : systemMessage, | |
| 418 | + }; | |
| 368 | 419 | |
| 369 | - const msgs = this.convertMessages(messages); | |
| 370 | 420 | const response = await this.fetch(new URL("messages", this.apiBase), { |
| 371 | 421 | method: "POST", |
| 372 | - headers: { | |
| 373 | - "Content-Type": "application/json", | |
| 374 | - Accept: "application/json", | |
| 375 | - "anthropic-version": "2023-06-01", | |
| 376 | - "x-api-key": this.apiKey as string, | |
| 377 | - ...(shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation | |
| 378 | - ? { "anthropic-beta": "prompt-caching-2024-07-31" } | |
| 379 | - : {}), | |
| 380 | - }, | |
| 381 | - body: JSON.stringify({ | |
| 382 | - ...this.convertArgs(options), | |
| 383 | - messages: msgs, | |
| 384 | - system: shouldCacheSystemMessage | |
| 385 | - ? [ | |
| 386 | - { | |
| 387 | - type: "text", | |
| 388 | - text: systemMessage, | |
| 389 | - cache_control: { type: "ephemeral" }, | |
| 390 | - }, | |
| 391 | - ] | |
| 392 | - : systemMessage, | |
| 393 | - }), | |
| 422 | + headers, | |
| 423 | + body: JSON.stringify(body), | |
| 394 | 424 | signal, |
| 395 | 425 | }); |
| 396 | 426 |
| @@ -0,0 +1,358 @@ | ||
| 1 | +import { LLMOptions } from "../../index.js"; | |
| 2 | +import { allModelProviders } from "@continuedev/llm-info"; | |
| 3 | +import OpenAI from "./OpenAI.js"; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * CometAPI-specific error types for better error handling | |
| 7 | + */ | |
| 8 | +export class CometAPIError extends Error { | |
| 9 | + constructor( | |
| 10 | + message: string, | |
| 11 | + public code?: string, | |
| 12 | + public statusCode?: number, | |
| 13 | + ) { | |
| 14 | + super(message); | |
| 15 | + this.name = "CometAPIError"; | |
| 16 | + } | |
| 17 | +} | |
| 18 | + | |
| 19 | +export class CometAPIAuthenticationError extends CometAPIError { | |
| 20 | + constructor(message: string = "Invalid CometAPI API key") { | |
| 21 | + super(message, "AUTHENTICATION_ERROR", 401); | |
| 22 | + this.name = "CometAPIAuthenticationError"; | |
| 23 | + } | |
| 24 | +} | |
| 25 | + | |
| 26 | +export class CometAPIQuotaExceededError extends CometAPIError { | |
| 27 | + constructor(message: string = "CometAPI quota exceeded") { | |
| 28 | + super(message, "QUOTA_EXCEEDED", 429); | |
| 29 | + this.name = "CometAPIQuotaExceededError"; | |
| 30 | + } | |
| 31 | +} | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * CometAPI LLM provider - aggregates multiple mainstream models | |
| 35 | + * from various providers (GPT, Claude, Gemini, Grok, DeepSeek, Qwen, etc.) | |
| 36 | + * | |
| 37 | + * Uses OpenAI-compatible API format with bearer token authentication | |
| 38 | + */ | |
| 39 | +class CometAPI extends OpenAI { | |
| 40 | + static providerName = "cometapi"; | |
| 41 | + | |
| 42 | + static defaultOptions: Partial<LLMOptions> = { | |
| 43 | + apiBase: "https://api.cometapi.com/v1/", | |
| 44 | + model: "gpt-4o-mini", // Default to a commonly available model | |
| 45 | + }; | |
| 46 | + | |
| 47 | + constructor(options: LLMOptions) { | |
| 48 | + // Validate required configuration before calling super | |
| 49 | + CometAPI.validateConfig(options); | |
| 50 | + super(options); | |
| 51 | + | |
| 52 | + // Align contextLength with llm-info for cometapi specifically (non-breaking for others) | |
| 53 | + try { | |
| 54 | + const cometProvider = allModelProviders.find((p) => p.id === "cometapi"); | |
| 55 | + const info = cometProvider?.models.find((m) => | |
| 56 | + m.regex ? m.regex.test(this.model) : m.model === this.model, | |
| 57 | + ); | |
| 58 | + if (info?.contextLength) { | |
| 59 | + // Always prefer cometapi-specific llm-info over generic provider matches | |
| 60 | + // eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
| 61 | + // @ts-ignore - accessing protected for targeted fix | |
| 62 | + this._contextLength = info.contextLength; | |
| 63 | + } | |
| 64 | + } catch { | |
| 65 | + // no-op: do not fail construction on metadata issues | |
| 66 | + } | |
| 67 | + } | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Validate CometAPI configuration | |
| 71 | + */ | |
| 72 | + private static validateConfig(options: LLMOptions): void { | |
| 73 | + // Allow constructing without API key (tests that only instantiate should pass). | |
| 74 | + // Enforce credentials at request time instead. | |
| 75 | + if (!options.apiKey) { | |
| 76 | + if (typeof process !== "undefined" && process.env?.NODE_ENV !== "test") { | |
| 77 | + console.warn( | |
| 78 | + "CometAPI: No API key provided. Requests will fail until an API key is configured. Get one at https://api.cometapi.com/console/token", | |
| 79 | + ); | |
| 80 | + } | |
| 81 | + return; | |
| 82 | + } | |
| 83 | + | |
| 84 | + if (options.apiBase && !CometAPI.isValidApiBase(options.apiBase)) { | |
| 85 | + throw new CometAPIError( | |
| 86 | + `Invalid CometAPI base URL: ${options.apiBase}. Expected https://api.cometapi.com/v1/ or compatible endpoint`, | |
| 87 | + ); | |
| 88 | + } | |
| 89 | + | |
| 90 | + if ( | |
| 91 | + options.model && | |
| 92 | + !CometAPI.isValidModelFormat(options.model) && | |
| 93 | + typeof process !== "undefined" && | |
| 94 | + process.env?.NODE_ENV !== "test" | |
| 95 | + ) { | |
| 96 | + console.warn( | |
| 97 | + `CometAPI: Model "${options.model}" may not be supported. Check CometAPI documentation for available models.`, | |
| 98 | + ); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Validate API base URL format | |
| 104 | + */ | |
| 105 | + private static isValidApiBase(apiBase: string): boolean { | |
| 106 | + try { | |
| 107 | + const url = new URL(apiBase); | |
| 108 | + return ( | |
| 109 | + url.protocol === "https:" && | |
| 110 | + (url.hostname === "api.cometapi.com" || | |
| 111 | + url.hostname.endsWith(".cometapi.com") || | |
| 112 | + apiBase.includes("v1")) // Allow custom compatible endpoints | |
| 113 | + ); | |
| 114 | + } catch { | |
| 115 | + return false; | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * Basic model format validation | |
| 121 | + */ | |
| 122 | + private static isValidModelFormat(model: string): boolean { | |
| 123 | + // Allow common model patterns | |
| 124 | + const validPatterns = [ | |
| 125 | + /^gpt-/i, | |
| 126 | + /^claude-/i, | |
| 127 | + /^gemini-/i, | |
| 128 | + /^grok/i, | |
| 129 | + /^deepseek/i, | |
| 130 | + /^qwen/i, | |
| 131 | + /^text-/i, | |
| 132 | + /^chat/i, | |
| 133 | + ]; | |
| 134 | + | |
| 135 | + return validPatterns.some((pattern) => pattern.test(model)); | |
| 136 | + } | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * Patterns to filter out non-chat models from the model list | |
| 140 | + * Based on CometAPI documentation requirements | |
| 141 | + */ | |
| 142 | + private static IGNORE_PATTERNS = [ | |
| 143 | + // Image generation models | |
| 144 | + "dall-e", | |
| 145 | + "dalle", | |
| 146 | + "midjourney", | |
| 147 | + "mj_", | |
| 148 | + "stable-diffusion", | |
| 149 | + "sd-", | |
| 150 | + "flux-", | |
| 151 | + "playground-v", | |
| 152 | + "ideogram", | |
| 153 | + "recraft-", | |
| 154 | + "black-forest-labs", | |
| 155 | + "/recraft-v3", | |
| 156 | + "recraftv3", | |
| 157 | + "stability-ai/", | |
| 158 | + "sdxl", | |
| 159 | + | |
| 160 | + // Audio generation models | |
| 161 | + "suno_", | |
| 162 | + "tts", | |
| 163 | + "whisper", | |
| 164 | + | |
| 165 | + // Video generation models | |
| 166 | + "runway", | |
| 167 | + "luma_", | |
| 168 | + "luma-", | |
| 169 | + "veo", | |
| 170 | + "kling_", | |
| 171 | + "minimax_video", | |
| 172 | + "hunyuan-t1", | |
| 173 | + | |
| 174 | + // Utility models | |
| 175 | + "embedding", | |
| 176 | + "search-gpts", | |
| 177 | + "files_retrieve", | |
| 178 | + "moderation", | |
| 179 | + ]; | |
| 180 | + | |
| 181 | + /** | |
| 182 | + * Recommended chat models from CometAPI documentation | |
| 183 | + */ | |
| 184 | + private static RECOMMENDED_MODELS = [ | |
| 185 | + // GPT series | |
| 186 | + "gpt-5-chat-latest", | |
| 187 | + "chatgpt-4o-latest", | |
| 188 | + "gpt-5-mini", | |
| 189 | + "gpt-5-nano", | |
| 190 | + "gpt-5", | |
| 191 | + "gpt-4.1-mini", | |
| 192 | + "gpt-4.1-nano", | |
| 193 | + "gpt-4.1", | |
| 194 | + "gpt-4o-mini", | |
| 195 | + "o4-mini-2025-04-16", | |
| 196 | + "o3-pro-2025-06-10", | |
| 197 | + | |
| 198 | + // Claude series | |
| 199 | + "claude-opus-4-1-20250805", | |
| 200 | + "claude-opus-4-1-20250805-thinking", | |
| 201 | + "claude-sonnet-4-20250514", | |
| 202 | + "claude-sonnet-4-20250514-thinking", | |
| 203 | + "claude-3-7-sonnet-latest", | |
| 204 | + "claude-3-5-haiku-latest", | |
| 205 | + | |
| 206 | + // Gemini series | |
| 207 | + "gemini-2.5-pro", | |
| 208 | + "gemini-2.5-flash", | |
| 209 | + "gemini-2.5-flash-lite", | |
| 210 | + "gemini-2.0-flash", | |
| 211 | + | |
| 212 | + // Grok series | |
| 213 | + "grok-4-0709", | |
| 214 | + "grok-3", | |
| 215 | + "grok-3-mini", | |
| 216 | + "grok-2-image-1212", | |
| 217 | + | |
| 218 | + // DeepSeek series | |
| 219 | + "deepseek-v3.1", | |
| 220 | + "deepseek-v3", | |
| 221 | + "deepseek-r1-0528", | |
| 222 | + "deepseek-chat", | |
| 223 | + "deepseek-reasoner", | |
| 224 | + | |
| 225 | + // Qwen series | |
| 226 | + "qwen3-30b-a3b", | |
| 227 | + "qwen3-coder-plus-2025-07-22", | |
| 228 | + ]; | |
| 229 | + | |
| 230 | + /** | |
| 231 | + * Filter model list to exclude non-chat models | |
| 232 | + * Uses pattern matching against model names | |
| 233 | + */ | |
| 234 | + protected filterChatModels(models: any[]): any[] { | |
| 235 | + if (!models || !Array.isArray(models)) { | |
| 236 | + return []; | |
| 237 | + } | |
| 238 | + | |
| 239 | + return models.filter((model) => { | |
| 240 | + const modelId = model.id || model.model || ""; | |
| 241 | + const modelName = modelId.toLowerCase(); | |
| 242 | + | |
| 243 | + // Check if model matches any ignore pattern | |
| 244 | + const shouldIgnore = CometAPI.IGNORE_PATTERNS.some((pattern) => | |
| 245 | + modelName.includes(pattern.toLowerCase()), | |
| 246 | + ); | |
| 247 | + | |
| 248 | + return !shouldIgnore; | |
| 249 | + }); | |
| 250 | + } | |
| 251 | + | |
| 252 | + /** | |
| 253 | + * Get recommended models for CometAPI | |
| 254 | + * Returns predefined list since CometAPI model info is limited | |
| 255 | + */ | |
| 256 | + protected getRecommendedModels(): string[] { | |
| 257 | + return [...CometAPI.RECOMMENDED_MODELS]; | |
| 258 | + } | |
| 259 | + | |
| 260 | + /** | |
| 261 | + * Override listModels method to apply model filtering with enhanced error handling | |
| 262 | + */ | |
| 263 | + async listModels(): Promise<string[]> { | |
| 264 | + try { | |
| 265 | + const allModels = await super.listModels(); | |
| 266 | + const filteredModels = this.filterChatModels( | |
| 267 | + allModels.map((id) => ({ id })), | |
| 268 | + ); | |
| 269 | + | |
| 270 | + // If filtered list is empty or very limited, return recommended models | |
| 271 | + if (filteredModels.length < 5) { | |
| 272 | + console.info( | |
| 273 | + "CometAPI: Limited models available, using recommended set", | |
| 274 | + ); | |
| 275 | + return this.getRecommendedModels(); | |
| 276 | + } | |
| 277 | + | |
| 278 | + return filteredModels.map((model) => model.id); | |
| 279 | + } catch (error: any) { | |
| 280 | + // Enhanced error handling with specific error types | |
| 281 | + const errorMessage = error?.message || "Unknown error"; | |
| 282 | + const statusCode = error?.status || error?.statusCode; | |
| 283 | + | |
| 284 | + if (statusCode === 401) { | |
| 285 | + throw new CometAPIAuthenticationError( | |
| 286 | + "CometAPI authentication failed. Please check your API key.", | |
| 287 | + ); | |
| 288 | + } else if (statusCode === 429) { | |
| 289 | + throw new CometAPIQuotaExceededError( | |
| 290 | + "CometAPI rate limit exceeded. Please try again later.", | |
| 291 | + ); | |
| 292 | + } else if (statusCode >= 400 && statusCode < 500) { | |
| 293 | + throw new CometAPIError( | |
| 294 | + `CometAPI client error: ${errorMessage}`, | |
| 295 | + "CLIENT_ERROR", | |
| 296 | + statusCode, | |
| 297 | + ); | |
| 298 | + } else if (statusCode >= 500) { | |
| 299 | + console.warn( | |
| 300 | + "CometAPI server error, falling back to recommended models:", | |
| 301 | + errorMessage, | |
| 302 | + ); | |
| 303 | + return this.getRecommendedModels(); | |
| 304 | + } else { | |
| 305 | + // Network or other errors - fallback gracefully | |
| 306 | + console.warn( | |
| 307 | + "CometAPI: Failed to fetch model list, using recommended models", | |
| 308 | + errorMessage, | |
| 309 | + ); | |
| 310 | + return this.getRecommendedModels(); | |
| 311 | + } | |
| 312 | + } | |
| 313 | + } | |
| 314 | + | |
| 315 | + /** | |
| 316 | + * Override chat completion with enhanced error handling | |
| 317 | + */ | |
| 318 | + protected async *_streamChat( | |
| 319 | + messages: any[], | |
| 320 | + signal: AbortSignal, | |
| 321 | + options: any = {}, | |
| 322 | + ): AsyncGenerator<any> { | |
| 323 | + try { | |
| 324 | + yield* super._streamChat(messages, signal, options); | |
| 325 | + } catch (error: any) { | |
| 326 | + const statusCode = error?.status || error?.statusCode; | |
| 327 | + const errorMessage = error?.message || "Unknown error"; | |
| 328 | + | |
| 329 | + if (statusCode === 401) { | |
| 330 | + throw new CometAPIAuthenticationError( | |
| 331 | + "CometAPI authentication failed during chat completion", | |
| 332 | + ); | |
| 333 | + } else if (statusCode === 429) { | |
| 334 | + throw new CometAPIQuotaExceededError( | |
| 335 | + "CometAPI rate limit exceeded during chat completion", | |
| 336 | + ); | |
| 337 | + } else if ( | |
| 338 | + errorMessage.includes("model") && | |
| 339 | + errorMessage.includes("not found") | |
| 340 | + ) { | |
| 341 | + throw new CometAPIError( | |
| 342 | + `Model "${this.model}" is not available on CometAPI. Please check available models.`, | |
| 343 | + "MODEL_NOT_FOUND", | |
| 344 | + 404, | |
| 345 | + ); | |
| 346 | + } else { | |
| 347 | + // Re-throw with more context | |
| 348 | + throw new CometAPIError( | |
| 349 | + `CometAPI chat completion failed: ${errorMessage}`, | |
| 350 | + "COMPLETION_ERROR", | |
| 351 | + statusCode, | |
| 352 | + ); | |
| 353 | + } | |
| 354 | + } | |
| 355 | + } | |
| 356 | +} | |
| 357 | + | |
| 358 | +export default CometAPI; |
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | import Cerebras from "./Cerebras.js"; |
| 14 | 14 | import DeepInfra from "./DeepInfra.js"; |
| 15 | 15 | import Nvidia from "./Nvidia.js"; |
| 16 | +import CometAPI from "./CometAPI.js"; | |
| 16 | 17 | |
| 17 | 18 | // Base OpenAI tests |
| 18 | 19 | import { afterEach, describe, expect, test, vi } from "vitest"; |
| @@ -292,3 +293,13 @@ | ||
| 292 | 293 | truncate: "END", |
| 293 | 294 | }, |
| 294 | 295 | }); |
| 296 | + | |
| 297 | +createOpenAISubclassTests(CometAPI, { | |
| 298 | + providerName: "cometapi", | |
| 299 | + defaultApiBase: "https://api.cometapi.com/v1/", | |
| 300 | + modelConversions: { | |
| 301 | + "gpt-5-mini": "gpt-5-mini", | |
| 302 | + "claude-4-sonnet": "claude-sonnet-4-20250514", | |
| 303 | + }, | |
| 304 | + modelConversionContent: "hello", | |
| 305 | +}); |
| @@ -223,6 +223,10 @@ | ||
| 223 | 223 | const shouldCacheSystemMessage = !!( |
| 224 | 224 | this.cacheBehavior?.cacheSystemMessage && systemMessage |
| 225 | 225 | ); |
| 226 | + const shouldCachePrompt = !!( | |
| 227 | + this.cacheBehavior?.cacheConversation ?? | |
| 228 | + this.completionOptions.promptCaching | |
| 229 | + ); | |
| 226 | 230 | |
| 227 | 231 | // <code>/v1/publishers/anthropic/models/claude-3-5-sonnet-20240620:streamRawPredict |
| 228 | 232 | |
| @@ -234,13 +238,16 @@ | ||
| 234 | 238 | const response = await this.fetch(apiURL, { |
| 235 | 239 | method: "POST", |
| 236 | 240 | headers: { |
| 237 | - ...(shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation | |
| 241 | + ...(shouldCacheSystemMessage || shouldCachePrompt | |
| 238 | 242 | ? { "anthropic-beta": "prompt-caching-2024-07-31" } |
| 239 | 243 | : {}), |
| 240 | 244 | }, |
| 241 | 245 | body: JSON.stringify({ |
| 242 | 246 | ...this._anthropicConvertArgs(options), |
| 243 | - messages: this.anthropicInstance.convertMessages(messages), | |
| 247 | + messages: this.anthropicInstance.convertMessages( | |
| 248 | + messages, | |
| 249 | + shouldCachePrompt, | |
| 250 | + ), | |
| 244 | 251 | system: shouldCacheSystemMessage |
| 245 | 252 | ? [ |
| 246 | 253 | { |
| @@ -17,6 +17,7 @@ | ||
| 17 | 17 | import Cerebras from "./Cerebras"; |
| 18 | 18 | import Cloudflare from "./Cloudflare"; |
| 19 | 19 | import Cohere from "./Cohere"; |
| 20 | +import CometAPI from "./CometAPI"; | |
| 20 | 21 | import DeepInfra from "./DeepInfra"; |
| 21 | 22 | import Deepseek from "./Deepseek"; |
| 22 | 23 | import Docker from "./Docker"; |
| @@ -67,6 +68,7 @@ | ||
| 67 | 68 | export const LLMClasses = [ |
| 68 | 69 | Anthropic, |
| 69 | 70 | Cohere, |
| 71 | + CometAPI, | |
| 70 | 72 | FunctionNetwork, |
| 71 | 73 | Gemini, |
| 72 | 74 | Llamafile, |
| @@ -7,14 +7,6 @@ | ||
| 7 | 7 | static defaultOptions: Partial<LLMOptions> = { |
| 8 | 8 | apiBase: "https://api.x.ai/v1/", |
| 9 | 9 | }; |
| 10 | - | |
| 11 | - private static MODEL_IDS: { [name: string]: string } = { | |
| 12 | - "grok-beta": "grok-beta", // Future names might not line up | |
| 13 | - }; | |
| 14 | - | |
| 15 | - protected _convertModelName(model: string) { | |
| 16 | - return xAI.MODEL_IDS[model] || this.model; | |
| 17 | - } | |
| 18 | 10 | } |
| 19 | 11 | |
| 20 | 12 | export default xAI; |
| @@ -280,6 +280,23 @@ | ||
| 280 | 280 | }); |
| 281 | 281 | }); |
| 282 | 282 | |
| 283 | + describe("xAI", () => { | |
| 284 | + const supportsFn = PROVIDER_TOOL_SUPPORT["xAI"]; | |
| 285 | + | |
| 286 | + it("should return true for Grok-3 models", () => { | |
| 287 | + expect(supportsFn("grok-3")).toBe(true); | |
| 288 | + expect(supportsFn("grok-3-mini")).toBe(true); | |
| 289 | + expect(supportsFn("grok-3-fast")).toBe(true); | |
| 290 | + }); | |
| 291 | + | |
| 292 | + it("should return true for Grok-4 models", () => { | |
| 293 | + expect(supportsFn("grok-4")).toBe(true); | |
| 294 | + expect(supportsFn("grok-4-fast-non-reasoning")).toBe(true); | |
| 295 | + expect(supportsFn("grok-4-fast-reasoning")).toBe(true); | |
| 296 | + expect(supportsFn("Grok-4-Fast")).toBe(true); | |
| 297 | + }); | |
| 298 | + }); | |
| 299 | + | |
| 283 | 300 | describe("novita", () => { |
| 284 | 301 | const supportsFn = PROVIDER_TOOL_SUPPORT["novita"]; |
| 285 | 302 |
| @@ -110,6 +110,10 @@ | ||
| 110 | 110 | } |
| 111 | 111 | return ["claude", "gemini"].some((val) => lowerCaseModel.includes(val)); |
| 112 | 112 | }, |
| 113 | + xAI: (model) => { | |
| 114 | + const lowerCaseModel = model.toLowerCase(); | |
| 115 | + return ["grok-3", "grok-4"].some((val) => lowerCaseModel.includes(val)); | |
| 116 | + }, | |
| 113 | 117 | bedrock: (model) => { |
| 114 | 118 | if ( |
| 115 | 119 | [ |
| @@ -1,49 +1,47 @@ | ||
| 1 | 1 | import { getSecureID } from "./getSecureID"; |
| 2 | 2 | |
| 3 | -// Mock the crypto.randomUUID function | |
| 4 | -const mockRandomUUID = jest.fn(); | |
| 5 | -global.crypto = { | |
| 6 | - ...global.crypto, | |
| 7 | - randomUUID: mockRandomUUID, | |
| 8 | -}; | |
| 9 | - | |
| 10 | 3 | describe("getSecureID", () => { |
| 11 | 4 | beforeEach(() => { |
| 12 | 5 | // Reset the static property before each test |
| 13 | 6 | (getSecureID as any).uuid = undefined; |
| 14 | - | |
| 15 | - // Reset the mock implementation | |
| 16 | - mockRandomUUID.mockReset(); | |
| 17 | - // Setup a mock implementation that returns a fixed value for testing | |
| 18 | - mockRandomUUID.mockReturnValue("test-uuid-1234"); | |
| 19 | 7 | }); |
| 20 | 8 | |
| 21 | 9 | test("should generate a UUID on first call", () => { |
| 22 | 10 | const result = getSecureID(); |
| 23 | - expect(mockRandomUUID).toHaveBeenCalledTimes(1); | |
| 24 | - expect(result).toBe("<!-- SID: test-uuid-1234 -->"); | |
| 11 | + | |
| 12 | + // Should return a properly formatted string with SID comment | |
| 13 | + expect(result).toMatch( | |
| 14 | + /^<!-- SID: [0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12} -->$/, | |
| 15 | + ); | |
| 16 | + | |
| 17 | + // Should have set the static uuid property | |
| 18 | + expect((getSecureID as any).uuid).toBeDefined(); | |
| 19 | + expect(typeof (getSecureID as any).uuid).toBe("string"); | |
| 25 | 20 | }); |
| 26 | 21 | |
| 27 | 22 | test("should reuse the same UUID on subsequent calls", () => { |
| 28 | 23 | const firstResult = getSecureID(); |
| 29 | 24 | const secondResult = getSecureID(); |
| 30 | 25 | |
| 31 | - // The UUID generation should only happen once | |
| 32 | - expect(mockRandomUUID).toHaveBeenCalledTimes(1); | |
| 33 | - | |
| 34 | 26 | // Both results should be identical |
| 35 | 27 | expect(firstResult).toBe(secondResult); |
| 36 | - expect(firstResult).toBe("<!-- SID: test-uuid-1234 -->"); | |
| 28 | + | |
| 29 | + // Should match UUID format | |
| 30 | + expect(firstResult).toMatch( | |
| 31 | + /^<!-- SID: [0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12} -->$/, | |
| 32 | + ); | |
| 37 | 33 | }); |
| 38 | 34 | |
| 39 | 35 | test("should maintain the same UUID across different test cases if not reset", () => { |
| 40 | - // Don't reset the UUID here to test persistence | |
| 36 | + // Set a specific UUID to test persistence | |
| 41 | 37 | (getSecureID as any).uuid = "persistent-uuid"; |
| 42 | 38 | |
| 43 | 39 | const result = getSecureID(); |
| 44 | 40 | |
| 45 | - // No new UUID should be generated | |
| 46 | - expect(mockRandomUUID).not.toHaveBeenCalled(); | |
| 41 | + // Should use the pre-existing UUID | |
| 47 | 42 | expect(result).toBe("<!-- SID: persistent-uuid -->"); |
| 43 | + | |
| 44 | + // The static property should remain unchanged | |
| 45 | + expect((getSecureID as any).uuid).toBe("persistent-uuid"); | |
| 48 | 46 | }); |
| 49 | 47 | }); |
| @@ -1,8 +1,10 @@ | ||
| 1 | +import { v4 as uuidv4 } from "uuid"; | |
| 2 | + | |
| 1 | 3 | // Utility function to get or generate UUID for LLM prompts |
| 2 | 4 | export function getSecureID(): string { |
| 3 | 5 | // Adding a type declaration for the static property |
| 4 | 6 | if (!(getSecureID as any).uuid) { |
| 5 | - (getSecureID as any).uuid = crypto.randomUUID(); | |
| 7 | + (getSecureID as any).uuid = uuidv4(); | |
| 6 | 8 | } |
| 7 | 9 | return `<!-- SID: ${(getSecureID as any).uuid} -->`; |
| 8 | 10 | } |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -54,6 +54,7 @@ | ||
| 54 | 54 | "vitest": "^3.1.4" |
| 55 | 55 | }, |
| 56 | 56 | "dependencies": { |
| 57 | + "@anthropic-ai/sdk": "^0.62.0", | |
| 57 | 58 | "@aws-sdk/client-bedrock-runtime": "^3.779.0", |
| 58 | 59 | "@aws-sdk/client-sagemaker-runtime": "^3.777.0", |
| 59 | 60 | "@aws-sdk/credential-providers": "^3.778.0", |
| @@ -148,6 +148,8 @@ | ||
| 148 | 148 | }, |
| 149 | 149 | void, |
| 150 | 150 | ]; |
| 151 | + "mcp/disconnectServer": [{ id: string }, void]; | |
| 152 | + "mcp/getDisconnectedServers": [undefined, string[]]; | |
| 151 | 153 | "mcp/getPrompt": [ |
| 152 | 154 | { |
| 153 | 155 | serverName: string; |
| @@ -32,6 +32,8 @@ | ||
| 32 | 32 | "mcp/getPrompt", |
| 33 | 33 | "mcp/startAuthentication", |
| 34 | 34 | "mcp/removeAuthentication", |
| 35 | + "mcp/disconnectServer", | |
| 36 | + "mcp/getDisconnectedServers", | |
| 35 | 37 | "context/getContextItems", |
| 36 | 38 | "context/getSymbolsForFiles", |
| 37 | 39 | "context/loadSubmenuItems", |
| @@ -0,0 +1,134 @@ | ||
| 1 | +--- | |
| 2 | +title: "Install Continue CLI" | |
| 3 | +description: "Get Continue CLI installed and configured for command-line AI coding assistance and automation" | |
| 4 | +sidebarTitle: "Install" | |
| 5 | +--- | |
| 6 | + | |
| 7 | +<Info> | |
| 8 | + Make sure you have [Node.js 18 or higher | |
| 9 | + installed](https://nodejs.org/en/download/). | |
| 10 | +</Info> | |
| 11 | + | |
| 12 | +## Installation | |
| 13 | + | |
| 14 | +Install Continue CLI globally using npm: | |
| 15 | + | |
| 16 | +```bash | |
| 17 | +npm i -g @continuedev/cli | |
| 18 | +``` | |
| 19 | + | |
| 20 | +## Two Ways to Use Continue CLI | |
| 21 | + | |
| 22 | +<Info> | |
| 23 | + **Quick Overview**: Continue CLI works in two modes - TUI for interactive | |
| 24 | + conversations or headless for automated commands. | |
| 25 | +</Info> | |
| 26 | + | |
| 27 | +<Tabs> | |
| 28 | +<Tab title="TUI Mode"> | |
| 29 | +**Interactive development sessions** | |
| 30 | + | |
| 31 | +Start a conversation with AI in your terminal: | |
| 32 | + | |
| 33 | +```bash | |
| 34 | +cn | |
| 35 | +> @src/app.js Generate unit tests for this component | |
| 36 | +``` | |
| 37 | + | |
| 38 | +Perfect for exploration, debugging, and iterative development. | |
| 39 | + | |
| 40 | +</Tab> | |
| 41 | + | |
| 42 | +<Tab title="Headless Mode"> | |
| 43 | +**Automation and scripting** | |
| 44 | + | |
| 45 | +Single commands that return results: | |
| 46 | + | |
| 47 | +```bash | |
| 48 | +cn -p "Generate a commit message for current changes" | |
| 49 | +cn -p "Review the last 5 commits for issues" | |
| 50 | +``` | |
| 51 | + | |
| 52 | +Perfect for CI/CD, git hooks, and automated workflows. | |
| 53 | + | |
| 54 | +</Tab> | |
| 55 | +</Tabs> | |
| 56 | + | |
| 57 | +## Setup | |
| 58 | + | |
| 59 | +<Tabs> | |
| 60 | +<Tab title="cn TUI Mode"> | |
| 61 | + | |
| 62 | +For interactive development and exploration: | |
| 63 | + | |
| 64 | +<Steps> | |
| 65 | +<Step title="Login to Continue CLI"> | |
| 66 | +```bash | |
| 67 | +cn login | |
| 68 | +``` | |
| 69 | +This will open your browser to authenticate with Continue Hub. | |
| 70 | +</Step> | |
| 71 | + | |
| 72 | +<Step title="Test TUI Mode"> | |
| 73 | +Start an interactive session: | |
| 74 | +```bash | |
| 75 | +cn | |
| 76 | +``` | |
| 77 | + | |
| 78 | +Try asking a question: | |
| 79 | + | |
| 80 | +``` | |
| 81 | +> Tell me about the CLI | |
| 82 | +``` | |
| 83 | + | |
| 84 | +</Step> | |
| 85 | +</Steps> | |
| 86 | +</Tab> | |
| 87 | +<Tab title="cn Headless Mode"> | |
| 88 | + | |
| 89 | +For automation workflows and scripting: | |
| 90 | + | |
| 91 | +<Steps> | |
| 92 | +<Step title="Get API Key for Automation"> | |
| 93 | +For automation workflows, get an API key: | |
| 94 | +1. Visit [Continue Hub API Keys](https://hub.continue.dev/settings/api-keys) | |
| 95 | +2. Click **"+ New API Key"** | |
| 96 | +3. Copy the API key immediately (you won't see it again!) | |
| 97 | +4. Login using your Continue account | |
| 98 | +</Step> | |
| 99 | + | |
| 100 | +<Step title="Add Secrets for Workflows"> | |
| 101 | +Store secure credentials for CLI workflows: | |
| 102 | +1. Visit [Continue Hub Secrets](https://hub.continue.dev/settings/secrets) | |
| 103 | +2. Add your API keys and sensitive data | |
| 104 | +3. Reference in configurations with `${{ secrets.SECRET_NAME }}` | |
| 105 | +</Step> | |
| 106 | + | |
| 107 | +<Step title="Test Headless Mode"> | |
| 108 | +Try headless mode for automation: | |
| 109 | +```bash | |
| 110 | +cn -p "Generate a conventional commit message for the current git changes" | |
| 111 | +``` | |
| 112 | +</Step> | |
| 113 | +</Steps> | |
| 114 | +</Tab> | |
| 115 | +</Tabs> | |
| 116 | + | |
| 117 | +## What's Next? | |
| 118 | + | |
| 119 | +<CardGroup cols={2}> | |
| 120 | +<Card title="Quick Start Guide" icon="rocket" href="/cli/quick-start"> | |
| 121 | + Learn basic usage with practical examples | |
| 122 | +</Card> | |
| 123 | + | |
| 124 | +<Card title="Create your first workflow" icon="gear" href="/guides/posthog-github-continuous-ai"> | |
| 125 | + Build automated workflows with Continue CLI | |
| 126 | +</Card> | |
| 127 | +</CardGroup> | |
| 128 | + | |
| 129 | +## Getting Help | |
| 130 | + | |
| 131 | +If you encounter issues: | |
| 132 | + | |
| 133 | +- Ask for help in [our discussions](https://github.com/continuedev/continue/discussions) | |
| 134 | +- Report bugs on [GitHub](https://github.com/continuedev/continue) |
| @@ -0,0 +1,228 @@ | ||
| 1 | +--- | |
| 2 | +title: "Continue CLI (cn) Overview" | |
| 3 | +description: "Command-line interface for automated coding tasks, scripting, and headless development workflows with Continue's AI coding capabilities" | |
| 4 | +sidebarTitle: "Overview" | |
| 5 | +--- | |
| 6 | + | |
| 7 | +<Frame> | |
| 8 | + <img src="/images/cn-demo.gif" /> | |
| 9 | +</Frame> | |
| 10 | + | |
| 11 | +**Continue enables developers to ship faster with Continuous AI.** | |
| 12 | + | |
| 13 | +<Tip> | |
| 14 | + Build features from descriptions. Debug and fix issues. Navigate any codebase. | |
| 15 | + Automate tedious tasks. | |
| 16 | +</Tip> | |
| 17 | + | |
| 18 | +## Get started in 30 seconds | |
| 19 | + | |
| 20 | +Prerequisites: | |
| 21 | + | |
| 22 | +- [Node.js 18 or newer](https://nodejs.org/en/download/) | |
| 23 | +- A [Continue Hub](https://hub.continue.dev) account (recommended) or local configuration | |
| 24 | + | |
| 25 | +```bash npm | |
| 26 | +# Install Continue CLI | |
| 27 | +npm install -g @continuedev/cli | |
| 28 | + | |
| 29 | +# Navigate to your project | |
| 30 | + | |
| 31 | +cd your-awesome-project | |
| 32 | + | |
| 33 | +# Start coding with Continue | |
| 34 | + | |
| 35 | +cn | |
| 36 | + | |
| 37 | +# You'll be prompted to set up on first use | |
| 38 | + | |
| 39 | +``` | |
| 40 | + | |
| 41 | +That's it! You're ready to start automating with Continue CLI. | |
| 42 | + | |
| 43 | +[Continue with CLI Quickstart →](/cli/quick-start) | |
| 44 | + | |
| 45 | +## Two Ways to Use Continue CLI | |
| 46 | + | |
| 47 | +Continue CLI offers two distinct modes designed for different workflows: | |
| 48 | + | |
| 49 | +### TUI Mode: Interactive Development | |
| 50 | + | |
| 51 | +**Perfect for exploration, debugging, and iterating on AI workflows** | |
| 52 | + | |
| 53 | +```bash | |
| 54 | +cn | |
| 55 | +> @src/components/UserProfile.js Review this component for security issues | |
| 56 | +> Generate comprehensive unit tests | |
| 57 | +> Suggest performance improvements | |
| 58 | +``` | |
| 59 | + | |
| 60 | +- **Interactive conversations** with your codebase | |
| 61 | +- **Iterate and refine** prompts and approaches | |
| 62 | +- **Explore and understand** complex codebases | |
| 63 | +- **Perfect for experimentation** and learning | |
| 64 | + | |
| 65 | +### Headless Mode: Production Automation | |
| 66 | + | |
| 67 | +**Perfect for CI/CD, automation, and reliable workflows** | |
| 68 | + | |
| 69 | +```bash | |
| 70 | +cn -p "Generate a conventional commit message for staged changes" | |
| 71 | +cn -p "Review pull request changes for security vulnerabilities" | |
| 72 | +cn -p "Update documentation based on recent code changes" | |
| 73 | +``` | |
| 74 | + | |
| 75 | +- **Single-command execution** for automation | |
| 76 | +- **Reliable, repeatable results** for production use | |
| 77 | +- **CI/CD and pipeline integration** | |
| 78 | +- **Git hooks and automated workflows** | |
| 79 | + | |
| 80 | +### Development Workflow: TUI → Headless | |
| 81 | + | |
| 82 | +<Tip> | |
| 83 | + **Pro Tip**: Start in TUI mode to iterate on your AI agent and prompts. Once | |
| 84 | + you have a workflow that works reliably, deploy it as a Continuous AI | |
| 85 | + automation. | |
| 86 | +</Tip> | |
| 87 | + | |
| 88 | +1. **Experiment in TUI mode** to perfect your prompts and agent configuration | |
| 89 | +2. **Test different approaches** interactively until you get consistent results | |
| 90 | +3. **Convert successful workflows** to automated Continuous AI commands | |
| 91 | +4. **Deploy in production** with confidence in your proven approach | |
| 92 | + | |
| 93 | +## Why developers love Continue CLI | |
| 94 | + | |
| 95 | +- **Works in your terminal**: Not another chat window. Not another IDE. Continue CLI meets you where you already work, with the tools you already love. | |
| 96 | +- **Takes action**: Continue CLI can directly edit files, run commands, and create commits. Need more? Check out our [MCPs](/customize/deep-dives/mcp). | |
| 97 | +- **Automate tasks**: Create issues from PostHog data, automatically assign labels to issues, and more. Do all this in a single command from your developer machines, or automatically in CI. | |
| 98 | +- **Flexible development flow**: Start interactive, then automate proven workflows. | |
| 99 | + | |
| 100 | +## Key Capabilities | |
| 101 | + | |
| 102 | +### Context Engineering | |
| 103 | + | |
| 104 | +- Use `@` to reference files and provide context | |
| 105 | +- Use `/` to run slash commands for specific tasks | |
| 106 | +- Access the same context providers as IDE extensions | |
| 107 | + | |
| 108 | +### Tool Integration | |
| 109 | + | |
| 110 | +- File editing and creation | |
| 111 | +- Terminal command execution | |
| 112 | +- Codebase understanding and analysis | |
| 113 | +- Git integration | |
| 114 | +- Web search and documentation access | |
| 115 | + | |
| 116 | +### Model Flexibility | |
| 117 | + | |
| 118 | +- Switch between models with `/model` command | |
| 119 | +- Use any model configured in your `config.yaml` | |
| 120 | +- Access Continue Hub models and configurations | |
| 121 | + | |
| 122 | +## Continue Hub Integration | |
| 123 | + | |
| 124 | +Continue CLI integrates seamlessly with [Continue Hub](https://hub.continue.dev) for: | |
| 125 | + | |
| 126 | +### API Access | |
| 127 | + | |
| 128 | +Get an API key for automation workflows: | |
| 129 | + | |
| 130 | +1. Visit [Continue Hub API Keys](https://hub.continue.dev/settings/api-keys) | |
| 131 | +2. Create a new API key | |
| 132 | +3. Use with `cn login` or in your automation scripts | |
| 133 | + | |
| 134 | +### Secrets Management | |
| 135 | + | |
| 136 | +Store secure credentials for CLI workflows: | |
| 137 | + | |
| 138 | +1. Visit [Continue Hub Secrets](https://hub.continue.dev/settings/secrets) | |
| 139 | +2. Add your API keys and sensitive data | |
| 140 | +3. Reference in configurations with `${{ secrets.SECRET_NAME }}` | |
| 141 | + | |
| 142 | +### Configuration Sync | |
| 143 | + | |
| 144 | +- Cloud-managed configurations automatically sync | |
| 145 | +- Share configurations across team members | |
| 146 | +- Version control for your AI workflows | |
| 147 | + | |
| 148 | +## Common Use Cases | |
| 149 | + | |
| 150 | +### TUI Mode Examples | |
| 151 | + | |
| 152 | +**Interactive development and exploration:** | |
| 153 | + | |
| 154 | +<CodeGroup> | |
| 155 | +```bash Codebase Exploration | |
| 156 | +# Start interactive session | |
| 157 | +cn | |
| 158 | +> @src/components Find all unused React components | |
| 159 | +> /explain How does authentication work in this codebase? | |
| 160 | +> @auth/ What security patterns are used here? | |
| 161 | +``` | |
| 162 | + | |
| 163 | +```bash Iterative Debugging | |
| 164 | +# Debug issues interactively | |
| 165 | +cn | |
| 166 | +> @tests/auth.test.js This test is failing, help me understand why | |
| 167 | +> @src/auth/middleware.js Let's examine this middleware | |
| 168 | +> /debug What could be causing the timeout error? | |
| 169 | +``` | |
| 170 | + | |
| 171 | +```bash Workflow Development | |
| 172 | +# Develop and test automation workflows | |
| 173 | +cn | |
| 174 | +> @package.json @CHANGELOG.md Generate a release notes template | |
| 175 | +> # Test and refine the approach | |
| 176 | +> # Once working, convert to: cn -p "Generate release notes" | |
| 177 | +``` | |
| 178 | + | |
| 179 | +</CodeGroup> | |
| 180 | + | |
| 181 | +### Headless Mode Examples | |
| 182 | + | |
| 183 | +**Production automation and scripting:** | |
| 184 | + | |
| 185 | +<CodeGroup> | |
| 186 | +```bash Git Automation | |
| 187 | +# Generate commit messages | |
| 188 | +cn -p "Generate a conventional commit message for the current changes" | |
| 189 | + | |
| 190 | +# Code review automation | |
| 191 | + | |
| 192 | +cn -p "Review the current git changes for bugs and suggest improvements" | |
| 193 | + | |
| 194 | +```` | |
| 195 | + | |
| 196 | +```bash CI/CD Integration | |
| 197 | +# In your pipeline scripts | |
| 198 | +cn -p "Analyze test failures and suggest fixes" | |
| 199 | + | |
| 200 | +# Automated documentation updates | |
| 201 | +cn -p "@README.md Update this documentation based on recent changes" | |
| 202 | +```` | |
| 203 | + | |
| 204 | +```bash Issue Management | |
| 205 | +# Create GitHub issues from PostHog data | |
| 206 | +cn -p "@posthog-data.json Create GitHub issues for UX problems found in this session data" | |
| 207 | + | |
| 208 | +# Automated security audits | |
| 209 | +cn -p "Scan the codebase for potential security vulnerabilities" | |
| 210 | +``` | |
| 211 | + | |
| 212 | +</CodeGroup> | |
| 213 | + | |
| 214 | +## Next steps | |
| 215 | + | |
| 216 | +<CardGroup cols={3}> | |
| 217 | + <Card title="CLI Quickstart" href="/cli/quick-start"> | |
| 218 | + Learn basic commands and common workflows | |
| 219 | + </Card> | |
| 220 | + | |
| 221 | +<Card title="Installation Guide" href="/cli/install"> | |
| 222 | + Install Continue CLI and set up your environment | |
| 223 | +</Card> | |
| 224 | + | |
| 225 | + <Card title="CLI Workflows" href="/guides/overview#continuous-ai"> | |
| 226 | + Task-specific tutorials and examples | |
| 227 | + </Card> | |
| 228 | +</CardGroup> |
| @@ -0,0 +1,176 @@ | ||
| 1 | +--- | |
| 2 | +title: "Continue CLI Quick Start" | |
| 3 | +description: "Get hands-on experience with Continue CLI through practical examples and common use cases" | |
| 4 | +sidebarTitle: "Quick Start" | |
| 5 | +--- | |
| 6 | + | |
| 7 | +Get hands-on experience with Continue CLI through practical development workflows. | |
| 8 | + | |
| 9 | +<Tabs> | |
| 10 | + <Tab title="TUI Mode"> | |
| 11 | + TUI Mode (`cn` command) is for **large development tasks** that require | |
| 12 | + agentic workflows with human oversight. Perfect for complex refactors, | |
| 13 | + feature implementation, or one-off automation tasks that need monitoring and | |
| 14 | + iteration. | |
| 15 | + </Tab> | |
| 16 | + <Tab title="Headless Mode"> | |
| 17 | + Headless Mode (`-p` flag) is for **reliable, repeatable tasks** that no | |
| 18 | + longer need constant supervision. Perfect for CI/CD pipelines, git hooks, | |
| 19 | + and automated workflows you've already tested and refined. | |
| 20 | + </Tab> | |
| 21 | +</Tabs> | |
| 22 | + | |
| 23 | +## TUI Mode: Large Development Tasks | |
| 24 | + | |
| 25 | +Make sure you have [Continue CLI installed](/cli/install) and are in a project directory. | |
| 26 | + | |
| 27 | +### Example: Implementing a New Feature | |
| 28 | + | |
| 29 | +```bash | |
| 30 | +# Navigate to your project directory | |
| 31 | +cd your-awesome-project | |
| 32 | + | |
| 33 | +# Start TUI Mode for complex development work | |
| 34 | +cn | |
| 35 | +``` | |
| 36 | + | |
| 37 | +**Example workflow for adding authentication:** | |
| 38 | + | |
| 39 | +``` | |
| 40 | +> I need to add JWT authentication to this Express app. Let me start by showing you the current structure. | |
| 41 | + | |
| 42 | +> @src/app.js @package.json Here's my current setup. Can you implement JWT auth with middleware, login/register routes, and user model? | |
| 43 | + | |
| 44 | +> [Agent analyzes codebase and implements auth system] | |
| 45 | +> [You review changes, test, and provide feedback] | |
| 46 | +> [Agent iterates based on your input until the feature is complete] | |
| 47 | +``` | |
| 48 | + | |
| 49 | +### Example: Complex Refactoring | |
| 50 | + | |
| 51 | +```bash | |
| 52 | +cn | |
| 53 | +``` | |
| 54 | + | |
| 55 | +**Refactoring a monolithic component:** | |
| 56 | + | |
| 57 | +``` | |
| 58 | +> @src/components/Dashboard.jsx This component is 800 lines and does too much. Help me break it into smaller, reusable components. | |
| 59 | + | |
| 60 | +> [Agent analyzes component structure] | |
| 61 | +> [Proposes component breakdown strategy] | |
| 62 | +> [You approve approach] | |
| 63 | +> [Agent implements the refactor with proper props and state management] | |
| 64 | +> [You test and request adjustments] | |
| 65 | +``` | |
| 66 | + | |
| 67 | +### When to Use TUI Mode | |
| 68 | + | |
| 69 | +✅ **Large development tasks** that need oversight | |
| 70 | +✅ **Complex refactors** requiring multiple steps | |
| 71 | +✅ **New feature implementation** with unknowns | |
| 72 | +✅ **One-off automation tasks** you haven't done before | |
| 73 | +✅ **Debugging complex issues** that need exploration | |
| 74 | + | |
| 75 | +## Headless Mode: Automated Workflows | |
| 76 | + | |
| 77 | +Once you've refined a workflow in TUI Mode, convert it to Continuous AI for automation. | |
| 78 | + | |
| 79 | +### Example: From REPL → Continuous AI | |
| 80 | + | |
| 81 | +**Step 1: Develop in TUI Mode** | |
| 82 | + | |
| 83 | +```bash | |
| 84 | +cn | |
| 85 | +> @package.json @CHANGELOG.md Generate release notes for version 2.1.0 | |
| 86 | +> [Test and refine the prompt until it works perfectly] | |
| 87 | +``` | |
| 88 | + | |
| 89 | +**Step 2: Convert to Continuous AI** | |
| 90 | + | |
| 91 | +```bash | |
| 92 | +# Now use the refined workflow in automation | |
| 93 | +cn -p "Generate release notes for the current version based on package.json and recent commits" | |
| 94 | +``` | |
| 95 | + | |
| 96 | +### Common Continuous AI Workflows | |
| 97 | + | |
| 98 | +```bash | |
| 99 | +# Git automation | |
| 100 | +cn -p "Generate a conventional commit message for staged changes" | |
| 101 | +cn -p "Review the last 3 commits for potential issues" | |
| 102 | + | |
| 103 | +# Code quality | |
| 104 | +cn -p "Fix all TypeScript errors in the src/ directory" | |
| 105 | +cn -p "Update outdated dependencies and fix breaking changes" | |
| 106 | + | |
| 107 | +# Documentation | |
| 108 | +cn -p "@README.md Update documentation based on recent changes" | |
| 109 | +cn -p "Generate API documentation from JSDoc comments" | |
| 110 | + | |
| 111 | +# CI/CD integration | |
| 112 | +cn -p "Analyze test failures and create GitHub issue with findings" | |
| 113 | +cn -p "Update version numbers and create release branch" | |
| 114 | +``` | |
| 115 | + | |
| 116 | +### When to Use Headless Mode | |
| 117 | + | |
| 118 | +✅ **Proven workflows** you've tested in TUI Mode | |
| 119 | +✅ **Repetitive tasks** that no longer need oversight | |
| 120 | +✅ **CI/CD automation** in pipelines | |
| 121 | +✅ **Git hooks** for automated checks | |
| 122 | +✅ **Scheduled tasks** that run unattended | |
| 123 | + | |
| 124 | +### Available Slash Commands | |
| 125 | + | |
| 126 | +Common slash commands available in CLI: | |
| 127 | + | |
| 128 | +- `/clear` - Clear the chat history | |
| 129 | +- `/compact` - Summarize chat history into a compact form | |
| 130 | +- `/config` - Switch configuration or organization | |
| 131 | +- `/exit` - Exit the chat | |
| 132 | +- `/fork` - Start a forked chat session from the current history | |
| 133 | +- `/help` - Show help message | |
| 134 | +- `/info` - Show session information | |
| 135 | +- `/init` - Create an AGENTS.md file | |
| 136 | +- `/login` - Authenticate with your account | |
| 137 | +- `/logout` - Sign out of your current session | |
| 138 | +- `/mcp` - Manage MCP server connections | |
| 139 | +- `/model` - Switch between available chat models | |
| 140 | +- `/resume` - Resume a previous chat session | |
| 141 | +- `/whoami` - Check who you're currently logged in as | |
| 142 | + | |
| 143 | +<Info>Use `/help` to see all available commands.</Info> | |
| 144 | + | |
| 145 | +## The Development Workflow | |
| 146 | + | |
| 147 | +<Info> | |
| 148 | + **Recommended Approach**: Start complex tasks in TUI Mode to iterate and | |
| 149 | + refine your approach. Once you have a reliable workflow, convert it to | |
| 150 | + Headless Mode for automation. | |
| 151 | +</Info> | |
| 152 | + | |
| 153 | +### Workflow Pattern | |
| 154 | + | |
| 155 | +1. **🔬 Experiment in TUI Mode** | |
| 156 | + | |
| 157 | + - Try complex development tasks with human oversight | |
| 158 | + - Iterate on prompts and approaches until they work reliably | |
| 159 | + - Test edge cases and refine the agent's behavior | |
| 160 | + | |
| 161 | +2. **⚡ Automate with Continuous AI** | |
| 162 | + - Convert proven REPL workflows to single commands | |
| 163 | + - Deploy in CI/CD, git hooks, or scheduled tasks | |
| 164 | + - Run with confidence knowing the approach is tested | |
| 165 | + | |
| 166 | +## Next Steps | |
| 167 | + | |
| 168 | +<CardGroup cols={2}> | |
| 169 | + <Card title="Create Your First Workflow" href="/guides/posthog-github-continuous-ai"> | |
| 170 | + Build an automated PostHog to GitHub issues workflow | |
| 171 | + </Card> | |
| 172 | + | |
| 173 | + <Card title="Continuous AI Guide" href="/guides/continuous-ai"> | |
| 174 | + Learn to build and deploy AI-powered development workflows | |
| 175 | + </Card> | |
| 176 | +</CardGroup> |
| @@ -65,10 +65,10 @@ | ||
| 65 | 65 | 3. Add `GEMINI_API_KEY` as a [User Secret](https://docs.continue.dev/hub/secrets/secret-types#user-secrets) on Continue Hub [here](https://hub.continue.dev/settings/secrets) |
| 66 | 66 | 4. Click `Reload config` in the agent selector in the Continue IDE extension |
| 67 | 67 | |
| 68 | -[Grok 4](https://hub.continue.dev/xai/grok-4) from xAI | |
| 68 | +[Grok Code Fast 1](https://hub.continue.dev/xai/grok-code-fast-1) from xAI | |
| 69 | 69 | |
| 70 | 70 | 1. Get your API key from [xAI](https://console.x.ai/) |
| 71 | -2. Add [Grok 4](https://hub.continue.dev/xai/grok-4) to an agent on Continue Hub | |
| 71 | +2. Add [Grok Code Fast 1](https://hub.continue.dev/xai/grok-code-fast-1) to an agent on Continue Hub | |
| 72 | 72 | 3. Add `XAI_API_KEY` as a [User Secret](https://docs.continue.dev/hub/secrets/secret-types#user-secrets) on Continue Hub [here](https://hub.continue.dev/settings/secrets) |
| 73 | 73 | 4. Click `Reload config` in the agent selector in the Continue IDE extension |
| 74 | 74 |
| @@ -210,9 +210,14 @@ | ||
| 210 | 210 | |
| 211 | 211 | ### xAI |
| 212 | 212 | |
| 213 | -| Model | Tool Use | Image Input | Context Window | | |
| 214 | -| :----- | -------- | ----------- | -------------- | | |
| 215 | -| Grok 4 | Yes | Yes | 128k | | |
| 213 | +| Model | Tool Use | Image Input | Context Window | | |
| 214 | +| :------------------------ | -------- | ----------- | -------------- | | |
| 215 | +| Grok Code Fast 1 | Yes | Yes | 256k | | |
| 216 | +| Grok 4 Fast Reasoning | Yes | Yes | 2M | | |
| 217 | +| Grok 4 Fast Non-Reasoning | Yes | Yes | 2M | | |
| 218 | +| Grok 4 | Yes | Yes | 256k | | |
| 219 | +| Grok 3 | Yes | Yes | 131k | | |
| 220 | +| Grok 3 Mini | Yes | Yes | 131k | | |
| 216 | 221 | |
| 217 | 222 | ### Moonshot AI |
| 218 | 223 |
| @@ -3,13 +3,9 @@ | ||
| 3 | 3 | slug: ../xai |
| 4 | 4 | --- |
| 5 | 5 | |
| 6 | -<Tip> | |
| 7 | - **Discover xAI models [here](https://hub.continue.dev/xai)** | |
| 8 | -</Tip> | |
| 6 | +<Tip>**Discover xAI models [here](https://hub.continue.dev/xai)**</Tip> | |
| 9 | 7 | |
| 10 | -<Info> | |
| 11 | - Get an API key from the [xAI Console](https://console.x.ai/) | |
| 12 | -</Info> | |
| 8 | +<Info>Get an API key from the [xAI Console](https://console.x.ai/)</Info> | |
| 13 | 9 | |
| 14 | 10 | ## Configuration |
| 15 | 11 | |
| @@ -29,7 +25,7 @@ | ||
| 29 | 25 | "models": [ |
| 30 | 26 | { |
| 31 | 27 | "title": "<MODEL_NAME>", |
| 32 | - "provider": "anthropic", | |
| 28 | + "provider": "xai", | |
| 33 | 29 | "model": "<MODEL_ID>", |
| 34 | 30 | "apiKey": "<YOUR_XAI_API_KEY>" |
| 35 | 31 | } |
| @@ -40,5 +36,6 @@ | ||
| 40 | 36 | </Tabs> |
| 41 | 37 | |
| 42 | 38 | <Info> |
| 43 | - **Check out a more advanced configuration [here](https://hub.continue.dev/xai/grok-4?view=config)** | |
| 44 | -</Info> | |
| No newline at the end of the file | ||
| 39 | + **Check out a more advanced configuration | |
| 40 | + [here](https://hub.continue.dev/xai/grok-code-fast-1?view=config)** | |
| 41 | +</Info> |
| @@ -23,6 +23,11 @@ | ||
| 23 | 23 | "getting-started/quick-start" |
| 24 | 24 | ] |
| 25 | 25 | }, |
| 26 | + { | |
| 27 | + "group": "CLI", | |
| 28 | + "icon": "terminal", | |
| 29 | + "pages": ["cli/overview", "cli/install", "cli/quick-start"] | |
| 30 | + }, | |
| 26 | 31 | { |
| 27 | 32 | "group": "Features", |
| 28 | 33 | "icon": "star", |
| @@ -230,10 +235,10 @@ | ||
| 230 | 235 | "pages": [ |
| 231 | 236 | "guides/overview", |
| 232 | 237 | "guides/understanding-agents", |
| 238 | + "guides/configuring-models-rules-tools", | |
| 233 | 239 | "guides/codebase-documentation-awareness", |
| 234 | 240 | "guides/cli", |
| 235 | 241 | "guides/continuous-ai", |
| 236 | - "guides/snyk-mcp-continue-cookbook", | |
| 237 | 242 | "guides/continuous-ai-readiness-assessment", |
| 238 | 243 | "guides/plan-mode-guide", |
| 239 | 244 | "guides/ollama-guide", |
| @@ -248,6 +253,7 @@ | ||
| 248 | 253 | "icon": "book-open-cover", |
| 249 | 254 | "pages": [ |
| 250 | 255 | "guides/posthog-github-continuous-ai", |
| 256 | + "guides/snyk-mcp-continue-cookbook", | |
| 251 | 257 | "guides/netlify-mcp-continuous-deployment" |
| 252 | 258 | ] |
| 253 | 259 | } |
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | <Warning> |
| 7 | 7 | Next Edit is currently an experimental feature. It requires |
| 8 | 8 | [Instinct](https://hub.continue.dev/continuedev/instinct) or [Mercury Coder |
| 9 | - model](https://hub.continue.dev/inceptionlabs/mercury-coder) configured in | |
| 9 | + model](https://hub.continue.dev/inception/mercury-coder) configured in | |
| 10 | 10 | your Continue autocomplete settings and is not yet available for JetBrains |
| 11 | 11 | use. |
| 12 | 12 | </Warning> |
| @@ -73,7 +73,6 @@ | ||
| 73 | 73 | Next Edit requires: |
| 74 | 74 | |
| 75 | 75 | - Compatible AI models (Mercury Coder or Instinct) |
| 76 | -- Continue development team access | |
| 77 | 76 | - VS Code (JetBrains support coming soon) |
| 78 | 77 | - **API Keys**: Organizations can add API keys to [org secrets](/hub/secrets/secret-types) for team-wide access. Individual users need to provide their own API keys in their [model configuration](/customize/model-providers/overview) |
| 79 | 78 |
| @@ -0,0 +1,168 @@ | ||
| 1 | +--- | |
| 2 | +title: "Configuring Models, Rules, and Tools" | |
| 3 | +description: "Learn how to work with Continue's configuration system. Understand how to use hub models, rules, and tools, create local configurations, and organize your setup for maximum reusability." | |
| 4 | +--- | |
| 5 | + | |
| 6 | +## What Are Models, Rules, and Tools? | |
| 7 | + | |
| 8 | +Continue agents are built from three main types of configuration: | |
| 9 | + | |
| 10 | +<Columns cols={3}> | |
| 11 | +<Card title="Models" icon="cube"> | |
| 12 | +Language models that power different capabilities like chat, autocomplete, and agent mode | |
| 13 | +</Card> | |
| 14 | + | |
| 15 | +<Card title="Rules" icon="pencil"> | |
| 16 | + Guidelines and instructions that shape how the AI behaves and responds | |
| 17 | +</Card> | |
| 18 | + | |
| 19 | +<Card title="Tools" icon="server"> | |
| 20 | +MCP tools that provide additional capabilities like database access, web search, or custom functions | |
| 21 | +</Card> | |
| 22 | +</Columns> | |
| 23 | + | |
| 24 | +There are two places where you can define these configurations: | |
| 25 | + | |
| 26 | +<Columns cols={2}> | |
| 27 | +<Card title="Local" icon="computer"> | |
| 28 | +Custom configurations you create and manage in your workspace or globally | |
| 29 | +</Card> | |
| 30 | + | |
| 31 | +<Card title="Hub" icon="cloud"> | |
| 32 | +Pre-built models, rules, and tools from the Continue community that you can import and use immediately | |
| 33 | +</Card> | |
| 34 | +</Columns> | |
| 35 | + | |
| 36 | +## Local | |
| 37 | + | |
| 38 | +Local configurations let you create custom models, rules, and tools that automatically apply to multiple agents, reducing duplication and ensuring consistency across your setup. | |
| 39 | + | |
| 40 | +<Columns cols={2}> | |
| 41 | +<Card title="Global" icon="globe"> | |
| 42 | +Applied to all agents across all workspaces. Ideal for personal preferences, universal coding standards, or tools you use everywhere. | |
| 43 | +</Card> | |
| 44 | +<Card title="Workspace" icon="folder-open"> | |
| 45 | +Applied automatically to all agents when working in a specific project. | |
| 46 | + | |
| 47 | +Perfect for project-specific setups like TypeScript rules for web apps or the Playwright MCP tool. | |
| 48 | + | |
| 49 | +</Card> | |
| 50 | + | |
| 51 | +</Columns> | |
| 52 | + | |
| 53 | +## Hub | |
| 54 | + | |
| 55 | +Continue hub uses a slug in the format of `owner/item-name` to resolve blocks. | |
| 56 | + | |
| 57 | +For example, to use the [Claude 4 Sonnet model](https://hub.continue.dev/anthropic/claude-4-sonnet), you'd reference it as `anthropic/claude-4-sonnet`. | |
| 58 | + | |
| 59 | +Import from the hub using the `uses` syntax alongside your custom configurations: | |
| 60 | + | |
| 61 | +```yaml config.yaml highlight={6} | |
| 62 | +name: Team Agent | |
| 63 | +version: 1.0.0 | |
| 64 | +schema: v1 | |
| 65 | + | |
| 66 | +models: | |
| 67 | + - uses: anthropic/claude-4-sonnet | |
| 68 | + with: | |
| 69 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} # Use a hub secret | |
| 70 | +``` | |
| 71 | + | |
| 72 | +### Organization | |
| 73 | + | |
| 74 | +Organize your local configurations using these directories: | |
| 75 | + | |
| 76 | +<Columns cols={3}> | |
| 77 | +<Card title="Models" icon="cube"> | |
| 78 | + `.continue/models` | |
| 79 | +</Card> | |
| 80 | + | |
| 81 | +<Card title="Rules" icon="pencil"> | |
| 82 | + `.continue/rules` | |
| 83 | +</Card> | |
| 84 | + | |
| 85 | +<Card title="Tools" icon="server"> | |
| 86 | + `.continue/mcpServers` | |
| 87 | +</Card> | |
| 88 | +</Columns> | |
| 89 | + | |
| 90 | +## Working with Secrets | |
| 91 | + | |
| 92 | +Models, and many MCP servers, require a secret for things like API keys. | |
| 93 | + | |
| 94 | +On the hub, you can configure secrets when adding a model or MCP server. | |
| 95 | + | |
| 96 | +This will use mustache notation to pass the secret, eg `${{ secrets.SECRET_NAME }}` | |
| 97 | + | |
| 98 | +When configuring a local model or MCP server, you can use the same mustache notation for secrets which read from: | |
| 99 | + | |
| 100 | +<Columns cols={2}> | |
| 101 | +<Card title="Global" icon="globe"> | |
| 102 | +`.env` file in `~/.continue/.env` | |
| 103 | +</Card> | |
| 104 | + | |
| 105 | +<Card title="Workspace" icon="folder-open"> | |
| 106 | +`.env` file at your project root | |
| 107 | +</Card> | |
| 108 | +</Columns> | |
| 109 | + | |
| 110 | +## Overriding Properties | |
| 111 | + | |
| 112 | +You can directly override properties using the `override` syntax: | |
| 113 | + | |
| 114 | +```yaml title="config.yaml" highlight={10-13} | |
| 115 | +name: myprofile/custom-agent | |
| 116 | +version: 1.0.0 | |
| 117 | +schema: v1 | |
| 118 | + | |
| 119 | +models: | |
| 120 | + - uses: myprofile/custom-model | |
| 121 | + with: | |
| 122 | + ANTHROPIC_API_KEY: ${{ secrets.MY_ANTHROPIC_API_KEY }} | |
| 123 | + TEMP: 0.9 | |
| 124 | + override: | |
| 125 | + roles: | |
| 126 | + - chat | |
| 127 | +``` | |
| 128 | + | |
| 129 | +## Advanced | |
| 130 | + | |
| 131 | +### Inputs | |
| 132 | + | |
| 133 | +Models and MCP server authors can configure inputs that require the user to provide a secret value by defining a `${{ inputs.SECRET_NAME }}` value. | |
| 134 | + | |
| 135 | +For example, here is how you could require that the user provide a value for the `apiKey` property on a model: | |
| 136 | + | |
| 137 | +```yaml title="config.yaml" highlight={8} | |
| 138 | +name: myprofile/custom-model | |
| 139 | +version: 1.0.0 | |
| 140 | +schema: v1 | |
| 141 | + | |
| 142 | +models: | |
| 143 | + - name: My Favorite Model | |
| 144 | + # ... other model properties ... | |
| 145 | + apiKey: ${{ inputs.SECRET_NAME }} | |
| 146 | +``` | |
| 147 | + | |
| 148 | +Users then map their secret to this input using a `${{ secrets.SECRET_NAME }}` value that maps to a property name which matches the required input, e.g. `SECRET_NAME`. | |
| 149 | + | |
| 150 | +```yaml title="config.yaml" highlight={8} | |
| 151 | +name: myprofile/custom-agent | |
| 152 | +version: 1.0.0 | |
| 153 | +schema: v1 | |
| 154 | + | |
| 155 | +models: | |
| 156 | + - uses: myprofile/custom-model | |
| 157 | + with: | |
| 158 | + SECRET_NAME: ${{ secrets.SECRET_NAME }} | |
| 159 | +``` | |
| 160 | + | |
| 161 | +## Next Steps | |
| 162 | + | |
| 163 | +Now that you understand how models, rules, and tools work, explore: | |
| 164 | + | |
| 165 | +- **[Config Reference](/reference)**: Detailed documentation of all available properties | |
| 166 | +- **[Continue Hub](https://hub.continue.dev)**: Browse community models, rules, and tools | |
| 167 | +- **[Custom Context Providers](/customize/deep-dives/custom-providers)**: Create advanced context integrations | |
| 168 | +- **[Model Roles](/customize/model-roles/intro)**: Understanding how different models work together |
| @@ -44,18 +44,82 @@ | ||
| 44 | 44 | |
| 45 | 45 | ## Quick Setup |
| 46 | 46 | |
| 47 | +<Info> | |
| 48 | + The Netlify Development Rules bundle includes guardrails for: | |
| 49 | + - Proper `.gitignore` configuration | |
| 50 | + - Function structure and placement | |
| 51 | + - Edge function constraints | |
| 52 | + - Local development best practices | |
| 53 | + | |
| 54 | +</Info> | |
| 55 | +For all options, first: | |
| 47 | 56 | <Steps> |
| 48 | - <Step title="Install Continue CLI"> | |
| 57 | +<Step title="Install Continue CLI"> | |
| 49 | 58 | ```bash |
| 50 | 59 | npm i -g @continuedev/cli |
| 51 | 60 | ``` |
| 52 | 61 | </Step> |
| 53 | 62 | |
| 63 | +<Step title="Install Netlify CLI"> | |
| 64 | + | |
| 65 | + 1. Install Netlify CLI: `npm i -g netlify-cli` | |
| 66 | + 2. Authenticate with Netlify: | |
| 67 | + `netlify login` | |
| 68 | + </Step> | |
| 69 | +</Steps> | |
| 70 | + | |
| 71 | +## Netlify Continuous AI Workflow Options | |
| 72 | + | |
| 73 | +<Card title="🚀 Fastest Path to Success" icon="zap"> | |
| 74 | + Skip the manual setup and use our pre-built Netlify Continuous AI agent that includes | |
| 75 | + optimized prompts, rules, and the Netlify MCP for more consistent results. | |
| 76 | +</Card> | |
| 77 | + | |
| 78 | +After completing **Quick Setup** above, you have two paths to get started: | |
| 79 | + | |
| 80 | +<Tabs> | |
| 81 | + <Tab title="⚡ Quick Start (Recommended)"> | |
| 82 | + | |
| 83 | + <Steps> | |
| 84 | + <Step title="Add the Pre-Built Agent"> | |
| 85 | + Visit the [Netlify Continuous AI Agent](https://hub.continue.dev/continuedev/netlify-continuous-ai) on Continue Hub and click **"Install Agent"** | |
| 86 | + | |
| 87 | + This agent includes: | |
| 88 | + - **Optimized prompts** for Netlify deployment and performance analysis | |
| 89 | + - **Built-in rules** for consistent formatting and error handling | |
| 90 | + - **Netlify MCP** for more reliable API interactions | |
| 91 | + </Step> | |
| 92 | + | |
| 93 | + <Step title="Verify Your Setup"> | |
| 94 | + The agent uses the Netlify MCP automatically and includes best practice rules for deployment and performance optimization. | |
| 95 | + </Step> | |
| 96 | + | |
| 97 | + <Step title="Run Performance Analysis"> | |
| 98 | + Navigate to your project directory and run: | |
| 99 | + ```bash | |
| 100 | + cn "Analyze my Netlify site's performance and optimize it for better Core Web Vitals." | |
| 101 | + ``` | |
| 102 | + | |
| 103 | + That's it! The agent handles everything automatically. | |
| 104 | + </Step> | |
| 105 | + </Steps> | |
| 106 | + | |
| 107 | + <Info> | |
| 108 | + **Why Use the Agent?** Results are more consistent and debugging is easier thanks to the Netlify MCP integration and pre-tested prompts. You can remix the agent later to customize it to your needs. | |
| 109 | + </Info> | |
| 110 | + | |
| 111 | + </Tab> | |
| 112 | + | |
| 113 | + <Tab title="🛠️ Manual Setup"> | |
| 114 | +<Steps> | |
| 115 | + | |
| 54 | 116 | <Step title="Configure Netlify MCP"> |
| 55 | - 1. Install Netlify CLI: `npm i -g netlify-cli` 2. Authenticate with Netlify: | |
| 56 | - `netlify login` 3. Visit [Netlify MCP on Continue | |
| 57 | - Hub](https://hub.continue.dev/netlify/netlify-mcp) 4. Follow the configuration | |
| 58 | - instructions for your editor | |
| 117 | + 1. Authenticate with Netlify: | |
| 118 | + `netlify login` | |
| 119 | + 2. Visit [Netlify MCP on Continue | |
| 120 | + Hub](https://hub.continue.dev/netlify/netlify-mcp) | |
| 121 | + 3. Follow the configuration instructions for your editor | |
| 122 | + | |
| 59 | 123 | </Step> |
| 60 | 124 | |
| 61 | 125 | <Step title="Add Development Rules"> |
| @@ -77,13 +141,26 @@ | ||
| 77 | 141 | ``` |
| 78 | 142 | |
| 79 | 143 | </Step> |
| 80 | -</Steps> | |
| 81 | 144 | |
| 82 | -<Info> | |
| 83 | - The Netlify Development Rules bundle includes guardrails for: - Proper | |
| 84 | - `.gitignore` configuration - Function structure and placement - Edge function | |
| 85 | - constraints - Local development best practices | |
| 86 | -</Info> | |
| 145 | + | |
| 146 | +</Steps> | |
| 147 | + <Info> | |
| 148 | + You're all set! Now you can use cn CLI to interact with Netlify using natural language prompts. Check out the examples below to get started. | |
| 149 | + </Info> | |
| 150 | + </Tab> | |
| 151 | +</Tabs> | |
| 152 | + | |
| 153 | +<Accordion title="Agent Requirements"> | |
| 154 | + To use the pre-built agent, you need either: | |
| 155 | + - **Continue CLI Pro Plan** with | |
| 156 | + the models add-on, OR | |
| 157 | + - **Your own API keys** added to Continue Hub secrets | |
| 158 | + The agent will automatically detect and use your | |
| 159 | + configuration along with the Netlify MCP for deployment operations. | |
| 160 | + | |
| 161 | +</Accordion> | |
| 162 | + | |
| 163 | +--- | |
| 87 | 164 | |
| 88 | 165 | ## Performance Optimization Steps |
| 89 | 166 | |
| @@ -375,6 +452,14 @@ | ||
| 375 | 452 | |
| 376 | 453 | ## Automated Performance Checks |
| 377 | 454 | |
| 455 | +### Add GitHub Secrets | |
| 456 | + | |
| 457 | +Navigate to **Repository Settings → Secrets and variables → Actions** and add: | |
| 458 | + | |
| 459 | +- `CONTINUE_API_KEY`: Your Continue API key from [hub.continue.dev/settings/api-keys](https://hub.continue.dev/settings/api-keys) | |
| 460 | +- `NETLIFY_AUTH_TOKEN`: Your Netlify personal access token | |
| 461 | +- `NETLIFY_SITE_ID`: Your Netlify site ID | |
| 462 | + | |
| 378 | 463 | ### GitHub Actions Performance Guard |
| 379 | 464 | |
| 380 | 465 | Block PRs that degrade performance: |
| @@ -394,17 +479,28 @@ | ||
| 394 | 479 | with: |
| 395 | 480 | node-version: "22" |
| 396 | 481 | |
| 482 | + - name: Install Continue CLI | |
| 483 | + run: | | |
| 484 | + npm install -g @continuedev/cli | |
| 485 | + echo "✅ Continue CLI installed" | |
| 486 | + | |
| 487 | + - name: Authenticate Continue CLI | |
| 488 | + env: | |
| 489 | + CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} | |
| 490 | + run: | | |
| 491 | + cn auth login --api-key "$CONTINUE_API_KEY" | |
| 492 | + echo "✅ Continue CLI authenticated" | |
| 493 | + | |
| 397 | 494 | - name: Deploy and Test Performance |
| 398 | 495 | id: perf |
| 399 | 496 | env: |
| 400 | 497 | NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 401 | 498 | NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 402 | 499 | run: | |
| 403 | - npx @continuedev/cli@latest << 'EOF' | |
| 404 | - Deploy PR preview and run Lighthouse. | |
| 405 | - Compare scores with main branch. | |
| 406 | - Output JSON with score deltas. | |
| 407 | - EOF > performance.json | |
| 500 | + echo "🚀 Deploying PR preview and analyzing performance..." | |
| 501 | + cn -p "Deploy PR preview and run Lighthouse. | |
| 502 | + Compare scores with main branch. | |
| 503 | + Output JSON with score deltas." > performance.json | |
| 408 | 504 | |
| 409 | 505 | - name: Comment Performance Results |
| 410 | 506 | uses: actions/github-script@v7 |
| @@ -442,9 +538,11 @@ | ||
| 442 | 538 | ``` |
| 443 | 539 | |
| 444 | 540 | <Warning> |
| 445 | - This workflow will: - **Block merge** if performance score drops >10 points - | |
| 446 | - **Warn** on any performance regression - **Celebrate** improvements with green | |
| 447 | - indicators | |
| 541 | + This workflow will: | |
| 542 | + - **Block merge** if performance score drops >10 points | |
| 543 | + - **Warn** on any performance regression | |
| 544 | + - **Celebrate** improvements with green indicators | |
| 545 | + | |
| 448 | 546 | </Warning> |
| 449 | 547 | |
| 450 | 548 | ## Performance Testing Locally |
| @@ -528,9 +626,12 @@ | ||
| 528 | 626 | |
| 529 | 627 | <Card title="On-Demand Builders" icon="hammer"> |
| 530 | 628 | **[On-Demand |
| 531 | - Builders](https://docs.netlify.com/configure-builds/on-demand-builders/)** - | |
| 532 | - Generate pages only when requested - Cache dynamically generated content - | |
| 533 | - Perfect for large sites (10k+ pages) - Reduce build times dramatically | |
| 629 | + Builders](https://docs.netlify.com/configure-builds/on-demand-builders/)** | |
| 630 | + - Generate pages only when requested | |
| 631 | + - Cache dynamically generated content | |
| 632 | + - Perfect for large sites (10k+ pages) | |
| 633 | + - Reduce build times dramatically | |
| 634 | + | |
| 534 | 635 | </Card> |
| 535 | 636 | |
| 536 | 637 | <Card title="Netlify Functions" icon="function"> |
| @@ -1,23 +1,32 @@ | ||
| 1 | 1 | --- |
| 2 | 2 | title: "Building a Continuous AI Workflow with PostHog and GitHub" |
| 3 | -description: "Build an automated system that continuously monitors PostHog session recordings, analyzes UX issues using Continue CLI, and creates GitHub issues automatically." | |
| 4 | -sidebarTitle: "PostHog Session Analysis with Continue CLI" | |
| 3 | +description: "Build an automated system that continuously monitors PostHog analytics, analyzes user behavior with AI, and creates GitHub issues automatically using PostHog MCP." | |
| 4 | +sidebarTitle: "PostHog Analytics with Continue CLI" | |
| 5 | 5 | --- |
| 6 | 6 | |
| 7 | 7 | <Card title="What You'll Build" icon="robot"> |
| 8 | - A fully automated workflow that uses Continue CLI to fetch PostHog session | |
| 9 | - data, analyze user experience issues with AI, and automatically create GitHub | |
| 10 | - issues with specific technical recommendations | |
| 8 | + A fully automated workflow that uses Continue CLI with the PostHog MCP to fetch analytics data, analyze user experience issues with AI, and automatically create GitHub | |
| 9 | + issues with the GitHub CLI. | |
| 11 | 10 | </Card> |
| 12 | 11 | |
| 12 | +## What You'll Learn | |
| 13 | + | |
| 14 | +This cookbook teaches you to: | |
| 15 | + | |
| 16 | +- Use [PostHog MCP](https://posthog.com/docs/model-context-protocol) to query [analytics](https://posthog.com/docs/web-analytics), [errors](https://posthog.com/docs/error-tracking), and [feature flags](https://posthog.com/docs/feature-flags) | |
| 17 | +- Analyze user behavior patterns with AI | |
| 18 | +- Automatically create GitHub issues using GitHub CLI | |
| 19 | +- Set up continuous monitoring with GitHub Actions | |
| 20 | + | |
| 13 | 21 | ## Prerequisites |
| 14 | 22 | |
| 15 | 23 | Before starting, ensure you have: |
| 16 | 24 | |
| 17 | 25 | - GitHub repository where you want to create issues |
| 18 | -- PostHog account with **[session recordings enabled and collecting data](https://posthog.com/docs/session-replay/installation)** | |
| 26 | +- [PostHog account](https://posthog.com) with [session recordings enabled](https://posthog.com/docs/session-replay/installation) and data collecting | |
| 19 | 27 | - Node.js 18+ installed locally |
| 20 | -- Continue CLI account with **active credits** (required for API usage) | |
| 28 | +- [Continue CLI](https://docs.continue.dev/guides/cli) with **active credits** (required for API usage) | |
| 29 | +- [GitHub CLI](https://cli.github.com/) installed (`gh` command) | |
| 21 | 30 | |
| 22 | 31 | <Steps> |
| 23 | 32 | <Step title="Install Continue CLI"> |
| @@ -66,39 +75,38 @@ | ||
| 66 | 75 | 7. Note your PostHog host URL (e.g., `https://us.posthog.com` or your custom domain) |
| 67 | 76 | 8. You'll also need your POSTHOG_AUTH_HEADER value, which is simply `Bearer YOUR_API_KEY` |
| 68 | 77 | |
| 69 | - <Tip> | |
| 70 | - **Find Your Project Details**: Your Project ID is in your PostHog URL: | |
| 71 | - `https://app.posthog.com/project/YOUR_PROJECT_ID` | |
| 72 | - </Tip> | |
| 78 | + <Info> | |
| 79 | + **Continue Secrets**: The `POSTHOG_AUTH_HEADER` secret should be stored in | |
| 80 | + Continue's secure secrets storage. This keeps your API key safe and the MCP | |
| 81 | + automatically connects to your default PostHog project. | |
| 82 | +</Info> | |
| 73 | 83 | |
| 74 | 84 | </Tab> |
| 75 | - <Tab title="GitHub Personal Access Token"> | |
| 76 | - You'll need a **Personal Access Token** to create issues in your GitHub repository: | |
| 77 | - | |
| 78 | - 1. Go to [GitHub Personal Access Tokens](https://github.com/settings/personal-access-tokens/new) | |
| 79 | - 2. Click **"Generate new token (classic)"** | |
| 80 | - 3. Name it "Continue CLI PostHog Analysis" | |
| 81 | - 4. Select these scopes: | |
| 82 | - - `repo` (or just `public_repo` if your repository is public) | |
| 83 | - - `issues:write` - **Required** for creating issues | |
| 84 | - 5. Copy the token immediately | |
| 85 | + <Tab title="Set Up GitHub CLI Authentication"> | |
| 86 | + GitHub CLI handles authentication automatically - no manual PAT needed: | |
| 85 | 87 | |
| 86 | - </Tab> | |
| 87 | -</Tabs> | |
| 88 | + 1. Install GitHub CLI if not already installed | |
| 89 | + 2. Run `gh auth login` and follow the prompts | |
| 90 | + 3. Choose authentication method (browser or token) | |
| 91 | + 4. Grant necessary permissions when prompted (`issues:write` is **required** for creating issues) | |
| 88 | 92 | |
| 89 | -### Add Secrets to Continue CLI | |
| 93 | + </Tab> | |
| 94 | +<Tab title= "Configure API Access in Continue CLI"> | |
| 95 | + | |
| 96 | +<Tip> | |
| 97 | +See https://docs.continue.dev/hub/secrets/secret-types#secret-types for adding secrets | |
| 98 | +</Tip> | |
| 90 | 99 | |
| 91 | -To add environment variables to your Continue Hub account: | |
| 100 | +You only need to configure the PostHog MCP credential - it automatically handles project selection. To add environment variables to your Continue Hub account: | |
| 92 | 101 | |
| 93 | 102 | 1. Go to the [Continue Hub](https://hub.continue.dev) |
| 94 | 103 | 2. Sign in to your account |
| 95 | 104 | 3. Navigate to your user settings |
| 96 | 105 | 4. Look for the "Secrets" section |
| 97 | -5. Add your variables there (like POSTHOG_API_KEY, POSTHOG_PROJECT_ID, | |
| 98 | - POSTHOG_HOST,GITHUB_PAT, etc.) | |
| 106 | +5. Add your Personal API Key from PostHog (phx_...) as POSTHOG_AUTH_HEADER secret with format: Bearer YOUR_API_KEY | |
| 99 | 107 | |
| 100 | -These environment variables will then be securely stored and available for use in | |
| 101 | -your Continue workflows. | |
| 108 | +</Tab> | |
| 109 | +</Tabs> | |
| 102 | 110 | |
| 103 | 111 | ## PostHog GitHub Continuous AI Workflow Options |
| 104 | 112 | |
| @@ -107,7 +115,17 @@ | ||
| 107 | 115 | optimized prompts, rules, and the PostHog MCP for more consistent results. |
| 108 | 116 | </Card> |
| 109 | 117 | |
| 110 | -After completing **Step 1** below, you have two paths to get started: | |
| 118 | +<Info> | |
| 119 | + **How PostHog MCP Works**: | |
| 120 | + - Your API key is tied to your PostHog account and | |
| 121 | + organization | |
| 122 | + - It automatically uses your default project (no project ID | |
| 123 | + needed) | |
| 124 | + - If you have multiple projects, use `mcp__posthog__switch-project` to | |
| 125 | + change | |
| 126 | + - The MCP connects via `https://mcp.posthog.com/sse` using your account context. | |
| 127 | + | |
| 128 | +</Info> | |
| 111 | 129 | |
| 112 | 130 | <Tabs> |
| 113 | 131 | <Tab title="⚡ Quick Start (Recommended)"> |
| @@ -115,20 +133,16 @@ | ||
| 115 | 133 | |
| 116 | 134 | <Steps> |
| 117 | 135 | <Step title="Add the Pre-Built Agent"> |
| 118 | - Visit the [PostHog GitHub Continuous AI Agent](https://hub.continue.dev/continuedev/awesome-models-posthog-gh) on Continue Hub and click **"Install Agent"** | |
| 136 | + Visit the [PostHog GitHub Continuous AI Agent](https://hub.continue.dev/continuedev/awesome-models-posthog-gh) on Continue Hub and click **"Install Agent"** or run: | |
| 137 | + | |
| 138 | + ```bash | |
| 139 | + cn --config continuedev/awesome-models-posthog-gh | |
| 140 | + ``` | |
| 119 | 141 | |
| 120 | 142 | This agent includes: |
| 121 | - - **Optimized prompts** for PostHog analysis and GitHub issue creation | |
| 122 | - - **Built-in rules** for consistent formatting and error handling | |
| 123 | - - **PostHog MCP** for more reliable API interactions | |
| 124 | - </Step> | |
| 125 | - | |
| 126 | - <Step title="Verify Your Secrets"> | |
| 127 | - The agent uses these Hub resources automatically: | |
| 128 | - - **Environment Variables**: [bekahhw/env-vars](https://hub.continue.dev/bekahhw/env-vars) | |
| 129 | - - **Analysis Rules**: [bekah-hawrot-weigel/posthog-github-continuous-ai-rules](https://hub.continue.dev/bekah-hawrot-weigel/posthog-github-continuous-ai-rules) | |
| 130 | - - **Analysis Prompt**: [continuedev/posthog-analysis](https://hub.continue.dev/continuedev/posthog-analysis) | |
| 131 | - - **Issue Creation Prompt**: [continuedev/github-issues](https://hub.continue.dev/continuedev/github-issues) | |
| 143 | + - **Optimized prompts** for [PostHog analysis](https://hub.continue.dev/continuedev/posthog-analysis) and [GitHub issue creation](https://hub.continue.dev/continuedev/posthog-github-issues) | |
| 144 | + - **[Built-in rules](https://hub.continue.dev/bekah-hawrot-weigel/posthog-github-continuous-ai-rules)** for consistent formatting and error handling | |
| 145 | + - **[PostHog MCP](https://hub.continue.dev/posthog/posthog-mcp)** for more reliable API interactions | |
| 132 | 146 | </Step> |
| 133 | 147 | |
| 134 | 148 | <Step title="Run the Analysis"> |
| @@ -148,72 +162,41 @@ | ||
| 148 | 162 | </Tab> |
| 149 | 163 | |
| 150 | 164 | <Tab title="🛠️ Manual Setup"> |
| 151 | - **Perfect for:** Learning the process and customizing prompts. | |
| 152 | - | |
| 153 | - Now you'll use Continue CLI to fetch PostHog session data and analyze it for UX issues. Continue CLI handles all the API calls and analysis automatically. | |
| 154 | - | |
| 155 | -### Run the PostHog Analysis | |
| 156 | - | |
| 157 | -Use this prompt with Continue CLI to fetch and analyze your PostHog sessions: | |
| 158 | - | |
| 159 | -```bash | |
| 160 | -cn -p "I need you to help me analyze PostHog session recordings to identify UX issues. Please: | |
| 161 | - | |
| 162 | -1. First, fetch session recordings from PostHog using these details: | |
| 163 | - - Use the POSTHOG_API_KEY, POSTHOG_PROJECT_ID, and POSTHOG_HOST from my secrets | |
| 164 | - - API endpoint: {POSTHOG_HOST}/api/projects/{POSTHOG_PROJECT_ID}/session_recordings/?limit=20 | |
| 165 | - - Include Authorization header: 'Bearer {POSTHOG_API_KEY}' | |
| 166 | - | |
| 167 | -2. Filter the sessions to find problematic ones with either: | |
| 168 | - - console_error_count > 0 (JavaScript errors) | |
| 169 | - - recording_duration > 300 (sessions longer than 5 minutes) | |
| 170 | - | |
| 171 | -3. Analyze the filtered sessions and create exactly 3 GitHub issues for the most critical UX problems. | |
| 172 | - | |
| 173 | -4. Format each issue like this: | |
| 174 | -### 1. **Issue Title Here** | |
| 175 | -**Problem**: One sentence describing the user problem | |
| 176 | -**Technical Causes**: Brief technical explanation | |
| 177 | -**Affected Pages**: List the URLs | |
| 178 | -**Recommended Fix**: | |
| 179 | -- Specific action item 1 | |
| 180 | -- Specific action item 2 | |
| 181 | -**Priority**: **HIGH** or **MEDIUM** or **LOW** | |
| 182 | -**Impact**: Quantify the impact (e.g., 'Affects 80% of sessions') | |
| 183 | - | |
| 184 | -Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data." | |
| 185 | -``` | |
| 186 | - | |
| 187 | -### Create GitHub Issues from PostHog Analysis | |
| 188 | - | |
| 189 | -Now use Continue CLI to create GitHub issues from your analysis results: | |
| 190 | - | |
| 191 | -```bash | |
| 192 | -cn -p "I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API. | |
| 193 | - | |
| 194 | -Use these details from my secrets: | |
| 195 | -- GITHUB_PAT: My GitHub Personal Access Token | |
| 196 | -- Repository: Extract from git remote or ask me to specify | |
| 197 | - | |
| 198 | -For each issue in my analysis: | |
| 199 | -1. Parse the issue title, body content, and priority level | |
| 200 | -2. Create a GitHub issue via API POST to: https://api.github.com/repos/{owner}/{repo}/issues | |
| 201 | -3. Use these headers: | |
| 202 | - - Authorization: token {GITHUB_PAT} | |
| 203 | - - Accept: application/vnd.github.v3+json | |
| 204 | - - Content-Type: application/json | |
| 205 | -4. Set labels based on priority: | |
| 206 | - - HIGH: [\"bug\", \"high-priority\", \"user-experience\", \"automated\"] | |
| 207 | - - MEDIUM: [\"enhancement\", \"medium-priority\", \"user-experience\", \"automated\"] | |
| 208 | - - LOW: [\"low-priority\", \"user-experience\", \"automated\"] | |
| 209 | -5. Format the issue title as: \"🔍 UX Issue: {original title}\" | |
| 210 | - | |
| 211 | -Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs. | |
| 212 | -" | |
| 213 | -``` | |
| 165 | + <Steps> | |
| 166 | + <Step title="Add PostHog MCP to Continue CLI"> | |
| 167 | + First, install the [PostHog MCP](https://hub.continue.dev/posthog/posthog-mcp) or run: | |
| 168 | + ```bash | |
| 169 | + npx -y mcp-remote@latest https://mcp.posthog.com/sse --header Authorization:${{ secrets.continuedev/awesome-models-posthog-gh/posthog/posthog-mcp/POSTHOG_AUTH_HEADER }} | |
| 170 | + ``` | |
| 171 | + </Step> | |
| 172 | + <Step title="Add PostHog + GitHub Analysis Rules"> | |
| 173 | + In the Continue Hub, add the [PostHog GitHub Continuous AI Rules](https://hub.continue.dev/bekah-hawrot-weigel/posthog-github-continuous-ai-rules) to your account for better formatting and error handling. | |
| 174 | + </Step> | |
| 175 | + <Step title="Create Your Custom Prompts"> | |
| 176 | + Use this prompt with Continue CLI to analyze PostHog data and create GitHub issues: | |
| 177 | + | |
| 178 | + ```bash | |
| 179 | + | |
| 180 | + # In cn TUI mode: | |
| 181 | + "Create GitHub issues from the PostHog analysis using gh CLI: | |
| 182 | + - For each issue, run: gh issue create --title '🔍 UX Issue: [title]' --body '[details]' | |
| 183 | + - Add labels: --label 'bug,user-experience,automated' | |
| 184 | + - Set priority labels (high/medium/low) | |
| 185 | + - Include session data and technical details in the body | |
| 186 | + Execute the commands and confirm each issue was created with URL." | |
| 187 | + ``` | |
| 188 | + </Step> | |
| 189 | +</Steps> | |
| 214 | 190 | |
| 215 | 191 | </Tab> |
| 216 | 192 | </Tabs> |
| 193 | +<Info> | |
| 194 | + | |
| 195 | + **Why GitHub CLI over GitHub MCP**: While GitHub MCP is available, it can be | |
| 196 | + token-expensive to run. The `gh` CLI is more efficient, requires no API tokens | |
| 197 | + (authenticated via `gh auth login`), and provides a cleaner command-line | |
| 198 | + experience. GitHub MCP remains an option if you prefer full MCP integration. | |
| 199 | +</Info> | |
| 217 | 200 | |
| 218 | 201 | <Accordion title="Agent Requirements"> |
| 219 | 202 | To use the pre-built agent, you need either: |
| @@ -492,16 +475,17 @@ | ||
| 492 | 475 | |
| 493 | 476 | <CardGroup cols={2}> |
| 494 | 477 | <Card title="Performance Analysis" icon="chart-line"> |
| 495 | - "Analyze PostHog performance metrics alongside session recordings to | |
| 496 | - identify slow page loads affecting user experience" | |
| 478 | + "Analyze [PostHog performance | |
| 479 | + metrics](https://posthog.com/docs/web-analytics) alongside session | |
| 480 | + recordings to identify slow page loads affecting user experience" | |
| 497 | 481 | </Card> |
| 498 | 482 | <Card title="Error Correlation" icon="bug"> |
| 499 | 483 | "Cross-reference JavaScript console errors with user actions to identify the |
| 500 | 484 | root cause of UX issues" |
| 501 | 485 | </Card> |
| 502 | 486 | <Card title="Feature Flag Analysis" icon="flag"> |
| 503 | - "Analyze how PostHog feature flags impact user behavior in session | |
| 504 | - recordings" | |
| 487 | + "Analyze how [PostHog feature flags](https://posthog.com/docs/feature-flags) | |
| 488 | + impact user behavior in session recordings" | |
| 505 | 489 | </Card> |
| 506 | 490 | <Card title="Custom Slack Alerts" icon="slack"> |
| 507 | 491 | "Create Slack alerts when critical UX issues are detected in PostHog |
| @@ -511,7 +495,19 @@ | ||
| 511 | 495 | |
| 512 | 496 | ## Next Steps |
| 513 | 497 | |
| 514 | -1. **Monitor your first issues** - Review the GitHub issues created and implement fixes | |
| 515 | -2. **Measure impact** - Track how resolved issues improve PostHog metrics | |
| 516 | -3. **Refine prompts** - Adjust the Continue CLI prompts based on issue quality | |
| 517 | -4. **Scale the system** - Add more data sources or create specialized analysis workflows | |
| 498 | +- Consider [GitHub MCP](https://hub.continue.dev/github/github-mcp) as an alternative (note: can be token-expensive) | |
| 499 | +- Configure [Slack MCP](https://hub.continue.dev/slack/slack-mcp) for alerts | |
| 500 | +- Set up [PostHog performance monitoring](https://posthog.com/docs/web-analytics) | |
| 501 | +- Join the [Continue Discord](https://discord.gg/continue) for support | |
| 502 | + | |
| 503 | +## Resources | |
| 504 | + | |
| 505 | +- [PostHog API Documentation](https://posthog.com/docs/api) | |
| 506 | +- [PostHog MCP Documentation](https://posthog.com/docs/model-context-protocol) | |
| 507 | +- [PostHog Session Replay](https://posthog.com/docs/session-replay) | |
| 508 | +- [PostHog Feature Flags](https://posthog.com/docs/feature-flags) | |
| 509 | +- [PostHog Error Tracking](https://posthog.com/docs/error-tracking) | |
| 510 | +- [GitHub CLI Documentation](https://cli.github.com/) | |
| 511 | +- [GitHub MCP on Continue Hub](https://hub.continue.dev/github/github-mcp) (alternative option) | |
| 512 | +- [Continue CLI Guide](https://docs.continue.dev/guides/cli) | |
| 513 | +- [Continuous AI Best Practices](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/) |
| @@ -20,9 +20,74 @@ | ||
| 20 | 20 | - [Snyk account](https://snyk.io/) (free tier works) |
| 21 | 21 | - A local project to scan for vulnerabilities |
| 22 | 22 | |
| 23 | +For all options, first: | |
| 23 | 24 | <Steps> |
| 25 | +<Step title="Install Continue CLI"> | |
| 26 | + ```bash | |
| 27 | + npm i -g @continuedev/cli | |
| 28 | + ``` | |
| 29 | + </Step> | |
| 30 | + | |
| 31 | +<Step title="Add Your Project to Snyk"> | |
| 32 | + | |
| 33 | + 1. Sign up for a Snyk account at [snyk.io](https://snyk.io/) | |
| 34 | + 2. Create a new project in Snyk by importing your code repository (Git | |
| 35 | + provider or manual upload) | |
| 36 | + </Step> | |
| 37 | +</Steps> | |
| 38 | + <Warning> | |
| 39 | + To use agents in headless mode, you need a [Continue API key](https://hub.continue.dev/settings/api-keys). | |
| 40 | + </Warning> | |
| 41 | + | |
| 42 | +## Snyk Continuous AI Workflow Options | |
| 43 | + | |
| 44 | +<Card title="🚀 Fastest Path to Success" icon="zap"> | |
| 45 | + Skip the manual setup and use our pre-built Snyk Continuous AI agent that includes | |
| 46 | + the Snyk MCP and optimized security scanning workflows for more consistent results. | |
| 47 | +</Card> | |
| 48 | + | |
| 49 | + | |
| 50 | +After ensuring you meet the **Prerequisites** above, you have two paths to get started: | |
| 51 | + | |
| 52 | +<Tabs> | |
| 53 | + <Tab title="⚡ Quick Start (Recommended)"> | |
| 54 | + <Steps> | |
| 55 | + <Step title="Load the Pre-Built Agent"> | |
| 56 | + Navigate to your project directory and run: | |
| 57 | + ```bash | |
| 58 | + cn --config continuedev/snyk-continuous-ai | |
| 59 | + ``` | |
| 60 | + | |
| 61 | + This agent includes: | |
| 62 | + - **Snyk MCP** pre-configured and ready to use | |
| 63 | + - **Security-focused rules** for best practices | |
| 64 | + </Step> | |
| 65 | + | |
| 66 | + <Step title="Run Your First Security Scan"> | |
| 67 | + Start with a comprehensive security scan: | |
| 68 | + ```bash | |
| 69 | + # TUI mode | |
| 70 | + cn -p "Run a complete security scan on this project including code vulnerabilities, dependencies, and any IaC files. Summarize findings by severity." | |
| 71 | + ``` | |
| 72 | + | |
| 73 | + That's it! The agent handles everything automatically. | |
| 74 | + </Step> | |
| 75 | + </Steps> | |
| 76 | + | |
| 77 | + <Info> | |
| 78 | + **Why Use the Agent?** The pre-built agent provides consistent security scanning workflows and handles MCP configuration automatically, making it easier to get started with AI-powered security scanning. | |
| 79 | + </Info> | |
| 80 | + | |
| 81 | + </Tab> | |
| 82 | + | |
| 83 | + <Tab title="🛠️ Manual Setup"> | |
| 84 | +<Steps> | |
| 85 | + <Step title="Create a New Agent via the Continue Hub"> | |
| 86 | + Go to the [Continue Hub](https://hub.continue.dev) and [create a new agent](https://hub.continue.dev/new?type=agent). | |
| 87 | + </Step> | |
| 88 | + | |
| 24 | 89 | <Step title="Connect Snyk MCP via Continue Hub"> |
| 25 | - Visit the [Snyk MCP on Continue Hub](https://hub.continue.dev/snyk/snyk-mcp) and click **Install** to add it to your Continue account. | |
| 90 | + Visit the [Snyk MCP on Continue Hub](https://hub.continue.dev/snyk/snyk-mcp) and click **Install** to add it to the agent you created in the step above. | |
| 26 | 91 | |
| 27 | 92 | This will add Snyk MCP to your agent's available tools. The Hub listing automatically configures the MCP command: |
| 28 | 93 | ```bash |
| @@ -31,7 +96,7 @@ | ||
| 31 | 96 | |
| 32 | 97 | <Tip> |
| 33 | 98 | **Alternative installation methods:** |
| 34 | - 1. **Quick CLI install**: `cn -p --mcp snyk/snyk-mcp` | |
| 99 | + 1. **Quick CLI install**: `cn --mcp snyk/snyk-mcp` | |
| 35 | 100 | 2. **Manual configuration**: Add the MCP to your `~/.continue/config.json` under the `mcpServers` section |
| 36 | 101 | |
| 37 | 102 | Once installed, Snyk MCP tools become available to your Continue agent for all prompts. |
| @@ -59,35 +124,42 @@ | ||
| 59 | 124 | |
| 60 | 125 | </Step> |
| 61 | 126 | |
| 62 | - <Step title="Authenticate with Snyk"> | |
| 63 | - Use this prompt with your Continue agent to set up authentication: | |
| 64 | - | |
| 65 | - ``` | |
| 66 | - Check Snyk auth status. If not authenticated, authenticate me and confirm my org context. | |
| 67 | - ``` | |
| 68 | - | |
| 69 | - Or use the Continue CLI: | |
| 127 | + <Step title="Run Your First Security Scan"> | |
| 128 | + Start with a comprehensive security scan: | |
| 70 | 129 | ```bash |
| 71 | - cn -p "Check Snyk auth status. If not authenticated, authenticate me and confirm my org context." | |
| 130 | + # TUI mode | |
| 131 | + cn "Run a complete security scan on this project including code vulnerabilities, dependencies, and any IaC files. Summarize findings by severity." | |
| 72 | 132 | ``` |
| 73 | - | |
| 74 | - <Tip> | |
| 75 | - A browser window will open for Snyk login. After authenticating, approve | |
| 76 | - the request to trust your project folder when prompted. | |
| 77 | - </Tip> | |
| 78 | - | |
| 79 | 133 | </Step> |
| 80 | 134 | </Steps> |
| 81 | 135 | |
| 136 | + </Tab> | |
| 137 | +</Tabs> | |
| 138 | + | |
| 139 | +<Accordion title="Agent Requirements"> | |
| 140 | + To use the pre-built agent, you need either: | |
| 141 | + - **Continue CLI Pro Plan** with the models add-on, OR | |
| 142 | + - **Your own API keys** added to Continue Hub secrets (same as manual setup) | |
| 143 | + | |
| 144 | + The agent will automatically detect and use your configuration along with the pre-configured Snyk MCP for security scanning operations. | |
| 145 | + | |
| 146 | +</Accordion> | |
| 147 | + | |
| 148 | +--- | |
| 149 | + | |
| 82 | 150 | ## Security Scanning Recipes |
| 83 | 151 | |
| 84 | 152 | Now you can use natural language prompts to run comprehensive security scans. The Continue agent automatically calls the appropriate Snyk MCP tools. |
| 85 | 153 | |
| 154 | +<Info> | |
| 155 | +You can add prompts to your agent's configuration for easy access in future sessions. Go to your agent in the [Continue Hub](https://hub.continue.dev), click **Edit**, and add prompts under the **Prompts** section. | |
| 156 | +</Info> | |
| 157 | + | |
| 86 | 158 | <Info> |
| 87 | 159 | **Where to run these workflows:** |
| 88 | 160 | - **IDE Extensions**: Use Continue in VS Code, JetBrains, or other supported IDEs |
| 89 | 161 | - **Terminal (TUI mode)**: Run `cn` to enter interactive mode, then type your prompts |
| 90 | - - **CLI (headless mode)**: Use `cn -p "your prompt"` for one-off commands | |
| 162 | + - **CLI (headless mode)**: Use `cn -p "your prompt"` for headless commands | |
| 91 | 163 | |
| 92 | 164 | **Test in Plan Mode First**: Before running security scans that might make |
| 93 | 165 | changes, test your prompts in plan mode (see the [Plan Mode |
| @@ -101,14 +173,14 @@ | ||
| 101 | 173 | <Card title="Static Application Security Testing" icon="code"> |
| 102 | 174 | Scan your source code for security vulnerabilities and code quality issues. |
| 103 | 175 | |
| 104 | -**Example prompt:** | |
| 176 | +**TUI Mode Prompt:** | |
| 105 | 177 | ``` |
| 106 | 178 | Run a Snyk Code scan on this repo with severity threshold medium. |
| 107 | 179 | Summarize issues with file:line. Propose minimal diffs for the top 3 |
| 108 | 180 | and rerun to verify. |
| 109 | 181 | ``` |
| 110 | 182 | |
| 111 | -**Using Continue CLI:** | |
| 183 | +**Headless Mode Prompt:** | |
| 112 | 184 | ```bash |
| 113 | 185 | cn -p "Run a Snyk Code scan on this repo with severity threshold medium. Summarize issues with file:line. Propose minimal diffs for the top 3 and rerun to verify." |
| 114 | 186 | ``` |
| @@ -120,14 +192,14 @@ | ||
| 120 | 192 | <Card title="Software Composition Analysis" icon="cube"> |
| 121 | 193 | Check open source dependencies for known vulnerabilities. |
| 122 | 194 | |
| 123 | -**Example prompt:** | |
| 195 | +**TUI Mode Prompt:** | |
| 124 | 196 | ``` |
| 125 | 197 | Run Snyk Open Source on this repo (include dev deps). |
| 126 | 198 | Summarize vulnerable paths and propose a minimal-risk upgrade plan. |
| 127 | 199 | Re-test after the plan (dry run). |
| 128 | 200 | ``` |
| 129 | 201 | |
| 130 | -**Using Continue CLI:** | |
| 202 | +**Headless Mode Prompt:** | |
| 131 | 203 | ```bash |
| 132 | 204 | cn -p "Run Snyk Open Source on this repo (include dev deps). Summarize vulnerable paths and propose a minimal-risk upgrade plan. Re-test after the plan (dry run)." |
| 133 | 205 | ``` |
| @@ -139,13 +211,13 @@ | ||
| 139 | 211 | <Card title="IaC Security" icon="cloud"> |
| 140 | 212 | Scan Terraform, CloudFormation, and Kubernetes configs for misconfigurations. |
| 141 | 213 | |
| 142 | -**Example prompt:** | |
| 214 | +**TUI Mode Prompt:** | |
| 143 | 215 | ``` |
| 144 | 216 | Scan ./infra with Snyk IaC. Report high/critical misconfigs |
| 145 | 217 | with exact files/lines. Provide code changes and re-scan to confirm. |
| 146 | 218 | ``` |
| 147 | 219 | |
| 148 | -**Using Continue CLI:** | |
| 220 | +**Headless Mode Prompt:** | |
| 149 | 221 | ```bash |
| 150 | 222 | cn -p "Scan ./infra with Snyk IaC. Report high/critical misconfigs with exact files/lines. Provide code changes and re-scan to confirm." |
| 151 | 223 | ``` |
| @@ -157,14 +229,14 @@ | ||
| 157 | 229 | <Card title="Container Security" icon="docker"> |
| 158 | 230 | Analyze Docker images for vulnerabilities in base images and packages. |
| 159 | 231 | |
| 160 | -**Example prompt:** | |
| 232 | +**TUI Mode Prompt:** | |
| 161 | 233 | ``` |
| 162 | 234 | Scan image my-api:latest. Exclude base image vulns. |
| 163 | 235 | Print dependency tree. Recommend a safer base image or upgrades. |
| 164 | 236 | Re-test after the change (dry run). |
| 165 | 237 | ``` |
| 166 | 238 | |
| 167 | -**Using Continue CLI:** | |
| 239 | +**Headless Mode Prompt:** | |
| 168 | 240 | ```bash |
| 169 | 241 | cn -p "Scan image my-api:latest. Exclude base image vulns. Print dependency tree. Recommend a safer base image or upgrades. Re-test after the change (dry run)." |
| 170 | 242 | ``` |
| @@ -176,13 +248,13 @@ | ||
| 176 | 248 | <Card title="Changed Files Only" icon="code-branch"> |
| 177 | 249 | Focus scanning on modified files to catch issues before merging. |
| 178 | 250 | |
| 179 | -**Example prompt:** | |
| 251 | +**TUI Mode Prompt:** | |
| 180 | 252 | ``` |
| 181 | 253 | Scan only files changed since origin/main with Snyk Code. |
| 182 | 254 | Block if new high issues would be introduced. Show deltas. |
| 183 | 255 | ``` |
| 184 | 256 | |
| 185 | -**Using Continue CLI:** | |
| 257 | +**Headless Mode Prompt:** | |
| 186 | 258 | ```bash |
| 187 | 259 | cn -p "Scan only files changed since origin/main with Snyk Code. Block if new high issues would be introduced. Show deltas." |
| 188 | 260 | ``` |
| @@ -194,12 +266,12 @@ | ||
| 194 | 266 | <Card title="Snyk Learn Integration" icon="graduation-cap"> |
| 195 | 267 | Access security education resources based on identified vulnerabilities ([CWE](https://cwe.mitre.org/)). |
| 196 | 268 | |
| 197 | -**Example prompt:** | |
| 269 | +**TUI Mode Prompt:** | |
| 198 | 270 | ``` |
| 199 | 271 | Open Snyk Learn lessons related to the top CWE(s) from this scan. |
| 200 | 272 | ``` |
| 201 | 273 | |
| 202 | -**Using Continue CLI:** | |
| 274 | +**Headless Mode Prompt:** | |
| 203 | 275 | ```bash |
| 204 | 276 | cn -p "Open Snyk Learn lessons related to the top CWE(s) from this scan." |
| 205 | 277 | ``` |
| @@ -208,7 +280,7 @@ | ||
| 208 | 280 | |
| 209 | 281 | ## Continuous Security with GitHub Actions |
| 210 | 282 | |
| 211 | -This example demonstrates a **Continuous AI workflow** where security scanning runs automatically in your CI/CD pipeline using Continue CLI in headless mode (`cn -p`) with Snyk MCP. | |
| 283 | +This example demonstrates a **Continuous AI workflow** where security scanning runs automatically in your CI/CD pipeline Headless Mode Prompt in headless mode (`cn -p`) with Snyk MCP. | |
| 212 | 284 | |
| 213 | 285 | ### Add GitHub Secrets |
| 214 | 286 | |
| @@ -249,8 +321,10 @@ | ||
| 249 | 321 | echo "✅ Continue CLI installed" |
| 250 | 322 | |
| 251 | 323 | - name: Authenticate Continue CLI |
| 324 | + env: | |
| 325 | + CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} | |
| 252 | 326 | run: | |
| 253 | - cn auth login --api-key "${{ secrets.CONTINUE_API_KEY }}" | |
| 327 | + cn auth login --api-key "$CONTINUE_API_KEY" | |
| 254 | 328 | echo "✅ Continue CLI authenticated" |
| 255 | 329 | |
| 256 | 330 | - name: Run Security Scans |
| @@ -8,7 +8,8 @@ | ||
| 8 | 8 | |
| 9 | 9 | To create an agent from scratch, select “New agent” in the top bar. |
| 10 | 10 | |
| 11 | - | |
| 11 | + | |
| 12 | + | |
| 12 | 13 | |
| 13 | 14 | Choose a name, slug, description, and icon for your agent. |
| 14 | 15 | |
| @@ -24,7 +25,7 @@ | ||
| 24 | 25 | |
| 25 | 26 | By clicking the “remix” button, you’ll be taken to the “Create a remix” page. |
| 26 | 27 | |
| 27 | - | |
| 28 | + | |
| 28 | 29 | |
| 29 | 30 | Once here, you’ll be able to |
| 30 | 31 |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
Binary content is not shown. View the file.
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
Binary content is not shown. View the file.
Binary content is not shown. View the file.
| @@ -1,55 +1,148 @@ | ||
| 1 | 1 | --- |
| 2 | -title: "Introduction" | |
| 2 | +title: "Welcome to Continue" | |
| 3 | 3 | icon: book-open |
| 4 | -description: "Continue is an open source platform for building AI-powered coding assistants with customizable components for chat, autocomplete, edit, and agent workflows in VS Code and JetBrains IDEs" | |
| 4 | +description: "Practice Continuous AI with an open-source CLI, open-source IDE extensions, and a Hub for custom AI coding agents" | |
| 5 | 5 | --- |
| 6 | 6 | |
| 7 | 7 | <Frame> |
| 8 | 8 | <img src="/images/intro-0c302b9c15b890c251b1ad04586c880f.png" /> |
| 9 | 9 | </Frame> |
| 10 | 10 | |
| 11 | -**Continue enables developers to ship faster with Continuous AI.** | |
| 11 | +<Note> | |
| 12 | + **Build faster with AI across your IDE, terminal, and CI/CD pipelines with | |
| 13 | + Continue.** | |
| 14 | +</Note> | |
| 12 | 15 | |
| 13 | -**You can use Continue to build and run custom agents across your IDE, terminal, and CI.** | |
| 16 | +## Continue CLI | |
| 14 | 17 | |
| 15 | -1. Get started with Continue in [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) or [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) extensions | |
| 18 | +<Info>Terminal-native AI coding assistance with TUI and headless modes.</Info> | |
| 16 | 19 | |
| 17 | -2. Try out [Continue CLI (cn)](https://docs.continue.dev/guides/cli) and give us feedback | |
| 20 | +<CodeGroup> | |
| 18 | 21 | |
| 19 | -3. Discover models, rules, and MCP tools on [Continue Hub](https://hub.continue.dev/) | |
| 22 | + ```bash npm | |
| 23 | + npm install -g @continuedev/cli | |
| 24 | + ``` | |
| 25 | + | |
| 26 | + ```bash yarn | |
| 27 | + yarn global add @continuedev/cli | |
| 28 | + ``` | |
| 29 | + | |
| 30 | + ```bash pnpm | |
| 31 | + pnpm add -g @continuedev/cli | |
| 32 | + ``` | |
| 33 | + | |
| 34 | +</CodeGroup> | |
| 20 | 35 | |
| 21 | 36 | <CardGroup cols={2}> |
| 22 | 37 | <Card |
| 23 | - title="Agent" | |
| 24 | - icon="robot" | |
| 25 | - href="/features/agent/quick-start" | |
| 26 | - horizontal | |
| 38 | + title="TUI Mode" | |
| 39 | + icon="terminal" | |
| 40 | + href="/cli/overview#tui-mode%3A-interactive-development" | |
| 27 | 41 | > |
| 28 | - to work on development tasks together with AI | |
| 42 | + Interactive terminal interface for development workflows | |
| 43 | + <br /> | |
| 44 | + <sub>• Automate builds & refactoring</sub> | |
| 45 | + <br /> | |
| 46 | + <sub>• Pre-commit hooks & scripted fixes</sub> | |
| 47 | + <br /> | |
| 48 | + <sub>• Terminal-first development</sub> | |
| 29 | 49 | </Card> |
| 30 | 50 | <Card |
| 31 | - title="Chat" | |
| 32 | - icon="messages" | |
| 33 | - href="/features/chat/quick-start" | |
| 34 | - horizontal | |
| 51 | + title="Headless Mode" | |
| 52 | + icon="server" | |
| 53 | + href="/cli/overview#headless-mode%3A-production-automation" | |
| 54 | + > | |
| 55 | + Automated AI coding for CI/CD and server environments | |
| 56 | + <br /> | |
| 57 | + <sub>• Run in CI/CD pipelines</sub> | |
| 58 | + <br /> | |
| 59 | + <sub>• Batch processing & bulk operations</sub> | |
| 60 | + <br /> | |
| 61 | + <sub>• Server & container deployments</sub> | |
| 62 | + </Card> | |
| 63 | +</CardGroup> | |
| 64 | + | |
| 65 | +## IDE Extensions | |
| 66 | + | |
| 67 | +<Info> | |
| 68 | + **Complement your CLI workflow** - Rich editor integrations for interactive | |
| 69 | + development. | |
| 70 | +</Info> | |
| 71 | + | |
| 72 | +<CardGroup cols={2}> | |
| 73 | + <Card | |
| 74 | + title="VS Code" | |
| 75 | + icon="code" | |
| 76 | + href="https://marketplace.visualstudio.com/items?itemName=Continue.continue" | |
| 35 | 77 | > |
| 36 | - to ask general questions and clarify code sections | |
| 78 | + Install from VS Code Marketplace | |
| 79 | + <br /> | |
| 80 | + <sub>Real-time coding assistance and refactoring</sub> | |
| 37 | 81 | </Card> |
| 38 | 82 | <Card |
| 39 | - title="Edit" | |
| 40 | - icon="pen-to-square" | |
| 41 | - href="/features/edit/quick-start" | |
| 42 | - horizontal | |
| 83 | + title="JetBrains" | |
| 84 | + icon="jet-fighter" | |
| 85 | + href="https://plugins.jetbrains.com/plugin/22707-continue-extension" | |
| 43 | 86 | > |
| 44 | - to modify a code section without leaving your current file | |
| 87 | + Install from JetBrains Plugin Repository | |
| 88 | + <br /> | |
| 89 | + <sub>Autocomplete and multi-file edits</sub> | |
| 90 | + </Card> | |
| 91 | +</CardGroup> | |
| 92 | + | |
| 93 | +## Core Features | |
| 94 | + | |
| 95 | +<CardGroup cols={2}> | |
| 96 | + <Card title="Agent" icon="robot" href="/features/agent/quick-start"> | |
| 97 | + Multi-step workflows and complex task automation | |
| 98 | + </Card> | |
| 99 | + <Card title="Chat" icon="messages" href="/features/chat/quick-start"> | |
| 100 | + Ask questions and explore your codebase | |
| 101 | + </Card> | |
| 102 | + <Card title="Edit" icon="pen-to-square" href="/features/edit/quick-start"> | |
| 103 | + In-place code editing without breaking flow | |
| 45 | 104 | </Card> |
| 46 | 105 | <Card |
| 47 | 106 | title="Autocomplete" |
| 48 | 107 | icon="sparkles" |
| 49 | 108 | href="/features/autocomplete/quick-start" |
| 50 | - horizontal | |
| 51 | 109 | > |
| 52 | - to receive inline code suggestions as you type | |
| 110 | + Inline AI suggestions as you type | |
| 111 | + </Card> | |
| 112 | +</CardGroup> | |
| 113 | + | |
| 114 | +## Configuration | |
| 115 | + | |
| 116 | +<CardGroup cols={3}> | |
| 117 | + <Card title="Models" icon="brain" href="/customization/models"> | |
| 118 | + Connect your preferred AI models | |
| 119 | + </Card> | |
| 120 | + <Card title="Rules" icon="shield" href="/customization/rules"> | |
| 121 | + Configure AI behavior and constraints | |
| 122 | + </Card> | |
| 123 | + <Card title="MCPs" icon="wrench" href="/customization/mcp-tools"> | |
| 124 | + Extend functionality with MCP tools | |
| 53 | 125 | </Card> |
| 126 | +</CardGroup> | |
| 54 | 127 | |
| 128 | +## Resources | |
| 129 | + | |
| 130 | +<CardGroup cols={3}> | |
| 131 | + <Card title="Continue Hub" icon="globe" href="https://hub.continue.dev/"> | |
| 132 | + Community models, rules, and tools | |
| 133 | + </Card> | |
| 134 | + <Card | |
| 135 | + title="GitHub Discussions" | |
| 136 | + icon="comments" | |
| 137 | + href="https://github.com/continuedev/continue/discussions" | |
| 138 | + > | |
| 139 | + Get help from the community | |
| 140 | + </Card> | |
| 141 | + <Card | |
| 142 | + title="CLI Examples" | |
| 143 | + icon="code-branch" | |
| 144 | + href="/guides/overview#continuous-ai" | |
| 145 | + > | |
| 146 | + TUI and headless workflow examples | |
| 147 | + </Card> | |
| 55 | 148 | </CardGroup> |
| @@ -1,136 +1,23 @@ | ||
| 1 | 1 | --- |
| 2 | 2 | title: "config.yaml Reference" |
| 3 | -description: "Comprehensive guide to the config.yaml format used by Continue.dev for building custom coding agents. Learn how to define models, context providers, rules, prompts, and more using reusable blocks and YAML configuration." | |
| 3 | +description: "Comprehensive guide to the config.yaml format used by Continue.dev for building custom coding agents. Learn how to define models, context providers, rules, prompts, and more using YAML configuration." | |
| 4 | 4 | --- |
| 5 | 5 | |
| 6 | 6 | ## Introduction |
| 7 | 7 | |
| 8 | -Continue hub agents are defined using the `config.yaml` specification. Agents can be loaded from [the Hub](https://hub.continue.dev/explore/agents) or locally | |
| 8 | +Continue Agents are defined using the `config.yaml` specification. | |
| 9 | 9 | |
| 10 | -- [Continue Hub](https://hub.continue.dev/explore/agents) - YAML is stored on the hub and automatically synced to the extension | |
| 10 | +**Agents** are composed of models, rules, and tools (MCP servers). | |
| 11 | 11 | |
| 12 | -- Locally | |
| 13 | - - in your global `.continue` folder (`~/.continue` on Mac, `%USERPROFILE%\.continue`) within `.continue/agents`. The name of the file will be used as the display name of the agent, e.g. `My Agent.yaml` | |
| 14 | - - in your workspace in a `/.continue/agents` folder, with the same naming convention | |
| 12 | +<Columns cols={2}> | |
| 13 | +<Card title="Configuring Models, Rules, and Tools" icon="cube" href="/guides/configuring-models-rules-tools"> | |
| 14 | +Learn how to work with Continue's configuration system, including using hub models, rules, and tools, creating local configurations, and organizing your setup. | |
| 15 | +</Card> | |
| 15 | 16 | |
| 16 | -<Info> | |
| 17 | - Config YAML replaces `config.json`, which is deprecated. View the **[Migration | |
| 18 | - Guide](/reference/yaml-migration)**. | |
| 19 | -</Info> | |
| 20 | - | |
| 21 | -An agent is made up of: | |
| 22 | - | |
| 23 | -1. **Top level properties**, which specify the `name`, `version`, and `config.yaml` `schema` for the agent | |
| 24 | -2. **Block lists**, which are composable arrays of coding agent building blocks available to the agent, such as models, docs, and context providers. | |
| 25 | - | |
| 26 | -A block is a single standalone building block of a coding agents, e.g., one model or one documentation source. In `config.yaml` syntax, a block consists of the same top-level properties as agents (`name`, `version`, and `schema`), but only has **ONE** item under whichever block type it is. | |
| 27 | - | |
| 28 | -Examples of blocks and agents can be found on the [Continue Hub](https://hub.continue.dev). | |
| 29 | - | |
| 30 | -Agents can either explicitly define blocks - see [Properties](#properties) below - or import and configure existing hub blocks. | |
| 31 | - | |
| 32 | -### Using Blocks | |
| 33 | - | |
| 34 | -Hub blocks and agents are identified with a slug in the format `owner-slug/block-or-agent-slug`, where an owner can be a user or organization (For example, if you want to use the [OpenAI 4o Model block](https://hub.continue.dev/openai/gpt-4o), your slug would be `openai/gpt-4o`). These blocks are pulled from [https://hub.continue.dev](https://hub.continue.dev). | |
| 35 | - | |
| 36 | -Blocks can be imported into an agent by adding a `uses` clause under the block type. This can be alongside other `uses` clauses or explicit blocks of that type. | |
| 37 | - | |
| 38 | -For example, the following agent imports an Anthropic model and defines an Ollama DeepSeek one. | |
| 39 | - | |
| 40 | -Agent models section | |
| 41 | - | |
| 42 | -```yaml | |
| 43 | -name: Team Agent | |
| 44 | -version: 1.0.0 | |
| 45 | -schema: v1 | |
| 46 | - | |
| 47 | -models: | |
| 48 | - - uses: anthropic/claude-3.5-sonnet # an imported model block | |
| 49 | - - model: deepseek-reasoner # an explicit model block | |
| 50 | - provider: ollama | |
| 51 | -``` | |
| 52 | - | |
| 53 | -### Local Blocks | |
| 54 | - | |
| 55 | -It is also possible to define blocks locally in a `.continue` folder. This folder can be located at either the root of your workspace (these will automatically be applied to all agents when you are in that workspace) or in your home directory at `~/.continue` (these will automatically be applied globally). | |
| 56 | - | |
| 57 | -Place your YAML files in the following folders: | |
| 58 | - | |
| 59 | -Agents: | |
| 60 | - | |
| 61 | -- `.continue/agents` - for agents | |
| 62 | - | |
| 63 | -Blocks: | |
| 64 | - | |
| 65 | -- `.continue/rules` - for rules | |
| 66 | -- `.continue/models` - for models | |
| 67 | -- `.continue/prompts` - for prompts | |
| 68 | -- `.continue/context` - for context providers | |
| 69 | -- `.continue/docs` - for docs | |
| 70 | -- `.continue/data` - for data | |
| 71 | -- `.continue/mcpServers` - for MCP Servers | |
| 72 | - | |
| 73 | -You can find many examples of each of these block types on the [Continue Explore Page](https://hub.continue.dev/explore/models) | |
| 74 | - | |
| 75 | -<Info> | |
| 76 | -Local blocks utilizing mustache notation for secrets (`${{ secrets.SECRET_NAME }}`) can read secret values: | |
| 77 | - | |
| 78 | -- globally, from a `.env` located in the global `.continue` folder (`~/.continue/.env`) | |
| 79 | -- per-workspace, from a `.env` file located at the root of the current workspace. | |
| 80 | - | |
| 81 | -</Info> | |
| 82 | - | |
| 83 | -### Inputs | |
| 84 | - | |
| 85 | -Blocks can be passed user inputs, including hub secrets and raw text values. To create a block that has an input, use mustache templating as follows: | |
| 86 | - | |
| 87 | -```yaml title="config.yaml" | |
| 88 | -name: myprofile/custom-model | |
| 89 | -version: 1.0.0 | |
| 90 | -schema: v1 | |
| 91 | - | |
| 92 | -models: | |
| 93 | - - name: My Favorite Model | |
| 94 | - provider: anthropic | |
| 95 | - apiKey: ${{ inputs.ANTHROPIC_API_KEY }} | |
| 96 | - defaultCompletionOptions: | |
| 97 | - temperature: ${{ inputs.TEMP }} | |
| 98 | -``` | |
| 99 | - | |
| 100 | -Which can then be imported like this: | |
| 101 | - | |
| 102 | -```yaml title="config.yaml" | |
| 103 | -name: myprofile/custom-agent | |
| 104 | -version: 1.0.0 | |
| 105 | -schema: v1 | |
| 106 | - | |
| 107 | -models: | |
| 108 | - - uses: myprofile/custom-model | |
| 109 | - with: | |
| 110 | - ANTHROPIC_API_KEY: ${{ secrets.MY_ANTHROPIC_API_KEY }} | |
| 111 | - TEMP: 0.9 | |
| 112 | -``` | |
| 113 | - | |
| 114 | -Note that hub secrets can be passed as inputs, using a similar mustache format: `secrets.SECRET_NAME`. | |
| 115 | - | |
| 116 | -### Overrides | |
| 117 | - | |
| 118 | -Block properties can be also be directly overriden using `override`. For example: | |
| 119 | - | |
| 120 | -```yaml title="config.yaml" | |
| 121 | -name: myprofile/custom-agent | |
| 122 | -version: 1.0.0 | |
| 123 | -schema: v1 | |
| 124 | - | |
| 125 | -models: | |
| 126 | - - uses: myprofile/custom-model | |
| 127 | - with: | |
| 128 | - ANTHROPIC_API_KEY: ${{ secrets.MY_ANTHROPIC_API_KEY }} | |
| 129 | - TEMP: 0.9 | |
| 130 | - override: | |
| 131 | - roles: | |
| 132 | - - chat | |
| 133 | -``` | |
| 17 | +<Card title="Understanding Agents" icon="robot" href="/guides/understanding-agents"> | |
| 18 | +Learn how to build and configure agents, understand their capabilities, and customize them for your development workflow. | |
| 19 | +</Card> | |
| 20 | +</Columns> | |
| 134 | 21 | |
| 135 | 22 | ## Properties |
| 136 | 23 | |
| @@ -566,3 +453,9 @@ | ||
| 566 | 453 | maxPromptTokens: 1024 |
| 567 | 454 | onlyMyCode: true |
| 568 | 455 | ``` |
| 456 | + | |
| 457 | +--- | |
| 458 | + | |
| 459 | +## `config.json` Deprecation | |
| 460 | + | |
| 461 | +`config.yaml `replaces `config.json`, which is deprecated. View the **[Migration Guide](/reference/yaml-migration)** for help transitioning from the old format. |
| @@ -1,9 +1,11 @@ | ||
| 1 | 1 | import { type AssistantConfig } from "@continuedev/sdk"; |
| 2 | +import { createRelativeRuleFilePath } from "core/config/markdown/utils.js"; | |
| 2 | 3 | |
| 3 | 4 | import { SlashCommandResult } from "../ui/hooks/useChat.types.js"; |
| 4 | 5 | |
| 5 | 6 | function createInitPrompt(): string { |
| 6 | - return `Please analyze this repository and create a comprehensive AGENTS.md file. Use your available tools to understand the project structure, read important files like README.md, package.json, requirements.txt, and other configuration files to understand the technology stack and setup. | |
| 7 | + const relativeRuleFilepath = createRelativeRuleFilePath("review"); | |
| 8 | + return `Please analyze this repository and create a comprehensive AGENTS.md file, along with a custom slash command. Use your available tools to understand the project structure, read important files like README.md, package.json, requirements.txt, and other configuration files to understand the technology stack and setup. | |
| 7 | 9 | |
| 8 | 10 | Create an AGENTS.md file with the following structure: |
| 9 | 11 | |
| @@ -30,7 +32,23 @@ | ||
| 30 | 32 | - Development environment setup |
| 31 | 33 | - Lint and format commands |
| 32 | 34 | |
| 33 | -Please create the AGENTS.md file using the Write tool after analyzing the repository. Focus on providing actionable information that would help both AI agents and human developers understand and work effectively with this codebase. Keep the file concise but informational.`; | |
| 35 | +Additionally, create a slash command file at ${relativeRuleFilepath} with the following structure: | |
| 36 | + | |
| 37 | +\`\`\`md | |
| 38 | +--- | |
| 39 | +invokable: true | |
| 40 | +--- | |
| 41 | + | |
| 42 | +Review this code for potential issues, including: | |
| 43 | + | |
| 44 | +<insert custom things to look for based on the repository details you find> | |
| 45 | + | |
| 46 | +Provide specific, actionable feedback for improvements. | |
| 47 | +\`\`\` | |
| 48 | + | |
| 49 | +This slash command will be invokable using /review and will provide instructions for code review tasks common to this repository. | |
| 50 | + | |
| 51 | +Please create both the AGENTS.md file and the .continue/rules/review.md file using the Write tool after analyzing the repository. Focus on providing actionable information that would help both AI agents and human developers understand and work effectively with this codebase. Keep the files concise but informational.`; | |
| 34 | 52 | } |
| 35 | 53 | |
| 36 | 54 | export async function handleInit( |
| @@ -22,13 +22,27 @@ | ||
| 22 | 22 | readonly: true, |
| 23 | 23 | isBuiltIn: true, |
| 24 | 24 | preprocess: async (args) => { |
| 25 | + // Resolve relative paths | |
| 26 | + const normalizedPath = path.normalize(args.dirpath); | |
| 27 | + const dirPath = path.resolve(process.cwd(), normalizedPath); | |
| 28 | + | |
| 29 | + if (!fs.existsSync(dirPath)) { | |
| 30 | + throw new Error(`Directory does not exist: ${dirPath}`); | |
| 31 | + } | |
| 32 | + | |
| 33 | + if (!fs.statSync(dirPath).isDirectory()) { | |
| 34 | + throw new Error(`Error: Path is not a directory: ${dirPath}`); | |
| 35 | + } | |
| 36 | + | |
| 25 | 37 | return { |
| 26 | - args, | |
| 38 | + args: { | |
| 39 | + dirpath: dirPath, | |
| 40 | + }, | |
| 27 | 41 | preview: [ |
| 28 | 42 | { |
| 29 | 43 | type: "text", |
| 30 | - content: args.dirpath | |
| 31 | - ? `Will list files in: ${formatToolArgument(args.dirpath)}` | |
| 44 | + content: dirPath | |
| 45 | + ? `Will list files in: ${formatToolArgument(dirPath)}` | |
| 32 | 46 | : "Will list files in current directory", |
| 33 | 47 | }, |
| 34 | 48 | ], |
| @@ -36,14 +50,6 @@ | ||
| 36 | 50 | }, |
| 37 | 51 | run: async (args: { dirpath: string }): Promise<string> => { |
| 38 | 52 | try { |
| 39 | - if (!fs.existsSync(args.dirpath)) { | |
| 40 | - return `Error: Directory does not exist: ${args.dirpath}`; | |
| 41 | - } | |
| 42 | - | |
| 43 | - if (!fs.statSync(args.dirpath).isDirectory()) { | |
| 44 | - return `Error: Path is not a directory: ${args.dirpath}`; | |
| 45 | - } | |
| 46 | - | |
| 47 | 53 | const files = fs.readdirSync(args.dirpath); |
| 48 | 54 | const fileDetails = files.map((file) => { |
| 49 | 55 | const fullPath = path.join(args.dirpath, file); |
| @@ -0,0 +1,63 @@ | ||
| 1 | +import { render } from "ink-testing-library"; | |
| 2 | +import React from "react"; | |
| 3 | + | |
| 4 | +import { ChecklistDisplay } from "./ChecklistDisplay.js"; | |
| 5 | + | |
| 6 | +describe("ChecklistDisplay", () => { | |
| 7 | + it("should highlight the first incomplete item", () => { | |
| 8 | + const content = `Task list status: | |
| 9 | +- [x] Completed task | |
| 10 | +- [ ] First incomplete task | |
| 11 | +- [ ] Second incomplete task`; | |
| 12 | + | |
| 13 | + const { lastFrame } = render(<ChecklistDisplay content={content} />); | |
| 14 | + const output = lastFrame(); | |
| 15 | + | |
| 16 | + // The output should contain the checkbox symbols and text | |
| 17 | + expect(output).toContain("✓"); | |
| 18 | + expect(output).toContain("○"); | |
| 19 | + expect(output).toContain("Completed task"); | |
| 20 | + expect(output).toContain("First incomplete task"); | |
| 21 | + expect(output).toContain("Second incomplete task"); | |
| 22 | + }); | |
| 23 | + | |
| 24 | + it("should handle empty checklist", () => { | |
| 25 | + const content = "Task list status:"; | |
| 26 | + | |
| 27 | + const { lastFrame } = render(<ChecklistDisplay content={content} />); | |
| 28 | + const output = lastFrame(); | |
| 29 | + | |
| 30 | + expect(output).toBeDefined(); | |
| 31 | + }); | |
| 32 | + | |
| 33 | + it("should handle all completed tasks", () => { | |
| 34 | + const content = `Task list status: | |
| 35 | +- [x] Completed task 1 | |
| 36 | +- [x] Completed task 2`; | |
| 37 | + | |
| 38 | + const { lastFrame } = render(<ChecklistDisplay content={content} />); | |
| 39 | + const output = lastFrame(); | |
| 40 | + | |
| 41 | + expect(output).toContain("✓"); | |
| 42 | + expect(output).toContain("Completed task 1"); | |
| 43 | + expect(output).toContain("Completed task 2"); | |
| 44 | + }); | |
| 45 | + | |
| 46 | + it("should handle mixed content with headers", () => { | |
| 47 | + const content = `Task list status: | |
| 48 | +## Important Tasks | |
| 49 | +- [x] Done task | |
| 50 | +- [ ] Todo task | |
| 51 | + | |
| 52 | +## Other Tasks | |
| 53 | +- [ ] Another todo`; | |
| 54 | + | |
| 55 | + const { lastFrame } = render(<ChecklistDisplay content={content} />); | |
| 56 | + const output = lastFrame(); | |
| 57 | + | |
| 58 | + expect(output).toContain("Important Tasks"); | |
| 59 | + expect(output).toContain("Other Tasks"); | |
| 60 | + expect(output).toContain("✓"); | |
| 61 | + expect(output).toContain("○"); | |
| 62 | + }); | |
| 63 | +}); |
| @@ -13,6 +13,17 @@ | ||
| 13 | 13 | }) => { |
| 14 | 14 | const lines = content.split("\n"); |
| 15 | 15 | |
| 16 | + // Find the index of the first incomplete checkbox item | |
| 17 | + let firstIncompleteIndex = -1; | |
| 18 | + for (let i = 0; i < lines.length; i++) { | |
| 19 | + const line = lines[i]; | |
| 20 | + const checkboxMatch = line.match(/^(\s*)-\s*\[([ x])\]\s*(.*)$/); | |
| 21 | + if (checkboxMatch && checkboxMatch[2] === " ") { | |
| 22 | + firstIncompleteIndex = i; | |
| 23 | + break; | |
| 24 | + } | |
| 25 | + } | |
| 26 | + | |
| 16 | 27 | return ( |
| 17 | 28 | <Box flexDirection="column" paddingLeft={2}> |
| 18 | 29 | {lines.map((line, index) => { |
| @@ -25,6 +36,7 @@ | ||
| 25 | 36 | if (checkboxMatch) { |
| 26 | 37 | const [, indent, status, taskText] = checkboxMatch; |
| 27 | 38 | const isCompleted = status === "x"; |
| 39 | + const isFirstIncomplete = index === firstIncompleteIndex; | |
| 28 | 40 | |
| 29 | 41 | return ( |
| 30 | 42 | <Box key={index}> |
| @@ -34,8 +46,11 @@ | ||
| 34 | 46 | </Text> |
| 35 | 47 | <Text> </Text> |
| 36 | 48 | <Text |
| 37 | - color={isCompleted ? "gray" : "white"} | |
| 49 | + color={ | |
| 50 | + isCompleted ? "gray" : isFirstIncomplete ? "cyan" : "white" | |
| 51 | + } | |
| 38 | 52 | strikethrough={isCompleted} |
| 53 | + bold={isFirstIncomplete} | |
| 39 | 54 | > |
| 40 | 55 | {taskText} |
| 41 | 56 | </Text> |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | pluginGroup=com.github.continuedev.continueintellijextension |
| 2 | -pluginVersion=1.0.45 | |
| 2 | +pluginVersion=1.0.46 | |
| 3 | 3 | platformVersion=2024.1 |
| 4 | 4 | kotlin.stdlib.default.dependency=false |
| 5 | 5 | org.gradle.configuration-cache=true |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | "name": "continue", |
| 3 | 3 | "icon": "media/icon.png", |
| 4 | 4 | "author": "Continue Dev, Inc", |
| 5 | - "version": "1.3.12", | |
| 5 | + "version": "1.3.13", | |
| 6 | 6 | "repository": { |
| 7 | 7 | "type": "git", |
| 8 | 8 | "url": "https://github.com/continuedev/continue" |
| @@ -373,6 +373,12 @@ | ||
| 373 | 373 | "category": "Continue", |
| 374 | 374 | "title": "Generate Rule", |
| 375 | 375 | "group": "Continue" |
| 376 | + }, | |
| 377 | + { | |
| 378 | + "command": "continue.openInNewWindow", | |
| 379 | + "category": "Continue", | |
| 380 | + "title": "Open in new window", | |
| 381 | + "group": "Continue" | |
| 376 | 382 | } |
| 377 | 383 | ], |
| 378 | 384 | "keybindings": [ |
| @@ -443,6 +449,12 @@ | ||
| 443 | 449 | "mac": "cmd+shift+r", |
| 444 | 450 | "key": "ctrl+shift+r" |
| 445 | 451 | }, |
| 452 | + { | |
| 453 | + "command": "continue.openInNewWindow", | |
| 454 | + "mac": "cmd+k cmd+m", | |
| 455 | + "key": "ctrl+k ctrl+m", | |
| 456 | + "when": "!terminalFocus" | |
| 457 | + }, | |
| 446 | 458 | { |
| 447 | 459 | "command": "continue.toggleTabAutocompleteEnabled", |
| 448 | 460 | "mac": "cmd+k cmd+a", |
| @@ -512,6 +524,9 @@ | ||
| 512 | 524 | }, |
| 513 | 525 | { |
| 514 | 526 | "command": "continue.generateRule" |
| 527 | + }, | |
| 528 | + { | |
| 529 | + "command": "continue.openInNewWindow" | |
| 515 | 530 | } |
| 516 | 531 | ], |
| 517 | 532 | "editor/context": [ |
| @@ -46,6 +46,15 @@ | ||
| 46 | 46 | import { openEditorAndRevealRange } from "./util/vscode"; |
| 47 | 47 | import { VsCodeIde } from "./VsCodeIde"; |
| 48 | 48 | |
| 49 | +let fullScreenPanel: vscode.WebviewPanel | undefined; | |
| 50 | + | |
| 51 | +function getFullScreenTab() { | |
| 52 | + const tabs = vscode.window.tabGroups.all.flatMap((tabGroup) => tabGroup.tabs); | |
| 53 | + return tabs.find((tab) => | |
| 54 | + (tab.input as any)?.viewType?.endsWith("continue.continueGUIView"), | |
| 55 | + ); | |
| 56 | +} | |
| 57 | + | |
| 49 | 58 | type TelemetryCaptureParams = Parameters<typeof Telemetry.capture>; |
| 50 | 59 | |
| 51 | 60 | /** |
| @@ -59,15 +68,27 @@ | ||
| 59 | 68 | } |
| 60 | 69 | |
| 61 | 70 | function focusGUI() { |
| 62 | - // focus sidebar | |
| 63 | - vscode.commands.executeCommand("continue.continueGUIView.focus"); | |
| 64 | - // vscode.commands.executeCommand("workbench.action.focusAuxiliaryBar"); | |
| 71 | + const fullScreenTab = getFullScreenTab(); | |
| 72 | + if (fullScreenTab) { | |
| 73 | + // focus fullscreen | |
| 74 | + fullScreenPanel?.reveal(); | |
| 75 | + } else { | |
| 76 | + // focus sidebar | |
| 77 | + vscode.commands.executeCommand("continue.continueGUIView.focus"); | |
| 78 | + // vscode.commands.executeCommand("workbench.action.focusAuxiliaryBar"); | |
| 79 | + } | |
| 65 | 80 | } |
| 66 | 81 | |
| 67 | 82 | function hideGUI() { |
| 68 | - // focus sidebar | |
| 69 | - vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); | |
| 70 | - // vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar"); | |
| 83 | + const fullScreenTab = getFullScreenTab(); | |
| 84 | + if (fullScreenTab) { | |
| 85 | + // focus fullscreen | |
| 86 | + fullScreenPanel?.dispose(); | |
| 87 | + } else { | |
| 88 | + // focus sidebar | |
| 89 | + vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); | |
| 90 | + // vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar"); | |
| 91 | + } | |
| 71 | 92 | } |
| 72 | 93 | |
| 73 | 94 | function waitForSidebarReady( |
| @@ -602,6 +623,11 @@ | ||
| 602 | 623 | label: "$(comment) Open chat", |
| 603 | 624 | description: getMetaKeyLabel() + " + L", |
| 604 | 625 | }, |
| 626 | + { | |
| 627 | + label: "$(screen-full) Open full screen chat", | |
| 628 | + description: | |
| 629 | + getMetaKeyLabel() + " + K, " + getMetaKeyLabel() + " + M", | |
| 630 | + }, | |
| 605 | 631 | { |
| 606 | 632 | label: quickPickStatusText(targetStatus), |
| 607 | 633 | description: |
| @@ -644,6 +670,8 @@ | ||
| 644 | 670 | } |
| 645 | 671 | } else if (selectedOption === "$(comment) Open chat") { |
| 646 | 672 | vscode.commands.executeCommand("continue.focusContinueInput"); |
| 673 | + } else if (selectedOption === "$(screen-full) Open full screen chat") { | |
| 674 | + vscode.commands.executeCommand("continue.openInNewWindow"); | |
| 647 | 675 | } else if (selectedOption === "$(gear) Open settings") { |
| 648 | 676 | vscode.commands.executeCommand("continue.navigateTo", "/config"); |
| 649 | 677 | } |
| @@ -770,6 +798,74 @@ | ||
| 770 | 798 | vscode.ConfigurationTarget.Global, |
| 771 | 799 | ); |
| 772 | 800 | }, |
| 801 | + "continue.openInNewWindow": async () => { | |
| 802 | + focusGUI(); | |
| 803 | + | |
| 804 | + const sessionId = await sidebar.webviewProtocol.request( | |
| 805 | + "getCurrentSessionId", | |
| 806 | + undefined, | |
| 807 | + ); | |
| 808 | + // Check if full screen is already open by checking open tabs | |
| 809 | + const fullScreenTab = getFullScreenTab(); | |
| 810 | + | |
| 811 | + if (fullScreenTab && fullScreenPanel) { | |
| 812 | + // Full screen open, but not focused - focus it | |
| 813 | + fullScreenPanel.reveal(); | |
| 814 | + return; | |
| 815 | + } | |
| 816 | + | |
| 817 | + // Clear the sidebar to prevent overwriting changes made in fullscreen | |
| 818 | + vscode.commands.executeCommand("continue.newSession"); | |
| 819 | + | |
| 820 | + // Full screen not open - open it | |
| 821 | + captureCommandTelemetry("openInNewWindow"); | |
| 822 | + | |
| 823 | + // Create the full screen panel | |
| 824 | + let panel = vscode.window.createWebviewPanel( | |
| 825 | + "continue.continueGUIView", | |
| 826 | + "Continue", | |
| 827 | + vscode.ViewColumn.One, | |
| 828 | + { | |
| 829 | + retainContextWhenHidden: true, | |
| 830 | + enableScripts: true, | |
| 831 | + }, | |
| 832 | + ); | |
| 833 | + fullScreenPanel = panel; | |
| 834 | + | |
| 835 | + // Add content to the panel | |
| 836 | + panel.webview.html = sidebar.getSidebarContent( | |
| 837 | + extensionContext, | |
| 838 | + panel, | |
| 839 | + undefined, | |
| 840 | + undefined, | |
| 841 | + true, | |
| 842 | + ); | |
| 843 | + | |
| 844 | + const sessionLoader = panel.onDidChangeViewState(() => { | |
| 845 | + vscode.commands.executeCommand("continue.newSession"); | |
| 846 | + if (sessionId) { | |
| 847 | + vscode.commands.executeCommand( | |
| 848 | + "continue.focusContinueSessionId", | |
| 849 | + sessionId, | |
| 850 | + ); | |
| 851 | + } | |
| 852 | + panel.reveal(); | |
| 853 | + sessionLoader.dispose(); | |
| 854 | + }); | |
| 855 | + | |
| 856 | + // When panel closes, reset the webview and focus | |
| 857 | + panel.onDidDispose( | |
| 858 | + () => { | |
| 859 | + sidebar.resetWebviewProtocolWebview(); | |
| 860 | + vscode.commands.executeCommand("continue.focusContinueInput"); | |
| 861 | + }, | |
| 862 | + null, | |
| 863 | + extensionContext.subscriptions, | |
| 864 | + ); | |
| 865 | + | |
| 866 | + vscode.commands.executeCommand("workbench.action.copyEditorToNewWindow"); | |
| 867 | + vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); | |
| 868 | + }, | |
| 773 | 869 | "continue.forceNextEdit": async () => { |
| 774 | 870 | captureCommandTelemetry("forceNextEdit"); |
| 775 | 871 |
| @@ -113,6 +113,9 @@ | ||
| 113 | 113 | this.onWebview("focusEditor", (msg) => { |
| 114 | 114 | vscode.commands.executeCommand("workbench.action.focusActiveEditorGroup"); |
| 115 | 115 | }); |
| 116 | + this.onWebview("toggleFullScreen", (msg) => { | |
| 117 | + vscode.commands.executeCommand("continue.openInNewWindow"); | |
| 118 | + }); | |
| 116 | 119 | |
| 117 | 120 | this.onWebview("acceptDiff", async ({ data: { filepath, streamId } }) => { |
| 118 | 121 | await vscode.commands.executeCommand( |
Binary content is not shown. View the file.
| @@ -48,9 +48,7 @@ | ||
| 48 | 48 | ) : ( |
| 49 | 49 | <> |
| 50 | 50 | <AssistantIcon assistant={selectedProfile} size={iconSize} /> |
| 51 | - <span | |
| 52 | - className={`select-none truncate text-xs ${isSidebar && "hidden md:block"}`} | |
| 53 | - > | |
| 51 | + <span className={`xs:line-clamp-1 hidden select-none text-xs`}> | |
| 54 | 52 | {selectedProfile.title} |
| 55 | 53 | </span> |
| 56 | 54 | </> |
| @@ -150,7 +150,7 @@ | ||
| 150 | 150 | /> |
| 151 | 151 | <Transition> |
| 152 | 152 | <ListboxOptions |
| 153 | - className="max-h-32 -translate-x-1.5 overflow-y-auto pb-0" | |
| 153 | + className="max-h-32 scale-x-[97%] overflow-y-auto pb-0" | |
| 154 | 154 | style={{ zIndex: 200 }} |
| 155 | 155 | > |
| 156 | 156 | <div className="flex items-center justify-between px-1.5 py-1"> |
| @@ -141,7 +141,7 @@ | ||
| 141 | 141 | {!!error ? ( |
| 142 | 142 | <div className="text-error whitespace-pre text-sm">{error}</div> |
| 143 | 143 | ) : ( |
| 144 | - <div className="relative"> | |
| 144 | + <div className="mermaid relative"> | |
| 145 | 145 | <div className="absolute right-0 z-10 m-2 flex items-center gap-x-1"> |
| 146 | 146 | <ToolTip content={"Zoom In"}> |
| 147 | 147 | <MagnifyingGlassPlusIcon |
| @@ -84,6 +84,26 @@ | ||
| 84 | 84 | font-family: var(--vscode-editor-font-family); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | + ul ul, | |
| 88 | + ul ol, | |
| 89 | + ol ul, | |
| 90 | + ol ol { | |
| 91 | + padding-left: 1.5em; | |
| 92 | + margin-top: 1em; | |
| 93 | + } | |
| 94 | + | |
| 95 | + li { | |
| 96 | + margin-bottom: 0.8em; | |
| 97 | + } | |
| 98 | + li:last-child { | |
| 99 | + margin-bottom: 0; | |
| 100 | + } | |
| 101 | + | |
| 102 | + ul, | |
| 103 | + ol { | |
| 104 | + padding-left: 2em; | |
| 105 | + } | |
| 106 | + | |
| 87 | 107 | code:not(pre > code) { |
| 88 | 108 | font-family: var(--vscode-editor-font-family); |
| 89 | 109 | } |
| @@ -1038,3 +1038,6 @@ | ||
| 1038 | 1038 | .token.entity { |
| 1039 | 1039 | cursor: help; |
| 1040 | 1040 | } |
| 1041 | +.mermaid foreignObject { | |
| 1042 | + width: 100%; | |
| 1043 | +} |
| @@ -56,7 +56,6 @@ | ||
| 56 | 56 | const hasReasoningEnabled = useAppSelector( |
| 57 | 57 | (store) => store.session.hasReasoningEnabled, |
| 58 | 58 | ); |
| 59 | - | |
| 60 | 59 | const isEnterDisabled = |
| 61 | 60 | props.disabled || (isInEdit && codeToEdit.length === 0); |
| 62 | 61 |
| @@ -105,7 +105,7 @@ | ||
| 105 | 105 | }; |
| 106 | 106 | |
| 107 | 107 | return ( |
| 108 | - <div className="flex flex-1 items-center justify-between gap-1.5"> | |
| 108 | + <div className="flex flex-1 items-center justify-between gap-3"> | |
| 109 | 109 | <div className="flex items-center gap-1"> |
| 110 | 110 | {shouldShowError && ( |
| 111 | 111 | <ToolTip delayShow={700} content="View configuration errors"> |
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | import { cancelStream } from "../../../../redux/thunks/cancelStream"; |
| 13 | 13 | import { logToolUsage } from "../../../../redux/util"; |
| 14 | 14 | import { isJetBrains } from "../../../../util"; |
| 15 | +import { useMainEditor } from "../../TipTapEditor"; | |
| 15 | 16 | import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar"; |
| 16 | 17 | import { EditOutcomeToolbar } from "./EditOutcomeToolbar"; |
| 17 | 18 | import { EditToolbar } from "./EditToolbar"; |
| @@ -64,6 +65,7 @@ | ||
| 64 | 65 | (state) => state.status === "done", |
| 65 | 66 | ); |
| 66 | 67 | const isApplying = applyStates.some((state) => state.status === "streaming"); |
| 68 | + const editor = useMainEditor(); | |
| 67 | 69 | |
| 68 | 70 | // Get ALL running terminal commands |
| 69 | 71 | const runningToolCalls = useAppSelector((state) => |
| @@ -140,7 +142,10 @@ | ||
| 140 | 142 | // Stop running terminal commands |
| 141 | 143 | void handleStopAction(); |
| 142 | 144 | } else if (firstPendingToolCall) { |
| 143 | - // Cancel pending tool call | |
| 145 | + // Cancel pending tool call. If last call, focus editor | |
| 146 | + if (pendingToolCalls.length === 1) { | |
| 147 | + editor.mainEditor?.commands.focus(); | |
| 148 | + } | |
| 144 | 149 | void dispatch( |
| 145 | 150 | cancelToolCall({ |
| 146 | 151 | toolCallId: firstPendingToolCall.toolCallId, |
| @@ -155,7 +160,13 @@ | ||
| 155 | 160 | return () => { |
| 156 | 161 | document.removeEventListener("keydown", handleToolCallKeyboardShortcuts); |
| 157 | 162 | }; |
| 158 | - }, [firstPendingToolCall, hasRunningTerminalCommand, runningTerminalCalls]); | |
| 163 | + }, [ | |
| 164 | + firstPendingToolCall, | |
| 165 | + pendingToolCalls, | |
| 166 | + editor, | |
| 167 | + hasRunningTerminalCommand, | |
| 168 | + runningTerminalCalls, | |
| 169 | + ]); | |
| 159 | 170 | |
| 160 | 171 | if (isApplying) { |
| 161 | 172 | return <IsApplyingToolbar />; |
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | import { cancelToolCallThunk } from "../../../../redux/thunks/cancelToolCall"; |
| 5 | 5 | import { getAltKeyLabel, getMetaKeyLabel, isJetBrains } from "../../../../util"; |
| 6 | 6 | import { Button } from "../../../ui"; |
| 7 | +import { useMainEditor } from "../../TipTapEditor"; | |
| 7 | 8 | |
| 8 | 9 | export const generateToolCallButtonTestId = ( |
| 9 | 10 | action: "accept" | "reject", |
| @@ -16,6 +17,7 @@ | ||
| 16 | 17 | const dispatch = useAppDispatch(); |
| 17 | 18 | const jetbrains = isJetBrains(); |
| 18 | 19 | const pendingToolCalls = useAppSelector(selectPendingToolCalls); |
| 20 | + const editor = useMainEditor(); | |
| 19 | 21 | |
| 20 | 22 | if (pendingToolCalls.length === 0) { |
| 21 | 23 | return null; |
| @@ -26,6 +28,10 @@ | ||
| 26 | 28 | }; |
| 27 | 29 | |
| 28 | 30 | const handleReject = (toolCallId: string) => { |
| 31 | + // put cursor in editor after last rejection | |
| 32 | + if (pendingToolCalls.length === 1) { | |
| 33 | + editor.mainEditor?.commands.focus(); | |
| 34 | + } | |
| 29 | 35 | void dispatch(cancelToolCallThunk({ toolCallId })); |
| 30 | 36 | }; |
| 31 | 37 |
| @@ -5,17 +5,15 @@ | ||
| 5 | 5 | CubeIcon, |
| 6 | 6 | PlusIcon, |
| 7 | 7 | } from "@heroicons/react/24/outline"; |
| 8 | -import { useContext, useEffect, useRef, useState } from "react"; | |
| 8 | +import { useEffect, useRef, useState } from "react"; | |
| 9 | 9 | import { useNavigate } from "react-router-dom"; |
| 10 | 10 | import { useAuth } from "../../context/Auth"; |
| 11 | -import { IdeMessengerContext } from "../../context/IdeMessenger"; | |
| 12 | 11 | import { AddModelForm } from "../../forms/AddModelForm"; |
| 13 | 12 | import { useAppDispatch, useAppSelector } from "../../redux/hooks"; |
| 14 | 13 | import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; |
| 15 | 14 | import { updateSelectedModelByRole } from "../../redux/thunks/updateSelectedModelByRole"; |
| 16 | 15 | import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; |
| 17 | 16 | import { CONFIG_ROUTES } from "../../util/navigation"; |
| 18 | -import { ToolTip } from "../gui/Tooltip"; | |
| 19 | 17 | import { |
| 20 | 18 | Button, |
| 21 | 19 | Listbox, |
| @@ -52,6 +50,15 @@ | ||
| 52 | 50 | return model?.class_name; |
| 53 | 51 | } |
| 54 | 52 | |
| 53 | +/**makeshift way to close the headlessui listbox due to absence of open state on the listbox */ | |
| 54 | +function closeDropDown(button: HTMLButtonElement | null) { | |
| 55 | + if (!button) return; | |
| 56 | + button.classList.add("hidden"); | |
| 57 | + setTimeout(() => { | |
| 58 | + button.classList.remove("hidden"); | |
| 59 | + }); | |
| 60 | +} | |
| 61 | + | |
| 55 | 62 | function ModelOption({ |
| 56 | 63 | option, |
| 57 | 64 | idx, |
| @@ -117,7 +124,6 @@ | ||
| 117 | 124 | const isInEdit = useAppSelector((store) => store.session.isInEdit); |
| 118 | 125 | const config = useAppSelector((state) => state.config.config); |
| 119 | 126 | const isConfigLoading = useAppSelector((state) => state.config.loading); |
| 120 | - const ideMessenger = useContext(IdeMessengerContext); | |
| 121 | 127 | const buttonRef = useRef<HTMLButtonElement>(null); |
| 122 | 128 | const [options, setOptions] = useState<Option[]>([]); |
| 123 | 129 | const [sortedOptions, setSortedOptions] = useState<Option[]>([]); |
| @@ -201,10 +207,8 @@ | ||
| 201 | 207 | e.stopPropagation(); |
| 202 | 208 | e.preventDefault(); |
| 203 | 209 | |
| 204 | - // Close the dropdown | |
| 205 | - if (buttonRef.current) { | |
| 206 | - buttonRef.current.click(); | |
| 207 | - } | |
| 210 | + closeDropDown(buttonRef.current); | |
| 211 | + | |
| 208 | 212 | dispatch(setShowDialog(true)); |
| 209 | 213 | dispatch( |
| 210 | 214 | setDialogMessage( |
| @@ -221,10 +225,7 @@ | ||
| 221 | 225 | e.stopPropagation(); |
| 222 | 226 | e.preventDefault(); |
| 223 | 227 | |
| 224 | - // Close the dropdown | |
| 225 | - if (buttonRef.current) { | |
| 226 | - buttonRef.current.click(); | |
| 227 | - } | |
| 228 | + closeDropDown(buttonRef.current); | |
| 228 | 229 | |
| 229 | 230 | navigate(CONFIG_ROUTES.MODELS); |
| 230 | 231 | } |
| @@ -40,7 +40,7 @@ | ||
| 40 | 40 | className={cn( |
| 41 | 41 | "cursor-pointer transition-all duration-200", |
| 42 | 42 | "hover:enabled:cursor-pointer", |
| 43 | - "disabled:text-description-muted disabled:pointer-events-none disabled:opacity-50", | |
| 43 | + "disabled:cursor-not-allowed disabled:opacity-50", | |
| 44 | 44 | buttonVariants[variant], |
| 45 | 45 | isIcon |
| 46 | 46 | ? iconButtonSizes[size] |
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | LLMInteractionSuccess, |
| 11 | 11 | } from "core"; |
| 12 | 12 | import { useEffect, useReducer } from "react"; |
| 13 | +import { v4 as uuidv4 } from "uuid"; | |
| 13 | 14 | |
| 14 | 15 | declare const vscode: any; |
| 15 | 16 | |
| @@ -231,7 +232,7 @@ | ||
| 231 | 232 | // messages from the previous generation. In particular, this |
| 232 | 233 | // avoids problems when React.StrictMode runs this effect |
| 233 | 234 | // twice - we don't want to process two "init" messages. |
| 234 | - const uuid = crypto.randomUUID(); | |
| 235 | + const uuid = uuidv4(); | |
| 235 | 236 | const onMessage = (event: MessageEvent<ToConsoleView>) => { |
| 236 | 237 | if (event.data.uuid !== uuid) { |
| 237 | 238 | return; |
| @@ -1585,14 +1585,83 @@ | ||
| 1585 | 1585 | providerOptions: ["scaleway", "nebius", "ovhcloud", "ncompass"], |
| 1586 | 1586 | isOpenSource: true, |
| 1587 | 1587 | }, |
| 1588 | - grokBeta: { | |
| 1589 | - title: "Grok Beta", | |
| 1590 | - description: "Generative artificial intelligence chatbot developed by xAI.", | |
| 1591 | - refUrl: "", | |
| 1588 | + grokCodeFast1: { | |
| 1589 | + title: "Grok Code Fast 1", | |
| 1590 | + description: | |
| 1591 | + "A speedy and economical reasoning model that excels at agentic coding", | |
| 1592 | + refUrl: "https://docs.x.ai/docs/models/grok-code-fast-1", | |
| 1592 | 1593 | params: { |
| 1593 | - title: "Grok Beta", | |
| 1594 | - model: "grok-beta", | |
| 1595 | - contextLength: 128_000, | |
| 1594 | + title: "Grok Code Fast 1", | |
| 1595 | + model: "grok-code-fast-1", | |
| 1596 | + contextLength: 256000, | |
| 1597 | + }, | |
| 1598 | + icon: "xAI.png", | |
| 1599 | + providerOptions: ["xAI", "askSage"], | |
| 1600 | + isOpenSource: false, | |
| 1601 | + }, | |
| 1602 | + grok4FastReasoning: { | |
| 1603 | + title: "Grok 4 Fast Reasoning", | |
| 1604 | + description: "xAI's latest advancement in cost-efficient reasoning models", | |
| 1605 | + refUrl: "https://docs.x.ai/docs/models/grok-4-fast-reasoning", | |
| 1606 | + params: { | |
| 1607 | + title: "Grok 4 Fast Reasoning", | |
| 1608 | + model: "grok-4-fast-reasoning", | |
| 1609 | + contextLength: 2_000_000, | |
| 1610 | + }, | |
| 1611 | + icon: "xAI.png", | |
| 1612 | + providerOptions: ["xAI", "askSage"], | |
| 1613 | + isOpenSource: false, | |
| 1614 | + }, | |
| 1615 | + grok4FastNonReasoning: { | |
| 1616 | + title: "Grok 4 Fast Non-Reasoning", | |
| 1617 | + description: "xAI's latest advancement in cost-efficient models", | |
| 1618 | + refUrl: "https://docs.x.ai/docs/models/grok-4-fast-non-reasoning", | |
| 1619 | + params: { | |
| 1620 | + title: "Grok 4 Fast Non-Reasoning", | |
| 1621 | + model: "grok-4-fast-non-reasoning", | |
| 1622 | + contextLength: 2_000_000, | |
| 1623 | + }, | |
| 1624 | + icon: "xAI.png", | |
| 1625 | + providerOptions: ["xAI", "askSage"], | |
| 1626 | + isOpenSource: false, | |
| 1627 | + }, | |
| 1628 | + grok4: { | |
| 1629 | + title: "Grok 4", | |
| 1630 | + description: | |
| 1631 | + "xAI's latest and greatest flagship model, offering strong performance in natural language, math and reasoning.", | |
| 1632 | + refUrl: "https://docs.x.ai/docs/models/grok-4", | |
| 1633 | + params: { | |
| 1634 | + title: "Grok 4", | |
| 1635 | + model: "grok-4", | |
| 1636 | + contextLength: 256_000, | |
| 1637 | + }, | |
| 1638 | + icon: "xAI.png", | |
| 1639 | + providerOptions: ["xAI", "askSage"], | |
| 1640 | + isOpenSource: false, | |
| 1641 | + }, | |
| 1642 | + grok3: { | |
| 1643 | + title: "Grok 3", | |
| 1644 | + description: | |
| 1645 | + "Excels at enterprise use cases like data extraction, coding, and text summarization", | |
| 1646 | + refUrl: "https://docs.x.ai/docs/models/grok-3", | |
| 1647 | + params: { | |
| 1648 | + title: "Grok 3", | |
| 1649 | + model: "grok-3", | |
| 1650 | + contextLength: 131_072, | |
| 1651 | + }, | |
| 1652 | + icon: "xAI.png", | |
| 1653 | + providerOptions: ["xAI", "askSage"], | |
| 1654 | + isOpenSource: false, | |
| 1655 | + }, | |
| 1656 | + grok3Mini: { | |
| 1657 | + title: "Grok 3 Mini", | |
| 1658 | + description: | |
| 1659 | + "A lightweight model that thinks before responding. Fast, smart, and great for logic-based tasks that do not require deep domain knowledge.", | |
| 1660 | + refUrl: "https://docs.x.ai/docs/models/grok-3-mini", | |
| 1661 | + params: { | |
| 1662 | + title: "Grok 3 Mini", | |
| 1663 | + model: "grok-3-mini", | |
| 1664 | + contextLength: 131_072, | |
| 1596 | 1665 | }, |
| 1597 | 1666 | icon: "xAI.png", |
| 1598 | 1667 | providerOptions: ["xAI", "askSage"], |
| @@ -1836,4 +1905,380 @@ | ||
| 1836 | 1905 | providerOptions: [], |
| 1837 | 1906 | isOpenSource: false, |
| 1838 | 1907 | }, |
| 1908 | + | |
| 1909 | + // CometAPI Models | |
| 1910 | + | |
| 1911 | + // GPT series models via CometAPI | |
| 1912 | + cometapiGpt5ChatLatest: { | |
| 1913 | + title: "GPT-5 Chat Latest", | |
| 1914 | + description: | |
| 1915 | + "GPT-5 Chat Latest via CometAPI - OpenAI's most advanced conversational model.", | |
| 1916 | + params: { | |
| 1917 | + model: "gpt-5-chat-latest", | |
| 1918 | + contextLength: 400_000, | |
| 1919 | + title: "GPT-5 Chat Latest", | |
| 1920 | + apiKey: "", | |
| 1921 | + }, | |
| 1922 | + providerOptions: ["cometapi"], | |
| 1923 | + icon: "cometapi.png", | |
| 1924 | + isOpenSource: false, | |
| 1925 | + }, | |
| 1926 | + cometapiGpt5Mini: { | |
| 1927 | + title: "GPT-5 Mini", | |
| 1928 | + description: | |
| 1929 | + "GPT-5 Mini via CometAPI - compact version of GPT-5 optimized for efficiency.", | |
| 1930 | + params: { | |
| 1931 | + model: "gpt-5-mini", | |
| 1932 | + contextLength: 400_000, | |
| 1933 | + title: "GPT-5 Mini", | |
| 1934 | + apiKey: "", | |
| 1935 | + }, | |
| 1936 | + providerOptions: ["cometapi"], | |
| 1937 | + icon: "cometapi.png", | |
| 1938 | + isOpenSource: false, | |
| 1939 | + }, | |
| 1940 | + cometapiGpt5: { | |
| 1941 | + title: "GPT-5", | |
| 1942 | + description: | |
| 1943 | + "GPT-5 via CometAPI - OpenAI's flagship model with advanced reasoning capabilities.", | |
| 1944 | + params: { | |
| 1945 | + model: "gpt-5", | |
| 1946 | + contextLength: 200_000, | |
| 1947 | + title: "GPT-5", | |
| 1948 | + apiKey: "", | |
| 1949 | + }, | |
| 1950 | + providerOptions: ["cometapi"], | |
| 1951 | + icon: "cometapi.png", | |
| 1952 | + isOpenSource: false, | |
| 1953 | + }, | |
| 1954 | + cometapiChatgpt4oLatest: { | |
| 1955 | + title: "ChatGPT-4o Latest", | |
| 1956 | + description: | |
| 1957 | + "ChatGPT-4o Latest via CometAPI - latest version of GPT-4o with enhanced capabilities.", | |
| 1958 | + params: { | |
| 1959 | + model: "chatgpt-4o-latest", | |
| 1960 | + contextLength: 128_000, | |
| 1961 | + title: "ChatGPT-4o Latest", | |
| 1962 | + apiKey: "", | |
| 1963 | + }, | |
| 1964 | + providerOptions: ["cometapi"], | |
| 1965 | + icon: "cometapi.png", | |
| 1966 | + isOpenSource: false, | |
| 1967 | + }, | |
| 1968 | + cometapiGpt41: { | |
| 1969 | + title: "GPT-4.1", | |
| 1970 | + description: | |
| 1971 | + "GPT-4.1 via CometAPI - enhanced version of GPT-4.1 with improved reasoning.", | |
| 1972 | + params: { | |
| 1973 | + model: "gpt-4.1", | |
| 1974 | + contextLength: 100_000, | |
| 1975 | + title: "GPT-4.1", | |
| 1976 | + apiKey: "", | |
| 1977 | + }, | |
| 1978 | + providerOptions: ["cometapi"], | |
| 1979 | + icon: "cometapi.png", | |
| 1980 | + isOpenSource: false, | |
| 1981 | + }, | |
| 1982 | + cometapiO4Mini: { | |
| 1983 | + title: "O4 Mini", | |
| 1984 | + description: | |
| 1985 | + "O4 Mini via CometAPI - OpenAI's reasoning model optimized for efficiency.", | |
| 1986 | + params: { | |
| 1987 | + model: "o4-mini-2025-04-16", | |
| 1988 | + contextLength: 200_000, | |
| 1989 | + title: "O4 Mini", | |
| 1990 | + apiKey: "", | |
| 1991 | + }, | |
| 1992 | + providerOptions: ["cometapi"], | |
| 1993 | + icon: "cometapi.png", | |
| 1994 | + isOpenSource: false, | |
| 1995 | + }, | |
| 1996 | + cometapiO3Pro: { | |
| 1997 | + title: "O3 Pro", | |
| 1998 | + description: | |
| 1999 | + "O3 Pro via CometAPI - advanced reasoning model with enhanced problem-solving capabilities.", | |
| 2000 | + params: { | |
| 2001 | + model: "o3-pro-2025-06-10", | |
| 2002 | + contextLength: 200_000, | |
| 2003 | + title: "O3 Pro", | |
| 2004 | + apiKey: "", | |
| 2005 | + }, | |
| 2006 | + providerOptions: ["cometapi"], | |
| 2007 | + icon: "cometapi.png", | |
| 2008 | + isOpenSource: false, | |
| 2009 | + }, | |
| 2010 | + | |
| 2011 | + // Claude series models via CometAPI | |
| 2012 | + cometapiClaudeOpus41: { | |
| 2013 | + title: "Claude Opus 4.1", | |
| 2014 | + description: | |
| 2015 | + "Claude Opus 4.1 via CometAPI - Anthropic's most capable model with advanced reasoning.", | |
| 2016 | + params: { | |
| 2017 | + model: "claude-opus-4-1-20250805", | |
| 2018 | + contextLength: 200_000, | |
| 2019 | + title: "Claude Opus 4.1", | |
| 2020 | + apiKey: "", | |
| 2021 | + }, | |
| 2022 | + providerOptions: ["cometapi"], | |
| 2023 | + icon: "cometapi.png", | |
| 2024 | + isOpenSource: false, | |
| 2025 | + }, | |
| 2026 | + cometapiClaudeOpus41Thinking: { | |
| 2027 | + title: "Claude Opus 4.1 Thinking", | |
| 2028 | + description: | |
| 2029 | + "Claude Opus 4.1 Thinking via CometAPI - version with enhanced thinking capabilities.", | |
| 2030 | + params: { | |
| 2031 | + model: "claude-opus-4-1-20250805-thinking", | |
| 2032 | + contextLength: 200_000, | |
| 2033 | + title: "Claude Opus 4.1 Thinking", | |
| 2034 | + apiKey: "", | |
| 2035 | + }, | |
| 2036 | + providerOptions: ["cometapi"], | |
| 2037 | + icon: "cometapi.png", | |
| 2038 | + isOpenSource: false, | |
| 2039 | + }, | |
| 2040 | + cometapiClaudeSonnet4: { | |
| 2041 | + title: "Claude Sonnet 4", | |
| 2042 | + description: | |
| 2043 | + "Claude Sonnet 4 via CometAPI - balanced performance and efficiency from Anthropic.", | |
| 2044 | + params: { | |
| 2045 | + model: "claude-sonnet-4-20250514", | |
| 2046 | + contextLength: 200_000, | |
| 2047 | + title: "Claude Sonnet 4", | |
| 2048 | + apiKey: "", | |
| 2049 | + }, | |
| 2050 | + providerOptions: ["cometapi"], | |
| 2051 | + icon: "cometapi.png", | |
| 2052 | + isOpenSource: false, | |
| 2053 | + }, | |
| 2054 | + cometapiClaudeSonnet4Thinking: { | |
| 2055 | + title: "Claude Sonnet 4 Thinking", | |
| 2056 | + description: | |
| 2057 | + "Claude Sonnet 4 Thinking via CometAPI - version with enhanced reasoning capabilities.", | |
| 2058 | + params: { | |
| 2059 | + model: "claude-sonnet-4-20250514-thinking", | |
| 2060 | + contextLength: 200_000, | |
| 2061 | + title: "Claude Sonnet 4 Thinking", | |
| 2062 | + apiKey: "", | |
| 2063 | + }, | |
| 2064 | + providerOptions: ["cometapi"], | |
| 2065 | + icon: "cometapi.png", | |
| 2066 | + isOpenSource: false, | |
| 2067 | + }, | |
| 2068 | + cometapiClaude37SonnetLatest: { | |
| 2069 | + title: "Claude 3.7 Sonnet Latest", | |
| 2070 | + description: | |
| 2071 | + "Claude 3.7 Sonnet Latest via CometAPI - latest version of Claude 3.7 Sonnet.", | |
| 2072 | + params: { | |
| 2073 | + model: "claude-3-7-sonnet-latest", | |
| 2074 | + contextLength: 200_000, | |
| 2075 | + title: "Claude 3.7 Sonnet Latest", | |
| 2076 | + apiKey: "", | |
| 2077 | + }, | |
| 2078 | + providerOptions: ["cometapi"], | |
| 2079 | + icon: "cometapi.png", | |
| 2080 | + isOpenSource: false, | |
| 2081 | + }, | |
| 2082 | + cometapiClaude35HaikuLatest: { | |
| 2083 | + title: "Claude 3.5 Haiku Latest", | |
| 2084 | + description: | |
| 2085 | + "Claude 3.5 Haiku Latest via CometAPI - fast and efficient model from Anthropic.", | |
| 2086 | + params: { | |
| 2087 | + model: "claude-3-5-haiku-latest", | |
| 2088 | + contextLength: 200_000, | |
| 2089 | + title: "Claude 3.5 Haiku Latest", | |
| 2090 | + apiKey: "", | |
| 2091 | + }, | |
| 2092 | + providerOptions: ["cometapi"], | |
| 2093 | + icon: "cometapi.png", | |
| 2094 | + isOpenSource: false, | |
| 2095 | + }, | |
| 2096 | + | |
| 2097 | + // Gemini series models via CometAPI | |
| 2098 | + cometapiGemini25Pro: { | |
| 2099 | + title: "Gemini 2.5 Pro", | |
| 2100 | + description: | |
| 2101 | + "Gemini 2.5 Pro via CometAPI - Google's advanced multimodal model with enhanced capabilities.", | |
| 2102 | + params: { | |
| 2103 | + model: "gemini-2.5-pro", | |
| 2104 | + contextLength: 1_000_000, | |
| 2105 | + title: "Gemini 2.5 Pro", | |
| 2106 | + apiKey: "", | |
| 2107 | + }, | |
| 2108 | + providerOptions: ["cometapi"], | |
| 2109 | + icon: "cometapi.png", | |
| 2110 | + isOpenSource: false, | |
| 2111 | + }, | |
| 2112 | + cometapiGemini25Flash: { | |
| 2113 | + title: "Gemini 2.5 Flash", | |
| 2114 | + description: | |
| 2115 | + "Gemini 2.5 Flash via CometAPI - optimized for speed and efficiency.", | |
| 2116 | + params: { | |
| 2117 | + model: "gemini-2.5-flash", | |
| 2118 | + contextLength: 1_000_000, | |
| 2119 | + title: "Gemini 2.5 Flash", | |
| 2120 | + apiKey: "", | |
| 2121 | + }, | |
| 2122 | + providerOptions: ["cometapi"], | |
| 2123 | + icon: "cometapi.png", | |
| 2124 | + isOpenSource: false, | |
| 2125 | + }, | |
| 2126 | + cometapiGemini25FlashLite: { | |
| 2127 | + title: "Gemini 2.5 Flash Lite", | |
| 2128 | + description: | |
| 2129 | + "Gemini 2.5 Flash Lite via CometAPI - lightweight version for faster responses.", | |
| 2130 | + params: { | |
| 2131 | + model: "gemini-2.5-flash-lite", | |
| 2132 | + contextLength: 8_000, | |
| 2133 | + title: "Gemini 2.5 Flash Lite", | |
| 2134 | + apiKey: "", | |
| 2135 | + }, | |
| 2136 | + providerOptions: ["cometapi"], | |
| 2137 | + icon: "cometapi.png", | |
| 2138 | + isOpenSource: false, | |
| 2139 | + }, | |
| 2140 | + cometapiGemini20Flash: { | |
| 2141 | + title: "Gemini 2.0 Flash", | |
| 2142 | + description: | |
| 2143 | + "Gemini 2.0 Flash via CometAPI - Google's powerful workhorse model with low latency.", | |
| 2144 | + params: { | |
| 2145 | + model: "gemini-2.0-flash", | |
| 2146 | + contextLength: 32_000, | |
| 2147 | + title: "Gemini 2.0 Flash", | |
| 2148 | + apiKey: "", | |
| 2149 | + }, | |
| 2150 | + providerOptions: ["cometapi"], | |
| 2151 | + icon: "cometapi.png", | |
| 2152 | + isOpenSource: false, | |
| 2153 | + }, | |
| 2154 | + | |
| 2155 | + // Grok series models via CometAPI | |
| 2156 | + cometapiGrok40709: { | |
| 2157 | + title: "Grok 4", | |
| 2158 | + description: | |
| 2159 | + "Grok 4 via CometAPI - xAI's advanced model with real-time information access.", | |
| 2160 | + params: { | |
| 2161 | + model: "grok-4-0709", | |
| 2162 | + contextLength: 256_000, | |
| 2163 | + title: "Grok 4", | |
| 2164 | + apiKey: "", | |
| 2165 | + }, | |
| 2166 | + providerOptions: ["cometapi"], | |
| 2167 | + icon: "cometapi.png", | |
| 2168 | + isOpenSource: false, | |
| 2169 | + }, | |
| 2170 | + cometapiGrok3: { | |
| 2171 | + title: "Grok 3", | |
| 2172 | + description: "Grok 3 via CometAPI - powerful reasoning model from xAI.", | |
| 2173 | + params: { | |
| 2174 | + model: "grok-3", | |
| 2175 | + contextLength: 128_000, | |
| 2176 | + title: "Grok 3", | |
| 2177 | + apiKey: "", | |
| 2178 | + }, | |
| 2179 | + providerOptions: ["cometapi"], | |
| 2180 | + icon: "cometapi.png", | |
| 2181 | + isOpenSource: false, | |
| 2182 | + }, | |
| 2183 | + cometapiGrok3Mini: { | |
| 2184 | + title: "Grok 3 Mini", | |
| 2185 | + description: "Grok 3 Mini via CometAPI - efficient version of Grok 3.", | |
| 2186 | + params: { | |
| 2187 | + model: "grok-3-mini", | |
| 2188 | + contextLength: 128_000, | |
| 2189 | + title: "Grok 3 Mini", | |
| 2190 | + apiKey: "", | |
| 2191 | + }, | |
| 2192 | + providerOptions: ["cometapi"], | |
| 2193 | + icon: "cometapi.png", | |
| 2194 | + isOpenSource: false, | |
| 2195 | + }, | |
| 2196 | + | |
| 2197 | + // DeepSeek series models via CometAPI (additional) | |
| 2198 | + cometapiDeepseekV31: { | |
| 2199 | + title: "DeepSeek V3.1", | |
| 2200 | + description: | |
| 2201 | + "DeepSeek V3.1 via CometAPI - enhanced version with improved performance.", | |
| 2202 | + params: { | |
| 2203 | + model: "deepseek-v3.1", | |
| 2204 | + contextLength: 128_000, | |
| 2205 | + title: "DeepSeek V3.1", | |
| 2206 | + apiKey: "", | |
| 2207 | + }, | |
| 2208 | + providerOptions: ["cometapi"], | |
| 2209 | + icon: "cometapi.png", | |
| 2210 | + isOpenSource: false, | |
| 2211 | + }, | |
| 2212 | + cometapiDeepseekR10528: { | |
| 2213 | + title: "DeepSeek R1", | |
| 2214 | + description: | |
| 2215 | + "DeepSeek R1 via CometAPI - reasoning model with enhanced problem-solving capabilities.", | |
| 2216 | + params: { | |
| 2217 | + model: "deepseek-r1-0528", | |
| 2218 | + contextLength: 64_000, | |
| 2219 | + title: "DeepSeek R1", | |
| 2220 | + apiKey: "", | |
| 2221 | + }, | |
| 2222 | + providerOptions: ["cometapi"], | |
| 2223 | + icon: "cometapi.png", | |
| 2224 | + isOpenSource: false, | |
| 2225 | + }, | |
| 2226 | + cometapiDeepseekChat: { | |
| 2227 | + title: "DeepSeek Chat", | |
| 2228 | + description: | |
| 2229 | + "DeepSeek Chat via CometAPI - optimized for conversational AI tasks.", | |
| 2230 | + params: { | |
| 2231 | + model: "deepseek-chat", | |
| 2232 | + contextLength: 64_000, | |
| 2233 | + title: "DeepSeek Chat", | |
| 2234 | + apiKey: "", | |
| 2235 | + }, | |
| 2236 | + providerOptions: ["cometapi"], | |
| 2237 | + icon: "cometapi.png", | |
| 2238 | + isOpenSource: false, | |
| 2239 | + }, | |
| 2240 | + cometapiDeepseekReasoner: { | |
| 2241 | + title: "DeepSeek Reasoner", | |
| 2242 | + description: | |
| 2243 | + "DeepSeek Reasoner via CometAPI - specialized model for complex reasoning tasks.", | |
| 2244 | + params: { | |
| 2245 | + model: "deepseek-reasoner", | |
| 2246 | + contextLength: 64_000, | |
| 2247 | + title: "DeepSeek Reasoner", | |
| 2248 | + apiKey: "", | |
| 2249 | + }, | |
| 2250 | + providerOptions: ["cometapi"], | |
| 2251 | + icon: "cometapi.png", | |
| 2252 | + isOpenSource: false, | |
| 2253 | + }, | |
| 2254 | + | |
| 2255 | + // Qwen series models via CometAPI | |
| 2256 | + cometapiQwen330BA3B: { | |
| 2257 | + title: "Qwen 3 30B A3B", | |
| 2258 | + description: | |
| 2259 | + "Qwen 3 30B A3B via CometAPI - Alibaba's advanced language model with 30B parameters.", | |
| 2260 | + params: { | |
| 2261 | + model: "qwen3-30b-a3b", | |
| 2262 | + contextLength: 128_000, | |
| 2263 | + title: "Qwen 3 30B A3B", | |
| 2264 | + apiKey: "", | |
| 2265 | + }, | |
| 2266 | + providerOptions: ["cometapi"], | |
| 2267 | + icon: "cometapi.png", | |
| 2268 | + isOpenSource: false, | |
| 2269 | + }, | |
| 2270 | + cometapiQwen3CoderPlus: { | |
| 2271 | + title: "Qwen 3 Coder Plus", | |
| 2272 | + description: | |
| 2273 | + "Qwen 3 Coder Plus via CometAPI - specialized coding model from Alibaba.", | |
| 2274 | + params: { | |
| 2275 | + model: "qwen3-coder-plus-2025-07-22", | |
| 2276 | + contextLength: 262_000, | |
| 2277 | + title: "Qwen 3 Coder Plus", | |
| 2278 | + apiKey: "", | |
| 2279 | + }, | |
| 2280 | + providerOptions: ["cometapi"], | |
| 2281 | + icon: "cometapi.png", | |
| 2282 | + isOpenSource: false, | |
| 2283 | + }, | |
| 1839 | 2284 | }; |
| @@ -49,6 +49,65 @@ | ||
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | 51 | export const providers: Partial<Record<string, ProviderInfo>> = { |
| 52 | + cometapi: { | |
| 53 | + title: "CometAPI", | |
| 54 | + provider: "cometapi", | |
| 55 | + description: "500+ AI Model API,All In One API. Just In CometAPI", | |
| 56 | + longDescription: | |
| 57 | + "Unified Access to Leading AI Models, see [here](https://www.cometapi.com/?utm_source=continue&utm_medium=integration&utm_campaign=cometapi_integration&utm_content=continue_plugin) for more details.", | |
| 58 | + icon: "cometapi.png", | |
| 59 | + tags: [ModelProviderTags.RequiresApiKey], | |
| 60 | + collectInputFor: [ | |
| 61 | + { | |
| 62 | + inputType: "text", | |
| 63 | + key: "apiKey", | |
| 64 | + label: "API Key", | |
| 65 | + placeholder: "Enter your CometAPI key", | |
| 66 | + required: true, | |
| 67 | + }, | |
| 68 | + ...completionParamsInputsConfigs, | |
| 69 | + ], | |
| 70 | + packages: [ | |
| 71 | + // GPT, OpenAI family | |
| 72 | + models.cometapiGpt5ChatLatest, | |
| 73 | + models.cometapiGpt5Mini, | |
| 74 | + models.cometapiGpt5, | |
| 75 | + models.cometapiChatgpt4oLatest, | |
| 76 | + models.cometapiGpt41, | |
| 77 | + models.cometapiO4Mini, | |
| 78 | + models.cometapiO3Pro, | |
| 79 | + // Anthropic Claude family | |
| 80 | + models.cometapiClaudeOpus41, | |
| 81 | + models.cometapiClaudeOpus41Thinking, | |
| 82 | + models.cometapiClaudeSonnet4, | |
| 83 | + models.cometapiClaudeSonnet4Thinking, | |
| 84 | + models.cometapiClaude37SonnetLatest, | |
| 85 | + models.cometapiClaude35HaikuLatest, | |
| 86 | + // Google Gemini family | |
| 87 | + models.cometapiGemini25Pro, | |
| 88 | + models.cometapiGemini25Flash, | |
| 89 | + models.cometapiGemini25FlashLite, | |
| 90 | + models.cometapiGemini20Flash, | |
| 91 | + // xAI Grok family | |
| 92 | + models.cometapiGrok40709, | |
| 93 | + models.cometapiGrok3, | |
| 94 | + models.cometapiGrok3Mini, | |
| 95 | + // Deepseek family | |
| 96 | + models.cometapiDeepseekV31, | |
| 97 | + models.cometapiDeepseekR10528, | |
| 98 | + models.cometapiDeepseekChat, | |
| 99 | + models.cometapiDeepseekReasoner, | |
| 100 | + // Qwen family | |
| 101 | + models.cometapiQwen330BA3B, | |
| 102 | + models.cometapiQwen3CoderPlus, | |
| 103 | + //TODO: Need to wait for the improvement after the upgrade of the cometapi model list interface | |
| 104 | + // { | |
| 105 | + // ...models.AUTODETECT, | |
| 106 | + // params: { ...models.AUTODETECT.params, title: "CometAPI" }, | |
| 107 | + // }, | |
| 108 | + ], | |
| 109 | + apiKeyUrl: "https://api.cometapi.com/console/token", | |
| 110 | + }, | |
| 52 | 111 | openai: { |
| 53 | 112 | title: "OpenAI", |
| 54 | 113 | provider: "openai", |
| @@ -563,7 +622,14 @@ | ||
| 563 | 622 | required: true, |
| 564 | 623 | }, |
| 565 | 624 | ], |
| 566 | - packages: [models.grokBeta], | |
| 625 | + packages: [ | |
| 626 | + models.grokCodeFast1, | |
| 627 | + models.grok4FastReasoning, | |
| 628 | + models.grok4FastNonReasoning, | |
| 629 | + models.grok4, | |
| 630 | + models.grok3, | |
| 631 | + models.grok3Mini, | |
| 632 | + ], | |
| 567 | 633 | apiKeyUrl: "https://console.x.ai/", |
| 568 | 634 | }, |
| 569 | 635 | lemonade: { |
| @@ -45,7 +45,7 @@ | ||
| 45 | 45 | case "chat": |
| 46 | 46 | return "All tools disabled in Chat, switch to Plan or Agent mode to use tools"; |
| 47 | 47 | case "plan": |
| 48 | - return "Read-only/MCP tools available in Plan mode"; | |
| 48 | + return "Read-only tools available in Plan mode"; | |
| 49 | 49 | default: |
| 50 | 50 | return ""; |
| 51 | 51 | } |
| @@ -91,7 +91,7 @@ | ||
| 91 | 91 | <span> |
| 92 | 92 | Used in Chat, Plan, Agent mode ( |
| 93 | 93 | <a |
| 94 | - href="https://docs.continue.dev/features/chat/quick-start hover:text-inherit" | |
| 94 | + href="https://docs.continue.dev/features/chat/quick-start" | |
| 95 | 95 | target="_blank" |
| 96 | 96 | rel="noopener noreferrer" |
| 97 | 97 | className="text-inherit underline hover:brightness-125" |
| @@ -4,16 +4,27 @@ | ||
| 4 | 4 | ChevronDownIcon, |
| 5 | 5 | CircleStackIcon, |
| 6 | 6 | CommandLineIcon, |
| 7 | + EllipsisVerticalIcon, | |
| 7 | 8 | GlobeAltIcon, |
| 9 | + PlayCircleIcon, | |
| 10 | + StopCircleIcon, | |
| 8 | 11 | UserCircleIcon, |
| 9 | 12 | WrenchScrewdriverIcon, |
| 10 | 13 | } from "@heroicons/react/24/outline"; |
| 11 | -import { MCPServerStatus } from "core"; | |
| 12 | -import { useContext, useMemo, useState } from "react"; | |
| 14 | +import { MCPConnectionStatus, MCPServerStatus } from "core"; | |
| 15 | +import { useContext, useEffect, useMemo, useState } from "react"; | |
| 13 | 16 | import Alert from "../../../components/gui/Alert"; |
| 14 | 17 | import { ToolTip } from "../../../components/gui/Tooltip"; |
| 15 | 18 | import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton"; |
| 16 | -import { Button, Card, EmptyState } from "../../../components/ui"; | |
| 19 | +import { | |
| 20 | + Button, | |
| 21 | + Card, | |
| 22 | + EmptyState, | |
| 23 | + Listbox, | |
| 24 | + ListboxButton, | |
| 25 | + ListboxOption, | |
| 26 | + ListboxOptions, | |
| 27 | +} from "../../../components/ui"; | |
| 17 | 28 | import { useAuth } from "../../../context/Auth"; |
| 18 | 29 | import { IdeMessengerContext } from "../../../context/IdeMessenger"; |
| 19 | 30 | import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; |
| @@ -27,14 +38,32 @@ | ||
| 27 | 38 | serverFromYaml?: NonNullable<ConfigYaml["mcpServers"]>[number]; |
| 28 | 39 | } |
| 29 | 40 | |
| 41 | +const ServerStatusTooltip: Record<MCPConnectionStatus, string> = { | |
| 42 | + connected: "Active", | |
| 43 | + connecting: "Connecting", | |
| 44 | + "not-connected": "Inactive", | |
| 45 | + authenticating: "Authenticating", | |
| 46 | + error: "Error", | |
| 47 | +}; | |
| 48 | + | |
| 49 | +const ServerStatusColor: Record<MCPConnectionStatus, string> = { | |
| 50 | + connected: "bg-success", | |
| 51 | + connecting: "bg-warning", | |
| 52 | + "not-connected": "bg-description-muted", | |
| 53 | + authenticating: "bg-warning", | |
| 54 | + error: "bg-error", | |
| 55 | +}; | |
| 56 | + | |
| 30 | 57 | function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { |
| 31 | 58 | const [expandedSections, setExpandedSections] = useState<{ |
| 32 | 59 | [key: string]: boolean; |
| 33 | 60 | }>({}); |
| 61 | + const [disconnectedMCPServers, setDisconnectedMCPServers] = useState< | |
| 62 | + string[] | |
| 63 | + >([]); | |
| 34 | 64 | const ideMessenger = useContext(IdeMessengerContext); |
| 35 | 65 | const config = useAppSelector((store) => store.config.config); |
| 36 | 66 | const dispatch = useAppDispatch(); |
| 37 | - | |
| 38 | 67 | const updateMCPServerStatus = (status: MCPServerStatus["status"]) => { |
| 39 | 68 | // optimistic config update |
| 40 | 69 | dispatch( |
| @@ -64,9 +93,35 @@ | ||
| 64 | 93 | |
| 65 | 94 | const onRefresh = async () => { |
| 66 | 95 | updateMCPServerStatus("connecting"); |
| 67 | - ideMessenger.post("mcp/reloadServer", { | |
| 96 | + await ideMessenger.request("mcp/reloadServer", { | |
| 97 | + id: server.id, | |
| 98 | + }); | |
| 99 | + await fetchDisconectedMCPServers(); | |
| 100 | + }; | |
| 101 | + | |
| 102 | + const onDisconnect = async () => { | |
| 103 | + updateMCPServerStatus("not-connected"); | |
| 104 | + setDisconnectedMCPServers((prev) => [...prev, server.id]); | |
| 105 | + dispatch( | |
| 106 | + updateConfig({ | |
| 107 | + ...config, | |
| 108 | + tools: config.tools.filter((tool) => tool.group !== server.id), | |
| 109 | + }), | |
| 110 | + ); | |
| 111 | + await ideMessenger.request("mcp/disconnectServer", { | |
| 68 | 112 | id: server.id, |
| 69 | 113 | }); |
| 114 | + await fetchDisconectedMCPServers(); | |
| 115 | + }; | |
| 116 | + | |
| 117 | + const fetchDisconectedMCPServers = async () => { | |
| 118 | + const disconnectedServersData = await ideMessenger.request( | |
| 119 | + "mcp/getDisconnectedServers", | |
| 120 | + undefined, | |
| 121 | + ); | |
| 122 | + if (disconnectedServersData.status === "success") { | |
| 123 | + setDisconnectedMCPServers(disconnectedServersData.content); | |
| 124 | + } | |
| 70 | 125 | }; |
| 71 | 126 | |
| 72 | 127 | const toggleSection = (section: string) => { |
| @@ -76,6 +131,8 @@ | ||
| 76 | 131 | })); |
| 77 | 132 | }; |
| 78 | 133 | |
| 134 | + useEffect(() => void fetchDisconectedMCPServers(), []); | |
| 135 | + | |
| 79 | 136 | const ResourceRow = ({ |
| 80 | 137 | title, |
| 81 | 138 | items, |
| @@ -83,7 +140,11 @@ | ||
| 83 | 140 | sectionKey, |
| 84 | 141 | }: { |
| 85 | 142 | title: string; |
| 86 | - items: any[]; | |
| 143 | + items: | |
| 144 | + | MCPServerStatus["tools"] | |
| 145 | + | MCPServerStatus["prompts"] | |
| 146 | + | MCPServerStatus["resources"] | |
| 147 | + | MCPServerStatus["resourceTemplates"]; | |
| 87 | 148 | icon: React.ReactNode; |
| 88 | 149 | sectionKey: string; |
| 89 | 150 | }) => { |
| @@ -146,23 +207,17 @@ | ||
| 146 | 207 | <div className="flex-1"> |
| 147 | 208 | <div className="flex items-center gap-3"> |
| 148 | 209 | <h3 className="my-0 text-sm font-medium">{server.name}</h3> |
| 149 | - <div | |
| 150 | - className={`h-2 w-2 flex-shrink-0 rounded-full ${ | |
| 151 | - server.status === "connected" | |
| 152 | - ? "bg-success" | |
| 153 | - : server.status === "connecting" | |
| 154 | - ? "bg-warning" | |
| 155 | - : server.status === "not-connected" | |
| 156 | - ? "bg-description-muted" | |
| 157 | - : "bg-error" | |
| 158 | - }`} | |
| 159 | - /> | |
| 210 | + <ToolTip content={ServerStatusTooltip[server.status] ?? "Error"}> | |
| 211 | + <div | |
| 212 | + className={`h-2 w-2 flex-shrink-0 rounded-full ${ServerStatusColor[server.status] ?? "bg-error"}`} | |
| 213 | + /> | |
| 214 | + </ToolTip> | |
| 160 | 215 | </div> |
| 161 | 216 | </div> |
| 162 | 217 | </div> |
| 163 | 218 | |
| 164 | 219 | <div className="-mr-2.5 flex items-center gap-1"> |
| 165 | - {server.isProtectedResource && ( | |
| 220 | + {server.isProtectedResource && server.status !== "connected" && ( | |
| 166 | 221 | <ToolTip |
| 167 | 222 | content={ |
| 168 | 223 | server.status === "error" |
| @@ -182,7 +237,7 @@ | ||
| 182 | 237 | } |
| 183 | 238 | variant="ghost" |
| 184 | 239 | size="sm" |
| 185 | - className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0" | |
| 240 | + className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0 pt-0.5" | |
| 186 | 241 | disabled={server.status === "authenticating"} |
| 187 | 242 | > |
| 188 | 243 | {server.status === "authenticating" ? ( |
| @@ -193,27 +248,59 @@ | ||
| 193 | 248 | </Button> |
| 194 | 249 | </ToolTip> |
| 195 | 250 | )} |
| 196 | - | |
| 197 | - <ToolTip content="Edit server configuration"> | |
| 198 | - <div> | |
| 199 | - <EditBlockButton | |
| 200 | - blockType={"mcpServers"} | |
| 201 | - block={serverFromYaml} | |
| 202 | - sourceFile={server.sourceFile} | |
| 203 | - /> | |
| 204 | - </div> | |
| 205 | - </ToolTip> | |
| 206 | - | |
| 207 | - <ToolTip content="Refresh server"> | |
| 208 | - <Button | |
| 209 | - onClick={onRefresh} | |
| 210 | - variant="ghost" | |
| 211 | - size="sm" | |
| 212 | - className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0" | |
| 213 | - > | |
| 214 | - <ArrowPathIcon className="h-4 w-4 flex-shrink-0" /> | |
| 215 | - </Button> | |
| 216 | - </ToolTip> | |
| 251 | + <Listbox> | |
| 252 | + <ListboxButton> | |
| 253 | + <EllipsisVerticalIcon className="h-4 w-4 flex-shrink-0" /> | |
| 254 | + </ListboxButton> | |
| 255 | + <ListboxOptions className="min-w-fit" anchor="bottom end"> | |
| 256 | + {server.isProtectedResource && server.status === "connected" && ( | |
| 257 | + <ListboxOption | |
| 258 | + value="remove auth" | |
| 259 | + onClick={onRemoveAuth} | |
| 260 | + className="justify-start gap-x-1.5" | |
| 261 | + > | |
| 262 | + <UserCircleIcon className="h-4 w-4 flex-shrink-0" /> Logout | |
| 263 | + </ListboxOption> | |
| 264 | + )} | |
| 265 | + | |
| 266 | + <ListboxOption | |
| 267 | + value="edit mcp" | |
| 268 | + className="justify-start gap-x-1.5" | |
| 269 | + > | |
| 270 | + <EditBlockButton | |
| 271 | + blockType={"mcpServers"} | |
| 272 | + block={serverFromYaml} | |
| 273 | + sourceFile={server.sourceFile} | |
| 274 | + className="h-3.5 w-3.5 text-inherit" | |
| 275 | + /> | |
| 276 | + Edit | |
| 277 | + </ListboxOption> | |
| 278 | + | |
| 279 | + {!disconnectedMCPServers.includes(server.name) && ( | |
| 280 | + <ListboxOption | |
| 281 | + value="disconnect" | |
| 282 | + onClick={onDisconnect} | |
| 283 | + className="justify-start gap-x-1.5" | |
| 284 | + > | |
| 285 | + <StopCircleIcon className="h-4 w-4 flex-shrink-0" />{" "} | |
| 286 | + Disconnect | |
| 287 | + </ListboxOption> | |
| 288 | + )} | |
| 289 | + | |
| 290 | + <ListboxOption | |
| 291 | + value="reconnect" | |
| 292 | + onClick={onRefresh} | |
| 293 | + className="justify-start gap-x-1.5" | |
| 294 | + > | |
| 295 | + {disconnectedMCPServers.includes(server.name) ? ( | |
| 296 | + <PlayCircleIcon className="h-4 w-4 flex-shrink-0" /> | |
| 297 | + ) : ( | |
| 298 | + <ArrowPathIcon className="h-4 w-4 flex-shrink-0" /> | |
| 299 | + )} | |
| 300 | + Reload | |
| 301 | + </ListboxOption> | |
| 302 | + </ListboxOptions> | |
| 303 | + </Listbox> | |
| 217 | 304 | </div> |
| 218 | 305 | </div> |
| 219 | 306 | |
| @@ -294,6 +381,7 @@ | ||
| 294 | 381 | |
| 295 | 382 | function McpSubsection() { |
| 296 | 383 | const currentOrg = useAppSelector(selectCurrentOrg); |
| 384 | + const mode = useAppSelector((store) => store.session.mode); | |
| 297 | 385 | const servers = useAppSelector( |
| 298 | 386 | (store) => store.config.config.mcpServerStatuses, |
| 299 | 387 | ); |
| @@ -317,7 +405,7 @@ | ||
| 317 | 405 | .map((server) => [server.name, server]) ?? [], |
| 318 | 406 | ); |
| 319 | 407 | |
| 320 | - return (servers ?? []).map((doc) => ({ | |
| 408 | + return (servers ?? []).map((doc: MCPServerStatus) => ({ | |
| 321 | 409 | block: doc, |
| 322 | 410 | blockFromYaml: yamlServersByName.get(doc.name), |
| 323 | 411 | })); |
| @@ -348,6 +436,13 @@ | ||
| 348 | 436 | <Card> |
| 349 | 437 | <EmptyState message="MCP servers are disabled in your organization" /> |
| 350 | 438 | </Card> |
| 439 | + ) : mode === "chat" ? ( | |
| 440 | + <Alert type="info" size="sm"> | |
| 441 | + <span className="text-2xs italic"> | |
| 442 | + All MCPs are disabled in Chat, switch to Plan or Agent mode to use | |
| 443 | + MCPs | |
| 444 | + </span> | |
| 445 | + </Alert> | |
| 351 | 446 | ) : mergedBlocks.length > 0 ? ( |
| 352 | 447 | mergedBlocks.map(({ block, blockFromYaml }, index) => ( |
| 353 | 448 | <div key={block.id}> |
| @@ -290,10 +290,7 @@ | ||
| 290 | 290 | <GhostButton |
| 291 | 291 | className="flex flex-row items-center gap-2 rounded px-3 py-1.5" |
| 292 | 292 | onClick={() => { |
| 293 | - ideMessenger.post("controlPlane/openUrl", { | |
| 294 | - path: GITHUB_LINK, | |
| 295 | - orgSlug: undefined, | |
| 296 | - }); | |
| 293 | + ideMessenger.post("openUrl", GITHUB_LINK); | |
| 297 | 294 | }} |
| 298 | 295 | > |
| 299 | 296 | <GithubIcon className="h-5 w-5" /> |
| @@ -302,10 +299,7 @@ | ||
| 302 | 299 | <GhostButton |
| 303 | 300 | className="flex flex-row items-center gap-2 rounded px-3 py-1.5" |
| 304 | 301 | onClick={() => { |
| 305 | - ideMessenger.post("controlPlane/openUrl", { | |
| 306 | - path: DISCORD_LINK, | |
| 307 | - orgSlug: undefined, | |
| 308 | - }); | |
| 302 | + ideMessenger.post("openUrl", DISCORD_LINK); | |
| 309 | 303 | }} |
| 310 | 304 | > |
| 311 | 305 | <DiscordIcon className="h-5 w-5" /> |
| @@ -185,24 +185,22 @@ | ||
| 185 | 185 | const statusIcon = useMemo(() => { |
| 186 | 186 | const status = toolCallState?.status; |
| 187 | 187 | if (status) { |
| 188 | - if (status === "canceled" || status === "errored" || status === "done") { | |
| 189 | - return ( | |
| 190 | - <div | |
| 191 | - className={`mr-1 h-4 w-4 flex-shrink-0 ${toolCallState.output ? "cursor-pointer" : ""}`} | |
| 192 | - onClick={(e) => { | |
| 193 | - if (toolCallState.output) { | |
| 194 | - e.stopPropagation(); | |
| 195 | - ideMessenger.post("showVirtualFile", { | |
| 196 | - name: "Edit output", | |
| 197 | - content: renderContextItems(toolCallState.output), | |
| 198 | - }); | |
| 199 | - } | |
| 200 | - }} | |
| 201 | - > | |
| 202 | - {getStatusIcon(toolCallState.status)} | |
| 203 | - </div> | |
| 204 | - ); | |
| 205 | - } | |
| 188 | + return ( | |
| 189 | + <div | |
| 190 | + className={`mr-1 h-4 w-4 flex-shrink-0 ${toolCallState.output ? "cursor-pointer" : ""}`} | |
| 191 | + onClick={(e) => { | |
| 192 | + if (toolCallState.output) { | |
| 193 | + e.stopPropagation(); | |
| 194 | + ideMessenger.post("showVirtualFile", { | |
| 195 | + name: "Edit output", | |
| 196 | + content: renderContextItems(toolCallState.output), | |
| 197 | + }); | |
| 198 | + } | |
| 199 | + }} | |
| 200 | + > | |
| 201 | + {getStatusIcon(status)} | |
| 202 | + </div> | |
| 203 | + ); | |
| 206 | 204 | } |
| 207 | 205 | }, [toolCallState?.status, toolCallState?.output]); |
| 208 | 206 |
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | import { IdeMessengerContext } from "../../../context/IdeMessenger"; |
| 8 | 8 | import { ToggleWithIcon } from "./ToggleWithIcon"; |
| 9 | 9 | import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; |
| 10 | +import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon"; | |
| 10 | 11 | import { toolCallStateToContextItems } from "./utils"; |
| 11 | 12 | |
| 12 | 13 | interface SimpleToolCallUIProps { |
| @@ -61,6 +62,10 @@ | ||
| 61 | 62 | /> |
| 62 | 63 | <ToolCallStatusMessage tool={tool} toolCallState={toolCallState} /> |
| 63 | 64 | </div> |
| 65 | + | |
| 66 | + {!!toolCallState.output?.length && ( | |
| 67 | + <ToolTruncateHistoryIcon historyIndex={historyIndex} /> | |
| 68 | + )} | |
| 64 | 69 | </div> |
| 65 | 70 | |
| 66 | 71 | {isToggleable && ( |
| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | import { Tool, ToolCallState } from "core"; |
| 2 | +import { useContext, useMemo } from "react"; | |
| 3 | +import { openContextItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek"; | |
| 4 | +import { IdeMessengerContext } from "../../../context/IdeMessenger"; | |
| 2 | 5 | import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; |
| 6 | +import { toolCallStateToContextItems } from "./utils"; | |
| 7 | +import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon"; | |
| 3 | 8 | |
| 4 | 9 | interface ToolCallDisplayProps { |
| 5 | 10 | children: React.ReactNode; |
| @@ -16,11 +21,29 @@ | ||
| 16 | 21 | icon, |
| 17 | 22 | historyIndex, |
| 18 | 23 | }: ToolCallDisplayProps) { |
| 24 | + const ideMessenger = useContext(IdeMessengerContext); | |
| 25 | + const shownContextItems = useMemo(() => { | |
| 26 | + const contextItems = toolCallStateToContextItems(toolCallState); | |
| 27 | + return contextItems.filter((item) => !item.hidden); | |
| 28 | + }, [toolCallState]); | |
| 29 | + | |
| 30 | + const isClickable = shownContextItems.length > 0; | |
| 31 | + | |
| 32 | + function handleClick() { | |
| 33 | + if (shownContextItems.length > 0) { | |
| 34 | + openContextItem(shownContextItems[0], ideMessenger); | |
| 35 | + } | |
| 36 | + } | |
| 19 | 37 | return ( |
| 20 | 38 | <div className="flex flex-col justify-center px-4"> |
| 21 | 39 | <div className="mb-2 flex flex-col"> |
| 22 | - <div className="flex flex-row items-center justify-between gap-1.5"> | |
| 23 | - <div className="flex min-w-0 flex-row items-center gap-2"> | |
| 40 | + <div className="flex flex-row items-start justify-between gap-1.5"> | |
| 41 | + <div | |
| 42 | + className={`flex min-w-0 flex-row items-center gap-2 transition-colors duration-200 ease-in-out ${ | |
| 43 | + isClickable ? "cursor-pointer hover:brightness-125" : "" | |
| 44 | + }`} | |
| 45 | + onClick={isClickable ? handleClick : undefined} | |
| 46 | + > | |
| 24 | 47 | <div className="mt-[1px] h-4 w-4 flex-shrink-0 font-semibold"> |
| 25 | 48 | {icon} |
| 26 | 49 | </div> |
| @@ -29,6 +52,9 @@ | ||
| 29 | 52 | )} |
| 30 | 53 | <ToolCallStatusMessage tool={tool} toolCallState={toolCallState} /> |
| 31 | 54 | </div> |
| 55 | + {!!toolCallState.output?.length && ( | |
| 56 | + <ToolTruncateHistoryIcon historyIndex={historyIndex} /> | |
| 57 | + )} | |
| 32 | 58 | </div> |
| 33 | 59 | </div> |
| 34 | 60 | <div>{children}</div> |
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | |
| 54 | 54 | return ( |
| 55 | 55 | <div |
| 56 | - className="text-description line-clamp-4 min-w-0 break-all" | |
| 56 | + className="text-description line-clamp-4 min-w-0 break-words" | |
| 57 | 57 | data-testid="tool-call-title" |
| 58 | 58 | > |
| 59 | 59 | {`Continue ${intro} ${message}`} |
| @@ -21,7 +21,8 @@ | ||
| 21 | 21 | const { mainEditor } = useMainEditor(); |
| 22 | 22 | |
| 23 | 23 | if (historyIndex === lastMessageIndex) { |
| 24 | - return null; | |
| 24 | + // filler so doesn't jump in | |
| 25 | + return <div className="h-3 w-3" />; | |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | return ( |
| @@ -9,6 +9,8 @@ | ||
| 9 | 9 | "@typescript-eslint/parser": "^7.8.0", |
| 10 | 10 | "concurrently": "^9.1.2", |
| 11 | 11 | "eslint-plugin-import": "^2.29.1", |
| 12 | + "husky": "^9.1.7", | |
| 13 | + "lint-staged": "^15.5.2", | |
| 12 | 14 | "prettier": "^3.3.3", |
| 13 | 15 | "prettier-plugin-tailwindcss": "^0.6.8", |
| 14 | 16 | "typescript": "^5.6.3" |
| @@ -385,6 +387,22 @@ | ||
| 385 | 387 | "url": "https://github.com/sponsors/epoberezkin" |
| 386 | 388 | } |
| 387 | 389 | }, |
| 390 | + "node_modules/ansi-escapes": { | |
| 391 | + "version": "7.1.1", | |
| 392 | + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.1.1.tgz", | |
| 393 | + "integrity": "sha512-Zhl0ErHcSRUaVfGUeUdDuLgpkEo8KIFjB4Y9uAc46ScOpdDiU1Dbyplh7qWJeJ/ZHpbyMSM26+X3BySgnIz40Q==", | |
| 394 | + "dev": true, | |
| 395 | + "license": "MIT", | |
| 396 | + "dependencies": { | |
| 397 | + "environment": "^1.0.0" | |
| 398 | + }, | |
| 399 | + "engines": { | |
| 400 | + "node": ">=18" | |
| 401 | + }, | |
| 402 | + "funding": { | |
| 403 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 404 | + } | |
| 405 | + }, | |
| 388 | 406 | "node_modules/ansi-regex": { |
| 389 | 407 | "version": "5.0.1", |
| 390 | 408 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", |
| @@ -698,6 +716,93 @@ | ||
| 698 | 716 | "node": ">=8" |
| 699 | 717 | } |
| 700 | 718 | }, |
| 719 | + "node_modules/cli-cursor": { | |
| 720 | + "version": "5.0.0", | |
| 721 | + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", | |
| 722 | + "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", | |
| 723 | + "dev": true, | |
| 724 | + "license": "MIT", | |
| 725 | + "dependencies": { | |
| 726 | + "restore-cursor": "^5.0.0" | |
| 727 | + }, | |
| 728 | + "engines": { | |
| 729 | + "node": ">=18" | |
| 730 | + }, | |
| 731 | + "funding": { | |
| 732 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 733 | + } | |
| 734 | + }, | |
| 735 | + "node_modules/cli-truncate": { | |
| 736 | + "version": "4.0.0", | |
| 737 | + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-4.0.0.tgz", | |
| 738 | + "integrity": "sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==", | |
| 739 | + "dev": true, | |
| 740 | + "license": "MIT", | |
| 741 | + "dependencies": { | |
| 742 | + "slice-ansi": "^5.0.0", | |
| 743 | + "string-width": "^7.0.0" | |
| 744 | + }, | |
| 745 | + "engines": { | |
| 746 | + "node": ">=18" | |
| 747 | + }, | |
| 748 | + "funding": { | |
| 749 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 750 | + } | |
| 751 | + }, | |
| 752 | + "node_modules/cli-truncate/node_modules/ansi-regex": { | |
| 753 | + "version": "6.2.2", | |
| 754 | + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", | |
| 755 | + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", | |
| 756 | + "dev": true, | |
| 757 | + "license": "MIT", | |
| 758 | + "engines": { | |
| 759 | + "node": ">=12" | |
| 760 | + }, | |
| 761 | + "funding": { | |
| 762 | + "url": "https://github.com/chalk/ansi-regex?sponsor=1" | |
| 763 | + } | |
| 764 | + }, | |
| 765 | + "node_modules/cli-truncate/node_modules/emoji-regex": { | |
| 766 | + "version": "10.5.0", | |
| 767 | + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", | |
| 768 | + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", | |
| 769 | + "dev": true, | |
| 770 | + "license": "MIT" | |
| 771 | + }, | |
| 772 | + "node_modules/cli-truncate/node_modules/string-width": { | |
| 773 | + "version": "7.2.0", | |
| 774 | + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", | |
| 775 | + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", | |
| 776 | + "dev": true, | |
| 777 | + "license": "MIT", | |
| 778 | + "dependencies": { | |
| 779 | + "emoji-regex": "^10.3.0", | |
| 780 | + "get-east-asian-width": "^1.0.0", | |
| 781 | + "strip-ansi": "^7.1.0" | |
| 782 | + }, | |
| 783 | + "engines": { | |
| 784 | + "node": ">=18" | |
| 785 | + }, | |
| 786 | + "funding": { | |
| 787 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 788 | + } | |
| 789 | + }, | |
| 790 | + "node_modules/cli-truncate/node_modules/strip-ansi": { | |
| 791 | + "version": "7.1.2", | |
| 792 | + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", | |
| 793 | + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", | |
| 794 | + "dev": true, | |
| 795 | + "license": "MIT", | |
| 796 | + "dependencies": { | |
| 797 | + "ansi-regex": "^6.0.1" | |
| 798 | + }, | |
| 799 | + "engines": { | |
| 800 | + "node": ">=12" | |
| 801 | + }, | |
| 802 | + "funding": { | |
| 803 | + "url": "https://github.com/chalk/strip-ansi?sponsor=1" | |
| 804 | + } | |
| 805 | + }, | |
| 701 | 806 | "node_modules/cliui": { |
| 702 | 807 | "version": "8.0.1", |
| 703 | 808 | "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", |
| @@ -733,6 +838,23 @@ | ||
| 733 | 838 | "dev": true, |
| 734 | 839 | "license": "MIT" |
| 735 | 840 | }, |
| 841 | + "node_modules/colorette": { | |
| 842 | + "version": "2.0.20", | |
| 843 | + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", | |
| 844 | + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", | |
| 845 | + "dev": true, | |
| 846 | + "license": "MIT" | |
| 847 | + }, | |
| 848 | + "node_modules/commander": { | |
| 849 | + "version": "13.1.0", | |
| 850 | + "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", | |
| 851 | + "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", | |
| 852 | + "dev": true, | |
| 853 | + "license": "MIT", | |
| 854 | + "engines": { | |
| 855 | + "node": ">=18" | |
| 856 | + } | |
| 857 | + }, | |
| 736 | 858 | "node_modules/concat-map": { |
| 737 | 859 | "version": "0.0.1", |
| 738 | 860 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", |
| @@ -772,7 +894,6 @@ | ||
| 772 | 894 | "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", |
| 773 | 895 | "dev": true, |
| 774 | 896 | "license": "MIT", |
| 775 | - "peer": true, | |
| 776 | 897 | "dependencies": { |
| 777 | 898 | "path-key": "^3.1.0", |
| 778 | 899 | "shebang-command": "^2.0.0", |
| @@ -947,6 +1068,19 @@ | ||
| 947 | 1068 | "dev": true, |
| 948 | 1069 | "license": "MIT" |
| 949 | 1070 | }, |
| 1071 | + "node_modules/environment": { | |
| 1072 | + "version": "1.1.0", | |
| 1073 | + "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", | |
| 1074 | + "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", | |
| 1075 | + "dev": true, | |
| 1076 | + "license": "MIT", | |
| 1077 | + "engines": { | |
| 1078 | + "node": ">=18" | |
| 1079 | + }, | |
| 1080 | + "funding": { | |
| 1081 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 1082 | + } | |
| 1083 | + }, | |
| 950 | 1084 | "node_modules/es-abstract": { |
| 951 | 1085 | "version": "1.24.0", |
| 952 | 1086 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.0.tgz", |
| @@ -1444,6 +1578,37 @@ | ||
| 1444 | 1578 | "node": ">=0.10.0" |
| 1445 | 1579 | } |
| 1446 | 1580 | }, |
| 1581 | + "node_modules/eventemitter3": { | |
| 1582 | + "version": "5.0.1", | |
| 1583 | + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", | |
| 1584 | + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", | |
| 1585 | + "dev": true, | |
| 1586 | + "license": "MIT" | |
| 1587 | + }, | |
| 1588 | + "node_modules/execa": { | |
| 1589 | + "version": "8.0.1", | |
| 1590 | + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", | |
| 1591 | + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", | |
| 1592 | + "dev": true, | |
| 1593 | + "license": "MIT", | |
| 1594 | + "dependencies": { | |
| 1595 | + "cross-spawn": "^7.0.3", | |
| 1596 | + "get-stream": "^8.0.1", | |
| 1597 | + "human-signals": "^5.0.0", | |
| 1598 | + "is-stream": "^3.0.0", | |
| 1599 | + "merge-stream": "^2.0.0", | |
| 1600 | + "npm-run-path": "^5.1.0", | |
| 1601 | + "onetime": "^6.0.0", | |
| 1602 | + "signal-exit": "^4.1.0", | |
| 1603 | + "strip-final-newline": "^3.0.0" | |
| 1604 | + }, | |
| 1605 | + "engines": { | |
| 1606 | + "node": ">=16.17" | |
| 1607 | + }, | |
| 1608 | + "funding": { | |
| 1609 | + "url": "https://github.com/sindresorhus/execa?sponsor=1" | |
| 1610 | + } | |
| 1611 | + }, | |
| 1447 | 1612 | "node_modules/fast-deep-equal": { |
| 1448 | 1613 | "version": "3.1.3", |
| 1449 | 1614 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", |
| @@ -1652,6 +1817,19 @@ | ||
| 1652 | 1817 | "node": "6.* || 8.* || >= 10.*" |
| 1653 | 1818 | } |
| 1654 | 1819 | }, |
| 1820 | + "node_modules/get-east-asian-width": { | |
| 1821 | + "version": "1.4.0", | |
| 1822 | + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.4.0.tgz", | |
| 1823 | + "integrity": "sha512-QZjmEOC+IT1uk6Rx0sX22V6uHWVwbdbxf1faPqJ1QhLdGgsRGCZoyaQBm/piRdJy/D2um6hM1UP7ZEeQ4EkP+Q==", | |
| 1824 | + "dev": true, | |
| 1825 | + "license": "MIT", | |
| 1826 | + "engines": { | |
| 1827 | + "node": ">=18" | |
| 1828 | + }, | |
| 1829 | + "funding": { | |
| 1830 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 1831 | + } | |
| 1832 | + }, | |
| 1655 | 1833 | "node_modules/get-intrinsic": { |
| 1656 | 1834 | "version": "1.3.0", |
| 1657 | 1835 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", |
| @@ -1691,6 +1869,19 @@ | ||
| 1691 | 1869 | "node": ">= 0.4" |
| 1692 | 1870 | } |
| 1693 | 1871 | }, |
| 1872 | + "node_modules/get-stream": { | |
| 1873 | + "version": "8.0.1", | |
| 1874 | + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", | |
| 1875 | + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", | |
| 1876 | + "dev": true, | |
| 1877 | + "license": "MIT", | |
| 1878 | + "engines": { | |
| 1879 | + "node": ">=16" | |
| 1880 | + }, | |
| 1881 | + "funding": { | |
| 1882 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 1883 | + } | |
| 1884 | + }, | |
| 1694 | 1885 | "node_modules/get-symbol-description": { |
| 1695 | 1886 | "version": "1.1.0", |
| 1696 | 1887 | "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz", |
| @@ -1942,6 +2133,32 @@ | ||
| 1942 | 2133 | "node": ">= 0.4" |
| 1943 | 2134 | } |
| 1944 | 2135 | }, |
| 2136 | + "node_modules/human-signals": { | |
| 2137 | + "version": "5.0.0", | |
| 2138 | + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", | |
| 2139 | + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", | |
| 2140 | + "dev": true, | |
| 2141 | + "license": "Apache-2.0", | |
| 2142 | + "engines": { | |
| 2143 | + "node": ">=16.17.0" | |
| 2144 | + } | |
| 2145 | + }, | |
| 2146 | + "node_modules/husky": { | |
| 2147 | + "version": "9.1.7", | |
| 2148 | + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", | |
| 2149 | + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", | |
| 2150 | + "dev": true, | |
| 2151 | + "license": "MIT", | |
| 2152 | + "bin": { | |
| 2153 | + "husky": "bin.js" | |
| 2154 | + }, | |
| 2155 | + "engines": { | |
| 2156 | + "node": ">=18" | |
| 2157 | + }, | |
| 2158 | + "funding": { | |
| 2159 | + "url": "https://github.com/sponsors/typicode" | |
| 2160 | + } | |
| 2161 | + }, | |
| 1945 | 2162 | "node_modules/ignore": { |
| 1946 | 2163 | "version": "5.3.2", |
| 1947 | 2164 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", |
| @@ -2332,6 +2549,19 @@ | ||
| 2332 | 2549 | "url": "https://github.com/sponsors/ljharb" |
| 2333 | 2550 | } |
| 2334 | 2551 | }, |
| 2552 | + "node_modules/is-stream": { | |
| 2553 | + "version": "3.0.0", | |
| 2554 | + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", | |
| 2555 | + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", | |
| 2556 | + "dev": true, | |
| 2557 | + "license": "MIT", | |
| 2558 | + "engines": { | |
| 2559 | + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" | |
| 2560 | + }, | |
| 2561 | + "funding": { | |
| 2562 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 2563 | + } | |
| 2564 | + }, | |
| 2335 | 2565 | "node_modules/is-string": { |
| 2336 | 2566 | "version": "1.1.1", |
| 2337 | 2567 | "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", |
| @@ -2441,8 +2671,7 @@ | ||
| 2441 | 2671 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", |
| 2442 | 2672 | "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", |
| 2443 | 2673 | "dev": true, |
| 2444 | - "license": "ISC", | |
| 2445 | - "peer": true | |
| 2674 | + "license": "ISC" | |
| 2446 | 2675 | }, |
| 2447 | 2676 | "node_modules/js-yaml": { |
| 2448 | 2677 | "version": "4.1.0", |
| @@ -2521,6 +2750,163 @@ | ||
| 2521 | 2750 | "node": ">= 0.8.0" |
| 2522 | 2751 | } |
| 2523 | 2752 | }, |
| 2753 | + "node_modules/lilconfig": { | |
| 2754 | + "version": "3.1.3", | |
| 2755 | + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", | |
| 2756 | + "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==", | |
| 2757 | + "dev": true, | |
| 2758 | + "license": "MIT", | |
| 2759 | + "engines": { | |
| 2760 | + "node": ">=14" | |
| 2761 | + }, | |
| 2762 | + "funding": { | |
| 2763 | + "url": "https://github.com/sponsors/antonk52" | |
| 2764 | + } | |
| 2765 | + }, | |
| 2766 | + "node_modules/lint-staged": { | |
| 2767 | + "version": "15.5.2", | |
| 2768 | + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.5.2.tgz", | |
| 2769 | + "integrity": "sha512-YUSOLq9VeRNAo/CTaVmhGDKG+LBtA8KF1X4K5+ykMSwWST1vDxJRB2kv2COgLb1fvpCo+A/y9A0G0znNVmdx4w==", | |
| 2770 | + "dev": true, | |
| 2771 | + "license": "MIT", | |
| 2772 | + "dependencies": { | |
| 2773 | + "chalk": "^5.4.1", | |
| 2774 | + "commander": "^13.1.0", | |
| 2775 | + "debug": "^4.4.0", | |
| 2776 | + "execa": "^8.0.1", | |
| 2777 | + "lilconfig": "^3.1.3", | |
| 2778 | + "listr2": "^8.2.5", | |
| 2779 | + "micromatch": "^4.0.8", | |
| 2780 | + "pidtree": "^0.6.0", | |
| 2781 | + "string-argv": "^0.3.2", | |
| 2782 | + "yaml": "^2.7.0" | |
| 2783 | + }, | |
| 2784 | + "bin": { | |
| 2785 | + "lint-staged": "bin/lint-staged.js" | |
| 2786 | + }, | |
| 2787 | + "engines": { | |
| 2788 | + "node": ">=18.12.0" | |
| 2789 | + }, | |
| 2790 | + "funding": { | |
| 2791 | + "url": "https://opencollective.com/lint-staged" | |
| 2792 | + } | |
| 2793 | + }, | |
| 2794 | + "node_modules/lint-staged/node_modules/chalk": { | |
| 2795 | + "version": "5.6.2", | |
| 2796 | + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", | |
| 2797 | + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", | |
| 2798 | + "dev": true, | |
| 2799 | + "license": "MIT", | |
| 2800 | + "engines": { | |
| 2801 | + "node": "^12.17.0 || ^14.13 || >=16.0.0" | |
| 2802 | + }, | |
| 2803 | + "funding": { | |
| 2804 | + "url": "https://github.com/chalk/chalk?sponsor=1" | |
| 2805 | + } | |
| 2806 | + }, | |
| 2807 | + "node_modules/listr2": { | |
| 2808 | + "version": "8.3.3", | |
| 2809 | + "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.3.3.tgz", | |
| 2810 | + "integrity": "sha512-LWzX2KsqcB1wqQ4AHgYb4RsDXauQiqhjLk+6hjbaeHG4zpjjVAB6wC/gz6X0l+Du1cN3pUB5ZlrvTbhGSNnUQQ==", | |
| 2811 | + "dev": true, | |
| 2812 | + "license": "MIT", | |
| 2813 | + "dependencies": { | |
| 2814 | + "cli-truncate": "^4.0.0", | |
| 2815 | + "colorette": "^2.0.20", | |
| 2816 | + "eventemitter3": "^5.0.1", | |
| 2817 | + "log-update": "^6.1.0", | |
| 2818 | + "rfdc": "^1.4.1", | |
| 2819 | + "wrap-ansi": "^9.0.0" | |
| 2820 | + }, | |
| 2821 | + "engines": { | |
| 2822 | + "node": ">=18.0.0" | |
| 2823 | + } | |
| 2824 | + }, | |
| 2825 | + "node_modules/listr2/node_modules/ansi-regex": { | |
| 2826 | + "version": "6.2.2", | |
| 2827 | + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", | |
| 2828 | + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", | |
| 2829 | + "dev": true, | |
| 2830 | + "license": "MIT", | |
| 2831 | + "engines": { | |
| 2832 | + "node": ">=12" | |
| 2833 | + }, | |
| 2834 | + "funding": { | |
| 2835 | + "url": "https://github.com/chalk/ansi-regex?sponsor=1" | |
| 2836 | + } | |
| 2837 | + }, | |
| 2838 | + "node_modules/listr2/node_modules/ansi-styles": { | |
| 2839 | + "version": "6.2.3", | |
| 2840 | + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", | |
| 2841 | + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", | |
| 2842 | + "dev": true, | |
| 2843 | + "license": "MIT", | |
| 2844 | + "engines": { | |
| 2845 | + "node": ">=12" | |
| 2846 | + }, | |
| 2847 | + "funding": { | |
| 2848 | + "url": "https://github.com/chalk/ansi-styles?sponsor=1" | |
| 2849 | + } | |
| 2850 | + }, | |
| 2851 | + "node_modules/listr2/node_modules/emoji-regex": { | |
| 2852 | + "version": "10.5.0", | |
| 2853 | + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", | |
| 2854 | + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", | |
| 2855 | + "dev": true, | |
| 2856 | + "license": "MIT" | |
| 2857 | + }, | |
| 2858 | + "node_modules/listr2/node_modules/string-width": { | |
| 2859 | + "version": "7.2.0", | |
| 2860 | + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", | |
| 2861 | + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", | |
| 2862 | + "dev": true, | |
| 2863 | + "license": "MIT", | |
| 2864 | + "dependencies": { | |
| 2865 | + "emoji-regex": "^10.3.0", | |
| 2866 | + "get-east-asian-width": "^1.0.0", | |
| 2867 | + "strip-ansi": "^7.1.0" | |
| 2868 | + }, | |
| 2869 | + "engines": { | |
| 2870 | + "node": ">=18" | |
| 2871 | + }, | |
| 2872 | + "funding": { | |
| 2873 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 2874 | + } | |
| 2875 | + }, | |
| 2876 | + "node_modules/listr2/node_modules/strip-ansi": { | |
| 2877 | + "version": "7.1.2", | |
| 2878 | + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", | |
| 2879 | + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", | |
| 2880 | + "dev": true, | |
| 2881 | + "license": "MIT", | |
| 2882 | + "dependencies": { | |
| 2883 | + "ansi-regex": "^6.0.1" | |
| 2884 | + }, | |
| 2885 | + "engines": { | |
| 2886 | + "node": ">=12" | |
| 2887 | + }, | |
| 2888 | + "funding": { | |
| 2889 | + "url": "https://github.com/chalk/strip-ansi?sponsor=1" | |
| 2890 | + } | |
| 2891 | + }, | |
| 2892 | + "node_modules/listr2/node_modules/wrap-ansi": { | |
| 2893 | + "version": "9.0.2", | |
| 2894 | + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", | |
| 2895 | + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", | |
| 2896 | + "dev": true, | |
| 2897 | + "license": "MIT", | |
| 2898 | + "dependencies": { | |
| 2899 | + "ansi-styles": "^6.2.1", | |
| 2900 | + "string-width": "^7.0.0", | |
| 2901 | + "strip-ansi": "^7.1.0" | |
| 2902 | + }, | |
| 2903 | + "engines": { | |
| 2904 | + "node": ">=18" | |
| 2905 | + }, | |
| 2906 | + "funding": { | |
| 2907 | + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" | |
| 2908 | + } | |
| 2909 | + }, | |
| 2524 | 2910 | "node_modules/locate-path": { |
| 2525 | 2911 | "version": "6.0.0", |
| 2526 | 2912 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", |
| @@ -2553,6 +2939,144 @@ | ||
| 2553 | 2939 | "license": "MIT", |
| 2554 | 2940 | "peer": true |
| 2555 | 2941 | }, |
| 2942 | + "node_modules/log-update": { | |
| 2943 | + "version": "6.1.0", | |
| 2944 | + "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", | |
| 2945 | + "integrity": "sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==", | |
| 2946 | + "dev": true, | |
| 2947 | + "license": "MIT", | |
| 2948 | + "dependencies": { | |
| 2949 | + "ansi-escapes": "^7.0.0", | |
| 2950 | + "cli-cursor": "^5.0.0", | |
| 2951 | + "slice-ansi": "^7.1.0", | |
| 2952 | + "strip-ansi": "^7.1.0", | |
| 2953 | + "wrap-ansi": "^9.0.0" | |
| 2954 | + }, | |
| 2955 | + "engines": { | |
| 2956 | + "node": ">=18" | |
| 2957 | + }, | |
| 2958 | + "funding": { | |
| 2959 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 2960 | + } | |
| 2961 | + }, | |
| 2962 | + "node_modules/log-update/node_modules/ansi-regex": { | |
| 2963 | + "version": "6.2.2", | |
| 2964 | + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", | |
| 2965 | + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", | |
| 2966 | + "dev": true, | |
| 2967 | + "license": "MIT", | |
| 2968 | + "engines": { | |
| 2969 | + "node": ">=12" | |
| 2970 | + }, | |
| 2971 | + "funding": { | |
| 2972 | + "url": "https://github.com/chalk/ansi-regex?sponsor=1" | |
| 2973 | + } | |
| 2974 | + }, | |
| 2975 | + "node_modules/log-update/node_modules/ansi-styles": { | |
| 2976 | + "version": "6.2.3", | |
| 2977 | + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", | |
| 2978 | + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", | |
| 2979 | + "dev": true, | |
| 2980 | + "license": "MIT", | |
| 2981 | + "engines": { | |
| 2982 | + "node": ">=12" | |
| 2983 | + }, | |
| 2984 | + "funding": { | |
| 2985 | + "url": "https://github.com/chalk/ansi-styles?sponsor=1" | |
| 2986 | + } | |
| 2987 | + }, | |
| 2988 | + "node_modules/log-update/node_modules/emoji-regex": { | |
| 2989 | + "version": "10.5.0", | |
| 2990 | + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", | |
| 2991 | + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", | |
| 2992 | + "dev": true, | |
| 2993 | + "license": "MIT" | |
| 2994 | + }, | |
| 2995 | + "node_modules/log-update/node_modules/is-fullwidth-code-point": { | |
| 2996 | + "version": "5.1.0", | |
| 2997 | + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.1.0.tgz", | |
| 2998 | + "integrity": "sha512-5XHYaSyiqADb4RnZ1Bdad6cPp8Toise4TzEjcOYDHZkTCbKgiUl7WTUCpNWHuxmDt91wnsZBc9xinNzopv3JMQ==", | |
| 2999 | + "dev": true, | |
| 3000 | + "license": "MIT", | |
| 3001 | + "dependencies": { | |
| 3002 | + "get-east-asian-width": "^1.3.1" | |
| 3003 | + }, | |
| 3004 | + "engines": { | |
| 3005 | + "node": ">=18" | |
| 3006 | + }, | |
| 3007 | + "funding": { | |
| 3008 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3009 | + } | |
| 3010 | + }, | |
| 3011 | + "node_modules/log-update/node_modules/slice-ansi": { | |
| 3012 | + "version": "7.1.2", | |
| 3013 | + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-7.1.2.tgz", | |
| 3014 | + "integrity": "sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w==", | |
| 3015 | + "dev": true, | |
| 3016 | + "license": "MIT", | |
| 3017 | + "dependencies": { | |
| 3018 | + "ansi-styles": "^6.2.1", | |
| 3019 | + "is-fullwidth-code-point": "^5.0.0" | |
| 3020 | + }, | |
| 3021 | + "engines": { | |
| 3022 | + "node": ">=18" | |
| 3023 | + }, | |
| 3024 | + "funding": { | |
| 3025 | + "url": "https://github.com/chalk/slice-ansi?sponsor=1" | |
| 3026 | + } | |
| 3027 | + }, | |
| 3028 | + "node_modules/log-update/node_modules/string-width": { | |
| 3029 | + "version": "7.2.0", | |
| 3030 | + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", | |
| 3031 | + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", | |
| 3032 | + "dev": true, | |
| 3033 | + "license": "MIT", | |
| 3034 | + "dependencies": { | |
| 3035 | + "emoji-regex": "^10.3.0", | |
| 3036 | + "get-east-asian-width": "^1.0.0", | |
| 3037 | + "strip-ansi": "^7.1.0" | |
| 3038 | + }, | |
| 3039 | + "engines": { | |
| 3040 | + "node": ">=18" | |
| 3041 | + }, | |
| 3042 | + "funding": { | |
| 3043 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3044 | + } | |
| 3045 | + }, | |
| 3046 | + "node_modules/log-update/node_modules/strip-ansi": { | |
| 3047 | + "version": "7.1.2", | |
| 3048 | + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", | |
| 3049 | + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", | |
| 3050 | + "dev": true, | |
| 3051 | + "license": "MIT", | |
| 3052 | + "dependencies": { | |
| 3053 | + "ansi-regex": "^6.0.1" | |
| 3054 | + }, | |
| 3055 | + "engines": { | |
| 3056 | + "node": ">=12" | |
| 3057 | + }, | |
| 3058 | + "funding": { | |
| 3059 | + "url": "https://github.com/chalk/strip-ansi?sponsor=1" | |
| 3060 | + } | |
| 3061 | + }, | |
| 3062 | + "node_modules/log-update/node_modules/wrap-ansi": { | |
| 3063 | + "version": "9.0.2", | |
| 3064 | + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", | |
| 3065 | + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", | |
| 3066 | + "dev": true, | |
| 3067 | + "license": "MIT", | |
| 3068 | + "dependencies": { | |
| 3069 | + "ansi-styles": "^6.2.1", | |
| 3070 | + "string-width": "^7.0.0", | |
| 3071 | + "strip-ansi": "^7.1.0" | |
| 3072 | + }, | |
| 3073 | + "engines": { | |
| 3074 | + "node": ">=18" | |
| 3075 | + }, | |
| 3076 | + "funding": { | |
| 3077 | + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" | |
| 3078 | + } | |
| 3079 | + }, | |
| 2556 | 3080 | "node_modules/math-intrinsics": { |
| 2557 | 3081 | "version": "1.1.0", |
| 2558 | 3082 | "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", |
| @@ -2563,6 +3087,13 @@ | ||
| 2563 | 3087 | "node": ">= 0.4" |
| 2564 | 3088 | } |
| 2565 | 3089 | }, |
| 3090 | + "node_modules/merge-stream": { | |
| 3091 | + "version": "2.0.0", | |
| 3092 | + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", | |
| 3093 | + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", | |
| 3094 | + "dev": true, | |
| 3095 | + "license": "MIT" | |
| 3096 | + }, | |
| 2566 | 3097 | "node_modules/merge2": { |
| 2567 | 3098 | "version": "1.4.1", |
| 2568 | 3099 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", |
| @@ -2587,6 +3118,32 @@ | ||
| 2587 | 3118 | "node": ">=8.6" |
| 2588 | 3119 | } |
| 2589 | 3120 | }, |
| 3121 | + "node_modules/mimic-fn": { | |
| 3122 | + "version": "4.0.0", | |
| 3123 | + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", | |
| 3124 | + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", | |
| 3125 | + "dev": true, | |
| 3126 | + "license": "MIT", | |
| 3127 | + "engines": { | |
| 3128 | + "node": ">=12" | |
| 3129 | + }, | |
| 3130 | + "funding": { | |
| 3131 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3132 | + } | |
| 3133 | + }, | |
| 3134 | + "node_modules/mimic-function": { | |
| 3135 | + "version": "5.0.1", | |
| 3136 | + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", | |
| 3137 | + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", | |
| 3138 | + "dev": true, | |
| 3139 | + "license": "MIT", | |
| 3140 | + "engines": { | |
| 3141 | + "node": ">=18" | |
| 3142 | + }, | |
| 3143 | + "funding": { | |
| 3144 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3145 | + } | |
| 3146 | + }, | |
| 2590 | 3147 | "node_modules/minimatch": { |
| 2591 | 3148 | "version": "9.0.5", |
| 2592 | 3149 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", |
| @@ -2628,6 +3185,35 @@ | ||
| 2628 | 3185 | "license": "MIT", |
| 2629 | 3186 | "peer": true |
| 2630 | 3187 | }, |
| 3188 | + "node_modules/npm-run-path": { | |
| 3189 | + "version": "5.3.0", | |
| 3190 | + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", | |
| 3191 | + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", | |
| 3192 | + "dev": true, | |
| 3193 | + "license": "MIT", | |
| 3194 | + "dependencies": { | |
| 3195 | + "path-key": "^4.0.0" | |
| 3196 | + }, | |
| 3197 | + "engines": { | |
| 3198 | + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" | |
| 3199 | + }, | |
| 3200 | + "funding": { | |
| 3201 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3202 | + } | |
| 3203 | + }, | |
| 3204 | + "node_modules/npm-run-path/node_modules/path-key": { | |
| 3205 | + "version": "4.0.0", | |
| 3206 | + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", | |
| 3207 | + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", | |
| 3208 | + "dev": true, | |
| 3209 | + "license": "MIT", | |
| 3210 | + "engines": { | |
| 3211 | + "node": ">=12" | |
| 3212 | + }, | |
| 3213 | + "funding": { | |
| 3214 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3215 | + } | |
| 3216 | + }, | |
| 2631 | 3217 | "node_modules/object-inspect": { |
| 2632 | 3218 | "version": "1.13.4", |
| 2633 | 3219 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", |
| @@ -2736,6 +3322,22 @@ | ||
| 2736 | 3322 | "wrappy": "1" |
| 2737 | 3323 | } |
| 2738 | 3324 | }, |
| 3325 | + "node_modules/onetime": { | |
| 3326 | + "version": "6.0.0", | |
| 3327 | + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", | |
| 3328 | + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", | |
| 3329 | + "dev": true, | |
| 3330 | + "license": "MIT", | |
| 3331 | + "dependencies": { | |
| 3332 | + "mimic-fn": "^4.0.0" | |
| 3333 | + }, | |
| 3334 | + "engines": { | |
| 3335 | + "node": ">=12" | |
| 3336 | + }, | |
| 3337 | + "funding": { | |
| 3338 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3339 | + } | |
| 3340 | + }, | |
| 2739 | 3341 | "node_modules/optionator": { |
| 2740 | 3342 | "version": "0.9.4", |
| 2741 | 3343 | "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", |
| @@ -2849,7 +3451,6 @@ | ||
| 2849 | 3451 | "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", |
| 2850 | 3452 | "dev": true, |
| 2851 | 3453 | "license": "MIT", |
| 2852 | - "peer": true, | |
| 2853 | 3454 | "engines": { |
| 2854 | 3455 | "node": ">=8" |
| 2855 | 3456 | } |
| @@ -2884,6 +3485,19 @@ | ||
| 2884 | 3485 | "url": "https://github.com/sponsors/jonschlinkert" |
| 2885 | 3486 | } |
| 2886 | 3487 | }, |
| 3488 | + "node_modules/pidtree": { | |
| 3489 | + "version": "0.6.0", | |
| 3490 | + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.0.tgz", | |
| 3491 | + "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", | |
| 3492 | + "dev": true, | |
| 3493 | + "license": "MIT", | |
| 3494 | + "bin": { | |
| 3495 | + "pidtree": "bin/pidtree.js" | |
| 3496 | + }, | |
| 3497 | + "engines": { | |
| 3498 | + "node": ">=0.10" | |
| 3499 | + } | |
| 3500 | + }, | |
| 2887 | 3501 | "node_modules/possible-typed-array-names": { |
| 2888 | 3502 | "version": "1.1.0", |
| 2889 | 3503 | "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", |
| @@ -3118,6 +3732,39 @@ | ||
| 3118 | 3732 | "node": ">=4" |
| 3119 | 3733 | } |
| 3120 | 3734 | }, |
| 3735 | + "node_modules/restore-cursor": { | |
| 3736 | + "version": "5.1.0", | |
| 3737 | + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", | |
| 3738 | + "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", | |
| 3739 | + "dev": true, | |
| 3740 | + "license": "MIT", | |
| 3741 | + "dependencies": { | |
| 3742 | + "onetime": "^7.0.0", | |
| 3743 | + "signal-exit": "^4.1.0" | |
| 3744 | + }, | |
| 3745 | + "engines": { | |
| 3746 | + "node": ">=18" | |
| 3747 | + }, | |
| 3748 | + "funding": { | |
| 3749 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3750 | + } | |
| 3751 | + }, | |
| 3752 | + "node_modules/restore-cursor/node_modules/onetime": { | |
| 3753 | + "version": "7.0.0", | |
| 3754 | + "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", | |
| 3755 | + "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", | |
| 3756 | + "dev": true, | |
| 3757 | + "license": "MIT", | |
| 3758 | + "dependencies": { | |
| 3759 | + "mimic-function": "^5.0.0" | |
| 3760 | + }, | |
| 3761 | + "engines": { | |
| 3762 | + "node": ">=18" | |
| 3763 | + }, | |
| 3764 | + "funding": { | |
| 3765 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 3766 | + } | |
| 3767 | + }, | |
| 3121 | 3768 | "node_modules/reusify": { |
| 3122 | 3769 | "version": "1.1.0", |
| 3123 | 3770 | "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", |
| @@ -3129,6 +3776,13 @@ | ||
| 3129 | 3776 | "node": ">=0.10.0" |
| 3130 | 3777 | } |
| 3131 | 3778 | }, |
| 3779 | + "node_modules/rfdc": { | |
| 3780 | + "version": "1.4.1", | |
| 3781 | + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", | |
| 3782 | + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", | |
| 3783 | + "dev": true, | |
| 3784 | + "license": "MIT" | |
| 3785 | + }, | |
| 3132 | 3786 | "node_modules/rimraf": { |
| 3133 | 3787 | "version": "3.0.2", |
| 3134 | 3788 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", |
| @@ -3304,7 +3958,6 @@ | ||
| 3304 | 3958 | "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", |
| 3305 | 3959 | "dev": true, |
| 3306 | 3960 | "license": "MIT", |
| 3307 | - "peer": true, | |
| 3308 | 3961 | "dependencies": { |
| 3309 | 3962 | "shebang-regex": "^3.0.0" |
| 3310 | 3963 | }, |
| @@ -3318,7 +3971,6 @@ | ||
| 3318 | 3971 | "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", |
| 3319 | 3972 | "dev": true, |
| 3320 | 3973 | "license": "MIT", |
| 3321 | - "peer": true, | |
| 3322 | 3974 | "engines": { |
| 3323 | 3975 | "node": ">=8" |
| 3324 | 3976 | } |
| @@ -3412,6 +4064,19 @@ | ||
| 3412 | 4064 | "url": "https://github.com/sponsors/ljharb" |
| 3413 | 4065 | } |
| 3414 | 4066 | }, |
| 4067 | + "node_modules/signal-exit": { | |
| 4068 | + "version": "4.1.0", | |
| 4069 | + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", | |
| 4070 | + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", | |
| 4071 | + "dev": true, | |
| 4072 | + "license": "ISC", | |
| 4073 | + "engines": { | |
| 4074 | + "node": ">=14" | |
| 4075 | + }, | |
| 4076 | + "funding": { | |
| 4077 | + "url": "https://github.com/sponsors/isaacs" | |
| 4078 | + } | |
| 4079 | + }, | |
| 3415 | 4080 | "node_modules/slash": { |
| 3416 | 4081 | "version": "3.0.0", |
| 3417 | 4082 | "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", |
| @@ -3422,6 +4087,49 @@ | ||
| 3422 | 4087 | "node": ">=8" |
| 3423 | 4088 | } |
| 3424 | 4089 | }, |
| 4090 | + "node_modules/slice-ansi": { | |
| 4091 | + "version": "5.0.0", | |
| 4092 | + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", | |
| 4093 | + "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", | |
| 4094 | + "dev": true, | |
| 4095 | + "license": "MIT", | |
| 4096 | + "dependencies": { | |
| 4097 | + "ansi-styles": "^6.0.0", | |
| 4098 | + "is-fullwidth-code-point": "^4.0.0" | |
| 4099 | + }, | |
| 4100 | + "engines": { | |
| 4101 | + "node": ">=12" | |
| 4102 | + }, | |
| 4103 | + "funding": { | |
| 4104 | + "url": "https://github.com/chalk/slice-ansi?sponsor=1" | |
| 4105 | + } | |
| 4106 | + }, | |
| 4107 | + "node_modules/slice-ansi/node_modules/ansi-styles": { | |
| 4108 | + "version": "6.2.3", | |
| 4109 | + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", | |
| 4110 | + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", | |
| 4111 | + "dev": true, | |
| 4112 | + "license": "MIT", | |
| 4113 | + "engines": { | |
| 4114 | + "node": ">=12" | |
| 4115 | + }, | |
| 4116 | + "funding": { | |
| 4117 | + "url": "https://github.com/chalk/ansi-styles?sponsor=1" | |
| 4118 | + } | |
| 4119 | + }, | |
| 4120 | + "node_modules/slice-ansi/node_modules/is-fullwidth-code-point": { | |
| 4121 | + "version": "4.0.0", | |
| 4122 | + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", | |
| 4123 | + "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", | |
| 4124 | + "dev": true, | |
| 4125 | + "license": "MIT", | |
| 4126 | + "engines": { | |
| 4127 | + "node": ">=12" | |
| 4128 | + }, | |
| 4129 | + "funding": { | |
| 4130 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 4131 | + } | |
| 4132 | + }, | |
| 3425 | 4133 | "node_modules/stop-iteration-iterator": { |
| 3426 | 4134 | "version": "1.1.0", |
| 3427 | 4135 | "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", |
| @@ -3436,6 +4144,16 @@ | ||
| 3436 | 4144 | "node": ">= 0.4" |
| 3437 | 4145 | } |
| 3438 | 4146 | }, |
| 4147 | + "node_modules/string-argv": { | |
| 4148 | + "version": "0.3.2", | |
| 4149 | + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", | |
| 4150 | + "integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==", | |
| 4151 | + "dev": true, | |
| 4152 | + "license": "MIT", | |
| 4153 | + "engines": { | |
| 4154 | + "node": ">=0.6.19" | |
| 4155 | + } | |
| 4156 | + }, | |
| 3439 | 4157 | "node_modules/string-width": { |
| 3440 | 4158 | "version": "4.2.3", |
| 3441 | 4159 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", |
| @@ -3533,6 +4251,19 @@ | ||
| 3533 | 4251 | "node": ">=4" |
| 3534 | 4252 | } |
| 3535 | 4253 | }, |
| 4254 | + "node_modules/strip-final-newline": { | |
| 4255 | + "version": "3.0.0", | |
| 4256 | + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", | |
| 4257 | + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", | |
| 4258 | + "dev": true, | |
| 4259 | + "license": "MIT", | |
| 4260 | + "engines": { | |
| 4261 | + "node": ">=12" | |
| 4262 | + }, | |
| 4263 | + "funding": { | |
| 4264 | + "url": "https://github.com/sponsors/sindresorhus" | |
| 4265 | + } | |
| 4266 | + }, | |
| 3536 | 4267 | "node_modules/strip-json-comments": { |
| 3537 | 4268 | "version": "3.1.1", |
| 3538 | 4269 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", |
| @@ -3796,7 +4527,6 @@ | ||
| 3796 | 4527 | "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", |
| 3797 | 4528 | "dev": true, |
| 3798 | 4529 | "license": "ISC", |
| 3799 | - "peer": true, | |
| 3800 | 4530 | "dependencies": { |
| 3801 | 4531 | "isexe": "^2.0.0" |
| 3802 | 4532 | }, |
| @@ -3943,6 +4673,19 @@ | ||
| 3943 | 4673 | "node": ">=10" |
| 3944 | 4674 | } |
| 3945 | 4675 | }, |
| 4676 | + "node_modules/yaml": { | |
| 4677 | + "version": "2.8.1", | |
| 4678 | + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", | |
| 4679 | + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", | |
| 4680 | + "dev": true, | |
| 4681 | + "license": "ISC", | |
| 4682 | + "bin": { | |
| 4683 | + "yaml": "bin.mjs" | |
| 4684 | + }, | |
| 4685 | + "engines": { | |
| 4686 | + "node": ">= 14.6" | |
| 4687 | + } | |
| 4688 | + }, | |
| 3946 | 4689 | "node_modules/yargs": { |
| 3947 | 4690 | "version": "17.7.2", |
| 3948 | 4691 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", |
| @@ -7,12 +7,18 @@ | ||
| 7 | 7 | "tsc:watch:core": "tsc --project core/tsconfig.json --watch --noEmit --pretty", |
| 8 | 8 | "tsc:watch:binary": "tsc --project binary/tsconfig.json --watch --noEmit --pretty", |
| 9 | 9 | "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\" --ignore-path .gitignore --ignore-path .prettierignore", |
| 10 | - "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\" --ignore-path .gitignore --ignore-path .prettierignore" | |
| 10 | + "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\" --ignore-path .gitignore --ignore-path .prettierignore", | |
| 11 | + "prepare": "husky" | |
| 12 | + }, | |
| 13 | + "lint-staged": { | |
| 14 | + "*.{js,jsx,ts,tsx,json,css,md}": "prettier --write" | |
| 11 | 15 | }, |
| 12 | 16 | "devDependencies": { |
| 13 | 17 | "@typescript-eslint/parser": "^7.8.0", |
| 14 | 18 | "concurrently": "^9.1.2", |
| 15 | 19 | "eslint-plugin-import": "^2.29.1", |
| 20 | + "husky": "^9.1.7", | |
| 21 | + "lint-staged": "^15.5.2", | |
| 16 | 22 | "prettier": "^3.3.3", |
| 17 | 23 | "prettier-plugin-tailwindcss": "^0.6.8", |
| 18 | 24 | "typescript": "^5.6.3" |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/llm-info", |
| 3 | - "version": "1.0.9", | |
| 3 | + "version": "1.0.10", | |
| 4 | 4 | "description": "", |
| 5 | 5 | "main": "dist/index.js", |
| 6 | 6 | "types": "dist/index.d.ts", |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | import { Azure } from "./providers/azure.js"; |
| 3 | 3 | import { Bedrock } from "./providers/bedrock.js"; |
| 4 | 4 | import { Cohere } from "./providers/cohere.js"; |
| 5 | +import { CometAPI } from "./providers/cometapi.js"; | |
| 5 | 6 | import { Gemini } from "./providers/gemini.js"; |
| 6 | 7 | import { Mistral } from "./providers/mistral.js"; |
| 7 | 8 | import { Ollama } from "./providers/ollama.js"; |
| @@ -9,7 +10,7 @@ | ||
| 9 | 10 | import { Vllm } from "./providers/vllm.js"; |
| 10 | 11 | import { Voyage } from "./providers/voyage.js"; |
| 11 | 12 | import { xAI } from "./providers/xAI.js"; |
| 12 | -import { LlmInfo, ModelProvider, UseCase } from "./types.js"; | |
| 13 | +import { LlmInfoWithProvider, ModelProvider, UseCase } from "./types.js"; | |
| 13 | 14 | |
| 14 | 15 | export const allModelProviders: ModelProvider[] = [ |
| 15 | 16 | OpenAi, |
| @@ -22,19 +23,36 @@ | ||
| 22 | 23 | Vllm, |
| 23 | 24 | Bedrock, |
| 24 | 25 | Cohere, |
| 26 | + CometAPI, | |
| 25 | 27 | xAI, |
| 26 | 28 | ]; |
| 27 | 29 | |
| 28 | -export const allLlms: LlmInfo[] = allModelProviders.flatMap((provider) => | |
| 29 | - provider.models.map((model) => ({ ...model, provider: provider.id })), | |
| 30 | +export const allLlms: LlmInfoWithProvider[] = allModelProviders.flatMap( | |
| 31 | + (provider) => | |
| 32 | + provider.models.map((model) => ({ ...model, provider: provider.id })), | |
| 30 | 33 | ); |
| 31 | 34 | |
| 32 | -export function findLlmInfo(model: string): LlmInfo | undefined { | |
| 35 | +export function findLlmInfo( | |
| 36 | + model: string, | |
| 37 | + preferProviderId?: string, | |
| 38 | +): LlmInfoWithProvider | undefined { | |
| 39 | + if (preferProviderId) { | |
| 40 | + const provider = allModelProviders.find((p) => p.id === preferProviderId); | |
| 41 | + const info = provider?.models.find((llm) => | |
| 42 | + llm.regex ? llm.regex.test(model) : llm.model === model, | |
| 43 | + ); | |
| 44 | + if (info) { | |
| 45 | + return { | |
| 46 | + ...info, | |
| 47 | + provider: preferProviderId, | |
| 48 | + }; | |
| 49 | + } | |
| 50 | + } | |
| 33 | 51 | return allLlms.find((llm) => |
| 34 | 52 | llm.regex ? llm.regex.test(model) : llm.model === model, |
| 35 | 53 | ); |
| 36 | 54 | } |
| 37 | 55 | |
| 38 | -export function getAllRecommendedFor(useCase: UseCase): LlmInfo[] { | |
| 56 | +export function getAllRecommendedFor(useCase: UseCase): LlmInfoWithProvider[] { | |
| 39 | 57 | return allLlms.filter((llm) => llm.recommendedFor?.includes(useCase)); |
| 40 | 58 | } |
| @@ -0,0 +1,280 @@ | ||
| 1 | +import { ModelProvider } from "../types.js"; | |
| 2 | + | |
| 3 | +export const CometAPI: ModelProvider = { | |
| 4 | + id: "cometapi", | |
| 5 | + displayName: "CometAPI", | |
| 6 | + models: [ | |
| 7 | + // GPT Series | |
| 8 | + { | |
| 9 | + model: "gpt-5-chat-latest", | |
| 10 | + displayName: "GPT-5 Chat Latest", | |
| 11 | + contextLength: 200000, | |
| 12 | + maxCompletionTokens: 8192, | |
| 13 | + description: | |
| 14 | + "Latest GPT-5 model optimized for chat conversations with enhanced reasoning capabilities.", | |
| 15 | + recommendedFor: ["chat"], | |
| 16 | + }, | |
| 17 | + { | |
| 18 | + model: "chatgpt-4o-latest", | |
| 19 | + displayName: "ChatGPT-4o Latest", | |
| 20 | + contextLength: 128000, | |
| 21 | + maxCompletionTokens: 4096, | |
| 22 | + description: | |
| 23 | + "Latest ChatGPT-4o model with improved performance and updated training data.", | |
| 24 | + recommendedFor: ["chat"], | |
| 25 | + }, | |
| 26 | + { | |
| 27 | + model: "gpt-5-mini", | |
| 28 | + displayName: "GPT-5 Mini", | |
| 29 | + contextLength: 128000, | |
| 30 | + maxCompletionTokens: 4096, | |
| 31 | + description: | |
| 32 | + "Efficient version of GPT-5 with faster response times while maintaining high quality.", | |
| 33 | + recommendedFor: ["chat"], | |
| 34 | + }, | |
| 35 | + { | |
| 36 | + model: "gpt-5-nano", | |
| 37 | + displayName: "GPT-5 Nano", | |
| 38 | + contextLength: 64000, | |
| 39 | + maxCompletionTokens: 2048, | |
| 40 | + description: | |
| 41 | + "Ultra-fast GPT-5 variant optimized for quick responses and simple tasks.", | |
| 42 | + recommendedFor: ["chat"], | |
| 43 | + }, | |
| 44 | + { | |
| 45 | + model: "gpt-5", | |
| 46 | + displayName: "GPT-5", | |
| 47 | + contextLength: 200000, | |
| 48 | + maxCompletionTokens: 8192, | |
| 49 | + description: | |
| 50 | + "Advanced GPT-5 model with state-of-the-art language understanding and generation.", | |
| 51 | + recommendedFor: ["chat"], | |
| 52 | + }, | |
| 53 | + { | |
| 54 | + model: "gpt-4o-mini", | |
| 55 | + displayName: "GPT-4o Mini", | |
| 56 | + contextLength: 128000, | |
| 57 | + maxCompletionTokens: 4096, | |
| 58 | + description: | |
| 59 | + "Compact version of GPT-4o with excellent performance for most use cases.", | |
| 60 | + recommendedFor: ["chat"], | |
| 61 | + }, | |
| 62 | + { | |
| 63 | + model: "o4-mini-2025-04-16", | |
| 64 | + displayName: "o4 Mini (2025-04-16)", | |
| 65 | + contextLength: 128000, | |
| 66 | + maxCompletionTokens: 4096, | |
| 67 | + description: | |
| 68 | + "Optimized o4 mini model with April 2025 training improvements.", | |
| 69 | + recommendedFor: ["chat"], | |
| 70 | + }, | |
| 71 | + { | |
| 72 | + model: "o3-pro-2025-06-10", | |
| 73 | + displayName: "o3 Pro (2025-06-10)", | |
| 74 | + contextLength: 200000, | |
| 75 | + maxCompletionTokens: 8192, | |
| 76 | + description: | |
| 77 | + "Professional-grade o3 model with enhanced reasoning and problem-solving capabilities.", | |
| 78 | + recommendedFor: ["chat"], | |
| 79 | + }, | |
| 80 | + | |
| 81 | + // Claude Series | |
| 82 | + { | |
| 83 | + model: "claude-opus-4-1-20250805", | |
| 84 | + displayName: "Claude Opus 4.1 (2025-08-05)", | |
| 85 | + contextLength: 200000, | |
| 86 | + maxCompletionTokens: 8192, | |
| 87 | + description: | |
| 88 | + "Most capable Claude model with exceptional reasoning, analysis, and creative capabilities.", | |
| 89 | + recommendedFor: ["chat"], | |
| 90 | + }, | |
| 91 | + { | |
| 92 | + model: "claude-opus-4-1-20250805-thinking", | |
| 93 | + displayName: "Claude Opus 4.1 Thinking (2025-08-05)", | |
| 94 | + contextLength: 200000, | |
| 95 | + maxCompletionTokens: 8192, | |
| 96 | + description: | |
| 97 | + "Claude Opus with enhanced thinking process for complex problem-solving tasks.", | |
| 98 | + recommendedFor: ["chat"], | |
| 99 | + }, | |
| 100 | + { | |
| 101 | + model: "claude-sonnet-4-20250514", | |
| 102 | + displayName: "Claude Sonnet 4 (2025-05-14)", | |
| 103 | + contextLength: 200000, | |
| 104 | + maxCompletionTokens: 8192, | |
| 105 | + description: | |
| 106 | + "Balanced Claude model offering excellent performance across various tasks.", | |
| 107 | + recommendedFor: ["chat"], | |
| 108 | + }, | |
| 109 | + { | |
| 110 | + model: "claude-sonnet-4-20250514-thinking", | |
| 111 | + displayName: "Claude Sonnet 4 Thinking (2025-05-14)", | |
| 112 | + contextLength: 200000, | |
| 113 | + maxCompletionTokens: 8192, | |
| 114 | + description: | |
| 115 | + "Claude Sonnet with enhanced reasoning capabilities for analytical tasks.", | |
| 116 | + recommendedFor: ["chat"], | |
| 117 | + }, | |
| 118 | + { | |
| 119 | + model: "claude-3-7-sonnet-latest", | |
| 120 | + displayName: "Claude 3.7 Sonnet Latest", | |
| 121 | + contextLength: 200000, | |
| 122 | + maxCompletionTokens: 4096, | |
| 123 | + description: | |
| 124 | + "Latest Claude 3.7 Sonnet with improved instruction following and safety.", | |
| 125 | + recommendedFor: ["chat"], | |
| 126 | + }, | |
| 127 | + { | |
| 128 | + model: "claude-3-5-haiku-latest", | |
| 129 | + displayName: "Claude 3.5 Haiku Latest", | |
| 130 | + contextLength: 200000, | |
| 131 | + maxCompletionTokens: 4096, | |
| 132 | + description: | |
| 133 | + "Fast and efficient Claude model optimized for quick responses.", | |
| 134 | + recommendedFor: ["chat"], | |
| 135 | + }, | |
| 136 | + | |
| 137 | + // Gemini Series | |
| 138 | + { | |
| 139 | + model: "gemini-2.5-pro", | |
| 140 | + displayName: "Gemini 2.5 Pro", | |
| 141 | + contextLength: 2000000, | |
| 142 | + maxCompletionTokens: 8192, | |
| 143 | + description: | |
| 144 | + "Advanced Gemini model with extensive context window and multimodal capabilities.", | |
| 145 | + recommendedFor: ["chat"], | |
| 146 | + }, | |
| 147 | + { | |
| 148 | + model: "gemini-2.5-flash", | |
| 149 | + displayName: "Gemini 2.5 Flash", | |
| 150 | + contextLength: 1000000, | |
| 151 | + maxCompletionTokens: 8192, | |
| 152 | + description: | |
| 153 | + "Fast Gemini model with large context window optimized for speed.", | |
| 154 | + recommendedFor: ["chat"], | |
| 155 | + }, | |
| 156 | + { | |
| 157 | + model: "gemini-2.5-flash-lite", | |
| 158 | + displayName: "Gemini 2.5 Flash Lite", | |
| 159 | + contextLength: 1000000, | |
| 160 | + maxCompletionTokens: 4096, | |
| 161 | + description: | |
| 162 | + "Lightweight version of Gemini Flash for efficient processing.", | |
| 163 | + recommendedFor: ["chat"], | |
| 164 | + }, | |
| 165 | + { | |
| 166 | + model: "gemini-2.0-flash", | |
| 167 | + displayName: "Gemini 2.0 Flash", | |
| 168 | + contextLength: 1000000, | |
| 169 | + maxCompletionTokens: 8192, | |
| 170 | + description: | |
| 171 | + "High-performance Gemini model with excellent speed-quality balance.", | |
| 172 | + recommendedFor: ["chat"], | |
| 173 | + }, | |
| 174 | + | |
| 175 | + // Grok Series | |
| 176 | + { | |
| 177 | + model: "grok-4-0709", | |
| 178 | + displayName: "Grok 4 (07-09)", | |
| 179 | + contextLength: 128000, | |
| 180 | + maxCompletionTokens: 4096, | |
| 181 | + description: | |
| 182 | + "Latest Grok model with improved reasoning and conversational abilities.", | |
| 183 | + recommendedFor: ["chat"], | |
| 184 | + }, | |
| 185 | + { | |
| 186 | + model: "grok-3", | |
| 187 | + displayName: "Grok 3", | |
| 188 | + contextLength: 128000, | |
| 189 | + maxCompletionTokens: 4096, | |
| 190 | + description: | |
| 191 | + "Advanced Grok model with enhanced understanding and generation capabilities.", | |
| 192 | + recommendedFor: ["chat"], | |
| 193 | + }, | |
| 194 | + { | |
| 195 | + model: "grok-3-mini", | |
| 196 | + displayName: "Grok 3 Mini", | |
| 197 | + contextLength: 64000, | |
| 198 | + maxCompletionTokens: 2048, | |
| 199 | + description: | |
| 200 | + "Compact Grok model optimized for efficiency and quick responses.", | |
| 201 | + recommendedFor: ["chat"], | |
| 202 | + }, | |
| 203 | + { | |
| 204 | + model: "grok-2-image-1212", | |
| 205 | + displayName: "Grok 2 Image (12-12)", | |
| 206 | + contextLength: 128000, | |
| 207 | + maxCompletionTokens: 4096, | |
| 208 | + description: | |
| 209 | + "Grok model with enhanced image understanding and multimodal capabilities.", | |
| 210 | + recommendedFor: ["chat"], | |
| 211 | + }, | |
| 212 | + | |
| 213 | + // DeepSeek Series | |
| 214 | + { | |
| 215 | + model: "deepseek-v3.1", | |
| 216 | + displayName: "DeepSeek V3.1", | |
| 217 | + contextLength: 128000, | |
| 218 | + maxCompletionTokens: 4096, | |
| 219 | + description: | |
| 220 | + "Latest DeepSeek model with improved reasoning and coding capabilities.", | |
| 221 | + recommendedFor: ["chat"], | |
| 222 | + }, | |
| 223 | + { | |
| 224 | + model: "deepseek-v3", | |
| 225 | + displayName: "DeepSeek V3", | |
| 226 | + contextLength: 128000, | |
| 227 | + maxCompletionTokens: 4096, | |
| 228 | + description: | |
| 229 | + "Advanced DeepSeek model with strong performance in technical domains.", | |
| 230 | + recommendedFor: ["chat"], | |
| 231 | + }, | |
| 232 | + { | |
| 233 | + model: "deepseek-r1-0528", | |
| 234 | + displayName: "DeepSeek R1 (05-28)", | |
| 235 | + contextLength: 128000, | |
| 236 | + maxCompletionTokens: 4096, | |
| 237 | + description: | |
| 238 | + "DeepSeek reasoning model optimized for complex problem-solving tasks.", | |
| 239 | + recommendedFor: ["chat"], | |
| 240 | + }, | |
| 241 | + { | |
| 242 | + model: "deepseek-chat", | |
| 243 | + displayName: "DeepSeek Chat", | |
| 244 | + contextLength: 128000, | |
| 245 | + maxCompletionTokens: 4096, | |
| 246 | + description: | |
| 247 | + "DeepSeek model specifically optimized for conversational interactions.", | |
| 248 | + recommendedFor: ["chat"], | |
| 249 | + }, | |
| 250 | + { | |
| 251 | + model: "deepseek-reasoner", | |
| 252 | + displayName: "DeepSeek Reasoner", | |
| 253 | + contextLength: 128000, | |
| 254 | + maxCompletionTokens: 4096, | |
| 255 | + description: | |
| 256 | + "DeepSeek model with enhanced reasoning capabilities for analytical tasks.", | |
| 257 | + recommendedFor: ["chat"], | |
| 258 | + }, | |
| 259 | + | |
| 260 | + // Qwen Series | |
| 261 | + { | |
| 262 | + model: "qwen3-30b-a3b", | |
| 263 | + displayName: "Qwen3 30B A3B", | |
| 264 | + contextLength: 128000, | |
| 265 | + maxCompletionTokens: 4096, | |
| 266 | + description: | |
| 267 | + "Large Qwen model with 30B parameters for high-quality text generation.", | |
| 268 | + recommendedFor: ["chat"], | |
| 269 | + }, | |
| 270 | + { | |
| 271 | + model: "qwen3-coder-plus-2025-07-22", | |
| 272 | + displayName: "Qwen3 Coder Plus (2025-07-22)", | |
| 273 | + contextLength: 128000, | |
| 274 | + maxCompletionTokens: 4096, | |
| 275 | + description: | |
| 276 | + "Qwen model specialized for coding tasks with enhanced programming capabilities.", | |
| 277 | + recommendedFor: ["chat"], | |
| 278 | + }, | |
| 279 | + ], | |
| 280 | +}; |
| @@ -7,6 +7,60 @@ | ||
| 7 | 7 | displayName: "Grok Beta", |
| 8 | 8 | contextLength: 128000, |
| 9 | 9 | recommendedFor: ["chat"], |
| 10 | + regex: /grok-beta/, | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + model: "grok-2", | |
| 14 | + displayName: "Grok 2", | |
| 15 | + contextLength: 131072, | |
| 16 | + recommendedFor: ["chat"], | |
| 17 | + regex: /grok-2/, | |
| 18 | + }, | |
| 19 | + { | |
| 20 | + model: "grok-3-mini", | |
| 21 | + displayName: "Grok 3 Mini", | |
| 22 | + contextLength: 131072, | |
| 23 | + maxCompletionTokens: 8000, | |
| 24 | + recommendedFor: ["chat"], | |
| 25 | + regex: /grok-3-mini/, | |
| 26 | + }, | |
| 27 | + { | |
| 28 | + model: "grok-3", | |
| 29 | + displayName: "Grok 3", | |
| 30 | + contextLength: 131072, | |
| 31 | + recommendedFor: ["chat"], | |
| 32 | + regex: /grok-3/, | |
| 33 | + }, | |
| 34 | + { | |
| 35 | + model: "grok-4-fast-reasoning", | |
| 36 | + displayName: "Grok 4 Fast Reasoning", | |
| 37 | + contextLength: 2000000, | |
| 38 | + maxCompletionTokens: 30000, | |
| 39 | + recommendedFor: ["chat"], | |
| 40 | + regex: /grok-4-fast-reasoning/, | |
| 41 | + }, | |
| 42 | + { | |
| 43 | + model: "grok-4-fast-non-reasoning", | |
| 44 | + displayName: "Grok 4 Fast Non-Reasoning", | |
| 45 | + contextLength: 2000000, | |
| 46 | + maxCompletionTokens: 30000, | |
| 47 | + recommendedFor: ["chat"], | |
| 48 | + regex: /grok-4-fast-non-reasoning/, | |
| 49 | + }, | |
| 50 | + { | |
| 51 | + model: "grok-4", | |
| 52 | + displayName: "Grok 4 Fast", | |
| 53 | + contextLength: 256000, | |
| 54 | + recommendedFor: ["chat"], | |
| 55 | + regex: /grok-4/, | |
| 56 | + }, | |
| 57 | + { | |
| 58 | + model: "grok-code-fast-1", | |
| 59 | + displayName: "Grok Code Fast 1", | |
| 60 | + contextLength: 256000, | |
| 61 | + maxCompletionTokens: 10000, | |
| 62 | + recommendedFor: ["chat"], | |
| 63 | + regex: /grok-code-fast-1/, | |
| 10 | 64 | }, |
| 11 | 65 | ], |
| 12 | 66 | id: "xAI", |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | "author": "Nate Sesti and Ty Dunn", |
| 13 | 13 | "license": "Apache-2.0", |
| 14 | 14 | "dependencies": { |
| 15 | + "@anthropic-ai/sdk": "^0.62.0", | |
| 15 | 16 | "@aws-sdk/client-bedrock-runtime": "^3.842.0", |
| 16 | 17 | "@aws-sdk/credential-providers": "^3.840.0", |
| 17 | 18 | "@continuedev/config-types": "^1.0.14", |
| @@ -1,8 +1,22 @@ | ||
| 1 | +import { | |
| 2 | + ContentBlockParam, | |
| 3 | + MessageCreateParams, | |
| 4 | + MessageParam, | |
| 5 | + RawContentBlockDeltaEvent, | |
| 6 | + RawContentBlockStartEvent, | |
| 7 | + RawMessageDeltaEvent, | |
| 8 | + RawMessageStartEvent, | |
| 9 | + RawMessageStreamEvent, | |
| 10 | + Tool, | |
| 11 | + ToolUseBlock, | |
| 12 | +} from "@anthropic-ai/sdk/resources"; | |
| 1 | 13 | import { streamSse } from "@continuedev/fetch"; |
| 2 | 14 | import { OpenAI } from "openai/index"; |
| 3 | 15 | import { |
| 4 | 16 | ChatCompletion, |
| 5 | 17 | ChatCompletionChunk, |
| 18 | + ChatCompletionContentPartRefusal, | |
| 19 | + ChatCompletionContentPartText, | |
| 6 | 20 | ChatCompletionCreateParamsNonStreaming, |
| 7 | 21 | ChatCompletionCreateParamsStreaming, |
| 8 | 22 | Completion, |
| @@ -24,6 +38,12 @@ | ||
| 24 | 38 | CACHING_STRATEGIES, |
| 25 | 39 | CachingStrategyName, |
| 26 | 40 | } from "./AnthropicCachingStrategies.js"; |
| 41 | +import { | |
| 42 | + getAnthropicHeaders, | |
| 43 | + getAnthropicMediaTypeFromDataUrl, | |
| 44 | + openAiToolChoiceToAnthropicToolChoice, | |
| 45 | + openaiToolToAnthropicTool, | |
| 46 | +} from "./AnthropicUtils.js"; | |
| 27 | 47 | import { |
| 28 | 48 | BaseLlmApi, |
| 29 | 49 | CreateRerankResponse, |
| @@ -59,11 +79,12 @@ | ||
| 59 | 79 | if (model.includes("haiku")) { |
| 60 | 80 | return 8192; |
| 61 | 81 | } |
| 62 | - | |
| 63 | 82 | return 32_000; |
| 64 | 83 | } |
| 65 | 84 | |
| 66 | - public _convertToCleanAnthropicBody(oaiBody: ChatCompletionCreateParams) { | |
| 85 | + public _convertToCleanAnthropicBody( | |
| 86 | + oaiBody: ChatCompletionCreateParams, | |
| 87 | + ): MessageCreateParams { | |
| 67 | 88 | let stop = undefined; |
| 68 | 89 | if (oaiBody.stop && Array.isArray(oaiBody.stop)) { |
| 69 | 90 | stop = oaiBody.stop.filter((x) => x.trim() !== ""); |
| @@ -75,145 +96,198 @@ | ||
| 75 | 96 | (msg) => msg.role === "system", |
| 76 | 97 | )?.content; |
| 77 | 98 | |
| 78 | - const anthropicBody = { | |
| 99 | + // TODO support custom tools | |
| 100 | + const functionTools = oaiBody.tools?.filter((t) => t.type === "function"); | |
| 101 | + let tools: Tool[] | undefined = undefined; | |
| 102 | + | |
| 103 | + if ( | |
| 104 | + oaiBody.tool_choice !== "none" && | |
| 105 | + functionTools && | |
| 106 | + functionTools.length > 0 | |
| 107 | + ) { | |
| 108 | + if ( | |
| 109 | + typeof oaiBody.tool_choice !== "string" && | |
| 110 | + oaiBody.tool_choice?.type === "allowed_tools" | |
| 111 | + ) { | |
| 112 | + const allowedToolNames = new Set( | |
| 113 | + oaiBody.tool_choice?.allowed_tools.tools.map( | |
| 114 | + (tool) => tool["name"], | |
| 115 | + ) ?? [], | |
| 116 | + ); | |
| 117 | + const allowedTools = functionTools.filter((t) => | |
| 118 | + allowedToolNames.has(t.function.name), | |
| 119 | + ); | |
| 120 | + tools = allowedTools.map(openaiToolToAnthropicTool); | |
| 121 | + } else { | |
| 122 | + tools = functionTools.map(openaiToolToAnthropicTool); | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + const anthropicBody: MessageCreateParams = { | |
| 79 | 127 | messages: this._convertMessages( |
| 80 | 128 | oaiBody.messages.filter((msg) => msg.role !== "system"), |
| 81 | 129 | ), |
| 82 | - system: systemMessage | |
| 83 | - ? [ | |
| 84 | - { | |
| 85 | - type: "text", | |
| 86 | - text: systemMessage, | |
| 87 | - }, | |
| 88 | - ] | |
| 89 | - : systemMessage, | |
| 90 | - top_p: oaiBody.top_p, | |
| 91 | - temperature: oaiBody.temperature, | |
| 130 | + system: | |
| 131 | + typeof systemMessage === "string" | |
| 132 | + ? [ | |
| 133 | + { | |
| 134 | + type: "text", | |
| 135 | + text: systemMessage, | |
| 136 | + }, | |
| 137 | + ] | |
| 138 | + : systemMessage, | |
| 139 | + top_p: oaiBody.top_p ?? undefined, | |
| 140 | + temperature: oaiBody.temperature ?? undefined, | |
| 92 | 141 | max_tokens: oaiBody.max_tokens ?? this.maxTokensForModel(oaiBody.model), // max_tokens is required |
| 93 | 142 | model: oaiBody.model, |
| 94 | 143 | stop_sequences: stop, |
| 95 | - stream: oaiBody.stream, | |
| 96 | - tools: oaiBody.tools?.map((tool) => { | |
| 97 | - // Type guard for function tools | |
| 98 | - if (tool.type === "function" && "function" in tool) { | |
| 99 | - return { | |
| 100 | - name: tool.function.name, | |
| 101 | - description: tool.function.description, | |
| 102 | - input_schema: tool.function.parameters, | |
| 103 | - }; | |
| 104 | - } else { | |
| 105 | - throw new Error(`Unsupported tool type in Anthropic: ${tool.type}`); | |
| 106 | - } | |
| 107 | - }), | |
| 108 | - tool_choice: oaiBody.tool_choice | |
| 109 | - ? { | |
| 110 | - type: "tool", | |
| 111 | - name: | |
| 112 | - typeof oaiBody.tool_choice === "string" | |
| 113 | - ? oaiBody.tool_choice | |
| 114 | - : oaiBody.tool_choice && "function" in oaiBody.tool_choice | |
| 115 | - ? oaiBody.tool_choice.function.name | |
| 116 | - : undefined, | |
| 117 | - } | |
| 118 | - : undefined, | |
| 144 | + stream: oaiBody.stream ?? undefined, | |
| 145 | + tools, | |
| 146 | + tool_choice: openAiToolChoiceToAnthropicToolChoice(oaiBody.tool_choice), | |
| 119 | 147 | }; |
| 120 | 148 | |
| 121 | 149 | return anthropicBody; |
| 122 | 150 | } |
| 123 | 151 | |
| 124 | - private _convertMessages( | |
| 125 | - msgs: OpenAI.Chat.Completions.ChatCompletionMessageParam[], | |
| 126 | - ): any[] { | |
| 127 | - const messages = msgs.map((message) => { | |
| 128 | - if (message.role === "tool") { | |
| 129 | - return { | |
| 130 | - role: "user", | |
| 131 | - content: [ | |
| 132 | - { | |
| 133 | - type: "tool_result", | |
| 134 | - tool_use_id: message.tool_call_id, | |
| 135 | - content: | |
| 136 | - typeof message.content === "string" | |
| 137 | - ? message.content | |
| 138 | - : message.content.map((part) => part.text).join(""), | |
| 139 | - }, | |
| 140 | - ], | |
| 141 | - }; | |
| 142 | - } else if (message.role === "assistant" && message.tool_calls) { | |
| 143 | - const parts: any[] = []; | |
| 144 | - if (message.content) { | |
| 145 | - if (typeof message.content === "string") { | |
| 146 | - parts.push({ | |
| 152 | + private convertToolCallsToBlocks( | |
| 153 | + toolCall: OpenAI.Chat.Completions.ChatCompletionMessageFunctionToolCall, | |
| 154 | + ): ToolUseBlock | undefined { | |
| 155 | + const toolCallId = toolCall.id; | |
| 156 | + const toolName = toolCall.function?.name; | |
| 157 | + if (toolCallId && toolName) { | |
| 158 | + return { | |
| 159 | + type: "tool_use", | |
| 160 | + id: toolCallId, | |
| 161 | + name: toolName, | |
| 162 | + input: safeParseArgs( | |
| 163 | + toolCall.function.arguments, | |
| 164 | + `${toolName} ${toolCallId}`, | |
| 165 | + ), | |
| 166 | + }; | |
| 167 | + } | |
| 168 | + } | |
| 169 | + | |
| 170 | + // 1. ignores empty content | |
| 171 | + // 2. converts string content to text parts | |
| 172 | + // 3. converts text and refusal parts to text blocks | |
| 173 | + // 4. converts image parts to image blocks | |
| 174 | + private convertMessageContentToBlocks( | |
| 175 | + content: | |
| 176 | + | string | |
| 177 | + | OpenAI.Chat.Completions.ChatCompletionContentPart[] | |
| 178 | + | (ChatCompletionContentPartText | ChatCompletionContentPartRefusal)[], | |
| 179 | + ): ContentBlockParam[] { | |
| 180 | + const blocks: ContentBlockParam[] = []; | |
| 181 | + if (typeof content === "string") { | |
| 182 | + if (content) { | |
| 183 | + blocks.push({ | |
| 184 | + type: "text", | |
| 185 | + text: content, | |
| 186 | + }); | |
| 187 | + } | |
| 188 | + } else { | |
| 189 | + const supportedParts = content.filter( | |
| 190 | + (p) => | |
| 191 | + p.type === "text" || p.type === "image_url" || p.type === "refusal", | |
| 192 | + ); | |
| 193 | + for (const part of supportedParts) { | |
| 194 | + if (part.type === "image_url") { | |
| 195 | + const dataUrl = part.image_url.url; | |
| 196 | + if (dataUrl?.startsWith("data:")) { | |
| 197 | + blocks.push({ | |
| 198 | + type: "image", | |
| 199 | + source: { | |
| 200 | + type: "base64", | |
| 201 | + media_type: getAnthropicMediaTypeFromDataUrl(dataUrl), | |
| 202 | + data: dataUrl.split(",")[1], | |
| 203 | + }, | |
| 204 | + }); | |
| 205 | + } | |
| 206 | + } else { | |
| 207 | + const text = part.type === "text" ? part.text : part.refusal; | |
| 208 | + if (text) { | |
| 209 | + blocks.push({ | |
| 147 | 210 | type: "text", |
| 148 | - text: message.content, | |
| 211 | + text, | |
| 149 | 212 | }); |
| 150 | - } else if (message.content.length > 0) { | |
| 151 | - parts.push( | |
| 152 | - message.content.map((c) => ({ | |
| 153 | - type: "text", | |
| 154 | - text: c.type === "text" ? c.text : c.refusal, | |
| 155 | - })), | |
| 156 | - ); | |
| 157 | 213 | } |
| 158 | 214 | } |
| 215 | + } | |
| 216 | + } | |
| 217 | + return blocks; | |
| 218 | + } | |
| 159 | 219 | |
| 160 | - parts.push( | |
| 161 | - ...message.tool_calls.map((toolCall) => { | |
| 162 | - // Type guard for function tool calls | |
| 163 | - if (toolCall.type === "function" && "function" in toolCall) { | |
| 164 | - return { | |
| 165 | - type: "tool_use", | |
| 166 | - id: toolCall.id, | |
| 167 | - name: toolCall.function?.name, | |
| 168 | - input: safeParseArgs( | |
| 169 | - toolCall.function?.arguments, | |
| 170 | - `${toolCall.function?.name} ${toolCall.id}`, | |
| 171 | - ), | |
| 172 | - }; | |
| 173 | - } else { | |
| 174 | - throw new Error(`Unsupported tool call type: ${toolCall.type}`); | |
| 175 | - } | |
| 176 | - }), | |
| 177 | - ); | |
| 178 | - return { | |
| 179 | - role: "assistant", | |
| 180 | - content: parts, | |
| 181 | - }; | |
| 220 | + private getContentBlocksFromChatMessage( | |
| 221 | + message: OpenAI.Chat.Completions.ChatCompletionMessageParam, | |
| 222 | + ): ContentBlockParam[] { | |
| 223 | + switch (message.role) { | |
| 224 | + // One tool message = one tool_result block | |
| 225 | + case "tool": | |
| 226 | + return [ | |
| 227 | + { | |
| 228 | + type: "tool_result", | |
| 229 | + tool_use_id: message.tool_call_id, | |
| 230 | + content: message.content, | |
| 231 | + }, | |
| 232 | + ]; | |
| 233 | + case "user": | |
| 234 | + return this.convertMessageContentToBlocks(message.content); | |
| 235 | + case "assistant": | |
| 236 | + const blocks: ContentBlockParam[] = message.content | |
| 237 | + ? this.convertMessageContentToBlocks(message.content) | |
| 238 | + : []; | |
| 239 | + // If any tool calls are present, always put them last | |
| 240 | + // Loses order vs what was originally sent, but they typically come last | |
| 241 | + for (const toolCall of message.tool_calls ?? []) { | |
| 242 | + if (toolCall.type !== "function") { | |
| 243 | + // TODO support custom tool calls | |
| 244 | + continue; | |
| 245 | + } | |
| 246 | + const block = this.convertToolCallsToBlocks(toolCall); | |
| 247 | + if (block) { | |
| 248 | + blocks.push(block); | |
| 249 | + } | |
| 250 | + } | |
| 251 | + return blocks; | |
| 252 | + // system, etc. | |
| 253 | + default: | |
| 254 | + return []; | |
| 255 | + } | |
| 256 | + } | |
| 257 | + | |
| 258 | + private _convertMessages( | |
| 259 | + msgs: OpenAI.Chat.Completions.ChatCompletionMessageParam[], | |
| 260 | + ): MessageParam[] { | |
| 261 | + const nonSystemMessages = msgs.filter((m) => m.role !== "system"); | |
| 262 | + | |
| 263 | + const convertedMessages: MessageParam[] = []; | |
| 264 | + let currentRole: "user" | "assistant" | undefined = undefined; | |
| 265 | + let currentParts: ContentBlockParam[] = []; | |
| 266 | + | |
| 267 | + const flushCurrentMessage = () => { | |
| 268 | + if (currentRole && currentParts.length > 0) { | |
| 269 | + convertedMessages.push({ | |
| 270 | + role: currentRole, | |
| 271 | + content: currentParts, | |
| 272 | + }); | |
| 273 | + currentParts = []; | |
| 182 | 274 | } |
| 275 | + }; | |
| 183 | 276 | |
| 184 | - if (!Array.isArray(message.content)) { | |
| 185 | - return message; | |
| 277 | + for (const message of nonSystemMessages) { | |
| 278 | + const newRole = | |
| 279 | + message.role === "user" || message.role === "tool" | |
| 280 | + ? "user" | |
| 281 | + : "assistant"; | |
| 282 | + if (currentRole !== newRole) { | |
| 283 | + flushCurrentMessage(); | |
| 284 | + currentRole = newRole; | |
| 186 | 285 | } |
| 187 | - return { | |
| 188 | - ...message, | |
| 189 | - content: message.content | |
| 190 | - .map((part) => { | |
| 191 | - if (part.type === "text") { | |
| 192 | - if ((part.text?.trim() ?? "") === "") { | |
| 193 | - return null; | |
| 194 | - } | |
| 195 | - return part; | |
| 196 | - } | |
| 197 | - const dataUrl = | |
| 198 | - (part as OpenAI.Chat.Completions.ChatCompletionContentPartImage) | |
| 199 | - ?.image_url?.url || ""; | |
| 200 | - // Extract media type from data URL (ex. "data:image/png;base64,..." -> "image/png") | |
| 201 | - const mediaTypeMatch = dataUrl.match(/^data:([^;]+);base64,/); | |
| 202 | - const mediaType = mediaTypeMatch ? mediaTypeMatch[1] : "image/jpeg"; | |
| 203 | - | |
| 204 | - return { | |
| 205 | - type: "image", | |
| 206 | - source: { | |
| 207 | - type: "base64", | |
| 208 | - media_type: mediaType, | |
| 209 | - data: dataUrl.split(",")[1], | |
| 210 | - }, | |
| 211 | - }; | |
| 212 | - }) | |
| 213 | - .filter((x) => x !== null), | |
| 214 | - }; | |
| 215 | - }); | |
| 216 | - return messages; | |
| 286 | + currentParts.push(...this.getContentBlocksFromChatMessage(message)); | |
| 287 | + } | |
| 288 | + flushCurrentMessage(); | |
| 289 | + | |
| 290 | + return convertedMessages; | |
| 217 | 291 | } |
| 218 | 292 | |
| 219 | 293 | async chatCompletionNonStream( |
| @@ -224,13 +298,7 @@ | ||
| 224 | 298 | new URL("messages", this.apiBase), |
| 225 | 299 | { |
| 226 | 300 | method: "POST", |
| 227 | - headers: { | |
| 228 | - "Content-Type": "application/json", | |
| 229 | - Accept: "application/json", | |
| 230 | - "anthropic-version": "2023-06-01", | |
| 231 | - "anthropic-beta": "prompt-caching-2024-07-31", | |
| 232 | - "x-api-key": this.config.apiKey, | |
| 233 | - }, | |
| 301 | + headers: this.getHeaders(), | |
| 234 | 302 | body: JSON.stringify(this._convertBody(body)), |
| 235 | 303 | signal, |
| 236 | 304 | }, |
| @@ -240,7 +308,7 @@ | ||
| 240 | 308 | return EMPTY_CHAT_COMPLETION; |
| 241 | 309 | } |
| 242 | 310 | |
| 243 | - const completion = (await response.json()) as any; | |
| 311 | + const completion = await response.json(); | |
| 244 | 312 | |
| 245 | 313 | const usage: Record<string, number> | undefined = completion.usage; |
| 246 | 314 | return { |
| @@ -281,30 +349,36 @@ | ||
| 281 | 349 | prompt_tokens: 0, |
| 282 | 350 | total_tokens: 0, |
| 283 | 351 | }; |
| 284 | - for await (const value of streamSse(response as any)) { | |
| 352 | + for await (const event of streamSse(response)) { | |
| 285 | 353 | // https://docs.anthropic.com/en/api/messages-streaming#event-types |
| 286 | - switch (value.type) { | |
| 354 | + const rawEvent = event as RawMessageStreamEvent; | |
| 355 | + switch (rawEvent.type) { | |
| 287 | 356 | case "content_block_start": |
| 288 | - if (value.content_block.type === "tool_use") { | |
| 289 | - lastToolUseId = value.content_block.id; | |
| 290 | - lastToolUseName = value.content_block.name; | |
| 357 | + const blockStartEvent = rawEvent as RawContentBlockStartEvent; | |
| 358 | + if (blockStartEvent.content_block.type === "tool_use") { | |
| 359 | + lastToolUseId = blockStartEvent.content_block.id; | |
| 360 | + lastToolUseName = blockStartEvent.content_block.name; | |
| 291 | 361 | } |
| 292 | 362 | break; |
| 293 | 363 | case "message_start": |
| 294 | - usage.prompt_tokens = value.message.usage?.input_tokens ?? 0; | |
| 364 | + const startEvent = rawEvent as RawMessageStartEvent; | |
| 365 | + usage.prompt_tokens = startEvent.message.usage?.input_tokens ?? 0; | |
| 295 | 366 | usage.prompt_tokens_details = { |
| 296 | - cached_tokens: value.message.usage?.cache_read_input_tokens ?? 0, | |
| 367 | + cached_tokens: | |
| 368 | + startEvent.message.usage?.cache_read_input_tokens ?? 0, | |
| 297 | 369 | }; |
| 298 | 370 | break; |
| 299 | 371 | case "message_delta": |
| 300 | - usage.completion_tokens = value.usage?.output_tokens ?? 0; | |
| 372 | + const deltaEvent = rawEvent as RawMessageDeltaEvent; | |
| 373 | + usage.completion_tokens = deltaEvent.usage?.output_tokens ?? 0; | |
| 301 | 374 | break; |
| 302 | 375 | case "content_block_delta": |
| 303 | 376 | // https://docs.anthropic.com/en/api/messages-streaming#delta-types |
| 304 | - switch (value.delta.type) { | |
| 377 | + const blockDeltaEvent = rawEvent as RawContentBlockDeltaEvent; | |
| 378 | + switch (blockDeltaEvent.delta.type) { | |
| 305 | 379 | case "text_delta": |
| 306 | 380 | yield chatChunk({ |
| 307 | - content: value.delta.text, | |
| 381 | + content: blockDeltaEvent.delta.text, | |
| 308 | 382 | model, |
| 309 | 383 | }); |
| 310 | 384 | break; |
| @@ -322,7 +396,7 @@ | ||
| 322 | 396 | index: 0, |
| 323 | 397 | function: { |
| 324 | 398 | name: lastToolUseName, |
| 325 | - arguments: value.delta.partial_json, | |
| 399 | + arguments: blockDeltaEvent.delta.partial_json, | |
| 326 | 400 | }, |
| 327 | 401 | }, |
| 328 | 402 | ], |
| @@ -352,25 +426,24 @@ | ||
| 352 | 426 | async *chatCompletionStream( |
| 353 | 427 | body: ChatCompletionCreateParamsStreaming, |
| 354 | 428 | signal: AbortSignal, |
| 355 | - ): AsyncGenerator<ChatCompletionChunk, any, unknown> { | |
| 356 | - body.messages; | |
| 429 | + ): AsyncGenerator<ChatCompletionChunk> { | |
| 357 | 430 | const response = await customFetch(this.config.requestOptions)( |
| 358 | 431 | new URL("messages", this.apiBase), |
| 359 | 432 | { |
| 360 | 433 | method: "POST", |
| 361 | - headers: { | |
| 362 | - "Content-Type": "application/json", | |
| 363 | - Accept: "application/json", | |
| 364 | - "anthropic-version": "2023-06-01", | |
| 365 | - "anthropic-beta": "prompt-caching-2024-07-31", | |
| 366 | - "x-api-key": this.config.apiKey, | |
| 367 | - }, | |
| 434 | + headers: this.getHeaders(), | |
| 368 | 435 | body: JSON.stringify(this._convertBody(body)), |
| 369 | 436 | signal, |
| 370 | 437 | }, |
| 371 | 438 | ); |
| 372 | 439 | yield* this.handleStreamResponse(response, body.model); |
| 373 | 440 | } |
| 441 | + | |
| 442 | + private getHeaders(): Record<string, string> { | |
| 443 | + const enableCaching = this.config?.cachingStrategy !== "none"; | |
| 444 | + return getAnthropicHeaders(this.config.apiKey, enableCaching); | |
| 445 | + } | |
| 446 | + | |
| 374 | 447 | async completionNonStream( |
| 375 | 448 | body: CompletionCreateParamsNonStreaming, |
| 376 | 449 | signal: AbortSignal, |
| @@ -380,13 +453,13 @@ | ||
| 380 | 453 | async *completionStream( |
| 381 | 454 | body: CompletionCreateParamsStreaming, |
| 382 | 455 | signal: AbortSignal, |
| 383 | - ): AsyncGenerator<Completion, any, unknown> { | |
| 456 | + ): AsyncGenerator<Completion> { | |
| 384 | 457 | throw new Error("Method not implemented."); |
| 385 | 458 | } |
| 386 | 459 | async *fimStream( |
| 387 | 460 | body: FimCreateParamsStreaming, |
| 388 | 461 | signal: AbortSignal, |
| 389 | - ): AsyncGenerator<ChatCompletionChunk, any, unknown> { | |
| 462 | + ): AsyncGenerator<ChatCompletionChunk> { | |
| 390 | 463 | throw new Error("Method not implemented."); |
| 391 | 464 | } |
| 392 | 465 |
| @@ -1,24 +1,42 @@ | ||
| 1 | +import { MessageCreateParams, ToolUnion } from "@anthropic-ai/sdk/resources"; | |
| 1 | 2 | import { |
| 2 | 3 | CACHING_STRATEGIES, |
| 3 | - CachingStrategy, | |
| 4 | 4 | CachingStrategyName, |
| 5 | 5 | getAvailableStrategies, |
| 6 | 6 | getStrategyDescription, |
| 7 | 7 | } from "./AnthropicCachingStrategies.js"; |
| 8 | 8 | |
| 9 | +const body_params = { | |
| 10 | + model: "claude", | |
| 11 | + stream: true, | |
| 12 | + max_tokens: 8192, | |
| 13 | +}; | |
| 14 | + | |
| 15 | +const makeTool = (name: string): ToolUnion => ({ | |
| 16 | + name, | |
| 17 | + input_schema: { | |
| 18 | + type: "object", | |
| 19 | + }, | |
| 20 | +}); | |
| 21 | + | |
| 9 | 22 | describe("AnthropicCachingStrategies", () => { |
| 10 | 23 | describe("noCachingStrategy", () => { |
| 11 | 24 | it("should return the body unchanged", () => { |
| 12 | - const body = { system: "test", messages: [] }; | |
| 25 | + const body: MessageCreateParams = { | |
| 26 | + system: "test", | |
| 27 | + messages: [], | |
| 28 | + ...body_params, | |
| 29 | + }; | |
| 13 | 30 | const result = CACHING_STRATEGIES.none(body); |
| 14 | 31 | expect(result).toBe(body); |
| 15 | 32 | }); |
| 16 | 33 | |
| 17 | 34 | it("should not modify complex objects", () => { |
| 18 | - const body = { | |
| 19 | - system: [{ text: "test" }], | |
| 20 | - tools: [{ name: "test" }], | |
| 21 | - messages: [{ content: "test" }], | |
| 35 | + const body: MessageCreateParams = { | |
| 36 | + system: [{ type: "text", text: "test" }], | |
| 37 | + tools: [makeTool("test")], | |
| 38 | + messages: [{ role: "user", content: "test" }], | |
| 39 | + ...body_params, | |
| 22 | 40 | }; |
| 23 | 41 | const result = CACHING_STRATEGIES.none(body); |
| 24 | 42 | expect(result).toBe(body); |
| @@ -27,24 +45,37 @@ | ||
| 27 | 45 | |
| 28 | 46 | describe("systemOnlyStrategy", () => { |
| 29 | 47 | it("should add cache_control to system messages array", () => { |
| 30 | - const body = { | |
| 31 | - system: [{ text: "system message 1" }, { text: "system message 2" }], | |
| 32 | - messages: [{ content: "user message" }], | |
| 48 | + const body: MessageCreateParams = { | |
| 49 | + system: [ | |
| 50 | + { type: "text", text: "system message 1" }, | |
| 51 | + { type: "text", text: "system message 2" }, | |
| 52 | + ], | |
| 53 | + messages: [{ role: "user", content: "user message" }], | |
| 54 | + ...body_params, | |
| 33 | 55 | }; |
| 34 | 56 | |
| 35 | 57 | const result = CACHING_STRATEGIES.systemOnly(body); |
| 36 | 58 | |
| 37 | 59 | expect(result.system).toEqual([ |
| 38 | - { text: "system message 1", cache_control: { type: "ephemeral" } }, | |
| 39 | - { text: "system message 2", cache_control: { type: "ephemeral" } }, | |
| 60 | + { | |
| 61 | + type: "text", | |
| 62 | + text: "system message 1", | |
| 63 | + cache_control: { type: "ephemeral" }, | |
| 64 | + }, | |
| 65 | + { | |
| 66 | + type: "text", | |
| 67 | + text: "system message 2", | |
| 68 | + cache_control: { type: "ephemeral" }, | |
| 69 | + }, | |
| 40 | 70 | ]); |
| 41 | 71 | expect(result.messages).toEqual(body.messages); |
| 42 | 72 | }); |
| 43 | 73 | |
| 44 | 74 | it("should return body unchanged if system is not an array", () => { |
| 45 | - const body = { | |
| 75 | + const body: MessageCreateParams = { | |
| 46 | 76 | system: "string system message", |
| 47 | - messages: [{ content: "user message" }], | |
| 77 | + messages: [{ role: "user", content: "user message" }], | |
| 78 | + ...body_params, | |
| 48 | 79 | }; |
| 49 | 80 | |
| 50 | 81 | const result = CACHING_STRATEGIES.systemOnly(body); |
| @@ -52,8 +83,9 @@ | ||
| 52 | 83 | }); |
| 53 | 84 | |
| 54 | 85 | it("should return body unchanged if system is undefined", () => { |
| 55 | - const body = { | |
| 56 | - messages: [{ content: "user message" }], | |
| 86 | + const body: MessageCreateParams = { | |
| 87 | + messages: [{ role: "user", content: "user message" }], | |
| 88 | + ...body_params, | |
| 57 | 89 | }; |
| 58 | 90 | |
| 59 | 91 | const result = CACHING_STRATEGIES.systemOnly(body); |
| @@ -61,25 +93,42 @@ | ||
| 61 | 93 | }); |
| 62 | 94 | |
| 63 | 95 | it("should not add more than 5 cached messages", () => { |
| 64 | - const body = { | |
| 96 | + const body: MessageCreateParams = { | |
| 65 | 97 | system: [ |
| 66 | - { text: "system message 1" }, | |
| 67 | - { text: "system message 2" }, | |
| 68 | - { text: "system message 3" }, | |
| 69 | - { text: "system message 4" }, | |
| 70 | - { text: "system message 5" }, | |
| 98 | + { type: "text", text: "system message 1" }, | |
| 99 | + { type: "text", text: "system message 2" }, | |
| 100 | + { type: "text", text: "system message 3" }, | |
| 101 | + { type: "text", text: "system message 4" }, | |
| 102 | + { type: "text", text: "system message 5" }, | |
| 71 | 103 | ], |
| 72 | - messages: [{ content: "user message" }], | |
| 104 | + messages: [{ role: "user", content: "user message" }], | |
| 105 | + ...body_params, | |
| 73 | 106 | }; |
| 74 | 107 | |
| 75 | 108 | const result = CACHING_STRATEGIES.systemOnly(body); |
| 76 | 109 | |
| 77 | 110 | expect(result.system).toEqual([ |
| 78 | - { text: "system message 1", cache_control: { type: "ephemeral" } }, | |
| 79 | - { text: "system message 2", cache_control: { type: "ephemeral" } }, | |
| 80 | - { text: "system message 3", cache_control: { type: "ephemeral" } }, | |
| 81 | - { text: "system message 4", cache_control: { type: "ephemeral" } }, | |
| 82 | - { text: "system message 5" }, | |
| 111 | + { | |
| 112 | + type: "text", | |
| 113 | + text: "system message 1", | |
| 114 | + cache_control: { type: "ephemeral" }, | |
| 115 | + }, | |
| 116 | + { | |
| 117 | + type: "text", | |
| 118 | + text: "system message 2", | |
| 119 | + cache_control: { type: "ephemeral" }, | |
| 120 | + }, | |
| 121 | + { | |
| 122 | + type: "text", | |
| 123 | + text: "system message 3", | |
| 124 | + cache_control: { type: "ephemeral" }, | |
| 125 | + }, | |
| 126 | + { | |
| 127 | + type: "text", | |
| 128 | + text: "system message 4", | |
| 129 | + cache_control: { type: "ephemeral" }, | |
| 130 | + }, | |
| 131 | + { type: "text", text: "system message 5" }, | |
| 83 | 132 | ]); |
| 84 | 133 | expect(result.messages).toEqual(body.messages); |
| 85 | 134 | }); |
| @@ -87,82 +136,116 @@ | ||
| 87 | 136 | |
| 88 | 137 | describe("systemAndToolsStrategy", () => { |
| 89 | 138 | it("should add cache_control to both system and tools", () => { |
| 90 | - const body = { | |
| 91 | - system: [{ text: "system message" }], | |
| 92 | - tools: [{ name: "tool1" }, { name: "tool2" }], | |
| 93 | - messages: [{ content: "user message" }], | |
| 139 | + const body: MessageCreateParams = { | |
| 140 | + system: [{ type: "text", text: "system message" }], | |
| 141 | + tools: [makeTool("tool1"), makeTool("tool2")], | |
| 142 | + messages: [{ role: "user", content: "user message" }], | |
| 143 | + ...body_params, | |
| 94 | 144 | }; |
| 95 | 145 | |
| 96 | 146 | const result = CACHING_STRATEGIES.systemAndTools(body); |
| 97 | 147 | |
| 98 | 148 | expect(result.system).toEqual([ |
| 99 | - { text: "system message", cache_control: { type: "ephemeral" } }, | |
| 149 | + { | |
| 150 | + type: "text", | |
| 151 | + text: "system message", | |
| 152 | + cache_control: { type: "ephemeral" }, | |
| 153 | + }, | |
| 100 | 154 | ]); |
| 101 | 155 | expect(result.tools).toEqual([ |
| 102 | - { name: "tool1" }, | |
| 103 | - { name: "tool2", cache_control: { type: "ephemeral" } }, | |
| 156 | + { | |
| 157 | + name: "tool1", | |
| 158 | + input_schema: { | |
| 159 | + type: "object", | |
| 160 | + }, | |
| 161 | + }, | |
| 162 | + { | |
| 163 | + name: "tool2", | |
| 164 | + input_schema: { | |
| 165 | + type: "object", | |
| 166 | + }, | |
| 167 | + cache_control: { type: "ephemeral" }, | |
| 168 | + }, | |
| 104 | 169 | ]); |
| 105 | 170 | expect(result.messages).toEqual(body.messages); |
| 106 | 171 | }); |
| 107 | 172 | |
| 108 | 173 | it("should handle missing system messages", () => { |
| 109 | - const body = { | |
| 110 | - tools: [{ name: "tool1" }], | |
| 111 | - messages: [{ content: "user message" }], | |
| 174 | + const body: MessageCreateParams = { | |
| 175 | + tools: [makeTool("tool1")], | |
| 176 | + messages: [{ role: "user", content: "user message" }], | |
| 177 | + ...body_params, | |
| 112 | 178 | }; |
| 113 | 179 | |
| 114 | 180 | const result = CACHING_STRATEGIES.systemAndTools(body); |
| 115 | 181 | |
| 116 | 182 | expect(result.tools).toEqual([ |
| 117 | - { name: "tool1", cache_control: { type: "ephemeral" } }, | |
| 183 | + { | |
| 184 | + name: "tool1", | |
| 185 | + input_schema: { | |
| 186 | + type: "object", | |
| 187 | + }, | |
| 188 | + cache_control: { type: "ephemeral" }, | |
| 189 | + }, | |
| 118 | 190 | ]); |
| 119 | 191 | expect(result.messages).toEqual(body.messages); |
| 120 | 192 | }); |
| 121 | 193 | |
| 122 | 194 | it("should handle missing tools", () => { |
| 123 | - const body = { | |
| 124 | - system: [{ text: "system message" }], | |
| 125 | - messages: [{ content: "user message" }], | |
| 195 | + const body: MessageCreateParams = { | |
| 196 | + system: [{ type: "text", text: "system message" }], | |
| 197 | + messages: [{ role: "user", content: "user message" }], | |
| 198 | + ...body_params, | |
| 126 | 199 | }; |
| 127 | 200 | |
| 128 | 201 | const result = CACHING_STRATEGIES.systemAndTools(body); |
| 129 | 202 | |
| 130 | 203 | expect(result.system).toEqual([ |
| 131 | - { text: "system message", cache_control: { type: "ephemeral" } }, | |
| 204 | + { | |
| 205 | + type: "text", | |
| 206 | + text: "system message", | |
| 207 | + cache_control: { type: "ephemeral" }, | |
| 208 | + }, | |
| 132 | 209 | ]); |
| 133 | 210 | expect(result.messages).toEqual(body.messages); |
| 134 | 211 | }); |
| 135 | 212 | |
| 136 | - it("should handle non-array system and tools", () => { | |
| 137 | - const body = { | |
| 138 | - system: "string system", | |
| 139 | - tools: "string tools", | |
| 140 | - messages: [{ content: "user message" }], | |
| 141 | - }; | |
| 142 | - | |
| 143 | - const result = CACHING_STRATEGIES.systemAndTools(body); | |
| 144 | - expect(result).toEqual(body); | |
| 145 | - }); | |
| 146 | - | |
| 147 | 213 | it("should add only 4 cache controls in total to both system and tools", () => { |
| 148 | - const body = { | |
| 214 | + const body: MessageCreateParams = { | |
| 149 | 215 | system: [ |
| 150 | - { text: "system message 1" }, | |
| 151 | - { text: "system message 2" }, | |
| 152 | - { text: "system message 3" }, | |
| 153 | - { text: "system message 4" }, | |
| 216 | + { type: "text", text: "system message 1" }, | |
| 217 | + { type: "text", text: "system message 2" }, | |
| 218 | + { type: "text", text: "system message 3" }, | |
| 219 | + { type: "text", text: "system message 4" }, | |
| 154 | 220 | ], |
| 155 | - tools: [{ name: "tool1" }, { name: "tool2" }], | |
| 156 | - messages: [{ content: "user message" }], | |
| 221 | + tools: [makeTool("tool1"), makeTool("tool2")], | |
| 222 | + messages: [{ role: "user", content: "user message" }], | |
| 223 | + ...body_params, | |
| 157 | 224 | }; |
| 158 | 225 | |
| 159 | 226 | const result = CACHING_STRATEGIES.systemAndTools(body); |
| 160 | 227 | |
| 161 | 228 | expect(result.system).toEqual([ |
| 162 | - { text: "system message 1", cache_control: { type: "ephemeral" } }, | |
| 163 | - { text: "system message 2", cache_control: { type: "ephemeral" } }, | |
| 164 | - { text: "system message 3", cache_control: { type: "ephemeral" } }, | |
| 165 | - { text: "system message 4", cache_control: { type: "ephemeral" } }, | |
| 229 | + { | |
| 230 | + type: "text", | |
| 231 | + text: "system message 1", | |
| 232 | + cache_control: { type: "ephemeral" }, | |
| 233 | + }, | |
| 234 | + { | |
| 235 | + type: "text", | |
| 236 | + text: "system message 2", | |
| 237 | + cache_control: { type: "ephemeral" }, | |
| 238 | + }, | |
| 239 | + { | |
| 240 | + type: "text", | |
| 241 | + text: "system message 3", | |
| 242 | + cache_control: { type: "ephemeral" }, | |
| 243 | + }, | |
| 244 | + { | |
| 245 | + type: "text", | |
| 246 | + text: "system message 4", | |
| 247 | + cache_control: { type: "ephemeral" }, | |
| 248 | + }, | |
| 166 | 249 | ]); |
| 167 | 250 | expect(result.tools).toEqual(body.tools); |
| 168 | 251 | expect(result.messages).toEqual(body.messages); |
| @@ -171,32 +254,45 @@ | ||
| 171 | 254 | |
| 172 | 255 | describe("optimizedStrategy", () => { |
| 173 | 256 | it("should cache system messages and tools", () => { |
| 174 | - const body = { | |
| 175 | - system: [{ text: "system message" }], | |
| 176 | - tools: [{ name: "tool1" }], | |
| 177 | - messages: [{ content: "short message" }], | |
| 257 | + const body: MessageCreateParams = { | |
| 258 | + system: [{ type: "text", text: "system message" }], | |
| 259 | + tools: [makeTool("tool1")], | |
| 260 | + messages: [{ role: "user", content: "short message" }], | |
| 261 | + ...body_params, | |
| 178 | 262 | }; |
| 179 | 263 | |
| 180 | 264 | const result = CACHING_STRATEGIES.optimized(body); |
| 181 | 265 | |
| 182 | 266 | expect(result.system).toEqual([ |
| 183 | - { text: "system message", cache_control: { type: "ephemeral" } }, | |
| 267 | + { | |
| 268 | + type: "text", | |
| 269 | + text: "system message", | |
| 270 | + cache_control: { type: "ephemeral" }, | |
| 271 | + }, | |
| 184 | 272 | ]); |
| 185 | 273 | expect(result.tools).toEqual([ |
| 186 | - { name: "tool1", cache_control: { type: "ephemeral" } }, | |
| 274 | + { | |
| 275 | + name: "tool1", | |
| 276 | + input_schema: { | |
| 277 | + type: "object", | |
| 278 | + }, | |
| 279 | + cache_control: { type: "ephemeral" }, | |
| 280 | + }, | |
| 187 | 281 | ]); |
| 188 | 282 | }); |
| 189 | 283 | |
| 190 | 284 | it("should cache large string messages (>500 tokens)", () => { |
| 191 | 285 | const largeContent = "a".repeat(2100); // ~525 tokens |
| 192 | - const body = { | |
| 193 | - messages: [{ content: largeContent }], | |
| 286 | + const body: MessageCreateParams = { | |
| 287 | + messages: [{ role: "user", content: largeContent }], | |
| 288 | + ...body_params, | |
| 194 | 289 | }; |
| 195 | 290 | |
| 196 | 291 | const result = CACHING_STRATEGIES.optimized(body); |
| 197 | 292 | |
| 198 | 293 | expect(result.messages).toEqual([ |
| 199 | 294 | { |
| 295 | + role: "user", | |
| 200 | 296 | content: [ |
| 201 | 297 | { |
| 202 | 298 | type: "text", |
| @@ -210,30 +306,42 @@ | ||
| 210 | 306 | |
| 211 | 307 | it("should not cache small string messages (<500 tokens)", () => { |
| 212 | 308 | const smallContent = "a".repeat(100); // ~25 tokens |
| 213 | - const body = { | |
| 214 | - messages: [{ content: smallContent }], | |
| 309 | + const body: MessageCreateParams = { | |
| 310 | + messages: [{ role: "user", content: smallContent }], | |
| 311 | + ...body_params, | |
| 215 | 312 | }; |
| 216 | 313 | |
| 217 | 314 | const result = CACHING_STRATEGIES.optimized(body); |
| 218 | 315 | |
| 219 | - expect(result.messages).toEqual([{ content: smallContent }]); | |
| 316 | + expect(result.messages).toEqual([ | |
| 317 | + { role: "user", content: smallContent }, | |
| 318 | + ]); | |
| 220 | 319 | }); |
| 221 | 320 | |
| 222 | 321 | it("should cache large text items in array content but only once per message", () => { |
| 223 | 322 | const largeText = "a".repeat(2100); // ~525 tokens |
| 224 | 323 | const anotherLargeText = "b".repeat(2100); // Also ~525 tokens |
| 225 | 324 | const smallText = "a".repeat(100); // ~25 tokens |
| 226 | - const body = { | |
| 325 | + const body: MessageCreateParams = { | |
| 227 | 326 | messages: [ |
| 228 | 327 | { |
| 328 | + role: "user", | |
| 229 | 329 | content: [ |
| 230 | 330 | { type: "text", text: largeText }, |
| 231 | 331 | { type: "text", text: anotherLargeText }, |
| 232 | 332 | { type: "text", text: smallText }, |
| 233 | - { type: "image", data: "image_data" }, | |
| 333 | + { | |
| 334 | + type: "image", | |
| 335 | + source: { | |
| 336 | + data: "image_data", | |
| 337 | + media_type: "image/jpeg", | |
| 338 | + type: "base64", | |
| 339 | + }, | |
| 340 | + }, | |
| 234 | 341 | ], |
| 235 | 342 | }, |
| 236 | 343 | ], |
| 344 | + ...body_params, | |
| 237 | 345 | }; |
| 238 | 346 | |
| 239 | 347 | const result = CACHING_STRATEGIES.optimized(body); |
| @@ -241,6 +349,7 @@ | ||
| 241 | 349 | // Only the first large text item should get cache_control |
| 242 | 350 | expect(result.messages).toEqual([ |
| 243 | 351 | { |
| 352 | + role: "user", | |
| 244 | 353 | content: [ |
| 245 | 354 | { |
| 246 | 355 | type: "text", |
| @@ -249,40 +358,78 @@ | ||
| 249 | 358 | }, |
| 250 | 359 | { type: "text", text: anotherLargeText }, |
| 251 | 360 | { type: "text", text: smallText }, |
| 252 | - { type: "image", data: "image_data" }, | |
| 361 | + { | |
| 362 | + type: "image", | |
| 363 | + source: { | |
| 364 | + data: "image_data", | |
| 365 | + media_type: "image/jpeg", | |
| 366 | + type: "base64", | |
| 367 | + }, | |
| 368 | + }, | |
| 253 | 369 | ], |
| 254 | 370 | }, |
| 255 | 371 | ]); |
| 256 | 372 | }); |
| 257 | 373 | |
| 258 | 374 | it("should add maximum 4 cache control blocks", () => { |
| 259 | - const body = { | |
| 260 | - system: [{ text: "system message 1" }, { text: "system message 2" }], | |
| 261 | - tools: [{ name: "tool" }], | |
| 375 | + const body: MessageCreateParams = { | |
| 376 | + system: [ | |
| 377 | + { type: "text", text: "system message 1" }, | |
| 378 | + { type: "text", text: "system message 2" }, | |
| 379 | + ], | |
| 380 | + tools: [makeTool("tool")], | |
| 262 | 381 | messages: [ |
| 263 | - { content: "small content" }, | |
| 264 | - { content: "a".repeat(2100) }, | |
| 265 | - { content: "b".repeat(2100) }, | |
| 382 | + { role: "user", content: "small content" }, | |
| 383 | + { role: "user", content: "a".repeat(2100) }, | |
| 384 | + { role: "user", content: "b".repeat(2100) }, | |
| 266 | 385 | { |
| 386 | + role: "user", | |
| 267 | 387 | content: [ |
| 268 | 388 | { type: "text", text: "c".repeat(2100) }, |
| 269 | - { type: "image", data: "image" }, | |
| 389 | + { | |
| 390 | + type: "image", | |
| 391 | + source: { | |
| 392 | + data: "image_data", | |
| 393 | + media_type: "image/jpeg", | |
| 394 | + type: "base64", | |
| 395 | + }, | |
| 396 | + }, | |
| 270 | 397 | ], |
| 271 | 398 | }, |
| 272 | 399 | ], |
| 400 | + ...body_params, | |
| 273 | 401 | }; |
| 274 | 402 | |
| 275 | 403 | const result = CACHING_STRATEGIES.optimized(body); |
| 276 | 404 | |
| 277 | 405 | expect(result.system).toEqual([ |
| 278 | - { text: "system message 1", cache_control: { type: "ephemeral" } }, | |
| 279 | - { text: "system message 2", cache_control: { type: "ephemeral" } }, | |
| 406 | + { | |
| 407 | + type: "text", | |
| 408 | + text: "system message 1", | |
| 409 | + cache_control: { type: "ephemeral" }, | |
| 410 | + }, | |
| 411 | + { | |
| 412 | + type: "text", | |
| 413 | + text: "system message 2", | |
| 414 | + cache_control: { type: "ephemeral" }, | |
| 415 | + }, | |
| 280 | 416 | ]); |
| 281 | 417 | expect(result.tools).toEqual([ |
| 282 | - { name: "tool", cache_control: { type: "ephemeral" } }, | |
| 418 | + { | |
| 419 | + name: "tool", | |
| 420 | + input_schema: { | |
| 421 | + type: "object", | |
| 422 | + }, | |
| 423 | + cache_control: { type: "ephemeral" }, | |
| 424 | + }, | |
| 283 | 425 | ]); |
| 284 | - expect(result.messages[0]).toEqual({ content: "small content" }); | |
| 426 | + expect(result.messages[0]).toEqual({ | |
| 427 | + role: "user", | |
| 428 | + content: "small content", | |
| 429 | + }); | |
| 430 | + | |
| 285 | 431 | expect(result.messages[1]).toEqual({ |
| 432 | + role: "user", | |
| 286 | 433 | content: [ |
| 287 | 434 | { |
| 288 | 435 | type: "text", |
| @@ -296,31 +443,50 @@ | ||
| 296 | 443 | }); |
| 297 | 444 | |
| 298 | 445 | it("should handle complex message structure", () => { |
| 299 | - const body = { | |
| 300 | - system: [{ text: "system" }], | |
| 301 | - tools: [{ name: "tool" }], | |
| 446 | + const body: MessageCreateParams = { | |
| 447 | + system: [{ type: "text", text: "system" }], | |
| 448 | + tools: [makeTool("tool")], | |
| 302 | 449 | messages: [ |
| 303 | - { content: "small content" }, | |
| 304 | - { content: "a".repeat(2100) }, // large content | |
| 450 | + { role: "user", content: "small content" }, | |
| 451 | + { role: "user", content: "a".repeat(2100) }, // large content | |
| 305 | 452 | { |
| 453 | + role: "user", | |
| 306 | 454 | content: [ |
| 307 | 455 | { type: "text", text: "a".repeat(2100) }, // large text |
| 308 | - { type: "image", data: "image" }, | |
| 456 | + { | |
| 457 | + type: "image", | |
| 458 | + source: { | |
| 459 | + data: "image_data", | |
| 460 | + media_type: "image/jpeg", | |
| 461 | + type: "base64", | |
| 462 | + }, | |
| 463 | + }, | |
| 309 | 464 | ], |
| 310 | 465 | }, |
| 311 | 466 | ], |
| 467 | + ...body_params, | |
| 312 | 468 | }; |
| 313 | 469 | |
| 314 | 470 | const result = CACHING_STRATEGIES.optimized(body); |
| 315 | 471 | |
| 316 | 472 | expect(result.system).toEqual([ |
| 317 | - { text: "system", cache_control: { type: "ephemeral" } }, | |
| 473 | + { type: "text", text: "system", cache_control: { type: "ephemeral" } }, | |
| 318 | 474 | ]); |
| 319 | 475 | expect(result.tools).toEqual([ |
| 320 | - { name: "tool", cache_control: { type: "ephemeral" } }, | |
| 476 | + { | |
| 477 | + name: "tool", | |
| 478 | + input_schema: { | |
| 479 | + type: "object", | |
| 480 | + }, | |
| 481 | + cache_control: { type: "ephemeral" }, | |
| 482 | + }, | |
| 321 | 483 | ]); |
| 322 | - expect(result.messages[0]).toEqual({ content: "small content" }); | |
| 484 | + expect(result.messages[0]).toEqual({ | |
| 485 | + role: "user", | |
| 486 | + content: "small content", | |
| 487 | + }); | |
| 323 | 488 | expect(result.messages[1]).toEqual({ |
| 489 | + role: "user", | |
| 324 | 490 | content: [ |
| 325 | 491 | { |
| 326 | 492 | type: "text", |
| @@ -337,30 +503,17 @@ | ||
| 337 | 503 | }); |
| 338 | 504 | |
| 339 | 505 | it("should handle empty or missing messages", () => { |
| 340 | - const body = { | |
| 341 | - system: [{ text: "system" }], | |
| 342 | - }; | |
| 343 | - | |
| 344 | - const result = CACHING_STRATEGIES.optimized(body); | |
| 345 | - | |
| 346 | - expect(result.system).toEqual([ | |
| 347 | - { text: "system", cache_control: { type: "ephemeral" } }, | |
| 348 | - ]); | |
| 349 | - expect(result.messages).toBeUndefined(); | |
| 350 | - }); | |
| 351 | - | |
| 352 | - it("should handle non-array messages", () => { | |
| 353 | - const body = { | |
| 354 | - system: [{ text: "system" }], | |
| 355 | - messages: "not an array", | |
| 506 | + const body: MessageCreateParams = { | |
| 507 | + system: [{ type: "text", text: "system" }], | |
| 508 | + messages: [], | |
| 509 | + ...body_params, | |
| 356 | 510 | }; |
| 357 | 511 | |
| 358 | 512 | const result = CACHING_STRATEGIES.optimized(body); |
| 359 | 513 | |
| 360 | 514 | expect(result.system).toEqual([ |
| 361 | - { text: "system", cache_control: { type: "ephemeral" } }, | |
| 515 | + { type: "text", text: "system", cache_control: { type: "ephemeral" } }, | |
| 362 | 516 | ]); |
| 363 | - expect(result.messages).toBe("not an array"); | |
| 364 | 517 | }); |
| 365 | 518 | }); |
| 366 | 519 | |
| @@ -370,8 +523,14 @@ | ||
| 370 | 523 | const smallContent = "a".repeat(100); // ~25 tokens |
| 371 | 524 | const largeContent = "a".repeat(2100); // ~525 tokens |
| 372 | 525 | |
| 373 | - const bodySmall = { messages: [{ content: smallContent }] }; | |
| 374 | - const bodyLarge = { messages: [{ content: largeContent }] }; | |
| 526 | + const bodySmall: MessageCreateParams = { | |
| 527 | + messages: [{ role: "user", content: smallContent }], | |
| 528 | + ...body_params, | |
| 529 | + }; | |
| 530 | + const bodyLarge: MessageCreateParams = { | |
| 531 | + messages: [{ role: "user", content: largeContent }], | |
| 532 | + ...body_params, | |
| 533 | + }; | |
| 375 | 534 | |
| 376 | 535 | const resultSmall = CACHING_STRATEGIES.optimized(bodySmall); |
| 377 | 536 | const resultLarge = CACHING_STRATEGIES.optimized(bodyLarge); |
| @@ -429,21 +588,6 @@ | ||
| 429 | 588 | }); |
| 430 | 589 | }); |
| 431 | 590 | }); |
| 432 | - | |
| 433 | - describe("CachingStrategy type", () => { | |
| 434 | - it("should accept valid caching strategy functions", () => { | |
| 435 | - const customStrategy: CachingStrategy = (body) => ({ | |
| 436 | - ...body, | |
| 437 | - custom: true, | |
| 438 | - }); | |
| 439 | - | |
| 440 | - const input = { test: "value" }; | |
| 441 | - const result = customStrategy(input); | |
| 442 | - | |
| 443 | - expect(result).toEqual({ test: "value", custom: true }); | |
| 444 | - }); | |
| 445 | - }); | |
| 446 | - | |
| 447 | 591 | describe("CachingStrategyName type", () => { |
| 448 | 592 | it("should work with valid strategy names", () => { |
| 449 | 593 | const strategyNames: CachingStrategyName[] = [ |
| @@ -1,21 +1,25 @@ | ||
| 1 | +import { MessageCreateParams } from "@anthropic-ai/sdk/resources"; | |
| 2 | + | |
| 1 | 3 | const MAX_CACHING_MESSAGES = 4; |
| 2 | 4 | |
| 3 | 5 | // Caching strategy type - transforms a clean Anthropic body by adding cache_control |
| 4 | -export type CachingStrategy = (anthropicBody: any) => any; | |
| 6 | +export type CachingStrategy = ( | |
| 7 | + anthropicBody: MessageCreateParams, | |
| 8 | +) => MessageCreateParams; | |
| 5 | 9 | |
| 6 | 10 | // Utility function to estimate token count |
| 7 | 11 | const estimateTokenCount = (text: string): number => Math.ceil(text.length / 4); |
| 8 | 12 | |
| 9 | -// Strategy 1: No Caching (Baseline) | |
| 13 | +// Strategy 1: No Caching | |
| 10 | 14 | const noCachingStrategy: CachingStrategy = (body) => body; |
| 11 | 15 | |
| 12 | -// Strategy 2: System Messages Only (Current Implementation) | |
| 16 | +// Strategy 2: System Messages Only | |
| 13 | 17 | const systemOnlyStrategy: CachingStrategy = (body) => { |
| 14 | 18 | let availableCacheMessages = MAX_CACHING_MESSAGES; |
| 15 | 19 | if (body.system && Array.isArray(body.system)) { |
| 16 | 20 | return { |
| 17 | 21 | ...body, |
| 18 | - system: body.system.map((item: any) => { | |
| 22 | + system: body.system.map((item) => { | |
| 19 | 23 | if (availableCacheMessages > 0) { |
| 20 | 24 | availableCacheMessages -= 1; |
| 21 | 25 | return { |
| @@ -37,7 +41,7 @@ | ||
| 37 | 41 | |
| 38 | 42 | // Cache system messages |
| 39 | 43 | if (result.system && Array.isArray(result.system)) { |
| 40 | - result.system = result.system.map((item: any) => { | |
| 44 | + result.system = result.system.map((item) => { | |
| 41 | 45 | if (availableCacheMessages > 0) { |
| 42 | 46 | availableCacheMessages -= 1; |
| 43 | 47 | return { |
| @@ -51,8 +55,8 @@ | ||
| 51 | 55 | |
| 52 | 56 | // Cache tool definitions |
| 53 | 57 | if (result.tools && Array.isArray(result.tools) && result.tools.length > 0) { |
| 54 | - result.tools = result.tools.map((tool: any, index: number) => { | |
| 55 | - if (index === result.tools.length - 1 && availableCacheMessages > 0) { | |
| 58 | + result.tools = result.tools.map((tool, index: number) => { | |
| 59 | + if (index === result.tools!.length - 1 && availableCacheMessages > 0) { | |
| 56 | 60 | availableCacheMessages -= 1; |
| 57 | 61 | return { |
| 58 | 62 | ...tool, |
| @@ -73,7 +77,7 @@ | ||
| 73 | 77 | |
| 74 | 78 | // Always cache system messages |
| 75 | 79 | if (result.system && Array.isArray(result.system)) { |
| 76 | - result.system = result.system.map((item: any) => { | |
| 80 | + result.system = result.system.map((item) => { | |
| 77 | 81 | if (availableCacheMessages > 0) { |
| 78 | 82 | availableCacheMessages -= 1; |
| 79 | 83 | return { |
| @@ -87,8 +91,8 @@ | ||
| 87 | 91 | |
| 88 | 92 | // Cache tool definitions |
| 89 | 93 | if (result.tools && Array.isArray(result.tools) && result.tools.length > 0) { |
| 90 | - result.tools = result.tools.map((tool: any, index: number) => { | |
| 91 | - if (index === result.tools.length - 1 && availableCacheMessages > 0) { | |
| 94 | + result.tools = result.tools.map((tool, index: number) => { | |
| 95 | + if (index === result.tools!.length - 1 && availableCacheMessages > 0) { | |
| 92 | 96 | availableCacheMessages -= 1; |
| 93 | 97 | return { |
| 94 | 98 | ...tool, |
| @@ -101,7 +105,7 @@ | ||
| 101 | 105 | |
| 102 | 106 | // Cache large messages (>500 tokens) |
| 103 | 107 | if (result.messages && Array.isArray(result.messages)) { |
| 104 | - result.messages = result.messages.map((message: any) => { | |
| 108 | + result.messages = result.messages.map((message) => { | |
| 105 | 109 | if (message.content && typeof message.content === "string") { |
| 106 | 110 | const tokens = estimateTokenCount(message.content); |
| 107 | 111 | if (tokens > 500 && availableCacheMessages > 0) { |
| @@ -112,7 +116,7 @@ | ||
| 112 | 116 | { |
| 113 | 117 | type: "text", |
| 114 | 118 | text: message.content, |
| 115 | - cache_control: { type: "ephemeral" }, | |
| 119 | + cache_control: { type: "ephemeral" as const }, | |
| 116 | 120 | }, |
| 117 | 121 | ], |
| 118 | 122 | }; |
| @@ -120,7 +124,7 @@ | ||
| 120 | 124 | } else if (message.content && Array.isArray(message.content)) { |
| 121 | 125 | // Only add one cache control per message with array content |
| 122 | 126 | let addedCacheControl = false; |
| 123 | - const updatedContent = message.content.map((item: any) => { | |
| 127 | + const updatedContent = message.content.map((item) => { | |
| 124 | 128 | if (item.type === "text" && item.text) { |
| 125 | 129 | const tokens = estimateTokenCount(item.text); |
| 126 | 130 | if ( |
| @@ -132,7 +136,7 @@ | ||
| 132 | 136 | addedCacheControl = true; |
| 133 | 137 | return { |
| 134 | 138 | ...item, |
| 135 | - cache_control: { type: "ephemeral" }, | |
| 139 | + cache_control: { type: "ephemeral" as const }, | |
| 136 | 140 | }; |
| 137 | 141 | } |
| 138 | 142 | } |
| @@ -0,0 +1,139 @@ | ||
| 1 | +import { | |
| 2 | + Base64ImageSource, | |
| 3 | + ErrorResponse, | |
| 4 | + MessageParam, | |
| 5 | + Tool, | |
| 6 | + ToolChoice, | |
| 7 | +} from "@anthropic-ai/sdk/resources"; | |
| 8 | +import { | |
| 9 | + ChatCompletionTool, | |
| 10 | + ChatCompletionToolChoiceOption, | |
| 11 | +} from "openai/resources"; | |
| 12 | + | |
| 13 | +export function getAnthropicErrorMessage(response: ErrorResponse): string { | |
| 14 | + switch (response.error.type) { | |
| 15 | + case "api_error": | |
| 16 | + return "An unexpected error has occurred internal to Anthropic's systems."; | |
| 17 | + case "invalid_request_error": | |
| 18 | + return "There was an issue with the format or content of your request."; | |
| 19 | + case "authentication_error": | |
| 20 | + return "There's an issue with your API key."; | |
| 21 | + case "permission_error": | |
| 22 | + return "Your API key does not have permission to use the specified resource."; | |
| 23 | + case "not_found_error": | |
| 24 | + return "The requested resource was not found."; | |
| 25 | + case "rate_limit_error": | |
| 26 | + return "Your account has hit a rate limit."; | |
| 27 | + case "overloaded_error": | |
| 28 | + return "Anthropic's API is temporarily overloaded. Please check their status page: https://status.anthropic.com/#past-incidents"; | |
| 29 | + case "timeout_error": | |
| 30 | + return "Anthropic API timed out. Please check their status page: https://status.anthropic.com/#past-incidents"; | |
| 31 | + case "billing_error": | |
| 32 | + default: | |
| 33 | + return response.error.message; | |
| 34 | + } | |
| 35 | +} | |
| 36 | + | |
| 37 | +export function getAnthropicHeaders( | |
| 38 | + apiKey: string, | |
| 39 | + enableCaching: boolean, | |
| 40 | +): Record<string, string> { | |
| 41 | + const headers: Record<string, string> = { | |
| 42 | + "Content-Type": "application/json", | |
| 43 | + Accept: "application/json", | |
| 44 | + "anthropic-version": "2023-06-01", | |
| 45 | + "x-api-key": apiKey, | |
| 46 | + }; | |
| 47 | + | |
| 48 | + if (enableCaching) { | |
| 49 | + headers["anthropic-beta"] = "prompt-caching-2024-07-31"; | |
| 50 | + } | |
| 51 | + return headers; | |
| 52 | +} | |
| 53 | + | |
| 54 | +export function addCacheControlToLastTwoUserMessages(messages: MessageParam[]) { | |
| 55 | + let userMessages = 0; | |
| 56 | + for (let i = messages.length - 1; i >= 0; i--) { | |
| 57 | + const msg = messages[i]; | |
| 58 | + if (msg.role === "user") { | |
| 59 | + userMessages++; | |
| 60 | + if (typeof msg.content === "string") { | |
| 61 | + continue; | |
| 62 | + } | |
| 63 | + for (let j = msg.content.length - 1; j >= 0; j--) { | |
| 64 | + const part = msg.content[j]; | |
| 65 | + if (part.type === "text") { | |
| 66 | + part.cache_control = { type: "ephemeral" }; | |
| 67 | + break; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + if (userMessages >= 2) { | |
| 71 | + break; | |
| 72 | + } | |
| 73 | + } | |
| 74 | + } | |
| 75 | +} | |
| 76 | + | |
| 77 | +export function openAiToolChoiceToAnthropicToolChoice( | |
| 78 | + toolChoice: ChatCompletionToolChoiceOption | undefined, | |
| 79 | +): ToolChoice | undefined { | |
| 80 | + if (!toolChoice) { | |
| 81 | + return undefined; | |
| 82 | + } | |
| 83 | + switch (toolChoice) { | |
| 84 | + case "none": | |
| 85 | + // "none" is handled by excluding tools | |
| 86 | + return undefined; | |
| 87 | + case "required": | |
| 88 | + return { | |
| 89 | + type: "any", | |
| 90 | + }; | |
| 91 | + case "auto": | |
| 92 | + return { | |
| 93 | + type: "auto", | |
| 94 | + }; | |
| 95 | + default: | |
| 96 | + switch (toolChoice.type) { | |
| 97 | + case "allowed_tools": | |
| 98 | + // Filtering of tools is handled elsewhere | |
| 99 | + return { | |
| 100 | + type: toolChoice.allowed_tools.mode === "auto" ? "auto" : "any", | |
| 101 | + }; | |
| 102 | + case "custom": | |
| 103 | + return undefined; // TODO not supported yet | |
| 104 | + case "function": | |
| 105 | + return { | |
| 106 | + type: "tool", | |
| 107 | + name: toolChoice.function.name, | |
| 108 | + }; | |
| 109 | + } | |
| 110 | + } | |
| 111 | +} | |
| 112 | + | |
| 113 | +export function openaiToolToAnthropicTool(tool: ChatCompletionTool): Tool { | |
| 114 | + if (tool.type === "function" && "function" in tool) { | |
| 115 | + return { | |
| 116 | + name: tool.function.name, | |
| 117 | + description: tool.function.description, | |
| 118 | + input_schema: tool.function.parameters as Tool.InputSchema, // TODO unsafe cast, may be differences between openai tool schema and anthropic tool schema, | |
| 119 | + }; | |
| 120 | + } else { | |
| 121 | + throw new Error(`Unsupported tool type in Anthropic: ${tool.type}`); | |
| 122 | + } | |
| 123 | +} | |
| 124 | + | |
| 125 | +// Extract media type from data URL (ex. "data:image/png;base64,..." -> "image/png") | |
| 126 | +export function getAnthropicMediaTypeFromDataUrl( | |
| 127 | + dataUrl: string, | |
| 128 | +): Base64ImageSource["media_type"] { | |
| 129 | + const match = dataUrl.match(/^data:([^;]+);base64,/); | |
| 130 | + if (match) { | |
| 131 | + switch (match[1]) { | |
| 132 | + case "image/png": | |
| 133 | + case "image/gif": | |
| 134 | + case "image/webp": | |
| 135 | + return match[1]; | |
| 136 | + } | |
| 137 | + } | |
| 138 | + return "image/jpeg"; | |
| 139 | +} |
| @@ -44,7 +44,7 @@ | ||
| 44 | 44 | function getSecureID(): string { |
| 45 | 45 | // Adding a type declaration for the static property |
| 46 | 46 | if (!(getSecureID as any).uuid) { |
| 47 | - (getSecureID as any).uuid = crypto.randomUUID(); | |
| 47 | + (getSecureID as any).uuid = uuidv4(); | |
| 48 | 48 | } |
| 49 | 49 | return `<!-- SID: ${(getSecureID as any).uuid} -->`; |
| 50 | 50 | } |
| @@ -0,0 +1,132 @@ | ||
| 1 | +import { | |
| 2 | + ChatCompletion, | |
| 3 | + ChatCompletionChunk, | |
| 4 | + ChatCompletionCreateParams, | |
| 5 | + ChatCompletionCreateParamsNonStreaming, | |
| 6 | + ChatCompletionCreateParamsStreaming, | |
| 7 | + Completion, | |
| 8 | + CompletionCreateParamsNonStreaming, | |
| 9 | + CompletionCreateParamsStreaming, | |
| 10 | + CreateEmbeddingResponse, | |
| 11 | + EmbeddingCreateParams, | |
| 12 | + Model, | |
| 13 | +} from "openai/resources/index"; | |
| 14 | +import { CometAPIConfig } from "../types.js"; | |
| 15 | +import { | |
| 16 | + BaseLlmApi, | |
| 17 | + CreateRerankResponse, | |
| 18 | + FimCreateParamsStreaming, | |
| 19 | + RerankCreateParams, | |
| 20 | +} from "./base.js"; | |
| 21 | +import { OpenAIApi } from "./OpenAI.js"; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * CometAPI adapter - extends OpenAI adapter since CometAPI is OpenAI-compatible | |
| 25 | + * | |
| 26 | + * CometAPI provides access to multiple LLM providers (GPT, Claude, Gemini, etc.) | |
| 27 | + * through a unified OpenAI-compatible API interface. | |
| 28 | + */ | |
| 29 | +export class CometAPIApi extends OpenAIApi implements BaseLlmApi { | |
| 30 | + // Store the original CometAPI config separately | |
| 31 | + private cometConfig: CometAPIConfig; | |
| 32 | + | |
| 33 | + constructor(config: CometAPIConfig) { | |
| 34 | + // CometAPI uses OpenAI-compatible API, so we can reuse OpenAI adapter | |
| 35 | + // Convert CometAPI config to OpenAI-compatible config for the base class | |
| 36 | + const openAICompatibleConfig = { | |
| 37 | + ...config, | |
| 38 | + provider: "openai" as const, | |
| 39 | + apiBase: config.apiBase ?? "https://api.cometapi.com/v1/", | |
| 40 | + }; | |
| 41 | + super(openAICompatibleConfig); | |
| 42 | + | |
| 43 | + // Store original config after super() call | |
| 44 | + this.cometConfig = config; | |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Override list method to handle CometAPI-specific model filtering | |
| 49 | + * The core filtering logic is handled in the CometAPI provider class | |
| 50 | + */ | |
| 51 | + async list(): Promise<Model[]> { | |
| 52 | + try { | |
| 53 | + return await super.list(); | |
| 54 | + } catch (error) { | |
| 55 | + // Fallback to empty list if model listing fails | |
| 56 | + console.warn("CometAPI: Failed to fetch model list", error); | |
| 57 | + return []; | |
| 58 | + } | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * Chat completion - uses OpenAI-compatible format | |
| 63 | + */ | |
| 64 | + async chatCompletionNonStream( | |
| 65 | + body: ChatCompletionCreateParamsNonStreaming, | |
| 66 | + signal: AbortSignal, | |
| 67 | + ): Promise<ChatCompletion> { | |
| 68 | + return super.chatCompletionNonStream(body, signal); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Streaming chat completion - uses OpenAI-compatible format | |
| 73 | + */ | |
| 74 | + async *chatCompletionStream( | |
| 75 | + body: ChatCompletionCreateParamsStreaming, | |
| 76 | + signal: AbortSignal, | |
| 77 | + ): AsyncGenerator<ChatCompletionChunk> { | |
| 78 | + yield* super.chatCompletionStream(body, signal); | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * Legacy completion endpoint support | |
| 83 | + */ | |
| 84 | + completionNonStream( | |
| 85 | + body: CompletionCreateParamsNonStreaming, | |
| 86 | + signal: AbortSignal, | |
| 87 | + ): Promise<Completion> { | |
| 88 | + return super.completionNonStream(body, signal); | |
| 89 | + } | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Legacy streaming completion endpoint support | |
| 93 | + */ | |
| 94 | + completionStream( | |
| 95 | + body: CompletionCreateParamsStreaming, | |
| 96 | + signal: AbortSignal, | |
| 97 | + ): AsyncGenerator<Completion> { | |
| 98 | + return super.completionStream(body, signal); | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Fill-in-the-middle completion support | |
| 103 | + */ | |
| 104 | + fimStream( | |
| 105 | + body: FimCreateParamsStreaming, | |
| 106 | + signal: AbortSignal, | |
| 107 | + ): AsyncGenerator<ChatCompletionChunk> { | |
| 108 | + return super.fimStream(body, signal); | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * Embeddings support (if available through CometAPI) | |
| 113 | + */ | |
| 114 | + async embed(body: EmbeddingCreateParams): Promise<CreateEmbeddingResponse> { | |
| 115 | + try { | |
| 116 | + return await super.embed(body); | |
| 117 | + } catch (error) { | |
| 118 | + throw new Error(`CometAPI embeddings not supported: ${error}`); | |
| 119 | + } | |
| 120 | + } | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Reranking support (if available through CometAPI) | |
| 124 | + */ | |
| 125 | + async rerank(body: RerankCreateParams): Promise<CreateRerankResponse> { | |
| 126 | + try { | |
| 127 | + return await super.rerank(body); | |
| 128 | + } catch (error) { | |
| 129 | + throw new Error(`CometAPI reranking not supported: ${error}`); | |
| 130 | + } | |
| 131 | + } | |
| 132 | +} |
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | import { WatsonXApi } from "./apis/WatsonX.js"; |
| 19 | 19 | import { BaseLlmApi } from "./apis/base.js"; |
| 20 | 20 | import { LLMConfig, OpenAIConfigSchema } from "./types.js"; |
| 21 | +import { CometAPIApi } from "./apis/CometAPI.js"; | |
| 21 | 22 | import { appendPathToUrlIfNotPresent } from "./util/appendPathToUrl.js"; |
| 22 | 23 | |
| 23 | 24 | dotenv.config(); |
| @@ -69,6 +70,8 @@ | ||
| 69 | 70 | return new BedrockApi(config); |
| 70 | 71 | case "cohere": |
| 71 | 72 | return new CohereApi(config); |
| 73 | + case "cometapi": | |
| 74 | + return new CometAPIApi(config); | |
| 72 | 75 | case "anthropic": |
| 73 | 76 | return new AnthropicApi(config); |
| 74 | 77 | case "gemini": |
| @@ -177,3 +180,10 @@ | ||
| 177 | 180 | // export |
| 178 | 181 | export type { BaseLlmApi } from "./apis/base.js"; |
| 179 | 182 | export type { LLMConfig } from "./types.js"; |
| 183 | + | |
| 184 | +export { | |
| 185 | + addCacheControlToLastTwoUserMessages, | |
| 186 | + getAnthropicErrorMessage, | |
| 187 | + getAnthropicHeaders, | |
| 188 | + getAnthropicMediaTypeFromDataUrl, | |
| 189 | +} from "./apis/AnthropicUtils.js"; |
| @@ -50,7 +50,17 @@ | ||
| 50 | 50 | "x-api-key": "test-api-key", |
| 51 | 51 | }, |
| 52 | 52 | body: { |
| 53 | - messages: [{ role: "user", content: "hello" }], | |
| 53 | + messages: [ | |
| 54 | + { | |
| 55 | + role: "user", | |
| 56 | + content: [ | |
| 57 | + { | |
| 58 | + type: "text", | |
| 59 | + text: "hello", | |
| 60 | + }, | |
| 61 | + ], | |
| 62 | + }, | |
| 63 | + ], | |
| 54 | 64 | system: undefined, |
| 55 | 65 | model: "claude-3-5-sonnet-20241022", |
| 56 | 66 | max_tokens: 32000, |
| @@ -104,7 +114,17 @@ | ||
| 104 | 114 | "x-api-key": "test-api-key", |
| 105 | 115 | }, |
| 106 | 116 | body: { |
| 107 | - messages: [{ role: "user", content: "hello" }], | |
| 117 | + messages: [ | |
| 118 | + { | |
| 119 | + role: "user", | |
| 120 | + content: [ | |
| 121 | + { | |
| 122 | + type: "text", | |
| 123 | + text: "hello", | |
| 124 | + }, | |
| 125 | + ], | |
| 126 | + }, | |
| 127 | + ], | |
| 108 | 128 | system: undefined, |
| 109 | 129 | model: "claude-3-5-sonnet-20241022", |
| 110 | 130 | max_tokens: 32000, |
| @@ -159,7 +179,17 @@ | ||
| 159 | 179 | "x-api-key": "test-api-key", |
| 160 | 180 | }, |
| 161 | 181 | body: { |
| 162 | - messages: [{ role: "user", content: "hello" }], | |
| 182 | + messages: [ | |
| 183 | + { | |
| 184 | + role: "user", | |
| 185 | + content: [ | |
| 186 | + { | |
| 187 | + type: "text", | |
| 188 | + text: "hello", | |
| 189 | + }, | |
| 190 | + ], | |
| 191 | + }, | |
| 192 | + ], | |
| 163 | 193 | system: [ |
| 164 | 194 | { |
| 165 | 195 | type: "text", |
| @@ -116,6 +116,11 @@ | ||
| 116 | 116 | }); |
| 117 | 117 | export type CohereConfig = z.infer<typeof CohereConfigSchema>; |
| 118 | 118 | |
| 119 | +export const CometAPIConfigSchema = OpenAIConfigSchema.extend({ | |
| 120 | + provider: z.literal("cometapi"), | |
| 121 | +}); | |
| 122 | +export type CometAPIConfig = z.infer<typeof CometAPIConfigSchema>; | |
| 123 | + | |
| 119 | 124 | export const AzureConfigSchema = OpenAIConfigSchema.extend({ |
| 120 | 125 | provider: z.literal("azure"), |
| 121 | 126 | env: z |
| @@ -197,5 +202,6 @@ | ||
| 197 | 202 | VertexAIConfigSchema, |
| 198 | 203 | LlamastackConfigSchema, |
| 199 | 204 | ContinueProxyConfigSchema, |
| 205 | + CometAPIConfigSchema, | |
| 200 | 206 | ]); |
| 201 | 207 | export type LLMConfig = z.infer<typeof LLMConfigSchema>; |