import { describe, expect, it } from 'vitest';
import type {
  AgentRuntimeProvider,
  RuntimeAttachHandle,
  RuntimeCapability,
  RuntimeError,
  RuntimeSession,
  RuntimeStreamEvent,
} from './agent-runtime-provider.js';

describe('AgentRuntimeProvider contract', (): void => {
  it('exposes stable, normalized runtime-only contracts', (): void => {
    const capability: RuntimeCapability = 'session.attach';
    const session: RuntimeSession = {
      id: 'session-1',
      providerId: 'fleet',
      runtimeId: 'tmux',
      state: 'active',
      createdAt: '2026-07-12T00:00:00.000Z',
      updatedAt: '2026-07-12T00:00:00.000Z',
    };
    const event: RuntimeStreamEvent = {
      type: 'message.delta',
      sessionId: session.id,
      cursor: '2',
      occurredAt: session.updatedAt,
      content: 'hello',
    };
    const error: RuntimeError = {
      code: 'capability_unsupported',
      message: 'Denied',
      retryable: false,
    };
    const attach: RuntimeAttachHandle = {
      attachmentId: 'attach-1',
      sessionId: session.id,
      mode: 'read',
      expiresAt: session.updatedAt,
    };
    const provider: Pick<AgentRuntimeProvider, 'capabilities' | 'getSessionTree' | 'attach'> =
      {} as Pick<AgentRuntimeProvider, 'capabilities' | 'getSessionTree' | 'attach'>;
    expect([capability, session.id, event.type, error.code, attach.mode, provider]).toHaveLength(6);
  });
});
