Fix error messages and improve type imports (#304837)

* Tweak error message
And fix inline type imports

Co-authored-by: Copilot <copilot@github.com>

* Fix

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Rob Lourens
2026-03-26 14:23:10 -07:00
committed by GitHub
parent 4cdcd4f345
commit 70aef526fa
3 changed files with 17 additions and 12 deletions

View File

@@ -66,8 +66,10 @@ import type {
ISessionModelChangedAction,
ISessionReasoningAction,
ISessionResponsePartAction,
ISessionToolCallApprovedAction,
ISessionToolCallCompleteAction,
ISessionToolCallConfirmedAction,
ISessionToolCallDeniedAction,
ISessionToolCallDeltaAction,
ISessionToolCallReadyAction,
ISessionToolCallResultConfirmedAction,
@@ -102,8 +104,8 @@ export type IResponsePartAction = ISessionResponsePartAction;
export type IToolCallStartAction = ISessionToolCallStartAction;
export type IToolCallDeltaAction = ISessionToolCallDeltaAction;
export type IToolCallReadyAction = ISessionToolCallReadyAction;
export type IToolCallApprovedAction = import('./protocol/actions.js').ISessionToolCallApprovedAction;
export type IToolCallDeniedAction = import('./protocol/actions.js').ISessionToolCallDeniedAction;
export type IToolCallApprovedAction = ISessionToolCallApprovedAction;
export type IToolCallDeniedAction = ISessionToolCallDeniedAction;
export type IToolCallConfirmedAction = ISessionToolCallConfirmedAction;
export type IToolCallCompleteAction = ISessionToolCallCompleteAction;
export type IToolCallResultConfirmedAction = ISessionToolCallResultConfirmedAction;

View File

@@ -221,7 +221,7 @@ export class RemoteAgentHostService extends Disposable implements IRemoteAgentHo
this._resolvePendingConnectionWait(address);
this._onDidChangeConnections.fire();
}).catch(err => {
this._logService.error(`[RemoteAgentHost] Failed to connect to ${address}`, err);
this._logService.error(`[RemoteAgentHost] Failed to connect to ${address}. Verify address and connectionToken`, err);
this._rejectPendingConnectionWait(address, err);
guardedRemove();
});

View File

@@ -12,6 +12,9 @@ import { connectionTokenQueryName } from '../../../base/common/network.js';
import { ILogService } from '../../log/common/log.js';
import { JSON_RPC_PARSE_ERROR, type IAhpServerNotification, type IJsonRpcResponse, type IProtocolMessage } from '../common/state/sessionProtocol.js';
import type { IProtocolServer, IProtocolTransport } from '../common/state/sessionTransport.js';
import type * as wsTypes from 'ws';
import type * as httpTypes from 'http';
import type * as urlTypes from 'url';
/**
* Options for creating a {@link WebSocketProtocolServer}.
@@ -46,8 +49,8 @@ export class WebSocketProtocolTransport extends Disposable implements IProtocolT
readonly onClose = this._onClose.event;
constructor(
private readonly _ws: import('ws').WebSocket,
private readonly _WebSocket: typeof import('ws').WebSocket,
private readonly _ws: wsTypes.WebSocket,
private readonly _WebSocket: typeof wsTypes.WebSocket,
) {
super();
@@ -94,9 +97,9 @@ export class WebSocketProtocolTransport extends Disposable implements IProtocolT
*/
export class WebSocketProtocolServer extends Disposable implements IProtocolServer {
private readonly _wss: import('ws').WebSocketServer;
private readonly _httpServer: import('http').Server | undefined;
private readonly _WebSocket: typeof import('ws').WebSocket;
private readonly _wss: wsTypes.WebSocketServer;
private readonly _httpServer: httpTypes.Server | undefined;
private readonly _WebSocket: typeof wsTypes.WebSocket;
private readonly _onConnection = this._register(new Emitter<IProtocolTransport>());
readonly onConnection = this._onConnection.event;
@@ -128,9 +131,9 @@ export class WebSocketProtocolServer extends Disposable implements IProtocolServ
private constructor(
options: IWebSocketServerOptions | number,
private readonly _logService: ILogService,
ws: typeof import('ws'),
http: typeof import('http'),
url: typeof import('url'),
ws: typeof wsTypes,
http: typeof httpTypes,
url: typeof urlTypes,
) {
super();
@@ -141,7 +144,7 @@ export class WebSocketProtocolServer extends Disposable implements IProtocolServ
const host = opts.host ?? '127.0.0.1';
const verifyClient = opts.connectionTokenValidate
? (info: { req: import('http').IncomingMessage }, cb: (res: boolean, code?: number, message?: string) => void) => {
? (info: { req: httpTypes.IncomingMessage }, cb: (res: boolean, code?: number, message?: string) => void) => {
const parsedUrl = url.parse(info.req.url ?? '', true);
const token = parsedUrl.query[connectionTokenQueryName];
if (!opts.connectionTokenValidate!(token)) {