loopengine 0.3.89 → 0.3.90

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>
@@ -216,6 +217,31 @@ export const consoleShellScript = `<script>
216
217
  }
217
218
  fullAccess.then(function (full) { if (full) reloadJobs(); });
218
219
 
220
+ // ---- Workflows, listed under the agents (GET /workflows/overview),
221
+ // each opening on its agent's Workflows tab. A tinted dot is running (a
222
+ // run under way, or a schedule or webhook on); yellow is pending (it
223
+ // only runs when someone starts it).
224
+ var workflowList = document.getElementById('leWorkflowList');
225
+ function reloadWorkflows() {
226
+ if (!workflowList) return Promise.resolve();
227
+ var q = new URLSearchParams(location.search);
228
+ var currentAgent = page === 'agent-config' && q.get('tab') === 'workflows' ? q.get('agent') : null;
229
+ var currentId = currentAgent ? q.get('workflow') : null;
230
+ return fetch('/workflows/overview', { headers: { accept: 'application/json' } })
231
+ .then(function (r) { return r.ok ? r.json() : { workflows: [] }; })
232
+ .then(function (data) {
233
+ var list = (data.workflows || []).slice().sort(function (a, b) { return a.title.localeCompare(b.title); });
234
+ workflowList.innerHTML = list.length ? list.map(function (w) {
235
+ var on = w.agent === currentAgent && w.id === currentId;
236
+ 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
+ '<span class="le-dot ' + (w.live ? 'tint' : 'pending') + '" aria-hidden="true"></span><span class="le-name">' + esc(w.title) + '</span></a></li>';
238
+ }).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 = ''; });
241
+ }
242
+ var DOT_SEP = ', ';
243
+ fullAccess.then(function (full) { if (full) reloadWorkflows(); });
244
+
219
245
  // ---- The Inbox, at the top: how many cases wait on a person, kept
220
246
  // current. The Inbox page marks itself.
221
247
  var inboxCount = document.getElementById('leInboxCount');
@@ -578,6 +604,6 @@ export const consoleShellScript = `<script>
578
604
  }
579
605
 
580
606
 
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 };
607
+ 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
608
  })();
583
609
  </script>`;
@@ -150,6 +150,8 @@ export const devUiCss = `
150
150
  .le-agent-item .le-meta { font-size: 12px; color: var(--ink-faint); }
151
151
  .le-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
152
152
  .le-dot.warn { background: var(--warn); }
153
+ .le-dot.tint { background: var(--accent); }
154
+ .le-dot.pending { background: #E8B06A; }
153
155
  .le-inbox-count { margin-left: auto; font-size: 11px; padding: 0 7px; }
154
156
  .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
157
  .le-dot.idle { background: var(--ink-faint); }
@@ -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.90",
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
- }