/**
 * PR14 Teams Inbox 类型契约 —— Bot Framework webhook + AAD↔FF AI 配对挑战。
 *
 * **本文件仅类型 + 接口骨架**；真实实现需先就位：
 * 1. Azure Bot Framework 注册（含 App ID + secret）
 * 2. AAD app registration + Graph API permission（User.Read.All / Files.ReadWrite）
 * 3. Teams app manifest 部署（zip 上传到组织 Teams admin）
 * 4. JWT signing cert：bot 验证入站请求来自 Bot Connector 服务
 *
 * 详见 docs/modules/agent/02-architecture.md PR14 段。
 */

/** Bot Framework Activity（精简版，覆盖 PR14 用到的字段） */
export interface BotActivity {
  readonly type: 'message' | 'invoke' | 'conversationUpdate' | 'event';
  readonly id: string;
  readonly timestamp: string;
  readonly serviceUrl: string;
  readonly channelId: 'msteams';
  readonly from: { id: string; aadObjectId?: string; name?: string };
  readonly conversation: { id: string; tenantId?: string };
  readonly recipient: { id: string; name?: string };
  readonly text?: string;
  readonly attachments?: ReadonlyArray<{
    contentType: string;
    contentUrl?: string;
    name?: string;
  }>;
  /** invoke 类型用（Adaptive Card 按钮回调） */
  readonly value?: unknown;
}

/** PR14 AAD↔FF AI Identity 配对状态 */
export type PairingStatus = 'pending' | 'paired' | 'denied' | 'expired';

/** 配对挑战：用户首次从 Teams 接入时下发一次性 OTP，要求在 FF AI Workspace Web/Desktop 已登录态下输入确认 */
export interface PairingChallenge {
  readonly id: string;
  readonly aadObjectId: string;
  readonly tenantId: string;
  /** 6 位 OTP，5 分钟过期 */
  readonly otp: string;
  readonly expiresAt: Date;
  readonly status: PairingStatus;
  readonly createdAt: Date;
  /** paired 后写入：对应 FF AI Workspace userId / organizationId */
  readonly ffaiUserId?: string;
  readonly ffaiOrganizationId?: string;
}

/** A2UI Adaptive Card 投影类型（占位，PR14 真实化时按 A2UI schema 映射） */
export interface AdaptiveCardEnvelope {
  readonly contentType: 'application/vnd.microsoft.card.adaptive';
  readonly content: unknown;
}
