@aws/chat-client

中文文档
0.1.58发布于 2026/10/09Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 3053

AWS Chat Client

原始使用文档
文档目录6 节
  1. Communication
  2. Host environments
  3. Usage
  4. Inbound events
  5. Outbound events
  6. Configuration

Q Chat Client

This package contains a chat client for the Q Language Server, that can be embedded in a webview. It uses MynahUI to render a web based chat interface.

Communication

The chat client communicates with the host application (e.g., an IDE extension) through postMessage requests to the webview:

  • When the host application sends a request, the client processes the message and sends it to the UI
  • When an event is triggered in the UI, the client sends a message through postMessage to the host application that rendered the chat client

Host environments

The webview is embedded by different IDE hosts, which use different browser engines and load the chat assets differently. As a result, the event.origin observed on inbound postMessage events is not uniform across hosts:

HostRendering engineAsset schemewindow.location.origin / inbound event.originMessage-delivery bridge
VS CodeChromium webviewvscode-webview://vscode-webview://<id> (non-HTTP)acquireVsCodeApi().postMessage
JetBrainsJCEFhttps://toolkitassethttps://toolkitasset (same-origin)JCEF JS query bridge + postMessage
Visual StudioEdge WebView2host-servedhost-dependentwindow.chrome.webview.postMessage
Eclipse (Windows)Edge WebView2HTML injected via Browser.setText()empty "" or "null" (opaque origin)host-injected window.postMessage
Eclipse (macOS / Linux)WebKit / WebKitGTKlocal asset serverHTTP(S) same-originhost-injected window.postMessage
SageMaker JupyterLabBrowser (Chromium / Firefox / Safari)same-domain iframesame-originwindow.postMessage

Because the origin is not uniform, the inbound message handler validates it defensively: it rejects only a real HTTP(S) cross-origin message and allows empty, "null", and file:// origins, which are produced by legitimate hosts (for example Eclipse on Windows, where Browser.setText()-injected HTML has an opaque origin). Any change to inbound message handling or origin validation must be validated against every host environment above — see the handleInboundMessage JSDoc in src/client/chat.ts.

Usage

To use the chat client, embed it in a webview within your application and handle the postMessage communication as needed. Chat client is based on inbound (from a destination to the chat client) and outbound events (from the chat client to a destination). Events consist of command and params:

interface SomeEvent {
    command: string;
    params: SomeOptions;
}

Inbound events

NameDescriptioncommandparams
sendChatPrompt responseProvides response to sendChatPrompt requestaws/chat/sendChatPromptChatResult
openTab requestRequest to open tab (creates tab if no tabId provided)aws/chat/openTabrequestID - ID shared between the webview and vscode client, OpenTabParams
sendToPromptRequest to send selection to promptsendToPromptSendToPromptParams
genericCommandRequest to execute generic commandgenericCommandGenericCommandParams
errorMessageRequest to show error in chat UIerrorMessageErrorParams
chatOptionsConfigures chat startup optionschatOptionsChatOptions
chatUpdateUpdates existing chat messagesaws/chat/sendChatUpdateChatUpdateParams
contextCommandSends context commands to the UIaws/chat/sendContextCommandsContextCommandParams
listConversations responseProvides response with list of history conversations to the UIaws/chat/listConversationsListConversationsResult
conversationClick responseProvides response to conversation click or action, specifying action execution resultaws/chat/conversationClickConversationClickResult
getSerializedChat requestRequest to get serialized chataws/chat/getSerializedChatGetSerializedChatParams
chatOptionsUpdateSends chat options update request from serveraws/chat/chatOptionsUpdateChatOptionsUpdateParams
listRules responseProvides response with list of workspace rules to the UIaws/chat/listRulesListRulesResult
ruleClicked responseProvides response to rule click or action, specifying action execution resultaws/chat/ruleClickRuleClickResult
addSelectedFilesToContextRequest to add selected files to contextaws/chat/openFileDialogOpenFileDialogResult
sendPinnedContextSends pinned context information to the UIaws/chat/sendPinnedContextPinnedContextParams

Outbound events

NameDescriptioncommandparams
openTab responseProvides response to openTab requestaws/chat/openTabrequestID - ID shared between the webview and vscode client, UiMessageResultParams with result of type OpenTabResult
disclaimerAcknowledgedNotifies destination that legal disclaimer was acknowledged by a userdisclaimerAcknowledgedN/A
sendChatPromptSends a chat prompt to the serveraws/chat/sendChatPromptChatParams
sendQuickActionCommandSends a quick action commandaws/chat/quickActionQuickActionParams
tabAddedNotifies when a tab is addedaws/chat/tabAddTabAddParams
tabChangedNotifies when a tab is changedaws/chat/tabChangeTabChangeParams
tabRemovedNotifies when a tab is removedaws/chat/tabRemoveTabRemoveParams
insertToCursorPositionRequests to insert code at cursor positioninsertToCursorPositionInsertToCursorPositionParams
copyToClipboardRequests to copy code to clipboardcopyToClipboardCopyCodeToClipboardParams
authFollowUpClickedNotifies when an auth follow-up is clickedauthFollowUpClickedAuthFollowUpClickedParams
followUpClickedNotifies when a follow-up suggestion is clickedaws/chat/followUpClickFollowUpClickParams
sendFeedbackSends user feedbackaws/chat/feedbackFeedbackParams
linkClickNotifies when a link is clickedaws/chat/linkClickLinkClickParams
sourceLinkClickNotifies when a source link is clickedaws/chat/sourceLinkClickSourceLinkClickParams
infoLinkClickNotifies when an info link is clickedaws/chat/infoLinkClickInfoLinkClickParams
uiReadyNotifies when the UI is readyaws/chat/readyN/A
chatPromptOptionAcknowledgedNotifies when a chat prompt option is acknowledgedchatPromptOptionAcknowledgedChatPromptOptionAcknowledgedParams
createPromptRequests to create a promptaws/chat/createPromptCreatePromptParams
fileClickNotifies when a file is clickedaws/chat/fileClickFileClickParams
listConversationsRequests to list conversations with filter providedaws/chat/listConversationsListConversationsParams
conversationClickNotifies when a conversation is clickedaws/chat/conversationClickConversationClickParams
tabBarActionNotifies when a tab bar action is requestedaws/chat/tabBarActionTabBarActionParams
getSerializedChat responseProvides response to getSerializedChat requestaws/chat/getSerializedChatGetSerializedChatResult
stopChatResponseRequests to stop current chat responsestopChatResponseStopChatResponseParams
sendButtonClickEventSends button click eventaws/chat/buttonClickButtonClickParams
onOpenSettingsRequests to open settingsopenSettingsOpenSettingsParams
onRuleClickNotifies when a rule is clickedaws/chat/ruleClickRuleClickParams
listRulesRequests to list workspace rulesaws/chat/listRulesListRulesParams
onAddPinnedContextRequests to add pinned contextaws/chat/addPinnedContextPinnedContextParams
onRemovePinnedContextRequests to remove pinned contextaws/chat/removePinnedContextPinnedContextParams
onOpenFileDialogClickRequests to open file dialogopenFileDialogOpenFileDialogParams
onFilesDroppedNotifies when files are droppedfilesDroppedFilesDroppedParams
promptInputOptionChangeNotifies when prompt input options changeaws/chat/promptInputOptionChangePromptInputOptionChangeParams

Configuration

Configuration can be passed as an explicit parameter when creating chat inside of webview, for example:

amazonQChat.createChat(acquireVsCodeApi(), configuration);

Configuration values:

// Configures quick actions
quickActionCommands?: QuickActionCommandGroup[]

// Configures chat client not to show legal disclaimer as it has already been acknowledged before
disclaimerAcknowledged?: boolean

版本与发布记录

@aws/chat-client 共发布 63 个版本,首次发布于 2024/10/09;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.58latest2026/10/0929 天前
0.1.572026/10/021 个月前
0.1.562026/08/192 个月前
0.1.552026/07/014 个月前
0.1.542026/05/275 个月前
0.1.532026/05/215 个月前

关于 @aws/chat-client 的常见问题

@aws/chat-client 是什么?

AWS Chat Client

如何安装 @aws/chat-client?

在项目目录运行 npm install @aws/chat-client,或使用 pnpm add / yarn add / bun add。

@aws/chat-client 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aws/chat-client 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aws/chat-client 可以商用吗?

@aws/chat-client 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aws/chat-client 的下载量有多少?

根据 npm 官方下载统计,@aws/chat-client 在 2026/10/08 – 2026/11/06 这 30 天内被下载 3,053 次,日均约 102 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aws/chat-client 还在维护吗?

最新版本 0.1.58 发布于 2026/10/09(29 天前);至今共发布 63 个版本,其中过去 12 个月发布了 17 个;首次发布于 2024/10/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。