CREATE TABLE IF NOT EXISTS agent_session (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    "user" UUID,
    wk UUID,
    name TEXT NOT NULL,
    description TEXT,
    agent_kind TEXT NOT NULL,
    model_version UUID,
    system_prompt TEXT,
    temperature REAL,
    max_output_tokens INTEGER,
    tool_policy TEXT,
    knowledge_base_ids TEXT,
    variables TEXT,
    visibility TEXT NOT NULL DEFAULT 'private',
    version INTEGER NOT NULL DEFAULT 1,
    published_at TIMESTAMPTZ,
    rollback_from_version INTEGER,
    enabled BOOLEAN NOT NULL DEFAULT TRUE,
    created_by UUID NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    deleted_at TIMESTAMPTZ
);
