loopengine 0.3.90 → 0.3.91
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.
- package/dist/web/console-shell.js +47 -23
- package/dist/web/dev-ui-styles.js +5 -4
- package/package.json +1 -1
|
@@ -86,6 +86,29 @@ export const consoleShellScript = `<script>
|
|
|
86
86
|
}
|
|
87
87
|
function enc(s) { return encodeURIComponent(s); }
|
|
88
88
|
|
|
89
|
+
// The sidebar's lists, kept in this tab's session storage: a page shows
|
|
90
|
+
// the last ones at once, then fetches them again and redraws only if
|
|
91
|
+
// something changed. Each console page is a full page load, so without
|
|
92
|
+
// this every click would redraw the lists from empty.
|
|
93
|
+
function recall(key) {
|
|
94
|
+
try { var v = sessionStorage.getItem('le-side:' + key); return v ? JSON.parse(v) : null; } catch (e) { return null; }
|
|
95
|
+
}
|
|
96
|
+
function remember(key, value) {
|
|
97
|
+
try { sessionStorage.setItem('le-side:' + key, JSON.stringify(value)); } catch (e) {}
|
|
98
|
+
}
|
|
99
|
+
function cachedFetch(key, url, render) {
|
|
100
|
+
var seen = recall(key);
|
|
101
|
+
if (seen) { try { render(seen); } catch (e) {} }
|
|
102
|
+
return fetch(url, { headers: { accept: 'application/json' } })
|
|
103
|
+
.then(function (r) { return r.ok ? r.json() : null; })
|
|
104
|
+
.then(function (data) {
|
|
105
|
+
if (!data) return;
|
|
106
|
+
if (!seen || JSON.stringify(seen) !== JSON.stringify(data)) render(data);
|
|
107
|
+
remember(key, data);
|
|
108
|
+
})
|
|
109
|
+
.catch(function () {});
|
|
110
|
+
}
|
|
111
|
+
|
|
89
112
|
// Who is signed in and their role (GET /config/settings), read once.
|
|
90
113
|
var settings = fetch('/config/settings')
|
|
91
114
|
.then(function (r) { return r.ok ? r.json() : null; })
|
|
@@ -150,8 +173,11 @@ export const consoleShellScript = `<script>
|
|
|
150
173
|
fetch('/agents/' + enc(a.name) + '/env')
|
|
151
174
|
.then(function (r) { return r.ok ? r.json() : []; })
|
|
152
175
|
.then(function (vars) {
|
|
153
|
-
|
|
154
|
-
|
|
176
|
+
var n = (vars || []).filter(function (v) { return v.slot === 'agent' && v.scope === 'agent' && !v.set; }).length;
|
|
177
|
+
var changed = toSet[a.name] !== n;
|
|
178
|
+
toSet[a.name] = n;
|
|
179
|
+
remember('toSet', toSet);
|
|
180
|
+
if (changed) renderList();
|
|
155
181
|
var slots = document.querySelectorAll('[data-le-env-count="' + a.name + '"]');
|
|
156
182
|
for (var i = 0; i < slots.length; i++) slots[i].innerHTML = envCountHtml(a.name);
|
|
157
183
|
})
|
|
@@ -167,9 +193,7 @@ export const consoleShellScript = `<script>
|
|
|
167
193
|
var goalList = document.getElementById('leGoalList');
|
|
168
194
|
function reloadGoals() {
|
|
169
195
|
if (!goalList) return Promise.resolve();
|
|
170
|
-
return
|
|
171
|
-
.then(function (r) { return r.ok ? r.json() : { goals: [] }; })
|
|
172
|
-
.then(function (data) {
|
|
196
|
+
return cachedFetch('goals', '/goals', function (data) {
|
|
173
197
|
var goals = data.goals || [];
|
|
174
198
|
// The Jobs page is the Goals page's jobs view; it marks Jobs instead.
|
|
175
199
|
var onJobs = location.pathname === '/jobs';
|
|
@@ -183,8 +207,7 @@ export const consoleShellScript = `<script>
|
|
|
183
207
|
return '<li><a class="le-agent-item le-goal-item" href="/goals?goal=' + enc(g.id) + '" title="' + esc(g.goal) + '"' + (g.id === current ? ' aria-current="page"' : '') + '>' +
|
|
184
208
|
'<span class="le-dot' + (g.status === 'planning' ? ' warn' : '') + '" aria-hidden="true"></span><span class="le-name">' + esc(g.goal) + '</span></a></li>';
|
|
185
209
|
}).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No goals yet</span><span></span></li>';
|
|
186
|
-
})
|
|
187
|
-
.catch(function () { goalList.innerHTML = ''; });
|
|
210
|
+
});
|
|
188
211
|
}
|
|
189
212
|
fullAccess.then(function (full) { if (full) reloadGoals(); });
|
|
190
213
|
|
|
@@ -199,9 +222,7 @@ export const consoleShellScript = `<script>
|
|
|
199
222
|
var current = onJobs ? new URLSearchParams(location.search).get('job') : null;
|
|
200
223
|
var jobsHead = document.querySelector('[data-le-nav-head="jobs"]');
|
|
201
224
|
if (jobsHead) { if (onJobs && !current) jobsHead.setAttribute('aria-current', 'page'); else jobsHead.removeAttribute('aria-current'); }
|
|
202
|
-
return
|
|
203
|
-
.then(function (r) { return r.ok ? r.json() : { jobs: [] }; })
|
|
204
|
-
.then(function (data) {
|
|
225
|
+
return cachedFetch('jobs', '/jobs', function (data) {
|
|
205
226
|
var jobs = data.jobs || [];
|
|
206
227
|
jobList.innerHTML = jobs.length ? jobs.map(function (x) {
|
|
207
228
|
var j = x.job;
|
|
@@ -212,8 +233,7 @@ export const consoleShellScript = `<script>
|
|
|
212
233
|
return '<li><a class="le-agent-item le-goal-item" href="/jobs?job=' + enc(j.id) + '" title="' + esc(j.title) + ' (' + label + ')"' + (j.id === current ? ' aria-current="page"' : '') + '>' +
|
|
213
234
|
'<span class="le-dot' + dot + '" aria-hidden="true"></span><span class="le-name">' + esc(j.title) + '</span></a></li>';
|
|
214
235
|
}).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No jobs yet</span><span></span></li>';
|
|
215
|
-
})
|
|
216
|
-
.catch(function () { jobList.innerHTML = ''; });
|
|
236
|
+
});
|
|
217
237
|
}
|
|
218
238
|
fullAccess.then(function (full) { if (full) reloadJobs(); });
|
|
219
239
|
|
|
@@ -227,17 +247,14 @@ export const consoleShellScript = `<script>
|
|
|
227
247
|
var q = new URLSearchParams(location.search);
|
|
228
248
|
var currentAgent = page === 'agent-config' && q.get('tab') === 'workflows' ? q.get('agent') : null;
|
|
229
249
|
var currentId = currentAgent ? q.get('workflow') : null;
|
|
230
|
-
return
|
|
231
|
-
.then(function (r) { return r.ok ? r.json() : { workflows: [] }; })
|
|
232
|
-
.then(function (data) {
|
|
250
|
+
return cachedFetch('workflows', '/workflows/overview', function (data) {
|
|
233
251
|
var list = (data.workflows || []).slice().sort(function (a, b) { return a.title.localeCompare(b.title); });
|
|
234
252
|
workflowList.innerHTML = list.length ? list.map(function (w) {
|
|
235
253
|
var on = w.agent === currentAgent && w.id === currentId;
|
|
236
254
|
return '<li><a class="le-agent-item le-goal-item" href="/agents/config?agent=' + enc(w.agent) + '&tab=workflows&workflow=' + enc(w.id) + '" title="' + esc(w.title) + ' (' + esc(w.agentLabel) + DOT_SEP + (w.live ? 'Running' : 'Pending') + ')"' + (on ? ' aria-current="page"' : '') + '>' +
|
|
237
255
|
'<span class="le-dot ' + (w.live ? 'tint' : 'pending') + '" aria-hidden="true"></span><span class="le-name">' + esc(w.title) + '</span></a></li>';
|
|
238
256
|
}).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No workflows yet</span><span></span></li>';
|
|
239
|
-
})
|
|
240
|
-
.catch(function () { workflowList.innerHTML = ''; });
|
|
257
|
+
});
|
|
241
258
|
}
|
|
242
259
|
var DOT_SEP = ', ';
|
|
243
260
|
fullAccess.then(function (full) { if (full) reloadWorkflows(); });
|
|
@@ -251,24 +268,31 @@ export const consoleShellScript = `<script>
|
|
|
251
268
|
if (workflowsHead && page === 'workflows-overview') workflowsHead.setAttribute('aria-current', 'page');
|
|
252
269
|
function reloadInboxCount() {
|
|
253
270
|
if (!inboxCount) return;
|
|
254
|
-
|
|
255
|
-
.then(function (r) { return r.ok ? r.json() : { open: 0 }; })
|
|
256
|
-
.then(function (d) { inboxCount.textContent = String(d.open || 0); inboxCount.hidden = !d.open; inboxCount.title = (d.open || 0) + ' waiting for a decision'; })
|
|
257
|
-
.catch(function () {});
|
|
271
|
+
cachedFetch('inbox', '/inbox/count', function (d) { inboxCount.textContent = String(d.open || 0); inboxCount.hidden = !d.open; inboxCount.title = (d.open || 0) + ' waiting for a decision'; });
|
|
258
272
|
}
|
|
259
273
|
reloadInboxCount();
|
|
260
274
|
setInterval(function () { if (!document.hidden) reloadInboxCount(); }, 30000);
|
|
261
275
|
|
|
262
276
|
var loadError = null;
|
|
263
277
|
var ready = fullAccess.then(function (full) { return full ? loadAgents() : []; });
|
|
264
|
-
function loadAgents() {
|
|
278
|
+
function loadAgents() {
|
|
279
|
+
// The last list at once (with how many settings each still needs);
|
|
280
|
+
// the fresh one replaces it below.
|
|
281
|
+
var seen = recall('agents');
|
|
282
|
+
if (seen && seen.agents) {
|
|
283
|
+
agents = seen.agents;
|
|
284
|
+
toSet = recall('toSet') || {};
|
|
285
|
+
renderList();
|
|
286
|
+
}
|
|
287
|
+
return fetch('/agents', { headers: { accept: 'application/json' } })
|
|
265
288
|
.then(function (r) {
|
|
266
289
|
if (!r.ok) throw new Error(r.status === 401 ? 'sign-in required (HTTP 401)' : 'HTTP ' + r.status);
|
|
267
290
|
return r.json();
|
|
268
291
|
})
|
|
269
292
|
.then(function (data) {
|
|
270
293
|
agents = data.agents || [];
|
|
271
|
-
renderList();
|
|
294
|
+
if (!seen || JSON.stringify(seen.agents) !== JSON.stringify(agents)) renderList();
|
|
295
|
+
remember('agents', { agents: agents });
|
|
272
296
|
loadToSet();
|
|
273
297
|
return agents;
|
|
274
298
|
})
|
|
@@ -132,7 +132,7 @@ export const devUiCss = `
|
|
|
132
132
|
.le-nav-label { padding: 10px 16px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); display: flex; justify-content: space-between; align-items: center; }
|
|
133
133
|
.le-nav-label a { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; text-decoration: none; }
|
|
134
134
|
.le-nav-label a[aria-current="page"] { font-weight: 700; }
|
|
135
|
-
.le-nav-label a.le-nav-head { display: inline-flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: 0.06em; font-size:
|
|
135
|
+
.le-nav-label a.le-nav-head { display: inline-flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; font-weight: 600; color: inherit; }
|
|
136
136
|
.le-nav-icon { width: 15px; height: 15px; flex-shrink: 0; }
|
|
137
137
|
.le-nav-label a.le-nav-head:hover { color: var(--ink); }
|
|
138
138
|
.le-nav-label a.le-nav-head[aria-current="page"] { color: var(--accent-ink); font-weight: 700; }
|
|
@@ -143,11 +143,12 @@ export const devUiCss = `
|
|
|
143
143
|
.le-find { margin: auto 16px 10px; font-size: 12.5px; font-weight: 500; color: var(--accent-ink); text-decoration: none; }
|
|
144
144
|
.le-find[aria-current="page"] { font-weight: 600; }
|
|
145
145
|
.le-find + .le-find { margin-top: -4px; }
|
|
146
|
-
|
|
146
|
+
/* List items read smaller than their section's head. */
|
|
147
|
+
.le-agent-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 12.5px; }
|
|
147
148
|
.le-agent-item:hover { background: var(--surface-2); }
|
|
148
149
|
.le-agent-item[aria-current="page"] { background: var(--accent-soft); }
|
|
149
150
|
.le-agent-item .le-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
150
|
-
.le-agent-item .le-meta { font-size:
|
|
151
|
+
.le-agent-item .le-meta { font-size: 11.5px; color: var(--ink-faint); }
|
|
151
152
|
.le-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
|
|
152
153
|
.le-dot.warn { background: var(--warn); }
|
|
153
154
|
.le-dot.tint { background: var(--accent); }
|
|
@@ -156,7 +157,7 @@ export const devUiCss = `
|
|
|
156
157
|
.le-inbox-only .le-nav-group, .le-inbox-only .le-nav-label:not(.le-inbox-nav), .le-inbox-only .le-agent-list, .le-inbox-only .le-find, .le-inbox-only .le-foot > a { display: none; }
|
|
157
158
|
.le-dot.idle { background: var(--ink-faint); }
|
|
158
159
|
.le-foot { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
|
|
159
|
-
.le-foot a { padding:
|
|
160
|
+
.le-foot a { padding: 6px 8px; border-radius: 6px; color: var(--ink-muted); text-decoration: none; font-size: 13px; }
|
|
160
161
|
.le-foot a:hover { background: var(--surface-2); color: var(--ink); }
|
|
161
162
|
.le-foot a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
|
|
162
163
|
.le-who { padding: 10px 8px 4px; font-size: 12px; color: var(--ink-faint); display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
|