loopengine 0.4.11 → 0.4.13

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.
@@ -45,6 +45,16 @@ export interface PlannedMcpServer {
45
45
  /** The workspace already has an ability made from this server. */
46
46
  existing?: string;
47
47
  }
48
+ export interface PlannedCriterion {
49
+ text: string;
50
+ kind: 'judge' | 'contains' | 'not_contains' | 'tool_called' | 'tool_not_called';
51
+ value?: string;
52
+ }
53
+ /** A plan's success criteria, tidied: words, a known kind, at most 8; a
54
+ * phrase check with no phrase, or a tool check for a tool the workflow
55
+ * doesn't use, is judged by reading instead. Also used on a plan edited
56
+ * before Create. */
57
+ export declare function planCriteria(raw: unknown, tools: string[]): PlannedCriterion[];
48
58
  export interface WorkflowPlan {
49
59
  name: string;
50
60
  /** lowercase-hyphenated: the workflow's id and its skill's folder. */
@@ -124,6 +134,10 @@ export interface WorkflowPlan {
124
134
  };
125
135
  /** What the workspace can't do yet, in plain words. */
126
136
  gaps: string[];
137
+ /** Yes or no checks a good result meets, specific to this workflow:
138
+ * saved as its success criteria on Create (web/workflow-evidence.ts),
139
+ * edited on the plan first. */
140
+ successCriteria?: PlannedCriterion[];
127
141
  /** MCP servers its steps use, set up on Create (filled in after planning). */
128
142
  mcpServers?: PlannedMcpServer[];
129
143
  /** Connected apps it adds to the agent, with just the tools its steps
@@ -186,7 +200,7 @@ export interface WorkflowPlannerTools {
186
200
  /** A server's tools, when it can be listed without a key (or with one already set). */
187
201
  mcpServerTools?(id: string): Promise<unknown>;
188
202
  }
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.";
203
+ 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.\n13. successCriteria: three to six yes or no checks a good result of THIS workflow meets: what a person reviewing a run would check before using it. Each checks one thing, in a short statement under 20 words true of a good result, specific to this job and taken from the request and the skill's rules (\"The reply gives the order's tracking number\", \"Every disputed charge has the delivery photo attached\", \"It never offers more than a full refund\"); never generic (\"The response is helpful\", \"It is accurate\"), and never a requirement the request doesn't imply. kind: \"judge\" for a statement a reviewer decides by reading the result (most); \"contains\" / \"not_contains\" with value only for exact words the request names (a sign-off, a banned phrase); \"tool_called\" / \"tool_not_called\" with value only for a tool in your steps the job must or mustn't use.\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
204
  export declare function workflowPlannerTools(withMcp?: boolean): ToolSchema[];
191
205
  /** lowercase-hyphenated, 2–40 characters. */
192
206
  export declare function slugify(value: string, fallback?: string): string;
@@ -1,3 +1,26 @@
1
+ /** A plan's success criteria, tidied: words, a known kind, at most 8; a
2
+ * phrase check with no phrase, or a tool check for a tool the workflow
3
+ * doesn't use, is judged by reading instead. Also used on a plan edited
4
+ * before Create. */
5
+ export function planCriteria(raw, tools) {
6
+ const known = new Set(tools.map((t) => t.toLowerCase()));
7
+ const kinds = ['judge', 'contains', 'not_contains', 'tool_called', 'tool_not_called'];
8
+ const seen = new Set();
9
+ return (Array.isArray(raw) ? raw : []).flatMap((x) => {
10
+ const c = (x ?? {});
11
+ const text = typeof c.text === 'string' ? c.text.trim().slice(0, 300) : '';
12
+ let kind = (kinds.includes(c.kind) ? c.kind : 'judge');
13
+ const value = typeof c.value === 'string' ? c.value.trim().slice(0, 300) : '';
14
+ if ((kind === 'tool_called' || kind === 'tool_not_called') && !known.has(value.toLowerCase()))
15
+ kind = 'judge';
16
+ if ((kind === 'contains' || kind === 'not_contains') && !value)
17
+ kind = 'judge';
18
+ if (!text || seen.has(text.toLowerCase()))
19
+ return [];
20
+ seen.add(text.toLowerCase());
21
+ return [{ text, kind, ...(kind !== 'judge' ? { value } : {}) }];
22
+ }).slice(0, 8);
23
+ }
1
24
  const MAX_TOOL_ROUNDS = 12;
2
25
  export 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.
3
26
 
@@ -41,6 +64,7 @@ How to plan:
41
64
  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.
42
65
  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.
43
66
  11. 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.
67
+ 13. successCriteria: three to six yes or no checks a good result of THIS workflow meets: what a person reviewing a run would check before using it. Each checks one thing, in a short statement under 20 words true of a good result, specific to this job and taken from the request and the skill's rules ("The reply gives the order's tracking number", "Every disputed charge has the delivery photo attached", "It never offers more than a full refund"); never generic ("The response is helpful", "It is accurate"), and never a requirement the request doesn't imply. kind: "judge" for a statement a reviewer decides by reading the result (most); "contains" / "not_contains" with value only for exact words the request names (a sign-off, a banned phrase); "tool_called" / "tool_not_called" with value only for a tool in your steps the job must or mustn't use.
44
68
  12. 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.
45
69
 
46
70
  Then 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.`;
@@ -120,8 +144,13 @@ export function workflowPlannerTools(withMcp = false) {
120
144
  output: { type: 'string', description: 'what the final reply must be, when an app or person reads it; empty otherwise' },
121
145
  fit: { type: 'object', properties: { matches: { type: 'boolean' }, reason: { type: 'string' } }, required: ['matches', 'reason'] },
122
146
  gaps: { type: 'array', items: { type: 'string' } },
147
+ successCriteria: {
148
+ type: 'array',
149
+ description: 'three to six yes or no checks a good result of this workflow meets, specific to it',
150
+ items: { type: 'object', properties: { text: { type: 'string' }, kind: { type: 'string', enum: ['judge', 'contains', 'not_contains', 'tool_called', 'tool_not_called'] }, value: { type: 'string' } }, required: ['text', 'kind'] },
151
+ },
123
152
  },
124
- required: ['name', 'summary', 'trigger', 'steps', 'rules', 'skill', 'startMessage', 'fit'],
153
+ required: ['name', 'summary', 'trigger', 'steps', 'rules', 'skill', 'startMessage', 'fit', 'successCriteria'],
125
154
  },
126
155
  },
127
156
  ];
@@ -234,6 +263,7 @@ export function validateWorkflowPlan(raw) {
234
263
  ...(str(r.output, 2000) ? { output: str(r.output, 2000) } : {}),
235
264
  ...(r.fit ? { fit: planFit(r.fit) } : {}),
236
265
  gaps: [...gaps, ...planned.notes].slice(0, 12),
266
+ successCriteria: planCriteria(r.successCriteria, [...steps.flatMap((s) => (s.tool ? [s.tool] : [])), ...rules.map((x) => x.tool)]),
237
267
  };
238
268
  }
239
269
  const SENDERS = ['stripe', 'github', 'shopify', 'standard', 'custom'];
package/dist/index.d.ts CHANGED
@@ -93,7 +93,7 @@ export { TemplateError, createFromTemplate, createFromTemplateObject, describeTe
93
93
  export { STARTER_TEMPLATES, starterTemplate, templateScheduleStart, type StarterTemplate, type TemplateRule, type TemplateSchedule, type TemplateSetup, type TemplateSkill, } from './core/system-agents/templates.js';
94
94
  export { workflowPageHtml } from './web/workflow-page.js';
95
95
  export { WorkflowError, checkWorkflowForAgent, checkWorkflowRequirements, createWorkflow, forgetWorkflow, forgetAgent, type ForgottenAgent, migrateAgentWorkflows, getPlanJob, listAgentWorkflows, noteForExistingAgent, planWorkflow, resolveConnections, prepareWorkflowRun, updateWorkflow, updateWorkflowMessages, startPlanJob, type AgentWorkflowView, type CreatedWorkflow, type PlanJob, type PlannedWorkflow, type WorkflowAgentInfo, type WorkflowAppStatus, type WorkflowCheck, type WorkflowPlanDeps, type WorkflowRequirement, type WorkflowConflict, type WorkflowCreateDeps, type WorkflowMcpDeps, type WorkflowMcpCreateDeps, resolveMcpServers, prepareMcpAbilities, moveScheduleResultsToWorkflows, postWorkflowResults } from './web/workflow-admin.js';
96
- export { WORKFLOW_PLANNER_PROMPT, planParameters, planWorkflowWithModel, validateWorkflowPlan, workflowTemplate, type WorkflowPlan, type WorkflowPlannerTools, type WorkflowStep } from './core/system-agents/workflow-planner.js';
96
+ export { WORKFLOW_PLANNER_PROMPT, planCriteria, planParameters, planWorkflowWithModel, validateWorkflowPlan, workflowTemplate, type WorkflowPlan, type WorkflowPlannerTools, type WorkflowStep, type PlannedCriterion } from './core/system-agents/workflow-planner.js';
97
97
  export { WORKFLOW_EXAMPLES, workflowExample, type WorkflowExample } from './core/system-agents/workflow-examples.js';
98
98
  export { WORKFLOW_EXAMPLE_MESSAGES, type WorkflowExampleMessage } from './core/system-agents/workflow-example-messages.js';
99
99
  export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError, type WorkflowTrigger, type PublicTrigger, type TriggerSettings, type TriggerVerify, type TriggerFilter, type TriggerSender, type SignatureAlgorithm, type TriggerDelivery, type TriggerOutcome, type TriggerStore } from './core/workflow-triggers.js';
@@ -135,7 +135,7 @@ export { createTrackedApprover, listApprovals, decideApproval, findApproval } fr
135
135
  export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, AgentNotFoundError, AgentModelError } from './bin/cli.js';
136
136
  export type { AgentTemplateOptions } from './bin/cli.js';
137
137
  export { goalsPageHtml, goalsPageAs, type GoalsPageView } from './web/goals-page.js';
138
- 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';
138
+ export { GoalError, addJob, chainedRuns, jobsByWorkflow, chainConditionMet, checkChain, editJob, MAX_CHAIN_DEPTH, type ChainStep, goalView, 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';
139
139
  export { sendLeverEvents, sharesLeverStats, startLeverEventsSync } from './web/lever-events-sync.js';
140
140
  export { createAgentNamesReporter, type AgentNamesReporter } from './web/agent-names-sync.js';
141
141
  export { runGoalPipeline, shapeJob, type GoalPlan, type GoalContext, type ShapedJob } from './core/system-agents/goal-planner.js';
package/dist/index.js CHANGED
@@ -86,7 +86,7 @@ export { TemplateError, createFromTemplate, createFromTemplateObject, describeTe
86
86
  export { STARTER_TEMPLATES, starterTemplate, templateScheduleStart, } from './core/system-agents/templates.js';
87
87
  export { workflowPageHtml } from './web/workflow-page.js';
88
88
  export { WorkflowError, checkWorkflowForAgent, checkWorkflowRequirements, createWorkflow, forgetWorkflow, forgetAgent, migrateAgentWorkflows, getPlanJob, listAgentWorkflows, noteForExistingAgent, planWorkflow, resolveConnections, prepareWorkflowRun, updateWorkflow, updateWorkflowMessages, startPlanJob, resolveMcpServers, prepareMcpAbilities, moveScheduleResultsToWorkflows, postWorkflowResults } from './web/workflow-admin.js';
89
- export { WORKFLOW_PLANNER_PROMPT, planParameters, planWorkflowWithModel, validateWorkflowPlan, workflowTemplate } from './core/system-agents/workflow-planner.js';
89
+ export { WORKFLOW_PLANNER_PROMPT, planCriteria, planParameters, planWorkflowWithModel, validateWorkflowPlan, workflowTemplate } from './core/system-agents/workflow-planner.js';
90
90
  export { WORKFLOW_EXAMPLES, workflowExample } from './core/system-agents/workflow-examples.js';
91
91
  export { WORKFLOW_EXAMPLE_MESSAGES } from './core/system-agents/workflow-example-messages.js';
92
92
  export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError } from './core/workflow-triggers.js';
@@ -126,7 +126,7 @@ export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, Agen
126
126
  // playbook, kept current on Cloud by core/playbook-sync.ts: a project's
127
127
  // own adapters/http.ts imports these.
128
128
  export { goalsPageHtml, goalsPageAs } from './web/goals-page.js';
129
- 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';
129
+ export { GoalError, addJob, 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';
130
130
  export { sendLeverEvents, sharesLeverStats, startLeverEventsSync } from './web/lever-events-sync.js';
131
131
  export { createAgentNamesReporter } from './web/agent-names-sync.js';
132
132
  export { runGoalPipeline, shapeJob } from './core/system-agents/goal-planner.js';
@@ -1413,7 +1413,7 @@ ${renderMarkdownScript}
1413
1413
  (workflowPageId ? '<section class="wf-section"><div class="wf-audit-tools"><a class="primary" href="/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/audit/report">Open the report</a><a href="' + auditHref + '">See everything in Audit ' + String.fromCharCode(8594) + '</a></div></section>' : '');
1414
1414
  }
1415
1415
 
1416
- // The Evaluation tab: the checklist, the eval cases (saved, then
1416
+ // The Evaluation tab: the success criteria, the eval cases (saved, then
1417
1417
  // suggested from real runs), and Evaluate.
1418
1418
  function workflowEvaluationHtml(w) {
1419
1419
  var evals = w.evals || { cases: [], criteria: [], rounds: [] };
@@ -1428,16 +1428,16 @@ ${renderMarkdownScript}
1428
1428
  var pill = !r || !r.total ? '' : '<span class="le-pill ' + (r.passed === r.total ? 'good' : r.passed * 2 >= r.total ? 'ask' : 'bad') + ' wf-crit-rate">' + r.passed + ' / ' + r.total + '</span>';
1429
1429
  return '<li class="wf-crit"><span><strong>' + escapeHtml(c.text) + '</strong><br><span class="wf-crit-kind">' + escapeHtml(critKindText(c)) + '</span></span>' + pill + '</li>';
1430
1430
  }).join('');
1431
- var critSection = '<h4 class="wf-sub">Checklist</h4>' +
1431
+ var critSection = '<h4 class="wf-sub">Success criteria</h4>' +
1432
1432
  '<p class="hint" style="margin:0">' + (evals.criteria && evals.criteria.length
1433
- ? 'What every good result must get right. Each eval case is checked against every item, yes or no.'
1434
- : 'What every good result must get right. Nothing on it yet, so each eval case is only compared with its good result. Add the items that matter, or have them suggested from its instructions.') + '</p>' +
1433
+ ? 'What every good result must get right. Each eval case is checked against every criterion, yes or no.'
1434
+ : 'What every good result must get right. None set yet, so each eval case is only compared with its good result. Add the criteria that matter, or have them suggested from its instructions.') + '</p>' +
1435
1435
  '<ul class="wf-crits">' + critList + '</ul>' +
1436
- '<div class="wf-crit-bar"><button type="button" class="wf-crit-edit">' + (evals.criteria && evals.criteria.length ? 'Edit the checklist' : 'Add to the checklist') + '</button></div>' +
1436
+ '<div class="wf-crit-bar"><button type="button" class="wf-crit-edit">' + (evals.criteria && evals.criteria.length ? 'Edit the success criteria' : 'Add success criteria') + '</button></div>' +
1437
1437
  '<div class="wf-crit-form" hidden>' +
1438
1438
  '<div class="wf-crit-rows">' + (evals.criteria && evals.criteria.length ? evals.criteria : []).map(critRowHtml).join('') + '</div>' +
1439
- '<div class="wf-crit-bar"><button type="button" class="plain wf-crit-add">+ Add an item</button><button type="button" class="plain wf-crit-draft">Suggest from its instructions</button>' +
1440
- '<span style="flex:1"></span><button type="button" class="plain wf-crit-cancel">Cancel</button><button type="button" class="wf-crit-save">Save the checklist</button></div>' +
1439
+ '<div class="wf-crit-bar"><button type="button" class="plain wf-crit-add">+ Add a criterion</button><button type="button" class="plain wf-crit-draft">Suggest from its instructions</button>' +
1440
+ '<span style="flex:1"></span><button type="button" class="plain wf-crit-cancel">Cancel</button><button type="button" class="wf-crit-save">Save success criteria</button></div>' +
1441
1441
  '<span class="hint wf-crit-status"></span>' +
1442
1442
  '</div>';
1443
1443
  var latest = {};
@@ -1450,7 +1450,7 @@ ${renderMarkdownScript}
1450
1450
  var values = Object.keys(c.params || {}).map(function (k) { var v = String(c.params[k]); return escapeHtml(k) + ': ' + escapeHtml(v.length > 60 ? v.slice(0, 60) + String.fromCharCode(8230) : v); }).join(DOT);
1451
1451
  var fails = last && last.checks ? last.checks.filter(function (x) { return !x.pass; }) : [];
1452
1452
  var pill = !last ? ''
1453
- : last.checks ? (fails.length ? '<span class="le-pill bad">' + fails.length + ' of ' + last.checks.length + ' items missed</span>' : '<span class="le-pill good">Passed all ' + last.checks.length + '</span>')
1453
+ : last.checks ? (fails.length ? '<span class="le-pill bad">' + fails.length + ' of ' + last.checks.length + ' criteria missed</span>' : '<span class="le-pill good">Passed all ' + last.checks.length + '</span>')
1454
1454
  : typeof last.score === 'number' ? '<span class="le-pill ' + (last.score >= 4 ? 'good' : last.score === 3 ? 'ask' : 'bad') + '">' + last.score + ' / 5</span>' : '<span class="le-pill bad">Not scored</span>';
1455
1455
  var why = !last ? ''
1456
1456
  : last.checks ? (fails.length ? '<ul class="wf-case-fails">' + fails.map(function (x) { return '<li><strong>' + escapeHtml(critName[x.criterionId] || x.criterionId) + '</strong>' + (x.reason ? ': ' + escapeHtml(x.reason) : '') + '</li>'; }).join('') + '</ul>' : '')
@@ -1473,14 +1473,14 @@ ${renderMarkdownScript}
1473
1473
  }).join('');
1474
1474
  var lastLine = !round ? ''
1475
1475
  : '<p class="wf-eval-last"><strong>Last evaluation: ' + escapeHtml(new Date(round.at).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) + (round.briefVersion ? ', version ' + round.briefVersion + ' of its instructions' : '') + '</strong>' +
1476
- (checked ? String.fromCharCode(8212) + ' ' + round.allPassed + ' of ' + round.cases.length + ' cases passed every checklist item.' : '') +
1476
+ (checked ? String.fromCharCode(8212) + ' ' + round.allPassed + ' of ' + round.cases.length + ' cases met every success criterion.' : '') +
1477
1477
  ' <details class="wf-eval-details"><summary>Details</summary>Ran with ' + escapeHtml(round.model) + DOT + 'judged by ' + escapeHtml(round.judge) + DOT + escapeHtml(new Date(round.at).toLocaleString()) + '</details></p>';
1478
1478
  return '<section class="wf-section">' + critSection + '</section>' +
1479
1479
  '<section class="wf-section"><h4 class="wf-sub">Eval cases' + (evals.cases.length ? ' (' + evals.cases.length + ')' : '') + '</h4>' +
1480
1480
  '<p class="hint" style="margin:0">Real runs saved to check every change against.</p>' +
1481
1481
  (cases ? '<ul class="wf-cases">' + cases + '</ul>' : '<p class="hint" style="margin:0">None yet: add suggested ones below, or save any run from its case page.</p>') +
1482
1482
  '<div class="wf-evals-bar"><button type="button" class="wf-evals-run"' + (!evals.cases.length || running ? ' disabled' : '') + '>' + (running ? 'Evaluating ' + running.done + ' of ' + running.total + String.fromCharCode(8230) : 'Evaluate') + '</button>' +
1483
- '<span class="hint">Runs every eval case again with the current instructions and checks each result against the checklist. Nothing is sent, refunded or submitted.</span></div>' +
1483
+ '<span class="hint">Runs every eval case again with the current instructions and checks each result against the success criteria. Nothing is sent, refunded or submitted.</span></div>' +
1484
1484
  lastLine + '</section>' +
1485
1485
  (workflowPageId ? '<section class="wf-section"><h4 class="wf-sub">Suggested eval cases</h4><div class="wf-candidates"><p class="hint" style="margin:0">Looking through its runs' + String.fromCharCode(8230) + '</p></div></section>' : '');
1486
1486
  }
@@ -1577,7 +1577,7 @@ ${renderMarkdownScript}
1577
1577
  '<span class="wf-page-meta-item"><span class="wf-page-meta-k">Agent</span><a href="/agents/config?agent=' + encodeURIComponent(name) + '">' + escapeHtml(agentLabel) + '</a></span>' +
1578
1578
  '<span class="wf-page-meta-item"><span class="wf-page-meta-k">Starts</span><span class="wf-page-starts">' + workflowStartsSummary(w) + '</span></span>' +
1579
1579
  '<span class="wf-page-meta-item"><span class="wf-page-meta-k">Last run</span><span class="wf-page-last">' + workflowLastRunHtml(last) + '</span></span>' +
1580
- (w.jobs && w.jobs.length ? '<span class="wf-page-meta-item"><span class="wf-page-meta-k">For job</span><span>' + w.jobs.map(function (j) { return '<a href="/jobs?job=' + encodeURIComponent(j.id) + '">' + escapeHtml(j.title) + '</a>'; }).join(', ') + '</span></span>' : '') +
1580
+ (w.jobs && w.jobs.length ? '<span class="wf-page-meta-item"><span class="wf-page-meta-k">For goal</span><span>' + w.jobs.map(function (j) { return '<a href="/goals?goal=' + encodeURIComponent(j.id) + '">' + escapeHtml(j.title) + '</a>'; }).join(', ') + '</span></span>' : '') +
1581
1581
  '</div>' +
1582
1582
  '</header>' +
1583
1583
  '<div class="wf-row-body wf-page-body">' +
@@ -1598,7 +1598,7 @@ ${renderMarkdownScript}
1598
1598
  '<span class="wf-row-caret" aria-hidden="true"></span>' +
1599
1599
  '<div class="wf-row-main"><strong>' + escapeHtml(w.title) + '</strong>' +
1600
1600
  // The job(s) it does, linking back to each job's page.
1601
- (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>' +
1601
+ (w.jobs && w.jobs.length ? '<span class="wf-row-job">For goal: ' + w.jobs.map(function (j) { return '<a href="/goals?goal=' + encodeURIComponent(j.id) + '">' + escapeHtml(j.title) + '</a>'; }).join(', ') + '</span>' : '') + '</div>' +
1602
1602
  '<span class="wf-row-starts">' + workflowStartsSummary(w) + '</span>' +
1603
1603
  '<span class="wf-row-last">' + workflowLastRunHtml(last) + '</span>' +
1604
1604
  '<span class="wf-row-actions"><button type="button" class="workflow-triggers-open">Triggers</button><button type="button" class="workflow-edit">Edit</button></span>' +
@@ -22,7 +22,7 @@ const LABELS = [
22
22
  [/^\/agents\/[^/]+\/workflows\/[^/]+\/versions\/(\d+)\/restore$/, (_method, m) => `Restored brief version ${m[1]}`],
23
23
  [/^\/agents\/[^/]+\/workflows\/[^/]+\/messages$/, 'Changed where messages go'],
24
24
  [/^\/agents\/[^/]+\/workflows\/[^/]+\/triggers/, 'Changed webhook triggers'],
25
- [/^\/agents\/[^/]+\/workflows\/[^/]+\/evals\/criteria/, 'Changed the checklist'],
25
+ [/^\/agents\/[^/]+\/workflows\/[^/]+\/evals\/criteria/, 'Changed the success criteria'],
26
26
  [/^\/agents\/[^/]+\/workflows\/[^/]+\/evals/, 'Changed eval cases'],
27
27
  [/^\/agents\/[^/]+\/schedules/, 'Changed schedules'],
28
28
  [/^\/schedules\//, 'Changed a schedule'],
@@ -127,7 +127,7 @@ function lineChanges(before, after) {
127
127
  * field. A text of several lines, or a long one, is told as lines added
128
128
  * and removed; anything else as its value before and after. */
129
129
  // Always told as lines, however short: what an agent reads.
130
- const TEXT_FIELDS = new Set(['instructions', 'shared policies', 'checklist']);
130
+ const TEXT_FIELDS = new Set(['instructions', 'shared policies', 'success criteria']);
131
131
  export function describeChanges(before, after) {
132
132
  const out = [];
133
133
  for (const field of [...new Set([...Object.keys(before), ...Object.keys(after)])]) {
@@ -32,13 +32,15 @@ const AGENTS_ICON = '<svg class="le-nav-icon" viewBox="3 3 18 18" fill="currentC
32
32
  const WORKFLOWS_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/><path d="M10 6.5h4a3.5 3.5 0 0 1 3.5 3.5v4"/><path d="M14 17.5h-4A3.5 3.5 0 0 1 6.5 14v-4"/></svg>';
33
33
  // An inbox tray, for the Inbox.
34
34
  const INBOX_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/></svg>';
35
+ // A target, for Goals.
36
+ const GOALS_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1"/></svg>';
35
37
  // A clipboard with a tick, for Audit.
36
38
  const AUDIT_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="4" width="14" height="17" rx="2"/><path d="M9 4V3h6v1"/><path d="m9 13 2 2 4-4"/></svg>';
37
39
  // A gear, for Settings.
38
40
  const SETTINGS_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>';
39
- // Two columns: the sections (Inbox, Agents, Workflows, Audit, Settings), and
40
- // beside them what's in the current one. Goals and Jobs stay at /goals
41
- // and /jobs, out of the menu: LoopEngine is about workflows. Pointing at
41
+ // Two columns: the sections (Inbox, Goals, Agents, Workflows, Audit,
42
+ // Settings), and beside them what's in the current one. A goal holds the
43
+ // workflows, and groups of workflows, suggested for it. Pointing at
42
44
  // another section shows its column instead, until the pointer leaves.
43
45
  // Inbox and Home have no second column; pointing at a section there
44
46
  // opens its column over the page.
@@ -46,6 +48,7 @@ export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console
46
48
  <nav class="le-rail" aria-label="Sections">
47
49
  <a class="le-brand" href="/" title="Home"><span class="le-brand-mark">${BRAND_MARK}</span></a>
48
50
  <a class="le-rail-item" href="/inbox" data-le-nav-head="inbox" data-le-section="inbox">${INBOX_ICON}<span>Inbox</span><span class="le-pill warn le-inbox-count" id="leInboxCount" hidden></span></a>
51
+ <a class="le-rail-item" href="/goals" data-le-nav-head="goals" data-le-section="goals">${GOALS_ICON}<span>Goals</span></a>
49
52
  <a class="le-rail-item" href="/agents" data-le-nav-head="agents" data-le-section="agents">${AGENTS_ICON}<span>Agents</span></a>
50
53
  <a class="le-rail-item" href="/workflows" data-le-nav-head="workflows" data-le-section="workflows">${WORKFLOWS_ICON}<span>Workflows</span></a>
51
54
  <a class="le-rail-item" href="/audit" data-le-nav-head="audit" data-le-section="audit">${AUDIT_ICON}<span>Audit</span></a>
@@ -54,6 +57,10 @@ export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console
54
57
  <div class="le-who" id="leWho" hidden></div>
55
58
  </nav>
56
59
  <div class="le-panel" hidden>
60
+ <section class="le-pane" data-le-pane="goals">
61
+ <div class="le-pane-head"><a href="/goals">Goals</a><a class="le-pane-new" href="/goals?new=1" data-le-goal-new>+ New</a></div>
62
+ <ul class="le-agent-list le-goal-list" id="leGoalList"></ul>
63
+ </section>
57
64
  <section class="le-pane" data-le-pane="agents">
58
65
  <div class="le-pane-head"><a href="/agents">Agents</a><a class="le-pane-new" href="/agents?new=1">+ New</a></div>
59
66
  <ul class="le-agent-list" id="leAgentList"></ul>
@@ -213,13 +220,11 @@ export const consoleShellScript = `<script>
213
220
  if (!goalList) return Promise.resolve();
214
221
  return cachedFetch('goals', '/goals', function (data) {
215
222
  var goals = data.goals || [];
216
- // The Jobs page is the Goals page's jobs view; it marks Jobs instead.
217
- var onJobs = location.pathname === '/jobs';
218
- var current = page === 'goals' && !onJobs ? new URLSearchParams(location.search).get('goal') : null;
223
+ var current = page === 'goals' ? new URLSearchParams(location.search).get('goal') : null;
219
224
  var newLink = document.querySelector('[data-le-goal-new]');
220
- var creating = page === 'goals' && !onJobs && !current && (location.pathname === '/' || new URLSearchParams(location.search).has('new'));
225
+ var creating = page === 'goals' && !current && (location.pathname === '/' || new URLSearchParams(location.search).has('new'));
221
226
  var head = document.querySelector('[data-le-nav-head="goals"]');
222
- if (head) { if (page === 'goals' && !onJobs && !current && !creating) head.setAttribute('aria-current', 'page'); else head.removeAttribute('aria-current'); }
227
+ if (head) { if (page === 'goals' && !current && !creating) head.setAttribute('aria-current', 'page'); else head.removeAttribute('aria-current'); }
223
228
  if (newLink) { if (creating) newLink.setAttribute('aria-current', 'page'); else newLink.removeAttribute('aria-current'); }
224
229
  goalList.innerHTML = goals.length ? goals.map(function (g) {
225
230
  return '<li><a class="le-agent-item le-goal-item" href="/goals?goal=' + enc(g.id) + '" title="' + esc(g.goal) + '"' + (g.id === current ? ' aria-current="page"' : '') + '>' +
@@ -229,31 +234,9 @@ export const consoleShellScript = `<script>
229
234
  }
230
235
  fullAccess.then(function (full) { if (full) reloadGoals(); });
231
236
 
232
- // ---- Jobs, listed under Goals: the person's own jobs (GET /jobs), newest
233
- // added first, each opening on the Jobs page; its dot says whether it's
234
- // running, waiting for them, or not started. The Jobs page reloads the
235
- // list when it changes (leShell.reloadJobs).
236
- var jobList = document.getElementById('leJobList');
237
- function reloadJobs() {
238
- if (!jobList) return Promise.resolve();
239
- var onJobs = location.pathname === '/jobs';
240
- var current = onJobs ? new URLSearchParams(location.search).get('job') : null;
241
- var jobsHead = document.querySelector('[data-le-nav-head="jobs"]');
242
- if (jobsHead) { if (onJobs && !current) jobsHead.setAttribute('aria-current', 'page'); else jobsHead.removeAttribute('aria-current'); }
243
- return cachedFetch('jobs', '/jobs', function (data) {
244
- var jobs = data.jobs || [];
245
- jobList.innerHTML = jobs.length ? jobs.map(function (x) {
246
- var j = x.job;
247
- var t = j.tries && j.tries.length ? j.tries[j.tries.length - 1] : null;
248
- var dot = t && (t.status === 'awaiting_approval' || t.status === 'done') && j.state === 'active' ? ' warn'
249
- : j.state === 'active' ? '' : ' idle';
250
- var label = j.state === 'done' ? 'Done' : j.state === 'active' ? (dot === ' warn' ? 'Needs you' : 'Running') : 'Not started';
251
- return '<li><a class="le-agent-item le-goal-item" href="/jobs?job=' + enc(j.id) + '" title="' + esc(j.title) + ' (' + label + ')"' + (j.id === current ? ' aria-current="page"' : '') + '>' +
252
- '<span class="le-dot' + dot + '" aria-hidden="true"></span><span class="le-name">' + esc(j.title) + '</span></a></li>';
253
- }).join('') : '<li class="le-agent-item"><span></span><span class="le-meta">No jobs yet</span><span></span></li>';
254
- });
255
- }
256
- fullAccess.then(function (full) { if (full) reloadJobs(); });
237
+ // Jobs are gone: a goal holds workflows and groups. Kept so a page that
238
+ // still asks to reload them does nothing.
239
+ function reloadJobs() { return Promise.resolve(); }
257
240
 
258
241
  // ---- Workflows, listed under the agents (GET /workflows/overview),
259
242
  // each opening on its agent's Workflows tab. A tinted dot is running (a
@@ -384,7 +367,7 @@ export const consoleShellScript = `<script>
384
367
  // The section this page is in, whose column shows beside the sections.
385
368
  var sidebar = document.querySelector('.le-sidebar');
386
369
  var panel = document.querySelector('.le-panel');
387
- var section0 = page === 'goals' ? (location.pathname === '/jobs' ? 'jobs' : 'goals')
370
+ var section0 = page === 'goals' ? 'goals'
388
371
  : page === 'agent-config' && params.get('tab') === 'workflows' && params.get('workflow') ? 'workflows'
389
372
  : page === 'agents' || page === 'agent-config' || page === 'chat' || page === 'interview' ? 'agents'
390
373
  : page === 'workflows' || page === 'workflows-overview' ? 'workflows'