loopengine 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,169 +7,210 @@
7
7
  // why the look is a shared import rather than a third copy of the same CSS.
8
8
  import { devUiCss } from './dev-ui-styles.js';
9
9
  import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
10
+ import { MASCOT_CSS, mascotSvg } from './mascot.js';
10
11
  export const agentsListPageHtml = `<!doctype html>
11
12
  <html lang="en">
12
13
  <head>
13
14
  <meta charset="utf-8">
14
15
  <meta name="viewport" content="width=device-width, initial-scale=1">
15
16
  <title>LoopEngine Agents</title>
16
- <style>${devUiCss}
17
- #agentUl { list-style: none; margin: 0; padding: 0; }
18
- #agentUl li { display: contents; }
19
- .agent-card { display: grid; gap: 10px; align-content: start; }
20
- .agent-card .name { font-weight: 600; font-size: 15px; }
21
- .agent-card .prompt { font-size: 12.5px; color: var(--ink-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
22
- .agent-card .does { font-size: 13px; color: var(--ink); line-height: 1.45; }
23
- .agent-card .does a { color: var(--accent-ink); text-decoration: none; }
24
- .agent-card .does .hint { font-size: 12.5px; }
25
- .agent-card .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
26
- .agent-card .links a { font-size: 12.5px; font-weight: 500; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; color: var(--ink); }
27
- .agent-card .links a.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
28
- #empty { color: var(--ink-muted); }
29
- .hint { font-size: 12px; color: var(--ink-muted); }
17
+ <style>${devUiCss}${MASCOT_CSS}
18
+ .ag { max-width: 1120px; display: grid; gap: 0; }
19
+ .ag-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 36px 32px 28px; border: 1px solid var(--line); border-bottom: 0; }
20
+ .ag-hero .le-mascot { flex: none; margin-bottom: -6px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .12)); }
21
+ .ag-cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
22
+ .ag-cols1 { grid-template-columns: minmax(0, 1fr); }
23
+ .ag-cols1[hidden] { display: none; }
24
+ .ag-card { display: grid; gap: 14px; align-content: start; padding: 20px 22px; background: var(--bg); }
25
+ .ag-filler { background: var(--bg); }
26
+ .ag-card-head { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
27
+ .ag-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-muted); box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
28
+ .ag-icon svg { width: 16px; height: 16px; }
29
+ .ag-icon.live { color: var(--good); }
30
+ .ag-card-text { display: grid; gap: 3px; min-width: 0; }
31
+ .ag-card-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; color: var(--ink); text-decoration: none; }
32
+ a.ag-card-title:hover { text-decoration: underline; }
33
+ .ag-id { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); font-weight: 400; margin-left: 6px; }
34
+ .ag-card-desc { font-size: 13px; line-height: 1.5; color: var(--ink-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
35
+ .ag-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
36
+ .ag-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); white-space: nowrap; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
37
+ .ag-chip.strong { background: var(--surface); border-color: transparent; color: var(--ink); font-weight: 500; }
38
+ .ag-chip.good { background: var(--good-soft); border-color: transparent; color: var(--good); font-weight: 600; }
39
+ .ag-chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); font-weight: 600; }
40
+ a.ag-chip:hover { color: var(--ink); border-color: var(--ink-faint); }
41
+ .ag-actions { display: flex; gap: 8px; align-items: center; }
42
+ .ag-actions a { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; text-decoration: none; border: 1px solid var(--line); color: var(--ink); background: var(--bg); }
43
+ .ag-actions a:hover { background: var(--surface); }
44
+ .ag-actions a.dark { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
45
+ .ag-actions a.dark:hover { opacity: .88; }
46
+ .ag-tile { display: grid; gap: 6px; align-content: start; padding: 22px; background: var(--bg); text-decoration: none; color: inherit; transition: background .15s; }
47
+ .ag-tile:hover { background: var(--surface); }
48
+ .ag-tile b { font-size: 15px; font-weight: 600; color: var(--ink); }
49
+ .ag-tile span { font-size: 13px; color: var(--ink-muted); line-height: 1.45; }
50
+ .ag-empty { padding: 40px 32px; text-align: center; color: var(--ink-muted); font-size: 14px; background: var(--bg); grid-column: 1 / -1; margin: 0; }
51
+ .ag-topbar-link { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 500; color: var(--ink); text-decoration: none; }
52
+ .ag-topbar-link:hover { background: var(--surface); }
53
+ .hint { font-size: 12.5px; color: var(--ink-muted); }
30
54
  .error { font-size: 13px; color: var(--bad); }
31
- #newAgentForm {
32
- border: 1px solid var(--line);
33
- border-radius: var(--radius);
34
- padding: 16px;
35
- display: grid;
36
- gap: 12px;
37
- max-width: 560px;
55
+ #newAgentResult { margin: 12px 2px 0; }
56
+ /* New agent, in a dialog like Create schedule. */
57
+ .ag-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .22); overflow: hidden; }
58
+ .ag-dialog::backdrop { background: rgba(20, 24, 25, .35); backdrop-filter: blur(3px); }
59
+ .ag-dialog form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100vh - 50px); }
60
+ .ag-dlg-head { display: flex; align-items: center; gap: 8px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
61
+ .ag-dlg-head h2 { margin: 0 auto 0 0; font-size: 18px; font-weight: 500; }
62
+ .ag-dlg-head button { height: 34px; padding: 0 14px; border-radius: 9px; font-size: 13px; }
63
+ .ag-dlg-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: auto; }
64
+ .ag-dlg-col { display: grid; align-content: start; }
65
+ .ag-dlg-col + .ag-dlg-col { border-left: 1px solid var(--line); background: var(--surface); }
66
+ .ag-field { display: grid; gap: 9px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
67
+ .ag-field > label, .ag-field-k { font-size: 14px; font-weight: 500; }
68
+ .ag-field label { display: grid; gap: 9px; }
69
+ .ag-field .hint { margin: 0; line-height: 1.45; }
70
+ .ag-field input, .ag-field select { height: 38px; border-radius: 9px; font-size: 13.5px; width: 100%; box-sizing: border-box; }
71
+ .ag-field textarea { min-height: 110px; border-radius: 9px; font-size: 13.5px; width: 100%; box-sizing: border-box; }
72
+ .ag-dlg-foot { padding: 12px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-muted); min-height: 46px; display: flex; align-items: center; }
73
+ .ag-dlg-foot:not(:has(.error[style*="block"])) { display: none; }
74
+ @media (max-width: 860px) {
75
+ .ag-hero { padding: 24px 18px 20px; }
76
+ .ag-hero .le-mascot { display: none; }
77
+ .ag-cols2 { grid-template-columns: minmax(0, 1fr); }
78
+ .ag-dlg-body { grid-template-columns: minmax(0, 1fr); }
79
+ .ag-dlg-col + .ag-dlg-col { border-left: 0; border-top: 1px solid var(--line); }
80
+ .le-search, .ag-topbar-link { display: none; }
38
81
  }
39
- #newAgentForm h2 { font-size: 15px; margin: 0; }
40
- #newAgentForm label { display: grid; gap: 4px; font-size: 13px; }
41
- #newAgentForm .row { display: flex; gap: 8px; flex-wrap: wrap; }
42
- #newAgentForm details summary { cursor: pointer; color: var(--ink-muted); font-size: 13px; }
43
- #newAgentForm details[open] { display: grid; gap: 10px; }
44
- #newAgentForm textarea { min-height: 72px; }
45
82
  </style>
46
83
  </head>
47
84
  <body data-le-page="agents">
48
85
  <div class="le-app">
49
86
  ${consoleSidebarHtml}
50
87
  <main class="le-main">
51
- <div class="le-head plain">
52
- <div class="le-head-row">
53
- <div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
54
- <div><h1>Agents</h1><p>Each agent has its own instructions, tools and permissions. Open one to chat with it, give it workflows, or change how it works.</p></div>
55
- </div>
56
- <div style="display:flex;gap:8px;flex-wrap:wrap"><a href="/interview" style="padding:6px 12px;border:1px solid var(--line);border-radius:6px;text-decoration:none;color:var(--ink);font-size:13px">Find your first agent</a>
57
- <button type="button" id="newAgentBtn" class="primary">New agent</button></div>
58
- </div>
59
- </div>
60
- <div class="le-scroll"><div class="le-page">
61
- <form id="newAgentForm" style="display:none">
62
- <p class="hint" style="margin:0">Not sure what to build? <a href="/interview">Find your first agent</a>: a short interview that suggests one and creates it. Then give it workflows, described in your own words or from an example.</p>
63
- <h2>New agent</h2>
64
- <label>Name <span class="hint">(what you'll see in the sidebar; you can change it later)</span>
65
- <input type="text" name="displayName" placeholder="Weather assistant" maxlength="60" required>
66
- </label>
67
- <label>ID <span class="hint">(lowercase and hyphens; its folder agents/&lt;id&gt;/ and API address use it, so it can't be changed later)</span>
68
- <input type="text" name="name" placeholder="weather-assistant" pattern="[a-z0-9]+(-[a-z0-9]+)*" required>
69
- </label>
70
- <label>Instructions <span class="hint">(who it is and the rules it always follows)</span>
71
- <textarea name="systemPrompt" placeholder="You are ..."></textarea>
72
- </label>
73
- <label>Model provider
74
- <select name="provider">
75
- <option value="openai" selected>openai</option>
76
- <option value="anthropic">anthropic</option>
77
- <option value="gemini">gemini</option>
78
- <option value="meta">meta</option>
79
- <option value="xai">xai</option>
80
- <option value="deepseek">deepseek</option>
81
- <option value="kimi">kimi</option>
82
- <option value="glm">glm</option>
83
- </select>
84
- </label>
85
- <label id="modelNameLabel">Model name <span class="hint">(choose Other&hellip; to type a model that isn't listed)</span>
86
- <input type="text" name="modelName" value="gpt-6-luna" placeholder="model name">
87
- </label>
88
- <div class="row">
89
- <button type="submit">Create agent</button>
90
- <button type="button" id="cancelNewAgentBtn">Cancel</button>
91
- </div>
92
- </form>
93
- <p class="error" id="newAgentError" style="display:none"></p>
88
+ <header class="le-topbar">
89
+ <button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
90
+ <h1 class="le-topbar-title">Agents</h1>
91
+ <span class="le-topbar-gap"></span>
92
+ <label class="le-search"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg><input type="search" id="agSearch" placeholder="Search agents" aria-label="Search agents"></label>
93
+ <a class="ag-topbar-link" href="/interview">Find your first agent</a>
94
+ <button type="button" id="newAgentBtn" class="le-btn-dark">+ New agent</button>
95
+ </header>
96
+ <div class="le-scroll"><div class="le-page"><div class="ag">
97
+ <div class="ag-hero"><div><h2 class="le-display">Your agents</h2><p class="le-display-sub" id="agSub">Each has its own instructions, tools and permissions. Open one to chat with it, give it workflows, or change how it works.</p></div>${mascotSvg(92)}</div>
98
+ <div class="le-grid ag-cols2" id="agentUl"><p class="ag-empty">Loading&hellip;</p></div>
94
99
  <p class="hint" id="newAgentResult" style="display:none"></p>
95
- <ul id="agentUl" class="le-cards"></ul>
96
- <p id="empty" style="display:none">No agents yet. Create one above, or add a folder under agents/.</p>
97
- </div></div>
100
+ </div></div></div>
98
101
  </main>
99
102
  </div>
103
+ <dialog class="ag-dialog" id="newAgentDialog" aria-labelledby="agDlgTitle">
104
+ <form id="newAgentForm">
105
+ <div class="ag-dlg-head"><h2 id="agDlgTitle">New agent</h2><button type="button" id="cancelNewAgentBtn">Cancel</button><button type="submit" class="primary">Create agent</button></div>
106
+ <div class="ag-dlg-body">
107
+ <div class="ag-dlg-col">
108
+ <div class="ag-field"><label for="agDisplayName">Name</label><input type="text" id="agDisplayName" name="displayName" placeholder="Weather assistant" maxlength="60" required><p class="hint">What you'll see in the sidebar. You can change it later.</p></div>
109
+ <div class="ag-field"><label for="agId">ID</label><input type="text" id="agId" name="name" placeholder="weather-assistant" pattern="[a-z0-9]+(-[a-z0-9]+)*" required><p class="hint">Lowercase and hyphens. Its folder agents/&lt;id&gt;/ and API address use it, so it can't be changed later.</p></div>
110
+ <div class="ag-field"><label for="agPrompt">Instructions</label><textarea id="agPrompt" name="systemPrompt" placeholder="You are ..."></textarea><p class="hint">Who it is and the rules it always follows. Its workflows say what to do.</p></div>
111
+ </div>
112
+ <div class="ag-dlg-col">
113
+ <div class="ag-field"><label for="agProvider">Model provider</label>
114
+ <select id="agProvider" name="provider">
115
+ <option value="openai" selected>openai</option>
116
+ <option value="anthropic">anthropic</option>
117
+ <option value="gemini">gemini</option>
118
+ <option value="meta">meta</option>
119
+ <option value="xai">xai</option>
120
+ <option value="deepseek">deepseek</option>
121
+ <option value="kimi">kimi</option>
122
+ <option value="glm">glm</option>
123
+ </select></div>
124
+ <div class="ag-field" id="modelNameLabel"><label>Model name
125
+ <input type="text" name="modelName" value="gpt-6-luna" placeholder="model name"></label><p class="hint">Choose Other&hellip; to type a model that isn't listed.</p></div>
126
+ <div class="ag-field"><span class="ag-field-k">Not sure what to build?</span><p class="hint"><a href="/interview">Find your first agent</a>: a short interview suggests one that fits your work and creates it. Then give it workflows, in your own words or from an example.</p></div>
127
+ </div>
128
+ </div>
129
+ <div class="ag-dlg-foot"><p class="error" id="newAgentError" style="display:none;margin:0"></p></div>
130
+ </form>
131
+ </dialog>
100
132
  ${consoleShellScript}
101
133
  <script>
102
134
  (function () {
103
135
  var agentUl = document.getElementById('agentUl');
104
- var empty = document.getElementById('empty');
105
136
  var newAgentBtn = document.getElementById('newAgentBtn');
137
+ var newAgentDialog = document.getElementById('newAgentDialog');
106
138
  var newAgentForm = document.getElementById('newAgentForm');
107
139
  var newAgentError = document.getElementById('newAgentError');
108
140
  var newAgentResult = document.getElementById('newAgentResult');
109
141
  var cancelNewAgentBtn = document.getElementById('cancelNewAgentBtn');
142
+ var search = document.getElementById('agSearch');
143
+ var ICON_AGENT = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="7" width="16" height="12" rx="3"/><path d="M12 3v4"/><circle cx="9" cy="13" r="1"/><circle cx="15" cy="13" r="1"/></svg>';
144
+
145
+ var agents = [];
146
+ var workflowsBy = null;
147
+
148
+ function escapeHtml(s) {
149
+ return String(s).replace(/[&<>"']/g, function (c) {
150
+ return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
151
+ });
152
+ }
110
153
 
111
- var agentNames = [];
112
- // What each agent does, from its workflows: on each card, the first
113
- // few by name, each opening its page.
154
+ // Each agent as a card: its name, its instructions in a line or two,
155
+ // what it does (its workflows, from /workflows/overview), Chat and Open.
156
+ function cardHtml(agent) {
157
+ var qs = '?agent=' + encodeURIComponent(agent.name);
158
+ var list = workflowsBy ? workflowsBy[agent.name] || [] : null;
159
+ var live = list ? list.filter(function (w) { return w.live; }).length : 0;
160
+ var chips = list === null ? '<span class="ag-chip">' + String.fromCharCode(8230) + '</span>'
161
+ : list.length
162
+ ? '<span class="ag-chip strong">' + list.length + (list.length === 1 ? ' workflow' : ' workflows') + '</span>' + (live ? '<span class="ag-chip good">' + live + ' running</span>' : '') +
163
+ list.slice(0, 3).map(function (w) { return '<a class="ag-chip" href="/agents/config' + qs + '&tab=workflows&workflow=' + encodeURIComponent(w.id) + '" title="' + escapeHtml(w.title) + '">' + escapeHtml(w.title) + '</a>'; }).join('') +
164
+ (list.length > 3 ? '<span class="hint">+' + (list.length - 3) + ' more</span>' : '')
165
+ : '<a class="ag-chip" href="/workflows/new' + qs + '">No workflows yet: give it one</a>';
166
+ return '<div class="ag-card">' +
167
+ '<div class="ag-card-head"><span class="ag-icon' + (live ? ' live' : '') + '">' + ICON_AGENT + '</span>' +
168
+ '<span class="ag-card-text"><a class="ag-card-title" href="/agents/config' + qs + '">' + escapeHtml(agent.displayName || agent.name) + (agent.displayName ? '<span class="ag-id">' + escapeHtml(agent.name) + '</span>' : '') + '</a>' +
169
+ (agent.systemPrompt ? '<span class="ag-card-desc">' + escapeHtml(agent.systemPrompt) + '</span>' : '') + '</span>' +
170
+ '<span class="ag-actions"><a class="dark" href="/playground' + qs + '">Chat</a><a href="/agents/config' + qs + '">Open</a></span></div>' +
171
+ '<div class="ag-chips">' + chips + (agent.toSet ? '<a class="ag-chip warn" href="/agents/config' + qs + '&tab=env">' + agent.toSet + (agent.toSet === 1 ? ' setting' : ' settings') + ' to set</a>' : '') + '</div>' +
172
+ '</div>';
173
+ }
174
+
175
+ function render() {
176
+ var q = (search.value || '').trim().toLowerCase();
177
+ var shown = agents.filter(function (a) { return !q || [a.name, a.displayName || '', a.systemPrompt || ''].join(' ').toLowerCase().indexOf(q) !== -1; });
178
+ var total = workflowsBy ? Object.keys(workflowsBy).reduce(function (n, k) { return n + workflowsBy[k].length; }, 0) : 0;
179
+ if (agents.length) document.getElementById('agSub').textContent = agents.length + (agents.length === 1 ? ' agent' : ' agents') + (total ? ', ' + total + (total === 1 ? ' workflow' : ' workflows') : '') + '. Open one to chat with it, give it workflows, or change how it works.';
180
+ var tiles = q ? [] : ['<a class="ag-tile" href="/agents?new=1" data-new-tile><b>+ New agent</b><span>Its own instructions, tools and permissions, for one area of your work.</span></a>',
181
+ '<a class="ag-tile" href="/interview"><b>Find an agent to build</b><span>A short interview suggests one that fits your work, and creates it.</span></a>'];
182
+ var cells = shown.map(cardHtml).concat(tiles);
183
+ agentUl.innerHTML = !agents.length && !q ? tiles.join('')
184
+ : shown.length || tiles.length ? cells.join('') + (cells.length % 2 ? '<div class="ag-filler" aria-hidden="true"></div>' : '')
185
+ : '<p class="ag-empty">No agent matches.</p>';
186
+ var tile = agentUl.querySelector('[data-new-tile]');
187
+ if (tile) tile.addEventListener('click', function (ev) { ev.preventDefault(); newAgentBtn.click(); });
188
+ }
189
+ search.addEventListener('input', render);
190
+
191
+ // What each agent does, from its workflows.
114
192
  function fillWorkflows() {
115
193
  return fetch('/workflows/overview', { headers: { accept: 'application/json' } })
116
194
  .then(function (r) { return r.ok ? r.json() : null; })
117
195
  .then(function (d) {
118
- var by = {};
119
- ((d && d.workflows) || []).forEach(function (w) { (by[w.agent] = by[w.agent] || []).push(w); });
120
- agentNames.forEach(function (name) {
121
- var box = document.querySelector('[data-agent-does="' + CSS.escape(name) + '"]');
122
- if (!box || !d) return;
123
- var list = by[name] || [];
124
- var link = function (w) { return '<a href="/agents/config?agent=' + encodeURIComponent(name) + '&tab=workflows&workflow=' + encodeURIComponent(w.id) + '">' + escapeHtml(w.title) + '</a>'; };
125
- box.innerHTML = list.length
126
- ? '<strong>' + list.length + (list.length === 1 ? ' workflow' : ' workflows') + ':</strong> ' + list.slice(0, 3).map(link).join(', ') + (list.length > 3 ? ' <span class="hint">and ' + (list.length - 3) + ' more</span>' : '')
127
- : '<span class="hint">No workflows yet. <a href="/workflows/new?agent=' + encodeURIComponent(name) + '">Give it one</a></span>';
128
- });
196
+ workflowsBy = {};
197
+ ((d && d.workflows) || []).forEach(function (w) { (workflowsBy[w.agent] = workflowsBy[w.agent] || []).push(w); });
198
+ render();
129
199
  })
130
200
  .catch(function () {});
131
201
  }
132
202
 
133
- function escapeHtml(s) {
134
- return String(s).replace(/[&<>"']/g, function (c) {
135
- return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
136
- });
137
- }
138
-
139
- // (Re)loads the list from GET /agents — factored out so a successful
140
- // create can refresh it directly instead of duplicating this fetch.
203
+ // (Re)loads the list from GET /agents.
141
204
  function loadAgents() {
142
205
  fetch('/agents')
143
206
  .then(function (r) { return r.json(); })
144
207
  .then(function (data) {
145
- var agents = data.agents || [];
146
- agentUl.textContent = '';
147
- agentNames = agents.map(function (a) { return a.name; });
148
- if (!agents.length) {
149
- empty.style.display = 'block';
150
- return;
151
- }
152
- empty.style.display = 'none';
153
- for (var i = 0; i < agents.length; i++) {
154
- var agent = agents[i];
155
- var li = document.createElement('li');
156
- var qs = '?agent=' + encodeURIComponent(agent.name);
157
- li.innerHTML =
158
- '<div class="le-card agent-card">' +
159
- '<div class="name">' + escapeHtml(agent.displayName || agent.name) + (agent.displayName ? ' <span class="hint" style="font-family:var(--font-mono);font-weight:400">' + escapeHtml(agent.name) + '</span>' : '') + '</div>' +
160
- '<div class="does" data-agent-does="' + escapeHtml(agent.name) + '"></div>' +
161
- '<div class="prompt">' + escapeHtml(agent.systemPrompt) + '</div>' +
162
- '<div class="links">' +
163
- '<a class="primary" href="/playground' + qs + '">Chat</a>' +
164
- '<a href="/agents/config' + qs + '">Open</a>' +
165
- '</div></div>';
166
- agentUl.appendChild(li);
167
- }
208
+ agents = data.agents || [];
209
+ render();
168
210
  })
169
211
  .then(fillWorkflows)
170
212
  .catch(function (err) {
171
- empty.textContent = 'Could not load agents: ' + err.message;
172
- empty.style.display = 'block';
213
+ agentUl.innerHTML = '<p class="ag-empty">Could not load agents: ' + escapeHtml(err.message) + '</p>';
173
214
  });
174
215
  }
175
216
 
@@ -206,9 +247,9 @@ ${consoleShellScript}
206
247
  newAgentForm.addEventListener('reset', function () { setTimeout(applyProviderKeys, 0); });
207
248
 
208
249
  newAgentBtn.addEventListener('click', function () {
209
- newAgentBtn.style.display = 'none';
210
- newAgentForm.style.display = 'grid';
211
250
  newAgentResult.style.display = 'none';
251
+ newAgentError.style.display = 'none';
252
+ if (!newAgentDialog.open) newAgentDialog.showModal();
212
253
  newAgentForm.querySelector('input[name="displayName"]').focus();
213
254
  // Checks which providers have keys, then loads the chosen provider's
214
255
  // models; both when the form opens, not on every visit to this page.
@@ -233,9 +274,9 @@ ${consoleShellScript}
233
274
  });
234
275
  newAgentForm.addEventListener('reset', function () { idTyped = false; });
235
276
 
277
+ newAgentDialog.addEventListener('click', function (ev) { if (ev.target === newAgentDialog) newAgentDialog.close(); });
236
278
  cancelNewAgentBtn.addEventListener('click', function () {
237
- newAgentForm.style.display = 'none';
238
- newAgentBtn.style.display = '';
279
+ newAgentDialog.close();
239
280
  newAgentError.style.display = 'none';
240
281
  });
241
282
 
@@ -269,8 +310,7 @@ ${consoleShellScript}
269
310
  .then(function (r) { return r.json().then(function (j) { return { ok: r.ok, body: j }; }); })
270
311
  .then(function (result) {
271
312
  if (!result.ok) throw new Error(result.body.error || 'request failed');
272
- newAgentForm.style.display = 'none';
273
- newAgentBtn.style.display = '';
313
+ newAgentDialog.close();
274
314
  newAgentForm.reset();
275
315
  newAgentResult.style.display = 'block';
276
316
  if (result.body.registered) {
@@ -23,27 +23,27 @@ export const auditPageHtml = `<!doctype html>
23
23
  <meta name="viewport" content="width=device-width, initial-scale=1">
24
24
  <title>Audit</title>
25
25
  <style>${devUiCss}
26
- .au { max-width: 1080px; display: grid; gap: 14px; }
27
- .au-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
28
- .au-bar select, .au-bar input { font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); max-width: 180px; }
29
- .au-bar input[type="search"] { flex: 1; min-width: 160px; max-width: none; }
30
- .au-bar [hidden] { display: none; }
31
- .au-actions { display: inline-flex; gap: 8px; margin-left: auto; }
32
- .au-verify { font-size: 13px; }
33
- .au-check { padding: 10px 14px; border-radius: 10px; font-size: 13px; background: var(--good-soft); color: var(--good); }
26
+ .au { max-width: 1180px; display: grid; gap: 14px; }
27
+ .au-topbar { flex-wrap: wrap; row-gap: 8px; }
28
+ .au-tool { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 13.5px; font-weight: 500; color: var(--ink); }
29
+ .au-tool:hover:not(:disabled) { background: var(--surface); }
30
+ .au-grid { grid-template-columns: minmax(0, 1fr); }
31
+ .au-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 20px; background: var(--bg); }
32
+ .au-bar select { height: 34px; padding: 0 10px; border: 0; border-radius: 9px; background: var(--surface); font-size: 13px; color: var(--ink); max-width: 200px; }
33
+ .au-check { padding: 12px 16px; border-radius: 10px; font-size: 13px; background: var(--good-soft); color: var(--good); }
34
34
  .au-check.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
35
35
  .au-check .hint { display: block; margin-top: 2px; font-weight: 400; }
36
- .au-summary { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 10px; background: var(--bg); }
36
+ .au-summary { border: 1px solid var(--line); padding: 18px 20px; display: grid; gap: 10px; background: var(--bg); }
37
37
  .au-summary[hidden], .au-check[hidden] { display: none; }
38
- .au-summary h2 { margin: 0; font-size: 15px; }
38
+ .au-summary h2 { margin: 0; font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
39
39
  .au-summary ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 13.5px; line-height: 1.5; }
40
40
  .au-summary-tools { display: flex; gap: 8px; flex-wrap: wrap; }
41
- .au-summary-tools a { font-size: 13px; font-weight: 600; color: var(--accent-ink); text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; }
41
+ .au-summary-tools a { display: inline-flex; align-items: center; height: 32px; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; }
42
42
  .au-summary-tools a.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
43
- .au-export { font-size: 13px; font-weight: 600; color: var(--accent-ink); text-decoration: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
44
- .au-list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
45
- .au-row, .au-head { display: grid; grid-template-columns: 136px minmax(0, 170px) minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; }
46
- .au-head { border-top: 0; padding-top: 8px; padding-bottom: 8px; background: var(--surface); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); }
43
+ .au-list { background: var(--bg); }
44
+ .au-row, .au-head { display: grid; grid-template-columns: 136px minmax(0, 170px) minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13.5px; }
45
+ .au-row:hover { background: var(--surface); }
46
+ .au-head { padding-top: 10px; padding-bottom: 10px; background: var(--surface); font-size: 12px; font-weight: 500; color: var(--ink-faint); }
47
47
  .au-who { overflow-wrap: anywhere; }
48
48
  .au-who.system { color: var(--ink-muted); font-style: italic; }
49
49
  .au-res { display: grid; gap: 1px; min-width: 0; }
@@ -71,10 +71,11 @@ export const auditPageHtml = `<!doctype html>
71
71
  .chg-ins { background: var(--good-soft); color: var(--good); padding: 1px 6px; }
72
72
  .chg-note { color: var(--ink-muted); font-family: inherit; font-weight: 400; }
73
73
  .chg details summary { cursor: pointer; color: var(--accent-ink); font-family: var(--font-sans, inherit); font-size: 12px; margin-top: 2px; }
74
- .au-empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); font-size: 13.5px; }
75
- .au-more { justify-self: center; }
74
+ .au-empty { margin: 0; padding: 40px 20px; text-align: center; color: var(--ink-muted); font-size: 13.5px; }
75
+ .au-more { justify-self: center; height: 34px; padding: 0 14px; border-radius: 9px; }
76
76
  .error { font-size: 13px; color: var(--bad); margin: 0; }
77
77
  @media (max-width: 720px) {
78
+ .le-search { display: none; }
78
79
  .au-head { display: none; }
79
80
  .au-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
80
81
  }
@@ -84,31 +85,34 @@ export const auditPageHtml = `<!doctype html>
84
85
  <div class="le-app">
85
86
  ${consoleSidebarHtml}
86
87
  <main class="le-main">
87
- <div class="le-head plain">
88
- <div class="le-head-row">
89
- <div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
90
- <div><h1>Audit</h1><p>Who did what, when, and to which resource, across the workspace: workflows created, edited, published and deleted, and every other setting changed. Runs are on each workflow's Activity tab.</p></div>
91
- </div>
92
- </div>
93
- </div>
88
+ <header class="le-topbar au-topbar">
89
+ <button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
90
+ <h1 class="le-topbar-title">Audit</h1>
91
+ <span class="le-seg" role="tablist" aria-label="Show" id="auKinds">
92
+ <button type="button" role="tab" data-kind="change" aria-selected="true">Changes</button><button type="button" role="tab" data-kind="decision" aria-selected="false">Approvals</button><button type="button" role="tab" data-kind="answer" aria-selected="false">Answers</button><button type="button" role="tab" data-kind="feedback" aria-selected="false">Feedback</button><button type="button" role="tab" data-kind="all" aria-selected="false">Everything</button>
93
+ </span>
94
+ <span class="le-topbar-gap"></span>
95
+ <label class="le-search"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg><input type="search" id="auQ" placeholder="Search the log" aria-label="Search"></label>
96
+ <button type="button" class="au-tool" id="auVerify">Verify log</button>
97
+ <a class="le-btn-dark" id="auExport" href="/audit/events.csv" download>Export CSV</a>
98
+ </header>
94
99
  <div class="le-scroll"><div class="le-page"><div class="au">
95
- <div class="au-bar">
96
- <select id="auAgent" aria-label="Agent"><option value="">All agents</option></select>
97
- <select id="auWorkflow" aria-label="Workflow"><option value="">All workflows</option></select>
98
- <select id="auBy" aria-label="Person"><option value="">Anyone</option></select>
99
- <select id="auKind" aria-label="Kind">
100
- <option value="change">Changes to workflows and settings</option><option value="decision">Approvals in runs</option><option value="answer">Answers in runs</option><option value="feedback">Feedback on runs</option><option value="all">Everything</option>
101
- </select>
102
- <select id="auPeriod" aria-label="Period">
103
- <option value="7">Last 7 days</option><option value="30" selected>Last 30 days</option><option value="90">Last 90 days</option><option value="365">Last year</option><option value="">All time</option>
104
- </select>
105
- <input type="search" id="auQ" placeholder="Search" aria-label="Search">
106
- <span class="au-actions"><button type="button" class="au-verify" id="auVerify">Verify log</button>
107
- <a class="au-export" id="auExport" href="/audit/events.csv" download>Export CSV</a></span>
108
- </div>
100
+ <select id="auKind" aria-label="Kind" hidden>
101
+ <option value="change">Changes to workflows and settings</option><option value="decision">Approvals in runs</option><option value="answer">Answers in runs</option><option value="feedback">Feedback on runs</option><option value="all">Everything</option>
102
+ </select>
109
103
  <div class="au-check" id="auCheck" role="status" hidden></div>
110
104
  <section class="au-summary" id="auSummary" hidden></section>
111
- <div id="auList"><p class="hint">Loading&hellip;</p></div>
105
+ <div class="le-grid au-grid">
106
+ <div class="au-bar">
107
+ <select id="auAgent" aria-label="Agent"><option value="">All agents</option></select>
108
+ <select id="auWorkflow" aria-label="Workflow"><option value="">All workflows</option></select>
109
+ <select id="auBy" aria-label="Person"><option value="">Anyone</option></select>
110
+ <select id="auPeriod" aria-label="Period">
111
+ <option value="7">Last 7 days</option><option value="30" selected>Last 30 days</option><option value="90">Last 90 days</option><option value="365">Last year</option><option value="">All time</option>
112
+ </select>
113
+ </div>
114
+ <div id="auList"><p class="hint" style="padding:16px 20px;margin:0">Loading&hellip;</p></div>
115
+ </div>
112
116
  <button type="button" class="au-more" id="auMore" hidden>Load older</button>
113
117
  </div></div></div>
114
118
  </main>
@@ -259,7 +263,7 @@ ${consoleShellScript}
259
263
  var url = '/audit/events?';
260
264
  var extra = append && next != null ? { before: String(next) } : {};
261
265
  extra.limit = '100';
262
- if (!append) list.innerHTML = '<p class="hint">Loading' + String.fromCharCode(8230) + '</p>';
266
+ if (!append) list.innerHTML = '<p class="hint" style="padding:16px 20px;margin:0">Loading' + String.fromCharCode(8230) + '</p>';
263
267
  more.hidden = true;
264
268
  return fetch(url + query(extra), { headers: { accept: 'application/json' } })
265
269
  .then(function (r) { return r.ok ? r.json() : r.json().then(function (b) { throw new Error(b.error || 'HTTP ' + r.status); }); })
@@ -357,6 +361,21 @@ ${consoleShellScript}
357
361
 
358
362
  el.q.value = state.q;
359
363
  el.kind.value = state.kind;
364
+ // The kinds, as the top bar's segmented control: each picks the hidden
365
+ // select's value, so the rest reads it as before.
366
+ var kinds = document.getElementById('auKinds');
367
+ function markKind() {
368
+ var bs = kinds.querySelectorAll('[data-kind]');
369
+ for (var b = 0; b < bs.length; b++) bs[b].setAttribute('aria-selected', String(bs[b].getAttribute('data-kind') === el.kind.value));
370
+ }
371
+ kinds.addEventListener('click', function (ev) {
372
+ var b = ev.target.closest('[data-kind]');
373
+ if (!b || b.getAttribute('data-kind') === el.kind.value) return;
374
+ el.kind.value = b.getAttribute('data-kind');
375
+ markKind();
376
+ el.kind.dispatchEvent(new Event('change'));
377
+ });
378
+ markKind();
360
379
  el.period.value = state.period;
361
380
  function fillFilters(f) {
362
381
  filters = f;