mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
refactor: bind remote runtime callers to concrete transport owners
This commit is contained in:
@@ -53,7 +53,8 @@ const LAYOUT_ORACLE_PREFIXES = [
|
||||
'src/renderer/src/store/slices/tabs/recently-closed-tabs.ts',
|
||||
// The client the oracle reads every view through.
|
||||
'src/cli/runtime/client.ts',
|
||||
'src/shared/remote-runtime/remote-runtime-client.ts',
|
||||
'src/shared/remote-runtime/requests/remote-runtime-request-socket.ts',
|
||||
'src/shared/remote-runtime/requests/remote-runtime-subscription-contract.ts',
|
||||
'src/shared/remote-runtime/requests/remote-runtime-subscription-transport.ts',
|
||||
'src/shared/remote-runtime/pairing/paired-runtime-connection.ts',
|
||||
'src/shared/remote-runtime/pairing/pairing.ts',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { parsePairingCode } from '../../shared/remote-runtime/pairing/pairing'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { exchangeRemotePairingTicket } from '../../shared/remote-runtime/pairing/remote-pairing-ticket-exchange'
|
||||
import { sendRemoteRuntimeRequest } from '../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { RemoteRuntimeClientError } from '../../shared/remote-runtime/remote-runtime-client-error'
|
||||
import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
|
||||
@@ -20,7 +20,7 @@ function pairingCodeRefused(): RuntimeClientError {
|
||||
/** Best effort: the pairing code to save, exchanged for a token only this machine holds when the host supports it. */
|
||||
export async function exchangeCliPairingCode(
|
||||
pairingCode: string,
|
||||
send: typeof sendRemoteRuntimeRequest = sendRemoteRuntimeRequest
|
||||
send: typeof sendRemoteRuntimeRequestOnSocket = sendRemoteRuntimeRequestOnSocket
|
||||
): Promise<string> {
|
||||
const offer = parsePairingCode(pairingCode)
|
||||
if (!offer) {
|
||||
@@ -33,7 +33,13 @@ export async function exchangeCliPairingCode(
|
||||
pairedRuntimeConnectionFromOffer(offer),
|
||||
'status.get',
|
||||
undefined,
|
||||
STATUS_PROBE_TIMEOUT_MS
|
||||
STATUS_PROBE_TIMEOUT_MS,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
} catch (error) {
|
||||
// A reachable host that refuses the code: saving it would only fail later.
|
||||
|
||||
@@ -6,10 +6,7 @@ import type {
|
||||
import { RemoteRuntimeClientError } from '../../shared/remote-runtime/remote-runtime-client-error'
|
||||
import { AGENT_LAUNCH_RUNTIME_CAPABILITY } from '../../shared/agent-launch/contracts/agent-launch-runtime-capability'
|
||||
import { AGENT_SESSION_RENAME_ONLY_CLIENT_CAPABILITY } from '../../shared/agent-session/structured-agent-session-surface-capabilities'
|
||||
import {
|
||||
sendRemoteRuntimeRequest,
|
||||
sendRemoteRuntimeRequestWithStatusPreflight
|
||||
} from '../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import type { RuntimeStatus } from '../../shared/runtime-types'
|
||||
import { RuntimeClientError, type RuntimeRpcResponse } from './types'
|
||||
|
||||
@@ -27,14 +24,17 @@ export async function sendWebSocketRequest<TResult>(
|
||||
envelope?: RuntimeOrchestrationEnvelope
|
||||
): Promise<RuntimeRpcResponse<TResult>> {
|
||||
try {
|
||||
return await sendRemoteRuntimeRequest<TResult>(
|
||||
return await sendRemoteRuntimeRequestOnSocket<TResult>(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
envelope,
|
||||
undefined,
|
||||
CLI_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
CLI_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof RemoteRuntimeClientError) {
|
||||
@@ -54,16 +54,17 @@ export async function sendWebSocketRequestWithStatusPreflight<TResult>(
|
||||
requestSelection?: RuntimeRequestSelection
|
||||
): Promise<RuntimeRpcResponse<TResult>> {
|
||||
try {
|
||||
return await sendRemoteRuntimeRequestWithStatusPreflight<TResult>(
|
||||
return await sendRemoteRuntimeRequestOnSocket<TResult>(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
validateStatus,
|
||||
envelope,
|
||||
CLI_CLIENT_CAPABILITIES,
|
||||
validateStatus,
|
||||
undefined,
|
||||
requestSelection
|
||||
CLI_CLIENT_CAPABILITIES,
|
||||
requestSelection,
|
||||
undefined
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof RemoteRuntimeClientError) {
|
||||
|
||||
@@ -6,11 +6,11 @@ import {
|
||||
BrowserClientAutomationResult as BrowserClientHostCommandResult,
|
||||
type BrowserClientAutomationResult as BrowserClientHostCommandResultType
|
||||
} from '../../../../shared/browser/client-hosting/browser-client-automation-protocol'
|
||||
import type { RemoteRuntimeSubscription } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { RemoteRuntimeClientError } from '../../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
|
||||
export async function submitBrowserHostCommandResult(
|
||||
sendRequest: NonNullable<RemoteRuntimeSubscription['sendRequest']>,
|
||||
sendRequest: NonNullable<RemoteRuntimeTransportSubscription['sendRequest']>,
|
||||
command: BrowserClientHostCommandEvent,
|
||||
candidate: BrowserClientHostCommandResultType,
|
||||
timeoutMs: number
|
||||
|
||||
+9
-9
@@ -2,17 +2,17 @@ import { pairedRuntimeConnectionFromOffer } from '../../../../shared/remote-runt
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { PairingOffer } from '../../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import type {
|
||||
RemoteRuntimeSubscription,
|
||||
RemoteRuntimeSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { RemoteRuntimeClientError } from '../../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
|
||||
const { subscribeRemoteRuntimeRequestMock } = vi.hoisted(() => ({
|
||||
subscribeRemoteRuntimeRequestMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
import { PairedRuntimeBrowserHostLease } from '../leases/paired-runtime-browser-host-lease'
|
||||
@@ -133,17 +133,17 @@ function createLease(overrides: {
|
||||
}
|
||||
|
||||
function mockAttempts(): {
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks
|
||||
callbacks: RemoteRuntimeTransportSubscriptionCallbacks
|
||||
close: ReturnType<typeof vi.fn>
|
||||
sendRequest: ReturnType<typeof vi.fn>
|
||||
}[] {
|
||||
const attempts: {
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks
|
||||
callbacks: RemoteRuntimeTransportSubscriptionCallbacks
|
||||
close: ReturnType<typeof vi.fn>
|
||||
sendRequest: ReturnType<typeof vi.fn>
|
||||
}[] = []
|
||||
subscribeRemoteRuntimeRequestMock.mockImplementation(
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeSubscription> => {
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
const close = vi.fn()
|
||||
const sendRequest = vi.fn().mockResolvedValue({
|
||||
id: 'file-channel',
|
||||
@@ -152,7 +152,7 @@ function mockAttempts(): {
|
||||
_meta: { runtimeId: 'runtime-a' }
|
||||
})
|
||||
attempts.push({
|
||||
callbacks: args[4] as RemoteRuntimeSubscriptionCallbacks,
|
||||
callbacks: args[4] as RemoteRuntimeTransportSubscriptionCallbacks,
|
||||
close,
|
||||
sendRequest
|
||||
})
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { RemoteRuntimeSubscription } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { RemoteRuntimeClientError } from '../../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
|
||||
/** Page traffic must use the lease's connection; ordinary runtime calls are rejected as stale. */
|
||||
export function requireBrowserHostLeaseSendRequest(
|
||||
sendRequest: RemoteRuntimeSubscription['sendRequest'] | undefined,
|
||||
sendRequest: RemoteRuntimeTransportSubscription['sendRequest'] | undefined,
|
||||
unavailableMessage: string
|
||||
): NonNullable<RemoteRuntimeSubscription['sendRequest']> {
|
||||
): NonNullable<RemoteRuntimeTransportSubscription['sendRequest']> {
|
||||
if (!sendRequest) {
|
||||
throw new RemoteRuntimeClientError('remote_runtime_unavailable', unavailableMessage)
|
||||
}
|
||||
|
||||
+12
-11
@@ -7,11 +7,12 @@ import {
|
||||
BROWSER_CLIENT_HOST_RUNTIME_CAPABILITY,
|
||||
BROWSER_CLIENT_PAGE_METADATA_RUNTIME_CAPABILITY
|
||||
} from '../../../../shared/browser-runtime-capabilities'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription,
|
||||
type RemoteRuntimeSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type {
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { RemoteRuntimeClientError } from '../../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
import { createBrowserClientHostAttachRequest } from '../lifecycle/browser-client-host-attach-request'
|
||||
import { sameBrowserClientHostLeaseAuthority } from '../commands/browser-client-host-command-authority'
|
||||
@@ -29,7 +30,7 @@ type PairedRuntimeBrowserHostLeaseConnectionOptions = {
|
||||
}
|
||||
|
||||
export class PairedRuntimeBrowserHostLeaseConnection {
|
||||
private subscription: RemoteRuntimeSubscription | null = null
|
||||
private subscription: RemoteRuntimeTransportSubscription | null = null
|
||||
private readyTimeout: ReturnType<typeof setTimeout> | null = null
|
||||
private resolveReady = (_authority: BrowserClientHostLeaseAuthority): void => {}
|
||||
private rejectReady = (_error: Error): void => {}
|
||||
@@ -48,7 +49,7 @@ export class PairedRuntimeBrowserHostLeaseConnection {
|
||||
return this.subscription !== null
|
||||
}
|
||||
|
||||
get sendRequest(): RemoteRuntimeSubscription['sendRequest'] | undefined {
|
||||
get sendRequest(): RemoteRuntimeTransportSubscription['sendRequest'] | undefined {
|
||||
return this.subscription?.sendRequest
|
||||
}
|
||||
|
||||
@@ -60,9 +61,9 @@ export class PairedRuntimeBrowserHostLeaseConnection {
|
||||
void ready.catch(() => undefined)
|
||||
const request = createBrowserClientHostAttachRequest(this.options.lease)
|
||||
try {
|
||||
let subscription: RemoteRuntimeSubscription
|
||||
let subscription: RemoteRuntimeTransportSubscription
|
||||
try {
|
||||
subscription = await subscribeRemoteRuntimeRequest(
|
||||
subscription = await subscribeRemoteRuntimeTransport(
|
||||
this.options.lease.connection,
|
||||
'browser.clientHost.attach',
|
||||
request.params,
|
||||
@@ -131,7 +132,7 @@ export class PairedRuntimeBrowserHostLeaseConnection {
|
||||
}
|
||||
|
||||
private callbacks(request: ReturnType<typeof createBrowserClientHostAttachRequest>) {
|
||||
const callbacks: RemoteRuntimeSubscriptionCallbacks = {
|
||||
const callbacks: RemoteRuntimeTransportSubscriptionCallbacks = {
|
||||
onResponse: (response) => this.handleResponse(response, request),
|
||||
onError: (error) => this.fail(error),
|
||||
onClose: () =>
|
||||
@@ -146,7 +147,7 @@ export class PairedRuntimeBrowserHostLeaseConnection {
|
||||
}
|
||||
|
||||
private handleResponse(
|
||||
response: Parameters<RemoteRuntimeSubscriptionCallbacks['onResponse']>[0],
|
||||
response: Parameters<RemoteRuntimeTransportSubscriptionCallbacks['onResponse']>[0],
|
||||
request: ReturnType<typeof createBrowserClientHostAttachRequest>
|
||||
): void {
|
||||
if (!this.active) {
|
||||
|
||||
@@ -6,14 +6,14 @@ import type {
|
||||
BrowserClientHostedPageInventory,
|
||||
BrowserClientHostCommandEvent
|
||||
} from '../../../../shared/browser/client-hosting/browser-client-host-protocol'
|
||||
import type { RemoteRuntimeSubscription } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
|
||||
const { subscribeRemoteRuntimeRequestMock } = vi.hoisted(() => ({
|
||||
subscribeRemoteRuntimeRequestMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
import { PairedRuntimeBrowserHostLease } from './paired-runtime-browser-host-lease'
|
||||
@@ -32,7 +32,7 @@ afterEach(() => {
|
||||
|
||||
describe('PairedRuntimeBrowserHostLease', () => {
|
||||
it('closes a subscription acquired after local teardown', async () => {
|
||||
let resolveSubscription = (_subscription: RemoteRuntimeSubscription): void => {}
|
||||
let resolveSubscription = (_subscription: RemoteRuntimeTransportSubscription): void => {}
|
||||
const close = vi.fn()
|
||||
subscribeRemoteRuntimeRequestMock.mockReturnValueOnce(
|
||||
new Promise((resolve) => {
|
||||
|
||||
+9
-9
@@ -2,17 +2,17 @@ import { pairedRuntimeConnectionFromOffer } from '../../../../shared/remote-runt
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { PairingOffer } from '../../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import type {
|
||||
RemoteRuntimeSubscription,
|
||||
RemoteRuntimeSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { RemoteRuntimeClientError } from '../../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
|
||||
const { subscribeRemoteRuntimeRequestMock } = vi.hoisted(() => ({
|
||||
subscribeRemoteRuntimeRequestMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
import { PairedRuntimeBrowserClientHost } from './paired-runtime-browser-client-host'
|
||||
@@ -102,17 +102,17 @@ describe('PairedRuntimeBrowserClientHost reconnect', () => {
|
||||
})
|
||||
|
||||
function mockAttempts(): {
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks
|
||||
callbacks: RemoteRuntimeTransportSubscriptionCallbacks
|
||||
close: ReturnType<typeof vi.fn>
|
||||
sendRequest: ReturnType<typeof vi.fn>
|
||||
}[] {
|
||||
const attempts: {
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks
|
||||
callbacks: RemoteRuntimeTransportSubscriptionCallbacks
|
||||
close: ReturnType<typeof vi.fn>
|
||||
sendRequest: ReturnType<typeof vi.fn>
|
||||
}[] = []
|
||||
subscribeRemoteRuntimeRequestMock.mockImplementation(
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeSubscription> => {
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
const close = vi.fn()
|
||||
const sendRequest = vi.fn().mockResolvedValue({
|
||||
id: 'command-result',
|
||||
@@ -121,7 +121,7 @@ function mockAttempts(): {
|
||||
_meta: { runtimeId: 'runtime-a' }
|
||||
})
|
||||
attempts.push({
|
||||
callbacks: args[4] as RemoteRuntimeSubscriptionCallbacks,
|
||||
callbacks: args[4] as RemoteRuntimeTransportSubscriptionCallbacks,
|
||||
close,
|
||||
sendRequest
|
||||
})
|
||||
|
||||
+11
-10
@@ -2,16 +2,16 @@ import { pairedRuntimeConnectionFromOffer } from '../../../../shared/remote-runt
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { PairingOffer } from '../../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import type {
|
||||
RemoteRuntimeSubscription,
|
||||
RemoteRuntimeSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
|
||||
const { subscribeRemoteRuntimeRequestMock } = vi.hoisted(() => ({
|
||||
subscribeRemoteRuntimeRequestMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
import { PairedRuntimeBrowserHostLease } from '../leases/paired-runtime-browser-host-lease'
|
||||
@@ -194,10 +194,10 @@ function createLease(
|
||||
}
|
||||
|
||||
async function subscribeLease(options?: { sendRequest?: ReturnType<typeof vi.fn> }): Promise<{
|
||||
callbacks: { current?: RemoteRuntimeSubscriptionCallbacks }
|
||||
callbacks: { current?: RemoteRuntimeTransportSubscriptionCallbacks }
|
||||
close: ReturnType<typeof vi.fn>
|
||||
}> {
|
||||
const callbacks: { current?: RemoteRuntimeSubscriptionCallbacks } = {}
|
||||
const callbacks: { current?: RemoteRuntimeTransportSubscriptionCallbacks } = {}
|
||||
const close = vi.fn()
|
||||
const sendRequest =
|
||||
options && 'sendRequest' in options
|
||||
@@ -209,15 +209,16 @@ async function subscribeLease(options?: { sendRequest?: ReturnType<typeof vi.fn>
|
||||
_meta: { runtimeId: 'runtime-a' }
|
||||
})
|
||||
subscribeRemoteRuntimeRequestMock.mockImplementationOnce(
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeSubscription> => {
|
||||
callbacks.current = args[4] as RemoteRuntimeSubscriptionCallbacks
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
callbacks.current = args[4] as RemoteRuntimeTransportSubscriptionCallbacks
|
||||
return {
|
||||
requestId: 'browser-host',
|
||||
close,
|
||||
sendBinary: () => false,
|
||||
...(sendRequest
|
||||
? {
|
||||
sendRequest: sendRequest as unknown as RemoteRuntimeSubscription['sendRequest']
|
||||
sendRequest:
|
||||
sendRequest as unknown as RemoteRuntimeTransportSubscription['sendRequest']
|
||||
}
|
||||
: {})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
type DesktopBrowserBridgeRequest,
|
||||
type DesktopBrowserBridgeResultParams
|
||||
} from '../../../shared/desktop-browser-bridge-protocol'
|
||||
import type { RemoteRuntimeSubscription } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import type { RuntimeRpcResponse } from '../../../shared/runtime-rpc-envelope'
|
||||
import type { DesktopBrowserBridgeOutcome } from './desktop-browser-bridge-executor'
|
||||
|
||||
@@ -17,10 +17,10 @@ export type DesktopBrowserBridgeSubscribe = (callbacks: {
|
||||
onResponse(response: RuntimeRpcResponse<unknown>): void
|
||||
onError(error: Error): void
|
||||
onClose(): void
|
||||
}) => Promise<RemoteRuntimeSubscription>
|
||||
}) => Promise<RemoteRuntimeTransportSubscription>
|
||||
|
||||
export class DesktopBrowserBridgeConnection {
|
||||
private subscription: RemoteRuntimeSubscription | null = null
|
||||
private subscription: RemoteRuntimeTransportSubscription | null = null
|
||||
private attachmentId: string | null = null
|
||||
private closed = false
|
||||
private readonly revoked = new AbortController()
|
||||
@@ -46,7 +46,7 @@ export class DesktopBrowserBridgeConnection {
|
||||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
let subscription: RemoteRuntimeSubscription
|
||||
let subscription: RemoteRuntimeTransportSubscription
|
||||
try {
|
||||
subscription = await this.options.subscribe({
|
||||
onResponse: (response) => this.handleResponse(response),
|
||||
@@ -158,7 +158,7 @@ export class DesktopBrowserBridgeConnection {
|
||||
|
||||
/** False when result submission throws or the host refuses it. */
|
||||
private async sendResult(
|
||||
sendRequest: NonNullable<RemoteRuntimeSubscription['sendRequest']>,
|
||||
sendRequest: NonNullable<RemoteRuntimeTransportSubscription['sendRequest']>,
|
||||
params: DesktopBrowserBridgeResultParams
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { RemoteRuntimeSubscription } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import type { RuntimeRpcResponse } from '../../../shared/runtime-rpc-envelope'
|
||||
import {
|
||||
DesktopBrowserBridgeManager,
|
||||
@@ -33,7 +33,7 @@ function harness(options: { supports?: boolean } = {}) {
|
||||
}))
|
||||
const subscribe = vi.fn(
|
||||
() =>
|
||||
async (callbacks: Callbacks): Promise<RemoteRuntimeSubscription> => {
|
||||
async (callbacks: Callbacks): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
const entry = {
|
||||
callbacks,
|
||||
close: vi.fn(),
|
||||
|
||||
+15
-15
@@ -11,17 +11,17 @@ import {
|
||||
import type { BrowserNetworkExecutionHost } from '../../../../shared/browser/client-hosting/browser-network-execution-host'
|
||||
import type { PairingOffer } from '../../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import type {
|
||||
RemoteRuntimeSubscription,
|
||||
RemoteRuntimeSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import type { RemoteRuntimeSubscriptionOptions } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
|
||||
const { subscribeRemoteRuntimeRequestMock } = vi.hoisted(() => ({
|
||||
subscribeRemoteRuntimeRequestMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
import { PairedRuntimeBrowserNetworkRoute } from './paired-runtime-browser-network-route'
|
||||
@@ -51,7 +51,7 @@ afterEach(() => {
|
||||
|
||||
describe('PairedRuntimeBrowserNetworkRoute', () => {
|
||||
it('closes a subscription that resolves after route teardown', async () => {
|
||||
let resolveSubscription = (_subscription: RemoteRuntimeSubscription): void => {}
|
||||
let resolveSubscription = (_subscription: RemoteRuntimeTransportSubscription): void => {}
|
||||
const closeSubscription = vi.fn()
|
||||
subscribeRemoteRuntimeRequestMock.mockReturnValueOnce(
|
||||
new Promise((resolve) => {
|
||||
@@ -77,11 +77,11 @@ describe('PairedRuntimeBrowserNetworkRoute', () => {
|
||||
})
|
||||
|
||||
it('settles startup when close follows subscription acquisition before readiness', async () => {
|
||||
let callbacks: RemoteRuntimeSubscriptionCallbacks | undefined
|
||||
let callbacks: RemoteRuntimeTransportSubscriptionCallbacks | undefined
|
||||
const closeSubscription = vi.fn()
|
||||
subscribeRemoteRuntimeRequestMock.mockImplementationOnce(
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeSubscription> => {
|
||||
callbacks = args[4] as RemoteRuntimeSubscriptionCallbacks
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
callbacks = args[4] as RemoteRuntimeTransportSubscriptionCallbacks
|
||||
return {
|
||||
requestId: 'waiting-subscription',
|
||||
close: closeSubscription,
|
||||
@@ -120,12 +120,12 @@ describe('PairedRuntimeBrowserNetworkRoute', () => {
|
||||
})
|
||||
|
||||
it('binds and releases the exact browser-host outbound memory lease', async () => {
|
||||
let callbacks: RemoteRuntimeSubscriptionCallbacks | undefined
|
||||
let callbacks: RemoteRuntimeTransportSubscriptionCallbacks | undefined
|
||||
let subscriptionOptions: Record<string, unknown> | undefined
|
||||
const registry = new BrowserNetworkTunnelOutboundMemoryBudgetRegistry()
|
||||
subscribeRemoteRuntimeRequestMock.mockImplementationOnce(
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeSubscription> => {
|
||||
callbacks = args[4] as RemoteRuntimeSubscriptionCallbacks
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
callbacks = args[4] as RemoteRuntimeTransportSubscriptionCallbacks
|
||||
subscriptionOptions = args[5] as Record<string, unknown>
|
||||
return { requestId: 'budgeted', close: vi.fn(), sendBinary: () => true }
|
||||
}
|
||||
@@ -423,7 +423,7 @@ function createRoute(
|
||||
type SubscriptionAttempt = {
|
||||
method: unknown
|
||||
params: unknown
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks
|
||||
callbacks: RemoteRuntimeTransportSubscriptionCallbacks
|
||||
options: unknown
|
||||
close: Mock<() => void>
|
||||
sent: Uint8Array<ArrayBufferLike>[]
|
||||
@@ -432,11 +432,11 @@ type SubscriptionAttempt = {
|
||||
function mockSubscriptionAttempts(): SubscriptionAttempt[] {
|
||||
const attempts: SubscriptionAttempt[] = []
|
||||
subscribeRemoteRuntimeRequestMock.mockImplementation(
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeSubscription> => {
|
||||
async (...args: unknown[]): Promise<RemoteRuntimeTransportSubscription> => {
|
||||
const attempt: SubscriptionAttempt = {
|
||||
method: args[1],
|
||||
params: args[2],
|
||||
callbacks: args[4] as RemoteRuntimeSubscriptionCallbacks,
|
||||
callbacks: args[4] as RemoteRuntimeTransportSubscriptionCallbacks,
|
||||
options: args[5],
|
||||
close: vi.fn(),
|
||||
sent: []
|
||||
|
||||
+8
-7
@@ -4,11 +4,12 @@ import {
|
||||
} from '../../../../shared/browser/client-hosting/browser-client-host-protocol'
|
||||
import type { BrowserNetworkExecutionHost } from '../../../../shared/browser/client-hosting/browser-network-execution-host'
|
||||
import type { PairedRuntimeConnection } from '../../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeSubscriptionOptions } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type {
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeSubscriptionOptions
|
||||
} from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { RemoteRuntimeClientError } from '../../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
import {
|
||||
BROWSER_CLIENT_HOST_RUNTIME_CAPABILITY,
|
||||
@@ -46,7 +47,7 @@ type PairedRuntimeBrowserNetworkTransportOptions = {
|
||||
export class PairedRuntimeBrowserNetworkTransport {
|
||||
private readonly options: PairedRuntimeBrowserNetworkTransportOptions
|
||||
private tunnelValue: BrowserNetworkTunnelClient | null = null
|
||||
private subscription: RemoteRuntimeSubscription | null = null
|
||||
private subscription: RemoteRuntimeTransportSubscription | null = null
|
||||
private startPromise: Promise<BrowserNetworkTunnelClient> | null = null
|
||||
private rejectReady: ((error: Error) => void) | null = null
|
||||
private closed = false
|
||||
@@ -98,7 +99,7 @@ export class PairedRuntimeBrowserNetworkTransport {
|
||||
this.rejectReady = rejectReady
|
||||
let readyTimeout: ReturnType<typeof setTimeout> | null = null
|
||||
try {
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
this.options.connection,
|
||||
'network.browserTunnel',
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
type KnownRuntimeEnvironment
|
||||
} from '../../shared/remote-runtime/host-catalog/runtime-environments'
|
||||
import type { PairedRuntimeConnection } from '../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { sendRemoteRuntimeRequest } from '../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { RemoteRuntimeClientError } from '../../shared/remote-runtime/remote-runtime-client-error'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../shared/electron-remote-runtime-client-capabilities'
|
||||
|
||||
@@ -62,14 +62,17 @@ async function confirmSavedPairing(
|
||||
}
|
||||
|
||||
async function probeSavedPairing(connection: PairedRuntimeConnection): Promise<void> {
|
||||
const response = await sendRemoteRuntimeRequest(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
'status.get',
|
||||
undefined,
|
||||
SAVED_PAIRING_PROBE_TIMEOUT_MS,
|
||||
undefined,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok && response.error.code === 'unauthorized') {
|
||||
throw new RemoteRuntimeClientError('unauthorized', response.error.message)
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
isDesktopBrowserBridgeMethod
|
||||
} from '../../../shared/desktop-browser-bridge-protocol'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import { resolveEnvironment } from '../../../shared/remote-runtime/host-store/runtime-environment-store'
|
||||
import {
|
||||
getOrcadSshDeployment,
|
||||
@@ -137,7 +138,7 @@ export function installDesktopBrowserBridge(options: {
|
||||
const connection = getPreferredPairedRuntimeConnection(
|
||||
resolveEnvironment(userDataPath, environmentId)
|
||||
)
|
||||
return subscribeRemoteRuntimeRequest(
|
||||
return subscribeRemoteRuntimeTransport(
|
||||
connection,
|
||||
'desktopBrowserBridge.attach',
|
||||
{ bridgeClientId: BRIDGE_CLIENT_ID },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PairedRuntimeConnection } from '../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import type { RuntimeCapability } from '../../../shared/protocol-version'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import type {
|
||||
RuntimeRequestPreparation,
|
||||
RuntimeOrchestrationEnvelope,
|
||||
@@ -22,20 +22,44 @@ export function sendRemoteRuntimeRequestAbortable(
|
||||
prepareRequest?: RuntimeRequestPreparation
|
||||
): Promise<RuntimeRpcResponse<unknown>> {
|
||||
if (signal || clientCapabilities.length > 0 || prepareRequest) {
|
||||
return sendRemoteRuntimeRequest(
|
||||
return sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
envelope,
|
||||
undefined,
|
||||
signal,
|
||||
clientCapabilities,
|
||||
...(prepareRequest ? ([prepareRequest] as const) : [])
|
||||
undefined,
|
||||
prepareRequest ? prepareRequest : undefined
|
||||
)
|
||||
}
|
||||
return envelope
|
||||
? sendRemoteRuntimeRequest(connection, method, params, timeoutMs, envelope)
|
||||
: sendRemoteRuntimeRequest(connection, method, params, timeoutMs)
|
||||
? sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
envelope,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
: sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
}
|
||||
|
||||
export function sendRemoteRuntimeConnectionRequestAbortable(
|
||||
|
||||
@@ -5,7 +5,7 @@ import { join } from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { encodePairingOffer } from '../../../shared/remote-runtime/pairing/pairing'
|
||||
|
||||
import type { RemoteRuntimeSubscription } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import {
|
||||
addEnvironmentFromPairingCode,
|
||||
removeEnvironment
|
||||
@@ -33,10 +33,13 @@ const { subscribeMock, supportsMock } = vi.hoisted(() => ({
|
||||
}))
|
||||
|
||||
vi.mock('electron', () => ({ BrowserWindow: { getAllWindows: () => [] } }))
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
subscribeRemoteRuntimeRequest: subscribeMock
|
||||
}))
|
||||
vi.mock(
|
||||
'../../../shared/remote-runtime/requests/remote-runtime-subscription-transport',
|
||||
async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
subscribeRemoteRuntimeTransport: subscribeMock
|
||||
})
|
||||
)
|
||||
vi.mock('./runtime-environment-shared-control-support', async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
supportsSharedControl: supportsMock
|
||||
@@ -102,7 +105,7 @@ async function subscribed(method: string) {
|
||||
subscribeMock.mockImplementation(
|
||||
async (_pairing, _method, _params, _timeoutMs, received: ResponseCallbacks) => {
|
||||
callbacks = received
|
||||
return { close: () => {} } satisfies Partial<RemoteRuntimeSubscription>
|
||||
return { close: () => {} } satisfies Partial<RemoteRuntimeTransportSubscription>
|
||||
}
|
||||
)
|
||||
const onEvent = vi.fn()
|
||||
|
||||
+34
-32
@@ -8,7 +8,7 @@ import {
|
||||
createSharedControlTestServer,
|
||||
closeSharedControlTestServers
|
||||
} from '../../../shared/remote-runtime/control/remote-runtime-shared-control-test-server'
|
||||
import type { sendRemoteRuntimeRequestWithStatusPreflight as StatusPreflight } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { encodePairingOffer } from '../../../shared/remote-runtime/pairing/pairing'
|
||||
import { REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY } from '../../../shared/protocol-version'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
|
||||
@@ -17,19 +17,14 @@ import {
|
||||
markEnvironmentUsed
|
||||
} from '../../../shared/remote-runtime/host-store/runtime-environment-store'
|
||||
|
||||
const {
|
||||
sendRemoteRuntimeRequestMock,
|
||||
sendRemoteRuntimeRequestWithStatusPreflightMock,
|
||||
sendRemoteRuntimeSharedControlRequestMock
|
||||
} = vi.hoisted(() => ({
|
||||
sendRemoteRuntimeRequestMock: vi.fn(),
|
||||
sendRemoteRuntimeRequestWithStatusPreflightMock: vi.fn(),
|
||||
sendRemoteRuntimeSharedControlRequestMock: vi.fn()
|
||||
}))
|
||||
const { sendRemoteRuntimeRequestOnSocketMock, sendRemoteRuntimeSharedControlRequestMock } =
|
||||
vi.hoisted(() => ({
|
||||
sendRemoteRuntimeRequestOnSocketMock: vi.fn(),
|
||||
sendRemoteRuntimeSharedControlRequestMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: sendRemoteRuntimeRequestMock,
|
||||
sendRemoteRuntimeRequestWithStatusPreflight: sendRemoteRuntimeRequestWithStatusPreflightMock
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: sendRemoteRuntimeRequestOnSocketMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-environment-request-connections', async () => {
|
||||
@@ -47,8 +42,8 @@ import { callRuntimeEnvironment } from './runtime-environment-transport-routing'
|
||||
import { resetSharedControlSupport } from './runtime-environment-shared-control-support'
|
||||
|
||||
const actual = await vi.importActual<{
|
||||
sendRemoteRuntimeRequestWithStatusPreflight: typeof StatusPreflight
|
||||
}>('../../../shared/remote-runtime/remote-runtime-client')
|
||||
sendRemoteRuntimeRequestOnSocket: typeof sendRemoteRuntimeRequestOnSocket
|
||||
}>('../../../shared/remote-runtime/requests/remote-runtime-request-socket')
|
||||
|
||||
describe('federated read RPC transport routing', () => {
|
||||
let userDataPath: string
|
||||
@@ -66,8 +61,7 @@ describe('federated read RPC transport routing', () => {
|
||||
})
|
||||
}).id
|
||||
resetSharedControlSupport()
|
||||
sendRemoteRuntimeRequestMock.mockReset()
|
||||
sendRemoteRuntimeRequestWithStatusPreflightMock.mockReset()
|
||||
sendRemoteRuntimeRequestOnSocketMock.mockReset()
|
||||
sendRemoteRuntimeSharedControlRequestMock.mockReset()
|
||||
})
|
||||
|
||||
@@ -89,7 +83,7 @@ describe('federated read RPC transport routing', () => {
|
||||
launchToken: 'launch-1'
|
||||
}
|
||||
}
|
||||
sendRemoteRuntimeRequestMock.mockResolvedValue({
|
||||
sendRemoteRuntimeRequestOnSocketMock.mockResolvedValue({
|
||||
id: 'status',
|
||||
ok: true,
|
||||
result: { capabilities: [REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY] },
|
||||
@@ -114,7 +108,9 @@ describe('federated read RPC transport routing', () => {
|
||||
)
|
||||
).resolves.toMatchObject({ ok: true })
|
||||
|
||||
expect(sendRemoteRuntimeRequestMock.mock.calls.map((call) => call[1])).toEqual(['status.get'])
|
||||
expect(sendRemoteRuntimeRequestOnSocketMock.mock.calls.map((call) => call[1])).toEqual([
|
||||
'status.get'
|
||||
])
|
||||
expect(sendRemoteRuntimeSharedControlRequestMock).toHaveBeenCalledWith(
|
||||
environmentId,
|
||||
expect.any(Object),
|
||||
@@ -132,7 +128,7 @@ describe('federated read RPC transport routing', () => {
|
||||
'routes enveloped %s over shared control with its authority intact',
|
||||
async (method, params) => {
|
||||
const envelope = { orchestrationContractVersion: 1, orchestrationRequestId: 'relay-1' }
|
||||
sendRemoteRuntimeRequestMock.mockResolvedValue({
|
||||
sendRemoteRuntimeRequestOnSocketMock.mockResolvedValue({
|
||||
id: 'status',
|
||||
ok: true,
|
||||
result: { capabilities: [REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY] },
|
||||
@@ -155,7 +151,9 @@ describe('federated read RPC transport routing', () => {
|
||||
envelope
|
||||
)
|
||||
|
||||
expect(sendRemoteRuntimeRequestMock.mock.calls.map((call) => call[1])).toEqual(['status.get'])
|
||||
expect(sendRemoteRuntimeRequestOnSocketMock.mock.calls.map((call) => call[1])).toEqual([
|
||||
'status.get'
|
||||
])
|
||||
expect(sendRemoteRuntimeSharedControlRequestMock).toHaveBeenCalledWith(
|
||||
environmentId,
|
||||
expect.any(Object),
|
||||
@@ -172,7 +170,7 @@ describe('federated read RPC transport routing', () => {
|
||||
['orchestration.federationImport', { dispatchId: 'dispatch-1', items: [] }]
|
||||
])('falls back to one-shot for %s when the host lacks shared control', async (method, params) => {
|
||||
const envelope = { orchestrationContractVersion: 1, orchestrationRequestId: 'relay-1' }
|
||||
sendRemoteRuntimeRequestMock.mockImplementation(async (_pairing, calledMethod) => ({
|
||||
sendRemoteRuntimeRequestOnSocketMock.mockImplementation(async (_pairing, calledMethod) => ({
|
||||
id: calledMethod,
|
||||
ok: true,
|
||||
result: calledMethod === 'status.get' ? { capabilities: [] } : { acknowledgedThrough: 4 },
|
||||
@@ -189,18 +187,21 @@ describe('federated read RPC transport routing', () => {
|
||||
envelope
|
||||
)
|
||||
|
||||
expect(sendRemoteRuntimeRequestMock.mock.calls.map((call) => call[1])).toEqual([
|
||||
expect(sendRemoteRuntimeRequestOnSocketMock.mock.calls.map((call) => call[1])).toEqual([
|
||||
'status.get',
|
||||
method
|
||||
])
|
||||
expect(sendRemoteRuntimeRequestMock).toHaveBeenLastCalledWith(
|
||||
expect(sendRemoteRuntimeRequestOnSocketMock).toHaveBeenLastCalledWith(
|
||||
expect.any(Object),
|
||||
method,
|
||||
params,
|
||||
15_000,
|
||||
envelope,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
expect(sendRemoteRuntimeSharedControlRequestMock).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -215,9 +216,7 @@ describe('federated read RPC transport routing', () => {
|
||||
pairingCode: encodePairingOffer(server.offer)
|
||||
})
|
||||
markEnvironmentUsed(userDataPath, paired.id, { runtimeId: 'runtime-proven' })
|
||||
sendRemoteRuntimeRequestWithStatusPreflightMock.mockImplementation(
|
||||
actual.sendRemoteRuntimeRequestWithStatusPreflight
|
||||
)
|
||||
sendRemoteRuntimeRequestOnSocketMock.mockImplementation(actual.sendRemoteRuntimeRequestOnSocket)
|
||||
await expect(
|
||||
callRuntimeEnvironment(
|
||||
userDataPath,
|
||||
@@ -237,7 +236,7 @@ describe('federated read RPC transport routing', () => {
|
||||
|
||||
it('falls back to one-shot with the envelope when shared control is unavailable', async () => {
|
||||
const envelope = { orchestrationContractVersion: 1 }
|
||||
sendRemoteRuntimeRequestMock.mockImplementation(async (_pairing, method) =>
|
||||
sendRemoteRuntimeRequestOnSocketMock.mockImplementation(async (_pairing, method) =>
|
||||
method === 'status.get'
|
||||
? {
|
||||
id: 'status',
|
||||
@@ -263,18 +262,21 @@ describe('federated read RPC transport routing', () => {
|
||||
envelope
|
||||
)
|
||||
|
||||
expect(sendRemoteRuntimeRequestMock.mock.calls.map((call) => call[1])).toEqual([
|
||||
expect(sendRemoteRuntimeRequestOnSocketMock.mock.calls.map((call) => call[1])).toEqual([
|
||||
'status.get',
|
||||
'orchestration.federationPull'
|
||||
])
|
||||
expect(sendRemoteRuntimeRequestMock).toHaveBeenLastCalledWith(
|
||||
expect(sendRemoteRuntimeRequestOnSocketMock).toHaveBeenLastCalledWith(
|
||||
expect.any(Object),
|
||||
'orchestration.federationPull',
|
||||
{ dispatchId: 'dispatch-1', afterSequence: 0, limit: 50 },
|
||||
15_000,
|
||||
envelope,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
expect(sendRemoteRuntimeSharedControlRequestMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
callRuntimeEnvironment,
|
||||
subscribeRuntimeEnvironment
|
||||
} from './runtime-environment-transport-routing'
|
||||
import type { RemoteRuntimeSubscription } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { isRuntimeSubscriptionReplayResponse } from '../../../shared/runtime-subscription-replay'
|
||||
import {
|
||||
isRuntimeEnvironmentManuallyDisconnected,
|
||||
@@ -209,7 +209,7 @@ function watchRuntimeEnvironmentChanges(
|
||||
callbacks: Parameters<MobileDesktopRelayHosts['watchChanges']>[2]
|
||||
): MobileDesktopRelayHostWatch {
|
||||
const controller = new AbortController()
|
||||
let subscription: RemoteRuntimeSubscription | null = null
|
||||
let subscription: RemoteRuntimeTransportSubscription | null = null
|
||||
const generation = getRuntimeEnvironmentTransportGeneration(environmentId)
|
||||
const current = (): boolean =>
|
||||
!controller.signal.aborted &&
|
||||
|
||||
+9
-3
@@ -12,8 +12,8 @@ import { PAIRING_TICKET_EXCHANGE_RUNTIME_CAPABILITY } from '../../../shared/remo
|
||||
import { verifyAndAddRuntimeEnvironmentFromPairingCode } from './runtime-environment-pairing-verification'
|
||||
|
||||
const { sendMock } = vi.hoisted(() => ({ sendMock: vi.fn() }))
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: sendMock
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: sendMock
|
||||
}))
|
||||
|
||||
const pairingCode = encodePairingOffer({
|
||||
@@ -64,7 +64,13 @@ describe('Add server with a pairing link', () => {
|
||||
expect.anything(),
|
||||
'pairing.exchangeTicket',
|
||||
{ deviceToken: saved.deviceToken },
|
||||
expect.any(Number)
|
||||
expect.any(Number),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
} else {
|
||||
expect(saved.deviceToken).toBe('link-token')
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from '../../../shared/remote-runtime/pairing/remote-pairing-verification'
|
||||
import { RemoteRuntimeClientError } from '../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
import { exchangeRemotePairingTicket } from '../../../shared/remote-runtime/pairing/remote-pairing-ticket-exchange'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import {
|
||||
getPreferredPairingOffer,
|
||||
@@ -58,14 +58,17 @@ async function verifyPairingCode(
|
||||
}
|
||||
}
|
||||
try {
|
||||
const response = await sendRemoteRuntimeRequest<RuntimeStatus>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<RuntimeStatus>(
|
||||
pairedRuntimeConnectionFromOffer(parsed.value.pairing),
|
||||
'status.get',
|
||||
undefined,
|
||||
15_000,
|
||||
undefined,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok) {
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PairedRuntimeConnection } from '../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { sendRemoteRuntimeRequestWithStatusPreflight } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { sendRemoteRuntimeRequestAbortable } from './runtime-environment-abortable-requests'
|
||||
import type { RuntimeRpcResponse } from '../../../shared/runtime-rpc-envelope'
|
||||
import type { KnownRuntimeEnvironment } from '../../../shared/remote-runtime/host-catalog/runtime-environments'
|
||||
@@ -16,22 +16,28 @@ async function sendOneShotRequestOnRuntime(
|
||||
): Promise<RuntimeRpcResponse<unknown> | null> {
|
||||
let otherRuntime = false
|
||||
try {
|
||||
return await sendRemoteRuntimeRequestWithStatusPreflight<unknown>(
|
||||
const requestMethod = call.method
|
||||
const requestParams = call.params
|
||||
const requestTimeoutMs = call.timeoutMs
|
||||
const orchestrationEnvelope = call.envelope
|
||||
const requestSignal = call.signal
|
||||
const requestPreparation = call.prepareRequest
|
||||
return await sendRemoteRuntimeRequestOnSocket<unknown>(
|
||||
connection,
|
||||
call.method,
|
||||
call.params,
|
||||
call.timeoutMs,
|
||||
requestMethod,
|
||||
requestParams,
|
||||
requestTimeoutMs,
|
||||
orchestrationEnvelope,
|
||||
(status) => {
|
||||
otherRuntime = !status.ok || status.result.runtimeId !== expectedRuntimeId
|
||||
if (otherRuntime) {
|
||||
throw new Error('Runtime changed before sending')
|
||||
}
|
||||
},
|
||||
call.envelope,
|
||||
requestSignal,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
call.signal,
|
||||
undefined,
|
||||
call.prepareRequest
|
||||
requestPreparation
|
||||
)
|
||||
} catch (error) {
|
||||
if (otherRuntime) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getRuntimeDesktopSurface } from '../../runtime/construction/runtime-desktop-surface'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY } from '../../../shared/protocol-version'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import {
|
||||
@@ -113,14 +113,17 @@ export function createRuntimeEnvironmentStatusOwner(
|
||||
getAcceptedRuntimeEnvironmentCapabilityOutcome(environment.id, connection, null)?.kind ===
|
||||
'supported'
|
||||
? transport.request(signal)
|
||||
: sendRemoteRuntimeRequest<RuntimeStatus>(
|
||||
: sendRemoteRuntimeRequestOnSocket<RuntimeStatus>(
|
||||
connection,
|
||||
'status.get',
|
||||
undefined,
|
||||
15_000,
|
||||
undefined,
|
||||
undefined,
|
||||
signal,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
))
|
||||
} catch (error) {
|
||||
response = runtimeHostStatusError(error)
|
||||
|
||||
@@ -20,8 +20,8 @@ const mocks = vi.hoisted(() => ({
|
||||
reconnect: vi.fn(),
|
||||
diagnostics: vi.fn()
|
||||
}))
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: mocks.request
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: mocks.request
|
||||
}))
|
||||
vi.mock('./runtime-environment-request-connections', async () => {
|
||||
const { withRuntimeStatusOwners } = await import('./runtime-environments-ipc-test-harness')
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import type * as SubscriptionSetup from '../../../shared/remote-runtime/host-catalog/runtime-environment-subscription-setup'
|
||||
import { ipcMain } from 'electron'
|
||||
import { abortWhenRendererGone } from '../renderer-lifetime-abort'
|
||||
import type { RemoteRuntimeSubscription } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { getRuntimeEnvironmentTransportGeneration } from './runtime-environment-transport-generation'
|
||||
import { subscribeRuntimeEnvironment } from './runtime-environment-transport-routing'
|
||||
|
||||
@@ -91,7 +91,7 @@ export function registerRuntimeEnvironmentSubscriptionHandlers(
|
||||
)
|
||||
: undefined
|
||||
let rendererGone = sender.isDestroyed()
|
||||
let subscription: RemoteRuntimeSubscription | null = null
|
||||
let subscription: RemoteRuntimeTransportSubscription | null = null
|
||||
const rendererLifetime = abortWhenRendererGone(sender)
|
||||
const disposeRendererLifetime = (): void => {
|
||||
associationObserver?.dispose()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import type { RuntimeRpcResponse } from '../../../shared/runtime-rpc-envelope'
|
||||
import type { RemoteRuntimeSubscription } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import type { IpcMainInvokeEvent, WebContents } from 'electron'
|
||||
import { isAbortSignalReason, throwIfSignalAborted } from '../../../shared/abort-signal-reason'
|
||||
import { RemoteRuntimeClientError } from '../../../shared/remote-runtime/remote-runtime-client-error'
|
||||
@@ -174,7 +174,7 @@ export function crewSubscriptionSetupFailure(
|
||||
}
|
||||
}
|
||||
|
||||
export type RetainedRemoteRuntimeSubscription = RemoteRuntimeSubscription & {
|
||||
export type RetainedRemoteRuntimeSubscription = RemoteRuntimeTransportSubscription & {
|
||||
setupController: AbortController
|
||||
environmentId: string
|
||||
ownerWebContentsId: number
|
||||
@@ -194,7 +194,7 @@ export function assertSubscriptionPairingCurrent(
|
||||
transportIsCurrent: () => boolean,
|
||||
crewResult: boolean,
|
||||
disposeRendererLifetime: () => void,
|
||||
subscription: RemoteRuntimeSubscription,
|
||||
subscription: RemoteRuntimeTransportSubscription,
|
||||
observeFailure: (failure: RuntimeEnvironmentSetupFailure) => void
|
||||
): void {
|
||||
let pairingIsCurrent = false
|
||||
@@ -246,7 +246,7 @@ export function assertSettledCrewSubscriptionCurrent(
|
||||
crewResult: boolean,
|
||||
assertCrewCurrent: () => void,
|
||||
disposeRendererLifetime: () => void,
|
||||
subscription: RemoteRuntimeSubscription
|
||||
subscription: RemoteRuntimeTransportSubscription
|
||||
): void {
|
||||
if (crewResult) {
|
||||
try {
|
||||
|
||||
@@ -13,10 +13,9 @@ import {
|
||||
import { resolveEnvironment } from '../../../shared/remote-runtime/host-store/runtime-environment-store'
|
||||
import { recordRuntimeEnvironmentUsage } from '../../../shared/remote-runtime/host-store/runtime-environment-usage-record'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { withRuntimeUnreachableHint } from './runtime-environment-unreachable-hint'
|
||||
import {
|
||||
isRuntimeEnvironmentCapabilityOutcomeCurrent,
|
||||
@@ -144,7 +143,7 @@ export async function subscribeSupportRoutedRuntimeEnvironment(args: {
|
||||
callbacks: SubscriptionCallbacks
|
||||
isCurrent: () => boolean
|
||||
signal?: AbortSignal
|
||||
}): Promise<RemoteRuntimeSubscription> {
|
||||
}): Promise<RemoteRuntimeTransportSubscription> {
|
||||
let markedUsed = false
|
||||
let supportOutcome: SupportRoute['outcome'] | null = null
|
||||
const callbacks = subscriptionCallbacks(args, () => {
|
||||
@@ -178,7 +177,7 @@ export async function subscribeSupportRoutedRuntimeEnvironment(args: {
|
||||
},
|
||||
unsupported: (route) => {
|
||||
supportOutcome = route.outcome
|
||||
return subscribeRemoteRuntimeRequest(
|
||||
return subscribeRemoteRuntimeTransport(
|
||||
route.connection,
|
||||
args.method,
|
||||
args.params,
|
||||
|
||||
@@ -17,10 +17,9 @@ import {
|
||||
} from './runtime-environment-managed-tunnel'
|
||||
import { recordRuntimeEnvironmentUsage } from '../../../shared/remote-runtime/host-store/runtime-environment-usage-record'
|
||||
import type * as Rpc from '../../../shared/runtime-rpc-envelope'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { withRuntimeUnreachableHint } from './runtime-environment-unreachable-hint'
|
||||
import { decodeRuntimeEnvironmentSubscriptionEvents } from './runtime-environment-subscription-events'
|
||||
import { enqueueRuntimeCall } from './runtime-environment-call-queue'
|
||||
@@ -192,7 +191,7 @@ export async function subscribeRuntimeEnvironment(
|
||||
assertCurrent: () => void
|
||||
observeFailure: (failure: RuntimeEnvironmentSetupFailure) => void
|
||||
}
|
||||
): Promise<RemoteRuntimeSubscription> {
|
||||
): Promise<RemoteRuntimeTransportSubscription> {
|
||||
const callbacks = {
|
||||
...rawCallbacks,
|
||||
onEvent: decodeRuntimeEnvironmentSubscriptionEvents(method, rawCallbacks.onEvent, isCurrent)
|
||||
@@ -259,7 +258,7 @@ export async function subscribeRuntimeEnvironment(
|
||||
signal
|
||||
})
|
||||
}
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
pairedConnection,
|
||||
method,
|
||||
params,
|
||||
|
||||
@@ -48,9 +48,11 @@ vi.mock('electron', () => ({
|
||||
}
|
||||
}))
|
||||
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: sendRemoteRuntimeRequestMock,
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: sendRemoteRuntimeRequestMock
|
||||
}))
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-environment-request-connections', async () => {
|
||||
|
||||
@@ -22,9 +22,11 @@ vi.mock('electron', () => ({
|
||||
}
|
||||
}))
|
||||
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: sendRemoteRuntimeRequestMock,
|
||||
subscribeRemoteRuntimeRequest: vi.fn()
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: sendRemoteRuntimeRequestMock
|
||||
}))
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-environment-request-connections', async () => {
|
||||
|
||||
+5
-3
@@ -47,9 +47,11 @@ vi.mock('electron', () => ({
|
||||
}
|
||||
}))
|
||||
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: sendRemoteRuntimeRequestMock,
|
||||
subscribeRemoteRuntimeRequest: subscribeRemoteRuntimeRequestMock
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: sendRemoteRuntimeRequestMock
|
||||
}))
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: subscribeRemoteRuntimeRequestMock
|
||||
}))
|
||||
|
||||
vi.mock('./runtime-environment-request-connections', async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import {
|
||||
getPreferredPairedRuntimeConnection,
|
||||
type KnownRuntimeEnvironment,
|
||||
@@ -271,11 +271,17 @@ export async function probeManagedOrcadTunnel(
|
||||
timeoutMs: number
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
await sendRemoteRuntimeRequest(
|
||||
await sendRemoteRuntimeRequestOnSocket(
|
||||
getPreferredPairedRuntimeConnection(environment),
|
||||
'status.get',
|
||||
undefined,
|
||||
timeoutMs
|
||||
timeoutMs,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
return true
|
||||
} catch {
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
} from '../activation/orcad-activation-record'
|
||||
|
||||
const mocks = vi.hoisted(() => ({ send: vi.fn(), ensure: vi.fn(), verify: vi.fn() }))
|
||||
vi.mock('../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequestWithStatusPreflight: mocks.send
|
||||
vi.mock('../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: mocks.send
|
||||
}))
|
||||
vi.mock('./orcad-managed-tunnel', () => ({
|
||||
ensureOrcadManagedTunnel: mocks.ensure
|
||||
@@ -44,10 +44,12 @@ const unverifiable = {
|
||||
const census = { liveSessions: 2, startedSinceActivation: 1, daemonProtocolVersion: 7 }
|
||||
|
||||
function answerWith(capabilities: string[], response: unknown) {
|
||||
mocks.send.mockImplementation(async (_pairing, _method, _params, _timeout, validate) => {
|
||||
validate({ ok: true, result: { capabilities } })
|
||||
return response
|
||||
})
|
||||
mocks.send.mockImplementation(
|
||||
async (_pairing, _method, _params, _timeout, _envelope, validate) => {
|
||||
validate({ ok: true, result: { capabilities } })
|
||||
return response
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
describe('managed orcad terminal census client', () => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type OrcadTerminalCensus,
|
||||
UNVERIFIABLE_ORCAD_TERMINAL_CENSUS
|
||||
} from '../../../shared/orcad-terminal-census'
|
||||
import { sendRemoteRuntimeRequestWithStatusPreflight } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import type { OrcadActivationRecord } from '../activation/orcad-activation-record'
|
||||
import { ensureOrcadManagedTunnel } from './orcad-managed-tunnel'
|
||||
import { verifyOrcadManagedServing } from './orcad-managed-serving-verify'
|
||||
@@ -63,7 +63,7 @@ export async function requestOrcadTerminalCensus(
|
||||
options: OrcadTerminalCensusRequestOptions = {}
|
||||
): Promise<OrcadTerminalCensus> {
|
||||
try {
|
||||
const response = await sendRemoteRuntimeRequestWithStatusPreflight<unknown>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<unknown>(
|
||||
connection,
|
||||
ORCAD_TERMINAL_CENSUS_METHOD,
|
||||
{
|
||||
@@ -77,6 +77,7 @@ export async function requestOrcadTerminalCensus(
|
||||
: { closeAdmissionForMs: options.closeAdmissionForMs })
|
||||
},
|
||||
timeoutMs,
|
||||
undefined,
|
||||
(status) => {
|
||||
if (
|
||||
!status.ok ||
|
||||
@@ -86,7 +87,9 @@ export async function requestOrcadTerminalCensus(
|
||||
}
|
||||
},
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
return response.ok
|
||||
? OrcadTerminalCensusSchema.parse(response.result)
|
||||
|
||||
+3
-2
@@ -14,12 +14,13 @@ import { PAIRING_OFFER_VERSION } from '../../../../shared/remote-runtime/pairing
|
||||
|
||||
const sendRequest = vi.hoisted(() => vi.fn())
|
||||
const extraCapabilities = vi.hoisted((): string[] => [])
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequestWithStatusPreflight: async (
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: async (
|
||||
pairing: unknown,
|
||||
method: string,
|
||||
params: unknown,
|
||||
_timeoutMs: number,
|
||||
_envelope: unknown,
|
||||
validate: (response: unknown) => void
|
||||
) => {
|
||||
validate({
|
||||
|
||||
+3
-2
@@ -9,12 +9,13 @@ import { computeOrcadMigrationManifestSha256 } from '../../../orcad/orcad-migrat
|
||||
|
||||
const sendRequest = vi.hoisted(() => vi.fn())
|
||||
const status = vi.hoisted((): { capabilities: string[] } => ({ capabilities: [] }))
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequestWithStatusPreflight: async (
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: async (
|
||||
pairing: unknown,
|
||||
method: string,
|
||||
params: unknown,
|
||||
_timeoutMs: number,
|
||||
_envelope: unknown,
|
||||
validate: (response: unknown) => void
|
||||
) => {
|
||||
validate({
|
||||
|
||||
@@ -8,16 +8,16 @@ import { PAIRING_OFFER_VERSION } from '../../../../shared/remote-runtime/pairing
|
||||
const sendRequest = vi.hoisted(() => vi.fn())
|
||||
const status = vi.hoisted(() => ({ capabilities: ['orcad.migration-catalog.v1'] }))
|
||||
// Run status preflight, then adapt to the existing single-call assertions.
|
||||
vi.mock('../../../../shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequestWithStatusPreflight: async (
|
||||
vi.mock('../../../../shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: async (
|
||||
pairing: unknown,
|
||||
method: string,
|
||||
params: unknown,
|
||||
timeoutMs: number,
|
||||
validate: (response: unknown) => void,
|
||||
envelope: unknown,
|
||||
capabilities: unknown,
|
||||
signal: unknown
|
||||
validate: (response: unknown) => void,
|
||||
signal: unknown,
|
||||
capabilities: unknown
|
||||
) => {
|
||||
validate({
|
||||
ok: true,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { pairedRuntimeConnectionFromOffer } from '../../../../shared/remote-runt
|
||||
import type { parsePairingCode } from '../../../../shared/remote-runtime/pairing/pairing'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import { ORCAD_MIGRATION_CATALOG_RUNTIME_CAPABILITY } from '../../../../shared/orcad-runtime-capabilities'
|
||||
import { sendRemoteRuntimeRequestWithStatusPreflight } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import type { RuntimeRpcResponse } from '../../../../shared/runtime-rpc-envelope'
|
||||
|
||||
/** Missing capability/method is definite refusal; other failures require catalog re-read because a lost reply may hide staged state. */
|
||||
@@ -32,11 +32,15 @@ export async function sendSupportedMigrationRequest(
|
||||
requiredSourceCapability: string | null = null,
|
||||
assertCapabilities: (capabilities: readonly string[]) => void = () => {}
|
||||
): Promise<RuntimeRpcResponse<unknown>> {
|
||||
const response = await sendRemoteRuntimeRequestWithStatusPreflight<unknown>(
|
||||
pairedRuntimeConnectionFromOffer(pairing),
|
||||
const pairingConnection = pairedRuntimeConnectionFromOffer(pairing)
|
||||
const requestTimeoutMs = options.timeoutMs ?? 15_000
|
||||
const requestSignal = options.signal
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<unknown>(
|
||||
pairingConnection,
|
||||
method,
|
||||
params,
|
||||
options.timeoutMs ?? 15_000,
|
||||
requestTimeoutMs,
|
||||
undefined,
|
||||
(status) => {
|
||||
if (!status.ok) {
|
||||
throw new Error(`orcad_migration_status_failed:${status.error.message}`)
|
||||
@@ -64,9 +68,10 @@ export async function sendSupportedMigrationRequest(
|
||||
}
|
||||
assertCapabilities(status.result.capabilities ?? [])
|
||||
},
|
||||
undefined,
|
||||
requestSignal,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
options.signal
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok && response.error.code === 'method_not_found') {
|
||||
throw new Error(ORCAD_MIGRATION_DESTINATION_UNSUPPORTED)
|
||||
|
||||
@@ -29,11 +29,9 @@ import {
|
||||
STRUCTURED_AGENT_SESSION_CLIENT_LAUNCH_MODE_CAPABILITY,
|
||||
STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY
|
||||
} from '../../shared/agent-session/agent-session-runtime-capabilities'
|
||||
import {
|
||||
sendRemoteRuntimeRequest,
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { claudeSessionIdForOrcaSession } from '../claude/structured/claude-structured-session-id'
|
||||
import { quotePosixShell } from '../../shared/shell/launch/shell-argument-quoting'
|
||||
import { materializeOrcadArtifact } from './orcad-artifact-materializer'
|
||||
@@ -141,14 +139,17 @@ async function call<T>(
|
||||
method: string,
|
||||
params: unknown
|
||||
): Promise<T> {
|
||||
const response = await sendRemoteRuntimeRequest<T>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<T>(
|
||||
pairing,
|
||||
method,
|
||||
params,
|
||||
20_000,
|
||||
undefined,
|
||||
undefined,
|
||||
capabilities
|
||||
undefined,
|
||||
capabilities,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok) {
|
||||
throw new Error(`${method}: ${JSON.stringify(response.error)}`)
|
||||
@@ -232,7 +233,7 @@ describe.skipIf(skip || process.platform === 'win32')('packaged plain-Node struc
|
||||
}
|
||||
writeFileSync(join(userData, 'orca-data.json'), JSON.stringify(state))
|
||||
const server = launch(slotDir, runtime, userData, home)
|
||||
let subscription: RemoteRuntimeSubscription | undefined
|
||||
let subscription: RemoteRuntimeTransportSubscription | undefined
|
||||
try {
|
||||
const pairing = await server.ready
|
||||
const group = await call<{ group: { id: string } }>(pairing, 'projectGroup.create', {
|
||||
@@ -259,7 +260,7 @@ describe.skipIf(skip || process.platform === 'win32')('packaged plain-Node struc
|
||||
const items = new Map<string, AgentJournalRenderItem>()
|
||||
const observedText: string[] = []
|
||||
const errors: Error[] = []
|
||||
subscription = await subscribeRemoteRuntimeRequest<AgentSessionSubscribeEvent>(
|
||||
subscription = await subscribeRemoteRuntimeTransport<AgentSessionSubscribeEvent>(
|
||||
pairing,
|
||||
'agentSession.subscribe',
|
||||
{ sessionId },
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
parsePairingCode
|
||||
} from '../../../shared/remote-runtime/pairing/pairing'
|
||||
import type { PairingOffer } from '../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import {
|
||||
ORCAD_DECLARE_CLIENT_METHOD,
|
||||
ORCAD_PEER_DESKTOPS_METHOD,
|
||||
@@ -89,11 +89,17 @@ describe(ORCAD_PEER_DESKTOPS_METHOD, () => {
|
||||
|
||||
/** A one-shot socket, as the desktop's Remove uses. */
|
||||
function oneShot<T>(offer: PairingOffer, method: string, params?: unknown) {
|
||||
return sendRemoteRuntimeRequest<T>(
|
||||
return sendRemoteRuntimeRequestOnSocket<T>(
|
||||
pairedRuntimeConnectionFromOffer(offer),
|
||||
method,
|
||||
params,
|
||||
5_000
|
||||
5_000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
getPreferredPairedRuntimeConnection,
|
||||
type KnownRuntimeEnvironment
|
||||
} from '../../../../shared/remote-runtime/host-catalog/runtime-environments'
|
||||
import { sendRemoteRuntimeRequest } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { verifyRemotePairingRuntimeStatus } from '../../../../shared/remote-runtime/pairing/remote-pairing-verification'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import type { RuntimeStatus } from '../../../../shared/runtime-session-contracts'
|
||||
@@ -32,14 +32,17 @@ export async function verifyRuntimePairingIdentity(
|
||||
signal?: AbortSignal
|
||||
) {
|
||||
signal?.throwIfAborted()
|
||||
const response = await sendRemoteRuntimeRequest<RuntimeStatus>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<RuntimeStatus>(
|
||||
connection,
|
||||
'status.get',
|
||||
undefined,
|
||||
15_000,
|
||||
undefined,
|
||||
undefined,
|
||||
signal,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
signal?.throwIfAborted()
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { DELEGATED_MOBILE_DEVICES_RUNTIME_CAPABILITY } from '../../../shared/del
|
||||
import { parsePairingCode } from '../../../shared/remote-runtime/pairing/pairing'
|
||||
import type { PairingOffer } from '../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import { RUNTIME_PROTOCOL_VERSION } from '../../../shared/protocol-version'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import {
|
||||
runtimeEnvironmentStatusFromSnapshot,
|
||||
type RuntimeHostStatusSnapshot
|
||||
@@ -158,11 +158,17 @@ describe('mobile relay hosts: phone -> desktop lists the servers it shows', () =
|
||||
return server ? { environmentId, fence: 'pairing-1', pairing: server.pairing } : null
|
||||
},
|
||||
call: (host, method, params) =>
|
||||
sendRemoteRuntimeRequest(
|
||||
sendRemoteRuntimeRequestOnSocket(
|
||||
pairedRuntimeConnectionFromOffer(servers.get(host.environmentId)!.pairing),
|
||||
method,
|
||||
params,
|
||||
5_000
|
||||
5_000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
),
|
||||
hostsBrowserPage: () => false,
|
||||
onEnvironmentRetired: () => () => {},
|
||||
|
||||
@@ -7,10 +7,9 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { z } from 'zod'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { parsePairingCode } from '../../shared/remote-runtime/pairing/pairing'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import {
|
||||
TerminalStreamOpcode,
|
||||
decodeTerminalStreamFrame,
|
||||
@@ -78,7 +77,7 @@ async function attach(
|
||||
const pairing = parsePairingCode(pairingUrl)!
|
||||
const responses: StreamResponse[] = []
|
||||
const frames: ReturnType<typeof decodeTerminalStreamFrame>[] = []
|
||||
const subscription: RemoteRuntimeSubscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription: RemoteRuntimeTransportSubscription = await subscribeRemoteRuntimeTransport(
|
||||
pairedRuntimeConnectionFromOffer(pairing),
|
||||
'terminal.multiplex',
|
||||
{},
|
||||
|
||||
@@ -5,7 +5,7 @@ import nacl from 'tweetnacl'
|
||||
import { WebSocketServer, type WebSocket } from 'ws'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { E2EEChannel } from './e2ee-channel'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { createRemoteRuntimeClientHandshake } from '../../../shared/remote-runtime/remote-runtime-client-framing'
|
||||
import {
|
||||
configureRemoteRuntimeE2EEV2HostLatch,
|
||||
@@ -123,14 +123,17 @@ async function startHost(kind: HostKind, keyPair = nacl.box.keyPair()): Promise<
|
||||
}
|
||||
|
||||
function ping(host: TestHost): Promise<unknown> {
|
||||
return sendRemoteRuntimeRequest(
|
||||
return sendRemoteRuntimeRequestOnSocket(
|
||||
host.connection,
|
||||
'status.ping',
|
||||
undefined,
|
||||
5_000,
|
||||
undefined,
|
||||
undefined,
|
||||
['test.capability.v1']
|
||||
undefined,
|
||||
['test.capability.v1'],
|
||||
undefined,
|
||||
undefined
|
||||
).then((response) => (response.ok ? response.result : response.error))
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
parsePairingCode
|
||||
} from '../../../../../shared/remote-runtime/pairing/pairing'
|
||||
import type { PairingOffer } from '../../../../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import { sendRemoteRuntimeRequest } from '../../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import {
|
||||
DELEGATED_MOBILE_DEVICE_SYNC_METHOD,
|
||||
type DelegatedMobileDeviceSyncResult
|
||||
@@ -93,11 +93,17 @@ describe('pairing.delegatedMobileDevice.sync', () => {
|
||||
desktop: PairingOffer,
|
||||
phones: { phoneKey: string; name: string }[]
|
||||
): Promise<DelegatedDevice[]> {
|
||||
const response = await sendRemoteRuntimeRequest<DelegatedMobileDeviceSyncResult>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<DelegatedMobileDeviceSyncResult>(
|
||||
pairedRuntimeConnectionFromOffer(desktop),
|
||||
DELEGATED_MOBILE_DEVICE_SYNC_METHOD,
|
||||
{ phones },
|
||||
5_000
|
||||
5_000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok) {
|
||||
throw new Error(`sync failed: ${response.error.code} ${response.error.message}`)
|
||||
|
||||
@@ -18,7 +18,8 @@ import { RemoteRuntimeRequestConnection } from '../../../../shared/remote-runtim
|
||||
|
||||
import { RemoteRuntimeSharedControlConnection } from '../../../../shared/remote-runtime/control/remote-runtime-shared-control-connection'
|
||||
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
|
||||
import type {
|
||||
RuntimeClientEvent,
|
||||
@@ -145,7 +146,7 @@ describe('remote runtime request connection integration', () => {
|
||||
const clientEvents: RuntimeClientEventStreamMessage[][] = [[], []]
|
||||
const subscriptions = await Promise.all(
|
||||
clientEvents.map((events) =>
|
||||
subscribeRemoteRuntimeRequest<RuntimeClientEventStreamMessage>(
|
||||
subscribeRemoteRuntimeTransport<RuntimeClientEventStreamMessage>(
|
||||
pairedRuntimeConnectionFromOffer(pairing),
|
||||
'runtime.clientEvents.subscribe',
|
||||
undefined,
|
||||
@@ -197,22 +198,23 @@ describe('remote runtime request connection integration', () => {
|
||||
).toEqual(['started', 'committed'])
|
||||
}
|
||||
const reconnectedEvents: RuntimeClientEventStreamMessage[] = []
|
||||
const reconnected = await subscribeRemoteRuntimeRequest<RuntimeClientEventStreamMessage>(
|
||||
pairedRuntimeConnectionFromOffer(pairing),
|
||||
'runtime.clientEvents.subscribe',
|
||||
undefined,
|
||||
REMOTE_RUNTIME_REQUEST_TIMEOUT_MS,
|
||||
{
|
||||
onResponse: (response) => {
|
||||
if (response.ok) {
|
||||
reconnectedEvents.push(response.result)
|
||||
const reconnected =
|
||||
await subscribeRemoteRuntimeTransport<RuntimeClientEventStreamMessage>(
|
||||
pairedRuntimeConnectionFromOffer(pairing),
|
||||
'runtime.clientEvents.subscribe',
|
||||
undefined,
|
||||
REMOTE_RUNTIME_REQUEST_TIMEOUT_MS,
|
||||
{
|
||||
onResponse: (response) => {
|
||||
if (response.ok) {
|
||||
reconnectedEvents.push(response.result)
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
throw error
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
try {
|
||||
await waitFor(() => reconnectedEvents.some((event) => event.type === 'ready'))
|
||||
expect(
|
||||
|
||||
@@ -11,7 +11,8 @@ import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { readRuntimeMetadata } from './runtime-metadata'
|
||||
import { OrcaRuntimeRpcServer } from './runtime-rpc'
|
||||
import { parsePairingCode } from '../../../../shared/remote-runtime/pairing/pairing'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import {
|
||||
TerminalStreamOpcode,
|
||||
decodeTerminalStreamFrame,
|
||||
@@ -350,7 +351,7 @@ describe('OrcaRuntimeRpcServer', () => {
|
||||
const responses: Record<string, unknown>[] = []
|
||||
const binaryFrames: Uint8Array<ArrayBufferLike>[] = []
|
||||
const onError = vi.fn()
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
pairedRuntimeConnectionFromOffer(pairing),
|
||||
'terminal.multiplex',
|
||||
{},
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { WslHostStatus } from '../../../../shared/wsl-host-types'
|
||||
import { hasOrcadTemplate } from '../../../orcad/orcad-artifact-materializer'
|
||||
import { createWslHostConnector } from '../../host-lifecycle/wsl-host-connector'
|
||||
import type { WslHostConnector } from '../../host-lifecycle/wsl-host-connector-contract'
|
||||
import { WslHostService } from '../../host-lifecycle/wsl-host-service'
|
||||
|
||||
export type LaneWslHost = {
|
||||
service: WslHostService
|
||||
connector: WslHostConnector
|
||||
/** Everything the service published, as the window's status listener receives it. */
|
||||
published: WslHostStatus[]
|
||||
}
|
||||
|
||||
/** The production service and connector, wired as wsl-host-handlers wires them minus Electron. */
|
||||
export function createLaneWslHost(userDataPath: string): LaneWslHost {
|
||||
const published: WslHostStatus[] = []
|
||||
const service = new WslHostService({
|
||||
userDataPath: () => userDataPath,
|
||||
isEnabled: () => true,
|
||||
hasServerFiles: hasOrcadTemplate,
|
||||
publish: (status) => {
|
||||
published.push(status)
|
||||
console.log(`[lane] host ${JSON.stringify(status)}`)
|
||||
},
|
||||
pairingChanged: () => {},
|
||||
ready: () => {},
|
||||
removed: () => {}
|
||||
})
|
||||
const refuse = (): Promise<never> => Promise.reject(new Error('The lane never removes a host'))
|
||||
const connector = createWslHostConnector({
|
||||
userDataPath,
|
||||
onChange: service.handleConnectionChange.bind(service),
|
||||
hasUserVisibleWork: (distro) => service.hasUserVisibleWork(distro),
|
||||
isKnownDistro: (distro) => service.isKnownDistro(distro),
|
||||
runtime: { call: refuse, census: refuse }
|
||||
})
|
||||
service.attach(connector)
|
||||
return { service, connector, published }
|
||||
}
|
||||
@@ -12,19 +12,20 @@ import type {
|
||||
} from '../../../../shared/agent-session/agent-session-wire'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import type { PairedRuntimeConnection } from '../../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import { latestNativeChatOrcaStopCut } from '../../../../shared/native-chat/native-chat-orca-stop-cut'
|
||||
import { quotePosixShell } from '../../../../shared/shell/launch/shell-argument-quoting'
|
||||
import type { WslHostStatus } from '../../../../shared/wsl-host-types'
|
||||
import { claudeSessionIdForOrcaSession } from '../../../claude/structured/claude-structured-session-id'
|
||||
import { hasOrcadTemplate } from '../../../orcad/orcad-artifact-materializer'
|
||||
import '../../../orcad/orcad-artifact-materializer'
|
||||
import { packagedClaudeChatScenario } from '../../../orcad/orcad-structured-chat-scenario'
|
||||
import { wslDistroHolderKey } from '../../discovery/wsl-distro-holder-record'
|
||||
import { wslHostStoppedMessage } from '../../../../shared/wsl-host-stopped-message'
|
||||
import { wslHostConnectOptions } from '../../host-lifecycle/wsl-host-connect-request'
|
||||
import { createWslHostConnector } from '../../host-lifecycle/wsl-host-connector'
|
||||
import type { WslHostConnector } from '../../host-lifecycle/wsl-host-connector-contract'
|
||||
import { WslHostService } from '../../host-lifecycle/wsl-host-service'
|
||||
import '../../host-lifecycle/wsl-host-connector'
|
||||
import '../../host-lifecycle/wsl-host-service'
|
||||
import type { LaneWslHost } from './wsl-orcad-lane-host-fixture'
|
||||
import { assistantText } from './wsl-orcad-chat-assistant-text'
|
||||
import { envelope } from './wsl-orcad-chat-envelope'
|
||||
import {
|
||||
@@ -39,40 +40,6 @@ import {
|
||||
const STAYS_STOPPED_MS = 30_000
|
||||
const POLL_MS = 5_000
|
||||
|
||||
export type LaneWslHost = {
|
||||
service: WslHostService
|
||||
connector: WslHostConnector
|
||||
/** Everything the service published, as the window's status listener receives it. */
|
||||
published: WslHostStatus[]
|
||||
}
|
||||
|
||||
/** The production service and connector, wired as wsl-host-handlers wires them minus Electron. */
|
||||
export function createLaneWslHost(userDataPath: string): LaneWslHost {
|
||||
const published: WslHostStatus[] = []
|
||||
const service = new WslHostService({
|
||||
userDataPath: () => userDataPath,
|
||||
isEnabled: () => true,
|
||||
hasServerFiles: hasOrcadTemplate,
|
||||
publish: (status) => {
|
||||
published.push(status)
|
||||
console.log(`[lane] host ${JSON.stringify(status)}`)
|
||||
},
|
||||
pairingChanged: () => {},
|
||||
ready: () => {},
|
||||
removed: () => {}
|
||||
})
|
||||
const refuse = (): Promise<never> => Promise.reject(new Error('The lane never removes a host'))
|
||||
const connector = createWslHostConnector({
|
||||
userDataPath,
|
||||
onChange: service.handleConnectionChange.bind(service),
|
||||
hasUserVisibleWork: (distro) => service.hasUserVisibleWork(distro),
|
||||
isKnownDistro: (distro) => service.isKnownDistro(distro),
|
||||
runtime: { call: refuse, census: refuse }
|
||||
})
|
||||
service.attach(connector)
|
||||
return { service, connector, published }
|
||||
}
|
||||
|
||||
export type MidTurnStopLane = Pick<WslChatHost, 'rpc' | 'guest'> & {
|
||||
/** The host connection's pairing, read at each call: Start replaces the connection. */
|
||||
pairing(): PairedRuntimeConnection
|
||||
@@ -101,7 +68,7 @@ type Watch = { close(): void }
|
||||
async function watchAssistantText(lane: MidTurnStopLane, sessionId: string, opened: Watch[]) {
|
||||
const text: string[] = []
|
||||
const errors: Error[] = []
|
||||
const subscription = await subscribeRemoteRuntimeRequest<AgentSessionSubscribeEvent>(
|
||||
const subscription = await subscribeRemoteRuntimeTransport<AgentSessionSubscribeEvent>(
|
||||
lane.pairing(),
|
||||
'agentSession.subscribe',
|
||||
{ sessionId },
|
||||
|
||||
@@ -4,7 +4,8 @@ import { z } from 'zod'
|
||||
import type { AgentJournalRenderItem } from '../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentSessionSubscribeEvent } from '../../../../shared/agent-session/agent-session-wire'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import { quotePosixShell } from '../../../../shared/shell/launch/shell-argument-quoting'
|
||||
import {
|
||||
waitForProviderReport,
|
||||
@@ -80,7 +81,7 @@ export async function exerciseScriptedProviderChat(
|
||||
const rows = new Map<string, AgentJournalRenderItem>()
|
||||
const text: string[] = []
|
||||
const errors: Error[] = []
|
||||
const subscription = await subscribeRemoteRuntimeRequest<AgentSessionSubscribeEvent>(
|
||||
const subscription = await subscribeRemoteRuntimeTransport<AgentSessionSubscribeEvent>(
|
||||
lane.pairing(),
|
||||
'agentSession.subscribe',
|
||||
{ sessionId },
|
||||
|
||||
@@ -9,10 +9,9 @@ import type {
|
||||
} from '../../../../shared/agent-session/agent-session-wire'
|
||||
import type { PairedRuntimeConnection } from '../../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../../../../shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import { claudeSessionIdForOrcaSession } from '../../../claude/structured/claude-structured-session-id'
|
||||
import { packagedClaudeChatScenario } from '../../../orcad/orcad-structured-chat-scenario'
|
||||
import { quotePosixShell } from '../../../../shared/shell/launch/shell-argument-quoting'
|
||||
@@ -69,9 +68,9 @@ async function exerciseChat(
|
||||
const text: string[] = []
|
||||
const errors: Error[] = []
|
||||
let dropping = false
|
||||
let subscription: RemoteRuntimeSubscription | undefined
|
||||
let subscription: RemoteRuntimeTransportSubscription | undefined
|
||||
const subscribe = async () =>
|
||||
subscribeRemoteRuntimeRequest<AgentSessionSubscribeEvent>(
|
||||
subscribeRemoteRuntimeTransport<AgentSessionSubscribeEvent>(
|
||||
lane.pairing(),
|
||||
'agentSession.subscribe',
|
||||
{ sessionId },
|
||||
|
||||
@@ -17,7 +17,7 @@ import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/ele
|
||||
import { ORCAD_E2E_IDLE_TIMEOUT_ENV } from '../../../shared/orcad-idle-exit'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { parsePairingCode } from '../../../shared/remote-runtime/pairing/pairing'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { RemoteRuntimeSharedControlConnection } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-connection'
|
||||
import { execCommand } from '../../ssh/remote-exec/remote-exec-command'
|
||||
import { readConfirmedRunningWslDistros } from '../discovery/wsl-background-distro-gate'
|
||||
@@ -184,7 +184,7 @@ function pairedConnectionOf(connection: WslOrcadConnection) {
|
||||
|
||||
function resultOf<T>(
|
||||
method: string,
|
||||
response: Awaited<ReturnType<typeof sendRemoteRuntimeRequest<T>>>
|
||||
response: Awaited<ReturnType<typeof sendRemoteRuntimeRequestOnSocket<T>>>
|
||||
): T {
|
||||
if (!response.ok) {
|
||||
throw new Error(`${method} failed: ${response.error.code}: ${response.error.message}`)
|
||||
@@ -193,14 +193,17 @@ function resultOf<T>(
|
||||
}
|
||||
|
||||
async function rpc<T>(connection: WslOrcadConnection, method: string, params?: unknown) {
|
||||
const response = await sendRemoteRuntimeRequest<T>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<T>(
|
||||
pairedConnectionOf(connection),
|
||||
method,
|
||||
params,
|
||||
30_000,
|
||||
undefined,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
return resultOf(method, response)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { setAppEnvironment } from '../../../shared/app-environment'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { parsePairingCode } from '../../../shared/remote-runtime/pairing/pairing'
|
||||
import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command'
|
||||
import {
|
||||
ORCAD_LAUNCHER_FILENAME,
|
||||
@@ -30,10 +30,8 @@ import { listenWslOrcadStdioBridge } from './wsl-orcad-stdio-bridge'
|
||||
import { createWslDistroHolder } from '../discovery/wsl-distro-holder'
|
||||
import type { WslDistroHolder } from '../discovery/wsl-distro-holder-types'
|
||||
import { proveWslStructuredChat } from './__tests__/wsl-orcad-structured-chat-contract'
|
||||
import {
|
||||
createLaneWslHost,
|
||||
proveWslMidTurnStopAndContinue
|
||||
} from './__tests__/wsl-orcad-midturn-stop-lane'
|
||||
import { proveWslMidTurnStopAndContinue } from './__tests__/wsl-orcad-midturn-stop-lane'
|
||||
import { createLaneWslHost } from './__tests__/wsl-orcad-lane-host-fixture'
|
||||
import {
|
||||
reinstallWslGuestCli,
|
||||
WSL_CHAT_GUEST_BIN
|
||||
@@ -211,14 +209,17 @@ function pairedConnection(connection: WslOrcadConnection) {
|
||||
}
|
||||
|
||||
async function rpc<T>(connection: WslOrcadConnection, method: string, params?: unknown) {
|
||||
const response = await sendRemoteRuntimeRequest<T>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<T>(
|
||||
pairedConnection(connection),
|
||||
method,
|
||||
params,
|
||||
30_000,
|
||||
undefined,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok) {
|
||||
throw new Error(`${method} failed: ${response.error.code}: ${response.error.message}`)
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
EXCHANGE_PAIRING_TICKET_METHOD,
|
||||
PAIRING_TICKET_EXCHANGE_RUNTIME_CAPABILITY
|
||||
} from './ticket-exchange-capability'
|
||||
import { sendRemoteRuntimeRequest } from '../remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../requests/remote-runtime-request-socket'
|
||||
|
||||
const EXCHANGE_TIMEOUT_MS = 10_000
|
||||
|
||||
@@ -24,20 +24,26 @@ export async function exchangeRemotePairingTicket(args: {
|
||||
pairingCode: string
|
||||
offer: PairingOffer
|
||||
hostCapabilities: readonly string[] | undefined
|
||||
send?: typeof sendRemoteRuntimeRequest
|
||||
send?: typeof sendRemoteRuntimeRequestOnSocket
|
||||
timeoutMs?: number
|
||||
}): Promise<string> {
|
||||
if (!args.hostCapabilities?.includes(PAIRING_TICKET_EXCHANGE_RUNTIME_CAPABILITY)) {
|
||||
return args.pairingCode
|
||||
}
|
||||
const deviceToken = randomHexToken()
|
||||
const send = args.send ?? sendRemoteRuntimeRequest
|
||||
const send = args.send ?? sendRemoteRuntimeRequestOnSocket
|
||||
try {
|
||||
const response = await send(
|
||||
pairedRuntimeConnectionFromOffer(args.offer),
|
||||
EXCHANGE_PAIRING_TICKET_METHOD,
|
||||
{ deviceToken },
|
||||
args.timeoutMs ?? EXCHANGE_TIMEOUT_MS
|
||||
args.timeoutMs ?? EXCHANGE_TIMEOUT_MS,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok) {
|
||||
return args.pairingCode
|
||||
@@ -50,7 +56,13 @@ export async function exchangeRemotePairingTicket(args: {
|
||||
pairedRuntimeConnectionFromOffer(exchanged),
|
||||
'status.get',
|
||||
undefined,
|
||||
args.timeoutMs ?? EXCHANGE_TIMEOUT_MS
|
||||
args.timeoutMs ?? EXCHANGE_TIMEOUT_MS,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
).catch(() => undefined)
|
||||
return encodePairingOffer(exchanged)
|
||||
} catch {
|
||||
|
||||
@@ -15,7 +15,8 @@ import {
|
||||
publicKeyFromBase64,
|
||||
publicKeyToBase64
|
||||
} from './e2ee/node/e2ee-crypto'
|
||||
import { sendRemoteRuntimeRequest, subscribeRemoteRuntimeRequest } from './remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from './requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from './requests/remote-runtime-subscription-transport'
|
||||
import { remoteRuntimeClientCapabilities } from './remote-runtime-client-capabilities'
|
||||
import { BROWSER_NETWORK_TUNNEL_RUNTIME_CAPABILITY } from '../browser-runtime-capabilities'
|
||||
|
||||
@@ -41,7 +42,7 @@ describe('subscribeRemoteRuntimeRequest', () => {
|
||||
const onResponse = vi.fn()
|
||||
const onError = vi.fn()
|
||||
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
server.pairing,
|
||||
'terminal.subscribe',
|
||||
{ terminal: 't1' },
|
||||
@@ -73,7 +74,7 @@ describe('subscribeRemoteRuntimeRequest', () => {
|
||||
const server = await createSubscriptionServer()
|
||||
const onResponse = vi.fn()
|
||||
const onError = vi.fn()
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
server.pairing,
|
||||
'network.browserTunnel',
|
||||
{},
|
||||
@@ -107,7 +108,7 @@ describe('subscribeRemoteRuntimeRequest', () => {
|
||||
const onError = vi.fn()
|
||||
const onClose = vi.fn()
|
||||
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
server.pairing,
|
||||
'terminal.subscribe',
|
||||
{ terminal: 't1' },
|
||||
@@ -141,7 +142,18 @@ describe('sendRemoteRuntimeRequest', () => {
|
||||
const server = await createInvalidHandshakeServer()
|
||||
|
||||
await expect(
|
||||
sendRemoteRuntimeRequest(server.pairing, 'status.get', {}, 1000)
|
||||
sendRemoteRuntimeRequestOnSocket(
|
||||
server.pairing,
|
||||
'status.get',
|
||||
{},
|
||||
1000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
).rejects.toMatchObject({
|
||||
code: 'invalid_runtime_response',
|
||||
pairingStage: 'host-identity'
|
||||
@@ -152,7 +164,18 @@ describe('sendRemoteRuntimeRequest', () => {
|
||||
const server = await createOneShotServer({ sendUndecryptableResponse: true })
|
||||
|
||||
await expect(
|
||||
sendRemoteRuntimeRequest(server.pairing, 'status.get', {}, 1000)
|
||||
sendRemoteRuntimeRequestOnSocket(
|
||||
server.pairing,
|
||||
'status.get',
|
||||
{},
|
||||
1000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
).rejects.toMatchObject({
|
||||
code: 'invalid_runtime_response',
|
||||
pairingStage: 'runtime'
|
||||
@@ -168,13 +191,17 @@ describe('sendRemoteRuntimeRequest', () => {
|
||||
const closeSpy = vi.spyOn(WebSocketClient.prototype, 'close')
|
||||
const controller = new AbortController()
|
||||
try {
|
||||
const request = sendRemoteRuntimeRequest(
|
||||
const request = sendRemoteRuntimeRequestOnSocket(
|
||||
server.pairing,
|
||||
'skills.install',
|
||||
{},
|
||||
60_000,
|
||||
undefined,
|
||||
controller.signal
|
||||
undefined,
|
||||
controller.signal,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
await observed
|
||||
|
||||
@@ -194,7 +221,7 @@ describe('sendRemoteRuntimeRequest', () => {
|
||||
}
|
||||
})
|
||||
|
||||
await sendRemoteRuntimeRequest(
|
||||
await sendRemoteRuntimeRequestOnSocket(
|
||||
server.pairing,
|
||||
'orchestration.federationControl',
|
||||
{ dispatch: 'ctx_1' },
|
||||
@@ -203,7 +230,12 @@ describe('sendRemoteRuntimeRequest', () => {
|
||||
orchestrationCapability: 'capability',
|
||||
orchestrationContractVersion: 1,
|
||||
orchestrationRequestId: 'mutation_1'
|
||||
}
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
|
||||
expect(receivedRequest).toMatchObject({
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
import type { PairedRuntimeConnection } from './pairing/paired-runtime-connection'
|
||||
import type { RuntimeCapability } from '../protocol-version'
|
||||
import type { RemoteRuntimeClientError } from './remote-runtime-client-error'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from './requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from './requests/remote-runtime-subscription-transport'
|
||||
import type {
|
||||
RemoteRuntimeSubscriptionOptions,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from './requests/remote-runtime-subscription-contract'
|
||||
import type {
|
||||
RuntimeRequestPreparation,
|
||||
RuntimeRequestSelection,
|
||||
RuntimeOrchestrationEnvelope,
|
||||
RuntimeRpcResponse
|
||||
} from '../runtime-rpc-envelope'
|
||||
import type { RuntimeStatus } from '../runtime-session-contracts'
|
||||
|
||||
export type RemoteRuntimeSubscription = {
|
||||
requestId: string
|
||||
close: () => void
|
||||
sendBinary: (bytes: Uint8Array<ArrayBufferLike>) => boolean
|
||||
sendRequest?: (
|
||||
method: string,
|
||||
params: unknown,
|
||||
timeoutMs: number
|
||||
) => Promise<RuntimeRpcResponse<unknown>>
|
||||
}
|
||||
|
||||
export type RemoteRuntimeSubscriptionCallbacks<TResult = unknown> = {
|
||||
onResponse: (response: RuntimeRpcResponse<TResult>) => void
|
||||
onBinary?: (bytes: Uint8Array<ArrayBufferLike>) => void
|
||||
onError: (error: RemoteRuntimeClientError) => void
|
||||
onClose?: () => void
|
||||
}
|
||||
|
||||
export function sendRemoteRuntimeRequest<TResult>(
|
||||
connection: PairedRuntimeConnection,
|
||||
method: string,
|
||||
params: unknown,
|
||||
timeoutMs: number,
|
||||
envelope?: RuntimeOrchestrationEnvelope,
|
||||
signal?: AbortSignal,
|
||||
clientCapabilities: readonly RuntimeCapability[] = [],
|
||||
prepareRequest?: RuntimeRequestPreparation
|
||||
): Promise<RuntimeRpcResponse<TResult>> {
|
||||
return sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
envelope,
|
||||
undefined,
|
||||
signal,
|
||||
clientCapabilities,
|
||||
undefined,
|
||||
prepareRequest
|
||||
)
|
||||
}
|
||||
|
||||
export function sendRemoteRuntimeRequestWithStatusPreflight<TResult>(
|
||||
connection: PairedRuntimeConnection,
|
||||
method: string,
|
||||
params: unknown,
|
||||
timeoutMs: number,
|
||||
validateStatus: (response: RuntimeRpcResponse<RuntimeStatus>) => void,
|
||||
envelope?: RuntimeOrchestrationEnvelope,
|
||||
clientCapabilities: readonly RuntimeCapability[] = [],
|
||||
signal?: AbortSignal,
|
||||
requestSelection?: RuntimeRequestSelection,
|
||||
prepareRequest?: RuntimeRequestPreparation
|
||||
): Promise<RuntimeRpcResponse<TResult>> {
|
||||
return sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
envelope,
|
||||
validateStatus,
|
||||
signal,
|
||||
clientCapabilities,
|
||||
requestSelection,
|
||||
prepareRequest
|
||||
)
|
||||
}
|
||||
|
||||
export function subscribeRemoteRuntimeRequest<TResult>(
|
||||
connection: PairedRuntimeConnection,
|
||||
method: string,
|
||||
params: unknown,
|
||||
timeoutMs: number,
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks<TResult>,
|
||||
options?: RemoteRuntimeSubscriptionOptions
|
||||
): Promise<RemoteRuntimeSubscription> {
|
||||
return subscribeRemoteRuntimeTransport(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
callbacks as RemoteRuntimeTransportSubscriptionCallbacks<TResult>,
|
||||
options
|
||||
)
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { WebSocketServer } from 'ws'
|
||||
import { generateKeyPair, publicKeyToBase64 } from './e2ee/node/e2ee-crypto'
|
||||
import { encodePairingOffer, parsePairingCode } from './pairing/pairing'
|
||||
import { sendRemoteRuntimeRequest } from './remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from './requests/remote-runtime-request-socket'
|
||||
import { REMOTE_RUNTIME_MAX_PROCESS_PENDING_REQUESTS } from './remote-runtime-memory-limits'
|
||||
import { getRemoteRuntimeRequestAdmissionEvidence } from './requests/remote-runtime-prepared-request-admission'
|
||||
import { RemoteRuntimeRequestConnection } from './requests/remote-runtime-request-connection'
|
||||
@@ -60,7 +60,18 @@ describe('remote runtime outbound admission', () => {
|
||||
code: 'remote_runtime_busy'
|
||||
})
|
||||
await expect(
|
||||
sendRemoteRuntimeRequest(pairing, 'status.one-shot-overflow', undefined, 60_000)
|
||||
sendRemoteRuntimeRequestOnSocket(
|
||||
pairing,
|
||||
'status.one-shot-overflow',
|
||||
undefined,
|
||||
60_000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
).rejects.toMatchObject({ code: 'remote_runtime_busy' })
|
||||
expect(getRemoteRuntimeRequestAdmissionEvidence().pendingRequestCount).toBe(
|
||||
REMOTE_RUNTIME_MAX_PROCESS_PENDING_REQUESTS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { federationRelayPrefix } from '../../../main/runtime/orchestration/federation/relay/federation-relay-prefix'
|
||||
import * as memoryLimits from '../remote-runtime-memory-limits'
|
||||
import { sendRemoteRuntimeRequest } from '../remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../requests/remote-runtime-request-socket'
|
||||
import {
|
||||
pairedRuntimeConnectionFromOffer,
|
||||
type PairedRuntimeConnection
|
||||
@@ -75,14 +75,16 @@ describe('RemoteRuntimeRequestConnection', () => {
|
||||
}))
|
||||
const params = { dispatchId: 'dispatch_remote', items }
|
||||
let selectedThrough = 0
|
||||
const response = await sendRemoteRuntimeRequest(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket(
|
||||
server.pairing,
|
||||
'orchestration.federationImport',
|
||||
params,
|
||||
5000,
|
||||
{ orchestrationRequestId: 'before' },
|
||||
undefined,
|
||||
undefined,
|
||||
[],
|
||||
undefined,
|
||||
federationRelayPrefix('dispatch_remote', items, (last) => {
|
||||
selectedThrough = last
|
||||
})
|
||||
|
||||
@@ -14,10 +14,9 @@ import {
|
||||
publicKeyToBase64
|
||||
} from '../e2ee/node/e2ee-crypto'
|
||||
import { encodePairingOffer, parsePairingCode } from '../pairing/pairing'
|
||||
import {
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription
|
||||
} from '../remote-runtime-client'
|
||||
import '../requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../requests/remote-runtime-subscription-transport'
|
||||
import type { RemoteRuntimeTransportSubscription } from '../requests/remote-runtime-subscription-contract'
|
||||
|
||||
const servers: WebSocketServer[] = []
|
||||
|
||||
@@ -69,7 +68,7 @@ describe('remote runtime subscription JSON requests', () => {
|
||||
})
|
||||
})
|
||||
|
||||
function requireSender(subscription: RemoteRuntimeSubscription) {
|
||||
function requireSender(subscription: RemoteRuntimeTransportSubscription) {
|
||||
if (!subscription.sendRequest) {
|
||||
throw new Error('subscription JSON request sender unavailable')
|
||||
}
|
||||
@@ -82,10 +81,10 @@ async function subscribe(
|
||||
onResponse?: (response: unknown) => void
|
||||
onError?: (error: unknown) => void
|
||||
onClose?: () => void
|
||||
options?: Parameters<typeof subscribeRemoteRuntimeRequest>[5]
|
||||
options?: Parameters<typeof subscribeRemoteRuntimeTransport>[5]
|
||||
} = {}
|
||||
): Promise<RemoteRuntimeSubscription> {
|
||||
return subscribeRemoteRuntimeRequest(
|
||||
): Promise<RemoteRuntimeTransportSubscription> {
|
||||
return subscribeRemoteRuntimeTransport(
|
||||
pairing,
|
||||
'browser.clientHost.attach',
|
||||
{},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { sendRemoteRuntimeRequest } from '../../../src/shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../src/shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { parsePairingCode } from '../../../src/shared/remote-runtime/pairing/pairing'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../src/shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../src/shared/electron-remote-runtime-client-capabilities'
|
||||
@@ -159,26 +159,32 @@ it('pairs to host-owned options and persists only a genuine pick on that host',
|
||||
const connection = pairedRuntimeConnectionFromOffer(parsed)
|
||||
pairedPort.call.mockImplementation(({ environmentId, method, params }) => {
|
||||
expect(environmentId).toBe('paired-host-B')
|
||||
return sendRemoteRuntimeRequest(
|
||||
return sendRemoteRuntimeRequestOnSocket(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
5_000,
|
||||
undefined,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
})
|
||||
const client = {
|
||||
async call<T>(method: string, params?: unknown) {
|
||||
const response = await sendRemoteRuntimeRequest<T>(
|
||||
const response = await sendRemoteRuntimeRequestOnSocket<T>(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
5_000,
|
||||
undefined,
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
||||
undefined,
|
||||
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!response.ok) {
|
||||
throw new Error(JSON.stringify(response.error))
|
||||
|
||||
@@ -6,7 +6,8 @@ import { expect } from './orca-app'
|
||||
import type { RuntimeClient } from '../../../src/cli/runtime/client'
|
||||
import { decodePairingOffer } from '../../../src/shared/remote-runtime/pairing/pairing'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../src/shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../src/shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../src/shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../src/shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../src/shared/runtime-session-contracts'
|
||||
import { isServeMintedPtySessionId } from '../../../src/shared/terminal/pty/lifecycle/pty-session-id-format'
|
||||
import type {
|
||||
@@ -156,7 +157,7 @@ export async function readPublishedLayout(
|
||||
resolveSnapshot = resolve
|
||||
rejectSnapshot = reject
|
||||
})
|
||||
const subscription = await subscribeRemoteRuntimeRequest<unknown>(
|
||||
const subscription = await subscribeRemoteRuntimeTransport<unknown>(
|
||||
pairedRuntimeConnectionFromOffer(decodePairingOffer(pairingUrl)),
|
||||
'layout.subscribe',
|
||||
{},
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../src/shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { decodePairingOffer } from '../../../src/shared/remote-runtime/pairing/pairing'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../src/shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../src/shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../src/shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import { toWebTerminalSurfaceTabId } from '../../../src/shared/workspace-layout/terminal-surface-id'
|
||||
import type { PublishedWorkspaceLayout } from '../../../src/shared/workspace-layout/workspace-layout-published'
|
||||
import { readWorkspaceLayoutStreamFrame } from '../../../src/shared/workspace-layout/workspace-layout-stream-frames'
|
||||
@@ -23,7 +24,7 @@ export async function readServerLayout(
|
||||
const snapshot = new Promise<unknown>((resolve) => {
|
||||
resolveSnapshot = resolve
|
||||
})
|
||||
const subscription = await subscribeRemoteRuntimeRequest<unknown>(
|
||||
const subscription = await subscribeRemoteRuntimeTransport<unknown>(
|
||||
pairedRuntimeConnectionFromOffer(decodePairingOffer(host.offer.pairingUrl)),
|
||||
'layout.subscribe',
|
||||
{ workspaces: [worktreeId] },
|
||||
|
||||
@@ -2,12 +2,12 @@ import { MOBILE_RUNTIME_CLIENT_CAPABILITIES } from '../../../mobile/src/transpor
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../src/shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { decodePairingOffer } from '../../../src/shared/remote-runtime/pairing/pairing'
|
||||
import type { PairingOffer } from '../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
|
||||
import {
|
||||
sendRemoteRuntimeRequest,
|
||||
subscribeRemoteRuntimeRequest,
|
||||
type RemoteRuntimeSubscription,
|
||||
type RemoteRuntimeSubscriptionCallbacks
|
||||
} from '../../../src/shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../../src/shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../src/shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type {
|
||||
RemoteRuntimeTransportSubscription,
|
||||
RemoteRuntimeTransportSubscriptionCallbacks
|
||||
} from '../../../src/shared/remote-runtime/requests/remote-runtime-subscription-contract'
|
||||
import type { RuntimeRpcResponse } from '../../../src/shared/runtime-rpc-envelope'
|
||||
import { openRemoteRuntimePassthroughSocket } from '../../../src/shared/remote-runtime/remote-runtime-passthrough-socket'
|
||||
import type { RuntimeCapability } from '../../../src/shared/protocol-version'
|
||||
@@ -37,9 +37,9 @@ export type PairedMobileClient = {
|
||||
subscribe: <T>(
|
||||
method: string,
|
||||
params: unknown,
|
||||
callbacks: RemoteRuntimeSubscriptionCallbacks<T>,
|
||||
callbacks: RemoteRuntimeTransportSubscriptionCallbacks<T>,
|
||||
timeoutMs?: number
|
||||
) => Promise<RemoteRuntimeSubscription>
|
||||
) => Promise<RemoteRuntimeTransportSubscription>
|
||||
/** One persistent phone socket, as the app holds one; needed for streams and `executionHost`. */
|
||||
openSocket: () => Promise<PairedMobileSocket>
|
||||
/** Closes every subscription and socket this client opened. */
|
||||
@@ -81,14 +81,17 @@ export function pairMobileClient(
|
||||
params: unknown = {},
|
||||
timeoutMs = DEFAULT_TIMEOUT_MS
|
||||
): Promise<RuntimeRpcResponse<T>> =>
|
||||
sendRemoteRuntimeRequest<T>(
|
||||
sendRemoteRuntimeRequestOnSocket<T>(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
timeoutMs,
|
||||
undefined,
|
||||
undefined,
|
||||
capabilities
|
||||
undefined,
|
||||
capabilities,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
return {
|
||||
request,
|
||||
@@ -100,7 +103,7 @@ export function pairMobileClient(
|
||||
return response.result
|
||||
},
|
||||
subscribe: async (method, params, callbacks, timeoutMs = DEFAULT_TIMEOUT_MS) => {
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
connection,
|
||||
method,
|
||||
params,
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../src/shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { decodePairingOffer } from '../../../src/shared/remote-runtime/pairing/pairing'
|
||||
import { subscribeRemoteRuntimeRequest } from '../../../src/shared/remote-runtime/remote-runtime-client'
|
||||
import '../../../src/shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../../src/shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import type { RuntimeRpcResponse } from '../../../src/shared/runtime-rpc-envelope'
|
||||
import type { LiveLayoutFeed } from './workspace-layout-oracle-feed'
|
||||
|
||||
@@ -48,7 +49,7 @@ export async function subscribeHeadlessLayout(
|
||||
feed: LiveLayoutFeed
|
||||
): Promise<{ close: () => void }> {
|
||||
feed.reopening()
|
||||
const subscription = await subscribeRemoteRuntimeRequest<unknown>(
|
||||
const subscription = await subscribeRemoteRuntimeTransport<unknown>(
|
||||
pairedRuntimeConnectionFromOffer(decodePairingOffer(pairingUrl)),
|
||||
'layout.subscribe',
|
||||
{},
|
||||
|
||||
@@ -15,10 +15,8 @@ import { ensureTerminalVisible, waitForSessionReady } from './helpers/store'
|
||||
import { createRuntimeDesktopPairingOffer } from './helpers/paired-electron-client'
|
||||
import { decodePairingOffer } from '../../src/shared/remote-runtime/pairing/pairing'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../src/shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import {
|
||||
sendRemoteRuntimeRequest,
|
||||
subscribeRemoteRuntimeRequest
|
||||
} from '../../src/shared/remote-runtime/remote-runtime-client'
|
||||
import { sendRemoteRuntimeRequestOnSocket } from '../../src/shared/remote-runtime/requests/remote-runtime-request-socket'
|
||||
import { subscribeRemoteRuntimeTransport } from '../../src/shared/remote-runtime/requests/remote-runtime-subscription-transport'
|
||||
import {
|
||||
TerminalStreamOpcode,
|
||||
decodeTerminalStreamFrame,
|
||||
@@ -130,9 +128,20 @@ test('phone subscribe to an idle relaunched terminal behind another tab fits the
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const list = await sendRemoteRuntimeRequest<{
|
||||
const list = await sendRemoteRuntimeRequestOnSocket<{
|
||||
terminals: { handle: string; ptyId: string | null }[]
|
||||
}>(connection, 'terminal.list', {}, 15_000)
|
||||
}>(
|
||||
connection,
|
||||
'terminal.list',
|
||||
{},
|
||||
15_000,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
if (!list.ok) {
|
||||
return JSON.stringify(list)
|
||||
}
|
||||
@@ -144,7 +153,7 @@ test('phone subscribe to an idle relaunched terminal behind another tab fits the
|
||||
.toBe('listed')
|
||||
|
||||
const seen: { snapshot: { cols: number; rows: number } | null } = { snapshot: null }
|
||||
const subscription = await subscribeRemoteRuntimeRequest(
|
||||
const subscription = await subscribeRemoteRuntimeTransport(
|
||||
connection,
|
||||
'terminal.subscribe',
|
||||
{
|
||||
|
||||
@@ -28,9 +28,11 @@ vi.mock('electron', () => ({
|
||||
app: { getPath: getPathMock },
|
||||
ipcMain: { handle: vi.fn(), on: vi.fn(), removeHandler: vi.fn(), removeAllListeners: vi.fn() }
|
||||
}))
|
||||
vi.mock('../../src/shared/remote-runtime/remote-runtime-client', () => ({
|
||||
sendRemoteRuntimeRequest: sendRemoteRuntimeRequestMock,
|
||||
subscribeRemoteRuntimeRequest: vi.fn()
|
||||
vi.mock('../../src/shared/remote-runtime/requests/remote-runtime-request-socket', () => ({
|
||||
sendRemoteRuntimeRequestOnSocket: sendRemoteRuntimeRequestMock
|
||||
}))
|
||||
vi.mock('../../src/shared/remote-runtime/requests/remote-runtime-subscription-transport', () => ({
|
||||
subscribeRemoteRuntimeTransport: vi.fn()
|
||||
}))
|
||||
vi.mock(
|
||||
'../../src/main/ipc/runtime-environments/runtime-environment-request-connections',
|
||||
|
||||
Reference in New Issue
Block a user