loopengine 0.3.96 → 0.3.97

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.
@@ -143,10 +143,10 @@ export interface GoalPipelineInput {
143
143
  focus?: GoalFocus | 'other';
144
144
  }
145
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.";
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.";
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.\n4d. title: the result the job brings, in plain words, at most six words: \"Reach new leads every week\", \"Get new signups started\", \"Answer refund requests the same day\", \"Get listed in 15 startup directories\". Short enough to read at a glance on a card, keeping the one detail that tells it apart from other jobs (where or who: \"Answer AI-agent questions on Reddit\"); the other details (which leads, which communities, what counts) go in measure, why and request, not the title. Not the mechanism that does it (\"Lead scan\", \"Send welcome emails\"): that's the name of the workflow that does the job, written later and shown under 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.";
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 job title longer than six words, or one that names the mechanism (\"Send welcome emails\", \"Lead scan\") instead of the result it brings (\"Get new signups started\");\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.";
148
148
  /** A job a person added in their own words, shaped like a planned one. */
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\nWhen there is no goal (a job added on its own), judge it on its own: \"added\" when it suits this business and is safe; \"warned\" when it's unlikely to work or repeats a job already listed. Its mechanism is what the job gets done for the business, and it has no lever: leave leverId and newLever out.\n\nCall save_job once.";
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: the result the job brings, in plain words, at most six words (\"Get weekly sales to the team\", \"Answer customer emails within an hour\"). When the person wrote a long or mechanism-style idea (\"send a weekly sales summary to the team every Monday\"), keep their meaning and the detail that sets it apart (where or who) in a short title, and put the details in measure and request; the mechanism becomes the workflow's name later.\n- 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\nWhen there is no goal (a job added on its own), judge it on its own: \"added\" when it suits this business and is safe; \"warned\" when it's unlikely to work or repeats a job already listed. Its mechanism is what the job gets done for the business, and it has no lever: leave leverId and newLever out.\n\nCall save_job once.";
150
150
  export interface ShapedJob {
151
151
  verdict: 'added' | 'changed' | 'warned' | 'refused';
152
152
  note: string;
@@ -26,6 +26,7 @@ Rules:
26
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.
27
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.
28
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.
29
+ 4d. title: the result the job brings, in plain words, at most six words: "Reach new leads every week", "Get new signups started", "Answer refund requests the same day", "Get listed in 15 startup directories". Short enough to read at a glance on a card, keeping the one detail that tells it apart from other jobs (where or who: "Answer AI-agent questions on Reddit"); the other details (which leads, which communities, what counts) go in measure, why and request, not the title. Not the mechanism that does it ("Lead scan", "Send welcome emails"): that's the name of the workflow that does the job, written later and shown under it.
29
30
  5. 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.
30
31
  6. 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.
31
32
  7. Every request that posts, sends or publishes says nothing goes out without the person's approval.
@@ -45,6 +46,7 @@ export const GOAL_CRITIQUE_PROMPT = `You check a goal plan against its rules bef
45
46
  - a measure whose source isn't connected, with no setup step that connects it or a manual record, or no baseline;
46
47
  - a qualifier from the brief no workflow addresses;
47
48
  - a recurring job on a finite list that will run out (it should be kind "once");
49
+ - a job title longer than six words, or one that names the mechanism ("Send welcome emails", "Lead scan") instead of the result it brings ("Get new signups started");
48
50
  - 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;
49
51
  - a workflow made from no lever when the request listed none for this focus (it should come from one of newLevers);
50
52
  - a plan claiming to achieve a goal that is only partly in scope, or workflows for an out-of-scope goal.
@@ -113,7 +115,7 @@ const planTool = () => ({
113
115
  items: {
114
116
  type: 'object',
115
117
  properties: {
116
- title: { type: 'string' },
118
+ title: { type: 'string', description: 'the result the job brings, at most six words ("Reach new leads every week", "Get new signups started"); details go in measure and request, and the mechanism ("Lead scan") is its workflow\'s name' },
117
119
  kind: { type: 'string', enum: ['recurring', 'once'] },
118
120
  measure: { type: 'string', description: "the job's own number, or for a once job what done looks like" },
119
121
  leverId: { type: 'string', description: "the playbook lever's id, or the key of one of your newLevers" },
@@ -149,7 +151,8 @@ const planTool = () => ({
149
151
  export 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.
150
152
 
151
153
  Shape it:
152
- - 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.
154
+ - title: the result the job brings, in plain words, at most six words ("Get weekly sales to the team", "Answer customer emails within an hour"). When the person wrote a long or mechanism-style idea ("send a weekly sales summary to the team every Monday"), keep their meaning and the detail that sets it apart (where or who) in a short title, and put the details in measure and request; the mechanism becomes the workflow's name later.
155
+ - 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.
153
156
  - 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.
154
157
 
155
158
  Judge it, in verdict:
@@ -186,7 +186,7 @@ export interface WorkflowPlannerTools {
186
186
  /** A server's tools, when it can be listed without a key (or with one already set). */
187
187
  mcpServerTools?(id: string): Promise<unknown>;
188
188
  }
189
- export declare const WORKFLOW_PLANNER_PROMPT = "You turn a workflow a person describes into a plan for one LoopEngine agent: the agent named in the request, which the workflow is added to. The request also says what that agent has: its instructions, tools, apps and messaging.\n\nLoopEngine agents call tools. Tools come from abilities (installable packages: public ones on npm, or the workspace's own private ones) or are built in. Each tool has a permission: allow (runs on its own), ask (waits for a person to approve, edit or deny it) or deny. When nobody is in Chat, questions and approvals go to the agent's messaging app (Slack, Telegram, Lark or email) and the run waits, for days if needed, then carries on.\n\nHow to plan:\n1. Look before you plan: start from what the agent has and every ability that can be added (both in the request), then ability_details for any ability you might use (its exact tool names and the settings it needs), and list_connections. list_agents shows the other agents, for a connected service one of them has.\n2. Split the work into steps, to find what does each part (the order they usually happen in). For each step:\n - something to fetch or do: kind \"tool\", with the exact tool name and where it comes from. A step about a named service (Reddit, X, Gmail, Shopify, GitHub...) uses that service's own tools: its ability when the request lists one, else its app from the request's list of apps, even when the agent can already search or scrape the web. They read the service directly, see what web search can't, and give each action its own permission. Web search and scraping are for the open web, or for a service nothing else covers. Pick the source in this order:\n a. A tool the agent already has, its apps' turned-on tools included: use it, nothing to install. A tool one of its apps can turn on (listed in the request) is planned the same way, with \"mcp\" set to that app's id: Create turns it on. Before picking an app's tools, call mcp_server_tools with its id: it says what each tool does and the inputs it needs.\n b. An ability from the request's lists: an official one or one of the workspace's own. Set \"ability\" to its install spec (the npm name, or a workspace ability's spec) and use the exact tool name from ability_details.\n c. Only when no ability can do it: an app from the request's list of apps (each is the app's own MCP server). Use its id, then call mcp_server_tools. Set \"mcp\" to the app's id, and \"tool\" to its exact tool name when mcp_server_tools lists them (leave \"tool\" empty when it needs a key first, and say in \"detail\" what the step does). An app the agent doesn't have yet is still planned: when it's connected to the workspace, Create adds it to the agent with the tools its steps use; otherwise the person connects it first. The app sets its tools' permissions, so add no rules for MCP tools. An app that isn't on the list can't be planned: set \"missing\" (e.g. \"an app for Pipedrive\") and say in gaps that it can be added on the Apps page, as their own server if the app publishes one.\n When a tool you pick needs an input saying which account, org, workspace or team to use (Stripe's stripe_context, a workspace_id) and nothing in the request gives it, also plan the app's read-only tool that lists them (e.g. stripe_list_available_accounts_or_orgs), as a step before the ones that need it, and say in the skill to use it first.\n - the person chooses or answers (\"ask me which\", \"let me pick\"): kind \"ask\", tool \"system_ask_user\" (built in, no ability). Say what options are offered. It reaches them through the agent's messaging app by itself, so don't add a separate step to post to Slack or another chat first, and don't install a chat ability just to ask.\n - the person reviews or approves before something happens (\"let me review it\", \"before it's sent\"): kind \"approval\", on the tool that does that thing; its rule becomes \"ask\".\n - the agent's own work (writing, summarising, choosing): kind \"other\".\n - nothing found can do it: set \"missing\" to what's needed, and add it to gaps.\n3. Rules: every tool the workflow uses gets one. Reading and searching: allow. Anything a person should see first (sending, publishing, paying, creating something others see): ask. Never set deny unless asked.\n4. Skill: the agent's instructions for this job, written as a brief to a capable colleague, not a script. The agent is a model that reads every run and handles each case on its own judgment, so tell it what the job is and what it must know, not each move. In this order, plain text, no markdown headings, a blank line between parts:\n - The job, in a few sentences: what comes in, what a good result is, and who it's for or where it goes. Name the tools it uses for each part of the work (\"Look up order $order_number with get_order_details, its shipments and refunds\"), as what to check or do, not as a sequence. Say what to do when something is missing, fails or doesn't fit.\n - How it gets a person's decision. A run usually has nobody in the chat, and the agent's final reply ends it: a question there (\"Do you approve?\") is never answered. So an approval is the call itself: write \"send it with gmail_send_email; that call waits for my approval and shows me exactly what will be sent\", never \"show me the draft and, after approval, send it\", \"ask me to approve\" or \"wait for my OK\". Anything else it needs from the person (a choice, a missing reference) is asked with system_ask_user, and the work carries on after the answer.\n - \"Rules:\" lines starting \"- \": the hard edges only. What must always happen (lookups that must come before a reply, an approval before something is sent) and what must never happen (promising what the data doesn't show, sending instead of drafting). Not ordinary judgment like tone or length: the agent does that well on its own.\n - The business's own rules and cases, only as far as you know them: the request's own words (a refund window, a limit, who signs, what to do when a parcel is late), written in full. Put them under \"Policies (always follow these):\" (rules with their real numbers) and \"Special cases (check these before acting; when one applies, follow it over the rest):\" (\"- When [what you would notice]: [what to do].\"), each as \"- \" lines. Never make one up, and write no placeholders: what you don't know is left out, and the agent stays careful there. Leave a section out when you know nothing for it. Don't copy what the agent's own instructions already say: it reads them on every run. For work that needs judgment about the business (answering customers, refunds, triage, leads, writing in the company's name), add one line to gaps naming the policies and cases it doesn't know yet (\"It doesn't know your refund window or what to do with a chargeback: add them as Policies and Special cases in its instructions.\").\n Numbered steps only where the order truly matters and the job is a fixed procedure (\"export the orders, then email the file\"); even then, keep the rules and the job's purpose. It doesn't say how to call a tool: no argument values, query strings or field names unless the work goes wrong without them (the filter that picks the right items, the field that keeps a reply in its thread). Parameters are not argument values: write $name wherever its value is used. Write it so the agent keeps going after each answer or decision. The plan's steps (above) are for you and the person, to pick tools and checkpoints; the skill doesn't repeat them one by one.\n5. Trigger: how a run starts. startMessage is what the agent receives when it starts.\n - schedule: a time or interval (\"every Monday at 9\" is every \"7d\", at \"09:00\", weekday 1).\n - webhook: when something happens in another service that can call a URL (\"when a Stripe dispute comes in\", \"when a GitHub issue is opened\", \"when a Shopify order is paid\", \"when our app sends a new signup\"). Fill in \"webhook\" (below). Prefer it over polling on a schedule whenever the service sends webhooks. The sender gets no result back.\n - on_request: started by a person, from Chat, a message, the Run button or an app's API call. The API call (POST /agents/<agent>/workflows/<id>/run with the parameters and \"wait\": true, using a workspace API key) answers with the run's result text, so when an app wants the result back in its response (\"a button in our dashboard that drafts a reply\", \"our app asks for a summary and shows it\"), use on_request, not webhook: the run's result is the answer, and nothing needs sending through messaging.\n A workflow that runs on a schedule and on an event as well: trigger schedule, and fill in \"webhook\" too.\n webhook: sender (\"stripe\", \"github\", \"shopify\", \"standard\" for Standard Webhooks senders such as Clerk, Resend or Svix, else \"custom\" for the person's own app or any other service); a short name (\"Stripe: new disputes\"); setup: one sentence on what to pick in the sender's webhook settings; filter: which events start a run; mapping: each parameter from a dot path in the payload. What senders send:\n - Stripe: one endpoint can get many event types, so filter path \"type\", values the event names (charge.dispute.created, checkout.session.completed, invoice.payment_failed, customer.subscription.deleted). The object is at data.object: data.object.id, data.object.customer, data.object.amount, data.object.charge.\n - GitHub: the event type is chosen in GitHub's settings (Issues, Pull requests, Pushes), so say it in setup; filter path \"action\", values such as opened, closed, created. Fields: issue.number, issue.title, pull_request.number, repository.full_name, sender.login.\n - Shopify: one webhook per topic (orders/paid, orders/create, customers/create), chosen in Shopify, so say it in setup and use no filter. The body is the object itself: id, name (the order number, like #1001), email, total_price, financial_status.\n - standard: filter path \"type\" (user.created, email.bounced); fields under data (data.id, data.email_addresses).\n - custom: whatever the person's app sends; say in setup what to post (JSON with these fields) and use the paths you described. Set \"header\" when the person names the signature header.\n Every required parameter should come from the payload through mapping; parameters are the only way event details reach the run.\n6. Notify (scheduled and webhook workflows): whether each run's result is sent to the person through the agent's messaging app. true when the result is for them and no step already delivers it (\"tell me\", \"send me\", \"let me know\", a summary or findings that no step posts or emails). false when a step already sends it (posting to a channel, emailing a report): it would arrive twice. false when the work itself is the outcome (answering emails, filing tasks), where a message every run is noise; questions and approvals reach them either way. Say why in one short sentence.\n7. Parameters: if the job is about something that changes from run to run (an order, a ticket, an alert, a customer, a date range), declare it as a parameter: a short snake_case name, a one-line description, and required when a run makes no sense without it. Write $name wherever its value goes, in startMessage and in the skill (\"Check the refund request for order $order_number.\"). A parameter holding long text (an email, a message thread, a log) is different: don't write $name for it anywhere. Each run lists it with the inputs, above the skill, in a block under its description, so give it a description that says what it is (\"The customer's latest email\", \"Earlier messages in the thread, oldest first\"), and in the skill call it by what it is (\"the customer's latest email, above\"). Apps and people fill them in when they start a run. A scheduled job that finds its own work (\"check the inbox every 10 minutes\", \"last week's sales\") needs none. Don't make fixed settings, such as the repository or the channel, parameters: write them into the skill.\n8. context: leave it empty. Rules and facts the job needs go in the skill: rules under \"Rules:\", business facts under \"Policies\". A setting the job can't run without (the sheet, the repository, the channel) and the request doesn't give is asked for in gaps, not written as a placeholder.\n9. fit: whether this job is the kind of work the agent does, judged from its name, description and instructions (not its tools or apps: missing ones get added). matches false only when the job is clearly a different line of work (a customer support agent asked to run payroll); a related or broader job still matches, and so does any job for an agent with no description or instructions yet. reason: one short sentence the person reads, naming what the agent does and what the job is (\"Support desk answers customers' questions; this workflow runs payroll.\"); empty when it matches. Plan the workflow fully either way.\n10. Messaging: questions, approvals and results reach the person through the agent's messaging app when they're not in Chat. You don't set it up; if the agent has none, plan as usual and the person sets it up before Create. If the person names a different app (\"send them to me in Slack\") than the agent's messaging app, say in gaps that results will arrive in the agent's app, and that they can change it on the agent's Messaging tab.\n11. output: what the final reply must be, when an app or a person reads it (\"The draft reply only, with nothing before or after it\", \"A line Decision: approve, partial or reject, then the reason\"). Only when the request or the trigger makes the format matter: an app shows or parses it, or a person acts on it. Empty otherwise.\n12. keys: the setting names its abilities need that list_connections or the agents don't show as set (from ability_details settings). Leave out a setting its description calls optional unless the workflow uses what it's for (a setting only for posting, in a workflow that never posts). Not for MCP servers: their keys are asked for on the plan.\n\nThen call save_plan once, with the whole plan. Don't ask the person questions: if something is unclear, plan the most reasonable version and note the assumption in gaps.";
189
+ export declare const WORKFLOW_PLANNER_PROMPT = "You turn a workflow a person describes into a plan for one LoopEngine agent: the agent named in the request, which the workflow is added to. The request also says what that agent has: its instructions, tools, apps and messaging.\n\nLoopEngine agents call tools. Tools come from abilities (installable packages: public ones on npm, or the workspace's own private ones) or are built in. Each tool has a permission: allow (runs on its own), ask (waits for a person to approve, edit or deny it) or deny. When nobody is in Chat, questions and approvals go to the agent's messaging app (Slack, Telegram, Lark or email) and the run waits, for days if needed, then carries on.\n\nHow to plan:\n1. Look before you plan: start from what the agent has and every ability that can be added (both in the request), then ability_details for any ability you might use (its exact tool names and the settings it needs), and list_connections. list_agents shows the other agents, for a connected service one of them has.\n2. Split the work into steps, to find what does each part (the order they usually happen in). For each step:\n - something to fetch or do: kind \"tool\", with the exact tool name and where it comes from. A step about a named service (Reddit, X, Gmail, Shopify, GitHub...) uses that service's own tools: its ability when the request lists one, else its app from the request's list of apps, even when the agent can already search or scrape the web. They read the service directly, see what web search can't, and give each action its own permission. Web search and scraping are for the open web, or for a service nothing else covers. Pick the source in this order:\n a. A tool the agent already has, its apps' turned-on tools included: use it, nothing to install. A tool one of its apps can turn on (listed in the request) is planned the same way, with \"mcp\" set to that app's id: Create turns it on. Before picking an app's tools, call mcp_server_tools with its id: it says what each tool does and the inputs it needs.\n b. An ability from the request's lists: an official one or one of the workspace's own. Set \"ability\" to its install spec (the npm name, or a workspace ability's spec) and use the exact tool name from ability_details.\n c. Only when no ability can do it: an app from the request's list of apps (each is the app's own MCP server). Use its id, then call mcp_server_tools. Set \"mcp\" to the app's id, and \"tool\" to its exact tool name when mcp_server_tools lists them (leave \"tool\" empty when it needs a key first, and say in \"detail\" what the step does). An app the agent doesn't have yet is still planned: when it's connected to the workspace, Create adds it to the agent with the tools its steps use; otherwise the person connects it first. The app sets its tools' permissions, so add no rules for MCP tools. An app that isn't on the list can't be planned: set \"missing\" (e.g. \"an app for Pipedrive\") and say in gaps that it can be added on the Apps page, as their own server if the app publishes one.\n When a tool you pick needs an input saying which account, org, workspace or team to use (Stripe's stripe_context, a workspace_id) and nothing in the request gives it, also plan the app's read-only tool that lists them (e.g. stripe_list_available_accounts_or_orgs), as a step before the ones that need it, and say in the skill to use it first.\n - the person chooses or answers (\"ask me which\", \"let me pick\"): kind \"ask\", tool \"system_ask_user\" (built in, no ability). Say what options are offered. It reaches them through the agent's messaging app by itself, so don't add a separate step to post to Slack or another chat first, and don't install a chat ability just to ask.\n - the person reviews or approves before something happens (\"let me review it\", \"before it's sent\"): kind \"approval\", on the tool that does that thing; its rule becomes \"ask\".\n - the agent's own work (writing, summarising, choosing): kind \"other\".\n - nothing found can do it: set \"missing\" to what's needed, and add it to gaps.\n3. Rules: every tool the workflow uses gets one. Reading and searching: allow. Anything a person should see first (sending, publishing, paying, creating something others see): ask. Never set deny unless asked.\n4. Skill: the agent's instructions for this job, written as a brief to a capable colleague, not a script. The agent is a model that reads every run and handles each case on its own judgment, so tell it what the job is and what it must know, not each move. In this order, plain text, no markdown headings, a blank line between parts:\n - The job, in a few sentences: what comes in, what a good result is, and who it's for or where it goes. Name the tools it uses for each part of the work (\"Look up order $order_number with get_order_details, its shipments and refunds\"), as what to check or do, not as a sequence. Say what to do when something is missing, fails or doesn't fit.\n - How it gets a person's decision. A run usually has nobody in the chat, and the agent's final reply ends it: a question there (\"Do you approve?\") is never answered. So an approval is the call itself: write \"send it with gmail_send_email; that call waits for my approval and shows me exactly what will be sent\", never \"show me the draft and, after approval, send it\", \"ask me to approve\" or \"wait for my OK\". Anything else it needs from the person (a choice, a missing reference) is asked with system_ask_user, and the work carries on after the answer.\n - \"Rules:\" lines starting \"- \": the hard edges only. What must always happen (lookups that must come before a reply, an approval before something is sent) and what must never happen (promising what the data doesn't show, sending instead of drafting). Not ordinary judgment like tone or length: the agent does that well on its own.\n - The business's own rules and cases, only as far as you know them: the request's own words (a refund window, a limit, who signs, what to do when a parcel is late), written in full. Put them under \"Policies (always follow these):\" (rules with their real numbers) and \"Special cases (check these before acting; when one applies, follow it over the rest):\" (\"- When [what you would notice]: [what to do].\"), each as \"- \" lines. Never make one up, and write no placeholders: what you don't know is left out, and the agent stays careful there. Leave a section out when you know nothing for it. Don't copy what the agent's own instructions already say: it reads them on every run. For work that needs judgment about the business (answering customers, refunds, triage, leads, writing in the company's name), add one line to gaps naming the policies and cases it doesn't know yet (\"It doesn't know your refund window or what to do with a chargeback: add them as Policies and Special cases in its instructions.\").\n Numbered steps only where the order truly matters and the job is a fixed procedure (\"export the orders, then email the file\"); even then, keep the rules and the job's purpose. It doesn't say how to call a tool: no argument values, query strings or field names unless the work goes wrong without them (the filter that picks the right items, the field that keeps a reply in its thread). Parameters are not argument values: write $name wherever its value is used. Write it so the agent keeps going after each answer or decision. The plan's steps (above) are for you and the person, to pick tools and checkpoints; the skill doesn't repeat them one by one.\n5. Trigger: how a run starts. startMessage is what the agent receives when it starts.\n - schedule: a time or interval (\"every Monday at 9\" is every \"7d\", at \"09:00\", weekday 1).\n - webhook: when something happens in another service that can call a URL (\"when a Stripe dispute comes in\", \"when a GitHub issue is opened\", \"when a Shopify order is paid\", \"when our app sends a new signup\"). Fill in \"webhook\" (below). Prefer it over polling on a schedule whenever the service sends webhooks. The sender gets no result back.\n - on_request: started by a person, from Chat, a message, the Run button or an app's API call. The API call (POST /agents/<agent>/workflows/<id>/run with the parameters and \"wait\": true, using a workspace API key) answers with the run's result text, so when an app wants the result back in its response (\"a button in our dashboard that drafts a reply\", \"our app asks for a summary and shows it\"), use on_request, not webhook: the run's result is the answer, and nothing needs sending through messaging.\n A workflow that runs on a schedule and on an event as well: trigger schedule, and fill in \"webhook\" too.\n webhook: sender (\"stripe\", \"github\", \"shopify\", \"standard\" for Standard Webhooks senders such as Clerk, Resend or Svix, else \"custom\" for the person's own app or any other service); a short name (\"Stripe: new disputes\"); setup: one sentence on what to pick in the sender's webhook settings; filter: which events start a run; mapping: each parameter from a dot path in the payload. What senders send:\n - Stripe: one endpoint can get many event types, so filter path \"type\", values the event names (charge.dispute.created, checkout.session.completed, invoice.payment_failed, customer.subscription.deleted). The object is at data.object: data.object.id, data.object.customer, data.object.amount, data.object.charge.\n - GitHub: the event type is chosen in GitHub's settings (Issues, Pull requests, Pushes), so say it in setup; filter path \"action\", values such as opened, closed, created. Fields: issue.number, issue.title, pull_request.number, repository.full_name, sender.login.\n - Shopify: one webhook per topic (orders/paid, orders/create, customers/create), chosen in Shopify, so say it in setup and use no filter. The body is the object itself: id, name (the order number, like #1001), email, total_price, financial_status.\n - standard: filter path \"type\" (user.created, email.bounced); fields under data (data.id, data.email_addresses).\n - custom: whatever the person's app sends; say in setup what to post (JSON with these fields) and use the paths you described. Set \"header\" when the person names the signature header.\n Every required parameter should come from the payload through mapping; parameters are the only way event details reach the run.\n6. Notify (scheduled and webhook workflows): whether each run's result is sent to the person through the agent's messaging app. true when the result is for them and no step already delivers it (\"tell me\", \"send me\", \"let me know\", a summary or findings that no step posts or emails). false when a step already sends it (posting to a channel, emailing a report): it would arrive twice. false when the work itself is the outcome (answering emails, filing tasks), where a message every run is noise; questions and approvals reach them either way. Say why in one short sentence.\n7. Parameters: if the job is about something that changes from run to run (an order, a ticket, an alert, a customer, a date range), declare it as a parameter: a short snake_case name, a one-line description, and required when a run makes no sense without it. Write $name wherever its value goes, in startMessage and in the skill (\"Check the refund request for order $order_number.\"). A parameter holding long text (an email, a message thread, a log) is different: don't write $name for it anywhere. Each run lists it with the inputs, above the skill, in a block under its description, so give it a description that says what it is (\"The customer's latest email\", \"Earlier messages in the thread, oldest first\"), and in the skill call it by what it is (\"the customer's latest email, above\"). Apps and people fill them in when they start a run. A scheduled job that finds its own work (\"check the inbox every 10 minutes\", \"last week's sales\") needs none. Don't make fixed settings, such as the repository or the channel, parameters: write them into the skill.\n7b. name: a short label for what the workflow does, two or three words: \"Lead scan\", \"Outreach draft\", \"Onboarding nudge\", \"Refund approvals\". Not the result or the goal (\"Reach new leads every week\", \"Fast support\"): when a job asks for this workflow, the job's own title says the result, and the workflow is listed under it by this name.\n8. context: leave it empty. Rules and facts the job needs go in the skill: rules under \"Rules:\", business facts under \"Policies\". A setting the job can't run without (the sheet, the repository, the channel) and the request doesn't give is asked for in gaps, not written as a placeholder.\n9. fit: whether this job is the kind of work the agent does, judged from its name, description and instructions (not its tools or apps: missing ones get added). matches false only when the job is clearly a different line of work (a customer support agent asked to run payroll); a related or broader job still matches, and so does any job for an agent with no description or instructions yet. reason: one short sentence the person reads, naming what the agent does and what the job is (\"Support desk answers customers' questions; this workflow runs payroll.\"); empty when it matches. Plan the workflow fully either way.\n10. Messaging: questions, approvals and results reach the person through the agent's messaging app when they're not in Chat. You don't set it up; if the agent has none, plan as usual and the person sets it up before Create. If the person names a different app (\"send them to me in Slack\") than the agent's messaging app, say in gaps that results will arrive in the agent's app, and that they can change it on the agent's Messaging tab.\n11. output: what the final reply must be, when an app or a person reads it (\"The draft reply only, with nothing before or after it\", \"A line Decision: approve, partial or reject, then the reason\"). Only when the request or the trigger makes the format matter: an app shows or parses it, or a person acts on it. Empty otherwise.\n12. keys: the setting names its abilities need that list_connections or the agents don't show as set (from ability_details settings). Leave out a setting its description calls optional unless the workflow uses what it's for (a setting only for posting, in a workflow that never posts). Not for MCP servers: their keys are asked for on the plan.\n\nThen call save_plan once, with the whole plan. Don't ask the person questions: if something is unclear, plan the most reasonable version and note the assumption in gaps.";
190
190
  export declare function workflowPlannerTools(withMcp?: boolean): ToolSchema[];
191
191
  /** lowercase-hyphenated, 2–40 characters. */
192
192
  export declare function slugify(value: string, fallback?: string): string;
@@ -36,6 +36,7 @@ How to plan:
36
36
  Every required parameter should come from the payload through mapping; parameters are the only way event details reach the run.
37
37
  6. Notify (scheduled and webhook workflows): whether each run's result is sent to the person through the agent's messaging app. true when the result is for them and no step already delivers it ("tell me", "send me", "let me know", a summary or findings that no step posts or emails). false when a step already sends it (posting to a channel, emailing a report): it would arrive twice. false when the work itself is the outcome (answering emails, filing tasks), where a message every run is noise; questions and approvals reach them either way. Say why in one short sentence.
38
38
  7. Parameters: if the job is about something that changes from run to run (an order, a ticket, an alert, a customer, a date range), declare it as a parameter: a short snake_case name, a one-line description, and required when a run makes no sense without it. Write $name wherever its value goes, in startMessage and in the skill ("Check the refund request for order $order_number."). A parameter holding long text (an email, a message thread, a log) is different: don't write $name for it anywhere. Each run lists it with the inputs, above the skill, in a block under its description, so give it a description that says what it is ("The customer's latest email", "Earlier messages in the thread, oldest first"), and in the skill call it by what it is ("the customer's latest email, above"). Apps and people fill them in when they start a run. A scheduled job that finds its own work ("check the inbox every 10 minutes", "last week's sales") needs none. Don't make fixed settings, such as the repository or the channel, parameters: write them into the skill.
39
+ 7b. name: a short label for what the workflow does, two or three words: "Lead scan", "Outreach draft", "Onboarding nudge", "Refund approvals". Not the result or the goal ("Reach new leads every week", "Fast support"): when a job asks for this workflow, the job's own title says the result, and the workflow is listed under it by this name.
39
40
  8. context: leave it empty. Rules and facts the job needs go in the skill: rules under "Rules:", business facts under "Policies". A setting the job can't run without (the sheet, the repository, the channel) and the request doesn't give is asked for in gaps, not written as a placeholder.
40
41
  9. fit: whether this job is the kind of work the agent does, judged from its name, description and instructions (not its tools or apps: missing ones get added). matches false only when the job is clearly a different line of work (a customer support agent asked to run payroll); a related or broader job still matches, and so does any job for an agent with no description or instructions yet. reason: one short sentence the person reads, naming what the agent does and what the job is ("Support desk answers customers' questions; this workflow runs payroll."); empty when it matches. Plan the workflow fully either way.
41
42
  10. Messaging: questions, approvals and results reach the person through the agent's messaging app when they're not in Chat. You don't set it up; if the agent has none, plan as usual and the person sets it up before Create. If the person names a different app ("send them to me in Slack") than the agent's messaging app, say in gaps that results will arrive in the agent's app, and that they can change it on the agent's Messaging tab.
@@ -70,7 +71,7 @@ export function workflowPlannerTools(withMcp = false) {
70
71
  input_schema: {
71
72
  type: 'object',
72
73
  properties: {
73
- name: { type: 'string' },
74
+ name: { type: 'string', description: 'a short label for what it does, two or three words ("Lead scan", "Refund approvals"); not the result a job wants' },
74
75
  id: { type: 'string', description: 'lowercase-hyphenated' },
75
76
  summary: { type: 'string' },
76
77
  trigger: {
package/dist/index.d.ts CHANGED
@@ -128,7 +128,7 @@ export { createTrackedApprover, listApprovals, decideApproval, findApproval } fr
128
128
  export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, AgentNotFoundError, AgentModelError } from './bin/cli.js';
129
129
  export type { AgentTemplateOptions } from './bin/cli.js';
130
130
  export { goalsPageHtml, goalsPageAs, type GoalsPageView } from './web/goals-page.js';
131
- export { GoalError, acceptJob, addJob, assignJob, assignmentMessage, listJob, listJobs, submitJob, MY_JOBS_ID, type ListedJob, chainedRuns, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, type ChainStep, goalView, type AssignmentView, checkBuiltWorkflows, createGoal, deleteGoal, editAmount, generateMore, getGoal, goalContextFrom, listGoals, markBuilt, prepareBuild, readAbout, readGoalSettings, readLeverEvents, setWorkflowState, writeAbout, writeGoalSettings, type Goal, type GoalJob, type GoalJobState, type JobDoer, type GoalWorkflow, type GoalsDeps, type LeverEvent, migrateGoal, migrateGoalFiles } from './web/goals-admin.js';
131
+ export { GoalError, acceptJob, addJob, assignJob, assignmentMessage, listJob, listJobs, submitJob, MY_JOBS_ID, type ListedJob, chainedRuns, jobsByWorkflow, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, type ChainStep, goalView, type AssignmentView, checkBuiltWorkflows, createGoal, deleteGoal, editAmount, generateMore, getGoal, goalContextFrom, listGoals, markBuilt, prepareBuild, readAbout, readGoalSettings, readLeverEvents, setWorkflowState, writeAbout, writeGoalSettings, type Goal, type GoalJob, type GoalJobState, type JobDoer, type GoalWorkflow, type GoalsDeps, type LeverEvent, migrateGoal, migrateGoalFiles } from './web/goals-admin.js';
132
132
  export { sendLeverEvents, sharesLeverStats, startLeverEventsSync } from './web/lever-events-sync.js';
133
133
  export { createAgentNamesReporter, type AgentNamesReporter } from './web/agent-names-sync.js';
134
134
  export { runGoalPipeline, shapeJob, type GoalPlan, type GoalContext, type ShapedJob } from './core/system-agents/goal-planner.js';
@@ -138,5 +138,6 @@ export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, agents
138
138
  export { inboxPageHtml, renderInboxOnlyPage } from './web/inbox-page.js';
139
139
  export { compressResponses, serveConsoleAsset } from './web/response-compression.js';
140
140
  export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
141
- export { workflowsOverview, startsOf, type WorkflowsOverview, type WorkflowOverviewRow } from './web/workflows-overview.js';
141
+ export { homeOverview, workflowsOverview, startsOf, type HomeOverview, type WorkflowsOverview, type WorkflowOverviewRow } from './web/workflows-overview.js';
142
+ export { homePageHtml } from './web/home-page.js';
142
143
  export { listInbox, getInboxCase, timelineOf, type InboxDeps, type InboxItem, type InboxCase, type InboxPending, type InboxStep } from './web/inbox-admin.js';
package/dist/index.js CHANGED
@@ -119,7 +119,7 @@ export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, Agen
119
119
  // playbook, kept current on Cloud by core/playbook-sync.ts: a project's
120
120
  // own adapters/http.ts imports these.
121
121
  export { goalsPageHtml, goalsPageAs } from './web/goals-page.js';
122
- export { GoalError, acceptJob, addJob, assignJob, assignmentMessage, listJob, listJobs, submitJob, MY_JOBS_ID, chainedRuns, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, goalView, checkBuiltWorkflows, createGoal, deleteGoal, editAmount, generateMore, getGoal, goalContextFrom, listGoals, markBuilt, prepareBuild, readAbout, readGoalSettings, readLeverEvents, setWorkflowState, writeAbout, writeGoalSettings, migrateGoal, migrateGoalFiles } from './web/goals-admin.js';
122
+ export { GoalError, acceptJob, addJob, assignJob, assignmentMessage, listJob, listJobs, submitJob, MY_JOBS_ID, chainedRuns, jobsByWorkflow, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, goalView, checkBuiltWorkflows, createGoal, deleteGoal, editAmount, generateMore, getGoal, goalContextFrom, listGoals, markBuilt, prepareBuild, readAbout, readGoalSettings, readLeverEvents, setWorkflowState, writeAbout, writeGoalSettings, migrateGoal, migrateGoalFiles } from './web/goals-admin.js';
123
123
  export { sendLeverEvents, sharesLeverStats, startLeverEventsSync } from './web/lever-events-sync.js';
124
124
  export { createAgentNamesReporter } from './web/agent-names-sync.js';
125
125
  export { runGoalPipeline, shapeJob } from './core/system-agents/goal-planner.js';
@@ -129,5 +129,6 @@ export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, agents
129
129
  export { inboxPageHtml, renderInboxOnlyPage } from './web/inbox-page.js';
130
130
  export { compressResponses, serveConsoleAsset } from './web/response-compression.js';
131
131
  export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
132
- export { workflowsOverview, startsOf } from './web/workflows-overview.js';
132
+ export { homeOverview, workflowsOverview, startsOf } from './web/workflows-overview.js';
133
+ export { homePageHtml } from './web/home-page.js';
133
134
  export { listInbox, getInboxCase, timelineOf } from './web/inbox-admin.js';
@@ -94,6 +94,9 @@ export const agentsConfigPageHtml = `<!doctype html>
94
94
  .wf-row-head { display: grid; grid-template-columns: 14px minmax(0, 1fr) 210px 200px auto; align-items: center; gap: 14px; padding: 12px 16px; cursor: pointer; }
95
95
  .wf-row-head:hover, .wf-row.is-open .wf-row-head { background: var(--surface); }
96
96
  .wf-row-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
97
+ .wf-slug { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; }
98
+ .wf-row-job { font-size: 12.5px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
99
+ .wf-row-job a { color: var(--accent-ink); }
97
100
  .wf-row-caret { width: 7px; height: 7px; border-right: 2px solid var(--ink-muted); border-bottom: 2px solid var(--ink-muted); transform: rotate(-45deg); transition: transform .15s; }
98
101
  .wf-row.is-open .wf-row-caret { transform: rotate(45deg); }
99
102
  .wf-row-main { min-width: 0; display: grid; gap: 2px; }
@@ -1197,7 +1200,7 @@ ${renderMarkdownScript}
1197
1200
 
1198
1201
  function renderWorkflowsHtml(name, workflows) {
1199
1202
  if (!workflows.length) {
1200
- return '<div class="wf-empty-state"><strong>No workflows yet</strong><p>Describe a job in a sentence or two, or start from an example, and it' + String.fromCharCode(8217) + 's planned and set up for you.</p><a class="wf-new-btn" href="/workflows/new?agent=' + encodeURIComponent(name) + '">Build a workflow</a></div>';
1203
+ return '<div class="wf-empty-state"><strong>No workflows yet</strong><p>Say what this agent should do in a sentence or two, or start from an example, and it' + String.fromCharCode(8217) + 's planned and set up for you.</p><a class="wf-new-btn" href="/workflows/new?agent=' + encodeURIComponent(name) + '">Build a workflow</a></div>';
1201
1204
  }
1202
1205
  // Those that need someone first: waiting for a decision, then failed.
1203
1206
  var rank = function (w) { return workflowNeedsDecision(w) ? 0 : (workflowLastRun(w) || {}).status === 'error' ? 1 : 2; };
@@ -1235,7 +1238,9 @@ ${renderMarkdownScript}
1235
1238
  return '<article class="workflow-card wf-row' + (open ? ' is-open' : '') + '" data-workflow="' + escapeHtml(w.id) + '">' +
1236
1239
  '<div class="wf-row-head" role="button" tabindex="0" aria-expanded="' + open + '">' +
1237
1240
  '<span class="wf-row-caret" aria-hidden="true"></span>' +
1238
- '<div class="wf-row-main"><strong>' + escapeHtml(w.title) + '</strong></div>' +
1241
+ '<div class="wf-row-main"><strong class="wf-slug" title="' + escapeHtml(w.title) + '">' + escapeHtml(w.id) + '</strong>' +
1242
+ // The job(s) it does, linking back to each job's page.
1243
+ (w.jobs && w.jobs.length ? '<span class="wf-row-job">For job: ' + w.jobs.map(function (j) { return '<a href="/jobs?job=' + encodeURIComponent(j.id) + '">' + escapeHtml(j.title) + '</a>'; }).join(', ') + '</span>' : '') + '</div>' +
1239
1244
  '<span class="wf-row-starts">' + workflowStartsSummary(w) + '</span>' +
1240
1245
  '<span class="wf-row-last">' + workflowLastRunHtml(last) + '</span>' +
1241
1246
  '<span class="wf-row-actions"><button type="button" class="workflow-triggers-open">Triggers</button><button type="button" class="workflow-edit">Edit</button></span>' +
@@ -1275,7 +1280,7 @@ ${renderMarkdownScript}
1275
1280
  var parts = [];
1276
1281
  if (waiting) parts.push(waiting + ' waiting for a decision');
1277
1282
  if (next) parts.push('next run ' + new Date(next).toLocaleString());
1278
- detailEl.textContent = parts.join(' \u00b7 ') || (workflows.length ? 'Run by hand, by an app or a webhook' : 'Describe a job for this agent to do');
1283
+ detailEl.textContent = parts.join(' \u00b7 ') || (workflows.length ? 'Run by hand, by an app or a webhook' : 'Build a workflow for this agent');
1279
1284
  }
1280
1285
 
1281
1286
  var workflowsRefreshTimer = null;
@@ -1386,7 +1391,7 @@ ${renderMarkdownScript}
1386
1391
  return '<form class="add-source workflow-editor-form">' +
1387
1392
  '<label>Title<input name="title" maxlength="120" value="' + escapeHtml(w.title) + '">' +
1388
1393
  '<span class="hint">ID: <code>' + escapeHtml(w.id) + '</code>, used by the API, schedules and webhooks; it doesn' + String.fromCharCode(8217) + 't change when you edit.</span></label>' +
1389
- '<label>Description <span class="hint">(one line on what this job is; the agent uses it to recognise the job when you ask in Chat)</span>' +
1394
+ '<label>Description <span class="hint">(one line on what this workflow does; the agent uses it to recognise the workflow when you ask in Chat)</span>' +
1390
1395
  '<input name="description" maxlength="500" required value="' + escapeHtml(w.description) + '"></label>' +
1391
1396
  '<h4 class="wf-editor-part">Brief <span class="hint">what the agent reads on every run</span></h4>' +
1392
1397
  '<div class="body-field"><div class="wp-instructions-head"><label for="wpInstructions">Instructions <span class="hint">(everything the agent needs for this job: what to get done, the rules it keeps, and your policies, special cases and examples. It handles each case on its own judgment, so describe the job rather than every step. Read in full on every run; $name puts in a parameter&#39;s value. Chat uses them too.)</span></label>' +
@@ -1438,7 +1443,7 @@ ${renderMarkdownScript}
1438
1443
  // in the card. Closing it any way (Esc, the backdrop, x, Cancel)
1439
1444
  // discards the edits.
1440
1445
  var dialog = document.createElement('dialog');
1441
- dialog.innerHTML = editDialogHtml('<h3>Edit workflow</h3>', '<p>Its title, what it' + String.fromCharCode(8217) + 's for, what the agent follows (the job, its rules, policies, special cases and examples) and the values each run is given.</p>', workflowEditorHtml(w));
1446
+ dialog.innerHTML = editDialogHtml('<h3>Edit workflow</h3>', '<p>Its title, what it' + String.fromCharCode(8217) + 's for, what the agent follows (what to do, its rules, policies, special cases and examples) and the values each run is given.</p>', workflowEditorHtml(w));
1442
1447
  dialog = dialog.firstChild;
1443
1448
  dialog.classList.add('workflow-editor-dialog');
1444
1449
  document.body.appendChild(dialog);
@@ -1820,7 +1825,7 @@ ${renderMarkdownScript}
1820
1825
  var base = '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(id);
1821
1826
  var head = card.querySelector('.wf-row-head');
1822
1827
  head.addEventListener('click', function (ev) {
1823
- if (ev.target.closest('button')) return;
1828
+ if (ev.target.closest('button, a')) return;
1824
1829
  setWorkflowOpen(card, !card.classList.contains('is-open'));
1825
1830
  });
1826
1831
  head.addEventListener('keydown', function (ev) {
@@ -3350,7 +3355,7 @@ ${renderMarkdownScript}
3350
3355
  ? '<div class="body-field">Runs' +
3351
3356
  '<div class="schedule-when"><input type="radio" name="runs" value="workflow" id="runsWorkflow" checked><label for="runsWorkflow">A workflow</label>' +
3352
3357
  '<select name="workflow_id" aria-label="Workflow">' + schedulesWorkflows.map(function (w) {
3353
- return '<option value="' + escapeHtml(w.id) + '">' + escapeHtml(w.title) + '</option>';
3358
+ return '<option value="' + escapeHtml(w.id) + '">' + escapeHtml(w.id) + '</option>';
3354
3359
  }).join('') + '</select></div>' +
3355
3360
  '<div class="workflow-params" id="scheduleParams" style="margin:0 0 4px 22px"></div>' +
3356
3361
  '<p class="hint" style="margin:0 0 4px 22px">Each run follows the workflow&#39;s instructions as they are then, so changing the workflow changes what runs.</p>' +
@@ -5426,7 +5431,7 @@ ${renderMarkdownScript}
5426
5431
  '<div class="tab-panel" data-tab-panel="overview">' + renderOverviewHtml(cfg) + '</div>' +
5427
5432
  // Workflows: the jobs this agent does, each with what starts it.
5428
5433
  '<div class="tab-panel" data-tab-panel="workflows">' +
5429
- '<div class="wf-tab-head"><p class="muted">The jobs this agent does on its own: what it does, the ways to run it (a schedule, a webhook, Run now or an app&#39;s API call) and how its runs went. In Chat it can do them too, when you ask.</p>' +
5434
+ '<div class="wf-tab-head"><p class="muted">What this agent does on its own, as workflows: what each does, the ways to run it (a schedule, a webhook, Run now or an app&#39;s API call) and how its runs went. In Chat it can do them too, when you ask.</p>' +
5430
5435
  '<a class="wf-new-btn" href="/workflows/new?agent=' + encodeURIComponent(cfg.name) + '">Build a workflow</a></div>' +
5431
5436
  '<section id="workflowsSection"><div id="workflowsContent"><p class="hint">Loading&hellip;</p></div></section>' +
5432
5437
  '</div>' +
@@ -249,11 +249,11 @@ export const consoleShellScript = `<script>
249
249
  var currentAgent = page === 'agent-config' && q.get('tab') === 'workflows' ? q.get('agent') : null;
250
250
  var currentId = currentAgent ? q.get('workflow') : null;
251
251
  return cachedFetch('workflows', '/workflows/overview', function (data) {
252
- var list = (data.workflows || []).slice().sort(function (a, b) { return a.title.localeCompare(b.title); });
252
+ var list = (data.workflows || []).slice().sort(function (a, b) { return a.id.localeCompare(b.id); });
253
253
  workflowList.innerHTML = list.length ? list.map(function (w) {
254
254
  var on = w.agent === currentAgent && w.id === currentId;
255
255
  return '<li><a class="le-agent-item le-goal-item" href="/agents/config?agent=' + enc(w.agent) + '&tab=workflows&workflow=' + enc(w.id) + '" title="' + esc(w.title) + ' (' + esc(w.agentLabel) + DOT_SEP + (w.live ? 'Running' : 'Pending') + ')"' + (on ? ' aria-current="page"' : '') + '>' +
256
- '<span class="le-dot ' + (w.live ? 'tint' : 'pending') + '" aria-hidden="true"></span><span class="le-name">' + esc(w.title) + '</span></a></li>';
256
+ '<span class="le-dot ' + (w.live ? 'tint' : 'pending') + '" aria-hidden="true"></span><span class="le-name le-slug">' + esc(w.id) + '</span></a></li>';
257
257
  }).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No workflows yet</span><span></span></li>';
258
258
  });
259
259
  }
@@ -137,6 +137,7 @@ export const devUiCss = `
137
137
  .le-nav-label a.le-nav-head:hover { color: var(--ink); }
138
138
  .le-nav-label a.le-nav-head[aria-current="page"] { color: var(--accent-ink); font-weight: 700; }
139
139
  .le-agent-list.le-goal-list { flex: 0 1 auto; max-height: 34vh; }
140
+ .le-name.le-slug { font-family: var(--font-mono); font-size: 12.5px; }
140
141
  .le-goal-item .le-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
141
142
  .le-agent-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 0 1 auto; max-height: 40vh; min-height: 0; }
142
143
  /* The lists sit together at the top; the rest goes to the bottom. */
@@ -274,6 +274,15 @@ export declare function addJob(deps: GoalsDeps, id: string, input: {
274
274
  }>;
275
275
  /** Adds a job to the person's list, or takes it off (it stays under its goal). */
276
276
  export declare function listJob(deps: GoalsDeps, id: string, jobId: string, on: boolean): Goal;
277
+ /** When a job joined the list: when added, else when it was first built
278
+ * or assigned (jobs built before the list existed). */
279
+ /** The jobs each workflow does, keyed "agent|workflowId": every job
280
+ * (not discarded) that lists it as a doer, for "For job" on the
281
+ * workflow's page. */
282
+ export declare function jobsByWorkflow(deps: GoalsDeps): Map<string, {
283
+ id: string;
284
+ title: string;
285
+ }[]>;
277
286
  export interface ListedJob {
278
287
  goalId: string;
279
288
  /** The goal it came from; null for a job submitted without one. */
@@ -469,6 +469,28 @@ export function listJob(deps, id, jobId, on) {
469
469
  }
470
470
  /** When a job joined the list: when added, else when it was first built
471
471
  * or assigned (jobs built before the list existed). */
472
+ /** The jobs each workflow does, keyed "agent|workflowId": every job
473
+ * (not discarded) that lists it as a doer, for "For job" on the
474
+ * workflow's page. */
475
+ export function jobsByWorkflow(deps) {
476
+ const out = new Map();
477
+ for (const goal of listGoals(deps)) {
478
+ for (const job of goal.jobs) {
479
+ if (job.state === 'discarded')
480
+ continue;
481
+ for (const d of job.doers) {
482
+ if (d.type !== 'workflow')
483
+ continue;
484
+ const key = `${d.agent}|${d.workflowId}`;
485
+ const list = out.get(key) ?? [];
486
+ if (!list.some((j) => j.id === job.id))
487
+ list.push({ id: job.id, title: job.title });
488
+ out.set(key, list);
489
+ }
490
+ }
491
+ }
492
+ return out;
493
+ }
472
494
  function addedWhen(job) {
473
495
  return job.addedAt ?? (job.state === 'active' || job.state === 'done' ? job.doers[0]?.at : undefined);
474
496
  }
@@ -65,6 +65,15 @@ const goalsPageTemplate = `<!doctype html>
65
65
  .gl-job-detail .gl-wf-title { font-size: 17px; }
66
66
  .gl-job-detail .gl-job-body, .gl-job-detail .gl-job-status-line { padding-left: 14px; }
67
67
  .gl-job-link { color: inherit; text-decoration: none; }
68
+ .gl-define { margin: 0; max-width: 72ch; }
69
+ .gl-doneby { display: grid; gap: 3px; justify-items: start; font-size: 13px; margin-top: 4px; }
70
+ .gl-doneby-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
71
+ .gl-doneby-row a { color: var(--ink); font-weight: 600; }
72
+ .gl-slug { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; background: var(--code-bg); padding: 1px 6px; border-radius: 4px; }
73
+ .gl-tag-wf { font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
74
+ .gl-doneby-then { font-size: 12px; color: var(--ink-muted); padding-left: 4px; }
75
+ .gl-agent-pill { font-size: 11.5px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
76
+ .gl-doneby-manage { font-size: 12.5px; color: var(--accent-ink); }
68
77
  .gl-job-link:hover { text-decoration: underline; }
69
78
  .gl-job-main { display: grid; gap: 3px; min-width: 0; }
70
79
  .gl-job-sub { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 12.5px; color: var(--ink-muted); }
@@ -333,17 +342,19 @@ ${consoleShellScript}
333
342
  }
334
343
 
335
344
  // A job: one piece of the goal, with its measure, and what does it.
336
- // A job as one row: its title, kind and one line (why it helps, until
337
- // it's kept; then its measure), its status, and the one action that
338
- // matters now. Click it for the rest: why, what it needs, how it's done,
339
- // and the other actions.
345
+ // A job as one row: its title, kind and one line (its measure, else why
346
+ // it helps), what does it (Done by), its status, and the one action
347
+ // that matters now. Click it for the rest: why, what it needs and the
348
+ // other actions; its own page also manages its workflows.
340
349
  function jobHtml(w, listed) {
350
+ // On its own page a job is shown whole, not folded, with its workflows.
351
+ var detail = jobPage === w.id;
341
352
  var once = w.kind === 'once';
342
353
  var doer = (w.doers || [])[0];
343
354
  var t = lastTry(w);
344
355
  var btn = function (act, label, cls) { return '<button type="button" class="gl-btn ' + (cls || '') + '" data-act="' + act + '">' + label + '</button>'; };
345
- var primary = w.state === 'suggested' && once ? btn('assign', 'Assign')
346
- : w.state === 'suggested' ? btn('build', 'Build it')
356
+ var primary = w.state === 'suggested' && once ? btn('assign', 'Give it to an agent')
357
+ : w.state === 'suggested' ? btn('build', 'Build a workflow')
347
358
  : w.state === 'active' && once && t && t.status === 'done' ? btn('accept', 'Accept')
348
359
  : w.state === 'active' && once && t && (t.status === 'error' || t.status === 'gone') ? btn('again', 'Try again')
349
360
  : w.state === 'discarded' ? btn('restore', 'Restore', 'plain') : '';
@@ -359,18 +370,19 @@ ${consoleShellScript}
359
370
  : w.state === 'active' ? '<span class="gl-state built">Running</span>'
360
371
  : w.state === 'done' ? '<span class="gl-state built">Done</span>'
361
372
  : w.state === 'discarded' ? '<span class="gl-state">Discarded</span>' : '';
362
- var sub = w.state === 'suggested' || w.state === 'discarded' ? (w.why || w.measure || '') : (w.measure ? (once ? '' : 'Measured by ') + w.measure : w.why || '');
373
+ // A job is about its outcome: its measure leads, then why it matters.
374
+ var sub = w.measure ? (once ? '' : 'Measured by ') + w.measure : w.why || '';
363
375
  var doneBy = once && (w.state === 'active' || w.state === 'done') && w.tries && w.tries.length ? triesHtml(w)
364
- : w.state === 'active' && doer && doer.type === 'workflow' ? howHtml(w)
376
+ : w.state === 'active' && doer && doer.type === 'workflow' ? (detail ? howHtml(w) : '')
365
377
  : w.state === 'done' && w.doneAt ? '<div class="gl-doer">Done ' + esc(new Date(w.doneAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) + '</div>' : '';
366
- // On its own page a job is shown whole, not folded.
367
- var detail = jobPage === w.id;
368
378
  var open = detail || !!state.openJobs[w.id];
369
379
  return '<div class="gl-wf gl-job' + (open ? ' is-open' : '') + (detail ? ' gl-job-detail' : '') + (w.state === 'active' || w.state === 'done' ? ' built' : '') + '" data-wf="' + esc(w.id) + '"' + (listed ? ' data-goal="' + esc(listed.goalId) + '"' : '') + '>' +
370
380
  (detail ? '<div class="gl-job-head">' : '<div class="gl-job-head" role="button" tabindex="0" aria-expanded="' + open + '">' +
371
381
  '<span class="gl-caret" aria-hidden="true"></span>') +
372
382
  '<div class="gl-job-main">' + (listed && !detail ? '<a class="gl-wf-title gl-job-link" href="/jobs?job=' + encodeURIComponent(w.id) + '">' + esc(w.title) + '</a>' : '<span class="gl-wf-title">' + esc(w.title) + '</span>') +
373
383
  '<span class="gl-job-sub"><span class="gl-kind">' + (once ? 'One-off' : 'Recurring') + '</span>' + (sub ? '<span class="gl-job-line">' + esc(sub) + '</span>' : '') + '</span>' +
384
+ (!detail && w.state === 'active' && !once && doer && doer.type === 'workflow' ? doneByHtml(w) : '') +
385
+ (!detail && once && (w.state === 'active' || w.state === 'done') && w.tries && w.tries.length ? assignedHtml(w) : '') +
374
386
  (listed ? '<span class="gl-job-from">Added ' + esc(new Date(listed.addedAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })) + ' ' + String.fromCharCode(183) + ' ' +
375
387
  (listed.goal ? 'Goal: <a href="/goals?goal=' + encodeURIComponent(listed.goalId) + '">' + esc(listed.goal) + '</a>' : 'No goal') + '</span>' : '') + '</div>' +
376
388
  '<span class="gl-job-status">' + pill + '<span class="gl-state planning" data-attn hidden>Needs you</span></span>' +
@@ -436,9 +448,37 @@ ${consoleShellScript}
436
448
  // How a recurring job is done: each workflow that does it, on its agent,
437
449
  // with how it starts and how it's doing. The detail (its instructions,
438
450
  // tools, runs) is on the workflow itself: Open.
451
+ // On a job's card: what does it, in one line per workflow, each with
452
+ // how it's going (filled by fillEvidence) and a link to manage them on
453
+ // the job's page.
454
+ function doneByHtml(w) {
455
+ var flows = (w.doers || []).filter(function (d) { return d.type === 'workflow'; });
456
+ // A chained workflow follows the one that starts it, marked "then".
457
+ var after = {};
458
+ (w.chain || []).forEach(function (st) { after[st.run.agent + '|' + st.run.workflowId] = st.after.agent + '|' + st.after.workflowId; });
459
+ var keyOf = function (d) { return d.agent + '|' + d.workflowId; };
460
+ var ordered = flows.filter(function (d) { return !after[keyOf(d)]; });
461
+ for (var i = 0; i < ordered.length; i++) {
462
+ flows.forEach(function (d) { if (after[keyOf(d)] === keyOf(ordered[i]) && ordered.indexOf(d) < 0) ordered.splice(i + 1, 0, d); });
463
+ }
464
+ flows.forEach(function (d) { if (ordered.indexOf(d) < 0) ordered.push(d); });
465
+ return '<span class="gl-doneby">' + ordered.map(function (d, i) {
466
+ var then = i > 0 && after[keyOf(d)] === keyOf(ordered[i - 1]);
467
+ return '<span class="gl-doneby-row" data-how="' + esc(d.agent) + '|' + esc(d.workflowId) + '">' +
468
+ (then ? '<span class="gl-doneby-then">then ' + String.fromCharCode(8594) + '</span>' : '<span class="gl-tag-wf">Workflow</span>') +
469
+ '<a href="/agents/config?agent=' + encodeURIComponent(d.agent) + '&tab=workflows&workflow=' + encodeURIComponent(d.workflowId) + '" class="gl-slug">' + esc(d.workflowId) + '</a>' +
470
+ '<span class="gl-agent-pill">' + esc(d.agent) + '</span><span class="hint" data-how-meta>' + ELLIPSIS + '</span></span>';
471
+ }).join('') + '<a class="gl-doneby-manage" href="/jobs?job=' + encodeURIComponent(w.id) + '">Manage</a></span>';
472
+ }
473
+
474
+ // A one-off job's card: the agent it's assigned to.
475
+ function assignedHtml(w) {
476
+ return '<span class="gl-doneby"><span class="gl-doneby-row"><span class="gl-tag-wf">Assignment</span><span class="gl-agent-pill">' + esc(w.agent.name) + '</span><span class="hint">one run, its result kept with the job</span></span></span>';
477
+ }
478
+
439
479
  function howHtml(w) {
440
480
  var flows = (w.doers || []).filter(function (d) { return d.type === 'workflow'; });
441
- var titleOf = function (r) { var d = flows.filter(function (x) { return x.agent === r.agent && x.workflowId === r.workflowId; })[0]; return d ? d.title : r.workflowId; };
481
+ var titleOf = function (r) { return r.workflowId; };
442
482
  var whenText = function (wh) { return wh.kind === 'always' ? '' : wh.kind === 'contains' ? ', when its result contains ' + String.fromCharCode(8220) + esc(wh.text) + String.fromCharCode(8221) : ', when its result has a line starting ' + String.fromCharCode(8220) + esc(wh.text) + String.fromCharCode(8221); };
443
483
  var chain = (w.chain || []).map(function (st) {
444
484
  var inputs = Object.keys(st.with || {}).map(function (p) { var src = st.with[p]; return esc(p) + ' ' + String.fromCharCode(8592) + ' ' + (src === 'result' ? 'its result' : 'its ' + esc(src.slice(6))); }).join(', ');
@@ -446,7 +486,7 @@ ${consoleShellScript}
446
486
  }).join('');
447
487
  return '<div class="gl-how"><div class="gl-how-head">Workflows</div>' + flows.map(function (d) {
448
488
  return '<div class="gl-how-row" data-how="' + esc(d.agent) + '|' + esc(d.workflowId) + '">' +
449
- '<div class="gl-how-main"><span class="gl-how-wf">' + esc(d.title) + '</span><span class="gl-how-agent">on <strong>' + esc(d.agent) + '</strong></span></div>' +
489
+ '<div class="gl-how-main"><span class="gl-how-wf gl-slug">' + esc(d.workflowId) + '</span><span class="gl-how-agent">on <strong>' + esc(d.agent) + '</strong></span></div>' +
450
490
  '<span class="gl-how-meta" data-how-meta>' + ELLIPSIS + '</span>' +
451
491
  '<span class="gl-how-actions"><a class="gl-how-open" href="/agents/config?agent=' + encodeURIComponent(d.agent) + '&tab=workflows&workflow=' + encodeURIComponent(d.workflowId) + '">Open</a>' +
452
492
  (flows.length > 1 ? '<button type="button" class="gl-link gl-unlink" data-unlink="' + esc(d.agent) + '|' + esc(d.workflowId) + '">Remove</button>' : '') + '</span></div>';
@@ -457,9 +497,9 @@ ${consoleShellScript}
457
497
  '<div class="gl-row"><select class="gl-select" id="addwf-' + esc(w.id) + '" data-pick-workflow><option value="">Loading' + ELLIPSIS + '</option></select><button type="button" class="gl-btn soft" data-act="link">Add it</button></div>' +
458
498
  '<div class="gl-row"><span class="hint">or</span><button type="button" class="gl-link" data-act="another">build a new one for this job</button></div></div>' +
459
499
  '<div class="gl-panel" data-panel="addstep" hidden>' +
460
- '<div class="gl-row"><span class="hint">After</span><select class="gl-select" data-step-after>' + flows.map(function (d) { return '<option value="' + esc(d.agent) + '|' + esc(d.workflowId) + '">' + esc(d.title) + '</option>'; }).join('') + '</select>' +
500
+ '<div class="gl-row"><span class="hint">After</span><select class="gl-select" data-step-after>' + flows.map(function (d) { return '<option value="' + esc(d.agent) + '|' + esc(d.workflowId) + '">' + esc(d.workflowId) + '</option>'; }).join('') + '</select>' +
461
501
  '<span class="hint">finishes</span><select class="gl-select" data-step-when><option value="always">every time</option><option value="contains">when its result contains</option><option value="line_starts">when its result has a line starting</option></select><input class="gl-input" data-step-text placeholder="e.g. Lead:" hidden></div>' +
462
- '<div class="gl-row"><span class="hint">run</span><select class="gl-select" data-step-run>' + flows.map(function (d, i) { return '<option value="' + esc(d.agent) + '|' + esc(d.workflowId) + '"' + (i === 1 ? ' selected' : '') + '>' + esc(d.title) + '</option>'; }).join('') + '</select></div>' +
502
+ '<div class="gl-row"><span class="hint">run</span><select class="gl-select" data-step-run>' + flows.map(function (d, i) { return '<option value="' + esc(d.agent) + '|' + esc(d.workflowId) + '"' + (i === 1 ? ' selected' : '') + '>' + esc(d.workflowId) + '</option>'; }).join('') + '</select></div>' +
463
503
  '<div class="gl-step-inputs" data-step-inputs></div>' +
464
504
  '<div class="gl-row"><button type="button" class="gl-btn soft" data-act="savestep">Save the step</button></div></div>' +
465
505
  '</div>';
@@ -530,6 +570,7 @@ ${consoleShellScript}
530
570
  (here ? jobHtml(here.job, here) : '<p class="gl-empty">This job isn' + String.fromCharCode(8217) + 't on your list any more: it may have been removed or discarded.</p>');
531
571
  }
532
572
  return notice +
573
+ '<p class="hint gl-define">A job is something that needs doing, with a way to tell it' + String.fromCharCode(8217) + 's done. Workflows and agents do jobs: a workflow for a recurring job, an agent for a one-off.</p>' +
533
574
  '<div class="gl-section"><h3>My jobs <span class="gl-count">' + items.length + '</span></h3>' +
534
575
  (items.length ? items.map(function (x) { return jobHtml(x.job, x); }).join('')
535
576
  : '<p class="gl-empty">No jobs yet. <a href="/jobs?new=1">Submit one</a>, or add jobs from a goal' + String.fromCharCode(8217) + 's suggestions with Add to my jobs.</p>') +
@@ -599,7 +640,7 @@ ${consoleShellScript}
599
640
  addJobHtml(planning) +
600
641
  '</div>' +
601
642
  '<div class="gl-section"><h3>Your jobs <span class="gl-count">' + kept.length + '</span></h3>' +
602
- (kept.length ? kept.map(function (w) { return jobHtml(w); }).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>') +
643
+ (kept.length ? kept.map(function (w) { return jobHtml(w); }).join('') : '<p class="gl-empty">Nothing running yet. Build a workflow for a recurring job, or give a one-off job to an agent.</p>') +
603
644
  '</div>' +
604
645
  (discarded.length ? '<div class="gl-section"><button type="button" class="gl-link" id="glShowDiscarded">' + (state.showDiscarded ? 'Hide' : 'Show') + ' discarded (' + discarded.length + ')</button>' +
605
646
  (state.showDiscarded ? discarded.map(function (w) { return jobHtml(w); }).join('') : '') + '</div>' : '') +
@@ -0,0 +1 @@
1
+ export declare const homePageHtml: string;
@@ -0,0 +1,172 @@
1
+ // The console's front page (/): each goal, the jobs that move it, and the
2
+ // workflows that do each job, one tinted level under the other; then jobs
3
+ // with no goal, and workflows no job points to. Its data is
4
+ // homeOverview (web/workflows-overview.ts) behind /home/overview. Every
5
+ // workflow on its own, as a table, stays at /workflows.
6
+ // Like the other console pages, its inline script avoids backslashes and
7
+ // template placeholders, since it lives inside a template literal.
8
+ import { devUiCss } from './dev-ui-styles.js';
9
+ import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
10
+ export const homePageHtml = `<!doctype html>
11
+ <html lang="en">
12
+ <head>
13
+ <meta charset="utf-8">
14
+ <meta name="viewport" content="width=device-width, initial-scale=1">
15
+ <title>Home</title>
16
+ <style>${devUiCss}
17
+ .hm { max-width: 860px; display: grid; gap: 28px;
18
+ --goal: #7a3e8f; --goal-soft: #f3e9f6; --job: #0c7a6a; --job-soft: #e2f1ef;
19
+ --how: #3d5a99; --how-soft: #e8edf8; --agent: #8a5a12; --agent-soft: #f7eedf; }
20
+ @media (prefers-color-scheme: dark) {
21
+ .hm { --goal: #d6a2e6; --goal-soft: #2e1d36; --job: #5cc0b0; --job-soft: #143330;
22
+ --how: #93abe6; --how-soft: #1b2440; --agent: #e0b56a; --agent-soft: #33280f; }
23
+ }
24
+ .hm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
25
+ .hm-stat { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 14px; display: grid; gap: 0; color: var(--ink); text-decoration: none; }
26
+ a.hm-stat:hover { border-color: var(--accent); }
27
+ .hm-stat b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
28
+ .hm-stat span { font-size: 12.5px; color: var(--ink-muted); }
29
+ .hm-stat.warn { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
30
+ .hm-stat.warn b { color: var(--warn); }
31
+ .hm-section { display: grid; gap: 10px; }
32
+ .hm-section h2 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); }
33
+ .hm-tree { display: grid; gap: 8px; }
34
+ .hm-node { border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; }
35
+ .hm-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
36
+ .hm-node strong { font-weight: 600; }
37
+ .hm-node strong a { color: var(--ink); text-decoration: none; }
38
+ .hm-node strong a:hover { text-decoration: underline; }
39
+ .hm-m { font-size: 13px; color: var(--ink-muted); }
40
+ .hm-m a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
41
+ .hm-goal { background: var(--goal-soft); }
42
+ .hm-job { background: var(--job-soft); margin-left: 22px; }
43
+ .hm-how { background: var(--bg); border: 1px solid var(--line); margin-left: 44px; }
44
+ .hm-tree.flat .hm-job { margin-left: 0; }
45
+ .hm-tree.flat .hm-how { margin-left: 22px; }
46
+ .hm-tree.loose .hm-how { margin-left: 0; }
47
+ .hm-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
48
+ .hm-t-goal { background: var(--bg); color: var(--goal); }
49
+ .hm-t-job { background: var(--bg); color: var(--job); }
50
+ .hm-t-how { background: var(--how-soft); color: var(--how); }
51
+ .hm-t-agent { background: var(--agent-soft); color: var(--agent); }
52
+ .hm-t-warn { background: var(--warn-soft); color: var(--warn); }
53
+ .hm-slug { font-family: var(--font-mono); font-size: 13px; background: var(--code-bg); padding: 1px 6px; border-radius: 4px; color: var(--ink); text-decoration: none; }
54
+ a.hm-slug:hover { text-decoration: underline; }
55
+ .hm-new { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; background: var(--accent); color: var(--on-accent); text-decoration: none; white-space: nowrap; }
56
+ .hm-empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px 24px; display: grid; gap: 14px; }
57
+ .hm-empty h2 { margin: 0; font-size: 17px; }
58
+ .hm-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
59
+ .hm-way { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 4px; color: var(--ink); text-decoration: none; background: var(--bg); }
60
+ .hm-way:hover { border-color: var(--accent); }
61
+ .hm-way b { font-size: 14px; }
62
+ .hm-way span { font-size: 12.5px; color: var(--ink-muted); }
63
+ .hint { font-size: 12.5px; color: var(--ink-muted); }
64
+ .error { font-size: 13px; color: var(--bad); margin: 0; }
65
+ @media (max-width: 620px) { .hm-job { margin-left: 10px; } .hm-how { margin-left: 20px; } .hm-tree.flat .hm-how { margin-left: 10px; } }
66
+ </style>
67
+ </head>
68
+ <body data-le-page="home">
69
+ <div class="le-app">
70
+ ${consoleSidebarHtml}
71
+ <main class="le-main">
72
+ <div class="le-head plain">
73
+ <div class="le-head-row">
74
+ <div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
75
+ <div><h1>Home</h1><p>What you want to achieve, the jobs that move it, and the workflows that do them.</p></div>
76
+ </div>
77
+ <a class="hm-new" href="/goals?new=1">New goal</a>
78
+ </div>
79
+ </div>
80
+ <div class="le-scroll"><div class="le-page"><div class="hm" id="hmPage"><p class="hint">Loading&hellip;</p></div></div></div>
81
+ </main>
82
+ </div>
83
+ ${consoleShellScript}
84
+ <script>
85
+ (function () {
86
+ var page = document.getElementById('hmPage');
87
+ var DOT = ' ' + String.fromCharCode(183) + ' ';
88
+ var esc = window.leShell.esc;
89
+
90
+ function wfHref(agent, id) {
91
+ return '/agents/config?agent=' + encodeURIComponent(agent) + '&tab=workflows&workflow=' + encodeURIComponent(id);
92
+ }
93
+ function agentTag(name) { return '<span class="hm-tag hm-t-agent">' + esc(name) + '</span>'; }
94
+
95
+ // How a job is done: its workflows, a chained one marked "then";
96
+ // a one-off job's assignment; or not built yet.
97
+ function howHtml(j) {
98
+ if (j.flows.length) {
99
+ return '<div class="hm-node hm-how">' + j.flows.map(function (f) {
100
+ return '<div class="hm-row">' +
101
+ (f.then ? '<span class="hm-m">then ' + String.fromCharCode(8594) + '</span>' : '<span class="hm-tag hm-t-how">Workflow</span>') +
102
+ '<a class="hm-slug" href="' + wfHref(f.agent, f.id) + '">' + esc(f.id) + '</a>' + agentTag(f.agent) +
103
+ (f.gone ? '<span class="hm-m">no longer on this agent</span>' : f.starts.length ? '<span class="hm-m">' + esc(f.starts.join(DOT)) + '</span>' : '') +
104
+ (f.waiting ? '<a class="hm-tag hm-t-warn" href="/inbox">' + f.waiting + ' waiting</a>' : '') +
105
+ '</div>';
106
+ }).join('') + '</div>';
107
+ }
108
+ if (j.kind === 'once' && (j.state === 'active' || j.state === 'done')) {
109
+ return '<div class="hm-node hm-how"><div class="hm-row"><span class="hm-tag hm-t-how">Assignment</span>' + agentTag(j.agent) + '<span class="hm-m">one run, its result kept with the job</span></div></div>';
110
+ }
111
+ return '<div class="hm-node hm-how"><div class="hm-row"><span class="hm-m">' + (j.kind === 'once' ? 'Not assigned yet' : 'No workflow yet') + DOT + '<a href="/jobs?job=' + encodeURIComponent(j.id) + '">' + (j.kind === 'once' ? 'Give it to an agent' : 'Build a workflow') + '</a></span></div></div>';
112
+ }
113
+
114
+ function jobHtml(j) {
115
+ var once = j.kind === 'once';
116
+ var measure = !j.measure ? '' : once && j.measure.toLowerCase().indexOf('done when') !== 0 ? 'done when: ' + j.measure : once ? j.measure : 'measured by: ' + j.measure;
117
+ return '<div class="hm-node hm-job"><div class="hm-row"><span class="hm-tag hm-t-job">Job</span>' +
118
+ '<strong><a href="/jobs?job=' + encodeURIComponent(j.id) + '">' + esc(j.title) + '</a></strong>' +
119
+ '<span class="hm-m">' + (once ? 'once' : 'recurring') + (j.state === 'done' ? DOT + 'done' : '') + '</span></div>' +
120
+ (measure ? '<span class="hm-m">' + esc(measure) + '</span>' : '') +
121
+ '</div>' + (j.state === 'done' ? '' : howHtml(j));
122
+ }
123
+
124
+ function goalHtml(g) {
125
+ return '<div class="hm-tree">' +
126
+ '<div class="hm-node hm-goal"><div class="hm-row"><span class="hm-tag hm-t-goal">Goal</span><strong><a href="/goals?goal=' + encodeURIComponent(g.id) + '">' + esc(g.goal) + '</a></strong></div>' +
127
+ (g.measure ? '<span class="hm-m">measured by: ' + esc(g.measure) + '</span>' : '') + '</div>' +
128
+ (g.jobs.length ? g.jobs.map(jobHtml).join('') : '<div class="hm-node hm-job"><span class="hm-m">No jobs picked yet' + DOT + '<a href="/goals?goal=' + encodeURIComponent(g.id) + '">See its suggestions</a></span></div>') +
129
+ '</div>';
130
+ }
131
+
132
+ function looseHtml(w) {
133
+ return '<div class="hm-node hm-how"><div class="hm-row"><span class="hm-tag hm-t-how">Workflow</span>' +
134
+ '<a class="hm-slug" href="' + wfHref(w.agent, w.id) + '">' + esc(w.id) + '</a>' + agentTag(w.agent) +
135
+ '<span class="hm-m">' + esc(w.starts.join(DOT)) + '</span>' +
136
+ (w.waiting ? '<a class="hm-tag hm-t-warn" href="/inbox">' + w.waiting + ' waiting</a>' : '') + '</div></div>';
137
+ }
138
+
139
+ function renderEmpty() {
140
+ page.innerHTML =
141
+ '<div class="hm-empty"><h2>Nothing set up yet</h2>' +
142
+ '<p class="hint" style="margin:0">Say what you want to achieve and LoopEngine breaks it into jobs, each done by an agent. Or go straight to a workflow: how an agent does something again and again.</p>' +
143
+ '<div class="hm-ways">' +
144
+ '<a class="hm-way" href="/goals?new=1"><b>Start from a goal</b><span>Get jobs suggested for what you want to achieve.</span></a>' +
145
+ '<a class="hm-way" href="/jobs?new=1"><b>Add a job</b><span>Something that needs doing, in your own words.</span></a>' +
146
+ '<a class="hm-way" href="/workflows/new"><b>Build a workflow</b><span>Say what the agent should do, or start from an example.</span></a>' +
147
+ '</div></div>';
148
+ }
149
+
150
+ function render(d) {
151
+ if (!d.goals.length && !d.jobs.length && !d.workflows.length) return renderEmpty();
152
+ var s = d.summary;
153
+ var html =
154
+ '<div class="hm-stats">' +
155
+ '<a class="hm-stat' + (s.waiting ? ' warn' : '') + '" href="/inbox"><b>' + s.waiting + '</b><span>' + (s.waiting === 1 ? 'Case waiting for you' : 'Cases waiting for you') + '</span></a>' +
156
+ '<a class="hm-stat" href="/workflows"><b>' + s.runsThisWeek + '</b><span>Runs in the last 7 days</span></a>' +
157
+ '<a class="hm-stat" href="/workflows"><b>' + s.failedThisWeek + '</b><span>Failed in the last 7 days</span></a>' +
158
+ '</div>';
159
+ if (d.goals.length) html += '<div class="hm-section"><h2>Goals</h2>' + d.goals.map(goalHtml).join('') + '</div>';
160
+ if (d.jobs.length) html += '<div class="hm-section"><h2>' + (d.goals.length ? 'Jobs without a goal' : 'Jobs') + '</h2><div class="hm-tree flat">' + d.jobs.map(jobHtml).join('') + '</div></div>';
161
+ if (d.loose.length) html += '<div class="hm-section"><h2>' + (d.goals.length || d.jobs.length ? 'Workflows not in a job' : 'Workflows') + '</h2><div class="hm-tree loose">' + d.loose.map(looseHtml).join('') + '</div></div>';
162
+ page.innerHTML = html;
163
+ }
164
+
165
+ fetch('/home/overview', { cache: 'no-store' })
166
+ .then(function (r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })
167
+ .then(render)
168
+ .catch(function (err) { page.innerHTML = '<p class="error">Couldn' + String.fromCharCode(8217) + 't load your home page: ' + esc(err.message) + '</p>'; });
169
+ })();
170
+ </script>
171
+ </body>
172
+ </html>`;
@@ -531,8 +531,8 @@ ${consoleShellScript}
531
531
  : '') +
532
532
  paramsSectionHtml(p) +
533
533
  '<h3>What it will use</h3>' +
534
- '<p class="hint" style="margin:0">The tools for each part of the job, and where you decide. The agent works out the order for each case from its instructions, below.</p>' +
535
- '<div class="le-table-wrap"><table class="wf-steps"><thead><tr><th>Part of the job</th><th>Uses</th><th>Checkpoint</th></tr></thead><tbody>' + p.steps.map(stepRow).join('') + '</tbody></table></div>' +
534
+ '<p class="hint" style="margin:0">The tools for each step, and where you decide. The agent works out the order for each case from its instructions, below.</p>' +
535
+ '<div class="le-table-wrap"><table class="wf-steps"><thead><tr><th>Step</th><th>Uses</th><th>Checkpoint</th></tr></thead><tbody>' + p.steps.map(stepRow).join('') + '</tbody></table></div>' +
536
536
  (p.abilities.length ? '<h3>Abilities it uses</h3><ul class="wf-list">' + p.abilities.map(function (a) { return '<li><code>' + esc(a) + '</code></li>'; }).join('') + '</ul>' + (state.canInstall ? '' : '<p class="hint">Installing abilities needs LOOPENGINE_ADMIN_AUTH set; otherwise they head the checklist.</p>') : '') +
537
537
  (p.skills && p.skills.length ? '<h3>Skills it comes with</h3><ul class="wf-list">' + p.skills.map(function (sk) { return '<li><code>' + esc(sk.id) + '</code> <span class="hint">' + esc(sk.description) + '</span></li>'; }).join('') + '</ul><p class="hint" style="margin:0">An agent that already has one keeps its own.</p>' : '') +
538
538
  (p.keys.length ? '<h3>Keys it needs</h3><p class="hint" style="margin:0">' + p.keys.map(esc).join(', ') + ' ' + DASH + ' you add them after, from the checklist.</p>' : '') +
@@ -540,14 +540,14 @@ ${consoleShellScript}
540
540
  contractExtrasHtml(p) +
541
541
  '</div>' +
542
542
  '<div class="wf-card"><h3 style="margin:0">Goes into ' + esc(agentLabel(agent)) + '</h3>' +
543
- (context ? '<div class="wf-instructions"><label for="wfContext"><strong>Rules and facts for this workflow</strong> <span class="hint">Short facts the job needs that the agent' + String.fromCharCode(8217) + 's own instructions don' + String.fromCharCode(8217) + 't say, like your company' + String.fromCharCode(8217) + 's name or who signs messages. They go at the top of this workflow' + String.fromCharCode(8217) + 's instructions. It' + String.fromCharCode(8217) + 's left empty when the agent already knows enough. Longer rules, special cases and examples go in the instructions, below.</span></label>' +
543
+ (context ? '<div class="wf-instructions"><label for="wfContext"><strong>Rules and facts for this workflow</strong> <span class="hint">Short facts the workflow needs that the agent' + String.fromCharCode(8217) + 's own instructions don' + String.fromCharCode(8217) + 't say, like your company' + String.fromCharCode(8217) + 's name or who signs messages. They go at the top of this workflow' + String.fromCharCode(8217) + 's instructions. It' + String.fromCharCode(8217) + 's left empty when the agent already knows enough. Longer rules, special cases and examples go in the instructions, below.</span></label>' +
544
544
  '<textarea id="wfContext">' + esc(context) + '</textarea></div>' : '') +
545
545
  (conflicts.length ? '<p class="hint" style="margin:0"><strong>Kept as they are:</strong> ' + conflicts.map(function (c) { return '<code>' + esc(c.tool) + '</code> stays ' + esc(LABELS[c.has]) + ' (the workflow wants ' + esc(LABELS[c.wants]) + ')'; }).join('; ') + '. Change them in Permissions if you want.</p>' : '') +
546
546
  '<p class="hint" style="margin:0">It keeps every decision the agent already has.</p>' +
547
547
  (misfit && !fitPending ? '<p class="hint" style="margin:0">You chose to add it here, though it' + String.fromCharCode(8217) + 's not this agent' + String.fromCharCode(8217) + 's usual work.</p>' : '') +
548
548
  '</div>' +
549
549
  needsHtml(reqs) +
550
- '<div class="wf-part"><h3>Brief</h3><span class="hint">What the agent reads on every run: the job, its rules, and what it needs to know about your business.</span></div>' +
550
+ '<div class="wf-part"><h3>Brief</h3><span class="hint">What the agent reads on every run: what to do, its rules, and what it needs to know about your business.</span></div>' +
551
551
  '<div class="wf-card"><label for="wfSkill"><strong>Instructions</strong> <span class="hint">(what the agent gets done, the rules it keeps, and what it needs to know about your business. Add your policies and special cases with the buttons below: the agent only knows what' + String.fromCharCode(8217) + 's written here. Saved as its skill <code>' + esc(p.id) + '</code>; edit them here, or later from the workflow' + String.fromCharCode(8217) + 's Edit.)</span></label>' +
552
552
  '<textarea id="wfSkill" class="wf-skill-edit">' + esc(p.skill.body) + '</textarea>' +
553
553
  '<div class="wp-sections"><span class="hint">Add a section:</span>' + workflowSectionButtonsHtml() + '</div>' +
@@ -28,6 +28,7 @@ export const workflowsOverviewPageHtml = `<!doctype html>
28
28
  .wo-head { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); background: var(--surface); }
29
29
  .wo-head:hover { background: var(--surface); }
30
30
  .wo-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
31
+ .wo-slug { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
31
32
  .wo-sub { font-size: 12.5px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
32
33
  .wo-runs { font-size: 13px; display: grid; gap: 2px; }
33
34
  .wo-side { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
@@ -58,7 +59,7 @@ ${consoleSidebarHtml}
58
59
  <div class="le-head plain">
59
60
  <div class="le-head-row">
60
61
  <div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
61
- <div><h1>Workflows</h1><p>Every job your agents run: how each one starts, how it's been going, and what's waiting for you.</p></div>
62
+ <div><h1>Workflows</h1><p>Every workflow your agents run: how each one starts, how it's been going, and what's waiting for you.</p></div>
62
63
  </div>
63
64
  <a class="wo-new" href="/workflows/new">New workflow</a>
64
65
  </div>
@@ -99,10 +100,10 @@ ${consoleShellScript}
99
100
  function renderEmpty() {
100
101
  page.innerHTML =
101
102
  '<div class="wo-empty"><h2>No workflows yet</h2>' +
102
- '<p class="hint" style="margin:0">A workflow is a job an agent does again and again: it runs on a schedule, from a webhook or from your app, asks you when it needs to, and every run is kept to check and improve.</p>' +
103
+ '<p class="hint" style="margin:0">A workflow is how an agent does something again and again: it runs on a schedule, from a webhook or from your app, asks you when it needs to, and every run is kept to check and improve.</p>' +
103
104
  '<div class="wo-ways">' +
104
- '<a class="wo-way" href="/workflows/new"><b>Describe a workflow</b><span>Write the job in a sentence or two and review the plan.</span></a>' +
105
- '<a class="wo-way" href="/workflows/new#examples"><b>Start from an example</b><span>A ready-made workflow for a common job.</span></a>' +
105
+ '<a class="wo-way" href="/workflows/new"><b>Describe a workflow</b><span>Say what the agent should do in a sentence or two and review the plan.</span></a>' +
106
+ '<a class="wo-way" href="/workflows/new#examples"><b>Start from an example</b><span>A ready-made workflow for a common task.</span></a>' +
106
107
  '<a class="wo-way" href="/goals?new=1"><b>Start from a goal</b><span>Not sure what to automate? Get jobs suggested for what you want to achieve.</span></a>' +
107
108
  '</div></div>';
108
109
  }
@@ -120,7 +121,7 @@ ${consoleShellScript}
120
121
  var rows = d.workflows.map(function (w) {
121
122
  var decided = w.approved + w.refused;
122
123
  return '<a class="wo-row" href="' + href(w) + '">' +
123
- '<span style="min-width:0"><div class="wo-title">' + esc(w.title) + '</div><div class="wo-sub">' + esc(w.agentLabel) + '</div></span>' +
124
+ '<span style="min-width:0"><div class="wo-title wo-slug" title="' + esc(w.title) + '">' + esc(w.id) + '</div><div class="wo-sub">' + esc(w.agentLabel) + '</div></span>' +
124
125
  '<span class="wo-col-starts wo-sub" title="' + esc(w.starts.join(', ')) + '">' + esc(w.starts.join(DOT)) + '</span>' +
125
126
  '<span class="wo-col-runs wo-runs"><span>' + plural(w.runsThisWeek, 'run', 'runs') + ' this week' + (w.failedThisWeek ? ', <span style="color:var(--bad)">' + w.failedThisWeek + ' failed</span>' : '') + '</span>' +
126
127
  '<span class="wo-sub">' + (w.lastRun ? 'Last ' + esc(ago(w.lastRun.at)) : 'Not run yet') + (decided ? DOT + w.approved + ' of ' + decided + ' approved' : '') + '</span></span>' +
@@ -1,6 +1,7 @@
1
1
  import type { WorkflowRun } from '../core/workflow-runs.js';
2
2
  import type { InboxItem } from './inbox-admin.js';
3
3
  import type { AgentWorkflowView } from './workflow-admin.js';
4
+ import type { Goal, GoalJob } from './goals-admin.js';
4
5
  export interface WorkflowOverviewRow {
5
6
  agent: string;
6
7
  agentLabel: string;
@@ -45,3 +46,40 @@ export declare function workflowsOverview(input: {
45
46
  waiting: InboxItem[];
46
47
  now?: Date;
47
48
  }): WorkflowsOverview;
49
+ export interface HomeFlow {
50
+ agent: string;
51
+ id: string;
52
+ starts: string[];
53
+ waiting: number;
54
+ /** Started by the workflow listed before it, when that one finishes. */
55
+ then: boolean;
56
+ /** No longer on its agent. */
57
+ gone?: true;
58
+ }
59
+ export interface HomeJob {
60
+ id: string;
61
+ title: string;
62
+ kind: 'recurring' | 'once';
63
+ measure: string;
64
+ state: string;
65
+ agent: string;
66
+ flows: HomeFlow[];
67
+ }
68
+ export interface HomeOverview extends WorkflowsOverview {
69
+ goals: {
70
+ id: string;
71
+ goal: string;
72
+ measure: string;
73
+ jobs: HomeJob[];
74
+ }[];
75
+ jobs: HomeJob[];
76
+ loose: WorkflowOverviewRow[];
77
+ }
78
+ type TreeJob = Pick<GoalJob, 'id' | 'title' | 'kind' | 'measure' | 'state' | 'agent' | 'doers' | 'chain' | 'addedAt'>;
79
+ export declare function homeOverview(overview: WorkflowsOverview, goals: (Pick<Goal, 'id' | 'goal' | 'standalone'> & {
80
+ brief?: {
81
+ measure?: string;
82
+ };
83
+ jobs: TreeJob[];
84
+ })[]): HomeOverview;
85
+ export {};
@@ -43,3 +43,38 @@ export function workflowsOverview(input) {
43
43
  },
44
44
  };
45
45
  }
46
+ export function homeOverview(overview, goals) {
47
+ const rows = new Map(overview.workflows.map((r) => [`${r.agent}|${r.id}`, r]));
48
+ const used = new Set();
49
+ const toJob = (j) => {
50
+ const flows = j.doers.flatMap((d) => (d.type === 'workflow' ? [`${d.agent}|${d.workflowId}`] : []));
51
+ const after = new Map((j.chain ?? []).map((st) => [`${st.run.agent}|${st.run.workflowId}`, `${st.after.agent}|${st.after.workflowId}`]));
52
+ const ordered = flows.filter((k) => !after.has(k) || !flows.includes(after.get(k)));
53
+ for (let i = 0; i < ordered.length; i++)
54
+ for (const k of flows)
55
+ if (after.get(k) === ordered[i] && !ordered.includes(k))
56
+ ordered.splice(i + 1, 0, k);
57
+ for (const k of flows)
58
+ if (!ordered.includes(k))
59
+ ordered.push(k);
60
+ return {
61
+ id: j.id,
62
+ title: j.title,
63
+ kind: j.kind,
64
+ measure: j.measure,
65
+ state: j.state,
66
+ agent: j.agent.name,
67
+ flows: ordered.map((k, i) => {
68
+ used.add(k);
69
+ const [agent, id] = k.split('|');
70
+ const row = rows.get(k);
71
+ return { agent, id, starts: row?.starts ?? [], waiting: row?.waiting ?? 0, then: i > 0 && after.get(k) === ordered[i - 1], ...(row ? {} : { gone: true }) };
72
+ }),
73
+ };
74
+ };
75
+ // A goal's suggestions not taken up yet stay on its own page.
76
+ const shown = (j, standalone) => j.state !== 'discarded' && (standalone || j.state === 'active' || j.state === 'done' || Boolean(j.addedAt));
77
+ const tree = goals.filter((g) => !g.standalone).map((g) => ({ id: g.id, goal: g.goal, measure: g.brief?.measure ?? '', jobs: g.jobs.filter((j) => shown(j, false)).map(toJob) }));
78
+ const jobs = goals.filter((g) => g.standalone).flatMap((g) => g.jobs.filter((j) => shown(j, true)).map(toJob));
79
+ return { ...overview, goals: tree, jobs, loose: overview.workflows.filter((r) => !used.has(`${r.agent}|${r.id}`)) };
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.3.96",
3
+ "version": "0.3.97",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",