agent-lyra 0.11.2 → 0.13.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/README.md +58 -35
- package/bin/agent-lyra.js +4 -1
- package/bin/lyra-oss-preview.js +3 -1
- package/package.json +1 -1
- package/src/app-builder/init.js +3 -3
- package/src/framework/agent.js +19 -8
- package/src/framework/mda.js +5 -2
- package/src/framework/run.py +83 -11
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/init.js +13 -1
- package/src/intelligence/graph-setup.js +125 -0
- package/src/intelligence/lifecycle.js +4 -2
- package/src/memory/LICENSE +1 -1
- package/src/memory/UPSTREAM.json +6 -3
- package/src/memory/external-engine.js +35 -0
- package/src/memory/index.js +19 -1
- package/src/memory/lifecycle.js +2 -1
- package/src/runtime/programmatic.d.ts +84 -0
- package/src/runtime/programmatic.js +155 -0
- package/src/runtime/run-agent.js +10 -2
- package/src/standalone/init.js +4 -2
- package/src/studio/browser.js +219 -23
- package/src/studio/code-discovery.js +81 -0
- package/src/studio/export.js +8 -5
- package/src/studio/graphsnip-workbench.js +72 -0
- package/src/studio/history-panel.js +193 -0
- package/src/studio/ide-provider.js +65 -0
- package/src/studio/index.html +69 -10
- package/src/studio/intelligence.js +110 -0
- package/src/studio/local-provider.js +43 -0
- package/src/studio/memory-actions.js +28 -1
- package/src/studio/memory-panel.js +29 -5
- package/src/studio/mission-ui.css +52 -0
- package/src/studio/mission-ui.js +57 -0
- package/src/studio/programmatic-runner.mjs +21 -0
- package/src/studio/programmatic.js +54 -0
- package/src/studio/project.js +103 -25
- package/src/studio/python-agent.py +31 -4
- package/src/studio/run-history.js +128 -0
- package/src/studio/server.js +90 -10
- package/src/studio/session.js +1 -1
- package/src/studio/studio.css +128 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Build agent workflows, design apps, and set up coding assistants from your project.**
|
|
6
6
|
|
|
7
|
-
[Get started](#get-started) · [SDK](#sdk-library) · [Coding setup](#coding-setup) · [
|
|
7
|
+
[Get started](#get-started) · [SDK](#sdk-library) · [Coding setup](#coding-setup) · [Workbench](#lyra-workbench) · [App Builder](#lyra-app-builder) · [Memory](#project-memory-and-skill-proposals) · [Cloud](#agentlyra-cloud-and-marketplace)
|
|
8
8
|
|
|
9
9
|
[Documentation](https://agentlyra.in/docs) · [Website](https://agentlyra.in/) · [Cloud console](https://console.agentlyra.in/) · [GitHub](https://github.com/agentlyra-labs/agent-lyra-sdk) · [npm](https://www.npmjs.com/package/agent-lyra) · [PyPI](https://pypi.org/project/agent-lyra/)
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
| | What you get |
|
|
14
14
|
| --- | --- |
|
|
15
15
|
| **GitHub source edition** | MIT-licensed JavaScript workflow and retrieval primitives, local execution and run history, evidence-based memory, manifest validation, and [technology skill guides](https://github.com/agentlyra-labs/agent-lyra-sdk/tree/main/src/coding/skills). |
|
|
16
|
-
| **SDK from npm or PyPI** | Coding stack detection, agent and skill generation, assistant exports,
|
|
16
|
+
| **SDK from npm or PyPI** | Coding stack detection, agent and skill generation, assistant exports, Workbench, App Builder, and optional Cloud access. The Python package also provides native Python workflow and memory APIs. |
|
|
17
17
|
| **AgentLyra Cloud** | A signed-in workspace for hosted agents, syncing selected project resources, and browsing the Marketplace. |
|
|
18
18
|
|
|
19
19
|
## Get started
|
|
@@ -34,7 +34,7 @@ python -m lyra --help
|
|
|
34
34
|
python -m lyra setup coding --detect --preview
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Coding setup,
|
|
37
|
+
Coding setup, Workbench, App Builder, Cloud commands, and skill proposals require Node.js 22.13 or newer. Native Python workflows and local Memory commands run with Python alone.
|
|
38
38
|
|
|
39
39
|
**GitHub source edition · Node.js 22.13 or newer**
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ cd agent-lyra-sdk
|
|
|
44
44
|
node bin/agent-lyra.js --help
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Run project commands from your own project folder using the absolute path to the cloned CLI. Use the npm or PyPI install below to try
|
|
47
|
+
Run project commands from your own project folder using the absolute path to the cloned CLI. Use the npm or PyPI install below to try Workbench, App Builder, coding setup, or Cloud commands.
|
|
48
48
|
|
|
49
49
|
**Command prefixes used below**
|
|
50
50
|
|
|
@@ -126,7 +126,7 @@ These commands are available in npm and Python. Both setup commands accept `--di
|
|
|
126
126
|
|
|
127
127
|
## Run a registered agent from Cloud
|
|
128
128
|
|
|
129
|
-
A private IDE agent card runs in
|
|
129
|
+
A private IDE agent card runs in Workbench by default. To enable **Run now** in Cloud, deploy your own HTTPS endpoint and have the AgentLyra Cloud operator associate it with your account and registration ID. Keep model credentials and agent code in your runtime. The operator configures `LYRA_FRAMEWORK_ENDPOINTS` as a JSON array of objects with `ownerId`, `agentId`, `url`, and a dedicated `token` of at least 32 URL-safe characters.
|
|
130
130
|
|
|
131
131
|
The endpoint handles an authenticated JSON POST. Verify the bearer token before running code. The request carries `schemaVersion: 1`, `agentId`, `traceId`, and `input`. Return JSON with the same `traceId` and an `output` matching the registered text or JSON type. The endpoint has 25 seconds to respond. Use the incoming trace ID in your runtime logs. Cloud retains status, timing and failure category for 30 days. The trace history excludes prompts and replies.
|
|
132
132
|
|
|
@@ -143,21 +143,21 @@ Start your existing Managed Deep Agents project with `npx mda dev` and leave tha
|
|
|
143
143
|
}
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
Run `agent register mda-registration.json` using either SDK CLI, then open
|
|
146
|
+
Run `agent register mda-registration.json` using either SDK CLI, then open Workbench and choose **Agent Registry → Reload agents**. Select the new card and use **Run now**. Workbench sends a text run to the local MDA server. Set `LYRA_MDA_PORT` before launching Workbench if your server uses a port other than 2024. If the dev server requires an API key, set `LYRA_MDA_API_KEY` in Workbench's terminal environment for that trusted local server. The MDA server owns provider credentials and agent behavior. Workbench records the Lyra trace ID and sends it in run metadata. Continue any approval prompts in the MDA interface.
|
|
147
147
|
|
|
148
148
|
## Register an existing Python agent
|
|
149
149
|
|
|
150
|
-
Keep the agent in its existing repository and install its framework in the Python environment
|
|
150
|
+
Keep the agent in its existing repository and install its framework in the Python environment Workbench uses. Set `LYRA_PYTHON` to that interpreter if needed.
|
|
151
151
|
|
|
152
152
|
| Framework in the descriptor | Python object to register |
|
|
153
153
|
| --- | --- |
|
|
154
154
|
| `langchain` | A LangChain agent with async `ainvoke` that accepts a messages state |
|
|
155
155
|
| `langgraph` | A compiled LangGraph graph with async `ainvoke` that accepts a messages state |
|
|
156
|
-
| `google-adk` | A Google ADK agent.
|
|
156
|
+
| `google-adk` | A Google ADK agent. Workbench creates a fresh in-memory session per run |
|
|
157
157
|
| `openai-agents` | An OpenAI Agents SDK agent |
|
|
158
158
|
| `custom` | A sync or async callable with signature `invoke(payload, context)` |
|
|
159
159
|
|
|
160
|
-
The named framework adapters receive text and return the final text. For a custom callable, set `"input": "json"` or `"output": "json"` in the descriptor to use structured values on that side. For example, an async callable can return `{"text": payload["text"].strip()}` with JSON input and output. In
|
|
160
|
+
The named framework adapters receive text and return the final text. For a custom callable, set `"input": "json"` or `"output": "json"` in the descriptor to use structured values on that side. For example, an async callable can return `{"text": payload["text"].strip()}` with JSON input and output. In Workbench, provide a JSON value in the input component or pass valid JSON from the preceding step. The callable receives the Lyra trace ID as `context["trace_id"]`. Framework packages and model credentials stay in your project environment.
|
|
161
161
|
|
|
162
162
|
Create `agent-registration.json` in your project with a relative Python file and the name of an exported object:
|
|
163
163
|
|
|
@@ -176,52 +176,70 @@ Create `agent-registration.json` in your project with a relative Python file and
|
|
|
176
176
|
| `agent trace <run-id>` | Inspect the local run timeline and trace ID |
|
|
177
177
|
| `agent sync <registration-id>` | Preview the private registration |
|
|
178
178
|
| `agent sync <registration-id> --yes` | Sync the preview to **Cloud → Agents** as a local-only card |
|
|
179
|
-
| `app init --local <registration-id>` | Create a local
|
|
179
|
+
| `app init --local <registration-id>` | Create a local Workbench manifest with input, agent, and output bindings |
|
|
180
180
|
|
|
181
|
-
These commands work in the npm and Python distributions. Launch
|
|
181
|
+
These commands work in the npm and Python distributions. Launch Workbench and reload its catalog after registering. Run only code you trust and use text inputs and outputs for this adapter. Workbench returns run and trace IDs, and local run history stores status and duration for framework runs. Sync sends registration metadata. Agent code, local paths, and run contents remain in the project environment. The framework controls any external telemetry it emits.
|
|
182
182
|
|
|
183
|
-
## Lyra
|
|
183
|
+
## Lyra Workbench
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
Workbench is AgentLyra's local workspace. It opens **Mission Control** with project run history and report downloads. Select a run to inspect its **Steps**, **Activity**, **Tokens**, and **Evaluations**. Token counts appear when the provider reports them. Use **Agent Registry** to inspect, run, or reload agents, **Layout** to build an app, and **Workflow** to compose and test a sequence. Open **Cloud Sync** to connect your account, pull the catalog, or pause sync and work locally. Add a text input, agent card or run button, and an output. Use the Inspector to bind inputs and outputs, then run an agent or workflow from the canvas.
|
|
186
186
|
|
|
187
187
|
```sh
|
|
188
|
-
npx agent-lyra
|
|
188
|
+
npx agent-lyra workbench
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
The same Mission Control and Agent Registry are available locally and when Cloud is connected. In **Agent Registry**, choose **Review and add** when Workbench finds supported code-defined agents. Registration writes a local descriptor and leaves your source file in place. Discovery reads supported JavaScript, TypeScript, and Python definitions without executing them. Use an explicit registration for definitions outside the supported patterns. Cloud sync remains a separate action.
|
|
192
|
+
|
|
193
|
+
Run `python -m lyra workbench` from a Python project. Start from the project root so Workbench can find your `.lyra` agents, workflows, and skills. See [Cloud sync](#agentlyra-cloud-and-marketplace) for importing or pushing selected resources.
|
|
192
194
|
|
|
193
195
|
### Provider switching and run records
|
|
194
196
|
|
|
195
|
-
In
|
|
197
|
+
In Workbench's run drawer, select an execution provider for text agents. The **Execution steps** list shows where each step runs.
|
|
196
198
|
|
|
197
199
|
| Provider | Requirements |
|
|
198
200
|
| --- | --- |
|
|
199
|
-
| Local OpenAI API | Set `OPENAI_API_KEY` in the
|
|
201
|
+
| Local OpenAI API | Set `OPENAI_API_KEY` in the Workbench terminal and select a model |
|
|
200
202
|
| Lyra Cloud | Connect an SDK key and configure your own OpenAI key in Cloud Models |
|
|
201
|
-
| Codex CLI | Install the authenticated Codex CLI on PATH.
|
|
202
|
-
| Claude Code CLI | Install the authenticated Claude Code CLI on PATH.
|
|
203
|
+
| Codex CLI | Install the authenticated Codex CLI on PATH. Workbench requests a read-only sandbox |
|
|
204
|
+
| Claude Code CLI | Install the authenticated Claude Code CLI on PATH. Workbench requests tool-free execution |
|
|
203
205
|
|
|
204
|
-
On Windows,
|
|
206
|
+
On Windows, Workbench discovers native CLI executables (`.exe`) on PATH. To run a saved Cloud text agent locally, connect an SDK key with resource sync permission so Workbench can fetch the private agent definition. Choosing Lyra Cloud for a local text agent sends its instructions and input to Cloud for execution. Python and registered framework agents use their own runtimes. VS Code discovery uses workspace settings. Workbench provider selection uses CLI or API credentials. If you select the local OpenAI API and no key is configured, choose **Add OpenAI API key** in the run drawer. Workbench saves the key in your user profile for reuse in Workbench and Lyra CLI runs from the VS Code terminal. A terminal-provided key takes precedence. VS Code extensions and external agent runtimes manage their own credentials.
|
|
205
207
|
|
|
206
|
-
Hosted
|
|
208
|
+
Hosted Workbench text runs record their status, model, duration, and step trace ID in Mission Control. The run drawer and terminal show the matching trace and run IDs. Local-only steps remain local. These SDK execution records store execution metadata and omit prompts and replies.
|
|
207
209
|
|
|
208
|
-
The GitHub source edition includes the approved local SDK subset and VS Code discovery helper. Install the npm or PyPI distribution for the full
|
|
210
|
+
The GitHub source edition includes the approved local SDK subset and VS Code discovery helper. Install the npm or PyPI distribution for the full Workbench experience.
|
|
209
211
|
|
|
210
|
-
In **Workflow**, create a sequence of agents between **Trigger** and **Output**. Give each step a task and optionally name its output so a later step can read it. Save to `.lyra/workflows`, test the sequence, then use **Layout** to bind a run button to the saved workflow. The run drawer shows each step's result, status, duration, and
|
|
212
|
+
In **Workflow**, create a sequence of agents between **Trigger** and **Output**. Give each step a task and optionally name its output so a later step can read it. Save to `.lyra/workflows`, test the sequence, then use **Layout** to bind a run button to the saved workflow. The run drawer shows each step's result, status, duration, and Workbench trace ID. Cloud-only workflows open for inspection and run in the Cloud console. Use **Duplicate locally** to customize a pulled workflow that can run in Workbench.
|
|
211
213
|
|
|
212
214
|
To sync a workflow through the existing Cloud commands, use two to eight steps with enabled Cloud text agents or local text agents already linked to Cloud.
|
|
213
215
|
|
|
214
216
|
Use **Test action** in the editor to try a bound action, or `app preview` to run the saved layout as an app user.
|
|
215
217
|
|
|
218
|
+
### Knowledge Graph and Token Intelligence
|
|
219
|
+
|
|
220
|
+
Choose **Build a local GraphSnip graph and report** during `agent-lyra init`, or pass `--with-graph` for explicit setup. On an existing project, run `npx agent-lyra graph setup` or `python -m lyra graph setup`. Setup reuses a compatible executable or installs GraphSnip 0.3.0 in a project-local environment using Python 3.10+. The same executable is used in Workbench. `LYRA_GRAPHSNIP_EXECUTABLE` can override it.
|
|
221
|
+
|
|
222
|
+
| Command after `npx agent-lyra` or `python -m lyra` | What it does |
|
|
223
|
+
| --- | --- |
|
|
224
|
+
| `graph setup` | Prepare GraphSnip and build the graph and report |
|
|
225
|
+
| `graph --help` | List all GraphSnip commands when installed |
|
|
226
|
+
| `graph build` | Build or incrementally refresh the graph |
|
|
227
|
+
| `graph report` | Generate the local dashboard |
|
|
228
|
+
| `graph stats --json` | Print the project token ledger |
|
|
229
|
+
| `graph <command> [options]` | Pass through any other GraphSnip command and its options |
|
|
230
|
+
|
|
231
|
+
Open **Intelligence → Knowledge Graph** in Workbench to view the report or choose **Build graph and report**. The embedded dashboard is a local, read-only preview with scripts and external resources disabled. For the full interactive dashboard, use `graph report --open`.
|
|
232
|
+
|
|
233
|
+
Set `LYRA_GRAPHSNIP=on` before launching Workbench to attach bounded repository context to supported model calls. Mission Control shows when context was attached and lists provider token usage when available. **Token Intelligence** separately shows GraphSnip ledger estimates for project and benchmark activity. Those estimates compare GraphSnip's returned context with its baseline and do not measure provider billing.
|
|
216
234
|
## Lyra App Builder
|
|
217
235
|
|
|
218
|
-
|
|
236
|
+
Workbench opens at `http://127.0.0.1:4174/`. Set `LYRA_STUDIO_PORT` before launching to use a different port. For Workbench or app preview, set the corresponding variable to `0` to pick a free port automatically.
|
|
219
237
|
|
|
220
|
-
|
|
238
|
+
Open **App Builder → Layout** in Workbench to build your app interface. Use **App Builder → Workflow** to design the workflow it runs. To scaffold a named manifest from a terminal, use `app init --name "My app"`. Add components, drag to reorder, or set component widths in the inspector. Bind agent cards and run buttons to agents or runnable workflows from your project. Save to `manifest.json`, then preview or export the same layout.
|
|
221
239
|
|
|
222
240
|
| Command | Purpose |
|
|
223
241
|
| --- | --- |
|
|
224
|
-
| `app init [manifest.json] [--name "My app"]` | Create a blank visual app and edit it in
|
|
242
|
+
| `app init [manifest.json] [--name "My app"]` | Create a blank visual app and edit it in Workbench |
|
|
225
243
|
| `app init --template agent` | Start with a side-by-side input and result and a run button ready to bind |
|
|
226
244
|
| `app init --saved-agents [manifest.json]` | Create the guided Cloud chat using two saved agents |
|
|
227
245
|
| `app validate <manifest.json>` | Check the manifest |
|
|
@@ -268,6 +286,11 @@ These commands work in Source, npm, and Python. Approving a proposal requires in
|
|
|
268
286
|
| `skills reject <id>` | Reject a pending proposal |
|
|
269
287
|
| `skills withdraw <id>` | Withdraw an approval |
|
|
270
288
|
|
|
289
|
+
### Independent Memory Engine
|
|
290
|
+
|
|
291
|
+
Workbench includes Memory Engine 0.1.0 from the [pinned upstream revision](https://github.com/naubadnithinkumar/memory-engine/tree/befb5607a7109d8bcc8160a1947878de09a3d807) in both the npm and PyPI distributions. Launch Workbench from your project to use the existing `.lyra/memory/memory.db` database or create it on first use. Node.js 22.13 or newer provides the SQLite runtime for Workbench. Python applications can also use the native memory API, which uses Python’s built-in SQLite module. Maintainers testing the pinned upstream checkout can set `LYRA_MEMORY_ENGINE_DIR` to its directory. Lyra verifies the checkout before loading it.
|
|
292
|
+
|
|
293
|
+
In **Mission Control**, select a completed run and choose **Record learning**. Workbench links the run ID as provenance and saves your write-up as a candidate. Evidence review is a separate action in **Memory & Learnings** before a record can be retrieved for future work.
|
|
271
294
|
## AgentLyra Cloud and Marketplace
|
|
272
295
|
|
|
273
296
|
[Open the AgentLyra console](https://console.agentlyra.in/) to run hosted agents, manage a workspace, and view synced records. Create one AgentLyra API key under [API Keys](https://console.agentlyra.in/mcp-servers). Enable the permissions you need for hosted runs, resource sync, and verified memory sync.
|
|
@@ -285,15 +308,15 @@ These commands work in the npm and Python distributions with a key that has Clou
|
|
|
285
308
|
|
|
286
309
|
| Command | Purpose |
|
|
287
310
|
| --- | --- |
|
|
288
|
-
| `
|
|
289
|
-
| `
|
|
290
|
-
| `
|
|
291
|
-
| `
|
|
292
|
-
| `
|
|
293
|
-
| `
|
|
294
|
-
| `
|
|
295
|
-
| `
|
|
296
|
-
| `
|
|
311
|
+
| `workbench pull` | Pull the workspace catalog from Cloud |
|
|
312
|
+
| `workbench push <agent-id>` | Push a local agent to Cloud |
|
|
313
|
+
| `workbench pull-agent <agent-id>` | Pull changes to a linked agent |
|
|
314
|
+
| `workbench push-workflow <workflow-id>` | Push a local workflow |
|
|
315
|
+
| `workbench pull-workflow <workflow-id>` | Pull changes to a linked workflow |
|
|
316
|
+
| `workbench push-team <team-id>` | Push a local team |
|
|
317
|
+
| `workbench pull-team <team-id>` | Pull changes to a linked team |
|
|
318
|
+
| `workbench push-skill <skill-id>` | Push a local text skill |
|
|
319
|
+
| `workbench pull-skill <skill-id>` | Pull changes to a linked text skill |
|
|
297
320
|
|
|
298
321
|
### Sync verified memories
|
|
299
322
|
|
package/bin/agent-lyra.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { runGraph } from "../src/intelligence/graph-setup.js";
|
|
3
4
|
import { runFrameworkCli } from "../src/framework/agent.js";
|
|
4
5
|
import { runSkillProposals } from "../src/memory/skills-cli.js";
|
|
5
6
|
import { runMemory } from "../src/memory/cli.js";
|
|
@@ -24,6 +25,7 @@ async function main() {
|
|
|
24
25
|
return argv[2] === "export" ? runCodingExport(argv.slice(3)) : runCodingSetup(argv.slice(2));
|
|
25
26
|
}
|
|
26
27
|
if (argv[0] === "agent" && argv[1] !== "run") return runFrameworkCli(argv.slice(1));
|
|
28
|
+
if (argv[0] === "graph") return runGraph(argv.slice(1));
|
|
27
29
|
if (argv[0] === "skills") return runSkillProposals(argv.slice(1));
|
|
28
30
|
if (argv[0] === "memory") return runMemory(argv.slice(1));
|
|
29
31
|
if (argv[0] === "connect-cloud") return switchMode(process.cwd(), "gated", argv.slice(1));
|
|
@@ -34,7 +36,8 @@ async function main() {
|
|
|
34
36
|
const key = await readSdkKey(process.cwd());
|
|
35
37
|
if (key) process.env.LYRA_API_KEY = key;
|
|
36
38
|
}
|
|
37
|
-
if (argv[0] === "studio")
|
|
39
|
+
if (argv[0] === "studio") throw new Error("Use agent-lyra workbench to open Workbench and App Builder.");
|
|
40
|
+
if (argv[0] === "workbench") return runStudio(argv.slice(1));
|
|
38
41
|
if (argv[0] === "app" && argv[1] === "use") return runAppUse(argv.slice(2));
|
|
39
42
|
if (argv[0] === "app" && argv[1] === "init") return runAppInit(argv.slice(2));
|
|
40
43
|
if (argv[0] === "app" && argv[1] === "preview") return runAppPreview(argv.slice(2));
|
package/bin/lyra-oss-preview.js
CHANGED
|
@@ -4,13 +4,15 @@ import { runLocalMemory } from '../src/memory/local-cli.js';
|
|
|
4
4
|
import { runSkillProposals } from '../src/memory/skills-cli.js';
|
|
5
5
|
import { runLocalCli } from '../src/runtime/local-cli.js';
|
|
6
6
|
import { serveSavedRuns } from '../src/runtime/mcp-stdio.js';
|
|
7
|
+
import { runGraph } from '../src/intelligence/graph-setup.js';
|
|
7
8
|
const [command,...args]=process.argv.slice(2);
|
|
8
9
|
try {
|
|
9
10
|
if (command==='init') await initStandalone(args);
|
|
11
|
+
else if (command==='graph') await runGraph(args);
|
|
10
12
|
else if (command==='memory') await runLocalMemory(args);
|
|
11
13
|
else if (command==='skills') await runSkillProposals(args);
|
|
12
14
|
else if (command==='mcp' && args[0]==='serve') await serveSavedRuns(args.slice(1));
|
|
13
15
|
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');
|
|
16
|
+
else if (!command || command==='--help') console.log('Usage: agent-lyra init | graph | memory | skills | agent run | team run | run status | mcp serve');
|
|
15
17
|
else throw new Error('Unsupported standalone command');
|
|
16
18
|
} catch(error) { console.error(error.message); process.exitCode=1; }
|
package/package.json
CHANGED
package/src/app-builder/init.js
CHANGED
|
@@ -12,7 +12,7 @@ export async function runAppInit(args, output = process.stdout, {
|
|
|
12
12
|
},
|
|
13
13
|
} = {}) {
|
|
14
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
|
|
15
|
+
output.write("Usage: agent-lyra app init [manifest.json] [--name \"My app\"] [--template agent]\nCreates a visual app. Run agent-lyra workbench to edit it.\nUse --local <registration-id> for a framework agent or --saved-agents for the guided Cloud chat.\n");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
if (args[0] === "--local") {
|
|
@@ -108,8 +108,8 @@ async function initVisualApp(args, output) {
|
|
|
108
108
|
await writeFile(target, JSON.stringify({
|
|
109
109
|
version: "3.0", application: { id: "lyra-app", name }, studio: { layout },
|
|
110
110
|
}, null, 2) + "\n", { flag: "wx" }).catch(error => {
|
|
111
|
-
if (error.code === "EEXIST") throw new Error("Manifest already exists at " + target + ". Open
|
|
111
|
+
if (error.code === "EEXIST") throw new Error("Manifest already exists at " + target + ". Open Workbench in that folder to edit it.");
|
|
112
112
|
throw error;
|
|
113
113
|
});
|
|
114
|
-
output.write("Created " + target + "\nRun agent-lyra
|
|
114
|
+
output.write("Created " + target + "\nRun agent-lyra workbench from the manifest folder to edit the app.\n");
|
|
115
115
|
}
|
package/src/framework/agent.js
CHANGED
|
@@ -113,16 +113,28 @@ export async function syncFrameworkAgent(root, id, confirmation, { request = fet
|
|
|
113
113
|
return result;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export async function runFrameworkAgent(root, agent, input, traceId) {
|
|
116
|
+
export async function runFrameworkAgent(root, agent, input, traceId, { signal, onActivity } = {}) {
|
|
117
|
+
signal?.throwIfAborted();
|
|
117
118
|
const path = await sourceFile(root, agent);
|
|
118
|
-
if (agent.framework === "managed-deepagents") return runManagedDeepAgent(agent, input, traceId);
|
|
119
|
+
if (agent.framework === "managed-deepagents") return runManagedDeepAgent(agent, input, traceId, { signal });
|
|
119
120
|
const python = process.env.LYRA_PYTHON || (process.platform === "win32" ? "py.exe" : "python3");
|
|
120
121
|
const runner = fileURLToPath(new URL("./run.py", import.meta.url));
|
|
121
122
|
return new Promise((resolve, reject) => {
|
|
122
123
|
const child = execFile(python, [runner, path, agent.entry.split(":")[1], traceId, agent.framework, agent.output], {
|
|
123
|
-
cwd: root, timeout: 60_000, maxBuffer: 1024 * 1024, windowsHide: true,
|
|
124
|
+
cwd: root, signal, timeout: 60_000, maxBuffer: 1024 * 1024, windowsHide: true,
|
|
124
125
|
}, (error, stdout) => {
|
|
126
|
+
let reply;
|
|
127
|
+
try { reply = JSON.parse(stdout); } catch {}
|
|
128
|
+
if (!signal?.aborted && onActivity && Array.isArray(reply?.activity)) {
|
|
129
|
+
for (const type of reply.activity.slice(0, 10)) {
|
|
130
|
+
if (typeof type !== "string" ||
|
|
131
|
+
!/^(model|tool)\.(started|completed|failed)$|^tool\.(requested|responded)$/.test(type)) continue;
|
|
132
|
+
try { onActivity({ type, id: type.startsWith("tool.") ? "framework-tool" : "framework-model" }); }
|
|
133
|
+
catch (failure) { return reject(failure); }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
125
136
|
if (error) {
|
|
137
|
+
if (signal?.aborted) return reject(signal.reason);
|
|
126
138
|
if (error.code === 20 || error.code === 21) {
|
|
127
139
|
const failure = new Error(error.code === 20 ? "Install the framework in the selected Python environment." : "Framework agent returned an invalid output.");
|
|
128
140
|
failure.code = error.code === 20 ? "FRAMEWORK_DEPENDENCY" : "FRAMEWORK_OUTPUT";
|
|
@@ -132,11 +144,10 @@ export async function runFrameworkAgent(root, agent, input, traceId) {
|
|
|
132
144
|
if (error.killed) failed.code = "FRAMEWORK_TIMEOUT";
|
|
133
145
|
return reject(failed);
|
|
134
146
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} catch { reject(new Error("Framework agent returned an invalid text response.")); }
|
|
147
|
+
if (typeof reply?.output !== "string") {
|
|
148
|
+
return reject(new Error("Framework agent returned an invalid text response."));
|
|
149
|
+
}
|
|
150
|
+
resolve(reply.output);
|
|
140
151
|
});
|
|
141
152
|
child.stdin.on("error", () => {});
|
|
142
153
|
child.stdin.end(JSON.stringify({ input }));
|
package/src/framework/mda.js
CHANGED
|
@@ -4,7 +4,8 @@ function failure(message, code = "FRAMEWORK_ENDPOINT") {
|
|
|
4
4
|
return Object.assign(new Error(message), { code });
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export async function runManagedDeepAgent(agent, input, traceId) {
|
|
7
|
+
export async function runManagedDeepAgent(agent, input, traceId, { signal } = {}) {
|
|
8
|
+
const timeout = AbortSignal.timeout(60_000);
|
|
8
9
|
const port = Number(process.env.LYRA_MDA_PORT || 2024);
|
|
9
10
|
if (!Number.isInteger(port) || port < 1024 || port > 65535) {
|
|
10
11
|
throw failure("Set LYRA_MDA_PORT to the port printed by mda dev.");
|
|
@@ -15,7 +16,7 @@ export async function runManagedDeepAgent(agent, input, traceId) {
|
|
|
15
16
|
response = await fetch("http://127.0.0.1:" + port + "/runs/wait", {
|
|
16
17
|
method: "POST",
|
|
17
18
|
redirect: "error",
|
|
18
|
-
signal: AbortSignal.timeout
|
|
19
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
19
20
|
headers: { "Content-Type": "application/json", ...(key ? { "x-api-key": key } : {}) },
|
|
20
21
|
body: JSON.stringify({
|
|
21
22
|
assistant_id: agent.assistantId,
|
|
@@ -24,6 +25,7 @@ export async function runManagedDeepAgent(agent, input, traceId) {
|
|
|
24
25
|
}),
|
|
25
26
|
});
|
|
26
27
|
} catch (error) {
|
|
28
|
+
signal?.throwIfAborted();
|
|
27
29
|
if (error.name === "TimeoutError") throw failure("Managed Deep Agent timed out.", "FRAMEWORK_TIMEOUT");
|
|
28
30
|
throw failure("Could not reach the Managed Deep Agent. Start mda dev on the configured port.");
|
|
29
31
|
}
|
|
@@ -46,6 +48,7 @@ export async function runManagedDeepAgent(agent, input, traceId) {
|
|
|
46
48
|
}
|
|
47
49
|
data = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
48
50
|
} catch (error) {
|
|
51
|
+
signal?.throwIfAborted();
|
|
49
52
|
if (error.name === "AbortError" || error.name === "TimeoutError") {
|
|
50
53
|
throw failure("Managed Deep Agent timed out.", "FRAMEWORK_TIMEOUT");
|
|
51
54
|
}
|
package/src/framework/run.py
CHANGED
|
@@ -7,12 +7,61 @@ from contextlib import redirect_stdout
|
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
import runpy
|
|
9
9
|
import sys
|
|
10
|
+
from threading import Lock
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
class Activity:
|
|
14
|
+
def __init__(self):
|
|
15
|
+
self.events = []
|
|
16
|
+
self.lock = Lock()
|
|
17
|
+
|
|
18
|
+
def add(self, event_type):
|
|
19
|
+
with self.lock:
|
|
20
|
+
if len(self.events) < 10:
|
|
21
|
+
self.events.append(event_type)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def langchain_callbacks(activity):
|
|
25
|
+
try:
|
|
26
|
+
from langchain_core.callbacks import BaseCallbackHandler
|
|
27
|
+
except ModuleNotFoundError as error:
|
|
28
|
+
if error.name != "langchain_core":
|
|
29
|
+
raise
|
|
30
|
+
return []
|
|
31
|
+
|
|
32
|
+
class Observer(BaseCallbackHandler):
|
|
33
|
+
def on_chat_model_start(self, *args, **kwargs):
|
|
34
|
+
activity.add("model.started")
|
|
35
|
+
|
|
36
|
+
def on_llm_start(self, *args, **kwargs):
|
|
37
|
+
activity.add("model.started")
|
|
38
|
+
|
|
39
|
+
def on_llm_end(self, *args, **kwargs):
|
|
40
|
+
activity.add("model.completed")
|
|
41
|
+
|
|
42
|
+
def on_llm_error(self, *args, **kwargs):
|
|
43
|
+
activity.add("model.failed")
|
|
44
|
+
|
|
45
|
+
def on_tool_start(self, *args, **kwargs):
|
|
46
|
+
activity.add("tool.started")
|
|
47
|
+
|
|
48
|
+
def on_tool_end(self, *args, **kwargs):
|
|
49
|
+
activity.add("tool.completed")
|
|
50
|
+
|
|
51
|
+
def on_tool_error(self, *args, **kwargs):
|
|
52
|
+
activity.add("tool.failed")
|
|
53
|
+
|
|
54
|
+
return [Observer()]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def invoke_langchain(target, prompt, trace_id, activity):
|
|
58
|
+
config = {"metadata": {"lyra_trace_id": trace_id}}
|
|
59
|
+
callbacks = langchain_callbacks(activity)
|
|
60
|
+
if callbacks:
|
|
61
|
+
config["callbacks"] = callbacks
|
|
13
62
|
result = await target.ainvoke(
|
|
14
63
|
{"messages": [{"role": "user", "content": prompt}]},
|
|
15
|
-
config=
|
|
64
|
+
config=config,
|
|
16
65
|
)
|
|
17
66
|
if isinstance(result, dict) and result.get("messages"):
|
|
18
67
|
result = result["messages"][-1]
|
|
@@ -27,7 +76,7 @@ async def invoke_langchain(target, prompt, trace_id):
|
|
|
27
76
|
return result
|
|
28
77
|
|
|
29
78
|
|
|
30
|
-
async def invoke_adk(target, prompt, trace_id):
|
|
79
|
+
async def invoke_adk(target, prompt, trace_id, activity):
|
|
31
80
|
from google.adk.runners import InMemoryRunner
|
|
32
81
|
from google.genai import types
|
|
33
82
|
|
|
@@ -43,6 +92,10 @@ async def invoke_adk(target, prompt, trace_id):
|
|
|
43
92
|
session_id=session.id,
|
|
44
93
|
new_message=types.Content(role="user", parts=[types.Part(text=prompt)]),
|
|
45
94
|
):
|
|
95
|
+
for _ in event.get_function_calls():
|
|
96
|
+
activity.add("tool.requested")
|
|
97
|
+
for _ in event.get_function_responses():
|
|
98
|
+
activity.add("tool.responded")
|
|
46
99
|
if event.is_final_response() and event.content:
|
|
47
100
|
for part in event.content.parts or []:
|
|
48
101
|
if part.text and not part.thought:
|
|
@@ -55,14 +108,27 @@ async def invoke_adk(target, prompt, trace_id):
|
|
|
55
108
|
await runner.close()
|
|
56
109
|
|
|
57
110
|
|
|
58
|
-
async def invoke_openai(target, prompt, trace_id):
|
|
59
|
-
from agents import RunConfig, Runner
|
|
111
|
+
async def invoke_openai(target, prompt, trace_id, activity):
|
|
112
|
+
from agents import RunConfig, RunHooks, Runner
|
|
113
|
+
|
|
114
|
+
class Observer(RunHooks):
|
|
115
|
+
async def on_llm_start(self, *args, **kwargs):
|
|
116
|
+
activity.add("model.started")
|
|
117
|
+
|
|
118
|
+
async def on_llm_end(self, *args, **kwargs):
|
|
119
|
+
activity.add("model.completed")
|
|
120
|
+
|
|
121
|
+
async def on_tool_start(self, *args, **kwargs):
|
|
122
|
+
activity.add("tool.started")
|
|
123
|
+
|
|
124
|
+
async def on_tool_end(self, *args, **kwargs):
|
|
125
|
+
activity.add("tool.completed")
|
|
60
126
|
|
|
61
127
|
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
|
|
128
|
+
return (await Runner.run(target, prompt, run_config=config, hooks=Observer())).final_output
|
|
63
129
|
|
|
64
130
|
|
|
65
|
-
async def invoke_custom(target, payload, trace_id):
|
|
131
|
+
async def invoke_custom(target, payload, trace_id, _activity):
|
|
66
132
|
result = target(payload, {"trace_id": trace_id})
|
|
67
133
|
return await result if inspect.isawaitable(result) else result
|
|
68
134
|
|
|
@@ -80,7 +146,7 @@ adapters = {
|
|
|
80
146
|
}
|
|
81
147
|
|
|
82
148
|
|
|
83
|
-
def main():
|
|
149
|
+
def main(activity):
|
|
84
150
|
file, symbol, trace_id, framework, output_kind = sys.argv[1:]
|
|
85
151
|
payload = json.load(sys.stdin)
|
|
86
152
|
sys.path.insert(0, str(Path.cwd()))
|
|
@@ -91,7 +157,7 @@ def main():
|
|
|
91
157
|
if not spec or not spec.origin or Path(spec.origin).resolve() != Path(file).resolve():
|
|
92
158
|
raise ImportError("The Python module does not match the registered file.")
|
|
93
159
|
target = runpy.run_module(module)[symbol]
|
|
94
|
-
reply = asyncio.run(adapters[framework](target, payload["input"], trace_id))
|
|
160
|
+
reply = asyncio.run(adapters[framework](target, payload["input"], trace_id, activity))
|
|
95
161
|
if output_kind == "json":
|
|
96
162
|
try:
|
|
97
163
|
reply = json.dumps(reply, ensure_ascii=False, allow_nan=False)
|
|
@@ -99,13 +165,19 @@ def main():
|
|
|
99
165
|
raise InvalidOutput("Expected serializable JSON.") from error
|
|
100
166
|
if not isinstance(reply, str) or not reply.strip() or len(reply) > 65536:
|
|
101
167
|
raise InvalidOutput("Expected a bounded, nonempty reply.")
|
|
102
|
-
print(json.dumps({"output": reply}, ensure_ascii=True))
|
|
168
|
+
print(json.dumps({"output": reply, "activity": activity.events}, ensure_ascii=True))
|
|
103
169
|
|
|
104
170
|
|
|
105
171
|
if __name__ == "__main__":
|
|
172
|
+
activity = Activity()
|
|
106
173
|
try:
|
|
107
|
-
main()
|
|
174
|
+
main(activity)
|
|
108
175
|
except ModuleNotFoundError:
|
|
176
|
+
print(json.dumps({"activity": activity.events}))
|
|
109
177
|
sys.exit(20)
|
|
110
178
|
except InvalidOutput:
|
|
179
|
+
print(json.dumps({"activity": activity.events}))
|
|
111
180
|
sys.exit(21)
|
|
181
|
+
except Exception:
|
|
182
|
+
print(json.dumps({"activity": activity.events}))
|
|
183
|
+
raise
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/init.js
CHANGED
|
@@ -7,6 +7,7 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
7
7
|
import { GATED_DOMAINS, STANDALONE_DOMAINS, getDomainCatalog } from "./catalog.js";
|
|
8
8
|
|
|
9
9
|
import { prepareCodingStack, recommendCodingStacks, selectCodingStack } from "./coding/setup.js";
|
|
10
|
+
import { setupGraphSnip } from "./intelligence/graph-setup.js";
|
|
10
11
|
import { ensureVSCodeAgentDiscovery } from "./vscode/workspace.js";
|
|
11
12
|
|
|
12
13
|
const DEFAULT_API_BASE_URL = "https://www.agentlyra.in";
|
|
@@ -43,7 +44,7 @@ function parseArgs(argv = process.argv.slice(2)) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
function printUsage() {
|
|
46
|
-
output.write(`Documentation: https://agentlyra.in/docs\n\nUsage:\n agent-lyra init\n lyra init\n\nOptions:\n --mode standalone|gated\n --domains coding,finance\n --stack mern,playwright\n --detect\n --api-key <key>\n --api-base-url <url>\n --dir <target-directory>\n --force\n`);
|
|
47
|
+
output.write(`Documentation: https://agentlyra.in/docs\n\nUsage:\n agent-lyra init [--with-graph]\n agent-lyra graph --help\n agent-lyra workbench\n lyra init\n\nOptions:\n --mode standalone|gated\n --domains coding,finance\n --stack mern,playwright\n --detect\n --with-graph / --without-graph\n --api-key <key>\n --api-base-url <url>\n --dir <target-directory>\n --force\n`);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
function printWelcomeBanner() {
|
|
@@ -938,6 +939,17 @@ export async function runInitWizard(options = {}) {
|
|
|
938
939
|
await ensureVSCodeAgentDiscovery(targetDir);
|
|
939
940
|
|
|
940
941
|
output.write(`Created ${lyraDir} for ${mode} mode with ${selectedDomains.length} domain(s).\n`);
|
|
942
|
+
const buildGraph = options["with-graph"] === true ||
|
|
943
|
+
(!options["without-graph"] && input.isTTY && await askYesNo(rl, "Build a local GraphSnip graph and report?", false));
|
|
944
|
+
if (buildGraph) {
|
|
945
|
+
try {
|
|
946
|
+
await setupGraphSnip(targetDir);
|
|
947
|
+
output.write("Graph and report are ready in Workbench → Intelligence → Knowledge Graph.\n");
|
|
948
|
+
} catch (error) {
|
|
949
|
+
output.write(`Project created. GraphSnip setup did not finish: ${error.message}. Retry with agent-lyra graph setup.\n`);
|
|
950
|
+
if (options["with-graph"] === true) process.exitCode = 1;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
941
953
|
} finally {
|
|
942
954
|
rl.close();
|
|
943
955
|
}
|