-
Couldn't load subscription status.
- Fork 273
feat(amazonq): Integrate named agents with chat #5674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7a8585d
e22ed08
c679cb0
56cfbbd
5ddcea1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import {ChatPrompt, MynahUI, QuickActionCommand, QuickActionCommandGroup} from '@aws/mynah-ui-chat' | ||
| import { isTabType } from './ui/storages/tabsStorage' | ||
| import { WebviewUIHandler } from './ui/main' | ||
| import { TabDataGenerator } from './ui/tabs/generator' | ||
| import { ChatClientAdapter, ChatEventHandler } from '@aws/chat-client' | ||
| import { FqnExtractor } from "./fqn/extractor"; | ||
|
|
||
| export * from "./ui/main"; | ||
|
|
||
| declare global { | ||
| interface Window { fqnExtractor: FqnExtractor; } | ||
| } | ||
|
|
||
| window.fqnExtractor = new FqnExtractor(); | ||
|
|
||
| export const initiateAdapter = (showWelcomePage: boolean, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you provide reference to VSC? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't have a reference in VSC. The webpack bundles this file and to be able to access its contents need an instance of the class |
||
| disclaimerAcknowledged: boolean, | ||
| isFeatureDevEnabled: boolean, | ||
| isCodeTransformEnabled: boolean, | ||
| isDocEnabled: boolean, | ||
| isCodeScanEnabled: boolean, | ||
| isCodeTestEnabled: boolean, | ||
| ideApiPostMessage: (message: any) => void, | ||
| profileName?: string) : HybridChatAdapter => { | ||
| return new HybridChatAdapter(showWelcomePage, disclaimerAcknowledged, isFeatureDevEnabled, isCodeTransformEnabled, isDocEnabled, isCodeScanEnabled, isCodeTestEnabled, ideApiPostMessage, profileName) | ||
| } | ||
|
|
||
|
|
||
| // Ref: https://github.com/aws/aws-toolkit-vscode/blob/e9ea8082ffe0b9968a873437407d0b6b31b9e1a5/packages/core/src/amazonq/webview/ui/connectorAdapter.ts#L14 | ||
| export class HybridChatAdapter implements ChatClientAdapter { | ||
| private uiHandler?: WebviewUIHandler | ||
|
|
||
| private mynahUIRef?: { mynahUI: MynahUI} | ||
|
|
||
| constructor( | ||
|
|
||
| private showWelcomePage: boolean, | ||
| private disclaimerAcknowledged: boolean, | ||
| private isFeatureDevEnabled: boolean, | ||
| private isCodeTransformEnabled: boolean, | ||
| private isDocEnabled: boolean, | ||
| private isCodeScanEnabled: boolean, | ||
| private isCodeTestEnabled: boolean, | ||
| private ideApiPostMessage: (message: any) => void, | ||
| private profileName?: string, | ||
|
|
||
| ) {} | ||
|
|
||
| /** | ||
| * First we create the ui handler to get the props, then once mynah UI gets created flare will re-inject the | ||
| * mynah UI instance on the hybrid chat adapter | ||
| */ | ||
| createChatEventHandler(mynahUIRef: { mynahUI: MynahUI }): ChatEventHandler { | ||
| this.mynahUIRef = mynahUIRef | ||
|
|
||
| this.uiHandler = new WebviewUIHandler({ | ||
| postMessage: this.ideApiPostMessage, | ||
| mynahUIRef: this.mynahUIRef, | ||
| showWelcomePage: this.showWelcomePage, | ||
| disclaimerAcknowledged: this.disclaimerAcknowledged, | ||
| isFeatureDevEnabled: this.isFeatureDevEnabled, | ||
| isCodeTransformEnabled: this.isCodeTransformEnabled, | ||
| isDocEnabled: this.isDocEnabled, | ||
| isCodeScanEnabled: this.isCodeScanEnabled, | ||
| isCodeTestEnabled: this.isCodeTestEnabled, | ||
| profileName: this.profileName, | ||
| hybridChat: true, | ||
| }) | ||
|
|
||
| return this.uiHandler.mynahUIProps | ||
| } | ||
|
|
||
| isSupportedTab(tabId: string): boolean { | ||
| const tabType = this.uiHandler?.tabsStorage.getTab(tabId)?.type | ||
| if (!tabType) { | ||
| return false | ||
| } | ||
| return isTabType(tabType) && tabType !== 'cwc' | ||
| } | ||
|
|
||
| async handleMessageReceive(message: MessageEvent): Promise<void> { | ||
| if (this.uiHandler) { | ||
| return this.uiHandler?.connector?.handleMessageReceive(message) | ||
| } | ||
|
|
||
| console.error('unknown message: ', message.data) | ||
| } | ||
|
|
||
| isSupportedQuickAction(command: string): boolean { | ||
| return ( | ||
| command === '/dev' || | ||
| command === '/test' || | ||
| command === '/review' || | ||
| command === '/doc' || | ||
| command === '/transform' | ||
| ) | ||
| } | ||
|
|
||
| handleQuickAction(prompt: ChatPrompt, tabId: string, eventId: string | undefined): void { | ||
| return this.uiHandler?.quickActionHandler?.handleCommand(prompt, tabId, eventId) | ||
| } | ||
|
|
||
| get initialQuickActions(): QuickActionCommandGroup[] { | ||
| const tabDataGenerator = new TabDataGenerator({ | ||
| isFeatureDevEnabled: this.isFeatureDevEnabled, | ||
| isCodeTransformEnabled: this.isCodeTransformEnabled, | ||
| isDocEnabled: this.isDocEnabled, | ||
| isCodeScanEnabled: this.isCodeScanEnabled, | ||
| isCodeTestEnabled: this.isCodeTestEnabled, | ||
| profileName: this.profileName | ||
| }) | ||
| return tabDataGenerator.quickActionsGenerator.generateForTab('cwc') ?? [] | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know!!