import type { CapabilityProvider, CapabilityRequest, ProviderResult } from '@insignia/iios-contracts';

/**
 * Default egress provider: a sandbox sink that records a deterministic providerRef
 * and never touches the network (mirrors the P5 adapter sandbox). Idempotent by
 * construction — the same request just yields another sim ref, never throws.
 */
export class SandboxProvider implements CapabilityProvider {
  readonly name = 'sandbox';
  readonly channelTypes: string[];
  readonly capabilities = { canSend: true };
  private seq = 0;

  constructor(channelTypes: string[]) {
    this.channelTypes = channelTypes;
  }

  async send(req: CapabilityRequest): Promise<ProviderResult> {
    return { providerRef: `sim-${req.channelType}-${++this.seq}`, outcome: 'SENT', latencyMs: 1 };
  }
}
