-- Mirror Llm's virtual-provider lifecycle on Agent. Reuses the
-- existing LlmKind / LlmStatus enums so we don't double-define them.
-- Existing rows backfill with kind='public' / status='active' so
-- nothing changes for manually-created agents.

ALTER TABLE "Agent"
  ADD COLUMN "kind"               "LlmKind"   NOT NULL DEFAULT 'public',
  ADD COLUMN "providerSessionId"  TEXT,
  ADD COLUMN "lastHeartbeatAt"    TIMESTAMP(3),
  ADD COLUMN "status"             "LlmStatus" NOT NULL DEFAULT 'active',
  ADD COLUMN "inactiveSince"      TIMESTAMP(3);

CREATE INDEX "Agent_kind_status_idx"          ON "Agent"("kind", "status");
CREATE INDEX "Agent_providerSessionId_idx"    ON "Agent"("providerSessionId");
