Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions ui/dash.html
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ <h1 id="page-title">Tasks</h1>
<section class="runs set-group" id="set-models" aria-labelledby="set-title" hidden><div id="set-models-body"></div></section>
<section class="runs set-group" id="set-workers" aria-labelledby="set-title" hidden><div id="set-workers-body"></div><p class="mute" id="set-dispatch"></p><p class="mute" id="set-triggers"><a href="#triggers">Triggers</a>: what starts a worker on its own (off by default), and templates for it. Owners only.</p></section>
<section class="runs set-group" id="set-connections" aria-labelledby="set-title" hidden><div id="set-connections-body"></div></section>
<section class="runs set-group" id="set-cloud" aria-labelledby="set-title" hidden><div id="set-cloud-body"></div></section>
<section class="runs set-group" id="set-terminal" aria-labelledby="set-title" hidden><div id="set-terminal-body"></div></section>
<section class="runs set-group" id="set-diagnostics" aria-labelledby="set-title" hidden><div id="set-diagnostics-body"></div></section>
<section class="runs set-group" id="set-personal" aria-labelledby="set-title" hidden>
Expand Down Expand Up @@ -1813,6 +1814,7 @@ <h3>Sign-in</h3><div id="set-access"></div><h3>Notifications</h3><div id="set-pe
{id:'models',group:'This host',title:'Models and prices',sub:'configured, used, price list',desc:'The models each agent and role is set to, the ones runs actually used, and their prices.'},
{id:'workers',group:'This host',title:'Workers',sub:'limits, budgets, sandbox, rules',desc:'How many workers run at once, their default tool and budget, and what they may reach.'},
{id:'connections',group:'This host',title:'Connections',sub:'GitHub, Linear, gateway, Runtime',desc:'What agentd reads from and talks to. Changed from the terminal.'},
{id:'cloud',group:'This host',title:'Cloud',sub:'Claude subscription, jobs at once',desc:'Cloud Workers on your own Claude subscription: the token file and how many of your jobs run on it at once.'},
{id:'terminal',group:'This host',title:'Terminal',sub:'set in config.toml',desc:'An owner’s shell on a task, in the server. Off unless config.toml turns it on.'},
{id:'diagnostics',group:'This host',title:'Diagnostics',sub:'agentd doctor',desc:'agentd doctor and the services, read here. Owners only.'},
{id:'personal',group:'You',title:'Personal',sub:'notifications, theme, shortcuts',desc:'Your theme, sign-in and notifications. These are yours and change nothing for others.'},
Expand All @@ -1821,7 +1823,7 @@ <h3>Sign-in</h3><div id="set-access"></div><h3>Notifications</h3><div id="set-pe
{id:'history',group:'Team',title:'Change history',sub:'who changed what',desc:'Every change made from Settings or agentd config set. Owners only.'}],SET_IDS=SET_SECTIONS.map(x=>x.id);
function settingsIdentity(){return [TOKEN,COOKIE,USER,ROLE].join('|')}
function settingsAccess(){$('set-access').replaceChildren(el('dl',{},el('dt',{},'Signed in as'),el('dd',{},TOKEN?'Shared token':USER||'Guest'),el('dt',{},'Access'),el('dd',{},ROLE==='owner'?'Owner':ROLE||'Read-only'),el('dt',{},'Change access'),el('dd',{},'Ask an owner to change your role or send a sign-in link.')));
if(SETTINGS.identity!==settingsIdentity()){SETTINGS.identity=settingsIdentity();SETTINGS.request++;SETTINGS.data=null;SETTINGS.diagnostics=null;SETTINGS.loading=false;$('set-invite-once').replaceChildren();$('set-invite-once').hidden=true;SETTINGS.agents=null;SETTINGS.agentsRequest++;$('set-connect-result').replaceChildren();$('set-connect-result').hidden=true;for(const n of ['agents','models','personal','members','workers','connections','terminal','diagnostics','app','history'])$('set-'+n+'-body').replaceChildren();$('set-agents-table').replaceChildren();if(ROUTE.item==='settings')settingsLoad()}}
if(SETTINGS.identity!==settingsIdentity()){SETTINGS.identity=settingsIdentity();SETTINGS.request++;SETTINGS.data=null;SETTINGS.diagnostics=null;SETTINGS.loading=false;$('set-invite-once').replaceChildren();$('set-invite-once').hidden=true;SETTINGS.agents=null;SETTINGS.agentsRequest++;$('set-connect-result').replaceChildren();$('set-connect-result').hidden=true;for(const n of ['agents','models','personal','members','workers','connections','cloud','terminal','diagnostics','app','history'])$('set-'+n+'-body').replaceChildren();$('set-agents-table').replaceChildren();if(ROUTE.item==='settings')settingsLoad()}}
async function settingsAPI(body,query=''){const identity=settingsIdentity(),r=await fetch('/api/settings'+query,{method:body?'POST':'GET',cache:'no-store',headers:{...auth(),...(body?{'Content-Type':'application/json'}:{})},...(body?{body:JSON.stringify(body)}:{})});let d={};try{d=await r.json()}catch(e){}if(body&&identity!==settingsIdentity())throw new Error('Sign-in changed while saving. Refresh to check the result.');if(!r.ok)throw new Error(d.error||'Could not read Settings (HTTP '+r.status+').');return d}
async function settingsLoad(){const seq=++SETTINGS.request,identity=settingsIdentity();SETTINGS.loading=true;$('set-error').hidden=true;$('set-status').textContent='Loading settings…';try{const d=await settingsAPI();if(seq!==SETTINGS.request||identity!==settingsIdentity())return;SETTINGS.data=d;SETTINGS.identity=identity;settingsRender();$('set-status').textContent=d.owner?'Changes are saved to history.':'Host settings are read-only. Sign in as an owner to change them.'}catch(e){if(seq===SETTINGS.request){$('set-error').textContent=errorText(e);$('set-error').hidden=false;$('set-status').textContent=SETTINGS.data?'Showing the previous settings. Refresh to try again.':'Sign in to view settings.'}}finally{if(seq===SETTINGS.request)SETTINGS.loading=false}}
// settingsShow shows one section, marks it in the panel, and names it in the top bar.
Expand All @@ -1833,7 +1835,7 @@ <h3>Sign-in</h3><div id="set-access"></div><h3>Notifications</h3><div id="set-pe
function settingsTable(head,rows){return el('div',{class:'tablewrap phone-rows'},el('table',{},el('thead',{},el('tr',{},head.map(h=>el('th',{},h)))),el('tbody',{},rows.length?rows.map(row=>el('tr',{},row.map((v,i)=>el('td',{'data-label':head[i]},v===null||v===undefined||v===''?'—':v)))):el('tr',{},el('td',{colspan:head.length,class:'mute'},'Nothing recorded yet.')))))}
function settingsPairs(pairs){return el('dl',{},pairs.map(([k,v])=>[el('dt',{},k),el('dd',{},v===undefined||v===null||v===''?'Not configured':typeof v==='boolean'?v?'On':'Off':v)]))}
function settingsSection(title,...body){return el('div',{class:'set-section'},el('h3',{},title),...body)}
function settingsEdit(key,label,value,options){return sheet({title:label,description:'Saved to config.toml with a backup and history entry.',action:'Save',fields:[{name:'value',label,value:String(value??''),options,required:key!=='dispatch.budget'}],onSubmit:async v=>{await settingsAPI({action:'config',key,value:v.value});await settingsLoad();toast('Saved',true)}})}
function settingsEdit(key,label,value,options){return sheet({title:label,description:'Saved to config.toml with a backup and history entry.',action:'Save',fields:[{name:'value',label,value:String(value??''),options,required:!['dispatch.budget','cloud.claude_token_file'].includes(key)}],onSubmit:async v=>{await settingsAPI({action:'config',key,value:v.value});await settingsLoad();toast('Saved',true)}})}
function settingsPrice(model=''){const prices=(SETTINGS.data?.models||{}).prices||{},p=prices[model]||{},rates=['input','output','cache_read','cache_write'];return sheet({title:model?'Price for '+model:'Add model price',description:'USD per million tokens. Enter your known rates; blanks stay unconfigured.',action:'Save',fields:[{name:'model',label:'Model or prefix',value:model,required:true},...rates.map(name=>({name,label:word(name.replaceAll('_',' ')),value:p[name]===undefined?'':String(p[name])}))],validate:v=>{for(const k of rates)if(v[k]!==''&&(!Number.isFinite(Number(v[k]))||Number(v[k])<0))return[k,'Enter a non-negative rate.'];if(!rates.some(k=>v[k]!==''&&Number(v[k])>0))return['input','Enter at least one positive rate.']},onSubmit:async v=>{const price={};for(const k of rates)if(v[k]!=='')price[k]=Number(v[k]);await settingsAPI({action:'config',key:'budget.prices.'+v.model,value:JSON.stringify(price)});await settingsLoad();toast('Price saved',true)}})}
function settingsRender(){const d=SETTINGS.data;if(!d)return;const cfg=d.config||{},m=d.models||{},owner=d.owner===true,button=(text,onclick,primary=false)=>el('button',{type:'button',class:primary?'primary':'',onclick},text);
$('set-models-body').replaceChildren(el('div',{class:'colhead'},el('h2',{},'Models')),settingsSection('Configured',settingsTable(['Where','Model'],(m.configured||[]).map(r=>[el('span',{},word(r.kind)+' · '+r.name,r.cwd?el('small',{class:'tm-why'},r.cwd):null),r.model||'Tool default · not configured here']))),settingsSection('Actually used · '+(m.window||'last 30 days'),el('p',{class:'mute'},'Recorded by worker runs and chat replies. Tool profiles can override configured defaults.'),settingsTable(['Where','Recorded model','Count','Last used'],(m.used||[]).map(r=>[r.kind+' · '+(r.role||r.tool),el('span',{},r.model||'unknown',r.differs?el('small',{class:'tm-why'},'Differs from configured '+r.configured_model):null),r.count,r.last_used]))),settingsSection('Available from gateway',el('p',{class:m.gateway_status==='unreachable'?'set-failure':'mute',role:'status'},m.gateway_status==='available'?'Gateway reachable':m.gateway_status==='unreachable'?'Gateway unreachable. Refresh to try again.':'Gateway not configured.'),m.gateway_status==='available'?settingsTable(['Model','Price'],(m.available||[]).map(r=>[r.model,r.priced?'Configured':'Not configured'])):null),settingsSection('Model prices',el('p',{class:'mute'},'USD per million tokens. A dash means no rate is configured.'),settingsTable(['Model','Input','Output','Cache read','Cache write',...(owner?['']:[])],Object.entries(m.prices||{}).map(([name,p])=>[name,...['input','output','cache_read','cache_write'].map(k=>p[k]??'—'),...(owner?[button('Edit',()=>settingsPrice(name))]:[])])),owner?button('Add price',()=>settingsPrice(),true):null),...(m.problems||[]).map(p=>el('p',{class:'set-failure'},p)));
Expand All @@ -1850,7 +1852,7 @@ <h3>Sign-in</h3><div id="set-access"></div><h3>Notifications</h3><div id="set-pe
$('set-dispatch').textContent='Start workers from the server: '+(cfg['dash.dispatch']?'On.':'Off.')+' Change from the terminal with agentd config set dash.dispatch true|false.';
$('set-connections-body').replaceChildren(el('div',{class:'colhead'},el('h2',{},'Connections')),settingsPairs([['Synced repos',(cfg['sync.repos']||[]).join(', ')||'None'],['MCP tools',cfg['mcp.tools']||'core'],['MCP origins',(cfg['mcp.allowed_origins']||[]).join(', ')||'None'],['Gateway',cfg['gateway.url']],['Gateway credential',cfg['gateway.key_file']],['Runtime',cfg['runtime.url']],['Runtime credential',cfg['runtime.password_file']],['Server address',cfg['dash.base_url']],['Strict users',cfg['users.strict']],['Prompt forwarding',cfg['dash.push_prompts']]]),el('p',{class:'mute'},'Connections and settings that widen access are changed from the terminal.'),settingsSection('Chat roles and tools',settingsTable(['Role','Model','Tools'],(d.chat_roles||[]).map(r=>[r.name,r.model,(r.tools||[]).join(', ')]))));
$('set-diagnostics-body').replaceChildren(el('div',{class:'colhead'},el('h2',{},'Diagnostics')),el('p',{class:'mute'},owner?'Open this group to run doctor and read service status.':'Diagnostics require an owner.'));
settingsTerminal(cfg);settingsApp();settingsAgentsRest(cfg,m,owner);
settingsTerminal(cfg);settingsCloud(cfg,owner,button);settingsApp();settingsAgentsRest(cfg,m,owner);
settingsShow(SETTINGS.section);settingsAccess()}
function settingsInviteResult(r){if(ROUTE.item!=='settings'){toast('Invitation created. Resend from Settings to get a new link.',true);return}const box=$('set-invite-once');box.replaceChildren();box.hidden=!r.link&&!r.temp_password;
// A new person's invitation comes with a one-time password, shown here once beside
Expand Down Expand Up @@ -1913,6 +1915,21 @@ <h3>Sign-in</h3><div id="set-access"></div><h3>Notifications</h3><div id="set-pe
el('div',{class:'set-card'},el('h3',{},'Default for new tasks'),settingsPairs([['Agent',{claude:'Claude Code',codex:'Codex',opencode:'opencode'}[tool]||tool]]),el('p',{class:'mute'},'The worker when a task, its offer and its role name none. ',owner?['Change it under ',el('a',{href:'#settings/workers'},'Workers'),'.']:'An owner changes it under Workers.')),
el('div',{class:'set-card'},el('h3',{},'Settings that widen access'),el('p',{class:'mute'},'The terminal, triggers, a dash address beyond loopback and worker rules are changed from a terminal, never from this page. Each shows its current value and the command.'),settingsWiden(cfg))));
}
// Settings > Cloud (#871): the path of the person's own claude setup-token and when it expires, a year
// from when it was first set. The page never sees the token; AgentD never makes or renews it.
const CLOUD_TOKEN_STATE={ok:'Valid','expires soon':'Expires soon',expired:'Expired',missing:'File missing','not configured':'Not configured'};
function settingsCloud(cfg,owner,button){const t=cfg['cloud.claude_token']||{},day=v=>v?String(v).slice(0,10):'',running=cfg['cloud.subscription_running']||1,
expires=t.expires?day(t.expires)+(t.days_left>0?' · '+t.days_left+' days left':''):'',edit=(key,label,value)=>owner?button('Edit',()=>settingsEdit(key,label,value)):'';
$('set-cloud-body').replaceChildren(el('div',{class:'colhead'},el('h2',{},'Cloud')),
settingsTable(['Setting','Value',...(owner?['']:[])],[
['Claude token file',cfg['cloud.claude_token_file']||'Not configured',...(owner?[edit('cloud.claude_token_file','Claude token file (absolute path)',cfg['cloud.claude_token_file'])]:[])],
['Token',el('span',{'data-token-state':t.state||'not configured'},CLOUD_TOKEN_STATE[t.state]||t.state||'Not configured',t.note?el('small',{class:'tm-why'},t.note):null),...(owner?['']:[])],
['First set',day(t.set_at),...(owner?['']:[])],
['Expires',expires,...(owner?['']:[])],
['Jobs at once on this token',String(running),...(owner?[edit('cloud.subscription_running','Jobs at once on this token (1 to 8)',running)]:[])]]),
t.state==='expired'||t.state==='expires soon'||t.state==='missing'?el('p',{role:'status',class:'set-failure'},'Run ',el('code',{},'claude setup-token'),' on your own machine and save the new token in the same file.'):null,
el('p',{class:'mute'},'Make the token yourself with ',el('code',{},'claude setup-token'),' on your own machine, save it alone in a file and ',el('code',{},'chmod 600'),' it. A token lasts one year; the expiry here counts a year from when the file was first set. AgentD never makes or renews it. Offer with ',el('code',{},'--cloud --model-access subscription'),'.'),
el('p',{class:'mute'},'Anthropic’s plan limits assume ordinary, individual use. Each job you run at once on your subscription counts against your plan, so more jobs at once reach its limit sooner. A job stopped by the limit ends plan_limited with its branch kept; offer it again once the limit resets.'))}
function settingsTerminal(cfg){$('set-terminal-body').replaceChildren(el('div',{class:'colhead'},el('h2',{},'Terminal')),
settingsPairs([['Terminal in the server',cfg['dash.terminal']?'On: owners get a shell on a task, on loopback only':'Off (the default)'],['Beyond loopback',cfg['dash.terminal_remote']?'On: a server listening beyond loopback (--public) also offers it':'Off']]),
el('p',{class:'mute'},'This widens access, so it is never changed from this page. To change it, set ',el('code',{},'terminal = true'),' (and only if you must, ',el('code',{},'terminal_remote = true'),') under [dash] in config.toml, then restart the server. ',el('code',{},'agentd doctor'),' shows it as dash-terminal.'))}
Expand Down
Loading