From f6d0c01d076703fd2c94858ff6ede530a0b7cae1 Mon Sep 17 00:00:00 2001 From: QQ Date: Tue, 17 Nov 2026 08:45:33 +0800 Subject: [PATCH] Import packages/plugin/src/client-runtime.ts --- packages/plugin/src/client-runtime.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/plugin/src/client-runtime.ts b/packages/plugin/src/client-runtime.ts index df07ea9..2b401a9 100644 --- a/packages/plugin/src/client-runtime.ts +++ b/packages/plugin/src/client-runtime.ts @@ -1,3 +1,4 @@ +import { uploadLocalMentions } from './local-mention-upload.js' import type { ControlResult } from './control-result.js' import { AgentAcpClient, CodexRemoteClient } from '@dsh-remote/client-core' import type { PluginRouteCallResult } from '@dsh-remote/protocol' @@ -885,6 +886,11 @@ export class ClientModeRuntime { if (!remote.features.pluginRoute) { throw new ClientModeError('FEATURE_NOT_SUPPORTED', 'The connected Host cannot forward plugin routes.') } + if (route === 'api/session/uploadFileBinary') { + const result = await this.remoteTypertGateway(remote).dispatch('remoteUploads/upload', { args: body }, signal) + if (!result.ok) throw new ClientModeError(result.error.code, result.error.message) + return result.value as PluginRouteCallResult + } return remote.client.rpc('plugin.route.call', { route, body }, signal) } @@ -896,7 +902,18 @@ export class ClientModeRuntime { this.assertRemoteCompatible(remote) this.clientAuthRequired = false const target = { deviceId: remote.target.deviceId, name: remote.target.name } - this.gatewaySwitch.selectRemote(this.remoteTypertGateway(remote), undefined, target) + const gateway = this.remoteTypertGateway(remote) + const selected = { + invoke: async (request: Parameters[0]) => { + if (`${request.namespace}/${request.method}` !== 'session/prompt') return gateway.invoke(request) + const payload = await uploadLocalMentions({ args: request.args }, gateway, request.signal ?? new AbortController().signal) + return gateway.invoke({ ...request, args: (payload as { args: typeof request.args }).args }) + }, + dispatch: async (endpoint: string, payload: unknown, signal: AbortSignal) => gateway.dispatch(endpoint, + endpoint === 'session/prompt' ? await uploadLocalMentions(payload, gateway, signal) : payload, signal), + open: (endpoint: string, payload: unknown, signal: AbortSignal) => gateway.open(endpoint, payload, signal), + } + this.gatewaySwitch.selectRemote(selected, undefined, target) this.recoverable = remote }