agent-lyra 0.11.2 → 0.13.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.
Files changed (43) hide show
  1. package/README.md +58 -35
  2. package/bin/agent-lyra.js +4 -1
  3. package/bin/lyra-oss-preview.js +3 -1
  4. package/package.json +1 -1
  5. package/src/app-builder/init.js +3 -3
  6. package/src/framework/agent.js +19 -8
  7. package/src/framework/mda.js +5 -2
  8. package/src/framework/run.py +83 -11
  9. package/src/index.d.ts +1 -0
  10. package/src/index.js +1 -0
  11. package/src/init.js +13 -1
  12. package/src/intelligence/graph-setup.js +125 -0
  13. package/src/intelligence/lifecycle.js +4 -2
  14. package/src/memory/LICENSE +1 -1
  15. package/src/memory/UPSTREAM.json +6 -3
  16. package/src/memory/external-engine.js +35 -0
  17. package/src/memory/index.js +19 -1
  18. package/src/memory/lifecycle.js +2 -1
  19. package/src/runtime/programmatic.d.ts +84 -0
  20. package/src/runtime/programmatic.js +155 -0
  21. package/src/runtime/run-agent.js +10 -2
  22. package/src/standalone/init.js +4 -2
  23. package/src/studio/browser.js +219 -23
  24. package/src/studio/code-discovery.js +81 -0
  25. package/src/studio/export.js +8 -5
  26. package/src/studio/graphsnip-workbench.js +72 -0
  27. package/src/studio/history-panel.js +193 -0
  28. package/src/studio/ide-provider.js +65 -0
  29. package/src/studio/index.html +69 -10
  30. package/src/studio/intelligence.js +110 -0
  31. package/src/studio/local-provider.js +43 -0
  32. package/src/studio/memory-actions.js +28 -1
  33. package/src/studio/memory-panel.js +29 -5
  34. package/src/studio/mission-ui.css +52 -0
  35. package/src/studio/mission-ui.js +57 -0
  36. package/src/studio/programmatic-runner.mjs +21 -0
  37. package/src/studio/programmatic.js +54 -0
  38. package/src/studio/project.js +103 -25
  39. package/src/studio/python-agent.py +31 -4
  40. package/src/studio/run-history.js +128 -0
  41. package/src/studio/server.js +90 -10
  42. package/src/studio/session.js +1 -1
  43. package/src/studio/studio.css +128 -0
@@ -0,0 +1,128 @@
1
+ import { DatabaseSync } from "node:sqlite";
2
+ import { lstat, mkdir, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+
5
+ const defaultRetentionDays = 30;
6
+ const maxEvents = 128;
7
+
8
+ function retentionDays() {
9
+ const value = Number(process.env.LYRA_RUN_HISTORY_DAYS ?? defaultRetentionDays);
10
+ return Number.isInteger(value) && value >= 1 && value <= 365 ? value : defaultRetentionDays;
11
+ }
12
+
13
+ export async function openRunHistory(root) {
14
+ const state = join(root, ".lyra", "state");
15
+ await mkdir(state, { recursive: true, mode: 0o700 });
16
+ for (const path of [join(root, ".lyra"), state]) {
17
+ if (!(await lstat(path)).isDirectory()) throw new Error("Run history requires regular project directories.");
18
+ }
19
+ await writeFile(join(state, ".gitignore"), "*\n", { flag: "wx" }).catch(error => {
20
+ if (error.code !== "EEXIST") throw error;
21
+ });
22
+ const path = join(state, "runs.sqlite");
23
+ const stat = await lstat(path).catch(error => {
24
+ if (error.code === "ENOENT") return undefined;
25
+ throw error;
26
+ });
27
+ if (stat && !stat.isFile()) throw new Error("Run history requires a regular SQLite file.");
28
+ const db = new DatabaseSync(path);
29
+ try {
30
+ db.exec(`
31
+ PRAGMA busy_timeout = 5000;
32
+ PRAGMA foreign_keys = ON;
33
+ CREATE TABLE IF NOT EXISTS studio_runs (
34
+ id TEXT PRIMARY KEY, started_at TEXT NOT NULL, status TEXT NOT NULL, ended_at TEXT
35
+ );
36
+ CREATE INDEX IF NOT EXISTS studio_runs_started ON studio_runs(started_at DESC);
37
+ CREATE TABLE IF NOT EXISTS studio_run_learnings (
38
+ run_id TEXT NOT NULL REFERENCES studio_runs(id) ON DELETE CASCADE,
39
+ position INTEGER NOT NULL, body TEXT NOT NULL, PRIMARY KEY(run_id, position)
40
+ );
41
+ CREATE TABLE IF NOT EXISTS studio_run_events (
42
+ run_id TEXT NOT NULL REFERENCES studio_runs(id) ON DELETE CASCADE,
43
+ sequence INTEGER NOT NULL, body TEXT NOT NULL, PRIMARY KEY(run_id, sequence)
44
+ );
45
+ `);
46
+ } catch (error) {
47
+ db.close();
48
+ throw error;
49
+ }
50
+ const insertRun = db.prepare("INSERT INTO studio_runs (id, started_at, status) VALUES (?, ?, 'running')");
51
+ const insertEvent = db.prepare("INSERT INTO studio_run_events (run_id, sequence, body) VALUES (?, ?, ?)");
52
+ const finishRun = db.prepare("UPDATE studio_runs SET status = ?, ended_at = ? WHERE id = ? AND status = 'running'");
53
+ const prune = db.prepare("DELETE FROM studio_runs WHERE started_at < ?");
54
+ const list = db.prepare(`
55
+ SELECT r.id, r.started_at AS startedAt, r.status, r.ended_at AS endedAt,
56
+ (SELECT e.body FROM studio_run_events e WHERE e.run_id = r.id
57
+ AND json_extract(e.body, '$.type') = 'step.started' ORDER BY e.sequence LIMIT 1) AS firstStep,
58
+ (SELECT COUNT(*) FROM studio_run_events e WHERE e.run_id = r.id
59
+ AND json_extract(e.body, '$.type') = 'step.started') AS steps
60
+ FROM studio_runs r ORDER BY r.started_at DESC, r.id LIMIT 100`);
61
+ const detail = db.prepare("SELECT id, started_at AS startedAt, status, ended_at AS endedAt FROM studio_runs WHERE id = ?");
62
+ const insertLearning = db.prepare("INSERT INTO studio_run_learnings (run_id, position, body) VALUES (?, ?, ?)");
63
+ const readLearnings = db.prepare("SELECT body FROM studio_run_learnings WHERE run_id = ? ORDER BY position");
64
+ const events = db.prepare("SELECT body FROM studio_run_events WHERE run_id = ? ORDER BY sequence LIMIT ?");
65
+ function transaction(work) {
66
+ db.exec("BEGIN IMMEDIATE");
67
+ try {
68
+ const result = work();
69
+ db.exec("COMMIT");
70
+ return result;
71
+ } catch (error) {
72
+ db.exec("ROLLBACK");
73
+ throw error;
74
+ }
75
+ }
76
+ return {
77
+ append(event, suggestions = []) {
78
+ transaction(() => {
79
+ if (event.type === "run.started") {
80
+ const cutoff = new Date(Date.now() - retentionDays() * 86_400_000).toISOString();
81
+ prune.run(cutoff);
82
+ insertRun.run(event.runId, event.timestamp);
83
+ } else if (event.type.startsWith("run.")) {
84
+ finishRun.run(event.type.slice(4), event.timestamp, event.runId);
85
+ }
86
+ if (event.sequence >= maxEvents) throw new Error("Studio run event limit exceeded.");
87
+ insertEvent.run(event.runId, event.sequence, JSON.stringify(event));
88
+ if (event.type === "run.completed") {
89
+ for (const [index, suggestion] of suggestions.entries()) {
90
+ insertLearning.run(event.runId, index, JSON.stringify(suggestion));
91
+ }
92
+ }
93
+ });
94
+ },
95
+ list: () => list.all().map(({ firstStep, ...run }) => {
96
+ const step = firstStep && JSON.parse(firstStep);
97
+ return { ...run, agentName: step?.agentName ?? step?.agentId, source: step?.source };
98
+ }),
99
+ suggestions(id) {
100
+ if (detail.get(id)?.status !== "completed") return [];
101
+ return readLearnings.all(id).map(row => JSON.parse(row.body));
102
+ },
103
+ withCompletedRun(id, action) {
104
+ return transaction(() => {
105
+ if (detail.get(id)?.status !== "completed") throw new Error("Choose a completed run in this project.");
106
+ return action();
107
+ });
108
+ },
109
+ get(id) {
110
+ const run = detail.get(id);
111
+ return run && { schemaVersion: 1, run, events: events.all(id, maxEvents).map(row => JSON.parse(row.body)) };
112
+ },
113
+ close: () => db.close(),
114
+ };
115
+ }
116
+
117
+ const short = value => typeof value === "string" ? value.slice(0, 160) : undefined;
118
+ export function stepEventFields(agentId, step) {
119
+ const usage = Object.fromEntries(Object.entries(step.usage ?? {}).filter(([key, value]) =>
120
+ ["inputTokens", "outputTokens"].includes(key) && Number.isSafeInteger(value) && value >= 0));
121
+ return {
122
+ agentId: short(agentId), source: short(step.source), stepId: short(step.traceId),
123
+ runtimeRunId: short(step.runId), index: step.index,
124
+ provider: short(step.provider), model: short(step.model),
125
+ durationMs: step.durationMs,
126
+ ...(Object.keys(usage).length ? { usage } : {}),
127
+ };
128
+ }
@@ -1,5 +1,8 @@
1
1
  import { discoverFrameworkAgents, syncFrameworkAgent } from "../framework/agent.js";
2
2
  import { memoryActions } from "./memory-actions.js";
3
+ import { discoverCodeAgents, registerCodeAgents } from "./code-discovery.js";
4
+ import { buildKnowledgeGraph, graphTokenLedger, knowledgeGraph, readGraphReport } from "./graphsnip-workbench.js";
5
+ import { openRunHistory } from "./run-history.js";
3
6
  import { createServer } from "node:http";
4
7
  import { readFile } from "node:fs/promises";
5
8
  import { describeRun, readCatalog, readLayout, runSelection, saveLayout, studioModels, validateRunBindings } from "./project.js";
@@ -13,6 +16,9 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
13
16
  const assets = new Map();
14
17
  for (const [route, name, mime] of [
15
18
  ["/lyra-icon.png", "lyra-icon.png", "image/png"],
19
+ ["/mission-ui.js", "mission-ui.js", "text/javascript"], ["/mission-ui.css", "mission-ui.css", "text/css"],
20
+ ["/intelligence.js", "intelligence.js", "text/javascript"],
21
+ ["/history-panel.js", "history-panel.js", "text/javascript"],
16
22
  ["/memory-panel.js", "memory-panel.js", "text/javascript"],
17
23
  ["/agent-ui.js", "agent-ui.js", "text/javascript"], ["/agent-ui.css", "agent-ui.css", "text/css"],
18
24
  ["/", "index.html", "text/html"], ["/studio.js", "browser.js", "text/javascript"], ["/workflow-editor.js", "workflow-editor.js", "text/javascript"], ["/studio.css", "studio.css", "text/css"],
@@ -30,6 +36,12 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
30
36
  await saveOpenAIKey(key);
31
37
  return { configured: true };
32
38
  }],
39
+ ["/api/code-agents/add", async ({ ids }) => registerCodeAgents(root, ids, (await readCatalog(root)).agents)],
40
+ ["/api/graphsnip/build", () => buildKnowledgeGraph(root)],
41
+ ["/api/work-locally", async () => {
42
+ await switchMode(root, "standalone", [], { output: { write() {} } });
43
+ return { connected: false };
44
+ }],
33
45
  ["/api/connect-cloud", async ({ key }) => {
34
46
  await switchMode(root, "gated", key ? ["--replace-key"] : [], {
35
47
  output: { write() {} }, prompt: async () => key,
@@ -70,12 +82,14 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
70
82
  }
71
83
 
72
84
  let running = false;
85
+ let activeStream;
73
86
  let writing = false;
74
87
  const server = createServer(async (req, res) => {
75
- const send = (status, data, type = "application/json") => {
88
+ const send = (status, data, type = "application/json", headers = {}) => {
76
89
  res.writeHead(status, {
77
90
  "Content-Type": type.startsWith("image/") ? type : type + "; charset=utf-8", "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff",
78
- "Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'; frame-ancestors 'none'",
91
+ "Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'; frame-src 'self'; frame-ancestors 'none'",
92
+ ...headers,
79
93
  });
80
94
  res.end(type === "application/json" ? JSON.stringify(data) : data);
81
95
  };
@@ -97,8 +111,8 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
97
111
  mode,
98
112
  hasCloudKey,
99
113
  cloudConnected: mode !== "standalone" && hasCloudKey,
100
- agents: [...catalog.agents.values()].map(({ id, name, source, framework, syncStatus, linkedLocalId }) =>
101
- ({ id, name, source, framework, syncStatus, linkedLocalId })),
114
+ agents: [...catalog.agents.values()].map(({ id, name, source, framework, syncStatus, linkedLocalId, file, description }) =>
115
+ ({ id, name, source, framework, syncStatus, linkedLocalId, file, description })),
102
116
  frameworkCandidates: appCatalog ? [] : await discoverFrameworkAgents(root).catch(() => []),
103
117
  workflows: catalog.workflows.map(({ id, name, runnable, source }) => ({ id, name, runnable, source })),
104
118
  skills: (catalog.skills ?? []).map(({ id, name, source }) => ({ id, name, source })),
@@ -106,8 +120,35 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
106
120
  models: studioModels(),
107
121
  });
108
122
  }
123
+ if (!readOnly && req.method === "GET") {
124
+ if (req.url === "/api/code-agents") return send(200, { candidates: await discoverCodeAgents(root, (await readCatalog(root)).agents) });
125
+ if (req.url === "/api/graphsnip/report") {
126
+ const report = await readGraphReport(root);
127
+ if (!report) return send(404, { error: "GraphSnip report is missing or too large to preview." });
128
+ return send(200, report, "text/html", {
129
+ "Content-Security-Policy": "sandbox; default-src 'none'; style-src 'unsafe-inline'; img-src data:; form-action 'none'; base-uri 'none'; frame-ancestors 'self'",
130
+ "Referrer-Policy": "no-referrer",
131
+ });
132
+ }
133
+ if (req.url === "/api/graphsnip/graph") return send(200, await knowledgeGraph(root));
134
+ if (req.url === "/api/graphsnip/tokens") return send(200, await graphTokenLedger(root));
135
+ }
136
+ const historyRoute = /^\/api\/history\/([a-f0-9-]{36})(\/report)?$/i.exec(req.url);
137
+ const historyId = historyRoute?.[1];
138
+ if (!appCatalog && req.method === "GET" && (req.url === "/api/history" || historyId)) {
139
+ const history = await openRunHistory(root);
140
+ try {
141
+ if (!historyId) return send(200, { schemaVersion: 1, runs: history.list() });
142
+ const detail = history.get(historyId);
143
+ if (!detail) return send(404, { error: "Run not found in this project." });
144
+ return send(200, detail, "application/json", historyRoute[2]
145
+ ? { "Content-Disposition": 'attachment; filename="lyra-run-' + historyId + '.json"' }
146
+ : {});
147
+ } finally { history.close(); }
148
+ }
109
149
  const runRequest = req.url === "/api/run" || req.url === "/api/run-plan";
110
- if (req.method !== "POST" || (!runRequest && (readOnly || !updates.has(req.url)))) {
150
+ const cancelRequest = req.url === "/api/cancel-run";
151
+ if (req.method !== "POST" || (!runRequest && !cancelRequest && (readOnly || !updates.has(req.url)))) {
111
152
  return send(404, { error: "Not found." });
112
153
  }
113
154
  if (req.headers.origin !== "http://" + host) return send(403, { error: "Use the Studio page to submit requests." });
@@ -120,6 +161,11 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
120
161
  chunks.push(chunk);
121
162
  }
122
163
  const body = JSON.parse(Buffer.concat(chunks).toString("utf8"));
164
+ if (cancelRequest) {
165
+ if (!activeStream || activeStream.id !== body.streamId) return send(404, { error: "The IDE run has already stopped." });
166
+ activeStream.controller.abort(new Error("Run cancelled."));
167
+ return send(200, { cancelled: true });
168
+ }
123
169
  if (runRequest && readOnly) {
124
170
  body.targets = await savedActionTargets(body);
125
171
  if (!body.targets) return send(409, { error: "The saved layout changed. Reload the preview before running." });
@@ -131,8 +177,42 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
131
177
  if (running) return send(409, { error: "A Studio run is already in progress." });
132
178
  running = true;
133
179
  try {
134
- return send(200, await run(root, body, appCatalog));
135
- } finally { running = false; }
180
+ if (typeof body.streamId !== "string" ||
181
+ !/^[a-f0-9-]{36}$/i.test(body.streamId)) {
182
+ return send(200, await run(root, body, appCatalog));
183
+ }
184
+ const controller = new AbortController();
185
+ const cancellable = body.provider === "vscode" ||
186
+ (await describeRun(root, body.targets, appCatalog, body.provider)).frameworkOnly;
187
+ if (cancellable) activeStream = { id: body.streamId, controller };
188
+ res.on("close", () => {
189
+ if (cancellable && !res.writableEnded) controller.abort(new Error("Run cancelled."));
190
+ });
191
+ res.writeHead(200, {
192
+ "Content-Type": "application/x-ndjson; charset=utf-8",
193
+ "Cache-Control": "no-store",
194
+ "X-Content-Type-Options": "nosniff",
195
+ });
196
+ res.flushHeaders();
197
+ const emit = event => {
198
+ if (!res.destroyed) res.write(JSON.stringify(event) + "\n");
199
+ };
200
+ try {
201
+ const result = await run(root, body, appCatalog, {
202
+ signal: cancellable ? controller.signal : undefined,
203
+ onDelta: text => emit({ type: "delta", text }),
204
+ onEvent: event => emit({ type: "event", event }),
205
+ });
206
+ emit({ type: "result", result });
207
+ } catch (error) {
208
+ emit({ type: "error", message: error.code ? "Studio could not read or write the project." : error.message,
209
+ progress: error.progress });
210
+ }
211
+ return res.end();
212
+ } finally {
213
+ activeStream = undefined;
214
+ running = false;
215
+ }
136
216
  }
137
217
  if (writing) return send(409, { error: "Studio is already saving or pulling files." });
138
218
  writing = true;
@@ -155,7 +235,7 @@ export async function startStudio(root, { port = 0, run = runSelection, pull = p
155
235
 
156
236
  export async function runStudio(args, output = process.stdout) {
157
237
  if (args[0] === "--help") {
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");
238
+ output.write("Usage: agent-lyra workbench | agent-lyra workbench pull | agent-lyra workbench push <local-agent-id> | agent-lyra workbench pull-agent <local-agent-id> | agent-lyra workbench push-workflow <workflow-id> | agent-lyra workbench pull-workflow <workflow-id> | agent-lyra workbench push-team <team-id> | agent-lyra workbench pull-team <team-id> | agent-lyra workbench push-skill <skill-id> | agent-lyra workbench pull-skill <skill-id>\nWorkbench listens on 127.0.0.1:4174. Set LYRA_STUDIO_PORT to override it, or use 0 to pick a free port.\n");
159
239
  return;
160
240
  }
161
241
  if (args.length === 1 && args[0] === "pull") {
@@ -184,7 +264,7 @@ export async function runStudio(args, output = process.stdout) {
184
264
  : result.updated ? "Updated " + result.name + " from Cloud.\n" : "No Cloud edits to pull.\n");
185
265
  return;
186
266
  }
187
- if (args.length) throw new Error("See agent-lyra studio --help.");
267
+ if (args.length) throw new Error("See agent-lyra workbench --help.");
188
268
  const port = Number(process.env.LYRA_STUDIO_PORT?.trim() || 4174);
189
269
  if (!Number.isInteger(port) || port < 0 || port > 65535) {
190
270
  throw new Error("LYRA_STUDIO_PORT must be an integer from 0 to 65535.");
@@ -195,5 +275,5 @@ export async function runStudio(args, output = process.stdout) {
195
275
  }
196
276
  throw error;
197
277
  });
198
- output.write("AgentLyra Studio: " + url + "\n");
278
+ output.write("AgentLyra Workbench: " + url + "\n");
199
279
  }
@@ -98,7 +98,7 @@ export async function switchMode(root, mode, args, { output = process.stdout, pr
98
98
  }
99
99
  await saveJson(workspace(root), "session.json", { mode });
100
100
  output.write(mode === "gated"
101
- ? "Connected to Cloud. Open Studio and choose Pull from Cloud.\n"
101
+ ? "Connected to Cloud. Open Workbench and choose Pull from Cloud.\n"
102
102
  : "Working locally. Studio Cloud actions are paused.\n");
103
103
  }
104
104
 
@@ -458,3 +458,131 @@ main > aside, main > section { border-color: var(--studio-line); border-radius:
458
458
  #skills > p { color: var(--studio-muted); font-size: .8rem; }
459
459
  #skills summary { margin-top: .45rem; color: var(--studio-green); cursor: pointer; font-weight: 600; }
460
460
  .skill-instructions pre { max-height: 16rem; overflow: auto; font-size: .77rem; }
461
+
462
+
463
+ #history-panel { grid-column: 1 / -1; }
464
+ .history-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: .65rem; }
465
+ .history-heading p { color: var(--studio-muted); }
466
+ .history-content { max-width: 78rem; }
467
+ .history-content { display: grid; grid-template-columns: minmax(11rem, 1fr) minmax(0, 2fr); gap: 1rem; }
468
+ #history-list { max-height: 72dvh; overflow-y: auto; padding: .2rem; }
469
+ .history-row { display: grid; gap: .1rem; padding: .6rem; margin-bottom: .3rem; border: 1px solid var(--studio-line); border-radius: 8px; color: var(--studio-ink); text-decoration: none; }
470
+ .history-row:hover, .history-row[aria-current="true"] { background: var(--studio-tint); }
471
+ .history-row > span:not(.lyra-mission-status), .history-row code { font-size: .76rem; color: var(--studio-muted); }
472
+ #history-detail { min-width: 0; overflow-wrap: anywhere; }
473
+ #history-detail h3 { margin: .15rem 0; }
474
+ #history-detail > a { display: block; width: fit-content; margin-top: .55rem; color: var(--studio-green); font-weight: 600; }
475
+ @media (max-width: 580px) {
476
+ .history-content { grid-template-columns: 1fr; }
477
+ #history-list { max-height: 28dvh; }
478
+ }
479
+
480
+
481
+ #cloud-settings, #library.registry-view { grid-column: 1 / -1; }
482
+ #cloud-settings p { max-width: 54ch; color: var(--studio-muted); }
483
+ #library.registry-view { position: static; }
484
+ #library.registry-view input { max-width: 25rem; }
485
+ #library.registry-view .agent-label > strong { white-space: normal; overflow-wrap: anywhere; }
486
+ #library.registry-view #library-content { max-width: 60rem; }
487
+ #studio-views { flex-wrap: wrap; }
488
+
489
+
490
+ .studio-header {
491
+ display: grid;
492
+ grid-template-columns: minmax(0, 1fr) auto;
493
+ gap: .55rem 1rem;
494
+ }
495
+ #studio-views {
496
+ grid-column: 1 / -1;
497
+ gap: .45rem 1.2rem;
498
+ padding: .35rem 0 0;
499
+ border: 0;
500
+ border-top: 1px solid var(--studio-line);
501
+ border-radius: 0;
502
+ background: transparent;
503
+ }
504
+ #studio-views > div { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem; }
505
+ #studio-views > div > span { margin-right: .25rem; color: var(--studio-muted); font-size: .72rem; }
506
+ #studio-views button { min-height: 30px; font-size: .8rem; }
507
+ #studio-views button[aria-pressed="true"] { border-color: #c9dfd0; background: var(--studio-tint); box-shadow: none; }
508
+ #library { top: 7.4rem; }
509
+ .history-detail-tabs {
510
+ display: flex;
511
+ flex-wrap: wrap;
512
+ gap: .4rem;
513
+ padding: .45rem 0 0;
514
+ margin-top: .6rem;
515
+ border-top: 1px solid var(--studio-line);
516
+ }
517
+ .history-detail-tabs button { min-height: 32px; border-color: transparent; font-size: .8rem; }
518
+ .history-detail-tabs button[aria-pressed="true"] { border-color: #c9dfd0; background: var(--studio-tint); }
519
+ @media (max-width: 950px) {
520
+ #library { top: 1rem; }
521
+ #studio-views { gap: .3rem .7rem; }
522
+ }
523
+ @media (max-width: 520px) {
524
+ .studio-header { grid-template-columns: minmax(0, 1fr); }
525
+ }
526
+
527
+
528
+ .intelligence-panel { grid-column: 1 / -1; }
529
+ #graph-content select { max-width: 28rem; }
530
+ #graph-content ul { max-height: 28rem; overflow: auto; }
531
+ #token-content { display: flex; flex-wrap: wrap; gap: 1rem; }
532
+ #token-content section { flex: 1 1 14rem; background: #f8faf8; border: 1px solid var(--studio-line); border-radius: 8px; padding: .8rem; }
533
+
534
+
535
+ .learning-suggestions { margin: .7rem 0; padding: .65rem; background: var(--studio-tint); border-radius: 8px; }
536
+ .learning-suggestions button { margin: .3rem .35rem 0 0; }
537
+
538
+ .graphsnip-report { display: block; width: 100%; min-height: 32rem; border: 1px solid #dce7df; border-radius: 8px; background: white; }
539
+ /* Workbench uses the same compact surfaces for local and connected projects. */
540
+ :root { --wb-blue:#245ce5; --wb-ink:#15243a; --wb-muted:#54657f; --wb-line:#dce4f0; --wb-tint:#edf3ff; }
541
+ body { font-family: "Inter", "Segoe UI", system-ui, sans-serif; }
542
+ .studio-header { color:var(--wb-ink); border-color:var(--wb-line); }
543
+ #studio-views button[aria-pressed="true"], .workbench-filters button[aria-pressed="true"] { color:#164abf; background:var(--wb-tint); border-color:#c7d8fc; }
544
+ #library.registry-view #library-content { max-width:none; }
545
+ .registry-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,15rem),1fr)); gap:1rem; margin-top:.9rem; }
546
+ .registry-grid .lyra-run-card { display:flex; flex-direction:column; min-width:0; border:1px solid var(--wb-line); border-top:2px solid var(--wb-blue); padding:1rem; border-radius:12px; background:#fff; }
547
+ .registry-grid .lyra-run-card > p { color:var(--wb-muted); flex:1; overflow-wrap:anywhere; margin:.8rem 0 1rem; }
548
+ .registry-grid .lyra-run-action { background:var(--wb-blue); color:white; flex:1; }
549
+ .registry-card-heading { display:flex; gap:.7rem; align-items:center; color:var(--wb-ink); overflow-wrap:anywhere; }
550
+ .registry-card-heading .agent-meta { color:var(--wb-muted); }
551
+ .registry-icon { display:grid; place-items:center; flex:0 0 2.3rem; height:2.3rem; border-radius:9px; background:#e5edff; color:#174fc6; font-weight:700; }
552
+ .workbench-filters { display:flex; gap:.5rem; flex-wrap:wrap; align-items:center; margin:.8rem 0; }
553
+ .workbench-filters input { width:min(100%,18rem); }
554
+ .discovery-callout { display:flex; align-items:center; justify-content:space-between; gap:.8rem; flex-wrap:wrap; border:1px solid #d2defc; background:var(--wb-tint); border-radius:10px; margin:.7rem 0; padding:.75rem 1rem; color:var(--wb-ink); }
555
+ .discovery-callout p { margin:.2rem 0 0; color:var(--wb-muted); }
556
+ .discovery-callout button, #add-discovered { background:var(--wb-blue); border-color:var(--wb-blue); color:#fff; }
557
+ .discovery-option { display:flex; align-items:center; gap:.7rem; padding:.85rem; margin:.5rem 0; border:1px solid var(--wb-line); border-radius:10px; }
558
+ .discovery-option code { display:block; color:var(--wb-muted); overflow-wrap:anywhere; }
559
+ #discovery-review[open], #history-detail[open] { position:fixed; inset:0 0 0 auto; width:min(100%,30rem); height:100dvh; max-height:none; margin:0; padding:1.15rem; background:white; color:var(--wb-ink); border-left:1px solid var(--wb-line); box-shadow:-8px 0 36px #15243a1a; z-index:8; overflow:auto; }
560
+ #discovery-review header, #history-detail header { border-bottom:1px solid var(--wb-line); margin-bottom:1rem; }
561
+ #add-discovered { width:100%; }
562
+ .workbench-metrics { display:grid; grid-template-columns:repeat(auto-fit,minmax(9rem,1fr)); gap:.7rem; }
563
+ .workbench-metrics > div { display:grid; gap:.3rem; padding:.85rem 1rem; border:1px solid var(--wb-line); border-radius:10px; background:#f5f7fb; color:var(--wb-muted); }
564
+ .workbench-metrics strong { font-size:1.65rem; line-height:1.2; color:var(--wb-ink); }
565
+ #history-panel .history-content { display:block; max-width:none; }
566
+ #history-list { overflow:auto; border:1px solid var(--wb-line); border-radius:11px; }
567
+ #history-list > p { padding:.65rem; }
568
+ .workbench-run-table { width:100%; border-collapse:collapse; font-size:.88rem; color:var(--wb-ink); }
569
+ .workbench-run-table th, .workbench-run-table td { padding:.8rem .9rem; border-bottom:1px solid var(--wb-line); text-align:left; }
570
+ .workbench-run-table th { background:#f5f7fb; color:var(--wb-muted); font-size:.76rem; }
571
+ .workbench-run-table td small { display:block; color:var(--wb-muted); }
572
+ .workbench-run-table a { color:#1849b4; font-weight:650; }
573
+ .workbench-run-table .selected-run { background:var(--wb-tint); }
574
+ #history-detail .history-detail-tabs button[aria-pressed="true"] { background:var(--wb-tint); color:#164abf; border-color:#c7d8fc; }
575
+ #drawer .primary { background:var(--wb-blue); border-color:var(--wb-blue); }
576
+
577
+ #drawer { border-left:1px solid var(--wb-line); box-shadow:-8px 0 36px #15243a18; color:var(--wb-ink); }
578
+ #drawer #run-plan { background:#f5f7fb; border-color:var(--wb-line); }
579
+ @media (min-width: 1060px) {
580
+ body:not(.exported) { padding-left:14rem; }
581
+ body:not(.exported) .studio-header { min-height:3.9rem; grid-template-columns:1fr; justify-items:end; }
582
+ body:not(.exported) .studio-brand { position:fixed; inset:0 auto auto 0; width:14rem; height:3.9rem; padding:.85rem; background:white; border-right:1px solid var(--wb-line); border-bottom:1px solid var(--wb-line); z-index:4; }
583
+ body:not(.exported) #studio-views { position:fixed; inset:3.9rem auto 0 0; width:14rem; display:flex; flex-direction:column; flex-wrap:nowrap; align-items:stretch; justify-content:flex-start; gap:.85rem; background:white; border:0; border-right:1px solid var(--wb-line); padding:.9rem; overflow-y:auto; z-index:4; }
584
+ #studio-views > div { flex-direction:column; align-items:stretch; }
585
+ #studio-views > div > span { padding:.2rem .45rem; }
586
+ #studio-views button { text-align:left; }
587
+ #library { top:5rem; }
588
+ }