agent-lyra 0.8.0 → 0.11.0
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/LICENSE +21 -21
- package/README.md +320 -291
- package/bin/agent-lyra.js +51 -51
- package/bin/lyra-oss-preview.js +16 -16
- package/package.json +60 -60
- package/src/app-builder/export.js +109 -109
- package/src/app-builder/gateway.js +62 -62
- package/src/app-builder/init.js +115 -72
- package/src/app-builder/manifest-contract.js +46 -46
- package/src/app-builder/native-adapter.js +29 -29
- package/src/app-builder/preview.js +35 -31
- package/src/app-builder/publish.js +14 -14
- package/src/app-builder/saved-app.js +73 -70
- package/src/app-builder/saved-preview-browser.js +33 -33
- package/src/app-builder/saved-preview.html +24 -24
- package/src/app-builder/saved-preview.js +61 -61
- package/src/app-builder/support-manifest.js +50 -50
- package/src/app-builder/support-template/manifest.json +55 -55
- package/src/app-builder/support-template/support-preview.html +56 -56
- package/src/app-builder/support-template/support-preview.js +37 -37
- package/src/app-builder/support-template/support-preview.mjs +67 -67
- package/src/app-builder/support-template/support-workflow.mjs +36 -36
- package/src/app-builder/use.js +37 -37
- package/src/app-builder/validate.js +31 -21
- package/src/app-builder/value-schema.js +37 -37
- package/src/catalog.js +147 -147
- package/src/coding/catalog.js +56 -56
- package/src/coding/cloud-catalog.js +64 -64
- package/src/coding/detect-stack.mjs +110 -110
- package/src/coding/export.js +133 -133
- package/src/coding/setup.js +175 -175
- package/src/coding/skills/lyra-android/SKILL.md +37 -37
- package/src/coding/skills/lyra-angular/SKILL.md +37 -37
- package/src/coding/skills/lyra-cucumber/SKILL.md +37 -37
- package/src/coding/skills/lyra-dbt/SKILL.md +37 -37
- package/src/coding/skills/lyra-django/SKILL.md +37 -37
- package/src/coding/skills/lyra-docker/SKILL.md +37 -37
- package/src/coding/skills/lyra-dotnet/SKILL.md +37 -37
- package/src/coding/skills/lyra-express/SKILL.md +37 -37
- package/src/coding/skills/lyra-fastapi/SKILL.md +37 -37
- package/src/coding/skills/lyra-flutter/SKILL.md +37 -37
- package/src/coding/skills/lyra-github-actions/SKILL.md +37 -37
- package/src/coding/skills/lyra-gitlab-ci/SKILL.md +37 -37
- package/src/coding/skills/lyra-go/SKILL.md +37 -37
- package/src/coding/skills/lyra-ios/SKILL.md +37 -37
- package/src/coding/skills/lyra-kubernetes/SKILL.md +37 -37
- package/src/coding/skills/lyra-mongodb/SKILL.md +37 -37
- package/src/coding/skills/lyra-mysql/SKILL.md +37 -37
- package/src/coding/skills/lyra-nextjs/SKILL.md +37 -37
- package/src/coding/skills/lyra-node/SKILL.md +37 -37
- package/src/coding/skills/lyra-playwright/SKILL.md +37 -37
- package/src/coding/skills/lyra-postgresql/SKILL.md +37 -37
- package/src/coding/skills/lyra-python/SKILL.md +37 -37
- package/src/coding/skills/lyra-react/SKILL.md +37 -37
- package/src/coding/skills/lyra-react-native/SKILL.md +37 -37
- package/src/coding/skills/lyra-redis/SKILL.md +37 -37
- package/src/coding/skills/lyra-rust/SKILL.md +37 -37
- package/src/coding/skills/lyra-spark/SKILL.md +37 -37
- package/src/coding/skills/lyra-spring-boot/SKILL.md +37 -37
- package/src/coding/skills/lyra-svelte/SKILL.md +37 -37
- package/src/coding/skills/lyra-terraform/SKILL.md +37 -37
- package/src/coding/skills/lyra-typescript/SKILL.md +37 -37
- package/src/coding/skills/lyra-vue/SKILL.md +37 -37
- package/src/framework/agent.js +181 -181
- package/src/framework/mda.js +65 -65
- package/src/framework/run.py +111 -111
- package/src/gated/hostedAgents.js +56 -56
- package/src/gated/index.d.ts +25 -25
- package/src/gated/index.js +5 -5
- package/src/index.d.ts +2 -2
- package/src/index.js +2 -2
- package/src/init.js +963 -960
- package/src/intelligence/graphsnip-provider.d.ts +5 -5
- package/src/intelligence/graphsnip-provider.js +57 -57
- package/src/intelligence/lifecycle.js +25 -25
- package/src/memory/LICENSE +21 -21
- package/src/memory/README.md +5 -5
- package/src/memory/UPSTREAM.json +24 -24
- package/src/memory/bridge-cli.js +16 -16
- package/src/memory/bridge.js +18 -18
- package/src/memory/cli.js +21 -21
- package/src/memory/cloud-sync-actions.js +61 -61
- package/src/memory/contract.json +45 -45
- package/src/memory/index.d.ts +50 -50
- package/src/memory/index.js +7 -7
- package/src/memory/lifecycle.js +29 -29
- package/src/memory/local-cli.js +34 -34
- package/src/memory/local-store.js +209 -209
- package/src/memory/package.json +33 -33
- package/src/memory/proposals.js +90 -90
- package/src/memory/skills-cli.js +26 -26
- package/src/memory/standalone.d.ts +50 -50
- package/src/memory/standalone.js +1 -1
- package/src/memory/sync.js +89 -89
- package/src/memory/validation.js +25 -25
- package/src/onboardingAgents.js +532 -532
- package/src/promptTemplates.js +178 -178
- package/src/resource-files.js +18 -18
- package/src/runtime/contracts.d.ts +47 -47
- package/src/runtime/local-cli.js +161 -161
- package/src/runtime/mcp-stdio.js +111 -111
- package/src/runtime/orchestration.js +59 -59
- package/src/runtime/run-agent.js +54 -54
- package/src/standalone/index.d.ts +45 -45
- package/src/standalone/index.js +13 -13
- package/src/standalone/init.js +14 -12
- package/src/standalone/orchestration.js +6 -6
- package/src/standalone/rag.js +113 -113
- package/src/studio/agent-ui.css +43 -43
- package/src/studio/agent-ui.js +32 -32
- package/src/studio/browser.js +562 -345
- package/src/studio/cli-providers.js +40 -0
- package/src/studio/export.js +83 -86
- package/src/studio/index.html +74 -37
- package/src/studio/memory-actions.js +37 -37
- package/src/studio/memory-panel.js +200 -200
- package/src/studio/project.js +333 -240
- package/src/studio/pull-agent.js +72 -72
- package/src/studio/push.js +54 -54
- package/src/studio/python-agent.js +47 -47
- package/src/studio/python-agent.py +25 -25
- package/src/studio/server.js +164 -150
- package/src/studio/session.js +83 -83
- package/src/studio/studio.css +257 -10
- package/src/studio/sync.js +42 -42
- package/src/studio/workflow-editor.js +240 -0
- package/src/studio/workflow-sync.js +229 -157
- package/src/vscode/workspace.js +158 -0
package/src/studio/browser.js
CHANGED
|
@@ -1,345 +1,562 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
else node
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
$("#
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
$("#
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
$("#
|
|
334
|
-
$("#
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
1
|
+
import { mountWorkflowEditor } from "./workflow-editor.js";
|
|
2
|
+
import { mountMemoryPanel } from "./memory-panel.js";
|
|
3
|
+
import { renderAgentCard, renderRunHeader } from "./agent-ui.js";
|
|
4
|
+
|
|
5
|
+
const $ = selector => document.querySelector(selector);
|
|
6
|
+
const element = (tag, text) => Object.assign(document.createElement(tag), text === undefined ? {} : { textContent: text });
|
|
7
|
+
function dom(tag, props, ...children) {
|
|
8
|
+
const node = document.createElement(tag);
|
|
9
|
+
for (const [key, value] of Object.entries(props)) {
|
|
10
|
+
if (value == null) continue;
|
|
11
|
+
if (key === "onClick") node.onclick = value;
|
|
12
|
+
else if (key === "aria-label") node.setAttribute(key, value);
|
|
13
|
+
else node[key] = value;
|
|
14
|
+
}
|
|
15
|
+
node.append(...children.filter(child => child != null && child !== false && child !== ""));
|
|
16
|
+
return node;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const agentSources = { local: "Local agent", cloud: "Cloud agent", python: "Python agent", framework: "Registered framework agent" };
|
|
20
|
+
const names = { heading:"Heading", text:"Text", input:"Text input", textarea:"Text area", button:"Run button", "agent-card":"Agent card", output:"Output" };
|
|
21
|
+
let project = { layout: [], agents: [], workflows: [], teams: [], skills: [] };
|
|
22
|
+
let selected, pending;
|
|
23
|
+
let libraryView = "palette";
|
|
24
|
+
let dirty = false;
|
|
25
|
+
let runInProgress = false;
|
|
26
|
+
const values = new Map();
|
|
27
|
+
const outputs = new Map();
|
|
28
|
+
|
|
29
|
+
function button(text, click) {
|
|
30
|
+
const control = element("button", text);
|
|
31
|
+
control.type = "button";
|
|
32
|
+
control.onclick = click;
|
|
33
|
+
return control;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function api(path, data) {
|
|
37
|
+
const response = await fetch("/api/" + path, data === undefined ? {} : {
|
|
38
|
+
method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data),
|
|
39
|
+
});
|
|
40
|
+
const payload = await response.json();
|
|
41
|
+
if (!response.ok) throw Object.assign(new Error(payload.error), { progress: payload.progress });
|
|
42
|
+
return payload;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
mountMemoryPanel(api);
|
|
46
|
+
const workflowEditor = mountWorkflowEditor({
|
|
47
|
+
api, project: () => project, reloadCatalog: () => load({ catalogOnly: true }),
|
|
48
|
+
run: id => openRun(["workflow:" + id]),
|
|
49
|
+
switchView: editing => {
|
|
50
|
+
$("#save").hidden = $("#canvas-panel").hidden = editing;
|
|
51
|
+
$("#library").hidden = editing;
|
|
52
|
+
if (editing) closeInspector();
|
|
53
|
+
$("#workflow-panel").hidden = !editing;
|
|
54
|
+
$("#show-layout").setAttribute("aria-pressed", String(!editing));
|
|
55
|
+
$("#show-workflow").setAttribute("aria-pressed", String(editing));
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function announce(message) { $("#status").textContent = message; }
|
|
60
|
+
function change() { dirty = true; renderCanvas(); renderInspector(); }
|
|
61
|
+
|
|
62
|
+
function add(kind, index = project.layout.length) {
|
|
63
|
+
if (!Object.hasOwn(names, kind) || project.layout.length >= 60) return;
|
|
64
|
+
const node = { id: crypto.randomUUID(), kind, label: names[kind] };
|
|
65
|
+
if (["button", "agent-card"].includes(kind)) node.targets = [];
|
|
66
|
+
project.layout.splice(index, 0, node);
|
|
67
|
+
selected = node.id;
|
|
68
|
+
change();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function move(node, offset) {
|
|
72
|
+
const index = project.layout.indexOf(node);
|
|
73
|
+
const next = index + offset;
|
|
74
|
+
if (next < 0 || next >= project.layout.length) return;
|
|
75
|
+
[project.layout[index], project.layout[next]] = [project.layout[next], node];
|
|
76
|
+
change();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function renderCanvas() {
|
|
80
|
+
const canvas = $("#canvas");
|
|
81
|
+
canvas.replaceChildren();
|
|
82
|
+
if (!project.layout.length) canvas.append(element("p", "Your canvas is empty."));
|
|
83
|
+
for (const node of project.layout) {
|
|
84
|
+
const card = element("div");
|
|
85
|
+
card.dataset.nodeId = node.id;
|
|
86
|
+
card.dataset.span = node.span ?? 12;
|
|
87
|
+
card.className = "node" + (node.id === selected ? " selected" : "");
|
|
88
|
+
const select = button("Edit " + names[node.kind], () => { selected = node.id; renderCanvas(); renderInspector(); });
|
|
89
|
+
if (!project.exported && !project.preview) {
|
|
90
|
+
const handle = element("span", "⠿");
|
|
91
|
+
handle.className = "move-handle";
|
|
92
|
+
handle.title = "Drag to move, or use the inspector's move buttons";
|
|
93
|
+
handle.setAttribute("aria-hidden", "true");
|
|
94
|
+
handle.draggable = true;
|
|
95
|
+
handle.ondragstart = event => {
|
|
96
|
+
event.dataTransfer.setData("text/lyra-node", node.id);
|
|
97
|
+
event.dataTransfer.effectAllowed = "move";
|
|
98
|
+
event.dataTransfer.setDragImage(card, 12, 12);
|
|
99
|
+
};
|
|
100
|
+
const tools = element("div");
|
|
101
|
+
tools.className = "component-tools";
|
|
102
|
+
tools.append(handle, select);
|
|
103
|
+
card.append(tools);
|
|
104
|
+
}
|
|
105
|
+
if (node.kind === "heading" || node.kind === "text") card.append(element(node.kind === "heading" ? "h2" : "p", node.label));
|
|
106
|
+
if (["input", "textarea"].includes(node.kind)) {
|
|
107
|
+
const id = "component-" + node.id;
|
|
108
|
+
const label = element("label", node.label);
|
|
109
|
+
label.htmlFor = id;
|
|
110
|
+
const input = element(node.kind);
|
|
111
|
+
input.id = id;
|
|
112
|
+
input.maxLength = 4000;
|
|
113
|
+
input.value = values.get(node.id) ?? "";
|
|
114
|
+
input.oninput = () => values.set(node.id, input.value);
|
|
115
|
+
card.append(label, input);
|
|
116
|
+
}
|
|
117
|
+
if (node.kind === "output") card.append(element("h2", node.label), element("pre", outputs.get(node.id) ?? "Run a workflow to see a result."));
|
|
118
|
+
if (node.kind === "agent-card") {
|
|
119
|
+
const agent = project.agents.find(item => item.id === node.targets[0]);
|
|
120
|
+
card.append(renderAgentCard(dom, {
|
|
121
|
+
name: node.label, source: agent ? agentSources[agent.source] : "Choose an agent in the inspector",
|
|
122
|
+
onRun: agent ? () => openRun(node.targets, values.get(node.sourceId) ?? "", node.outputId, node.id) : undefined,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
if (node.kind === "button") {
|
|
126
|
+
const trigger = button(node.label, () => {
|
|
127
|
+
if (!node.targets.length) return announce("Assign an agent or workflow in the inspector first.");
|
|
128
|
+
openRun(node.targets, values.get(node.sourceId) ?? "", node.outputId, node.id);
|
|
129
|
+
});
|
|
130
|
+
if (!node.targets.length) trigger.title = "Assign a target in the inspector";
|
|
131
|
+
trigger.className = "primary";
|
|
132
|
+
card.append(trigger);
|
|
133
|
+
}
|
|
134
|
+
canvas.append(card);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function addSelect(parent, label, choices, value, onChange) {
|
|
139
|
+
const wrap = element("label", label);
|
|
140
|
+
const select = element("select");
|
|
141
|
+
for (const [id, title] of choices) select.add(new Option(title, id));
|
|
142
|
+
select.value = value ?? "";
|
|
143
|
+
select.onchange = () => onChange(select.value);
|
|
144
|
+
wrap.append(select);
|
|
145
|
+
parent.append(wrap);
|
|
146
|
+
return select;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function labelFor(id) {
|
|
150
|
+
return project.agents.find(agent => agent.id === id)?.name ??
|
|
151
|
+
project.workflows.find(workflow => "workflow:" + workflow.id === id)?.name ?? id;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function renderInspector() {
|
|
155
|
+
const box = $("#inspector");
|
|
156
|
+
box.replaceChildren();
|
|
157
|
+
const node = project.layout.find(item => item.id === selected);
|
|
158
|
+
$("#inspector-panel").hidden = !node;
|
|
159
|
+
if (!node) return;
|
|
160
|
+
|
|
161
|
+
const label = element("label", "Label");
|
|
162
|
+
const field = element("input");
|
|
163
|
+
field.value = node.label;
|
|
164
|
+
field.maxLength = 160;
|
|
165
|
+
field.oninput = () => { node.label = field.value; dirty = true; renderCanvas(); };
|
|
166
|
+
label.append(field);
|
|
167
|
+
const actions = element("div");
|
|
168
|
+
actions.className = "actions";
|
|
169
|
+
actions.append(button("Move up", () => move(node, -1)), button("Move down", () => move(node, 1)), button("Remove", () => {
|
|
170
|
+
project.layout = project.layout.filter(item => item !== node);
|
|
171
|
+
for (const item of project.layout) {
|
|
172
|
+
if (item.sourceId === node.id) item.sourceId = "";
|
|
173
|
+
if (item.outputId === node.id) item.outputId = "";
|
|
174
|
+
}
|
|
175
|
+
selected = null;
|
|
176
|
+
change();
|
|
177
|
+
}));
|
|
178
|
+
box.append(label);
|
|
179
|
+
addSelect(box, "Width", [[12, "Full"], [9, "Three quarters"], [8, "Two thirds"], [6, "Half"], [4, "One third"], [3, "Quarter"]], node.span ?? 12, width => {
|
|
180
|
+
node.span = Number(width);
|
|
181
|
+
dirty = true;
|
|
182
|
+
renderCanvas();
|
|
183
|
+
});
|
|
184
|
+
box.append(actions);
|
|
185
|
+
if (!["button", "agent-card"].includes(node.kind)) return;
|
|
186
|
+
|
|
187
|
+
const fields = project.layout.filter(item => ["input", "textarea"].includes(item.kind));
|
|
188
|
+
const results = project.layout.filter(item => item.kind === "output");
|
|
189
|
+
addSelect(box, "Input component", [["", "Enter in run drawer"], ...fields.map(item => [item.id, item.label])], node.sourceId, id => {
|
|
190
|
+
node.sourceId = id; dirty = true;
|
|
191
|
+
});
|
|
192
|
+
addSelect(box, "Output component", [["", "Show in run drawer"], ...results.map(item => [item.id, item.label])], node.outputId, id => {
|
|
193
|
+
node.outputId = id; dirty = true;
|
|
194
|
+
});
|
|
195
|
+
if (node.kind === "agent-card") {
|
|
196
|
+
addSelect(box, "Agent", [["", "Choose an agent"], ...project.agents.map(agent => [agent.id, agent.name])], node.targets[0], id => {
|
|
197
|
+
if (node.label === names["agent-card"] || node.label === labelFor(node.targets[0])) {
|
|
198
|
+
node.label = id ? labelFor(id) : names["agent-card"];
|
|
199
|
+
}
|
|
200
|
+
node.targets = id ? [id] : [];
|
|
201
|
+
change();
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
box.append(element("h2", "Run order"));
|
|
206
|
+
node.targets.forEach((target, index) => {
|
|
207
|
+
const row = element("div", labelFor(target));
|
|
208
|
+
row.className = "binding";
|
|
209
|
+
row.append(button("Remove", () => { node.targets.splice(index, 1); change(); }));
|
|
210
|
+
box.append(row);
|
|
211
|
+
});
|
|
212
|
+
const options = [
|
|
213
|
+
...project.agents.map(agent => [agent.id, agent.name]),
|
|
214
|
+
...project.workflows.filter(item => item.runnable).map(item => ["workflow:" + item.id, item.name + " (workflow)"]),
|
|
215
|
+
];
|
|
216
|
+
addSelect(box, "Add next step", [["", "Choose agent or workflow"], ...options], "", id => {
|
|
217
|
+
if (id && node.targets.length < 8) { node.targets.push(id); change(); }
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function renderCatalog() {
|
|
222
|
+
for (const tab of $("#library-tabs").querySelectorAll("button")) {
|
|
223
|
+
const active = libraryView === tab.dataset.library;
|
|
224
|
+
tab.setAttribute("aria-pressed", String(active));
|
|
225
|
+
$("#" + tab.dataset.library).hidden = !active;
|
|
226
|
+
}
|
|
227
|
+
const search = $("#library-search");
|
|
228
|
+
search.hidden = $("#library-search-label").hidden = libraryView === "palette";
|
|
229
|
+
if (search.hidden) return;
|
|
230
|
+
|
|
231
|
+
const id = libraryView;
|
|
232
|
+
const section = $("#" + id);
|
|
233
|
+
const query = search.value.trim().toLowerCase();
|
|
234
|
+
const rows = project[id].filter(row => [row.name, row.source, row.framework, agentSources[row.source]]
|
|
235
|
+
.some(value => value?.toLowerCase().includes(query)));
|
|
236
|
+
section.replaceChildren();
|
|
237
|
+
if (!rows.length) section.append(element("p", query ? "No matching items." : "None in this project."));
|
|
238
|
+
if (id === "agents" && project.frameworkCandidates?.length) {
|
|
239
|
+
section.append(element("p", "LangGraph candidates: " + project.frameworkCandidates.map(item => item.name).join(", ") +
|
|
240
|
+
". Run agent-lyra agent discover, then register the entry you want."));
|
|
241
|
+
}
|
|
242
|
+
for (const row of rows) {
|
|
243
|
+
if (id === "agents") {
|
|
244
|
+
const push = row.source === "local" && project.mode !== "standalone"
|
|
245
|
+
? button("Push to Cloud", async () => {
|
|
246
|
+
if (!window.confirm("Send the name and instructions for " + row.name + " to your private AgentLyra Cloud workspace?")) return;
|
|
247
|
+
push.disabled = true;
|
|
248
|
+
try {
|
|
249
|
+
const result = await api("push", { id: row.id });
|
|
250
|
+
announce((result.created ? "Created " : "Synced ") + row.name + " in AgentLyra Cloud.");
|
|
251
|
+
} catch (error) { announce(error.message); }
|
|
252
|
+
finally { push.disabled = false; }
|
|
253
|
+
}) : undefined;
|
|
254
|
+
const pull = push && button("Pull agent edits", async () => {
|
|
255
|
+
pull.disabled = true;
|
|
256
|
+
try {
|
|
257
|
+
const result = await api("pull-agent", { id: row.id });
|
|
258
|
+
await load({ catalogOnly: true });
|
|
259
|
+
announce(result.updated ? "Updated " + result.name + " from Cloud." : "No Cloud edits to pull.");
|
|
260
|
+
} catch (error) { announce(error.message); }
|
|
261
|
+
finally { pull.disabled = false; }
|
|
262
|
+
});
|
|
263
|
+
const sync = row.source === "framework" && project.mode !== "standalone" && button("Sync registration", async () => {
|
|
264
|
+
try {
|
|
265
|
+
const id = row.id.slice("framework:".length);
|
|
266
|
+
const preview = await api("framework-preview", { id });
|
|
267
|
+
if (!window.confirm("Sync only this private registration?\n" + JSON.stringify(preview.payload, null, 2))) return;
|
|
268
|
+
await api("framework-sync", { id, fingerprint: preview.fingerprint });
|
|
269
|
+
announce("Registration synced. Open Cloud → Agents to view it.");
|
|
270
|
+
} catch (error) { announce(error.message); }
|
|
271
|
+
});
|
|
272
|
+
const entry = element("details");
|
|
273
|
+
entry.className = "library-entry";
|
|
274
|
+
const summary = element("summary");
|
|
275
|
+
const source = row.framework ? row.framework + " · Local" : agentSources[row.source];
|
|
276
|
+
summary.append(element("strong", row.name), element("span", source));
|
|
277
|
+
const actions = dom("div", { className: "actions" }, button("Run now", () => openRun([row.id])), push, pull, sync);
|
|
278
|
+
entry.append(summary, actions);
|
|
279
|
+
section.append(entry);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const card = element("article");
|
|
283
|
+
card.className = "agent-card";
|
|
284
|
+
card.append(element("strong", row.name));
|
|
285
|
+
if (id === "workflows") {
|
|
286
|
+
card.append(button("Open workflow", () => workflowEditor.open(row.id)));
|
|
287
|
+
card.append(row.runnable ? button("Run now", () => openRun(["workflow:" + row.id]))
|
|
288
|
+
: element("span", "Run this workflow in Lyra Cloud."));
|
|
289
|
+
}
|
|
290
|
+
const syncType = id === "skills" && row.source !== "markdown" ? "skill" : id === "teams" ? "team" : id === "workflows" && row.runnable ? "workflow" : undefined;
|
|
291
|
+
if (syncType && row.source !== "cloud" && project.mode !== "standalone") {
|
|
292
|
+
for (const [action, label] of [["push", "Push to Cloud"], ["pull", "Pull " + syncType + " edits"]]) {
|
|
293
|
+
const control = button(label, async () => {
|
|
294
|
+
if (action === "push" && !window.confirm("Send this " + syncType + " definition to your private Cloud workspace?")) return;
|
|
295
|
+
control.disabled = true;
|
|
296
|
+
try {
|
|
297
|
+
const result = await api(action + "-" + syncType, { id: row.id });
|
|
298
|
+
await load({ catalogOnly: true });
|
|
299
|
+
announce(action === "push" ? "Saved " + result.name + " in Cloud."
|
|
300
|
+
: result.updated ? "Updated " + result.name + " from Cloud." : "No Cloud edits to pull.");
|
|
301
|
+
} catch (error) { announce(error.message); }
|
|
302
|
+
finally { control.disabled = false; }
|
|
303
|
+
});
|
|
304
|
+
card.append(control);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (id === "skills") card.append(element("span", row.source === "cloud" ? "Cloud skill" : row.source === "markdown" ? "Local Markdown skill" : "Local text skill"));
|
|
308
|
+
if (id === "teams") card.append(element("span", row.source === "cloud" ? "Cloud team" : "Local team"));
|
|
309
|
+
section.append(card);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function minimizeRun() {
|
|
314
|
+
$("#drawer").close();
|
|
315
|
+
$("#resume-run").hidden = false;
|
|
316
|
+
$("#resume-run").focus();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async function openRun(targets, input = "", outputId = "", buttonId) {
|
|
320
|
+
if (runInProgress) {
|
|
321
|
+
$("#resume-run").click();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
$("#resume-run").hidden = true;
|
|
325
|
+
const action = { targets: [...targets], outputId, buttonId, revision: project.revision };
|
|
326
|
+
pending = action;
|
|
327
|
+
$("#run-header").replaceChildren(renderRunHeader(dom, {
|
|
328
|
+
title: targets.map(labelFor).join(" → "), kind: targets.length > 1 || targets[0].startsWith("workflow:") ? "Workflow" : "Agent",
|
|
329
|
+
closeId: "close-run", onClose: () => $("#drawer").close(),
|
|
330
|
+
}));
|
|
331
|
+
$("#prompt").value = input;
|
|
332
|
+
$("#run-result").textContent = "";
|
|
333
|
+
$("#run-status").textContent = "Checking run setup…";
|
|
334
|
+
$("#run-input-label").textContent = "Input";
|
|
335
|
+
$("#prompt").setCustomValidity("");
|
|
336
|
+
const plan = $("#run-plan");
|
|
337
|
+
plan.hidden = true;
|
|
338
|
+
plan.replaceChildren();
|
|
339
|
+
const providerPicker = $("#execution-provider");
|
|
340
|
+
const providerLabel = $('label[for="execution-provider"]');
|
|
341
|
+
providerPicker.hidden = providerLabel.hidden = true;
|
|
342
|
+
providerPicker.disabled = false;
|
|
343
|
+
const picker = $("#model");
|
|
344
|
+
const modelLabel = $('label[for="model"]');
|
|
345
|
+
picker.hidden = modelLabel.hidden = true;
|
|
346
|
+
$("#run").disabled = true;
|
|
347
|
+
$("#run").textContent = project.preview || project.exported ? "Run" : "Test action";
|
|
348
|
+
$("#drawer").showModal();
|
|
349
|
+
try {
|
|
350
|
+
const component = project.layout.find(node => node.id === buttonId);
|
|
351
|
+
if (component && ((component.sourceId && !project.layout.some(node => node.id === component.sourceId && ["input", "textarea"].includes(node.kind))) ||
|
|
352
|
+
(component.outputId && !project.layout.some(node => node.id === component.outputId && node.kind === "output")))) {
|
|
353
|
+
throw new Error("Fix the input or output binding in the inspector.");
|
|
354
|
+
}
|
|
355
|
+
let planRequest = 0;
|
|
356
|
+
const refreshPlan = async provider => {
|
|
357
|
+
const request = ++planRequest;
|
|
358
|
+
const setup = await api("run-plan", { targets: action.targets, buttonId, revision: action.revision, provider });
|
|
359
|
+
if (pending !== action || request !== planRequest) return;
|
|
360
|
+
const list = element("ol");
|
|
361
|
+
for (const step of setup.steps) {
|
|
362
|
+
const row = element("li");
|
|
363
|
+
row.append(element("strong", step.name), element("span",
|
|
364
|
+
[step.location, step.framework, step.provider].filter(Boolean).join(" · ")));
|
|
365
|
+
list.append(row);
|
|
366
|
+
}
|
|
367
|
+
plan.replaceChildren(element("h2", "Execution steps"), list);
|
|
368
|
+
plan.hidden = false;
|
|
369
|
+
providerPicker.replaceChildren(...(setup.providers || []).map(id => new Option(id === "openai" ? "Local OpenAI API" : id === "cloud" ? "Lyra Cloud" : id + " CLI", id)));
|
|
370
|
+
providerPicker.value = setup.provider || "";
|
|
371
|
+
providerPicker.hidden = providerLabel.hidden = !setup.providers?.length;
|
|
372
|
+
const previousModel = picker.value;
|
|
373
|
+
picker.replaceChildren(...setup.models.map(model => new Option(model, model)));
|
|
374
|
+
if (setup.models.includes(previousModel)) picker.value = previousModel;
|
|
375
|
+
picker.hidden = modelLabel.hidden = !setup.needsModel;
|
|
376
|
+
action.inputKind = setup.inputKind;
|
|
377
|
+
if (setup.inputKind === "json") $("#run-input-label").textContent = "JSON input";
|
|
378
|
+
action.ready = setup.issues.length === 0;
|
|
379
|
+
$("#run-status").textContent = setup.issues.join(" ");
|
|
380
|
+
$("#run").disabled = !action.ready;
|
|
381
|
+
};
|
|
382
|
+
providerPicker.onchange = async () => {
|
|
383
|
+
action.ready = false;
|
|
384
|
+
$("#run").disabled = true;
|
|
385
|
+
providerPicker.disabled = true;
|
|
386
|
+
try { await refreshPlan(providerPicker.value); }
|
|
387
|
+
catch (error) { if (pending === action) $("#run-status").textContent = error.message; }
|
|
388
|
+
finally { if (pending === action) providerPicker.disabled = false; }
|
|
389
|
+
};
|
|
390
|
+
await refreshPlan();
|
|
391
|
+
} catch (error) {
|
|
392
|
+
if (pending === action) $("#run-status").textContent = error.message;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function showRunResults({ answers, traceId, steps }) {
|
|
397
|
+
const lines = traceId ? ["Studio run trace " + traceId] : [];
|
|
398
|
+
if (steps) {
|
|
399
|
+
for (const step of steps) {
|
|
400
|
+
const heading = step.index + ". " + step.agent + " · " + step.state + " · " + step.durationMs + " ms";
|
|
401
|
+
lines.push([heading, "Step trace " + step.traceId, step.runId && "Runtime run " + step.runId, step.provider && "Provider " + step.provider, step.model && "Model " + step.model,
|
|
402
|
+
answers[step.index - 1]?.output].filter(Boolean).join("\n"));
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
for (const { agent, output } of answers) lines.push(agent + "\n" + output);
|
|
406
|
+
}
|
|
407
|
+
$("#run-result").textContent = lines.join("\n\n");
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
$("#runner").onsubmit = async event => {
|
|
411
|
+
event.preventDefault();
|
|
412
|
+
if (!pending?.ready || runInProgress) return;
|
|
413
|
+
const prompt = $("#prompt");
|
|
414
|
+
if (pending.inputKind === "json") {
|
|
415
|
+
try { JSON.parse(prompt.value); }
|
|
416
|
+
catch {
|
|
417
|
+
prompt.setCustomValidity("Enter valid JSON for the first agent.");
|
|
418
|
+
prompt.reportValidity();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
runInProgress = true;
|
|
423
|
+
$("#run").disabled = true;
|
|
424
|
+
$("#close-run").disabled = true;
|
|
425
|
+
$("#run-status").textContent = "Running…";
|
|
426
|
+
$("#run-result").textContent = "";
|
|
427
|
+
try {
|
|
428
|
+
const result = await api("run", { targets: pending.targets, buttonId: pending.buttonId, revision: pending.revision, input: prompt.value, model: $("#model").value, provider: $("#execution-provider").value });
|
|
429
|
+
showRunResults(result);
|
|
430
|
+
if (pending.outputId) outputs.set(pending.outputId, result.answers.at(-1).output);
|
|
431
|
+
renderCanvas();
|
|
432
|
+
$("#run-status").textContent = "Run completed.";
|
|
433
|
+
} catch (error) {
|
|
434
|
+
if (error.progress) showRunResults(error.progress);
|
|
435
|
+
$("#run-status").textContent = error.message;
|
|
436
|
+
} finally {
|
|
437
|
+
runInProgress = false;
|
|
438
|
+
$("#run").disabled = false;
|
|
439
|
+
$("#close-run").disabled = false;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
$("#prompt").oninput = event => event.target.setCustomValidity("");
|
|
443
|
+
const drawer = $("#drawer");
|
|
444
|
+
$("#resume-run").onclick = () => {
|
|
445
|
+
if (!drawer.open) drawer.showModal();
|
|
446
|
+
$("#resume-run").hidden = true;
|
|
447
|
+
};
|
|
448
|
+
$("#minimize-run").onclick = minimizeRun;
|
|
449
|
+
drawer.oncancel = event => {
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
minimizeRun();
|
|
452
|
+
};
|
|
453
|
+
let pressedBackdrop = false;
|
|
454
|
+
drawer.onpointerdown = event => { pressedBackdrop = event.target === drawer; };
|
|
455
|
+
drawer.onclick = event => {
|
|
456
|
+
if (pressedBackdrop && event.target === drawer) {
|
|
457
|
+
const { left, right, top, bottom } = drawer.getBoundingClientRect();
|
|
458
|
+
if (event.clientX < left || event.clientX > right || event.clientY < top || event.clientY > bottom) minimizeRun();
|
|
459
|
+
}
|
|
460
|
+
pressedBackdrop = false;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
async function load({ catalogOnly = false } = {}) {
|
|
464
|
+
const next = await api("project");
|
|
465
|
+
if (catalogOnly) {
|
|
466
|
+
for (const key of ["agents", "workflows", "teams", "skills", "mode", "frameworkCandidates"]) project[key] = next[key];
|
|
467
|
+
} else {
|
|
468
|
+
project = next;
|
|
469
|
+
dirty = false;
|
|
470
|
+
}
|
|
471
|
+
$("#project-name").textContent = project.name + (project.mode === "gated" ? " · Cloud connected" : project.mode === "standalone" ? " · Working locally" : "");
|
|
472
|
+
$("#open-memory").hidden = Boolean(project.exported || project.preview);
|
|
473
|
+
if (project.exported || project.preview) {
|
|
474
|
+
document.body.classList.add("exported");
|
|
475
|
+
document.title = project.name;
|
|
476
|
+
$("main h1").textContent = project.name;
|
|
477
|
+
} else {
|
|
478
|
+
renderCatalog();
|
|
479
|
+
renderInspector();
|
|
480
|
+
workflowEditor.refresh();
|
|
481
|
+
}
|
|
482
|
+
renderCanvas();
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
for (const [kind, title] of Object.entries(names)) {
|
|
486
|
+
const item = button(title, () => add(kind));
|
|
487
|
+
item.draggable = true;
|
|
488
|
+
item.ondragstart = event => event.dataTransfer.setData("text/lyra-component", kind);
|
|
489
|
+
$("#palette").append(item);
|
|
490
|
+
}
|
|
491
|
+
function closeInspector() {
|
|
492
|
+
selected = null;
|
|
493
|
+
$("#canvas .selected")?.classList.remove("selected");
|
|
494
|
+
renderInspector();
|
|
495
|
+
}
|
|
496
|
+
$("#close-inspector").onclick = closeInspector;
|
|
497
|
+
$("#canvas-panel").onclick = event => {
|
|
498
|
+
if (selected && event.target.isConnected && !event.target.closest(".node")) closeInspector();
|
|
499
|
+
};
|
|
500
|
+
$("#library-search").oninput = renderCatalog;
|
|
501
|
+
$("#library-tabs").onclick = event => {
|
|
502
|
+
const tab = event.target.closest("button[data-library]");
|
|
503
|
+
if (!tab || tab.dataset.library === libraryView) return;
|
|
504
|
+
libraryView = tab.dataset.library;
|
|
505
|
+
$("#library-search").value = "";
|
|
506
|
+
$("#library-content").scrollTop = 0;
|
|
507
|
+
renderCatalog();
|
|
508
|
+
};
|
|
509
|
+
$("#canvas").ondragover = event => {
|
|
510
|
+
if (project.exported || project.preview) return;
|
|
511
|
+
const types = event.dataTransfer.types;
|
|
512
|
+
if (types.includes("text/lyra-component") || types.includes("text/lyra-node")) event.preventDefault();
|
|
513
|
+
};
|
|
514
|
+
$("#canvas").ondrop = event => {
|
|
515
|
+
if (project.exported || project.preview) return;
|
|
516
|
+
event.preventDefault();
|
|
517
|
+
const target = event.target.closest(".node");
|
|
518
|
+
const targetId = target?.dataset.nodeId;
|
|
519
|
+
const targetIndex = project.layout.findIndex(node => node.id === targetId);
|
|
520
|
+
let index = project.layout.length;
|
|
521
|
+
if (targetIndex !== -1) {
|
|
522
|
+
const bounds = target.getBoundingClientRect();
|
|
523
|
+
const spansRow = target.offsetWidth >= $("#canvas").clientWidth - 32;
|
|
524
|
+
const after = spansRow ? event.clientY > bounds.top + bounds.height / 2 :
|
|
525
|
+
event.clientX > bounds.left + bounds.width / 2;
|
|
526
|
+
index = targetIndex + Number(after);
|
|
527
|
+
}
|
|
528
|
+
const sourceId = event.dataTransfer.getData("text/lyra-node");
|
|
529
|
+
if (!sourceId) {
|
|
530
|
+
add(event.dataTransfer.getData("text/lyra-component"), index);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const from = project.layout.findIndex(node => node.id === sourceId);
|
|
534
|
+
if (from === -1 || from === index || from + 1 === index) return;
|
|
535
|
+
const [node] = project.layout.splice(from, 1);
|
|
536
|
+
project.layout.splice(index > from ? index - 1 : index, 0, node);
|
|
537
|
+
selected = node.id;
|
|
538
|
+
change();
|
|
539
|
+
};
|
|
540
|
+
$("#refresh").onclick = () => load({ catalogOnly: dirty }).then(() => announce("Project refreshed.")).catch(error => announce(error.message));
|
|
541
|
+
$("#pull").onclick = async () => {
|
|
542
|
+
$("#pull").disabled = true;
|
|
543
|
+
try {
|
|
544
|
+
const result = await api("pull", {});
|
|
545
|
+
await load({ catalogOnly: true });
|
|
546
|
+
announce(result.added + " added. " + result.preserved + " existing files preserved.");
|
|
547
|
+
} catch (error) { announce(error.message); }
|
|
548
|
+
finally { $("#pull").disabled = false; }
|
|
549
|
+
};
|
|
550
|
+
$("#save").onclick = async () => {
|
|
551
|
+
$("#save").disabled = true;
|
|
552
|
+
const snapshot = JSON.stringify(project.layout);
|
|
553
|
+
try {
|
|
554
|
+
const result = await api("save", { layout: JSON.parse(snapshot), revision: project.revision });
|
|
555
|
+
project.revision = result.revision;
|
|
556
|
+
dirty = snapshot !== JSON.stringify(project.layout);
|
|
557
|
+
announce(dirty ? "Saved. You have newer canvas edits." : "Saved to manifest.json.");
|
|
558
|
+
} catch (error) { announce(error.message); }
|
|
559
|
+
finally { $("#save").disabled = false; }
|
|
560
|
+
};
|
|
561
|
+
window.addEventListener("beforeunload", event => { if (dirty || workflowEditor.dirty()) { event.preventDefault(); event.returnValue = ""; } });
|
|
562
|
+
load().catch(error => announce(error.message));
|