const HARNESS_ENV_KEYS = [
    'AGENT_RELAY_HARNESS',
    'AGENT_RELAY_ORCHESTRATOR_HARNESS',
    'RELAYCAST_HARNESS',
    'X_RELAYCAST_HARNESS',
];
function defaultEnv() {
    return globalThis.process?.env ?? {};
}
function nonEmpty(value) {
    const trimmed = value?.trim();
    return trimmed ? trimmed : undefined;
}
export function relaycastTelemetryOptions(explicit = {}, env = defaultEnv()) {
    const harness = nonEmpty(explicit.harness) ??
        HARNESS_ENV_KEYS.map((key) => nonEmpty(env[key])).find((value) => Boolean(value));
    const agentRelayDistinctId = nonEmpty(explicit.agentRelayDistinctId) ?? nonEmpty(env.AGENT_RELAY_DISTINCT_ID);
    return {
        ...(harness ? { harness } : {}),
        ...(agentRelayDistinctId ? { agentRelayDistinctId } : {}),
    };
}
export function relaycastWorkspaceTelemetryOptions(explicit = {}, env = defaultEnv()) {
    const { agentRelayDistinctId } = relaycastTelemetryOptions(explicit, env);
    return agentRelayDistinctId ? { agentRelayDistinctId } : {};
}
export function withRelaycastTelemetry(options, explicit = {}, env = defaultEnv()) {
    return { ...options, ...relaycastTelemetryOptions(explicit, env) };
}
//# sourceMappingURL=relaycast-telemetry.js.map