loopengine 0.3.89 → 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.
@@ -10,6 +10,9 @@ export interface ProxyIdentity {
10
10
  /** Where the person manages this workspace on the host, shown as the
11
11
  * console's "Dashboard" link. */
12
12
  dashboardUrl?: string;
13
+ /** For an approver or viewer limited to some agents (set in the host's
14
+ * dashboard): the ones they see. Absent for every agent. */
15
+ agents?: string[];
13
16
  /** Expiry, Unix seconds. */
14
17
  exp: number;
15
18
  }
@@ -4,6 +4,10 @@ export declare function workspaceRole(raw: string | undefined): WorkspaceRole;
4
4
  export declare function canDecide(role: WorkspaceRole): boolean;
5
5
  /** Sees only the Inbox. */
6
6
  export declare function inboxOnly(role: WorkspaceRole): boolean;
7
+ /** The agents a caller may see, or undefined for every agent: only an
8
+ * approver or viewer is ever limited, to the agents their signed identity
9
+ * lists (chosen in the host's dashboard). */
10
+ export declare function agentsFor(role: WorkspaceRole, agents: unknown): string[] | undefined;
7
11
  /** A role's name for people. */
8
12
  export declare function roleLabel(role: WorkspaceRole): string;
9
13
  /** What an Inbox-only role may reach: the Inbox and its data, deciding
@@ -26,6 +26,14 @@ export function canDecide(role) {
26
26
  export function inboxOnly(role) {
27
27
  return role === 'approver' || role === 'viewer';
28
28
  }
29
+ /** The agents a caller may see, or undefined for every agent: only an
30
+ * approver or viewer is ever limited, to the agents their signed identity
31
+ * lists (chosen in the host's dashboard). */
32
+ export function agentsFor(role, agents) {
33
+ if (!inboxOnly(role) || !Array.isArray(agents))
34
+ return undefined;
35
+ return agents.filter((a) => typeof a === 'string');
36
+ }
29
37
  /** A role's name for people. */
30
38
  export function roleLabel(role) {
31
39
  return role === 'api' ? 'API key' : role.charAt(0).toUpperCase() + role.slice(1);
package/dist/index.d.ts CHANGED
@@ -130,11 +130,11 @@ export type { AgentTemplateOptions } from './bin/cli.js';
130
130
  export { goalsPageHtml } from './web/goals-page.js';
131
131
  export { GoalError, acceptJob, addJob, assignJob, assignmentMessage, listJob, listJobs, submitJob, MY_JOBS_ID, type ListedJob, chainedRuns, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, type ChainStep, goalView, type AssignmentView, checkBuiltWorkflows, createGoal, deleteGoal, editAmount, generateMore, getGoal, goalContextFrom, listGoals, markBuilt, prepareBuild, readAbout, readGoalSettings, readLeverEvents, setWorkflowState, writeAbout, writeGoalSettings, type Goal, type GoalJob, type GoalJobState, type JobDoer, type GoalWorkflow, type GoalsDeps, type LeverEvent, migrateGoal, migrateGoalFiles } from './web/goals-admin.js';
132
132
  export { sendLeverEvents, sharesLeverStats, startLeverEventsSync } from './web/lever-events-sync.js';
133
+ export { createAgentNamesReporter, type AgentNamesReporter } from './web/agent-names-sync.js';
133
134
  export { runGoalPipeline, shapeJob, type GoalPlan, type GoalContext, type ShapedJob } from './core/system-agents/goal-planner.js';
134
135
  export { LEVERS, PLAYBOOK_VERSION, activePlaybook, setPlaybookProjectDir, type Lever } from './core/system-agents/goal-playbooks.js';
135
136
  export { startPlaybookSync, syncPlaybook, playbookSyncConfig } from './core/playbook-sync.js';
136
- export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, type WorkspaceRole } from './core/workspace-roles.js';
137
- export { readPeople, recordVisit, setPersonAgents, removePerson, agentsFor, type WorkspacePerson } from './core/workspace-people.js';
137
+ export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, agentsFor, type WorkspaceRole } from './core/workspace-roles.js';
138
138
  export { inboxPageHtml, renderInboxOnlyPage } from './web/inbox-page.js';
139
139
  export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
140
140
  export { workflowsOverview, startsOf, type WorkflowsOverview, type WorkflowOverviewRow } from './web/workflows-overview.js';
package/dist/index.js CHANGED
@@ -121,11 +121,11 @@ export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, Agen
121
121
  export { goalsPageHtml } from './web/goals-page.js';
122
122
  export { GoalError, acceptJob, addJob, assignJob, assignmentMessage, listJob, listJobs, submitJob, MY_JOBS_ID, chainedRuns, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, goalView, checkBuiltWorkflows, createGoal, deleteGoal, editAmount, generateMore, getGoal, goalContextFrom, listGoals, markBuilt, prepareBuild, readAbout, readGoalSettings, readLeverEvents, setWorkflowState, writeAbout, writeGoalSettings, migrateGoal, migrateGoalFiles } from './web/goals-admin.js';
123
123
  export { sendLeverEvents, sharesLeverStats, startLeverEventsSync } from './web/lever-events-sync.js';
124
+ export { createAgentNamesReporter } from './web/agent-names-sync.js';
124
125
  export { runGoalPipeline, shapeJob } from './core/system-agents/goal-planner.js';
125
126
  export { LEVERS, PLAYBOOK_VERSION, activePlaybook, setPlaybookProjectDir } from './core/system-agents/goal-playbooks.js';
126
127
  export { startPlaybookSync, syncPlaybook, playbookSyncConfig } from './core/playbook-sync.js';
127
- export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel } from './core/workspace-roles.js';
128
- export { readPeople, recordVisit, setPersonAgents, removePerson, agentsFor } from './core/workspace-people.js';
128
+ export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, agentsFor } from './core/workspace-roles.js';
129
129
  export { inboxPageHtml, renderInboxOnlyPage } from './web/inbox-page.js';
130
130
  export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
131
131
  export { workflowsOverview, startsOf } from './web/workflows-overview.js';
@@ -0,0 +1,11 @@
1
+ export declare const AGENT_NAMES_PATH = "/api/workspace/agents";
2
+ export interface AgentNamesReporter {
3
+ /** Sends the names if they changed since the last send that worked. */
4
+ report(): Promise<void>;
5
+ }
6
+ export declare function createAgentNamesReporter(list: () => string[], deps?: {
7
+ env?: NodeJS.ProcessEnv;
8
+ fetch?: typeof fetch;
9
+ log?: (message: string) => void;
10
+ retryMs?: number;
11
+ }): AgentNamesReporter;
@@ -0,0 +1,51 @@
1
+ // Tells loopengine.co the workspace's agents' names, so its dashboard can
2
+ // offer them when an owner or admin chooses which agents an approver or
3
+ // viewer sees. Only the names: nothing about what the agents do. Sent when
4
+ // the server starts and whenever an agent is added or removed; a send that
5
+ // fails is tried again a few minutes later.
6
+ //
7
+ // Signed like the workspace's run reports (web/lever-events-sync.ts):
8
+ // X-LoopEngine-Workspace names it, X-LoopEngine-Signature is t=<unix
9
+ // seconds>,v1=<HMAC-SHA256 of "<t>.<body>"> with
10
+ // LOOPENGINE_TRUSTED_PROXY_SECRET. Off outside LoopEngine Cloud.
11
+ import { leverEventsSyncConfig, signLeverEvents } from './lever-events-sync.js';
12
+ export const AGENT_NAMES_PATH = '/api/workspace/agents';
13
+ const RETRY_MS = 5 * 60 * 1000;
14
+ export function createAgentNamesReporter(list, deps = {}) {
15
+ const config = leverEventsSyncConfig(deps.env ?? process.env);
16
+ const doFetch = deps.fetch ?? fetch;
17
+ let sent;
18
+ let retry;
19
+ async function report() {
20
+ if ('off' in config)
21
+ return;
22
+ const body = JSON.stringify({ agents: [...new Set(list())].sort() });
23
+ if (body === sent)
24
+ return;
25
+ if (retry)
26
+ clearTimeout(retry);
27
+ retry = undefined;
28
+ try {
29
+ const res = await doFetch(config.url.replace(/\/api\/workspace\/lever-events$/, AGENT_NAMES_PATH), {
30
+ method: 'POST',
31
+ headers: { 'content-type': 'application/json', 'x-loopengine-workspace': config.slug, 'x-loopengine-signature': signLeverEvents(body, Math.floor(Date.now() / 1000), config.secret) },
32
+ body,
33
+ signal: AbortSignal.timeout(10_000),
34
+ });
35
+ // An older loopengine.co doesn't take them yet; nothing to retry.
36
+ if (res.status === 404) {
37
+ sent = body;
38
+ return;
39
+ }
40
+ if (!res.ok)
41
+ throw new Error(`HTTP ${res.status}`);
42
+ sent = body;
43
+ }
44
+ catch (err) {
45
+ deps.log?.(`[loopengine] couldn't send the agent list to loopengine.co (trying again shortly): ${err instanceof Error ? err.message : String(err)}`);
46
+ retry = setTimeout(() => void report(), deps.retryMs ?? RETRY_MS);
47
+ retry.unref?.();
48
+ }
49
+ }
50
+ return { report };
51
+ }
@@ -1463,6 +1463,8 @@ ${consoleShellScript}
1463
1463
  function loadWorkflowsSection(name) {
1464
1464
  var el = detail.querySelector('#workflowsContent');
1465
1465
  if (!el) return;
1466
+ // Keep the sidebar's workflow list in step (running or pending).
1467
+ if (window.leShell && window.leShell.reloadWorkflows) window.leShell.reloadWorkflows();
1466
1468
  if (workflowsRefreshTimer) { clearTimeout(workflowsRefreshTimer); workflowsRefreshTimer = null; }
1467
1469
  fetchJsonRetryOnce('/agents/' + encodeURIComponent(name) + '/workflows').then(function (r) {
1468
1470
  if (currentName !== name) return;
@@ -39,9 +39,10 @@ const INBOX_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" str
39
39
  export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console navigation">
40
40
  <a class="le-brand" href="/"><span class="le-brand-mark">${BRAND_MARK}</span><span class="le-brand-name">LoopEngine</span></a>
41
41
  <div class="le-nav-label le-inbox-nav"><a class="le-nav-head" href="/inbox" data-le-nav-head="inbox">${INBOX_ICON}Inbox</a><span class="le-pill warn le-inbox-count" id="leInboxCount" hidden></span></div>
42
- <div class="le-nav-label"><a class="le-nav-head" href="/workflows" data-le-nav-head="workflows">${WORKFLOWS_ICON}Workflows</a><a href="/workflows/new">+ New</a></div>
43
42
  <div class="le-nav-label"><a class="le-nav-head" href="/agents" data-le-nav-head="agents">${AGENTS_ICON}Agents</a><a href="/agents?new=1">+ New</a></div>
44
43
  <ul class="le-agent-list" id="leAgentList"></ul>
44
+ <div class="le-nav-label"><a class="le-nav-head" href="/workflows" data-le-nav-head="workflows">${WORKFLOWS_ICON}Workflows</a><a href="/workflows/new">+ New</a></div>
45
+ <ul class="le-agent-list le-goal-list" id="leWorkflowList"></ul>
45
46
  <div class="le-nav-group">Plan</div>
46
47
  <div class="le-nav-label"><a class="le-nav-head" href="/goals" data-le-nav-head="goals">${GOALS_ICON}Goals</a><a href="/goals?new=1" data-le-goal-new>+ New</a></div>
47
48
  <ul class="le-agent-list le-goal-list" id="leGoalList"></ul>
@@ -85,6 +86,29 @@ export const consoleShellScript = `<script>
85
86
  }
86
87
  function enc(s) { return encodeURIComponent(s); }
87
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
+
88
112
  // Who is signed in and their role (GET /config/settings), read once.
89
113
  var settings = fetch('/config/settings')
90
114
  .then(function (r) { return r.ok ? r.json() : null; })
@@ -149,8 +173,11 @@ export const consoleShellScript = `<script>
149
173
  fetch('/agents/' + enc(a.name) + '/env')
150
174
  .then(function (r) { return r.ok ? r.json() : []; })
151
175
  .then(function (vars) {
152
- toSet[a.name] = (vars || []).filter(function (v) { return v.slot === 'agent' && v.scope === 'agent' && !v.set; }).length;
153
- renderList();
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();
154
181
  var slots = document.querySelectorAll('[data-le-env-count="' + a.name + '"]');
155
182
  for (var i = 0; i < slots.length; i++) slots[i].innerHTML = envCountHtml(a.name);
156
183
  })
@@ -166,9 +193,7 @@ export const consoleShellScript = `<script>
166
193
  var goalList = document.getElementById('leGoalList');
167
194
  function reloadGoals() {
168
195
  if (!goalList) return Promise.resolve();
169
- return fetch('/goals', { headers: { accept: 'application/json' } })
170
- .then(function (r) { return r.ok ? r.json() : { goals: [] }; })
171
- .then(function (data) {
196
+ return cachedFetch('goals', '/goals', function (data) {
172
197
  var goals = data.goals || [];
173
198
  // The Jobs page is the Goals page's jobs view; it marks Jobs instead.
174
199
  var onJobs = location.pathname === '/jobs';
@@ -182,8 +207,7 @@ export const consoleShellScript = `<script>
182
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"' : '') + '>' +
183
208
  '<span class="le-dot' + (g.status === 'planning' ? ' warn' : '') + '" aria-hidden="true"></span><span class="le-name">' + esc(g.goal) + '</span></a></li>';
184
209
  }).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No goals yet</span><span></span></li>';
185
- })
186
- .catch(function () { goalList.innerHTML = ''; });
210
+ });
187
211
  }
188
212
  fullAccess.then(function (full) { if (full) reloadGoals(); });
189
213
 
@@ -198,9 +222,7 @@ export const consoleShellScript = `<script>
198
222
  var current = onJobs ? new URLSearchParams(location.search).get('job') : null;
199
223
  var jobsHead = document.querySelector('[data-le-nav-head="jobs"]');
200
224
  if (jobsHead) { if (onJobs && !current) jobsHead.setAttribute('aria-current', 'page'); else jobsHead.removeAttribute('aria-current'); }
201
- return fetch('/jobs', { headers: { accept: 'application/json' } })
202
- .then(function (r) { return r.ok ? r.json() : { jobs: [] }; })
203
- .then(function (data) {
225
+ return cachedFetch('jobs', '/jobs', function (data) {
204
226
  var jobs = data.jobs || [];
205
227
  jobList.innerHTML = jobs.length ? jobs.map(function (x) {
206
228
  var j = x.job;
@@ -211,11 +233,32 @@ export const consoleShellScript = `<script>
211
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"' : '') + '>' +
212
234
  '<span class="le-dot' + dot + '" aria-hidden="true"></span><span class="le-name">' + esc(j.title) + '</span></a></li>';
213
235
  }).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No jobs yet</span><span></span></li>';
214
- })
215
- .catch(function () { jobList.innerHTML = ''; });
236
+ });
216
237
  }
217
238
  fullAccess.then(function (full) { if (full) reloadJobs(); });
218
239
 
240
+ // ---- Workflows, listed under the agents (GET /workflows/overview),
241
+ // each opening on its agent's Workflows tab. A tinted dot is running (a
242
+ // run under way, or a schedule or webhook on); yellow is pending (it
243
+ // only runs when someone starts it).
244
+ var workflowList = document.getElementById('leWorkflowList');
245
+ function reloadWorkflows() {
246
+ if (!workflowList) return Promise.resolve();
247
+ var q = new URLSearchParams(location.search);
248
+ var currentAgent = page === 'agent-config' && q.get('tab') === 'workflows' ? q.get('agent') : null;
249
+ var currentId = currentAgent ? q.get('workflow') : null;
250
+ return cachedFetch('workflows', '/workflows/overview', function (data) {
251
+ var list = (data.workflows || []).slice().sort(function (a, b) { return a.title.localeCompare(b.title); });
252
+ workflowList.innerHTML = list.length ? list.map(function (w) {
253
+ var on = w.agent === currentAgent && w.id === currentId;
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"' : '') + '>' +
255
+ '<span class="le-dot ' + (w.live ? 'tint' : 'pending') + '" aria-hidden="true"></span><span class="le-name">' + esc(w.title) + '</span></a></li>';
256
+ }).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No workflows yet</span><span></span></li>';
257
+ });
258
+ }
259
+ var DOT_SEP = ', ';
260
+ fullAccess.then(function (full) { if (full) reloadWorkflows(); });
261
+
219
262
  // ---- The Inbox, at the top: how many cases wait on a person, kept
220
263
  // current. The Inbox page marks itself.
221
264
  var inboxCount = document.getElementById('leInboxCount');
@@ -225,24 +268,31 @@ export const consoleShellScript = `<script>
225
268
  if (workflowsHead && page === 'workflows-overview') workflowsHead.setAttribute('aria-current', 'page');
226
269
  function reloadInboxCount() {
227
270
  if (!inboxCount) return;
228
- fetch('/inbox/count', { headers: { accept: 'application/json' } })
229
- .then(function (r) { return r.ok ? r.json() : { open: 0 }; })
230
- .then(function (d) { inboxCount.textContent = String(d.open || 0); inboxCount.hidden = !d.open; inboxCount.title = (d.open || 0) + ' waiting for a decision'; })
231
- .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'; });
232
272
  }
233
273
  reloadInboxCount();
234
274
  setInterval(function () { if (!document.hidden) reloadInboxCount(); }, 30000);
235
275
 
236
276
  var loadError = null;
237
277
  var ready = fullAccess.then(function (full) { return full ? loadAgents() : []; });
238
- function loadAgents() { return fetch('/agents', { headers: { accept: 'application/json' } })
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' } })
239
288
  .then(function (r) {
240
289
  if (!r.ok) throw new Error(r.status === 401 ? 'sign-in required (HTTP 401)' : 'HTTP ' + r.status);
241
290
  return r.json();
242
291
  })
243
292
  .then(function (data) {
244
293
  agents = data.agents || [];
245
- renderList();
294
+ if (!seen || JSON.stringify(seen.agents) !== JSON.stringify(agents)) renderList();
295
+ remember('agents', { agents: agents });
246
296
  loadToSet();
247
297
  return agents;
248
298
  })
@@ -578,6 +628,6 @@ export const consoleShellScript = `<script>
578
628
  }
579
629
 
580
630
 
581
- window.leShell = { loadError: function () { return loadError; }, ready: ready, reloadGoals: reloadGoals, reloadJobs: reloadJobs, reloadInboxCount: reloadInboxCount, renderHead: renderHead, setTab: setTab, setActive: setActive, setDisplayName: setDisplayName, displayNameOf: displayNameOf, esc: esc, tabHref: tabHref, envCountHtml: envCountHtml, setCount: setCount, wireModelPicker: wireModelPicker, loadProviderKeys: loadProviderKeys, applyProviderKeys: applyProviderKeys, abilityOriginBadge: abilityOriginBadge, toggleAbilityDetails: toggleAbilityDetails };
631
+ window.leShell = { loadError: function () { return loadError; }, ready: ready, reloadGoals: reloadGoals, reloadJobs: reloadJobs, reloadWorkflows: reloadWorkflows, reloadInboxCount: reloadInboxCount, renderHead: renderHead, setTab: setTab, setActive: setActive, setDisplayName: setDisplayName, displayNameOf: displayNameOf, esc: esc, tabHref: tabHref, envCountHtml: envCountHtml, setCount: setCount, wireModelPicker: wireModelPicker, loadProviderKeys: loadProviderKeys, applyProviderKeys: applyProviderKeys, abilityOriginBadge: abilityOriginBadge, toggleAbilityDetails: toggleAbilityDetails };
582
632
  })();
583
633
  </script>`;
@@ -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: 11px; font-weight: 600; color: inherit; }
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,18 +143,21 @@ 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
- .le-agent-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; }
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: 12px; color: var(--ink-faint); }
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); }
154
+ .le-dot.tint { background: var(--accent); }
155
+ .le-dot.pending { background: #E8B06A; }
153
156
  .le-inbox-count { margin-left: auto; font-size: 11px; padding: 0 7px; }
154
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; }
155
158
  .le-dot.idle { background: var(--ink-faint); }
156
159
  .le-foot { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
157
- .le-foot a { padding: 7px 8px; border-radius: 6px; color: var(--ink-muted); text-decoration: none; }
160
+ .le-foot a { padding: 6px 8px; border-radius: 6px; color: var(--ink-muted); text-decoration: none; font-size: 13px; }
158
161
  .le-foot a:hover { background: var(--surface-2); color: var(--ink); }
159
162
  .le-foot a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
160
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; }
@@ -1015,7 +1015,6 @@ ${consoleShellScript}
1015
1015
  rows.map(function (r) { return '<tr><td>' + r[0] + '</td><td>' + r[1] + '</td></tr>'; }).join('') +
1016
1016
  '</tbody></table></section>' +
1017
1017
  (d.timeZone ? '<section><h3>Time zone</h3><div class="source" id="timeZoneBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' : '') +
1018
- (si.mode === 'hosted' ? '<section><h3>People</h3><div class="source" id="peopleBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' : '') +
1019
1018
  '<section><h3>Shared policies</h3><div class="source" id="policiesBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' +
1020
1019
  '<section><h3>Private ability sources</h3><p class="muted" style="margin:0 0 10px">Where your own abilities come from, listed under Private on the Abilities page next to LoopEngine&#39;s official ones.</p><div class="source" id="abilitySourcesBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' +
1021
1020
  '<section><h3>Updates</h3><div class="source" id="upgradeBox"><p class="hint">Checking for a newer LoopEngine' + String.fromCharCode(8230) + '</p></div></section>';
@@ -1203,126 +1202,6 @@ ${consoleShellScript}
1203
1202
  });
1204
1203
  }
1205
1204
 
1206
- // ---- People: which agents each approver or viewer sees (hosted
1207
- // workspaces; invites and roles are in the dashboard). ----
1208
- var peopleData = null;
1209
- var settingsDashboardUrl = '';
1210
- var peopleEditing = '';
1211
- function roleName(role) {
1212
- return role ? role.charAt(0).toUpperCase() + role.slice(1) : 'Not here yet';
1213
- }
1214
- function limitedRole(role) {
1215
- return role === 'approver' || role === 'viewer';
1216
- }
1217
- function agentChecks(selected, all) {
1218
- if (!all.length) return '<p class="hint">No agents yet.</p>';
1219
- return '<div style="display:flex;flex-wrap:wrap;gap:6px 14px">' + all.map(function (a) {
1220
- return '<label style="display:inline-flex;gap:6px;align-items:center"><input type="checkbox" name="agent" value="' + escapeHtml(a) + '"' + (selected.indexOf(a) !== -1 ? ' checked' : '') + '> ' + escapeHtml(a) + '</label>';
1221
- }).join('') + '</div>';
1222
- }
1223
- function agentsText(p) {
1224
- return p.agents ? (p.agents.length ? p.agents.map(escapeHtml).join(', ') : 'No agents') : 'All agents';
1225
- }
1226
- function renderPeople() {
1227
- var box = document.getElementById('peopleBox');
1228
- if (!box || !peopleData) return;
1229
- var d = peopleData;
1230
- var intro = '<p style="margin:0 0 10px">Choose which agents each approver or viewer sees. The Inbox shows them only those agents' + String.fromCharCode(8217) + ' cases, and an approver can decide only on those. Owners, admins and editors always see every agent. Invite people and set their role in the ' +
1231
- '<a href="#" id="peopleDashboard">dashboard</a>.</p>';
1232
- var rows = d.people.map(function (p) {
1233
- var editing = peopleEditing === p.email;
1234
- var full = p.role && !limitedRole(p.role);
1235
- var agentsCell = full
1236
- ? '<span class="hint">All agents (' + escapeHtml(roleName(p.role)) + ')</span>'
1237
- : editing
1238
- ? '<form class="peopleForm" data-email="' + escapeHtml(p.email) + '" style="display:flex;flex-direction:column;gap:8px">' +
1239
- '<label style="display:inline-flex;gap:6px;align-items:center"><input type="checkbox" name="all"' + (p.agents ? '' : ' checked') + '> All agents, including new ones</label>' +
1240
- '<div class="peopleAgents"' + (p.agents ? '' : ' hidden') + '>' + agentChecks(p.agents || [], d.agents) + '</div>' +
1241
- '<div style="display:flex;gap:6px"><button type="submit" class="primary">Save</button><button type="button" data-people-cancel="1">Cancel</button></div>' +
1242
- '</form>'
1243
- : agentsText(p);
1244
- var actions = !d.canChange || full || editing ? ''
1245
- : '<button type="button" data-people-edit="' + escapeHtml(p.email) + '">Change</button>' +
1246
- (p.role ? '' : ' <button type="button" data-people-remove="' + escapeHtml(p.email) + '">Remove</button>');
1247
- return '<tr><td>' + escapeHtml(p.email) + '</td><td>' + escapeHtml(roleName(p.role)) + (p.seen ? '<div class="hint">last here ' + escapeHtml(new Date(p.seen).toLocaleDateString()) + '</div>' : '') + '</td><td>' + agentsCell + '</td><td style="white-space:nowrap">' + actions + '</td></tr>';
1248
- }).join('');
1249
- var table = d.people.length
1250
- ? '<table><thead><tr><th>Person</th><th>Role</th><th>Sees</th><th></th></tr></thead><tbody>' + rows + '</tbody></table>'
1251
- : '<p class="hint">Nobody else has signed in yet. People show here after their first visit, or add someone by email below.</p>';
1252
- var add = d.canChange
1253
- ? '<form id="peopleAddForm" style="display:flex;flex-direction:column;gap:8px;margin-top:12px;max-width:720px">' +
1254
- '<label for="peopleEmail" class="hint">Limit someone before their first visit</label>' +
1255
- '<div style="display:flex;gap:6px;flex-wrap:wrap"><input id="peopleEmail" type="email" placeholder="jane@example.com" style="flex:1;min-width:200px" required></div>' +
1256
- agentChecks([], d.agents) +
1257
- '<div><button type="submit">Add</button></div>' +
1258
- '</form>'
1259
- : '<p class="hint">Only an owner or admin can change who sees which agents.</p>';
1260
- box.innerHTML = intro + table + add + '<div id="peopleMsg" class="hint" style="margin-top:8px"></div>';
1261
- var dash = document.getElementById('peopleDashboard');
1262
- if (dash) {
1263
- if (settingsDashboardUrl) dash.setAttribute('href', settingsDashboardUrl);
1264
- else dash.outerHTML = 'dashboard';
1265
- }
1266
- }
1267
- function sendPeople(method, body) {
1268
- var msg = document.getElementById('peopleMsg');
1269
- if (msg) msg.textContent = 'Saving' + String.fromCharCode(8230);
1270
- return fetch('/config/people', { method: method, headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
1271
- .then(function (r) { return r.json().then(function (b) { return { ok: r.ok, body: b }; }); })
1272
- .then(function (r) {
1273
- if (!r.ok) throw new Error(r.body.error || 'Could not save');
1274
- peopleData = r.body;
1275
- peopleEditing = '';
1276
- renderPeople();
1277
- var m = document.getElementById('peopleMsg');
1278
- if (m) m.textContent = 'Saved. It applies on their next page load.';
1279
- })
1280
- .catch(function (err) {
1281
- var m = document.getElementById('peopleMsg');
1282
- if (m) m.innerHTML = '<span class="error">' + escapeHtml(err.message) + '</span>';
1283
- });
1284
- }
1285
- function checkedAgents(form) {
1286
- return Array.prototype.map.call(form.querySelectorAll('input[name="agent"]:checked'), function (i) { return i.value; });
1287
- }
1288
- document.getElementById('settingsContent').addEventListener('click', function (ev) {
1289
- var t = ev.target;
1290
- if (!t || !t.getAttribute) return;
1291
- if (t.getAttribute('data-people-edit')) { peopleEditing = t.getAttribute('data-people-edit'); renderPeople(); }
1292
- else if (t.getAttribute('data-people-cancel')) { peopleEditing = ''; renderPeople(); }
1293
- else if (t.getAttribute('data-people-remove')) sendPeople('DELETE', { email: t.getAttribute('data-people-remove') });
1294
- });
1295
- document.getElementById('settingsContent').addEventListener('change', function (ev) {
1296
- var t = ev.target;
1297
- if (!t || t.name !== 'all') return;
1298
- var form = t.closest('.peopleForm');
1299
- var list = form && form.querySelector('.peopleAgents');
1300
- if (list) list.hidden = t.checked;
1301
- });
1302
- document.getElementById('settingsContent').addEventListener('submit', function (ev) {
1303
- var form = ev.target;
1304
- if (form.classList && form.classList.contains('peopleForm')) {
1305
- ev.preventDefault();
1306
- sendPeople('PUT', { email: form.getAttribute('data-email'), agents: form.querySelector('input[name="all"]').checked ? null : checkedAgents(form) });
1307
- } else if (form.id === 'peopleAddForm') {
1308
- ev.preventDefault();
1309
- sendPeople('PUT', { email: document.getElementById('peopleEmail').value, agents: checkedAgents(form) });
1310
- }
1311
- });
1312
- function loadPeople() {
1313
- if (!document.getElementById('peopleBox')) return;
1314
- fetch('/config/people', { cache: 'no-store' })
1315
- .then(function (r) {
1316
- if (r.status === 404) throw new Error('this server' + String.fromCharCode(8217) + 's template is older; update it (Updates, below) to choose who sees which agents');
1317
- return r.json();
1318
- })
1319
- .then(function (d) { peopleData = d; renderPeople(); })
1320
- .catch(function (err) {
1321
- var box = document.getElementById('peopleBox');
1322
- if (box) box.innerHTML = '<p class="hint">People aren' + String.fromCharCode(8217) + 't available: ' + escapeHtml(err.message) + '.</p>';
1323
- });
1324
- }
1325
-
1326
1205
  function loadPolicies() {
1327
1206
  if (!document.getElementById('policiesBox')) return;
1328
1207
  fetch('/config/policies', { cache: 'no-store' })
@@ -1476,11 +1355,9 @@ ${consoleShellScript}
1476
1355
  fetch('/config/settings')
1477
1356
  .then(function (r) { return r.json(); })
1478
1357
  .then(function (d) {
1479
- settingsDashboardUrl = d.signIn && d.signIn.dashboardUrl ? d.signIn.dashboardUrl : '';
1480
1358
  content.innerHTML = renderSettings(d);
1481
1359
  loadedSections.settings = true;
1482
1360
  loadTimeZone();
1483
- loadPeople();
1484
1361
  loadPolicies();
1485
1362
  loadAbilitySources();
1486
1363
  loadUpgrade();
@@ -9,6 +9,9 @@ export interface WorkflowOverviewRow {
9
9
  /** How it starts, in words: its schedules and webhooks; "Run now" when
10
10
  * nothing else starts it. */
11
11
  starts: string[];
12
+ /** Running: a run under way, or a schedule or webhook on to start it.
13
+ * Otherwise it's pending: it only runs when someone starts it. */
14
+ live: boolean;
12
15
  /** Runs started in the last 7 days, and how many of them failed. */
13
16
  runsThisWeek: number;
14
17
  failedThisWeek: number;
@@ -22,6 +22,7 @@ export function workflowsOverview(input) {
22
22
  id: view.id,
23
23
  title: view.title || view.id,
24
24
  starts: startsOf(view),
25
+ live: own.some((r) => r.status === 'running') || view.webhooks > 0 || view.schedules.some((s) => s.status !== 'paused' && s.status !== 'done' && s.status !== 'cancelled'),
25
26
  runsThisWeek: week.length,
26
27
  failedThisWeek: week.filter((r) => r.status === 'error').length,
27
28
  ...(latest ? { lastRun: { status: latest.status, at: latest.started_at } } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.3.89",
3
+ "version": "0.3.91",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",
@@ -47,8 +47,6 @@
47
47
  "dist/core/trusted-proxy.d.ts",
48
48
  "dist/core/workspace-roles.js",
49
49
  "dist/core/workspace-roles.d.ts",
50
- "dist/core/workspace-people.js",
51
- "dist/core/workspace-people.d.ts",
52
50
  "dist/core/unattended.js",
53
51
  "dist/core/unattended.d.ts",
54
52
  "dist/core/usage.js",
@@ -1,21 +0,0 @@
1
- import { type WorkspaceRole } from './workspace-roles.js';
2
- export interface WorkspacePerson {
3
- email: string;
4
- role?: WorkspaceRole;
5
- /** When they were last here (ISO). */
6
- seen?: string;
7
- /** The agents they see; absent for every agent. */
8
- agents?: string[];
9
- }
10
- export declare function readPeople(projectDir: string): WorkspacePerson[];
11
- /** Notes a signed-in person's visit: a new person, a changed role, or an
12
- * hour since "last here" is written; anything else costs nothing. */
13
- export declare function recordVisit(projectDir: string, rawEmail: string, role: WorkspaceRole, now?: Date): void;
14
- /** Sets which agents `email` sees; undefined for every agent. Adds them
15
- * if they haven't been here yet. */
16
- export declare function setPersonAgents(projectDir: string, rawEmail: string, agents: string[] | undefined): WorkspacePerson;
17
- /** Forgets `email` (they see every agent again, if they still have access). */
18
- export declare function removePerson(projectDir: string, rawEmail: string): void;
19
- /** The agents a caller may see, or undefined for every agent. Only an
20
- * approver or viewer is ever limited. */
21
- export declare function agentsFor(projectDir: string, role: WorkspaceRole, rawEmail: string | undefined): string[] | undefined;
@@ -1,75 +0,0 @@
1
- // Which agents each person sees, for a hosted workspace with a team
2
- // (core/workspace-roles.ts). The control plane says who may come in and
3
- // with what role; this says where an approver or viewer may look: the
4
- // Inbox shows them only those agents' cases, and they decide only on
5
- // those. Owners, admins and editors always see every agent.
6
- //
7
- // Kept in .loopengine/people.json by email, with each person's role and
8
- // when they were last here, so Settings → People can list everyone who
9
- // has signed in. Someone can be added by email before their first visit.
10
- // No entry, or no agent list, means every agent.
11
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
12
- import { dirname, join } from 'node:path';
13
- import { inboxOnly } from './workspace-roles.js';
14
- /** How often a visit updates "last here". */
15
- const SEEN_EVERY_MS = 60 * 60 * 1000;
16
- function peopleFile(projectDir) {
17
- return join(projectDir, '.loopengine', 'people.json');
18
- }
19
- function normalEmail(raw) {
20
- return raw.trim().toLowerCase();
21
- }
22
- export function readPeople(projectDir) {
23
- try {
24
- const parsed = JSON.parse(readFileSync(peopleFile(projectDir), 'utf8'));
25
- return Array.isArray(parsed.people) ? parsed.people.filter((p) => p && typeof p.email === 'string') : [];
26
- }
27
- catch {
28
- return [];
29
- }
30
- }
31
- function writePeople(projectDir, people) {
32
- const file = peopleFile(projectDir);
33
- mkdirSync(dirname(file), { recursive: true });
34
- const temp = `${file}.${process.pid}.tmp`;
35
- writeFileSync(temp, JSON.stringify({ people: [...people].sort((a, b) => a.email.localeCompare(b.email)) }, null, 2) + '\n');
36
- renameSync(temp, file);
37
- }
38
- /** Notes a signed-in person's visit: a new person, a changed role, or an
39
- * hour since "last here" is written; anything else costs nothing. */
40
- export function recordVisit(projectDir, rawEmail, role, now = new Date()) {
41
- const email = normalEmail(rawEmail);
42
- if (!email)
43
- return;
44
- const people = readPeople(projectDir);
45
- const known = people.find((p) => p.email === email);
46
- if (known && known.role === role && known.seen && now.getTime() - Date.parse(known.seen) < SEEN_EVERY_MS)
47
- return;
48
- const updated = { ...(known ?? { email }), role, seen: now.toISOString() };
49
- writePeople(projectDir, [...people.filter((p) => p.email !== email), updated]);
50
- }
51
- /** Sets which agents `email` sees; undefined for every agent. Adds them
52
- * if they haven't been here yet. */
53
- export function setPersonAgents(projectDir, rawEmail, agents) {
54
- const email = normalEmail(rawEmail);
55
- const people = readPeople(projectDir);
56
- const { agents: _old, ...rest } = people.find((p) => p.email === email) ?? { email };
57
- const updated = agents ? { ...rest, agents: [...new Set(agents)].sort() } : rest;
58
- writePeople(projectDir, [...people.filter((p) => p.email !== email), updated]);
59
- return updated;
60
- }
61
- /** Forgets `email` (they see every agent again, if they still have access). */
62
- export function removePerson(projectDir, rawEmail) {
63
- const email = normalEmail(rawEmail);
64
- writePeople(projectDir, readPeople(projectDir).filter((p) => p.email !== email));
65
- }
66
- /** The agents a caller may see, or undefined for every agent. Only an
67
- * approver or viewer is ever limited. */
68
- export function agentsFor(projectDir, role, rawEmail) {
69
- if (!inboxOnly(role))
70
- return undefined;
71
- if (!rawEmail)
72
- return undefined;
73
- const email = normalEmail(rawEmail);
74
- return readPeople(projectDir).find((p) => p.email === email)?.agents;
75
- }