loopengine 0.3.67 → 0.3.68

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.
@@ -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 businesses (no names of this business, its products, people, places or sites), 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.\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.";
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 businesses (no names of this business, its products, people, places or sites), 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.
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
- return { setup: strings(raw.setup), workflows, leftOut: strings(raw.leftOut), assumptions: strings(raw.assumptions), message: str(raw.message), ...(used.length ? { newLevers: used } : {}) };
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,5 +1,5 @@
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
4
  export type GoalJobState = 'suggested' | 'saved' | 'active' | 'done' | 'discarded';
5
5
  /** What does a job: a workflow on an agent, or, for a once job, each try
@@ -96,9 +96,11 @@ export interface GoalJob {
96
96
  note?: string;
97
97
  alternative?: string;
98
98
  };
99
- /** The person asked to keep this job's approach to their workspace: its
100
- * lever events are never sent, and its lever is never offered as a
101
- * candidate for the shared playbook. */
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
- private?: unknown;
258
+ share?: unknown;
250
259
  }): Promise<{
251
260
  goal: Goal;
252
261
  verdict: 'added' | 'changed' | 'warned' | 'refused';
@@ -188,7 +188,10 @@ const sameLever = (a, b) => Boolean((a.leverId && a.leverId === b.leverId) || a.
188
188
  function toJob(w, round, deps) {
189
189
  const name = agentName(w.newAgent?.name || w.agent) || 'goal-agent';
190
190
  const exists = deps.agentExists(name);
191
+ // Made from a lever written from a person's job they kept private.
192
+ const fromPrivate = Boolean(w.leverId && activePlaybook().levers.find((l) => l.id === w.leverId)?.private);
191
193
  return {
194
+ ...(fromPrivate ? { keepPrivate: true } : {}),
192
195
  id: newId('w'),
193
196
  title: w.title,
194
197
  kind: w.kind,
@@ -247,6 +250,7 @@ function startPlanning(deps, goal) {
247
250
  status: 'ready',
248
251
  error: undefined,
249
252
  rounds: round,
253
+ ...(plan.considered?.length ? { choices: [...(latest.choices ?? []), { round, at: now(), considered: plan.considered }].slice(-5) } : {}),
250
254
  jobs: [...latest.jobs, ...fresh],
251
255
  updatedAt: now(),
252
256
  };
@@ -414,9 +418,12 @@ export async function addJob(deps, id, input) {
414
418
  if (shaped.verdict === 'refused' || !shaped.job) {
415
419
  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
420
  }
421
+ // The person's own idea stays theirs unless they agreed to share its
422
+ // approach: then the lever written from it can become a candidate.
423
+ const share = input.share === true;
417
424
  if (shaped.newLever) {
418
425
  try {
419
- addToLocalPlaybook(deps.projectDir(), { levers: [shaped.newLever] });
426
+ addToLocalPlaybook(deps.projectDir(), { levers: [share ? shaped.newLever : { ...shaped.newLever, private: true }] });
420
427
  }
421
428
  catch (err) {
422
429
  console.error('[loopengine] couldn\'t add the job\'s lever to the playbook:', err instanceof Error ? err.message : err);
@@ -425,7 +432,7 @@ export async function addJob(deps, id, input) {
425
432
  const job = {
426
433
  ...toJob(shaped.job, goal.rounds || 1, deps),
427
434
  state: 'saved',
428
- ...(input.private === true ? { keepPrivate: true } : {}),
435
+ ...(share ? {} : { keepPrivate: true }),
429
436
  added: { idea, verdict: shaped.verdict, ...(shaped.note ? { note: shaped.note } : {}), ...(shaped.alternative ? { alternative: shaped.alternative } : {}) },
430
437
  };
431
438
  const latest = getGoal(deps, id);
@@ -163,7 +163,7 @@ ${consoleShellScript}
163
163
  // Which view: the list (/goals), a new goal (?new=1, or the front page)
164
164
  // or one goal (?goal=).
165
165
  var startNew = location.pathname === '/' || new URLSearchParams(location.search).has('new');
166
- var state = { addOpen: false, addDraft: '', addPrivate: false, addNotice: null, flows: {}, openJobs: {}, goals: [], about: '', settings: {}, current: null, creating: startNew, showDiscarded: false, justDiscarded: null, error: '', poll: null, startedAt: 0 };
166
+ 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
167
 
168
168
  function esc(s) {
169
169
  return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
@@ -313,7 +313,7 @@ ${consoleShellScript}
313
313
  '<span class="gl-job-primary">' + primary + '</span>' +
314
314
  '</div>' +
315
315
  '<div class="gl-job-body"' + (open ? '' : ' hidden') + '>' +
316
- (w.added ? '<p class="hint" style="margin:0">You added this: ' + String.fromCharCode(8220) + esc(w.added.idea) + String.fromCharCode(8221) + (w.added.note ? ' ' + String.fromCharCode(183) + ' ' + esc(w.added.note) : '') + (w.keepPrivate ? ' ' + String.fromCharCode(183) + ' kept to your workspace' : '') + '</p>' : '') +
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' : ' ' + String.fromCharCode(183) + ' its approach may be shared') + '</p>' : '') +
317
317
  (w.why && sub !== w.why ? '<p class="gl-why">' + esc(w.why) + '</p>' : '') +
318
318
  (w.measure && sub.indexOf(w.measure) < 0 ? '<p class="gl-job-measure">' + (once ? '' : 'Measured by ') + esc(w.measure) + '</p>' : '') +
319
319
  (w.state === 'active' || w.state === 'done' ? '' : '<div class="gl-row">' + agentHtml(w) + '</div>' + needsHtml(w)) +
@@ -339,8 +339,8 @@ ${consoleShellScript}
339
339
  '<div class="gl-add-form"' + (state.addOpen ? '' : ' hidden') + '>' +
340
340
  '<label for="glAddIdea"><strong>A job you have in mind</strong> <span class="hint">in your own words; LoopEngine shapes it into a job and says if anything looks off</span></label>' +
341
341
  '<textarea id="glAddIdea" rows="2" placeholder="e.g. Thank every new customer by email within a day">' + esc(state.addDraft || '') + '</textarea>' +
342
- '<label class="hint gl-share"><input type="checkbox" id="glAddPrivate"' + (state.addPrivate ? ' checked' : '') + '> Keep this one to my workspace</label>' +
343
- '<p class="hint" style="margin:0">Unless you tick that, the approach behind this job (never your words) may be shared anonymously to improve suggestions, and only once many workspaces use something similar.</p>' +
342
+ '<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>' +
343
+ '<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
344
  '<div class="gl-row"><button type="button" class="gl-btn soft" id="glAddJob"' + (planning ? ' disabled' : '') + '>Add it</button><button type="button" class="gl-btn plain" id="glAddCancel">Cancel</button><span class="hint" id="glAddStatus"></span></div>' +
345
345
  '</div>' + notice + '</div>';
346
346
  }
@@ -547,8 +547,8 @@ ${consoleShellScript}
547
547
  if (addCancel) addCancel.addEventListener('click', function () { state.addOpen = false; state.addDraft = ''; render(); });
548
548
  var addIdea = document.getElementById('glAddIdea');
549
549
  if (addIdea) addIdea.addEventListener('input', function () { state.addDraft = addIdea.value; });
550
- var addPrivate = document.getElementById('glAddPrivate');
551
- if (addPrivate) addPrivate.addEventListener('change', function () { state.addPrivate = addPrivate.checked; });
550
+ var addShare = document.getElementById('glAddShare');
551
+ if (addShare) addShare.addEventListener('change', function () { state.addShare = addShare.checked; });
552
552
  var addJob = document.getElementById('glAddJob');
553
553
  if (addJob) addJob.addEventListener('click', function () {
554
554
  var idea = document.getElementById('glAddIdea').value.trim();
@@ -556,11 +556,11 @@ ${consoleShellScript}
556
556
  if (idea.length < 5) { status.textContent = 'Say what the job is first.'; return; }
557
557
  addJob.disabled = true;
558
558
  status.textContent = 'Shaping it into a job' + ELLIPSIS;
559
- var keep = document.getElementById('glAddPrivate');
560
- api('POST', base + '/jobs', { idea: idea, private: !!(keep && keep.checked) }).then(function (r) {
559
+ var shareBox = document.getElementById('glAddShare');
560
+ api('POST', base + '/jobs', { idea: idea, share: !!(shareBox && shareBox.checked) }).then(function (r) {
561
561
  if (!r.ok) { addJob.disabled = false; status.textContent = r.body.error || 'Could not add it.'; return; }
562
562
  state.addNotice = { verdict: r.body.verdict, note: r.body.note, alternative: r.body.alternative };
563
- if (r.body.verdict !== 'refused') { state.addOpen = false; state.addDraft = ''; state.addPrivate = false; if (r.body.jobId) state.openJobs[r.body.jobId] = true; }
563
+ if (r.body.verdict !== 'refused') { state.addOpen = false; state.addDraft = ''; state.addShare = false; if (r.body.jobId) state.openJobs[r.body.jobId] = true; }
564
564
  replaceGoal(r.body.goal);
565
565
  render();
566
566
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.3.67",
3
+ "version": "0.3.68",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",