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/home-page.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// The console's
|
|
2
|
-
// workflows
|
|
3
|
-
//
|
|
1
|
+
// The console's home page (/home): each goal, and the workflows and
|
|
2
|
+
// groups of workflows built for it, one tinted level under the other;
|
|
3
|
+
// then workflows no goal points to. Its data is
|
|
4
4
|
// homeOverview (web/workflows-overview.ts) behind /home/overview. Every
|
|
5
5
|
// workflow on its own, as a table, stays at /workflows.
|
|
6
6
|
// Like the other console pages, its inline script avoids backslashes and
|
|
@@ -72,7 +72,7 @@ ${consoleSidebarHtml}
|
|
|
72
72
|
<div class="le-head plain">
|
|
73
73
|
<div class="le-head-row">
|
|
74
74
|
<div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">☰</button>
|
|
75
|
-
<div><h1>Home</h1><p>
|
|
75
|
+
<div><h1>Home</h1><p>Your goals, big or small, and the workflows and groups of workflows that take care of them.</p></div>
|
|
76
76
|
</div>
|
|
77
77
|
<a class="hm-new" href="/goals?new=1">New goal</a>
|
|
78
78
|
</div>
|
|
@@ -92,9 +92,10 @@ ${consoleShellScript}
|
|
|
92
92
|
}
|
|
93
93
|
function agentTag(name) { return '<span class="hm-tag hm-t-agent">' + esc(name) + '</span>'; }
|
|
94
94
|
|
|
95
|
-
//
|
|
96
|
-
//
|
|
95
|
+
// A workflow or group's workflows, a chained one marked "then", and a
|
|
96
|
+
// group's steps not built yet.
|
|
97
97
|
function howHtml(j) {
|
|
98
|
+
var unbuilt = j.group ? j.group.steps.filter(function (st) { return !st.built; }) : [];
|
|
98
99
|
if (j.flows.length) {
|
|
99
100
|
return '<div class="hm-node hm-how">' + j.flows.map(function (f) {
|
|
100
101
|
return '<div class="hm-row">' +
|
|
@@ -103,29 +104,25 @@ ${consoleShellScript}
|
|
|
103
104
|
(f.gone ? '<span class="hm-m">no longer on this agent</span>' : f.starts.length ? '<span class="hm-m">' + esc(f.starts.join(DOT)) + '</span>' : '') +
|
|
104
105
|
(f.waiting ? '<a class="hm-tag hm-t-warn" href="/inbox">' + f.waiting + ' waiting</a>' : '') +
|
|
105
106
|
'</div>';
|
|
106
|
-
}).join('') + '</div>';
|
|
107
|
+
}).join('') + unbuilt.map(function (st) { return '<div class="hm-row"><span class="hm-m">then ' + String.fromCharCode(8594) + ' ' + esc(st.name) + ', not built yet</span></div>'; }).join('') + '</div>';
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
return '<div class="hm-node hm-how"><div class="hm-row"><span class="hm-tag hm-t-how">Assignment</span>' + agentTag(j.agent) + '<span class="hm-m">one run, its result kept with the job</span></div></div>';
|
|
110
|
-
}
|
|
111
|
-
return '<div class="hm-node hm-how"><div class="hm-row"><span class="hm-m">' + (j.kind === 'once' ? 'Not assigned yet' : 'No workflow yet') + DOT + '<a href="/jobs?job=' + encodeURIComponent(j.id) + '">' + (j.kind === 'once' ? 'Give it to an agent' : 'Build a workflow') + '</a></span></div></div>';
|
|
109
|
+
return '';
|
|
112
110
|
}
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'<
|
|
119
|
-
'<span class="hm-m">
|
|
120
|
-
|
|
121
|
-
'</div>' + (j.state === 'done' ? '' : howHtml(j));
|
|
112
|
+
// A goal's workflow, or group of workflows that run in order.
|
|
113
|
+
function itemHtml(j, goalId) {
|
|
114
|
+
return '<div class="hm-node hm-job"><div class="hm-row"><span class="hm-tag hm-t-job">' + (j.group ? 'Group' : 'Workflow') + '</span>' +
|
|
115
|
+
'<strong><a href="/goals?goal=' + encodeURIComponent(goalId) + '">' + esc(j.title) + '</a></strong>' +
|
|
116
|
+
(j.group ? '<span class="hm-m">' + j.group.steps.length + ' workflows in order</span>' : '') + '</div>' +
|
|
117
|
+
(j.measure ? '<span class="hm-m">measured by: ' + esc(j.measure) + '</span>' : '') +
|
|
118
|
+
'</div>' + howHtml(j);
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
function goalHtml(g) {
|
|
125
122
|
return '<div class="hm-tree">' +
|
|
126
123
|
'<div class="hm-node hm-goal"><div class="hm-row"><span class="hm-tag hm-t-goal">Goal</span><strong><a href="/goals?goal=' + encodeURIComponent(g.id) + '">' + esc(g.goal) + '</a></strong></div>' +
|
|
127
124
|
(g.measure ? '<span class="hm-m">measured by: ' + esc(g.measure) + '</span>' : '') + '</div>' +
|
|
128
|
-
(g.jobs.length ? g.jobs.map(
|
|
125
|
+
(g.jobs.length ? g.jobs.map(function (j) { return itemHtml(j, g.id); }).join('') : '<div class="hm-node hm-job"><span class="hm-m">Nothing built yet' + DOT + '<a href="/goals?goal=' + encodeURIComponent(g.id) + '">See its suggestions</a></span></div>') +
|
|
129
126
|
'</div>';
|
|
130
127
|
}
|
|
131
128
|
|
|
@@ -139,16 +136,15 @@ ${consoleShellScript}
|
|
|
139
136
|
function renderEmpty() {
|
|
140
137
|
page.innerHTML =
|
|
141
138
|
'<div class="hm-empty"><h2>Nothing set up yet</h2>' +
|
|
142
|
-
'<p class="hint" style="margin:0">
|
|
139
|
+
'<p class="hint" style="margin:0">Give LoopEngine a goal, big or small, and it suggests the workflows for it, and groups of workflows that run in order. Or go straight to a workflow: how an agent does something again and again.</p>' +
|
|
143
140
|
'<div class="hm-ways">' +
|
|
144
|
-
'<a class="hm-way" href="/goals?new=1"><b>Start from a goal</b><span>
|
|
145
|
-
'<a class="hm-way" href="/jobs?new=1"><b>Add a job</b><span>Something that needs doing, in your own words.</span></a>' +
|
|
141
|
+
'<a class="hm-way" href="/goals?new=1"><b>Start from a goal</b><span>Work to hand off or a result to reach: get workflows suggested for it.</span></a>' +
|
|
146
142
|
'<a class="hm-way" href="/workflows/new"><b>Build a workflow</b><span>Say what the agent should do, or start from an example.</span></a>' +
|
|
147
143
|
'</div></div>';
|
|
148
144
|
}
|
|
149
145
|
|
|
150
146
|
function render(d) {
|
|
151
|
-
if (!d.goals.length && !d.
|
|
147
|
+
if (!d.goals.length && !d.workflows.length) return renderEmpty();
|
|
152
148
|
var s = d.summary;
|
|
153
149
|
var html =
|
|
154
150
|
'<div class="hm-stats">' +
|
|
@@ -157,8 +153,7 @@ ${consoleShellScript}
|
|
|
157
153
|
'<a class="hm-stat" href="/workflows"><b>' + s.failedThisWeek + '</b><span>Failed in the last 7 days</span></a>' +
|
|
158
154
|
'</div>';
|
|
159
155
|
if (d.goals.length) html += '<div class="hm-section"><h2>Goals</h2>' + d.goals.map(goalHtml).join('') + '</div>';
|
|
160
|
-
if (d.
|
|
161
|
-
if (d.loose.length) html += '<div class="hm-section"><h2>' + (d.goals.length || d.jobs.length ? 'Workflows not in a job' : 'Workflows') + '</h2><div class="hm-tree loose">' + d.loose.map(looseHtml).join('') + '</div></div>';
|
|
156
|
+
if (d.loose.length) html += '<div class="hm-section"><h2>' + (d.goals.length ? 'Workflows not for a goal' : 'Workflows') + '</h2><div class="hm-tree loose">' + d.loose.map(looseHtml).join('') + '</div></div>';
|
|
162
157
|
page.innerHTML = html;
|
|
163
158
|
}
|
|
164
159
|
|
|
@@ -59,8 +59,19 @@ async function latestVersions(projectDir) {
|
|
|
59
59
|
latestCache = { value, template, until: Date.now() + 60_000, at: new Date().toISOString() };
|
|
60
60
|
return latestCache;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
/** The newest version of a package that the project's package.json
|
|
63
|
+
* allows (npm lists the matching ones, oldest first). */
|
|
64
|
+
async function newestWithinRange(name, projectDir) {
|
|
65
|
+
try {
|
|
66
|
+
const range = JSON.parse(readFileSync(join(projectDir, 'package.json'), 'utf8')).dependencies?.[name];
|
|
67
|
+
if (!range)
|
|
68
|
+
return null;
|
|
69
|
+
const parsed = JSON.parse((await run('npm', ['view', `${name}@${range}`, 'version', '--json'], projectDir, 15_000)).trim() || 'null');
|
|
70
|
+
return (Array.isArray(parsed) ? parsed[parsed.length - 1] : parsed) ?? null;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
76
|
function templateVersion(projectDir) {
|
|
66
77
|
const path = join(projectDir, '.create-loopengine.json');
|
|
@@ -159,9 +170,12 @@ export async function runUpgrade(options) {
|
|
|
159
170
|
throw new UpgradeError(result.error);
|
|
160
171
|
if (result.npmInstall && !result.npmInstall.ok)
|
|
161
172
|
throw new UpgradeError(`Installing the new packages failed: ${result.npmInstall.error ?? 'unknown error'}`);
|
|
162
|
-
// package.json may already allow
|
|
163
|
-
//
|
|
164
|
-
|
|
173
|
+
// package.json may already allow a newer version while an older one
|
|
174
|
+
// stays installed (the lockfile keeps it); install it outright. Only
|
|
175
|
+
// within package.json's range (the template's, after the step above):
|
|
176
|
+
// a loopengine newer than the template was made for may drop a name
|
|
177
|
+
// its adapters/http.ts imports, and the server wouldn't start.
|
|
178
|
+
const latest = await newestWithinRange('loopengine', projectDir);
|
|
165
179
|
const current = loopengineVersion();
|
|
166
180
|
if (latest && semver.valid(current) && semver.gt(latest, current) && !result.dependencies.some((d) => d.name === 'loopengine')) {
|
|
167
181
|
try {
|
|
@@ -12,12 +12,12 @@ import { writeSkill } from './skills-admin.js';
|
|
|
12
12
|
import { setAgentEnvVar } from './env-admin.js';
|
|
13
13
|
import { installFailureReason, templateChecklist } from './templates-admin.js';
|
|
14
14
|
import { templateScheduleStart } from '../core/system-agents/templates.js';
|
|
15
|
-
import { planParameters, planWebhook, planWorkflowWithModel, workflowTemplate } from '../core/system-agents/workflow-planner.js';
|
|
15
|
+
import { planCriteria, planParameters, planWebhook, planWorkflowWithModel, workflowTemplate } from '../core/system-agents/workflow-planner.js';
|
|
16
16
|
import { checkRunDelivery, createTrigger, getTriggerStore, listTriggers, publicTrigger } from '../core/workflow-triggers.js';
|
|
17
17
|
import { mcpAbilityNames } from '../core/mcp-ability-generator.js';
|
|
18
18
|
import { contextToolsFor } from '../core/mcp-apps.js';
|
|
19
19
|
import { clearWorkflowFields, migrateWorkflowsFile, readWorkflow, readWorkflows, setWorkflowDelivery, setWorkflowFields, validateParams, workflowRunMessage } from '../core/workflows.js';
|
|
20
|
-
import { readEvals, workflowScores } from './workflow-evidence.js';
|
|
20
|
+
import { readEvals, setEvalCriteria, workflowScores } from './workflow-evidence.js';
|
|
21
21
|
import { isUnderWay, listRuns } from '../core/workflow-runs.js';
|
|
22
22
|
import { cancelScheduledTask, createScheduledTask, deleteScheduledTask, describeSchedule, getSchedulerStore, listScheduledTasks, pauseScheduledTask } from '../core/scheduler.js';
|
|
23
23
|
import { wallTimeAt, workspaceTimeZone } from '../core/time-zone.js';
|
|
@@ -659,6 +659,17 @@ export async function createWorkflow(input, deps) {
|
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
661
|
markWorkflow(deps.agentDir(agent.name), typeof input.workflowContext === 'string' ? input.workflowContext.slice(0, 6000) : '');
|
|
662
|
+
// Its success criteria, as planned or as edited on the plan: what every
|
|
663
|
+
// eval case is checked against from the start.
|
|
664
|
+
const criteria = planCriteria(plan.successCriteria, [...plan.steps.flatMap((st) => (st.tool ? [st.tool] : [])), ...(plan.rules ?? []).map((r) => r.tool)]);
|
|
665
|
+
if (criteria.length) {
|
|
666
|
+
try {
|
|
667
|
+
setEvalCriteria(deps.agentDir(agent.name), plan.id, criteria);
|
|
668
|
+
}
|
|
669
|
+
catch (err) {
|
|
670
|
+
console.error(`[loopengine] could not save ${plan.id}'s success criteria:`, err instanceof Error ? err.message : err);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
662
673
|
const hook = await makePlannedWebhook(plan, agent.name, deps.agentDir(agent.name));
|
|
663
674
|
return {
|
|
664
675
|
agent: agent.name,
|
|
@@ -156,7 +156,7 @@ export declare function checkCase(judge: ModelCall, input: {
|
|
|
156
156
|
}): Promise<EvalCheck[]>;
|
|
157
157
|
/** A round's pass rate per criterion, and the cases that passed all. */
|
|
158
158
|
export declare function roundSummary(criteria: EvalCriterion[], cases: EvalCaseResult[]): Pick<EvalRound, 'passRates' | 'allPassed'>;
|
|
159
|
-
export declare const DRAFT_CRITERIA_PROMPT = "You write the checks a workflow's results are tested against, from its brief: what the agent is told to do, its rules and policies.\n\nWrite three to six yes or no checks, the ones that matter most: a result failing one is a result a person would have to fix. Each
|
|
159
|
+
export declare const DRAFT_CRITERIA_PROMPT = "You write the checks a workflow's results are tested against, from its brief: what the agent is told to do, its rules and policies.\n\nWrite three to six yes or no checks, the ones that matter most: a result failing one is a result a person would have to fix. Each checks one thing, in a short statement under 20 words that is true of a good result (\"The reply gives the order's tracking number\", \"It doesn't promise a refund\"); split a rule with several parts into separate checks, keeping the ones that matter most. Take them from the brief's rules and its job; never invent requirements it doesn't state.\n\nEach check has a kind:\n- \"judge\": a statement a reviewer decides by reading the result (most checks).\n- \"contains\" / \"not_contains\" with \"value\": an exact phrase that must or mustn't appear, only when the brief names the exact words (a sign-off, a banned phrase).\n- \"tool_called\" / \"tool_not_called\" with \"value\": a tool the run must or mustn't call, only when the brief says so and the tool's exact name is in the list given.\n\nReply with JSON only: {\"criteria\": [{\"text\": \"...\", \"kind\": \"judge\"}, {\"text\": \"...\", \"kind\": \"tool_called\", \"value\": \"<tool name>\"}]}";
|
|
160
160
|
/** Criteria drafted from a workflow's brief, for a person to edit before
|
|
161
161
|
* saving. */
|
|
162
162
|
export declare function draftCriteria(model: ModelCall, input: {
|
|
@@ -253,7 +253,7 @@ export function roundSummary(criteria, cases) {
|
|
|
253
253
|
}
|
|
254
254
|
export const DRAFT_CRITERIA_PROMPT = `You write the checks a workflow's results are tested against, from its brief: what the agent is told to do, its rules and policies.
|
|
255
255
|
|
|
256
|
-
Write three to six yes or no checks, the ones that matter most: a result failing one is a result a person would have to fix. Each
|
|
256
|
+
Write three to six yes or no checks, the ones that matter most: a result failing one is a result a person would have to fix. Each checks one thing, in a short statement under 20 words that is true of a good result ("The reply gives the order's tracking number", "It doesn't promise a refund"); split a rule with several parts into separate checks, keeping the ones that matter most. Take them from the brief's rules and its job; never invent requirements it doesn't state.
|
|
257
257
|
|
|
258
258
|
Each check has a kind:
|
|
259
259
|
- "judge": a statement a reviewer decides by reading the result (most checks).
|
|
@@ -55,6 +55,13 @@ export const workflowPageHtml = `<!doctype html>
|
|
|
55
55
|
.wf-cb-decision.deny { background: var(--bad-soft); color: var(--bad); }
|
|
56
56
|
@media (max-width: 520px) { .wf-cb { grid-template-columns: minmax(0, 1fr); gap: 2px; } .wf-cb-v { margin-bottom: 8px; } }
|
|
57
57
|
.wf-part { display: grid; gap: 2px; margin-top: 8px; }
|
|
58
|
+
.wf-crit-rows { display: grid; gap: 8px; }
|
|
59
|
+
.wf-crit-row { display: grid; grid-template-columns: minmax(0, 1fr) 210px auto; gap: 8px; align-items: center; }
|
|
60
|
+
.wf-crit-row:has(.wf-crit-value:not([hidden])) { grid-template-columns: minmax(0, 1fr) 210px 160px auto; }
|
|
61
|
+
.wf-crit-row input, .wf-crit-row select { font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); min-width: 0; }
|
|
62
|
+
.wf-crit-row input[hidden] { display: none; }
|
|
63
|
+
.wf-crit-remove { border: 0; background: none; font-size: 18px; line-height: 1; color: var(--ink-muted); cursor: pointer; padding: 4px 8px; }
|
|
64
|
+
@media (max-width: 640px) { .wf-crit-row, .wf-crit-row:has(.wf-crit-value:not([hidden])) { grid-template-columns: 1fr auto; } .wf-crit-row select, .wf-crit-row .wf-crit-value { grid-column: 1; } }
|
|
58
65
|
.wf-part h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
|
|
59
66
|
.wf-mono { font-family: var(--font-mono); font-size: 12.5px; }
|
|
60
67
|
.wf-model-row { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
@@ -124,7 +131,8 @@ ${consoleShellScript}
|
|
|
124
131
|
// Opened from a goal's saved workflow (/goals): build it straight away,
|
|
125
132
|
// and link the created workflow back to the goal.
|
|
126
133
|
// Built for a goal's job (goalJob; goalWorkflow from before jobs).
|
|
127
|
-
|
|
134
|
+
// Built for a goal: its workflow (or a group's step, ?goalStep=), linked back on Create.
|
|
135
|
+
var fromGoal = { goal: new URLSearchParams(location.search).get('goal') || '', workflow: new URLSearchParams(location.search).get('goalJob') || new URLSearchParams(location.search).get('goalWorkflow') || '', step: new URLSearchParams(location.search).get('goalStep') || '' };
|
|
128
136
|
|
|
129
137
|
function esc(s) {
|
|
130
138
|
return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
|
|
@@ -447,13 +455,60 @@ ${consoleShellScript}
|
|
|
447
455
|
var PROVIDERS = ['openai', 'anthropic', 'gemini', 'deepseek', 'kimi', 'glm', 'xai', 'meta'];
|
|
448
456
|
function contractExtrasHtml(p) {
|
|
449
457
|
var m = p.model || {};
|
|
450
|
-
return '<h3>
|
|
451
|
-
'<p class="hint" style="margin:0">What its final reply must be, when an app or a person reads it. Empty: a reply in its own words.</p>' +
|
|
452
|
-
'<textarea id="wfOutput" rows="2" placeholder="The draft only, then a line Flag: reason if a person must act.">' + esc(p.output || '') + '</textarea>' +
|
|
453
|
-
'<h3>Model</h3>' +
|
|
458
|
+
return '<h3>Model</h3>' +
|
|
454
459
|
'<div class="wf-model-row"><select id="wfModelProvider" aria-label="Provider"><option value="">The agent' + String.fromCharCode(8217) + 's model</option>' + PROVIDERS.map(function (x) { return '<option value="' + x + '"' + (m.provider === x ? ' selected' : '') + '>' + x + '</option>'; }).join('') + '</select>' +
|
|
455
460
|
'<input id="wfModelName" aria-label="Model name" placeholder="e.g. gpt-6.1-sol" value="' + esc(m.model || '') + '"></div>';
|
|
456
461
|
}
|
|
462
|
+
// ---- Success criteria: yes or no checks a good result of this
|
|
463
|
+
// workflow meets, drafted with the plan (or from its brief, for an
|
|
464
|
+
// example that came without them), edited here, saved on Create. ----
|
|
465
|
+
var CRIT_KINDS = [['judge', 'Judged by reading'], ['contains', 'Must say'], ['not_contains', 'Must not say'], ['tool_called', 'Must use the tool'], ['tool_not_called', 'Must not use the tool']];
|
|
466
|
+
function critRow(c) {
|
|
467
|
+
c = c || { text: '', kind: 'judge' };
|
|
468
|
+
var needsValue = c.kind !== 'judge';
|
|
469
|
+
return '<div class="wf-crit-row">' +
|
|
470
|
+
'<input class="wf-crit-text" value="' + esc(c.text) + '" placeholder="e.g. The reply gives the order' + String.fromCharCode(8217) + 's tracking number" aria-label="Criterion">' +
|
|
471
|
+
'<select class="wf-crit-kind" aria-label="How it' + String.fromCharCode(8217) + 's checked">' + CRIT_KINDS.map(function (k) { return '<option value="' + k[0] + '"' + (k[0] === c.kind ? ' selected' : '') + '>' + k[1] + '</option>'; }).join('') + '</select>' +
|
|
472
|
+
'<input class="wf-crit-value" value="' + esc(c.value || '') + '" placeholder="' + (String(c.kind).indexOf('tool') === 0 ? 'tool name' : 'exact text') + '"' + (needsValue ? '' : ' hidden') + ' aria-label="What to look for">' +
|
|
473
|
+
'<button type="button" class="wf-crit-remove" aria-label="Remove">' + String.fromCharCode(215) + '</button></div>';
|
|
474
|
+
}
|
|
475
|
+
function criteriaHtml(p) {
|
|
476
|
+
var list = p.successCriteria || [];
|
|
477
|
+
return '<div class="wf-part"><h3>Success criteria</h3><span class="hint">What every good result of this workflow must get right. Once it runs, each eval case is checked against these, yes or no.</span></div>' +
|
|
478
|
+
'<div class="wf-card" id="wfCriteria">' +
|
|
479
|
+
(state.planned.drafting ? '<p class="hint" style="margin:0">Suggesting criteria from its instructions' + ELLIPSIS + '</p>' : '') +
|
|
480
|
+
'<div class="wf-crit-rows">' + list.map(critRow).join('') + '</div>' +
|
|
481
|
+
(state.planned.draftError ? '<p class="hint" style="margin:0">' + esc(state.planned.draftError) + '</p>' : '') +
|
|
482
|
+
'<div class="wf-actions"><button type="button" class="wf-btn plain" id="wfCritAdd">+ Add a criterion</button>' +
|
|
483
|
+
'<button type="button" class="wf-btn plain" id="wfCritDraft"' + (state.planned.drafting ? ' disabled' : '') + '>' + (list.length ? 'Suggest again from the instructions' : 'Suggest from the instructions') + '</button></div>' +
|
|
484
|
+
'</div>';
|
|
485
|
+
}
|
|
486
|
+
function readCriteria() {
|
|
487
|
+
var rows = document.querySelectorAll('#wfCriteria .wf-crit-row');
|
|
488
|
+
var out = [];
|
|
489
|
+
for (var i = 0; i < rows.length; i++) {
|
|
490
|
+
var text = rows[i].querySelector('.wf-crit-text').value.trim();
|
|
491
|
+
var kind = rows[i].querySelector('.wf-crit-kind').value;
|
|
492
|
+
var value = rows[i].querySelector('.wf-crit-value').value.trim();
|
|
493
|
+
if (!text) continue;
|
|
494
|
+
out.push(kind === 'judge' || !value ? { text: text, kind: kind === 'judge' || value ? kind : 'judge' } : { text: text, kind: kind, value: value });
|
|
495
|
+
}
|
|
496
|
+
return out;
|
|
497
|
+
}
|
|
498
|
+
// Drafts criteria from the plan's instructions, when it has none.
|
|
499
|
+
function draftCriteria(p, agent) {
|
|
500
|
+
state.planned.drafting = true;
|
|
501
|
+
state.planned.draftError = '';
|
|
502
|
+
readPlanEdits(p);
|
|
503
|
+
renderPlan();
|
|
504
|
+
post('/workflows/criteria', { plan: p, agent: agent }).then(function (r) {
|
|
505
|
+
state.planned.drafting = false;
|
|
506
|
+
if (r.ok) p.successCriteria = r.body.criteria || [];
|
|
507
|
+
else state.planned.draftError = (r.body && r.body.error) || 'Could not suggest criteria: add them by hand.';
|
|
508
|
+
renderPlan();
|
|
509
|
+
}).catch(function (err) { state.planned.drafting = false; state.planned.draftError = err.message; renderPlan(); });
|
|
510
|
+
}
|
|
511
|
+
|
|
457
512
|
// The plan's contract as one block, the way the workflow's Contract tab
|
|
458
513
|
// shows it once created: trigger, inputs, tools, result, model.
|
|
459
514
|
function planContractBlockHtml(p) {
|
|
@@ -491,8 +546,7 @@ ${consoleShellScript}
|
|
|
491
546
|
function readPlanEdits(p) {
|
|
492
547
|
p.context = contextValue();
|
|
493
548
|
p.skill.body = document.getElementById('wfSkill').value;
|
|
494
|
-
|
|
495
|
-
if (o) p.output = o.value;
|
|
549
|
+
if (document.getElementById('wfCriteria')) p.successCriteria = readCriteria();
|
|
496
550
|
var prov = document.getElementById('wfModelProvider');
|
|
497
551
|
var name = document.getElementById('wfModelName');
|
|
498
552
|
if (prov && name) p.model = prov.value && name.value.trim() ? { provider: prov.value, model: name.value.trim() } : null;
|
|
@@ -518,8 +572,14 @@ ${consoleShellScript}
|
|
|
518
572
|
: '') +
|
|
519
573
|
'<div class="wf-card">' +
|
|
520
574
|
'<h2>' + esc(p.name) + '</h2><p style="margin:0">' + esc(p.summary) + '</p>' +
|
|
521
|
-
'<p class="hint" style="margin:0">
|
|
575
|
+
'<p class="hint" style="margin:0">Check its <strong>brief</strong>, what the agent reads on every run; its <strong>success criteria</strong>, what a good result must get right; and its <strong>contract</strong>, how it starts and what it may use. You can change any of them later.</p>' +
|
|
522
576
|
'</div>' +
|
|
577
|
+
'<div class="wf-part"><h3>Brief</h3><span class="hint">What the agent reads on every run: what to do, its rules, and what it needs to know about your business.</span></div>' +
|
|
578
|
+
'<div class="wf-card"><label for="wfSkill"><strong>Instructions</strong> <span class="hint">(what the agent gets done, the rules it keeps, and what it needs to know about your business. Add your policies and special cases with the buttons below: the agent only knows what' + String.fromCharCode(8217) + 's written here. Saved as its skill <code>' + esc(p.id) + '</code>; edit them here, or later from the workflow' + String.fromCharCode(8217) + 's Edit.)</span></label>' +
|
|
579
|
+
'<textarea id="wfSkill" class="wf-skill-edit">' + esc(p.skill.body) + '</textarea>' +
|
|
580
|
+
'<div class="wp-sections"><span class="hint">Add a section:</span>' + workflowSectionButtonsHtml() + '</div>' +
|
|
581
|
+
'<p class="hint" style="margin:0">Each run lists its inputs above these instructions, long ones like an email or a thread in their own blocks, so the instructions refer to them by name.</p></div>' +
|
|
582
|
+
criteriaHtml(p) +
|
|
523
583
|
'<div class="wf-part"><h3>Contract</h3><span class="hint">What the system holds it to: how it starts, what it' + String.fromCharCode(8217) + 's given, what it may use, its model and its result.</span></div>' +
|
|
524
584
|
'<div class="wf-card">' +
|
|
525
585
|
planContractBlockHtml(p) +
|
|
@@ -547,22 +607,31 @@ ${consoleShellScript}
|
|
|
547
607
|
(misfit && !fitPending ? '<p class="hint" style="margin:0">You chose to add it here, though it' + String.fromCharCode(8217) + 's not this agent' + String.fromCharCode(8217) + 's usual work.</p>' : '') +
|
|
548
608
|
'</div>' +
|
|
549
609
|
needsHtml(reqs) +
|
|
550
|
-
'<div class="wf-part"><h3>Brief</h3><span class="hint">What the agent reads on every run: what to do, its rules, and what it needs to know about your business.</span></div>' +
|
|
551
|
-
'<div class="wf-card"><label for="wfSkill"><strong>Instructions</strong> <span class="hint">(what the agent gets done, the rules it keeps, and what it needs to know about your business. Add your policies and special cases with the buttons below: the agent only knows what' + String.fromCharCode(8217) + 's written here. Saved as its skill <code>' + esc(p.id) + '</code>; edit them here, or later from the workflow' + String.fromCharCode(8217) + 's Edit.)</span></label>' +
|
|
552
|
-
'<textarea id="wfSkill" class="wf-skill-edit">' + esc(p.skill.body) + '</textarea>' +
|
|
553
|
-
'<div class="wp-sections"><span class="hint">Add a section:</span>' + workflowSectionButtonsHtml() + '</div>' +
|
|
554
|
-
'<p class="hint" style="margin:0">Each run lists its inputs above these instructions, long ones like an email or a thread in their own blocks, so the instructions refer to them by name.</p></div>' +
|
|
555
610
|
(p.gaps.length ? '<div class="wf-gaps"><strong>Worth knowing</strong><ul>' + p.gaps.map(function (g) { return '<li>' + esc(g) + '</li>'; }).join('') + '</ul></div>' : '') +
|
|
556
611
|
(p.notes && p.notes.length ? '<div class="wf-card"><strong>After it' + String.fromCharCode(8217) + 's created, you also</strong><ul class="wf-list">' + p.notes.map(function (n) { return '<li>' + esc(n) + '</li>'; }).join('') + '</ul></div>' : '') +
|
|
557
|
-
'<div class="wf-part"><h3>Evidence</h3><span class="hint">Builds up once it runs.</span></div>' +
|
|
558
|
-
'<div class="wf-card"><ul class="wf-list">' +
|
|
559
|
-
'<li><strong>History:</strong> every run, its result, and the approvals you gave or refused.</li>' +
|
|
560
|
-
'<li><strong>Eval cases:</strong> save a good run as a case, then run the cases after each change to the instructions or model; a different model scores each result.</li>' +
|
|
561
|
-
'<li><strong>Feedback:</strong> an app can report the text it actually used, so you see how much results get edited.</li>' +
|
|
562
|
-
'</ul><p class="hint" style="margin:0">All on the workflow' + String.fromCharCode(8217) + 's Evidence tab, once it' + String.fromCharCode(8217) + 's created.</p></div>' +
|
|
563
612
|
'<div class="wf-actions"><button type="button" class="wf-btn" id="wfCreate"' + (blocked ? ' disabled' : '') + '>Create it</button><button type="button" class="wf-btn plain" id="wfBack">' + (state.planned.example ? 'Back to the examples' : 'Change the description') + '</button>' +
|
|
564
613
|
'<span class="hint" id="wfStatus">' + (fitPending ? 'Choose where it goes, above, first.' : '') + '</span></div>' +
|
|
565
614
|
(error ? '<p class="error">' + esc(error) + '</p>' : '');
|
|
615
|
+
var critBox = document.getElementById('wfCriteria');
|
|
616
|
+
critBox.addEventListener('click', function (ev) {
|
|
617
|
+
if (ev.target.classList.contains('wf-crit-remove')) ev.target.closest('.wf-crit-row').remove();
|
|
618
|
+
});
|
|
619
|
+
critBox.addEventListener('change', function (ev) {
|
|
620
|
+
if (!ev.target.classList.contains('wf-crit-kind')) return;
|
|
621
|
+
var value = ev.target.closest('.wf-crit-row').querySelector('.wf-crit-value');
|
|
622
|
+
value.hidden = ev.target.value === 'judge';
|
|
623
|
+
value.placeholder = ev.target.value.indexOf('tool') === 0 ? 'tool name' : 'exact text';
|
|
624
|
+
});
|
|
625
|
+
document.getElementById('wfCritAdd').addEventListener('click', function () {
|
|
626
|
+
critBox.querySelector('.wf-crit-rows').insertAdjacentHTML('beforeend', critRow(null));
|
|
627
|
+
critBox.querySelector('.wf-crit-rows').lastElementChild.querySelector('.wf-crit-text').focus();
|
|
628
|
+
});
|
|
629
|
+
document.getElementById('wfCritDraft').addEventListener('click', function () { draftCriteria(p, agent); });
|
|
630
|
+
if (!(p.successCriteria || []).length && !state.planned.drafting && !state.planned.drafted) {
|
|
631
|
+
state.planned.drafted = true;
|
|
632
|
+
draftCriteria(p, agent);
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
566
635
|
document.querySelector('.wp-sections').addEventListener('click', function (ev) {
|
|
567
636
|
addWorkflowSection(document.getElementById('wfSkill'), ev.target.dataset && ev.target.dataset.section);
|
|
568
637
|
});
|
|
@@ -631,7 +700,7 @@ ${consoleShellScript}
|
|
|
631
700
|
post('/workflows/create', body).then(function (r) {
|
|
632
701
|
if (!r.ok) { renderPlan(r.body.error || 'Could not create it.'); return; }
|
|
633
702
|
if (!fromGoal.goal || !fromGoal.workflow) { renderDone(r.body); return; }
|
|
634
|
-
post('/goals/' + encodeURIComponent(fromGoal.goal) + '/jobs/' + encodeURIComponent(fromGoal.workflow) + '/built', { agent: r.body.agent, workflowId: r.body.workflowId, title: r.body.workflow, description: state.description })
|
|
703
|
+
post('/goals/' + encodeURIComponent(fromGoal.goal) + '/jobs/' + encodeURIComponent(fromGoal.workflow) + '/built', { agent: r.body.agent, workflowId: r.body.workflowId, title: r.body.workflow, description: state.description, step: fromGoal.step || undefined })
|
|
635
704
|
.then(function () { renderDone(r.body); }, function () { renderDone(r.body); });
|
|
636
705
|
}).catch(function (err) { renderPlan(err.message); });
|
|
637
706
|
});
|
|
@@ -671,8 +740,7 @@ ${consoleShellScript}
|
|
|
671
740
|
(c.keptDecisions.length ? '<p class="hint" style="margin:0"><strong>Kept as they were:</strong> ' + c.keptDecisions.map(function (k) { return '<code>' + esc(k.tool) + '</code> stays ' + esc(LABELS[k.has]) + ' (the workflow wanted ' + esc(LABELS[k.wants]) + ')'; }).join('; ') + '. Change them in Permissions if you want.</p>' : '') +
|
|
672
741
|
(items.length ? '<h3>Left to do</h3><ul class="wf-list">' + items.map(function (it) { return '<li>' + (it.href ? '<a href="' + esc(it.href) + '">' + esc(it.label) + '</a>' : esc(it.label)) + '</li>'; }).join('') + '</ul>' : '<p class="hint" style="margin:0">Nothing left to set up.</p>') +
|
|
673
742
|
'<div class="wf-actions"><a class="wf-btn" href="' + agentHref + '">Open ' + esc(agentLabel(c.agent)) + '</a><a class="wf-btn plain" href="/playground?agent=' + encodeURIComponent(c.agent) + '">Try it in Chat</a>' +
|
|
674
|
-
(fromGoal.goal
|
|
675
|
-
: fromGoal.goal ? '<a class="wf-btn plain" href="/goals?goal=' + encodeURIComponent(fromGoal.goal) + '">Back to your goal</a>' : '<button type="button" class="wf-btn plain" id="wfAnother">Build another</button>') + '</div>' +
|
|
743
|
+
(fromGoal.goal ? '<a class="wf-btn plain" href="/goals?goal=' + encodeURIComponent(fromGoal.goal) + '">Back to your goal</a>' : '<button type="button" class="wf-btn plain" id="wfAnother">Build another</button>') + '</div>' +
|
|
676
744
|
'</div>';
|
|
677
745
|
var another = document.getElementById('wfAnother');
|
|
678
746
|
if (another) another.addEventListener('click', function () { state.description = ''; state.planned = null; renderDescribe(); });
|
|
@@ -64,6 +64,13 @@ export interface HomeJob {
|
|
|
64
64
|
state: string;
|
|
65
65
|
agent: string;
|
|
66
66
|
flows: HomeFlow[];
|
|
67
|
+
/** A group's steps in order, each with whether it's built yet. */
|
|
68
|
+
group?: {
|
|
69
|
+
steps: {
|
|
70
|
+
name: string;
|
|
71
|
+
built: boolean;
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
67
74
|
}
|
|
68
75
|
export interface HomeOverview extends WorkflowsOverview {
|
|
69
76
|
goals: {
|
|
@@ -72,10 +79,9 @@ export interface HomeOverview extends WorkflowsOverview {
|
|
|
72
79
|
measure: string;
|
|
73
80
|
jobs: HomeJob[];
|
|
74
81
|
}[];
|
|
75
|
-
jobs: HomeJob[];
|
|
76
82
|
loose: WorkflowOverviewRow[];
|
|
77
83
|
}
|
|
78
|
-
type TreeJob = Pick<GoalJob, 'id' | 'title' | 'kind' | 'measure' | 'state' | 'agent' | 'doers' | 'chain' | '
|
|
84
|
+
type TreeJob = Pick<GoalJob, 'id' | 'title' | 'kind' | 'measure' | 'state' | 'agent' | 'doers' | 'chain' | 'group'>;
|
|
79
85
|
export declare function homeOverview(overview: WorkflowsOverview, goals: (Pick<Goal, 'id' | 'goal' | 'standalone'> & {
|
|
80
86
|
brief?: {
|
|
81
87
|
measure?: string;
|
|
@@ -70,11 +70,13 @@ export function homeOverview(overview, goals) {
|
|
|
70
70
|
const row = rows.get(k);
|
|
71
71
|
return { agent, id, starts: row?.starts ?? [], waiting: row?.waiting ?? 0, then: i > 0 && after.get(k) === ordered[i - 1], ...(row ? {} : { gone: true }) };
|
|
72
72
|
}),
|
|
73
|
+
...(j.group ? { group: { steps: j.group.steps.map((st) => ({ name: st.name, built: Boolean(st.built) })) } } : {}),
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
|
-
// A goal's suggestions not
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
76
|
+
// A goal's suggestions not built yet stay on its own page; one-off jobs
|
|
77
|
+
// from before goals suggested only workflows aren't shown, and workflows
|
|
78
|
+
// built from jobs once submitted without a goal are listed apart.
|
|
79
|
+
const shown = (j) => j.state === 'active' && j.kind !== 'once';
|
|
80
|
+
const tree = goals.filter((g) => !g.standalone).map((g) => ({ id: g.id, goal: g.goal, measure: g.brief?.measure ?? '', jobs: g.jobs.filter(shown).map(toJob) }));
|
|
81
|
+
return { ...overview, goals: tree, loose: overview.workflows.filter((r) => !used.has(`${r.agent}|${r.id}`)) };
|
|
80
82
|
}
|