agent-lyra 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +435 -395
- package/bin/agent-lyra.js +49 -44
- package/bin/lyra-oss-preview.js +16 -0
- package/package.json +60 -60
- package/src/app-builder/export.js +109 -109
- package/src/app-builder/gateway.js +62 -62
- package/src/app-builder/init.js +52 -52
- package/src/app-builder/manifest-contract.js +46 -0
- package/src/app-builder/native-adapter.js +29 -29
- package/src/app-builder/preview.js +22 -22
- package/src/app-builder/publish.js +14 -14
- package/src/app-builder/saved-app.js +70 -70
- package/src/app-builder/saved-preview-browser.js +33 -33
- package/src/app-builder/saved-preview.html +24 -24
- package/src/app-builder/saved-preview.js +61 -61
- package/src/app-builder/support-manifest.js +50 -50
- package/src/app-builder/support-template/manifest.json +55 -55
- package/src/app-builder/support-template/support-preview.html +56 -56
- package/src/app-builder/support-template/support-preview.js +37 -37
- package/src/app-builder/support-template/support-preview.mjs +67 -67
- package/src/app-builder/support-template/support-workflow.mjs +36 -36
- package/src/app-builder/use.js +37 -37
- package/src/app-builder/validate.js +21 -64
- package/src/app-builder/value-schema.js +37 -37
- package/src/catalog.js +147 -147
- package/src/coding/catalog.js +56 -0
- package/src/coding/cloud-catalog.js +64 -0
- package/src/coding/detect-stack.mjs +110 -0
- package/src/coding/export.js +130 -0
- package/src/coding/setup.js +175 -0
- package/src/coding/skills/lyra-android/SKILL.md +37 -0
- package/src/coding/skills/lyra-angular/SKILL.md +37 -0
- package/src/coding/skills/lyra-cucumber/SKILL.md +37 -0
- package/src/coding/skills/lyra-dbt/SKILL.md +37 -0
- package/src/coding/skills/lyra-django/SKILL.md +37 -0
- package/src/coding/skills/lyra-docker/SKILL.md +37 -0
- package/src/coding/skills/lyra-dotnet/SKILL.md +37 -0
- package/src/coding/skills/lyra-express/SKILL.md +37 -0
- package/src/coding/skills/lyra-fastapi/SKILL.md +37 -0
- package/src/coding/skills/lyra-flutter/SKILL.md +37 -0
- package/src/coding/skills/lyra-github-actions/SKILL.md +37 -0
- package/src/coding/skills/lyra-gitlab-ci/SKILL.md +37 -0
- package/src/coding/skills/lyra-go/SKILL.md +37 -0
- package/src/coding/skills/lyra-ios/SKILL.md +37 -0
- package/src/coding/skills/lyra-kubernetes/SKILL.md +37 -0
- package/src/coding/skills/lyra-mongodb/SKILL.md +37 -0
- package/src/coding/skills/lyra-mysql/SKILL.md +37 -0
- package/src/coding/skills/lyra-nextjs/SKILL.md +37 -0
- package/src/coding/skills/lyra-node/SKILL.md +37 -0
- package/src/coding/skills/lyra-playwright/SKILL.md +37 -0
- package/src/coding/skills/lyra-postgresql/SKILL.md +37 -0
- package/src/coding/skills/lyra-python/SKILL.md +37 -0
- package/src/coding/skills/lyra-react/SKILL.md +37 -0
- package/src/coding/skills/lyra-react-native/SKILL.md +37 -0
- package/src/coding/skills/lyra-redis/SKILL.md +37 -0
- package/src/coding/skills/lyra-rust/SKILL.md +37 -0
- package/src/coding/skills/lyra-spark/SKILL.md +37 -0
- package/src/coding/skills/lyra-spring-boot/SKILL.md +37 -0
- package/src/coding/skills/lyra-svelte/SKILL.md +37 -0
- package/src/coding/skills/lyra-terraform/SKILL.md +37 -0
- package/src/coding/skills/lyra-typescript/SKILL.md +37 -0
- package/src/coding/skills/lyra-vue/SKILL.md +37 -0
- package/src/gated/hostedAgents.js +56 -56
- package/src/gated/index.d.ts +25 -25
- package/src/gated/index.js +5 -5
- package/src/index.d.ts +2 -2
- package/src/index.js +2 -2
- package/src/init.js +965 -937
- package/src/memory/cli.js +21 -49
- package/src/memory/contract.json +28 -28
- package/src/memory/index.d.ts +49 -49
- package/src/memory/index.js +259 -259
- package/src/memory/lifecycle.js +29 -29
- package/src/memory/local-cli.js +34 -0
- package/src/memory/proposals.js +84 -84
- package/src/memory/skills-cli.js +26 -26
- package/src/memory/sync.js +89 -85
- package/src/memory/validation.js +25 -25
- package/src/onboardingAgents.js +532 -532
- package/src/promptTemplates.js +178 -178
- package/src/runtime/contracts.d.ts +47 -47
- package/src/runtime/local-cli.js +160 -160
- package/src/runtime/mcp-stdio.js +111 -111
- package/src/runtime/orchestration.js +59 -59
- package/src/runtime/run-agent.js +43 -43
- package/src/standalone/index.d.ts +45 -45
- package/src/standalone/index.js +13 -13
- package/src/standalone/init.js +12 -0
- package/src/standalone/orchestration.js +6 -6
- package/src/standalone/rag.js +113 -113
- package/src/studio/agent-ui.css +43 -43
- package/src/studio/agent-ui.js +32 -32
- package/src/studio/browser.js +331 -331
- package/src/studio/export.js +80 -80
- package/src/studio/index.html +37 -37
- package/src/studio/memory-actions.js +37 -37
- package/src/studio/memory-panel.js +200 -200
- package/src/studio/project.js +216 -197
- package/src/studio/pull-agent.js +72 -72
- package/src/studio/push.js +54 -54
- package/src/studio/python-agent.js +47 -47
- package/src/studio/python-agent.py +25 -25
- package/src/studio/server.js +143 -143
- package/src/studio/session.js +83 -83
- package/src/studio/studio.css +10 -10
- package/src/studio/sync.js +42 -42
- package/src/studio/workflow-sync.js +157 -157
package/src/studio/export.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { pythonSource } from "./python-agent.js";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { readCatalog, resolveSequence, validateLayout } from "./project.js";
|
|
5
|
-
|
|
6
|
-
const runtime = [
|
|
7
|
-
"studio/server.js", "studio/memory-actions.js", "studio/memory-panel.js", "studio/project.js", "studio/sync.js", "studio/index.html",
|
|
8
|
-
"studio/browser.js", "studio/studio.css", "studio/agent-ui.js", "studio/agent-ui.css", "app-builder/saved-app.js",
|
|
9
|
-
"memory/index.js", "memory/validation.js", "memory/proposals.js", "memory/sync.js", "memory/lifecycle.js", "memory/contract.json",
|
|
10
|
-
"runtime/local-cli.js", "runtime/run-agent.js", "studio/session.js", "studio/push.js", "studio/workflow-sync.js", "studio/pull-agent.js", "studio/python-agent.js", "studio/python-agent.py",
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
export async function exportStudioApp(app, root, directory) {
|
|
14
|
-
const layout = validateLayout(app.studio.layout);
|
|
15
|
-
if (!layout.length) throw new Error("Add components to the Studio canvas and save before exporting.");
|
|
16
|
-
const catalog = await readCatalog(root);
|
|
17
|
-
const agents = new Map();
|
|
18
|
-
const workflows = new Map();
|
|
19
|
-
const buttons = layout.filter(node => ["button", "agent-card"].includes(node.kind));
|
|
20
|
-
for (const button of buttons) {
|
|
21
|
-
if ((button.sourceId && !layout.some(node => node.id === button.sourceId && ["input", "textarea"].includes(node.kind))) ||
|
|
22
|
-
(button.outputId && !layout.some(node => node.id === button.outputId && node.kind === "output"))) {
|
|
23
|
-
throw new Error("Fix the input or output binding for " + button.label + " in Studio.");
|
|
24
|
-
}
|
|
25
|
-
let sequence;
|
|
26
|
-
try {
|
|
27
|
-
sequence = resolveSequence(catalog, button.targets);
|
|
28
|
-
if (button.kind === "agent-card" && !catalog.agents.has(button.targets[0])) {
|
|
29
|
-
throw new Error("Choose one agent for this card.");
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
throw new Error("Fix the run targets for " + button.label + ": " + error.message);
|
|
33
|
-
}
|
|
34
|
-
for (const { agentId } of sequence) agents.set(agentId, catalog.agents.get(agentId));
|
|
35
|
-
for (const target of button.targets.filter(id => id.startsWith("workflow:"))) {
|
|
36
|
-
const workflow = catalog.workflows.find(item => "workflow:" + item.id === target);
|
|
37
|
-
workflows.set(workflow.id, {
|
|
38
|
-
id: workflow.id, name: workflow.name, runnable: true,
|
|
39
|
-
steps: workflow.steps.map(({ agentId, task, input, output }) => ({ agentId, task, input, output })),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const name = typeof app.application?.name === "string" ? app.application.name : "Lyra app";
|
|
44
|
-
const files = await Promise.all(runtime.map(async file => [
|
|
45
|
-
"runtime/" + file, await readFile(new URL("../" + file, import.meta.url)),
|
|
46
|
-
]));
|
|
47
|
-
const pythonAgents = [...agents.values()].filter(agent => agent.source === "python");
|
|
48
|
-
const pythonFiles = new Map();
|
|
49
|
-
for (const agent of pythonAgents) {
|
|
50
|
-
if (pythonFiles.has(agent.file)) continue;
|
|
51
|
-
const path = await pythonSource(root, agent, false);
|
|
52
|
-
pythonFiles.set(agent.file, await readFile(path));
|
|
53
|
-
}
|
|
54
|
-
for (const [filename, source] of pythonFiles) files.push(["python-agents/" + filename, source]);
|
|
55
|
-
const pythonNotes = pythonAgents.length
|
|
56
|
-
? "\nInstall the Python SDK and any agent dependencies in your Python environment. Set LYRA_PYTHON to its interpreter if needed. The python-agents folder contains the source of the bound agents.\n"
|
|
57
|
-
: "";
|
|
58
|
-
files.push(
|
|
59
|
-
["LICENSE", await readFile(new URL("../../LICENSE", import.meta.url))],
|
|
60
|
-
["package.json", { name: "lyra-app", version: "1.0.0", private: true, type: "module", engines: { node: ">=22.13.0" }, scripts: { start: "node server.js" } }],
|
|
61
|
-
["manifest.json", { version: "3.0", application: { id: "lyra-app", name }, studio: { layout } }],
|
|
62
|
-
["catalog.json", { agents: [...agents.values()], workflows: [...workflows.values()] }],
|
|
63
|
-
[".gitignore", ".lyra/\n.env\n"],
|
|
64
|
-
["README.md", "# Run the exported Lyra app\n\nUse Node.js 22.13 or newer. Run `npm start` and open the loopback URL printed in the terminal.\n\nLocal agents require `OPENAI_API_KEY`. Cloud agents require `LYRA_API_KEY`, plus an OpenAI key configured in Cloud Models. Set credentials in the environment. The export includes system prompts for referenced local agents. The server is intended for local use.\n" + pythonNotes],
|
|
65
|
-
["server.js", 'import { readFile } from "node:fs/promises";\nimport { fileURLToPath } from "node:url";\nimport { startStudio } from "./runtime/studio/server.js";\n\nconst snapshot = JSON.parse(await readFile(new URL("./catalog.json", import.meta.url), "utf8"));\nconst catalog = { agents: new Map(snapshot.agents.map(agent => [agent.id, agent])), workflows: snapshot.workflows, teams: [] };\nconst { url } = await startStudio(fileURLToPath(new URL(".", import.meta.url)), { appCatalog: catalog });\nconsole.log("Lyra app: " + url);\n'],
|
|
66
|
-
);
|
|
67
|
-
try {
|
|
68
|
-
await mkdir(directory);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
if (error.code === "EEXIST") throw new Error("Choose a new directory. Existing files were preserved.");
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
for (const [file, contents] of files) {
|
|
74
|
-
const path = join(directory, file);
|
|
75
|
-
await mkdir(dirname(path), { recursive: true });
|
|
76
|
-
await writeFile(path, typeof contents === "string" || Buffer.isBuffer(contents)
|
|
77
|
-
? contents
|
|
78
|
-
: JSON.stringify(contents, null, 2) + "\n", { flag: "wx" });
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { pythonSource } from "./python-agent.js";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { readCatalog, resolveSequence, validateLayout } from "./project.js";
|
|
5
|
+
|
|
6
|
+
const runtime = [
|
|
7
|
+
"studio/server.js", "studio/memory-actions.js", "studio/memory-panel.js", "studio/project.js", "studio/sync.js", "studio/index.html",
|
|
8
|
+
"studio/browser.js", "studio/studio.css", "studio/agent-ui.js", "studio/agent-ui.css", "app-builder/saved-app.js",
|
|
9
|
+
"memory/index.js", "memory/validation.js", "memory/proposals.js", "memory/sync.js", "memory/lifecycle.js", "memory/contract.json",
|
|
10
|
+
"runtime/local-cli.js", "runtime/run-agent.js", "studio/session.js", "studio/push.js", "studio/workflow-sync.js", "studio/pull-agent.js", "studio/python-agent.js", "studio/python-agent.py",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export async function exportStudioApp(app, root, directory) {
|
|
14
|
+
const layout = validateLayout(app.studio.layout);
|
|
15
|
+
if (!layout.length) throw new Error("Add components to the Studio canvas and save before exporting.");
|
|
16
|
+
const catalog = await readCatalog(root);
|
|
17
|
+
const agents = new Map();
|
|
18
|
+
const workflows = new Map();
|
|
19
|
+
const buttons = layout.filter(node => ["button", "agent-card"].includes(node.kind));
|
|
20
|
+
for (const button of buttons) {
|
|
21
|
+
if ((button.sourceId && !layout.some(node => node.id === button.sourceId && ["input", "textarea"].includes(node.kind))) ||
|
|
22
|
+
(button.outputId && !layout.some(node => node.id === button.outputId && node.kind === "output"))) {
|
|
23
|
+
throw new Error("Fix the input or output binding for " + button.label + " in Studio.");
|
|
24
|
+
}
|
|
25
|
+
let sequence;
|
|
26
|
+
try {
|
|
27
|
+
sequence = resolveSequence(catalog, button.targets);
|
|
28
|
+
if (button.kind === "agent-card" && !catalog.agents.has(button.targets[0])) {
|
|
29
|
+
throw new Error("Choose one agent for this card.");
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new Error("Fix the run targets for " + button.label + ": " + error.message);
|
|
33
|
+
}
|
|
34
|
+
for (const { agentId } of sequence) agents.set(agentId, catalog.agents.get(agentId));
|
|
35
|
+
for (const target of button.targets.filter(id => id.startsWith("workflow:"))) {
|
|
36
|
+
const workflow = catalog.workflows.find(item => "workflow:" + item.id === target);
|
|
37
|
+
workflows.set(workflow.id, {
|
|
38
|
+
id: workflow.id, name: workflow.name, runnable: true,
|
|
39
|
+
steps: workflow.steps.map(({ agentId, task, input, output }) => ({ agentId, task, input, output })),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const name = typeof app.application?.name === "string" ? app.application.name : "Lyra app";
|
|
44
|
+
const files = await Promise.all(runtime.map(async file => [
|
|
45
|
+
"runtime/" + file, await readFile(new URL("../" + file, import.meta.url)),
|
|
46
|
+
]));
|
|
47
|
+
const pythonAgents = [...agents.values()].filter(agent => agent.source === "python");
|
|
48
|
+
const pythonFiles = new Map();
|
|
49
|
+
for (const agent of pythonAgents) {
|
|
50
|
+
if (pythonFiles.has(agent.file)) continue;
|
|
51
|
+
const path = await pythonSource(root, agent, false);
|
|
52
|
+
pythonFiles.set(agent.file, await readFile(path));
|
|
53
|
+
}
|
|
54
|
+
for (const [filename, source] of pythonFiles) files.push(["python-agents/" + filename, source]);
|
|
55
|
+
const pythonNotes = pythonAgents.length
|
|
56
|
+
? "\nInstall the Python SDK and any agent dependencies in your Python environment. Set LYRA_PYTHON to its interpreter if needed. The python-agents folder contains the source of the bound agents.\n"
|
|
57
|
+
: "";
|
|
58
|
+
files.push(
|
|
59
|
+
["LICENSE", await readFile(new URL("../../LICENSE", import.meta.url))],
|
|
60
|
+
["package.json", { name: "lyra-app", version: "1.0.0", private: true, type: "module", engines: { node: ">=22.13.0" }, scripts: { start: "node server.js" } }],
|
|
61
|
+
["manifest.json", { version: "3.0", application: { id: "lyra-app", name }, studio: { layout } }],
|
|
62
|
+
["catalog.json", { agents: [...agents.values()], workflows: [...workflows.values()] }],
|
|
63
|
+
[".gitignore", ".lyra/\n.env\n"],
|
|
64
|
+
["README.md", "# Run the exported Lyra app\n\nUse Node.js 22.13 or newer. Run `npm start` and open the loopback URL printed in the terminal.\n\nLocal agents require `OPENAI_API_KEY`. Cloud agents require `LYRA_API_KEY`, plus an OpenAI key configured in Cloud Models. Set credentials in the environment. The export includes system prompts for referenced local agents. The server is intended for local use.\n" + pythonNotes],
|
|
65
|
+
["server.js", 'import { readFile } from "node:fs/promises";\nimport { fileURLToPath } from "node:url";\nimport { startStudio } from "./runtime/studio/server.js";\n\nconst snapshot = JSON.parse(await readFile(new URL("./catalog.json", import.meta.url), "utf8"));\nconst catalog = { agents: new Map(snapshot.agents.map(agent => [agent.id, agent])), workflows: snapshot.workflows, teams: [] };\nconst { url } = await startStudio(fileURLToPath(new URL(".", import.meta.url)), { appCatalog: catalog });\nconsole.log("Lyra app: " + url);\n'],
|
|
66
|
+
);
|
|
67
|
+
try {
|
|
68
|
+
await mkdir(directory);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.code === "EEXIST") throw new Error("Choose a new directory. Existing files were preserved.");
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
for (const [file, contents] of files) {
|
|
74
|
+
const path = join(directory, file);
|
|
75
|
+
await mkdir(dirname(path), { recursive: true });
|
|
76
|
+
await writeFile(path, typeof contents === "string" || Buffer.isBuffer(contents)
|
|
77
|
+
? contents
|
|
78
|
+
: JSON.stringify(contents, null, 2) + "\n", { flag: "wx" });
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/studio/index.html
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
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
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<header><strong>AgentLyra Studio</strong><span id="project-name"></span><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>
|
|
9
|
-
<p role="status" id="status"></p>
|
|
10
|
-
<main>
|
|
11
|
-
<aside><h2>Components</h2><div id="palette"></div><h2>Agents</h2><div id="agents"></div><h2>Workflows</h2><div id="workflows"></div><h2>Teams</h2><div id="teams"></div><h2>Skills</h2><div id="skills"></div></aside>
|
|
12
|
-
<section><h1>App canvas</h1><p>Drop a component here or select it from the palette. Use the inspector to bind an Agent card or Run button to your inputs and outputs.</p><div id="canvas"></div></section>
|
|
13
|
-
<aside><h2>Inspector</h2><div id="inspector"></div></aside>
|
|
14
|
-
</main>
|
|
15
|
-
<dialog id="memory-panel" aria-labelledby="memory-title">
|
|
16
|
-
<header><h2 id="memory-title">Memory</h2><button id="close-memory" type="button">Close</button></header>
|
|
17
|
-
<p>Project memories stay local until you choose to upload a verified record.</p>
|
|
18
|
-
<p id="memory-status" role="status"></p>
|
|
19
|
-
<p id="memory-summary"></p>
|
|
20
|
-
<form id="memory-search"><label for="memory-query">Search project memories</label><input id="memory-query" maxlength="240"><button type="submit">Search</button></form>
|
|
21
|
-
<details><summary>Record a candidate</summary><form id="memory-create">
|
|
22
|
-
<label>Type<select name="type"><option>corrective</option><option>episodic</option><option>semantic</option><option>procedural</option></select></label>
|
|
23
|
-
<label>Title<input name="title" maxlength="160" required></label>
|
|
24
|
-
<label>Learning<textarea name="learning" maxlength="4000" required></textarea></label>
|
|
25
|
-
<label>Evidence IDs, separated by commas<input name="evidence" maxlength="2048"></label>
|
|
26
|
-
<button type="submit">Record candidate</button>
|
|
27
|
-
</form></details>
|
|
28
|
-
<details><summary>Pull a Cloud memory</summary><form id="memory-pull">
|
|
29
|
-
<label>Cloud memory ID<input name="id" maxlength="36" required></label>
|
|
30
|
-
<button type="submit">Pull from Cloud</button>
|
|
31
|
-
</form></details>
|
|
32
|
-
<div id="memory-list" aria-label="Project memories"></div>
|
|
33
|
-
<section id="memory-detail" aria-label="Selected memory"></section>
|
|
34
|
-
<details><summary>Skill proposals</summary><section id="memory-proposals" aria-label="Skill proposals"></section></details>
|
|
35
|
-
</dialog>
|
|
36
|
-
<dialog id="drawer" aria-labelledby="run-title"><form id="runner"><div id="run-header"></div><label for="model">Local model</label><select id="model"></select><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>
|
|
37
|
-
</body></html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
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
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<header><strong>AgentLyra Studio</strong><span id="project-name"></span><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>
|
|
9
|
+
<p role="status" id="status"></p>
|
|
10
|
+
<main>
|
|
11
|
+
<aside><h2>Components</h2><div id="palette"></div><h2>Agents</h2><div id="agents"></div><h2>Workflows</h2><div id="workflows"></div><h2>Teams</h2><div id="teams"></div><h2>Skills</h2><div id="skills"></div></aside>
|
|
12
|
+
<section><h1>App canvas</h1><p>Drop a component here or select it from the palette. Use the inspector to bind an Agent card or Run button to your inputs and outputs.</p><div id="canvas"></div></section>
|
|
13
|
+
<aside><h2>Inspector</h2><div id="inspector"></div></aside>
|
|
14
|
+
</main>
|
|
15
|
+
<dialog id="memory-panel" aria-labelledby="memory-title">
|
|
16
|
+
<header><h2 id="memory-title">Memory</h2><button id="close-memory" type="button">Close</button></header>
|
|
17
|
+
<p>Project memories stay local until you choose to upload a verified record.</p>
|
|
18
|
+
<p id="memory-status" role="status"></p>
|
|
19
|
+
<p id="memory-summary"></p>
|
|
20
|
+
<form id="memory-search"><label for="memory-query">Search project memories</label><input id="memory-query" maxlength="240"><button type="submit">Search</button></form>
|
|
21
|
+
<details><summary>Record a candidate</summary><form id="memory-create">
|
|
22
|
+
<label>Type<select name="type"><option>corrective</option><option>episodic</option><option>semantic</option><option>procedural</option></select></label>
|
|
23
|
+
<label>Title<input name="title" maxlength="160" required></label>
|
|
24
|
+
<label>Learning<textarea name="learning" maxlength="4000" required></textarea></label>
|
|
25
|
+
<label>Evidence IDs, separated by commas<input name="evidence" maxlength="2048"></label>
|
|
26
|
+
<button type="submit">Record candidate</button>
|
|
27
|
+
</form></details>
|
|
28
|
+
<details><summary>Pull a Cloud memory</summary><form id="memory-pull">
|
|
29
|
+
<label>Cloud memory ID<input name="id" maxlength="36" required></label>
|
|
30
|
+
<button type="submit">Pull from Cloud</button>
|
|
31
|
+
</form></details>
|
|
32
|
+
<div id="memory-list" aria-label="Project memories"></div>
|
|
33
|
+
<section id="memory-detail" aria-label="Selected memory"></section>
|
|
34
|
+
<details><summary>Skill proposals</summary><section id="memory-proposals" aria-label="Skill proposals"></section></details>
|
|
35
|
+
</dialog>
|
|
36
|
+
<dialog id="drawer" aria-labelledby="run-title"><form id="runner"><div id="run-header"></div><label for="model">Local model</label><select id="model"></select><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>
|
|
37
|
+
</body></html>
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { openMemoryStore } from "../memory/index.js";
|
|
2
|
-
import { syncMemory } from "../memory/sync.js";
|
|
3
|
-
|
|
4
|
-
export function memoryActions(root) {
|
|
5
|
-
return new Map([
|
|
6
|
-
["/api/memory/list", ({ query = "" }) => useStore(root, store => ({
|
|
7
|
-
records: query.trim() ? store.search(query, 50) : store.list(50), stats: store.stats(),
|
|
8
|
-
}))],
|
|
9
|
-
["/api/memory/record", body => useStore(root, store => store.record({
|
|
10
|
-
...body, evidence: typeof body.evidence === "string" ? body.evidence.split(",").map(value => value.trim()).filter(Boolean) : body.evidence,
|
|
11
|
-
}))],
|
|
12
|
-
["/api/memory/archive", ({ id }) => useStore(root, store => {
|
|
13
|
-
const record = store.archive(id);
|
|
14
|
-
if (!record) throw new Error("Memory record was not found.");
|
|
15
|
-
return record;
|
|
16
|
-
})],
|
|
17
|
-
["/api/memory/preview", ({ id }) => syncMemory(root, "preview", id)],
|
|
18
|
-
["/api/memory/push", ({ id, fingerprint }) => {
|
|
19
|
-
if (typeof fingerprint !== "string" || !/^[a-f0-9]{64}$/.test(fingerprint)) throw new Error("Preview the outbound memory before uploading.");
|
|
20
|
-
return syncMemory(root, "push", id, { confirmed: true, expectedPreview: fingerprint });
|
|
21
|
-
}],
|
|
22
|
-
["/api/memory/pull", ({ id }) => syncMemory(root, "pull", id)],
|
|
23
|
-
["/api/memory/compare", ({ id }) => syncMemory(root, "compare", id)],
|
|
24
|
-
["/api/memory/resolve", ({ id, choice, fingerprint }) =>
|
|
25
|
-
syncMemory(root, "resolve", id, { choice, expectedConflict: fingerprint })],
|
|
26
|
-
["/api/memory/verify", ({ id, evidence }) => useStore(root, store => store.verify(id, evidence))],
|
|
27
|
-
["/api/memory/proposals", () => useStore(root, store => store.proposals())],
|
|
28
|
-
["/api/memory/proposal-decision", ({ id, decision, evidence }) =>
|
|
29
|
-
useStore(root, store => store.decideProposal(id, decision, evidence))],
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function useStore(root, action) {
|
|
34
|
-
const store = await openMemoryStore(root);
|
|
35
|
-
try { return await action(store); }
|
|
36
|
-
finally { store.close(); }
|
|
37
|
-
}
|
|
1
|
+
import { openMemoryStore } from "../memory/index.js";
|
|
2
|
+
import { syncMemory } from "../memory/sync.js";
|
|
3
|
+
|
|
4
|
+
export function memoryActions(root) {
|
|
5
|
+
return new Map([
|
|
6
|
+
["/api/memory/list", ({ query = "" }) => useStore(root, store => ({
|
|
7
|
+
records: query.trim() ? store.search(query, 50) : store.list(50), stats: store.stats(),
|
|
8
|
+
}))],
|
|
9
|
+
["/api/memory/record", body => useStore(root, store => store.record({
|
|
10
|
+
...body, evidence: typeof body.evidence === "string" ? body.evidence.split(",").map(value => value.trim()).filter(Boolean) : body.evidence,
|
|
11
|
+
}))],
|
|
12
|
+
["/api/memory/archive", ({ id }) => useStore(root, store => {
|
|
13
|
+
const record = store.archive(id);
|
|
14
|
+
if (!record) throw new Error("Memory record was not found.");
|
|
15
|
+
return record;
|
|
16
|
+
})],
|
|
17
|
+
["/api/memory/preview", ({ id }) => syncMemory(root, "preview", id)],
|
|
18
|
+
["/api/memory/push", ({ id, fingerprint }) => {
|
|
19
|
+
if (typeof fingerprint !== "string" || !/^[a-f0-9]{64}$/.test(fingerprint)) throw new Error("Preview the outbound memory before uploading.");
|
|
20
|
+
return syncMemory(root, "push", id, { confirmed: true, expectedPreview: fingerprint });
|
|
21
|
+
}],
|
|
22
|
+
["/api/memory/pull", ({ id }) => syncMemory(root, "pull", id)],
|
|
23
|
+
["/api/memory/compare", ({ id }) => syncMemory(root, "compare", id)],
|
|
24
|
+
["/api/memory/resolve", ({ id, choice, fingerprint }) =>
|
|
25
|
+
syncMemory(root, "resolve", id, { choice, expectedConflict: fingerprint })],
|
|
26
|
+
["/api/memory/verify", ({ id, evidence }) => useStore(root, store => store.verify(id, evidence))],
|
|
27
|
+
["/api/memory/proposals", () => useStore(root, store => store.proposals())],
|
|
28
|
+
["/api/memory/proposal-decision", ({ id, decision, evidence }) =>
|
|
29
|
+
useStore(root, store => store.decideProposal(id, decision, evidence))],
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function useStore(root, action) {
|
|
34
|
+
const store = await openMemoryStore(root);
|
|
35
|
+
try { return await action(store); }
|
|
36
|
+
finally { store.close(); }
|
|
37
|
+
}
|