/**
 * The structural adapter surface over the `@relaycast/sdk` client.
 *
 * `RelaycastWorkspaceLike` / `RelaycastAgentLike` describe only the slice of the
 * relaycast SDK that `RelaycastMessagingClient` depends on. Modeling them
 * structurally (rather than importing the SDK's concrete classes) keeps the
 * client testable with lightweight fakes and insulates relay from relaycast SDK
 * shape churn. `createRelaycastClient` is the single place that constructs a
 * real `RelayCast` instance from messaging options.
 */
import { RelayCast } from '@relaycast/sdk';
import { relaycastTelemetryOptions } from '../relaycast-telemetry.js';
import { definedOptions } from './relaycast-translate.js';
export function createRelaycastClient(options) {
    if (options.relaycast)
        return options.relaycast;
    const workspaceKey = options.workspaceKey ?? options.apiKey;
    if (!workspaceKey) {
        throw new Error('RelaycastMessagingClient requires workspaceKey when relaycast is not provided.');
    }
    return new RelayCast(definedOptions({
        apiKey: workspaceKey,
        baseUrl: options.baseUrl,
        retryPolicy: options.retryPolicy,
        ...relaycastTelemetryOptions({
            originActor: options.originActor,
            agentRelayDistinctId: options.agentRelayDistinctId,
        }),
    }));
}
//# sourceMappingURL=relaycast-client.js.map