loopengine 0.4.12 → 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.
- package/dist/core/system-agents/goal-planner.d.ts +23 -8
- package/dist/core/system-agents/goal-planner.js +68 -20
- package/dist/core/system-agents/goal-playbooks.d.ts +0 -3
- package/dist/core/system-agents/goal-playbooks.js +1 -3
- package/dist/core/system-agents/playbook.json +2 -25
- package/dist/core/system-agents/workflow-planner.d.ts +15 -1
- package/dist/core/system-agents/workflow-planner.js +31 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/web/agents-config-page.js +2 -2
- package/dist/web/console-shell.js +17 -34
- package/dist/web/goals-admin.d.ts +45 -93
- package/dist/web/goals-admin.js +127 -230
- package/dist/web/goals-page.d.ts +1 -1
- package/dist/web/goals-page.js +108 -276
- package/dist/web/home-page.js +21 -26
- package/dist/web/workflow-admin.js +13 -2
- package/dist/web/workflow-evidence.d.ts +1 -1
- package/dist/web/workflow-evidence.js +1 -1
- package/dist/web/workflow-page.js +90 -22
- package/dist/web/workflows-overview.d.ts +8 -2
- package/dist/web/workflows-overview.js +7 -5
- package/package.json +1 -1
|
@@ -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,
|
|
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,
|
|
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';
|
|
@@ -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
|
|
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
|
|
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>' +
|
|
@@ -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,
|
|
40
|
-
// beside them what's in the current one.
|
|
41
|
-
// and
|
|
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
|
-
|
|
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' && !
|
|
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' && !
|
|
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
|
-
//
|
|
233
|
-
//
|
|
234
|
-
|
|
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' ?
|
|
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'
|
|
@@ -43,15 +43,34 @@ export interface ChainStep {
|
|
|
43
43
|
}
|
|
44
44
|
/** Runs a chain may start one after another, after the first. */
|
|
45
45
|
export declare const MAX_CHAIN_DEPTH = 5;
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
/** A group of workflows under a goal: steps that run in order (only
|
|
47
|
+
* "sequence" for now), each built as its own workflow. Once two steps in
|
|
48
|
+
* a row are built, the next is chained to start after the one before
|
|
49
|
+
* (GoalJob.chain), given its result. */
|
|
50
|
+
export interface WorkflowGroup {
|
|
51
|
+
order: 'sequence';
|
|
52
|
+
steps: GroupStep[];
|
|
53
|
+
}
|
|
54
|
+
export interface GroupStep {
|
|
55
|
+
id: string;
|
|
56
|
+
/** A short label for its workflow ("Lead scan"). */
|
|
57
|
+
name: string;
|
|
58
|
+
request: string;
|
|
59
|
+
agent: {
|
|
60
|
+
name: string;
|
|
61
|
+
isNew: boolean;
|
|
62
|
+
instructions?: string;
|
|
63
|
+
};
|
|
64
|
+
needs: GoalNeed[];
|
|
65
|
+
/** The workflow built for it, once built. */
|
|
66
|
+
built?: {
|
|
67
|
+
agent: string;
|
|
68
|
+
workflowId: string;
|
|
69
|
+
};
|
|
54
70
|
}
|
|
71
|
+
/** A suggestion under a goal: one workflow, or a group of them (`group`).
|
|
72
|
+
* Stored as before under the name "job" (a goal's `jobs`), so saved
|
|
73
|
+
* goals keep working; the console calls it a workflow or a group. */
|
|
55
74
|
export interface GoalJob {
|
|
56
75
|
id: string;
|
|
57
76
|
title: string;
|
|
@@ -82,12 +101,13 @@ export interface GoalJob {
|
|
|
82
101
|
restoreTo?: 'suggested';
|
|
83
102
|
/** What does it, once built: the workflow (skill id) on its agent. */
|
|
84
103
|
doers: JobDoer[];
|
|
85
|
-
/**
|
|
104
|
+
/** Older one-off jobs: when marked done, and the accepted result. */
|
|
86
105
|
doneAt?: string;
|
|
87
|
-
/** The accepted result of a once job's assignment. */
|
|
88
106
|
result?: string;
|
|
89
107
|
/** For a recurring job done by several workflows: what runs after what. */
|
|
90
108
|
chain?: ChainStep[];
|
|
109
|
+
/** A group of workflows that run in order, instead of one. */
|
|
110
|
+
group?: WorkflowGroup;
|
|
91
111
|
/** A job the person added themselves: their own words, and how the
|
|
92
112
|
* planner judged it ("changed" or "warned", with its note). */
|
|
93
113
|
added?: {
|
|
@@ -117,9 +137,6 @@ export interface GoalJob {
|
|
|
117
137
|
};
|
|
118
138
|
/** Which generation suggested it (1 on create). */
|
|
119
139
|
round: number;
|
|
120
|
-
/** When it was added to the person's own list of jobs (the Jobs page):
|
|
121
|
-
* with Add to my jobs, on Build or Assign, or when submitted there. */
|
|
122
|
-
addedAt?: string;
|
|
123
140
|
}
|
|
124
141
|
/** Before jobs: the same thing, called a workflow under its goal. */
|
|
125
142
|
export type GoalWorkflow = GoalJob;
|
|
@@ -147,15 +164,12 @@ export interface Goal {
|
|
|
147
164
|
jobs: GoalJob[];
|
|
148
165
|
createdAt: string;
|
|
149
166
|
updatedAt: string;
|
|
150
|
-
/** The
|
|
151
|
-
*
|
|
167
|
+
/** The holder of jobs once submitted without a goal (before goals held
|
|
168
|
+
* only workflows): never listed as a goal. */
|
|
152
169
|
standalone?: true;
|
|
153
170
|
}
|
|
154
171
|
export declare class GoalError extends Error {
|
|
155
172
|
}
|
|
156
|
-
/** Where jobs submitted without a goal live: a goal file of its own, so
|
|
157
|
-
* building, assigning, chains and runs work for them as for any job. */
|
|
158
|
-
export declare const MY_JOBS_ID = "g-my-jobs";
|
|
159
173
|
export type EditAmount = 'none' | 'light' | 'heavy';
|
|
160
174
|
export declare const DISCARD_REASONS: readonly ["not-relevant", "too-much-work", "already-doing-it", "other"];
|
|
161
175
|
export type DiscardReason = (typeof DISCARD_REASONS)[number];
|
|
@@ -175,14 +189,6 @@ export interface GoalsDeps {
|
|
|
175
189
|
runs: number;
|
|
176
190
|
done: number;
|
|
177
191
|
}>;
|
|
178
|
-
/** Starts a once job's assignment: one unattended run of the agent with
|
|
179
|
-
* this message; returns its run id. */
|
|
180
|
-
startAssignment?: (agent: string, message: string, job: {
|
|
181
|
-
goal: string;
|
|
182
|
-
job: string;
|
|
183
|
-
}) => Promise<{
|
|
184
|
-
runId: string;
|
|
185
|
-
}>;
|
|
186
192
|
/** A workflow on an agent, when it exists: its title and inputs (for
|
|
187
193
|
* linking it to a job and checking a chain). */
|
|
188
194
|
workflowInfo?: (agent: string, workflowId: string) => {
|
|
@@ -191,19 +197,11 @@ export interface GoalsDeps {
|
|
|
191
197
|
required: boolean;
|
|
192
198
|
}>;
|
|
193
199
|
} | undefined;
|
|
194
|
-
/** An assignment run's state, for the page. */
|
|
195
|
-
assignmentRun?: (agent: string, runId: string) => Promise<{
|
|
196
|
-
status: AssignmentView['status'];
|
|
197
|
-
result?: string;
|
|
198
|
-
error?: string;
|
|
199
|
-
} | undefined>;
|
|
200
200
|
}
|
|
201
201
|
/** A goal as saved before jobs (its `workflows`, a built one's `built`
|
|
202
202
|
* link) read as one with jobs; one saved since, as it is. Each becomes a
|
|
203
|
-
* job: a built one active, done by its workflow
|
|
204
|
-
* the
|
|
205
|
-
* job). Each gets a measure: the lever's, else how it was said to move
|
|
206
|
-
* the goal. */
|
|
203
|
+
* recurring job: a built one active, done by its workflow. Each gets a
|
|
204
|
+
* measure: the lever's, else how it was said to move the goal. */
|
|
207
205
|
export declare function migrateGoal(raw: Record<string, unknown>): Goal;
|
|
208
206
|
/** Rewrites every goal saved before jobs in the new form (jobs, with
|
|
209
207
|
* their workflows as doers), once, at start. Returns how many changed. */
|
|
@@ -242,12 +240,12 @@ export declare function generateMore(deps: GoalsDeps, id: string, input?: {
|
|
|
242
240
|
}): Goal;
|
|
243
241
|
export declare function setWorkflowState(deps: GoalsDeps, id: string, workflowId: string, action: unknown, reason?: unknown): Goal;
|
|
244
242
|
/** Build: makes the suggested agent when there is none by that name,
|
|
245
|
-
* then returns
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* ready to send. */
|
|
243
|
+
* then returns Build a workflow's address, with the request and the agent
|
|
244
|
+
* filled in and the goal to link the result back to. For a group, `step`
|
|
245
|
+
* says which of its workflows. */
|
|
249
246
|
export declare function prepareBuild(deps: GoalsDeps, id: string, workflowId: string, opts?: {
|
|
250
247
|
another?: boolean;
|
|
248
|
+
step?: string;
|
|
251
249
|
}): Promise<{
|
|
252
250
|
goal: Goal;
|
|
253
251
|
agent: string;
|
|
@@ -261,6 +259,7 @@ export declare function markBuilt(deps: GoalsDeps, id: string, workflowId: strin
|
|
|
261
259
|
workflowId?: unknown;
|
|
262
260
|
title?: unknown;
|
|
263
261
|
description?: unknown;
|
|
262
|
+
step?: unknown;
|
|
264
263
|
}): Goal;
|
|
265
264
|
export declare function addJob(deps: GoalsDeps, id: string, input: {
|
|
266
265
|
idea?: unknown;
|
|
@@ -272,42 +271,12 @@ export declare function addJob(deps: GoalsDeps, id: string, input: {
|
|
|
272
271
|
alternative: string;
|
|
273
272
|
jobId?: string;
|
|
274
273
|
}>;
|
|
275
|
-
/**
|
|
276
|
-
|
|
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. */
|
|
274
|
+
/** The goals each workflow was built for ("agent|workflowId" -> goals,
|
|
275
|
+
* each its id and its words), for a workflow's "For goal". */
|
|
282
276
|
export declare function jobsByWorkflow(deps: GoalsDeps): Map<string, {
|
|
283
277
|
id: string;
|
|
284
278
|
title: string;
|
|
285
279
|
}[]>;
|
|
286
|
-
export interface ListedJob {
|
|
287
|
-
goalId: string;
|
|
288
|
-
/** The goal it came from; null for a job submitted without one. */
|
|
289
|
-
goal: string | null;
|
|
290
|
-
addedAt: string;
|
|
291
|
-
job: GoalJob & {
|
|
292
|
-
tries?: AssignmentView[];
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
/** The person's jobs, newest added first: every job on the list, from any
|
|
296
|
-
* goal, and every job submitted without one (discarded ones left out). */
|
|
297
|
-
export declare function listJobs(deps: GoalsDeps): Promise<ListedJob[]>;
|
|
298
|
-
/** A job the person submits on the Jobs page, with no goal: shaped and
|
|
299
|
-
* judged like one added under a goal (judged on its own), and put on
|
|
300
|
-
* their list, ready to build or assign. */
|
|
301
|
-
export declare function submitJob(deps: GoalsDeps, input: {
|
|
302
|
-
idea?: unknown;
|
|
303
|
-
share?: unknown;
|
|
304
|
-
}): Promise<{
|
|
305
|
-
verdict: 'added' | 'changed' | 'warned' | 'refused';
|
|
306
|
-
note: string;
|
|
307
|
-
alternative: string;
|
|
308
|
-
goalId: string;
|
|
309
|
-
jobId?: string;
|
|
310
|
-
}>;
|
|
311
280
|
/** Checks a chain against the job's workflows: each step joins two of
|
|
312
281
|
* them, its condition and inputs make sense, every required input of the
|
|
313
282
|
* next run is filled, and nothing loops. Returns it tidied, with ids. */
|
|
@@ -343,27 +312,10 @@ export declare function chainedRuns(deps: GoalsDeps, run: {
|
|
|
343
312
|
params: Record<string, string>;
|
|
344
313
|
depth: number;
|
|
345
314
|
}[];
|
|
346
|
-
/**
|
|
347
|
-
*
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
note?: string;
|
|
351
|
-
}): string;
|
|
352
|
-
/** Assigns a once job to its agent (making the agent first when there is
|
|
353
|
-
* none), or, with a note, asks again after a try that finished or
|
|
354
|
-
* failed. */
|
|
355
|
-
export declare function assignJob(deps: GoalsDeps, id: string, jobId: string, input?: {
|
|
356
|
-
note?: unknown;
|
|
357
|
-
}): Promise<Goal>;
|
|
358
|
-
/** Accepts a once job's latest result: the job is done, the result kept. */
|
|
359
|
-
export declare function acceptJob(deps: GoalsDeps, id: string, jobId: string): Promise<Goal>;
|
|
360
|
-
/** A goal with its once jobs' tries as the page shows them: each one's
|
|
361
|
-
* run state and result. */
|
|
362
|
-
export declare function goalView(deps: GoalsDeps, goal: Goal): Promise<Goal & {
|
|
363
|
-
jobs: (GoalJob & {
|
|
364
|
-
tries?: AssignmentView[];
|
|
365
|
-
})[];
|
|
366
|
-
}>;
|
|
315
|
+
/** A goal as its page shows it: its workflows and groups. One-off jobs
|
|
316
|
+
* (from before goals suggested only workflows) are left out; their
|
|
317
|
+
* files keep them. */
|
|
318
|
+
export declare function goalView(_deps: GoalsDeps, goal: Goal): Promise<Goal>;
|
|
367
319
|
/** none (same words), light (mostly the same: names, a schedule, tone)
|
|
368
320
|
* or heavy (a different request), by how many words the two share. */
|
|
369
321
|
export declare function editAmount(before: string, after: string): EditAmount;
|