loopengine 0.3.95 → 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 +1 -1
- package/dist/index.js +1 -1
- package/dist/web/goals-page.d.ts +3 -0
- package/dist/web/goals-page.js +71 -17
- package/package.json +1 -1
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';
|
package/dist/web/goals-page.d.ts
CHANGED
package/dist/web/goals-page.js
CHANGED
|
@@ -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
|
-
|
|
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">☰</button>
|
|
150
|
-
<div
|
|
156
|
+
<div>__GL_HEAD__</div>
|
|
151
157
|
</div>
|
|
152
|
-
<a class="gl-btn gl-new-btn" id="glNewBtn" href="
|
|
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…</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
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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">
|
|
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
|
|
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) {
|
|
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
|
-
|
|
586
|
-
if (
|
|
587
|
-
if (
|
|
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’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;
|