@aws/language-server-runtimes
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "@aws/language-server-runtimes", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Runtimes to host Language Servers for AWS", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -137,2 +137,58 @@ # Language Server Runtimes | ||
### Chat | ||
The runtime defines Chat interface that allow runtime server implementors to define handlers for chat events to enable conversational experiences. Chat data types are mostly modeled after [mynah-ui](https://github.com/aws/mynah-ui), an event driven UI library designed for chat experiences. `mynah-ui` is the suggested UI library to be used on the destination. However the Chat interface is generic enough to be compatible with other UI approaches | ||
#### Initialization | ||
The runtime supports chat by default | ||
#### Feature Specification | ||
| Description | Method | Params | Method type | Response Type | | ||
| ----------- | ------ | ------ | ----------- | ------------- | | ||
| Send chat prompt | `aws/chat/sendChatPrompt` | `ChatParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) | `ChatResult` | | ||
| End conversation | `aws/chat/endChat` | `EndChatParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) | `EndChatResult` | | ||
| Send chat quick action | `aws/chat/sendChatQuickAction` | `QuickActionParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) | `ChatResult` | | ||
| Send chat UI ready event | `aws/chat/ready` | n/a | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send chat vote event | `aws/chat/vote` | `VoteParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send chat feedback event | `aws/chat/feedback` | `FeedbackParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send tab add event | `aws/chat/tabAdd` | `TabAddParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send active tab change event | `aws/chat/tabChange` | `TabChangeParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send tab remove event | `aws/chat/tabRemove` | `TabRemoveParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send insert to cursor position event | `aws/chat/insertToCursorPosition` | `InsertToCursorPositionParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send copy code to clipboard event | `aws/chat/copyCodeToClipboard` | `CopyCodeToClipboardParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send link click event | `aws/chat/linkClick` | `LinkClickParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send info link click event | `aws/chat/infoLinkClick` | `InfoLinkClickParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send source link click event | `aws/chat/sourceLinkClick` | `SourceLinkClickParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
| Send followup chat item click event | `aws/chat/followUpClick` | `FollowUpClickParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | | ||
```ts | ||
export interface ChatPrompt { | ||
prompt?: string | ||
escapedPrompt?: string | ||
command?: string | ||
} | ||
export interface ChatParams { | ||
tabId: string | ||
prompt: ChatPrompt | ||
partialResultToken?: ProgressToken | ||
} | ||
export interface ChatResult { | ||
body?: string | ||
messageId?: string | ||
canBeVoted?: boolean // requires messageId to be filled to show vote thumbs | ||
relatedContent?: { | ||
title?: string | ||
content: SourceLink[] | ||
} | ||
followUp?: { | ||
text?: string | ||
options?: ChatItemAction[] | ||
} | ||
codeReference?: ReferenceTrackerInformation[] | ||
} | ||
``` | ||
Complete Chat parameter and result interfaces can be found in [chat.ts](src/protocol/chat.ts) | ||
## Runtime Host Environments | ||
@@ -139,0 +195,0 @@ |
@@ -47,3 +47,4 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const initialize_1 = require("./initialize"); | ||
const lspRouter_1 = require("./lsp/router/lspRouter"); | ||
const lspServer_1 = require("./lsp/router/lspServer"); | ||
/** | ||
@@ -106,4 +107,2 @@ * The runtime for standalone LSP-based servers. | ||
const documents = new vscode_languageserver_1.TextDocuments(protocol_1.TextDocument); | ||
let initializeHandler = new initialize_1.InitializeHandler(props.name, props.version); | ||
lspConnection.onInitialize(initializeHandler.onInitialize); | ||
// Set up logging over LSP | ||
@@ -125,3 +124,3 @@ // TODO: set up Logging once implemented | ||
const normalizedFileUri = fileUrl.pathname || ''; | ||
const folders = initializeHandler.clientInitializeParams.workspaceFolders; | ||
const folders = lspRouter.clientInitializeParams.workspaceFolders; | ||
if (!folders) | ||
@@ -179,40 +178,48 @@ return undefined; | ||
}; | ||
// Map the LSP client to the LSP feature. | ||
const lsp = { | ||
addInitializer: initializeHandler.addHandler, | ||
onInitialized: handler => lspConnection.onInitialized(p => { | ||
var _a, _b; | ||
const workspaceCapabilities = (_a = initializeHandler.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace; | ||
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) { | ||
// Ask the client to notify the server on configuration changes | ||
lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined); | ||
} | ||
handler(p); | ||
}), | ||
onCompletion: handler => lspConnection.onCompletion(handler), | ||
onInlineCompletion: handler => lspConnection.onRequest(protocol_1.inlineCompletionRequestType, handler), | ||
didChangeConfiguration: handler => lspConnection.onDidChangeConfiguration(handler), | ||
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler), | ||
onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler), | ||
onDidChangeTextDocument: handler => documentsObserver.callbacks.onDidChangeTextDocument(handler), | ||
onDidCloseTextDocument: handler => documentsObserver.callbacks.onDidCloseTextDocument(handler), | ||
onExecuteCommand: handler => lspConnection.onExecuteCommand(handler), | ||
workspace: { | ||
getConfiguration: section => lspConnection.workspace.getConfiguration(section), | ||
}, | ||
publishDiagnostics: params => lspConnection.sendNotification(protocol_1.PublishDiagnosticsNotification.method, params), | ||
sendProgress: (type, token, value) => { | ||
return lspConnection.sendProgress(type, token, value); | ||
}, | ||
onHover: handler => lspConnection.onHover(handler), | ||
extensions: { | ||
onInlineCompletionWithReferences: handler => lspConnection.onRequest(protocol_1.inlineCompletionWithReferencesRequestType, handler), | ||
onLogInlineCompletionSessionResults: handler => { | ||
lspConnection.onNotification(protocol_1.logInlineCompletionSessionResultsNotificationType, handler); | ||
}, | ||
}, | ||
}; | ||
const credentialsProvider = auth.getCredentialsProvider(); | ||
// Create router that will be routing LSP events from the client to server(s) | ||
const lspRouter = new lspRouter_1.LspRouter(lspConnection, props.name, props.version); | ||
// Initialize every Server | ||
const disposables = props.servers.map(s => s({ chat, credentialsProvider, lsp, workspace, telemetry, logging })); | ||
const disposables = props.servers.map(s => { | ||
// Create server representation, processing LSP event handlers, in runtimes | ||
// and add it to the LSP router | ||
const lspServer = new lspServer_1.LspServer(); | ||
lspRouter.servers.push(lspServer); | ||
// Set up LSP events handlers per server | ||
const lsp = { | ||
addInitializer: lspServer.setInitializeHandler, | ||
onInitialized: handler => lspConnection.onInitialized(p => { | ||
var _a, _b; | ||
const workspaceCapabilities = (_a = lspRouter.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace; | ||
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) { | ||
// Ask the client to notify the server on configuration changes | ||
lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined); | ||
} | ||
handler(p); | ||
}), | ||
onCompletion: handler => lspConnection.onCompletion(handler), | ||
onInlineCompletion: handler => lspConnection.onRequest(protocol_1.inlineCompletionRequestType, handler), | ||
didChangeConfiguration: handler => lspConnection.onDidChangeConfiguration(handler), | ||
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler), | ||
onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler), | ||
onDidChangeTextDocument: handler => documentsObserver.callbacks.onDidChangeTextDocument(handler), | ||
onDidCloseTextDocument: handler => documentsObserver.callbacks.onDidCloseTextDocument(handler), | ||
onExecuteCommand: lspServer.setExecuteCommandHandler, | ||
workspace: { | ||
getConfiguration: section => lspConnection.workspace.getConfiguration(section), | ||
}, | ||
publishDiagnostics: params => lspConnection.sendNotification(protocol_1.PublishDiagnosticsNotification.method, params), | ||
sendProgress: (type, token, value) => { | ||
return lspConnection.sendProgress(type, token, value); | ||
}, | ||
onHover: handler => lspConnection.onHover(handler), | ||
extensions: { | ||
onInlineCompletionWithReferences: handler => lspConnection.onRequest(protocol_1.inlineCompletionWithReferencesRequestType, handler), | ||
onLogInlineCompletionSessionResults: handler => { | ||
lspConnection.onNotification(protocol_1.logInlineCompletionSessionResultsNotificationType, handler); | ||
}, | ||
}, | ||
}; | ||
return s({ chat, credentialsProvider, lsp, workspace, telemetry, logging }); | ||
}); | ||
// Free up any resources or threads used by Servers | ||
@@ -219,0 +226,0 @@ lspConnection.onExit(() => { |
@@ -18,3 +18,4 @@ "use strict"; | ||
const lsp_1 = require("./lsp"); | ||
const initialize_1 = require("./initialize"); | ||
const lspRouter_1 = require("./lsp/router/lspRouter"); | ||
const lspServer_1 = require("./lsp/router/lspServer"); | ||
// TODO: testing rig for runtimes | ||
@@ -25,4 +26,4 @@ const webworker = (props) => { | ||
const documents = new vscode_languageserver_1.TextDocuments(protocol_1.TextDocument); | ||
let initializeHandler = new initialize_1.InitializeHandler(props.name, props.version); | ||
lspConnection.onInitialize(initializeHandler.onInitialize); | ||
// Create router that will be routing LSP events from the client to server(s) | ||
const lspRouter = new lspRouter_1.LspRouter(lspConnection, props.name, props.version); | ||
// Set up logigng over LSP | ||
@@ -39,4 +40,3 @@ const logging = { | ||
getTextDocument: (uri) => __awaiter(void 0, void 0, void 0, function* () { return documents.get(uri); }), | ||
getWorkspaceFolder: _uri => initializeHandler.clientInitializeParams.workspaceFolders && | ||
initializeHandler.clientInitializeParams.workspaceFolders[0], | ||
getWorkspaceFolder: _uri => lspRouter.clientInitializeParams.workspaceFolders && lspRouter.clientInitializeParams.workspaceFolders[0], | ||
fs: { | ||
@@ -70,37 +70,2 @@ copy: (_src, _dest) => Promise.resolve(), | ||
}; | ||
// Map the LSP client to the LSP feature. | ||
const lsp = { | ||
addInitializer: initializeHandler.addHandler, | ||
onInitialized: handler => lspConnection.onInitialized(p => { | ||
var _a, _b; | ||
const workspaceCapabilities = (_a = initializeHandler.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace; | ||
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) { | ||
// Ask the client to notify the server on configuration changes | ||
lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined); | ||
} | ||
handler(p); | ||
}), | ||
onCompletion: handler => lspConnection.onCompletion(handler), | ||
onInlineCompletion: handler => lspConnection.onRequest(protocol_1.inlineCompletionRequestType, handler), | ||
didChangeConfiguration: handler => lspConnection.onDidChangeConfiguration(handler), | ||
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler), | ||
onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler), | ||
onDidChangeTextDocument: handler => documentsObserver.callbacks.onDidChangeTextDocument(handler), | ||
onDidCloseTextDocument: handler => lspConnection.onDidCloseTextDocument(handler), | ||
onExecuteCommand: handler => lspConnection.onExecuteCommand(handler), | ||
workspace: { | ||
getConfiguration: section => lspConnection.workspace.getConfiguration(section), | ||
}, | ||
publishDiagnostics: params => lspConnection.sendNotification(protocol_1.PublishDiagnosticsNotification.method, params), | ||
sendProgress: (type, token, value) => { | ||
return lspConnection.sendProgress(type, token, value); | ||
}, | ||
onHover: handler => lspConnection.onHover(handler), | ||
extensions: { | ||
onInlineCompletionWithReferences: handler => lspConnection.onRequest(protocol_1.inlineCompletionWithReferencesRequestType, handler), | ||
onLogInlineCompletionSessionResults: handler => { | ||
lspConnection.onNotification(protocol_1.logInlineCompletionSessionResultsNotificationType, handler); | ||
}, | ||
}, | ||
}; | ||
// Set up auth without encryption | ||
@@ -110,3 +75,44 @@ const auth = new auth_1.Auth(lspConnection); | ||
// Initialize every Server | ||
const disposables = props.servers.map(s => s({ chat, credentialsProvider, lsp, workspace, telemetry, logging })); | ||
const disposables = props.servers.map(s => { | ||
// Create server representation, processing LSP event handlers, in runtimes | ||
// and add it to the LSP router | ||
const lspServer = new lspServer_1.LspServer(); | ||
lspRouter.servers.push(lspServer); | ||
// Set up LSP events handlers per server | ||
const lsp = { | ||
addInitializer: lspServer.setInitializeHandler, | ||
onInitialized: handler => lspConnection.onInitialized(p => { | ||
var _a, _b; | ||
const workspaceCapabilities = (_a = lspRouter.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace; | ||
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) { | ||
// Ask the client to notify the server on configuration changes | ||
lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined); | ||
} | ||
handler(p); | ||
}), | ||
onCompletion: handler => lspConnection.onCompletion(handler), | ||
onInlineCompletion: handler => lspConnection.onRequest(protocol_1.inlineCompletionRequestType, handler), | ||
didChangeConfiguration: handler => lspConnection.onDidChangeConfiguration(handler), | ||
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler), | ||
onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler), | ||
onDidChangeTextDocument: handler => documentsObserver.callbacks.onDidChangeTextDocument(handler), | ||
onDidCloseTextDocument: handler => lspConnection.onDidCloseTextDocument(handler), | ||
onExecuteCommand: lspServer.setExecuteCommandHandler, | ||
workspace: { | ||
getConfiguration: section => lspConnection.workspace.getConfiguration(section), | ||
}, | ||
publishDiagnostics: params => lspConnection.sendNotification(protocol_1.PublishDiagnosticsNotification.method, params), | ||
sendProgress: (type, token, value) => { | ||
return lspConnection.sendProgress(type, token, value); | ||
}, | ||
onHover: handler => lspConnection.onHover(handler), | ||
extensions: { | ||
onInlineCompletionWithReferences: handler => lspConnection.onRequest(protocol_1.inlineCompletionWithReferencesRequestType, handler), | ||
onLogInlineCompletionSessionResults: handler => { | ||
lspConnection.onNotification(protocol_1.logInlineCompletionSessionResultsNotificationType, handler); | ||
}, | ||
}, | ||
}; | ||
return s({ chat, credentialsProvider, lsp, workspace, telemetry, logging }); | ||
}); | ||
// Free up any resources or threads used by Servers | ||
@@ -113,0 +119,0 @@ lspConnection.onExit(() => { |
import { CompletionItem, CompletionList, InlineCompletionItem, CompletionParams, DidChangeConfigurationParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, ExecuteCommandParams, Hover, HoverParams, InitializeError, InitializeParams, InitializedParams, InlineCompletionList, InlineCompletionParams, NotificationHandler, PublishDiagnosticsParams, ServerCapabilities, InlineCompletionItemWithReferences, InlineCompletionListWithReferences, LogInlineCompletionSessionResultsParams, RequestHandler, DidOpenTextDocumentParams, DocumentFormattingParams, TextEdit, ProgressType, ProgressToken } from '../protocol'; | ||
export * from '../protocol/lsp'; | ||
export type PartialServerCapabilities<T = any> = Pick<ServerCapabilities<T>, 'completionProvider' | 'hoverProvider'>; | ||
export type PartialServerCapabilities<T = any> = Pick<ServerCapabilities<T>, 'completionProvider' | 'hoverProvider' | 'executeCommandProvider'>; | ||
export type PartialInitializeResult<T = any> = { | ||
@@ -5,0 +5,0 @@ capabilities: PartialServerCapabilities<T>; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
156151
71
2563
275
0