agent-lyra 0.11.1 → 0.11.2

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 CHANGED
@@ -215,6 +215,8 @@ Use **Test action** in the editor to try a bound action, or `app preview` to run
215
215
 
216
216
  ## Lyra App Builder
217
217
 
218
+ Studio opens at `http://127.0.0.1:4174/`. Set `LYRA_STUDIO_PORT` before launching to use a different port. For Studio or app preview, set the corresponding variable to `0` to pick a free port automatically.
219
+
218
220
  Use `app init --name "My app"` in your project, then open `studio` to build its interface. Add components, drag to reorder, or set component widths in the inspector. Bind agent cards and run buttons to agents or runnable workflows from your project. Save to `manifest.json`, then preview or export the same layout.
219
221
 
220
222
  | Command | Purpose |
@@ -223,7 +225,7 @@ Use `app init --name "My app"` in your project, then open `studio` to build its
223
225
  | `app init --template agent` | Start with a side-by-side input and result and a run button ready to bind |
224
226
  | `app init --saved-agents [manifest.json]` | Create the guided Cloud chat using two saved agents |
225
227
  | `app validate <manifest.json>` | Check the manifest |
226
- | `app preview [manifest.json]` | Run the saved layout in a local browser. Set `LYRA_PREVIEW_PORT` to choose a port |
228
+ | `app preview [manifest.json]` | Run the saved layout at `http://127.0.0.1:4173/`. Set `LYRA_PREVIEW_PORT` to override it |
227
229
  | `app export <manifest.json> <new-directory>` | Export editable source to a new directory |
228
230
 
229
231
  These commands are available in npm and Python. To import an app or preview a public listing, see [Marketplace](#marketplace).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-lyra",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Two-layer Lyra SDK with standalone local primitives and gated hosted agents.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -7,29 +7,32 @@ import { startSupportPreview } from "./support-template/support-preview.mjs";
7
7
 
8
8
  export async function runAppPreview(args, output = process.stdout) {
9
9
  if (args.length === 1 && args[0] === "--help") {
10
- output.write("Usage: agent-lyra app preview [manifest.json]\nSet LYRA_PREVIEW_PORT to override the loopback port.\n");
10
+ output.write("Usage: agent-lyra app preview [manifest.json]\nApp preview listens on 127.0.0.1:4173. Set LYRA_PREVIEW_PORT to override it, or use 0 to pick a free port.\n");
11
11
  return;
12
12
  }
13
13
  if (args.length > 1 || args[0]?.startsWith("-")) {
14
14
  throw new Error("Provide at most one manifest path. See agent-lyra app preview --help.");
15
15
  }
16
+ const port = Number(process.env.LYRA_PREVIEW_PORT?.trim() || 4173);
17
+ if (!Number.isInteger(port) || port < 0 || port > 65535) {
18
+ throw new Error("LYRA_PREVIEW_PORT must be an integer from 0 to 65535.");
19
+ }
16
20
  const app = await readAppManifest(args[0] ?? "manifest.json");
17
21
  if (Array.isArray(app?.studio?.layout)) {
18
22
  const path = resolve(args[0] ?? "manifest.json");
19
23
  if (basename(path) !== "manifest.json") throw new Error("Use the project manifest.json for a Studio app preview.");
20
- const port = Number(process.env.LYRA_PREVIEW_PORT ?? 0);
21
24
  const { url } = await startStudio(dirname(path), { preview: true, port }).catch(error => {
22
- if (error.code === "EADDRINUSE") throw new Error("Preview port is busy. Set LYRA_PREVIEW_PORT=0 to pick a free port.");
25
+ if (error.code === "EADDRINUSE") throw new Error("Preview port " + port + " is busy. Close the other server, choose another LYRA_PREVIEW_PORT, or set it to 0 to pick a free port.");
23
26
  throw error;
24
27
  });
25
28
  output.write("App preview: " + url + "\n");
26
29
  return;
27
30
  }
28
31
  if (app?.version === SAVED_VERSION) {
29
- const { url } = await startSavedPreview(app);
32
+ const { url } = await startSavedPreview(app, { port });
30
33
  output.write("App preview: " + url + "\n");
31
34
  return;
32
35
  }
33
36
  const manifest = await readSupportManifest(args[0] ?? "manifest.json");
34
- await startSupportPreview(manifest);
37
+ await startSupportPreview(manifest, { port });
35
38
  }
@@ -18,6 +18,10 @@ function dom(tag, props, ...children) {
18
18
 
19
19
  const agentSources = { local: "Local agent", cloud: "Cloud agent", python: "Python agent", framework: "Registered framework agent" };
20
20
  const names = { heading:"Heading", text:"Text", input:"Text input", textarea:"Text area", button:"Run button", "agent-card":"Agent card", output:"Output" };
21
+ const componentMarks = {
22
+ heading: "H", text: "≡", input: "▏", textarea: "▤",
23
+ button: "▶", "agent-card": "◇", output: "↳",
24
+ };
21
25
  let project = { layout: [], agents: [], workflows: [], teams: [], skills: [] };
22
26
  let selected, pending;
23
27
  let libraryView = "palette";
@@ -235,7 +239,7 @@ function renderCatalog() {
235
239
  const query = search.value.trim().toLowerCase();
236
240
  const rows = project[id].filter(row => !row.linkedLocalId && [row.name, row.source, row.framework, agentSources[row.source]]
237
241
  .some(value => value?.toLowerCase().includes(query)));
238
- const expanded = new Set([...section.querySelectorAll("details[open]")].map(item => item.dataset.agent));
242
+ const expanded = new Set([...section.querySelectorAll(".agent-options[open]")].map(item => item.dataset.agent));
239
243
  section.replaceChildren();
240
244
  if (id === "agents" && !project.cloudConnected) {
241
245
  const callout = dom("div", { className: "cloud-callout" },
@@ -243,6 +247,8 @@ function renderCatalog() {
243
247
  button("Connect to Cloud", openCloudSetup));
244
248
  section.append(callout);
245
249
  }
250
+ if (id === "skills" && rows.length) section.append(element("p",
251
+ "Open a skill to read its instructions. Skills are reference material here and cannot be run from the canvas."));
246
252
  if (!rows.length) section.append(element("p", query ? "No matching items." : "None in this project."));
247
253
  if (id === "agents" && project.frameworkCandidates?.length) {
248
254
  section.append(element("p", "LangGraph candidates: " + project.frameworkCandidates.map(item => item.name).join(", ") +
@@ -279,17 +285,26 @@ function renderCatalog() {
279
285
  announce("Registration synced. Open Cloud → Agents to view it.");
280
286
  } catch (error) { announce(error.message); }
281
287
  });
282
- const entry = element("details");
283
- entry.className = "library-entry";
284
- entry.dataset.agent = row.id;
285
- entry.open = expanded.has(row.id);
286
- const summary = element("summary");
287
288
  const source = row.framework ? row.framework + " · Local" : agentSources[row.source];
288
- summary.append(element("strong", row.name), dom("span", { className: "agent-meta" },
289
+ const name = dom("strong", { title: row.name }, row.name);
290
+ const metadata = dom("div", { className: "agent-meta" },
289
291
  element("span", source), row.syncStatus && dom("span", { className: "pill" },
290
- row.syncStatus === "synced" ? "Synced to Cloud" : "Local edits")));
291
- const actions = dom("div", { className: "actions" }, button("Run now", () => openRun([row.id])), push, pull, sync);
292
- entry.append(summary, actions);
292
+ row.syncStatus === "synced" ? "Synced to Cloud" : "Local edits"));
293
+ const run = button("", () => openRun([row.id]));
294
+ run.className = "agent-icon agent-run";
295
+ run.title = "Run " + row.name;
296
+ run.setAttribute("aria-label", run.title);
297
+ run.append(dom("span", { className: "play-icon" }));
298
+ const entry = dom("article", { className: "library-entry" },
299
+ dom("div", { className: "agent-row" }, dom("div", { className: "agent-label" }, name, metadata), run));
300
+ if (push || pull || sync) {
301
+ const control = dom("summary", { className: "agent-icon", title: "Cloud actions",
302
+ "aria-label": "Cloud actions for " + row.name }, "⋯");
303
+ const options = dom("details", { className: "agent-options", open: expanded.has(row.id) },
304
+ control, dom("div", { className: "actions" }, push, pull, sync));
305
+ options.dataset.agent = row.id;
306
+ entry.append(options);
307
+ }
293
308
  section.append(entry);
294
309
  continue;
295
310
  }
@@ -318,7 +333,23 @@ function renderCatalog() {
318
333
  card.append(control);
319
334
  }
320
335
  }
321
- if (id === "skills") card.append(element("span", row.source === "cloud" ? "Cloud skill" : row.source === "markdown" ? "Local Markdown skill" : "Local text skill"));
336
+ if (id === "skills") {
337
+ card.append(element("span", row.source === "cloud" ? "Cloud skill" : row.source === "markdown" ? "Local Markdown skill" : "Local text skill"));
338
+ const details = element("details");
339
+ const body = dom("div", { className: "skill-instructions", "aria-label": "Skill instructions" });
340
+ details.append(element("summary", "View instructions"), body);
341
+ details.ontoggle = async () => {
342
+ if (!details.open) return;
343
+ body.textContent = "Loading instructions…";
344
+ try {
345
+ const skill = await api("open-skill", { id: row.id });
346
+ body.replaceChildren();
347
+ if (skill.description) body.append(element("p", skill.description));
348
+ body.append(element("pre", skill.instructions || "This skill has no saved instructions."));
349
+ } catch (error) { body.textContent = error.message; }
350
+ };
351
+ card.append(details);
352
+ }
322
353
  if (id === "teams") card.append(element("span", row.source === "cloud" ? "Cloud team" : "Local team"));
323
354
  section.append(card);
324
355
  }
@@ -519,6 +550,11 @@ async function load({ catalogOnly = false } = {}) {
519
550
 
520
551
  for (const [kind, title] of Object.entries(names)) {
521
552
  const item = button(title, () => add(kind));
553
+ item.className = "component-tile";
554
+ const mark = element("span", componentMarks[kind]);
555
+ mark.className = "component-mark";
556
+ mark.setAttribute("aria-hidden", "true");
557
+ item.replaceChildren(mark, element("span", title));
522
558
  item.draggable = true;
523
559
  item.ondragstart = event => event.dataTransfer.setData("text/lyra-component", kind);
524
560
  $("#palette").append(item);
@@ -52,7 +52,7 @@ export function readLocalAgent(source) {
52
52
  return { id: "local:" + id, name, source: "local", prompt };
53
53
  }
54
54
 
55
- export async function readCatalog(root) {
55
+ export async function readCatalog(root, { includeSkillInstructions = false } = {}) {
56
56
  const directory = join(root, ".lyra", "agents");
57
57
  const agents = new Map();
58
58
  for (const name of await resourceFiles(directory, ".md")) {
@@ -119,7 +119,12 @@ export async function readCatalog(root) {
119
119
  const source = await readFile(metadata, "utf8");
120
120
  const front = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/.exec(source);
121
121
  const name = front && markdownValue(front[1], "name");
122
- if (name) skills.push({ id: "markdown:" + folder.name, name, source: "markdown" });
122
+ if (name) skills.push({
123
+ id: "markdown:" + folder.name,
124
+ name,
125
+ source: "markdown",
126
+ ...(includeSkillInstructions ? { body: source.slice(front[0].length).trim() } : {}),
127
+ });
123
128
  }
124
129
  return { agents, workflows: await records("workflows"), teams: await records("teams"), skills };
125
130
  }
@@ -36,6 +36,16 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
36
36
  });
37
37
  return { connected: true };
38
38
  }],
39
+ ["/api/open-skill", async ({ id }) => {
40
+ if (typeof id !== "string") throw new Error("Choose a skill from the library.");
41
+ const { skills } = await readCatalog(root, { includeSkillInstructions: true });
42
+ const skill = skills.find(item => item.id === id);
43
+ if (!skill) throw new Error("This skill is no longer in the project. Reload the library.");
44
+ return {
45
+ description: typeof skill.description === "string" ? skill.description.slice(0, 1024) : "",
46
+ instructions: typeof skill.body === "string" ? skill.body.slice(0, 64_000) : "",
47
+ };
48
+ }],
39
49
  ["/api/save", ({ layout, revision }) => saveLayout(root, layout, revision)],
40
50
  ["/api/pull", () => pull(root)],
41
51
  ["/api/push", ({ id }) => pushStudioAgent(root, id)],
@@ -145,7 +155,7 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
145
155
 
146
156
  export async function runStudio(args, output = process.stdout) {
147
157
  if (args[0] === "--help") {
148
- output.write("Usage: agent-lyra studio | agent-lyra studio pull | agent-lyra studio push <local-agent-id> | agent-lyra studio pull-agent <local-agent-id> | agent-lyra studio push-workflow <workflow-id> | agent-lyra studio pull-workflow <workflow-id> | agent-lyra studio push-team <team-id> | agent-lyra studio pull-team <team-id> | agent-lyra studio push-skill <skill-id> | agent-lyra studio pull-skill <skill-id>\n");
158
+ output.write("Usage: agent-lyra studio | agent-lyra studio pull | agent-lyra studio push <local-agent-id> | agent-lyra studio pull-agent <local-agent-id> | agent-lyra studio push-workflow <workflow-id> | agent-lyra studio pull-workflow <workflow-id> | agent-lyra studio push-team <team-id> | agent-lyra studio pull-team <team-id> | agent-lyra studio push-skill <skill-id> | agent-lyra studio pull-skill <skill-id>\nStudio listens on 127.0.0.1:4174. Set LYRA_STUDIO_PORT to override it, or use 0 to pick a free port.\n");
149
159
  return;
150
160
  }
151
161
  if (args.length === 1 && args[0] === "pull") {
@@ -175,6 +185,15 @@ export async function runStudio(args, output = process.stdout) {
175
185
  return;
176
186
  }
177
187
  if (args.length) throw new Error("See agent-lyra studio --help.");
178
- const { url } = await startStudio(process.cwd());
188
+ const port = Number(process.env.LYRA_STUDIO_PORT?.trim() || 4174);
189
+ if (!Number.isInteger(port) || port < 0 || port > 65535) {
190
+ throw new Error("LYRA_STUDIO_PORT must be an integer from 0 to 65535.");
191
+ }
192
+ const { url } = await startStudio(process.cwd(), { port }).catch(error => {
193
+ if (error.code === "EADDRINUSE") {
194
+ throw new Error("Studio port " + port + " is busy. Close the other server, choose another LYRA_STUDIO_PORT, or set it to 0 to pick a free port.");
195
+ }
196
+ throw error;
197
+ });
179
198
  output.write("AgentLyra Studio: " + url + "\n");
180
199
  }
@@ -24,15 +24,27 @@ main:has(#inspector-panel:not([hidden])) {
24
24
  #library-tabs {
25
25
  display: flex;
26
26
  flex-wrap: wrap;
27
- gap: .35rem;
28
- margin-bottom: .75rem;
27
+ gap: .15rem .7rem;
28
+ margin: 0 0 .85rem;
29
+ padding: 0 0 .25rem;
30
+ border-bottom: 1px solid var(--studio-line);
29
31
  }
30
32
  #library-tabs button {
33
+ min-height: 34px;
34
+ padding: .28rem .08rem;
35
+ border: 0;
36
+ border-bottom: 2px solid transparent;
37
+ border-radius: 0;
38
+ background: transparent;
39
+ color: var(--studio-muted);
31
40
  font-size: .8rem;
32
41
  }
42
+ #library-tabs button:hover,
33
43
  #library-tabs button[aria-pressed="true"] {
34
- background: #e6f0e9;
35
- border-color: #478367;
44
+ color: var(--studio-green);
45
+ }
46
+ #library-tabs button[aria-pressed="true"] {
47
+ border-bottom-color: var(--studio-green);
36
48
  }
37
49
  #library-search-label {
38
50
  font-size: .8rem;
@@ -46,26 +58,6 @@ main:has(#inspector-panel:not([hidden])) {
46
58
  #library-content #palette {
47
59
  margin: 0;
48
60
  }
49
- .library-entry {
50
- border-bottom: 1px solid #d9e4dd;
51
- }
52
- .library-entry summary {
53
- cursor: pointer;
54
- padding: .55rem .25rem;
55
- overflow-wrap: anywhere;
56
- }
57
- .library-entry summary span {
58
- display: block;
59
- padding-left: 1.15rem;
60
- color: #47675a;
61
- font-size: .8rem;
62
- }
63
- .library-entry .actions {
64
- padding: 0 .25rem .6rem;
65
- }
66
- .library-entry .actions button {
67
- font-size: .8rem;
68
- }
69
61
  .inspector-heading {
70
62
  display: flex;
71
63
  justify-content: space-between;
@@ -314,7 +306,6 @@ main { padding-inline: clamp(.9rem, 2.5vw, 2rem); }
314
306
  main > aside, main > section { border-color: var(--studio-line); border-radius: 12px; padding: 1.1rem; box-shadow: 0 2px 5px #192b2408; }
315
307
  #library { top: 5.15rem; }
316
308
  #library-content { padding-right: .25rem; }
317
- #library-tabs button[aria-pressed="true"] { background: var(--studio-tint); border-color: #86ac97; }
318
309
  #status { color: var(--studio-muted); font-size: .83rem; padding-inline: clamp(.9rem, 2.5vw, 2rem); }
319
310
  #status:empty { min-height: .65rem; }
320
311
  #canvas {
@@ -325,11 +316,64 @@ main > aside, main > section { border-color: var(--studio-line); border-radius:
325
316
  background-size: 16px 16px;
326
317
  padding: .9rem;
327
318
  }
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; }
319
+ .library-entry {
320
+ display: grid;
321
+ grid-template-columns: minmax(0, 1fr) auto;
322
+ align-items: start;
323
+ border-bottom: 1px solid var(--studio-line);
324
+ }
325
+ .agent-row {
326
+ display: flex;
327
+ align-items: center;
328
+ justify-content: space-between;
329
+ gap: .25rem;
330
+ min-width: 0;
331
+ padding: .38rem 0 .38rem .25rem;
332
+ }
333
+ .library-entry:hover { background: #f8faf8; }
334
+ .agent-label { min-width: 0; }
335
+ .agent-label > strong {
336
+ display: block;
337
+ overflow: hidden;
338
+ text-overflow: ellipsis;
339
+ white-space: nowrap;
340
+ font-size: .82rem;
341
+ }
342
+ .agent-meta {
343
+ display: flex;
344
+ align-items: center;
345
+ flex-wrap: wrap;
346
+ gap: .15rem .35rem;
347
+ color: var(--studio-muted);
348
+ font-size: .72rem;
349
+ }
350
+ .agent-icon {
351
+ display: grid;
352
+ place-items: center;
353
+ width: 32px;
354
+ min-height: 32px;
355
+ padding: 0;
356
+ border: 0;
357
+ border-radius: 6px;
358
+ background: transparent;
359
+ color: var(--studio-green);
360
+ cursor: pointer;
361
+ }
362
+ .agent-icon:hover, .agent-options[open] > summary { background: var(--studio-tint); }
363
+ .agent-run { flex: 0 0 auto; background: #edf4ef; }
364
+ .play-icon {
365
+ width: 0;
366
+ height: 0;
367
+ margin-left: 2px;
368
+ border-block: 5px solid transparent;
369
+ border-left: 8px solid currentColor;
370
+ }
371
+ .agent-options { display: contents; }
372
+ .agent-options[open]::details-content { display: contents; }
373
+ .agent-options > summary { list-style: none; margin: .38rem 0; font-size: 1.1rem; }
374
+ .agent-options > summary::-webkit-details-marker { display: none; }
375
+ .agent-options .actions { grid-column: 1 / -1; padding: 0 .25rem .45rem; }
376
+ .agent-options .actions button { font-size: .76rem; }
333
377
  .pill, .library-entry .agent-meta .pill {
334
378
  display: inline-block;
335
379
  padding: .1rem .45rem;
@@ -372,3 +416,45 @@ main > aside, main > section { border-color: var(--studio-line); border-radius:
372
416
  .canvas-empty p { margin: .2rem 0 0; color: var(--studio-muted); }
373
417
  .exported #canvas { background-image: none; min-height: 0; }
374
418
  .exported .canvas-empty { display: none; }
419
+
420
+ /* Component tiles in the project library */
421
+ #library-content #palette {
422
+ padding: .2rem .15rem .45rem;
423
+ gap: .5rem;
424
+ }
425
+ .component-tile {
426
+ display: grid;
427
+ justify-items: start;
428
+ align-content: start;
429
+ gap: .42rem;
430
+ min-width: 0;
431
+ min-height: 66px;
432
+ padding: .45rem .55rem;
433
+ border-color: var(--studio-line);
434
+ border-radius: 8px;
435
+ background: #f8faf8;
436
+ color: var(--studio-ink);
437
+ cursor: grab;
438
+ font-size: .8rem;
439
+ text-align: left;
440
+ }
441
+ .component-tile:hover {
442
+ border-color: #86ac97;
443
+ background: var(--studio-tint);
444
+ }
445
+ .component-tile:active { cursor: grabbing; }
446
+ .component-mark {
447
+ display: grid;
448
+ place-items: center;
449
+ width: 23px;
450
+ height: 23px;
451
+ border-radius: 5px;
452
+ background: #e3eee7;
453
+ color: var(--studio-green);
454
+ font: 650 .87rem/1 system-ui, sans-serif;
455
+ }
456
+
457
+
458
+ #skills > p { color: var(--studio-muted); font-size: .8rem; }
459
+ #skills summary { margin-top: .45rem; color: var(--studio-green); cursor: pointer; font-weight: 600; }
460
+ .skill-instructions pre { max-height: 16rem; overflow: auto; font-size: .77rem; }