@omnidim-ai/mcp-server 0.15.0 → 0.16.1
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/build/index.d.ts +1 -1
- package/build/index.js +3 -2
- package/build/index.js.map +1 -1
- package/build/procedures.js +8 -5
- package/build/procedures.js.map +1 -1
- package/build/tool-annotations.js +1 -0
- package/build/tool-annotations.js.map +1 -1
- package/build/workflow-canvas.d.ts +15 -1
- package/build/workflow-canvas.js +378 -116
- package/build/workflow-canvas.js.map +1 -1
- package/package.json +3 -1
- package/src/index.ts +3 -2
- package/src/procedures.ts +8 -5
- package/src/tool-annotations.ts +1 -0
- package/src/workflow-canvas.ts +389 -117
package/build/workflow-canvas.js
CHANGED
|
@@ -1,29 +1,87 @@
|
|
|
1
|
-
// MCP Apps view (ui:// resource) that
|
|
1
|
+
// MCP Apps view (ui:// resource) that shows and edits a workflow draft inside the chat.
|
|
2
2
|
// The page holds no API key: every read and edit goes back through this
|
|
3
3
|
// server's own tools via the host, so it runs on the user's existing login.
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
// Where the canvas lived before its address carried a hash. Chats that showed it still ask for it there.
|
|
6
|
+
export const LEGACY_CANVAS_URI = "ui://omnidim/workflow-canvas";
|
|
7
|
+
// Only showWorkflow draws the canvas. Linking get/create/edit posted one canvas per build step.
|
|
6
8
|
export function toolMeta(name) {
|
|
7
|
-
return
|
|
9
|
+
return name === "showWorkflow" ? { ui: { resourceUri: WORKFLOW_CANVAS_URI } } : undefined;
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
const SHOW_WORKFLOW_DESCRIPTION = `Show a workflow to the user as an interactive canvas in the chat, where they can move, rename, edit and delete nodes. Call it when the user asks to see a workflow, and once after you finish building or changing one. Do not call it before every edit: use \`getWorkflow\` to read the draft.
|
|
12
|
+
|
|
13
|
+
(Tags: Workflows)`;
|
|
14
|
+
// showWorkflow reads the same endpoint as getWorkflow; it exists so the canvas has one trigger.
|
|
15
|
+
export function addShowWorkflow(map) {
|
|
16
|
+
const get = map.get("getWorkflow");
|
|
17
|
+
if (!get)
|
|
18
|
+
return;
|
|
19
|
+
map.set("showWorkflow", {
|
|
20
|
+
...get,
|
|
21
|
+
name: "showWorkflow",
|
|
22
|
+
description: SHOW_WORKFLOW_DESCRIPTION,
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: { workflow_id: get.inputSchema.properties.workflow_id },
|
|
26
|
+
required: ["workflow_id"],
|
|
27
|
+
},
|
|
28
|
+
executionParameters: get.executionParameters.filter((p) => p.name === "workflow_id"),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// The three helpers below are embedded into the page with toString(), so they must not
|
|
32
|
+
// reference anything outside themselves.
|
|
10
33
|
export function readWorkflow(result) {
|
|
11
34
|
const text = (result.content || []).filter((c) => c.type === "text").map((c) => c.text || "").join("\n");
|
|
12
35
|
if (result.isError)
|
|
13
|
-
return { workflow: null, workflowId: null, error: text };
|
|
36
|
+
return { workflow: null, workflowId: null, issues: [], error: text };
|
|
14
37
|
const body = text.startsWith("API Response") ? text.slice(text.indexOf("\n") + 1) : text;
|
|
15
38
|
let data;
|
|
16
39
|
try {
|
|
17
40
|
data = JSON.parse(body);
|
|
18
41
|
}
|
|
19
42
|
catch {
|
|
20
|
-
return { workflow: null, workflowId: null, error: text };
|
|
43
|
+
return { workflow: null, workflowId: null, issues: [], error: text };
|
|
21
44
|
}
|
|
22
45
|
const wf = data && (data.workflow || data);
|
|
23
46
|
const id = wf && (wf.id ?? wf.workflow_id);
|
|
24
47
|
const workflowId = typeof id === "number" ? id : null;
|
|
25
|
-
|
|
48
|
+
const src = data && data.issues ? data.issues : data;
|
|
49
|
+
const issues = src && Array.isArray(src.errors) ? src.errors : [];
|
|
50
|
+
return { workflow: wf && wf.draft ? wf : null, workflowId, issues, error: null };
|
|
26
51
|
}
|
|
52
|
+
// The hosted server takes edit fields flat; the npm server takes them under requestBody.
|
|
53
|
+
// Each drops the shape it does not use, and the API ignores the extra key.
|
|
54
|
+
export function editArgs(workflowId, revision, ops) {
|
|
55
|
+
return { workflow_id: workflowId, revision, ops, requestBody: { revision, ops } };
|
|
56
|
+
}
|
|
57
|
+
export function errorText(text) {
|
|
58
|
+
const start = text.indexOf("{");
|
|
59
|
+
if (start >= 0) {
|
|
60
|
+
try {
|
|
61
|
+
const data = JSON.parse(text.slice(start));
|
|
62
|
+
const msg = data.error_description || data.message || data.detail || data.error;
|
|
63
|
+
if (typeof msg === "string" && msg)
|
|
64
|
+
return msg;
|
|
65
|
+
}
|
|
66
|
+
catch { /* not JSON: fall through to the plain text */ }
|
|
67
|
+
}
|
|
68
|
+
return text.length > 160 ? text.slice(0, 157) + "..." : text;
|
|
69
|
+
}
|
|
70
|
+
// Icon shapes copied from lucide (the set the dashboard's workflow editor uses).
|
|
71
|
+
const ICONS = {
|
|
72
|
+
zap: '<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>',
|
|
73
|
+
phone: '<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/>',
|
|
74
|
+
clock: '<circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>',
|
|
75
|
+
branch: '<line x1="6" x2="6" y1="3" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',
|
|
76
|
+
mail: '<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>',
|
|
77
|
+
globe: '<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>',
|
|
78
|
+
braces: '<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"/>',
|
|
79
|
+
workflow: '<rect width="8" height="8" x="3" y="3" rx="2"/><path d="M7 11v4a2 2 0 0 0 2 2h4"/><rect width="8" height="8" x="13" y="13" rx="2"/>',
|
|
80
|
+
message: '<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',
|
|
81
|
+
sparkles: '<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>',
|
|
82
|
+
user: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><line x1="19" x2="19" y1="8" y2="14"/><line x1="22" x2="16" y1="11" y2="11"/>',
|
|
83
|
+
note: '<path d="M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z"/><path d="M15 3v4a2 2 0 0 0 2 2h4"/>',
|
|
84
|
+
};
|
|
27
85
|
export const WORKFLOW_CANVAS_HTML = `<!doctype html>
|
|
28
86
|
<html lang="en">
|
|
29
87
|
<head>
|
|
@@ -31,68 +89,99 @@ export const WORKFLOW_CANVAS_HTML = `<!doctype html>
|
|
|
31
89
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
32
90
|
<title>Workflow canvas</title>
|
|
33
91
|
<style>
|
|
92
|
+
/* Colors follow the dashboard's workflow editor tokens. */
|
|
34
93
|
:root {
|
|
35
|
-
--bg:
|
|
36
|
-
--
|
|
37
|
-
--
|
|
94
|
+
--bg: hsl(210 30% 96%); --card: hsl(210 30% 99%); --fg: hsl(222 47% 9%); --muted: hsl(215 19% 36%);
|
|
95
|
+
--line: hsl(214 25% 87%); --edge: #94a3b8; --dot: hsl(214 25% 84%); --primary: hsl(172.5 66% 40.4%);
|
|
96
|
+
--primary-soft: hsl(172.5 66% 40.4% / .12); --sel: #fbbf24; --err: #dc2626; --err-soft: hsl(0 84% 60% / .08);
|
|
38
97
|
color-scheme: light;
|
|
39
98
|
}
|
|
40
99
|
:root[data-theme="dark"] {
|
|
41
|
-
--bg:
|
|
42
|
-
--
|
|
43
|
-
--
|
|
100
|
+
--bg: hsl(0 0% 3.9%); --card: hsl(0 0% 7%); --fg: hsl(0 0% 98%); --muted: hsl(0 0% 64%);
|
|
101
|
+
--line: hsl(0 0% 16%); --edge: #64748b; --dot: hsl(0 0% 14%); --primary: hsl(180 100% 35.1%);
|
|
102
|
+
--primary-soft: hsl(180 100% 35.1% / .16); --sel: #fbbf24; --err: #f87171; --err-soft: hsl(0 91% 71% / .1);
|
|
44
103
|
color-scheme: dark;
|
|
45
104
|
}
|
|
46
105
|
* { box-sizing: border-box; }
|
|
47
|
-
body { margin: 0; font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--
|
|
48
|
-
header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
|
|
106
|
+
body { margin: 0; font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
|
|
107
|
+
header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--card); }
|
|
49
108
|
header h1 { font-size: 14px; margin: 0; font-weight: 600; flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
50
109
|
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
|
|
51
|
-
|
|
110
|
+
.pill.bad { color: var(--err); border-color: var(--err); }
|
|
111
|
+
button, input, textarea { font: inherit; font-size: 12px; color: var(--fg); }
|
|
112
|
+
button { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
|
|
52
113
|
button:hover { border-color: var(--edge); }
|
|
53
|
-
button:
|
|
54
|
-
|
|
55
|
-
:
|
|
114
|
+
button:disabled { opacity: .6; cursor: progress; }
|
|
115
|
+
button.danger { color: var(--err); }
|
|
116
|
+
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
|
|
117
|
+
#stage { overflow: auto; background-color: var(--bg); background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 16px 16px; }
|
|
118
|
+
:root[data-mode="fullscreen"] #stage { height: calc(100vh - 52px - var(--panel-h, 0px)); }
|
|
56
119
|
svg { display: block; touch-action: none; }
|
|
57
|
-
.
|
|
58
|
-
.node
|
|
120
|
+
.card { fill: var(--card); stroke: var(--line); stroke-width: 1; }
|
|
121
|
+
.node:hover .card { stroke: var(--primary); }
|
|
122
|
+
.node.selected .card { stroke: var(--sel); stroke-width: 2; }
|
|
123
|
+
.node.invalid .card { stroke: var(--err); stroke-width: 1.5; }
|
|
59
124
|
.node { cursor: grab; }
|
|
60
|
-
.node.dragging { cursor: grabbing;
|
|
61
|
-
.
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
125
|
+
.node.dragging { cursor: grabbing; }
|
|
126
|
+
.icon-box { fill: var(--primary-soft); }
|
|
127
|
+
.icon { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
128
|
+
.label { font-size: 13px; font-weight: 600; fill: var(--fg); }
|
|
129
|
+
.sub { font-size: 11.5px; fill: var(--muted); }
|
|
130
|
+
.handle { fill: var(--edge); stroke: var(--card); stroke-width: 2; }
|
|
131
|
+
.edge { fill: none; stroke: var(--edge); stroke-width: 2; }
|
|
132
|
+
.chip rect { fill: var(--card); stroke: var(--line); }
|
|
133
|
+
.chip text { font-size: 10px; font-weight: 700; letter-spacing: .04em; fill: var(--muted); text-transform: uppercase; }
|
|
134
|
+
.skel { fill: var(--card); stroke: var(--line); }
|
|
135
|
+
@media (prefers-reduced-motion: no-preference) { .skel { animation: pulse 1.2s ease-in-out infinite; } }
|
|
136
|
+
@keyframes pulse { 50% { opacity: .5; } }
|
|
137
|
+
#panel { padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card); display: grid; gap: 8px; }
|
|
138
|
+
#panel[hidden] { display: none; }
|
|
139
|
+
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
68
140
|
.muted { color: var(--muted); }
|
|
69
|
-
#
|
|
70
|
-
#
|
|
141
|
+
#n-label { flex: 1 1 180px; min-width: 0; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
|
|
142
|
+
#n-config { width: 100%; min-height: 120px; max-height: 240px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
|
|
143
|
+
#n-errors { color: var(--err); background: var(--err-soft); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
|
|
144
|
+
#n-errors[hidden] { display: none; }
|
|
145
|
+
#notice { font-size: 12px; color: var(--err); padding: 6px 12px; border-top: 1px solid var(--line); background: var(--err-soft); }
|
|
146
|
+
#notice.info { color: var(--muted); background: var(--card); }
|
|
147
|
+
#notice[hidden] { display: none; }
|
|
71
148
|
</style>
|
|
72
149
|
</head>
|
|
73
150
|
<body>
|
|
74
151
|
<header>
|
|
75
152
|
<h1 id="title">Loading workflow</h1>
|
|
76
153
|
<span class="pill" id="state" hidden></span>
|
|
77
|
-
<
|
|
154
|
+
<span class="pill bad" id="issues" hidden></span>
|
|
155
|
+
<button id="refresh" type="button">Reload</button>
|
|
78
156
|
<button id="full" type="button">Full screen</button>
|
|
79
157
|
<button id="open" type="button">Open in dashboard</button>
|
|
80
158
|
</header>
|
|
81
159
|
<div id="stage"><svg id="canvas" role="img" aria-label="Workflow graph"></svg></div>
|
|
82
|
-
<div id="
|
|
83
|
-
|
|
84
|
-
<div
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
<
|
|
160
|
+
<div id="notice" role="status" hidden></div>
|
|
161
|
+
<div id="panel" hidden>
|
|
162
|
+
<div class="row">
|
|
163
|
+
<input id="n-label" aria-label="Node name">
|
|
164
|
+
<span class="pill" id="n-type"></span>
|
|
165
|
+
<span class="muted" id="n-id"></span>
|
|
166
|
+
</div>
|
|
167
|
+
<div id="n-errors" hidden></div>
|
|
168
|
+
<textarea id="n-config" aria-label="Node settings (JSON)" spellcheck="false"></textarea>
|
|
169
|
+
<div class="row">
|
|
170
|
+
<button id="save" type="button">Save changes</button>
|
|
171
|
+
<button id="delete" type="button" class="danger">Delete node</button>
|
|
172
|
+
<button id="ask" type="button">Ask Claude about this node</button>
|
|
88
173
|
</div>
|
|
89
174
|
</div>
|
|
90
175
|
<script>
|
|
91
176
|
const readWorkflow = ${readWorkflow.toString()};
|
|
92
|
-
const
|
|
177
|
+
const editArgs = ${editArgs.toString()};
|
|
178
|
+
const errorText = ${errorText.toString()};
|
|
179
|
+
const ICONS = ${JSON.stringify(ICONS)};
|
|
180
|
+
// Card size and handles match the dashboard editor: inputs on top, outputs at the bottom.
|
|
181
|
+
const NODE_W = 220, NODE_H = 62, PAD = 40, MIN_SCALE = 0.7, FALLBACK_MS = 800;
|
|
93
182
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
94
183
|
const $ = (id) => document.getElementById(id);
|
|
95
|
-
const state = { wf: null, id: null, selected: null, busy: false };
|
|
184
|
+
const state = { wf: null, id: null, issues: [], selected: null, busy: false, dirty: false, dragging: false, redraw: false, form: null };
|
|
96
185
|
|
|
97
186
|
// JSON-RPC over postMessage to the host (MCP Apps protocol 2026-01-26).
|
|
98
187
|
let nextId = 1;
|
|
@@ -117,6 +206,8 @@ window.addEventListener("message", (event) => {
|
|
|
117
206
|
if (msg.method === "ui/notifications/tool-input") {
|
|
118
207
|
const id = msg.params && msg.params.arguments && msg.params.arguments.workflow_id;
|
|
119
208
|
if (typeof id === "number") state.id = id;
|
|
209
|
+
// Some hosts hand over the result late; load it ourselves instead of sitting empty.
|
|
210
|
+
setTimeout(() => { if (!state.wf) refresh(); }, FALLBACK_MS);
|
|
120
211
|
} else if (msg.method === "ui/notifications/tool-result") {
|
|
121
212
|
applyResult(msg.params);
|
|
122
213
|
} else if (msg.method === "ui/notifications/host-context-changed") {
|
|
@@ -134,42 +225,89 @@ function applyContext(ctx) {
|
|
|
134
225
|
if (ctx.displayMode) document.documentElement.dataset.mode = ctx.displayMode;
|
|
135
226
|
}
|
|
136
227
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
$("
|
|
228
|
+
// The bar under the canvas stays hidden unless something needs the user's attention.
|
|
229
|
+
function notice(text, kind) {
|
|
230
|
+
const el = $("notice");
|
|
231
|
+
el.hidden = !text;
|
|
232
|
+
el.textContent = text || "";
|
|
233
|
+
el.className = kind === "info" ? "info" : "";
|
|
140
234
|
}
|
|
141
235
|
|
|
142
|
-
|
|
143
|
-
return request("tools/call", { name, arguments: args });
|
|
144
|
-
}
|
|
236
|
+
function callTool(name, args) { return request("tools/call", { name, arguments: args }); }
|
|
145
237
|
|
|
146
238
|
async function refresh() {
|
|
147
239
|
if (state.id == null || state.busy) return;
|
|
148
|
-
state.busy = true;
|
|
149
|
-
try {
|
|
150
|
-
|
|
240
|
+
state.busy = true;
|
|
241
|
+
try {
|
|
242
|
+
const r = readWorkflow(await callTool("getWorkflow", { workflow_id: state.id }));
|
|
243
|
+
if (r.error) notice("Could not load the workflow: " + errorText(r.error));
|
|
244
|
+
else if (r.workflow) show(r.workflow, null);
|
|
245
|
+
} catch (e) { notice("Could not load the workflow: " + e.message); }
|
|
151
246
|
finally { state.busy = false; }
|
|
152
247
|
}
|
|
153
248
|
|
|
154
249
|
function applyResult(result) {
|
|
155
250
|
const r = readWorkflow(result || {});
|
|
156
|
-
if (r.error) {
|
|
251
|
+
if (r.error) { notice(errorText(r.error)); return; }
|
|
157
252
|
if (r.workflowId != null) state.id = r.workflowId;
|
|
158
253
|
if (!r.workflow) { refresh(); return; }
|
|
159
|
-
|
|
254
|
+
show(r.workflow, r.issues);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function show(wf, issues) {
|
|
258
|
+
state.wf = wf;
|
|
259
|
+
if (issues) state.issues = issues;
|
|
260
|
+
notice("");
|
|
160
261
|
render();
|
|
161
|
-
|
|
262
|
+
validate();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// getWorkflow carries no problems, so ask validateWorkflow which nodes to mark, like the dashboard does.
|
|
266
|
+
async function validate() {
|
|
267
|
+
try {
|
|
268
|
+
const r = readWorkflow(await callTool("validateWorkflow", { workflow_id: state.id }));
|
|
269
|
+
if (!r.error) { state.issues = r.issues; render(); }
|
|
270
|
+
} catch { /* the marks are a hint; the canvas works without them */ }
|
|
162
271
|
}
|
|
163
272
|
|
|
164
|
-
function
|
|
165
|
-
if (type === "trigger" || type.endsWith("_trigger")) return "
|
|
166
|
-
if (type
|
|
167
|
-
if (type
|
|
168
|
-
if (type
|
|
169
|
-
if (type.includes("email")) return "
|
|
170
|
-
|
|
273
|
+
function iconFor(type) {
|
|
274
|
+
if (type === "trigger" || type.endsWith("_trigger") || type.endsWith("_inbound")) return "zap";
|
|
275
|
+
if (type === "voice_ai" || type.includes("dialer")) return "phone";
|
|
276
|
+
if (type === "wait" || type === "wait_for_time" || type === "time_condition") return "clock";
|
|
277
|
+
if (type === "switch_condition" || type === "conditional") return "branch";
|
|
278
|
+
if (type.includes("email")) return "mail";
|
|
279
|
+
if (type === "custom_api") return "globe";
|
|
280
|
+
if (type === "code") return "braces";
|
|
281
|
+
if (type === "sub_workflow") return "workflow";
|
|
282
|
+
if (type.includes("whatsapp") || type.includes("sms") || type === "slack") return "message";
|
|
283
|
+
if (type === "ai_assistant" || type === "photo_analyzer") return "sparkles";
|
|
284
|
+
if (type.includes("contact") || type.includes("crm")) return "user";
|
|
285
|
+
if (type === "notes") return "note";
|
|
286
|
+
return "branch";
|
|
171
287
|
}
|
|
172
288
|
|
|
289
|
+
// Mirrors the subtitles the dashboard editor shows under each node name.
|
|
290
|
+
function subtitle(n) {
|
|
291
|
+
const c = n.config || {};
|
|
292
|
+
switch (n.type) {
|
|
293
|
+
case "trigger": return c.webhook_enabled ? "Webhook enabled" : "Configure webhook";
|
|
294
|
+
case "voice_ai": return c.bot_name || (c.bot_id ? "Agent " + c.bot_id : "Choose an agent");
|
|
295
|
+
case "wait": return (c.delay_seconds || 0) + " seconds";
|
|
296
|
+
case "whatsapp": return c.template_name || "Choose a template";
|
|
297
|
+
case "send_email": return c.email_to || "Configure email";
|
|
298
|
+
case "custom_api": return c.url || "Configure request";
|
|
299
|
+
case "switch_condition": return ((c.cases || []).length) + " cases + else";
|
|
300
|
+
case "time_condition": return "Time window";
|
|
301
|
+
case "code": return c.code ? "Python snippet" : "Write a snippet";
|
|
302
|
+
case "sub_workflow": return c.target_workflow_name || "Choose a workflow";
|
|
303
|
+
case "slack": return c.message ? String(c.message).slice(0, 60) : "Configure message";
|
|
304
|
+
default: return n.type;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Workflow text is data, not instructions: one line, capped, quoted, before it goes into the chat.
|
|
309
|
+
function quoted(s) { return JSON.stringify(String(s).replace(/\\s+/g, " ").slice(0, 80)); }
|
|
310
|
+
|
|
173
311
|
function el(tag, attrs, text) {
|
|
174
312
|
const e = document.createElementNS(SVG_NS, tag);
|
|
175
313
|
for (const k in attrs) e.setAttribute(k, attrs[k]);
|
|
@@ -177,16 +315,62 @@ function el(tag, attrs, text) {
|
|
|
177
315
|
return e;
|
|
178
316
|
}
|
|
179
317
|
|
|
180
|
-
function clip(s, n) { return s.length > n ? s.slice(0, n - 1) + "
|
|
318
|
+
function clip(s, n) { s = String(s); return s.length > n ? s.slice(0, n - 1) + "…" : s; }
|
|
319
|
+
|
|
320
|
+
function ports(p) {
|
|
321
|
+
return { in: { x: p.x + NODE_W / 2, y: p.y }, out: { x: p.x + NODE_W / 2, y: p.y + NODE_H } };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Right-angle path with rounded corners, like React Flow's smoothstep edge.
|
|
325
|
+
function stepPath(a, b) {
|
|
326
|
+
const pts = [a];
|
|
327
|
+
if (b.y - a.y >= 40) { const m = (a.y + b.y) / 2; pts.push({ x: a.x, y: m }, { x: b.x, y: m }); }
|
|
328
|
+
else { const mx = (a.x + b.x) / 2; pts.push({ x: a.x, y: a.y + 20 }, { x: mx, y: a.y + 20 }, { x: mx, y: b.y - 20 }, { x: b.x, y: b.y - 20 }); }
|
|
329
|
+
pts.push(b);
|
|
330
|
+
let d = "M" + pts[0].x + "," + pts[0].y;
|
|
331
|
+
for (let i = 1; i < pts.length - 1; i++) {
|
|
332
|
+
const p = pts[i], prev = pts[i - 1], next = pts[i + 1];
|
|
333
|
+
const r = Math.min(6, Math.hypot(p.x - prev.x, p.y - prev.y) / 2, Math.hypot(next.x - p.x, next.y - p.y) / 2);
|
|
334
|
+
const ux = Math.sign(p.x - prev.x), uy = Math.sign(p.y - prev.y), vx = Math.sign(next.x - p.x), vy = Math.sign(next.y - p.y);
|
|
335
|
+
d += " L" + (p.x - ux * r) + "," + (p.y - uy * r) + " Q" + p.x + "," + p.y + " " + (p.x + vx * r) + "," + (p.y + vy * r);
|
|
336
|
+
}
|
|
337
|
+
d += " L" + b.x + "," + b.y;
|
|
338
|
+
const mid = pts[Math.floor(pts.length / 2)], mid2 = pts[Math.floor(pts.length / 2) - 1];
|
|
339
|
+
return { d, label: { x: (mid.x + mid2.x) / 2, y: (mid.y + mid2.y) / 2 } };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function drawEdges(layer) {
|
|
343
|
+
layer.replaceChildren();
|
|
344
|
+
const pos = {};
|
|
345
|
+
for (const n of state.wf.draft.nodes) pos[n.id] = n.position;
|
|
346
|
+
for (const e of state.wf.draft.edges) {
|
|
347
|
+
const a = pos[e.from], b = pos[e.to];
|
|
348
|
+
if (!a || !b) continue;
|
|
349
|
+
const s = stepPath(ports(a).out, ports(b).in);
|
|
350
|
+
layer.append(el("path", { class: "edge", d: s.d, "marker-end": "url(#arrow)" }));
|
|
351
|
+
if (e.handle && e.handle !== "default") {
|
|
352
|
+
const text = clip(e.handle, 18), w = text.length * 6.4 + 14;
|
|
353
|
+
const chip = el("g", { class: "chip", transform: "translate(" + (s.label.x - w / 2) + "," + (s.label.y - 9) + ")" });
|
|
354
|
+
chip.append(el("rect", { width: w, height: 18, rx: 5 }), el("text", { x: 7, y: 12.5 }, text));
|
|
355
|
+
layer.append(chip);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function errorsFor(id) { return state.issues.filter((i) => i.node === id); }
|
|
181
361
|
|
|
182
362
|
function render() {
|
|
363
|
+
if (!state.wf) return;
|
|
364
|
+
// Redrawing replaces the node under the pointer and kills the drag, so wait for the drop.
|
|
365
|
+
if (state.dragging) { state.redraw = true; return; }
|
|
183
366
|
const wf = state.wf, draft = wf.draft, svg = $("canvas");
|
|
184
367
|
$("title").textContent = wf.name || "Workflow " + wf.id;
|
|
185
368
|
$("state").hidden = false;
|
|
186
|
-
$("state").textContent = (wf.status || "draft") + "
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
369
|
+
$("state").textContent = (wf.status || "draft") + " · " + draft.nodes.length + " nodes";
|
|
370
|
+
$("issues").hidden = !state.issues.length;
|
|
371
|
+
$("issues").textContent = state.issues.length + (state.issues.length === 1 ? " problem" : " problems");
|
|
372
|
+
draft.nodes.forEach((n, i) => { if (!n.position) n.position = { x: i * 260, y: 0 }; });
|
|
373
|
+
const xs = draft.nodes.map((n) => n.position.x), ys = draft.nodes.map((n) => n.position.y);
|
|
190
374
|
const minX = Math.min(...xs, 0) - PAD, minY = Math.min(...ys, 0) - PAD;
|
|
191
375
|
const w = Math.max(...xs, 0) + NODE_W + PAD - minX, h = Math.max(...ys, 0) + NODE_H + PAD - minY;
|
|
192
376
|
const avail = $("stage").clientWidth || 600;
|
|
@@ -195,35 +379,40 @@ function render() {
|
|
|
195
379
|
svg.setAttribute("width", Math.round(w * scale));
|
|
196
380
|
svg.setAttribute("height", Math.round(h * scale));
|
|
197
381
|
svg.replaceChildren();
|
|
198
|
-
|
|
199
|
-
const edges = el("g", {});
|
|
200
|
-
for (const e of draft.edges) {
|
|
201
|
-
const a = pos[e.from], b = pos[e.to];
|
|
202
|
-
if (!a || !b) continue;
|
|
203
|
-
const x1 = a.x + NODE_W, y1 = a.y + NODE_H / 2, x2 = b.x, y2 = b.y + NODE_H / 2, dx = Math.max(40, (x2 - x1) / 2);
|
|
204
|
-
edges.append(el("path", { class: "edge", d: "M" + x1 + "," + y1 + " C" + (x1 + dx) + "," + y1 + " " + (x2 - dx) + "," + y2 + " " + x2 + "," + y2, "marker-end": "url(#arrow)" }));
|
|
205
|
-
if (e.handle && e.handle !== "default") {
|
|
206
|
-
edges.append(el("text", { class: "handle-label", x: x2 - 8, y: y2 - 8, "text-anchor": "end" }, e.handle));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
382
|
const defs = el("defs", {});
|
|
210
|
-
const marker = el("marker", { id: "arrow", viewBox: "0 0 10 10", refX: "
|
|
383
|
+
const marker = el("marker", { id: "arrow", viewBox: "0 0 10 10", refX: "8", refY: "5", markerWidth: "6", markerHeight: "6", orient: "auto-start-reverse" });
|
|
211
384
|
marker.append(el("path", { d: "M0,0 L10,5 L0,10 z", fill: "var(--edge)" }));
|
|
212
385
|
defs.append(marker);
|
|
386
|
+
const edges = el("g", {});
|
|
213
387
|
svg.append(defs, edges);
|
|
388
|
+
drawEdges(edges);
|
|
214
389
|
|
|
215
390
|
for (const n of draft.nodes) {
|
|
216
|
-
const
|
|
217
|
-
const
|
|
391
|
+
const bad = errorsFor(n.id).length > 0;
|
|
392
|
+
const cls = "node" + (state.selected === n.id ? " selected" : "") + (bad ? " invalid" : "");
|
|
393
|
+
const g = el("g", { class: cls, transform: "translate(" + n.position.x + "," + n.position.y + ")", tabindex: "0", role: "button", "aria-label": (n.label || n.id) + ", " + n.type + (bad ? ", has problems" : "") });
|
|
218
394
|
g.append(el("rect", { class: "card", width: NODE_W, height: NODE_H, rx: 8 }));
|
|
219
|
-
g.append(el("rect", {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
g.
|
|
395
|
+
g.append(el("rect", { class: "icon-box", x: 10, y: 10, width: 24, height: 24, rx: 6 }));
|
|
396
|
+
const icon = el("g", { class: "icon", transform: "translate(15,15) scale(0.5833)" });
|
|
397
|
+
icon.innerHTML = ICONS[iconFor(n.type)];
|
|
398
|
+
g.append(icon);
|
|
399
|
+
g.append(el("text", { class: "label", x: 42, y: 26.5 }, clip(n.label || n.id, 23)));
|
|
400
|
+
g.append(el("text", { class: "sub", x: 12, y: NODE_H - 12 }, clip(subtitle(n), 31)));
|
|
401
|
+
const pt = ports({ x: 0, y: 0 });
|
|
402
|
+
if (!n.type.endsWith("trigger") && !n.type.endsWith("_inbound")) g.append(el("circle", { class: "handle", cx: pt.in.x, cy: pt.in.y, r: 4 }));
|
|
403
|
+
g.append(el("circle", { class: "handle", cx: pt.out.x, cy: pt.out.y, r: 4 }));
|
|
404
|
+
g.addEventListener("pointerdown", (ev) => startDrag(ev, n, g, edges));
|
|
223
405
|
g.addEventListener("keydown", (ev) => { if (ev.key === "Enter" || ev.key === " ") { ev.preventDefault(); select(n.id); } });
|
|
224
406
|
svg.append(g);
|
|
225
407
|
}
|
|
226
|
-
|
|
408
|
+
showPanel();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function placeholder() {
|
|
412
|
+
const svg = $("canvas");
|
|
413
|
+
svg.setAttribute("viewBox", "0 0 600 240"); svg.setAttribute("width", 600); svg.setAttribute("height", 240);
|
|
414
|
+
svg.replaceChildren();
|
|
415
|
+
[[40, 90], [320, 30], [320, 150]].forEach(([x, y]) => svg.append(el("rect", { class: "skel", x, y, width: 220, height: 62, rx: 8 })));
|
|
227
416
|
}
|
|
228
417
|
|
|
229
418
|
function toSvg(ev) {
|
|
@@ -232,67 +421,137 @@ function toSvg(ev) {
|
|
|
232
421
|
return pt.matrixTransform(svg.getScreenCTM().inverse());
|
|
233
422
|
}
|
|
234
423
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
424
|
+
// The drag is tracked on the whole document, not the node: a release outside the chat's
|
|
425
|
+
// frame never reaches the frame, so leaving the frame (or a move with no button held) drops the node there.
|
|
426
|
+
function startDrag(ev, node, g, edges) {
|
|
427
|
+
// One drag at a time, primary pointer only: a second finger must not start a drag nobody saves.
|
|
428
|
+
if (state.busy || state.dragging || ev.button !== 0 || !ev.isPrimary) return;
|
|
429
|
+
const start = toSvg(ev), origin = { x: node.position.x, y: node.position.y };
|
|
238
430
|
let moved = false;
|
|
239
|
-
|
|
431
|
+
state.dragging = true;
|
|
240
432
|
const move = (e) => {
|
|
433
|
+
if (e.buttons === 0) return up();
|
|
241
434
|
const cur = toSvg(e), dx = cur.x - start.x, dy = cur.y - start.y;
|
|
242
435
|
if (!moved && Math.hypot(dx, dy) < 4) return;
|
|
243
436
|
moved = true; g.classList.add("dragging");
|
|
244
|
-
|
|
245
|
-
g.setAttribute("transform", "translate(" +
|
|
437
|
+
node.position = { x: Math.round(origin.x + dx), y: Math.round(origin.y + dy) };
|
|
438
|
+
g.setAttribute("transform", "translate(" + node.position.x + "," + node.position.y + ")");
|
|
439
|
+
drawEdges(edges);
|
|
246
440
|
};
|
|
247
441
|
const up = () => {
|
|
248
|
-
|
|
249
|
-
|
|
442
|
+
document.removeEventListener("pointermove", move);
|
|
443
|
+
document.removeEventListener("pointerup", up);
|
|
444
|
+
document.documentElement.removeEventListener("pointerleave", up);
|
|
445
|
+
window.removeEventListener("blur", up);
|
|
250
446
|
g.classList.remove("dragging");
|
|
447
|
+
if (!state.dragging) return;
|
|
448
|
+
state.dragging = false;
|
|
449
|
+
if (state.redraw) { state.redraw = false; render(); }
|
|
251
450
|
if (!moved) { select(node.id); return; }
|
|
252
|
-
|
|
451
|
+
if (node.position.x === origin.x && node.position.y === origin.y) return;
|
|
452
|
+
save([{ op: "move_node", id: node.id, position: node.position }], "moved node " + quoted(node.id), () => { node.position = origin; });
|
|
253
453
|
};
|
|
254
|
-
|
|
255
|
-
|
|
454
|
+
document.addEventListener("pointermove", move);
|
|
455
|
+
document.addEventListener("pointerup", up);
|
|
456
|
+
document.documentElement.addEventListener("pointerleave", up);
|
|
457
|
+
window.addEventListener("blur", up);
|
|
256
458
|
}
|
|
257
459
|
|
|
258
|
-
|
|
259
|
-
|
|
460
|
+
// Every edit sends the draft revision, so a stale edit is refused instead of overwriting Claude's.
|
|
461
|
+
async function save(ops, what, rollback, button) {
|
|
462
|
+
if (!state.wf) return false;
|
|
463
|
+
if (state.busy) { if (rollback) rollback(); render(); notice("Still loading the workflow. Try again in a moment."); return false; }
|
|
464
|
+
state.busy = true;
|
|
465
|
+
if (button) { button.disabled = true; button.dataset.text = button.textContent; button.textContent = "Saving…"; }
|
|
466
|
+
let ok = false;
|
|
260
467
|
try {
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
notify("ui/update-model-context", { content: [{ type: "text", text: "The user moved node \\"" + node.id + "\\" on workflow " + state.id + " in the canvas. Call getWorkflow for the new revision before your next edit." }] });
|
|
468
|
+
const r = readWorkflow(await callTool("editWorkflow", editArgs(state.id, state.wf.draft.revision, ops)) || {});
|
|
469
|
+
if (r.error) throw new Error(errorText(r.error));
|
|
470
|
+
ok = true;
|
|
471
|
+
notify("ui/update-model-context", { content: [{ type: "text", text: "In the workflow canvas the user " + what + " on workflow " + state.id + ". Call getWorkflow for the new revision before your next edit." }] });
|
|
266
472
|
} catch (e) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
473
|
+
if (rollback) rollback();
|
|
474
|
+
notice("Not saved: " + e.message);
|
|
475
|
+
} finally {
|
|
476
|
+
state.busy = false;
|
|
477
|
+
if (button) { button.disabled = false; button.textContent = button.dataset.text; }
|
|
270
478
|
}
|
|
271
|
-
|
|
479
|
+
const failure = ok ? "" : $("notice").textContent;
|
|
272
480
|
await refresh();
|
|
481
|
+
if (!ok) notice(failure);
|
|
482
|
+
return ok;
|
|
273
483
|
}
|
|
274
484
|
|
|
275
485
|
function select(id) {
|
|
276
486
|
state.selected = id;
|
|
487
|
+
state.dirty = false;
|
|
277
488
|
render();
|
|
278
489
|
const n = state.wf.draft.nodes.find((x) => x.id === id);
|
|
279
|
-
|
|
490
|
+
if (!n) return;
|
|
491
|
+
notify("ui/update-model-context", { content: [{ type: "text", text: "In the workflow canvas the user selected node " + quoted(id) + " (type " + quoted(n.type) + ") on workflow " + state.id + "." }] });
|
|
280
492
|
}
|
|
281
493
|
|
|
282
|
-
function
|
|
283
|
-
|
|
284
|
-
$("
|
|
285
|
-
|
|
494
|
+
function showPanel() {
|
|
495
|
+
const n = state.selected && state.wf.draft.nodes.find((x) => x.id === state.selected);
|
|
496
|
+
$("panel").hidden = !n;
|
|
497
|
+
if (!n) return;
|
|
498
|
+
if (state.dirty && $("panel").dataset.node === n.id) return;
|
|
499
|
+
$("panel").dataset.node = n.id;
|
|
500
|
+
state.dirty = false;
|
|
501
|
+
// What the form was loaded with: the base for working out what the user changed.
|
|
502
|
+
state.form = { id: n.id, label: n.label || "", config: JSON.parse(JSON.stringify(n.config || {})) };
|
|
503
|
+
$("n-label").value = n.label || "";
|
|
286
504
|
$("n-type").textContent = n.type;
|
|
287
505
|
$("n-id").textContent = "id " + n.id;
|
|
288
|
-
$("n-config").
|
|
506
|
+
$("n-config").value = n.config ? JSON.stringify(n.config, null, 2) : "{}";
|
|
507
|
+
const errs = errorsFor(n.id);
|
|
508
|
+
$("n-errors").hidden = !errs.length;
|
|
509
|
+
$("n-errors").textContent = errs.map((e) => e.message).join(" ");
|
|
510
|
+
$("delete").textContent = "Delete node";
|
|
511
|
+
document.documentElement.style.setProperty("--panel-h", $("panel").offsetHeight + "px");
|
|
289
512
|
}
|
|
290
513
|
|
|
514
|
+
// Typed but unsaved settings survive the refresh that follows a move or another save.
|
|
515
|
+
for (const id of ["n-label", "n-config"]) $(id).addEventListener("input", () => { state.dirty = true; });
|
|
516
|
+
|
|
517
|
+
// Sends only what the user changed since the form loaded. If Claude changed the same field in the
|
|
518
|
+
// meantime the save is refused, so neither edit silently overwrites the other.
|
|
519
|
+
$("save").addEventListener("click", () => {
|
|
520
|
+
const n = state.wf && state.wf.draft.nodes.find((x) => x.id === state.selected);
|
|
521
|
+
const base = state.form;
|
|
522
|
+
if (!n || !base || base.id !== n.id) return;
|
|
523
|
+
let config;
|
|
524
|
+
try { config = JSON.parse($("n-config").value || "{}"); }
|
|
525
|
+
catch { notice("The settings are not valid JSON. Fix them and save again."); return; }
|
|
526
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) { notice('The settings must be a JSON object, like {"key": "value"}.'); return; }
|
|
527
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
528
|
+
const now = n.config || {}, op = { op: "update_node", id: n.id }, changed = Object.create(null), clash = [];
|
|
529
|
+
for (const k of Object.keys(config)) if (k !== "__proto__" && !same(config[k], base.config[k])) changed[k] = config[k];
|
|
530
|
+
for (const k of Object.keys(base.config)) if (!(k in config)) changed[k] = null;
|
|
531
|
+
for (const k of Object.keys(changed)) if (!same(now[k], base.config[k])) clash.push(k);
|
|
532
|
+
const label = $("n-label").value.trim();
|
|
533
|
+
if (label && label !== base.label) {
|
|
534
|
+
if ((n.label || "") !== base.label) clash.push("name");
|
|
535
|
+
op.label = label;
|
|
536
|
+
}
|
|
537
|
+
if (clash.length) { notice("Claude changed " + clash.join(", ") + " on this node while you were editing. Select the node again to load its version, then redo your change."); return; }
|
|
538
|
+
if (Object.keys(changed).length) op.config = changed;
|
|
539
|
+
if (!op.label && !op.config) { notice("Nothing changed.", "info"); return; }
|
|
540
|
+
save([op], "edited node " + quoted(n.id), null, $("save")).then((ok) => { if (ok) { state.dirty = false; showPanel(); } });
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
$("delete").addEventListener("click", () => {
|
|
544
|
+
const btn = $("delete"), id = state.selected;
|
|
545
|
+
if (!id) return;
|
|
546
|
+
if (btn.textContent !== "Click again to delete") { btn.textContent = "Click again to delete"; return; }
|
|
547
|
+
save([{ op: "delete_node", id }], "deleted node " + quoted(id), null, btn).then((ok) => { if (ok) { state.selected = null; render(); } });
|
|
548
|
+
});
|
|
549
|
+
|
|
291
550
|
$("refresh").addEventListener("click", refresh);
|
|
292
551
|
$("full").addEventListener("click", async () => {
|
|
293
552
|
const mode = document.documentElement.dataset.mode === "fullscreen" ? "inline" : "fullscreen";
|
|
294
553
|
try { const r = await request("ui/request-display-mode", { mode }); applyContext({ displayMode: r && r.mode }); render(); }
|
|
295
|
-
catch (e) {
|
|
554
|
+
catch (e) { notice("Full screen is not available here."); }
|
|
296
555
|
});
|
|
297
556
|
$("open").addEventListener("click", () => {
|
|
298
557
|
if (state.id != null) request("ui/open-link", { url: "https://omnidim.io/workflow/" + state.id }).catch(() => {});
|
|
@@ -300,21 +559,24 @@ $("open").addEventListener("click", () => {
|
|
|
300
559
|
$("ask").addEventListener("click", () => {
|
|
301
560
|
const n = state.wf && state.wf.draft.nodes.find((x) => x.id === state.selected);
|
|
302
561
|
if (!n) return;
|
|
303
|
-
request("ui/message", { role: "user", content: [{ type: "text", text: "In workflow " + state.id + ", explain the
|
|
562
|
+
request("ui/message", { role: "user", content: [{ type: "text", text: "In workflow " + state.id + ", explain the node with id " + quoted(n.id) + " (type " + quoted(n.type) + ", named " + quoted(n.label || n.id) + ") and check its settings for problems." }] }).catch(() => notice("Could not send the message to the chat."));
|
|
304
563
|
});
|
|
305
564
|
|
|
306
565
|
new ResizeObserver(() => notify("ui/notifications/size-changed", { width: document.documentElement.scrollWidth, height: document.documentElement.scrollHeight })).observe(document.body);
|
|
307
566
|
|
|
567
|
+
placeholder();
|
|
308
568
|
request("ui/initialize", {
|
|
309
569
|
protocolVersion: "2026-01-26",
|
|
310
|
-
appInfo: { name: "omnidim-workflow-canvas", version: "0.
|
|
570
|
+
appInfo: { name: "omnidim-workflow-canvas", version: "0.2.0" },
|
|
311
571
|
appCapabilities: { availableDisplayModes: ["inline", "fullscreen"] },
|
|
312
572
|
}).then((r) => {
|
|
313
573
|
applyContext(r && r.hostContext);
|
|
314
574
|
notify("ui/notifications/initialized", {});
|
|
315
|
-
}).catch((
|
|
575
|
+
}).catch(() => notice("This chat app could not open the canvas."));
|
|
316
576
|
</script>
|
|
317
577
|
</body>
|
|
318
578
|
</html>
|
|
319
579
|
`;
|
|
580
|
+
// Chat apps cache a view by its address, so a changed page needs a new address or users keep the old one.
|
|
581
|
+
export const WORKFLOW_CANVAS_URI = `${LEGACY_CANVAS_URI}/${createHash("sha256").update(WORKFLOW_CANVAS_HTML).digest("hex").slice(0, 12)}`;
|
|
320
582
|
//# sourceMappingURL=workflow-canvas.js.map
|