Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtimes/protocol/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './identity-management'
export * from './lsp'
export * from './notification'
export * from './telemetry'
export * from './terminal'
export * from './configuration'
export * from './window'
export * from './workspace'
75 changes: 75 additions & 0 deletions runtimes/protocol/terminal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import { RequestType } from 'vscode-languageserver-protocol'

/**
* Parameters for executing a command in the IDE terminal
*/
export interface ExecuteTerminalCommandParams {
/**
* The command to execute
*/
command: string

/**
* Working directory for command execution
*/
cwd?: string

/**
* Environment variables to set for the command
*/
env?: Record<string, string>

/**
* Whether to create a new terminal or reuse existing one
*/
createNew?: boolean

/**
* Name for the terminal (if creating new)
*/
terminalName?: string
}

/**
* Result of terminal command execution
*/
export interface ExecuteTerminalCommandResult {
/**
* Exit code of the command
*/
exitCode: number

/**
* Standard output from the command
*/
stdout: string

/**
* Standard error from the command
*/
stderr: string

/**
* Whether the command executed successfully
*/
success: boolean

/**
* Optional message providing additional context
*/
message?: string
}

/**
* Request type for executing commands in terminal
*/
export const executeTerminalCommandRequest = new RequestType<
ExecuteTerminalCommandParams,
ExecuteTerminalCommandResult,
void
>('aws/terminal/executeCommand')
5 changes: 5 additions & 0 deletions runtimes/runtimes/base-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
listAvailableModelsRequestType,
subscriptionDetailsNotificationType,
subscriptionUpgradeNotificationType,
executeTerminalCommandRequest,
getSupplementalContextRequestType,
} from '../protocol'
import { createConnection } from 'vscode-languageserver/browser'
Expand Down Expand Up @@ -306,6 +307,10 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
lspConnection.onNotification(didChangeDependencyPathsNotificationType, handler)
},
},
terminal: {
executeCommand: (params, token) =>
lspConnection.sendRequest(executeTerminalCommandRequest, params, token),
},
}

const sdkInitializator: SDKInitializator = Object.assign(
Expand Down
5 changes: 5 additions & 0 deletions runtimes/runtimes/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
getMfaCodeRequestType,
CheckDiagnosticsParams,
OpenWorkspaceFileParams,
executeTerminalCommandRequest,
getSupplementalContextRequestType,
} from '../protocol'
import { ProposedFeatures, createConnection } from 'vscode-languageserver/node'
Expand Down Expand Up @@ -451,6 +452,10 @@ export const standalone = (props: RuntimeProps) => {
lspConnection.onRequest(getSupplementalContextRequestType, handler)
},
},
terminal: {
executeCommand: (params, token) =>
lspConnection.sendRequest(executeTerminalCommandRequest, params, token),
},
}

const isExperimentalProxy = process.env.EXPERIMENTAL_HTTP_PROXY_SUPPORT === 'true'
Expand Down
15 changes: 15 additions & 0 deletions runtimes/server-interface/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ import {
CheckDiagnosticsResult,
OpenWorkspaceFileParams,
OpenWorkspaceFileResult,
ExecuteTerminalCommandParams,
ExecuteTerminalCommandResult,
CancellationToken,
GetSupplementalContextParams,
SupplementalContextItem,
} from '../protocol'
Expand Down Expand Up @@ -197,4 +200,16 @@ export type Lsp = {
handler: RequestHandler<GetSupplementalContextParams, SupplementalContextItem[] | undefined | null, void>
) => void
}
terminal: {
/**
* Execute a command in the IDE terminal
* @param params Terminal command execution parameters
* @param token Optional cancellation token
* @returns Promise that resolves with the execution result
*/
executeCommand: (
params: ExecuteTerminalCommandParams,
token?: CancellationToken
) => Promise<ExecuteTerminalCommandResult>
}
}
Loading