diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 031ed1fbe..2e047b5d0 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -16,7 +16,7 @@ jobs: contents: write # Needed for creating releases steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Get version from package.json id: get_version @@ -45,7 +45,7 @@ jobs: contents: write # Needed for creating releases steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/.github/workflows/compliance.yaml b/.github/workflows/compliance.yaml index 3b69c00cb..6ab98b27e 100644 --- a/.github/workflows/compliance.yaml +++ b/.github/workflows/compliance.yaml @@ -101,7 +101,7 @@ jobs: contents: read steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js uses: actions/setup-node@v4 @@ -134,7 +134,7 @@ jobs: if: ${{ !github.event.pull_request.draft }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Check required files run: | diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b83567fca..589a8e2ed 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js uses: actions/setup-node@v4 diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml index 72bd84235..a0aa2d3f0 100644 --- a/.github/workflows/jetbrains-release.yaml +++ b/.github/workflows/jetbrains-release.yaml @@ -56,7 +56,7 @@ jobs: # steps: # # 0. Setup git # - name: Checkout - # uses: actions/checkout@v4 + # uses: actions/checkout@v5 # - name: Set up Git # run: | @@ -102,7 +102,7 @@ jobs: steps: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ github.event.release.tag_name }} @@ -362,7 +362,7 @@ jobs: steps: # 1. Check-out repository - name: Check-out repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 # 2. Install npm dependencies - name: Use Node.js from .nvmrc @@ -429,7 +429,7 @@ jobs: steps: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 # Set up Java environment for the next steps - name: Setup Java @@ -482,7 +482,7 @@ jobs: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 # Set up Java environment for the next steps - name: Setup Java @@ -513,7 +513,7 @@ jobs: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 # Set up Java environment for the next steps - name: Setup Java diff --git a/.github/workflows/label-merged-prs.yml b/.github/workflows/label-merged-prs.yml index c3c034117..d6f83eba8 100644 --- a/.github/workflows/label-merged-prs.yml +++ b/.github/workflows/label-merged-prs.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Check if author is in tier list id: check-author diff --git a/.github/workflows/main-build.yaml b/.github/workflows/main-build.yaml index 75e4104ab..a04afb945 100644 --- a/.github/workflows/main-build.yaml +++ b/.github/workflows/main-build.yaml @@ -18,7 +18,7 @@ jobs: matrix: platform: [Linux, macOS] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 2 # Get the last 2 commits to find the merge commit diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0a5845f6d..cf276f360 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -66,7 +66,7 @@ jobs: arch: arm64 npm_config_arch: arm64 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 @@ -92,7 +92,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 # This ensures all tags are fetched @@ -112,7 +112,7 @@ jobs: - build steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Git run: | @@ -145,7 +145,7 @@ jobs: steps: # 0. Setup git - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Git run: | diff --git a/.github/workflows/pr-build-upload-vsix.yaml b/.github/workflows/pr-build-upload-vsix.yaml index 6a8250a83..926855b7c 100644 --- a/.github/workflows/pr-build-upload-vsix.yaml +++ b/.github/workflows/pr-build-upload-vsix.yaml @@ -24,7 +24,7 @@ jobs: runner: macos-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 63afde345..6aa1429a8 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -14,7 +14,7 @@ jobs: prettier-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -35,7 +35,7 @@ jobs: core-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup packages uses: ./.github/actions/setup-packages - name: Setup core component @@ -71,7 +71,7 @@ jobs: gui-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup packages uses: ./.github/actions/setup-packages - name: Setup core component @@ -101,7 +101,7 @@ jobs: binary-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup packages uses: ./.github/actions/setup-packages - name: Setup core component @@ -123,7 +123,7 @@ jobs: vscode-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup packages uses: ./.github/actions/setup-packages - name: Setup core component @@ -156,7 +156,7 @@ jobs: outputs: packages: ${{ steps.get-packages.outputs.packages }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Get package list id: get-packages run: | @@ -171,7 +171,7 @@ jobs: matrix: package: ${{ fromJson(needs.get-packages-matrix.outputs.packages) }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup packages uses: ./.github/actions/setup-packages @@ -197,7 +197,7 @@ jobs: outputs: test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 @@ -289,7 +289,7 @@ jobs: test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }} command: ["e2e:ci:run", "e2e:ci:run-yaml"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Run VS Code E2E test uses: ./.github/actions/run-vscode-e2e-test with: @@ -303,7 +303,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Run JetBrains tests uses: ./.github/actions/run-jetbrains-tests with: diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 84e5399eb..b68a65efd 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -66,7 +66,7 @@ jobs: arch: arm64 npm_config_arch: arm64 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 @@ -96,7 +96,7 @@ jobs: - build steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Git run: | @@ -131,7 +131,7 @@ jobs: steps: # 0. Setup git - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Git run: | diff --git a/.github/workflows/reusable-release.yml b/.github/workflows/reusable-release.yml index 80d135e29..7cab0df2a 100644 --- a/.github/workflows/reusable-release.yml +++ b/.github/workflows/reusable-release.yml @@ -47,7 +47,7 @@ jobs: working-directory: ${{ inputs.package-path }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/.github/workflows/similar-issues.yml b/.github/workflows/similar-issues.yml index 13ebcf269..343982af8 100644 --- a/.github/workflows/similar-issues.yml +++ b/.github/workflows/similar-issues.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout deja-view - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: 'bdougie/deja-view' # Option 1: Pin to specific commit (most secure) diff --git a/.github/workflows/submit-github-dependency-graph.yml b/.github/workflows/submit-github-dependency-graph.yml index 50987cc2c..83611f4b7 100644 --- a/.github/workflows/submit-github-dependency-graph.yml +++ b/.github/workflows/submit-github-dependency-graph.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/vscode-version-bump.yml b/.github/workflows/vscode-version-bump.yml index a7aaee3d5..961fa50ba 100644 --- a/.github/workflows/vscode-version-bump.yml +++ b/.github/workflows/vscode-version-bump.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 # Fetch all history and tags diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 179e5fad4..9d977d071 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -17,6 +17,7 @@ import { ControlPlaneSessionInfo, } from "../control-plane/AuthTypes.js"; import { getControlPlaneEnv } from "../control-plane/env.js"; +import { PolicySingleton } from "../control-plane/PolicySingleton.js"; import { logger } from "../util/logger.js"; import { Telemetry } from "../util/posthog.js"; import { @@ -45,7 +46,7 @@ export class ConfigHandler { private organizations: OrgWithProfiles[] = []; currentProfile: ProfileLifecycleManager | null; - currentOrg: OrgWithProfiles; + currentOrg: OrgWithProfiles | null; totalConfigReloads: number = 0; public isInitialized: Promise; @@ -83,16 +84,9 @@ export class ConfigHandler { this.ide, ); - // Just to be safe, always force a default personal org with local profile manager - this.currentProfile = this.globalLocalProfileManager; - const personalOrg: OrgWithProfiles = { - currentProfile: this.globalLocalProfileManager, - profiles: [this.globalLocalProfileManager], - ...this.PERSONAL_ORG_DESC, - }; - - this.currentOrg = personalOrg; - this.organizations = [personalOrg]; + this.currentOrg = null; + this.currentProfile = null; + this.organizations = []; this.initter = new EventEmitter(); this.isInitialized = new Promise((resolve) => { @@ -132,10 +126,10 @@ export class ConfigHandler { const firstNonPersonal = orgs.find( (org) => org.id !== this.PERSONAL_ORG_DESC.id, ); - const fallback = firstNonPersonal ?? orgs[0]; - // note, ignoring case of zero orgs since should never happen + const fallback: OrgWithProfiles | null = + firstNonPersonal ?? orgs[0] ?? null; - let selectedOrg: OrgWithProfiles; + let selectedOrg: OrgWithProfiles | null; if (currentSelection) { const match = orgs.find((org) => org.id === currentSelection); if (match) { @@ -153,12 +147,12 @@ export class ConfigHandler { this.globalContext.update("lastSelectedOrgIdForWorkspace", { ...selectedOrgs, - [workspaceId]: selectedOrg.id, + [workspaceId]: selectedOrg?.id, }); this.organizations = orgs; this.currentOrg = selectedOrg; - this.currentProfile = selectedOrg.currentProfile; + this.currentProfile = selectedOrg?.currentProfile; await this.reloadConfig(reason, errors); } catch (e) { @@ -179,10 +173,27 @@ export class ConfigHandler { const isSignedIn = await this.controlPlaneClient.isSignedIn(); if (isSignedIn) { try { - const orgDescs = await this.controlPlaneClient.listOrganizations(); + // TODO use policy returned with org, not policy endpoint + const policyResponse = await this.controlPlaneClient.getPolicy(); + PolicySingleton.getInstance().policy = policyResponse; + const orgDescriptions = + await this.controlPlaneClient.listOrganizations(); + const orgsWithPolicy = orgDescriptions.map((d) => ({ + ...d, + policy: policyResponse?.policy, + })); + + if (policyResponse?.policy?.allowOtherOrgs === false) { + if (orgsWithPolicy.length === 0) { + return { orgs: [] }; + } else { + const firstOrg = await this.getNonPersonalHubOrg(orgsWithPolicy[0]); + return { orgs: [firstOrg] }; + } + } const orgs = await Promise.all([ this.getPersonalHubOrg(), - ...orgDescs.map((org) => this.getNonPersonalHubOrg(org)), + ...orgsWithPolicy.map((org) => this.getNonPersonalHubOrg(org)), ]); // TODO make try/catch more granular here, to catch specific org errors return { orgs }; @@ -426,7 +437,7 @@ export class ConfigHandler { // Org id: check id validity, save selection, switch and reload async setSelectedOrgId(orgId: string, profileId?: string) { - if (orgId === this.currentOrg.id) { + if (orgId === this.currentOrg?.id) { return; } const org = this.organizations.find((org) => org.id === orgId); @@ -454,6 +465,9 @@ export class ConfigHandler { // Profile id: check id validity, save selection, switch and reload async setSelectedProfileId(profileId: string) { + if (!this.currentOrg) { + throw new Error(`No org selected`); + } if ( this.currentProfile && profileId === this.currentProfile.profileDescription.id @@ -490,10 +504,7 @@ export class ConfigHandler { if (!this.currentProfile) { return { config: undefined, - errors: [ - { message: "Current profile not found", fatal: true }, - ...(injectErrors ?? []), - ], + errors: injectErrors, configLoadInterrupted: true, }; } @@ -562,7 +573,7 @@ export class ConfigHandler { if (!this.currentProfile) { return { config: undefined, - errors: [{ message: "Current profile not found", fatal: true }], + errors: undefined, configLoadInterrupted: true, }; } @@ -575,7 +586,7 @@ export class ConfigHandler { if (!this.currentProfile) { return { config: undefined, - errors: [{ message: "Current profile not found", fatal: true }], + errors: undefined, configLoadInterrupted: true, }; } @@ -598,11 +609,15 @@ export class ConfigHandler { if (!openProfileId) { return; } - const profile = this.currentOrg.profiles.find( + const profile = this.currentOrg?.profiles.find( (p) => p.profileDescription.id === openProfileId, ); + if (!profile) { + console.error(`Profile ${profileId} not found`); + return; + } - if (profile?.profileDescription.profileType === "local") { + if (profile.profileDescription.profileType === "local") { const configFile = element?.sourceFile ?? profile.profileDescription.uri; await this.ide.openFile(configFile); } else { diff --git a/core/config/ConfigHandler.vitest.ts b/core/config/ConfigHandler.vitest.ts index f58160044..1307ce6ab 100644 --- a/core/config/ConfigHandler.vitest.ts +++ b/core/config/ConfigHandler.vitest.ts @@ -10,7 +10,7 @@ import { defaultConfig } from "./default"; describe.skip("Test the ConfigHandler and E2E config loading", () => { test("should show only local profile", () => { - const profiles = testConfigHandler.currentOrg.profiles; + const profiles = testConfigHandler.currentOrg?.profiles; expect(profiles?.length).toBe(1); expect(profiles?.[0].profileDescription.id).toBe("local"); diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index f61908e32..e16bb7986 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -2,6 +2,7 @@ import { ConfigResult, ConfigValidationError, FullSlug, + Policy, } from "@continuedev/config-yaml"; import { @@ -30,6 +31,7 @@ export interface OrganizationDescription { iconUrl: string; name: string; slug: string | undefined; // TODO: This doesn't need to be undefined, just doing while transitioning the backend + policy?: Policy; } export type OrgWithProfiles = OrganizationDescription & { diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index ea6b0bf51..d6528454b 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -26,6 +26,7 @@ import RulesContextProvider from "../../context/providers/RulesContextProvider"; import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { getControlPlaneEnv } from "../../control-plane/env.js"; +import { PolicySingleton } from "../../control-plane/PolicySingleton"; import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js"; import ContinueProxy from "../../llm/llms/stubs/ContinueProxy"; import { getConfigDependentToolDefinitions } from "../../tools"; @@ -325,8 +326,18 @@ export default async function doLoadConfig(options: { } }); - newConfig.allowAnonymousTelemetry = - newConfig.allowAnonymousTelemetry && (await ide.isTelemetryEnabled()); + if (newConfig.allowAnonymousTelemetry !== false) { + if ((await ide.isTelemetryEnabled()) === false) { + newConfig.allowAnonymousTelemetry = false; + } + } + + if ( + PolicySingleton.getInstance().policy?.policy?.allowAnonymousTelemetry === + false + ) { + newConfig.allowAnonymousTelemetry = false; + } // Setup telemetry only after (and if) we know it is enabled await Telemetry.setup( diff --git a/core/config/util.ts b/core/config/util.ts index a53027a76..08bf8949b 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -10,7 +10,6 @@ import { JSONModelDescription, PromptTemplate, } from "../"; -import { DEFAULT_CHAT_SYSTEM_MESSAGE } from "../llm/defaultSystemMessages"; import { GlobalContext } from "../util/GlobalContext"; import { editConfigFile } from "../util/paths"; @@ -80,12 +79,6 @@ export function addModel( maxStopWords: model.maxStopWords, defaultCompletionOptions: model.completionOptions, }; - if (model.systemMessage) { - desc.chatOptions = { - baseSystemMessage: - DEFAULT_CHAT_SYSTEM_MESSAGE + "\n\n" + model.systemMessage, - }; - } config.models.push(desc); return config; }, diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 0f87a3f61..5c8e0af1b 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -43,9 +43,13 @@ class DocsContextProvider extends BaseContextProvider { try { const scores = await reranker.rerank(fullInput, chunksCopy); - chunksCopy.sort( - (a, b) => scores[chunksCopy.indexOf(b)] - scores[chunksCopy.indexOf(a)], - ); + if (Array.isArray(scores)) { + // reranker model has returned a valid array + chunksCopy.sort( + (a, b) => + scores[chunksCopy.indexOf(b)] - scores[chunksCopy.indexOf(a)], + ); + } chunksCopy = chunksCopy.splice( 0, diff --git a/core/context/providers/_context-providers.vitest.ts b/core/context/providers/_context-providers.vitest.ts index f7096bf87..bde33cec1 100644 --- a/core/context/providers/_context-providers.vitest.ts +++ b/core/context/providers/_context-providers.vitest.ts @@ -36,6 +36,7 @@ async function getContextProviderExtras( llmLogger, Promise.resolve(undefined), ); + await configHandler.isInitialized; const { config } = await configHandler.loadConfig(); if (!config) { throw new Error("Config not found"); @@ -54,7 +55,7 @@ async function getContextProviderExtras( }; } -describe.skip("Should successfully run all context providers", () => { +describe("Should successfully run all context providers", () => { afterAll(() => { tearDownTestDir(); }); diff --git a/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts b/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts index fa49bee2e..e062e8ff3 100644 --- a/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts +++ b/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts @@ -27,7 +27,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { let embeddingsChunks: Chunk[] = []; try { - embeddingsChunks = !!config.selectedModelByRole.embed + embeddingsChunks = Boolean(config.selectedModelByRole.embed) ? await this.retrieveEmbeddings(input, nRetrieve) : []; } catch (error) { @@ -116,7 +116,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { const chunkIndexMap = new Map(); chunks.forEach((chunk, idx) => chunkIndexMap.set(chunk, idx)); - results.sort( + results?.sort( (a, b) => scores[chunkIndexMap.get(b)!] - scores[chunkIndexMap.get(a)!], ); results = results.slice(0, this.options.nFinal); diff --git a/core/control-plane/PolicySingleton.ts b/core/control-plane/PolicySingleton.ts new file mode 100644 index 000000000..705e67b49 --- /dev/null +++ b/core/control-plane/PolicySingleton.ts @@ -0,0 +1,15 @@ +import { PolicyResponse } from "./client.js"; + +export class PolicySingleton { + private static instance: PolicySingleton; + public policy: PolicyResponse | null = null; + + private constructor() {} + + public static getInstance(): PolicySingleton { + if (!PolicySingleton.instance) { + PolicySingleton.instance = new PolicySingleton(); + } + return PolicySingleton.instance; + } +} diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index ad6112aa9..d5f99a274 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -4,6 +4,7 @@ import { ConfigResult, FQSN, FullSlug, + Policy, SecretResult, SecretType, } from "@continuedev/config-yaml"; @@ -15,6 +16,11 @@ import { IdeInfo, IdeSettings, ModelDescription } from "../index.js"; import { ControlPlaneSessionInfo, isOnPremSession } from "./AuthTypes.js"; import { getControlPlaneEnv } from "./env.js"; +export interface PolicyResponse { + orgSlug?: string; + policy?: Policy; +} + export interface ControlPlaneWorkspace { id: string; name: string; @@ -215,6 +221,21 @@ export class ControlPlaneClient { } } + public async getPolicy(): Promise { + if (!(await this.isSignedIn())) { + return null; + } + + try { + const resp = await this.request(`ide/policy`, { + method: "GET", + }); + return (await resp.json()) as PolicyResponse; + } catch (e) { + return null; + } + } + public async getFreeTrialStatus(): Promise { if (!(await this.isSignedIn())) { return null; diff --git a/core/core.ts b/core/core.ts index 905151f07..aa558736c 100644 --- a/core/core.ts +++ b/core/core.ts @@ -184,7 +184,7 @@ export class Core { profileId: this.configHandler.currentProfile?.profileDescription.id || null, organizations: this.configHandler.getSerializedOrgs(), - selectedOrgId: this.configHandler.currentOrg.id, + selectedOrgId: this.configHandler.currentOrg?.id ?? null, }); // update additional submenu context providers registered via VSCode API @@ -465,7 +465,7 @@ export class Core { profileId: this.configHandler.currentProfile?.profileDescription.id ?? null, organizations: this.configHandler.getSerializedOrgs(), - selectedOrgId: this.configHandler.currentOrg.id, + selectedOrgId: this.configHandler.currentOrg?.id ?? null, }; }); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 6e1dab530..54e84bf17 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -56,7 +56,7 @@ export class CodebaseIndexer { // and only need to `await` it for tests. public initPromise: Promise; private config!: ContinueConfig; - private indexingCancellationController: AbortController | undefined; + private indexingCancellationController: AbortController; private codebaseIndexingState: IndexingProgressUpdate; private readonly pauseToken: PauseToken; @@ -97,6 +97,9 @@ export class CodebaseIndexer { this.pauseToken = new PauseToken(initialPaused); this.initPromise = this.init(configHandler); + + this.indexingCancellationController = new AbortController(); + this.indexingCancellationController.abort(); // initialize and abort so that a new one can be created } // Initialization - load config and attach config listener @@ -693,7 +696,7 @@ export class CodebaseIndexer { } public async refreshCodebaseIndex(paths: string[]) { - if (this.indexingCancellationController) { + if (!this.indexingCancellationController.signal.aborted) { this.indexingCancellationController.abort(); } const localController = new AbortController(); @@ -735,16 +738,13 @@ export class CodebaseIndexer { }); } if (this.indexingCancellationController === localController) { - this.indexingCancellationController = undefined; + this.indexingCancellationController.abort(); } } public async refreshCodebaseIndexFiles(files: string[]) { // Can be cancelled by codebase index but not vice versa - if ( - this.indexingCancellationController && - !this.indexingCancellationController.signal.aborted - ) { + if (!this.indexingCancellationController.signal.aborted) { return; } const localController = new AbortController(); @@ -770,7 +770,7 @@ export class CodebaseIndexer { }); } if (this.indexingCancellationController === localController) { - this.indexingCancellationController = undefined; + this.indexingCancellationController.abort(); } } diff --git a/core/llm/llms/Voyage.ts b/core/llm/llms/Voyage.ts index fe08d8b1d..9ba43554e 100644 --- a/core/llm/llms/Voyage.ts +++ b/core/llm/llms/Voyage.ts @@ -1,7 +1,21 @@ -import { Chunk, LLMOptions } from "../../index.js"; +import { z } from "zod"; +import { Chunk, LLMOptions } from "../../index.js"; import OpenAI from "./OpenAI.js"; +/**used to check a valid response from voyage is received + * reference: https://docs.voyageai.com/reference/reranker-api + */ +const VoyageRerankSuccessResponseSchema = z.object({ + data: z.array( + z.object({ + index: z.number(), + relevance_score: z.number(), + document: z.string(), + }), + ), +}); + class Voyage extends OpenAI { static providerName = "voyage"; static defaultOptions: Partial | undefined = { @@ -36,7 +50,10 @@ class Voyage extends OpenAI { const data = (await resp.json()) as { data: Array<{ index: number; relevance_score: number }>; }; - const results = data.data.sort((a, b) => a.index - b.index); + + const parsedData = VoyageRerankSuccessResponseSchema.parse(data); + + const results = parsedData.data.sort((a, b) => a.index - b.index); return results.map((result) => result.relevance_score); } } diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 85bca7242..258feaaa9 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -90,7 +90,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { result: ConfigResult; profileId: string | null; organizations: SerializedOrgWithProfiles[]; - selectedOrgId: string; + selectedOrgId: string | null; }, ]; "config/deleteModel": [{ title: string }, void]; diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 75b2d5bd8..6ca982585 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -1,6 +1,6 @@ pluginGroup=com.github.continuedev.continueintellijextension pluginRepositoryUrl=https://github.com/continuedev/continue -pluginVersion=1.0.35 +pluginVersion=1.0.36 pluginSinceBuild=223 platformType=IC platformVersion=2022.3.3 diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 9d15d1bb6..1282f2cd4 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.75", + "version": "1.1.76", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/gui/src/components/config/FatalErrorNotice.tsx b/gui/src/components/config/FatalErrorNotice.tsx index 8c0a346c2..3d528e810 100644 --- a/gui/src/components/config/FatalErrorNotice.tsx +++ b/gui/src/components/config/FatalErrorNotice.tsx @@ -32,10 +32,10 @@ export const FatalErrorIndicator = () => { return null; } - const displayName = - selectedProfile?.title ?? - `${selectedProfile?.fullSlug?.ownerSlug}/${selectedProfile?.fullSlug?.packageSlug}` ?? - "assistant"; + const displayName = selectedProfile + ? (selectedProfile.title ?? + `${selectedProfile.fullSlug?.ownerSlug}/${selectedProfile.fullSlug?.packageSlug}`) + : "agent"; return ( diff --git a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx index 97da69b99..09b64f2ed 100644 --- a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx +++ b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx @@ -118,7 +118,7 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
state.config.config); + const currentOrg = useAppSelector(selectCurrentOrg); + const [showExperimental, setShowExperimental] = useState(false); const { session } = useAuth(); @@ -133,6 +136,9 @@ export function UserSettingsForm() { "@continue.dev", ); + const disableTelemetryToggle = + currentOrg?.policy?.allowAnonymousTelemetry === false; + return (
{/* {selectedProfile && isLocalProfile(selectedProfile) ? ( @@ -225,6 +231,7 @@ export function UserSettingsForm() { handleUpdate({ allowAnonymousTelemetry: !allowAnonymousTelemetry, diff --git a/packages/config-yaml/src/browser.ts b/packages/config-yaml/src/browser.ts index b8c5cca1b..9edef65aa 100644 --- a/packages/config-yaml/src/browser.ts +++ b/packages/config-yaml/src/browser.ts @@ -15,4 +15,5 @@ export * from "./modelName.js"; export * from "./schemas/data/index.js"; export * from "./schemas/index.js"; export * from "./schemas/models.js"; +export * from "./schemas/policy.js"; export * from "./validation.js"; diff --git a/packages/config-yaml/src/schemas/policy.ts b/packages/config-yaml/src/schemas/policy.ts new file mode 100644 index 000000000..c9b3d3a0b --- /dev/null +++ b/packages/config-yaml/src/schemas/policy.ts @@ -0,0 +1,9 @@ +import * as z from "zod"; + +export const policySchema = z.object({ + allowAnonymousTelemetry: z.boolean().optional(), + allowOtherOrgs: z.boolean().optional(), + // allowLocalConfigFile: z.boolean().optional(), +}); + +export type Policy = z.infer;