agent-lyra 0.7.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +301 -276
- package/bin/agent-lyra.js +51 -51
- package/bin/lyra-oss-preview.js +16 -16
- package/package.json +60 -60
- package/src/app-builder/export.js +109 -109
- package/src/app-builder/gateway.js +62 -62
- package/src/app-builder/init.js +115 -72
- package/src/app-builder/manifest-contract.js +46 -46
- package/src/app-builder/native-adapter.js +29 -29
- package/src/app-builder/preview.js +35 -31
- package/src/app-builder/publish.js +14 -14
- package/src/app-builder/saved-app.js +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 +31 -21
- package/src/app-builder/value-schema.js +37 -37
- package/src/catalog.js +147 -147
- package/src/coding/catalog.js +56 -56
- package/src/coding/cloud-catalog.js +64 -64
- package/src/coding/detect-stack.mjs +110 -110
- package/src/coding/export.js +133 -133
- package/src/coding/setup.js +175 -175
- package/src/coding/skills/lyra-android/SKILL.md +37 -37
- package/src/coding/skills/lyra-angular/SKILL.md +37 -37
- package/src/coding/skills/lyra-cucumber/SKILL.md +37 -37
- package/src/coding/skills/lyra-dbt/SKILL.md +37 -37
- package/src/coding/skills/lyra-django/SKILL.md +37 -37
- package/src/coding/skills/lyra-docker/SKILL.md +37 -37
- package/src/coding/skills/lyra-dotnet/SKILL.md +37 -37
- package/src/coding/skills/lyra-express/SKILL.md +37 -37
- package/src/coding/skills/lyra-fastapi/SKILL.md +37 -37
- package/src/coding/skills/lyra-flutter/SKILL.md +37 -37
- package/src/coding/skills/lyra-github-actions/SKILL.md +37 -37
- package/src/coding/skills/lyra-gitlab-ci/SKILL.md +37 -37
- package/src/coding/skills/lyra-go/SKILL.md +37 -37
- package/src/coding/skills/lyra-ios/SKILL.md +37 -37
- package/src/coding/skills/lyra-kubernetes/SKILL.md +37 -37
- package/src/coding/skills/lyra-mongodb/SKILL.md +37 -37
- package/src/coding/skills/lyra-mysql/SKILL.md +37 -37
- package/src/coding/skills/lyra-nextjs/SKILL.md +37 -37
- package/src/coding/skills/lyra-node/SKILL.md +37 -37
- package/src/coding/skills/lyra-playwright/SKILL.md +37 -37
- package/src/coding/skills/lyra-postgresql/SKILL.md +37 -37
- package/src/coding/skills/lyra-python/SKILL.md +37 -37
- package/src/coding/skills/lyra-react/SKILL.md +37 -37
- package/src/coding/skills/lyra-react-native/SKILL.md +37 -37
- package/src/coding/skills/lyra-redis/SKILL.md +37 -37
- package/src/coding/skills/lyra-rust/SKILL.md +37 -37
- package/src/coding/skills/lyra-spark/SKILL.md +37 -37
- package/src/coding/skills/lyra-spring-boot/SKILL.md +37 -37
- package/src/coding/skills/lyra-svelte/SKILL.md +37 -37
- package/src/coding/skills/lyra-terraform/SKILL.md +37 -37
- package/src/coding/skills/lyra-typescript/SKILL.md +37 -37
- package/src/coding/skills/lyra-vue/SKILL.md +37 -37
- package/src/framework/agent.js +181 -173
- package/src/framework/mda.js +65 -0
- package/src/framework/run.py +111 -111
- package/src/gated/hostedAgents.js +56 -56
- package/src/gated/index.d.ts +25 -25
- package/src/gated/index.js +5 -5
- package/src/index.d.ts +2 -2
- package/src/index.js +2 -2
- package/src/init.js +960 -960
- package/src/intelligence/graphsnip-provider.d.ts +5 -5
- package/src/intelligence/graphsnip-provider.js +57 -57
- package/src/intelligence/lifecycle.js +25 -0
- package/src/memory/LICENSE +21 -21
- package/src/memory/README.md +5 -5
- package/src/memory/UPSTREAM.json +24 -14
- package/src/memory/bridge-cli.js +16 -16
- package/src/memory/bridge.js +18 -18
- package/src/memory/cli.js +21 -21
- package/src/memory/cloud-sync-actions.js +61 -61
- package/src/memory/contract.json +45 -45
- package/src/memory/index.d.ts +50 -49
- package/src/memory/index.js +7 -7
- package/src/memory/lifecycle.js +29 -29
- package/src/memory/local-cli.js +34 -34
- package/src/memory/local-store.js +209 -209
- package/src/memory/package.json +33 -33
- package/src/memory/proposals.js +90 -90
- package/src/memory/skills-cli.js +26 -26
- package/src/memory/standalone.d.ts +50 -50
- package/src/memory/standalone.js +1 -1
- package/src/memory/sync.js +89 -89
- package/src/memory/validation.js +25 -25
- package/src/onboardingAgents.js +532 -532
- package/src/promptTemplates.js +178 -178
- package/src/resource-files.js +18 -18
- package/src/runtime/contracts.d.ts +47 -47
- package/src/runtime/local-cli.js +161 -160
- package/src/runtime/mcp-stdio.js +111 -111
- package/src/runtime/orchestration.js +59 -59
- package/src/runtime/run-agent.js +54 -53
- package/src/standalone/index.d.ts +45 -45
- package/src/standalone/index.js +13 -13
- package/src/standalone/init.js +12 -12
- package/src/standalone/orchestration.js +6 -6
- package/src/standalone/rag.js +113 -113
- package/src/studio/agent-ui.css +43 -43
- package/src/studio/agent-ui.js +32 -32
- package/src/studio/browser.js +542 -345
- package/src/studio/export.js +83 -85
- package/src/studio/index.html +74 -37
- package/src/studio/memory-actions.js +37 -37
- package/src/studio/memory-panel.js +200 -200
- package/src/studio/project.js +308 -240
- package/src/studio/pull-agent.js +72 -72
- package/src/studio/push.js +54 -54
- package/src/studio/python-agent.js +47 -47
- package/src/studio/python-agent.py +25 -25
- package/src/studio/server.js +164 -150
- package/src/studio/session.js +83 -83
- package/src/studio/studio.css +257 -10
- package/src/studio/sync.js +42 -42
- package/src/studio/workflow-editor.js +240 -0
- package/src/studio/workflow-sync.js +229 -157
package/src/app-builder/init.js
CHANGED
|
@@ -1,72 +1,115 @@
|
|
|
1
|
-
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { createInterface } from "node:readline/promises";
|
|
4
|
-
import { readFrameworkAgent } from "../framework/agent.js";
|
|
5
|
-
import { createSavedAgentClient, SAVED_VERSION, validateSavedApp } from "./saved-app.js";
|
|
6
|
-
|
|
7
|
-
export async function runAppInit(args, output = process.stdout, {
|
|
8
|
-
openTerminal = () => createInterface({ input: process.stdin, output }),
|
|
9
|
-
listAgents = async () => {
|
|
10
|
-
if (!process.stdin.isTTY) throw new Error("Run app init from an interactive terminal to choose your agents.");
|
|
11
|
-
return createSavedAgentClient().list();
|
|
12
|
-
},
|
|
13
|
-
} = {}) {
|
|
14
|
-
if (args.length === 1 && args[0] === "--help") {
|
|
15
|
-
output.write("Usage: agent-lyra app init [manifest.json]\
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (args[0] === "--local") {
|
|
19
|
-
if (args.length !== 2) throw new Error("Usage: agent-lyra app init --local <registration-id>");
|
|
20
|
-
const agent = await readFrameworkAgent(process.cwd(), args[1]);
|
|
21
|
-
if (!agent) throw new Error("Register the framework agent in this project first.");
|
|
22
|
-
const layout = [
|
|
23
|
-
{ id: "prompt", kind: "textarea", label: "Input" },
|
|
24
|
-
{ id: "run", kind: "agent-card", label: agent.name, targets: ["framework:" + agent.id], sourceId: "prompt", outputId: "output" },
|
|
25
|
-
{ id: "output", kind: "output", label: "Result" },
|
|
26
|
-
];
|
|
27
|
-
const target = resolve("manifest.json");
|
|
28
|
-
await writeFile(target, JSON.stringify({
|
|
29
|
-
version: "3.0", application: { id: "lyra-app", name: agent.name }, studio: { layout },
|
|
30
|
-
}, null, 2) + "\n", { flag: "wx" }).catch(error => {
|
|
31
|
-
if (error.code === "EEXIST") throw new Error("manifest.json already exists. Bind the agent in Studio to keep your layout.");
|
|
32
|
-
throw error;
|
|
33
|
-
});
|
|
34
|
-
output.write("Created " + target + "\n");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (args
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
1
|
+
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, resolve } from "node:path";
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import { readFrameworkAgent } from "../framework/agent.js";
|
|
5
|
+
import { createSavedAgentClient, SAVED_VERSION, validateSavedApp } from "./saved-app.js";
|
|
6
|
+
|
|
7
|
+
export async function runAppInit(args, output = process.stdout, {
|
|
8
|
+
openTerminal = () => createInterface({ input: process.stdin, output }),
|
|
9
|
+
listAgents = async () => {
|
|
10
|
+
if (!process.stdin.isTTY) throw new Error("Run app init from an interactive terminal to choose your agents.");
|
|
11
|
+
return createSavedAgentClient().list();
|
|
12
|
+
},
|
|
13
|
+
} = {}) {
|
|
14
|
+
if (args.length === 1 && args[0] === "--help") {
|
|
15
|
+
output.write("Usage: agent-lyra app init [manifest.json] [--name \"My app\"] [--template agent]\nCreates a visual app. Run agent-lyra studio to edit it.\nUse --local <registration-id> for a framework agent or --saved-agents for the guided Cloud chat.\n");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (args[0] === "--local") {
|
|
19
|
+
if (args.length !== 2) throw new Error("Usage: agent-lyra app init --local <registration-id>");
|
|
20
|
+
const agent = await readFrameworkAgent(process.cwd(), args[1]);
|
|
21
|
+
if (!agent) throw new Error("Register the framework agent in this project first.");
|
|
22
|
+
const layout = [
|
|
23
|
+
{ id: "prompt", kind: "textarea", label: "Input" },
|
|
24
|
+
{ id: "run", kind: "agent-card", label: agent.name, targets: ["framework:" + agent.id], sourceId: "prompt", outputId: "output" },
|
|
25
|
+
{ id: "output", kind: "output", label: "Result" },
|
|
26
|
+
];
|
|
27
|
+
const target = resolve("manifest.json");
|
|
28
|
+
await writeFile(target, JSON.stringify({
|
|
29
|
+
version: "3.0", application: { id: "lyra-app", name: agent.name }, studio: { layout },
|
|
30
|
+
}, null, 2) + "\n", { flag: "wx" }).catch(error => {
|
|
31
|
+
if (error.code === "EEXIST") throw new Error("manifest.json already exists. Bind the agent in Studio to keep your layout.");
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
output.write("Created " + target + "\n");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (args[0] !== "--saved-agents") return initVisualApp(args, output);
|
|
38
|
+
args = args.slice(1);
|
|
39
|
+
if (args.length > 1 || args[0]?.startsWith("-")) {
|
|
40
|
+
throw new Error("Provide at most one manifest path. See agent-lyra app init --help.");
|
|
41
|
+
}
|
|
42
|
+
const target = resolve(args[0] ?? "manifest.json");
|
|
43
|
+
try {
|
|
44
|
+
await access(target);
|
|
45
|
+
throw new Error("Manifest already exists at " + target + ". Choose a new path.");
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error.code !== "ENOENT") throw error;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const agents = await listAgents();
|
|
51
|
+
if (agents.length < 2) throw new Error("Create at least two enabled agents in AgentLyra Console first.");
|
|
52
|
+
for (const [index, agent] of agents.entries()) {
|
|
53
|
+
const name = String(agent.name).replace(/[\x00-\x1f\x7f]/g, " ");
|
|
54
|
+
output.write((index + 1) + ". " + name + "\n");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const terminal = openTerminal();
|
|
58
|
+
try {
|
|
59
|
+
const name = (await terminal.question("Application name: ")).trim();
|
|
60
|
+
const first = agents[Number(await terminal.question("First agent number: ")) - 1];
|
|
61
|
+
const second = agents[Number(await terminal.question("Second agent number: ")) - 1];
|
|
62
|
+
const id = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
63
|
+
const manifest = validateSavedApp({
|
|
64
|
+
version: SAVED_VERSION,
|
|
65
|
+
application: { id: id && /^[a-z]/.test(id) ? id.slice(0, 80) : "lyra-app", name },
|
|
66
|
+
workflow: { steps: [{ agentId: first?.id }, { agentId: second?.id }] },
|
|
67
|
+
});
|
|
68
|
+
await mkdir(dirname(target), { recursive: true });
|
|
69
|
+
await writeFile(target, JSON.stringify(manifest, null, 2) + "\n", { flag: "wx" });
|
|
70
|
+
output.write("Created " + target + "\n");
|
|
71
|
+
} finally {
|
|
72
|
+
terminal.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function initVisualApp(args, output) {
|
|
77
|
+
const options = { name: "Lyra app", template: "blank" };
|
|
78
|
+
const seen = new Set();
|
|
79
|
+
let path;
|
|
80
|
+
for (let index = 0; index < args.length; index++) {
|
|
81
|
+
const value = args[index];
|
|
82
|
+
if (!value.startsWith("-") && path === undefined) {
|
|
83
|
+
path = value;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const key = value.slice(2);
|
|
87
|
+
const next = args[index + 1];
|
|
88
|
+
if (!value.startsWith("--") || !Object.hasOwn(options, key) || seen.has(key) || !next || next.startsWith("--")) {
|
|
89
|
+
throw new Error("See agent-lyra app init --help.");
|
|
90
|
+
}
|
|
91
|
+
seen.add(key);
|
|
92
|
+
options[key] = next;
|
|
93
|
+
index++;
|
|
94
|
+
}
|
|
95
|
+
const name = options.name.trim();
|
|
96
|
+
if (!name || name.length > 120 || /[\x00-\x1f\x7f]/.test(name)) throw new Error("Enter an application name of up to 120 characters.");
|
|
97
|
+
if (!["blank", "agent"].includes(options.template)) throw new Error("Choose the blank or agent template.");
|
|
98
|
+
const target = resolve(path ?? "manifest.json");
|
|
99
|
+
if (basename(target) !== "manifest.json") {
|
|
100
|
+
throw new Error("Visual apps use manifest.json as the project manifest.");
|
|
101
|
+
}
|
|
102
|
+
const layout = options.template === "agent" ? [
|
|
103
|
+
{ id: "prompt", kind: "textarea", label: "Input", span: 6 },
|
|
104
|
+
{ id: "output", kind: "output", label: "Result", span: 6 },
|
|
105
|
+
{ id: "run", kind: "button", label: "Run agent", targets: [], sourceId: "prompt", outputId: "output" },
|
|
106
|
+
] : [];
|
|
107
|
+
await mkdir(dirname(target), { recursive: true });
|
|
108
|
+
await writeFile(target, JSON.stringify({
|
|
109
|
+
version: "3.0", application: { id: "lyra-app", name }, studio: { layout },
|
|
110
|
+
}, null, 2) + "\n", { flag: "wx" }).catch(error => {
|
|
111
|
+
if (error.code === "EEXIST") throw new Error("Manifest already exists at " + target + ". Open Studio in that folder to edit it.");
|
|
112
|
+
throw error;
|
|
113
|
+
});
|
|
114
|
+
output.write("Created " + target + "\nRun agent-lyra studio from the manifest folder to edit the app.\n");
|
|
115
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { assertValueSchema } from "./value-schema.js";
|
|
2
|
-
|
|
3
|
-
const modes = new Set(["in-process", "local-process", "remote"]);
|
|
4
|
-
const identifier = /^[a-z][a-z0-9-]*$/;
|
|
5
|
-
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
-
const isIdentifier = (value) => typeof value === "string" && identifier.test(value);
|
|
7
|
-
|
|
8
|
-
export function validateAppManifest(manifest) {
|
|
9
|
-
if (!isRecord(manifest) || manifest.version !== "1.0") {
|
|
10
|
-
throw new Error('Application manifest requires version "1.0".');
|
|
11
|
-
}
|
|
12
|
-
const { application, capabilities, actions } = manifest;
|
|
13
|
-
if (!isRecord(application) || !isIdentifier(application.id) ||
|
|
14
|
-
typeof application.name !== "string" || !application.name.trim()) {
|
|
15
|
-
throw new Error("Application requires a valid id and a name.");
|
|
16
|
-
}
|
|
17
|
-
if (!Array.isArray(capabilities) || !Array.isArray(actions)) {
|
|
18
|
-
throw new Error("Capabilities and actions must be arrays.");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const capabilityIds = new Set();
|
|
22
|
-
for (const capability of capabilities) {
|
|
23
|
-
if (!isRecord(capability) || !isIdentifier(capability.id) || !isIdentifier(capability.adapterId) ||
|
|
24
|
-
!modes.has(capability.executionMode)) {
|
|
25
|
-
throw new Error("Each capability requires an id, adapterId, and supported executionMode.");
|
|
26
|
-
}
|
|
27
|
-
if (capabilityIds.has(capability.id)) throw new Error(`Duplicate capability: ${capability.id}.`);
|
|
28
|
-
for (const key of ["inputSchema", "outputSchema"]) {
|
|
29
|
-
if (Object.hasOwn(capability, key)) assertValueSchema(capability[key], `${capability.id} ${key}`);
|
|
30
|
-
}
|
|
31
|
-
capabilityIds.add(capability.id);
|
|
32
|
-
}
|
|
33
|
-
const actionIds = new Set();
|
|
34
|
-
for (const action of actions) {
|
|
35
|
-
if (!isRecord(action) || !isIdentifier(action.id) || !isIdentifier(action.capabilityId)) {
|
|
36
|
-
throw new Error("Each action requires an id and capabilityId.");
|
|
37
|
-
}
|
|
38
|
-
if (actionIds.has(action.id)) throw new Error(`Duplicate action: ${action.id}.`);
|
|
39
|
-
if (!capabilityIds.has(action.capabilityId)) {
|
|
40
|
-
throw new Error(`Action ${action.id} refers to unknown capability ${action.capabilityId}.`);
|
|
41
|
-
}
|
|
42
|
-
actionIds.add(action.id);
|
|
43
|
-
}
|
|
44
|
-
return { id: application.id, capabilityCount: capabilityIds.size, actionCount: actionIds.size };
|
|
45
|
-
}
|
|
46
|
-
|
|
1
|
+
import { assertValueSchema } from "./value-schema.js";
|
|
2
|
+
|
|
3
|
+
const modes = new Set(["in-process", "local-process", "remote"]);
|
|
4
|
+
const identifier = /^[a-z][a-z0-9-]*$/;
|
|
5
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
const isIdentifier = (value) => typeof value === "string" && identifier.test(value);
|
|
7
|
+
|
|
8
|
+
export function validateAppManifest(manifest) {
|
|
9
|
+
if (!isRecord(manifest) || manifest.version !== "1.0") {
|
|
10
|
+
throw new Error('Application manifest requires version "1.0".');
|
|
11
|
+
}
|
|
12
|
+
const { application, capabilities, actions } = manifest;
|
|
13
|
+
if (!isRecord(application) || !isIdentifier(application.id) ||
|
|
14
|
+
typeof application.name !== "string" || !application.name.trim()) {
|
|
15
|
+
throw new Error("Application requires a valid id and a name.");
|
|
16
|
+
}
|
|
17
|
+
if (!Array.isArray(capabilities) || !Array.isArray(actions)) {
|
|
18
|
+
throw new Error("Capabilities and actions must be arrays.");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const capabilityIds = new Set();
|
|
22
|
+
for (const capability of capabilities) {
|
|
23
|
+
if (!isRecord(capability) || !isIdentifier(capability.id) || !isIdentifier(capability.adapterId) ||
|
|
24
|
+
!modes.has(capability.executionMode)) {
|
|
25
|
+
throw new Error("Each capability requires an id, adapterId, and supported executionMode.");
|
|
26
|
+
}
|
|
27
|
+
if (capabilityIds.has(capability.id)) throw new Error(`Duplicate capability: ${capability.id}.`);
|
|
28
|
+
for (const key of ["inputSchema", "outputSchema"]) {
|
|
29
|
+
if (Object.hasOwn(capability, key)) assertValueSchema(capability[key], `${capability.id} ${key}`);
|
|
30
|
+
}
|
|
31
|
+
capabilityIds.add(capability.id);
|
|
32
|
+
}
|
|
33
|
+
const actionIds = new Set();
|
|
34
|
+
for (const action of actions) {
|
|
35
|
+
if (!isRecord(action) || !isIdentifier(action.id) || !isIdentifier(action.capabilityId)) {
|
|
36
|
+
throw new Error("Each action requires an id and capabilityId.");
|
|
37
|
+
}
|
|
38
|
+
if (actionIds.has(action.id)) throw new Error(`Duplicate action: ${action.id}.`);
|
|
39
|
+
if (!capabilityIds.has(action.capabilityId)) {
|
|
40
|
+
throw new Error(`Action ${action.id} refers to unknown capability ${action.capabilityId}.`);
|
|
41
|
+
}
|
|
42
|
+
actionIds.add(action.id);
|
|
43
|
+
}
|
|
44
|
+
return { id: application.id, capabilityCount: capabilityIds.size, actionCount: actionIds.size };
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { runAgent } from "../runtime/run-agent.js";
|
|
2
|
-
import { capabilityContractVersion } from "./gateway.js";
|
|
3
|
-
|
|
4
|
-
export function createNativeAdapter({ agents, provider, store }) {
|
|
5
|
-
const configured = new Map(agents);
|
|
6
|
-
return {
|
|
7
|
-
id: "native",
|
|
8
|
-
contractVersion: capabilityContractVersion,
|
|
9
|
-
async invoke({ capabilityId, input }) {
|
|
10
|
-
const agent = configured.get(capabilityId);
|
|
11
|
-
if (!agent || typeof input !== "string" || !input.trim()) return { status: "failed" };
|
|
12
|
-
const event = await runAgent({
|
|
13
|
-
agentId: capabilityId,
|
|
14
|
-
request: {
|
|
15
|
-
model: agent.model,
|
|
16
|
-
messages: [
|
|
17
|
-
...(agent.system ? [{ role: "system", content: agent.system }] : []),
|
|
18
|
-
{ role: "user", content: input },
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
provider,
|
|
22
|
-
store,
|
|
23
|
-
});
|
|
24
|
-
if (event.type === "run.failed") return { status: "failed", nativeExecutionId: event.run_id };
|
|
25
|
-
const { text, usage } = event.data.result;
|
|
26
|
-
return { status: "completed", nativeExecutionId: event.run_id, output: text, ...(usage && { usage }) };
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
1
|
+
import { runAgent } from "../runtime/run-agent.js";
|
|
2
|
+
import { capabilityContractVersion } from "./gateway.js";
|
|
3
|
+
|
|
4
|
+
export function createNativeAdapter({ agents, provider, store }) {
|
|
5
|
+
const configured = new Map(agents);
|
|
6
|
+
return {
|
|
7
|
+
id: "native",
|
|
8
|
+
contractVersion: capabilityContractVersion,
|
|
9
|
+
async invoke({ capabilityId, input }) {
|
|
10
|
+
const agent = configured.get(capabilityId);
|
|
11
|
+
if (!agent || typeof input !== "string" || !input.trim()) return { status: "failed" };
|
|
12
|
+
const event = await runAgent({
|
|
13
|
+
agentId: capabilityId,
|
|
14
|
+
request: {
|
|
15
|
+
model: agent.model,
|
|
16
|
+
messages: [
|
|
17
|
+
...(agent.system ? [{ role: "system", content: agent.system }] : []),
|
|
18
|
+
{ role: "user", content: input },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
provider,
|
|
22
|
+
store,
|
|
23
|
+
});
|
|
24
|
+
if (event.type === "run.failed") return { status: "failed", nativeExecutionId: event.run_id };
|
|
25
|
+
const { text, usage } = event.data.result;
|
|
26
|
+
return { status: "completed", nativeExecutionId: event.run_id, output: text, ...(usage && { usage }) };
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import { basename, dirname, resolve } from "node:path";
|
|
2
|
-
import { startStudio } from "../studio/server.js";
|
|
3
|
-
import { readAppManifest, SAVED_VERSION } from "./saved-app.js";
|
|
4
|
-
import { startSavedPreview } from "./saved-preview.js";
|
|
5
|
-
import { readSupportManifest } from "./support-manifest.js";
|
|
6
|
-
import { startSupportPreview } from "./support-template/support-preview.mjs";
|
|
7
|
-
|
|
8
|
-
export async function runAppPreview(args, output = process.stdout) {
|
|
9
|
-
if (args.length === 1 && args[0] === "--help") {
|
|
10
|
-
output.write("Usage: agent-lyra app preview
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (args.length
|
|
14
|
-
throw new Error("Provide
|
|
15
|
-
}
|
|
16
|
-
const app = await readAppManifest(args[0]);
|
|
17
|
-
if (app?.
|
|
18
|
-
const path = resolve(args[0]);
|
|
19
|
-
if (basename(path) !== "manifest.json") throw new Error("Use the project manifest.json for a Studio app preview.");
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { basename, dirname, resolve } from "node:path";
|
|
2
|
+
import { startStudio } from "../studio/server.js";
|
|
3
|
+
import { readAppManifest, SAVED_VERSION } from "./saved-app.js";
|
|
4
|
+
import { startSavedPreview } from "./saved-preview.js";
|
|
5
|
+
import { readSupportManifest } from "./support-manifest.js";
|
|
6
|
+
import { startSupportPreview } from "./support-template/support-preview.mjs";
|
|
7
|
+
|
|
8
|
+
export async function runAppPreview(args, output = process.stdout) {
|
|
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");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (args.length > 1 || args[0]?.startsWith("-")) {
|
|
14
|
+
throw new Error("Provide at most one manifest path. See agent-lyra app preview --help.");
|
|
15
|
+
}
|
|
16
|
+
const app = await readAppManifest(args[0] ?? "manifest.json");
|
|
17
|
+
if (Array.isArray(app?.studio?.layout)) {
|
|
18
|
+
const path = resolve(args[0] ?? "manifest.json");
|
|
19
|
+
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
|
+
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.");
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
output.write("App preview: " + url + "\n");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (app?.version === SAVED_VERSION) {
|
|
29
|
+
const { url } = await startSavedPreview(app);
|
|
30
|
+
output.write("App preview: " + url + "\n");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const manifest = await readSupportManifest(args[0] ?? "manifest.json");
|
|
34
|
+
await startSupportPreview(manifest);
|
|
35
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { readSupportManifest } from "./support-manifest.js";
|
|
2
|
-
|
|
3
|
-
export async function runAppPublish(args, output = process.stdout) {
|
|
4
|
-
if (args.length === 1 && args[0] === "--help") {
|
|
5
|
-
output.write("Usage: agent-lyra app publish <manifest.json> --dry-run\n");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (args.length !== 2 || args[0].startsWith("-") || args[1] !== "--dry-run") {
|
|
9
|
-
throw new Error("Only offline listing previews are supported. Pass <manifest.json> --dry-run.");
|
|
10
|
-
}
|
|
11
|
-
const manifest = await readSupportManifest(args[0]);
|
|
12
|
-
const listing = { listingSchemaVersion: "1.0", manifest };
|
|
13
|
-
output.write(`${JSON.stringify(listing, null, 2)}\n`);
|
|
14
|
-
}
|
|
1
|
+
import { readSupportManifest } from "./support-manifest.js";
|
|
2
|
+
|
|
3
|
+
export async function runAppPublish(args, output = process.stdout) {
|
|
4
|
+
if (args.length === 1 && args[0] === "--help") {
|
|
5
|
+
output.write("Usage: agent-lyra app publish <manifest.json> --dry-run\n");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (args.length !== 2 || args[0].startsWith("-") || args[1] !== "--dry-run") {
|
|
9
|
+
throw new Error("Only offline listing previews are supported. Pass <manifest.json> --dry-run.");
|
|
10
|
+
}
|
|
11
|
+
const manifest = await readSupportManifest(args[0]);
|
|
12
|
+
const listing = { listingSchemaVersion: "1.0", manifest };
|
|
13
|
+
output.write(`${JSON.stringify(listing, null, 2)}\n`);
|
|
14
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
|
|
3
|
-
export const SAVED_VERSION = "2.0";
|
|
4
|
-
const idPattern = /^[a-f0-9]{24}$/i;
|
|
5
|
-
const appIdPattern = /^[a-z][a-z0-9-]{0,79}$/;
|
|
6
|
-
|
|
7
|
-
export function validateSavedApp(manifest) {
|
|
8
|
-
if (manifest?.version !== SAVED_VERSION || !appIdPattern.test(manifest.application?.id ?? "") ||
|
|
9
|
-
typeof manifest.application.name !== "string" || !manifest.application.name.trim() ||
|
|
10
|
-
manifest.application.name.length > 120) {
|
|
11
|
-
throw new Error('Version "2.0" requires an application ID and name.');
|
|
12
|
-
}
|
|
13
|
-
const { steps } = manifest.workflow ?? {};
|
|
14
|
-
if (!Array.isArray(steps) || steps.length !== 2 ||
|
|
15
|
-
!steps.every(step => typeof step?.agentId === "string" && idPattern.test(step.agentId)) ||
|
|
16
|
-
steps[0].agentId.toLowerCase() === steps[1].agentId.toLowerCase()) {
|
|
17
|
-
throw new Error("A workflow requires two distinct saved Lyra agent IDs.");
|
|
18
|
-
}
|
|
19
|
-
return manifest;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function readAppManifest(path) {
|
|
23
|
-
const source = await readFile(path, "utf8");
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(source.replace(/^\uFEFF/, ""));
|
|
26
|
-
} catch {
|
|
27
|
-
throw new Error("Application manifest is not valid JSON.");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function createSavedAgentClient({ key = process.env.LYRA_API_KEY, fetchRequest = fetch } = {}) {
|
|
32
|
-
if (!/^lyra_sdk_[a-f0-9]{64}$/.test(key ?? "")) {
|
|
33
|
-
throw new Error("Set LYRA_API_KEY to a dedicated SDK key from AgentLyra Console.");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function request(path, prompt) {
|
|
37
|
-
const response = await fetchRequest("https://api.agentlyra.in/api/sdk/v1/saved-agents" + path, {
|
|
38
|
-
method: prompt === undefined ? "GET" : "POST",
|
|
39
|
-
headers: { Authorization: "Bearer " + key, "Content-Type": "application/json" },
|
|
40
|
-
body: prompt === undefined ? undefined : JSON.stringify({ prompt }),
|
|
41
|
-
redirect: "error",
|
|
42
|
-
signal: AbortSignal.timeout(65_000),
|
|
43
|
-
});
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
if (response.status === 401) throw new Error("The SDK key is invalid or revoked.");
|
|
46
|
-
if (response.status === 403) throw new Error("Add your OpenAI key in AgentLyra Console → Models.");
|
|
47
|
-
if (response.status === 404) throw new Error("A selected agent is unavailable to this SDK key.");
|
|
48
|
-
throw new Error("AgentLyra Cloud request failed (HTTP " + response.status + ").");
|
|
49
|
-
}
|
|
50
|
-
return response.json();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
list: async () => (await request("")).agents,
|
|
55
|
-
invoke: async (id, prompt) => (await request("/" + encodeURIComponent(id) + "/invoke", prompt)).output,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export async function runSavedApp(manifest, input, client = createSavedAgentClient()) {
|
|
60
|
-
const [first, second] = validateSavedApp(manifest).workflow.steps;
|
|
61
|
-
if (typeof input !== "string" || !input.trim() || input.length > 4000) {
|
|
62
|
-
throw new Error("Enter between 1 and 4,000 characters.");
|
|
63
|
-
}
|
|
64
|
-
const firstOutput = await client.invoke(first.agentId, input.trim());
|
|
65
|
-
const output = await client.invoke(second.agentId, JSON.stringify({
|
|
66
|
-
input: input.trim(),
|
|
67
|
-
previousAgentOutput: firstOutput,
|
|
68
|
-
}).slice(0, 12_000));
|
|
69
|
-
return { firstOutput, output };
|
|
70
|
-
}
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
export const SAVED_VERSION = "2.0";
|
|
4
|
+
const idPattern = /^[a-f0-9]{24}$/i;
|
|
5
|
+
const appIdPattern = /^[a-z][a-z0-9-]{0,79}$/;
|
|
6
|
+
|
|
7
|
+
export function validateSavedApp(manifest) {
|
|
8
|
+
if (manifest?.version !== SAVED_VERSION || !appIdPattern.test(manifest.application?.id ?? "") ||
|
|
9
|
+
typeof manifest.application.name !== "string" || !manifest.application.name.trim() ||
|
|
10
|
+
manifest.application.name.length > 120) {
|
|
11
|
+
throw new Error('Version "2.0" requires an application ID and name.');
|
|
12
|
+
}
|
|
13
|
+
const { steps } = manifest.workflow ?? {};
|
|
14
|
+
if (!Array.isArray(steps) || steps.length !== 2 ||
|
|
15
|
+
!steps.every(step => typeof step?.agentId === "string" && idPattern.test(step.agentId)) ||
|
|
16
|
+
steps[0].agentId.toLowerCase() === steps[1].agentId.toLowerCase()) {
|
|
17
|
+
throw new Error("A workflow requires two distinct saved Lyra agent IDs.");
|
|
18
|
+
}
|
|
19
|
+
return manifest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function readAppManifest(path) {
|
|
23
|
+
const source = await readFile(path, "utf8");
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(source.replace(/^\uFEFF/, ""));
|
|
26
|
+
} catch {
|
|
27
|
+
throw new Error("Application manifest is not valid JSON.");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createSavedAgentClient({ key = process.env.LYRA_API_KEY, fetchRequest = fetch } = {}) {
|
|
32
|
+
if (!/^lyra_sdk_[a-f0-9]{64}$/.test(key ?? "")) {
|
|
33
|
+
throw new Error("Set LYRA_API_KEY to a dedicated SDK key from AgentLyra Console.");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function request(path, prompt) {
|
|
37
|
+
const response = await fetchRequest("https://api.agentlyra.in/api/sdk/v1/saved-agents" + path, {
|
|
38
|
+
method: prompt === undefined ? "GET" : "POST",
|
|
39
|
+
headers: { Authorization: "Bearer " + key, "Content-Type": "application/json" },
|
|
40
|
+
body: prompt === undefined ? undefined : JSON.stringify({ prompt }),
|
|
41
|
+
redirect: "error",
|
|
42
|
+
signal: AbortSignal.timeout(65_000),
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
if (response.status === 401) throw new Error("The SDK key is invalid or revoked.");
|
|
46
|
+
if (response.status === 403) throw new Error("Add your OpenAI key in AgentLyra Console → Models.");
|
|
47
|
+
if (response.status === 404) throw new Error("A selected agent is unavailable to this SDK key.");
|
|
48
|
+
throw new Error("AgentLyra Cloud request failed (HTTP " + response.status + ").");
|
|
49
|
+
}
|
|
50
|
+
return response.json();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
list: async () => (await request("")).agents,
|
|
55
|
+
invoke: async (id, prompt) => (await request("/" + encodeURIComponent(id) + "/invoke", prompt)).output,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function runSavedApp(manifest, input, client = createSavedAgentClient()) {
|
|
60
|
+
const [first, second] = validateSavedApp(manifest).workflow.steps;
|
|
61
|
+
if (typeof input !== "string" || !input.trim() || input.length > 4000) {
|
|
62
|
+
throw new Error("Enter between 1 and 4,000 characters.");
|
|
63
|
+
}
|
|
64
|
+
const firstOutput = await client.invoke(first.agentId, input.trim());
|
|
65
|
+
const output = await client.invoke(second.agentId, JSON.stringify({
|
|
66
|
+
input: input.trim(),
|
|
67
|
+
previousAgentOutput: firstOutput,
|
|
68
|
+
}).slice(0, 12_000));
|
|
69
|
+
return { firstOutput, output };
|
|
70
|
+
}
|