diff --git a/buildspec/release/50githubrelease.yml b/buildspec/release/50githubrelease.yml index c994b4111a6..df542cbee14 100644 --- a/buildspec/release/50githubrelease.yml +++ b/buildspec/release/50githubrelease.yml @@ -36,10 +36,13 @@ phases: - echo "posting $VERSION with sha384 hash $HASH to GitHub" - PKG_DISPLAY_NAME=$(grep -m 1 displayName packages/${TARGET_EXTENSION}/package.json | grep -o '[a-zA-z][^\"]\+' | tail -n1) - RELEASE_MESSAGE="${PKG_DISPLAY_NAME} for VS Code $VERSION" + # Only set amazonq as "latest" release. This ensures https://api.github.com/repos/aws/aws-toolkit-vscode/releases/latest + # consistently points to the amazonq artifact, instead of being "random". + - LATEST="$([ "$TARGET_EXTENSION" = amazonq ] && echo '--latest' || echo '--latest=false' )" - | if [ "$STAGE" = "prod" ]; then # note: the tag arg passed here should match what is in 10changeversion.yml - gh release create --repo $REPO --title "$PKG_DISPLAY_NAME $VERSION" --notes "$RELEASE_MESSAGE" -- "${TARGET_EXTENSION}/v${VERSION}" "$UPLOAD_TARGET" "$HASH_UPLOAD_TARGET" + gh release create "$LATEST" --repo $REPO --title "$PKG_DISPLAY_NAME $VERSION" --notes "$RELEASE_MESSAGE" -- "${TARGET_EXTENSION}/v${VERSION}" "$UPLOAD_TARGET" "$HASH_UPLOAD_TARGET" else echo "SKIPPED (stage=${STAGE}): 'gh release create --repo $REPO'" fi diff --git a/package-lock.json b/package-lock.json index 9bde57faca6..8b90e6d0ad8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "vscode-nls-dev": "^4.0.4" }, "devDependencies": { - "@aws-toolkits/telemetry": "^1.0.322", + "@aws-toolkits/telemetry": "^1.0.323", "@playwright/browser-chromium": "^1.43.1", "@stylistic/eslint-plugin": "^2.11.0", "@types/he": "^1.2.3", @@ -10879,7 +10879,9 @@ } }, "node_modules/@aws-toolkits/telemetry": { - "version": "1.0.322", + "version": "1.0.323", + "resolved": "https://registry.npmjs.org/@aws-toolkits/telemetry/-/telemetry-1.0.323.tgz", + "integrity": "sha512-Wc6HE+l5iJm/3TYx8Y8pU99ffmq78FgDDVMKjYG9Mfr4cXO4PEkB6XOkiVwGYnrNOGWqyYNlnkBFJ32WJRfkKg==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -25396,7 +25398,7 @@ }, "packages/amazonq": { "name": "amazon-q-vscode", - "version": "1.71.0-SNAPSHOT", + "version": "1.72.0-SNAPSHOT", "license": "Apache-2.0", "dependencies": { "aws-core-vscode": "file:../core/" @@ -27110,7 +27112,7 @@ }, "packages/toolkit": { "name": "aws-toolkit-vscode", - "version": "3.64.0-SNAPSHOT", + "version": "3.65.0-SNAPSHOT", "license": "Apache-2.0", "dependencies": { "aws-core-vscode": "file:../core/" diff --git a/package.json b/package.json index 525655b8c35..751144b9f47 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "skippedTestReport": "ts-node ./scripts/skippedTestReport.ts ./packages/amazonq/test/e2e/" }, "devDependencies": { - "@aws-toolkits/telemetry": "^1.0.322", + "@aws-toolkits/telemetry": "^1.0.323", "@playwright/browser-chromium": "^1.43.1", "@stylistic/eslint-plugin": "^2.11.0", "@types/he": "^1.2.3", diff --git a/packages/amazonq/.changes/1.71.0.json b/packages/amazonq/.changes/1.71.0.json new file mode 100644 index 00000000000..be5cc5a2013 --- /dev/null +++ b/packages/amazonq/.changes/1.71.0.json @@ -0,0 +1,5 @@ +{ + "date": "2025-06-04", + "version": "1.71.0", + "entries": [] +} \ No newline at end of file diff --git a/packages/amazonq/.changes/next-release/Feature-d6714581-799f-49dc-bb63-f08d461e9bde.json b/packages/amazonq/.changes/next-release/Feature-d6714581-799f-49dc-bb63-f08d461e9bde.json new file mode 100644 index 00000000000..c1ff05f38ff --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-d6714581-799f-49dc-bb63-f08d461e9bde.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "Launch LSP with bundled artifacts as fallback" +} diff --git a/packages/amazonq/CHANGELOG.md b/packages/amazonq/CHANGELOG.md index 10c6904fe2a..eebb0bdc496 100644 --- a/packages/amazonq/CHANGELOG.md +++ b/packages/amazonq/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.71.0 2025-06-04 + +- Miscellaneous non-user-facing changes + ## 1.70.0 2025-05-28 - **Removal** Disable local workspace LSP diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index 889d5f70967..09c26af6b06 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -2,7 +2,7 @@ "name": "amazon-q-vscode", "displayName": "Amazon Q", "description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI", - "version": "1.71.0-SNAPSHOT", + "version": "1.72.0-SNAPSHOT", "extensionKind": [ "workspace" ], @@ -212,6 +212,12 @@ "items": { "type": "string" } + }, + "amazonQ.proxy.certificateAuthority": { + "type": "string", + "markdownDescription": "%AWS.configuration.description.amazonq.proxy.certificateAuthority%", + "default": null, + "scope": "application" } } }, diff --git a/packages/amazonq/src/app/chat/activation.ts b/packages/amazonq/src/app/chat/activation.ts index af48bc65e05..659115d4256 100644 --- a/packages/amazonq/src/app/chat/activation.ts +++ b/packages/amazonq/src/app/chat/activation.ts @@ -7,7 +7,7 @@ import * as vscode from 'vscode' import { ExtensionContext } from 'vscode' import { telemetry } from 'aws-core-vscode/telemetry' import { AuthUtil } from 'aws-core-vscode/codewhisperer' -import { Commands, placeholder } from 'aws-core-vscode/shared' +import { Commands, getLogger, placeholder } from 'aws-core-vscode/shared' import * as amazonq from 'aws-core-vscode/amazonq' export async function activate(context: ExtensionContext) { @@ -67,7 +67,9 @@ async function setupAuthNotification() { const selection = await vscode.window.showWarningMessage('Start using Amazon Q', buttonAction) if (selection === buttonAction) { - void amazonq.focusAmazonQPanel.execute(placeholder, source) + amazonq.focusAmazonQPanel.execute(placeholder, source).catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } } } diff --git a/packages/amazonq/src/extension.ts b/packages/amazonq/src/extension.ts index b034f360cec..e0b1c66cdf7 100644 --- a/packages/amazonq/src/extension.ts +++ b/packages/amazonq/src/extension.ts @@ -39,6 +39,7 @@ import { Experiments, isSageMaker, Commands, + ProxyUtil, } from 'aws-core-vscode/shared' import { ExtStartUpSources } from 'aws-core-vscode/telemetry' import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils' @@ -127,7 +128,10 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is // Auth is dependent on LSP, needs to be activated before CW and Inline await activateAmazonqLsp(context) - // This contains every lsp agnostic things (security scan, code scan) + // Configure proxy settings early + ProxyUtil.configureProxyForLanguageServer() + + // This contains every lsp agnostic things (auth, security scan, code scan) await activateCodeWhisperer(extContext as ExtContext) if (!Experiments.instance.get('amazonqLSPInline', false)) { await activateInlineCompletion() @@ -170,7 +174,9 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is // Give time for the extension to finish initializing. globals.clock.setTimeout(async () => { CommonAuthWebview.authSource = ExtStartUpSources.firstStartUp - void focusAmazonQPanel.execute(placeholder, ExtStartUpSources.firstStartUp) + focusAmazonQPanel.execute(placeholder, ExtStartUpSources.firstStartUp).catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) }, 1000) } diff --git a/packages/amazonq/src/lsp/activation.ts b/packages/amazonq/src/lsp/activation.ts index aebb4a60479..2142f2f3188 100644 --- a/packages/amazonq/src/lsp/activation.ts +++ b/packages/amazonq/src/lsp/activation.ts @@ -5,8 +5,8 @@ import vscode from 'vscode' import { startLanguageServer } from './client' -import { AmazonQLspInstaller } from './lspInstaller' -import { lspSetupStage, ToolkitError, messages } from 'aws-core-vscode/shared' +import { AmazonQLspInstaller, getBundledResourcePaths } from './lspInstaller' +import { lspSetupStage, ToolkitError, messages, getLogger } from 'aws-core-vscode/shared' export async function activate(ctx: vscode.ExtensionContext) { try { @@ -16,6 +16,15 @@ export async function activate(ctx: vscode.ExtensionContext) { }) } catch (err) { const e = err as ToolkitError - void messages.showViewLogsMessage(`Failed to launch Amazon Q language server: ${e.message}`) + getLogger('amazonqLsp').warn(`Failed to start downloaded LSP, falling back to bundled LSP: ${e.message}`) + try { + await lspSetupStage('all', async () => { + await lspSetupStage('launch', async () => await startLanguageServer(ctx, getBundledResourcePaths(ctx))) + }) + } catch (error) { + void messages.showViewLogsMessage( + `Failed to launch Amazon Q language server: ${(error as ToolkitError).message}` + ) + } } } diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index 11f00be3a22..ac3f1836521 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -50,6 +50,8 @@ import { CancellationTokenSource, chatUpdateNotificationType, ChatUpdateParams, + chatOptionsUpdateType, + ChatOptionsUpdateParams, } from '@aws/language-server-runtimes/protocol' import { v4 as uuidv4 } from 'uuid' import * as vscode from 'vscode' @@ -451,6 +453,13 @@ export function registerMessageListeners( params: params, }) }) + + languageClient.onNotification(chatOptionsUpdateType.method, (params: ChatOptionsUpdateParams) => { + void provider.webview?.postMessage({ + command: chatOptionsUpdateType.method, + params: params, + }) + }) } function isServerEvent(command: string) { diff --git a/packages/amazonq/src/lsp/chat/webviewProvider.ts b/packages/amazonq/src/lsp/chat/webviewProvider.ts index 3f9d273ab96..6d40b8eff08 100644 --- a/packages/amazonq/src/lsp/chat/webviewProvider.ts +++ b/packages/amazonq/src/lsp/chat/webviewProvider.ts @@ -19,6 +19,7 @@ import { AmazonQPromptSettings, LanguageServerResolver, amazonqMark, + getLogger, } from 'aws-core-vscode/shared' import { AuthUtil, RegionProfile } from 'aws-core-vscode/codewhisperer' import { featureConfig } from 'aws-core-vscode/amazonq' @@ -44,9 +45,12 @@ export class AmazonQChatViewProvider implements WebviewViewProvider { ) { const lspDir = Uri.file(LanguageServerResolver.defaultDir()) const dist = Uri.joinPath(globals.context.extensionUri, 'dist') - - const resourcesRoots = [lspDir, dist] - + const bundledResources = Uri.joinPath(globals.context.extensionUri, 'resources/language-server') + let resourcesRoots = [lspDir, dist] + if (this.mynahUIPath?.startsWith(globals.context.extensionUri.fsPath)) { + getLogger('amazonqLsp').info(`Using bundled webview resources ${bundledResources.fsPath}`) + resourcesRoots = [bundledResources, dist] + } /** * if the mynah chat client is defined, then make sure to add it to the resource roots, otherwise * it will 401 when trying to load diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index f703bb85378..2460af9260c 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -48,7 +48,6 @@ import { getOptOutPreference, isAmazonLinux2, oidcClientName, - openUrl, getClientId, extensionVersion, Commands, @@ -151,7 +150,6 @@ export async function startLanguageServer( awsClientCapabilities: { q: { developerProfiles: true, - mcp: true, }, window: { notifications: true, @@ -305,9 +303,20 @@ async function postStartLanguageServer( const uri = vscode.Uri.parse(params.uri) getLogger().info(`Processing ShowDocumentRequest for URI scheme: ${uri.scheme}`) try { - if (uri.scheme.startsWith('http')) { + if (params.external) { getLogger().info('Opening URL...') - await openUrl(vscode.Uri.parse(params.uri)) + + // Note: Not using openUrl() because we probably don't want telemetry for these URLs. + // Also it doesn't yet support the required HACK below. + + // HACK: workaround vscode bug: https://github.com/microsoft/vscode/issues/85930 + vscode.env.openExternal(params.uri as any).then(undefined, (e) => { + // TODO: getLogger('?').error('failed vscode.env.openExternal: %O', e) + vscode.env.openExternal(uri).then(undefined, (e) => { + // TODO: getLogger('?').error('failed vscode.env.openExternal: %O', e) + }) + }) + return params } else { getLogger().info('Opening text document...') const doc = await vscode.workspace.openTextDocument(uri) diff --git a/packages/amazonq/src/lsp/lspInstaller.ts b/packages/amazonq/src/lsp/lspInstaller.ts index 84d5ee8961b..9ac19601fe7 100644 --- a/packages/amazonq/src/lsp/lspInstaller.ts +++ b/packages/amazonq/src/lsp/lspInstaller.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import vscode from 'vscode' import { fs, getNodeExecutableName, getRgExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared' import path from 'path' import { ExtendedAmazonQLSPConfig, getAmazonQLspConfig } from './config' @@ -54,3 +55,13 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller< protected override downloadMessageOverride: string | undefined = 'Updating Amazon Q plugin' } + +export function getBundledResourcePaths(ctx: vscode.ExtensionContext): AmazonQResourcePaths { + const assetDirectory = vscode.Uri.joinPath(ctx.extensionUri, 'resources', 'language-server').fsPath + return { + lsp: path.join(assetDirectory, 'servers', 'aws-lsp-codewhisperer.js'), + node: process.execPath, + ripGrep: '', + ui: path.join(assetDirectory, 'clients', 'amazonq-ui.js'), + } +} diff --git a/packages/core/package.nls.json b/packages/core/package.nls.json index 9922ec6fcd8..609eeb5cd08 100644 --- a/packages/core/package.nls.json +++ b/packages/core/package.nls.json @@ -98,7 +98,7 @@ "AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns": "File patterns to ignore when indexing your workspace files", "AWS.configuration.description.amazonq.workspaceIndexCacheDirPath": "The path to the directory that contains the cache of the index of your workspace files", "AWS.configuration.description.amazonq.ignoredSecurityIssues": "Specifies a list of code issue identifiers that Amazon Q should ignore when reviewing your workspace. Each item in the array should be a unique string identifier for a specific code issue. This allows you to suppress notifications for known issues that you've assessed and determined to be false positives or not applicable to your project. Use this setting with caution, as it may cause you to miss important security alerts.", - "AWS.command.apig.copyUrl": "Copy URL", + "AWS.configuration.description.amazonq.proxy.certificateAuthority": "Path to a Certificate Authority (PEM file) for SSL/TLS verification when using a proxy.", "AWS.command.apig.invokeRemoteRestApi": "Invoke in the cloud", "AWS.command.apig.invokeRemoteRestApi.cn": "Invoke on Amazon", "AWS.appBuilder.explorerTitle": "Application Builder", diff --git a/packages/core/src/amazonq/auth/controller.ts b/packages/core/src/amazonq/auth/controller.ts index 9cc09ef17cb..5b9772d686a 100644 --- a/packages/core/src/amazonq/auth/controller.ts +++ b/packages/core/src/amazonq/auth/controller.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { getLogger } from '../../shared/logger/logger' import { reconnect } from '../../codewhisperer/commands/basicCommands' import { amazonQChatSource } from '../../codewhisperer/commands/types' import { focusAmazonQPanel } from '../../codewhispererChat/commands/registerCommands' @@ -27,7 +28,9 @@ export class AuthController { } private handleFullAuth() { - void focusAmazonQPanel.execute(placeholder, 'amazonQChat') + focusAmazonQPanel.execute(placeholder, 'amazonQChat').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } private handleReAuth() { diff --git a/packages/core/src/amazonq/webview/ui/tabs/constants.ts b/packages/core/src/amazonq/webview/ui/tabs/constants.ts index ed7d6a1d1fe..8578c72377a 100644 --- a/packages/core/src/amazonq/webview/ui/tabs/constants.ts +++ b/packages/core/src/amazonq/webview/ui/tabs/constants.ts @@ -63,7 +63,8 @@ To learn more, visit the [User Guide](${userGuideURL}).`, gumby: { title: 'Q - Code Transformation', placeholder: 'Open a new tab to chat with Q', - welcome: 'Welcome to Code Transformation!', + welcome: + 'Welcome to Code Transformation! You can also run transformations from the command line. To install the tool, see the [documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/run-CLI-transformations.html).', }, review: { title: 'Q - Review', diff --git a/packages/core/src/codewhisperer/commands/basicCommands.ts b/packages/core/src/codewhisperer/commands/basicCommands.ts index 1ecdf641fb4..990a7e96560 100644 --- a/packages/core/src/codewhisperer/commands/basicCommands.ts +++ b/packages/core/src/codewhisperer/commands/basicCommands.ts @@ -404,7 +404,9 @@ export const notifyNewCustomizationsCmd = Commands.declare( function focusQAfterDelay() { // this command won't work without a small delay after install globals.clock.setTimeout(() => { - void focusAmazonQPanel.execute(placeholder, 'startDelay') + focusAmazonQPanel.execute(placeholder, 'startDelay').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) }, 1000) } @@ -596,7 +598,10 @@ export const signoutCodeWhisperer = Commands.declare( () => async (_: VsCodeCommandArg, source: CodeWhispererSource) => { await AuthUtil.instance.logout() SecurityIssueTreeViewProvider.instance.refresh() - return focusAmazonQPanel.execute(placeholder, source) + return focusAmazonQPanel.execute(placeholder, source).catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + return undefined + }) } ) diff --git a/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts b/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts index 1b887e587d5..0e3090538fb 100644 --- a/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts +++ b/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts @@ -29,6 +29,7 @@ import { submitFeedback } from '../../feedback/vue/submitFeedback' import { focusAmazonQPanel } from '../../codewhispererChat/commands/registerCommands' import { isWeb } from '../../shared/extensionGlobals' import { builderIdRegion, builderIdStartUrl } from '../../auth/sso/constants' +import { getLogger } from '../../shared/logger/logger' export function createAutoSuggestions(running: boolean): DataQuickPickItem<'autoSuggestions'> { const labelResume = localize('AWS.codewhisperer.resumeCodeWhispererNode.label', 'Resume Auto-Suggestions') @@ -239,7 +240,10 @@ export function switchToAmazonQNode(): DataQuickPickItem<'openChatPanel'> { data: 'openChatPanel', label: 'Open Chat Panel', iconPath: getIcon('vscode-comment'), - onClick: () => focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick'), + onClick: () => + focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }), } } @@ -248,7 +252,9 @@ export function createSignIn(): DataQuickPickItem<'signIn'> { const icon = getIcon('vscode-account') let onClick = () => { - void focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick') + focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } if (isWeb()) { // TODO: nkomonen, call a Command instead diff --git a/packages/core/src/shared/index.ts b/packages/core/src/shared/index.ts index b74b6862b45..3004ee475a8 100644 --- a/packages/core/src/shared/index.ts +++ b/packages/core/src/shared/index.ts @@ -39,6 +39,7 @@ export { CodewhispererUserDecision, CodewhispererSecurityScan, } from './telemetry/telemetry.gen' +export { ProxyUtil } from './utilities/proxyUtil' export { randomUUID } from './crypto' export * from './environmentVariables' export * from './vscode/setContext' diff --git a/packages/core/src/shared/logger/logger.ts b/packages/core/src/shared/logger/logger.ts index bb94fb0dc53..929b059c062 100644 --- a/packages/core/src/shared/logger/logger.ts +++ b/packages/core/src/shared/logger/logger.ts @@ -22,6 +22,7 @@ export type LogTopic = | 'resourceCache' | 'telemetry' | 'amazonqAuth' + | 'proxyUtil' class ErrorLog { constructor( diff --git a/packages/core/src/shared/settings-amazonq.gen.ts b/packages/core/src/shared/settings-amazonq.gen.ts index 637c5b1b12e..836b68444f2 100644 --- a/packages/core/src/shared/settings-amazonq.gen.ts +++ b/packages/core/src/shared/settings-amazonq.gen.ts @@ -36,7 +36,8 @@ export const amazonqSettings = { "amazonQ.workspaceIndexMaxFileSize": {}, "amazonQ.workspaceIndexCacheDirPath": {}, "amazonQ.workspaceIndexIgnoreFilePatterns": {}, - "amazonQ.ignoredSecurityIssues": {} + "amazonQ.ignoredSecurityIssues": {}, + "amazonQ.proxy.certificateAuthority": {} } export default amazonqSettings diff --git a/packages/core/src/shared/utilities/proxyUtil.ts b/packages/core/src/shared/utilities/proxyUtil.ts new file mode 100644 index 00000000000..4e0e5c940b5 --- /dev/null +++ b/packages/core/src/shared/utilities/proxyUtil.ts @@ -0,0 +1,80 @@ +/*! + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import vscode from 'vscode' +import { getLogger } from '../logger/logger' + +interface ProxyConfig { + proxyUrl: string | undefined + certificateAuthority: string | undefined +} + +/** + * Utility class for handling proxy configuration + */ +export class ProxyUtil { + private static readonly logger = getLogger('proxyUtil') + + /** + * Sets proxy environment variables based on VS Code settings for use with the Flare Language Server + * + * See documentation here for setting the environement variables which are inherited by Flare LS process: + * https://github.com/aws/language-server-runtimes/blob/main/runtimes/docs/proxy.md + */ + public static configureProxyForLanguageServer(): void { + try { + const proxyConfig = this.getProxyConfiguration() + + this.setProxyEnvironmentVariables(proxyConfig) + } catch (err) { + this.logger.error(`Failed to configure proxy: ${err}`) + } + } + + /** + * Gets proxy configuration from VS Code settings + */ + private static getProxyConfiguration(): ProxyConfig { + const httpConfig = vscode.workspace.getConfiguration('http') + const proxyUrl = httpConfig.get('proxy') + this.logger.debug(`Proxy URL Setting in VSCode Settings: ${proxyUrl}`) + + const amazonQConfig = vscode.workspace.getConfiguration('amazonQ') + const proxySettings = amazonQConfig.get<{ + certificateAuthority?: string + }>('proxy', {}) + + return { + proxyUrl, + certificateAuthority: proxySettings.certificateAuthority, + } + } + + /** + * Sets environment variables based on proxy configuration + */ + private static setProxyEnvironmentVariables(config: ProxyConfig): void { + const proxyUrl = config.proxyUrl + + // Always enable experimental proxy support for better handling of both explicit and transparent proxies + process.env.EXPERIMENTAL_HTTP_PROXY_SUPPORT = 'true' + // Add OpenSSL certificate store support + process.env.NODE_OPTIONS = '--use-openssl-ca' + + // Set proxy environment variables + if (proxyUrl) { + process.env.HTTPS_PROXY = proxyUrl + process.env.HTTP_PROXY = proxyUrl + this.logger.debug(`Set proxy environment variables: ${proxyUrl}`) + } + + // Set certificate bundle environment variables if configured + if (config.certificateAuthority) { + process.env.NODE_EXTRA_CA_CERTS = config.certificateAuthority + process.env.AWS_CA_BUNDLE = config.certificateAuthority + this.logger.debug(`Set certificate bundle path: ${config.certificateAuthority}`) + } + } +} diff --git a/packages/core/src/shared/utilities/vsCodeUtils.ts b/packages/core/src/shared/utilities/vsCodeUtils.ts index 03229cf104a..57f9e380974 100644 --- a/packages/core/src/shared/utilities/vsCodeUtils.ts +++ b/packages/core/src/shared/utilities/vsCodeUtils.ts @@ -215,8 +215,11 @@ export function reloadWindowPrompt(message: string): void { * if user dismisses the vscode confirmation prompt. */ export async function openUrl(url: vscode.Uri, source?: string): Promise { + // Avoid PII in URL. + const truncatedUrl = `${url.scheme}${url.authority}${url.path}${url.fragment.substring(20)}` + return telemetry.aws_openUrl.run(async (span) => { - span.record({ url: url.toString(), source }) + span.record({ url: truncatedUrl, source }) const didOpen = await vscode.env.openExternal(url) if (!didOpen) { throw new CancellationError('user') diff --git a/packages/toolkit/.changes/3.64.0.json b/packages/toolkit/.changes/3.64.0.json new file mode 100644 index 00000000000..c9fd077f42d --- /dev/null +++ b/packages/toolkit/.changes/3.64.0.json @@ -0,0 +1,5 @@ +{ + "date": "2025-06-04", + "version": "3.64.0", + "entries": [] +} \ No newline at end of file diff --git a/packages/toolkit/CHANGELOG.md b/packages/toolkit/CHANGELOG.md index d2d3f1e9479..2f19a136349 100644 --- a/packages/toolkit/CHANGELOG.md +++ b/packages/toolkit/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.64.0 2025-06-04 + +- Miscellaneous non-user-facing changes + ## 3.63.0 2025-05-22 - Miscellaneous non-user-facing changes diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index e99c8325388..0bd06012a10 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -2,7 +2,7 @@ "name": "aws-toolkit-vscode", "displayName": "AWS Toolkit", "description": "Including CodeCatalyst, Infrastructure Composer, and support for Lambda, S3, CloudWatch Logs, CloudFormation, and many other services.", - "version": "3.64.0-SNAPSHOT", + "version": "3.65.0-SNAPSHOT", "extensionKind": [ "workspace" ], diff --git a/scripts/lspArtifact.ts b/scripts/lspArtifact.ts new file mode 100644 index 00000000000..fb055ad94b7 --- /dev/null +++ b/scripts/lspArtifact.ts @@ -0,0 +1,181 @@ +import * as https from 'https' +import * as fs from 'fs' +import * as crypto from 'crypto' +import * as path from 'path' +import * as os from 'os' +import AdmZip from 'adm-zip' + +interface ManifestContent { + filename: string + url: string + hashes: string[] + bytes: number +} + +interface ManifestTarget { + platform: string + arch: string + contents: ManifestContent[] +} + +interface ManifestVersion { + serverVersion: string + isDelisted: boolean + targets: ManifestTarget[] +} + +interface Manifest { + versions: ManifestVersion[] +} +async function verifyFileHash(filePath: string, expectedHash: string): Promise { + return new Promise((resolve, reject) => { + const hash = crypto.createHash('sha384') + const stream = fs.createReadStream(filePath) + + stream.on('data', (data) => { + hash.update(data) + }) + + stream.on('end', () => { + const fileHash = hash.digest('hex') + // Remove 'sha384:' prefix from expected hash if present + const expectedHashValue = expectedHash.replace('sha384:', '') + resolve(fileHash === expectedHashValue) + }) + + stream.on('error', reject) + }) +} + +async function ensureDirectoryExists(dirPath: string): Promise { + if (!fs.existsSync(dirPath)) { + await fs.promises.mkdir(dirPath, { recursive: true }) + } +} + +export async function downloadLanguageServer(): Promise { + const tempDir = path.join(os.tmpdir(), 'amazonq-download-temp') + const resourcesDir = path.join(__dirname, '../packages/amazonq/resources/language-server') + + // clear previous cached language server + try { + if (fs.existsSync(resourcesDir)) { + fs.rmdirSync(resourcesDir, { recursive: true }) + } + } catch (e) { + throw Error(`Failed to clean up language server ${resourcesDir}`) + } + + await ensureDirectoryExists(tempDir) + await ensureDirectoryExists(resourcesDir) + + return new Promise((resolve, reject) => { + const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/qAgenticChatServer/0/manifest.json' + + https + .get(manifestUrl, (res) => { + let data = '' + + res.on('data', (chunk) => { + data += chunk + }) + + res.on('end', async () => { + try { + const manifest: Manifest = JSON.parse(data) + + const latestVersion = manifest.versions + .filter((v) => !v.isDelisted) + .sort((a, b) => b.serverVersion.localeCompare(a.serverVersion))[0] + + if (!latestVersion) { + throw new Error('No valid version found in manifest') + } + + const darwinArm64Target = latestVersion.targets.find( + (t) => t.platform === 'darwin' && t.arch === 'arm64' + ) + + if (!darwinArm64Target) { + throw new Error('No darwin arm64 target found') + } + + for (const content of darwinArm64Target.contents) { + const fileName = content.filename + const fileUrl = content.url + const expectedHash = content.hashes[0] + const tempFilePath = path.join(tempDir, fileName) + const fileFolderName = content.filename.replace('.zip', '') + + console.log(`Downloading ${fileName} from ${fileUrl} ...`) + + await new Promise((downloadResolve, downloadReject) => { + https + .get(fileUrl, (fileRes) => { + const fileStream = fs.createWriteStream(tempFilePath) + fileRes.pipe(fileStream) + + fileStream.on('finish', () => { + fileStream.close() + downloadResolve(void 0) + }) + + fileStream.on('error', (err) => { + fs.unlink(tempFilePath, () => {}) + downloadReject(err) + }) + }) + .on('error', (err) => { + fs.unlink(tempFilePath, () => {}) + downloadReject(err) + }) + }) + + console.log(`Verifying hash for ${fileName}...`) + const isHashValid = await verifyFileHash(tempFilePath, expectedHash) + + if (!isHashValid) { + fs.unlinkSync(tempFilePath) + throw new Error(`Hash verification failed for ${fileName}`) + } + + console.log(`Extracting ${fileName}...`) + const zip = new AdmZip(tempFilePath) + zip.extractAllTo(path.join(resourcesDir, fileFolderName), true) // true for overwrite + + // Clean up temp file + fs.unlinkSync(tempFilePath) + console.log(`Successfully processed ${fileName}`) + } + + // Clean up temp directory + fs.rmdirSync(tempDir) + fs.rmdirSync(path.join(resourcesDir, 'servers', 'indexing'), { recursive: true }) + fs.rmdirSync(path.join(resourcesDir, 'servers', 'ripgrep'), { recursive: true }) + fs.rmSync(path.join(resourcesDir, 'servers', 'node')) + if (!fs.existsSync(path.join(resourcesDir, 'servers', 'aws-lsp-codewhisperer.js'))) { + throw new Error(`Extracting aws-lsp-codewhisperer.js failure`) + } + if (!fs.existsSync(path.join(resourcesDir, 'clients', 'amazonq-ui.js'))) { + throw new Error(`Extracting amazonq-ui.js failure`) + } + console.log('Download and extraction completed successfully') + resolve() + } catch (err) { + // Clean up temp directory on error + if (fs.existsSync(tempDir)) { + fs.rmdirSync(tempDir, { recursive: true }) + } + reject(err) + } + }) + }) + .on('error', (err) => { + // Clean up temp directory on error + if (fs.existsSync(tempDir)) { + fs.rmdirSync(tempDir, { recursive: true }) + } + reject(err) + }) + }) +} diff --git a/scripts/package.ts b/scripts/package.ts index 84622ac12c0..203777e8131 100644 --- a/scripts/package.ts +++ b/scripts/package.ts @@ -20,6 +20,7 @@ import * as child_process from 'child_process' // eslint-disable-line no-restricted-imports import * as nodefs from 'fs' // eslint-disable-line no-restricted-imports import * as path from 'path' +import { downloadLanguageServer } from './lspArtifact' function parseArgs() { // Invoking this script with argument "foo": @@ -105,7 +106,7 @@ function getVersionSuffix(feature: string, debug: boolean): string { return `${debugSuffix}${featureSuffix}${commitSuffix}` } -function main() { +async function main() { const args = parseArgs() // It is expected that this will package from a packages/{subproject} folder. // There is a base config in packages/ @@ -155,6 +156,12 @@ function main() { } nodefs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, undefined, ' ')) + + // add language server bundle + if (packageJson.name === 'amazon-q-vscode') { + await downloadLanguageServer() + } + child_process.execFileSync( 'vsce', [