loopengine 0.4.12 → 0.4.14
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/core/system-agents/goal-planner.d.ts +24 -9
- package/dist/core/system-agents/goal-planner.js +76 -24
- package/dist/core/system-agents/goal-playbooks.d.ts +0 -3
- package/dist/core/system-agents/goal-playbooks.js +1 -3
- package/dist/core/system-agents/playbook.json +2 -25
- package/dist/core/system-agents/workflow-planner.d.ts +15 -1
- package/dist/core/system-agents/workflow-planner.js +31 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/web/agents-config-page.js +2 -2
- package/dist/web/console-shell.js +17 -34
- package/dist/web/goals-admin.d.ts +45 -93
- package/dist/web/goals-admin.js +127 -230
- package/dist/web/goals-page.d.ts +1 -1
- package/dist/web/goals-page.js +127 -281
- package/dist/web/home-page.js +21 -26
- package/dist/web/upgrade-admin.js +19 -5
- package/dist/web/workflow-admin.js +13 -2
- package/dist/web/workflow-evidence.d.ts +1 -1
- package/dist/web/workflow-evidence.js +1 -1
- package/dist/web/workflow-page.js +90 -22
- package/dist/web/workflows-overview.d.ts +8 -2
- package/dist/web/workflows-overview.js +7 -5
- package/package.json +1 -1
package/dist/web/goals-page.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// The console's Goals page: /goals lists the goals made so far, /goals?new=1
|
|
2
2
|
// (and the workspace's front page, /) starts one, and /goals?goal=<id>
|
|
3
|
-
// opens one.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// which makes its agent first when it doesn't exist (web/goals-admin.ts
|
|
3
|
+
// opens one. Type a goal, get suggested workflows, each with its own
|
|
4
|
+
// measure and the agent it would go into: one workflow, or for a bigger
|
|
5
|
+
// piece of the goal a group of workflows that run in order. Generate more,
|
|
6
|
+
// and build one (or a group's step) straight from the suggestions, which
|
|
7
|
+
// makes its agent first when it doesn't exist (web/goals-admin.ts
|
|
9
8
|
// behind /goals/*). Same shell and
|
|
10
9
|
// styles as the other console pages; like them, its inline script avoids
|
|
11
10
|
// backslashes and template placeholders, since it lives inside a template
|
|
@@ -93,6 +92,17 @@ const goalsPageTemplate = `<!doctype html>
|
|
|
93
92
|
@media (max-width: 560px) { .gl-job-head { grid-template-columns: 12px minmax(0, 1fr); } .gl-job-status, .gl-job-primary { grid-column: 2; } .gl-job-body, .gl-job-status-line { padding-left: 16px; } }
|
|
94
93
|
.gl-job-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12.5px; color: var(--ink-muted); }
|
|
95
94
|
.gl-kind { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
|
|
95
|
+
.gl-kind.group { background: var(--accent-soft); color: var(--accent-ink); }
|
|
96
|
+
.gl-gsteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
|
|
97
|
+
.gl-gstep { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
|
|
98
|
+
.gl-gstep.built { border-color: var(--good-soft); }
|
|
99
|
+
.gl-gstep-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13.5px; }
|
|
100
|
+
.gl-gstep-n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--ink-muted); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
|
|
101
|
+
.gl-gstep.built .gl-gstep-n { background: var(--good-soft); color: var(--good); }
|
|
102
|
+
.gl-gstep-build { margin-left: auto; }
|
|
103
|
+
.gl-gstep-then { font-size: 12px; color: var(--ink-muted); padding: 6px 0 0 32px; margin-bottom: -4px; }
|
|
104
|
+
.gl-gstep + .gl-gstep { margin-top: 8px; }
|
|
105
|
+
.gl-order summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent-ink); }
|
|
96
106
|
.gl-doer { font-size: 13px; color: var(--ink-muted); }
|
|
97
107
|
.gl-doer strong { color: var(--ink); font-family: var(--font-mono); font-size: 12px; }
|
|
98
108
|
.gl-link-btn { display: inline-flex; align-items: center; text-decoration: none; }
|
|
@@ -135,6 +145,9 @@ const goalsPageTemplate = `<!doctype html>
|
|
|
135
145
|
.gl-setup-more summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; }
|
|
136
146
|
.gl-setup-more .gl-setup { margin-top: 4px; }
|
|
137
147
|
.gl-select { font: inherit; font-size: 13px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
|
|
148
|
+
.gl-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
|
|
149
|
+
.gl-example { font: inherit; font-size: 12.5px; color: var(--accent-ink); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
|
|
150
|
+
.gl-example:hover { border-color: var(--accent-ink); }
|
|
138
151
|
.gl-share { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; line-height: 1.45; }
|
|
139
152
|
.gl-share input { margin-top: 2px; }
|
|
140
153
|
.gl-discarded-note { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--surface); font-size: 13.5px; }
|
|
@@ -182,22 +195,17 @@ ${consoleShellScript}
|
|
|
182
195
|
// The focuses in use (the playbook's, and the workspace's own the
|
|
183
196
|
// planner named), from the server; these until it answers.
|
|
184
197
|
var FOCUS = [['new-signups', 'Getting new signups or customers'], ['activation', 'Getting new users started'], ['retention', 'Keeping users'], ['faster-support', 'Faster support'], ['revenue-recovery', 'Recovering revenue'], ['ops-hygiene', 'Smoother operations'], ['other', 'Something else']];
|
|
198
|
+
// Goals of every size, to show what can go in the box.
|
|
199
|
+
var GOAL_EXAMPLES = ['Answer every customer email within a day', 'Get 100 paying customers by March', 'Post on LinkedIn three times a week'];
|
|
185
200
|
var KINDS = [['', 'Choose one'], ['ecommerce', 'Online store'], ['saas', 'Software or app'], ['agency', 'Agency or services'], ['local', 'Local business'], ['creator', 'Creator or media'], ['nonprofit', 'Nonprofit'], ['other', 'Something else']];
|
|
186
201
|
var REASONS = [['not-relevant', 'Not relevant'], ['too-much-work', 'Too much work'], ['already-doing-it', 'Already doing it']];
|
|
187
202
|
// Which view: the list (/goals), a new goal (?new=1, or the front page)
|
|
188
203
|
// or one goal (?goal=).
|
|
189
|
-
|
|
190
|
-
// or submitted there without one.
|
|
191
|
-
var jobsView = location.pathname === '/jobs';
|
|
192
|
-
// On the Jobs page, the new-job form (?new=1, or no jobs yet) or the list.
|
|
193
|
-
var jobCreating = jobsView && new URLSearchParams(location.search).has('new');
|
|
194
|
-
// One job's page (?job=, from the sidebar or after submitting one).
|
|
195
|
-
var jobPage = jobsView && !jobCreating ? new URLSearchParams(location.search).get('job') : null;
|
|
196
|
-
var startNew = !jobsView && (location.pathname === '/' || new URLSearchParams(location.search).has('new'));
|
|
204
|
+
var startNew = location.pathname === '/' || new URLSearchParams(location.search).has('new');
|
|
197
205
|
// A goal to start from (?new=1&text=...): one typed on the website's
|
|
198
206
|
// goal box before signing up, carried in by "Open workspace".
|
|
199
207
|
var startText = (new URLSearchParams(location.search).get('text') || '').slice(0, 500);
|
|
200
|
-
var state = {
|
|
208
|
+
var state = { addOpen: false, addDraft: '', addShare: false, addNotice: null, flows: {}, openJobs: {}, goals: [], about: '', settings: {}, current: null, creating: startNew, showDiscarded: false, justDiscarded: null, error: '', poll: null, startedAt: 0 };
|
|
201
209
|
|
|
202
210
|
function esc(s) {
|
|
203
211
|
return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
|
|
@@ -221,25 +229,7 @@ ${consoleShellScript}
|
|
|
221
229
|
history.replaceState(null, '', url);
|
|
222
230
|
}
|
|
223
231
|
|
|
224
|
-
function loadJobs() {
|
|
225
|
-
api('GET', '/jobs').then(function (r) {
|
|
226
|
-
if (!r.ok) { page.innerHTML = '<p class="error">Could not load jobs: ' + esc(r.body.error || 'unknown error') + '</p>'; return; }
|
|
227
|
-
var first = !state.jobsLoaded;
|
|
228
|
-
state.jobs = r.body.jobs || [];
|
|
229
|
-
if (first && !state.jobs.length) jobCreating = true;
|
|
230
|
-
state.jobsLoaded = true;
|
|
231
|
-
state.jobsStale = false;
|
|
232
|
-
// A job picked in the sidebar (?job=): open, and brought into view.
|
|
233
|
-
var picked = first ? new URLSearchParams(location.search).get('job') : null;
|
|
234
|
-
if (picked) state.openJobs[picked] = true;
|
|
235
|
-
if (!first) reloadSidebar();
|
|
236
|
-
render();
|
|
237
|
-
if (picked) { var el = page.querySelector('.gl-job[data-wf="' + picked.replace(/[^a-z0-9-]/gi, '') + '"]'); if (el) el.scrollIntoView({ block: 'center' }); }
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
232
|
function load(selectId) {
|
|
242
|
-
if (jobsView) { loadJobs(); return; }
|
|
243
233
|
api('GET', '/goals').then(function (r) {
|
|
244
234
|
if (!r.ok) { page.innerHTML = '<p class="error">Could not load goals: ' + esc(r.body.error || 'unknown error') + '</p>'; return; }
|
|
245
235
|
state.goals = r.body.goals || [];
|
|
@@ -253,16 +243,11 @@ ${consoleShellScript}
|
|
|
253
243
|
}
|
|
254
244
|
|
|
255
245
|
// While a goal is planning, check every few seconds.
|
|
256
|
-
// While a goal is planning, or a one-off job's try is going, check again
|
|
257
|
-
// every few seconds (not while a note is being written).
|
|
258
|
-
function lastTry(job) { return job.tries && job.tries.length ? job.tries[job.tries.length - 1] : null; }
|
|
259
|
-
function tryGoing(t) { return t && (t.status === 'running' || t.status === 'awaiting_approval'); }
|
|
260
246
|
function watch() {
|
|
261
247
|
if (state.poll) { clearTimeout(state.poll); state.poll = null; }
|
|
262
248
|
if (!state.current) return;
|
|
263
249
|
var planning = state.current.status === 'planning';
|
|
264
|
-
|
|
265
|
-
if (!planning && !going) return;
|
|
250
|
+
if (!planning) return;
|
|
266
251
|
state.poll = setTimeout(function () {
|
|
267
252
|
var typing = document.activeElement && document.activeElement.classList && document.activeElement.classList.contains('gl-note');
|
|
268
253
|
if (typing) { watch(); return; }
|
|
@@ -272,34 +257,19 @@ ${consoleShellScript}
|
|
|
272
257
|
if (planning && r.body.goal.status !== 'planning') reloadSidebar();
|
|
273
258
|
render();
|
|
274
259
|
});
|
|
275
|
-
},
|
|
276
|
-
}
|
|
277
|
-
function watchJobs() {
|
|
278
|
-
if (state.poll) { clearTimeout(state.poll); state.poll = null; }
|
|
279
|
-
var going = state.jobs.some(function (x) { return x.job.state === 'active' && tryGoing(lastTry(x.job)); });
|
|
280
|
-
if (!going) return;
|
|
281
|
-
state.poll = setTimeout(function () {
|
|
282
|
-
var typing = document.activeElement && document.activeElement.classList && document.activeElement.classList.contains('gl-note');
|
|
283
|
-
if (typing) { watchJobs(); return; }
|
|
284
|
-
loadJobs();
|
|
285
|
-
}, 4000);
|
|
260
|
+
}, 3000);
|
|
286
261
|
}
|
|
287
262
|
function reloadSidebar() {
|
|
288
263
|
if (window.leShell && window.leShell.reloadGoals) window.leShell.reloadGoals();
|
|
289
|
-
if (window.leShell && window.leShell.reloadJobs) window.leShell.reloadJobs();
|
|
290
264
|
}
|
|
291
265
|
function replaceGoal(goal) {
|
|
292
|
-
// On the Jobs page, a job's goal coming back means the list changed.
|
|
293
|
-
if (jobsView) { state.jobsStale = true; return; }
|
|
294
266
|
state.goals = state.goals.map(function (g) { return g.id === goal.id ? goal : g; });
|
|
295
267
|
if (!state.goals.some(function (g) { return g.id === goal.id; })) state.goals.unshift(goal);
|
|
296
268
|
state.current = goal;
|
|
297
269
|
}
|
|
298
|
-
// A
|
|
270
|
+
// A workflow or group under the current goal.
|
|
299
271
|
function findJob(id) {
|
|
300
|
-
|
|
301
|
-
var hit = state.jobs.filter(function (x) { return x.job.id === id; })[0];
|
|
302
|
-
return hit ? hit.job : undefined;
|
|
272
|
+
return state.current ? (state.current.jobs || []).filter(function (j) { return j.id === id; })[0] : undefined;
|
|
303
273
|
}
|
|
304
274
|
|
|
305
275
|
function listHtml() {
|
|
@@ -308,11 +278,10 @@ ${consoleShellScript}
|
|
|
308
278
|
var parts = [];
|
|
309
279
|
if (g.status === 'planning') parts.push('<span class="gl-state planning">Suggesting' + ELLIPSIS + '</span>');
|
|
310
280
|
if (g.status === 'failed') parts.push('<span class="gl-state failed">Failed</span>');
|
|
311
|
-
var suggested = count(g, 'suggested'), active = count(g, 'active')
|
|
281
|
+
var suggested = count(g, 'suggested'), active = count(g, 'active');
|
|
312
282
|
if (suggested) parts.push(suggested + ' suggested');
|
|
313
283
|
if (active) parts.push('<span class="gl-state built">' + active + ' running</span>');
|
|
314
|
-
if (
|
|
315
|
-
if (!parts.length) parts.push('No jobs kept yet');
|
|
284
|
+
if (!parts.length) parts.push('Nothing kept yet');
|
|
316
285
|
var date = g.createdAt ? new Date(g.createdAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' }) : '';
|
|
317
286
|
return '<li><a href="/goals?goal=' + encodeURIComponent(g.id) + '"><span class="gl-list-goal" title="' + esc(g.goal) + '">' + esc(g.goal) + '</span>' +
|
|
318
287
|
'<span class="gl-list-date">' + esc(date) + '</span>' +
|
|
@@ -322,14 +291,16 @@ ${consoleShellScript}
|
|
|
322
291
|
|
|
323
292
|
function newGoalHtml() {
|
|
324
293
|
return '<div class="gl-card">' +
|
|
325
|
-
'<label for="glGoal"><strong>What
|
|
326
|
-
'<
|
|
327
|
-
'<
|
|
328
|
-
|
|
294
|
+
'<label for="glGoal"><strong>What should your agents take care of?</strong></label>' +
|
|
295
|
+
'<p class="hint" style="margin:2px 0 8px">Big or small: work to hand off, or a result to reach.</p>' +
|
|
296
|
+
'<textarea id="glGoal" placeholder="e.g. Help me research AI industry trends and publish a weekly report">' + esc(startText) + '</textarea>' +
|
|
297
|
+
'<div class="gl-examples hint">Or try: ' + GOAL_EXAMPLES.map(function (x) { return '<button type="button" class="gl-example" data-example="' + esc(x) + '">' + esc(x) + '</button>'; }).join('') + '</div>' +
|
|
298
|
+
'<details' + (state.about ? '' : ' open') + '><summary class="hint">About you or your business ' + (state.about ? '(saved, used for every goal)' : '(optional, makes suggestions fit you)') + '</summary>' +
|
|
299
|
+
'<textarea id="glAbout" style="margin-top:8px" placeholder="What you do, for whom, and the tools you use (Gmail, Shopify, Slack' + ELLIPSIS + ')">' + esc(state.about) + '</textarea>' +
|
|
329
300
|
'<div class="gl-row" style="margin-top:8px"><label class="hint" for="glKind">Kind of business</label><select id="glKind" class="gl-select">' + KINDS.map(function (k) { return '<option value="' + k[0] + '"' + ((state.settings.businessKind || '') === k[0] ? ' selected' : '') + '>' + k[1] + '</option>'; }).join('') + '</select></div>' +
|
|
330
301
|
(state.settings.cloud ? '<label class="hint gl-share"><input type="checkbox" id="glShare"' + (state.settings.shareLeverStats ? ' checked' : '') + '> Share anonymous stats about which suggestions you save, build and keep, to improve suggestions for everyone. Never your goals, requests or data.</label>' : '') +
|
|
331
302
|
'</details>' +
|
|
332
|
-
'<div class="gl-row"><button type="button" class="gl-btn" id="glSubmit">Suggest
|
|
303
|
+
'<div class="gl-row"><button type="button" class="gl-btn" id="glSubmit">Suggest workflows</button><span class="hint" id="glSubmitStatus"></span></div>' +
|
|
333
304
|
'</div>';
|
|
334
305
|
}
|
|
335
306
|
|
|
@@ -344,68 +315,67 @@ ${consoleShellScript}
|
|
|
344
315
|
return '<span class="gl-agent">' + ARROW + ' ' + (w.agent.isNew ? '<span class="gl-new">New agent</span>' : '') + '<strong>' + esc(w.agent.name) + '</strong></span>';
|
|
345
316
|
}
|
|
346
317
|
|
|
347
|
-
// A
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
var
|
|
355
|
-
var
|
|
356
|
-
var
|
|
357
|
-
var
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
: w.state === 'suggested' ? btn('build', 'Build
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
:
|
|
364
|
-
// On a goal's page, a job not yet on the person's list can be added to it.
|
|
365
|
-
var onList = !!(w.addedAt || ((w.state === 'active' || w.state === 'done') && (w.doers || []).length));
|
|
366
|
-
var listBtn = listed || w.state === 'discarded' ? '' : onList ? '<span class="gl-listed">In my jobs</span>' : btn('list', 'Add to my jobs', 'soft');
|
|
367
|
-
var more = w.state === 'suggested' && once ? btn('build', 'Open in Chat', 'plain') + btn('done', 'Mark done', 'plain') + btn('discard', 'Discard', 'plain')
|
|
368
|
-
: w.state === 'suggested' ? btn('discard', 'Discard', 'plain')
|
|
369
|
-
: w.state === 'active' && once ? (t && t.status === 'done' ? btn('again', 'Ask again', 'soft') : '') + btn('done', 'Mark done', 'plain') + btn('discard', 'Discard', 'plain')
|
|
370
|
-
: w.state === 'done' ? btn('undone', 'Reopen', 'plain') : '';
|
|
371
|
-
if (listed && listed.goalId !== 'g-my-jobs') more += btn('unlist', 'Remove from my jobs', 'plain');
|
|
372
|
-
var pill = w.state === 'active' && once ? (t && t.status === 'done' ? '<span class="gl-state built">Result ready</span>' : t && t.status === 'awaiting_approval' ? '<span class="gl-state planning">Needs you</span>' : t && t.status === 'running' ? '<span class="gl-state saved">Working' + ELLIPSIS + '</span>' : '<span class="gl-state failed">Failed</span>')
|
|
373
|
-
: w.state === 'active' ? '<span class="gl-state built">Running</span>'
|
|
374
|
-
: w.state === 'done' ? '<span class="gl-state built">Done</span>'
|
|
318
|
+
// A suggestion under the goal: one workflow, or a group of workflows
|
|
319
|
+
// that run in order. One row: its title, which it is, its measure, what
|
|
320
|
+
// does it, its state and the one action that matters now. Click it for
|
|
321
|
+
// the rest: why, what it needs, each workflow and their order.
|
|
322
|
+
function itemHtml(w) {
|
|
323
|
+
var group = w.group && w.group.steps && w.group.steps.length ? w.group : null;
|
|
324
|
+
var steps = group ? group.steps : [];
|
|
325
|
+
var builtSteps = steps.filter(function (st) { return st.built; }).length;
|
|
326
|
+
var nextStep = group ? steps.filter(function (st) { return !st.built; })[0] : null;
|
|
327
|
+
var active = w.state === 'active';
|
|
328
|
+
var btn = function (act, label, cls, step) { return '<button type="button" class="gl-btn ' + (cls || '') + '" data-act="' + act + '"' + (step ? ' data-step="' + esc(step) + '"' : '') + '>' + label + '</button>'; };
|
|
329
|
+
var primary = w.state === 'discarded' ? btn('restore', 'Restore', 'plain')
|
|
330
|
+
: group && nextStep ? btn('buildstep', builtSteps ? 'Build step ' + (builtSteps + 1) : 'Build step 1', '', nextStep.id)
|
|
331
|
+
: !group && w.state === 'suggested' ? btn('build', 'Build the workflow') : '';
|
|
332
|
+
var more = w.state === 'suggested' ? btn('discard', 'Discard', 'plain') : '';
|
|
333
|
+
var pill = active && group && nextStep ? '<span class="gl-state saved">' + builtSteps + ' of ' + steps.length + ' built</span>'
|
|
334
|
+
: active ? '<span class="gl-state built">Running</span>'
|
|
375
335
|
: w.state === 'discarded' ? '<span class="gl-state">Discarded</span>' : '';
|
|
376
|
-
|
|
377
|
-
var sub = w.measure ?
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
'<span class="gl-caret" aria-hidden="true"></span>') +
|
|
385
|
-
'<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>') +
|
|
386
|
-
'<span class="gl-job-sub"><span class="gl-kind">' + (once ? 'One-off' : 'Recurring') + '</span>' + (sub ? '<span class="gl-job-line">' + esc(sub) + '</span>' : '') + '</span>' +
|
|
387
|
-
(!detail && w.state === 'active' && !once && doer && doer.type === 'workflow' ? doneByHtml(w) : '') +
|
|
388
|
-
(!detail && once && (w.state === 'active' || w.state === 'done') && w.tries && w.tries.length ? assignedHtml(w) : '') +
|
|
389
|
-
(listed ? '<span class="gl-job-from">Added ' + esc(new Date(listed.addedAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })) + ' ' + String.fromCharCode(183) + ' ' +
|
|
390
|
-
(listed.goal ? 'Goal: <a href="/goals?goal=' + encodeURIComponent(listed.goalId) + '">' + esc(listed.goal) + '</a>' : 'No goal') + '</span>' : '') + '</div>' +
|
|
336
|
+
var kind = group ? 'Group ' + String.fromCharCode(183) + ' ' + steps.length + ' workflows in order' : 'Workflow';
|
|
337
|
+
var sub = w.measure ? 'Measured by ' + w.measure : w.why || '';
|
|
338
|
+
var open = !!state.openJobs[w.id];
|
|
339
|
+
return '<div class="gl-wf gl-job' + (open ? ' is-open' : '') + (active ? ' built' : '') + '" data-wf="' + esc(w.id) + '">' +
|
|
340
|
+
'<div class="gl-job-head" role="button" tabindex="0" aria-expanded="' + open + '"><span class="gl-caret" aria-hidden="true"></span>' +
|
|
341
|
+
'<div class="gl-job-main"><span class="gl-wf-title">' + esc(w.title) + '</span>' +
|
|
342
|
+
'<span class="gl-job-sub"><span class="gl-kind' + (group ? ' group' : '') + '">' + kind + '</span>' + (sub ? '<span class="gl-job-line">' + esc(sub) + '</span>' : '') + '</span>' +
|
|
343
|
+
(!open && active && !group ? doneByHtml(w) : '') + '</div>' +
|
|
391
344
|
'<span class="gl-job-status">' + pill + '<span class="gl-state planning" data-attn hidden>Needs you</span></span>' +
|
|
392
|
-
'<span class="gl-job-primary">' +
|
|
345
|
+
'<span class="gl-job-primary">' + primary + '</span>' +
|
|
393
346
|
'</div>' +
|
|
394
347
|
'<div class="gl-job-body"' + (open ? '' : ' hidden') + '>' +
|
|
395
348
|
(w.added ? '<p class="hint" style="margin:0">You added this: ' + String.fromCharCode(8220) + esc(w.added.idea) + String.fromCharCode(8221) + (w.added.note ? ' ' + String.fromCharCode(183) + ' ' + esc(w.added.note) : '') + (w.keepPrivate ? ' ' + String.fromCharCode(183) + ' kept to your workspace' : ' ' + String.fromCharCode(183) + ' its approach may be shared') + '</p>' : '') +
|
|
396
349
|
(w.why && sub !== w.why ? '<p class="gl-why">' + esc(w.why) + '</p>' : '') +
|
|
397
|
-
(w.measure && sub.indexOf(w.measure) < 0 ? '<p class="gl-job-measure">
|
|
398
|
-
(w
|
|
399
|
-
|
|
400
|
-
|
|
350
|
+
(w.measure && sub.indexOf(w.measure) < 0 ? '<p class="gl-job-measure">Measured by ' + esc(w.measure) + '</p>' : '') +
|
|
351
|
+
(group ? stepsHtml(w, steps) + (active && (w.doers || []).length > 1 ? '<details class="gl-order"><summary>Change the order</summary>' + howHtml(w) + '</details>' : '')
|
|
352
|
+
: active ? howHtml(w)
|
|
353
|
+
: '<div class="gl-row">' + agentHtml(w) + '</div>' + needsHtml(w) + '<details><summary>What the workflow will do</summary><p>' + esc(w.request) + '</p></details>') +
|
|
401
354
|
(more ? '<div class="gl-row">' + more + '</div>' : '') +
|
|
402
|
-
(once && w.state === 'active' ? '<div class="gl-again" hidden><label class="hint" for="note-' + esc(w.id) + '">What should change this time? (optional)</label><textarea class="gl-note" id="note-' + esc(w.id) + '" rows="2" placeholder="e.g. Add 5 more, and skip the paid ones."></textarea><div class="gl-row"><button type="button" class="gl-btn" data-act="assign">Send it back</button></div></div>' : '') +
|
|
403
355
|
'</div>' +
|
|
404
356
|
'<span class="hint gl-job-status-line" data-wf-status></span>' +
|
|
405
357
|
'</div>';
|
|
406
358
|
}
|
|
407
359
|
|
|
408
|
-
// A
|
|
360
|
+
// A group's workflows, in the order they run: each built one with how
|
|
361
|
+
// it's doing (filled by fillEvidence), each to build with its agent,
|
|
362
|
+
// what it needs and what it will do; then what it passes on.
|
|
363
|
+
function stepsHtml(w, steps) {
|
|
364
|
+
return '<ol class="gl-gsteps">' + steps.map(function (st, i) {
|
|
365
|
+
var head = '<span class="gl-gstep-n">' + (i + 1) + '</span><strong class="gl-gstep-name">' + esc(st.name) + '</strong>';
|
|
366
|
+
var row = st.built
|
|
367
|
+
? '<div class="gl-gstep-head" data-how="' + esc(st.built.agent) + '|' + esc(st.built.workflowId) + '">' + head +
|
|
368
|
+
'<a class="gl-slug" href="/agents/config?agent=' + encodeURIComponent(st.built.agent) + '&tab=workflows&workflow=' + encodeURIComponent(st.built.workflowId) + '">' + esc(st.built.workflowId) + '</a>' +
|
|
369
|
+
'<span class="gl-agent-pill">' + esc(st.built.agent) + '</span><span class="hint" data-how-meta>' + ELLIPSIS + '</span></div>'
|
|
370
|
+
: '<div class="gl-gstep-head">' + head + agentHtml(st) +
|
|
371
|
+
(w.state !== 'discarded' ? '<button type="button" class="gl-btn soft gl-gstep-build" data-act="buildstep" data-step="' + esc(st.id) + '">Build</button>' : '') + '</div>' +
|
|
372
|
+
needsHtml(st) + '<details><summary>What it will do</summary><p>' + esc(st.request) + '</p></details>';
|
|
373
|
+
return '<li class="gl-gstep' + (st.built ? ' built' : '') + '">' + row +
|
|
374
|
+
(i < steps.length - 1 ? '<div class="gl-gstep-then">then ' + ARROW + ' starts when this one finishes, with its result</div>' : '') + '</li>';
|
|
375
|
+
}).join('') + '</ol>';
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// A workflow of the person's own: typed in their words, shaped and judged by
|
|
409
379
|
// the planner (added, changed, warned or refused), with what it said.
|
|
410
380
|
function addJobHtml(planning) {
|
|
411
381
|
var n = state.addNotice;
|
|
@@ -414,46 +384,19 @@ ${consoleShellScript}
|
|
|
414
384
|
(n.note ? '<span>' + esc(n.note) + '</span>' : '') +
|
|
415
385
|
(n.alternative ? '<span class="hint">Instead, you could: ' + esc(n.alternative) + '</span>' : '') + '</div>';
|
|
416
386
|
return '<div class="gl-add">' +
|
|
417
|
-
'<button type="button" class="gl-link" id="glAddToggle"' + (state.addOpen ? ' hidden' : '') + '>+ Add your own
|
|
387
|
+
'<button type="button" class="gl-link" id="glAddToggle"' + (state.addOpen ? ' hidden' : '') + '>+ Add your own workflow</button>' +
|
|
418
388
|
'<div class="gl-add-form"' + (state.addOpen ? '' : ' hidden') + '>' +
|
|
419
|
-
'<label for="glAddIdea"><strong>A
|
|
389
|
+
'<label for="glAddIdea"><strong>A workflow you have in mind</strong> <span class="hint">in your own words; LoopEngine shapes it into a workflow (or a group, when it has stages) and says if anything looks off</span></label>' +
|
|
420
390
|
'<textarea id="glAddIdea" rows="2" placeholder="e.g. Thank every new customer by email within a day">' + esc(state.addDraft || '') + '</textarea>' +
|
|
421
|
-
'<label class="hint gl-share"><input type="checkbox" id="glAddShare"' + (state.addShare ? ' checked' : '') + '> Share the approach behind
|
|
391
|
+
'<label class="hint gl-share"><input type="checkbox" id="glAddShare"' + (state.addShare ? ' checked' : '') + '> Share the approach behind it to improve suggestions for everyone</label>' +
|
|
422
392
|
'<p class="hint" style="margin:0">Your idea stays in your workspace unless you tick that. If you do, only a generic description of the approach is shared, never your words, and only once many workspaces use something similar.</p>' +
|
|
423
393
|
'<div class="gl-row"><button type="button" class="gl-btn soft" id="glAddJob"' + (planning ? ' disabled' : '') + '>Add it</button><button type="button" class="gl-btn plain" id="glAddCancel">Cancel</button><span class="hint" id="glAddStatus"></span></div>' +
|
|
424
394
|
'</div>' + notice + '</div>';
|
|
425
395
|
}
|
|
426
396
|
|
|
427
|
-
//
|
|
428
|
-
//
|
|
429
|
-
|
|
430
|
-
var pill = t.status === 'running' ? '<span class="gl-state saved">Working' + ELLIPSIS + '</span>'
|
|
431
|
-
: t.status === 'awaiting_approval' ? '<span class="gl-state planning">Waiting for your decision</span>'
|
|
432
|
-
: t.status === 'done' ? '<span class="gl-state built">Finished</span>'
|
|
433
|
-
: t.status === 'error' ? '<span class="gl-state failed">Failed</span>' : '<span class="gl-state failed">Its record is gone</span>';
|
|
434
|
-
return '<div class="gl-try"><div class="gl-row"><strong>Try ' + n + '</strong>' + pill + '<span class="hint">' + esc(new Date(t.at).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })) + '</span></div>' +
|
|
435
|
-
(t.note ? '<p class="hint" style="margin:0">You asked: ' + esc(t.note) + '</p>' : '') +
|
|
436
|
-
(t.status === 'awaiting_approval' ? '<p class="hint" style="margin:0">It asked you something: answer in the agent' + String.fromCharCode(8217) + 's messaging app, or on its Approvals.</p>' : '') +
|
|
437
|
-
(t.result ? '<div class="gl-result">' + esc(t.result) + '</div>' : '') +
|
|
438
|
-
(t.error ? '<p class="error">' + esc(t.error) + '</p>' : '') + '</div>';
|
|
439
|
-
}
|
|
440
|
-
function triesHtml(w) {
|
|
441
|
-
var tries = w.tries;
|
|
442
|
-
var latest = tries[tries.length - 1];
|
|
443
|
-
var earlier = tries.slice(0, -1);
|
|
444
|
-
var done = w.state === 'done';
|
|
445
|
-
return '<div class="gl-doer">Assigned to <strong>' + esc(w.agent.name) + '</strong>' + (done && w.doneAt ? ' ' + String.fromCharCode(183) + ' done ' + esc(new Date(w.doneAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) : '') + '</div>' +
|
|
446
|
-
(done ? (w.result ? '<details class="gl-result-wrap" open><summary>The accepted result</summary><div class="gl-result">' + esc(w.result) + '</div></details>' : '') : tryHtml(latest, tries.length)) +
|
|
447
|
-
(earlier.length || done ? '<details class="gl-result-wrap"><summary>' + (done ? 'All tries (' + tries.length + ')' : 'Earlier tries (' + earlier.length + ')') + '</summary>' +
|
|
448
|
-
(done ? tries : earlier).map(function (t, i) { return tryHtml(t, i + 1); }).join('') + '</details>' : '');
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// How a recurring job is done: each workflow that does it, on its agent,
|
|
452
|
-
// with how it starts and how it's doing. The detail (its instructions,
|
|
453
|
-
// tools, runs) is on the workflow itself: Open.
|
|
454
|
-
// On a job's card: what does it, in one line per workflow, each with
|
|
455
|
-
// how it's going (filled by fillEvidence) and a link to manage them on
|
|
456
|
-
// the job's page.
|
|
397
|
+
// On a built workflow's card: what does it, one line per workflow, each
|
|
398
|
+
// with how it's going (filled by fillEvidence); "then" marks one that
|
|
399
|
+
// starts after another.
|
|
457
400
|
function doneByHtml(w) {
|
|
458
401
|
var flows = (w.doers || []).filter(function (d) { return d.type === 'workflow'; });
|
|
459
402
|
// A chained workflow follows the one that starts it, marked "then".
|
|
@@ -471,12 +414,7 @@ ${consoleShellScript}
|
|
|
471
414
|
(then ? '<span class="gl-doneby-then">then ' + String.fromCharCode(8594) + '</span>' : '<span class="gl-tag-wf">Workflow</span>') +
|
|
472
415
|
'<a href="/agents/config?agent=' + encodeURIComponent(d.agent) + '&tab=workflows&workflow=' + encodeURIComponent(d.workflowId) + '" class="gl-slug">' + esc(d.workflowId) + '</a>' +
|
|
473
416
|
'<span class="gl-agent-pill">' + esc(d.agent) + '</span><span class="hint" data-how-meta>' + ELLIPSIS + '</span></span>';
|
|
474
|
-
}).join('') + '
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// A one-off job's card: the agent it's assigned to.
|
|
478
|
-
function assignedHtml(w) {
|
|
479
|
-
return '<span class="gl-doneby"><span class="gl-doneby-row"><span class="gl-tag-wf">Assignment</span><span class="gl-agent-pill">' + esc(w.agent.name) + '</span><span class="hint">one run, its result kept with the job</span></span></span>';
|
|
417
|
+
}).join('') + '</span>';
|
|
480
418
|
}
|
|
481
419
|
|
|
482
420
|
function howHtml(w) {
|
|
@@ -498,7 +436,7 @@ ${consoleShellScript}
|
|
|
498
436
|
'<div class="gl-row"><button type="button" class="gl-btn plain" data-act="addwf">Add a workflow</button>' + (flows.length > 1 ? '<button type="button" class="gl-btn plain" data-act="addstep">Add a step</button>' : '') + '</div>' +
|
|
499
437
|
'<div class="gl-panel" data-panel="addwf" hidden><label class="hint" for="addwf-' + esc(w.id) + '">A workflow already on one of your agents</label>' +
|
|
500
438
|
'<div class="gl-row"><select class="gl-select" id="addwf-' + esc(w.id) + '" data-pick-workflow><option value="">Loading' + ELLIPSIS + '</option></select><button type="button" class="gl-btn soft" data-act="link">Add it</button></div>' +
|
|
501
|
-
'<div class="gl-row"><span class="hint">or</span><button type="button" class="gl-link" data-act="another">build a new one for
|
|
439
|
+
'<div class="gl-row"><span class="hint">or</span><button type="button" class="gl-link" data-act="another">build a new one for it</button></div></div>' +
|
|
502
440
|
'<div class="gl-panel" data-panel="addstep" hidden>' +
|
|
503
441
|
'<div class="gl-row"><span class="hint">After</span><select class="gl-select" data-step-after>' + flows.map(function (d) { return '<option value="' + esc(d.agent) + '|' + esc(d.workflowId) + '">' + esc(d.workflowId) + '</option>'; }).join('') + '</select>' +
|
|
504
442
|
'<span class="hint">finishes</span><select class="gl-select" data-step-when><option value="always">every time</option><option value="contains">when its result contains</option><option value="line_starts">when its result has a line starting</option></select><input class="gl-input" data-step-text placeholder="e.g. Lead:" hidden></div>' +
|
|
@@ -516,7 +454,7 @@ ${consoleShellScript}
|
|
|
516
454
|
}
|
|
517
455
|
|
|
518
456
|
// Fills each workflow row from its agent's workflow list, and marks the
|
|
519
|
-
//
|
|
457
|
+
// suggestion when one is waiting for a decision.
|
|
520
458
|
function fillEvidence() {
|
|
521
459
|
var rows = page.querySelectorAll('[data-how]');
|
|
522
460
|
var agents = {};
|
|
@@ -551,76 +489,11 @@ ${consoleShellScript}
|
|
|
551
489
|
});
|
|
552
490
|
}
|
|
553
491
|
|
|
554
|
-
// The Jobs page: submit a job (no goal needed), then every job on the
|
|
555
|
-
// person's list, newest added first, each with when and which goal.
|
|
556
|
-
function jobsHtml() {
|
|
557
|
-
var n = state.jobNotice;
|
|
558
|
-
var notice = !n ? '' : '<div class="gl-notice ' + (n.verdict === 'refused' ? 'bad' : n.verdict === 'added' ? 'good' : 'warn') + '">' +
|
|
559
|
-
'<strong>' + (n.verdict === 'refused' ? 'Not added' : n.verdict === 'changed' ? 'Added, with changes' : n.verdict === 'warned' ? 'Added, with a caution' : 'Added to your jobs') + '</strong>' +
|
|
560
|
-
(n.note ? '<span>' + esc(n.note) + '</span>' : '') +
|
|
561
|
-
(n.alternative ? '<span class="hint">Instead, you could: ' + esc(n.alternative) + '</span>' : '') + '</div>';
|
|
562
|
-
var items = state.jobs;
|
|
563
|
-
if (jobCreating) return '<div class="gl-card">' +
|
|
564
|
-
'<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>' +
|
|
565
|
-
'<textarea id="glJobIdea" rows="2" placeholder="e.g. Answer every customer email within an hour">' + esc(state.jobDraft || '') + '</textarea>' +
|
|
566
|
-
'<div class="gl-row"><button type="button" class="gl-btn" id="glJobSubmit">Submit job</button><span class="hint" id="glJobStatus"></span>' +
|
|
567
|
-
'<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>' +
|
|
568
|
-
notice +
|
|
569
|
-
'</div>' +
|
|
570
|
-
(items.length ? '<div><a class="gl-link" href="/jobs">' + String.fromCharCode(8592) + ' My jobs (' + items.length + ')</a></div>' : '');
|
|
571
|
-
if (jobPage) {
|
|
572
|
-
var here = items.filter(function (x) { return x.job.id === jobPage; })[0];
|
|
573
|
-
return '<div><a class="gl-link" href="/jobs">' + String.fromCharCode(8592) + ' My jobs (' + items.length + ')</a></div>' + notice +
|
|
574
|
-
(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>');
|
|
575
|
-
}
|
|
576
|
-
return notice +
|
|
577
|
-
'<p class="hint gl-define">A job is something that needs doing, with a way to tell it' + String.fromCharCode(8217) + 's done. Workflows and agents do jobs: a workflow for a recurring job, an agent for a one-off.</p>' +
|
|
578
|
-
'<div class="gl-section"><h3>My jobs <span class="gl-count">' + items.length + '</span></h3>' +
|
|
579
|
-
(items.length ? items.map(function (x) { return jobHtml(x.job, x); }).join('')
|
|
580
|
-
: '<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>') +
|
|
581
|
-
'</div>';
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function wireJobs() {
|
|
585
|
-
var idea = document.getElementById('glJobIdea');
|
|
586
|
-
if (idea) idea.addEventListener('input', function () { state.jobDraft = idea.value; });
|
|
587
|
-
// The sidebar's Jobs "+ New" (?new=1): straight to the box, once.
|
|
588
|
-
if (idea && !state.jobFocused && new URLSearchParams(location.search).has('new')) { state.jobFocused = true; idea.focus(); }
|
|
589
|
-
var submit = document.getElementById('glJobSubmit');
|
|
590
|
-
if (submit) submit.addEventListener('click', function () {
|
|
591
|
-
var text = idea.value.trim();
|
|
592
|
-
var status = document.getElementById('glJobStatus');
|
|
593
|
-
if (text.length < 5) { status.textContent = 'Say what the job is first.'; return; }
|
|
594
|
-
submit.disabled = true;
|
|
595
|
-
status.textContent = 'Shaping it' + ELLIPSIS;
|
|
596
|
-
api('POST', '/jobs', { idea: text }).then(function (r) {
|
|
597
|
-
submit.disabled = false;
|
|
598
|
-
if (!r.ok) { status.textContent = r.body.error || 'Could not add it.'; return; }
|
|
599
|
-
state.jobNotice = { verdict: r.body.verdict, note: r.body.note, alternative: r.body.alternative };
|
|
600
|
-
if (r.body.jobId) {
|
|
601
|
-
state.jobDraft = '';
|
|
602
|
-
state.openJobs[r.body.jobId] = true;
|
|
603
|
-
// Added: back to the list, with it open. A refused one stays on the form.
|
|
604
|
-
jobCreating = false;
|
|
605
|
-
jobPage = r.body.jobId;
|
|
606
|
-
var url = new URL(location.href);
|
|
607
|
-
url.searchParams.delete('new');
|
|
608
|
-
url.searchParams.set('job', r.body.jobId);
|
|
609
|
-
history.replaceState(null, '', url);
|
|
610
|
-
}
|
|
611
|
-
loadJobs();
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
var cards = page.querySelectorAll('.gl-job[data-goal]');
|
|
615
|
-
for (var i = 0; i < cards.length; i++) wireCard(cards[i], '/goals/' + encodeURIComponent(cards[i].getAttribute('data-goal')));
|
|
616
|
-
}
|
|
617
|
-
|
|
618
492
|
function goalHtml(g) {
|
|
619
493
|
var jobs = g.jobs || [];
|
|
620
494
|
var by = function (s) { return jobs.filter(function (w) { return w.state === s; }); };
|
|
621
495
|
var suggested = by('suggested');
|
|
622
|
-
|
|
623
|
-
var kept = by('active').concat(by('done'));
|
|
496
|
+
var kept = by('active');
|
|
624
497
|
var discarded = by('discarded');
|
|
625
498
|
var planning = g.status === 'planning';
|
|
626
499
|
var focus = g.focus || (g.brief && g.brief.focus) || '';
|
|
@@ -631,7 +504,7 @@ ${consoleShellScript}
|
|
|
631
504
|
(focus.indexOf('x-') === 0 ? '<span class="hint" title="No focus in the playbook fit this goal, so its planner named one and wrote the approaches it needed. They stay in this workspace for next time.">written for your goals</span>' : '') +
|
|
632
505
|
(g.brief && g.brief.measure ? '<span>' + String.fromCharCode(183) + ' measured by ' + esc(g.brief.measure) + '</span>' : '') + '</div>' : '') +
|
|
633
506
|
(g.message ? '<p class="gl-why">' + esc(g.message) + '</p>' : '') +
|
|
634
|
-
(planning ? '<p class="gl-status">Suggesting
|
|
507
|
+
(planning ? '<p class="gl-status">Suggesting workflows' + ELLIPSIS + (secs ? ' ' + secs + 's' : '') + ' It reads your workspace first; this takes about a minute.</p>' : '') +
|
|
635
508
|
(g.status === 'failed' ? '<p class="error">' + esc(g.error || 'Planning failed.') + '</p>' : '') +
|
|
636
509
|
(g.setup && g.setup.length ? '<div><strong style="font-size:13.5px">Before you start</strong><ol class="gl-setup">' + g.setup.slice(0, 4).map(function (s) { return '<li>' + esc(s) + '</li>'; }).join('') + '</ol>' +
|
|
637
510
|
(g.setup.length > 4 ? '<details class="gl-setup-more"><summary>' + (g.setup.length - 4) + ' more</summary><ol class="gl-setup" start="5">' + g.setup.slice(4).map(function (s) { return '<li>' + esc(s) + '</li>'; }).join('') + '</ol></details>' : '') + '</div>' : '') +
|
|
@@ -639,16 +512,17 @@ ${consoleShellScript}
|
|
|
639
512
|
(state.justDiscarded ? '<div class="gl-discarded-note" data-discarded="' + esc(state.justDiscarded.id) + '"><span>Discarded <strong>' + esc(state.justDiscarded.title) + '</strong>. Why?</span>' +
|
|
640
513
|
REASONS.map(function (r) { return '<button type="button" class="gl-btn plain" data-reason="' + r[0] + '">' + r[1] + '</button>'; }).join('') +
|
|
641
514
|
'<button type="button" class="gl-link" data-undo="1">Undo</button></div>' : '') +
|
|
642
|
-
'<div class="gl-section"><h3>Suggested
|
|
643
|
-
|
|
644
|
-
'
|
|
515
|
+
'<div class="gl-section"><h3>Suggested <span class="gl-count">' + suggested.length + '</span></h3>' +
|
|
516
|
+
'<p class="hint gl-define">Workflows that move this goal, and groups of workflows that run in order, one after another.</p>' +
|
|
517
|
+
(suggested.length ? suggested.map(function (w) { return itemHtml(w); }).join('') : '<p class="gl-empty">' + (planning ? 'On their way' + ELLIPSIS : 'No suggestions waiting. Generate more for new ideas.') + '</p>') +
|
|
518
|
+
'<div class="gl-row"><button type="button" class="gl-btn soft" id="glMore"' + (planning ? ' disabled' : '') + '>Generate more</button><span class="hint">More workflows or groups: nothing already here, built or discarded comes back.</span></div>' +
|
|
645
519
|
addJobHtml(planning) +
|
|
646
520
|
'</div>' +
|
|
647
|
-
'<div class="gl-section"><h3>Your
|
|
648
|
-
(kept.length ? kept.map(function (w) { return
|
|
521
|
+
'<div class="gl-section"><h3>Your workflows <span class="gl-count">' + kept.length + '</span></h3>' +
|
|
522
|
+
(kept.length ? kept.map(function (w) { return itemHtml(w); }).join('') : '<p class="gl-empty">Nothing built yet. Build a suggested workflow, or a group' + String.fromCharCode(8217) + 's workflows one by one.</p>') +
|
|
649
523
|
'</div>' +
|
|
650
524
|
(discarded.length ? '<div class="gl-section"><button type="button" class="gl-link" id="glShowDiscarded">' + (state.showDiscarded ? 'Hide' : 'Show') + ' discarded (' + discarded.length + ')</button>' +
|
|
651
|
-
(state.showDiscarded ? discarded.map(function (w) { return
|
|
525
|
+
(state.showDiscarded ? discarded.map(function (w) { return itemHtml(w); }).join('') : '') + '</div>' : '') +
|
|
652
526
|
'<div><button type="button" class="gl-link" id="glDelete" style="color:var(--bad)">Delete this goal</button></div>';
|
|
653
527
|
}
|
|
654
528
|
|
|
@@ -656,23 +530,6 @@ ${consoleShellScript}
|
|
|
656
530
|
var title = document.getElementById('glTitle');
|
|
657
531
|
var lead = document.getElementById('glLead');
|
|
658
532
|
var newBtn = document.getElementById('glNewBtn');
|
|
659
|
-
if (jobsView) {
|
|
660
|
-
if (state.jobsStale) { loadJobs(); return; }
|
|
661
|
-
var shown = jobPage && state.jobs.filter(function (x) { return x.job.id === jobPage; })[0];
|
|
662
|
-
if (title) title.textContent = jobCreating ? 'New job' : jobPage ? 'Job' : 'Jobs';
|
|
663
|
-
if (shown) document.title = shown.job.title;
|
|
664
|
-
if (lead) {
|
|
665
|
-
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.';
|
|
666
|
-
lead.style.display = jobCreating ? '' : 'none';
|
|
667
|
-
}
|
|
668
|
-
if (newBtn) { newBtn.hidden = jobCreating; newBtn.textContent = 'New job'; newBtn.setAttribute('href', '/jobs?new=1'); }
|
|
669
|
-
page.innerHTML = state.jobsLoaded ? jobsHtml() + (state.error ? '<p class="error">' + esc(state.error) + '</p>' : '') : '<p class="hint">Loading' + ELLIPSIS + '</p>';
|
|
670
|
-
state.error = '';
|
|
671
|
-
wireJobs();
|
|
672
|
-
watchJobs();
|
|
673
|
-
fillEvidence();
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
533
|
// The list, unless there are no goals yet: then the new-goal form.
|
|
677
534
|
var listing = !state.current && !state.creating && state.goals.length > 0;
|
|
678
535
|
if (title) title.textContent = state.current ? 'Goal' : listing ? 'Goals' : 'New goal';
|
|
@@ -686,13 +543,20 @@ ${consoleShellScript}
|
|
|
686
543
|
}
|
|
687
544
|
|
|
688
545
|
function wire() {
|
|
546
|
+
page.querySelectorAll('[data-example]').forEach(function (b) {
|
|
547
|
+
b.addEventListener('click', function () {
|
|
548
|
+
var box = document.getElementById('glGoal');
|
|
549
|
+
box.value = b.dataset.example;
|
|
550
|
+
box.focus();
|
|
551
|
+
});
|
|
552
|
+
});
|
|
689
553
|
var submit = document.getElementById('glSubmit');
|
|
690
554
|
if (submit) submit.addEventListener('click', function () {
|
|
691
555
|
var goal = document.getElementById('glGoal').value.trim();
|
|
692
556
|
startText = '';
|
|
693
557
|
var aboutBox = document.getElementById('glAbout');
|
|
694
558
|
var status = document.getElementById('glSubmitStatus');
|
|
695
|
-
if (goal.length < 5) { status.textContent = 'Say what
|
|
559
|
+
if (goal.length < 5) { status.textContent = 'Say what your agents should take care of first.'; return; }
|
|
696
560
|
this.disabled = true;
|
|
697
561
|
status.textContent = 'Starting' + ELLIPSIS;
|
|
698
562
|
api('POST', '/goals', { goal: goal, about: aboutBox ? aboutBox.value : state.about }).then(function (r) {
|
|
@@ -744,9 +608,9 @@ ${consoleShellScript}
|
|
|
744
608
|
if (addJob) addJob.addEventListener('click', function () {
|
|
745
609
|
var idea = document.getElementById('glAddIdea').value.trim();
|
|
746
610
|
var status = document.getElementById('glAddStatus');
|
|
747
|
-
if (idea.length < 5) { status.textContent = 'Say what the
|
|
611
|
+
if (idea.length < 5) { status.textContent = 'Say what the workflow should do first.'; return; }
|
|
748
612
|
addJob.disabled = true;
|
|
749
|
-
status.textContent = 'Shaping it into a
|
|
613
|
+
status.textContent = 'Shaping it into a workflow' + ELLIPSIS;
|
|
750
614
|
var shareBox = document.getElementById('glAddShare');
|
|
751
615
|
api('POST', base + '/jobs', { idea: idea, share: !!(shareBox && shareBox.checked) }).then(function (r) {
|
|
752
616
|
if (!r.ok) { addJob.disabled = false; status.textContent = r.body.error || 'Could not add it.'; return; }
|
|
@@ -760,7 +624,7 @@ ${consoleShellScript}
|
|
|
760
624
|
if (shown) shown.addEventListener('click', function () { state.showDiscarded = !state.showDiscarded; render(); });
|
|
761
625
|
var del = document.getElementById('glDelete');
|
|
762
626
|
if (del) del.addEventListener('click', function () {
|
|
763
|
-
if (del.dataset.confirming !== '1') { del.dataset.confirming = '1'; del.textContent = 'Click again to delete this goal (the workflows
|
|
627
|
+
if (del.dataset.confirming !== '1') { del.dataset.confirming = '1'; del.textContent = 'Click again to delete this goal (the workflows built for it stay in their agents)'; return; }
|
|
764
628
|
api('DELETE', base).then(function () { state.current = null; setUrl(''); reloadSidebar(); load(); });
|
|
765
629
|
});
|
|
766
630
|
var cards = page.querySelectorAll('[data-wf]');
|
|
@@ -844,7 +708,7 @@ ${consoleShellScript}
|
|
|
844
708
|
ev.preventDefault();
|
|
845
709
|
setJobOpen(card, !card.classList.contains('is-open'));
|
|
846
710
|
});
|
|
847
|
-
// A
|
|
711
|
+
// A suggestion's chain: change the step being written, remove a step or a workflow.
|
|
848
712
|
['[data-step-run]', '[data-step-after]', '[data-step-when]'].forEach(function (sel) {
|
|
849
713
|
var el = card.querySelector(sel);
|
|
850
714
|
if (el) el.addEventListener('change', function () { stepInputs(card); });
|
|
@@ -866,7 +730,7 @@ ${consoleShellScript}
|
|
|
866
730
|
var unlinks = card.querySelectorAll('[data-unlink]');
|
|
867
731
|
for (var ul = 0; ul < unlinks.length; ul++) unlinks[ul].addEventListener('click', function (ev) {
|
|
868
732
|
var b = ev.currentTarget;
|
|
869
|
-
if (b.dataset.confirming !== '1') { b.dataset.confirming = '1'; b.textContent = 'Click again to remove it from this
|
|
733
|
+
if (b.dataset.confirming !== '1') { b.dataset.confirming = '1'; b.textContent = 'Click again to remove it from this goal (it stays on its agent)'; return; }
|
|
870
734
|
var parts = b.getAttribute('data-unlink').split('|');
|
|
871
735
|
patch({ action: 'unlink', agent: parts[0], workflowId: parts[1] }, b);
|
|
872
736
|
});
|
|
@@ -913,26 +777,10 @@ ${consoleShellScript}
|
|
|
913
777
|
});
|
|
914
778
|
return;
|
|
915
779
|
}
|
|
916
|
-
if (act === 'again') {
|
|
917
|
-
setJobOpen(card, true);
|
|
918
|
-
var box = card.querySelector('.gl-again');
|
|
919
|
-
if (box) { box.hidden = false; box.querySelector('textarea').focus(); }
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
780
|
btn.disabled = true;
|
|
923
|
-
if (act === '
|
|
924
|
-
var noteBox = card.querySelector('.gl-note');
|
|
925
|
-
status.textContent = act === 'assign' ? 'Assigning' + ELLIPSIS : '';
|
|
926
|
-
api('POST', base + '/jobs/' + encodeURIComponent(id) + '/' + act, act === 'assign' ? { note: noteBox ? noteBox.value : '' } : {}).then(function (r) {
|
|
927
|
-
if (!r.ok) { status.textContent = r.body.error || 'Could not do that.'; btn.disabled = false; return; }
|
|
928
|
-
replaceGoal(r.body.goal);
|
|
929
|
-
render();
|
|
930
|
-
});
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
if (act === 'build') {
|
|
781
|
+
if (act === 'build' || act === 'buildstep') {
|
|
934
782
|
status.textContent = 'Getting the agent ready' + ELLIPSIS;
|
|
935
|
-
api('POST', base + '/jobs/' + encodeURIComponent(id) + '/build').then(function (r) {
|
|
783
|
+
api('POST', base + '/jobs/' + encodeURIComponent(id) + '/build', act === 'buildstep' ? { step: btn.getAttribute('data-step') } : undefined).then(function (r) {
|
|
936
784
|
if (!r.ok) { status.textContent = r.body.error || 'Could not build it.'; btn.disabled = false; return; }
|
|
937
785
|
location.href = r.body.url;
|
|
938
786
|
});
|
|
@@ -954,20 +802,18 @@ ${consoleShellScript}
|
|
|
954
802
|
</script>
|
|
955
803
|
</body>
|
|
956
804
|
</html>`;
|
|
957
|
-
const GOALS_LEAD = '
|
|
958
|
-
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.';
|
|
805
|
+
const GOALS_LEAD = 'LoopEngine suggests the workflows a goal needs: one for a small goal; more, or groups that run in order, for a big one. Build the ones you want.';
|
|
959
806
|
function goalsPageFor(view) {
|
|
960
|
-
const
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const hideLead = view === 'goal' || view === 'goals' || view === 'jobs' || view === 'job';
|
|
807
|
+
const title = view === 'goal' ? 'Goal' : view === 'goals' ? 'Goals' : 'New goal';
|
|
808
|
+
// A list or one goal shows no lead; a new goal explains itself.
|
|
809
|
+
const hideLead = view === 'goal' || view === 'goals';
|
|
964
810
|
return goalsPageTemplate
|
|
965
|
-
.replace('__GL_HEAD__', `<h1 id="glTitle">${title}</h1><p id="glLead"${hideLead ? ' style="display:none"' : ''}>${
|
|
966
|
-
.replace('__GL_NEW_HREF__',
|
|
967
|
-
.replace('__GL_NEW_HIDDEN__', view === 'goals'
|
|
968
|
-
.replace('__GL_NEW_LABEL__',
|
|
811
|
+
.replace('__GL_HEAD__', `<h1 id="glTitle">${title}</h1><p id="glLead"${hideLead ? ' style="display:none"' : ''}>${GOALS_LEAD}</p>`)
|
|
812
|
+
.replace('__GL_NEW_HREF__', '/goals?new=1')
|
|
813
|
+
.replace('__GL_NEW_HIDDEN__', view === 'goals' ? '' : ' hidden')
|
|
814
|
+
.replace('__GL_NEW_LABEL__', 'New goal');
|
|
969
815
|
}
|
|
970
|
-
const goalsPages = { goals: goalsPageFor('goals'), goal: goalsPageFor('goal'), new: goalsPageFor('new')
|
|
816
|
+
const goalsPages = { goals: goalsPageFor('goals'), goal: goalsPageFor('goal'), new: goalsPageFor('new') };
|
|
971
817
|
export function goalsPageAs(view) {
|
|
972
818
|
return goalsPages[view];
|
|
973
819
|
}
|