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,111 +1,111 @@
1
- """Run a registered Python agent and emit a bounded JSON response to Studio."""
2
- import asyncio
3
- import importlib.util
4
- import inspect
5
- import json
6
- from contextlib import redirect_stdout
7
- from pathlib import Path
8
- import runpy
9
- import sys
10
-
11
-
12
- async def invoke_langchain(target, prompt, trace_id):
13
- result = await target.ainvoke(
14
- {"messages": [{"role": "user", "content": prompt}]},
15
- config={"metadata": {"lyra_trace_id": trace_id}},
16
- )
17
- if isinstance(result, dict) and result.get("messages"):
18
- result = result["messages"][-1]
19
- if getattr(result, "type", None) == "human" or (isinstance(result, dict) and result.get("role") == "user"):
20
- raise InvalidOutput("The agent did not return a reply.")
21
- if isinstance(result, dict) and isinstance(result.get("content"), str):
22
- result = result["content"]
23
- elif hasattr(result, "content"):
24
- result = result.content
25
- if not isinstance(result, str):
26
- raise InvalidOutput("Expected a text response.")
27
- return result
28
-
29
-
30
- async def invoke_adk(target, prompt, trace_id):
31
- from google.adk.runners import InMemoryRunner
32
- from google.genai import types
33
-
34
- runner = InMemoryRunner(agent=target, app_name="lyra")
35
- try:
36
- session = await runner.session_service.create_session(
37
- app_name=runner.app_name, user_id="lyra-local", session_id=trace_id
38
- )
39
- chunks = []
40
- length = 0
41
- async for event in runner.run_async(
42
- user_id=session.user_id,
43
- session_id=session.id,
44
- new_message=types.Content(role="user", parts=[types.Part(text=prompt)]),
45
- ):
46
- if event.is_final_response() and event.content:
47
- for part in event.content.parts or []:
48
- if part.text and not part.thought:
49
- length += len(part.text)
50
- if length > 65536:
51
- raise InvalidOutput
52
- chunks.append(part.text)
53
- return "\n".join(chunks)
54
- finally:
55
- await runner.close()
56
-
57
-
58
- async def invoke_openai(target, prompt, trace_id):
59
- from agents import RunConfig, Runner
60
-
61
- config = RunConfig(trace_include_sensitive_data=False, trace_metadata={"lyra_trace_id": trace_id})
62
- return (await Runner.run(target, prompt, run_config=config)).final_output
63
-
64
-
65
- async def invoke_custom(target, payload, trace_id):
66
- result = target(payload, {"trace_id": trace_id})
67
- return await result if inspect.isawaitable(result) else result
68
-
69
-
70
- class InvalidOutput(ValueError):
71
- pass
72
-
73
-
74
- adapters = {
75
- "langchain": invoke_langchain,
76
- "langgraph": invoke_langchain,
77
- "google-adk": invoke_adk,
78
- "openai-agents": invoke_openai,
79
- "custom": invoke_custom,
80
- }
81
-
82
-
83
- def main():
84
- file, symbol, trace_id, framework, output_kind = sys.argv[1:]
85
- payload = json.load(sys.stdin)
86
- sys.path.insert(0, str(Path.cwd()))
87
- with redirect_stdout(sys.stderr):
88
- root = Path.cwd()
89
- module = ".".join(Path(file).relative_to(root).with_suffix("").parts)
90
- spec = importlib.util.find_spec(module)
91
- if not spec or not spec.origin or Path(spec.origin).resolve() != Path(file).resolve():
92
- raise ImportError("The Python module does not match the registered file.")
93
- target = runpy.run_module(module)[symbol]
94
- reply = asyncio.run(adapters[framework](target, payload["input"], trace_id))
95
- if output_kind == "json":
96
- try:
97
- reply = json.dumps(reply, ensure_ascii=False, allow_nan=False)
98
- except (TypeError, ValueError, OverflowError) as error:
99
- raise InvalidOutput("Expected serializable JSON.") from error
100
- if not isinstance(reply, str) or not reply.strip() or len(reply) > 65536:
101
- raise InvalidOutput("Expected a bounded, nonempty reply.")
102
- print(json.dumps({"output": reply}, ensure_ascii=True))
103
-
104
-
105
- if __name__ == "__main__":
106
- try:
107
- main()
108
- except ModuleNotFoundError:
109
- sys.exit(20)
110
- except InvalidOutput:
111
- sys.exit(21)
1
+ """Run a registered Python agent and emit a bounded JSON response to Studio."""
2
+ import asyncio
3
+ import importlib.util
4
+ import inspect
5
+ import json
6
+ from contextlib import redirect_stdout
7
+ from pathlib import Path
8
+ import runpy
9
+ import sys
10
+
11
+
12
+ async def invoke_langchain(target, prompt, trace_id):
13
+ result = await target.ainvoke(
14
+ {"messages": [{"role": "user", "content": prompt}]},
15
+ config={"metadata": {"lyra_trace_id": trace_id}},
16
+ )
17
+ if isinstance(result, dict) and result.get("messages"):
18
+ result = result["messages"][-1]
19
+ if getattr(result, "type", None) == "human" or (isinstance(result, dict) and result.get("role") == "user"):
20
+ raise InvalidOutput("The agent did not return a reply.")
21
+ if isinstance(result, dict) and isinstance(result.get("content"), str):
22
+ result = result["content"]
23
+ elif hasattr(result, "content"):
24
+ result = result.content
25
+ if not isinstance(result, str):
26
+ raise InvalidOutput("Expected a text response.")
27
+ return result
28
+
29
+
30
+ async def invoke_adk(target, prompt, trace_id):
31
+ from google.adk.runners import InMemoryRunner
32
+ from google.genai import types
33
+
34
+ runner = InMemoryRunner(agent=target, app_name="lyra")
35
+ try:
36
+ session = await runner.session_service.create_session(
37
+ app_name=runner.app_name, user_id="lyra-local", session_id=trace_id
38
+ )
39
+ chunks = []
40
+ length = 0
41
+ async for event in runner.run_async(
42
+ user_id=session.user_id,
43
+ session_id=session.id,
44
+ new_message=types.Content(role="user", parts=[types.Part(text=prompt)]),
45
+ ):
46
+ if event.is_final_response() and event.content:
47
+ for part in event.content.parts or []:
48
+ if part.text and not part.thought:
49
+ length += len(part.text)
50
+ if length > 65536:
51
+ raise InvalidOutput
52
+ chunks.append(part.text)
53
+ return "\n".join(chunks)
54
+ finally:
55
+ await runner.close()
56
+
57
+
58
+ async def invoke_openai(target, prompt, trace_id):
59
+ from agents import RunConfig, Runner
60
+
61
+ config = RunConfig(trace_include_sensitive_data=False, trace_metadata={"lyra_trace_id": trace_id})
62
+ return (await Runner.run(target, prompt, run_config=config)).final_output
63
+
64
+
65
+ async def invoke_custom(target, payload, trace_id):
66
+ result = target(payload, {"trace_id": trace_id})
67
+ return await result if inspect.isawaitable(result) else result
68
+
69
+
70
+ class InvalidOutput(ValueError):
71
+ pass
72
+
73
+
74
+ adapters = {
75
+ "langchain": invoke_langchain,
76
+ "langgraph": invoke_langchain,
77
+ "google-adk": invoke_adk,
78
+ "openai-agents": invoke_openai,
79
+ "custom": invoke_custom,
80
+ }
81
+
82
+
83
+ def main():
84
+ file, symbol, trace_id, framework, output_kind = sys.argv[1:]
85
+ payload = json.load(sys.stdin)
86
+ sys.path.insert(0, str(Path.cwd()))
87
+ with redirect_stdout(sys.stderr):
88
+ root = Path.cwd()
89
+ module = ".".join(Path(file).relative_to(root).with_suffix("").parts)
90
+ spec = importlib.util.find_spec(module)
91
+ if not spec or not spec.origin or Path(spec.origin).resolve() != Path(file).resolve():
92
+ raise ImportError("The Python module does not match the registered file.")
93
+ target = runpy.run_module(module)[symbol]
94
+ reply = asyncio.run(adapters[framework](target, payload["input"], trace_id))
95
+ if output_kind == "json":
96
+ try:
97
+ reply = json.dumps(reply, ensure_ascii=False, allow_nan=False)
98
+ except (TypeError, ValueError, OverflowError) as error:
99
+ raise InvalidOutput("Expected serializable JSON.") from error
100
+ if not isinstance(reply, str) or not reply.strip() or len(reply) > 65536:
101
+ raise InvalidOutput("Expected a bounded, nonempty reply.")
102
+ print(json.dumps({"output": reply}, ensure_ascii=True))
103
+
104
+
105
+ if __name__ == "__main__":
106
+ try:
107
+ main()
108
+ except ModuleNotFoundError:
109
+ sys.exit(20)
110
+ except InvalidOutput:
111
+ sys.exit(21)
@@ -1,56 +1,56 @@
1
- export const LYRA_VERTICALS = [
2
- "hr",
3
- "sales",
4
- "support",
5
- "finance",
6
- "coding",
7
- "legal",
8
- "news",
9
- "markets",
10
- ];
11
-
12
- const DEFAULT_BASE_URL = "https://api.lyra.ai/v1";
13
-
14
- export class HostedAgentClient {
15
- constructor({ apiKey, baseUrl = DEFAULT_BASE_URL, fetchImpl = fetch } = {}) {
16
- if (!apiKey || typeof apiKey !== "string") {
17
- throw new Error("A Lyra API key is required for gated features.");
18
- }
19
- if (typeof fetchImpl !== "function") {
20
- throw new Error("fetchImpl must be a function.");
21
- }
22
-
23
- this.apiKey = apiKey;
24
- this.baseUrl = baseUrl;
25
- this.fetchImpl = fetchImpl;
26
- }
27
-
28
- listVerticals() {
29
- return [...LYRA_VERTICALS];
30
- }
31
-
32
- async invoke(vertical, payload = {}) {
33
- if (!LYRA_VERTICALS.includes(vertical)) {
34
- throw new Error(`Unsupported vertical: ${vertical}`);
35
- }
36
-
37
- const response = await this.fetchImpl(`${this.baseUrl}/agents/${vertical}/invoke`, {
38
- method: "POST",
39
- headers: {
40
- "Content-Type": "application/json",
41
- Authorization: `Bearer ${this.apiKey}`,
42
- },
43
- body: JSON.stringify(payload),
44
- });
45
-
46
- if (!response.ok) {
47
- throw new Error(`Lyra API request failed with status ${response.status}.`);
48
- }
49
-
50
- return response.json();
51
- }
52
- }
53
-
54
- export function createHostedAgentClient(options) {
55
- return new HostedAgentClient(options);
56
- }
1
+ export const LYRA_VERTICALS = [
2
+ "hr",
3
+ "sales",
4
+ "support",
5
+ "finance",
6
+ "coding",
7
+ "legal",
8
+ "news",
9
+ "markets",
10
+ ];
11
+
12
+ const DEFAULT_BASE_URL = "https://api.lyra.ai/v1";
13
+
14
+ export class HostedAgentClient {
15
+ constructor({ apiKey, baseUrl = DEFAULT_BASE_URL, fetchImpl = fetch } = {}) {
16
+ if (!apiKey || typeof apiKey !== "string") {
17
+ throw new Error("A Lyra API key is required for gated features.");
18
+ }
19
+ if (typeof fetchImpl !== "function") {
20
+ throw new Error("fetchImpl must be a function.");
21
+ }
22
+
23
+ this.apiKey = apiKey;
24
+ this.baseUrl = baseUrl;
25
+ this.fetchImpl = fetchImpl;
26
+ }
27
+
28
+ listVerticals() {
29
+ return [...LYRA_VERTICALS];
30
+ }
31
+
32
+ async invoke(vertical, payload = {}) {
33
+ if (!LYRA_VERTICALS.includes(vertical)) {
34
+ throw new Error(`Unsupported vertical: ${vertical}`);
35
+ }
36
+
37
+ const response = await this.fetchImpl(`${this.baseUrl}/agents/${vertical}/invoke`, {
38
+ method: "POST",
39
+ headers: {
40
+ "Content-Type": "application/json",
41
+ Authorization: `Bearer ${this.apiKey}`,
42
+ },
43
+ body: JSON.stringify(payload),
44
+ });
45
+
46
+ if (!response.ok) {
47
+ throw new Error(`Lyra API request failed with status ${response.status}.`);
48
+ }
49
+
50
+ return response.json();
51
+ }
52
+ }
53
+
54
+ export function createHostedAgentClient(options) {
55
+ return new HostedAgentClient(options);
56
+ }
@@ -1,25 +1,25 @@
1
- export type LyraVertical = "hr" | "sales" | "support" | "finance" | "coding" | "legal" | "news" | "markets";
2
- export const LYRA_VERTICALS: LyraVertical[];
3
-
4
- export type HostedFetch = (url: string, options: {
5
- method: string;
6
- headers: Record<string, string>;
7
- body: string;
8
- }) => Promise<{ ok: boolean; status: number; json(): Promise<unknown> }>;
9
-
10
- export interface HostedAgentOptions {
11
- apiKey: string;
12
- baseUrl?: string;
13
- fetchImpl?: HostedFetch;
14
- }
15
-
16
- export class HostedAgentClient {
17
- constructor(options: HostedAgentOptions);
18
- apiKey: string;
19
- baseUrl: string;
20
- fetchImpl: HostedFetch;
21
- listVerticals(): LyraVertical[];
22
- invoke(vertical: LyraVertical, payload?: Record<string, unknown>): Promise<unknown>;
23
- }
24
-
25
- export function createHostedAgentClient(options: HostedAgentOptions): HostedAgentClient;
1
+ export type LyraVertical = "hr" | "sales" | "support" | "finance" | "coding" | "legal" | "news" | "markets";
2
+ export const LYRA_VERTICALS: LyraVertical[];
3
+
4
+ export type HostedFetch = (url: string, options: {
5
+ method: string;
6
+ headers: Record<string, string>;
7
+ body: string;
8
+ }) => Promise<{ ok: boolean; status: number; json(): Promise<unknown> }>;
9
+
10
+ export interface HostedAgentOptions {
11
+ apiKey: string;
12
+ baseUrl?: string;
13
+ fetchImpl?: HostedFetch;
14
+ }
15
+
16
+ export class HostedAgentClient {
17
+ constructor(options: HostedAgentOptions);
18
+ apiKey: string;
19
+ baseUrl: string;
20
+ fetchImpl: HostedFetch;
21
+ listVerticals(): LyraVertical[];
22
+ invoke(vertical: LyraVertical, payload?: Record<string, unknown>): Promise<unknown>;
23
+ }
24
+
25
+ export function createHostedAgentClient(options: HostedAgentOptions): HostedAgentClient;
@@ -1,5 +1,5 @@
1
- export {
2
- LYRA_VERTICALS,
3
- createHostedAgentClient,
4
- HostedAgentClient,
5
- } from "./hostedAgents.js";
1
+ export {
2
+ LYRA_VERTICALS,
3
+ createHostedAgentClient,
4
+ HostedAgentClient,
5
+ } from "./hostedAgents.js";
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * as standalone from "./standalone/index.js";
2
- export * as gated from "./gated/index.js";
1
+ export * as standalone from "./standalone/index.js";
2
+ export * as gated from "./gated/index.js";
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * as standalone from "./standalone/index.js";
2
- export * as gated from "./gated/index.js";
1
+ export * as standalone from "./standalone/index.js";
2
+ export * as gated from "./gated/index.js";