agent-lyra 0.6.2 → 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 -435
- package/bin/agent-lyra.js +49 -49
- package/bin/lyra-oss-preview.js +16 -14
- 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 -46
- 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 -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 -44
- package/src/coding/detect-stack.mjs +110 -110
- package/src/coding/export.js +130 -130
- package/src/coding/setup.js +175 -174
- 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 -965
- package/src/memory/cli.js +21 -21
- 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 -34
- package/src/memory/proposals.js +84 -84
- package/src/memory/skills-cli.js +26 -26
- 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/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 -216
- 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/bin/agent-lyra.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { runSkillProposals } from "../src/memory/skills-cli.js";
|
|
4
|
-
import { runMemory } from "../src/memory/cli.js";
|
|
5
|
-
import { runCli } from "../src/init.js";
|
|
6
|
-
import { runCodingExport } from "../src/coding/export.js";
|
|
7
|
-
import { runCodingSetup } from "../src/coding/setup.js";
|
|
8
|
-
import { runLocalCli } from "../src/runtime/local-cli.js";
|
|
9
|
-
import { serveSavedRuns } from "../src/runtime/mcp-stdio.js";
|
|
10
|
-
import { runAppValidation } from "../src/app-builder/validate.js";
|
|
11
|
-
import { runAppExport } from "../src/app-builder/export.js";
|
|
12
|
-
import { runAppInit } from "../src/app-builder/init.js";
|
|
13
|
-
import { runAppPreview } from "../src/app-builder/preview.js";
|
|
14
|
-
import { runAppPublish } from "../src/app-builder/publish.js";
|
|
15
|
-
import { runAppUse } from "../src/app-builder/use.js";
|
|
16
|
-
|
|
17
|
-
import { readMode, readSdkKey, requireCloudMode, switchMode } from "../src/studio/session.js";
|
|
18
|
-
import { runStudio } from "../src/studio/server.js";
|
|
19
|
-
|
|
20
|
-
async function main() {
|
|
21
|
-
const argv = process.argv.slice(2);
|
|
22
|
-
if (argv[0] === "setup" && argv[1] === "coding") {
|
|
23
|
-
return argv[2] === "export" ? runCodingExport(argv.slice(3)) : runCodingSetup(argv.slice(2));
|
|
24
|
-
}
|
|
25
|
-
if (argv[0] === "skills") return runSkillProposals(argv.slice(1));
|
|
26
|
-
if (argv[0] === "memory") return runMemory(argv.slice(1));
|
|
27
|
-
if (argv[0] === "connect-cloud") return switchMode(process.cwd(), "gated", argv.slice(1));
|
|
28
|
-
if (argv[0] === "work-locally") return switchMode(process.cwd(), "standalone", argv.slice(1));
|
|
29
|
-
if (["gated", "standalone"].includes(argv[0])) return switchMode(process.cwd(), argv[0], argv.slice(1));
|
|
30
|
-
if (argv[0] === "app" && ["init", "preview"].includes(argv[1]) && !argv.includes("--help")) {
|
|
31
|
-
if (argv[1] === "init") requireCloudMode(await readMode(process.cwd()));
|
|
32
|
-
const key = await readSdkKey(process.cwd());
|
|
33
|
-
if (key) process.env.LYRA_API_KEY = key;
|
|
34
|
-
}
|
|
35
|
-
if (argv[0] === "studio") return runStudio(argv.slice(1));
|
|
36
|
-
if (argv[0] === "app" && argv[1] === "use") return runAppUse(argv.slice(2));
|
|
37
|
-
if (argv[0] === "app" && argv[1] === "init") return runAppInit(argv.slice(2));
|
|
38
|
-
if (argv[0] === "app" && argv[1] === "preview") return runAppPreview(argv.slice(2));
|
|
39
|
-
if (argv[0] === "app" && argv[1] === "publish") return runAppPublish(argv.slice(2));
|
|
40
|
-
if (argv[0] === "app" && argv[1] === "export") return runAppExport(argv.slice(2));
|
|
41
|
-
if (argv[0] === "app" && argv[1] === "validate") return runAppValidation(argv.slice(2));
|
|
42
|
-
if (argv[0] === "mcp" && argv[1] === "serve") return serveSavedRuns(argv.slice(2));
|
|
43
|
-
if (!(await runLocalCli(argv))) await runCli(argv);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
main().catch((error) => {
|
|
47
|
-
process.stderr.write(`${error.message}\n`);
|
|
48
|
-
process.exitCode = 1;
|
|
49
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runSkillProposals } from "../src/memory/skills-cli.js";
|
|
4
|
+
import { runMemory } from "../src/memory/cli.js";
|
|
5
|
+
import { runCli } from "../src/init.js";
|
|
6
|
+
import { runCodingExport } from "../src/coding/export.js";
|
|
7
|
+
import { runCodingSetup } from "../src/coding/setup.js";
|
|
8
|
+
import { runLocalCli } from "../src/runtime/local-cli.js";
|
|
9
|
+
import { serveSavedRuns } from "../src/runtime/mcp-stdio.js";
|
|
10
|
+
import { runAppValidation } from "../src/app-builder/validate.js";
|
|
11
|
+
import { runAppExport } from "../src/app-builder/export.js";
|
|
12
|
+
import { runAppInit } from "../src/app-builder/init.js";
|
|
13
|
+
import { runAppPreview } from "../src/app-builder/preview.js";
|
|
14
|
+
import { runAppPublish } from "../src/app-builder/publish.js";
|
|
15
|
+
import { runAppUse } from "../src/app-builder/use.js";
|
|
16
|
+
|
|
17
|
+
import { readMode, readSdkKey, requireCloudMode, switchMode } from "../src/studio/session.js";
|
|
18
|
+
import { runStudio } from "../src/studio/server.js";
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
const argv = process.argv.slice(2);
|
|
22
|
+
if (argv[0] === "setup" && argv[1] === "coding") {
|
|
23
|
+
return argv[2] === "export" ? runCodingExport(argv.slice(3)) : runCodingSetup(argv.slice(2));
|
|
24
|
+
}
|
|
25
|
+
if (argv[0] === "skills") return runSkillProposals(argv.slice(1));
|
|
26
|
+
if (argv[0] === "memory") return runMemory(argv.slice(1));
|
|
27
|
+
if (argv[0] === "connect-cloud") return switchMode(process.cwd(), "gated", argv.slice(1));
|
|
28
|
+
if (argv[0] === "work-locally") return switchMode(process.cwd(), "standalone", argv.slice(1));
|
|
29
|
+
if (["gated", "standalone"].includes(argv[0])) return switchMode(process.cwd(), argv[0], argv.slice(1));
|
|
30
|
+
if (argv[0] === "app" && ["init", "preview"].includes(argv[1]) && !argv.includes("--help")) {
|
|
31
|
+
if (argv[1] === "init") requireCloudMode(await readMode(process.cwd()));
|
|
32
|
+
const key = await readSdkKey(process.cwd());
|
|
33
|
+
if (key) process.env.LYRA_API_KEY = key;
|
|
34
|
+
}
|
|
35
|
+
if (argv[0] === "studio") return runStudio(argv.slice(1));
|
|
36
|
+
if (argv[0] === "app" && argv[1] === "use") return runAppUse(argv.slice(2));
|
|
37
|
+
if (argv[0] === "app" && argv[1] === "init") return runAppInit(argv.slice(2));
|
|
38
|
+
if (argv[0] === "app" && argv[1] === "preview") return runAppPreview(argv.slice(2));
|
|
39
|
+
if (argv[0] === "app" && argv[1] === "publish") return runAppPublish(argv.slice(2));
|
|
40
|
+
if (argv[0] === "app" && argv[1] === "export") return runAppExport(argv.slice(2));
|
|
41
|
+
if (argv[0] === "app" && argv[1] === "validate") return runAppValidation(argv.slice(2));
|
|
42
|
+
if (argv[0] === "mcp" && argv[1] === "serve") return serveSavedRuns(argv.slice(2));
|
|
43
|
+
if (!(await runLocalCli(argv))) await runCli(argv);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main().catch((error) => {
|
|
47
|
+
process.stderr.write(`${error.message}\n`);
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
});
|
package/bin/lyra-oss-preview.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
else if (command==='
|
|
11
|
-
else if (await
|
|
12
|
-
else if (
|
|
13
|
-
else
|
|
14
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { initStandalone } from '../src/standalone/init.js';
|
|
3
|
+
import { runLocalMemory } from '../src/memory/local-cli.js';
|
|
4
|
+
import { runSkillProposals } from '../src/memory/skills-cli.js';
|
|
5
|
+
import { runLocalCli } from '../src/runtime/local-cli.js';
|
|
6
|
+
import { serveSavedRuns } from '../src/runtime/mcp-stdio.js';
|
|
7
|
+
const [command,...args]=process.argv.slice(2);
|
|
8
|
+
try {
|
|
9
|
+
if (command==='init') await initStandalone(args);
|
|
10
|
+
else if (command==='memory') await runLocalMemory(args);
|
|
11
|
+
else if (command==='skills') await runSkillProposals(args);
|
|
12
|
+
else if (command==='mcp' && args[0]==='serve') await serveSavedRuns(args.slice(1));
|
|
13
|
+
else if (await runLocalCli([command,...args])) {}
|
|
14
|
+
else if (!command || command==='--help') console.log('Usage: agent-lyra init | memory | skills | agent run | team run | run status | mcp serve');
|
|
15
|
+
else throw new Error('Unsupported standalone command');
|
|
16
|
+
} catch(error) { console.error(error.message); process.exitCode=1; }
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "agent-lyra",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Two-layer Lyra SDK with standalone local primitives and gated hosted agents.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./src/index.js",
|
|
7
|
-
"types": "./src/index.d.ts",
|
|
8
|
-
"engines": {
|
|
9
|
-
"node": ">=22.13.0"
|
|
10
|
-
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://gitlab.com/vibified/agent-lyra.git",
|
|
14
|
-
"directory": "packages/lyra"
|
|
15
|
-
},
|
|
16
|
-
"homepage": "https://agentlyra.in",
|
|
17
|
-
"bin": {
|
|
18
|
-
"agent-lyra": "./bin/agent-lyra.js"
|
|
19
|
-
},
|
|
20
|
-
"exports": {
|
|
21
|
-
".": {
|
|
22
|
-
"types": "./src/index.d.ts",
|
|
23
|
-
"default": "./src/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./memory": {
|
|
26
|
-
"types": "./src/memory/index.d.ts",
|
|
27
|
-
"default": "./src/memory/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./standalone": {
|
|
30
|
-
"types": "./src/standalone/index.d.ts",
|
|
31
|
-
"default": "./src/standalone/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./gated": {
|
|
34
|
-
"types": "./src/gated/index.d.ts",
|
|
35
|
-
"default": "./src/gated/index.js"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"files": [
|
|
39
|
-
"bin",
|
|
40
|
-
"src",
|
|
41
|
-
"README.md",
|
|
42
|
-
"LICENSE"
|
|
43
|
-
],
|
|
44
|
-
"sideEffects": false,
|
|
45
|
-
"scripts": {
|
|
46
|
-
"test": "node --test"
|
|
47
|
-
},
|
|
48
|
-
"keywords": [
|
|
49
|
-
"lyra",
|
|
50
|
-
"orchestration",
|
|
51
|
-
"rag",
|
|
52
|
-
"agents",
|
|
53
|
-
"sdk"
|
|
54
|
-
],
|
|
55
|
-
"author": "",
|
|
56
|
-
"license": "MIT",
|
|
57
|
-
"publishConfig": {
|
|
58
|
-
"access": "public"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-lyra",
|
|
3
|
+
"version": "0.6.3",
|
|
4
|
+
"description": "Two-layer Lyra SDK with standalone local primitives and gated hosted agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.13.0"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://gitlab.com/vibified/agent-lyra.git",
|
|
14
|
+
"directory": "packages/lyra"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://agentlyra.in",
|
|
17
|
+
"bin": {
|
|
18
|
+
"agent-lyra": "./bin/agent-lyra.js"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./src/index.d.ts",
|
|
23
|
+
"default": "./src/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./memory": {
|
|
26
|
+
"types": "./src/memory/index.d.ts",
|
|
27
|
+
"default": "./src/memory/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./standalone": {
|
|
30
|
+
"types": "./src/standalone/index.d.ts",
|
|
31
|
+
"default": "./src/standalone/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./gated": {
|
|
34
|
+
"types": "./src/gated/index.d.ts",
|
|
35
|
+
"default": "./src/gated/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"bin",
|
|
40
|
+
"src",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "node --test"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"lyra",
|
|
50
|
+
"orchestration",
|
|
51
|
+
"rag",
|
|
52
|
+
"agents",
|
|
53
|
+
"sdk"
|
|
54
|
+
],
|
|
55
|
+
"author": "",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, join, resolve } from "node:path";
|
|
3
|
-
import { readAppManifest, SAVED_VERSION, validateSavedApp } from "./saved-app.js";
|
|
4
|
-
import { exportStudioApp } from "../studio/export.js";
|
|
5
|
-
import { readSupportManifest } from "./support-manifest.js";
|
|
6
|
-
|
|
7
|
-
const assets = {
|
|
8
|
-
"runtime/app-builder/support-template/support-preview.mjs": "./support-template/support-preview.mjs",
|
|
9
|
-
"runtime/app-builder/support-template/support-preview.html": "./support-template/support-preview.html",
|
|
10
|
-
"runtime/app-builder/support-template/support-preview.js": "./support-template/support-preview.js",
|
|
11
|
-
"runtime/app-builder/support-template/support-workflow.mjs": "./support-template/support-workflow.mjs",
|
|
12
|
-
"runtime/app-builder/gateway.js": "./gateway.js",
|
|
13
|
-
"runtime/app-builder/validate.js": "./validate.js",
|
|
14
|
-
"runtime/app-builder/saved-app.js": "./saved-app.js",
|
|
15
|
-
"runtime/app-builder/value-schema.js": "./value-schema.js",
|
|
16
|
-
"runtime/app-builder/native-adapter.js": "./native-adapter.js",
|
|
17
|
-
"runtime/runtime/run-agent.js": "../runtime/run-agent.js",
|
|
18
|
-
LICENSE: "../../LICENSE",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export async function runAppExport(args, output = process.stdout) {
|
|
22
|
-
if (args.length === 1 && args[0] === "--help") {
|
|
23
|
-
output.write("Usage: agent-lyra app export <manifest.json> <new-directory>\n");
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (args.length !== 2 || args.some((arg) => arg.startsWith("-"))) {
|
|
27
|
-
throw new Error("Provide a manifest and new output directory. See agent-lyra app export --help.");
|
|
28
|
-
}
|
|
29
|
-
const app = await readAppManifest(args[0]);
|
|
30
|
-
if (Array.isArray(app?.studio?.layout)) {
|
|
31
|
-
const directory = resolve(args[1]);
|
|
32
|
-
await exportStudioApp(app, dirname(resolve(args[0])), directory);
|
|
33
|
-
output.write("Exported Studio app to " + directory + "\n");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (app?.version === SAVED_VERSION) {
|
|
37
|
-
await exportSavedApp(validateSavedApp(app), resolve(args[1]));
|
|
38
|
-
output.write("Exported " + app.application.id + " to " + resolve(args[1]) + "\n");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const manifest = await readSupportManifest(args[0]);
|
|
42
|
-
const directory = resolve(args[1]);
|
|
43
|
-
const files = await Promise.all(Object.entries(assets).map(async ([name, sourcePath]) =>
|
|
44
|
-
[name, await readFile(new URL(sourcePath, import.meta.url))]));
|
|
45
|
-
const manifestReader = 'const manifest = JSON.parse(await readFile(new URL("./example-manifest.json", import.meta.url), "utf8"));\n';
|
|
46
|
-
files.push(["example-manifest.json", JSON.stringify(manifest, null, 2) + "\n"]);
|
|
47
|
-
files.push(["support-preview.mjs",
|
|
48
|
-
'import { readFile } from "node:fs/promises";\n' +
|
|
49
|
-
'import { startSupportPreview } from "./runtime/app-builder/support-template/support-preview.mjs";\n' +
|
|
50
|
-
manifestReader + "await startSupportPreview(manifest);\n"]);
|
|
51
|
-
files.push(["support-example.mjs",
|
|
52
|
-
'import { readFile } from "node:fs/promises";\n' +
|
|
53
|
-
'import { createSupportWorkflow } from "./runtime/app-builder/support-template/support-workflow.mjs";\n' +
|
|
54
|
-
manifestReader +
|
|
55
|
-
'console.log(JSON.stringify(await createSupportWorkflow(manifest)(process.argv[2] ?? "Invoice question"), null, 2));\n']);
|
|
56
|
-
files.push(["package.json", JSON.stringify({
|
|
57
|
-
name: manifest.application.id, version: "1.0.0", private: true, type: "module",
|
|
58
|
-
engines: { node: ">=22.13.0" },
|
|
59
|
-
scripts: { start: "node support-preview.mjs", demo: "node support-example.mjs" },
|
|
60
|
-
}, null, 2) + "\n"]);
|
|
61
|
-
files.push(["README.md", "# Support app\n\nRun `npm start` and open http://127.0.0.1:4173/. Run `npm run demo` for the terminal workflow.\n\nThe bundled classifier and provider are deterministic. The app binds to loopback and does not persist or send tickets.\n"]);
|
|
62
|
-
try {
|
|
63
|
-
await mkdir(directory);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
if (error.code === "EEXIST") throw new Error("Choose a new directory. Existing files were preserved.");
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
for (const [name, contents] of files) {
|
|
69
|
-
const target = join(directory, name);
|
|
70
|
-
await mkdir(dirname(target), { recursive: true });
|
|
71
|
-
await writeFile(target, contents, { flag: "wx" });
|
|
72
|
-
}
|
|
73
|
-
output.write(`Exported ${manifest.application.id} to ${directory}\n`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function exportSavedApp(manifest, directory) {
|
|
77
|
-
const runtime = ["saved-app.js", "saved-preview.js", "saved-preview-browser.js", "saved-preview.html"];
|
|
78
|
-
const files = await Promise.all(runtime.map(async name => [
|
|
79
|
-
name, await readFile(new URL("./" + name, import.meta.url)),
|
|
80
|
-
]));
|
|
81
|
-
const project = {
|
|
82
|
-
name: manifest.application.id, version: "1.0.0", private: true, type: "module",
|
|
83
|
-
engines: { node: ">=22.13.0" }, scripts: { start: "node server.js" },
|
|
84
|
-
};
|
|
85
|
-
const safeManifest = {
|
|
86
|
-
version: SAVED_VERSION,
|
|
87
|
-
application: { id: manifest.application.id, name: manifest.application.name },
|
|
88
|
-
workflow: { steps: manifest.workflow.steps.map(({ agentId }) => ({ agentId })) },
|
|
89
|
-
};
|
|
90
|
-
files.push(["package.json", JSON.stringify(project, null, 2) + "\n"]);
|
|
91
|
-
files.push(["manifest.json", JSON.stringify(safeManifest, null, 2) + "\n"]);
|
|
92
|
-
files.push(["server.js",
|
|
93
|
-
'import { readAppManifest } from "./saved-app.js";\n' +
|
|
94
|
-
'import { startSavedPreview } from "./saved-preview.js";\n' +
|
|
95
|
-
'const { url } = await startSavedPreview(await readAppManifest(new URL("./manifest.json", import.meta.url)));\n' +
|
|
96
|
-
'console.log("App preview: " + url);\n']);
|
|
97
|
-
files.push(["README.md", "# Run this Lyra app\n\nSet LYRA_API_KEY to your AgentLyra SDK key, then run npm start. Open the loopback URL. Your selected agents run in AgentLyra Cloud. Set LYRA_PREVIEW_PORT=0 to pick a free port. The local server does not provide authentication for public hosting.\n"]);
|
|
98
|
-
files.push(["LICENSE", await readFile(new URL("../../LICENSE", import.meta.url))]);
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
await mkdir(directory);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (error.code === "EEXIST") throw new Error("Choose a new directory. Existing files were preserved.");
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
for (const [name, contents] of files) {
|
|
107
|
-
await writeFile(join(directory, name), contents, { flag: "wx" });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { readAppManifest, SAVED_VERSION, validateSavedApp } from "./saved-app.js";
|
|
4
|
+
import { exportStudioApp } from "../studio/export.js";
|
|
5
|
+
import { readSupportManifest } from "./support-manifest.js";
|
|
6
|
+
|
|
7
|
+
const assets = {
|
|
8
|
+
"runtime/app-builder/support-template/support-preview.mjs": "./support-template/support-preview.mjs",
|
|
9
|
+
"runtime/app-builder/support-template/support-preview.html": "./support-template/support-preview.html",
|
|
10
|
+
"runtime/app-builder/support-template/support-preview.js": "./support-template/support-preview.js",
|
|
11
|
+
"runtime/app-builder/support-template/support-workflow.mjs": "./support-template/support-workflow.mjs",
|
|
12
|
+
"runtime/app-builder/gateway.js": "./gateway.js",
|
|
13
|
+
"runtime/app-builder/validate.js": "./validate.js",
|
|
14
|
+
"runtime/app-builder/saved-app.js": "./saved-app.js",
|
|
15
|
+
"runtime/app-builder/value-schema.js": "./value-schema.js",
|
|
16
|
+
"runtime/app-builder/native-adapter.js": "./native-adapter.js",
|
|
17
|
+
"runtime/runtime/run-agent.js": "../runtime/run-agent.js",
|
|
18
|
+
LICENSE: "../../LICENSE",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export async function runAppExport(args, output = process.stdout) {
|
|
22
|
+
if (args.length === 1 && args[0] === "--help") {
|
|
23
|
+
output.write("Usage: agent-lyra app export <manifest.json> <new-directory>\n");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (args.length !== 2 || args.some((arg) => arg.startsWith("-"))) {
|
|
27
|
+
throw new Error("Provide a manifest and new output directory. See agent-lyra app export --help.");
|
|
28
|
+
}
|
|
29
|
+
const app = await readAppManifest(args[0]);
|
|
30
|
+
if (Array.isArray(app?.studio?.layout)) {
|
|
31
|
+
const directory = resolve(args[1]);
|
|
32
|
+
await exportStudioApp(app, dirname(resolve(args[0])), directory);
|
|
33
|
+
output.write("Exported Studio app to " + directory + "\n");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (app?.version === SAVED_VERSION) {
|
|
37
|
+
await exportSavedApp(validateSavedApp(app), resolve(args[1]));
|
|
38
|
+
output.write("Exported " + app.application.id + " to " + resolve(args[1]) + "\n");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const manifest = await readSupportManifest(args[0]);
|
|
42
|
+
const directory = resolve(args[1]);
|
|
43
|
+
const files = await Promise.all(Object.entries(assets).map(async ([name, sourcePath]) =>
|
|
44
|
+
[name, await readFile(new URL(sourcePath, import.meta.url))]));
|
|
45
|
+
const manifestReader = 'const manifest = JSON.parse(await readFile(new URL("./example-manifest.json", import.meta.url), "utf8"));\n';
|
|
46
|
+
files.push(["example-manifest.json", JSON.stringify(manifest, null, 2) + "\n"]);
|
|
47
|
+
files.push(["support-preview.mjs",
|
|
48
|
+
'import { readFile } from "node:fs/promises";\n' +
|
|
49
|
+
'import { startSupportPreview } from "./runtime/app-builder/support-template/support-preview.mjs";\n' +
|
|
50
|
+
manifestReader + "await startSupportPreview(manifest);\n"]);
|
|
51
|
+
files.push(["support-example.mjs",
|
|
52
|
+
'import { readFile } from "node:fs/promises";\n' +
|
|
53
|
+
'import { createSupportWorkflow } from "./runtime/app-builder/support-template/support-workflow.mjs";\n' +
|
|
54
|
+
manifestReader +
|
|
55
|
+
'console.log(JSON.stringify(await createSupportWorkflow(manifest)(process.argv[2] ?? "Invoice question"), null, 2));\n']);
|
|
56
|
+
files.push(["package.json", JSON.stringify({
|
|
57
|
+
name: manifest.application.id, version: "1.0.0", private: true, type: "module",
|
|
58
|
+
engines: { node: ">=22.13.0" },
|
|
59
|
+
scripts: { start: "node support-preview.mjs", demo: "node support-example.mjs" },
|
|
60
|
+
}, null, 2) + "\n"]);
|
|
61
|
+
files.push(["README.md", "# Support app\n\nRun `npm start` and open http://127.0.0.1:4173/. Run `npm run demo` for the terminal workflow.\n\nThe bundled classifier and provider are deterministic. The app binds to loopback and does not persist or send tickets.\n"]);
|
|
62
|
+
try {
|
|
63
|
+
await mkdir(directory);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.code === "EEXIST") throw new Error("Choose a new directory. Existing files were preserved.");
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
for (const [name, contents] of files) {
|
|
69
|
+
const target = join(directory, name);
|
|
70
|
+
await mkdir(dirname(target), { recursive: true });
|
|
71
|
+
await writeFile(target, contents, { flag: "wx" });
|
|
72
|
+
}
|
|
73
|
+
output.write(`Exported ${manifest.application.id} to ${directory}\n`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function exportSavedApp(manifest, directory) {
|
|
77
|
+
const runtime = ["saved-app.js", "saved-preview.js", "saved-preview-browser.js", "saved-preview.html"];
|
|
78
|
+
const files = await Promise.all(runtime.map(async name => [
|
|
79
|
+
name, await readFile(new URL("./" + name, import.meta.url)),
|
|
80
|
+
]));
|
|
81
|
+
const project = {
|
|
82
|
+
name: manifest.application.id, version: "1.0.0", private: true, type: "module",
|
|
83
|
+
engines: { node: ">=22.13.0" }, scripts: { start: "node server.js" },
|
|
84
|
+
};
|
|
85
|
+
const safeManifest = {
|
|
86
|
+
version: SAVED_VERSION,
|
|
87
|
+
application: { id: manifest.application.id, name: manifest.application.name },
|
|
88
|
+
workflow: { steps: manifest.workflow.steps.map(({ agentId }) => ({ agentId })) },
|
|
89
|
+
};
|
|
90
|
+
files.push(["package.json", JSON.stringify(project, null, 2) + "\n"]);
|
|
91
|
+
files.push(["manifest.json", JSON.stringify(safeManifest, null, 2) + "\n"]);
|
|
92
|
+
files.push(["server.js",
|
|
93
|
+
'import { readAppManifest } from "./saved-app.js";\n' +
|
|
94
|
+
'import { startSavedPreview } from "./saved-preview.js";\n' +
|
|
95
|
+
'const { url } = await startSavedPreview(await readAppManifest(new URL("./manifest.json", import.meta.url)));\n' +
|
|
96
|
+
'console.log("App preview: " + url);\n']);
|
|
97
|
+
files.push(["README.md", "# Run this Lyra app\n\nSet LYRA_API_KEY to your AgentLyra SDK key, then run npm start. Open the loopback URL. Your selected agents run in AgentLyra Cloud. Set LYRA_PREVIEW_PORT=0 to pick a free port. The local server does not provide authentication for public hosting.\n"]);
|
|
98
|
+
files.push(["LICENSE", await readFile(new URL("../../LICENSE", import.meta.url))]);
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
await mkdir(directory);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error.code === "EEXIST") throw new Error("Choose a new directory. Existing files were preserved.");
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
for (const [name, contents] of files) {
|
|
107
|
+
await writeFile(join(directory, name), contents, { flag: "wx" });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { validateAppManifest } from "./validate.js";
|
|
3
|
-
import { matchesValueSchema } from "./value-schema.js";
|
|
4
|
-
|
|
5
|
-
export const capabilityContractVersion = "1.0";
|
|
6
|
-
|
|
7
|
-
export function createCapabilityGateway(manifest, adapters = []) {
|
|
8
|
-
validateAppManifest(manifest);
|
|
9
|
-
const registry = new Map();
|
|
10
|
-
for (const adapter of adapters) {
|
|
11
|
-
if (!adapter || typeof adapter.id !== "string" || !adapter.id ||
|
|
12
|
-
adapter.contractVersion !== capabilityContractVersion || typeof adapter.invoke !== "function") {
|
|
13
|
-
throw new Error("Adapter requires an id, contract version 1.0, and invoke function.");
|
|
14
|
-
}
|
|
15
|
-
if (registry.has(adapter.id)) throw new Error(`Duplicate adapter: ${adapter.id}.`);
|
|
16
|
-
registry.set(adapter.id, adapter.invoke.bind(adapter));
|
|
17
|
-
}
|
|
18
|
-
const capabilities = new Map(manifest.capabilities.map(({ id, adapterId, executionMode, inputSchema, outputSchema }) =>
|
|
19
|
-
[id, structuredClone({ id, adapterId, executionMode, inputSchema, outputSchema })]));
|
|
20
|
-
const actions = new Map(manifest.actions.map(({ id, capabilityId }) => [id, capabilityId]));
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
async invokeAction(actionId, input, { correlationId = randomUUID() } = {}) {
|
|
24
|
-
const capability = capabilities.get(actions.get(actionId));
|
|
25
|
-
const base = { executionId: randomUUID(), correlationId };
|
|
26
|
-
const fail = (status, code, message) => ({
|
|
27
|
-
...base, status, error: { code, message, retryable: false },
|
|
28
|
-
});
|
|
29
|
-
if (!capability) return fail("failed", "UNKNOWN_ACTION", "Action is not declared in the manifest.");
|
|
30
|
-
if (capability.executionMode !== "in-process") {
|
|
31
|
-
return fail("unsupported", "UNSUPPORTED_MODE", "Only in-process execution is supported by this gateway.");
|
|
32
|
-
}
|
|
33
|
-
const invoke = registry.get(capability.adapterId);
|
|
34
|
-
if (!invoke) return fail("unsupported", "ADAPTER_NOT_REGISTERED", "Capability adapter is not registered.");
|
|
35
|
-
if (capability.inputSchema && !matchesValueSchema(input, capability.inputSchema)) {
|
|
36
|
-
return fail("failed", "INVALID_INPUT", "Input does not satisfy the capability schema.");
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
const result = await invoke({ ...base, capabilityId: capability.id, input });
|
|
40
|
-
if (result?.status === "completed") {
|
|
41
|
-
if (capability.outputSchema && !matchesValueSchema(result.output, capability.outputSchema)) {
|
|
42
|
-
return fail("failed", "INVALID_OUTPUT", "Adapter output does not satisfy the capability schema.");
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...base, status: "completed", output: result.output,
|
|
46
|
-
...(result.nativeExecutionId && { nativeExecutionId: result.nativeExecutionId }),
|
|
47
|
-
...(result.usage && { usage: result.usage }),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (result?.status === "failed") {
|
|
51
|
-
return {
|
|
52
|
-
...fail("failed", "ADAPTER_FAILED", "Capability execution failed."),
|
|
53
|
-
...(result.nativeExecutionId && { nativeExecutionId: result.nativeExecutionId }),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return fail("failed", "INVALID_ADAPTER_RESULT", "Adapter returned an invalid result.");
|
|
57
|
-
} catch {
|
|
58
|
-
return fail("failed", "ADAPTER_FAILED", "Capability execution failed.");
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { validateAppManifest } from "./validate.js";
|
|
3
|
+
import { matchesValueSchema } from "./value-schema.js";
|
|
4
|
+
|
|
5
|
+
export const capabilityContractVersion = "1.0";
|
|
6
|
+
|
|
7
|
+
export function createCapabilityGateway(manifest, adapters = []) {
|
|
8
|
+
validateAppManifest(manifest);
|
|
9
|
+
const registry = new Map();
|
|
10
|
+
for (const adapter of adapters) {
|
|
11
|
+
if (!adapter || typeof adapter.id !== "string" || !adapter.id ||
|
|
12
|
+
adapter.contractVersion !== capabilityContractVersion || typeof adapter.invoke !== "function") {
|
|
13
|
+
throw new Error("Adapter requires an id, contract version 1.0, and invoke function.");
|
|
14
|
+
}
|
|
15
|
+
if (registry.has(adapter.id)) throw new Error(`Duplicate adapter: ${adapter.id}.`);
|
|
16
|
+
registry.set(adapter.id, adapter.invoke.bind(adapter));
|
|
17
|
+
}
|
|
18
|
+
const capabilities = new Map(manifest.capabilities.map(({ id, adapterId, executionMode, inputSchema, outputSchema }) =>
|
|
19
|
+
[id, structuredClone({ id, adapterId, executionMode, inputSchema, outputSchema })]));
|
|
20
|
+
const actions = new Map(manifest.actions.map(({ id, capabilityId }) => [id, capabilityId]));
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
async invokeAction(actionId, input, { correlationId = randomUUID() } = {}) {
|
|
24
|
+
const capability = capabilities.get(actions.get(actionId));
|
|
25
|
+
const base = { executionId: randomUUID(), correlationId };
|
|
26
|
+
const fail = (status, code, message) => ({
|
|
27
|
+
...base, status, error: { code, message, retryable: false },
|
|
28
|
+
});
|
|
29
|
+
if (!capability) return fail("failed", "UNKNOWN_ACTION", "Action is not declared in the manifest.");
|
|
30
|
+
if (capability.executionMode !== "in-process") {
|
|
31
|
+
return fail("unsupported", "UNSUPPORTED_MODE", "Only in-process execution is supported by this gateway.");
|
|
32
|
+
}
|
|
33
|
+
const invoke = registry.get(capability.adapterId);
|
|
34
|
+
if (!invoke) return fail("unsupported", "ADAPTER_NOT_REGISTERED", "Capability adapter is not registered.");
|
|
35
|
+
if (capability.inputSchema && !matchesValueSchema(input, capability.inputSchema)) {
|
|
36
|
+
return fail("failed", "INVALID_INPUT", "Input does not satisfy the capability schema.");
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const result = await invoke({ ...base, capabilityId: capability.id, input });
|
|
40
|
+
if (result?.status === "completed") {
|
|
41
|
+
if (capability.outputSchema && !matchesValueSchema(result.output, capability.outputSchema)) {
|
|
42
|
+
return fail("failed", "INVALID_OUTPUT", "Adapter output does not satisfy the capability schema.");
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...base, status: "completed", output: result.output,
|
|
46
|
+
...(result.nativeExecutionId && { nativeExecutionId: result.nativeExecutionId }),
|
|
47
|
+
...(result.usage && { usage: result.usage }),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (result?.status === "failed") {
|
|
51
|
+
return {
|
|
52
|
+
...fail("failed", "ADAPTER_FAILED", "Capability execution failed."),
|
|
53
|
+
...(result.nativeExecutionId && { nativeExecutionId: result.nativeExecutionId }),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return fail("failed", "INVALID_ADAPTER_RESULT", "Adapter returned an invalid result.");
|
|
57
|
+
} catch {
|
|
58
|
+
return fail("failed", "ADAPTER_FAILED", "Capability execution failed.");
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|