loopengine 0.3.84 → 0.3.86
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/workflows.d.ts +6 -0
- package/dist/core/workflows.js +34 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/web/agents-config-page.js +124 -72
- package/dist/web/workflow-admin.d.ts +4 -0
- package/dist/web/workflow-admin.js +15 -4
- package/package.json +1 -1
package/dist/core/workflows.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export interface WorkflowDelivery {
|
|
|
44
44
|
/** Posted to the messaging app when a run starts; {{name}} is filled
|
|
45
45
|
* from the run's inputs. */
|
|
46
46
|
chat_notice?: string;
|
|
47
|
+
/** Post each run's result to the messaging app too. */
|
|
48
|
+
result_to_chat?: boolean;
|
|
47
49
|
}
|
|
48
50
|
/** The front matter that makes a skill a workflow: `instructions` (the
|
|
49
51
|
* new way) replaces the body and drops any start message and label;
|
|
@@ -65,6 +67,10 @@ export interface WorkflowFields {
|
|
|
65
67
|
}
|
|
66
68
|
export declare class WorkflowParamsError extends Error {
|
|
67
69
|
}
|
|
70
|
+
/** Sets where a workflow's runs send their updates, decisions, start
|
|
71
|
+
* notice and result (null: the messaging app's defaults); nothing else
|
|
72
|
+
* changes. */
|
|
73
|
+
export declare function setWorkflowDelivery(agentDir: string, id: string, delivery: WorkflowDelivery | null): void;
|
|
68
74
|
/** Writes a skill file: its front matter (name and description first) and
|
|
69
75
|
* body. */
|
|
70
76
|
export declare function writeSkillFile(path: string, frontmatter: Record<string, unknown>, body: string): void;
|
package/dist/core/workflows.js
CHANGED
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
// delivery:
|
|
37
37
|
// callback_url: https://ops.example.com/loopengine
|
|
38
38
|
// decisions: callback
|
|
39
|
-
// chat_notice: New dispute {{dispute_id}}
|
|
39
|
+
// chat_notice: New dispute {{dispute_id}}
|
|
40
|
+
// result_to_chat: true The workspace's shared
|
|
40
41
|
// policies (policies.md in the project) go into every run, after the
|
|
41
42
|
// instructions.
|
|
42
43
|
//
|
|
@@ -73,9 +74,38 @@ function deliveryFrom(value) {
|
|
|
73
74
|
...(callbackUrl ? { callback_url: callbackUrl } : {}),
|
|
74
75
|
...(callbackUrl && d.decisions === 'callback' ? { decisions_to: 'callback' } : {}),
|
|
75
76
|
...(notice ? { chat_notice: notice } : {}),
|
|
77
|
+
...(d.result_to_chat === true ? { result_to_chat: true } : {}),
|
|
76
78
|
};
|
|
77
79
|
return Object.keys(delivery).length ? delivery : undefined;
|
|
78
80
|
}
|
|
81
|
+
/** A delivery as its front matter, `decisions` named as in the API. */
|
|
82
|
+
function deliveryFrontmatter(delivery) {
|
|
83
|
+
const d = delivery ? deliveryFrom({ ...delivery, decisions: delivery.decisions_to }) : undefined;
|
|
84
|
+
if (!d)
|
|
85
|
+
return undefined;
|
|
86
|
+
return {
|
|
87
|
+
...(d.callback_url ? { callback_url: d.callback_url } : {}),
|
|
88
|
+
...(d.decisions_to ? { decisions: d.decisions_to } : {}),
|
|
89
|
+
...(d.chat_notice ? { chat_notice: d.chat_notice } : {}),
|
|
90
|
+
...(d.result_to_chat ? { result_to_chat: true } : {}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Sets where a workflow's runs send their updates, decisions, start
|
|
94
|
+
* notice and result (null: the messaging app's defaults); nothing else
|
|
95
|
+
* changes. */
|
|
96
|
+
export function setWorkflowDelivery(agentDir, id, delivery) {
|
|
97
|
+
const path = skillPath(agentDir, id);
|
|
98
|
+
const skill = readSkillFile(path, id);
|
|
99
|
+
if (!skill || !workflowFrom(id, skill.frontmatter, skill.body))
|
|
100
|
+
throw new Error(`No workflow ${id}.`);
|
|
101
|
+
const frontmatter = { ...skill.frontmatter };
|
|
102
|
+
const saved = deliveryFrontmatter(delivery);
|
|
103
|
+
if (saved)
|
|
104
|
+
frontmatter.delivery = saved;
|
|
105
|
+
else
|
|
106
|
+
delete frontmatter.delivery;
|
|
107
|
+
writeSkillFile(path, frontmatter, skill.body);
|
|
108
|
+
}
|
|
79
109
|
function skillsDir(agentDir) {
|
|
80
110
|
return join(agentDir, 'skills');
|
|
81
111
|
}
|
|
@@ -197,9 +227,9 @@ export function setWorkflowFields(agentDir, id, fields) {
|
|
|
197
227
|
delete frontmatter.output;
|
|
198
228
|
}
|
|
199
229
|
if (fields.delivery !== undefined) {
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
202
|
-
frontmatter.delivery =
|
|
230
|
+
const saved = deliveryFrontmatter(fields.delivery);
|
|
231
|
+
if (saved)
|
|
232
|
+
frontmatter.delivery = saved;
|
|
203
233
|
else
|
|
204
234
|
delete frontmatter.delivery;
|
|
205
235
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -86,14 +86,14 @@ export { templatesPageHtml } from './web/templates-page.js';
|
|
|
86
86
|
export { TemplateError, createFromTemplate, createFromTemplateObject, describeTemplateSchedule, listTemplates, previewTemplate, templateChecklist, type CreatedTemplateAgent, type LegacyTemplateCreateDeps, type TemplateChecklistItem, type TemplateCreateDeps, type TemplatePreview, type TemplateSummary, } from './web/templates-admin.js';
|
|
87
87
|
export { STARTER_TEMPLATES, starterTemplate, templateScheduleStart, type StarterTemplate, type TemplateRule, type TemplateSchedule, type TemplateSetup, type TemplateSkill, } from './core/system-agents/templates.js';
|
|
88
88
|
export { workflowPageHtml } from './web/workflow-page.js';
|
|
89
|
-
export { WorkflowError, checkWorkflowForAgent, checkWorkflowRequirements, createWorkflow, forgetWorkflow, forgetAgent, type ForgottenAgent, migrateAgentWorkflows, getPlanJob, listAgentWorkflows, noteForExistingAgent, planWorkflow, resolveConnections, prepareWorkflowRun, updateWorkflow, 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, } from './web/workflow-admin.js';
|
|
89
|
+
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, } from './web/workflow-admin.js';
|
|
90
90
|
export { WORKFLOW_PLANNER_PROMPT, planParameters, planWorkflowWithModel, validateWorkflowPlan, workflowTemplate, type WorkflowPlan, type WorkflowPlannerTools, type WorkflowStep } from './core/system-agents/workflow-planner.js';
|
|
91
91
|
export { WORKFLOW_EXAMPLES, workflowExample, type WorkflowExample } from './core/system-agents/workflow-examples.js';
|
|
92
92
|
export { WORKFLOW_EXAMPLE_MESSAGES, type WorkflowExampleMessage } from './core/system-agents/workflow-example-messages.js';
|
|
93
93
|
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';
|
|
94
94
|
export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError, type CallbackDelivery, type CallbackPending, type RunCallbackEvent } from './core/run-callbacks.js';
|
|
95
95
|
export { WorkflowRunner, FileRunStore, getRunStore, setRunStore, listRuns, getRun, isUnderWay, RunError, type WorkflowRun, type WorkflowRunStatus, type RunStore, type ExecuteRun, type RunOutcome, type StartRunInput } from './core/workflow-runs.js';
|
|
96
|
-
export { readWorkflows, readWorkflow, setWorkflowFields, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies, type Workflow, type WorkflowFields, type WorkflowParameter, type WorkflowModel, type RunMessageExtras } from './core/workflows.js';
|
|
96
|
+
export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies, type Workflow, type WorkflowFields, type WorkflowParameter, type WorkflowModel, type WorkflowDelivery, type RunMessageExtras } from './core/workflows.js';
|
|
97
97
|
export { EvidenceError, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, judgeEvalResult, startEvalRound, EVAL_JUDGE_PROMPT, type WorkflowScores, type EvalCase, type EvalCaseResult, type EvalRound, type WorkflowEvals, type EvalRunDeps } from './web/workflow-evidence.js';
|
|
98
98
|
export { globalConfigPageHtml } from './web/global-config-page.js';
|
|
99
99
|
export { playgroundHtml } from './web/playground.js';
|
package/dist/index.js
CHANGED
|
@@ -79,14 +79,14 @@ export { templatesPageHtml } from './web/templates-page.js';
|
|
|
79
79
|
export { TemplateError, createFromTemplate, createFromTemplateObject, describeTemplateSchedule, listTemplates, previewTemplate, templateChecklist, } from './web/templates-admin.js';
|
|
80
80
|
export { STARTER_TEMPLATES, starterTemplate, templateScheduleStart, } from './core/system-agents/templates.js';
|
|
81
81
|
export { workflowPageHtml } from './web/workflow-page.js';
|
|
82
|
-
export { WorkflowError, checkWorkflowForAgent, checkWorkflowRequirements, createWorkflow, forgetWorkflow, forgetAgent, migrateAgentWorkflows, getPlanJob, listAgentWorkflows, noteForExistingAgent, planWorkflow, resolveConnections, prepareWorkflowRun, updateWorkflow, startPlanJob, resolveMcpServers, prepareMcpAbilities, } from './web/workflow-admin.js';
|
|
82
|
+
export { WorkflowError, checkWorkflowForAgent, checkWorkflowRequirements, createWorkflow, forgetWorkflow, forgetAgent, migrateAgentWorkflows, getPlanJob, listAgentWorkflows, noteForExistingAgent, planWorkflow, resolveConnections, prepareWorkflowRun, updateWorkflow, updateWorkflowMessages, startPlanJob, resolveMcpServers, prepareMcpAbilities, } from './web/workflow-admin.js';
|
|
83
83
|
export { WORKFLOW_PLANNER_PROMPT, planParameters, planWorkflowWithModel, validateWorkflowPlan, workflowTemplate } from './core/system-agents/workflow-planner.js';
|
|
84
84
|
export { WORKFLOW_EXAMPLES, workflowExample } from './core/system-agents/workflow-examples.js';
|
|
85
85
|
export { WORKFLOW_EXAMPLE_MESSAGES } from './core/system-agents/workflow-example-messages.js';
|
|
86
86
|
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';
|
|
87
87
|
export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError } from './core/run-callbacks.js';
|
|
88
88
|
export { WorkflowRunner, FileRunStore, getRunStore, setRunStore, listRuns, getRun, isUnderWay, RunError } from './core/workflow-runs.js';
|
|
89
|
-
export { readWorkflows, readWorkflow, setWorkflowFields, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies } from './core/workflows.js';
|
|
89
|
+
export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies } from './core/workflows.js';
|
|
90
90
|
export { EvidenceError, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, judgeEvalResult, startEvalRound, EVAL_JUDGE_PROMPT } from './web/workflow-evidence.js';
|
|
91
91
|
export { globalConfigPageHtml } from './web/global-config-page.js';
|
|
92
92
|
export { playgroundHtml } from './web/playground.js';
|
|
@@ -119,6 +119,15 @@ export const agentsConfigPageHtml = `<!doctype html>
|
|
|
119
119
|
.wf-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 10px; margin-bottom: -1px; font-size: 13px; font-weight: 600; color: var(--ink-muted); }
|
|
120
120
|
.wf-tab:hover:not(:disabled) { background: none; color: var(--ink); }
|
|
121
121
|
.wf-tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
|
|
122
|
+
.wf-msg-form { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
|
|
123
|
+
.wf-msg-row { display: grid; grid-template-columns: 190px 1fr; gap: 12px; align-items: start; }
|
|
124
|
+
.wf-msg-k { font-weight: 600; font-size: 13px; padding-top: 7px; }
|
|
125
|
+
.wf-msg-v { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
|
126
|
+
.wf-msg-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
|
|
127
|
+
.wf-msg-check input { width: auto; margin: 0; }
|
|
128
|
+
.wf-msg-own { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
|
|
129
|
+
.wf-msg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
|
|
130
|
+
@media (max-width: 640px) { .wf-msg-row { grid-template-columns: 1fr; gap: 4px; } .wf-msg-k { padding-top: 0; } }
|
|
122
131
|
.wf-tab-count { margin-left: 4px; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
|
|
123
132
|
.wf-row .workflow-steps-text { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--surface); font-size: 13px; line-height: 1.6; max-height: 420px; overflow: auto; white-space: pre-wrap; }
|
|
124
133
|
.wf-original { margin-top: 10px; }
|
|
@@ -998,7 +1007,6 @@ ${consoleShellScript}
|
|
|
998
1007
|
return '<div class="wf-run-bar">' +
|
|
999
1008
|
(paramsHtml ? '<div class="workflow-params">' + paramsHtml + '</div>' : '') +
|
|
1000
1009
|
'<div class="wf-run-bar-controls">' +
|
|
1001
|
-
'<label class="workflow-run-notify" title="Sends the completed result through this agent' + String.fromCharCode(8217) + 's configured notifier"><input type="checkbox" class="workflow-run-notify-toggle"> Send result to messaging app</label>' +
|
|
1002
1010
|
'<button type="button" class="workflow-run primary">Run now</button></div>' +
|
|
1003
1011
|
'</div>';
|
|
1004
1012
|
}
|
|
@@ -1013,7 +1021,7 @@ ${consoleShellScript}
|
|
|
1013
1021
|
return '<div class="wf-api">' +
|
|
1014
1022
|
'<pre>POST ' + escapeHtml(apiUrl) + String.fromCharCode(10) + escapeHtml(example) + '</pre>' +
|
|
1015
1023
|
'<p class="hint" style="margin:0">' + (paramNames.length ? '<code>params</code>: ' + paramNames.map(function (p) { return '<code>' + escapeHtml(p) + '</code>' + (w.parameters[p].required ? ' (required)' : '') + (w.parameters[p].description ? ', ' + escapeHtml(w.parameters[p].description) : ''); }).join('; ') + '. ' : 'It takes no params. ') +
|
|
1016
|
-
'Optional: <code>"wait": true</code> answers with the result once the run finishes;
|
|
1024
|
+
'Optional: <code>"wait": true</code> answers with the result once the run finishes; without it you get the run' + String.fromCharCode(8217) + 's id back at once. Each run follows this workflow' + String.fromCharCode(8217) + 's <strong>Messages</strong> tab for where its updates, approvals and result go. An app can send its own <code>"callback_url"</code> (and <code>"decisions": "callback"</code>) to get this run' + String.fromCharCode(8217) + 's updates itself.</p>' +
|
|
1017
1025
|
'</div>';
|
|
1018
1026
|
}
|
|
1019
1027
|
|
|
@@ -1130,6 +1138,55 @@ ${consoleShellScript}
|
|
|
1130
1138
|
return 'the agent' + String.fromCharCode(8217) + 's messaging app';
|
|
1131
1139
|
}
|
|
1132
1140
|
|
|
1141
|
+
// Where the agent's approvals go by name ("Telegram", "Webhook"), or
|
|
1142
|
+
// null with none.
|
|
1143
|
+
function workflowChatName() {
|
|
1144
|
+
return workflowsMeta.messaging ? (APP_NAMES[workflowsMeta.messaging] || workflowsMeta.messaging) : null;
|
|
1145
|
+
}
|
|
1146
|
+
// Its chat app by name, for messages people read (Slack, Telegram or
|
|
1147
|
+
// Lark), or null.
|
|
1148
|
+
function workflowChatAppName() {
|
|
1149
|
+
return ['slack', 'telegram', 'lark'].indexOf(workflowsMeta.messaging) !== -1 ? workflowChatName() : null;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Its Messages tab: where every run's updates go, however it starts:
|
|
1153
|
+
// your app's address, a chat message when it starts, where approvals
|
|
1154
|
+
// and questions go, and whether the result is posted to chat.
|
|
1155
|
+
function workflowMessagesHtml(w, agentName) {
|
|
1156
|
+
var d = w.delivery || {};
|
|
1157
|
+
var chat = workflowChatAppName();
|
|
1158
|
+
var chatLabel = escapeHtml(chat || 'chat');
|
|
1159
|
+
// With no messaging app, an unattended run's approvals are refused and
|
|
1160
|
+
// its questions go unanswered (adapters/http.ts, executeUnattendedRun).
|
|
1161
|
+
var decisionsLabel = workflowChatName() ? escapeHtml(workflowChatName())
|
|
1162
|
+
: 'The messaging app <span class="hint">(none set up: approvals are refused and questions go unanswered)</span>';
|
|
1163
|
+
var noChat = chat ? '' : ' disabled';
|
|
1164
|
+
var RSQ = String.fromCharCode(8217);
|
|
1165
|
+
var row = function (label, body) { return '<div class="wf-msg-row"><div class="wf-msg-k">' + label + '</div><div class="wf-msg-v">' + body + '</div></div>'; };
|
|
1166
|
+
// Webhooks saved with settings of their own: their runs use those.
|
|
1167
|
+
var own = (w.triggers || []).filter(function (t) { return t.callback || t.decisions_to || t.chat_notice || t.result_to_chat; });
|
|
1168
|
+
return '<form class="wf-msg-form">' +
|
|
1169
|
+
'<p class="hint" style="margin:0 0 12px">For every run, whether it' + RSQ + 's started by Run now, a schedule, a webhook or the API.' +
|
|
1170
|
+
(chat ? '' : ' This agent has no chat app (Slack, Telegram or Lark): <a href="?agent=' + encodeURIComponent(agentName) + '&tab=messaging">set one up in Messaging</a> to post to chat.') + '</p>' +
|
|
1171
|
+
row('Your app', '<input name="msgUrl" inputmode="url" placeholder="https://example.com/hooks/loopengine" value="' + escapeHtml(d.callback_url || '') + '">' +
|
|
1172
|
+
'<span class="hint">Optional. Gets every run' + RSQ + 's updates as signed JSON: when it stops for a decision, finishes or fails.</span>') +
|
|
1173
|
+
row('When a run starts', '<label class="wf-msg-check"><input type="checkbox" name="msgNoticeOn"' + (d.chat_notice ? ' checked' : noChat) + '> Post to ' + chatLabel + '</label>' +
|
|
1174
|
+
'<input name="msgNotice" maxlength="1000" placeholder="New dispute {{dispute_id}}" value="' + escapeHtml(d.chat_notice || '') + '"' + (d.chat_notice ? '' : ' disabled') + '>' +
|
|
1175
|
+
'<span class="hint">{{name}} puts in an input' + RSQ + 's value.</span>') +
|
|
1176
|
+
row('Approvals and questions', '<label class="wf-msg-check"><input type="radio" name="msgDecisions" value="chat"' + (d.decisions_to === 'callback' ? '' : ' checked') + '> ' + decisionsLabel + '</label>' +
|
|
1177
|
+
'<label class="wf-msg-check"><input type="radio" name="msgDecisions" value="callback"' + (d.decisions_to === 'callback' ? ' checked' : '') + (d.callback_url ? '' : ' disabled') + '> Your app <span class="hint">(it shows them and answers through the API; needs the address above)</span></label>') +
|
|
1178
|
+
row('When a run finishes', '<label class="wf-msg-check"><input type="checkbox" name="msgResult"' + (d.result_to_chat ? ' checked' : noChat) + '> Post the result to ' + chatLabel + '</label>' +
|
|
1179
|
+
'<span class="hint">Your app gets it too, when an address is set.</span>') +
|
|
1180
|
+
(own.length
|
|
1181
|
+
? '<div class="wf-msg-own">' + own.map(function (t) {
|
|
1182
|
+
return '<p class="hint" style="margin:0">The ' + escapeHtml(t.name) + ' webhook has settings of its own, so its runs use those instead. ' +
|
|
1183
|
+
'<button type="button" class="wf-msg-clear-hook" data-trigger="' + escapeHtml(t.trigger_id) + '">Use these instead</button></p>';
|
|
1184
|
+
}).join('') + '</div>'
|
|
1185
|
+
: '') +
|
|
1186
|
+
'<div class="wf-msg-foot"><span class="hint wf-msg-result" role="status"></span><button type="submit" class="primary">Save</button></div>' +
|
|
1187
|
+
'</form>';
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1133
1190
|
// Its Triggers tab: the four ways a run starts, each in its own box
|
|
1134
1191
|
// with what it is: Run now, a schedule, a webhook, the API.
|
|
1135
1192
|
function workflowTriggersHtml(w, name, params) {
|
|
@@ -1181,19 +1238,15 @@ ${consoleShellScript}
|
|
|
1181
1238
|
var result = [];
|
|
1182
1239
|
if (w.output) result.push(escapeHtml(w.output));
|
|
1183
1240
|
result.push('returned to whoever starts it <span class="hint">(Run now, or the app' + RSQ + 's API call)</span>');
|
|
1184
|
-
var notified = (w.schedules || []).some(function (x) { return x.notify && x.status !== 'cancelled'; }) || (w.triggers || []).some(function (t) { return t.result_to_chat; });
|
|
1185
|
-
if (notified) result.push(escapeHtml(workflowsMeta.messaging ? (APP_NAMES[workflowsMeta.messaging] || workflowsMeta.messaging) : 'messaging app') + ' report <span class="hint">(for the schedules and webhooks set to send it)</span>');
|
|
1241
|
+
var notified = (w.delivery && w.delivery.result_to_chat) || (w.schedules || []).some(function (x) { return x.notify && x.status !== 'cancelled'; }) || (w.triggers || []).some(function (t) { return t.result_to_chat; });
|
|
1242
|
+
if (notified) result.push(escapeHtml(workflowsMeta.messaging ? (APP_NAMES[workflowsMeta.messaging] || workflowsMeta.messaging) : 'messaging app') + ' report' + (w.delivery && w.delivery.result_to_chat ? '' : ' <span class="hint">(for the schedules and webhooks set to send it)</span>'));
|
|
1186
1243
|
if ((w.triggers || []).some(function (t) { return t.callback; })) result.push('posted to the webhook' + RSQ + 's update address');
|
|
1187
|
-
if (w.delivery && w.delivery.callback_url) result.push('run updates posted to ' + escapeHtml(w.delivery.callback_url)
|
|
1188
|
-
var decisions = [w.delivery && w.delivery.decisions_to === 'callback'
|
|
1189
|
-
? 'your app at ' + escapeHtml(w.delivery.callback_url) + ' <span class="hint">(not the messaging app; every run, however it starts)</span>'
|
|
1190
|
-
: escapeHtml(workflowsMeta.messaging ? (APP_NAMES[workflowsMeta.messaging] || workflowsMeta.messaging) : 'the agent' + RSQ + 's messaging app')];
|
|
1191
|
-
if ((w.triggers || []).some(function (t) { return t.decisions_to === 'callback'; })) decisions.push('runs from a webhook set to send them to its own update address go there instead');
|
|
1192
|
-
if (w.delivery && w.delivery.chat_notice) decisions.push('a message in the messaging app when each run starts: ' + escapeHtml(w.delivery.chat_notice));
|
|
1244
|
+
if (w.delivery && w.delivery.callback_url) result.push('run updates posted to ' + escapeHtml(w.delivery.callback_url));
|
|
1245
|
+
var decisions = [(w.delivery && w.delivery.decisions_to === 'callback' ? 'your app' : escapeHtml(workflowChatName() || 'the agent' + RSQ + 's messaging app')) + ' <span class="hint">(see Messages)</span>'];
|
|
1193
1246
|
var model = w.model ? escapeHtml(w.model.provider + ' ' + w.model.model) : escapeHtml(workflowsMeta.agentModel || 'the agent' + RSQ + 's') + ' <span class="hint">(the agent' + RSQ + 's model)</span>';
|
|
1194
1247
|
var row = function (k, lines) { return '<div class="wf-cb-k">' + k + '</div><div class="wf-cb-v">' + contractLinesHtml(lines) + '</div>'; };
|
|
1195
1248
|
return '<div class="wf-cb">' + row('trigger', trigger) + row('inputs', inputs) + row('tools', tools) + row('result', result) + row('approvals', decisions) + row('model', [model]) + '</div>' +
|
|
1196
|
-
'<p class="hint" style="margin:0">Change the inputs, result, where
|
|
1249
|
+
'<p class="hint" style="margin:0">Change the inputs, result and model with Edit, where updates and approvals go in Messages, and what tools may do in Permissions.</p>';
|
|
1197
1250
|
}
|
|
1198
1251
|
|
|
1199
1252
|
function workflowBriefHtml(w) {
|
|
@@ -1308,9 +1361,10 @@ ${consoleShellScript}
|
|
|
1308
1361
|
'<div class="wf-row-body"' + (open ? '' : ' hidden') + '>' +
|
|
1309
1362
|
// What it does, in full, once it's open (the row shows just its name).
|
|
1310
1363
|
(w.description && w.description !== w.title ? '<p class="wf-desc">' + escapeHtml(w.description) + '</p>' : '') +
|
|
1311
|
-
'<div class="wf-tabs" role="tablist">' + tabBtn('brief', 'Brief') + tabBtn('contract', 'Contract') + tabBtn('triggers', 'Triggers') + tabBtn('evidence', 'Evidence' + (runs ? ' <span class="wf-tab-count">' + w.recentRuns.length + '</span>' : '')) + '</div>' +
|
|
1364
|
+
'<div class="wf-tabs" role="tablist">' + tabBtn('brief', 'Brief') + tabBtn('contract', 'Contract') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messages') + tabBtn('evidence', 'Evidence' + (runs ? ' <span class="wf-tab-count">' + w.recentRuns.length + '</span>' : '')) + '</div>' +
|
|
1312
1365
|
panel('contract', workflowContractHtml(w, name, params)) +
|
|
1313
1366
|
panel('triggers', workflowTriggersHtml(w, name, params)) +
|
|
1367
|
+
panel('messages', workflowMessagesHtml(w, name)) +
|
|
1314
1368
|
panel('brief', workflowBriefHtml(w)) +
|
|
1315
1369
|
panel('evidence', workflowEvidenceHtml(w, runs)) +
|
|
1316
1370
|
'<div class="hint workflow-result"></div>' +
|
|
@@ -1468,11 +1522,6 @@ ${consoleShellScript}
|
|
|
1468
1522
|
'<div class="wp-model-row"><select name="modelProvider" aria-label="Provider"><option value="">The agent' + String.fromCharCode(8217) + 's model</option>' +
|
|
1469
1523
|
['openai', 'anthropic', 'gemini', 'deepseek', 'kimi', 'glm', 'xai', 'meta'].map(function (p) { return '<option value="' + p + '"' + (w.model && w.model.provider === p ? ' selected' : '') + '>' + p + '</option>'; }).join('') +
|
|
1470
1524
|
'</select><input name="modelName" aria-label="Model name" placeholder="e.g. gpt-6.1-sol" value="' + escapeHtml((w.model && w.model.model) || '') + '"></div></div>' +
|
|
1471
|
-
'<div class="body-field">Your app <span class="hint">(optional: an https address in your own app, told when each run stops for a decision, finishes or fails, whether it' + String.fromCharCode(8217) + 's started by Run now, a schedule, a webhook or the API)</span>' +
|
|
1472
|
-
'<input name="deliveryUrl" inputmode="url" placeholder="https://example.com/hooks/loopengine" value="' + escapeHtml((w.delivery && w.delivery.callback_url) || '') + '">' +
|
|
1473
|
-
'<label class="http-tool-inline-label"><input type="checkbox" name="deliveryDecisions"' + (w.delivery && w.delivery.decisions_to === 'callback' ? ' checked' : '') + (w.delivery && w.delivery.callback_url ? '' : ' disabled') + '> Send approvals and questions there instead of the messaging app <span class="hint">(your app shows them and answers through the API)</span></label></div>' +
|
|
1474
|
-
'<label>Message the chat when a run starts <span class="hint">(optional: posted to the messaging app; {{name}} puts in an input' + String.fromCharCode(8217) + 's value)</span>' +
|
|
1475
|
-
'<input name="deliveryNotice" maxlength="1000" placeholder="New dispute {{dispute_id}}" value="' + escapeHtml((w.delivery && w.delivery.chat_notice) || '') + '"></label>' +
|
|
1476
1525
|
'<p class="hint workflow-editor-check" style="margin:0"></p>' +
|
|
1477
1526
|
'<div class="hint workflow-editor-result"></div>' +
|
|
1478
1527
|
'<div class="ed-actions"><button type="button" class="wp-cancel">Cancel</button><button type="submit" class="primary">Save</button></div></form>';
|
|
@@ -1497,18 +1546,6 @@ ${consoleShellScript}
|
|
|
1497
1546
|
form.querySelector('.workflow-editor-check').textContent = notes.join(' ');
|
|
1498
1547
|
}
|
|
1499
1548
|
|
|
1500
|
-
// The editor's Your app fields, as the save's delivery: null for none.
|
|
1501
|
-
function workflowDeliveryFromForm(form) {
|
|
1502
|
-
var url = form.deliveryUrl.value.trim();
|
|
1503
|
-
var notice = form.deliveryNotice.value.trim();
|
|
1504
|
-
if (!url && !notice) return null;
|
|
1505
|
-
var d = {};
|
|
1506
|
-
if (url) d.callback_url = url;
|
|
1507
|
-
if (url && form.deliveryDecisions.checked) d.decisions = 'callback';
|
|
1508
|
-
if (notice) d.chat_notice = notice;
|
|
1509
|
-
return d;
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
1549
|
function openWorkflowEditor(name, card) {
|
|
1513
1550
|
var w = workflowsById[card.dataset.workflow];
|
|
1514
1551
|
if (!w) return;
|
|
@@ -1534,11 +1571,6 @@ ${consoleShellScript}
|
|
|
1534
1571
|
if (ev.target.classList.contains('wp-remove')) { ev.target.closest('.workflow-param-row').remove(); check(); }
|
|
1535
1572
|
});
|
|
1536
1573
|
form.addEventListener('input', check);
|
|
1537
|
-
// Decisions can only go to an address that's given.
|
|
1538
|
-
form.deliveryUrl.addEventListener('input', function () {
|
|
1539
|
-
form.deliveryDecisions.disabled = !form.deliveryUrl.value.trim();
|
|
1540
|
-
if (form.deliveryDecisions.disabled) form.deliveryDecisions.checked = false;
|
|
1541
|
-
});
|
|
1542
1574
|
form.querySelector('.wp-add').addEventListener('click', function () {
|
|
1543
1575
|
rows.insertAdjacentHTML('beforeend', workflowParamRowHtml('', null));
|
|
1544
1576
|
rows.lastElementChild.querySelector('.wp-name').focus();
|
|
@@ -1584,7 +1616,7 @@ ${consoleShellScript}
|
|
|
1584
1616
|
result.textContent = 'Saving' + String.fromCharCode(8230);
|
|
1585
1617
|
fetchJsonRetryOnce('/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id), {
|
|
1586
1618
|
method: 'PUT', headers: { 'content-type': 'application/json' },
|
|
1587
|
-
body: JSON.stringify({ title: form.title.value, description: form.description.value, instructions: form.instructions.value, parameters: parameters, output: form.output.value, model: form.modelProvider.value && form.modelName.value.trim() ? { provider: form.modelProvider.value, model: form.modelName.value.trim() } : null
|
|
1619
|
+
body: JSON.stringify({ title: form.title.value, description: form.description.value, instructions: form.instructions.value, parameters: parameters, output: form.output.value, model: form.modelProvider.value && form.modelName.value.trim() ? { provider: form.modelProvider.value, model: form.modelName.value.trim() } : null }),
|
|
1588
1620
|
}).then(function (r) {
|
|
1589
1621
|
if (!r.ok) { result.textContent = r.body.error || 'Could not save'; return; }
|
|
1590
1622
|
close();
|
|
@@ -1621,7 +1653,6 @@ ${consoleShellScript}
|
|
|
1621
1653
|
if (t.mapping) rules.push(Object.keys(t.mapping).map(function (p) { return escapeHtml(p) + ' ' + String.fromCharCode(8592) + ' ' + escapeHtml(t.mapping[p]); }).join(', '));
|
|
1622
1654
|
if (t.payload_param) rules.push('the whole payload goes to ' + escapeHtml(t.payload_param));
|
|
1623
1655
|
if (t.chat_notice) rules.push('posts a notice to the messaging app when it starts');
|
|
1624
|
-
if (t.result_to_chat || t.notify) rules.push('<span class="workflow-option-value">Send result to messaging app</span>');
|
|
1625
1656
|
if (t.callback_url) rules.push('sends run updates to ' + escapeHtml(t.callback_url));
|
|
1626
1657
|
if (t.decisions_to === 'callback') rules.push('approvals and questions go there too, not to the messaging app');
|
|
1627
1658
|
// Made by the workflow planner without its secret: it turns on once
|
|
@@ -1699,14 +1730,7 @@ ${consoleShellScript}
|
|
|
1699
1730
|
field('Or give the whole payload to', '<select name="payload_param"><option value="">(none)</option>' + params.map(function (p) { return '<option>' + escapeHtml(p) + '</option>'; }).join('') + '</select>', '')
|
|
1700
1731
|
: '<p class="hd-hint">This workflow takes no inputs, so what the app sends isn' + RSQ + 't passed on. Add one with Edit to use it.</p>') +
|
|
1701
1732
|
'</section>' +
|
|
1702
|
-
'<
|
|
1703
|
-
field('Message the chat when it starts <span class="hd-optional">(optional)</span>', '<input name="chat_notice" maxlength="1000" placeholder="New dispute: {{data.object.amount}} {{data.object.currency}}, {{data.object.reason}}">', 'Posted when each run starts. <code>{{data.object.id}}</code> is filled from what the app sends.') +
|
|
1704
|
-
'<label class="hd-check"><input type="checkbox" name="result_to_chat"><span><strong>Send the result to the messaging app</strong><span class="hd-hint">Through the agent' + RSQ + 's Messaging tab: Slack, Telegram, Lark or another you set up.</span></span></label>' +
|
|
1705
|
-
'</section>' +
|
|
1706
|
-
'<section class="hd-section"><h4>Your app</h4>' +
|
|
1707
|
-
field('Send run updates to <span class="hd-optional">(optional)</span>', '<input name="callback_url" placeholder="https://example.com/hooks/loopengine" inputmode="url">', 'An https address in your own app. It' + RSQ + 's told when each run stops for a decision, finishes or fails.') +
|
|
1708
|
-
'<label class="hd-check"><input type="checkbox" name="decisions_callback" disabled><span><strong>Send approvals and questions here instead of the messaging app</strong><span class="hd-hint">Your app shows them and answers through the API. Needs the address above.</span></span></label>' +
|
|
1709
|
-
'</section>' +
|
|
1733
|
+
'<p class="hd-hint">Where its runs' + RSQ + ' updates, approvals and questions go is set once for the workflow, in its Messages tab.</p>' +
|
|
1710
1734
|
'</div>' +
|
|
1711
1735
|
'<footer class="hd-foot"><span class="hook-form-result" role="status"></span>' +
|
|
1712
1736
|
'<div class="hd-actions"><button type="button" class="hook-dialog-cancel">Cancel</button><button type="submit" class="primary">' + (t ? 'Save' : 'Create webhook') + '</button></div></footer>' +
|
|
@@ -1732,10 +1756,6 @@ ${consoleShellScript}
|
|
|
1732
1756
|
form.name.value = t.name || '';
|
|
1733
1757
|
Object.keys(t.mapping || {}).forEach(function (p) { var input = form.querySelector('input[name="map:' + p + '"]'); if (input) input.value = t.mapping[p]; });
|
|
1734
1758
|
if (form.payload_param && t.payload_param) form.payload_param.value = t.payload_param;
|
|
1735
|
-
form.chat_notice.value = t.chat_notice || '';
|
|
1736
|
-
form.result_to_chat.checked = Boolean(t.result_to_chat || t.notify);
|
|
1737
|
-
form.callback_url.value = t.callback_url || '';
|
|
1738
|
-
form.decisions_callback.checked = t.decisions_to === 'callback';
|
|
1739
1759
|
}
|
|
1740
1760
|
|
|
1741
1761
|
// existing: a webhook to change instead of making one; onDone then gets
|
|
@@ -1766,15 +1786,7 @@ ${consoleShellScript}
|
|
|
1766
1786
|
}
|
|
1767
1787
|
form.sender.addEventListener('change', senderChanged);
|
|
1768
1788
|
form.filter_values.addEventListener('input', function () { form.name.placeholder = defaultName(); });
|
|
1769
|
-
// Decisions can only go to an address that's given.
|
|
1770
|
-
function callbackChanged() {
|
|
1771
|
-
form.decisions_callback.disabled = !form.callback_url.value.trim();
|
|
1772
|
-
if (form.decisions_callback.disabled) form.decisions_callback.checked = false;
|
|
1773
|
-
}
|
|
1774
|
-
form.callback_url.addEventListener('input', callbackChanged);
|
|
1775
1789
|
if (existing) fillHookForm(form, existing);
|
|
1776
|
-
callbackChanged();
|
|
1777
|
-
if (existing) form.decisions_callback.checked = existing.decisions_to === 'callback' && !form.decisions_callback.disabled;
|
|
1778
1790
|
senderChanged();
|
|
1779
1791
|
form.addEventListener('submit', function (ev) {
|
|
1780
1792
|
ev.preventDefault();
|
|
@@ -1799,15 +1811,11 @@ ${consoleShellScript}
|
|
|
1799
1811
|
for (var j = 0; j < inputs.length; j++) if (inputs[j].value.trim()) mapping[inputs[j].name.slice(4)] = inputs[j].value.trim();
|
|
1800
1812
|
if (Object.keys(mapping).length) body.mapping = mapping;
|
|
1801
1813
|
if (form.payload_param && form.payload_param.value) body.payload_param = form.payload_param.value;
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
if (body.callback_url && form.decisions_callback.checked) body.decisions = 'callback';
|
|
1805
|
-
if (form.chat_notice.value.trim()) body.chat_notice = form.chat_notice.value.trim();
|
|
1806
|
-
// A change says what's cleared too; a setting left out is kept.
|
|
1814
|
+
// A change says what's cleared too; a setting left out is kept (its
|
|
1815
|
+
// own message settings, from before: the Messages tab clears them).
|
|
1807
1816
|
if (existing) {
|
|
1808
|
-
['verify', 'filter', 'mapping'
|
|
1817
|
+
['verify', 'filter', 'mapping'].forEach(function (k) { if (!(k in body)) body[k] = null; });
|
|
1809
1818
|
if (!('payload_param' in body)) body.payload_param = '';
|
|
1810
|
-
if (!body.result_to_chat) body.result_to_chat = false;
|
|
1811
1819
|
}
|
|
1812
1820
|
var failed = existing ? 'Could not save it' : 'Could not make it';
|
|
1813
1821
|
result.textContent = (existing ? 'Saving' : 'Making it') + String.fromCharCode(8230);
|
|
@@ -1944,6 +1952,49 @@ ${consoleShellScript}
|
|
|
1944
1952
|
if (!card.classList.contains('is-open')) setWorkflowOpen(card, true);
|
|
1945
1953
|
showWorkflowTab(card, 'triggers');
|
|
1946
1954
|
});
|
|
1955
|
+
// Messages: where every run's updates and decisions go.
|
|
1956
|
+
var msgForm = card.querySelector('.wf-msg-form');
|
|
1957
|
+
if (msgForm) {
|
|
1958
|
+
var msgResult = msgForm.querySelector('.wf-msg-result');
|
|
1959
|
+
var appRadio = msgForm.querySelector('input[name="msgDecisions"][value="callback"]');
|
|
1960
|
+
// Decisions can only go to an address that's given.
|
|
1961
|
+
msgForm.msgUrl.addEventListener('input', function () {
|
|
1962
|
+
appRadio.disabled = !msgForm.msgUrl.value.trim();
|
|
1963
|
+
if (appRadio.disabled && appRadio.checked) msgForm.querySelector('input[name="msgDecisions"][value="chat"]').checked = true;
|
|
1964
|
+
});
|
|
1965
|
+
msgForm.msgNoticeOn.addEventListener('change', function () {
|
|
1966
|
+
msgForm.msgNotice.disabled = !msgForm.msgNoticeOn.checked;
|
|
1967
|
+
if (msgForm.msgNoticeOn.checked) msgForm.msgNotice.focus();
|
|
1968
|
+
});
|
|
1969
|
+
var reloadOnMessages = function () { workflowTabs[id] = 'messages'; loadWorkflowsSection(name); };
|
|
1970
|
+
msgForm.addEventListener('submit', function (ev) {
|
|
1971
|
+
ev.preventDefault();
|
|
1972
|
+
var url = msgForm.msgUrl.value.trim();
|
|
1973
|
+
var body = {};
|
|
1974
|
+
if (url) body.callback_url = url;
|
|
1975
|
+
if (url && appRadio.checked) body.decisions = 'callback';
|
|
1976
|
+
if (msgForm.msgNoticeOn.checked && msgForm.msgNotice.value.trim()) body.chat_notice = msgForm.msgNotice.value.trim();
|
|
1977
|
+
if (msgForm.msgResult.checked) body.result_to_chat = true;
|
|
1978
|
+
msgResult.textContent = 'Saving' + String.fromCharCode(8230);
|
|
1979
|
+
fetchJsonRetryOnce(base + '/messages', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }).then(function (r) {
|
|
1980
|
+
if (!r.ok) { msgResult.textContent = r.body.error || 'Could not save'; return; }
|
|
1981
|
+
reloadOnMessages();
|
|
1982
|
+
});
|
|
1983
|
+
});
|
|
1984
|
+
var clearButtons = msgForm.querySelectorAll('.wf-msg-clear-hook');
|
|
1985
|
+
for (var cb = 0; cb < clearButtons.length; cb++) {
|
|
1986
|
+
clearButtons[cb].addEventListener('click', function (ev) {
|
|
1987
|
+
var tid = ev.currentTarget.dataset.trigger;
|
|
1988
|
+
fetchJsonRetryOnce(base + '/triggers/' + encodeURIComponent(tid), {
|
|
1989
|
+
method: 'PUT', headers: { 'content-type': 'application/json' },
|
|
1990
|
+
body: JSON.stringify({ callback_url: null, decisions: null, chat_notice: null, result_to_chat: false }),
|
|
1991
|
+
}).then(function (r) {
|
|
1992
|
+
if (!r.ok) { msgResult.textContent = r.body.error || 'Could not change the webhook'; return; }
|
|
1993
|
+
reloadOnMessages();
|
|
1994
|
+
});
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1947
1998
|
// Evidence: save a run as an eval case, change or remove a case, run them.
|
|
1948
1999
|
card.querySelector('.wf-row-body').addEventListener('click', function (ev) {
|
|
1949
2000
|
var btn = ev.target.closest('.wf-save-case, .wf-case-remove, .wf-case-save, .wf-evals-run');
|
|
@@ -2015,17 +2066,13 @@ ${consoleShellScript}
|
|
|
2015
2066
|
if (!value && inputs[i].required) { result.textContent = 'Fill in ' + inputs[i].name + ' first.'; inputs[i].focus(); return; }
|
|
2016
2067
|
if (value) params[inputs[i].name] = value;
|
|
2017
2068
|
}
|
|
2018
|
-
var notifyToggle = card.querySelector('.workflow-run-notify-toggle');
|
|
2019
|
-
var notifyResult = notifyToggle.checked;
|
|
2020
|
-
notifyToggle.disabled = true;
|
|
2021
2069
|
btn.disabled = true;
|
|
2022
2070
|
result.textContent = 'Starting' + String.fromCharCode(8230);
|
|
2023
|
-
fetchJsonRetryOnce(base + '/run', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ params: params, source: 'console'
|
|
2071
|
+
fetchJsonRetryOnce(base + '/run', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ params: params, source: 'console' }) }).then(function (r) {
|
|
2024
2072
|
btn.disabled = false;
|
|
2025
|
-
notifyToggle.disabled = false;
|
|
2026
2073
|
if (!r.ok) { result.textContent = r.body.error || 'Could not start it.'; return; }
|
|
2027
2074
|
var started = workflowsById[id];
|
|
2028
|
-
result.innerHTML = 'Started. Questions and approvals go to ' + workflowDecisionsTo(started || {}) + '; the result shows under Evidence.' + (
|
|
2075
|
+
result.innerHTML = 'Started. Questions and approvals go to ' + workflowDecisionsTo(started || {}) + '; the result shows under Evidence.' + (started && started.delivery && started.delivery.result_to_chat ? ' The result will also be posted to the messaging app when it finishes.' : '') +
|
|
2029
2076
|
(r.body.warnings ? ' ' + escapeHtml(r.body.warnings.join(' ')) : '');
|
|
2030
2077
|
setTimeout(function () { loadWorkflowsSection(name); }, 800);
|
|
2031
2078
|
});
|
|
@@ -3370,7 +3417,9 @@ ${consoleShellScript}
|
|
|
3370
3417
|
: t.workflow_missing
|
|
3371
3418
|
? '<div><span class="le-pill bad">Workflow removed</span> <span class="hint">' + escapeHtml(t.workflow_id) + '</span></div>'
|
|
3372
3419
|
: '<div class="schedule-result hint">' + escapeHtml(t.message) + '</div>') +
|
|
3373
|
-
|
|
3420
|
+
// A workflow's schedule follows its Messages tab; one ticked from
|
|
3421
|
+
// before can still be turned off here.
|
|
3422
|
+
(t.status !== 'cancelled' && t.status !== 'done' && (!t.workflow_id || t.notify)
|
|
3374
3423
|
? '<label class="schedule-notify hint" title="Sent through its Messaging tab: Slack, email, Lark or a webhook"><input type="checkbox" class="schedule-notify-toggle" data-id="' + escapeHtml(t.task_id) + '"' + (t.notify ? ' checked' : '') + '> Send result to messaging app</label>'
|
|
3375
3424
|
: (t.notify ? '<div><span class="workflow-option-value">Send result to messaging app</span></div>' : '')) + '</td>' +
|
|
3376
3425
|
'<td>' + scheduleText(t.schedule) + (t.next_run_at ? '<div class="hint">next ' + escapeHtml(fmtScheduleTime(t.next_run_at)) + '</div>' : '') + '</td>' +
|
|
@@ -3414,7 +3463,7 @@ ${consoleShellScript}
|
|
|
3414
3463
|
'<input type="datetime-local" name="runAt" aria-label="Date and time"></div>' +
|
|
3415
3464
|
'</div>' +
|
|
3416
3465
|
'<label>Name <span class="hint">(optional)</span><input name="task_name" placeholder="Daily ticket summary"></label>' +
|
|
3417
|
-
'<label class="http-tool-inline-label"><input type="checkbox" name="notify"> Send result to messaging app <span class="hint">(through its Messaging tab: Slack, email, Lark or a webhook)</span></label>' +
|
|
3466
|
+
'<label class="http-tool-inline-label" id="scheduleNotifyField"' + (schedulesWorkflows.length ? ' hidden' : '') + '><input type="checkbox" name="notify"> Send result to messaging app <span class="hint">(through its Messaging tab: Slack, email, Lark or a webhook)</span></label>' +
|
|
3418
3467
|
'<div style="display:flex;gap:8px"><button type="submit">Schedule</button></div>' +
|
|
3419
3468
|
'<div id="scheduleResult" class="hint"></div>' +
|
|
3420
3469
|
'</form></section>';
|
|
@@ -3516,6 +3565,9 @@ ${consoleShellScript}
|
|
|
3516
3565
|
var byMessage = form.querySelector('input[name="runs"]:checked').value === 'message';
|
|
3517
3566
|
messageField.hidden = !byMessage;
|
|
3518
3567
|
if (paramsBox) paramsBox.hidden = byMessage;
|
|
3568
|
+
// A workflow's result goes where its Messages tab says.
|
|
3569
|
+
var notifyField = form.querySelector('#scheduleNotifyField');
|
|
3570
|
+
if (notifyField) notifyField.hidden = !byMessage;
|
|
3519
3571
|
});
|
|
3520
3572
|
}
|
|
3521
3573
|
form.addEventListener('submit', function (ev) {
|
|
@@ -3539,7 +3591,7 @@ ${consoleShellScript}
|
|
|
3539
3591
|
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
3540
3592
|
body: JSON.stringify(Object.assign(
|
|
3541
3593
|
runsWorkflow ? { workflow_id: data.get('workflow_id'), params: scheduleParams(data) } : { message: data.get('message') },
|
|
3542
|
-
{ schedule: schedule, task_name: data.get('task_name'), result_to_chat: data.get('notify') === 'on' }
|
|
3594
|
+
{ schedule: schedule, task_name: data.get('task_name'), result_to_chat: !runsWorkflow && data.get('notify') === 'on' }
|
|
3543
3595
|
)),
|
|
3544
3596
|
}).then(function (r) {
|
|
3545
3597
|
if (!r.ok) { result.textContent = r.body.error || 'Could not schedule'; return; }
|
|
@@ -319,6 +319,10 @@ export declare function contractFields(input: Record<string, unknown>): {
|
|
|
319
319
|
model?: WorkflowModel | null;
|
|
320
320
|
output?: string | null;
|
|
321
321
|
};
|
|
322
|
+
/** The Messages tab's save: where every run's updates, approvals and
|
|
323
|
+
* questions, start notice and result go. { callback_url, decisions,
|
|
324
|
+
* chat_notice, result_to_chat }; empty for the messaging app's defaults. */
|
|
325
|
+
export declare function updateWorkflowMessages(agentDir: string, id: string, input: Record<string, unknown>): Workflow;
|
|
322
326
|
export declare function updateWorkflow(agentDir: string, id: string, input: Record<string, unknown>): Workflow;
|
|
323
327
|
/** Removes a workflow: its skill stays, as a plain skill the agent can
|
|
324
328
|
* still use in chat, and what started it goes: its schedules are
|
|
@@ -16,7 +16,7 @@ import { planParameters, planWebhook, planWorkflowWithModel, workflowTemplate }
|
|
|
16
16
|
import { checkRunDelivery, createTrigger, getTriggerStore, listTriggers, publicTrigger } from '../core/workflow-triggers.js';
|
|
17
17
|
import { mcpAbilityNames } from '../core/mcp-ability-generator.js';
|
|
18
18
|
import { contextToolsFor } from '../core/mcp-apps.js';
|
|
19
|
-
import { clearWorkflowFields, migrateWorkflowsFile, readWorkflow, readWorkflows, setWorkflowFields, validateParams, workflowRunMessage } from '../core/workflows.js';
|
|
19
|
+
import { clearWorkflowFields, migrateWorkflowsFile, readWorkflow, readWorkflows, setWorkflowDelivery, setWorkflowFields, validateParams, workflowRunMessage } from '../core/workflows.js';
|
|
20
20
|
import { readEvals, workflowScores } from './workflow-evidence.js';
|
|
21
21
|
import { isUnderWay, listRuns } from '../core/workflow-runs.js';
|
|
22
22
|
import { cancelScheduledTask, createScheduledTask, deleteScheduledTask, describeSchedule, getSchedulerStore, listScheduledTasks, pauseScheduledTask } from '../core/scheduler.js';
|
|
@@ -830,13 +830,24 @@ export function contractFields(input) {
|
|
|
830
830
|
else if (typeof input.delivery !== 'object' || Array.isArray(input.delivery))
|
|
831
831
|
throw new WorkflowError('delivery must be { callback_url, decisions, chat_notice }, or null.');
|
|
832
832
|
else {
|
|
833
|
-
|
|
834
|
-
const { result_to_chat: _r, ...kept } = d;
|
|
835
|
-
fields.delivery = Object.keys(kept).length ? kept : null;
|
|
833
|
+
fields.delivery = deliveryOf(input.delivery);
|
|
836
834
|
}
|
|
837
835
|
}
|
|
838
836
|
return fields;
|
|
839
837
|
}
|
|
838
|
+
function deliveryOf(input) {
|
|
839
|
+
const d = checkRunDelivery(input, (m) => new WorkflowError(m));
|
|
840
|
+
return Object.keys(d).length ? d : null;
|
|
841
|
+
}
|
|
842
|
+
/** The Messages tab's save: where every run's updates, approvals and
|
|
843
|
+
* questions, start notice and result go. { callback_url, decisions,
|
|
844
|
+
* chat_notice, result_to_chat }; empty for the messaging app's defaults. */
|
|
845
|
+
export function updateWorkflowMessages(agentDir, id, input) {
|
|
846
|
+
if (!readWorkflow(agentDir, id))
|
|
847
|
+
throw new WorkflowError(`No workflow ${id}.`);
|
|
848
|
+
setWorkflowDelivery(agentDir, id, deliveryOf(input));
|
|
849
|
+
return readWorkflow(agentDir, id);
|
|
850
|
+
}
|
|
840
851
|
export function updateWorkflow(agentDir, id, input) {
|
|
841
852
|
if (!readWorkflow(agentDir, id))
|
|
842
853
|
throw new WorkflowError(`No workflow ${id}.`);
|