agent-lyra 0.8.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.
Files changed (126) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +301 -291
  3. package/bin/agent-lyra.js +51 -51
  4. package/bin/lyra-oss-preview.js +16 -16
  5. package/package.json +60 -60
  6. package/src/app-builder/export.js +109 -109
  7. package/src/app-builder/gateway.js +62 -62
  8. package/src/app-builder/init.js +115 -72
  9. package/src/app-builder/manifest-contract.js +46 -46
  10. package/src/app-builder/native-adapter.js +29 -29
  11. package/src/app-builder/preview.js +35 -31
  12. package/src/app-builder/publish.js +14 -14
  13. package/src/app-builder/saved-app.js +70 -70
  14. package/src/app-builder/saved-preview-browser.js +33 -33
  15. package/src/app-builder/saved-preview.html +24 -24
  16. package/src/app-builder/saved-preview.js +61 -61
  17. package/src/app-builder/support-manifest.js +50 -50
  18. package/src/app-builder/support-template/manifest.json +55 -55
  19. package/src/app-builder/support-template/support-preview.html +56 -56
  20. package/src/app-builder/support-template/support-preview.js +37 -37
  21. package/src/app-builder/support-template/support-preview.mjs +67 -67
  22. package/src/app-builder/support-template/support-workflow.mjs +36 -36
  23. package/src/app-builder/use.js +37 -37
  24. package/src/app-builder/validate.js +31 -21
  25. package/src/app-builder/value-schema.js +37 -37
  26. package/src/catalog.js +147 -147
  27. package/src/coding/catalog.js +56 -56
  28. package/src/coding/cloud-catalog.js +64 -64
  29. package/src/coding/detect-stack.mjs +110 -110
  30. package/src/coding/export.js +133 -133
  31. package/src/coding/setup.js +175 -175
  32. package/src/coding/skills/lyra-android/SKILL.md +37 -37
  33. package/src/coding/skills/lyra-angular/SKILL.md +37 -37
  34. package/src/coding/skills/lyra-cucumber/SKILL.md +37 -37
  35. package/src/coding/skills/lyra-dbt/SKILL.md +37 -37
  36. package/src/coding/skills/lyra-django/SKILL.md +37 -37
  37. package/src/coding/skills/lyra-docker/SKILL.md +37 -37
  38. package/src/coding/skills/lyra-dotnet/SKILL.md +37 -37
  39. package/src/coding/skills/lyra-express/SKILL.md +37 -37
  40. package/src/coding/skills/lyra-fastapi/SKILL.md +37 -37
  41. package/src/coding/skills/lyra-flutter/SKILL.md +37 -37
  42. package/src/coding/skills/lyra-github-actions/SKILL.md +37 -37
  43. package/src/coding/skills/lyra-gitlab-ci/SKILL.md +37 -37
  44. package/src/coding/skills/lyra-go/SKILL.md +37 -37
  45. package/src/coding/skills/lyra-ios/SKILL.md +37 -37
  46. package/src/coding/skills/lyra-kubernetes/SKILL.md +37 -37
  47. package/src/coding/skills/lyra-mongodb/SKILL.md +37 -37
  48. package/src/coding/skills/lyra-mysql/SKILL.md +37 -37
  49. package/src/coding/skills/lyra-nextjs/SKILL.md +37 -37
  50. package/src/coding/skills/lyra-node/SKILL.md +37 -37
  51. package/src/coding/skills/lyra-playwright/SKILL.md +37 -37
  52. package/src/coding/skills/lyra-postgresql/SKILL.md +37 -37
  53. package/src/coding/skills/lyra-python/SKILL.md +37 -37
  54. package/src/coding/skills/lyra-react/SKILL.md +37 -37
  55. package/src/coding/skills/lyra-react-native/SKILL.md +37 -37
  56. package/src/coding/skills/lyra-redis/SKILL.md +37 -37
  57. package/src/coding/skills/lyra-rust/SKILL.md +37 -37
  58. package/src/coding/skills/lyra-spark/SKILL.md +37 -37
  59. package/src/coding/skills/lyra-spring-boot/SKILL.md +37 -37
  60. package/src/coding/skills/lyra-svelte/SKILL.md +37 -37
  61. package/src/coding/skills/lyra-terraform/SKILL.md +37 -37
  62. package/src/coding/skills/lyra-typescript/SKILL.md +37 -37
  63. package/src/coding/skills/lyra-vue/SKILL.md +37 -37
  64. package/src/framework/agent.js +181 -181
  65. package/src/framework/mda.js +65 -65
  66. package/src/framework/run.py +111 -111
  67. package/src/gated/hostedAgents.js +56 -56
  68. package/src/gated/index.d.ts +25 -25
  69. package/src/gated/index.js +5 -5
  70. package/src/index.d.ts +2 -2
  71. package/src/index.js +2 -2
  72. package/src/init.js +960 -960
  73. package/src/intelligence/graphsnip-provider.d.ts +5 -5
  74. package/src/intelligence/graphsnip-provider.js +57 -57
  75. package/src/intelligence/lifecycle.js +25 -25
  76. package/src/memory/LICENSE +21 -21
  77. package/src/memory/README.md +5 -5
  78. package/src/memory/UPSTREAM.json +24 -24
  79. package/src/memory/bridge-cli.js +16 -16
  80. package/src/memory/bridge.js +18 -18
  81. package/src/memory/cli.js +21 -21
  82. package/src/memory/cloud-sync-actions.js +61 -61
  83. package/src/memory/contract.json +45 -45
  84. package/src/memory/index.d.ts +50 -50
  85. package/src/memory/index.js +7 -7
  86. package/src/memory/lifecycle.js +29 -29
  87. package/src/memory/local-cli.js +34 -34
  88. package/src/memory/local-store.js +209 -209
  89. package/src/memory/package.json +33 -33
  90. package/src/memory/proposals.js +90 -90
  91. package/src/memory/skills-cli.js +26 -26
  92. package/src/memory/standalone.d.ts +50 -50
  93. package/src/memory/standalone.js +1 -1
  94. package/src/memory/sync.js +89 -89
  95. package/src/memory/validation.js +25 -25
  96. package/src/onboardingAgents.js +532 -532
  97. package/src/promptTemplates.js +178 -178
  98. package/src/resource-files.js +18 -18
  99. package/src/runtime/contracts.d.ts +47 -47
  100. package/src/runtime/local-cli.js +161 -161
  101. package/src/runtime/mcp-stdio.js +111 -111
  102. package/src/runtime/orchestration.js +59 -59
  103. package/src/runtime/run-agent.js +54 -54
  104. package/src/standalone/index.d.ts +45 -45
  105. package/src/standalone/index.js +13 -13
  106. package/src/standalone/init.js +12 -12
  107. package/src/standalone/orchestration.js +6 -6
  108. package/src/standalone/rag.js +113 -113
  109. package/src/studio/agent-ui.css +43 -43
  110. package/src/studio/agent-ui.js +32 -32
  111. package/src/studio/browser.js +542 -345
  112. package/src/studio/export.js +83 -86
  113. package/src/studio/index.html +74 -37
  114. package/src/studio/memory-actions.js +37 -37
  115. package/src/studio/memory-panel.js +200 -200
  116. package/src/studio/project.js +308 -240
  117. package/src/studio/pull-agent.js +72 -72
  118. package/src/studio/push.js +54 -54
  119. package/src/studio/python-agent.js +47 -47
  120. package/src/studio/python-agent.py +25 -25
  121. package/src/studio/server.js +164 -150
  122. package/src/studio/session.js +83 -83
  123. package/src/studio/studio.css +257 -10
  124. package/src/studio/sync.js +42 -42
  125. package/src/studio/workflow-editor.js +240 -0
  126. package/src/studio/workflow-sync.js +229 -157
@@ -1,67 +1,67 @@
1
- import { readFile } from "node:fs/promises";
2
- import { createServer } from "node:http";
3
- import { createSupportWorkflow } from "./support-workflow.mjs";
4
-
5
- export async function startSupportPreview(manifest, { port = Number(process.env.LYRA_PREVIEW_PORT ?? "4173") } = {}) {
6
- const runSupportTicket = createSupportWorkflow(manifest);
7
-
8
- const host = "127.0.0.1";
9
- if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error("Invalid preview port.");
10
-
11
- const title = manifest.application.name.replace(/[&<>"']/g, (character) =>
12
- ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[character]);
13
- const html = (await readFile(new URL("./support-preview.html", import.meta.url), "utf8"))
14
- .replaceAll("__LYRA_APP_TITLE__", () => title);
15
- const script = await readFile(new URL("./support-preview.js", import.meta.url));
16
- const server = createServer(async (req, res) => {
17
- const send = (status, type, body) => {
18
- res.writeHead(status, {
19
- "Content-Type": type,
20
- "Cache-Control": "no-store",
21
- "X-Content-Type-Options": "nosniff",
22
- "Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'unsafe-inline'; connect-src 'self'; frame-ancestors 'none'",
23
- });
24
- res.end(body);
25
- };
26
- const json = (status, data) => send(status, "application/json; charset=utf-8", JSON.stringify(data));
27
- const authority = `${host}:${server.address().port}`;
28
- if (req.headers.host !== authority) return json(403, { error: "Use the loopback preview address." });
29
- if (req.method === "GET" && req.url === "/") return send(200, "text/html; charset=utf-8", html);
30
- if (req.method === "GET" && req.url === "/preview.js") return send(200, "text/javascript; charset=utf-8", script);
31
- if (req.method !== "POST" || req.url !== "/api/ticket") return json(404, { error: "Route not found." });
32
- if (req.headers.origin !== `http://${authority}`) return json(403, { error: "Request must come from the preview." });
33
- if (req.headers["content-type"]?.split(";")[0] !== "application/json") {
34
- return json(415, { error: "Expected a JSON ticket." });
35
- }
36
- let size = 0;
37
- const chunks = [];
38
- try {
39
- for await (const chunk of req) {
40
- size += chunk.length;
41
- if (size > 16384) {
42
- json(413, { error: "Ticket request is too large." });
43
- return;
44
- }
45
- chunks.push(chunk);
46
- }
47
- } catch {
48
- return;
49
- }
50
- let ticket;
51
- try {
52
- ({ ticket } = JSON.parse(Buffer.concat(chunks).toString("utf8")));
53
- } catch {
54
- return json(400, { error: "Invalid JSON ticket." });
55
- }
56
- if (typeof ticket !== "string" || !ticket.trim() || ticket.length > 2000) {
57
- return json(400, { error: "Enter a ticket between 1 and 2,000 characters." });
58
- }
59
- try {
60
- return json(200, await runSupportTicket(ticket));
61
- } catch {
62
- return json(500, { error: "The support workflow could not produce a draft." });
63
- }
64
- });
65
- server.requestTimeout = 10000;
66
- server.listen(port, host, () => console.log(`Support preview: http://${host}:${server.address().port}/`));
67
- }
1
+ import { readFile } from "node:fs/promises";
2
+ import { createServer } from "node:http";
3
+ import { createSupportWorkflow } from "./support-workflow.mjs";
4
+
5
+ export async function startSupportPreview(manifest, { port = Number(process.env.LYRA_PREVIEW_PORT ?? "4173") } = {}) {
6
+ const runSupportTicket = createSupportWorkflow(manifest);
7
+
8
+ const host = "127.0.0.1";
9
+ if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error("Invalid preview port.");
10
+
11
+ const title = manifest.application.name.replace(/[&<>"']/g, (character) =>
12
+ ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[character]);
13
+ const html = (await readFile(new URL("./support-preview.html", import.meta.url), "utf8"))
14
+ .replaceAll("__LYRA_APP_TITLE__", () => title);
15
+ const script = await readFile(new URL("./support-preview.js", import.meta.url));
16
+ const server = createServer(async (req, res) => {
17
+ const send = (status, type, body) => {
18
+ res.writeHead(status, {
19
+ "Content-Type": type,
20
+ "Cache-Control": "no-store",
21
+ "X-Content-Type-Options": "nosniff",
22
+ "Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'unsafe-inline'; connect-src 'self'; frame-ancestors 'none'",
23
+ });
24
+ res.end(body);
25
+ };
26
+ const json = (status, data) => send(status, "application/json; charset=utf-8", JSON.stringify(data));
27
+ const authority = `${host}:${server.address().port}`;
28
+ if (req.headers.host !== authority) return json(403, { error: "Use the loopback preview address." });
29
+ if (req.method === "GET" && req.url === "/") return send(200, "text/html; charset=utf-8", html);
30
+ if (req.method === "GET" && req.url === "/preview.js") return send(200, "text/javascript; charset=utf-8", script);
31
+ if (req.method !== "POST" || req.url !== "/api/ticket") return json(404, { error: "Route not found." });
32
+ if (req.headers.origin !== `http://${authority}`) return json(403, { error: "Request must come from the preview." });
33
+ if (req.headers["content-type"]?.split(";")[0] !== "application/json") {
34
+ return json(415, { error: "Expected a JSON ticket." });
35
+ }
36
+ let size = 0;
37
+ const chunks = [];
38
+ try {
39
+ for await (const chunk of req) {
40
+ size += chunk.length;
41
+ if (size > 16384) {
42
+ json(413, { error: "Ticket request is too large." });
43
+ return;
44
+ }
45
+ chunks.push(chunk);
46
+ }
47
+ } catch {
48
+ return;
49
+ }
50
+ let ticket;
51
+ try {
52
+ ({ ticket } = JSON.parse(Buffer.concat(chunks).toString("utf8")));
53
+ } catch {
54
+ return json(400, { error: "Invalid JSON ticket." });
55
+ }
56
+ if (typeof ticket !== "string" || !ticket.trim() || ticket.length > 2000) {
57
+ return json(400, { error: "Enter a ticket between 1 and 2,000 characters." });
58
+ }
59
+ try {
60
+ return json(200, await runSupportTicket(ticket));
61
+ } catch {
62
+ return json(500, { error: "The support workflow could not produce a draft." });
63
+ }
64
+ });
65
+ server.requestTimeout = 10000;
66
+ server.listen(port, host, () => console.log(`Support preview: http://${host}:${server.address().port}/`));
67
+ }
@@ -1,36 +1,36 @@
1
- import { createCapabilityGateway } from "../gateway.js";
2
- import { createNativeAdapter } from "../native-adapter.js";
3
-
4
- export function createSupportWorkflow(manifest) {
5
- const { classifyAction, draftAction } = manifest.preview;
6
- const draftCapabilityId = manifest.actions.find(({ id }) => id === draftAction).capabilityId;
7
- return async function runSupportTicket(ticket) {
8
- const events = [];
9
- const gateway = createCapabilityGateway(manifest, [
10
- {
11
- id: "mock",
12
- contractVersion: "1.0",
13
- async invoke({ input }) {
14
- return { status: "completed", output: { category: /invoice|refund|charge/i.test(input) ? "billing" : "general" } };
15
- },
16
- },
17
- createNativeAdapter({
18
- agents: [[draftCapabilityId, { model: "demo-fixture" }]],
19
- provider: {
20
- async complete({ messages }) {
21
- return { text: `Thanks for contacting support. Your ticket is categorized as ${messages.at(-1).content} and is ready for review.` };
22
- },
23
- },
24
- store: { append: async (event) => events.push(event) },
25
- }),
26
- ]);
27
-
28
- const classified = await gateway.invokeAction(classifyAction, ticket);
29
- if (classified.status !== "completed") throw new Error(classified.error.message);
30
- const reply = await gateway.invokeAction(draftAction, classified.output.category, { correlationId: classified.correlationId });
31
- if (reply.status !== "completed") throw new Error(reply.error.message);
32
- return { category: classified.output.category, draft: reply.output,
33
- correlationId: reply.correlationId, nativeExecutionId: reply.nativeExecutionId,
34
- events: events.map(({ type }) => type) };
35
- }
36
- }
1
+ import { createCapabilityGateway } from "../gateway.js";
2
+ import { createNativeAdapter } from "../native-adapter.js";
3
+
4
+ export function createSupportWorkflow(manifest) {
5
+ const { classifyAction, draftAction } = manifest.preview;
6
+ const draftCapabilityId = manifest.actions.find(({ id }) => id === draftAction).capabilityId;
7
+ return async function runSupportTicket(ticket) {
8
+ const events = [];
9
+ const gateway = createCapabilityGateway(manifest, [
10
+ {
11
+ id: "mock",
12
+ contractVersion: "1.0",
13
+ async invoke({ input }) {
14
+ return { status: "completed", output: { category: /invoice|refund|charge/i.test(input) ? "billing" : "general" } };
15
+ },
16
+ },
17
+ createNativeAdapter({
18
+ agents: [[draftCapabilityId, { model: "demo-fixture" }]],
19
+ provider: {
20
+ async complete({ messages }) {
21
+ return { text: `Thanks for contacting support. Your ticket is categorized as ${messages.at(-1).content} and is ready for review.` };
22
+ },
23
+ },
24
+ store: { append: async (event) => events.push(event) },
25
+ }),
26
+ ]);
27
+
28
+ const classified = await gateway.invokeAction(classifyAction, ticket);
29
+ if (classified.status !== "completed") throw new Error(classified.error.message);
30
+ const reply = await gateway.invokeAction(draftAction, classified.output.category, { correlationId: classified.correlationId });
31
+ if (reply.status !== "completed") throw new Error(reply.error.message);
32
+ return { category: classified.output.category, draft: reply.output,
33
+ correlationId: reply.correlationId, nativeExecutionId: reply.nativeExecutionId,
34
+ events: events.map(({ type }) => type) };
35
+ }
36
+ }
@@ -1,37 +1,37 @@
1
- import { lstat, mkdir, writeFile } from "node:fs/promises";
2
- import { dirname, resolve } from "node:path";
3
- import { projectSupportManifest } from "./support-manifest.js";
4
-
5
- export async function runAppUse(args, {
6
- output = process.stdout, token = process.env.LYRA_SESSION_TOKEN, fetchRequest = globalThis.fetch,
7
- } = {}) {
8
- if (args.length === 1 && args[0] === "--help") {
9
- output.write("Usage: agent-lyra app use <listing-id> [new-manifest.json]\n");
10
- return;
11
- }
12
- if (!/^[a-f0-9]{24}$/i.test(args[0] ?? "") || args.length > 2 || args[1]?.startsWith("-")) {
13
- throw new Error("Provide a Marketplace listing ID and an optional new manifest path.");
14
- }
15
- if (!token) throw new Error("Sign in to use an app. Set LYRA_SESSION_TOKEN to a valid cloud session token.");
16
- const target = resolve(args[1] ?? ".lyra/app/manifest.json");
17
- try {
18
- await lstat(target);
19
- throw new Error("Manifest already exists. Choose a new path.");
20
- } catch (error) {
21
- if (error.code !== "ENOENT") throw error;
22
- }
23
- const response = await fetchRequest(`https://api.agentlyra.in/api/app-marketplace/apps/${args[0]}/use`, {
24
- method: "POST",
25
- headers: { Authorization: `Bearer ${token}` },
26
- redirect: "error",
27
- signal: AbortSignal.timeout(15000),
28
- });
29
- if (response.status === 401 || response.status === 403) throw new Error("Cloud session expired or is invalid.");
30
- if (!response.ok) throw new Error(`Marketplace import failed (HTTP ${response.status}).`);
31
- const { listing } = await response.json();
32
- if (listing?.listingSchemaVersion !== "1.0") throw new Error("Unsupported Marketplace listing.");
33
- const manifest = projectSupportManifest(listing.manifest);
34
- await mkdir(dirname(target), { recursive: true });
35
- await writeFile(target, JSON.stringify(manifest, null, 2) + "\n", { flag: "wx" });
36
- output.write(`Imported ${manifest.application.name} to ${target}\n`);
37
- }
1
+ import { lstat, mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname, resolve } from "node:path";
3
+ import { projectSupportManifest } from "./support-manifest.js";
4
+
5
+ export async function runAppUse(args, {
6
+ output = process.stdout, token = process.env.LYRA_SESSION_TOKEN, fetchRequest = globalThis.fetch,
7
+ } = {}) {
8
+ if (args.length === 1 && args[0] === "--help") {
9
+ output.write("Usage: agent-lyra app use <listing-id> [new-manifest.json]\n");
10
+ return;
11
+ }
12
+ if (!/^[a-f0-9]{24}$/i.test(args[0] ?? "") || args.length > 2 || args[1]?.startsWith("-")) {
13
+ throw new Error("Provide a Marketplace listing ID and an optional new manifest path.");
14
+ }
15
+ if (!token) throw new Error("Sign in to use an app. Set LYRA_SESSION_TOKEN to a valid cloud session token.");
16
+ const target = resolve(args[1] ?? ".lyra/app/manifest.json");
17
+ try {
18
+ await lstat(target);
19
+ throw new Error("Manifest already exists. Choose a new path.");
20
+ } catch (error) {
21
+ if (error.code !== "ENOENT") throw error;
22
+ }
23
+ const response = await fetchRequest(`https://api.agentlyra.in/api/app-marketplace/apps/${args[0]}/use`, {
24
+ method: "POST",
25
+ headers: { Authorization: `Bearer ${token}` },
26
+ redirect: "error",
27
+ signal: AbortSignal.timeout(15000),
28
+ });
29
+ if (response.status === 401 || response.status === 403) throw new Error("Cloud session expired or is invalid.");
30
+ if (!response.ok) throw new Error(`Marketplace import failed (HTTP ${response.status}).`);
31
+ const { listing } = await response.json();
32
+ if (listing?.listingSchemaVersion !== "1.0") throw new Error("Unsupported Marketplace listing.");
33
+ const manifest = projectSupportManifest(listing.manifest);
34
+ await mkdir(dirname(target), { recursive: true });
35
+ await writeFile(target, JSON.stringify(manifest, null, 2) + "\n", { flag: "wx" });
36
+ output.write(`Imported ${manifest.application.name} to ${target}\n`);
37
+ }
@@ -1,21 +1,31 @@
1
- import { readAppManifest, SAVED_VERSION, validateSavedApp } from "./saved-app.js";
2
- import { validateAppManifest } from "./manifest-contract.js";
3
- export { validateAppManifest } from "./manifest-contract.js";
4
-
5
- export async function runAppValidation(args, output = process.stdout) {
6
- if (args.length === 1 && args[0] === "--help") {
7
- output.write("Usage: agent-lyra app validate <manifest.json>\n");
8
- return;
9
- }
10
- if (args.length !== 1 || args[0].startsWith("-")) {
11
- throw new Error("Provide a manifest path. See agent-lyra app validate --help.");
12
- }
13
- const manifest = await readAppManifest(args[0]);
14
- if (manifest?.version === SAVED_VERSION) {
15
- validateSavedApp(manifest);
16
- output.write("Valid app " + manifest.application.id + " (2 saved agents).\n");
17
- return;
18
- }
19
- const { id, capabilityCount, actionCount } = validateAppManifest(manifest);
20
- output.write(`Valid app ${id} (${capabilityCount} capabilities, ${actionCount} actions).\n`);
21
- }
1
+ import { readAppManifest, SAVED_VERSION, validateSavedApp } from "./saved-app.js";
2
+ import { validateAppManifest } from "./manifest-contract.js";
3
+ export { validateAppManifest } from "./manifest-contract.js";
4
+
5
+ export async function runAppValidation(args, output = process.stdout) {
6
+ if (args.length === 1 && args[0] === "--help") {
7
+ output.write("Usage: agent-lyra app validate <manifest.json>\n");
8
+ return;
9
+ }
10
+ if (args.length !== 1 || args[0].startsWith("-")) {
11
+ throw new Error("Provide a manifest path. See agent-lyra app validate --help.");
12
+ }
13
+ const manifest = await readAppManifest(args[0]);
14
+ if (["1.0", "2.0", "3.0"].includes(manifest?.version) && manifest.studio) {
15
+ const { id, name } = manifest.application ?? {};
16
+ if (typeof id !== "string" || typeof name !== "string" || !id.trim() || !name.trim()) {
17
+ throw new Error("Visual apps require an application ID and name.");
18
+ }
19
+ const { validateLayout } = await import("../studio/project.js");
20
+ const components = validateLayout(manifest.studio.layout);
21
+ output.write("Valid visual app " + id + " (" + components.length + " components).\n");
22
+ return;
23
+ }
24
+ if (manifest?.version === SAVED_VERSION) {
25
+ validateSavedApp(manifest);
26
+ output.write("Valid app " + manifest.application.id + " (2 saved agents).\n");
27
+ return;
28
+ }
29
+ const { id, capabilityCount, actionCount } = validateAppManifest(manifest);
30
+ output.write(`Valid app ${id} (${capabilityCount} capabilities, ${actionCount} actions).\n`);
31
+ }
@@ -1,37 +1,37 @@
1
- const scalarTypes = new Set(["string", "boolean", "number", "integer", "null"]);
2
- const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
3
-
4
- function isScalarSchema(schema) {
5
- return isObject(schema) && scalarTypes.has(schema.type) && Object.keys(schema).length === 1;
6
- }
7
-
8
- export function assertValueSchema(schema, label) {
9
- if (isScalarSchema(schema)) return;
10
- if (!isObject(schema) || schema.type !== "object" || !isObject(schema.properties) ||
11
- Object.keys(schema).some((key) => !["type", "properties", "required", "additionalProperties"].includes(key)) ||
12
- (schema.additionalProperties !== undefined && typeof schema.additionalProperties !== "boolean") ||
13
- !Object.values(schema.properties).every(isScalarSchema)) {
14
- throw new Error(`${label} must be a scalar schema or a flat object schema with scalar properties.`);
15
- }
16
- if (schema.required !== undefined &&
17
- (!Array.isArray(schema.required) || new Set(schema.required).size !== schema.required.length ||
18
- schema.required.some((key) => typeof key !== "string" || !Object.hasOwn(schema.properties, key)))) {
19
- throw new Error(`${label} required entries must be unique declared properties.`);
20
- }
21
- }
22
-
23
- function matchesScalar(value, type) {
24
- if (type === "null") return value === null;
25
- if (type === "integer") return Number.isInteger(value);
26
- if (type === "number") return Number.isFinite(value);
27
- return typeof value === type;
28
- }
29
-
30
- export function matchesValueSchema(value, schema) {
31
- if (schema.type !== "object") return matchesScalar(value, schema.type);
32
- if (!isObject(value) || (schema.required ?? []).some((key) => !Object.hasOwn(value, key))) return false;
33
- return Object.entries(value).every(([key, entry]) =>
34
- Object.hasOwn(schema.properties, key)
35
- ? matchesScalar(entry, schema.properties[key].type)
36
- : schema.additionalProperties !== false);
37
- }
1
+ const scalarTypes = new Set(["string", "boolean", "number", "integer", "null"]);
2
+ const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
3
+
4
+ function isScalarSchema(schema) {
5
+ return isObject(schema) && scalarTypes.has(schema.type) && Object.keys(schema).length === 1;
6
+ }
7
+
8
+ export function assertValueSchema(schema, label) {
9
+ if (isScalarSchema(schema)) return;
10
+ if (!isObject(schema) || schema.type !== "object" || !isObject(schema.properties) ||
11
+ Object.keys(schema).some((key) => !["type", "properties", "required", "additionalProperties"].includes(key)) ||
12
+ (schema.additionalProperties !== undefined && typeof schema.additionalProperties !== "boolean") ||
13
+ !Object.values(schema.properties).every(isScalarSchema)) {
14
+ throw new Error(`${label} must be a scalar schema or a flat object schema with scalar properties.`);
15
+ }
16
+ if (schema.required !== undefined &&
17
+ (!Array.isArray(schema.required) || new Set(schema.required).size !== schema.required.length ||
18
+ schema.required.some((key) => typeof key !== "string" || !Object.hasOwn(schema.properties, key)))) {
19
+ throw new Error(`${label} required entries must be unique declared properties.`);
20
+ }
21
+ }
22
+
23
+ function matchesScalar(value, type) {
24
+ if (type === "null") return value === null;
25
+ if (type === "integer") return Number.isInteger(value);
26
+ if (type === "number") return Number.isFinite(value);
27
+ return typeof value === type;
28
+ }
29
+
30
+ export function matchesValueSchema(value, schema) {
31
+ if (schema.type !== "object") return matchesScalar(value, schema.type);
32
+ if (!isObject(value) || (schema.required ?? []).some((key) => !Object.hasOwn(value, key))) return false;
33
+ return Object.entries(value).every(([key, entry]) =>
34
+ Object.hasOwn(schema.properties, key)
35
+ ? matchesScalar(entry, schema.properties[key].type)
36
+ : schema.additionalProperties !== false);
37
+ }