agent-lyra 0.11.0 → 0.11.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/README.md +2 -2
- package/package.json +1 -1
- package/src/init.js +1 -1
- package/src/runtime/local-cli.js +19 -3
- package/src/studio/browser.js +72 -13
- package/src/studio/export.js +1 -1
- package/src/studio/index.html +19 -3
- package/src/studio/lyra-icon.png +0 -0
- package/src/studio/project.js +26 -9
- package/src/studio/pull-agent.js +2 -3
- package/src/studio/push.js +4 -1
- package/src/studio/server.js +22 -6
- package/src/studio/session.js +25 -1
- package/src/studio/studio.css +117 -0
- package/src/studio/sync.js +7 -0
- package/src/studio/workflow-editor.js +3 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[Get started](#get-started) · [SDK](#sdk-library) · [Coding setup](#coding-setup) · [Studio](#lyra-studio) · [App Builder](#lyra-app-builder) · [Memory](#project-memory-and-skill-proposals) · [Cloud](#agentlyra-cloud-and-marketplace)
|
|
8
8
|
|
|
9
|
-
[Website](https://agentlyra.in/) · [Cloud console](https://console.agentlyra.in/) · [GitHub](https://github.com/agentlyra-labs/agent-lyra-sdk) · [npm](https://www.npmjs.com/package/agent-lyra) · [PyPI](https://pypi.org/project/agent-lyra/)
|
|
9
|
+
[Documentation](https://agentlyra.in/docs) · [Website](https://agentlyra.in/) · [Cloud console](https://console.agentlyra.in/) · [GitHub](https://github.com/agentlyra-labs/agent-lyra-sdk) · [npm](https://www.npmjs.com/package/agent-lyra) · [PyPI](https://pypi.org/project/agent-lyra/)
|
|
10
10
|
|
|
11
11
|
## Choose your starting point
|
|
12
12
|
|
|
@@ -201,7 +201,7 @@ In Studio's run drawer, select an execution provider for text agents. The **Exec
|
|
|
201
201
|
| Codex CLI | Install the authenticated Codex CLI on PATH. Studio requests a read-only sandbox |
|
|
202
202
|
| Claude Code CLI | Install the authenticated Claude Code CLI on PATH. Studio requests tool-free execution |
|
|
203
203
|
|
|
204
|
-
On Windows, Studio discovers native CLI executables (`.exe`) on PATH. To run a saved Cloud text agent locally, connect an SDK key with resource sync permission so Studio can fetch the private agent definition. Choosing Lyra Cloud for a local text agent sends its instructions and input to Cloud for execution. Python and registered framework agents use their own runtimes. VS Code discovery uses workspace settings. Studio provider selection uses CLI or API credentials.
|
|
204
|
+
On Windows, Studio discovers native CLI executables (`.exe`) on PATH. To run a saved Cloud text agent locally, connect an SDK key with resource sync permission so Studio can fetch the private agent definition. Choosing Lyra Cloud for a local text agent sends its instructions and input to Cloud for execution. Python and registered framework agents use their own runtimes. VS Code discovery uses workspace settings. Studio provider selection uses CLI or API credentials. If you select the local OpenAI API and no key is configured, choose **Add OpenAI API key** in the run drawer. Studio saves the key in your user profile for reuse in Studio and Lyra CLI runs from the VS Code terminal. A terminal-provided key takes precedence. VS Code extensions and external agent runtimes manage their own credentials.
|
|
205
205
|
|
|
206
206
|
Hosted Studio text runs record their status, model, duration, and step trace ID in Mission Control. The run drawer and terminal show the matching trace and run IDs. Local-only steps remain local. These SDK execution records store execution metadata and omit prompts and replies.
|
|
207
207
|
|
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -43,7 +43,7 @@ function parseArgs(argv = process.argv.slice(2)) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function printUsage() {
|
|
46
|
-
output.write(`
|
|
46
|
+
output.write(`Documentation: https://agentlyra.in/docs\n\nUsage:\n agent-lyra init\n lyra init\n\nOptions:\n --mode standalone|gated\n --domains coding,finance\n --stack mern,playwright\n --detect\n --api-key <key>\n --api-base-url <url>\n --dir <target-directory>\n --force\n`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function printWelcomeBanner() {
|
package/src/runtime/local-cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
import { parseArgs } from "node:util";
|
|
4
5
|
import { withProjectMemory } from "../memory/lifecycle.js";
|
|
@@ -126,8 +127,9 @@ export async function runLocalCli(argv, {
|
|
|
126
127
|
options: { model: { type: "string" }, prompt: { type: "string" } },
|
|
127
128
|
});
|
|
128
129
|
if (!values.model?.trim() || !values.prompt?.trim()) throw new Error("--model and --prompt are required.");
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
const key = env === process.env ? await readOpenAIKey() : env.OPENAI_API_KEY?.trim();
|
|
131
|
+
if (!key) throw new Error("Add an OpenAI API key in Studio or set OPENAI_API_KEY in your terminal.");
|
|
132
|
+
const provider = createOpenAIProvider(key, fetchRequest);
|
|
131
133
|
const stages = teamCommand
|
|
132
134
|
? [
|
|
133
135
|
{ agentId: "draft-writer", system: "Write a first draft that addresses the user's request." },
|
|
@@ -159,3 +161,17 @@ export async function runLocalCli(argv, {
|
|
|
159
161
|
}
|
|
160
162
|
return true;
|
|
161
163
|
}
|
|
164
|
+
|
|
165
|
+
export async function readOpenAIKey() {
|
|
166
|
+
if (process.env.OPENAI_API_KEY?.trim()) return process.env.OPENAI_API_KEY.trim();
|
|
167
|
+
const directory = join(homedir(), ".agent-lyra");
|
|
168
|
+
const path = join(directory, "providers.json");
|
|
169
|
+
try {
|
|
170
|
+
if (!(await lstat(directory)).isDirectory() || !(await lstat(path)).isFile()) return undefined;
|
|
171
|
+
const { OPENAI_API_KEY: key } = JSON.parse(await readFile(path, "utf8"));
|
|
172
|
+
return typeof key === "string" ? key.trim() : undefined;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
if (error.code === "ENOENT") return undefined;
|
|
175
|
+
throw new Error("Studio could not read the saved OpenAI credential.");
|
|
176
|
+
}
|
|
177
|
+
}
|
package/src/studio/browser.js
CHANGED
|
@@ -79,7 +79,9 @@ function move(node, offset) {
|
|
|
79
79
|
function renderCanvas() {
|
|
80
80
|
const canvas = $("#canvas");
|
|
81
81
|
canvas.replaceChildren();
|
|
82
|
-
if (!project.layout.length) canvas.append(
|
|
82
|
+
if (!project.layout.length) canvas.append(dom("div", { className: "canvas-empty" },
|
|
83
|
+
element("strong", "Start with a component"),
|
|
84
|
+
element("p", "Drag a component here or click one in the library.")));
|
|
83
85
|
for (const node of project.layout) {
|
|
84
86
|
const card = element("div");
|
|
85
87
|
card.dataset.nodeId = node.id;
|
|
@@ -193,7 +195,7 @@ function renderInspector() {
|
|
|
193
195
|
node.outputId = id; dirty = true;
|
|
194
196
|
});
|
|
195
197
|
if (node.kind === "agent-card") {
|
|
196
|
-
addSelect(box, "Agent", [["", "Choose an agent"], ...project.agents.map(agent => [agent.id, agent.name])], node.targets[0], id => {
|
|
198
|
+
addSelect(box, "Agent", [["", "Choose an agent"], ...project.agents.filter(agent => !agent.linkedLocalId || agent.id === node.targets[0]).map(agent => [agent.id, agent.name])], node.targets[0], id => {
|
|
197
199
|
if (node.label === names["agent-card"] || node.label === labelFor(node.targets[0])) {
|
|
198
200
|
node.label = id ? labelFor(id) : names["agent-card"];
|
|
199
201
|
}
|
|
@@ -210,7 +212,7 @@ function renderInspector() {
|
|
|
210
212
|
box.append(row);
|
|
211
213
|
});
|
|
212
214
|
const options = [
|
|
213
|
-
...project.agents.map(agent => [agent.id, agent.name]),
|
|
215
|
+
...project.agents.filter(agent => !agent.linkedLocalId).map(agent => [agent.id, agent.name]),
|
|
214
216
|
...project.workflows.filter(item => item.runnable).map(item => ["workflow:" + item.id, item.name + " (workflow)"]),
|
|
215
217
|
];
|
|
216
218
|
addSelect(box, "Add next step", [["", "Choose agent or workflow"], ...options], "", id => {
|
|
@@ -231,9 +233,16 @@ function renderCatalog() {
|
|
|
231
233
|
const id = libraryView;
|
|
232
234
|
const section = $("#" + id);
|
|
233
235
|
const query = search.value.trim().toLowerCase();
|
|
234
|
-
const rows = project[id].filter(row => [row.name, row.source, row.framework, agentSources[row.source]]
|
|
236
|
+
const rows = project[id].filter(row => !row.linkedLocalId && [row.name, row.source, row.framework, agentSources[row.source]]
|
|
235
237
|
.some(value => value?.toLowerCase().includes(query)));
|
|
238
|
+
const expanded = new Set([...section.querySelectorAll("details[open]")].map(item => item.dataset.agent));
|
|
236
239
|
section.replaceChildren();
|
|
240
|
+
if (id === "agents" && !project.cloudConnected) {
|
|
241
|
+
const callout = dom("div", { className: "cloud-callout" },
|
|
242
|
+
element("p", "Connect to AgentLyra Cloud to pull, push, and sync agents."),
|
|
243
|
+
button("Connect to Cloud", openCloudSetup));
|
|
244
|
+
section.append(callout);
|
|
245
|
+
}
|
|
237
246
|
if (!rows.length) section.append(element("p", query ? "No matching items." : "None in this project."));
|
|
238
247
|
if (id === "agents" && project.frameworkCandidates?.length) {
|
|
239
248
|
section.append(element("p", "LangGraph candidates: " + project.frameworkCandidates.map(item => item.name).join(", ") +
|
|
@@ -241,17 +250,18 @@ function renderCatalog() {
|
|
|
241
250
|
}
|
|
242
251
|
for (const row of rows) {
|
|
243
252
|
if (id === "agents") {
|
|
244
|
-
const push = row.source === "local" && project.
|
|
245
|
-
? button("Push to Cloud", async () => {
|
|
253
|
+
const push = row.source === "local" && project.cloudConnected && row.syncStatus !== "synced"
|
|
254
|
+
? button(row.syncStatus ? "Push local edits" : "Push to Cloud", async () => {
|
|
246
255
|
if (!window.confirm("Send the name and instructions for " + row.name + " to your private AgentLyra Cloud workspace?")) return;
|
|
247
256
|
push.disabled = true;
|
|
248
257
|
try {
|
|
249
258
|
const result = await api("push", { id: row.id });
|
|
250
|
-
|
|
259
|
+
await load({ catalogOnly: true });
|
|
260
|
+
announce((result.unchanged ? "Already synced " : result.created ? "Created " : "Synced ") + row.name + " in AgentLyra Cloud.");
|
|
251
261
|
} catch (error) { announce(error.message); }
|
|
252
262
|
finally { push.disabled = false; }
|
|
253
263
|
}) : undefined;
|
|
254
|
-
const pull =
|
|
264
|
+
const pull = row.syncStatus && project.cloudConnected && button("Pull agent edits", async () => {
|
|
255
265
|
pull.disabled = true;
|
|
256
266
|
try {
|
|
257
267
|
const result = await api("pull-agent", { id: row.id });
|
|
@@ -260,7 +270,7 @@ function renderCatalog() {
|
|
|
260
270
|
} catch (error) { announce(error.message); }
|
|
261
271
|
finally { pull.disabled = false; }
|
|
262
272
|
});
|
|
263
|
-
const sync = row.source === "framework" && project.
|
|
273
|
+
const sync = row.source === "framework" && project.cloudConnected && button("Sync registration", async () => {
|
|
264
274
|
try {
|
|
265
275
|
const id = row.id.slice("framework:".length);
|
|
266
276
|
const preview = await api("framework-preview", { id });
|
|
@@ -271,9 +281,13 @@ function renderCatalog() {
|
|
|
271
281
|
});
|
|
272
282
|
const entry = element("details");
|
|
273
283
|
entry.className = "library-entry";
|
|
284
|
+
entry.dataset.agent = row.id;
|
|
285
|
+
entry.open = expanded.has(row.id);
|
|
274
286
|
const summary = element("summary");
|
|
275
287
|
const source = row.framework ? row.framework + " · Local" : agentSources[row.source];
|
|
276
|
-
summary.append(element("strong", row.name),
|
|
288
|
+
summary.append(element("strong", row.name), dom("span", { className: "agent-meta" },
|
|
289
|
+
element("span", source), row.syncStatus && dom("span", { className: "pill" },
|
|
290
|
+
row.syncStatus === "synced" ? "Synced to Cloud" : "Local edits")));
|
|
277
291
|
const actions = dom("div", { className: "actions" }, button("Run now", () => openRun([row.id])), push, pull, sync);
|
|
278
292
|
entry.append(summary, actions);
|
|
279
293
|
section.append(entry);
|
|
@@ -288,7 +302,7 @@ function renderCatalog() {
|
|
|
288
302
|
: element("span", "Run this workflow in Lyra Cloud."));
|
|
289
303
|
}
|
|
290
304
|
const syncType = id === "skills" && row.source !== "markdown" ? "skill" : id === "teams" ? "team" : id === "workflows" && row.runnable ? "workflow" : undefined;
|
|
291
|
-
if (syncType && row.source !== "cloud" && project.
|
|
305
|
+
if (syncType && row.source !== "cloud" && project.cloudConnected) {
|
|
292
306
|
for (const [action, label] of [["push", "Push to Cloud"], ["pull", "Pull " + syncType + " edits"]]) {
|
|
293
307
|
const control = button(label, async () => {
|
|
294
308
|
if (action === "push" && !window.confirm("Send this " + syncType + " definition to your private Cloud workspace?")) return;
|
|
@@ -343,6 +357,10 @@ async function openRun(targets, input = "", outputId = "", buttonId) {
|
|
|
343
357
|
const picker = $("#model");
|
|
344
358
|
const modelLabel = $('label[for="model"]');
|
|
345
359
|
picker.hidden = modelLabel.hidden = true;
|
|
360
|
+
$("#openai-setup").hidden = true;
|
|
361
|
+
$("#openai-setup").open = false;
|
|
362
|
+
$("#openai-key").value = "";
|
|
363
|
+
$("#openai-status").textContent = "";
|
|
346
364
|
$("#run").disabled = true;
|
|
347
365
|
$("#run").textContent = project.preview || project.exported ? "Run" : "Test action";
|
|
348
366
|
$("#drawer").showModal();
|
|
@@ -373,12 +391,26 @@ async function openRun(targets, input = "", outputId = "", buttonId) {
|
|
|
373
391
|
picker.replaceChildren(...setup.models.map(model => new Option(model, model)));
|
|
374
392
|
if (setup.models.includes(previousModel)) picker.value = previousModel;
|
|
375
393
|
picker.hidden = modelLabel.hidden = !setup.needsModel;
|
|
394
|
+
$("#openai-setup").hidden = !setup.needsOpenAIKey || project.preview || project.exported;
|
|
376
395
|
action.inputKind = setup.inputKind;
|
|
377
396
|
if (setup.inputKind === "json") $("#run-input-label").textContent = "JSON input";
|
|
378
397
|
action.ready = setup.issues.length === 0;
|
|
379
398
|
$("#run-status").textContent = setup.issues.join(" ");
|
|
380
399
|
$("#run").disabled = !action.ready;
|
|
381
400
|
};
|
|
401
|
+
$("#save-openai").onclick = async () => {
|
|
402
|
+
const button = $("#save-openai");
|
|
403
|
+
const key = $("#openai-key");
|
|
404
|
+
button.disabled = true;
|
|
405
|
+
try {
|
|
406
|
+
await api("openai-key", { key: key.value });
|
|
407
|
+
key.value = "";
|
|
408
|
+
await refreshPlan(providerPicker.value);
|
|
409
|
+
if (pending === action && action.ready) $("#run-status").textContent = "OpenAI configured. Ready to run.";
|
|
410
|
+
} catch (error) {
|
|
411
|
+
if (pending === action) $("#openai-status").textContent = error.message;
|
|
412
|
+
} finally { button.disabled = false; }
|
|
413
|
+
};
|
|
382
414
|
providerPicker.onchange = async () => {
|
|
383
415
|
action.ready = false;
|
|
384
416
|
$("#run").disabled = true;
|
|
@@ -463,12 +495,15 @@ drawer.onclick = event => {
|
|
|
463
495
|
async function load({ catalogOnly = false } = {}) {
|
|
464
496
|
const next = await api("project");
|
|
465
497
|
if (catalogOnly) {
|
|
466
|
-
for (const key of ["agents", "workflows", "teams", "skills", "mode", "frameworkCandidates"]) project[key] = next[key];
|
|
498
|
+
for (const key of ["agents", "workflows", "teams", "skills", "mode", "frameworkCandidates", "cloudConnected", "hasCloudKey"]) project[key] = next[key];
|
|
467
499
|
} else {
|
|
468
500
|
project = next;
|
|
469
501
|
dirty = false;
|
|
470
502
|
}
|
|
471
|
-
$("#project-name").textContent = project.name
|
|
503
|
+
$("#project-name").textContent = project.name;
|
|
504
|
+
$("#cloud-state").textContent = project.cloudConnected ? "Cloud connected" : "Working locally";
|
|
505
|
+
$("#pull").hidden = !project.cloudConnected;
|
|
506
|
+
$("#connect-cloud").hidden = project.cloudConnected;
|
|
472
507
|
$("#open-memory").hidden = Boolean(project.exported || project.preview);
|
|
473
508
|
if (project.exported || project.preview) {
|
|
474
509
|
document.body.classList.add("exported");
|
|
@@ -538,6 +573,30 @@ $("#canvas").ondrop = event => {
|
|
|
538
573
|
change();
|
|
539
574
|
};
|
|
540
575
|
$("#refresh").onclick = () => load({ catalogOnly: dirty }).then(() => announce("Project refreshed.")).catch(error => announce(error.message));
|
|
576
|
+
function openCloudSetup() {
|
|
577
|
+
$("#cloud-key").value = "";
|
|
578
|
+
$("#cloud-key").required = !project.hasCloudKey;
|
|
579
|
+
$("#cloud-key-help").replaceChildren(
|
|
580
|
+
project.hasCloudKey ? "Leave this blank to use your saved AgentLyra key. " : "Create a key with resource sync permission. ",
|
|
581
|
+
dom("a", { href: "https://console.agentlyra.in/mcp-servers", target: "_blank", rel: "noopener noreferrer" }, "Open API Keys"));
|
|
582
|
+
$("#cloud-error").textContent = "";
|
|
583
|
+
$("#cloud-setup").showModal();
|
|
584
|
+
}
|
|
585
|
+
$("#connect-cloud").onclick = openCloudSetup;
|
|
586
|
+
$("#close-cloud").onclick = () => $("#cloud-setup").close();
|
|
587
|
+
$("#cloud-setup").addEventListener("close", () => { $("#cloud-key").value = ""; });
|
|
588
|
+
$("#cloud-form").onsubmit = async event => {
|
|
589
|
+
event.preventDefault();
|
|
590
|
+
const control = event.submitter;
|
|
591
|
+
control.disabled = true;
|
|
592
|
+
try {
|
|
593
|
+
await api("connect-cloud", { key: $("#cloud-key").value.trim() });
|
|
594
|
+
$("#cloud-setup").close();
|
|
595
|
+
await load({ catalogOnly: true });
|
|
596
|
+
announce("Cloud mode enabled. You can now pull agents or sync edits.");
|
|
597
|
+
} catch (error) { $("#cloud-error").textContent = error.message; }
|
|
598
|
+
finally { control.disabled = false; }
|
|
599
|
+
};
|
|
541
600
|
$("#pull").onclick = async () => {
|
|
542
601
|
$("#pull").disabled = true;
|
|
543
602
|
try {
|
package/src/studio/export.js
CHANGED
|
@@ -5,7 +5,7 @@ import { readCatalog, resolveSequence, validateLayout, validateRunBindings } fro
|
|
|
5
5
|
|
|
6
6
|
const runtime = [
|
|
7
7
|
"resource-files.js",
|
|
8
|
-
"studio/server.js", "studio/memory-actions.js", "studio/memory-panel.js", "studio/project.js", "studio/sync.js", "studio/index.html",
|
|
8
|
+
"studio/server.js", "studio/memory-actions.js", "studio/memory-panel.js", "studio/project.js", "studio/sync.js", "studio/index.html", "studio/lyra-icon.png",
|
|
9
9
|
"studio/browser.js", "studio/workflow-editor.js", "studio/cli-providers.js", "studio/studio.css", "studio/agent-ui.js", "studio/agent-ui.css", "app-builder/saved-app.js",
|
|
10
10
|
"memory/index.js", "memory/local-store.js", "memory/cloud-sync-actions.js", "memory/validation.js", "memory/proposals.js", "memory/sync.js", "memory/lifecycle.js", "memory/contract.json",
|
|
11
11
|
"framework/agent.js", "framework/run.py", "framework/mda.js",
|
package/src/studio/index.html
CHANGED
|
@@ -5,12 +5,23 @@
|
|
|
5
5
|
<title>AgentLyra Studio</title><link rel="stylesheet" href="/studio.css"><link rel="stylesheet" href="/agent-ui.css"><script src="/studio.js" type="module"></script>
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
|
-
<header
|
|
8
|
+
<header class="studio-header">
|
|
9
|
+
<div class="studio-brand"><img class="studio-mark" src="/lyra-icon.png" width="34" height="34" alt=""><div><strong>AgentLyra Studio</strong><span id="project-name"></span></div></div>
|
|
9
10
|
<nav id="studio-views" aria-label="Studio views">
|
|
10
11
|
<button id="show-layout" type="button" aria-pressed="true">Layout</button>
|
|
11
12
|
<button id="show-workflow" type="button" aria-pressed="false">Workflow</button>
|
|
12
|
-
</nav><div><button id="open-memory" type="button" hidden>Memory</button> <button id="refresh">Reload agents</button> <button id="pull">Pull from Cloud</button> <button class="primary" id="save">Save layout</button></div></header>
|
|
13
|
+
</nav><div class="toolbar"><span id="cloud-state" class="pill"></span><button id="open-memory" type="button" hidden>Memory</button> <button id="refresh">Reload agents</button> <button id="connect-cloud" type="button" hidden>Connect to Cloud</button> <button id="pull" type="button" hidden>Pull from Cloud</button> <button class="primary" id="save">Save layout</button></div></header>
|
|
13
14
|
<p role="status" id="status"></p>
|
|
15
|
+
<dialog id="cloud-setup" aria-labelledby="cloud-title">
|
|
16
|
+
<header><h2 id="cloud-title">Connect to AgentLyra Cloud</h2><button id="close-cloud" type="button">Close</button></header>
|
|
17
|
+
<p>Connect your private workspace to pull agents, send local edits, and sync linked resources.</p>
|
|
18
|
+
<form id="cloud-form">
|
|
19
|
+
<label for="cloud-key">AgentLyra SDK key</label>
|
|
20
|
+
<input id="cloud-key" type="password" maxlength="80" autocomplete="off" spellcheck="false">
|
|
21
|
+
<p id="cloud-key-help"></p>
|
|
22
|
+
<button type="submit" class="primary">Connect workspace</button>
|
|
23
|
+
<p id="cloud-error" role="status"></p>
|
|
24
|
+
</form></dialog>
|
|
14
25
|
<main>
|
|
15
26
|
<aside id="library" aria-labelledby="library-title">
|
|
16
27
|
<h2 id="library-title">Project library</h2>
|
|
@@ -70,5 +81,10 @@
|
|
|
70
81
|
<details><summary>Skill proposals</summary><section id="memory-proposals" aria-label="Skill proposals"></section></details>
|
|
71
82
|
</dialog>
|
|
72
83
|
<button id="resume-run" type="button" class="primary" hidden>Resume run</button>
|
|
73
|
-
<dialog id="drawer" aria-labelledby="run-title"><form id="runner"><div id="run-header"></div><button id="minimize-run" type="button">Minimize</button><section id="run-plan" aria-label="Execution steps" hidden></section><label for="execution-provider" hidden>Local execution provider</label><select id="execution-provider" hidden></select><label for="model" hidden>Local OpenAI model</label><select id="model" hidden></select><
|
|
84
|
+
<dialog id="drawer" aria-labelledby="run-title"><form id="runner"><div id="run-header"></div><button id="minimize-run" type="button">Minimize</button><section id="run-plan" aria-label="Execution steps" hidden></section><label for="execution-provider" hidden>Local execution provider</label><select id="execution-provider" hidden></select><label for="model" hidden>Local OpenAI model</label><select id="model" hidden></select><details id="openai-setup" hidden><summary>Add OpenAI API key</summary>
|
|
85
|
+
<p>Save the key on this computer for Studio and Lyra SDK commands run from your VS Code terminal.</p>
|
|
86
|
+
<label for="openai-key">OpenAI API key</label>
|
|
87
|
+
<input id="openai-key" type="password" maxlength="503" autocomplete="off" spellcheck="false">
|
|
88
|
+
<button id="save-openai" type="button">Save key</button><p id="openai-status" role="status"></p>
|
|
89
|
+
</details><label id="run-input-label" for="prompt">Input</label><textarea id="prompt" maxlength="4000" rows="6" required></textarea><button class="primary" id="run">Run</button><p role="status" id="run-status"></p><pre id="run-result"></pre></form></dialog>
|
|
74
90
|
</body></html>
|
|
Binary file
|
package/src/studio/project.js
CHANGED
|
@@ -5,8 +5,8 @@ import { join, dirname, basename } from "node:path";
|
|
|
5
5
|
import { resourceFiles } from "../resource-files.js";
|
|
6
6
|
import { frameworkDescriptor, runFrameworkAgent } from "../framework/agent.js";
|
|
7
7
|
import { createSavedAgentClient } from "../app-builder/saved-app.js";
|
|
8
|
-
import { createOpenAIProvider, openStore } from "../runtime/local-cli.js";
|
|
9
|
-
import { readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
8
|
+
import { createOpenAIProvider, openStore, readOpenAIKey } from "../runtime/local-cli.js";
|
|
9
|
+
import { agentRevision, readAgentLink, readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
10
10
|
import { pythonDescriptor, runPythonAgent } from "./python-agent.js";
|
|
11
11
|
import { withProjectMemory } from "../memory/lifecycle.js";
|
|
12
12
|
import { runAgent } from "../runtime/run-agent.js";
|
|
@@ -92,6 +92,18 @@ export async function readCatalog(root) {
|
|
|
92
92
|
const id = "python:" + item.id;
|
|
93
93
|
if (!agents.has(id)) agents.set(id, { id, name: item.name, source: "python", ...descriptor });
|
|
94
94
|
}
|
|
95
|
+
for (const agent of [...agents.values()]) {
|
|
96
|
+
if (agent.source !== "local") continue;
|
|
97
|
+
const link = await readAgentLink(root, agent.id).catch(error => {
|
|
98
|
+
if (error instanceof SyntaxError) return undefined;
|
|
99
|
+
throw error;
|
|
100
|
+
});
|
|
101
|
+
if (!link) continue;
|
|
102
|
+
const id = "cloud:" + link.cloudId;
|
|
103
|
+
agent.syncStatus = agentRevision(agent.name, agent.prompt) === link.revision ? "synced" : "edited";
|
|
104
|
+
// Keep legacy Cloud bindings runnable while offering one card for this linked agent.
|
|
105
|
+
agents.set(id, { id, name: agents.get(id)?.name ?? agent.name, source: "cloud", linkedLocalId: agent.id });
|
|
106
|
+
}
|
|
95
107
|
const skills = await records("skills");
|
|
96
108
|
const skillRoot = join(root, ".lyra", "skills");
|
|
97
109
|
for (const relative of await resourceFiles(skillRoot, "SKILL.md")) {
|
|
@@ -216,9 +228,11 @@ export async function describeRun(root, targets, appCatalog, provider) {
|
|
|
216
228
|
provider ??= needsModel ? (hasCloud && cloudAvailable ? "cloud" : "openai") : undefined;
|
|
217
229
|
const models = needsModel && provider === 'openai' ? studioModels() : [];
|
|
218
230
|
const issues = [];
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
231
|
+
const needsOpenAIKey = needsModel && provider === "openai" &&
|
|
232
|
+
!(appCatalog ? process.env.OPENAI_API_KEY?.trim() : await readOpenAIKey());
|
|
233
|
+
if (needsOpenAIKey) issues.push(appCatalog
|
|
234
|
+
? "Configure an OpenAI API key on the app server."
|
|
235
|
+
: "Add an OpenAI API key to run with the OpenAI API, or choose another provider.");
|
|
222
236
|
if (needsModel && provider === 'openai' && !models.length) issues.push("Set LYRA_STUDIO_MODELS to a comma-separated list of OpenAI model IDs.");
|
|
223
237
|
if (hasCloud || provider === "cloud") {
|
|
224
238
|
try {
|
|
@@ -231,7 +245,7 @@ export async function describeRun(root, targets, appCatalog, provider) {
|
|
|
231
245
|
name: agent.name, framework: agent.framework, ...runtimeLabels[agent.source],
|
|
232
246
|
}));
|
|
233
247
|
if (needsModel && !providers.includes(provider)) issues.push('Selected provider is unavailable.');
|
|
234
|
-
return { steps: steps.map((step, i) => ['local', 'cloud'].includes(agents[i].source) ? { ...step, location: provider === 'cloud' ? 'Lyra Cloud' : 'Local project', provider } : step), providers, provider, models, needsModel: needsModel && provider === 'openai', issues, inputKind: agents[0].source === "framework" ? agents[0].input : "text" };
|
|
248
|
+
return { steps: steps.map((step, i) => ['local', 'cloud'].includes(agents[i].source) ? { ...step, location: provider === 'cloud' ? 'Lyra Cloud' : 'Local project', provider } : step), providers, provider, models, needsModel: needsModel && provider === 'openai', issues, needsOpenAIKey, inputKind: agents[0].source === "framework" ? agents[0].input : "text" };
|
|
235
249
|
}
|
|
236
250
|
|
|
237
251
|
export async function runSelection(root, { targets, input, model, provider }, catalog) {
|
|
@@ -247,8 +261,11 @@ export async function runSelection(root, { targets, input, model, provider }, ca
|
|
|
247
261
|
const cli = exported ? [] : await availableCliProviders();
|
|
248
262
|
provider ??= hasCloud ? "cloud" : "openai";
|
|
249
263
|
if (local && !['openai', 'cloud', ...cli].includes(provider)) throw new Error('Selected provider is unavailable.');
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
const openAIKey = local && provider === "openai"
|
|
265
|
+
? exported ? process.env.OPENAI_API_KEY?.trim() : await readOpenAIKey()
|
|
266
|
+
: undefined;
|
|
267
|
+
if (local && provider === "openai" && (!openAIKey || !modelId.test(model ?? ""))) {
|
|
268
|
+
throw new Error("Configure an OpenAI API key and choose a model for this run.");
|
|
252
269
|
}
|
|
253
270
|
let cloud = null;
|
|
254
271
|
if (hasCloud || provider === "cloud") {
|
|
@@ -307,7 +324,7 @@ export async function runSelection(root, { targets, input, model, provider }, ca
|
|
|
307
324
|
const definition = agent.source === "cloud" ? await cloud.definition(agent.id.slice(6)) : agent;
|
|
308
325
|
const request = { model, messages: [{ role: "system", content: definition.prompt }, { role: "user", content: text }] };
|
|
309
326
|
const event = await runAgent({
|
|
310
|
-
agentId: agent.id, store, traceId: status.traceId, provider: createOpenAIProvider(
|
|
327
|
+
agentId: agent.id, store, traceId: status.traceId, provider: createOpenAIProvider(openAIKey, fetch),
|
|
311
328
|
request: exported ? request : await withProjectMemory(root, request),
|
|
312
329
|
});
|
|
313
330
|
status.runId = event.run_id;
|
package/src/studio/pull-agent.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { lstat, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { resourceFiles } from "../resource-files.js";
|
|
5
5
|
import { readLocalAgent } from "./project.js";
|
|
6
|
-
import { readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
6
|
+
import { agentRevision as hash, readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
7
7
|
|
|
8
|
-
const hash = (name, systemPrompt) => createHash("sha256").update(JSON.stringify({ name, systemPrompt })).digest("hex");
|
|
9
8
|
const digest = /^[a-f0-9]{64}$/;
|
|
10
9
|
|
|
11
10
|
export async function pullAgentEdits(root, id, { request = fetch, key } = {}) {
|
package/src/studio/push.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { lstat, mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { readCatalog } from "./project.js";
|
|
5
|
-
import { readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
5
|
+
import { agentRevision, readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
6
6
|
|
|
7
7
|
export async function pushStudioAgent(root, id, { key, request = fetch } = {}) {
|
|
8
8
|
requireCloudMode(await readMode(root));
|
|
@@ -29,6 +29,9 @@ export async function pushStudioAgent(root, id, { key, request = fetch } = {}) {
|
|
|
29
29
|
} catch (error) {
|
|
30
30
|
if (error.code !== "ENOENT") throw error;
|
|
31
31
|
}
|
|
32
|
+
if (link && agentRevision(agent.name, agent.prompt) === link.revision) {
|
|
33
|
+
return { name: agent.name, created: false, unchanged: true };
|
|
34
|
+
}
|
|
32
35
|
const linkId = link?.linkId ?? createHash("sha256").update(resolve(root) + "\0" + id).digest("hex");
|
|
33
36
|
const response = await request("https://api.agentlyra.in/api/sdk/v1/studio/agents/" + linkId, {
|
|
34
37
|
method: "PUT", headers: { Authorization: "Bearer " + key, "Content-Type": "application/json" },
|
package/src/studio/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { memoryActions } from "./memory-actions.js";
|
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import { describeRun, readCatalog, readLayout, runSelection, saveLayout, studioModels, validateRunBindings } from "./project.js";
|
|
6
|
-
import { readMode } from "./session.js";
|
|
6
|
+
import { readMode, readSdkKey, saveOpenAIKey, switchMode } from "./session.js";
|
|
7
7
|
import { openStudioWorkflow, saveStudioWorkflow, syncSkill, syncTeam, syncWorkflow } from "./workflow-sync.js";
|
|
8
8
|
import { pullAgentEdits } from "./pull-agent.js";
|
|
9
9
|
import { pushStudioAgent } from "./push.js";
|
|
@@ -12,6 +12,7 @@ import { pullStudio } from "./sync.js";
|
|
|
12
12
|
export async function startStudio(root, { port = 0, run = runSelection, pull = pullStudio, appCatalog, preview = false } = {}) {
|
|
13
13
|
const assets = new Map();
|
|
14
14
|
for (const [route, name, mime] of [
|
|
15
|
+
["/lyra-icon.png", "lyra-icon.png", "image/png"],
|
|
15
16
|
["/memory-panel.js", "memory-panel.js", "text/javascript"],
|
|
16
17
|
["/agent-ui.js", "agent-ui.js", "text/javascript"], ["/agent-ui.css", "agent-ui.css", "text/css"],
|
|
17
18
|
["/", "index.html", "text/html"], ["/studio.js", "browser.js", "text/javascript"], ["/workflow-editor.js", "workflow-editor.js", "text/javascript"], ["/studio.css", "studio.css", "text/css"],
|
|
@@ -25,6 +26,16 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
|
|
|
25
26
|
if (typeof fingerprint !== "string") throw new Error("Preview the registration before syncing.");
|
|
26
27
|
return syncFrameworkAgent(root, id, fingerprint);
|
|
27
28
|
}],
|
|
29
|
+
["/api/openai-key", async ({ key }) => {
|
|
30
|
+
await saveOpenAIKey(key);
|
|
31
|
+
return { configured: true };
|
|
32
|
+
}],
|
|
33
|
+
["/api/connect-cloud", async ({ key }) => {
|
|
34
|
+
await switchMode(root, "gated", key ? ["--replace-key"] : [], {
|
|
35
|
+
output: { write() {} }, prompt: async () => key,
|
|
36
|
+
});
|
|
37
|
+
return { connected: true };
|
|
38
|
+
}],
|
|
28
39
|
["/api/save", ({ layout, revision }) => saveLayout(root, layout, revision)],
|
|
29
40
|
["/api/pull", () => pull(root)],
|
|
30
41
|
["/api/push", ({ id }) => pushStudioAgent(root, id)],
|
|
@@ -53,8 +64,8 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
|
|
|
53
64
|
const server = createServer(async (req, res) => {
|
|
54
65
|
const send = (status, data, type = "application/json") => {
|
|
55
66
|
res.writeHead(status, {
|
|
56
|
-
"Content-Type": type + "; charset=utf-8", "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff",
|
|
57
|
-
"Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; frame-ancestors 'none'",
|
|
67
|
+
"Content-Type": type.startsWith("image/") ? type : type + "; charset=utf-8", "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff",
|
|
68
|
+
"Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'; frame-ancestors 'none'",
|
|
58
69
|
});
|
|
59
70
|
res.end(type === "application/json" ? JSON.stringify(data) : data);
|
|
60
71
|
};
|
|
@@ -67,12 +78,17 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
|
|
|
67
78
|
try {
|
|
68
79
|
if (req.method === "GET" && req.url === "/api/project") {
|
|
69
80
|
const catalog = appCatalog ?? await readCatalog(root);
|
|
81
|
+
const mode = appCatalog ? undefined : await readMode(root);
|
|
82
|
+
const hasCloudKey = !appCatalog && Boolean(await readSdkKey(root));
|
|
70
83
|
return send(200, {
|
|
71
84
|
...await readLayout(root),
|
|
72
85
|
exported: Boolean(appCatalog),
|
|
73
86
|
preview,
|
|
74
|
-
mode
|
|
75
|
-
|
|
87
|
+
mode,
|
|
88
|
+
hasCloudKey,
|
|
89
|
+
cloudConnected: mode !== "standalone" && hasCloudKey,
|
|
90
|
+
agents: [...catalog.agents.values()].map(({ id, name, source, framework, syncStatus, linkedLocalId }) =>
|
|
91
|
+
({ id, name, source, framework, syncStatus, linkedLocalId })),
|
|
76
92
|
frameworkCandidates: appCatalog ? [] : await discoverFrameworkAgents(root).catch(() => []),
|
|
77
93
|
workflows: catalog.workflows.map(({ id, name, runnable, source }) => ({ id, name, runnable, source })),
|
|
78
94
|
skills: (catalog.skills ?? []).map(({ id, name, source }) => ({ id, name, source })),
|
|
@@ -140,7 +156,7 @@ export async function runStudio(args, output = process.stdout) {
|
|
|
140
156
|
if (args.length === 2 && args[0] === "push") {
|
|
141
157
|
const id = args[1].startsWith("local:") ? args[1] : "local:" + args[1];
|
|
142
158
|
const result = await pushStudioAgent(process.cwd(), id);
|
|
143
|
-
output.write((result.created ? "Created " : "Synced ") + result.name + " in AgentLyra Cloud.\n");
|
|
159
|
+
output.write((result.unchanged ? "Already synced " : result.created ? "Created " : "Synced ") + result.name + " in AgentLyra Cloud.\n");
|
|
144
160
|
return;
|
|
145
161
|
}
|
|
146
162
|
if (args.length === 2 && args[0] === "pull-agent") {
|
package/src/studio/session.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { lstat, mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
@@ -46,6 +46,30 @@ export async function readSdkKey(root, { home = account() } = {}) {
|
|
|
46
46
|
return validKey(workspaceKey) ? workspaceKey : undefined;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export const agentRevision = (name, systemPrompt) =>
|
|
50
|
+
createHash("sha256").update(JSON.stringify({ name: name.trim(), systemPrompt: systemPrompt.trim() })).digest("hex");
|
|
51
|
+
|
|
52
|
+
export async function readAgentLink(root, id) {
|
|
53
|
+
if (!/^local:[a-zA-Z0-9][a-zA-Z0-9_-]{0,95}$/.test(id)) return undefined;
|
|
54
|
+
const directory = join(workspace(root), "agent-links");
|
|
55
|
+
if (!(await lstat(directory).catch(error => {
|
|
56
|
+
if (error.code === "ENOENT") return null;
|
|
57
|
+
throw error;
|
|
58
|
+
}))?.isDirectory()) return undefined;
|
|
59
|
+
const link = await readJson(join(directory, id.slice(6) + ".json"));
|
|
60
|
+
return /^[a-f0-9]{64}$/.test(link.linkId ?? "") &&
|
|
61
|
+
/^[a-f0-9]{64}$/.test(link.revision ?? "") &&
|
|
62
|
+
/^[a-f0-9]{24}$/i.test(link.cloudId ?? "") ? link : undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function saveOpenAIKey(value) {
|
|
66
|
+
const key = typeof value === "string" ? value.trim() : "";
|
|
67
|
+
if (!/^sk-[a-zA-Z0-9_-]{16,500}$/.test(key)) {
|
|
68
|
+
throw new Error("Paste an OpenAI API key beginning with sk-.");
|
|
69
|
+
}
|
|
70
|
+
await saveJson(account(), "providers.json", { OPENAI_API_KEY: key });
|
|
71
|
+
}
|
|
72
|
+
|
|
49
73
|
async function promptKey() {
|
|
50
74
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
51
75
|
throw new Error("Run this command in your IDE terminal to enter an AgentLyra API key, or supply LYRA_API_KEY in the environment.");
|
package/src/studio/studio.css
CHANGED
|
@@ -255,3 +255,120 @@ main:has(#inspector-panel:not([hidden])) {
|
|
|
255
255
|
margin: 1rem 0;
|
|
256
256
|
padding-left: .85rem;
|
|
257
257
|
}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
/* AgentLyra workspace */
|
|
261
|
+
:root {
|
|
262
|
+
--studio-ink: #192b24;
|
|
263
|
+
--studio-muted: #52675e;
|
|
264
|
+
--studio-line: #dce6df;
|
|
265
|
+
--studio-green: #214e3d;
|
|
266
|
+
--studio-tint: #eaf3ed;
|
|
267
|
+
}
|
|
268
|
+
body {
|
|
269
|
+
background: #f4f7f5;
|
|
270
|
+
color: var(--studio-ink);
|
|
271
|
+
font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
|
|
272
|
+
}
|
|
273
|
+
.studio-header {
|
|
274
|
+
position: sticky;
|
|
275
|
+
top: 0;
|
|
276
|
+
z-index: 2;
|
|
277
|
+
min-height: 68px;
|
|
278
|
+
padding: .65rem clamp(.9rem, 2.5vw, 2rem);
|
|
279
|
+
border-color: var(--studio-line);
|
|
280
|
+
}
|
|
281
|
+
.studio-brand, .toolbar { display: flex; align-items: center; gap: .5rem; }
|
|
282
|
+
.toolbar { flex-wrap: wrap; }
|
|
283
|
+
.studio-mark {
|
|
284
|
+
display: grid;
|
|
285
|
+
place-items: center;
|
|
286
|
+
width: 34px;
|
|
287
|
+
height: 34px;
|
|
288
|
+
margin-right: .2rem;
|
|
289
|
+
border-radius: 9px;
|
|
290
|
+
background: var(--studio-green);
|
|
291
|
+
color: white;
|
|
292
|
+
font-size: 19px;
|
|
293
|
+
font-weight: 650;
|
|
294
|
+
}
|
|
295
|
+
#project-name { display: block; color: var(--studio-muted); font-size: .78rem; overflow-wrap: anywhere; }
|
|
296
|
+
#studio-views { padding: .22rem; background: #f0f4f1; border: 1px solid var(--studio-line); border-radius: 9px; }
|
|
297
|
+
#studio-views button { border-color: transparent; background: transparent; }
|
|
298
|
+
#studio-views button[aria-pressed="true"] { background: white; border-color: var(--studio-line); box-shadow: 0 1px 3px #192b2411; }
|
|
299
|
+
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.025em; }
|
|
300
|
+
h2 { font-weight: 650; }
|
|
301
|
+
button {
|
|
302
|
+
min-height: 34px;
|
|
303
|
+
border-color: #cbdacf;
|
|
304
|
+
border-radius: 7px;
|
|
305
|
+
font-weight: 600;
|
|
306
|
+
}
|
|
307
|
+
button:disabled { cursor: not-allowed; }
|
|
308
|
+
.primary { background: var(--studio-green); border-color: var(--studio-green); }
|
|
309
|
+
:is(button, a, input, textarea, select, summary):focus-visible { outline: 2px solid #286b51; outline-offset: 2px; }
|
|
310
|
+
label { font-size: .85rem; font-weight: 600; }
|
|
311
|
+
input, textarea, select { border-color: #cbdacf; border-radius: 7px; padding: .52rem .65rem; }
|
|
312
|
+
select { padding-right: 1.4rem; }
|
|
313
|
+
main { padding-inline: clamp(.9rem, 2.5vw, 2rem); }
|
|
314
|
+
main > aside, main > section { border-color: var(--studio-line); border-radius: 12px; padding: 1.1rem; box-shadow: 0 2px 5px #192b2408; }
|
|
315
|
+
#library { top: 5.15rem; }
|
|
316
|
+
#library-content { padding-right: .25rem; }
|
|
317
|
+
#library-tabs button[aria-pressed="true"] { background: var(--studio-tint); border-color: #86ac97; }
|
|
318
|
+
#status { color: var(--studio-muted); font-size: .83rem; padding-inline: clamp(.9rem, 2.5vw, 2rem); }
|
|
319
|
+
#status:empty { min-height: .65rem; }
|
|
320
|
+
#canvas {
|
|
321
|
+
min-height: 22rem;
|
|
322
|
+
border-color: #adbfaf;
|
|
323
|
+
background-color: #f9fcfa;
|
|
324
|
+
background-image: radial-gradient(#dce6df 1px, transparent 1px);
|
|
325
|
+
background-size: 16px 16px;
|
|
326
|
+
padding: .9rem;
|
|
327
|
+
}
|
|
328
|
+
.library-entry { margin-bottom: .35rem; padding: .1rem .2rem; border: 1px solid var(--studio-line); border-radius: 7px; }
|
|
329
|
+
.library-entry[open] { border-color: #a1bbaa; }
|
|
330
|
+
.library-entry summary:hover { color: #286b51; }
|
|
331
|
+
.library-entry .agent-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .4rem; }
|
|
332
|
+
.library-entry .agent-meta span { padding-left: 0; }
|
|
333
|
+
.pill, .library-entry .agent-meta .pill {
|
|
334
|
+
display: inline-block;
|
|
335
|
+
padding: .1rem .45rem;
|
|
336
|
+
border: 1px solid #d4e5da;
|
|
337
|
+
border-radius: 99px;
|
|
338
|
+
background: var(--studio-tint);
|
|
339
|
+
color: var(--studio-green);
|
|
340
|
+
font-size: .73rem;
|
|
341
|
+
font-weight: 650;
|
|
342
|
+
}
|
|
343
|
+
.cloud-callout, #openai-setup {
|
|
344
|
+
padding: .7rem;
|
|
345
|
+
margin-bottom: .65rem;
|
|
346
|
+
border: 1px solid var(--studio-line);
|
|
347
|
+
border-radius: 8px;
|
|
348
|
+
background: #f4f8f5;
|
|
349
|
+
}
|
|
350
|
+
#openai-setup summary { cursor: pointer; font-weight: 650; }
|
|
351
|
+
#openai-setup p, #cloud-key-help { color: var(--studio-muted); }
|
|
352
|
+
#run-result:empty, #openai-status:empty, #cloud-error:empty { display: none; }
|
|
353
|
+
#drawer, #cloud-setup { padding: 1.25rem; box-shadow: -12px 0 44px #192b2422; }
|
|
354
|
+
#drawer::backdrop, #cloud-setup::backdrop { background: #132d246b; }
|
|
355
|
+
#cloud-setup a { color: var(--studio-green); font-weight: 600; }
|
|
356
|
+
@media (max-width: 950px) {
|
|
357
|
+
.studio-header { position: static; flex-wrap: wrap; }
|
|
358
|
+
#library { top: 1rem; }
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.canvas-empty {
|
|
362
|
+
place-self: center;
|
|
363
|
+
align-self: start;
|
|
364
|
+
max-width: 26rem;
|
|
365
|
+
margin: 6rem 0 2rem;
|
|
366
|
+
padding: .8rem 1.15rem;
|
|
367
|
+
border: 1px solid var(--studio-line);
|
|
368
|
+
border-radius: 9px;
|
|
369
|
+
background: white;
|
|
370
|
+
text-align: center;
|
|
371
|
+
}
|
|
372
|
+
.canvas-empty p { margin: .2rem 0 0; color: var(--studio-muted); }
|
|
373
|
+
.exported #canvas { background-image: none; min-height: 0; }
|
|
374
|
+
.exported .canvas-empty { display: none; }
|
package/src/studio/sync.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readCatalog } from "./project.js";
|
|
1
2
|
import { lstat, mkdir, writeFile } from "node:fs/promises";
|
|
2
3
|
import { readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
3
4
|
import { join } from "node:path";
|
|
@@ -16,6 +17,8 @@ export async function pullStudio(root, { key, request = fetch } = {}) {
|
|
|
16
17
|
await mkdir(base, { recursive: true });
|
|
17
18
|
if (!(await lstat(base)).isDirectory()) throw new Error(".lyra must be a regular directory.");
|
|
18
19
|
|
|
20
|
+
const linked = new Set([...((await readCatalog(root)).agents.values())]
|
|
21
|
+
.filter(agent => agent.linkedLocalId).map(agent => agent.id));
|
|
19
22
|
for (const [kind, rows] of Object.entries({ agents: catalog.agents, workflows: catalog.workflows, teams: catalog.teams, skills: catalog.skills ?? [] })) {
|
|
20
23
|
if (!Array.isArray(rows) || rows.length > 100) throw new Error("Unexpected Cloud catalog response.");
|
|
21
24
|
const folder = join(base, kind);
|
|
@@ -25,6 +28,10 @@ export async function pullStudio(root, { key, request = fetch } = {}) {
|
|
|
25
28
|
if (typeof row?.id !== "string" || !/^[a-f0-9]{24}$/i.test(row.id) || typeof row.name !== "string") {
|
|
26
29
|
throw new Error("Unexpected Cloud catalog entry.");
|
|
27
30
|
}
|
|
31
|
+
if (kind === "agents" && linked.has("cloud:" + row.id)) {
|
|
32
|
+
count.preserved++;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
28
35
|
const name = "cloud-" + row.id + (kind === "agents" ? ".md" : ".json");
|
|
29
36
|
const content = kind === "agents"
|
|
30
37
|
? "---\nid: " + row.id + "\nname: " + JSON.stringify(row.name) + "\nmode: cloud\n---\n"
|
|
@@ -104,7 +104,9 @@ export function mountWorkflowEditor({ api, project, reloadCatalog, run, switchVi
|
|
|
104
104
|
config.append(element("h2", "Configure step " + (selected + 1)));
|
|
105
105
|
const agent = document.createElement("select");
|
|
106
106
|
agent.add(new Option("Choose an agent", ""));
|
|
107
|
-
for (const candidate of project().agents)
|
|
107
|
+
for (const candidate of project().agents) {
|
|
108
|
+
if (!candidate.linkedLocalId || candidate.id === step.agentId) agent.add(new Option(candidate.name, candidate.id));
|
|
109
|
+
}
|
|
108
110
|
if (step.agentId && !agentName(step.agentId)) agent.add(new Option("Unavailable agent · " + step.agentId, step.agentId));
|
|
109
111
|
agent.value = step.agentId ?? "";
|
|
110
112
|
agent.onchange = () => { step.agentId = agent.value; markChanged(); drawGraph(); };
|