import {C,frame,screen,rect,text,label,mark,icon,line,card,metric,pill,button,tabs,table,chart,progress,aiNote,codeBlock,steps,rowList,group,path,ellipse} from './design-lib.mjs';
export function intelligence(){
screen('overview','Your platform, in focus.','03 / Intelligence','Overview',()=>{
group('Daily briefing',256,190,750,220,()=>{rect(0,0,750,220,C.dark,14);label(25,23,'Ankra intelligence  /  Daily briefing',C.lime);text(25,57,'A clear view. A considered next move.',27,C.paper,500,690);text(25,105,'Production is stable. One deployment needs review and two\nright-sizing opportunities could lower your monthly spend.',14,C.navMuted,400,675);button(25,164,'Review your briefing',{kind:'secondary',w:191,target:'ai-home',icon:'arrow'});text(239,175,'Updated 2 minutes ago · 4 sources',11,C.navMuted);});
card(1026,190,382,220,'Needs your decision','3 items · ordered by impact',()=>{line(20,76,342);text(22,93,'Approve checkout rollout',13,C.ink,600,310,{target:'ai-plan'});pill(22,121,'Production','amber',{small:true});text(112,126,'2 min review',11,C.muted);text(22,166,'View all decisions  →',12,C.green,600,320,{target:'inbox'});});
metric(256,432,272,'Fleet availability','99.98%','SLO met · last 30 days');metric(546,432,272,'Applications healthy','47 / 48','1 deployment needs attention','amber');metric(836,432,272,'Monthly forecast','€8,420','€1,180 potential savings');metric(1126,432,282,'Security priorities','3','2 have a verified fix','amber');
card(256,582,750,322,'Fleet health','12 clusters · 3 providers · all regions',()=>{table(20,81,710,['CLUSTER','HEALTH','CAPACITY','LAST CHANGE'],[['eu-prod-01|Hetzner · Helsinki',{text:'Healthy',kind:'green'},'43% CPU','6 min ago'],['eu-staging-01|AWS · Stockholm',{text:'Healthy',kind:'green'},'28% CPU','21 min ago'],['onprem-01|Proxmox · Private cloud',{text:'Degraded',kind:'amber'},'81% memory','38 min ago']],{widths:[237,139,146,188],targets:['cluster-overview','cluster-overview','cluster-overview']});});
card(1026,432+150,382,322,'Working with you','4 agents active · within budget',()=>{rowList(20,86,342,[{title:'SRE agent',detail:'Investigating checkout latency',status:'Running',icon:'spark',kind:'blue'},{title:'Cost advisor',detail:'Prepared 2 saving plans',status:'Review',kind:'amber'},{title:'Security reviewer',detail:'Validated dependency patches',status:'Done'}]);});
text(256,940,'Everything you see is scoped to Northstar. Change workspace from the sidebar.',11,C.muted);
},{subtitle:'Monday, 7 September · Northstar workspace',description:'A single daily operating view merges the existing dashboard and AI home. Attention is ranked before fleet detail.'});

screen('ai-home','Intelligence','03 / Intelligence','Intelligence',()=>{
rect(256,188,1152,154,C.dark,13);icon('spark',281,212,23,C.lime);text(321,211,'What would you like to move forward?',23,C.paper,500,860);rect(280,264,1104,52,'#244133',9,'#456050');text(300,280,'Investigate, plan, build, or operate across your platform…',14,C.navMuted,400,875,{target:'ai-chat'});button(1237,273,'Start',{w:127,h:34,kind:'secondary',icon:'arrow',target:'ai-chat'});
tabs(256,365,1152,[{label:'Your work',target:'ai-home'},{label:'Board',target:'ai-board'},{label:'Agents',target:'agents'},{label:'Automations',target:'automations'},{label:'Run history',target:'agent-runs'},{label:'Usage',target:'ai-usage'}]);
card(256,435,745,241,'Ready for your review','Plans with evidence, scope, and a clear outcome',()=>{table(20,80,705,['PROPOSED ACTION','SCOPE','REVIEW'],[['Increase checkout memory limit|SRE agent · 3 evidence sources','eu-prod-01',{text:'Needs approval',kind:'amber'}],['Reduce staging node pool|Cost advisor · €420 / month','eu-staging-01',{text:'Plan ready',kind:'blue'}]],{widths:[357,154,194],targets:['ai-plan','cost-savings']});});
card(1021,435,387,241,'Autonomy at a glance','The boundaries your agents work within',()=>{text(22,85,'Production',13,C.ink,500);pill(205,82,'Approval required','amber',{small:true});text(22,131,'Monthly AI budget',12,C.muted);text(259,131,'€86 / €250',12,C.ink,600);progress(22,165,343,.344);text(22,195,'Manage boundaries  →',12,C.green,600,310,{target:'ai-autonomy'});});
card(256,698,745,232,'In progress','2 investigations · 1 scheduled check',()=>{rowList(22,86,700,[{title:'Why did checkout p95 increase?',detail:'Correlating deployment, logs, and resource pressure',status:'Running',kind:'blue',icon:'spark'},{title:'Nightly drift review',detail:'12 clusters checked · collecting final evidence',status:'Running',kind:'blue',icon:'git'}]);});
aiNote(1021,698,387,'Connected context','12 clusters · 8 repositories\nRunbooks and service ownership available',{h:132,target:'ai-context'});button(1021,849,'Browse the agent team',{kind:'secondary',w:220,target:'agents',icon:'user'});
},{subtitle:'From a question to a verified outcome. Every action stays traceable.',description:'Central AI workspace; capabilities and account-specific features from the live AI area retained.'});

screen('ai-chat','Ask Ankra','03 / Intelligence','Intelligence',()=>{
card(256,190,245,740,'Conversations',null,()=>{button(16,59,'New conversation',{kind:'secondary',w:213,target:'ai-chat',icon:'plus'});label(18,122,'Today');rect(10,150,225,67,C.greenSoft,7);text(22,162,'Checkout latency',13,C.green,600,192,{target:'ai-investigation'});text(22,185,'eu-prod-01 · Investigating',10,C.muted);text(22,242,'Prepare a staging environment',12,C.ink,500,195);text(22,293,'Review the security baseline',12,C.ink,500,195);label(18,368,'Yesterday');text(22,406,'Monthly cost opportunities',12,C.muted,400,190);});
text(543,213,'Checkout latency',20,C.ink,600);pill(1142,210,'Read-only investigation','green');rect(716,285,652,70,C.soft,11);text(738,303,'Why did checkout latency increase after the last deployment?',14,C.ink,400,608);
mark(541,387,26,C.green);text(585,389,'Ankra',14,C.ink,600);text(586,423,'I’ll compare the rollout with request latency, pod resource\npressure, and recent application errors.',16,C.ink,400,734);
card(585,498,783,183,'Investigation plan','Scoped to eu-prod-01 / checkout',()=>{rowList(20,77,740,[{title:'Check deployment and metric timelines',detail:'Read deployment history and p95 latency',status:'Done'},{title:'Correlate resource pressure and errors',detail:'Read pod metrics and recent logs',status:'Running',kind:'blue',icon:'spark'}]);});
text(586,708,'3 connected sources · No infrastructure changes',11,C.muted);button(586,752,'Open investigation workspace',{w:255,target:'ai-investigation',icon:'arrow'});
rect(540,832,844,97,C.paper,11,C.line);text(560,847,'Ask a follow-up or add context…',14,C.subtle,400,700);pill(558,887,'eu-prod-01 / checkout','neutral',{small:true});pill(740,887,'Investigate','green',{small:true});button(1291,878,'Send',{w:77,h:34,target:'ai-investigation'});
},{subtitle:'A conversation that stays connected to the work.',description:'Durable conversation history, context scope, execution mode, and an artifact workspace; not a floating chat bubble.'});

screen('ai-investigation','Checkout latency investigation','03 / Intelligence','Intelligence',()=>{
tabs(256,185,1152,[{label:'Evidence',target:'ai-investigation'},{label:'Proposed plan',target:'ai-plan'},{label:'Execution',target:'ai-execution'}]);
card(256,253,732,210,'Memory pressure began after rollout','Finding · supported by 3 sources',()=>{text(22,83,'Two checkout pods are restarting after reaching their memory\nlimit. The timing matches rollout #1842 at 09:41 UTC.',16,C.ink,500,687);pill(22,151,'Observed','green');text(122,157,'Application error rate remains within SLO.',12,C.muted,400,579);});
card(1010,253,398,347,'Investigation context',null,()=>{[['Scope','eu-prod-01 / checkout'],['Time window','09:30–10:15 UTC'],['Agent','SRE agent'],['Mode','Read only'],['Freshness','Synced 12 seconds ago']].forEach(([a,b],i)=>{text(22,75+i*44,a,12,C.muted);text(158,75+i*44,b,12,C.ink,500,215)});line(22,302,354);text(22,317,'Open full transcript  →',11,C.green,500,340,{target:'agent-run-detail'});});
card(256,485,732,258,'p95 request latency','Rollout #1842 at 09:41 · source: Prometheus',()=>{chart(22,88,686,139,{secondary:true,seed:3});});
card(256,765,732,166,'Evidence trail',null,()=>{text(22,67,'01   Pod events   ·   OOMKilled · 09:44 UTC',12,C.ink,500,665);text(22,100,'02   Deployment diff   ·   memory limit unchanged',12,C.ink,500,665);text(22,133,'03   Prometheus   ·   working set exceeded 512 MiB',12,C.ink,500,665);});
aiNote(1010,624,398,'Recommended next step','Increase the memory limit after checking node headroom. Review the exact diff and rollout conditions.',{h:162,target:null});button(1032,810,'Review proposed plan',{w:353,target:'ai-plan',icon:'arrow'});text(1034,865,'Alternative: roll back to revision 1841.\nNeither action has been executed.',12,C.muted,400,347);
},{subtitle:'Evidence first. A proposed action follows.',description:'Freshness, explicit observations, source timestamps, alternatives, and certainty without invented confidence percentages.'});

screen('ai-plan','Review proposed change','03 / Intelligence','Intelligence',()=>{
steps(256,192,1135,['Investigate','Review plan','Execute','Verify'],1);
card(256,248,749,188,'Increase checkout memory limit','Plan #AP-204 · prepared by SRE agent · 10:16 UTC',()=>{text(22,83,'Allow checkout pods to use 768 MiB during peak traffic.\nA rolling update preserves availability.',15,C.ink,400,700);pill(22,145,'Production','amber');pill(126,145,'1 resource','neutral');pill(236,145,'Approval required','amber');});
codeBlock(256,458,749,263,['# spec.template.spec (excerpt)','containers:','  - name: checkout','    resources:','      limits:','-       memory: 512Mi','+       memory: 768Mi'],{title:'Deployment / checkout — proposed diff'});
card(256,743,749,197,'Validation & rollback',null,()=>{rowList(22,70,700,[{title:'Capacity check passed',detail:'1.8 GiB of allocatable memory available',status:'Passed'},{title:'Rollback to revision 1841',detail:'If readiness fails or p95 remains elevated for 5 minutes',status:'Ready'}]);});
card(1027,248,381,500,'Approval summary','Review what will happen before execution',()=>{[['Target','eu-prod-01 / checkout'],['Changes','1 deployment'],['Risk','Rolling restart'],['Estimated cost','No node cost change'],['Required permission','workloads.update'],['Expires','In 15 minutes']].forEach(([a,b],i)=>{text(22,86+i*48,a,11,C.muted);text(157,86+i*48,b,12,C.ink,500,202)});line(22,375,337);button(22,397,'Approve & execute',{w:337,target:'ai-execution',icon:'check'});button(22,446,'Request changes',{w:337,kind:'secondary',target:'ai-chat'});});
aiNote(1027,770,381,'Revalidated before execution','If the resource has changed, this plan returns to review. Approval applies only to this exact diff.',{h:170,target:null});
},{subtitle:'Ankra has prepared this plan. Your approval is required.',description:'Explicit permission, scope, exact diff, stale-plan expiry, cost impact, validation and rollback conditions.'});

screen('ai-execution','Change verified','03 / Intelligence','Intelligence',()=>{
steps(256,192,1135,['Investigate','Review plan','Execute','Verify'],4);
rect(256,252,1152,113,C.greenSoft,12);icon('check',281,276,25,C.green);text(322,271,'Checkout latency has recovered.',23,C.green,600,900);text(322,312,'4 replicas ready · p95 returned to 182 ms · observation window completed',13,C.muted,400,1010);
metric(256,389,369,'p95 latency','182 ms','Down from 840 ms');metric(647,389,369,'Ready replicas','4 / 4','Stable for 5 minutes');metric(1038,389,370,'Error rate','0.02%','Within the 0.1% SLO');
card(256,539,749,357,'Execution receipt','AP-204 · approved by Alex Morgan · 10:18 UTC',()=>{rowList(22,82,701,[{title:'Preconditions revalidated',detail:'Resource revision matched the approved plan',status:'Passed'},{title:'Rolling update completed',detail:'1 deployment updated · no unavailable replicas',status:'Done'},{title:'Health verified',detail:'Readiness, p95, and error rate observed for 5 minutes',status:'Passed'},{title:'Receipt recorded',detail:'Diff, approval, timestamps, and measurements preserved',status:'Saved'}]);});
card(1027,539,381,357,'Before → after',null,()=>{chart(22,86,337,156,{seed:5});text(22,260,'Rollback is available from the operation.',12,C.muted,400,337);button(22,296,'Open operation',{w:337,kind:'secondary',target:'operation-detail'});});
text(256,937,'View audit record  →',12,C.green,600,250,{target:'audit-log'});button(1192,921,'Back to overview',{kind:'secondary',w:216,target:'overview'});
},{subtitle:'The approved plan is complete, with a durable record of the outcome.',description:'Verified recovery is separate from tool completion. Partial failure and rollback alternatives live in the states chapter.'});

screen('inbox','Your decisions','03 / Intelligence','Inbox',()=>{
tabs(256,187,1152,['Needs you  3','All activity','Resolved','Snoozed']);
card(256,252,412,670,'Inbox','Prioritized across your workspace',()=>{[['Approve checkout memory change','Production · SRE agent · 4 min ago','amber'],['Review a security exception','Security · expires in 7 days','red'],['Approve staging right-sizing','Cost advisor · €420 / month','green'],['Drift detected on eu-prod-02','Infrastructure · 23 min ago','neutral']].forEach(([a,b,k],i)=>{if(i===0)rect(10,81+i*118,392,111,C.greenSoft,8);text(23,98+i*118,a,14,C.ink,600,365,{target:'ai-plan'});text(23,149+i*118,b,11,C.muted,400,365);});});
card(690,252,718,670,'Approve checkout memory change','One decision, with the context needed to make it',()=>{pill(24,83,'Production','amber');text(24,137,'Why this needs you',17,C.ink,600);text(24,176,'The SRE agent found memory pressure after the latest rollout.\nProduction changes require a human approval in this workspace.',14,C.muted,400,665);aiNote(24,255,670,'Evidence attached','Pod events, metrics, and deployment history support the proposed action.',{target:'ai-investigation',h:117});text(24,407,'Proposed outcome',17,C.ink,600);text(24,445,'Increase the memory limit to 768 MiB, roll out gradually,\nand verify recovery over five minutes.',14,C.muted,400,665);button(24,553,'Review full plan',{w:192,target:'ai-plan',icon:'arrow'});button(233,553,'Snooze',{w:105,kind:'secondary',target:'activity-snoozes'});text(24,615,'Assigned to you · AP-204 · 3 linked sources',11,C.muted,400,650);});
},{subtitle:'Approvals, incidents, and findings in one actionable queue.',description:'Consolidates dashboard attention, AI inbox, incidents, insights, and organisation activity without hiding their types.'});

screen('ai-board','Work board','03 / Intelligence','Intelligence',()=>{
tabs(256,189,1152,['Board','List','Conditions','Run history']);pill(256,255,'All agents','neutral');pill(375,255,'All clusters','neutral');button(1268,250,'New task',{w:140,target:'task-detail',icon:'plus'});
const cols=[['Queued',C.muted,[['Audit staging drift','Nightly auditor','P2 · 12 clusters'],['Review stale secrets','Security agent','P2 · All environments']]],['Investigating',C.blue,[['Checkout latency','SRE agent','P1 · eu-prod-01'],['Image scan regression','Security reviewer','P1 · checkout']]],['Needs review',C.amber,[['Increase memory limit','SRE agent','Plan AP-204'],['Reduce staging capacity','Cost advisor','€420 / month']]],['Verified',C.green,[['Rotate registry token','Platform agent','Receipt OP-928'],['Resolve ingress drift','SRE agent','Receipt OP-920']]]];
cols.forEach(([title,color,items],i)=>{const x=256+i*293;rect(x,311,274,618,C.soft,10);ellipse(x+17,332,7,7,color);text(x+34,326,title,14,C.ink,600);text(x+238,329,'2',12,C.muted);items.forEach(([a,b,c],j)=>{card(x+10,374+j*201,254,180,null,null,()=>{pill(16,16,j===0?'Incident':'Task',j===0?'amber':'neutral',{small:true});text(16,57,a,16,C.ink,600,220,{target:i===2?'ai-plan':'task-detail'});text(16,116,b,11,C.muted,500);line(16,142,222);text(16,155,c,10,C.muted);});});});
},{subtitle:'A shared view of work owned by people and agents.',description:'Task ownership, priority, cluster, status, dependencies, and run history; durable tasks remain distinct from chat.'});

screen('task-detail','Investigate checkout latency','03 / Intelligence','Intelligence',()=>{
pill(256,191,'Investigating','blue');pill(384,191,'P1 · High','amber');pill(480,191,'Incident','neutral');
card(256,244,748,229,'Objective','TASK-142 · Created from alert ALT-28',()=>{text(23,84,'Restore checkout latency to its SLO and explain the cause.\nPrepare a plan for any production changes.',17,C.ink,400,700);text(23,160,'Success criteria',12,C.muted,600);text(23,188,'p95 < 250 ms for 5 minutes · error rate < 0.1%',13,C.ink,500,700);});
card(256,495,748,427,'Activity & evidence',null,()=>{rowList(22,83,700,[{title:'Alex assigned SRE agent',detail:'09:59 UTC · Investigation only',status:'Assigned',kind:'neutral',icon:'user'},{title:'Metrics and rollout history collected',detail:'10:01 UTC · 3 evidence sources attached',status:'Done'},{title:'Memory pressure identified',detail:'10:12 UTC · source: pod events + Prometheus',status:'Observed',kind:'blue'},{title:'Plan AP-204 prepared',detail:'10:16 UTC · Waiting for your review',status:'Review',kind:'amber'}]);button(22,368,'Open proposed plan',{w:204,target:'ai-plan',icon:'arrow'});});
card(1026,244,382,402,'Ownership & boundaries',null,()=>{[['Owner','SRE agent'],['Reviewer','Alex Morgan'],['Cluster','eu-prod-01'],['Budget','€4.20 / €10.00'],['Deadline','Today · 12:00 UTC'],['Dependencies','No blockers']].forEach(([a,b],i)=>{text(22,82+i*48,a,12,C.muted);text(155,82+i*48,b,12,C.ink,500,200)});});aiNote(1026,668,382,'Run is durable','You can leave this page. Progress, evidence, and approvals are saved on the task.',{h:156,target:'agent-run-detail'});
},{subtitle:'A durable unit of work with an owner and a measurable outcome.'});

screen('agents','Your agent team','03 / Intelligence','Intelligence',()=>{
tabs(256,187,1152,[{label:'Agents',target:'agents'},{label:'Run history',target:'agent-runs'},{label:'Usage',target:'ai-usage'},{label:'Boundaries',target:'ai-autonomy'}]);
const list=[['SRE agent','Reliability, incidents, and recovery','Running','blue','2 tasks in progress'],['Security reviewer','Findings, policies, and remediation','Ready','green','8 findings reviewed today'],['Cost advisor','Capacity and spend optimisation','Ready','green','€1,180 savings identified'],['Delivery engineer','Builds, pipelines, and release health','Running','blue','Watching rollout #1842'],['Nightly auditor','Configuration drift and fleet hygiene','Scheduled','neutral','Next run · 02:00 UTC'],['Platform guide','Onboarding and platform questions','Ready','green','Available across the workspace']];
list.forEach(([name,desc,status,kind,meta],i)=>card(256+(i%3)*391,255+Math.floor(i/3)*279,370,257,null,null,()=>{rect(22,23,43,43,C.greenSoft,10);icon('spark',33,34,21,C.green);pill(237,29,status,kind,{small:true});text(22,90,name,20,C.ink,600,324,{target:'agent-detail'});text(22,127,desc,13,C.muted,400,321);line(22,184,326);text(22,201,meta,11,C.muted,400,320);text(22,230,'View agent  →',11,C.green,600,310,{target:'agent-detail'});}));
aiNote(256,838,1152,'Add expertise with clear boundaries','Start from a role template, connect context, choose a schedule or goal, and set permissions and budget.',{h:92,target:'agent-detail'});
},{subtitle:'Purpose-built roles. Visible ownership. Bounded autonomy.',action:{label:'Create agent',target:'agent-detail'}});

screen('agent-detail','SRE agent','03 / Intelligence','Intelligence',()=>{
tabs(256,186,1152,['Overview','Instructions','Context','Permissions','Budget','Schedule']);
card(256,254,748,254,'Mission','Reliability engineering',()=>{text(22,84,'Keep production services healthy. Investigate incidents,\nprepare safe recovery plans, and verify the outcome.',19,C.ink,500,700);pill(22,166,'Read access · all production','green');pill(258,166,'Writes · approval required','amber');text(22,214,'Updated by Alex Morgan · 5 September',11,C.muted);});
card(1026,254,382,254,'Run controls',null,()=>{text(22,78,'Current status',12,C.muted);pill(223,74,'Running','blue');text(22,122,'Budget per run',12,C.muted);text(226,122,'€10.00',13,C.ink,600);text(22,163,'Maximum duration',12,C.muted);text(226,163,'30 minutes',13,C.ink,500);button(22,201,'Pause agent',{w:338,kind:'secondary',icon:'pause',target:'ai-autonomy'});});
card(256,530,1152,355,'Recent runs','Every run includes an execution transcript and receipts',()=>{table(22,85,1108,['RUN','TRIGGER','DURATION','SPEND','OUTCOME'],[['Checkout latency|Today · 09:59 UTC','Alert ALT-28','18m 24s','€4.20',{text:'Needs review',kind:'amber'}],['Ingress drift|Yesterday · 15:10 UTC','Scheduled','6m 12s','€1.40',{text:'Verified',kind:'green'}],['Node pressure|Yesterday · 08:30 UTC','Manual','9m 41s','€2.10',{text:'Verified',kind:'green'}]],{widths:[378,219,166,144,201],targets:['agent-run-detail','agent-run-detail','agent-run-detail']});});
},{subtitle:'Investigates reliability issues and prepares evidence-backed recovery plans.'});

screen('agent-run-detail','Run #428 · Checkout latency','03 / Intelligence','Intelligence',()=>{
pill(256,191,'Awaiting approval','amber');pill(410,191,'SRE agent','neutral');text(1251,195,'18m 24s',13,C.muted);
card(256,251,364,673,'Run timeline','Started 09:59 UTC',()=>{rowList(20,90,324,[{title:'Context loaded',detail:'Scope + runbook + permissions',status:null},{title:'Evidence collected',detail:'Metrics, logs, rollout history',status:null},{title:'Cause identified',detail:'Memory pressure after rollout',status:null},{title:'Plan prepared',detail:'AP-204 · 2 resource changes',status:null}]);pill(20,394,'Paused for your decision','amber');text(20,465,'Used €4.20 of €10.00 budget.\nAgent will not execute before approval.',12,C.muted,400,319);button(20,591,'Review plan',{w:323,target:'ai-plan',icon:'arrow'});});
codeBlock(642,251,766,509,['09:59:02  RUN STARTED  SRE agent','09:59:03  SCOPE        eu-prod-01 / checkout','09:59:04  READ         deployment history','10:00:18  READ         request latency (p95)','10:01:36  READ         pod events','10:02:08  OBSERVED     OOMKilled x 2','10:06:14  READ         node capacity','10:12:40  FINDING      memory pressure','10:15:21  PLAN         AP-204 prepared','10:16:03  VALIDATED    capacity + rollout','10:17:26  WAITING      approval required'],{title:'Durable transcript · actions and observations'});
aiNote(642,782,766,'No writes have run','The agent completed its investigation and stopped at the production approval boundary.',{h:141,target:null});
},{subtitle:'A live transcript, explicit budgets, and receipts that survive your browser session.'});

screen('automations','Automations','03 / Intelligence','Intelligence',()=>{
metric(256,192,368,'Active automations','8','All within their configured scope');metric(647,192,368,'Completed this week','124','119 verified · 5 need review','amber');metric(1038,192,370,'Time returned','18.4 h','Estimate from recorded task durations');
card(256,344,1152,494,'Operational routines','Triggers, boundaries, and outcomes in one place',()=>{table(22,92,1108,['AUTOMATION','TRIGGER','PERMISSION','LAST RUN','STATUS'],[['Nightly drift review|Nightly auditor','02:00 UTC daily','Investigate only','Today · 02:00',{text:'Enabled',kind:'green'}],['Production incident triage|SRE agent','Critical alert','Approval for writes','Today · 09:59',{text:'Enabled',kind:'green'}],['Weekly cost review|Cost advisor','Monday · 07:00','Prepare plans','Today · 07:00',{text:'Enabled',kind:'green'}],['Dependency patch review|Security reviewer','New critical CVE','Prepare PR','Yesterday',{text:'Paused',kind:'neutral'}]],{widths:[331,205,240,176,156],rowH:76,targets:['automation-detail','automation-detail','automation-detail','automation-detail']});});
},{subtitle:'Make repeatable work dependable.',action:{label:'New automation',target:'automation-detail'}});

screen('automation-detail','Production incident triage','03 / Intelligence','Intelligence',()=>{
steps(256,191,1152,['Trigger','Agent & context','Boundaries','Review'],2);
card(256,253,748,664,'Build your automation','A trigger starts a bounded agent run',()=>{fieldGroup();function fieldGroup(){text(24,86,'WHEN',11,C.muted,600);rect(24,113,698,89,C.soft,9);icon('bell',44,137,21,C.green);text(82,133,'A critical production alert fires',16,C.ink,500,589);text(82,164,'Group related alerts within 5 minutes',12,C.muted,400,589);line(370,204,1,C.line,36);text(24,233,'THEN',11,C.muted,600);rect(24,261,698,89,C.greenSoft,9);icon('spark',44,285,21,C.green);text(82,281,'SRE agent investigates',16,C.green,500,589);text(82,312,'Attach metrics, logs, deployment context, and a plan',12,C.muted,400,589);text(24,385,'EXECUTION BOUNDARY',11,C.muted,600);rect(24,414,698,111,C.amberSoft,9);icon('shield',43,438,21,C.amber);text(82,434,'Production changes require approval',16,C.amber,600,589);text(82,470,'Route plans to the platform team. Stop after €10 or 30 minutes.',12,C.muted,400,589);button(24,578,'Save automation',{w:195,target:'automations',icon:'check'});}});
aiNote(1026,253,382,'Preview the trigger','2 alerts from the last 7 days would have started this automation. Test with a historical event before enabling.',{h:185,target:null});card(1026,460,382,296,'Run policy',null,()=>{text(22,82,'Retries',12,C.muted);text(205,82,'2 with backoff',12,C.ink,500);text(22,128,'Cooldown',12,C.muted);text(205,128,'30 minutes',12,C.ink,500);text(22,174,'Concurrency',12,C.muted);text(205,174,'1 run / incident',12,C.ink,500);text(22,220,'On failure',12,C.muted);text(205,220,'Notify owner',12,C.ink,500);});
},{subtitle:'Define when work starts, what it can do, and when it must stop.'});
}
