Merge branch 'main' into cli-long-start
This commit is contained in:
commit
19e1dc05c3
57 changed files with 2816 additions and 453 deletions
4
.github/workflows/compliance.yaml
vendored
4
.github/workflows/compliance.yaml
vendored
|
|
@ -119,12 +119,12 @@ jobs:
|
|||
run: npm audit --audit-level=moderate
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
languages: javascript
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
uses: github/codeql-action/analyze@v4
|
||||
|
||||
# Use this for any files that we want to be certain exist
|
||||
# Basically creates a forcing function to discuss were anyone to want to remove them
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"system_setup_commands": [
|
||||
"npm i -g @continuedev/cli@latest",
|
||||
"sudo apt update",
|
||||
"sudo apt install -y ripgrep"
|
||||
"sudo apt install -y ripgrep",
|
||||
"sudo apt install asciinema"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
231
.github/workflows/vscode-prerelease.yml
vendored
Normal file
231
.github/workflows/vscode-prerelease.yml
vendored
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
name: VSCode Pre-release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
main_commit_sha:
|
||||
description: "Main branch commit SHA to create pre-release from - leave empty to use HEAD of main"
|
||||
required: false
|
||||
type: string
|
||||
prerelease_version:
|
||||
description: "New pre-release version (e.g., 1.3.15) - leave empty to auto-increment"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
create-prerelease:
|
||||
name: Create VSCode Pre-release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ inputs.main_commit_sha || 'main' }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Determine version numbers
|
||||
id: version
|
||||
working-directory: extensions/vscode
|
||||
run: |
|
||||
# Get current version from package.json
|
||||
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||
echo "Current version in package.json: $CURRENT_VERSION"
|
||||
|
||||
# Determine new pre-release version
|
||||
if [[ -n "${{ inputs.prerelease_version }}" ]]; then
|
||||
NEW_VERSION="${{ inputs.prerelease_version }}"
|
||||
echo "Using manually specified new version: $NEW_VERSION"
|
||||
else
|
||||
# Auto-increment patch version
|
||||
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
|
||||
NEW_PATCH=$((patch + 1))
|
||||
NEW_VERSION="${major}.${minor}.${NEW_PATCH}"
|
||||
echo "Auto-incremented version: $NEW_VERSION"
|
||||
fi
|
||||
|
||||
TAG_NAME="v${NEW_VERSION}-vscode"
|
||||
|
||||
echo "previous_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "Summary:"
|
||||
echo " Previous version: $CURRENT_VERSION"
|
||||
echo " New version: $NEW_VERSION"
|
||||
echo " Tag name: $TAG_NAME"
|
||||
|
||||
- name: Create pre-release branch
|
||||
id: branch
|
||||
run: |
|
||||
BRANCH_NAME="prerelease/vscode-${{ steps.version.outputs.new_version }}"
|
||||
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
||||
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
|
||||
git checkout -b "$BRANCH_NAME"
|
||||
echo "Created branch: $BRANCH_NAME"
|
||||
|
||||
- name: Update package.json version
|
||||
working-directory: extensions/vscode
|
||||
run: |
|
||||
# Update version in package.json
|
||||
npm version ${{ steps.version.outputs.new_version }} --no-git-tag-version
|
||||
|
||||
echo "Updated package.json to version ${{ steps.version.outputs.new_version }}"
|
||||
|
||||
- name: Commit version bump
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
|
||||
git add extensions/vscode/package.json
|
||||
git commit -m "chore: bump VSCode extension version to ${{ steps.version.outputs.new_version }}"
|
||||
|
||||
echo "Committed version bump"
|
||||
|
||||
- name: Push branch and create PR
|
||||
id: pr
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git push origin "${{ steps.branch.outputs.branch_name }}"
|
||||
echo "Pushed branch: ${{ steps.branch.outputs.branch_name }}"
|
||||
|
||||
# Create pull request
|
||||
PR_URL=$(gh pr create \
|
||||
--base main \
|
||||
--head "${{ steps.branch.outputs.branch_name }}" \
|
||||
--title "chore: VSCode pre-release ${{ steps.version.outputs.new_version }}" \
|
||||
--body "$(cat <<'EOF'
|
||||
## VSCode Pre-release ${{ steps.version.outputs.new_version }}
|
||||
|
||||
This PR bumps the VSCode extension version for pre-release.
|
||||
|
||||
### Changes
|
||||
- Version bumped from ${{ steps.version.outputs.previous_version }} to ${{ steps.version.outputs.new_version }}
|
||||
- Based on commit: ${{ inputs.main_commit_sha }}
|
||||
|
||||
### Release Process
|
||||
After merging this PR:
|
||||
1. The tag \`${{ steps.version.outputs.tag_name }}\` will be created automatically
|
||||
2. A GitHub pre-release will be created with auto-generated release notes
|
||||
|
||||
🤖 This PR was created automatically by the VSCode Pre-release workflow.
|
||||
EOF
|
||||
)")
|
||||
|
||||
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
|
||||
echo "Created PR: $PR_URL"
|
||||
|
||||
- name: Auto-merge PR
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Get PR number from URL
|
||||
PR_NUMBER=$(echo "${{ steps.pr.outputs.pr_url }}" | grep -oE '[0-9]+$')
|
||||
|
||||
# Merge the PR
|
||||
gh pr merge "$PR_NUMBER" --squash --auto
|
||||
|
||||
echo "PR #$PR_NUMBER set to auto-merge"
|
||||
|
||||
# Wait for merge to complete (with timeout)
|
||||
echo "Waiting for PR to be merged..."
|
||||
TIMEOUT=300 # 5 minutes
|
||||
ELAPSED=0
|
||||
INTERVAL=10
|
||||
|
||||
while [ $ELAPSED -lt $TIMEOUT ]; do
|
||||
PR_STATE=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
|
||||
if [ "$PR_STATE" = "MERGED" ]; then
|
||||
echo "PR successfully merged!"
|
||||
break
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
ELAPSED=$((ELAPSED + INTERVAL))
|
||||
echo "Still waiting... ($ELAPSED seconds elapsed)"
|
||||
done
|
||||
|
||||
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||
echo "Warning: Timed out waiting for PR merge. Please check manually." && exit 1
|
||||
fi
|
||||
|
||||
- name: Checkout main branch
|
||||
run: |
|
||||
git fetch origin main
|
||||
git checkout main
|
||||
git pull origin main
|
||||
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
|
||||
git tag "${{ steps.version.outputs.tag_name }}"
|
||||
git push origin "${{ steps.version.outputs.tag_name }}"
|
||||
|
||||
echo "Created and pushed tag: ${{ steps.version.outputs.tag_name }}"
|
||||
|
||||
- name: Get previous tag for release notes
|
||||
id: prev_tag
|
||||
run: |
|
||||
# Find the previous vscode pre-release tag
|
||||
PREV_TAG=$(git tag -l "v*-vscode" --sort=-version:refname | head -n 2 | tail -n 1)
|
||||
|
||||
if [ -z "$PREV_TAG" ]; then
|
||||
echo "No previous tag found, using first commit"
|
||||
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
|
||||
fi
|
||||
|
||||
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
|
||||
echo "Previous tag for release notes: $PREV_TAG"
|
||||
|
||||
- name: Create GitHub pre-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Generate release notes between previous tag and current tag
|
||||
RELEASE_NOTES=$(gh api \
|
||||
--method POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
/repos/${{ github.repository }}/releases/generate-notes \
|
||||
-f tag_name="${{ steps.version.outputs.tag_name }}" \
|
||||
-f target_commitish="main" \
|
||||
-f previous_tag_name="${{ steps.prev_tag.outputs.prev_tag }}" \
|
||||
--jq '.body')
|
||||
|
||||
# Create the pre-release
|
||||
gh release create "${{ steps.version.outputs.tag_name }}" \
|
||||
--title "VSCode Pre-release ${{ steps.version.outputs.new_version }}" \
|
||||
--notes "$RELEASE_NOTES" \
|
||||
--prerelease \
|
||||
--target main
|
||||
|
||||
echo "Created pre-release: ${{ steps.version.outputs.tag_name }}"
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "## VSCode Pre-release Created Successfully! 🚀" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Version Information" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Previous Version:** ${{ steps.version.outputs.previous_version }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **New Version:** ${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Tag:** \`${{ steps.version.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Links" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **PR:** ${{ steps.pr.outputs.pr_url }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Release:** https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Commit" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Base Commit:** \`${{ inputs.main_commit_sha }}\`" >> $GITHUB_STEP_SUMMARY
|
||||
|
|
@ -268,6 +268,8 @@ export class CompletionProvider {
|
|||
gitRepo: await this.ide.getRepoName(helper.filepath),
|
||||
uniqueId: await this.ide.getUniqueId(),
|
||||
timestamp: new Date().toISOString(),
|
||||
profileType:
|
||||
this.configHandler.currentProfile?.profileDescription.profileType,
|
||||
...helper.options,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ function isBlank(completion: string): boolean {
|
|||
|
||||
/**
|
||||
* Removes markdown code block delimiters from completion.
|
||||
* Removes the first line if it starts with "```" and the last line if it is exactly "```".
|
||||
* Removes the first line if it starts with backticks (with optional language name).
|
||||
* Removes the last line if it contains only backticks.
|
||||
*/
|
||||
function removeBackticks(completion: string): string {
|
||||
const lines = completion.split("\n");
|
||||
|
|
@ -66,14 +67,18 @@ function removeBackticks(completion: string): string {
|
|||
let startIdx = 0;
|
||||
let endIdx = lines.length;
|
||||
|
||||
// Remove first line if it starts with ```
|
||||
if (lines[0].trimStart().startsWith("```")) {
|
||||
// Remove first line if it starts with backticks (``` or ```language)
|
||||
const firstLineTrimmed = lines[0].trim();
|
||||
if (firstLineTrimmed.startsWith("```")) {
|
||||
startIdx = 1;
|
||||
}
|
||||
|
||||
// Remove last line if it is exactly ```
|
||||
if (lines.length > startIdx && lines[lines.length - 1].trim() === "```") {
|
||||
endIdx = lines.length - 1;
|
||||
// Remove last line if it contains only backticks (one or more)
|
||||
if (lines.length > startIdx) {
|
||||
const lastLineTrimmed = lines[lines.length - 1].trim();
|
||||
if (lastLineTrimmed.length > 0 && /^`+$/.test(lastLineTrimmed)) {
|
||||
endIdx = lines.length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// If we removed lines, return the modified completion
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ export class AutocompleteLoggingService {
|
|||
time: restOfOutcome.time,
|
||||
useRecentlyEdited: restOfOutcome.useRecentlyEdited,
|
||||
numLines: restOfOutcome.numLines,
|
||||
profileType: restOfOutcome.profileType,
|
||||
};
|
||||
|
||||
outcome.enabledStaticContextualization
|
||||
|
|
|
|||
|
|
@ -43,4 +43,5 @@ export interface AutocompleteOutcome extends TabAutocompleteOptions {
|
|||
uniqueId: string;
|
||||
timestamp: string;
|
||||
enabledStaticContextualization?: boolean;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -537,12 +537,19 @@ export class ConfigHandler {
|
|||
// Track config loading telemetry
|
||||
const endTime = performance.now();
|
||||
const duration = endTime - startTime;
|
||||
void Telemetry.capture("config_reload", {
|
||||
|
||||
const profileDescription = this.currentProfile.profileDescription;
|
||||
const telemetryData: Record<string, any> = {
|
||||
duration,
|
||||
reason,
|
||||
totalConfigLoads: this.totalConfigReloads,
|
||||
configLoadInterrupted,
|
||||
});
|
||||
profileType: profileDescription.profileType,
|
||||
isPersonalOrg: this.currentOrg?.id === this.PERSONAL_ORG_DESC.id,
|
||||
errorCount: errors.length,
|
||||
};
|
||||
|
||||
void Telemetry.capture("config_reload", telemetryData);
|
||||
|
||||
return {
|
||||
config,
|
||||
|
|
|
|||
|
|
@ -58,13 +58,14 @@ export function convertYamlMcpConfigToInternalMcpOptions(
|
|||
return stdioOptions;
|
||||
}
|
||||
// HTTP/SSE
|
||||
const { type, url, requestOptions } = config;
|
||||
const { type, url, apiKey, requestOptions } = config;
|
||||
const httpSseConfig:
|
||||
| InternalStreamableHttpMcpOptions
|
||||
| InternalSseMcpOptions = {
|
||||
...shared,
|
||||
type,
|
||||
url,
|
||||
apiKey,
|
||||
requestOptions: mergeConfigYamlRequestOptions(
|
||||
requestOptions,
|
||||
globalRequestOptions,
|
||||
|
|
|
|||
|
|
@ -468,6 +468,12 @@ class MCPConnection {
|
|||
? new HttpsAgent({ rejectUnauthorized: false })
|
||||
: undefined;
|
||||
|
||||
// Merge apiKey into headers if provided
|
||||
const headers = {
|
||||
...options.requestOptions?.headers,
|
||||
...(options.apiKey && { Authorization: `Bearer ${options.apiKey}` }),
|
||||
};
|
||||
|
||||
return new SSEClientTransport(new URL(options.url), {
|
||||
eventSourceInit: {
|
||||
fetch: (input, init) =>
|
||||
|
|
@ -475,13 +481,13 @@ class MCPConnection {
|
|||
...init,
|
||||
headers: {
|
||||
...init?.headers,
|
||||
...options.requestOptions?.headers,
|
||||
...headers,
|
||||
},
|
||||
...(sseAgent && { agent: sseAgent }),
|
||||
}),
|
||||
},
|
||||
requestInit: {
|
||||
headers: options.requestOptions?.headers,
|
||||
headers,
|
||||
...(sseAgent && { agent: sseAgent }),
|
||||
},
|
||||
});
|
||||
|
|
@ -496,9 +502,15 @@ class MCPConnection {
|
|||
? new HttpsAgent({ rejectUnauthorized: false })
|
||||
: undefined;
|
||||
|
||||
// Merge apiKey into headers if provided
|
||||
const headers = {
|
||||
...requestOptions?.headers,
|
||||
...(options.apiKey && { Authorization: `Bearer ${options.apiKey}` }),
|
||||
};
|
||||
|
||||
return new StreamableHTTPClientTransport(new URL(url), {
|
||||
requestInit: {
|
||||
headers: requestOptions?.headers,
|
||||
headers,
|
||||
...(streamableAgent && { agent: streamableAgent }),
|
||||
},
|
||||
});
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -1350,11 +1350,13 @@ export type InternalStdioMcpOptions = BaseInternalMCPOptions & {
|
|||
export type InternalStreamableHttpMcpOptions = BaseInternalMCPOptions & {
|
||||
type?: "streamable-http";
|
||||
url: string;
|
||||
apiKey?: string;
|
||||
};
|
||||
|
||||
export type InternalSseMcpOptions = BaseInternalMCPOptions & {
|
||||
type?: "sse";
|
||||
url: string;
|
||||
apiKey?: string;
|
||||
};
|
||||
|
||||
export type InternalWebsocketMcpOptions = BaseInternalMCPOptions & {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import FormData from "form-data";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
|
|
@ -6,48 +7,169 @@ import {
|
|||
} from "../../index.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
|
||||
// Extended options for AskSage
|
||||
interface AskSageCompletionOptions extends CompletionOptions {
|
||||
mode?: "chat" | "deep_agent";
|
||||
limitReferences?: 0 | 1;
|
||||
persona?: number;
|
||||
systemPrompt?: string;
|
||||
askSageTools?: AskSageTool[];
|
||||
enabledMcpTools?: string[];
|
||||
toolsToExecute?: string[];
|
||||
askSageToolChoice?: ToolChoice;
|
||||
reasoningEffort?: "low" | "medium" | "high";
|
||||
deepAgentId?: number;
|
||||
streaming?: boolean;
|
||||
file?: unknown;
|
||||
}
|
||||
|
||||
const DEFAULT_API_URL = "https://api.asksage.ai/server";
|
||||
const DEFAULT_USER_API_URL = "https://api.asksage.ai/user";
|
||||
const TOKEN_TTL = 3600000; // 1 hour in milliseconds
|
||||
|
||||
interface AskSageTool {
|
||||
type: string;
|
||||
function: {
|
||||
name: string;
|
||||
description?: string;
|
||||
parameters?: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
type ToolChoice =
|
||||
| "auto"
|
||||
| "none"
|
||||
| { type: "function"; function: { name: string } };
|
||||
|
||||
interface AskSageRequestArgs {
|
||||
model?: string;
|
||||
temperature?: number;
|
||||
mode?: "chat" | "deep_agent";
|
||||
message?: string | { user: string; message: string }[];
|
||||
live?: 0 | 1 | 2;
|
||||
dataset?: string | string[];
|
||||
limit_references?: 0 | 1;
|
||||
persona?: number;
|
||||
system_prompt?: string;
|
||||
tools?: AskSageTool[];
|
||||
enabled_mcp_tools?: string[];
|
||||
tools_to_execute?: string[];
|
||||
tool_choice?: ToolChoice;
|
||||
reasoning_effort?: "low" | "medium" | "high";
|
||||
deep_agent_id?: number;
|
||||
streaming?: boolean;
|
||||
file?: unknown;
|
||||
}
|
||||
|
||||
interface AskSageResponse {
|
||||
text?: string;
|
||||
answer?: string;
|
||||
message?: string;
|
||||
status?: number | string;
|
||||
response?: unknown;
|
||||
choices?: Array<{
|
||||
message?: {
|
||||
content?: string;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
|
||||
interface TokenResponse {
|
||||
status: number | string;
|
||||
response: {
|
||||
access_token: string;
|
||||
};
|
||||
}
|
||||
|
||||
class Asksage extends BaseLLM {
|
||||
static providerName = "askSage";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "https://api.asksage.ai/server/",
|
||||
apiBase: DEFAULT_API_URL,
|
||||
model: "gpt-4o",
|
||||
};
|
||||
|
||||
private static modelConversion: { [key: string]: string } = {
|
||||
"gpt-4o-gov": "gpt-4o-gov", // Works
|
||||
"gpt-4o-mini-gov": "gpt-4o-mini-gov",
|
||||
"gpt4-gov": "gpt4-gov", // Works
|
||||
"gpt-gov": "gpt-gov", // Works
|
||||
"gpt-4o": "gpt-4o", // Works
|
||||
"gpt-4o-mini": "gpt-4o-mini", // Works
|
||||
gpt4: "gpt4", // Works
|
||||
"gpt4-32k": "gpt4-32k",
|
||||
"gpt-o1": "gpt-o1", // Works
|
||||
"gpt-o1-mini": "gpt-o1-mini", // Works
|
||||
"gpt-o3-mini": "gpt-o3-mini", // Stub
|
||||
"gpt-3.5-turbo": "gpt35-16k", // Works
|
||||
"aws-bedrock-claude-35-sonnet-gov": "aws-bedrock-claude-35-sonnet-gov", // Works
|
||||
"claude-3-5-sonnet-latest": "claude-35-sonnet", // Works
|
||||
"claude-3-opus-20240229": "claude-3-opus", // Works
|
||||
"claude-3-sonnet-20240229": "claude-3-sonnet", // Works
|
||||
"grok-beta": "xai-grok",
|
||||
"groq-llama33": "groq-llama33",
|
||||
"groq-70b": "groq-70b",
|
||||
"mistral-large-latest": "mistral-large", // Works
|
||||
"llama3-70b": "llma3", // Works
|
||||
"gemini-1.5-pro-latest": "google-gemini-pro", // Works
|
||||
};
|
||||
private sessionTokenPromise: Promise<string> | null = null;
|
||||
private tokenTimestamp: number = 0;
|
||||
private email?: string;
|
||||
private userApiUrl: string;
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
this.apiVersion = options.apiVersion ?? "v1.2.4";
|
||||
this.email = process.env.ASKSAGE_EMAIL;
|
||||
this.userApiUrl = process.env.ASKSAGE_USER_API_URL || DEFAULT_USER_API_URL;
|
||||
}
|
||||
|
||||
protected _convertModelName(model: string): string {
|
||||
console.log("Converting model:", model);
|
||||
const convertedModel = Asksage.modelConversion[model] ?? model;
|
||||
console.log("Converted model:", convertedModel);
|
||||
return convertedModel;
|
||||
private async getSessionToken(): Promise<string> {
|
||||
if (!this.apiKey) {
|
||||
throw new Error(
|
||||
"AskSage adapter: missing ASKSAGE_API_KEY. Provide it in your environment variables or .env file.",
|
||||
);
|
||||
}
|
||||
|
||||
// If no email, use API key directly
|
||||
if (!this.email || this.email.length === 0) {
|
||||
return this.apiKey;
|
||||
}
|
||||
|
||||
const url = this.userApiUrl.replace(/\/$/, "") + "/get-token-with-api-key";
|
||||
const res = await this.fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ email: this.email, api_key: this.apiKey }),
|
||||
});
|
||||
|
||||
const data = (await res.json()) as TokenResponse;
|
||||
if (parseInt(String(data.status)) !== 200) {
|
||||
throw new Error("Error getting access token: " + JSON.stringify(data));
|
||||
}
|
||||
return data.response.access_token;
|
||||
}
|
||||
|
||||
private async getToken(): Promise<string> {
|
||||
// Check if token needs refresh
|
||||
if (
|
||||
!this.sessionTokenPromise ||
|
||||
Date.now() - this.tokenTimestamp > TOKEN_TTL
|
||||
) {
|
||||
this.sessionTokenPromise = this.getSessionToken();
|
||||
this.tokenTimestamp = Date.now();
|
||||
}
|
||||
return this.sessionTokenPromise;
|
||||
}
|
||||
|
||||
private isFileLike(val: unknown): boolean {
|
||||
return (
|
||||
val !== null &&
|
||||
val !== undefined &&
|
||||
((typeof File !== "undefined" && val instanceof File) ||
|
||||
(typeof Buffer !== "undefined" && val instanceof Buffer) ||
|
||||
(typeof val === "object" &&
|
||||
("path" in val || "name" in val || "type" in val)))
|
||||
);
|
||||
}
|
||||
|
||||
private toFormData(args: AskSageRequestArgs): FormData {
|
||||
const form = new FormData();
|
||||
|
||||
for (const [key, value] of Object.entries(args)) {
|
||||
if (value === undefined || value === null) continue;
|
||||
|
||||
if (key === "file" && value) {
|
||||
if (Buffer.isBuffer(value)) {
|
||||
form.append("file", value, "file");
|
||||
} else if (typeof value === "string") {
|
||||
form.append("file", value);
|
||||
} else {
|
||||
form.append("file", value as Buffer);
|
||||
}
|
||||
} else if (Array.isArray(value) || typeof value === "object") {
|
||||
form.append(key, JSON.stringify(value));
|
||||
} else {
|
||||
form.append(key, String(value));
|
||||
}
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
protected _convertMessage(message: ChatMessage) {
|
||||
|
|
@ -63,43 +185,63 @@ class Asksage extends BaseLLM {
|
|||
};
|
||||
}
|
||||
|
||||
protected _convertArgs(options: any, messages: ChatMessage[]) {
|
||||
let formattedMessage: any;
|
||||
protected _convertArgs(
|
||||
options: AskSageCompletionOptions,
|
||||
messages: ChatMessage[],
|
||||
): AskSageRequestArgs {
|
||||
let formattedMessage: string | { user: string; message: string }[];
|
||||
if (messages.length === 1) {
|
||||
formattedMessage = messages[0].content;
|
||||
formattedMessage = messages[0].content as string;
|
||||
} else {
|
||||
formattedMessage = messages.map(this._convertMessage);
|
||||
}
|
||||
|
||||
const args: any = {
|
||||
const args: AskSageRequestArgs = {
|
||||
message: formattedMessage,
|
||||
persona: options.persona ?? "default",
|
||||
dataset: options.dataset ?? "none",
|
||||
limit_references: options.limitReferences ?? 0,
|
||||
model: options.model,
|
||||
temperature: options.temperature ?? 0.0,
|
||||
live: options.live ?? 0,
|
||||
model: this._convertModelName(options.model),
|
||||
mode: "chat", // Always use chat mode
|
||||
limit_references: 0, // Always use 0
|
||||
persona: options.persona as number | undefined,
|
||||
system_prompt:
|
||||
options.systemPrompt ??
|
||||
process.env.ASKSAGE_SYSTEM_PROMPT ??
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
tools: options.tools,
|
||||
tool_choice: options.toolChoice,
|
||||
tools: options.askSageTools,
|
||||
// enabled_mcp_tools: options.enabledMcpTools as string[] | undefined,
|
||||
// tools_to_execute: options.toolsToExecute as string[] | undefined,
|
||||
tool_choice: options.askSageToolChoice,
|
||||
reasoning_effort: options.reasoningEffort as
|
||||
| "low"
|
||||
| "medium"
|
||||
| "high"
|
||||
| undefined,
|
||||
deep_agent_id: options.deepAgentId as number | undefined,
|
||||
streaming: options.streaming as boolean | undefined,
|
||||
file: options.file,
|
||||
};
|
||||
|
||||
// Remove undefined values
|
||||
Object.keys(args).forEach(
|
||||
(key) => args[key] === undefined && delete args[key],
|
||||
(key) =>
|
||||
args[key as keyof AskSageRequestArgs] === undefined &&
|
||||
delete args[key as keyof AskSageRequestArgs],
|
||||
);
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
protected _getHeaders() {
|
||||
protected async _getHeaders(
|
||||
hasFile: boolean = false,
|
||||
): Promise<Record<string, string>> {
|
||||
const token = await this.getToken();
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
accept: "application/json",
|
||||
"x-access-tokens": token,
|
||||
};
|
||||
|
||||
if (this.apiKey) {
|
||||
headers["x-access-tokens"] = this.apiKey;
|
||||
if (!hasFile) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
}
|
||||
|
||||
return headers;
|
||||
|
|
@ -125,21 +267,66 @@ class Asksage extends BaseLLM {
|
|||
}
|
||||
|
||||
const messages: ChatMessage[] = [{ role: "user", content: prompt }];
|
||||
|
||||
const args = this._convertArgs(options, messages);
|
||||
const hasFile = this.isFileLike(args.file);
|
||||
const endpoint = hasFile ? "query_with_file" : "query";
|
||||
|
||||
const response = await this.fetch(this._getEndpoint("query"), {
|
||||
method: "POST",
|
||||
headers: this._getHeaders(),
|
||||
body: JSON.stringify(args),
|
||||
});
|
||||
try {
|
||||
let response;
|
||||
if (hasFile) {
|
||||
const form = this.toFormData(args);
|
||||
const headers = await this._getHeaders(true);
|
||||
response = await this.fetch(this._getEndpoint(endpoint), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
...headers,
|
||||
...form.getHeaders(),
|
||||
},
|
||||
body: form as unknown as BodyInit,
|
||||
signal,
|
||||
});
|
||||
} else {
|
||||
const headers = await this._getHeaders(false);
|
||||
response = await this.fetch(this._getEndpoint(endpoint), {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify(args),
|
||||
signal,
|
||||
});
|
||||
}
|
||||
|
||||
if (response.status === 499) {
|
||||
return ""; // Aborted by user
|
||||
if (response.status === 499) {
|
||||
return ""; // Aborted by user
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const errText = await response.text();
|
||||
|
||||
// Clear token cache on 401
|
||||
if (response.status === 401) {
|
||||
this.sessionTokenPromise = null;
|
||||
this.tokenTimestamp = 0;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`AskSage API error: ${response.status} ${response.statusText}: ${errText}`,
|
||||
);
|
||||
}
|
||||
|
||||
const data = (await response.json()) as AskSageResponse;
|
||||
return (
|
||||
data.text ||
|
||||
data.answer ||
|
||||
data.message ||
|
||||
data.choices?.[0]?.message?.content ||
|
||||
""
|
||||
);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`AskSage client error: ${error.message}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.message;
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
|
|
@ -157,30 +344,74 @@ class Asksage extends BaseLLM {
|
|||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const args = this._convertArgs(options, messages);
|
||||
const hasFile = this.isFileLike(args.file);
|
||||
const endpoint = hasFile ? "query_with_file" : "query";
|
||||
|
||||
const response = await this.fetch(this._getEndpoint("query"), {
|
||||
method: "POST",
|
||||
headers: this._getHeaders(),
|
||||
body: JSON.stringify(args),
|
||||
signal,
|
||||
});
|
||||
try {
|
||||
let response;
|
||||
if (hasFile) {
|
||||
const form = this.toFormData(args);
|
||||
const headers = await this._getHeaders(true);
|
||||
response = await this.fetch(this._getEndpoint(endpoint), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
...headers,
|
||||
...form.getHeaders(),
|
||||
},
|
||||
body: form as unknown as BodyInit,
|
||||
signal,
|
||||
});
|
||||
} else {
|
||||
const headers = await this._getHeaders(false);
|
||||
response = await this.fetch(this._getEndpoint(endpoint), {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify(args),
|
||||
signal,
|
||||
});
|
||||
}
|
||||
|
||||
if (response.status === 499) {
|
||||
return; // Aborted by user
|
||||
if (response.status === 499) {
|
||||
return; // Aborted by user
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const errText = await response.text();
|
||||
|
||||
// Clear token cache on 401
|
||||
if (response.status === 401) {
|
||||
this.sessionTokenPromise = null;
|
||||
this.tokenTimestamp = 0;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`AskSage API error: ${response.status} ${response.statusText}: ${errText}`,
|
||||
);
|
||||
}
|
||||
|
||||
const data = (await response.json()) as AskSageResponse;
|
||||
|
||||
const assistantMessage: ChatMessage = {
|
||||
role: "assistant",
|
||||
content:
|
||||
data.text ||
|
||||
data.answer ||
|
||||
data.message ||
|
||||
data.choices?.[0]?.message?.content ||
|
||||
"",
|
||||
};
|
||||
|
||||
yield assistantMessage;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`AskSage client error: ${error.message}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
const assistantMessage: ChatMessage = {
|
||||
role: "assistant",
|
||||
content: data.message,
|
||||
};
|
||||
|
||||
yield assistantMessage;
|
||||
}
|
||||
|
||||
async listModels(): Promise<string[]> {
|
||||
return Object.keys(Asksage.modelConversion);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,9 +95,6 @@ export class NextEditLoggingService {
|
|||
outcome.accepted = true;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
if (outcome.requestId) {
|
||||
void this.logAcceptReject(outcome.requestId, true);
|
||||
}
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
}
|
||||
|
|
@ -116,9 +113,6 @@ export class NextEditLoggingService {
|
|||
outcome.accepted = false;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
if (outcome.requestId) {
|
||||
void this.logAcceptReject(outcome.requestId, false);
|
||||
}
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
}
|
||||
|
|
@ -151,9 +145,6 @@ export class NextEditLoggingService {
|
|||
outcome.accepted = false;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
if (outcome.requestId) {
|
||||
void this.logAcceptReject(outcome.requestId, false);
|
||||
}
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
this._outcomes.delete(completionId);
|
||||
}, COUNT_COMPLETION_REJECTED_AFTER);
|
||||
|
|
@ -197,44 +188,15 @@ export class NextEditLoggingService {
|
|||
this._logRejectionTimeouts.delete(completionId);
|
||||
}
|
||||
|
||||
// If we have the full outcome, log it as aborted.
|
||||
// Only log if the completion was displayed to the user.
|
||||
// This aligns with Autocomplete behavior and prevents logging
|
||||
// of cancelled requests that never reached the user.
|
||||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = false;
|
||||
// outcome.accepted = false;
|
||||
outcome.aborted = true;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
} else {
|
||||
// Log minimal abort event for requests that never got displayed.
|
||||
const pendingData = this._pendingCompletions.get(completionId);
|
||||
|
||||
const minimalAbortOutcome: Partial<NextEditOutcome> = {
|
||||
completionId,
|
||||
accepted: false,
|
||||
aborted: true,
|
||||
timestamp: Date.now(),
|
||||
uniqueId: completionId,
|
||||
elapsed: pendingData ? Date.now() - pendingData.startTime : 0,
|
||||
modelName: pendingData?.modelName || "unknown",
|
||||
modelProvider: pendingData?.modelProvider || "unknown",
|
||||
fileUri: pendingData?.filepath || "unknown",
|
||||
|
||||
// Empty/default values for fields we don't have.
|
||||
completion: "",
|
||||
prompt: "",
|
||||
userEdits: "",
|
||||
userExcerpts: "",
|
||||
originalEditableRange: "",
|
||||
workspaceDirUri: "",
|
||||
cursorPosition: { line: -1, character: -1 },
|
||||
finalCursorPosition: { line: -1, character: -1 },
|
||||
editableRegionStartLine: -1,
|
||||
editableRegionEndLine: -1,
|
||||
diffLines: [],
|
||||
completionOptions: {},
|
||||
};
|
||||
|
||||
this.logNextEditOutcome(minimalAbortOutcome as NextEditOutcome);
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
|
|
@ -255,6 +217,9 @@ export class NextEditLoggingService {
|
|||
});
|
||||
|
||||
// const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome;
|
||||
if (outcome.requestId && outcome.accepted !== undefined) {
|
||||
void this.logAcceptReject(outcome.requestId, outcome.accepted);
|
||||
}
|
||||
void Telemetry.capture("nextEditOutcome", outcome, true);
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +233,7 @@ export class NextEditLoggingService {
|
|||
}
|
||||
|
||||
const controlPlaneEnv = getControlPlaneEnvSync("production");
|
||||
await fetchwithRequestOptions(
|
||||
const resp = await fetchwithRequestOptions(
|
||||
new URL("model-proxy/v1/feedback", controlPlaneEnv.CONTROL_PLANE_URL),
|
||||
{
|
||||
method: "POST",
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export class PrefetchQueue {
|
|||
const count = Math.min(3, this.processedQueue.length);
|
||||
const firstThree = this.processedQueue.slice(0, count);
|
||||
firstThree.forEach((item, index) => {
|
||||
console.log(
|
||||
console.debug(
|
||||
`Item ${index + 1}: ${item.location.range.start.line} to ${item.location.range.end.line}`,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { ContextRetrievalService } from "../autocomplete/context/ContextRetrieva
|
|||
|
||||
import { BracketMatchingService } from "../autocomplete/filtering/BracketMatchingService.js";
|
||||
import { CompletionStreamer } from "../autocomplete/generation/CompletionStreamer.js";
|
||||
import { postprocessCompletion } from "../autocomplete/postprocessing/index.js";
|
||||
import { shouldPrefilter } from "../autocomplete/prefiltering/index.js";
|
||||
import { getAllSnippetsWithoutRace } from "../autocomplete/snippets/index.js";
|
||||
import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types.js";
|
||||
|
|
@ -415,6 +416,7 @@ export class NextEditProvider {
|
|||
filePath: helper.filepath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
workspaceDir: workspaceDirs[0], // Use first workspace directory
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -468,33 +470,53 @@ export class NextEditProvider {
|
|||
}
|
||||
|
||||
// Extract completion using model-specific logic.
|
||||
const nextCompletion = this.modelProvider.extractCompletion(msg.content);
|
||||
let nextCompletion = this.modelProvider.extractCompletion(msg.content);
|
||||
|
||||
// Postprocess the completion (same as autocomplete).
|
||||
const postprocessed = postprocessCompletion({
|
||||
completion: nextCompletion,
|
||||
llm,
|
||||
prefix: helper.prunedPrefix,
|
||||
suffix: helper.prunedSuffix,
|
||||
});
|
||||
|
||||
// Return early if postprocessing filtered out the completion.
|
||||
if (!postprocessed) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
nextCompletion = postprocessed;
|
||||
|
||||
let outcome: NextEditOutcome | undefined;
|
||||
|
||||
// Handle based on diff type.
|
||||
const profileType =
|
||||
this.configHandler.currentProfile?.profileDescription.profileType;
|
||||
|
||||
if (opts?.usingFullFileDiff === false || !opts?.usingFullFileDiff) {
|
||||
outcome = await this.modelProvider.handlePartialFileDiff(
|
||||
outcome = await this.modelProvider.handlePartialFileDiff({
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
this.promptMetadata!,
|
||||
this.ide,
|
||||
);
|
||||
promptMetadata: this.promptMetadata!,
|
||||
ide: this.ide,
|
||||
profileType,
|
||||
});
|
||||
} else {
|
||||
outcome = await this.modelProvider.handleFullFileDiff(
|
||||
outcome = await this.modelProvider.handleFullFileDiff({
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
this.promptMetadata!,
|
||||
this.ide,
|
||||
);
|
||||
promptMetadata: this.promptMetadata!,
|
||||
ide: this.ide,
|
||||
profileType,
|
||||
});
|
||||
}
|
||||
|
||||
if (outcome) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { createPatch } from "diff";
|
||||
import { getUriPathBasename } from "../../util/uri";
|
||||
|
||||
export enum DiffFormatType {
|
||||
Unified = "unified",
|
||||
|
|
@ -18,6 +19,7 @@ export interface CreateDiffArgs {
|
|||
filePath: string;
|
||||
diffType: DiffFormatType;
|
||||
contextLines: number;
|
||||
workspaceDir?: string;
|
||||
}
|
||||
|
||||
export const createDiff = ({
|
||||
|
|
@ -26,6 +28,7 @@ export const createDiff = ({
|
|||
filePath,
|
||||
diffType,
|
||||
contextLines,
|
||||
workspaceDir,
|
||||
}: CreateDiffArgs) => {
|
||||
switch (diffType) {
|
||||
case DiffFormatType.Unified:
|
||||
|
|
@ -34,6 +37,7 @@ export const createDiff = ({
|
|||
afterContent,
|
||||
filePath,
|
||||
contextLines,
|
||||
workspaceDir,
|
||||
);
|
||||
case DiffFormatType.TokenLineDiff:
|
||||
return createTokenLineDiff(beforeContent, afterContent, filePath);
|
||||
|
|
@ -46,6 +50,7 @@ const createUnifiedDiff = (
|
|||
afterContent: string,
|
||||
filePath: string,
|
||||
contextLines: number,
|
||||
workspaceDir?: string,
|
||||
) => {
|
||||
const normalizedBefore = beforeContent.endsWith("\n")
|
||||
? beforeContent
|
||||
|
|
@ -54,12 +59,21 @@ const createUnifiedDiff = (
|
|||
? afterContent
|
||||
: afterContent + "\n";
|
||||
|
||||
// Use relative path if workspace directory is provided
|
||||
let displayPath = filePath;
|
||||
if (workspaceDir && filePath.startsWith(workspaceDir)) {
|
||||
displayPath = filePath.slice(workspaceDir.length).replace(/^[\/]/, "");
|
||||
} else if (workspaceDir) {
|
||||
// Fallback to just the basename if we can't determine relative path
|
||||
displayPath = getUriPathBasename(filePath);
|
||||
}
|
||||
|
||||
const patch = createPatch(
|
||||
filePath,
|
||||
displayPath,
|
||||
normalizedBefore,
|
||||
normalizedAfter,
|
||||
"before",
|
||||
"after",
|
||||
undefined,
|
||||
undefined,
|
||||
{ context: contextLines },
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,72 @@ describe("diffFormatting", () => {
|
|||
|
||||
expect(result).toContain("@@ -4,5 +4,5 @@");
|
||||
});
|
||||
|
||||
it("should use relative path when workspaceDir is provided", () => {
|
||||
const args: CreateDiffArgs = {
|
||||
beforeContent,
|
||||
afterContent,
|
||||
filePath: "file:///workspace/project/src/test.js",
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
workspaceDir: "file:///workspace/project",
|
||||
};
|
||||
|
||||
const result = createDiff(args);
|
||||
|
||||
expect(result).toContain("--- src/test.js");
|
||||
expect(result).toContain("+++ src/test.js");
|
||||
expect(result).not.toContain("file://");
|
||||
expect(result).not.toContain("/workspace/project");
|
||||
});
|
||||
|
||||
it("should handle workspaceDir with trailing slash", () => {
|
||||
const args: CreateDiffArgs = {
|
||||
beforeContent,
|
||||
afterContent,
|
||||
filePath: "file:///workspace/project/src/test.js",
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
workspaceDir: "file:///workspace/project/",
|
||||
};
|
||||
|
||||
const result = createDiff(args);
|
||||
|
||||
expect(result).toContain("--- src/test.js");
|
||||
expect(result).toContain("+++ src/test.js");
|
||||
});
|
||||
|
||||
it("should fallback to basename when path not in workspace", () => {
|
||||
const args: CreateDiffArgs = {
|
||||
beforeContent,
|
||||
afterContent,
|
||||
filePath: "file:///other/location/test.js",
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
workspaceDir: "file:///workspace/project",
|
||||
};
|
||||
|
||||
const result = createDiff(args);
|
||||
|
||||
expect(result).toContain("--- test.js");
|
||||
expect(result).toContain("+++ test.js");
|
||||
});
|
||||
|
||||
it("should use full path when no workspaceDir provided", () => {
|
||||
const fullPath = "file:///workspace/project/src/test.js";
|
||||
const args: CreateDiffArgs = {
|
||||
beforeContent,
|
||||
afterContent,
|
||||
filePath: fullPath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
};
|
||||
|
||||
const result = createDiff(args);
|
||||
|
||||
expect(result).toContain(`--- ${fullPath}`);
|
||||
expect(result).toContain(`+++ ${fullPath}`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("createBeforeAfterDiff", () => {
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ export const processNextEditData = async ({
|
|||
filePath: filePath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 25, // storing many context lines for downstream trimming
|
||||
workspaceDir: workspaceDir,
|
||||
}),
|
||||
fileUri: filePath,
|
||||
workspaceUri: workspaceDir,
|
||||
|
|
|
|||
|
|
@ -14,16 +14,6 @@ export const processSmallEdit = async (
|
|||
getDefsFromLspFunction: GetLspDefinitionsFunction,
|
||||
ide: IDE,
|
||||
) => {
|
||||
NextEditProvider.getInstance().addDiffToContext(
|
||||
createDiff({
|
||||
beforeContent: beforeAfterdiff.beforeContent,
|
||||
afterContent: beforeAfterdiff.afterContent,
|
||||
filePath: beforeAfterdiff.filePath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 5, // NOTE: This can change depending on experiments!
|
||||
}),
|
||||
);
|
||||
|
||||
// Get the current context data from the most recent message
|
||||
const currentData = (EditAggregator.getInstance() as any)
|
||||
.latestContextData || {
|
||||
|
|
@ -33,6 +23,17 @@ export const processSmallEdit = async (
|
|||
recentlyVisitedRanges: [],
|
||||
};
|
||||
|
||||
NextEditProvider.getInstance().addDiffToContext(
|
||||
createDiff({
|
||||
beforeContent: beforeAfterdiff.beforeContent,
|
||||
afterContent: beforeAfterdiff.afterContent,
|
||||
filePath: beforeAfterdiff.filePath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3, // NOTE: This can change depending on experiments!
|
||||
workspaceDir: currentData.workspaceDir,
|
||||
}),
|
||||
);
|
||||
|
||||
void processNextEditData({
|
||||
filePath: beforeAfterdiff.filePath,
|
||||
beforeContent: beforeAfterdiff.beforeContent,
|
||||
|
|
|
|||
|
|
@ -47,16 +47,28 @@ export abstract class BaseNextEditModelProvider {
|
|||
};
|
||||
|
||||
// Methods that can be used as default fallback.
|
||||
public async handlePartialFileDiff(
|
||||
helper: HelperVars,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
nextCompletion: string,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<NextEditOutcome> {
|
||||
public async handlePartialFileDiff(params: {
|
||||
helper: HelperVars;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
nextCompletion: string;
|
||||
promptMetadata: PromptMetadata;
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<NextEditOutcome> {
|
||||
const {
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
promptMetadata,
|
||||
ide,
|
||||
profileType,
|
||||
} = params;
|
||||
const oldEditRangeSlice = helper.fileContents
|
||||
.split("\n")
|
||||
.slice(editableRegionStartLine, editableRegionEndLine + 1)
|
||||
|
|
@ -83,21 +95,34 @@ export abstract class BaseNextEditModelProvider {
|
|||
originalEditableRange: oldEditRangeSlice,
|
||||
diffLines: [],
|
||||
ide,
|
||||
profileType,
|
||||
});
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public async handleFullFileDiff(
|
||||
helper: HelperVars,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
nextCompletion: string,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
public async handleFullFileDiff(params: {
|
||||
helper: HelperVars;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
nextCompletion: string;
|
||||
promptMetadata: PromptMetadata;
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<NextEditOutcome | undefined> {
|
||||
const {
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
promptMetadata,
|
||||
ide,
|
||||
profileType,
|
||||
} = params;
|
||||
const fileSlice = helper.fileLines
|
||||
.slice(editableRegionStartLine, editableRegionEndLine + 1)
|
||||
.join("\n");
|
||||
|
|
@ -111,7 +136,7 @@ export abstract class BaseNextEditModelProvider {
|
|||
const currentLine = helper.pos.line;
|
||||
const prefetchQueue = PrefetchQueue.getInstance();
|
||||
|
||||
const cursorLocalDiffGroup = await this.processDiffGroups(
|
||||
const cursorLocalDiffGroup = await this.processDiffGroups({
|
||||
diffGroups,
|
||||
currentLine,
|
||||
helper,
|
||||
|
|
@ -120,19 +145,21 @@ export abstract class BaseNextEditModelProvider {
|
|||
prefetchQueue,
|
||||
promptMetadata,
|
||||
ide,
|
||||
);
|
||||
profileType,
|
||||
});
|
||||
|
||||
if (cursorLocalDiffGroup) {
|
||||
return await this.createOutcomeFromDiffGroup(
|
||||
cursorLocalDiffGroup,
|
||||
return await this.createOutcomeFromDiffGroup({
|
||||
diffGroup: cursorLocalDiffGroup,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
helper.input.completionId,
|
||||
true,
|
||||
completionId: helper.input.completionId,
|
||||
isCurrentCursorGroup: true,
|
||||
promptMetadata,
|
||||
ide,
|
||||
);
|
||||
profileType,
|
||||
});
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
|
@ -141,23 +168,35 @@ export abstract class BaseNextEditModelProvider {
|
|||
/**
|
||||
* Process diff groups and find the one containing the cursor.
|
||||
*/
|
||||
private async processDiffGroups(
|
||||
diffGroups: DiffGroup[],
|
||||
currentLine: number,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
prefetchQueue: PrefetchQueue,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<DiffGroup | undefined> {
|
||||
private async processDiffGroups(params: {
|
||||
diffGroups: DiffGroup[];
|
||||
currentLine: number;
|
||||
helper: HelperVars;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
prefetchQueue: PrefetchQueue;
|
||||
promptMetadata: PromptMetadata;
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<DiffGroup | undefined> {
|
||||
const {
|
||||
diffGroups,
|
||||
currentLine,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
prefetchQueue,
|
||||
promptMetadata,
|
||||
ide,
|
||||
profileType,
|
||||
} = params;
|
||||
let cursorGroup: DiffGroup | undefined;
|
||||
|
||||
for (const group of diffGroups) {
|
||||
if (currentLine >= group.startLine && currentLine <= group.endLine) {
|
||||
cursorGroup = group;
|
||||
} else {
|
||||
await this.addDiffGroupToPrefetchQueue(
|
||||
await this.addDiffGroupToPrefetchQueue({
|
||||
group,
|
||||
helper,
|
||||
startTime,
|
||||
|
|
@ -165,22 +204,34 @@ export abstract class BaseNextEditModelProvider {
|
|||
prefetchQueue,
|
||||
promptMetadata,
|
||||
ide,
|
||||
);
|
||||
profileType,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return cursorGroup;
|
||||
}
|
||||
|
||||
private async addDiffGroupToPrefetchQueue(
|
||||
group: DiffGroup,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
prefetchQueue: PrefetchQueue,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<void> {
|
||||
private async addDiffGroupToPrefetchQueue(params: {
|
||||
group: DiffGroup;
|
||||
helper: HelperVars;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
prefetchQueue: PrefetchQueue;
|
||||
promptMetadata: PromptMetadata;
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<void> {
|
||||
const {
|
||||
group,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
prefetchQueue,
|
||||
promptMetadata,
|
||||
ide,
|
||||
profileType,
|
||||
} = params;
|
||||
// Extract lines that are not old.
|
||||
const groupContent = group.lines
|
||||
.filter((l) => l.type !== "old")
|
||||
|
|
@ -223,6 +274,7 @@ export abstract class BaseNextEditModelProvider {
|
|||
completionId: uuidv4(), // Generate a new ID for this prefetched item.
|
||||
diffLines: group.lines,
|
||||
ide,
|
||||
profileType,
|
||||
});
|
||||
|
||||
prefetchQueue.enqueueProcessed({
|
||||
|
|
@ -231,16 +283,28 @@ export abstract class BaseNextEditModelProvider {
|
|||
});
|
||||
}
|
||||
|
||||
private async createOutcomeFromDiffGroup(
|
||||
diffGroup: DiffGroup,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
completionId: string,
|
||||
isCurrentCursorGroup: boolean,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<NextEditOutcome> {
|
||||
private async createOutcomeFromDiffGroup(params: {
|
||||
diffGroup: DiffGroup;
|
||||
helper: HelperVars;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
completionId: string;
|
||||
isCurrentCursorGroup: boolean;
|
||||
promptMetadata: PromptMetadata;
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<NextEditOutcome> {
|
||||
const {
|
||||
diffGroup,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
completionId,
|
||||
isCurrentCursorGroup,
|
||||
promptMetadata,
|
||||
ide,
|
||||
profileType,
|
||||
} = params;
|
||||
const groupContent = diffGroup.lines
|
||||
.filter((l) => l.type !== "old")
|
||||
.map((l) => l.line)
|
||||
|
|
@ -278,6 +342,7 @@ export abstract class BaseNextEditModelProvider {
|
|||
completionId,
|
||||
diffLines: diffGroup.lines,
|
||||
ide,
|
||||
profileType,
|
||||
});
|
||||
|
||||
return outcomeNext;
|
||||
|
|
@ -299,6 +364,7 @@ export abstract class BaseNextEditModelProvider {
|
|||
completionId?: string;
|
||||
diffLines: DiffLine[];
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<NextEditOutcome> {
|
||||
return {
|
||||
elapsed: Date.now() - outcomeCtx.startTime,
|
||||
|
|
@ -325,6 +391,7 @@ export abstract class BaseNextEditModelProvider {
|
|||
editableRegionStartLine: outcomeCtx.editableRegionStartLine,
|
||||
editableRegionEndLine: outcomeCtx.editableRegionEndLine,
|
||||
diffLines: outcomeCtx.diffLines,
|
||||
profileType: outcomeCtx.profileType,
|
||||
...outcomeCtx.helper.options,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
|
|||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
diffLines: DiffLine[];
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}
|
||||
|
||||
export interface PromptMetadata {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,34 @@
|
|||
---
|
||||
title: "AskSage"
|
||||
description: "Configure AskSage with Continue to access a wide range of models including government-compliant versions of GPT and Claude models, supporting chat and edit functionalities"
|
||||
title: "Ask Sage"
|
||||
slug: ../asksage
|
||||
---
|
||||
|
||||
<Tip>
|
||||
**Discover Ask Sage models [here](https://hub.continue.dev/?q=Ask%20Sage)**
|
||||
</Tip>
|
||||
|
||||
<Info>
|
||||
To get an Ask Sage API key login to the Ask Sage platform (If you don't have
|
||||
an account, you can create one [here](https://chat.asksage.ai/)) and follow
|
||||
the instructions in the Ask Sage Docs: [Ask Sage API
|
||||
Key](https://docs.asksage.ai/docs/api-documentation/api-documentation.html)
|
||||
You can get an API key from the [Ask Sage](https://www.asksage.ai/).
|
||||
</Info>
|
||||
|
||||
## Configuration
|
||||
|
||||
To use the Ask Sage models, you can use the following
|
||||
## Overview
|
||||
|
||||
Ask Sage provides secure, government-compliant access to LLMs. This guide explains how to set up and configure Ask Sage models, including support for DoD certificates.
|
||||
|
||||
## 1. Prerequisites
|
||||
|
||||
- **Ask Sage Account:**
|
||||
Sign up or log in at [Ask Sage Platform](https://chat.asksage.ai/).
|
||||
|
||||
- **API Key:**
|
||||
Follow the [API Key Documentation](https://docs.asksage.ai/docs/api-documentation/api-documentation.html) to generate your key.
|
||||
|
||||
|
||||
## 2. Configuration
|
||||
|
||||
Add your Ask Sage model to your Continue configuration file.
|
||||
|
||||
|
||||
<Tabs>
|
||||
<Tab title="YAML">
|
||||
|
|
@ -42,53 +58,66 @@ To use the Ask Sage models, you can use the following
|
|||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
The `apiBase` will be listed on the Ask Sage platform when you generate an `API key`. You will see context as shown below:
|
||||
## 3. Using DoD Certificates
|
||||
|
||||
> Server API for query/training etc.:
|
||||
>
|
||||
> - Documentation: https://app.swaggerhub.com/apis-docs/NICOLASCHAILLAN_1/server_ask-sage_api/1.0
|
||||
> - URL for this API is: https://api.asksage.ai/server/
|
||||
For secure environments, specify your DoD CA bundle path:
|
||||
|
||||
## Usage
|
||||
|
||||
Currently, the setup for the models provided by Ask Sage is to support the following two functionalities provided by Continue.Dev:
|
||||
<Tabs>
|
||||
<Tab title="YAML">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: GPT-4 gov
|
||||
provider: askSage
|
||||
model: gpt4-gov
|
||||
apiBase: https://api.asksage.ai/server/
|
||||
apiKey: <YOUR_ASK_SAGE_API_KEY>
|
||||
requestOptions:
|
||||
caBundlePath: /path/to/dod/certificates
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="JSON">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "GPT-4 gov",
|
||||
"provider": "askSage",
|
||||
"model": "gpt4-gov",
|
||||
"apiBase": "https://api.asksage.ai/server/",
|
||||
"apiKey": "<YOUR_ASK_SAGE_API_KEY>",
|
||||
"requestOptions": {
|
||||
"caBundlePath": "/path/to/dod/certificates"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- `Chat` to understand and iterate on code in the sidebar
|
||||
- `Edit` to modify code without leaving your current file
|
||||
Replace `/path/to/dod/certificates` with your actual CA bundle file path.
|
||||
|
||||
More models, functionalities and documentation will be added in the future for Ask Sage Integration.
|
||||
---
|
||||
|
||||
> We recommend to utilize the `OpenAI` or `Anthropic` models for the best performance and results for the `Chat` and `Edit` functionalities.
|
||||
## 4. Final Steps
|
||||
|
||||
## Ask Sage Documentation
|
||||
- Save your configuration file.
|
||||
- Restart Continue to apply changes.
|
||||
|
||||
Ask Sage documentation is not available with Continue.Dev, so if you have any questions or need help with Ask Sage type `@ask` and select the `Ask Sage` option in the chat. Then procced to ask your question about Ask Sage.
|
||||
Your Ask Sage model will now be available in Continue.
|
||||
|
||||
## Current Models From Ask Sage Supported
|
||||
## 5. Usage
|
||||
|
||||
The current Models available provided by Ask Sage are:
|
||||
Supported features:
|
||||
|
||||
- **Chat:** Interact and iterate on code in the sidebar.
|
||||
- **Edit:** Modify code in place.
|
||||
|
||||
## 6. Support
|
||||
|
||||
- Refer to [Ask Sage Docs](https://docs.asksage.ai/docs/api-documentation/api-documentation.html) for more details.
|
||||
- Email the Ask Sage support team for assistance at support@asksage.ai.
|
||||
|
||||
---
|
||||
|
||||
| Index | Model | Added |
|
||||
| ----- | --------------------- | ----- |
|
||||
| 1 | GPT-4 Gov | ✅ |
|
||||
| 2 | GPT-4o Gov | ✅ |
|
||||
| 3 | GPT-4o-mini Gov | ✅ |
|
||||
| 4 | GPT-3.5-Turbo Gov | ✅ |
|
||||
| 5 | GPT-4o | ✅ |
|
||||
| 6 | GPT-4o-mini | ✅ |
|
||||
| 7 | GPT-4 | ✅ |
|
||||
| 8 | GPT-4-32K | ✅ |
|
||||
| 9 | GPT-o1 | ✅ |
|
||||
| 10 | GPT-o1-mini | ✅ |
|
||||
| 10 | GPT-o3-mini | ✅ |
|
||||
| 11 | GPT-3.5-turbo | ✅ |
|
||||
| 12 | Claude 3.5 Sonnet Gov | ✅ |
|
||||
| 13 | Claude 3 Opus | ✅ |
|
||||
| 14 | Claude 3 Sonet | ✅ |
|
||||
| 15 | Claude 3.5 Sonnet | ✅ |
|
||||
| 16 | Grok (xAI) | ✅ |
|
||||
| 17 | Groq Llama 3.3 | ✅ |
|
||||
| 18 | Groq 70B | ✅ |
|
||||
| 19 | Gemini Pro | ✅ |
|
||||
| 20 | llama 3 | ✅ |
|
||||
| 21 | Mistral Large | ✅ |
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ If you are using an OpenAI API compatible providers, you can change the `apiBase
|
|||
|
||||
### How to Force Legacy Completions Endpoint Usage
|
||||
|
||||
To force usage of `chat/completions` instead of `completions` endpoint you can set:
|
||||
To force usage of `completions` instead of `chat/completions` endpoint you can set:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="YAML">
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@
|
|||
{
|
||||
"group": "More Providers",
|
||||
"pages": [
|
||||
"customize/model-providers/more/asksage",
|
||||
"customize/model-providers/more/deepseek",
|
||||
"customize/model-providers/more/deepinfra",
|
||||
"customize/model-providers/more/groq",
|
||||
|
|
@ -257,7 +258,8 @@
|
|||
"guides/instinct",
|
||||
"guides/running-continue-without-internet",
|
||||
"guides/custom-code-rag",
|
||||
"guides/how-to-self-host-a-model"
|
||||
"guides/how-to-self-host-a-model",
|
||||
"guides/notion-continue-guide"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
377
docs/guides/notion-continue-guide.mdx
Normal file
377
docs/guides/notion-continue-guide.mdx
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
---
|
||||
title: "Developer & Team Workflows with Notion + Continue CLI"
|
||||
description: "Use Continue CLI with Notion to generate docs, manage tasks, and automate project workflows – all through natural-language prompts."
|
||||
sidebarTitle: "Notion with Continue"
|
||||
---
|
||||
|
||||
<Card title="What You'll Build" icon="notion">
|
||||
|
||||
A workflow that lets you query, update, and create Notion pages or database
|
||||
entries from natural-language prompts. Generate PRDs, sprint tasks, meeting
|
||||
notes, or status reports automatically – perfect for individual developers
|
||||
and cross-functional teams.
|
||||
|
||||
</Card>
|
||||
|
||||
## What You'll Learn
|
||||
|
||||
This guide teaches you to:
|
||||
- Use natural language to connect to the Notion API directly with Continue CLI for powerful automation
|
||||
- Configure Notion API access with proper permissions and security
|
||||
- Run prompts in both TUI (interactive) and headless modes
|
||||
- Create automated workflows that generate docs, manage tasks, and sync data
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before starting, ensure you have:
|
||||
|
||||
- [Continue CLI](https://docs.continue.dev/cli/overview) installed (`npm i -g @continuedev/cli`)
|
||||
- A [Notion workspace](https://notion.so) with Editor (or higher) access
|
||||
- Node.js 18+ installed locally
|
||||
- [Continue account](https://hub.continue.dev) with **Hub access**
|
||||
|
||||
<Warning>
|
||||
|
||||
**Agent usage requires credits** – create a Continue API key at
|
||||
[hub.continue.dev/settings/api-keys](https://hub.continue.dev/settings/api-keys)
|
||||
and store it as a secret.
|
||||
|
||||
</Warning>
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
Verify installation:
|
||||
```bash
|
||||
cn --version
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create Notion Integration & Get API Key">
|
||||
1. Go to **[Notion Integrations](https://www.notion.so/my-integrations)**
|
||||
2. Click **+ New integration** → give it a name (e.g. "Continue Integration")
|
||||
3. Select your workspace
|
||||
4. Under **Content Capabilities**, enable:
|
||||
- ✅ Read content
|
||||
- ✅ Update content
|
||||
- ✅ Insert content
|
||||
5. Under **Comment Capabilities**, enable:
|
||||
- ✅ Read comments
|
||||
- ✅ Insert comments
|
||||
6. Under **User Capabilities**, select:
|
||||
- ✅ Read user information including email addresses
|
||||
7. Click **Submit** and copy the **Internal Integration Secret** (starts with `secret_`)
|
||||
|
||||
<Info>
|
||||
|
||||
This token is your `NOTION_API_KEY`.
|
||||
Keep it safe – you won't be able to view it again.
|
||||
|
||||
</Info>
|
||||
|
||||
8. In Notion, open each database or top-level page you want accessible → **Share** → **Invite** your new integration → **Full access**.
|
||||
</Step>
|
||||
|
||||
<Step title="Configure API Access">
|
||||
Set your Notion API key as an environment variable in your terminal:
|
||||
|
||||
```bash
|
||||
export NOTION_API_KEY="secret_xxx"
|
||||
```
|
||||
|
||||
<Tip>
|
||||
|
||||
Running this command sets your API key for the current terminal session only.
|
||||
When you close the terminal, the variable won't persist. To test your API key, run the curl command below in the same session.
|
||||
|
||||
```bash
|
||||
curl -H "Authorization: Bearer $NOTION_API_KEY" \
|
||||
-H "Notion-Version: 2022-06-28" \
|
||||
https://api.notion.com/v1/databases
|
||||
```
|
||||
</Tip>
|
||||
|
||||
</Step>
|
||||
<Step title="Add Workspace Keys to Terminal Session">
|
||||
Depending on what you want `cn` to accomplish, you'll need to add your Notion workspace keys to the terminal session. The workspace key is your Notion database ID. Run the following command:
|
||||
|
||||
```bash
|
||||
export NOTION_DATABASE_ID="your_database_id"
|
||||
```
|
||||
<Tip>
|
||||
|
||||
You can find your database ID by:
|
||||
1. Opening your Notion changelog database
|
||||
2. Looking at the URL - it will be something like:
|
||||
https://www.notion.so/your-workspace/DATABASE_ID?v=...
|
||||
3. The DATABASE_ID is the long string of characters between the last / and the ?
|
||||
|
||||
</Tip>
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Running Continue AI Agent with Notion API
|
||||
|
||||
<Card title="🚀 Choose Your Interface" icon="zap">
|
||||
|
||||
Continue CLI offers two powerful modes for Notion automation:
|
||||
**TUI mode** for interactive workflows and **Headless mode** for automated scripts.
|
||||
|
||||
</Card>
|
||||
|
||||
<Tabs>
|
||||
<Tab title="🖥️ TUI Mode (Interactive)">
|
||||
|
||||
<Steps>
|
||||
<Step title="Launch Interactive Mode">
|
||||
Navigate to your project directory and run:
|
||||
```bash
|
||||
cn
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run Your First Prompt">
|
||||
In the TUI interface, enter:
|
||||
```
|
||||
1. Fetch my Notion databases using the Notion API key
|
||||
and Database ID stored in this terminal session.
|
||||
2. Look at the last week of Merged GitHub PRs, and create
|
||||
a changelog entry in Notion summarizing the features and breaking changes.
|
||||
```
|
||||
|
||||
<Tip>
|
||||
|
||||
TUI mode lets you review and approve each action before execution,
|
||||
perfect for learning and debugging.
|
||||
|
||||
</Tip>
|
||||
</Step>
|
||||
</Steps>
|
||||
</Tab>
|
||||
|
||||
<Tab title="🤖 Headless Mode (Automated)">
|
||||
<Steps>
|
||||
<Step title="Run Automated Commands">
|
||||
Execute prompts directly from the command line:
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Fetch my Notion databases using the Notion API key
|
||||
and Database ID stored in this terminal session.
|
||||
2. Analyze all merged GitHub PRs from the past week.
|
||||
3. Extract feature descriptions and breaking changes.
|
||||
4. Create a technical changelog in Notion with PR links."
|
||||
```
|
||||
|
||||
**Flags explained:**
|
||||
- `-p`: Run without TUI interface
|
||||
- `--auto`: Execute without manual approval
|
||||
|
||||
<Warning>
|
||||
|
||||
Always test prompts in TUI mode first before running
|
||||
them with `--auto` in production.
|
||||
|
||||
</Warning>
|
||||
</Step>
|
||||
</Steps>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Accordion title="API Connection Notes">
|
||||
|
||||
- Environment variable `NOTION_API_KEY` must be set before running Continue CLI
|
||||
- Continue automatically uses the API key to authenticate with Notion
|
||||
- No need for manual curl commands - just reference "the API key stored in this session"
|
||||
- For complex workflows, Continue maintains the API connection throughout
|
||||
- Consider creating aliases or scripts for frequently used prompts
|
||||
|
||||
</Accordion>
|
||||
|
||||
---
|
||||
|
||||
## Quick Start Example
|
||||
|
||||
Working example that demonstrates the power of Continue with Notion API:
|
||||
|
||||
<Card title="📊 Weekly Sprint Summary" icon="chart-line">
|
||||
|
||||
**This exact command has been tested and works:**
|
||||
|
||||
```bash
|
||||
# Weekly Sprint Summary
|
||||
cn -p --auto "
|
||||
1. Fetch Notion Sprint database
|
||||
2. Analyze completed tasks vs planned
|
||||
3. Generate sprint retrospective page
|
||||
4. Add velocity metrics and burndown chart"
|
||||
```
|
||||
|
||||
**What this does:**
|
||||
1. Connects to your Notion workspace using the API key
|
||||
2. Analyzes your sprint data
|
||||
3. Calculates completion metrics
|
||||
4. Creates a comprehensive retrospective with visualizations
|
||||
|
||||
</Card>
|
||||
|
||||
|
||||
## Example Prompts & Workflows
|
||||
|
||||
With the Notion API configured, you can use natural language prompts to automate your workspace. Here are examples for both TUI and headless modes:
|
||||
|
||||
<CardGroup cols={1}>
|
||||
<Card title="API Documentation" icon="code">
|
||||
**TUI Mode:**
|
||||
```bash
|
||||
cn "
|
||||
1. Fetch my Notion databases using the API key and secrets stored in this session
|
||||
2. Generate API documentation for all endpoints
|
||||
in src/api/routes with request/response schemas
|
||||
3. Create a page in Technical Docs database
|
||||
"
|
||||
```
|
||||
|
||||
**Headless Mode:**
|
||||
```bash
|
||||
cn -p --auto "Fetch my Notion databases using the API key and secrets stored in this session. Generate API docs
|
||||
for src/api/routes and save to Notion in Technical Docs database"
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Sprint Planning from Code" icon="list-checks">
|
||||
**Headless Mode (Automated):**
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Fetch my Notion databases using the API key stored in this session
|
||||
2. Scan codebase for TODO and FIXME comments
|
||||
3. Create tasks in my Notion Engineering Backlog database
|
||||
4. Include file paths and complexity estimates"
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Changelog from PRs" icon="rocket">
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Fetch my Notion databases using the API key stored in this session
|
||||
2. Analyze all merged GitHub PRs from past month
|
||||
3. In my Notion Launch Database, review the Launch Template.
|
||||
4. Create an October Launch doc in Notion with a week of launches and materials based on the Launch documents based on the PR analysis and launch documents."
|
||||
```
|
||||
|
||||
</Card>
|
||||
|
||||
<Card title="Daily Standup Automation" icon="comments">
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Fetch my Tasks database from Notion using the API key
|
||||
2. Find tasks completed yesterday
|
||||
3. Find tasks in progress
|
||||
4. Create standup note with: completed,
|
||||
in-progress, and blockers sections"
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Advanced Workflows
|
||||
|
||||
<CardGroup cols={1}>
|
||||
<Card title="Notion + GitHub" icon="github">
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Connect to Notion using the API key in this session
|
||||
2. Get merged PRs from last 7 days using GitHub
|
||||
3. Extract feature descriptions and changes
|
||||
4. Create formatted changelog in Notion
|
||||
5. Add links back to GitHub PRs"
|
||||
```
|
||||
|
||||
<Info>
|
||||
|
||||
Requires GitHub repository access. To add GitHub access, update your [integration settings](https://hub.continue.dev/settings/integrations).
|
||||
|
||||
</Info>
|
||||
</Card>
|
||||
|
||||
<Card title="Test Coverage Report" icon="chart-bar">
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Connect to Notion using the API key in this session
|
||||
2. Run test coverage report (npm test -- --coverage)
|
||||
3. Parse coverage metrics
|
||||
4. Update Test Metrics database in Notion
|
||||
5. Flag files with coverage below 80%"
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Blog Post Review" icon="magnifying-glass">
|
||||
```bash
|
||||
cn "
|
||||
1. Connect to Notion using the API key in this session
|
||||
2. In my Blog Posts Database, find drafts tagged 'Review'
|
||||
3. Review all blog posts for grammar and clarity and suggest improvements through comments.
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Weekly Report Generation" icon="list">
|
||||
```bash
|
||||
cn -p --auto "
|
||||
1. Connect to Notion databases using API key
|
||||
2. Aggregate completed tasks from the week
|
||||
3. Calculate velocity and burndown metrics
|
||||
4. Generate weekly report with charts
|
||||
5. Share link in Slack #team-updates"
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
<Warning>
|
||||
|
||||
**Protect Your API Keys:**
|
||||
- Never commit `NOTION_API_KEY` to version control
|
||||
- Use environment variables or secure secret managers
|
||||
- Rotate API keys every 90 days
|
||||
- Grant integration access only to required databases/pages
|
||||
- Monitor API usage through Notion's integration dashboard
|
||||
- Use `.env` files with `.gitignore` for local development
|
||||
|
||||
</Warning>
|
||||
|
||||
|
||||
## Next Steps
|
||||
|
||||
- Create a **GitHub Actions** workflow to automate changelog generation on releases
|
||||
- Build a **daily standup bot** that runs every morning and posts to Slack
|
||||
- Set up **database templates** in Notion for consistent formatting
|
||||
- Explore **batch operations** to update multiple pages efficiently
|
||||
- Implement **error handling** for API rate limits and network issues
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<Accordion title="Common Issues and Solutions">
|
||||
|
||||
**API Key Not Found:**
|
||||
- Ensure `NOTION_API_KEY` is exported in your current shell session
|
||||
- Check for typos in the environment variable name
|
||||
- Verify the key starts with `secret_`
|
||||
|
||||
**Database Access Denied:**
|
||||
- Share the specific database with your integration in Notion
|
||||
- Ensure the integration has the correct permissions (Read, Write, Insert)
|
||||
|
||||
**Connection Issues:**
|
||||
- Verify Continue CLI has internet access
|
||||
- Check network connectivity to api.notion.com
|
||||
- Ensure your Notion workspace allows API access
|
||||
|
||||
**Rate Limiting:**
|
||||
- Notion API has rate limits (3 requests per second)
|
||||
- Implement exponential backoff for automated scripts
|
||||
- Consider batching operations when possible
|
||||
|
||||
</Accordion>
|
||||
|
|
@ -14,6 +14,7 @@ description: "Comprehensive collection of practical guides for Continue includin
|
|||
- [Continuous AI: A Developer's Guide](/guides/continuous-ai) - Integrating AI into development workflows
|
||||
- [How to Use Continue CLI (cn)](/guides/cli) - Command-line interface for Continue
|
||||
- [Continuous AI Readiness Assessment](/guides/continuous-ai-readiness-assessment) - Evaluate team readiness for Continuous AI adoption
|
||||
- [Notion + Continue Guide](/guides/notion-continue-guide) - Automate docs, tasks, and release workflows
|
||||
|
||||
## MCP Integration Cookbooks
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,25 @@ The following usage information is collected and reported:
|
|||
|
||||
## How to Opt Out
|
||||
|
||||
### IDE extensions
|
||||
|
||||
You can disable anonymous telemetry by toggling "Allow Anonymous Telemetry" off in the user settings.
|
||||
|
||||
#### VS Code
|
||||
|
||||
Alternatively in VS Code, you can disable telemetry through your VS Code settings by unchecking the "Continue: Telemetry Enabled" box (this will override the Settings Page settings). VS Code settings can be accessed with `File` > `Preferences` > `Settings` (or use the keyboard shortcut `ctrl` + `,` on Windows/Linux or `cmd` + `,` on macOS).
|
||||
|
||||
### CLI
|
||||
|
||||
For `cn`, the Continue CLI, set the environment variable `CONTINUE_CLI_ENABLE_TELEMETRY=0` before running commands:
|
||||
|
||||
```bash
|
||||
export CONTINUE_CLI_ENABLE_TELEMETRY=0
|
||||
cn <your prompt>
|
||||
```
|
||||
|
||||
Or run it inline:
|
||||
|
||||
```bash
|
||||
CONTINUE_CLI_ENABLE_TELEMETRY=0 cn <your prompt>
|
||||
```
|
||||
|
|
|
|||
3
extensions/cli/.gitignore
vendored
3
extensions/cli/.gitignore
vendored
|
|
@ -11,3 +11,6 @@ chat.log
|
|||
config.yaml
|
||||
|
||||
.continue-debug/
|
||||
|
||||
*.expect
|
||||
!demo.expect
|
||||
|
|
@ -6,8 +6,9 @@ The Continue CLI uses esbuild to bundle the application along with local package
|
|||
|
||||
## Build Steps
|
||||
|
||||
1. **Install dependencies**: `npm install`
|
||||
2. **Build**: `npm run build`
|
||||
1. **Build packages**: `cd ../../ && node ./scripts/build-packages.js`
|
||||
2. **Install dependencies**: `npm install`
|
||||
3. **Build**: `npm run build`
|
||||
- This first builds the local packages
|
||||
- Then bundles everything with esbuild
|
||||
|
||||
|
|
|
|||
36
extensions/cli/demo.expect
Normal file
36
extensions/cli/demo.expect
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/expect -f
|
||||
# Automated demo script for Continue TUI
|
||||
|
||||
set timeout 30
|
||||
log_user 1
|
||||
|
||||
# Set terminal environment for better TUI rendering
|
||||
set env(TERM) "xterm-256color"
|
||||
|
||||
# Spawn cn directly inside an asciinema recording session
|
||||
spawn bash -c "asciinema rec --overwrite demo.cast -c 'npm run start'"
|
||||
|
||||
# Wait for TUI to load
|
||||
sleep 5
|
||||
|
||||
# Demo interaction 1: Show help
|
||||
send "?"
|
||||
sleep 3
|
||||
|
||||
# Demo interaction 2: Close help
|
||||
send "?"
|
||||
sleep 2
|
||||
|
||||
# Demo interaction 3: Type a message
|
||||
send "Hello, this is a demo!"
|
||||
sleep 1
|
||||
|
||||
# Submit the message
|
||||
send "\r"
|
||||
sleep 3
|
||||
|
||||
# Exit the application with Ctrl+C
|
||||
send "\x03"
|
||||
sleep 1
|
||||
|
||||
expect eof
|
||||
|
|
@ -196,11 +196,12 @@ describe("ConfigEnhancer", () => {
|
|||
});
|
||||
|
||||
it("should prepend MCPs from --mcp flag", async () => {
|
||||
// Mock loadPackagesFromHub to return test MCPs
|
||||
const { loadPackagesFromHub } = await import("./hubLoader.js");
|
||||
(loadPackagesFromHub as any).mockResolvedValueOnce([
|
||||
{ name: "New-MCP", command: "new-mcp" },
|
||||
]);
|
||||
// Mock loadPackageFromHub to return test MCP (singular call for each MCP)
|
||||
const { loadPackageFromHub } = await import("./hubLoader.js");
|
||||
(loadPackageFromHub as any).mockResolvedValueOnce({
|
||||
name: "New-MCP",
|
||||
command: "new-mcp",
|
||||
});
|
||||
|
||||
// Set up existing MCPs in config
|
||||
mockConfig.mcpServers = [{ name: "Existing-MCP", command: "existing-mcp" }];
|
||||
|
|
@ -223,6 +224,70 @@ describe("ConfigEnhancer", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should handle URLs in --mcp flag as streamable-http servers", async () => {
|
||||
// Set up existing MCPs in config
|
||||
mockConfig.mcpServers = [{ name: "Existing-MCP", command: "existing-mcp" }];
|
||||
|
||||
const options: BaseCommandOptions = {
|
||||
mcp: ["https://docs.continue.dev/mcp"],
|
||||
};
|
||||
|
||||
const config = await enhancer.enhanceConfig(mockConfig, options);
|
||||
|
||||
// URL should be converted to streamable-http MCP configuration
|
||||
expect(config.mcpServers).toHaveLength(2);
|
||||
expect(config.mcpServers?.[0]).toEqual({
|
||||
name: "docs.continue.dev",
|
||||
type: "streamable-http",
|
||||
url: "https://docs.continue.dev/mcp",
|
||||
});
|
||||
expect(config.mcpServers?.[1]).toEqual({
|
||||
name: "Existing-MCP",
|
||||
command: "existing-mcp",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle mix of URLs and hub slugs in --mcp flag", async () => {
|
||||
// Mock loadPackageFromHub to return test MCP for hub slug
|
||||
const { loadPackageFromHub } = await import("./hubLoader.js");
|
||||
(loadPackageFromHub as any).mockResolvedValueOnce({
|
||||
name: "Hub-MCP",
|
||||
command: "hub-mcp",
|
||||
});
|
||||
|
||||
const options: BaseCommandOptions = {
|
||||
mcp: ["https://example.com/mcp", "test/hub-mcp"],
|
||||
};
|
||||
|
||||
const config = await enhancer.enhanceConfig(mockConfig, options);
|
||||
|
||||
expect(config.mcpServers).toHaveLength(2);
|
||||
expect(config.mcpServers?.[0]).toEqual({
|
||||
name: "example.com",
|
||||
type: "streamable-http",
|
||||
url: "https://example.com/mcp",
|
||||
});
|
||||
expect(config.mcpServers?.[1]).toEqual({
|
||||
name: "Hub-MCP",
|
||||
command: "hub-mcp",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle http:// URLs in --mcp flag", async () => {
|
||||
const options: BaseCommandOptions = {
|
||||
mcp: ["http://localhost:8080/mcp"],
|
||||
};
|
||||
|
||||
const config = await enhancer.enhanceConfig(mockConfig, options);
|
||||
|
||||
expect(config.mcpServers).toHaveLength(1);
|
||||
expect(config.mcpServers?.[0]).toEqual({
|
||||
name: "localhost",
|
||||
type: "streamable-http",
|
||||
url: "http://localhost:8080/mcp",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle workflow integration gracefully when no workflow", async () => {
|
||||
// The mocked service container returns null workflow state
|
||||
const options: BaseCommandOptions = {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,28 @@ export class ConfigEnhancer {
|
|||
config: AssistantUnrolled,
|
||||
mcps: string[],
|
||||
): Promise<AssistantUnrolled> {
|
||||
const processedMcps = await loadPackagesFromHub(mcps, mcpProcessor);
|
||||
const processedMcps: any[] = [];
|
||||
|
||||
// Process each MCP spec - check if it's a URL or hub slug
|
||||
for (const mcpSpec of mcps) {
|
||||
try {
|
||||
// Check if it's a URL (starts with http:// or https://)
|
||||
if (mcpSpec.startsWith("http://") || mcpSpec.startsWith("https://")) {
|
||||
// Create a streamable-http MCP configuration
|
||||
processedMcps.push({
|
||||
name: new URL(mcpSpec).hostname,
|
||||
type: "streamable-http",
|
||||
url: mcpSpec,
|
||||
});
|
||||
} else {
|
||||
// Otherwise, treat it as a hub slug
|
||||
const hubMcp = await loadPackageFromHub(mcpSpec, mcpProcessor);
|
||||
processedMcps.push(hubMcp);
|
||||
}
|
||||
} catch (error: any) {
|
||||
logger.warn(`Failed to load MCP "${mcpSpec}": ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Clone the config to avoid mutating the original
|
||||
const modifiedConfig = { ...config };
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import { type AssistantConfig } from "@continuedev/sdk";
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
||||
import {
|
||||
SSEClientTransport,
|
||||
SseError,
|
||||
} from "@modelcontextprotocol/sdk/client/sse.js";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
||||
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||
import {
|
||||
|
|
@ -21,6 +24,14 @@ import {
|
|||
SERVICE_NAMES,
|
||||
} from "./types.js";
|
||||
|
||||
function is401Error(error: unknown) {
|
||||
return (
|
||||
(error instanceof SseError && error.code === 401) ||
|
||||
(error instanceof Error && error.message.includes("401")) ||
|
||||
(error instanceof Error && error.message.includes("Unauthorized"))
|
||||
);
|
||||
}
|
||||
|
||||
interface ServerConnection extends MCPConnectionInfo {
|
||||
client: Client | null;
|
||||
}
|
||||
|
|
@ -366,15 +377,29 @@ export class MCPService
|
|||
url: serverConfig.url,
|
||||
});
|
||||
|
||||
if (serverConfig.type === "sse") {
|
||||
const transport = this.constructSseTransport(serverConfig);
|
||||
await client.connect(transport, {});
|
||||
} else if (serverConfig.type === "streamable-http") {
|
||||
const transport = this.constructHttpTransport(serverConfig);
|
||||
await client.connect(transport, {});
|
||||
} else if (serverConfig.type) {
|
||||
throw new Error(`Unsupported transport type: ${serverConfig.type}`);
|
||||
} else {
|
||||
try {
|
||||
if (serverConfig.type === "sse") {
|
||||
const transport = this.constructSseTransport(serverConfig);
|
||||
await client.connect(transport, {});
|
||||
} else if (serverConfig.type === "streamable-http") {
|
||||
const transport = this.constructHttpTransport(serverConfig);
|
||||
await client.connect(transport, {});
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
// on authorization error, use "mcp-remote" with stdio transport to connect
|
||||
if (is401Error(error)) {
|
||||
const transport = this.constructStdioTransport({
|
||||
name: serverConfig.name,
|
||||
command: "npx",
|
||||
args: ["-y", "mcp-remote", serverConfig.url],
|
||||
});
|
||||
await client.connect(transport, {});
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof serverConfig.type === "undefined") {
|
||||
try {
|
||||
const transport = this.constructHttpTransport(serverConfig);
|
||||
await client.connect(transport, {});
|
||||
|
|
@ -394,6 +419,10 @@ export class MCPService
|
|||
);
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
!["streamable-http", "sse", "stdio"].includes(serverConfig.type)
|
||||
) {
|
||||
throw new Error(`Unsupported transport type: ${serverConfig.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -403,6 +432,14 @@ export class MCPService
|
|||
private constructSseTransport(
|
||||
serverConfig: SseMcpServer,
|
||||
): SSEClientTransport {
|
||||
// Merge apiKey into headers if provided
|
||||
const headers = {
|
||||
...serverConfig.requestOptions?.headers,
|
||||
...(serverConfig.apiKey && {
|
||||
Authorization: `Bearer ${serverConfig.apiKey}`,
|
||||
}),
|
||||
};
|
||||
|
||||
return new SSEClientTransport(new URL(serverConfig.url), {
|
||||
eventSourceInit: {
|
||||
fetch: (input, init) =>
|
||||
|
|
@ -410,18 +447,26 @@ export class MCPService
|
|||
...init,
|
||||
headers: {
|
||||
...init?.headers,
|
||||
...serverConfig.requestOptions?.headers,
|
||||
...headers,
|
||||
},
|
||||
}),
|
||||
},
|
||||
requestInit: { headers: serverConfig.requestOptions?.headers },
|
||||
requestInit: { headers },
|
||||
});
|
||||
}
|
||||
private constructHttpTransport(
|
||||
serverConfig: HttpMcpServer,
|
||||
): StreamableHTTPClientTransport {
|
||||
// Merge apiKey into headers if provided
|
||||
const headers = {
|
||||
...serverConfig.requestOptions?.headers,
|
||||
...(serverConfig.apiKey && {
|
||||
Authorization: `Bearer ${serverConfig.apiKey}`,
|
||||
}),
|
||||
};
|
||||
|
||||
return new StreamableHTTPClientTransport(new URL(serverConfig.url), {
|
||||
requestInit: { headers: serverConfig.requestOptions?.headers },
|
||||
requestInit: { headers },
|
||||
});
|
||||
}
|
||||
private constructStdioTransport(
|
||||
|
|
|
|||
|
|
@ -554,11 +554,19 @@ describe("Workflow Integration Tests", () => {
|
|||
tools: "owner/mcp1, another/mcp2:specific_tool",
|
||||
};
|
||||
|
||||
mockLoadPackageFromHub.mockResolvedValue(workflowWithTools);
|
||||
mockLoadPackagesFromHub.mockResolvedValue([
|
||||
{ name: "mcp1" },
|
||||
{ name: "mcp2" },
|
||||
]);
|
||||
// Clear the default mock and setup specific mocks
|
||||
mockLoadPackageFromHub.mockReset();
|
||||
// First call loads the workflow file
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce(workflowWithTools);
|
||||
// Second call loads the workflow model
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce({
|
||||
name: "gpt-4-workflow",
|
||||
provider: "openai",
|
||||
});
|
||||
// Third call loads mcp1
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce({ name: "mcp1" });
|
||||
// Fourth call loads mcp2
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce({ name: "mcp2" });
|
||||
|
||||
await workflowService.initialize("owner/workflow");
|
||||
|
||||
|
|
@ -573,6 +581,7 @@ describe("Workflow Integration Tests", () => {
|
|||
);
|
||||
|
||||
expect(enhancedConfig.mcpServers).toHaveLength(3);
|
||||
// MCPs are prepended in the order they are loaded
|
||||
expect(enhancedConfig.mcpServers?.[0]).toEqual({ name: "mcp1" });
|
||||
expect(enhancedConfig.mcpServers?.[1]).toEqual({ name: "mcp2" });
|
||||
expect(enhancedConfig.mcpServers?.[2]).toEqual({ name: "existing-mcp" });
|
||||
|
|
@ -584,7 +593,8 @@ describe("Workflow Integration Tests", () => {
|
|||
tools: undefined,
|
||||
};
|
||||
|
||||
mockLoadPackageFromHub.mockResolvedValue(workflowWithoutTools);
|
||||
mockLoadPackageFromHub.mockReset();
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce(workflowWithoutTools);
|
||||
await workflowService.initialize("owner/workflow");
|
||||
|
||||
const baseConfig = {
|
||||
|
|
@ -607,13 +617,22 @@ describe("Workflow Integration Tests", () => {
|
|||
tools: "owner/mcp1, owner/mcp1:tool1, owner/mcp1:tool2",
|
||||
};
|
||||
|
||||
mockLoadPackageFromHub.mockResolvedValue(workflowWithDuplicateTools);
|
||||
mockLoadPackagesFromHub.mockResolvedValue([{ name: "mcp1" }]);
|
||||
// Clear the default mock and setup specific mocks
|
||||
mockLoadPackageFromHub.mockReset();
|
||||
// First call loads the workflow file
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce(workflowWithDuplicateTools);
|
||||
// Second call loads the workflow model
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce({
|
||||
name: "gpt-4-workflow",
|
||||
provider: "openai",
|
||||
});
|
||||
// Third call: The parseWorkflowTools will extract only unique MCP servers, so only one loadPackageFromHub call
|
||||
mockLoadPackageFromHub.mockResolvedValueOnce({ name: "mcp1" });
|
||||
|
||||
await workflowService.initialize("owner/workflow");
|
||||
|
||||
const baseConfig = {
|
||||
mcpServers: [{ name: "mcp1" }], // Already exists
|
||||
mcpServers: [{ name: "existing-mcp" }], // Changed to avoid confusion
|
||||
};
|
||||
|
||||
const enhancedConfig = await configEnhancer.enhanceConfig(
|
||||
|
|
@ -622,10 +641,10 @@ describe("Workflow Integration Tests", () => {
|
|||
workflowService.getState(),
|
||||
);
|
||||
|
||||
// Should not deduplicate since we simplified the logic
|
||||
// parseWorkflowTools deduplicates, so we only get mcp1 once
|
||||
expect(enhancedConfig.mcpServers).toHaveLength(2);
|
||||
expect(enhancedConfig.mcpServers?.[0]).toEqual({ name: "mcp1" });
|
||||
expect(enhancedConfig.mcpServers?.[1]).toEqual({ name: "mcp1" });
|
||||
expect(enhancedConfig.mcpServers?.[1]).toEqual({ name: "existing-mcp" });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -81,4 +81,19 @@ describe("IntroMessage", () => {
|
|||
expect(lastFrame()).toContain("Model:");
|
||||
expect(lastFrame()).toContain("Loading...");
|
||||
});
|
||||
|
||||
it("renders organization name when provided", () => {
|
||||
const { lastFrame } = render(
|
||||
<IntroMessage organizationName="Test Organization" />,
|
||||
);
|
||||
|
||||
expect(lastFrame()).toContain("Org:");
|
||||
expect(lastFrame()).toContain("Test Organization");
|
||||
});
|
||||
|
||||
it("does not render organization section when not provided", () => {
|
||||
const { lastFrame } = render(<IntroMessage />);
|
||||
|
||||
expect(lastFrame()).not.toContain("Org:");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ interface IntroMessageProps {
|
|||
config?: AssistantUnrolled;
|
||||
model?: ModelConfig;
|
||||
mcpService?: MCPService;
|
||||
organizationName?: string;
|
||||
}
|
||||
|
||||
// Helper function to extract rule names
|
||||
|
|
@ -26,6 +27,7 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
|
|||
config,
|
||||
model,
|
||||
mcpService,
|
||||
organizationName,
|
||||
}) => {
|
||||
// Get MCP prompts directly (not memoized since they can change after first render)
|
||||
const mcpPrompts = mcpService?.getState().prompts ?? [];
|
||||
|
|
@ -98,6 +100,13 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
|
|||
{/* Tips Display - shown randomly 1 in 5 times */}
|
||||
{showTip && <TipsDisplay />}
|
||||
|
||||
{/* Organization name */}
|
||||
{organizationName && (
|
||||
<Text color="blue">
|
||||
<Text bold>Org:</Text> <Text color="white">{organizationName}</Text>
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{/* Agent name */}
|
||||
{config && (
|
||||
<Text color="blue">
|
||||
|
|
|
|||
|
|
@ -117,6 +117,13 @@ export const MCPSelector: React.FC<MCPSelectorProps> = ({ onCancel }) => {
|
|||
{ label: "⏹️ Stop all servers", value: "stop-all" },
|
||||
);
|
||||
}
|
||||
|
||||
// Add "Explore MCP Servers" option at the bottom
|
||||
options.push({
|
||||
label: "🔍 Explore MCP Servers",
|
||||
value: "explore-mcp-servers",
|
||||
});
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
|
|
@ -280,6 +287,12 @@ export const MCPSelector: React.FC<MCPSelectorProps> = ({ onCancel }) => {
|
|||
await mcpService.shutdownConnections();
|
||||
setMessage("All servers stopped");
|
||||
break;
|
||||
case "explore-mcp-servers":
|
||||
// Open the MCP servers hub in the default browser
|
||||
const open = (await import("open")).default;
|
||||
await open("https://hub.continue.dev/?type=mcpServers");
|
||||
setMessage("Opened MCP servers hub in browser");
|
||||
break;
|
||||
case "back":
|
||||
onCancel();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import React, {
|
|||
|
||||
import { ToolPermissionServiceState } from "src/services/ToolPermissionService.js";
|
||||
|
||||
import { listUserOrganizations } from "../auth/workos.js";
|
||||
import { useServices } from "../hooks/useService.js";
|
||||
import {
|
||||
ApiClientServiceState,
|
||||
|
|
@ -110,6 +111,44 @@ function useTUIChatServices(remoteUrl?: string) {
|
|||
return { services, allServicesReady, isRemoteMode };
|
||||
}
|
||||
|
||||
// Custom hook to fetch organization name
|
||||
function useOrganizationName(organizationId?: string): string | undefined {
|
||||
const [organizationName, setOrganizationName] = useState<string | undefined>(
|
||||
undefined,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!organizationId) {
|
||||
setOrganizationName(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
let isMounted = true;
|
||||
|
||||
async function fetchOrgName() {
|
||||
try {
|
||||
const orgs = await listUserOrganizations();
|
||||
if (!isMounted) return;
|
||||
|
||||
const org = orgs?.find((o) => o.id === organizationId);
|
||||
if (org) {
|
||||
setOrganizationName(org.name);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.debug("Failed to fetch organization name", { error });
|
||||
}
|
||||
}
|
||||
|
||||
fetchOrgName();
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [organizationId]);
|
||||
|
||||
return organizationName;
|
||||
}
|
||||
|
||||
// Custom hook for chat handlers
|
||||
function useChatHandlers(
|
||||
setShowIntroMessage: (show: boolean) => void,
|
||||
|
|
@ -298,6 +337,9 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
// State for image in clipboard status
|
||||
const [hasImageInClipboard, setHasImageInClipboard] = useState(false);
|
||||
|
||||
// Fetch organization name based on auth state
|
||||
const organizationName = useOrganizationName(services.auth?.organizationId);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" height="100%">
|
||||
{/* Chat history - takes up all available space above input */}
|
||||
|
|
@ -320,6 +362,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
config={services.config?.config || undefined}
|
||||
model={services.model?.model || undefined}
|
||||
mcpService={services.mcp?.mcpService || undefined}
|
||||
organizationName={organizationName}
|
||||
chatHistory={chatHistory}
|
||||
queuedMessages={queuedMessages}
|
||||
renderMessage={renderMessage}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { renderInMode, testSingleMode } from "./TUIChat.dualModeHelper.js";
|
||||
import { waitForNextRender } from "./TUIChat.testHelper.js";
|
||||
|
||||
describe("TUIChat - @ File Search Tests", () => {
|
||||
testSingleMode("shows @ character when user types @", "local", async () => {
|
||||
|
|
@ -56,9 +57,8 @@ describe("TUIChat - @ File Search Tests", () => {
|
|||
|
||||
// Type multiple @ characters
|
||||
stdin.write("@@test");
|
||||
|
||||
// Wait for UI update
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
await waitForNextRender();
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import { testBothModes, renderInMode } from "./TUIChat.dualModeHelper.js";
|
||||
import { renderInMode, testBothModes } from "./TUIChat.dualModeHelper.js";
|
||||
import { waitForNextRender } from "./TUIChat.testHelper.js";
|
||||
|
||||
describe("TUIChat - User Input Tests", () => {
|
||||
testBothModes("shows typed text in input field", (mode) => {
|
||||
testBothModes("shows typed text in input field", async (mode) => {
|
||||
const { lastFrame, stdin } = renderInMode(mode);
|
||||
|
||||
stdin.write("Testing 123");
|
||||
await waitForNextRender();
|
||||
|
||||
const frame = lastFrame();
|
||||
// The input might be in a different format, let's be more flexible
|
||||
|
|
@ -23,13 +25,14 @@ describe("TUIChat - User Input Tests", () => {
|
|||
testBothModes("handles Enter key to submit", async (mode) => {
|
||||
const { lastFrame, stdin } = renderInMode(mode);
|
||||
|
||||
await waitForNextRender();
|
||||
const beforeEnter = lastFrame();
|
||||
expect(beforeEnter).toContain("Ask anything");
|
||||
|
||||
stdin.write("\r");
|
||||
|
||||
// Wait for the UI to update after pressing enter
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
|
||||
const afterEnter = lastFrame();
|
||||
|
||||
|
|
@ -46,11 +49,12 @@ describe("TUIChat - User Input Tests", () => {
|
|||
|
||||
testBothModes(
|
||||
"handles special characters in input without crashing",
|
||||
(mode) => {
|
||||
async (mode) => {
|
||||
const { lastFrame, stdin } = renderInMode(mode);
|
||||
|
||||
// Try typing various special characters
|
||||
stdin.write("!@#$%^&*()");
|
||||
await waitForNextRender();
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -58,8 +62,9 @@ describe("TUIChat - User Input Tests", () => {
|
|||
expect(frame).toBeDefined();
|
||||
expect(frame).not.toBe("");
|
||||
|
||||
// UI should still be functional
|
||||
expect(frame).toContain("Ask anything");
|
||||
// UI should still be functional and show the typed special characters
|
||||
// Note: "Ask anything" placeholder is replaced when text is typed
|
||||
expect(frame).toContain("!@#$%^&*()");
|
||||
|
||||
// Mode-specific UI elements
|
||||
if (mode === "remote") {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { renderInMode, testBothModes } from "./TUIChat.dualModeHelper.js";
|
||||
import { waitForNextRender } from "./TUIChat.testHelper.js";
|
||||
|
||||
describe("TUIChat - Slash Commands Tests", () => {
|
||||
testBothModes("shows slash when user types /", async (mode) => {
|
||||
|
|
@ -6,9 +7,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Type / to trigger slash command
|
||||
stdin.write("/");
|
||||
|
||||
// Wait a bit for the UI to update
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
await waitForNextRender();
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -29,9 +28,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Type /exi to trigger slash command filtering
|
||||
stdin.write("/exi");
|
||||
|
||||
// Wait a bit for the UI to update (allow extra time in both modes)
|
||||
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||
await waitForNextRender();
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -52,12 +49,10 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Type /exi and then tab
|
||||
stdin.write("/exi");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
await waitForNextRender();
|
||||
|
||||
stdin.write("\t");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
await waitForNextRender();
|
||||
|
||||
const frameAfterTab = lastFrame();
|
||||
|
||||
|
|
@ -80,8 +75,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Type just /
|
||||
stdin.write("/");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||
await waitForNextRender();
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -113,8 +107,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Type a complete command name first
|
||||
stdin.write("/title");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
await waitForNextRender();
|
||||
|
||||
const frameAfterCommand = lastFrame();
|
||||
if (mode === "remote") {
|
||||
|
|
@ -127,8 +120,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Now add a space and arguments
|
||||
stdin.write(" My Session Title");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
await waitForNextRender();
|
||||
|
||||
const frameAfterArgs = lastFrame();
|
||||
|
||||
|
|
@ -151,8 +143,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Type a complete command with arguments
|
||||
stdin.write("/title Test Session");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
await waitForNextRender();
|
||||
|
||||
const frameBeforeEnter = lastFrame();
|
||||
expect(frameBeforeEnter).toContain("/title");
|
||||
|
|
@ -160,8 +151,7 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Press Enter - this should execute the command, not try to autocomplete
|
||||
stdin.write("\r");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
await waitForNextRender();
|
||||
|
||||
const frameAfterEnter = lastFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -422,6 +422,20 @@ export async function sendMessage(
|
|||
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to wait for next render cycle to complete
|
||||
* Use this after stdin.write() to ensure at least one render has occurred
|
||||
* This prevents flaky tests caused by calling lastFrame() before React renders
|
||||
*/
|
||||
export async function waitForNextRender(): Promise<void> {
|
||||
// Wait for multiple ticks to ensure render completes
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
// Add a delay to allow Ink terminal UI to render
|
||||
// CI environments are slower, so we need a longer delay
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to check if UI shows remote mode indicators
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ interface StaticChatContentProps {
|
|||
config?: AssistantUnrolled;
|
||||
model?: ModelConfig;
|
||||
mcpService?: MCPService;
|
||||
organizationName?: string;
|
||||
chatHistory: ChatHistoryItem[];
|
||||
queuedMessages?: QueuedMessage[];
|
||||
renderMessage: (
|
||||
|
|
@ -29,6 +30,7 @@ export const StaticChatContent: React.FC<StaticChatContentProps> = ({
|
|||
config,
|
||||
model,
|
||||
mcpService,
|
||||
organizationName,
|
||||
chatHistory,
|
||||
queuedMessages = [],
|
||||
renderMessage,
|
||||
|
|
@ -96,6 +98,7 @@ export const StaticChatContent: React.FC<StaticChatContentProps> = ({
|
|||
config={config}
|
||||
model={model}
|
||||
mcpService={mcpService}
|
||||
organizationName={organizationName}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
|
@ -129,6 +132,7 @@ export const StaticChatContent: React.FC<StaticChatContentProps> = ({
|
|||
config,
|
||||
model,
|
||||
mcpService,
|
||||
organizationName,
|
||||
processedChatHistory,
|
||||
renderMessage,
|
||||
]);
|
||||
|
|
|
|||
5
extensions/vscode/package-lock.json
generated
5
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.3.12",
|
||||
"version": "1.3.15",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.3.12",
|
||||
"version": "1.3.15",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "file:../../packages/config-types",
|
||||
|
|
@ -100,6 +100,7 @@
|
|||
"version": "1.1.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.62.0",
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.779.0",
|
||||
"@aws-sdk/client-sagemaker-runtime": "^3.777.0",
|
||||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.3.15",
|
||||
"version": "1.3.16",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export class GhostTextAcceptanceTracker {
|
|||
);
|
||||
|
||||
if (wasGhostTextAccepted) {
|
||||
console.log(
|
||||
console.debug(
|
||||
"GhostTextAcceptanceTracker: ghost text was accepted, preserving chain",
|
||||
);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@ import { AutocompleteCodeSnippet } from "core/autocomplete/snippets/types";
|
|||
import { GetLspDefinitionsFunction } from "core/autocomplete/types";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { RecentlyEditedRange } from "core/nextEdit/types";
|
||||
import { getContinueGlobalPath, isFileWithinFolder } from "core/util/paths";
|
||||
import fs from "fs";
|
||||
import { resolve } from "path";
|
||||
import * as vscode from "vscode";
|
||||
import { ContinueCompletionProvider } from "../autocomplete/completionProvider";
|
||||
|
||||
|
|
@ -21,23 +18,6 @@ export const getBeforeCursorPos = (range: Range, activePos: Position) => {
|
|||
}
|
||||
};
|
||||
|
||||
const isEditLoggingAllowed = async (editedFileURI: string) => {
|
||||
const globalContinuePath = getContinueGlobalPath();
|
||||
const editLogDirsPath = resolve(globalContinuePath, ".editlogdirs");
|
||||
|
||||
try {
|
||||
const fileContent = await fs.promises.readFile(editLogDirsPath, "utf-8");
|
||||
const stringItems = fileContent
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line.length > 0);
|
||||
|
||||
return stringItems.some((dir) => isFileWithinFolder(editedFileURI, dir));
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const getWorkspaceDirUri = async (event: vscode.TextDocumentChangeEvent) => {
|
||||
const workspaceFolder = vscode.workspace.getWorkspaceFolder(
|
||||
event.document.uri,
|
||||
|
|
@ -68,7 +48,6 @@ export const handleTextDocumentChange = async (
|
|||
// Ensure that logging will only happen in the open-source continue repo
|
||||
const workspaceDirUri = await getWorkspaceDirUri(event);
|
||||
if (!workspaceDirUri) return;
|
||||
if (!(await isEditLoggingAllowed(event.document.uri.toString()))) return;
|
||||
|
||||
const activeCursorPos = editor.selection.active;
|
||||
const editActions: RangeInFileWithNextEditInfo[] = changes.map((change) => ({
|
||||
|
|
|
|||
3
gui/package-lock.json
generated
3
gui/package-lock.json
generated
|
|
@ -116,6 +116,7 @@
|
|||
"version": "1.1.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.62.0",
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.779.0",
|
||||
"@aws-sdk/client-sagemaker-runtime": "^3.777.0",
|
||||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
|
|
@ -235,7 +236,7 @@
|
|||
},
|
||||
"../packages/config-yaml": {
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.14.0",
|
||||
"version": "1.23.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
|
|||
491
gui/src/components/CliInstallBanner.test.tsx
Normal file
491
gui/src/components/CliInstallBanner.test.tsx
Normal file
|
|
@ -0,0 +1,491 @@
|
|||
import {
|
||||
act,
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
} from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { MockIdeMessenger } from "../context/MockIdeMessenger";
|
||||
import * as util from "../util";
|
||||
import * as localStorage from "../util/localStorage";
|
||||
import { CliInstallBanner } from "./CliInstallBanner";
|
||||
|
||||
vi.mock("../util", async () => {
|
||||
const actual = await vi.importActual("../util");
|
||||
return {
|
||||
...actual,
|
||||
getPlatform: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../util/localStorage", async () => {
|
||||
const actual = await vi.importActual("../util/localStorage");
|
||||
return {
|
||||
...actual,
|
||||
getLocalStorage: vi.fn(),
|
||||
setLocalStorage: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe("CliInstallBanner", () => {
|
||||
let mockIdeMessenger: MockIdeMessenger;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockIdeMessenger = new MockIdeMessenger();
|
||||
vi.mocked(util.getPlatform).mockReturnValue("mac");
|
||||
vi.mocked(localStorage.getLocalStorage).mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
const renderComponent = async (subprocessResponse: [string, string]) => {
|
||||
// Mock the subprocess call on the IDE
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue(
|
||||
subprocessResponse,
|
||||
);
|
||||
|
||||
return act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
describe("CLI detection", () => {
|
||||
it("does not render when CLI is installed (subprocess returns path)", async () => {
|
||||
await renderComponent(["/usr/local/bin/cn", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders when CLI is not installed (subprocess returns empty)", async () => {
|
||||
await renderComponent(["", "command not found"]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders when CLI is not installed (subprocess returns empty stdout)", async () => {
|
||||
await renderComponent(["", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("uses 'which cn' command on mac platform", async () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("mac");
|
||||
const subprocessSpy = vi
|
||||
.spyOn(mockIdeMessenger.ide, "subprocess")
|
||||
.mockResolvedValue(["", ""]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(subprocessSpy).toHaveBeenCalledWith("which cn");
|
||||
});
|
||||
});
|
||||
|
||||
it("uses 'which cn' command on linux platform", async () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("linux");
|
||||
const subprocessSpy = vi
|
||||
.spyOn(mockIdeMessenger.ide, "subprocess")
|
||||
.mockResolvedValue(["", ""]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(subprocessSpy).toHaveBeenCalledWith("which cn");
|
||||
});
|
||||
});
|
||||
|
||||
it("uses 'where cn' command on windows platform", async () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("windows");
|
||||
const subprocessSpy = vi
|
||||
.spyOn(mockIdeMessenger.ide, "subprocess")
|
||||
.mockResolvedValue(["", ""]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(subprocessSpy).toHaveBeenCalledWith("where cn");
|
||||
});
|
||||
});
|
||||
|
||||
it("handles subprocess errors gracefully", async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockRejectedValue(
|
||||
new Error("Command failed"),
|
||||
);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Banner content", () => {
|
||||
beforeEach(async () => {
|
||||
await renderComponent(["", "not found"]);
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("displays the title", () => {
|
||||
expect(screen.getByText("Try out the Continue CLI")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the description with 'cn' code element", () => {
|
||||
const description = screen.getByText(/Use/);
|
||||
expect(description).toBeInTheDocument();
|
||||
expect(screen.getByText("cn")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the installation command", () => {
|
||||
expect(screen.getByText("npm i -g @continuedev/cli")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the Learn more link", () => {
|
||||
expect(screen.getByText("Learn more.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the close button", () => {
|
||||
// Get the styled close button (it doesn't have a text label)
|
||||
const buttons = screen.getAllByRole("button");
|
||||
// There should be multiple buttons (close, copy, run)
|
||||
expect(buttons.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("displays the CommandLine icon", () => {
|
||||
// The icon should be present in the component
|
||||
const banner = screen
|
||||
.getByText("Try out the Continue CLI")
|
||||
.closest("div");
|
||||
expect(banner).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("User interactions", () => {
|
||||
beforeEach(async () => {
|
||||
await renderComponent(["", "not found"]);
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("dismisses banner when close button is clicked", async () => {
|
||||
const buttons = screen.getAllByRole("button");
|
||||
// First button should be the close button (CloseButton component)
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("opens documentation URL when Learn more link is clicked", async () => {
|
||||
const postSpy = vi.spyOn(mockIdeMessenger, "post");
|
||||
const learnMoreLink = screen.getByText("Learn more.");
|
||||
|
||||
fireEvent.click(learnMoreLink);
|
||||
|
||||
expect(postSpy).toHaveBeenCalledWith(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/guides/cli",
|
||||
);
|
||||
});
|
||||
|
||||
it("displays the installation command with interactive controls", async () => {
|
||||
// The installation command should be visible
|
||||
expect(screen.getByText("npm i -g @continuedev/cli")).toBeInTheDocument();
|
||||
// The "Run" text should be visible for the run button
|
||||
expect(screen.getByText(/Run/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("runs installation command in terminal when run button is clicked", async () => {
|
||||
const postSpy = vi.spyOn(mockIdeMessenger, "post");
|
||||
|
||||
// Find the "Run" text or CommandLineIcon
|
||||
const runButton = screen.getByText(/Run/i).closest("div");
|
||||
if (runButton) {
|
||||
fireEvent.click(runButton);
|
||||
|
||||
expect(postSpy).toHaveBeenCalledWith("runCommand", {
|
||||
command: `npm i -g @continuedev/cli && cn "Explore this repo and provide a concise summary of it's contents"`,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Banner visibility states", () => {
|
||||
it("does not render while CLI check is loading", async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockImplementation(
|
||||
() =>
|
||||
new Promise((resolve) => setTimeout(() => resolve(["", ""]), 100)),
|
||||
);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
// Should not be visible immediately
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("remains hidden after dismissal even on re-render", async () => {
|
||||
const { rerender } = await renderComponent(["", "not found"]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Dismiss the banner
|
||||
const buttons = screen.getAllByRole("button");
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Re-render the component
|
||||
rerender(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
);
|
||||
|
||||
// Should still be hidden
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Edge cases", () => {
|
||||
it("handles whitespace in subprocess output", async () => {
|
||||
await renderComponent([" \n ", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("detects CLI when path has trailing newline", async () => {
|
||||
await renderComponent(["/usr/local/bin/cn\n", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders banner when stderr contains 'not found'", async () => {
|
||||
await renderComponent(["", "cn: command not found"]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Session threshold logic", () => {
|
||||
const renderWithSessionCount = async (
|
||||
sessionCount?: number,
|
||||
sessionThreshold?: number,
|
||||
) => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([
|
||||
"",
|
||||
"not found",
|
||||
]);
|
||||
|
||||
return act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner
|
||||
sessionCount={sessionCount}
|
||||
sessionThreshold={sessionThreshold}
|
||||
/>
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
it("shows banner when no threshold is set", async () => {
|
||||
await renderWithSessionCount(0, undefined);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("does not show banner when session count is below threshold", async () => {
|
||||
await renderWithSessionCount(2, 3);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows banner when session count meets threshold", async () => {
|
||||
await renderWithSessionCount(3, 3);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows banner when session count exceeds threshold", async () => {
|
||||
await renderWithSessionCount(5, 3);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Permanent dismissal with localStorage", () => {
|
||||
const renderWithPermanentDismissal = async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([
|
||||
"",
|
||||
"not found",
|
||||
]);
|
||||
|
||||
return act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner permanentDismissal={true} />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
it("does not show banner when previously dismissed permanently", async () => {
|
||||
vi.mocked(localStorage.getLocalStorage).mockReturnValue(true);
|
||||
|
||||
await renderWithPermanentDismissal();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("sets localStorage when dismissed with permanentDismissal=true", async () => {
|
||||
await renderWithPermanentDismissal();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const buttons = screen.getAllByRole("button");
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
expect(localStorage.setLocalStorage).toHaveBeenCalledWith(
|
||||
"hasDismissedCliInstallBanner",
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("does not set localStorage when dismissed with permanentDismissal=false", async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([
|
||||
"",
|
||||
"not found",
|
||||
]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner permanentDismissal={false} />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const buttons = screen.getAllByRole("button");
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
expect(localStorage.setLocalStorage).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
167
gui/src/components/CliInstallBanner.tsx
Normal file
167
gui/src/components/CliInstallBanner.tsx
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
import { CommandLineIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { CloseButton } from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import useCopy from "../hooks/useCopy";
|
||||
import { getPlatform } from "../util";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { CopyButton } from "./StyledMarkdownPreview/StepContainerPreToolbar/CopyButton";
|
||||
import { RunInTerminalButton } from "./StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton";
|
||||
import { Card } from "./ui";
|
||||
|
||||
interface CliInstallBannerProps {
|
||||
/** Number of sessions user has had - banner shows only if >= sessionThreshold */
|
||||
sessionCount?: number;
|
||||
/** Minimum sessions before showing banner (default: always show) */
|
||||
sessionThreshold?: number;
|
||||
/** If true, dismissal is permanent via localStorage (default: session only) */
|
||||
permanentDismissal?: boolean;
|
||||
}
|
||||
|
||||
export function CliInstallBanner({
|
||||
sessionCount,
|
||||
sessionThreshold,
|
||||
permanentDismissal = false,
|
||||
}: CliInstallBannerProps = {}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [cliInstalled, setCliInstalled] = useState<boolean | null>(null);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const commandTextRef = useRef<HTMLSpanElement>(null);
|
||||
const { copyText } = useCopy("npm i -g @continuedev/cli");
|
||||
const [showCopiedMessage, setShowCopiedMessage] = useState(false);
|
||||
|
||||
const handleCommandClick = () => {
|
||||
// Select the text
|
||||
if (commandTextRef.current) {
|
||||
const selection = window.getSelection();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(commandTextRef.current);
|
||||
selection?.removeAllRanges();
|
||||
selection?.addRange(range);
|
||||
}
|
||||
// Copy to clipboard
|
||||
copyText();
|
||||
|
||||
// Show "Copied!" message for 3 seconds
|
||||
setShowCopiedMessage(true);
|
||||
setTimeout(() => setShowCopiedMessage(false), 3000);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Check if user has permanently dismissed the banner
|
||||
if (permanentDismissal) {
|
||||
const hasDismissed = getLocalStorage("hasDismissedCliInstallBanner");
|
||||
if (hasDismissed) {
|
||||
setDismissed(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const checkCliInstallation = async () => {
|
||||
try {
|
||||
const platform = getPlatform();
|
||||
// Use 'which' on mac/linux, 'where' on windows
|
||||
const command = platform === "windows" ? "where cn" : "which cn";
|
||||
|
||||
const [stdout, stderr] = await ideMessenger.ide.subprocess(command);
|
||||
|
||||
// If stdout has content (path to cn), it's installed
|
||||
// If empty or stderr has "not found", it's not installed
|
||||
const isInstalled =
|
||||
stdout.trim().length > 0 && !stderr.includes("not found");
|
||||
setCliInstalled(isInstalled);
|
||||
} catch (error) {
|
||||
// If subprocess throws an error, assume CLI is not installed
|
||||
setCliInstalled(false);
|
||||
}
|
||||
};
|
||||
|
||||
void checkCliInstallation();
|
||||
}, [ideMessenger, permanentDismissal]);
|
||||
|
||||
const handleDismiss = () => {
|
||||
setDismissed(true);
|
||||
if (permanentDismissal) {
|
||||
setLocalStorage("hasDismissedCliInstallBanner", true);
|
||||
}
|
||||
};
|
||||
|
||||
// Don't show if:
|
||||
// - Still loading CLI status
|
||||
// - CLI is already installed
|
||||
// - User has dismissed it
|
||||
// - Session threshold not met (if threshold is set)
|
||||
if (
|
||||
cliInstalled === null ||
|
||||
cliInstalled === true ||
|
||||
dismissed ||
|
||||
(sessionThreshold !== undefined &&
|
||||
(sessionCount === undefined || sessionCount < sessionThreshold))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-t-vsc-input-border bg-vsc-background sticky bottom-0 border-t px-4 pb-4 pt-4">
|
||||
<Card className="relative">
|
||||
<CloseButton onClick={handleDismiss}>
|
||||
<XMarkIcon className="h-5 w-5 hover:brightness-125" />
|
||||
</CloseButton>
|
||||
<div className="flex flex-col gap-3">
|
||||
<div>
|
||||
<div className="text-foreground flex items-center gap-2 font-medium">
|
||||
<CommandLineIcon className="h-5 w-5 flex-shrink-0 text-gray-400" />
|
||||
Try out the Continue CLI
|
||||
</div>
|
||||
<div className="text-description mt-1 text-sm">
|
||||
Use{" "}
|
||||
<code className="bg-vsc-background rounded px-1.5 py-0.5">
|
||||
cn
|
||||
</code>{" "}
|
||||
in your terminal interactively and then deploy Continuous AI
|
||||
workflows.{" "}
|
||||
<span
|
||||
onClick={() =>
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/guides/cli",
|
||||
)
|
||||
}
|
||||
className="cursor-pointer underline hover:brightness-125"
|
||||
>
|
||||
Learn more.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col items-start gap-2 self-stretch">
|
||||
<div className="rounded-default outline-command-border flex items-center self-stretch outline outline-1">
|
||||
<div className="bg-editor rounded-l-default relative flex-1 px-3 py-3">
|
||||
<span
|
||||
ref={commandTextRef}
|
||||
className="text-foreground cursor-pointer text-xs"
|
||||
style={{ fontFamily: "var(--vscode-editor-font-family)" }}
|
||||
onClick={handleCommandClick}
|
||||
>
|
||||
npm i -g @continuedev/cli
|
||||
</span>
|
||||
{showCopiedMessage && (
|
||||
<span className="bg-editor rounded-l-default absolute inset-0 flex items-center justify-center px-2 text-xs font-medium">
|
||||
Copied!
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="bg-background rounded-r-default flex items-center gap-2 px-3 py-3">
|
||||
<CopyButton
|
||||
text={`npm i -g @continuedev/cli && cn "Explore this repo and provide a concise summary of it's contents"`}
|
||||
/>
|
||||
<RunInTerminalButton
|
||||
command={`npm i -g @continuedev/cli && cn "Explore this repo and provide a concise summary of it's contents"`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -23,9 +23,34 @@ import { visit } from "unist-util-visit";
|
|||
export function remarkTables() {
|
||||
return (tree: any) => {
|
||||
visit(tree, "paragraph", (paragraphNode, index, parentOfParagraphNode) => {
|
||||
let buffer = "";
|
||||
visit(paragraphNode, "text", (textNode) => {
|
||||
buffer += textNode.value;
|
||||
// Collect all child nodes into a buffer, preserving their types
|
||||
const buffer: any[] = [];
|
||||
paragraphNode.children.forEach((child: any) => {
|
||||
buffer.push(child);
|
||||
});
|
||||
|
||||
// Flatten buffer to a string for regex matching, but keep track of positions
|
||||
let bufferString = "";
|
||||
const positions: { start: number; end: number; node: any }[] = [];
|
||||
|
||||
// Recursive renderer for inline nodes -> markdown-ish text
|
||||
function renderInline(node: any): string {
|
||||
if (!node) return "";
|
||||
if (Array.isArray(node.children)) {
|
||||
return node.children.map(renderInline).join("");
|
||||
}
|
||||
if (typeof node.value === "string") {
|
||||
return node.value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
buffer.forEach((item) => {
|
||||
const start = bufferString.length;
|
||||
// renderInline returns a markdown-like string for inline nodes so decorations are preserved
|
||||
const rendered = renderInline(item);
|
||||
bufferString += rendered;
|
||||
positions.push({ start, end: bufferString.length, node: item });
|
||||
});
|
||||
|
||||
const tableRegex =
|
||||
|
|
@ -33,7 +58,7 @@ export function remarkTables() {
|
|||
//// header // newline // |:---|----:| // new line // table rows
|
||||
|
||||
// prevent modifying if no markdown tables are present
|
||||
if (!buffer.match(tableRegex)) {
|
||||
if (!bufferString.match(tableRegex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +67,7 @@ export function remarkTables() {
|
|||
const newNodes = [];
|
||||
let failed = false;
|
||||
|
||||
while ((match = tableRegex.exec(buffer)) !== null) {
|
||||
while ((match = tableRegex.exec(bufferString)) !== null) {
|
||||
const fullTableString = match[0];
|
||||
const headerGroup = match[1];
|
||||
const separatorGroup = match[2];
|
||||
|
|
@ -104,16 +129,46 @@ export function remarkTables() {
|
|||
],
|
||||
};
|
||||
|
||||
// Add any text before the table as a text node
|
||||
if (match.index > lastIndex) {
|
||||
newNodes.push({
|
||||
type: "text",
|
||||
value: buffer.slice(lastIndex, match.index),
|
||||
});
|
||||
}
|
||||
// Add any nodes before/after the table in one go
|
||||
const tableStart = match.index;
|
||||
const tableEnd = match.index + fullTableString.length;
|
||||
|
||||
// Add table node
|
||||
// Process the text within the table and the surrounding text together
|
||||
const beforeNodes: any[] = [];
|
||||
const afterNodes: any[] = [];
|
||||
|
||||
positions.forEach((pos) => {
|
||||
if (pos.end <= tableStart) {
|
||||
beforeNodes.push(pos.node);
|
||||
} else if (pos.start >= tableEnd) {
|
||||
afterNodes.push(pos.node);
|
||||
} else if (pos.node.type === "text") {
|
||||
// Node is text and overlaps with table, may need splitting
|
||||
const beforeText = pos.node.value.slice(
|
||||
0,
|
||||
Math.max(0, tableStart - pos.start),
|
||||
);
|
||||
const afterText = pos.node.value.slice(
|
||||
Math.max(0, tableEnd - pos.start),
|
||||
);
|
||||
if (beforeText)
|
||||
beforeNodes.push({ type: "text", value: beforeText });
|
||||
if (afterText)
|
||||
afterNodes.push({ type: "text", value: afterText });
|
||||
} else {
|
||||
// Node overlaps with table but isn't text (e.g., inlineCode, emphasis, etc.)
|
||||
if (pos.start < tableStart) beforeNodes.push(pos.node);
|
||||
if (pos.end > tableEnd) afterNodes.push(pos.node);
|
||||
}
|
||||
});
|
||||
|
||||
// Add to new nodes
|
||||
newNodes.push(...beforeNodes);
|
||||
newNodes.push(tableNode);
|
||||
newNodes.push(...afterNodes);
|
||||
|
||||
// Mark positions as consumed
|
||||
positions.length = 0;
|
||||
} catch (e) {
|
||||
console.error("Failed to parse markdown table after regex match", e);
|
||||
newNodes.push({
|
||||
|
|
@ -129,14 +184,6 @@ export function remarkTables() {
|
|||
return;
|
||||
}
|
||||
|
||||
// Add any remaining text after the last table
|
||||
if (lastIndex < buffer.length) {
|
||||
newNodes.push({
|
||||
type: "text",
|
||||
value: buffer.slice(lastIndex),
|
||||
});
|
||||
}
|
||||
|
||||
// Replace the original paragraph node with the new nodes
|
||||
if (newNodes.length > 0) {
|
||||
parentOfParagraphNode.children.splice(index, 1, ...newNodes);
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 8192,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["groq", "askSage"],
|
||||
providerOptions: ["groq"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
llama318bChat: {
|
||||
|
|
@ -841,7 +841,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 32000,
|
||||
},
|
||||
icon: "mistral.png",
|
||||
providerOptions: ["mistral", "askSage"],
|
||||
providerOptions: ["mistral"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
mistralNemo: {
|
||||
|
|
@ -1114,7 +1114,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 128_000,
|
||||
title: "GPT-4o",
|
||||
},
|
||||
providerOptions: ["openai", "askSage"],
|
||||
providerOptions: ["openai"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1125,9 +1125,10 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
params: {
|
||||
model: "gpt-4o-mini",
|
||||
contextLength: 128_000,
|
||||
|
||||
title: "GPT-4o mini",
|
||||
},
|
||||
providerOptions: ["openai", "askSage"],
|
||||
providerOptions: ["openai"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1140,7 +1141,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 8096,
|
||||
title: "GPT-3.5-Turbo",
|
||||
},
|
||||
providerOptions: ["openai", "askSage"],
|
||||
providerOptions: ["openai"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1154,7 +1155,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Claude 4 Sonnet",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["anthropic", "askSage"],
|
||||
providerOptions: ["anthropic"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1167,7 +1168,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Claude 4.1 Opus",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["anthropic", "askSage"],
|
||||
providerOptions: ["anthropic"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1331,135 +1332,382 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
providerOptions: ["vertexai"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
// OpenAI Models via Ask Sage
|
||||
asksagegpt4o: {
|
||||
title: "GPT-4o*",
|
||||
description:
|
||||
"An even faster version of GPT-4 with stronger multi-modal capabilities.",
|
||||
params: {
|
||||
model: "gpt-4o",
|
||||
contextLength: 128_000,
|
||||
maxTokens: 16_384,
|
||||
title: "GPT-4o*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt4omini: {
|
||||
title: "GPT-4o Mini*",
|
||||
description:
|
||||
"A model at less than half the price of gpt-3.5-turbo, but near gpt-4 in capabilities.",
|
||||
params: {
|
||||
model: "gpt-4o-mini",
|
||||
contextLength: 128_000,
|
||||
maxTokens: 16_384,
|
||||
title: "GPT-4o mini*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt4gov: {
|
||||
title: "GPT-4 gov",
|
||||
title: "GPT-4 gov*",
|
||||
description:
|
||||
"U.S. Government. Most capable model today - which is similar to GPT-4 but approved for use by the U.S. Government.",
|
||||
params: {
|
||||
model: "gpt4-gov",
|
||||
contextLength: 128_000,
|
||||
title: "GPT-4 gov",
|
||||
maxTokens: 4096,
|
||||
title: "GPT-4 gov*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt4ogov: {
|
||||
title: "GPT-4o gov",
|
||||
title: "GPT-4o gov*",
|
||||
description:
|
||||
"U.S. Government. Most capable model today - which is similar to GPT-4o but approved for use by the U.S. Government.",
|
||||
params: {
|
||||
model: "gpt-4o-gov",
|
||||
contextLength: 128_000,
|
||||
title: "GPT-4o-gov",
|
||||
maxTokens: 4096,
|
||||
title: "GPT-4o-gov*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt35: {
|
||||
title: "GPT-3.5*",
|
||||
description: "Azure OpenAI GPT 3.5 Model.",
|
||||
params: {
|
||||
model: "gpt",
|
||||
contextLength: 4096,
|
||||
title: "GPT-3.5*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt35gov: {
|
||||
title: "GPT-3.5-Turbo gov",
|
||||
title: "GPT-3.5 gov*",
|
||||
description: "U.S. Government. Inexpensive and good ROI.",
|
||||
params: {
|
||||
model: "gpt-gov",
|
||||
contextLength: 8096,
|
||||
title: "GPT-3.5-Turbo gov",
|
||||
contextLength: 16834,
|
||||
maxTokens: 4096,
|
||||
title: "GPT-3.5 gov*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt4ominigov: {
|
||||
title: "GPT-4o-mini gov",
|
||||
description:
|
||||
"U.S. Government. Latest OpenAI GPT 4o-mini model. More inexpensive than GPT4. Capable of ingesting and analyzing images (JPG, PNG, GIF (20MB files max)). 16,384 token response max.",
|
||||
title: "GPT-4o-mini gov*",
|
||||
description: "OpenAI GPT 4o-mini model.",
|
||||
params: {
|
||||
model: "gpt-4o-mini-gov",
|
||||
contextLength: 128_000,
|
||||
title: "GPT-4o-mini gov",
|
||||
maxTokens: 16_384,
|
||||
title: "GPT-4o-mini gov*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt4: {
|
||||
title: "GPT-4",
|
||||
title: "GPT-4*",
|
||||
description:
|
||||
"GPT4 is about 5X more expensive than Ask Sage tokens and 50X more expensive than GPT3.5",
|
||||
params: {
|
||||
model: "gpt4",
|
||||
contextLength: 8_192,
|
||||
title: "GPT-4",
|
||||
},
|
||||
providerOptions: ["openai"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt432: {
|
||||
title: "GPT-4-32k",
|
||||
description:
|
||||
"The GPT-4-32k model is a variant of the GPT-4 model developed by OpenAI. It is designed to handle a larger context window, capable of processing up to 32,768 tokens, which makes it suitable for scenarios that require extensive information integration and data analysis",
|
||||
params: {
|
||||
model: "gpt4-32k",
|
||||
contextLength: 32_768,
|
||||
title: "GPT-4-32k",
|
||||
title: "GPT-4*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["openai"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpto1: {
|
||||
title: "GPT-o1",
|
||||
title: "GPT-o1*",
|
||||
description:
|
||||
"Latest OpenAI GPT-o1 model. More inexpensive than GPT4. Capable of ingesting and analyzing images (JPG, PNG, GIF (20MB files max)).",
|
||||
params: {
|
||||
model: "gpt-o1",
|
||||
contextLength: 128_000,
|
||||
title: "GPT-o1",
|
||||
maxTokens: 32_768,
|
||||
title: "GPT-o1*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false, // stopped here
|
||||
},
|
||||
asksagegpt41: {
|
||||
title: "GPT-4.1*",
|
||||
description: "Azure OpenAI GPT 4.1 model.",
|
||||
params: {
|
||||
model: "gpt-4.1",
|
||||
contextLength: 1_000_000,
|
||||
maxTokens: 32_768,
|
||||
title: "GPT-4.1*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpto1mini: {
|
||||
title: "GPT-o1-mini",
|
||||
description:
|
||||
"Latest OpenAI GPT-o1-mini model. More inexpensive than GPT-o1. Capable of ingesting and analyzing images (JPG, PNG, GIF (20MB files max)). 16,384 token response max.",
|
||||
asksagegpt41mini: {
|
||||
title: "GPT-4.1 mini*",
|
||||
description: "Azure OpenAI GPT 4.1 mini model.",
|
||||
params: {
|
||||
model: "gpt-o1-mini",
|
||||
contextLength: 128_000,
|
||||
title: "GPT-o1-mini",
|
||||
model: "gpt-4.1-mini",
|
||||
contextLength: 1_000_000,
|
||||
maxTokens: 32_768,
|
||||
title: "GPT-4.1 mini*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpto3mini: {
|
||||
title: "GPT-o3-mini",
|
||||
description:
|
||||
"o3-mini can outperform o1 in coding and other reasoning tasks, and is 93% cheaper and has lower latency. It supports function calling, Structured Outputs, streaming, and developer messages. o3-mini comes with a larger context window of 200,000 tokens and a max output of 100,000 tokens",
|
||||
asksagegpt41nano: {
|
||||
title: "GPT-4.1 nano*",
|
||||
description: "Azure OpenAI GPT 4.1 nano model.",
|
||||
params: {
|
||||
model: "gpt-o3-mini",
|
||||
model: "gpt-4.1-nano",
|
||||
contextLength: 1_000_000,
|
||||
maxTokens: 32_768,
|
||||
title: "GPT-4.1 nano*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt5: {
|
||||
title: "GPT-5*",
|
||||
description: "OpenAI's GPT-5 model",
|
||||
params: {
|
||||
model: "gpt-5",
|
||||
contextLength: 272_000,
|
||||
maxTokens: 128_000,
|
||||
title: "GPT-5*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt5nano: {
|
||||
title: "GPT-5-nano*",
|
||||
description: "OpenAI's GPT-5-nano model",
|
||||
params: {
|
||||
model: "gpt-5-nano",
|
||||
contextLength: 272_000,
|
||||
maxTokens: 128_000,
|
||||
title: "GPT-5-nano*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpt5mini: {
|
||||
title: "GPT-5-mini*",
|
||||
description: "OpenAI's GPT-5-mini model",
|
||||
params: {
|
||||
model: "gpt-5-mini",
|
||||
contextLength: 272_000,
|
||||
maxTokens: 128_000,
|
||||
title: "GPT-5-mini*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpto3: {
|
||||
title: "GPT-o3",
|
||||
description: "Azure OpenAI GPT o3 model.",
|
||||
params: {
|
||||
model: "gpt-o3",
|
||||
contextLength: 200_000,
|
||||
title: "GPT-o3-mini",
|
||||
maxTokens: 100_000,
|
||||
title: "GPT-o3",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude35gov: {
|
||||
title: "Claude 3.5 Sonnet gov",
|
||||
asksagegpt04mini: {
|
||||
title: "GPT-o4-mini",
|
||||
description: "Azure OpenAI GPT o4-mini model.",
|
||||
params: {
|
||||
model: "gpt-o4-mini",
|
||||
contextLength: 200_000,
|
||||
maxTokens: 100_000,
|
||||
title: "GPT-o4-mini",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude35Sonnet: {
|
||||
title: "Claude 3.5 Sonnet",
|
||||
description:
|
||||
"Anthropic's most intelligent model, but much less expensive than Claude 3 Opus",
|
||||
params: {
|
||||
model: "aws-bedrock-claude-35-sonnet-gov",
|
||||
model: "claude-35-sonnet",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 3.5 Sonnet gov",
|
||||
title: "Claude 3.5 Sonnet",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude37sonnet: {
|
||||
title: "Claude 3.7 Sonnet",
|
||||
description: "Anthropic's 3.7 model.",
|
||||
params: {
|
||||
model: "claude-37-sonnet",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 3.7 Sonnet",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude37sonnetgov: {
|
||||
title: "Claude 3.7 Sonnet gov*",
|
||||
description: "Anthropic's 3.7 Sonnet model.",
|
||||
params: {
|
||||
model: "aws-bedrock-claude-37-sonnet-gov",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 3.7 Sonnet gov*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude35gov: {
|
||||
title: "Claude 3.5 Sonnet gov*",
|
||||
description: "Anthropic's 3.5 Sonnet model.",
|
||||
params: {
|
||||
model: "aws-bedrock-claude-35-sonnet-gov",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 3.5 Sonnet gov*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude4s: {
|
||||
title: "Claude 4 Sonnet",
|
||||
description: "Anthropic's Claude 4 Sonnet",
|
||||
params: {
|
||||
model: "claude-4-sonnet",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 4 Sonnet",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude4o: {
|
||||
title: "Claude 4 Opus",
|
||||
description: "Anthropic's Claude 4 Opus",
|
||||
params: {
|
||||
model: "claude-4-opus",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 4 Opus",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude4sonnet: {
|
||||
title: "Claude 4 Sonnet*",
|
||||
description:
|
||||
"Anthropic's most powerful model, designed for complex, reasoning-heavy tasks like agentic search, coding, and writing.",
|
||||
params: {
|
||||
model: "google-claude-4-sonnet",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 4 Sonnet*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude45sonnet: {
|
||||
title: "Claude 4.5 Sonnet*",
|
||||
description:
|
||||
"Anthropic's most powerful model, designed for complex, reasoning-heavy tasks like agentic search, coding, and writing.",
|
||||
params: {
|
||||
model: "google-claude-45-sonnet",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 4.5 Sonnet*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude41opus: {
|
||||
title: "Claude 4.1 Opus*",
|
||||
description: "Claude 4.1 Opus",
|
||||
params: {
|
||||
model: "google-claude-4-opus",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 4.1 Opus*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagenovalite: {
|
||||
title: "Nova Lite*",
|
||||
description: "AWS Gov Nova Lite model.",
|
||||
params: {
|
||||
model: "aws-bedrock-nova-lite-gov",
|
||||
contextLength: 300_000,
|
||||
title: "Nova Lite*",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "aws.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegroqllama33: {
|
||||
title: "Llama 3.3",
|
||||
description: "Llama-3.3 is a large language model customized by Groq.",
|
||||
|
|
@ -1467,7 +1715,9 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Llama 3.3",
|
||||
model: "groq-llama33",
|
||||
contextLength: 128_000,
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "groq.png",
|
||||
isOpenSource: true,
|
||||
},
|
||||
|
|
@ -1478,10 +1728,66 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Groq-70B",
|
||||
model: "groq-70b",
|
||||
contextLength: 8_192,
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "groq.png",
|
||||
isOpenSource: true,
|
||||
},
|
||||
asksagegemini20Flash: {
|
||||
title: "Gemini 2.0 Flash*",
|
||||
description:
|
||||
"Google's powerful workhorse model with low latency and enhanced performance.",
|
||||
params: {
|
||||
title: "Gemini 2.0 Flash*",
|
||||
model: "google-gemini-20-flash",
|
||||
contextLength: 1_000_000,
|
||||
apiKey: "",
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["askSage"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegemini25Pro: {
|
||||
title: "Gemini 2.5 Pro*",
|
||||
description: "Google's Gemini 2.5 Pro model",
|
||||
params: {
|
||||
title: "Gemini 2.5 Pro*",
|
||||
model: "google-gemini-2.5-pro",
|
||||
contextLength: 1_000_000,
|
||||
apiKey: "",
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["askSage"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegemini25flash: {
|
||||
title: "Gemini 2.5 Flash*",
|
||||
description: "Google's Gemini 2.5 Flash model",
|
||||
params: {
|
||||
title: "Gemini 2.5 Flash*",
|
||||
model: "google-gemini-2.5-flash",
|
||||
contextLength: 1_000_000,
|
||||
apiKey: "",
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["askSage"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegrok4: {
|
||||
title: "Grok 4",
|
||||
description:
|
||||
"xAI's latest and greatest flagship model, offering strong performance in natural language, math and reasoning.",
|
||||
params: {
|
||||
title: "Grok 4",
|
||||
model: "xai-grok",
|
||||
contextLength: 256_000,
|
||||
apiKey: "",
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["askSage"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
Qwen2Coder: {
|
||||
title: "Qwen 2.5 Coder 7b",
|
||||
description:
|
||||
|
|
@ -1531,7 +1837,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 256000,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI", "askSage"],
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok4FastReasoning: {
|
||||
|
|
@ -1544,7 +1850,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 2_000_000,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI", "askSage"],
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok4FastNonReasoning: {
|
||||
|
|
@ -1557,7 +1863,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 2_000_000,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI", "askSage"],
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok4: {
|
||||
|
|
@ -1571,7 +1877,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 256_000,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI", "askSage"],
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok3: {
|
||||
|
|
@ -1585,7 +1891,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 131_072,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI", "askSage"],
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok3Mini: {
|
||||
|
|
@ -1599,7 +1905,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 131_072,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI", "askSage"],
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
gemma2_2b: {
|
||||
|
|
|
|||
|
|
@ -942,7 +942,6 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
...completionParamsInputsConfigs,
|
||||
],
|
||||
},
|
||||
|
||||
askSage: {
|
||||
title: "Ask Sage",
|
||||
provider: "askSage",
|
||||
|
|
@ -953,7 +952,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
tags: [ModelProviderTags.RequiresApiKey],
|
||||
params: {
|
||||
apiKey: "",
|
||||
apiBase: "https://api.asksage.ai/server/", // Default base URL
|
||||
apiBase: "https://api.asksage.ai/server/",
|
||||
},
|
||||
collectInputFor: [
|
||||
{
|
||||
|
|
@ -967,32 +966,46 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
inputType: "text",
|
||||
key: "apiBase",
|
||||
label: "API Base URL",
|
||||
placeholder: "Enter the API Base URL",
|
||||
placeholder: "Enter your Ask Sage API base URL",
|
||||
required: true,
|
||||
defaultValue: "https://api.asksage.ai/server/",
|
||||
},
|
||||
...completionParamsInputsConfigs,
|
||||
],
|
||||
packages: [
|
||||
models.asksagegpt4ogov,
|
||||
models.asksagegpt4ominigov,
|
||||
models.asksagegpt4gov,
|
||||
models.asksagegpt35gov,
|
||||
models.gpt4o,
|
||||
models.gpt4omini,
|
||||
models.asksagegpt4,
|
||||
models.asksagegpt432,
|
||||
models.asksagegpto1,
|
||||
models.asksagegpto1mini,
|
||||
models.gpt35turbo,
|
||||
models.asksageclaude45sonnet,
|
||||
models.asksageclaude4sonnet,
|
||||
models.asksageclaude41opus,
|
||||
models.asksagegpt5,
|
||||
models.asksagegpt5nano,
|
||||
models.asksagegpt5mini,
|
||||
models.asksagegemini20Flash,
|
||||
models.asksagegemini25Pro,
|
||||
models.asksagegemini25flash,
|
||||
models.asksageclaude35gov,
|
||||
models.claude35Sonnet,
|
||||
models.claude3Opus,
|
||||
models.claude3Sonnet,
|
||||
models.grokBeta,
|
||||
models.asksagegroqllama33,
|
||||
models.asksageclaude37sonnetgov,
|
||||
models.asksagegpt4o,
|
||||
models.asksagegpt4omini,
|
||||
models.asksagegpt4gov,
|
||||
models.asksagegpt4ogov,
|
||||
models.asksagegpt35,
|
||||
models.asksagegpt35gov,
|
||||
models.asksagegpt4ominigov,
|
||||
models.asksagegpt4,
|
||||
models.asksagegpto1,
|
||||
models.asksagegpt41,
|
||||
models.asksagegpt41mini,
|
||||
models.asksagegpt41nano,
|
||||
models.asksagegpto3,
|
||||
models.asksagegpt04mini,
|
||||
models.asksagenovalite,
|
||||
models.asksagegroq70b,
|
||||
models.mistralLarge,
|
||||
models.llama370bChat,
|
||||
models.asksagegroqllama33,
|
||||
models.asksagegrok4,
|
||||
models.asksageclaude35Sonnet,
|
||||
models.asksageclaude37sonnet,
|
||||
models.asksageclaude4s,
|
||||
models.asksageclaude4o,
|
||||
],
|
||||
apiKeyUrl: "https://chat.asksage.ai/",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { TabGroup } from "../../components/ui/TabGroup";
|
|||
import { useAuth } from "../../context/Auth";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import { bottomTabSections, getAllTabs, topTabSections } from "./configTabs";
|
||||
import { CliInstallBanner } from "../../components/CliInstallBanner";
|
||||
import { AccountDropdown } from "./features/account/AccountDropdown";
|
||||
|
||||
function ConfigPage() {
|
||||
|
|
@ -89,8 +90,11 @@ function ConfigPage() {
|
|||
</div>
|
||||
|
||||
{/* Tab Content for larger screens (md and above) */}
|
||||
<div className="thin-scrollbar hidden flex-1 space-y-6 overflow-y-auto px-4 py-4 sm:block">
|
||||
{allTabs.find((tab) => tab.id === activeTab)?.component}
|
||||
<div className="thin-scrollbar relative hidden flex-1 overflow-y-auto sm:block">
|
||||
<div className="space-y-6 px-4 py-4">
|
||||
{allTabs.find((tab) => tab.id === activeTab)?.component}
|
||||
</div>
|
||||
<CliInstallBanner permanentDismissal={true} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -43,14 +43,15 @@ import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
|||
import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { ToolCallDiv } from "./ToolCallDiv";
|
||||
|
||||
import { useStore } from "react-redux";
|
||||
import { CliInstallBanner } from "../../components/CliInstallBanner";
|
||||
import { FatalErrorIndicator } from "../../components/config/FatalErrorNotice";
|
||||
import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { cancelStream } from "../../redux/thunks/cancelStream";
|
||||
import { EmptyChatBody } from "./EmptyChatBody";
|
||||
import { ExploreDialogWatcher } from "./ExploreDialogWatcher";
|
||||
import { useAutoScroll } from "./useAutoScroll";
|
||||
import { useStore } from "react-redux";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
// Helper function to find the index of the latest conversation summary
|
||||
function findLatestSummaryIndex(history: ChatHistoryItem[]): number {
|
||||
|
|
@ -118,6 +119,9 @@ export function Chat() {
|
|||
const isInEdit = useAppSelector((store) => store.session.isInEdit);
|
||||
|
||||
const lastSessionId = useAppSelector((state) => state.session.lastSessionId);
|
||||
const allSessionMetadata = useAppSelector(
|
||||
(state) => state.session.allSessionMetadata,
|
||||
);
|
||||
const hasDismissedExploreDialog = useAppSelector(
|
||||
(state) => state.ui.hasDismissedExploreDialog,
|
||||
);
|
||||
|
|
@ -421,6 +425,12 @@ export function Chat() {
|
|||
inputId={MAIN_EDITOR_INPUT_ID}
|
||||
/>
|
||||
|
||||
<CliInstallBanner
|
||||
sessionCount={allSessionMetadata.length}
|
||||
sessionThreshold={3}
|
||||
permanentDismissal={true}
|
||||
/>
|
||||
|
||||
<div
|
||||
style={{
|
||||
pointerEvents: isStreaming ? "none" : "auto",
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ type LocalStorageTypes = {
|
|||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
hasExitedFreeTrial: boolean;
|
||||
hasDismissedCliInstallBanner: boolean;
|
||||
};
|
||||
|
||||
export enum LocalStorageKey {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export type StdioMcpServer = z.infer<typeof stdioMcpServerSchema>;
|
|||
const sseOrHttpMcpServerSchema = baseMcpServerSchema.extend({
|
||||
url: z.string(), // .url() fails with e.g. IP addresses
|
||||
type: z.union([z.literal("sse"), z.literal("streamable-http")]).optional(),
|
||||
apiKey: z.string().optional(),
|
||||
requestOptions: requestOptionsSchema.optional(),
|
||||
});
|
||||
export type SseMcpServer = z.infer<typeof sseOrHttpMcpServerSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue