loopengine 0.3.94 → 0.3.96

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/index.d.ts CHANGED
@@ -127,7 +127,7 @@ export { workspaceTimeZone, serverTimeZone, isValidTimeZone, TIME_ZONE_ENV } fro
127
127
  export { createTrackedApprover, listApprovals, decideApproval, findApproval } from './web/web-approver.js';
128
128
  export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, AgentNotFoundError, AgentModelError } from './bin/cli.js';
129
129
  export type { AgentTemplateOptions } from './bin/cli.js';
130
- export { goalsPageHtml } from './web/goals-page.js';
130
+ export { goalsPageHtml, goalsPageAs, type GoalsPageView } 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
133
  export { createAgentNamesReporter, type AgentNamesReporter } from './web/agent-names-sync.js';
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, Agen
118
118
  // Goals (web/goals-admin.ts, web/goals-page.ts) and the goal planner's
119
119
  // playbook, kept current on Cloud by core/playbook-sync.ts: a project's
120
120
  // own adapters/http.ts imports these.
121
- export { goalsPageHtml } from './web/goals-page.js';
121
+ export { goalsPageHtml, goalsPageAs } 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
124
  export { createAgentNamesReporter } from './web/agent-names-sync.js';
@@ -126,25 +126,16 @@ export const consoleShellScript = `<script>
126
126
  // Who is signed in and their role (GET /config/settings), read once;
127
127
  // pages read it through leShell.settings() rather than asking again.
128
128
  var settings = getJson('/config/settings');
129
- // On the Inbox, the lists wait for the role: an approver or viewer sees
130
- // the Inbox only, and the rest of the sidebar is hidden. Other pages
131
- // are only open to the roles that see everything.
132
- // The server marks the page for an Inbox-only role before it's shown.
129
+ // An approver or viewer sees the Inbox only, with the rest of the
130
+ // sidebar hidden. The server knows the role from the request and marks
131
+ // the page before it's sent (and those roles can't open any other
132
+ // page), so the lists draw at once instead of waiting on a role check.
133
133
  var markedInboxOnly = Boolean(app && app.classList.contains('le-inbox-only'));
134
134
  if (markedInboxOnly) {
135
135
  var inboxBrand = document.querySelector('.le-brand');
136
136
  if (inboxBrand) inboxBrand.setAttribute('href', '/inbox');
137
137
  }
138
- var fullAccess = markedInboxOnly ? Promise.resolve(false) : page === 'inbox' ? settings.then(function (s) {
139
- var role = s && s.signIn && s.signIn.role;
140
- var only = role === 'approver' || role === 'viewer';
141
- if (only && app) {
142
- app.classList.add('le-inbox-only');
143
- var brand = document.querySelector('.le-brand');
144
- if (brand) brand.setAttribute('href', '/inbox');
145
- }
146
- return !only;
147
- }) : Promise.resolve(true);
138
+ var fullAccess = Promise.resolve(!markedInboxOnly);
148
139
 
149
140
  function tabHref(name, tab) {
150
141
  if (tab === 'chat') return '/playground?agent=' + enc(name);
@@ -1 +1,4 @@
1
+ export type GoalsPageView = 'goals' | 'goal' | 'new' | 'jobs' | 'job' | 'new-job';
2
+ export declare function goalsPageAs(view: GoalsPageView): string;
3
+ /** The Goals page as the list shows it. */
1
4
  export declare const goalsPageHtml: string;
@@ -12,7 +12,7 @@
12
12
  // literal.
13
13
  import { devUiCss } from './dev-ui-styles.js';
14
14
  import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
15
- export const goalsPageHtml = `<!doctype html>
15
+ const goalsPageTemplate = `<!doctype html>
16
16
  <html lang="en">
17
17
  <head>
18
18
  <meta charset="utf-8">
@@ -60,6 +60,12 @@ export const goalsPageHtml = `<!doctype html>
60
60
  .gl-job-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
61
61
  .gl-caret { width: 7px; height: 7px; border-right: 2px solid var(--ink-muted); border-bottom: 2px solid var(--ink-muted); transform: rotate(-45deg); transition: transform .15s; }
62
62
  .gl-job.is-open .gl-caret { transform: rotate(45deg); }
63
+ .gl-job-detail .gl-job-head { grid-template-columns: minmax(0, 1fr) auto auto; cursor: default; }
64
+ .gl-job-detail .gl-job-head:hover { background: none; }
65
+ .gl-job-detail .gl-wf-title { font-size: 17px; }
66
+ .gl-job-detail .gl-job-body, .gl-job-detail .gl-job-status-line { padding-left: 14px; }
67
+ .gl-job-link { color: inherit; text-decoration: none; }
68
+ .gl-job-link:hover { text-decoration: underline; }
63
69
  .gl-job-main { display: grid; gap: 3px; min-width: 0; }
64
70
  .gl-job-sub { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 12.5px; color: var(--ink-muted); }
65
71
  .gl-job-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@@ -147,9 +153,9 @@ ${consoleSidebarHtml}
147
153
  <div class="le-head plain">
148
154
  <div class="le-head-row">
149
155
  <div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
150
- <div><h1 id="glTitle">Goals</h1><p id="glLead">Say what you want to achieve. LoopEngine breaks it into jobs that move it, each with the agent that would do it. Build the recurring ones into workflows, assign the one-off ones to their agent, and generate more when you want new ideas.</p></div>
156
+ <div>__GL_HEAD__</div>
151
157
  </div>
152
- <a class="gl-btn gl-new-btn" id="glNewBtn" href="/goals?new=1" hidden>New goal</a>
158
+ <a class="gl-btn gl-new-btn" id="glNewBtn" href="__GL_NEW_HREF__"__GL_NEW_HIDDEN__>__GL_NEW_LABEL__</a>
153
159
  </div>
154
160
  </div>
155
161
  <div class="le-scroll"><div class="le-page"><div class="gl" id="glPage"><p class="hint">Loading&hellip;</p></div></div></div>
@@ -171,6 +177,10 @@ ${consoleShellScript}
171
177
  // The Jobs page (/jobs): the person's own list of jobs, from any goal
172
178
  // or submitted there without one.
173
179
  var jobsView = location.pathname === '/jobs';
180
+ // On the Jobs page, the new-job form (?new=1, or no jobs yet) or the list.
181
+ var jobCreating = jobsView && new URLSearchParams(location.search).has('new');
182
+ // One job's page (?job=, from the sidebar or after submitting one).
183
+ var jobPage = jobsView && !jobCreating ? new URLSearchParams(location.search).get('job') : null;
174
184
  var startNew = !jobsView && (location.pathname === '/' || new URLSearchParams(location.search).has('new'));
175
185
  // A goal to start from (?new=1&text=...): one typed on the website's
176
186
  // goal box before signing up, carried in by "Open workspace".
@@ -204,6 +214,7 @@ ${consoleShellScript}
204
214
  if (!r.ok) { page.innerHTML = '<p class="error">Could not load jobs: ' + esc(r.body.error || 'unknown error') + '</p>'; return; }
205
215
  var first = !state.jobsLoaded;
206
216
  state.jobs = r.body.jobs || [];
217
+ if (first && !state.jobs.length) jobCreating = true;
207
218
  state.jobsLoaded = true;
208
219
  state.jobsStale = false;
209
220
  // A job picked in the sidebar (?job=): open, and brought into view.
@@ -352,11 +363,13 @@ ${consoleShellScript}
352
363
  var doneBy = once && (w.state === 'active' || w.state === 'done') && w.tries && w.tries.length ? triesHtml(w)
353
364
  : w.state === 'active' && doer && doer.type === 'workflow' ? howHtml(w)
354
365
  : w.state === 'done' && w.doneAt ? '<div class="gl-doer">Done ' + esc(new Date(w.doneAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) + '</div>' : '';
355
- var open = !!state.openJobs[w.id];
356
- return '<div class="gl-wf gl-job' + (open ? ' is-open' : '') + (w.state === 'active' || w.state === 'done' ? ' built' : '') + '" data-wf="' + esc(w.id) + '"' + (listed ? ' data-goal="' + esc(listed.goalId) + '"' : '') + '>' +
357
- '<div class="gl-job-head" role="button" tabindex="0" aria-expanded="' + open + '">' +
358
- '<span class="gl-caret" aria-hidden="true"></span>' +
359
- '<div class="gl-job-main"><span class="gl-wf-title">' + esc(w.title) + '</span>' +
366
+ // On its own page a job is shown whole, not folded.
367
+ var detail = jobPage === w.id;
368
+ var open = detail || !!state.openJobs[w.id];
369
+ return '<div class="gl-wf gl-job' + (open ? ' is-open' : '') + (detail ? ' gl-job-detail' : '') + (w.state === 'active' || w.state === 'done' ? ' built' : '') + '" data-wf="' + esc(w.id) + '"' + (listed ? ' data-goal="' + esc(listed.goalId) + '"' : '') + '>' +
370
+ (detail ? '<div class="gl-job-head">' : '<div class="gl-job-head" role="button" tabindex="0" aria-expanded="' + open + '">' +
371
+ '<span class="gl-caret" aria-hidden="true"></span>') +
372
+ '<div class="gl-job-main">' + (listed && !detail ? '<a class="gl-wf-title gl-job-link" href="/jobs?job=' + encodeURIComponent(w.id) + '">' + esc(w.title) + '</a>' : '<span class="gl-wf-title">' + esc(w.title) + '</span>') +
360
373
  '<span class="gl-job-sub"><span class="gl-kind">' + (once ? 'One-off' : 'Recurring') + '</span>' + (sub ? '<span class="gl-job-line">' + esc(sub) + '</span>' : '') + '</span>' +
361
374
  (listed ? '<span class="gl-job-from">Added ' + esc(new Date(listed.addedAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })) + ' ' + String.fromCharCode(183) + ' ' +
362
375
  (listed.goal ? 'Goal: <a href="/goals?goal=' + encodeURIComponent(listed.goalId) + '">' + esc(listed.goal) + '</a>' : 'No goal') + '</span>' : '') + '</div>' +
@@ -431,7 +444,7 @@ ${consoleShellScript}
431
444
  var inputs = Object.keys(st.with || {}).map(function (p) { var src = st.with[p]; return esc(p) + ' ' + String.fromCharCode(8592) + ' ' + (src === 'result' ? 'its result' : 'its ' + esc(src.slice(6))); }).join(', ');
432
445
  return '<div class="gl-step" data-step="' + esc(st.id) + '"><span>After <strong>' + esc(titleOf(st.after)) + '</strong>' + whenText(st.when) + ', run <strong>' + esc(titleOf(st.run)) + '</strong>' + (inputs ? ' <span class="hint">(' + inputs + ')</span>' : '') + '</span><button type="button" class="gl-link" data-chain-remove="' + esc(st.id) + '">Remove</button></div>';
433
446
  }).join('');
434
- return '<div class="gl-how"><div class="gl-how-head">How it' + String.fromCharCode(8217) + 's done</div>' + flows.map(function (d) {
447
+ return '<div class="gl-how"><div class="gl-how-head">Workflows</div>' + flows.map(function (d) {
435
448
  return '<div class="gl-how-row" data-how="' + esc(d.agent) + '|' + esc(d.workflowId) + '">' +
436
449
  '<div class="gl-how-main"><span class="gl-how-wf">' + esc(d.title) + '</span><span class="gl-how-agent">on <strong>' + esc(d.agent) + '</strong></span></div>' +
437
450
  '<span class="gl-how-meta" data-how-meta>' + ELLIPSIS + '</span>' +
@@ -503,16 +516,23 @@ ${consoleShellScript}
503
516
  (n.note ? '<span>' + esc(n.note) + '</span>' : '') +
504
517
  (n.alternative ? '<span class="hint">Instead, you could: ' + esc(n.alternative) + '</span>' : '') + '</div>';
505
518
  var items = state.jobs;
506
- return '<div class="gl-card">' +
519
+ if (jobCreating) return '<div class="gl-card">' +
507
520
  '<label for="glJobIdea"><strong>Submit a job</strong> <span class="hint">in your own words; LoopEngine shapes it into a job, with its measure and the agent that would do it</span></label>' +
508
521
  '<textarea id="glJobIdea" rows="2" placeholder="e.g. Answer every customer email within an hour">' + esc(state.jobDraft || '') + '</textarea>' +
509
522
  '<div class="gl-row"><button type="button" class="gl-btn" id="glJobSubmit">Submit job</button><span class="hint" id="glJobStatus"></span>' +
510
523
  '<span class="hint gl-push">Not sure what to do? <a href="/goals?new=1">Start from a goal</a> and add the jobs it suggests.</span></div>' +
511
524
  notice +
512
525
  '</div>' +
526
+ (items.length ? '<div><a class="gl-link" href="/jobs">' + String.fromCharCode(8592) + ' My jobs (' + items.length + ')</a></div>' : '');
527
+ if (jobPage) {
528
+ var here = items.filter(function (x) { return x.job.id === jobPage; })[0];
529
+ return '<div><a class="gl-link" href="/jobs">' + String.fromCharCode(8592) + ' My jobs (' + items.length + ')</a></div>' + notice +
530
+ (here ? jobHtml(here.job, here) : '<p class="gl-empty">This job isn' + String.fromCharCode(8217) + 't on your list any more: it may have been removed or discarded.</p>');
531
+ }
532
+ return notice +
513
533
  '<div class="gl-section"><h3>My jobs <span class="gl-count">' + items.length + '</span></h3>' +
514
534
  (items.length ? items.map(function (x) { return jobHtml(x.job, x); }).join('')
515
- : '<p class="gl-empty">No jobs yet. Submit one above, or add jobs from a goal' + String.fromCharCode(8217) + 's suggestions with Add to my jobs.</p>') +
535
+ : '<p class="gl-empty">No jobs yet. <a href="/jobs?new=1">Submit one</a>, or add jobs from a goal' + String.fromCharCode(8217) + 's suggestions with Add to my jobs.</p>') +
516
536
  '</div>';
517
537
  }
518
538
 
@@ -532,7 +552,17 @@ ${consoleShellScript}
532
552
  submit.disabled = false;
533
553
  if (!r.ok) { status.textContent = r.body.error || 'Could not add it.'; return; }
534
554
  state.jobNotice = { verdict: r.body.verdict, note: r.body.note, alternative: r.body.alternative };
535
- if (r.body.jobId) { state.jobDraft = ''; state.openJobs[r.body.jobId] = true; }
555
+ if (r.body.jobId) {
556
+ state.jobDraft = '';
557
+ state.openJobs[r.body.jobId] = true;
558
+ // Added: back to the list, with it open. A refused one stays on the form.
559
+ jobCreating = false;
560
+ jobPage = r.body.jobId;
561
+ var url = new URL(location.href);
562
+ url.searchParams.delete('new');
563
+ url.searchParams.set('job', r.body.jobId);
564
+ history.replaceState(null, '', url);
565
+ }
536
566
  loadJobs();
537
567
  });
538
568
  });
@@ -582,9 +612,14 @@ ${consoleShellScript}
582
612
  var newBtn = document.getElementById('glNewBtn');
583
613
  if (jobsView) {
584
614
  if (state.jobsStale) { loadJobs(); return; }
585
- if (title) title.textContent = 'Jobs';
586
- if (lead) lead.textContent = 'Everything you want done. Submit a job in your own words, or add jobs from a goal' + String.fromCharCode(8217) + 's suggestions. Build a recurring job into a workflow, or give a one-off job to an agent.';
587
- if (newBtn) newBtn.hidden = true;
615
+ var shown = jobPage && state.jobs.filter(function (x) { return x.job.id === jobPage; })[0];
616
+ if (title) title.textContent = jobCreating ? 'New job' : jobPage ? 'Job' : 'Jobs';
617
+ if (shown) document.title = shown.job.title;
618
+ if (lead) {
619
+ lead.textContent = 'Everything you want done. Submit a job in your own words, or add jobs from a goal' + String.fromCharCode(8217) + 's suggestions. Build a recurring job into a workflow, or give a one-off job to an agent.';
620
+ lead.style.display = jobCreating ? '' : 'none';
621
+ }
622
+ if (newBtn) { newBtn.hidden = jobCreating; newBtn.textContent = 'New job'; newBtn.setAttribute('href', '/jobs?new=1'); }
588
623
  page.innerHTML = state.jobsLoaded ? jobsHtml() + (state.error ? '<p class="error">' + esc(state.error) + '</p>' : '') : '<p class="hint">Loading' + ELLIPSIS + '</p>';
589
624
  state.error = '';
590
625
  wireJobs();
@@ -755,11 +790,11 @@ ${consoleShellScript}
755
790
  var status = card.querySelector('[data-wf-status]');
756
791
  var head = card.querySelector('.gl-job-head');
757
792
  head.addEventListener('click', function (ev) {
758
- if (ev.target.closest('button, a')) return;
793
+ if (card.classList.contains('gl-job-detail') || ev.target.closest('button, a')) return;
759
794
  setJobOpen(card, !card.classList.contains('is-open'));
760
795
  });
761
796
  head.addEventListener('keydown', function (ev) {
762
- if (ev.target !== head || (ev.key !== 'Enter' && ev.key !== ' ')) return;
797
+ if (card.classList.contains('gl-job-detail') || ev.target !== head || (ev.key !== 'Enter' && ev.key !== ' ')) return;
763
798
  ev.preventDefault();
764
799
  setJobOpen(card, !card.classList.contains('is-open'));
765
800
  });
@@ -873,3 +908,22 @@ ${consoleShellScript}
873
908
  </script>
874
909
  </body>
875
910
  </html>`;
911
+ const GOALS_LEAD = 'Say what you want to achieve. LoopEngine breaks it into jobs that move it, each with the agent that would do it. Build the recurring ones into workflows, assign the one-off ones to their agent, and generate more when you want new ideas.';
912
+ const JOBS_LEAD = 'Everything you want done. Submit a job in your own words, or add jobs from a goal&#8217;s suggestions. Build a recurring job into a workflow, or give a one-off job to an agent.';
913
+ function goalsPageFor(view) {
914
+ const jobs = view === 'jobs' || view === 'job' || view === 'new-job';
915
+ const title = view === 'jobs' ? 'Jobs' : view === 'job' ? 'Job' : view === 'new-job' ? 'New job' : view === 'goal' ? 'Goal' : view === 'goals' ? 'Goals' : 'New goal';
916
+ // A list or one goal shows no lead; a new goal or job explains itself.
917
+ const hideLead = view === 'goal' || view === 'goals' || view === 'jobs' || view === 'job';
918
+ return goalsPageTemplate
919
+ .replace('__GL_HEAD__', `<h1 id="glTitle">${title}</h1><p id="glLead"${hideLead ? ' style="display:none"' : ''}>${jobs ? JOBS_LEAD : GOALS_LEAD}</p>`)
920
+ .replace('__GL_NEW_HREF__', jobs ? '/jobs?new=1' : '/goals?new=1')
921
+ .replace('__GL_NEW_HIDDEN__', view === 'goals' || view === 'jobs' || view === 'job' ? '' : ' hidden')
922
+ .replace('__GL_NEW_LABEL__', jobs ? 'New job' : 'New goal');
923
+ }
924
+ const goalsPages = { goals: goalsPageFor('goals'), goal: goalsPageFor('goal'), new: goalsPageFor('new'), jobs: goalsPageFor('jobs'), job: goalsPageFor('job'), 'new-job': goalsPageFor('new-job') };
925
+ export function goalsPageAs(view) {
926
+ return goalsPages[view];
927
+ }
928
+ /** The Goals page as the list shows it. */
929
+ export const goalsPageHtml = goalsPages.goals;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.3.94",
3
+ "version": "0.3.96",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",