-- Консольные агенты Claude (шаги 2-4 спецификации): память менеджера, итоговые списки, журналы; удаление объектов рутин alter table construction_manager add column slack_user_id text; alter table construction_manager add column slack_channel_id text; create table agent_manager_memory ( manager_person_id uuid primary key references construction_manager(person_id), memory_text text not null default '', claude_session_id uuid, updated_at timestamptz not null default now() ); create table manager_day_list ( id uuid primary key default gen_random_uuid(), manager_person_id uuid not null references construction_manager(person_id), list_date date not null, package_ids uuid[] not null default '{}', list_text text not null, is_current boolean not null default true, created_at timestamptz not null default now() ); create index manager_day_list_cur_idx on manager_day_list (manager_person_id, list_date) where is_current; create table agent_problem_log ( id uuid primary key default gen_random_uuid(), manager_person_id uuid references construction_manager(person_id), step text not null check (step in ('step2','step4')), severity text not null check (severity in ('log','it_request')), body text not null, created_at timestamptz not null default now() ); create table slack_message_log ( channel_id text not null, message_ts text not null, manager_person_id uuid references construction_manager(person_id), has_files boolean not null default false, status text not null check (status in ('received','processing','done','failed','ignored')), received_at timestamptz not null default now(), processed_at timestamptz, primary key (channel_id, message_ts) ); -- журнал запусков консольных агентов (замена вызовов рутин в ap_agent_invocation) create table agent_run ( id uuid primary key default gen_random_uuid(), manager_person_id uuid references construction_manager(person_id), step text not null check (step in ('step2','step4')), attempt int not null default 1, session_id uuid, resumed boolean not null default false, status text not null check (status in ('running','ok','failed')), started_at timestamptz not null default now(), finished_at timestamptz, duration_ms int, cost_usd numeric, changes text, error text ); alter table agent_manager_memory enable row level security; alter table manager_day_list enable row level security; alter table agent_problem_log enable row level security; alter table slack_message_log enable row level security; alter table agent_run enable row level security; -- объекты рутин Claude больше не используются drop table active_task; drop table active_task_list; drop table ap_agent_invocation;