loopengine 0.3.65 → 0.3.67
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 +32 -4
- package/dist/core/system-agents/goal-planner.js +176 -23
- package/dist/core/system-agents/goal-playbooks.d.ts +40 -6
- package/dist/core/system-agents/goal-playbooks.js +110 -18
- package/dist/core/system-agents/playbook.json +33 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/web/goals-admin.d.ts +35 -3
- package/dist/web/goals-admin.js +95 -7
- package/dist/web/goals-page.js +135 -26
- package/dist/web/lever-events-sync.d.ts +3 -1
- package/dist/web/lever-events-sync.js +9 -4
- package/package.json +1 -1
package/dist/web/goals-page.js
CHANGED
|
@@ -53,6 +53,23 @@ export const goalsPageHtml = `<!doctype html>
|
|
|
53
53
|
.gl-state { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
|
|
54
54
|
.gl-state.saved { background: var(--accent-soft); color: var(--accent-ink); }
|
|
55
55
|
.gl-state.built { background: var(--good-soft); color: var(--good); }
|
|
56
|
+
.gl-job { padding: 0; gap: 0; }
|
|
57
|
+
.gl-job-head { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; border-radius: 10px; }
|
|
58
|
+
.gl-job-head:hover { background: var(--surface); }
|
|
59
|
+
.gl-job-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
60
|
+
.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; }
|
|
61
|
+
.gl-job.is-open .gl-caret { transform: rotate(45deg); }
|
|
62
|
+
.gl-job-main { display: grid; gap: 3px; min-width: 0; }
|
|
63
|
+
.gl-job-sub { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 12.5px; color: var(--ink-muted); }
|
|
64
|
+
.gl-job-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
65
|
+
.gl-job-status { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
|
|
66
|
+
.gl-job-primary .gl-btn { height: 30px; font-size: 13px; padding: 0 12px; }
|
|
67
|
+
.gl-job-body { display: grid; gap: 10px; padding: 2px 16px 14px 40px; }
|
|
68
|
+
.gl-job-body[hidden] { display: none; }
|
|
69
|
+
.gl-job-measure { margin: 0; font-size: 13px; color: var(--ink-muted); }
|
|
70
|
+
.gl-job-status-line:empty { display: none; }
|
|
71
|
+
.gl-job-status-line { padding: 0 16px 10px 40px; }
|
|
72
|
+
@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; } }
|
|
56
73
|
.gl-job-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12.5px; color: var(--ink-muted); }
|
|
57
74
|
.gl-kind { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
|
|
58
75
|
.gl-doer { font-size: 13px; color: var(--ink-muted); }
|
|
@@ -78,6 +95,14 @@ export const goalsPageHtml = `<!doctype html>
|
|
|
78
95
|
.gl-how-open:hover { text-decoration: underline; }
|
|
79
96
|
.gl-waiting { color: var(--warn); font-weight: 600; }
|
|
80
97
|
[data-attn][hidden] { display: none; }
|
|
98
|
+
.gl-add { display: grid; gap: 8px; }
|
|
99
|
+
.gl-add-form { display: grid; gap: 6px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; }
|
|
100
|
+
.gl-add-form[hidden], #glAddToggle[hidden] { display: none; }
|
|
101
|
+
#glAddToggle { justify-self: start; }
|
|
102
|
+
.gl-notice { display: grid; gap: 4px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; }
|
|
103
|
+
.gl-notice.good { background: var(--good-soft); }
|
|
104
|
+
.gl-notice.warn { background: var(--warn-soft); }
|
|
105
|
+
.gl-notice.bad { background: var(--bad-soft); }
|
|
81
106
|
.gl-try { display: grid; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--surface); }
|
|
82
107
|
.gl-try + .gl-try { margin-top: 6px; }
|
|
83
108
|
.gl-result { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.55; max-height: 360px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
|
|
@@ -130,13 +155,15 @@ ${consoleShellScript}
|
|
|
130
155
|
var page = document.getElementById('glPage');
|
|
131
156
|
var ELLIPSIS = String.fromCharCode(8230);
|
|
132
157
|
var ARROW = String.fromCharCode(8594);
|
|
158
|
+
// The focuses in use (the playbook's, and the workspace's own the
|
|
159
|
+
// planner named), from the server; these until it answers.
|
|
133
160
|
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']];
|
|
134
161
|
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']];
|
|
135
162
|
var REASONS = [['not-relevant', 'Not relevant'], ['too-much-work', 'Too much work'], ['already-doing-it', 'Already doing it']];
|
|
136
163
|
// Which view: the list (/goals), a new goal (?new=1, or the front page)
|
|
137
164
|
// or one goal (?goal=).
|
|
138
165
|
var startNew = location.pathname === '/' || new URLSearchParams(location.search).has('new');
|
|
139
|
-
var state = { flows: {}, goals: [], about: '', settings: {}, current: null, creating: startNew, showDiscarded: false, justDiscarded: null, error: '', poll: null, startedAt: 0 };
|
|
166
|
+
var state = { addOpen: false, addDraft: '', addPrivate: false, addNotice: null, flows: {}, openJobs: {}, goals: [], about: '', settings: {}, current: null, creating: startNew, showDiscarded: false, justDiscarded: null, error: '', poll: null, startedAt: 0 };
|
|
140
167
|
|
|
141
168
|
function esc(s) {
|
|
142
169
|
return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
|
|
@@ -165,6 +192,7 @@ ${consoleShellScript}
|
|
|
165
192
|
state.goals = r.body.goals || [];
|
|
166
193
|
state.about = r.body.about || '';
|
|
167
194
|
state.settings = r.body.settings || {};
|
|
195
|
+
if (Array.isArray(r.body.focuses) && r.body.focuses.length) FOCUS = r.body.focuses.map(function (f) { return [f.id, f.label]; }).concat([['other', 'Something else']]);
|
|
168
196
|
var id = selectId || new URLSearchParams(location.search).get('goal');
|
|
169
197
|
state.current = state.goals.filter(function (g) { return g.id === id; })[0] || null;
|
|
170
198
|
render();
|
|
@@ -246,41 +274,77 @@ ${consoleShellScript}
|
|
|
246
274
|
}
|
|
247
275
|
|
|
248
276
|
// A job: one piece of the goal, with its measure, and what does it.
|
|
277
|
+
// A job as one row: its title, kind and one line (why it helps, until
|
|
278
|
+
// it's kept; then its measure), its status, and the one action that
|
|
279
|
+
// matters now. Click it for the rest: why, what it needs, how it's done,
|
|
280
|
+
// and the other actions.
|
|
249
281
|
function jobHtml(w) {
|
|
250
282
|
var once = w.kind === 'once';
|
|
251
283
|
var doer = (w.doers || [])[0];
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
284
|
+
var t = lastTry(w);
|
|
285
|
+
var btn = function (act, label, cls) { return '<button type="button" class="gl-btn ' + (cls || '') + '" data-act="' + act + '">' + label + '</button>'; };
|
|
286
|
+
var primary = w.state === 'suggested' ? btn('save', 'Save', 'soft')
|
|
287
|
+
: w.state === 'saved' && once ? btn('assign', 'Assign')
|
|
288
|
+
: w.state === 'saved' ? btn('build', 'Build it')
|
|
289
|
+
: w.state === 'active' && once && t && t.status === 'done' ? btn('accept', 'Accept')
|
|
290
|
+
: w.state === 'active' && once && t && (t.status === 'error' || t.status === 'gone') ? btn('again', 'Try again')
|
|
291
|
+
: w.state === 'discarded' ? btn('restore', 'Restore', 'plain') : '';
|
|
292
|
+
var more = w.state === 'suggested' ? btn('discard', 'Discard', 'plain')
|
|
293
|
+
: w.state === 'saved' && once ? btn('build', 'Open in Chat', 'plain') + btn('done', 'Mark done', 'plain') + btn('discard', 'Discard', 'plain')
|
|
294
|
+
: w.state === 'saved' ? btn('discard', 'Discard', 'plain')
|
|
295
|
+
: w.state === 'active' && once ? (t && t.status === 'done' ? btn('again', 'Ask again', 'soft') : '') + btn('done', 'Mark done', 'plain') + btn('discard', 'Discard', 'plain')
|
|
296
|
+
: w.state === 'done' ? btn('undone', 'Reopen', 'plain') : '';
|
|
264
297
|
var pill = w.state === 'saved' ? '<span class="gl-state saved">Saved</span>'
|
|
265
|
-
: w.state === 'active' && once ? '<span class="gl-state saved">
|
|
298
|
+
: 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>')
|
|
266
299
|
: w.state === 'active' ? '<span class="gl-state built">Running</span>'
|
|
267
|
-
: w.state === 'done' ? '<span class="gl-state built">Done</span>'
|
|
268
|
-
|
|
300
|
+
: w.state === 'done' ? '<span class="gl-state built">Done</span>'
|
|
301
|
+
: w.state === 'discarded' ? '<span class="gl-state">Discarded</span>' : '';
|
|
302
|
+
var sub = w.state === 'suggested' || w.state === 'discarded' ? (w.why || w.measure || '') : (w.measure ? (once ? '' : 'Measured by ') + w.measure : w.why || '');
|
|
269
303
|
var doneBy = once && (w.state === 'active' || w.state === 'done') && w.tries && w.tries.length ? triesHtml(w)
|
|
270
304
|
: w.state === 'active' && doer && doer.type === 'workflow' ? howHtml(w)
|
|
271
305
|
: w.state === 'done' && w.doneAt ? '<div class="gl-doer">Done ' + esc(new Date(w.doneAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) + '</div>' : '';
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
'<div class="gl-job-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
306
|
+
var open = !!state.openJobs[w.id];
|
|
307
|
+
return '<div class="gl-wf gl-job' + (open ? ' is-open' : '') + (w.state === 'active' || w.state === 'done' ? ' built' : '') + '" data-wf="' + esc(w.id) + '">' +
|
|
308
|
+
'<div class="gl-job-head" role="button" tabindex="0" aria-expanded="' + open + '">' +
|
|
309
|
+
'<span class="gl-caret" aria-hidden="true"></span>' +
|
|
310
|
+
'<div class="gl-job-main"><span class="gl-wf-title">' + esc(w.title) + '</span>' +
|
|
311
|
+
'<span class="gl-job-sub"><span class="gl-kind">' + (once ? 'One-off' : 'Recurring') + '</span>' + (sub ? '<span class="gl-job-line">' + esc(sub) + '</span>' : '') + '</span></div>' +
|
|
312
|
+
'<span class="gl-job-status">' + pill + '<span class="gl-state planning" data-attn hidden>Needs you</span></span>' +
|
|
313
|
+
'<span class="gl-job-primary">' + primary + '</span>' +
|
|
314
|
+
'</div>' +
|
|
315
|
+
'<div class="gl-job-body"' + (open ? '' : ' hidden') + '>' +
|
|
316
|
+
(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' : '') + '</p>' : '') +
|
|
317
|
+
(w.why && sub !== w.why ? '<p class="gl-why">' + esc(w.why) + '</p>' : '') +
|
|
318
|
+
(w.measure && sub.indexOf(w.measure) < 0 ? '<p class="gl-job-measure">' + (once ? '' : 'Measured by ') + esc(w.measure) + '</p>' : '') +
|
|
319
|
+
(w.state === 'active' || w.state === 'done' ? '' : '<div class="gl-row">' + agentHtml(w) + '</div>' + needsHtml(w)) +
|
|
320
|
+
doneBy +
|
|
321
|
+
(w.state === 'active' && !once ? '' : '<details><summary>' + (once ? 'What the agent is asked to do' : 'What its workflow will do') + '</summary><p>' + esc(w.request) + '</p></details>') +
|
|
322
|
+
(more ? '<div class="gl-row">' + more + '</div>' : '') +
|
|
323
|
+
(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>' : '') +
|
|
324
|
+
'</div>' +
|
|
325
|
+
'<span class="hint gl-job-status-line" data-wf-status></span>' +
|
|
281
326
|
'</div>';
|
|
282
327
|
}
|
|
283
328
|
|
|
329
|
+
// A job of the person's own: typed in their words, shaped and judged by
|
|
330
|
+
// the planner (added, changed, warned or refused), with what it said.
|
|
331
|
+
function addJobHtml(planning) {
|
|
332
|
+
var n = state.addNotice;
|
|
333
|
+
var notice = !n ? '' : '<div class="gl-notice ' + (n.verdict === 'refused' ? 'bad' : n.verdict === 'added' ? 'good' : 'warn') + '">' +
|
|
334
|
+
'<strong>' + (n.verdict === 'refused' ? 'Not added' : n.verdict === 'changed' ? 'Added, with changes' : n.verdict === 'warned' ? 'Added, with a caution' : 'Added') + '</strong>' +
|
|
335
|
+
(n.note ? '<span>' + esc(n.note) + '</span>' : '') +
|
|
336
|
+
(n.alternative ? '<span class="hint">Instead, you could: ' + esc(n.alternative) + '</span>' : '') + '</div>';
|
|
337
|
+
return '<div class="gl-add">' +
|
|
338
|
+
'<button type="button" class="gl-link" id="glAddToggle"' + (state.addOpen ? ' hidden' : '') + '>+ Add your own job</button>' +
|
|
339
|
+
'<div class="gl-add-form"' + (state.addOpen ? '' : ' hidden') + '>' +
|
|
340
|
+
'<label for="glAddIdea"><strong>A job you have in mind</strong> <span class="hint">in your own words; LoopEngine shapes it into a job and says if anything looks off</span></label>' +
|
|
341
|
+
'<textarea id="glAddIdea" rows="2" placeholder="e.g. Thank every new customer by email within a day">' + esc(state.addDraft || '') + '</textarea>' +
|
|
342
|
+
'<label class="hint gl-share"><input type="checkbox" id="glAddPrivate"' + (state.addPrivate ? ' checked' : '') + '> Keep this one to my workspace</label>' +
|
|
343
|
+
'<p class="hint" style="margin:0">Unless you tick that, the approach behind this job (never your words) may be shared anonymously to improve suggestions, and only once many workspaces use something similar.</p>' +
|
|
344
|
+
'<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>' +
|
|
345
|
+
'</div>' + notice + '</div>';
|
|
346
|
+
}
|
|
347
|
+
|
|
284
348
|
// A one-off job's tries: the latest with its state and result, earlier
|
|
285
349
|
// ones folded away.
|
|
286
350
|
function tryHtml(t, n) {
|
|
@@ -391,7 +455,8 @@ ${consoleShellScript}
|
|
|
391
455
|
var secs = state.startedAt ? Math.round((Date.now() - state.startedAt) / 1000) : 0;
|
|
392
456
|
return '<div class="gl-card">' +
|
|
393
457
|
'<h2 class="gl-goal-title">' + esc(g.goal) + '</h2>' +
|
|
394
|
-
(focus ? '<div class="gl-focus"
|
|
458
|
+
(focus ? '<div class="gl-focus"><label for="glFocus">Focus</label> <select id="glFocus"' + (planning ? ' disabled' : '') + '>' + (FOCUS.some(function (f) { return f[0] === focus; }) ? FOCUS : FOCUS.concat([[focus, (g.brief && g.brief.newFocus && g.brief.newFocus.label) || focus]])).map(function (f) { return '<option value="' + esc(f[0]) + '"' + (f[0] === focus ? ' selected' : '') + '>' + esc(f[1]) + '</option>'; }).join('') + '</select>' +
|
|
459
|
+
(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>' : '') +
|
|
395
460
|
(g.brief && g.brief.measure ? '<span>' + String.fromCharCode(183) + ' measured by ' + esc(g.brief.measure) + '</span>' : '') + '</div>' : '') +
|
|
396
461
|
(g.message ? '<p class="gl-why">' + esc(g.message) + '</p>' : '') +
|
|
397
462
|
(planning ? '<p class="gl-status">Suggesting jobs' + ELLIPSIS + (secs ? ' ' + secs + 's' : '') + ' It reads your workspace first; this takes about a minute.</p>' : '') +
|
|
@@ -407,6 +472,7 @@ ${consoleShellScript}
|
|
|
407
472
|
'</div>' +
|
|
408
473
|
'<div class="gl-section"><h3>Your jobs <span class="gl-count">' + kept.length + '</span></h3>' +
|
|
409
474
|
(kept.length ? kept.map(jobHtml).join('') : '<p class="gl-empty">Save a suggestion to keep it here. Build a recurring job into a workflow on its agent; assign a one-off job to its agent.</p>') +
|
|
475
|
+
addJobHtml(planning) +
|
|
410
476
|
'</div>' +
|
|
411
477
|
(discarded.length ? '<div class="gl-section"><button type="button" class="gl-link" id="glShowDiscarded">' + (state.showDiscarded ? 'Hide' : 'Show') + ' discarded (' + discarded.length + ')</button>' +
|
|
412
478
|
(state.showDiscarded ? discarded.map(jobHtml).join('') : '') + '</div>' : '') +
|
|
@@ -475,6 +541,30 @@ ${consoleShellScript}
|
|
|
475
541
|
render();
|
|
476
542
|
});
|
|
477
543
|
});
|
|
544
|
+
var addToggle = document.getElementById('glAddToggle');
|
|
545
|
+
if (addToggle) addToggle.addEventListener('click', function () { state.addOpen = true; state.addNotice = null; render(); var box = document.getElementById('glAddIdea'); if (box) box.focus(); });
|
|
546
|
+
var addCancel = document.getElementById('glAddCancel');
|
|
547
|
+
if (addCancel) addCancel.addEventListener('click', function () { state.addOpen = false; state.addDraft = ''; render(); });
|
|
548
|
+
var addIdea = document.getElementById('glAddIdea');
|
|
549
|
+
if (addIdea) addIdea.addEventListener('input', function () { state.addDraft = addIdea.value; });
|
|
550
|
+
var addPrivate = document.getElementById('glAddPrivate');
|
|
551
|
+
if (addPrivate) addPrivate.addEventListener('change', function () { state.addPrivate = addPrivate.checked; });
|
|
552
|
+
var addJob = document.getElementById('glAddJob');
|
|
553
|
+
if (addJob) addJob.addEventListener('click', function () {
|
|
554
|
+
var idea = document.getElementById('glAddIdea').value.trim();
|
|
555
|
+
var status = document.getElementById('glAddStatus');
|
|
556
|
+
if (idea.length < 5) { status.textContent = 'Say what the job is first.'; return; }
|
|
557
|
+
addJob.disabled = true;
|
|
558
|
+
status.textContent = 'Shaping it into a job' + ELLIPSIS;
|
|
559
|
+
var keep = document.getElementById('glAddPrivate');
|
|
560
|
+
api('POST', base + '/jobs', { idea: idea, private: !!(keep && keep.checked) }).then(function (r) {
|
|
561
|
+
if (!r.ok) { addJob.disabled = false; status.textContent = r.body.error || 'Could not add it.'; return; }
|
|
562
|
+
state.addNotice = { verdict: r.body.verdict, note: r.body.note, alternative: r.body.alternative };
|
|
563
|
+
if (r.body.verdict !== 'refused') { state.addOpen = false; state.addDraft = ''; state.addPrivate = false; if (r.body.jobId) state.openJobs[r.body.jobId] = true; }
|
|
564
|
+
replaceGoal(r.body.goal);
|
|
565
|
+
render();
|
|
566
|
+
});
|
|
567
|
+
});
|
|
478
568
|
var shown = document.getElementById('glShowDiscarded');
|
|
479
569
|
if (shown) shown.addEventListener('click', function () { state.showDiscarded = !state.showDiscarded; render(); });
|
|
480
570
|
var del = document.getElementById('glDelete');
|
|
@@ -542,9 +632,27 @@ ${consoleShellScript}
|
|
|
542
632
|
box.innerHTML = params.map(function (p) { return '<div class="gl-row"><span class="hint"><code>' + esc(p) + '</code>' + (target.parameters[p].required ? '' : ' (optional)') + ' from</span><select class="gl-select" data-input="' + esc(p) + '">' + choices(p) + '</select></div>'; }).join('');
|
|
543
633
|
}
|
|
544
634
|
|
|
635
|
+
function setJobOpen(card, open) {
|
|
636
|
+
var id = card.getAttribute('data-wf');
|
|
637
|
+
state.openJobs[id] = open;
|
|
638
|
+
card.classList.toggle('is-open', open);
|
|
639
|
+
card.querySelector('.gl-job-head').setAttribute('aria-expanded', String(open));
|
|
640
|
+
card.querySelector('.gl-job-body').hidden = !open;
|
|
641
|
+
}
|
|
642
|
+
|
|
545
643
|
function wireCard(card, base) {
|
|
546
644
|
var id = card.getAttribute('data-wf');
|
|
547
645
|
var status = card.querySelector('[data-wf-status]');
|
|
646
|
+
var head = card.querySelector('.gl-job-head');
|
|
647
|
+
head.addEventListener('click', function (ev) {
|
|
648
|
+
if (ev.target.closest('button, a')) return;
|
|
649
|
+
setJobOpen(card, !card.classList.contains('is-open'));
|
|
650
|
+
});
|
|
651
|
+
head.addEventListener('keydown', function (ev) {
|
|
652
|
+
if (ev.target !== head || (ev.key !== 'Enter' && ev.key !== ' ')) return;
|
|
653
|
+
ev.preventDefault();
|
|
654
|
+
setJobOpen(card, !card.classList.contains('is-open'));
|
|
655
|
+
});
|
|
548
656
|
// A job's chain: change the step being written, remove a step or a workflow.
|
|
549
657
|
['[data-step-run]', '[data-step-after]', '[data-step-when]'].forEach(function (sel) {
|
|
550
658
|
var el = card.querySelector(sel);
|
|
@@ -615,6 +723,7 @@ ${consoleShellScript}
|
|
|
615
723
|
return;
|
|
616
724
|
}
|
|
617
725
|
if (act === 'again') {
|
|
726
|
+
setJobOpen(card, true);
|
|
618
727
|
var box = card.querySelector('.gl-again');
|
|
619
728
|
if (box) { box.hidden = false; box.querySelector('textarea').focus(); }
|
|
620
729
|
return;
|
|
@@ -12,7 +12,9 @@ export declare function leverEventsSyncConfig(env?: NodeJS.ProcessEnv): LeverEve
|
|
|
12
12
|
* a Cloud workspace. */
|
|
13
13
|
export declare function sharesLeverStats(projectDir: string, env?: NodeJS.ProcessEnv): boolean;
|
|
14
14
|
export declare function signLeverEvents(body: string, timestamp: number, secret: string): string;
|
|
15
|
-
/** An event as it leaves the workspace: only the anonymous fields.
|
|
15
|
+
/** An event as it leaves the workspace: only the anonymous fields. A
|
|
16
|
+
* workspace's own focus or lever (written by its planner, "x-...") goes
|
|
17
|
+
* as "other" and as its generic label, not its id. */
|
|
16
18
|
export declare function outgoingLeverEvent(e: Record<string, unknown>, businessKind: string | undefined): Record<string, unknown>;
|
|
17
19
|
export type LeverEventsSendResult = {
|
|
18
20
|
status: 'off';
|
|
@@ -57,14 +57,17 @@ export function sharesLeverStats(projectDir, env = process.env) {
|
|
|
57
57
|
export function signLeverEvents(body, timestamp, secret) {
|
|
58
58
|
return `t=${timestamp},v1=${createHmac('sha256', secret).update(`${timestamp}.${body}`).digest('hex')}`;
|
|
59
59
|
}
|
|
60
|
-
/** An event as it leaves the workspace: only the anonymous fields.
|
|
60
|
+
/** An event as it leaves the workspace: only the anonymous fields. A
|
|
61
|
+
* workspace's own focus or lever (written by its planner, "x-...") goes
|
|
62
|
+
* as "other" and as its generic label, not its id. */
|
|
61
63
|
export function outgoingLeverEvent(e, businessKind) {
|
|
64
|
+
const local = (v) => typeof v === 'string' && /(^|\.)x-/.test(v);
|
|
62
65
|
return {
|
|
63
66
|
id: e.id,
|
|
64
67
|
type: e.type,
|
|
65
|
-
...(typeof e.leverId === 'string' ? { leverId: e.leverId } : {}),
|
|
68
|
+
...(typeof e.leverId === 'string' && !local(e.leverId) ? { leverId: e.leverId } : {}),
|
|
66
69
|
lever: e.lever,
|
|
67
|
-
focus: e.focus,
|
|
70
|
+
focus: local(e.focus) ? 'other' : e.focus,
|
|
68
71
|
...(typeof e.playbookVersion === 'number' ? { playbookVersion: e.playbookVersion } : {}),
|
|
69
72
|
...(businessKind ? { businessKind } : {}),
|
|
70
73
|
// The job, as an opaque id (an event from before jobs: goalWorkflow).
|
|
@@ -104,9 +107,11 @@ export async function sendLeverEvents(projectDir, config, fetchImpl = fetch, env
|
|
|
104
107
|
}
|
|
105
108
|
if (!lines.length)
|
|
106
109
|
break;
|
|
110
|
+
// An event from a job the person kept to their workspace isn't sent.
|
|
107
111
|
const events = lines.flatMap((line) => {
|
|
108
112
|
try {
|
|
109
|
-
|
|
113
|
+
const e = JSON.parse(line);
|
|
114
|
+
return e.private === true ? [] : [outgoingLeverEvent(e, businessKind)];
|
|
110
115
|
}
|
|
111
116
|
catch {
|
|
112
117
|
return [];
|