loopengine 0.3.67 → 0.3.69
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 +28 -2
- package/dist/core/system-agents/goal-planner.js +48 -2
- package/dist/core/system-agents/goal-playbooks.d.ts +4 -0
- package/dist/core/system-agents/goal-playbooks.js +1 -0
- package/dist/web/goals-admin.d.ts +18 -7
- package/dist/web/goals-admin.js +35 -27
- package/dist/web/goals-page.js +26 -29
- package/dist/web/workflow-admin.js +7 -3
- package/package.json +1 -1
|
@@ -19,6 +19,27 @@ export interface GoalContext {
|
|
|
19
19
|
weeklyHours?: number;
|
|
20
20
|
}
|
|
21
21
|
export type GoalScope = 'in' | 'partial' | 'out';
|
|
22
|
+
export interface GoalProfile {
|
|
23
|
+
/** The number it moves, and which way: up, down, reach a milestone, or keep it steady. */
|
|
24
|
+
metric: string;
|
|
25
|
+
direction: 'up' | 'down' | 'reach' | 'keep';
|
|
26
|
+
/** Limits that rule approaches out: budget, time, diet, an injury, a region… */
|
|
27
|
+
constraints: string[];
|
|
28
|
+
timeframe: string;
|
|
29
|
+
/** Where they start: first try, tried before, what's already in place. */
|
|
30
|
+
startingPoint: string;
|
|
31
|
+
/** What's most likely to stop this goal, and why. */
|
|
32
|
+
bottleneck: string;
|
|
33
|
+
bottleneckWhy: string;
|
|
34
|
+
}
|
|
35
|
+
/** How the plan chose its levers: every lever it looked at, chosen or
|
|
36
|
+
* ruled out, and why. */
|
|
37
|
+
export interface LeverChoice {
|
|
38
|
+
leverId?: string;
|
|
39
|
+
lever: string;
|
|
40
|
+
decision: 'chosen' | 'ruled_out';
|
|
41
|
+
reason: string;
|
|
42
|
+
}
|
|
22
43
|
export interface GoalBrief {
|
|
23
44
|
/** Whether agents can work on it: fully, only the information work
|
|
24
45
|
* around it, or not at all. */
|
|
@@ -39,6 +60,9 @@ export interface GoalBrief {
|
|
|
39
60
|
/** What the goal singles out beyond its main outcome (a segment, a
|
|
40
61
|
* topic, a season…): each must be covered by a workflow. */
|
|
41
62
|
qualifiers: string[];
|
|
63
|
+
/** What makes this goal different from others with the same focus, and
|
|
64
|
+
* what's most likely to stop it: levers are chosen against this. */
|
|
65
|
+
profile?: GoalProfile;
|
|
42
66
|
audience: string;
|
|
43
67
|
weeklyHours: number;
|
|
44
68
|
approvals: string;
|
|
@@ -104,6 +128,8 @@ export interface GoalPlan {
|
|
|
104
128
|
};
|
|
105
129
|
/** The playbook version the plan was made with. */
|
|
106
130
|
playbookVersion: number;
|
|
131
|
+
/** Every lever the plan looked at, chosen or ruled out, and why. */
|
|
132
|
+
considered?: LeverChoice[];
|
|
107
133
|
/** Levers the planner wrote because the playbook had none that fit
|
|
108
134
|
* (generic, like the playbook's own; saved in the workspace's own
|
|
109
135
|
* playbook, and the jobs made from them refer to them). */
|
|
@@ -116,8 +142,8 @@ export interface GoalPipelineInput {
|
|
|
116
142
|
/** The focus the person chose, instead of the one the brief reads. */
|
|
117
143
|
focus?: GoalFocus | 'other';
|
|
118
144
|
}
|
|
119
|
-
export declare const GOAL_BRIEF_PROMPT = "You read a goal someone gives LoopEngine, a platform of AI agents that work with information and software: they search, read, write, draft, track, and act in connected apps (email, chat, stores, CRMs, payments, code hosts). They can't do physical work or run large real-world projects on their own.\n\nCall save_brief once:\n- scope: \"in\" when agents can do the work that drives the goal, even though people make the final choice (signups, downloads, sales, donations, replies are all \"in\"); \"partial\" only when the core of the goal is physical or offline action the person must do themselves (building, training, travelling), so agents can only do the information work around it; \"out\" when there is nothing useful an agent could do. scopeReason: one sentence.\n- reading: how you read it. When the wording could be a metaphor (\"land on the moon\", \"climb Everest\" said of a business), prefer the reading the context supports and say which.\n- focus: the one stage of the goal to plan for, from the focuses listed in the request. Growth of users means \"new-signups\" unless the goal speaks of using, keeping or activating people. Answering customers sooner is \"faster-support\". When none fits, focus \"other\" and newFocus: name the stage in a few generic words (label, e.g. \"Hiring\", \"Closing sales deals\", \"Personal health habits\") with a one-sentence hint of what goals with this focus are about. No names of the business, its products, people or places.\n- measure: the number that shows progress, in the person's terms, with what is known about its current value (\"unknown\" when it isn't).\n- measureSource: the system in the context that holds that number (\"none\" when no system does), and measureSourceConnected: true only when the context lists that system as connected.\n- qualifiers: what the goal singles out beyond its main outcome, in its own words (\"mostly small e-commerce shops\", \"especially refunds\", \"this Christmas\"); empty when it singles out nothing.\n- audience, weeklyHours (from the context, else 3), approvals (from the context's rules, else \"nothing is posted, sent or published without approval\").";
|
|
120
|
-
export declare const GOAL_PLAN_PROMPT = "You plan workflows for a confirmed goal brief in LoopEngine. Each workflow is one recurring job for one AI agent; a person reviews what it drafts.\n\nRules:\n1. Levers first, capabilities second. Choose what moves this focus's measure (the playbook's levers, or your own when the context calls for one), then map each to what the workspace has. Never start from what the connected tools could do.\n1b. When the request lists no playbook levers for this focus (none yet, or every one already under this goal), write the levers you need first, in newLevers (two to five), then make each workflow from one of them (its leverId is the lever's key). When levers are listed but one this goal clearly needs is missing, you may add up to two. A new lever is like the playbook's: one distinct approach (one reason it works), in generic words that fit many
|
|
145
|
+
export declare const GOAL_BRIEF_PROMPT = "You read a goal someone gives LoopEngine, a platform of AI agents that work with information and software: they search, read, write, draft, track, and act in connected apps (email, chat, stores, CRMs, payments, code hosts). They can't do physical work or run large real-world projects on their own.\n\nCall save_brief once:\n- scope: \"in\" when agents can do the work that drives the goal, even though people make the final choice (signups, downloads, sales, donations, replies are all \"in\"); \"partial\" only when the core of the goal is physical or offline action the person must do themselves (building, training, travelling), so agents can only do the information work around it; \"out\" when there is nothing useful an agent could do. scopeReason: one sentence.\n- reading: how you read it. When the wording could be a metaphor (\"land on the moon\", \"climb Everest\" said of a business), prefer the reading the context supports and say which.\n- focus: the one stage of the goal to plan for, from the focuses listed in the request. Growth of users means \"new-signups\" unless the goal speaks of using, keeping or activating people. Answering customers sooner is \"faster-support\". When none fits, focus \"other\" and newFocus: name the stage in a few generic words (label, e.g. \"Hiring\", \"Closing sales deals\", \"Personal health habits\") with a one-sentence hint of what goals with this focus are about. No names of the business, its products, people or places.\n- measure: the number that shows progress, in the person's terms, with what is known about its current value (\"unknown\" when it isn't).\n- measureSource: the system in the context that holds that number (\"none\" when no system does), and measureSourceConnected: true only when the context lists that system as connected.\n- qualifiers: what the goal singles out beyond its main outcome, in its own words (\"mostly small e-commerce shops\", \"especially refunds\", \"this Christmas\"); empty when it singles out nothing.\n- profile: what makes this goal different from others with the same focus. metric: the number it moves; direction: \"up\", \"down\", \"reach\" (a milestone) or \"keep\"; constraints: limits that rule approaches out (no budget, night shifts, vegetarian, an injury, only one market), from the goal and the context, empty when none; timeframe (\"by March\", \"unknown\"); startingPoint (first try, tried before, what's already in place, or \"unknown\"); bottleneck: what's most likely to stop this particular goal (for most weight goals it's sticking with it; for a new product it may be that nobody knows it exists), and bottleneckWhy in a sentence.\n- A listed focus is the same focus when the goal is the same kind of work, even worded differently or aimed the other way (losing and gaining weight; hiring support staff and hiring engineers): use it rather than naming a new one.\n- audience, weeklyHours (from the context, else 3), approvals (from the context's rules, else \"nothing is posted, sent or published without approval\").";
|
|
146
|
+
export declare const GOAL_PLAN_PROMPT = "You plan workflows for a confirmed goal brief in LoopEngine. Each workflow is one recurring job for one AI agent; a person reviews what it drafts.\n\nRules:\n1. Levers first, capabilities second. Choose what moves this focus's measure (the playbook's levers, or your own when the context calls for one), then map each to what the workspace has. Never start from what the connected tools could do.\n1b. When the request lists no playbook levers for this focus (none yet, or every one already under this goal), write the levers you need first, in newLevers (two to five), then make each workflow from one of them (its leverId is the lever's key). When levers are listed but one this goal clearly needs is missing, you may add up to two. A new lever is like the playbook's: one distinct approach (one reason it works), in generic words that fit many goals of this focus (no names of this business, its products, people, places or sites; no direction, target or amount when the approach works either way: \"a weekly meal routine toward the target\", not \"eat less\"), with when it fits and doesn't, what it needs, review time, how its effect shows up, guardrails (approval before anything is sent, posted or published), and a generic template with {placeholders}. The workflow's request is where this business's specifics go.\n2. Every workflow serves the brief's focus directly and moves its measure. Workflows that only support it (reporting, onboarding for an acquisition goal, support) go in leftOut with a reason, not in workflows.\n3. One lever per workflow, named in a few generic words (no business, product, person, place or site names: \"list in app marketplaces\", not \"list Wick & Ember on Shopify\"); no two workflows on the same lever. Never propose a lever already saved under the goal (built, proposed or dismissed): those are listed in the request.\n3b. Choose levers for this goal, not for the focus in general. Look at every lever listed: rule out one whose \"not when\", needs or the profile's constraints don't fit; prefer the ones that address the profile's bottleneck; pick ones that work in different ways (not three kinds of tracking). In considered, list every lever you looked at with chosen or ruled_out and a short reason tied to this goal (\"addresses sticking with it\", \"no gym: ruled out\"). Reuse a listed lever whenever its approach fits, even if it was written for a goal aimed the other way: put what's specific to this goal (the direction, the target, the details) in the workflow's request. Write a new lever only for what no listed lever covers.\n4. Three to five workflows for an \"in\" goal, ordered by impact against effort, quickest useful one first; startsAfter when one depends on another. Their humanMinutesPerWeek together stay within three quarters of the brief's weeklyHours, so the plan survives a busy week.\n4b. Each one is a job: kind \"recurring\" when it runs again and again (a weekly scan, a reply to each signup), kind \"once\" for work on a finite list or done one time (submitting to a set of directories, a one-time audit, researching a list of communities). A once job is done by an agent once, in Chat; never make it a weekly job that runs out of things to do.\n4c. measure: the job's own number, in the person's terms, that shows it's working (\"replies per week\", \"signups tagged ref=directories\"); for a once job, what done looks like (\"done when: listed in 15 directories\"). A playbook lever says the kind and measure it usually has: start from those, and change them only when the context calls for it.\n5. Specific to this context: name the person's own communities, systems, products and channels in each request. A request anyone could use unchanged is wrong.\n6. needs: what each workflow uses, each with a kind from the playbook's vocabulary and connected true only when the context lists that kind as connected.\n7. Every request that posts, sends or publishes says nothing goes out without the person's approval.\n8. The measure must be readable. When measureSourceConnected is false, setup says how the number will be read: connecting that source (name it, e.g. \"connect Clerk's user.created webhook so signups and their ref are recorded\"), or, when it can't be connected, a light manual record the person updates weekly (kept with the Records ability). Always record a baseline: the number today. Tag what workflows produce (ref=<channel>) so each one's effect can be told apart.\n8b. Every qualifier in the brief is covered by at least one workflow that addresses it directly; list it in that workflow's covers.\n9. \"partial\" scope: at most three workflows, only ones that help the person pursue the goal, and say so in the message (\"helps you pursue\", never \"achieves\"). \"out\" scope: no workflows; the message says plainly why, and offers a smaller or related goal.\n10. agent: an existing agent's exact name when its work fits. When none fits, or there are no agents yet, suggest a new one: agent and newAgent.name the same short lowercase name with hyphens (e.g. \"community-agent\"), and newAgent.instructions two or three sentences on what it does and how it behaves. Group workflows that belong together in one agent rather than one agent each.\n\nCall save_plan once.";
|
|
121
147
|
export declare const GOAL_CRITIQUE_PROMPT = "You check a goal plan against its rules before a person sees it. List every issue (be strict, quote the workflow):\n- a workflow that doesn't serve the brief's focus or move its measure;\n- two workflows on the same lever, or one repeating a lever already saved;\n- a request generic enough to fit any business;\n- a need marked connected that the context doesn't list as connected;\n- a request that posts, sends or publishes without saying it waits for approval;\n- review time over three quarters of the weekly budget;\n- a measure whose source isn't connected, with no setup step that connects it or a manual record, or no baseline;\n- a qualifier from the brief no workflow addresses;\n- a recurring job on a finite list that will run out (it should be kind \"once\");\n- a lever in newLevers that names this business, its products, people, places or sites, mixes several approaches, or has no way to see its effect;\n- a workflow made from no lever when the request listed none for this focus (it should come from one of newLevers);\n- a plan claiming to achieve a goal that is only partly in scope, or workflows for an out-of-scope goal.\nCall save_review once: passed true only when there are no issues.";
|
|
122
148
|
/** A job a person added in their own words, shaped like a planned one. */
|
|
123
149
|
export declare const GOAL_ADD_JOB_PROMPT = "A person adds a job of their own to a goal in LoopEngine, in their own words. Shape it into one job like a planner's, and judge it honestly; it's their business, so advise, don't lecture.\n\nShape it:\n- title, kind (\"recurring\" when it repeats, \"once\" for finite work), measure (its own number, or for a once job what done looks like), why it moves the goal (mechanism), the agent (an existing agent's exact name when its work fits, else newAgent with a short name and two or three sentences of instructions), needs (connected only when the context lists it), humanMinutesPerWeek, and a request specific to this business that the agent can act on. Anything that posts, sends or publishes says nothing goes out without the person's approval.\n- lever: when it's one of the playbook levers listed, its id in leverId. When none fits, write one generic lever in newLever (one approach, no names of this business, its products, people, places or sites; when it fits and doesn't; what it needs; how its effect shows up; guardrails; a generic template) and put its key in leverId.\n\nJudge it, in verdict:\n- \"added\": it fits the goal and is safe.\n- \"changed\": a sound idea with risky details you changed (an approval added, volume limited, a platform's rules respected); say what you changed in note.\n- \"warned\": it's safe but unlikely to move the goal's measure, repeats a job already under the goal, or is unlikely to work; say why in note and give a better-aimed alternative.\n- \"refused\": it's deceptive, illegal or against a platform's rules (fake reviews or accounts, spam, buying followers, harvesting private data, impersonation, misleading claims) or could harm people. Don't shape it; say why in note, plainly and briefly, and give a legitimate alternative.\n\nCall save_job once.";
|
|
@@ -12,14 +12,17 @@ Call save_brief once:
|
|
|
12
12
|
- measure: the number that shows progress, in the person's terms, with what is known about its current value ("unknown" when it isn't).
|
|
13
13
|
- measureSource: the system in the context that holds that number ("none" when no system does), and measureSourceConnected: true only when the context lists that system as connected.
|
|
14
14
|
- qualifiers: what the goal singles out beyond its main outcome, in its own words ("mostly small e-commerce shops", "especially refunds", "this Christmas"); empty when it singles out nothing.
|
|
15
|
+
- profile: what makes this goal different from others with the same focus. metric: the number it moves; direction: "up", "down", "reach" (a milestone) or "keep"; constraints: limits that rule approaches out (no budget, night shifts, vegetarian, an injury, only one market), from the goal and the context, empty when none; timeframe ("by March", "unknown"); startingPoint (first try, tried before, what's already in place, or "unknown"); bottleneck: what's most likely to stop this particular goal (for most weight goals it's sticking with it; for a new product it may be that nobody knows it exists), and bottleneckWhy in a sentence.
|
|
16
|
+
- A listed focus is the same focus when the goal is the same kind of work, even worded differently or aimed the other way (losing and gaining weight; hiring support staff and hiring engineers): use it rather than naming a new one.
|
|
15
17
|
- audience, weeklyHours (from the context, else 3), approvals (from the context's rules, else "nothing is posted, sent or published without approval").`;
|
|
16
18
|
export const GOAL_PLAN_PROMPT = `You plan workflows for a confirmed goal brief in LoopEngine. Each workflow is one recurring job for one AI agent; a person reviews what it drafts.
|
|
17
19
|
|
|
18
20
|
Rules:
|
|
19
21
|
1. Levers first, capabilities second. Choose what moves this focus's measure (the playbook's levers, or your own when the context calls for one), then map each to what the workspace has. Never start from what the connected tools could do.
|
|
20
|
-
1b. When the request lists no playbook levers for this focus (none yet, or every one already under this goal), write the levers you need first, in newLevers (two to five), then make each workflow from one of them (its leverId is the lever's key). When levers are listed but one this goal clearly needs is missing, you may add up to two. A new lever is like the playbook's: one distinct approach (one reason it works), in generic words that fit many
|
|
22
|
+
1b. When the request lists no playbook levers for this focus (none yet, or every one already under this goal), write the levers you need first, in newLevers (two to five), then make each workflow from one of them (its leverId is the lever's key). When levers are listed but one this goal clearly needs is missing, you may add up to two. A new lever is like the playbook's: one distinct approach (one reason it works), in generic words that fit many goals of this focus (no names of this business, its products, people, places or sites; no direction, target or amount when the approach works either way: "a weekly meal routine toward the target", not "eat less"), with when it fits and doesn't, what it needs, review time, how its effect shows up, guardrails (approval before anything is sent, posted or published), and a generic template with {placeholders}. The workflow's request is where this business's specifics go.
|
|
21
23
|
2. Every workflow serves the brief's focus directly and moves its measure. Workflows that only support it (reporting, onboarding for an acquisition goal, support) go in leftOut with a reason, not in workflows.
|
|
22
24
|
3. One lever per workflow, named in a few generic words (no business, product, person, place or site names: "list in app marketplaces", not "list Wick & Ember on Shopify"); no two workflows on the same lever. Never propose a lever already saved under the goal (built, proposed or dismissed): those are listed in the request.
|
|
25
|
+
3b. Choose levers for this goal, not for the focus in general. Look at every lever listed: rule out one whose "not when", needs or the profile's constraints don't fit; prefer the ones that address the profile's bottleneck; pick ones that work in different ways (not three kinds of tracking). In considered, list every lever you looked at with chosen or ruled_out and a short reason tied to this goal ("addresses sticking with it", "no gym: ruled out"). Reuse a listed lever whenever its approach fits, even if it was written for a goal aimed the other way: put what's specific to this goal (the direction, the target, the details) in the workflow's request. Write a new lever only for what no listed lever covers.
|
|
23
26
|
4. Three to five workflows for an "in" goal, ordered by impact against effort, quickest useful one first; startsAfter when one depends on another. Their humanMinutesPerWeek together stay within three quarters of the brief's weeklyHours, so the plan survives a busy week.
|
|
24
27
|
4b. Each one is a job: kind "recurring" when it runs again and again (a weekly scan, a reply to each signup), kind "once" for work on a finite list or done one time (submitting to a set of directories, a one-time audit, researching a list of communities). A once job is done by an agent once, in Chat; never make it a weekly job that runs out of things to do.
|
|
25
28
|
4c. measure: the job's own number, in the person's terms, that shows it's working ("replies per week", "signups tagged ref=directories"); for a once job, what done looks like ("done when: listed in 15 directories"). A playbook lever says the kind and measure it usually has: start from those, and change them only when the context calls for it.
|
|
@@ -60,6 +63,14 @@ const briefTool = () => ({
|
|
|
60
63
|
reading: { type: 'string' },
|
|
61
64
|
focus: { type: 'string', enum: focusEnum() },
|
|
62
65
|
newFocus: { type: 'object', properties: { label: { type: 'string' }, hint: { type: 'string' } }, required: ['label', 'hint'], description: 'only when focus is "other": the stage, named in generic words' },
|
|
66
|
+
profile: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
metric: { type: 'string' }, direction: { type: 'string', enum: ['up', 'down', 'reach', 'keep'] }, constraints: { type: 'array', items: { type: 'string' } },
|
|
70
|
+
timeframe: { type: 'string' }, startingPoint: { type: 'string' }, bottleneck: { type: 'string' }, bottleneckWhy: { type: 'string' },
|
|
71
|
+
},
|
|
72
|
+
required: ['metric', 'direction', 'constraints', 'timeframe', 'startingPoint', 'bottleneck', 'bottleneckWhy'],
|
|
73
|
+
},
|
|
63
74
|
measure: { type: 'string' },
|
|
64
75
|
measureSource: { type: 'string' },
|
|
65
76
|
measureSourceConnected: { type: 'boolean' },
|
|
@@ -122,6 +133,11 @@ const planTool = () => ({
|
|
|
122
133
|
},
|
|
123
134
|
},
|
|
124
135
|
newLevers: { type: 'array', items: NEW_LEVER_SCHEMA, description: 'levers the playbook lacks; required when the request lists none for this focus' },
|
|
136
|
+
considered: {
|
|
137
|
+
type: 'array',
|
|
138
|
+
description: 'every lever you looked at (listed ones, and any you wrote), chosen or ruled out, with a short reason tied to this goal',
|
|
139
|
+
items: { type: 'object', properties: { lever: { type: 'string', description: 'its id, or for one you wrote its key' }, decision: { type: 'string', enum: ['chosen', 'ruled_out'] }, reason: { type: 'string' } }, required: ['lever', 'decision', 'reason'] },
|
|
140
|
+
},
|
|
125
141
|
leftOut: { type: 'array', items: { type: 'string' } },
|
|
126
142
|
assumptions: { type: 'array', items: { type: 'string' } },
|
|
127
143
|
message: { type: 'string' },
|
|
@@ -266,6 +282,16 @@ export function agentName(raw) {
|
|
|
266
282
|
const str = (v, fallback = '') => (typeof v === 'string' ? v.trim() : fallback);
|
|
267
283
|
const strings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string' && x.trim().length > 0).map((x) => x.trim()) : []);
|
|
268
284
|
const focusOf = (v) => (typeof v === 'string' && focusEnum().includes(v) ? v : 'other');
|
|
285
|
+
function profileFrom(raw) {
|
|
286
|
+
const p = raw && typeof raw === 'object' ? raw : undefined;
|
|
287
|
+
if (!p || !str(p.bottleneck))
|
|
288
|
+
return undefined;
|
|
289
|
+
const direction = p.direction === 'down' || p.direction === 'reach' || p.direction === 'keep' ? p.direction : 'up';
|
|
290
|
+
return {
|
|
291
|
+
metric: str(p.metric).slice(0, 200), direction, constraints: strings(p.constraints).slice(0, 8), timeframe: str(p.timeframe, 'unknown').slice(0, 100),
|
|
292
|
+
startingPoint: str(p.startingPoint, 'unknown').slice(0, 300), bottleneck: str(p.bottleneck).slice(0, 200), bottleneckWhy: str(p.bottleneckWhy).slice(0, 400),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
269
295
|
const slug = (v) => v.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40).replace(/-+$/, '');
|
|
270
296
|
/** Text that shouldn't leave the workspace in a lever: links, addresses,
|
|
271
297
|
* handles, long numbers. */
|
|
@@ -337,12 +363,21 @@ export async function readGoalBrief(modelCall, goal, context) {
|
|
|
337
363
|
measureSource: str(raw.measureSource, 'none'),
|
|
338
364
|
measureSourceConnected: raw.measureSourceConnected === true,
|
|
339
365
|
qualifiers: strings(raw.qualifiers),
|
|
366
|
+
...(profileFrom(raw.profile) ? { profile: profileFrom(raw.profile) } : {}),
|
|
340
367
|
audience: str(raw.audience, context.audience ?? ''),
|
|
341
368
|
weeklyHours: typeof raw.weeklyHours === 'number' && raw.weeklyHours > 0 ? raw.weeklyHours : context.weeklyHours ?? 3,
|
|
342
369
|
approvals: str(raw.approvals, 'nothing is posted, sent or published without approval'),
|
|
343
370
|
};
|
|
344
371
|
}
|
|
372
|
+
function profileText(p) {
|
|
373
|
+
if (!p)
|
|
374
|
+
return '';
|
|
375
|
+
return `\n- profile: ${p.metric}, ${p.direction}; constraints: ${p.constraints.join('; ') || 'none'}; timeframe: ${p.timeframe}; starting point: ${p.startingPoint}\n- bottleneck: ${p.bottleneck} (${p.bottleneckWhy})`;
|
|
376
|
+
}
|
|
345
377
|
function briefText(brief) {
|
|
378
|
+
return profileText(brief.profile).length ? `${briefTextCore(brief)}${profileText(brief.profile)}` : briefTextCore(brief);
|
|
379
|
+
}
|
|
380
|
+
function briefTextCore(brief) {
|
|
346
381
|
return `Confirmed brief:\n- scope: ${brief.scope} (${brief.scopeReason})\n- reading: ${brief.reading}\n- focus: ${brief.focus}${brief.newFocus ? ` (${brief.newFocus.label}: ${brief.newFocus.hint}; new, not in the playbook yet)` : ''}\n- measure: ${brief.measure}\n- measure source: ${brief.measureSource} (${brief.measureSourceConnected ? 'connected' : 'not connected'})\n- qualifiers: ${brief.qualifiers.join('; ') || 'none'}\n- audience: ${brief.audience}\n- weekly review time: ${brief.weeklyHours} hours\n- approvals: ${brief.approvals}`;
|
|
347
382
|
}
|
|
348
383
|
function parsePlan(raw, focus) {
|
|
@@ -391,7 +426,18 @@ function parsePlan(raw, focus) {
|
|
|
391
426
|
});
|
|
392
427
|
// The plan's own levers that a workflow is made from: the ones to keep.
|
|
393
428
|
const used = [...written.values()].filter((l) => workflows.some((w) => w.leverId === l.id));
|
|
394
|
-
|
|
429
|
+
// How it chose: each lever it looked at, named for people.
|
|
430
|
+
const considered = (Array.isArray(raw.considered) ? raw.considered : []).flatMap((c) => {
|
|
431
|
+
const x = c && typeof c === 'object' ? c : {};
|
|
432
|
+
const ref = str(x.lever);
|
|
433
|
+
const own = written.get(slug(ref));
|
|
434
|
+
const known = levers.find((l) => l.id === ref);
|
|
435
|
+
const name = own?.name ?? known?.name ?? ref;
|
|
436
|
+
if (!name || !str(x.reason))
|
|
437
|
+
return [];
|
|
438
|
+
return [{ ...(own || known ? { leverId: (own ?? known).id } : {}), lever: name, decision: x.decision === 'ruled_out' ? 'ruled_out' : 'chosen', reason: str(x.reason).slice(0, 300) }];
|
|
439
|
+
}).slice(0, 20);
|
|
440
|
+
return { setup: strings(raw.setup), workflows, leftOut: strings(raw.leftOut), assumptions: strings(raw.assumptions), message: str(raw.message), ...(used.length ? { newLevers: used } : {}), ...(considered.length ? { considered } : {}) };
|
|
395
441
|
}
|
|
396
442
|
export async function draftGoalPlan(modelCall, input, brief, issues = []) {
|
|
397
443
|
const user = [
|
|
@@ -40,6 +40,10 @@ export interface Lever {
|
|
|
40
40
|
guardrails: string[];
|
|
41
41
|
/** The request it starts from, with {placeholders} filled from context. */
|
|
42
42
|
template: string;
|
|
43
|
+
/** A workspace's own lever written from a job the person typed, which
|
|
44
|
+
* they didn't agree to share: it, and every job made from it, stays in
|
|
45
|
+
* the workspace. */
|
|
46
|
+
private?: true;
|
|
43
47
|
}
|
|
44
48
|
/** Checks the playbook's shape, naming the lever at fault. A lever's
|
|
45
49
|
* focus must be one the playbook lists, or one of `knownFocuses`. */
|
|
@@ -88,6 +88,7 @@ export function parsePlaybook(raw, knownFocuses = GOAL_FOCUSES) {
|
|
|
88
88
|
needs: { ...(anyOf ? { anyOf } : {}), ...(plus ? { plus } : {}) },
|
|
89
89
|
humanMinutesPerWeek: num('humanMinutesPerWeek'), firstResultDays: num('firstResultDays'), measureLink: text('measureLink'),
|
|
90
90
|
guardrails: list('guardrails'), template: text('template'),
|
|
91
|
+
...(l.private === true ? { private: true } : {}),
|
|
91
92
|
};
|
|
92
93
|
});
|
|
93
94
|
return { version, focuses, levers };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelCall } from '../core/run-agent.js';
|
|
2
|
-
import { type GoalBrief, type GoalContext, type GoalNeed } from '../core/system-agents/goal-planner.js';
|
|
2
|
+
import { type GoalBrief, type GoalContext, type GoalNeed, type LeverChoice } from '../core/system-agents/goal-planner.js';
|
|
3
3
|
import { type GoalFocus } from '../core/system-agents/goal-playbooks.js';
|
|
4
|
-
export type GoalJobState = 'suggested' | '
|
|
4
|
+
export type GoalJobState = 'suggested' | 'active' | 'done' | 'discarded';
|
|
5
5
|
/** What does a job: a workflow on an agent, or, for a once job, each try
|
|
6
6
|
* of its assignment (a run of its agent). */
|
|
7
7
|
export type JobDoer = {
|
|
@@ -79,7 +79,7 @@ export interface GoalJob {
|
|
|
79
79
|
measureLink: string;
|
|
80
80
|
state: GoalJobState;
|
|
81
81
|
/** Where a discarded one goes back to on Restore. */
|
|
82
|
-
restoreTo?: 'suggested'
|
|
82
|
+
restoreTo?: 'suggested';
|
|
83
83
|
/** What does it, once built: the workflow (skill id) on its agent. */
|
|
84
84
|
doers: JobDoer[];
|
|
85
85
|
/** When a once job was marked done. */
|
|
@@ -96,9 +96,11 @@ export interface GoalJob {
|
|
|
96
96
|
note?: string;
|
|
97
97
|
alternative?: string;
|
|
98
98
|
};
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
99
|
+
/** This job's approach stays in the workspace: its lever events are
|
|
100
|
+
* never sent, and its lever is never offered as a candidate for the
|
|
101
|
+
* shared playbook. A job the person typed is kept this way unless they
|
|
102
|
+
* agreed to share its approach; a planner's job, when it's made from a
|
|
103
|
+
* lever written from such a job. */
|
|
102
104
|
keepPrivate?: true;
|
|
103
105
|
/** How much the person changed the suggested request before building it
|
|
104
106
|
* (edits to the built workflow's instructions later don't count). */
|
|
@@ -132,6 +134,13 @@ export interface Goal {
|
|
|
132
134
|
/** The playbook version the latest suggestions came from. */
|
|
133
135
|
playbookVersion?: number;
|
|
134
136
|
rounds: number;
|
|
137
|
+
/** How each round of suggestions chose its levers (the latest five):
|
|
138
|
+
* every lever looked at, chosen or ruled out, and why. */
|
|
139
|
+
choices?: {
|
|
140
|
+
round: number;
|
|
141
|
+
at: string;
|
|
142
|
+
considered: LeverChoice[];
|
|
143
|
+
}[];
|
|
135
144
|
jobs: GoalJob[];
|
|
136
145
|
createdAt: string;
|
|
137
146
|
updatedAt: string;
|
|
@@ -246,7 +255,7 @@ export declare function markBuilt(deps: GoalsDeps, id: string, workflowId: strin
|
|
|
246
255
|
}): Goal;
|
|
247
256
|
export declare function addJob(deps: GoalsDeps, id: string, input: {
|
|
248
257
|
idea?: unknown;
|
|
249
|
-
|
|
258
|
+
share?: unknown;
|
|
250
259
|
}): Promise<{
|
|
251
260
|
goal: Goal;
|
|
252
261
|
verdict: 'added' | 'changed' | 'warned' | 'refused';
|
|
@@ -318,6 +327,8 @@ export declare function editAmount(before: string, after: string): EditAmount;
|
|
|
318
327
|
* reason), restored; built (a workflow does it) or done (a once job
|
|
319
328
|
* finished); edited (its request, at Build); then, from its workflow,
|
|
320
329
|
* kept_14d, used (weekly) and removed. */
|
|
330
|
+
/** "saved" is from before suggestions were built or assigned directly;
|
|
331
|
+
* no longer recorded. */
|
|
321
332
|
export type LeverEventType = 'suggested' | 'added' | 'saved' | 'discarded' | 'discard_reason' | 'restored' | 'built' | 'done' | 'edited' | 'kept_14d' | 'used' | 'removed';
|
|
322
333
|
export interface LeverEvent {
|
|
323
334
|
id: string;
|
package/dist/web/goals-admin.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// A job is one piece of the goal, with its own measure: recurring (done
|
|
8
8
|
// by a workflow on an agent) or once (a one-off piece of work, assigned to
|
|
9
9
|
// an agent as one unattended run, or done with it in Chat). It's in one
|
|
10
|
-
// of
|
|
11
|
-
// suggested the planner proposed it (on create or Generate more)
|
|
12
|
-
//
|
|
10
|
+
// of four states:
|
|
11
|
+
// suggested the planner proposed it (on create or Generate more), or the
|
|
12
|
+
// person added it; it's built or assigned straight from here
|
|
13
13
|
// active a workflow does it (Build linked the real workflow back),
|
|
14
14
|
// or, for a once job, it's been assigned and not accepted yet
|
|
15
15
|
// done a once job whose result the person accepted, or marked done
|
|
@@ -103,7 +103,7 @@ export function migrateGoalFiles(deps) {
|
|
|
103
103
|
const raw = JSON.parse(readFileSync(join(dir, f), 'utf8'));
|
|
104
104
|
if (Array.isArray(raw.jobs) || !Array.isArray(raw.workflows))
|
|
105
105
|
continue;
|
|
106
|
-
write(deps, migrateGoal(raw));
|
|
106
|
+
write(deps, withoutSaved(migrateGoal(raw)));
|
|
107
107
|
changed++;
|
|
108
108
|
}
|
|
109
109
|
catch (err) {
|
|
@@ -112,11 +112,18 @@ export function migrateGoalFiles(deps) {
|
|
|
112
112
|
}
|
|
113
113
|
return changed;
|
|
114
114
|
}
|
|
115
|
+
/** Jobs once saved (a state since removed) are suggestions again, ready
|
|
116
|
+
* to build or assign; a discarded one restores to a suggestion. */
|
|
117
|
+
function withoutSaved(goal) {
|
|
118
|
+
if (!goal.jobs.some((j) => j.state === 'saved' || j.restoreTo === 'saved'))
|
|
119
|
+
return goal;
|
|
120
|
+
return { ...goal, jobs: goal.jobs.map((j) => ({ ...j, ...(j.state === 'saved' ? { state: 'suggested' } : {}), ...(j.restoreTo === 'saved' ? { restoreTo: 'suggested' } : {}) })) };
|
|
121
|
+
}
|
|
115
122
|
export function getGoal(deps, id) {
|
|
116
123
|
const file = goalFile(deps, id);
|
|
117
124
|
if (!existsSync(file))
|
|
118
125
|
throw new GoalError('No such goal');
|
|
119
|
-
const goal = migrateGoal(JSON.parse(readFileSync(file, 'utf8')));
|
|
126
|
+
const goal = withoutSaved(migrateGoal(JSON.parse(readFileSync(file, 'utf8'))));
|
|
120
127
|
if (goal.status === 'planning' && Date.now() - Date.parse(goal.updatedAt) > STALE_PLANNING_MS && !running.has(id)) {
|
|
121
128
|
return write(deps, { ...goal, status: 'failed', error: 'Planning was interrupted. Try Generate more.', updatedAt: now() });
|
|
122
129
|
}
|
|
@@ -188,7 +195,10 @@ const sameLever = (a, b) => Boolean((a.leverId && a.leverId === b.leverId) || a.
|
|
|
188
195
|
function toJob(w, round, deps) {
|
|
189
196
|
const name = agentName(w.newAgent?.name || w.agent) || 'goal-agent';
|
|
190
197
|
const exists = deps.agentExists(name);
|
|
198
|
+
// Made from a lever written from a person's job they kept private.
|
|
199
|
+
const fromPrivate = Boolean(w.leverId && activePlaybook().levers.find((l) => l.id === w.leverId)?.private);
|
|
191
200
|
return {
|
|
201
|
+
...(fromPrivate ? { keepPrivate: true } : {}),
|
|
192
202
|
id: newId('w'),
|
|
193
203
|
title: w.title,
|
|
194
204
|
kind: w.kind,
|
|
@@ -247,6 +257,7 @@ function startPlanning(deps, goal) {
|
|
|
247
257
|
status: 'ready',
|
|
248
258
|
error: undefined,
|
|
249
259
|
rounds: round,
|
|
260
|
+
...(plan.considered?.length ? { choices: [...(latest.choices ?? []), { round, at: now(), considered: plan.considered }].slice(-5) } : {}),
|
|
250
261
|
jobs: [...latest.jobs, ...fresh],
|
|
251
262
|
updatedAt: now(),
|
|
252
263
|
};
|
|
@@ -296,19 +307,13 @@ function updateWorkflow(deps, goal, jobId, change) {
|
|
|
296
307
|
export function setWorkflowState(deps, id, workflowId, action, reason) {
|
|
297
308
|
const goal = getGoal(deps, id);
|
|
298
309
|
const w = findWorkflow(goal, workflowId);
|
|
299
|
-
if (action === 'save') {
|
|
300
|
-
if (w.state !== 'suggested')
|
|
301
|
-
throw new GoalError('Only a suggestion can be saved.');
|
|
302
|
-
recordLeverEvent(deps, goal, w, 'saved');
|
|
303
|
-
return updateWorkflow(deps, goal, workflowId, (x) => ({ ...x, state: 'saved' }));
|
|
304
|
-
}
|
|
305
310
|
if (action === 'discard') {
|
|
306
311
|
if (w.state === 'discarded')
|
|
307
312
|
return goal;
|
|
308
313
|
if (w.state === 'active' && w.kind !== 'once')
|
|
309
314
|
throw new GoalError('A workflow does this job: remove it from its agent instead.');
|
|
310
315
|
recordLeverEvent(deps, goal, w, 'discarded');
|
|
311
|
-
return updateWorkflow(deps, goal, workflowId, (x) => ({ ...x, state: 'discarded', restoreTo:
|
|
316
|
+
return updateWorkflow(deps, goal, workflowId, (x) => ({ ...x, state: 'discarded', restoreTo: 'suggested' }));
|
|
312
317
|
}
|
|
313
318
|
if (action === 'restore') {
|
|
314
319
|
if (w.state !== 'discarded')
|
|
@@ -321,15 +326,15 @@ export function setWorkflowState(deps, id, workflowId, action, reason) {
|
|
|
321
326
|
throw new GoalError('Only a one-off job is marked done.');
|
|
322
327
|
if (w.state === 'done')
|
|
323
328
|
return goal;
|
|
324
|
-
if (w.state !== '
|
|
325
|
-
throw new GoalError('
|
|
329
|
+
if (w.state !== 'suggested' && w.state !== 'active')
|
|
330
|
+
throw new GoalError('Restore it first.');
|
|
326
331
|
recordLeverEvent(deps, goal, w, 'done', { newAgent: Boolean(w.agentCreated) });
|
|
327
332
|
return updateWorkflow(deps, goal, workflowId, (x) => ({ ...x, state: 'done', doneAt: now() }));
|
|
328
333
|
}
|
|
329
334
|
if (action === 'undone') {
|
|
330
335
|
if (w.state !== 'done')
|
|
331
336
|
return goal;
|
|
332
|
-
return updateWorkflow(deps, goal, workflowId, ({ doneAt: _d, ...x }) => ({ ...x, state: '
|
|
337
|
+
return updateWorkflow(deps, goal, workflowId, ({ doneAt: _d, ...x }) => ({ ...x, state: x.doers.length ? 'active' : 'suggested' }));
|
|
333
338
|
}
|
|
334
339
|
if (action === 'reason') {
|
|
335
340
|
if (w.state !== 'discarded')
|
|
@@ -341,7 +346,7 @@ export function setWorkflowState(deps, id, workflowId, action, reason) {
|
|
|
341
346
|
recordLeverEvent(deps, goal, w, 'discard_reason', { reason: reason });
|
|
342
347
|
return updateWorkflow(deps, goal, workflowId, (x) => ({ ...x, discardReason: reason }));
|
|
343
348
|
}
|
|
344
|
-
throw new GoalError('action must be
|
|
349
|
+
throw new GoalError('action must be discard, restore, done, undone or reason');
|
|
345
350
|
}
|
|
346
351
|
/** Build: makes the suggested agent when there is none by that name,
|
|
347
352
|
* then returns where the work starts. A recurring job goes to Build a
|
|
@@ -355,8 +360,8 @@ export async function prepareBuild(deps, id, workflowId, opts = {}) {
|
|
|
355
360
|
throw new GoalError('This job is assigned already.');
|
|
356
361
|
if (w.state === 'active' && !opts.another)
|
|
357
362
|
throw new GoalError('A workflow already does this job: add another workflow to it instead.');
|
|
358
|
-
if (w.state !== '
|
|
359
|
-
throw new GoalError('
|
|
363
|
+
if (w.state !== 'suggested' && w.state !== 'active')
|
|
364
|
+
throw new GoalError('Restore it first.');
|
|
360
365
|
let createdAgent = false;
|
|
361
366
|
if (!deps.agentExists(w.agent.name)) {
|
|
362
367
|
await deps.createAgent(w.agent.name, w.agent.instructions || `You help with: ${w.title}.`);
|
|
@@ -414,9 +419,12 @@ export async function addJob(deps, id, input) {
|
|
|
414
419
|
if (shaped.verdict === 'refused' || !shaped.job) {
|
|
415
420
|
return { goal, verdict: 'refused', note: shaped.note || 'This couldn\'t be shaped into a job: say a little more about what it should do.', alternative: shaped.alternative };
|
|
416
421
|
}
|
|
422
|
+
// The person's own idea stays theirs unless they agreed to share its
|
|
423
|
+
// approach: then the lever written from it can become a candidate.
|
|
424
|
+
const share = input.share === true;
|
|
417
425
|
if (shaped.newLever) {
|
|
418
426
|
try {
|
|
419
|
-
addToLocalPlaybook(deps.projectDir(), { levers: [shaped.newLever] });
|
|
427
|
+
addToLocalPlaybook(deps.projectDir(), { levers: [share ? shaped.newLever : { ...shaped.newLever, private: true }] });
|
|
420
428
|
}
|
|
421
429
|
catch (err) {
|
|
422
430
|
console.error('[loopengine] couldn\'t add the job\'s lever to the playbook:', err instanceof Error ? err.message : err);
|
|
@@ -424,8 +432,8 @@ export async function addJob(deps, id, input) {
|
|
|
424
432
|
}
|
|
425
433
|
const job = {
|
|
426
434
|
...toJob(shaped.job, goal.rounds || 1, deps),
|
|
427
|
-
state: '
|
|
428
|
-
...(
|
|
435
|
+
state: 'suggested',
|
|
436
|
+
...(share ? {} : { keepPrivate: true }),
|
|
429
437
|
added: { idea, verdict: shaped.verdict, ...(shaped.note ? { note: shaped.note } : {}), ...(shaped.alternative ? { alternative: shaped.alternative } : {}) },
|
|
430
438
|
};
|
|
431
439
|
const latest = getGoal(deps, id);
|
|
@@ -510,11 +518,11 @@ export function editJob(deps, id, jobId, body) {
|
|
|
510
518
|
const info = deps.workflowInfo?.(ref.agent, ref.workflowId);
|
|
511
519
|
if (!info)
|
|
512
520
|
throw new GoalError(`${ref.agent} has no workflow ${ref.workflowId}.`);
|
|
513
|
-
if (job.state !== '
|
|
514
|
-
throw new GoalError('
|
|
521
|
+
if (job.state !== 'suggested' && job.state !== 'active')
|
|
522
|
+
throw new GoalError('Restore it first.');
|
|
515
523
|
if (job.doers.some((d) => d.type === 'workflow' && sameRef(d, ref)))
|
|
516
524
|
return goal;
|
|
517
|
-
if (job.state === '
|
|
525
|
+
if (job.state === 'suggested')
|
|
518
526
|
recordLeverEvent(deps, goal, job, 'built', { newAgent: false });
|
|
519
527
|
return updateWorkflow(deps, goal, jobId, (x) => ({ ...x, state: 'active', doers: [...x.doers, { type: 'workflow', ...ref, title: info.title, at: now() }] }));
|
|
520
528
|
}
|
|
@@ -523,7 +531,7 @@ export function editJob(deps, id, jobId, body) {
|
|
|
523
531
|
return updateWorkflow(deps, goal, jobId, (x) => {
|
|
524
532
|
const doers = x.doers.filter((d) => !(d.type === 'workflow' && sameRef(d, ref)));
|
|
525
533
|
const chain = (x.chain ?? []).filter((st) => !sameRef(st.after, ref) && !sameRef(st.run, ref));
|
|
526
|
-
return { ...x, doers, ...(chain.length ? { chain } : { chain: undefined }), state: doers.length ? x.state : '
|
|
534
|
+
return { ...x, doers, ...(chain.length ? { chain } : { chain: undefined }), state: doers.length ? x.state : 'suggested' };
|
|
527
535
|
});
|
|
528
536
|
}
|
|
529
537
|
if (body.action === 'chain') {
|
|
@@ -585,8 +593,8 @@ export async function assignJob(deps, id, jobId, input = {}) {
|
|
|
585
593
|
const job = findWorkflow(goal, jobId);
|
|
586
594
|
if (job.kind !== 'once')
|
|
587
595
|
throw new GoalError('Only a one-off job is assigned; build a recurring job into a workflow.');
|
|
588
|
-
if (job.state !== '
|
|
589
|
-
throw new GoalError(job.state === 'done' ? 'This job is done: reopen it first.' : '
|
|
596
|
+
if (job.state !== 'suggested' && job.state !== 'active')
|
|
597
|
+
throw new GoalError(job.state === 'done' ? 'This job is done: reopen it first.' : 'Restore it first.');
|
|
590
598
|
const tries = job.doers.filter((d) => d.type === 'assignment');
|
|
591
599
|
const last = tries[tries.length - 1];
|
|
592
600
|
let previous;
|
package/dist/web/goals-page.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// (and the workspace's front page, /) starts one, and /goals?goal=<id>
|
|
3
3
|
// opens one. A goal breaks into jobs, each with its own measure: recurring
|
|
4
4
|
// ones are built into a workflow on an agent, one-off ones are assigned to
|
|
5
|
-
// an agent (each try's result shown, accepted or sent back with a note).
|
|
6
|
-
// (each with the agent it would go into),
|
|
7
|
-
// generate more, and build
|
|
8
|
-
// it doesn't exist (web/goals-admin.ts
|
|
5
|
+
// an agent (each try's result shown, accepted or sent back with a note).
|
|
6
|
+
// Type a goal, get suggested jobs (each with the agent it would go into),
|
|
7
|
+
// generate more, and build or assign one straight from the suggestions,
|
|
8
|
+
// which makes its agent first when it doesn't exist (web/goals-admin.ts
|
|
9
|
+
// behind /goals/*). Same shell and
|
|
9
10
|
// styles as the other console pages; like them, its inline script avoids
|
|
10
11
|
// backslashes and template placeholders, since it lives inside a template
|
|
11
12
|
// literal.
|
|
@@ -141,7 +142,7 @@ ${consoleSidebarHtml}
|
|
|
141
142
|
<div class="le-head plain">
|
|
142
143
|
<div class="le-head-row">
|
|
143
144
|
<div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">☰</button>
|
|
144
|
-
<div><h1 id="glTitle">Goals</h1><p id="glLead">Say what you want to achieve. LoopEngine breaks it into jobs that move it, each with the agent that would do it.
|
|
145
|
+
<div><h1 id="glTitle">Goals</h1><p id="glLead">Say what you want to achieve. LoopEngine breaks it into jobs that move it, each with the agent that would do it. Build the recurring ones into workflows, assign the one-off ones to their agent, and generate more when you want new ideas.</p></div>
|
|
145
146
|
</div>
|
|
146
147
|
<a class="gl-btn gl-new-btn" id="glNewBtn" href="/goals?new=1" hidden>New goal</a>
|
|
147
148
|
</div>
|
|
@@ -163,7 +164,7 @@ ${consoleShellScript}
|
|
|
163
164
|
// Which view: the list (/goals), a new goal (?new=1, or the front page)
|
|
164
165
|
// or one goal (?goal=).
|
|
165
166
|
var startNew = location.pathname === '/' || new URLSearchParams(location.search).has('new');
|
|
166
|
-
var state = { addOpen: false, addDraft: '',
|
|
167
|
+
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 };
|
|
167
168
|
|
|
168
169
|
function esc(s) {
|
|
169
170
|
return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
|
|
@@ -236,9 +237,8 @@ ${consoleShellScript}
|
|
|
236
237
|
var parts = [];
|
|
237
238
|
if (g.status === 'planning') parts.push('<span class="gl-state planning">Suggesting' + ELLIPSIS + '</span>');
|
|
238
239
|
if (g.status === 'failed') parts.push('<span class="gl-state failed">Failed</span>');
|
|
239
|
-
var suggested = count(g, 'suggested'),
|
|
240
|
+
var suggested = count(g, 'suggested'), active = count(g, 'active'), done = count(g, 'done');
|
|
240
241
|
if (suggested) parts.push(suggested + ' suggested');
|
|
241
|
-
if (saved) parts.push(saved + ' saved');
|
|
242
242
|
if (active) parts.push('<span class="gl-state built">' + active + ' running</span>');
|
|
243
243
|
if (done) parts.push(done + ' done');
|
|
244
244
|
if (!parts.length) parts.push('No jobs kept yet');
|
|
@@ -283,19 +283,16 @@ ${consoleShellScript}
|
|
|
283
283
|
var doer = (w.doers || [])[0];
|
|
284
284
|
var t = lastTry(w);
|
|
285
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('
|
|
287
|
-
: w.state === '
|
|
288
|
-
: w.state === 'saved' ? btn('build', 'Build it')
|
|
286
|
+
var primary = w.state === 'suggested' && once ? btn('assign', 'Assign')
|
|
287
|
+
: w.state === 'suggested' ? btn('build', 'Build it')
|
|
289
288
|
: w.state === 'active' && once && t && t.status === 'done' ? btn('accept', 'Accept')
|
|
290
289
|
: w.state === 'active' && once && t && (t.status === 'error' || t.status === 'gone') ? btn('again', 'Try again')
|
|
291
290
|
: w.state === 'discarded' ? btn('restore', 'Restore', 'plain') : '';
|
|
292
|
-
var more = w.state === 'suggested' ? btn('discard', 'Discard', 'plain')
|
|
293
|
-
: w.state === '
|
|
294
|
-
: w.state === 'saved' ? btn('discard', 'Discard', 'plain')
|
|
291
|
+
var more = w.state === 'suggested' && once ? btn('build', 'Open in Chat', 'plain') + btn('done', 'Mark done', 'plain') + btn('discard', 'Discard', 'plain')
|
|
292
|
+
: w.state === 'suggested' ? btn('discard', 'Discard', 'plain')
|
|
295
293
|
: w.state === 'active' && once ? (t && t.status === 'done' ? btn('again', 'Ask again', 'soft') : '') + btn('done', 'Mark done', 'plain') + btn('discard', 'Discard', 'plain')
|
|
296
294
|
: w.state === 'done' ? btn('undone', 'Reopen', 'plain') : '';
|
|
297
|
-
var pill = w.state === '
|
|
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>')
|
|
295
|
+
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>')
|
|
299
296
|
: w.state === 'active' ? '<span class="gl-state built">Running</span>'
|
|
300
297
|
: w.state === 'done' ? '<span class="gl-state built">Done</span>'
|
|
301
298
|
: w.state === 'discarded' ? '<span class="gl-state">Discarded</span>' : '';
|
|
@@ -313,7 +310,7 @@ ${consoleShellScript}
|
|
|
313
310
|
'<span class="gl-job-primary">' + primary + '</span>' +
|
|
314
311
|
'</div>' +
|
|
315
312
|
'<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>' : '') +
|
|
313
|
+
(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>' : '') +
|
|
317
314
|
(w.why && sub !== w.why ? '<p class="gl-why">' + esc(w.why) + '</p>' : '') +
|
|
318
315
|
(w.measure && sub.indexOf(w.measure) < 0 ? '<p class="gl-job-measure">' + (once ? '' : 'Measured by ') + esc(w.measure) + '</p>' : '') +
|
|
319
316
|
(w.state === 'active' || w.state === 'done' ? '' : '<div class="gl-row">' + agentHtml(w) + '</div>' + needsHtml(w)) +
|
|
@@ -339,8 +336,8 @@ ${consoleShellScript}
|
|
|
339
336
|
'<div class="gl-add-form"' + (state.addOpen ? '' : ' hidden') + '>' +
|
|
340
337
|
'<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
338
|
'<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="
|
|
343
|
-
'<p class="hint" style="margin:0">
|
|
339
|
+
'<label class="hint gl-share"><input type="checkbox" id="glAddShare"' + (state.addShare ? ' checked' : '') + '> Share the approach behind this job to improve suggestions for everyone</label>' +
|
|
340
|
+
'<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>' +
|
|
344
341
|
'<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
342
|
'</div>' + notice + '</div>';
|
|
346
343
|
}
|
|
@@ -447,8 +444,8 @@ ${consoleShellScript}
|
|
|
447
444
|
var jobs = g.jobs || [];
|
|
448
445
|
var by = function (s) { return jobs.filter(function (w) { return w.state === s; }); };
|
|
449
446
|
var suggested = by('suggested');
|
|
450
|
-
// Yours: running first, then
|
|
451
|
-
var kept = by('active').concat(by('
|
|
447
|
+
// Yours: running first, then done.
|
|
448
|
+
var kept = by('active').concat(by('done'));
|
|
452
449
|
var discarded = by('discarded');
|
|
453
450
|
var planning = g.status === 'planning';
|
|
454
451
|
var focus = g.focus || (g.brief && g.brief.focus) || '';
|
|
@@ -468,11 +465,11 @@ ${consoleShellScript}
|
|
|
468
465
|
'<button type="button" class="gl-link" data-undo="1">Undo</button></div>' : '') +
|
|
469
466
|
'<div class="gl-section"><h3>Suggested jobs <span class="gl-count">' + suggested.length + '</span></h3>' +
|
|
470
467
|
(suggested.length ? suggested.map(jobHtml).join('') : '<p class="gl-empty">' + (planning ? 'On their way' + ELLIPSIS : 'No suggestions waiting. Generate more for new ideas.') + '</p>') +
|
|
471
|
-
'<div class="gl-row"><button type="button" class="gl-btn soft" id="glMore"' + (planning ? ' disabled' : '') + '>Generate more</button><span class="hint">New ideas only: nothing
|
|
468
|
+
'<div class="gl-row"><button type="button" class="gl-btn soft" id="glMore"' + (planning ? ' disabled' : '') + '>Generate more</button><span class="hint">New ideas only: nothing already here, built or discarded comes back.</span></div>' +
|
|
469
|
+
addJobHtml(planning) +
|
|
472
470
|
'</div>' +
|
|
473
471
|
'<div class="gl-section"><h3>Your jobs <span class="gl-count">' + kept.length + '</span></h3>' +
|
|
474
|
-
(kept.length ? kept.map(jobHtml).join('') : '<p class="gl-empty">
|
|
475
|
-
addJobHtml(planning) +
|
|
472
|
+
(kept.length ? kept.map(jobHtml).join('') : '<p class="gl-empty">Nothing running yet. Build it turns a recurring suggestion into a workflow on its agent; Assign gives a one-off one to its agent.</p>') +
|
|
476
473
|
'</div>' +
|
|
477
474
|
(discarded.length ? '<div class="gl-section"><button type="button" class="gl-link" id="glShowDiscarded">' + (state.showDiscarded ? 'Hide' : 'Show') + ' discarded (' + discarded.length + ')</button>' +
|
|
478
475
|
(state.showDiscarded ? discarded.map(jobHtml).join('') : '') + '</div>' : '') +
|
|
@@ -547,8 +544,8 @@ ${consoleShellScript}
|
|
|
547
544
|
if (addCancel) addCancel.addEventListener('click', function () { state.addOpen = false; state.addDraft = ''; render(); });
|
|
548
545
|
var addIdea = document.getElementById('glAddIdea');
|
|
549
546
|
if (addIdea) addIdea.addEventListener('input', function () { state.addDraft = addIdea.value; });
|
|
550
|
-
var
|
|
551
|
-
if (
|
|
547
|
+
var addShare = document.getElementById('glAddShare');
|
|
548
|
+
if (addShare) addShare.addEventListener('change', function () { state.addShare = addShare.checked; });
|
|
552
549
|
var addJob = document.getElementById('glAddJob');
|
|
553
550
|
if (addJob) addJob.addEventListener('click', function () {
|
|
554
551
|
var idea = document.getElementById('glAddIdea').value.trim();
|
|
@@ -556,11 +553,11 @@ ${consoleShellScript}
|
|
|
556
553
|
if (idea.length < 5) { status.textContent = 'Say what the job is first.'; return; }
|
|
557
554
|
addJob.disabled = true;
|
|
558
555
|
status.textContent = 'Shaping it into a job' + ELLIPSIS;
|
|
559
|
-
var
|
|
560
|
-
api('POST', base + '/jobs', { idea: idea,
|
|
556
|
+
var shareBox = document.getElementById('glAddShare');
|
|
557
|
+
api('POST', base + '/jobs', { idea: idea, share: !!(shareBox && shareBox.checked) }).then(function (r) {
|
|
561
558
|
if (!r.ok) { addJob.disabled = false; status.textContent = r.body.error || 'Could not add it.'; return; }
|
|
562
559
|
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.
|
|
560
|
+
if (r.body.verdict !== 'refused') { state.addOpen = false; state.addDraft = ''; state.addShare = false; if (r.body.jobId) state.openJobs[r.body.jobId] = true; }
|
|
564
561
|
replaceGoal(r.body.goal);
|
|
565
562
|
render();
|
|
566
563
|
});
|
|
@@ -370,9 +370,13 @@ export async function prepareMcpAbilities(plan, deps) {
|
|
|
370
370
|
continue;
|
|
371
371
|
plan.skill.body = plan.skill.body.replace(new RegExp(`(?<![A-Za-z0-9_])${remote.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![A-Za-z0-9_])`, 'g'), name);
|
|
372
372
|
}
|
|
373
|
-
// Added to the agent as an app, with just these tools
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
// Added to the agent as an app, with just these tools, next to any of
|
|
374
|
+
// the same app's tools other steps already turn on (a step on a tool of
|
|
375
|
+
// an app the agent has, resolved before): merged, never replaced.
|
|
376
|
+
if (tools.length) {
|
|
377
|
+
const before = plan.apps?.find((a) => a.id === planned.id)?.tools ?? [];
|
|
378
|
+
plan.apps = [...(plan.apps ?? []).filter((a) => a.id !== planned.id), { id: planned.id, title: planned.title, tools: [...new Set([...before, ...tools])] }];
|
|
379
|
+
}
|
|
376
380
|
}
|
|
377
381
|
delete plan.mcpServers;
|
|
378
382
|
return { failed };
|