agent-lyra 0.6.0 → 0.6.1

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 (38) hide show
  1. package/README.md +395 -173
  2. package/bin/agent-lyra.js +16 -3
  3. package/package.json +60 -56
  4. package/src/app-builder/export.js +109 -109
  5. package/src/app-builder/init.js +52 -52
  6. package/src/app-builder/preview.js +22 -22
  7. package/src/app-builder/saved-app.js +70 -70
  8. package/src/app-builder/saved-preview-browser.js +33 -33
  9. package/src/app-builder/saved-preview.html +24 -24
  10. package/src/app-builder/saved-preview.js +61 -61
  11. package/src/app-builder/validate.js +64 -64
  12. package/src/memory/cli.js +49 -0
  13. package/src/memory/contract.json +28 -0
  14. package/src/memory/index.d.ts +49 -0
  15. package/src/memory/index.js +259 -0
  16. package/src/memory/lifecycle.js +29 -0
  17. package/src/memory/proposals.js +84 -0
  18. package/src/memory/skills-cli.js +26 -0
  19. package/src/memory/sync.js +85 -0
  20. package/src/memory/validation.js +25 -0
  21. package/src/runtime/local-cli.js +2 -1
  22. package/src/studio/agent-ui.css +43 -43
  23. package/src/studio/agent-ui.js +32 -32
  24. package/src/studio/browser.js +331 -289
  25. package/src/studio/export.js +80 -79
  26. package/src/studio/index.html +37 -16
  27. package/src/studio/memory-actions.js +37 -0
  28. package/src/studio/memory-panel.js +200 -0
  29. package/src/studio/project.js +197 -190
  30. package/src/studio/pull-agent.js +72 -0
  31. package/src/studio/push.js +54 -0
  32. package/src/studio/python-agent.js +47 -47
  33. package/src/studio/python-agent.py +25 -25
  34. package/src/studio/server.js +143 -102
  35. package/src/studio/session.js +83 -0
  36. package/src/studio/studio.css +10 -7
  37. package/src/studio/sync.js +42 -39
  38. package/src/studio/workflow-sync.js +157 -0
package/README.md CHANGED
@@ -1,173 +1,395 @@
1
- # AgentLyra SDK
2
-
3
- Build apps from your saved Lyra agents, run agents with your own OpenAI key, and inspect saved runs from your IDE. The Node.js package includes a command-line tool and typed JavaScript APIs for composing workflows.
4
-
5
- [AgentLyra homepage](https://agentlyra.in/) · [CLI reference](https://agentlyra.in/#sdk-commands) · [Cloud console](https://console.agentlyra.in/)
6
-
7
- ## Choose an SDK mode
8
-
9
- | Mode | Where work runs | What you need |
10
- | --- | --- | --- |
11
- | **Standalone** | In your own Node.js process. Use `agent-lyra/standalone` for local workflows and retrieval, or run your own local workflows. | No AgentLyra account or key. Model-backed CLI runs use your own OpenAI key. |
12
- | **Gated** | On a compatible hosted backend. `agent-lyra/gated` calls the backend's `/agents/<vertical>/invoke` endpoint. | A Lyra API key for that backend and its base URL. For AgentLyra Cloud, use a dedicated SDK key and the base URL https://api.agentlyra.in/api/sdk/v1. Cloud SDK calls also require an OpenAI key in Models settings. |
13
-
14
- The App Builder below uses a dedicated SDK key to run saved agents in AgentLyra Cloud. Standalone workflows remain available through the SDK and CLI.
15
-
16
- ## Install
17
-
18
- Requires **Node.js 22.13 or newer**. From your project directory:
19
-
20
- ```bash
21
- npm install agent-lyra
22
- ```
23
-
24
- Use `pnpm add agent-lyra` if your project uses pnpm. Run the CLI with `npx agent-lyra` after installation.
25
-
26
- ## Build an app from your Lyra agents
27
-
28
- Create two enabled text agents in AgentLyra Console. In [API key settings](https://console.agentlyra.in/settings/lyra-api-key), choose **Generate SDK key** and set it as `LYRA_API_KEY` in your terminal environment. Add your own OpenAI key in Console → Models. Keep both keys out of source control.
29
-
30
- ```bash
31
- npx agent-lyra app init
32
- npx agent-lyra app validate manifest.json
33
- npx agent-lyra app preview manifest.json
34
- ```
35
-
36
- Choose the agents in the order they should run. The CLI creates one `manifest.json` in your project. Open the URL printed by the preview and enter some text. The first agent runs on that input, then the second receives the input and first result. The browser shows both outputs. This version runs each saved agent's instructions as text-only; connected tools and skills are outside this workflow.
37
-
38
- Stop the preview or open a new terminal, then export into a new folder:
39
-
40
- ```bash
41
- npx agent-lyra app export manifest.json ./my-app
42
- cd my-app
43
- npm start
44
- ```
45
-
46
- The export contains editable HTML, a Node.js server, the runtime, and the app manifest. Keep `LYRA_API_KEY` in the server environment. The exported server binds to loopback and the two agents continue to run in Cloud.
47
-
48
- ## Choose the workflow you need
49
-
50
- | I want to… | Start here |
51
- | --- | --- |
52
- | Set up a repo with starter agent definitions | `npx agent-lyra init` |
53
- | Build and export an app from your own saved agents | [Build an app from your Lyra agents](#build-an-app-from-your-lyra-agents) |
54
- | Run a model-backed agent from my terminal | [Run an agent](#run-an-agent) |
55
- | Inspect saved runs inside my IDE | [Connect your IDE](#connect-your-ide) |
56
- | Share or import an app | [Use the Marketplace](#use-the-marketplace) |
57
-
58
- ### Run an agent
59
-
60
- Set `OPENAI_API_KEY` in your environment. Replace `YOUR_MODEL` with an OpenAI model available to your key.
61
-
62
- ```bash
63
- npx agent-lyra agent run --model YOUR_MODEL --prompt "Draft a project update"
64
- npx agent-lyra run status YOUR_RUN_ID
65
- ```
66
-
67
- Copy the run ID printed by the first command into the second. The CLI saves run events locally in `.lyra/state/runs.sqlite`. To run a writer followed by a reviewer, use `team run draft-review` with the same model and prompt flags.
68
-
69
- ### Connect your IDE
70
-
71
- Configure a stdio MCP server with the installed `agent-lyra` executable, using its absolute path if your IDE requires one. Set the arguments to:
72
-
73
- ```json
74
- ["mcp", "serve", "--dir", "ABSOLUTE_PROJECT_PATH"]
75
- ```
76
-
77
- The MCP server reads saved runs from that project.
78
-
79
- ### Use the Marketplace
80
-
81
- Generate a shareable listing preview with `npx agent-lyra app publish .lyra/app/manifest.json --dry-run`. Review it before submitting the listing in the cloud. Browse apps publicly, then sign in to import an editable private copy. CLI imports require an existing Lyra session supplied through `LYRA_SESSION_TOKEN`. [Marketplace Apps](https://agentlyra.in/marketplace/apps)
82
-
83
- ## Local Studio
84
-
85
- ```bash
86
- npx agent-lyra studio
87
- ```
88
-
89
- Open the printed loopback URL. Drag a heading, text, input, text area, run button, or output onto the canvas. You can also add components by clicking them. Select a run button in the inspector, bind an input and output, and add agents or compatible workflows in the order they should run. **Save layout** writes the layout into your root `manifest.json`.
90
-
91
- Studio reads standalone Markdown agents from `.lyra/agents/`. Each needs an `id`, a `name`, and a `## System Prompt` section. To run a local agent, set `OPENAI_API_KEY` and choose a model in the Run now drawer. Override the model list with a comma-separated `LYRA_STUDIO_MODELS` environment variable if needed.
92
-
93
- Set `LYRA_API_KEY` to an AgentLyra SDK key, then select **Pull from Cloud** or run `npx agent-lyra studio pull`. The pull saves Cloud agent references, workflows, and team metadata into `.lyra/agents/`, `.lyra/workflows/`, and `.lyra/teams/`. Existing files are preserved. Studio can run compatible sequential text workflows. Other workflows and teams appear as reference cards. Cloud agents use the OpenAI key configured in Cloud Models.
94
-
95
- Add an **Agent card** to let users run one agent directly from the app. Choose the agent in the Inspector and optionally bind an input and an output. Use a **Run button** for a sequence of agents or workflows.
96
-
97
- Save the canvas in Studio and export it with `npx agent-lyra app export manifest.json ./my-app`. Open the new folder and run `npm start` to launch the app locally. The export keeps the component layout and Run button bindings. It includes the prompts of referenced local agents and the IDs of referenced Cloud agents. Supply your API keys through environment variables when starting the app.
98
-
99
-
100
- ### Run a Python skill from the canvas
101
-
102
- Install the Python SDK in your environment. Create `.lyra/agents/draft.py`:
103
-
104
- ```python
105
- from lyra.standalone import Agent, Skill
106
-
107
- def draft(text):
108
- return f"Draft: {text}"
109
-
110
- agent = Agent("draft", [Skill("draft-note", draft)])
111
- ```
112
-
113
- Register the skill in `.lyra/agents/draft.json`:
114
-
115
- ```json
116
- {"id":"draft","name":"Draft a note","runtime":"python","file":"draft.py","skill":"draft-note"}
117
- ```
118
-
119
- Restart Studio or click **Reload agents**. Select **Draft a note** on an Agent card, or add it to a Run button's execution order. Studio passes the input as a string, along with any previous step result. Skills may return strings or JSON-serializable values. The Python CLI uses its own interpreter. If you launch Studio from npm or start an exported app, set `LYRA_PYTHON` to your virtual environment's Python executable when needed.
120
-
121
- Export includes the Python files bound to the canvas. Install the Python SDK and any dependencies in the environment running the export. If an agent imports other project files, add those files to the exported project and make them importable in that environment. Run Python agents from projects whose source you trust.
122
-
123
- ## CLI reference
124
-
125
- Prefix each command with `npx agent-lyra`. Angle brackets indicate required arguments. Square brackets indicate optional arguments.
126
-
127
- ### Project setup
128
-
129
- | Command | What it does |
130
- | --- | --- |
131
- | `init [options]` | Scaffold a `.lyra` workspace and starter agents. Options include `--mode`, `--domains`, `--api-key`, `--api-base-url`, `--dir`, and `--force`. |
132
- | `--help` | Show the init command and its options. The help alias does the same. Add `--help` to a specific command for its syntax. |
133
-
134
- ### App Builder
135
-
136
- | Command | What it does |
137
- | --- | --- |
138
- | `app init [manifest.json]` | Select two saved Lyra agents. Defaults to `manifest.json` in your project. |
139
- | `app validate <manifest.json>` | Check the app manifest before previewing or exporting. |
140
- | `app preview <manifest.json>` | Preview the app in your browser on loopback. Set `LYRA_PREVIEW_PORT` to change its port. |
141
- | `app export <manifest.json> <new-directory>` | Export editable app source into a new directory. |
142
- | `app publish <manifest.json> --dry-run` | Print the proposed Marketplace payload for review. Submit the listing in the cloud. |
143
- | `app use <listing-id> [new-manifest.json]` | Import a published app and save its manifest. Requires `LYRA_SESSION_TOKEN`. |
144
-
145
- ### Agent runs and IDE integration
146
-
147
- | Command | What it does |
148
- | --- | --- |
149
- | `agent run --model <model> --prompt <text>` | Run a local agent with an OpenAI model. Requires `OPENAI_API_KEY`. |
150
- | `team run draft-review --model <model> --prompt <text>` | Run the built-in writer and reviewer team. Requires `OPENAI_API_KEY`. |
151
- | `run status <run-id>` | Read the latest event for a run from local SQLite history. |
152
- | `mcp serve --dir <absolute-project-directory>` | Expose saved runs to an IDE over read-only stdio MCP. |
153
-
154
- ## Use the library from JavaScript
155
-
156
- ```js
157
- import { createLinearWorkflow, runWorkflow } from "agent-lyra/standalone";
158
-
159
- const workflow = createLinearWorkflow(
160
- async () => "collect",
161
- async (context) => `${context.step_1}:analyze`,
162
- );
163
-
164
- console.log(await runWorkflow(workflow));
165
- ```
166
-
167
- The standalone entry point also includes retrieval utilities. The gated entry point is a compatibility client for deployments that expose the hosted invocation API. Check endpoint compatibility before using it with a cloud deployment.
168
-
169
- ## Current scope
170
-
171
- The App Builder supports two saved text agents in sequence. Publishing saved-agent app manifests to Marketplace is outside the current release. OpenAI-backed agent runs use your own provider key. Cloud accounts and AgentLyra API keys are managed in the [AgentLyra console](https://console.agentlyra.in/).
172
-
173
- MIT licensed.
1
+ # AgentLyra SDK
2
+
3
+ Build apps from your saved Lyra agents, run agents with your own OpenAI key, and inspect saved runs from your IDE. The Node.js package includes a command-line tool and typed JavaScript APIs for composing workflows.
4
+
5
+ [AgentLyra homepage](https://agentlyra.in/) · [CLI reference](https://agentlyra.in/#sdk-commands) · [Cloud console](https://console.agentlyra.in/)
6
+
7
+ ## Choose an SDK mode
8
+
9
+ | Mode | Where work runs | What you need |
10
+ | --- | --- | --- |
11
+ | **Work locally** | In your own Node.js process. Use `agent-lyra/standalone` for local workflows and retrieval, or run your own local workflows. | No AgentLyra account or key. Model-backed CLI runs use your own OpenAI key. |
12
+ | **Connect to Cloud** | On a compatible hosted backend. `agent-lyra/gated` calls the backend's `/agents/<vertical>/invoke` endpoint. | A Lyra API key for that backend and its base URL. For AgentLyra Cloud, use a dedicated SDK key and the base URL https://api.agentlyra.in/api/sdk/v1. Cloud SDK calls also require an OpenAI key in Models settings. |
13
+
14
+ The App Builder below uses a dedicated SDK key to run saved agents in AgentLyra Cloud. Standalone workflows remain available through the SDK and CLI.
15
+
16
+ ## Install
17
+
18
+ Requires **Node.js 22.13 or newer**. From your project directory:
19
+
20
+ ```bash
21
+ npm install agent-lyra
22
+ ```
23
+
24
+ Use `pnpm add agent-lyra` if your project uses pnpm. Run the CLI with `npx agent-lyra` after installation.
25
+
26
+ ## Cloud access
27
+
28
+ ### Switch workspace mode from your IDE
29
+
30
+ From the project folder, run one of these commands:
31
+
32
+ ```sh
33
+ npx.cmd agent-lyra connect-cloud
34
+ npx.cmd agent-lyra work-locally
35
+ ```
36
+
37
+ The first connection to Cloud prompts for an SDK key if none is available. Paste the key at the hidden prompt. The CLI saves a prompted key under `~/.agent-lyra/` for reuse by your OS account. Later switches reuse it. Run `npx.cmd agent-lyra connect-cloud --replace-key` to replace it. Working locally pauses Studio Cloud pulls and runs. Switching preserves your canvas and local agents. When connected to Cloud, you can use local and Cloud agents. If Studio is already open, click **Reload agents** to refresh the mode shown in its header.
38
+
39
+
40
+ ### Push a local text agent to Cloud
41
+
42
+ Generate a **Cloud sync key** on the API Keys page and set it with `npx.cmd agent-lyra connect-cloud --replace-key`. In Studio, click **Push to Cloud** on a local Markdown agent. From the terminal, use `npx.cmd agent-lyra studio push <local-agent-id>`. This sends the name and instructions and creates a private Cloud agent. Later pushes update the same agent. If the Cloud instructions or name changed, Studio stops before overwriting them. Use **Pull agent edits** on the linked card or `npx.cmd agent-lyra studio pull-agent <local-agent-id>` to bring the Cloud version back. If both copies changed, review them before updating either one. If your terminal already sets `LYRA_API_KEY`, that value takes priority over the saved key.
43
+
44
+ ### Sync a sequential workflow
45
+
46
+ Use a **Cloud sync key**. Push any local Markdown agents referenced by the workflow first. Save a workflow such as this one in `.lyra/workflows/review.json`:
47
+
48
+ ```json
49
+ {
50
+ "id": "review",
51
+ "name": "Draft and review",
52
+ "description": "Run two text agents in order.",
53
+ "runnable": true,
54
+ "steps": [
55
+ {"agentId": "local:writer", "task": "Draft a note.", "output": "draft"},
56
+ {"agentId": "local:reviewer", "task": "Review the draft.", "input": "draft"}
57
+ ]
58
+ }
59
+ ```
60
+
61
+ In Studio, use **Push to Cloud** on the workflow card. This creates a sequential workflow in your own Cloud account. Use **Pull workflow edits** on the same card to bring changes back. If both copies changed, syncing stops for review. Use **Pull from Cloud** to download references for any newly added Cloud agents. Canvas workflows and their triggers are outside this sync path.
62
+
63
+ From the terminal:
64
+
65
+ ```sh
66
+ npx.cmd agent-lyra studio push-workflow review
67
+ npx.cmd agent-lyra studio pull-workflow review
68
+ ```
69
+
70
+
71
+ ### Sync a personal team
72
+
73
+ Use a **Cloud sync key**. Push local agents first, then save a definition such as this one in `.lyra/teams/research.json`:
74
+
75
+ ```json
76
+ {"id":"research","name":"Research","description":"Draft and review research notes.","agentIds":["local:writer"]}
77
+ ```
78
+
79
+ Use **Push to Cloud** on the team card to create or update a private team where you are the only member. Use **Pull team edits** to bring back the name, description, and active assignments. Manage shared teams and teams with pending invitations or requests in the Cloud console. If you want to assign an agent that was removed or blocked, review it in the Cloud roster before syncing again.
80
+
81
+ ```sh
82
+ npx.cmd agent-lyra studio push-team research
83
+ npx.cmd agent-lyra studio pull-team research
84
+ ```
85
+
86
+
87
+ ### Sync a text skill
88
+
89
+ Use a **Cloud sync key**. Save a text definition such as this one in `.lyra/skills/notes.json`:
90
+
91
+ ```json
92
+ {"id":"notes","name":"Meeting notes","description":"Turn notes into a short recap.","body":"Summarize decisions and list next steps."}
93
+ ```
94
+
95
+ In Studio, use **Push to Cloud** on the skill card to create a private skill in your Cloud skill registry. Use **Pull skill edits** to bring back changes from Cloud. If both copies changed, sync stops for review. The skill's name, description, and text instructions can sync. Configure tool access and agent assignments separately. Executable Python skills stay in their local runtime.
96
+
97
+ ```sh
98
+ npx.cmd agent-lyra studio push-skill notes
99
+ npx.cmd agent-lyra studio pull-skill notes
100
+ ```
101
+
102
+
103
+ ### Add Cloud access with an environment variable
104
+
105
+ Standalone agents run in your project. Cloud agents run in AgentLyra Cloud. Studio can use both in one canvas. You can keep your existing `.lyra` files and `manifest.json`. Rerunning `init` or changing the manifest mode is unnecessary.
106
+
107
+ 1. Open [AgentLyra Console → API Keys](https://console.agentlyra.in/mcp-servers). Select **Generate SDK key** and copy the key beginning with `lyra_sdk_`.
108
+ 2. In VS Code, open a **PowerShell** terminal in your project. Run the line below, paste the key at the masked prompt, and press Enter. The key is available to this terminal and the programs it starts.
109
+
110
+ ```powershell
111
+ $env:LYRA_API_KEY = Read-Host "Paste your AgentLyra SDK key" -MaskInput
112
+ ```
113
+
114
+ 3. Start Studio from that same terminal. If it is already running, stop it first with **Ctrl+C** so it picks up the key.
115
+
116
+ ```sh
117
+ npx agent-lyra studio
118
+ ```
119
+
120
+ 4. Open the URL Studio prints and click **Pull from Cloud**. You can also pull from the terminal with `npx agent-lyra studio pull`. The pull adds agent references, workflows, team metadata, and skill references under `.lyra/` and preserves existing files.
121
+ 5. In the Inspector, choose the Cloud agent for an **Agent card**, or add it to a **Run button** sequence. Existing bindings keep using their current agents until you change them. To execute a Cloud agent, also configure your OpenAI key in **Console → Models**. The SDK key authorizes the pull and Cloud requests.
122
+
123
+ For exported apps with Cloud agents, set `LYRA_API_KEY` in the terminal that starts the exported app. Keep keys out of manifests and Git. If Studio asks for the SDK key after you set it, check that you launched Studio in the same terminal. If Cloud execution asks for a provider key, check **Console → Models**.
124
+
125
+
126
+ ## Build an app from your Lyra agents
127
+
128
+ Create two enabled text agents in AgentLyra Console. In [API key settings](https://console.agentlyra.in/mcp-servers), choose **Generate SDK key** and set it as `LYRA_API_KEY` in your terminal environment. Add your own OpenAI key in Console → Models. Keep both keys out of source control.
129
+
130
+ ```bash
131
+ npx agent-lyra app init
132
+ npx agent-lyra app validate manifest.json
133
+ npx agent-lyra app preview manifest.json
134
+ ```
135
+
136
+ Choose the agents in the order they should run. The CLI creates one `manifest.json` in your project. Open the URL printed by the preview and enter some text. The first agent runs on that input, then the second receives the input and first result. The browser shows both outputs. This version runs each saved agent's instructions as text-only; connected tools and skills are outside this workflow.
137
+
138
+ Stop the preview or open a new terminal, then export into a new folder:
139
+
140
+ ```bash
141
+ npx agent-lyra app export manifest.json ./my-app
142
+ cd my-app
143
+ npm start
144
+ ```
145
+
146
+ The export contains editable HTML, a Node.js server, the runtime, and the app manifest. Keep `LYRA_API_KEY` in the server environment. The exported server binds to loopback and the two agents continue to run in Cloud.
147
+
148
+ ## Choose the workflow you need
149
+
150
+ | I want to… | Start here |
151
+ | --- | --- |
152
+ | Build a drag-and-drop app | [Local Studio](#local-studio) |
153
+ | Set up a repo with starter agent definitions | `npx agent-lyra init` |
154
+ | Build and export an app from your own saved agents | [Build an app from your Lyra agents](#build-an-app-from-your-lyra-agents) |
155
+ | Run a model-backed agent from my terminal | [Run an agent](#run-an-agent) |
156
+ | Inspect saved runs inside my IDE | [Connect your IDE](#connect-your-ide) |
157
+ | Share or import an app | [Use the Marketplace](#use-the-marketplace) |
158
+
159
+ ### Run an agent
160
+
161
+ Set `OPENAI_API_KEY` in your environment. Replace `YOUR_MODEL` with an OpenAI model available to your key.
162
+
163
+ ```bash
164
+ npx agent-lyra agent run --model YOUR_MODEL --prompt "Draft a project update"
165
+ npx agent-lyra run status YOUR_RUN_ID
166
+ ```
167
+
168
+ Copy the run ID printed by the first command into the second. The CLI saves run events locally in `.lyra/state/runs.sqlite`. To run a writer followed by a reviewer, use `team run draft-review` with the same model and prompt flags.
169
+
170
+ ### Connect your IDE
171
+
172
+ Configure a stdio MCP server with the installed `agent-lyra` executable, using its absolute path if your IDE requires one. Set the arguments to:
173
+
174
+ ```json
175
+ ["mcp", "serve", "--dir", "ABSOLUTE_PROJECT_PATH"]
176
+ ```
177
+
178
+ The MCP server reads saved runs from that project.
179
+
180
+ ### Use the Marketplace
181
+
182
+ Generate a shareable listing preview with `npx agent-lyra app publish .lyra/app/manifest.json --dry-run`. Review it before submitting the listing in the cloud. Browse apps publicly, then sign in to import an editable private copy. CLI imports require an existing Lyra session supplied through `LYRA_SESSION_TOKEN`. [Marketplace Apps](https://agentlyra.in/marketplace/apps)
183
+
184
+ ## Local Studio
185
+
186
+ ```bash
187
+ npx agent-lyra studio
188
+ ```
189
+
190
+ Open the printed loopback URL. Drag a heading, text, input, text area, run button, or output onto the canvas. You can also add components by clicking them. Select a run button in the inspector, bind an input and output, and add agents or compatible workflows in the order they should run. **Save layout** writes the layout into your root `manifest.json`.
191
+
192
+ Studio reads standalone Markdown agents from `.lyra/agents/`. Each needs an `id`, a `name`, and a `## System Prompt` section. To run a local agent, set `OPENAI_API_KEY` and choose a model in the Run now drawer. Override the model list with a comma-separated `LYRA_STUDIO_MODELS` environment variable if needed.
193
+
194
+ Follow [Add Cloud access](#cloud-access) to import Cloud resources. Studio runs compatible sequential text workflows. Canvas workflows and teams appear as references.
195
+
196
+ Add an **Agent card** to let users run one agent directly from the app. Choose the agent in the Inspector and optionally bind an input and an output. Use a **Run button** for a sequence of agents or workflows.
197
+
198
+ Save the canvas in Studio and export it with `npx agent-lyra app export manifest.json ./my-app`. Open the new folder and run `npm start` to launch the app locally. The export keeps the component layout and Run button bindings. It includes the prompts of referenced local agents and the IDs of referenced Cloud agents. Supply your API keys through environment variables when starting the app.
199
+
200
+
201
+ ### Run a Python skill from the canvas
202
+
203
+ Install the Python SDK in your environment. Create `.lyra/agents/draft.py`:
204
+
205
+ ```python
206
+ from lyra.standalone import Agent, Skill
207
+
208
+ def draft(text):
209
+ return f"Draft: {text}"
210
+
211
+ agent = Agent("draft", [Skill("draft-note", draft)])
212
+ ```
213
+
214
+ Register the skill in `.lyra/agents/draft.json`:
215
+
216
+ ```json
217
+ {"id":"draft","name":"Draft a note","runtime":"python","file":"draft.py","skill":"draft-note"}
218
+ ```
219
+
220
+ Restart Studio or click **Reload agents**. Select **Draft a note** on an Agent card, or add it to a Run button's execution order. Studio passes the input as a string, along with any previous step result. Skills may return strings or JSON-serializable values. The Python CLI uses its own interpreter. If you launch Studio from npm or start an exported app, set `LYRA_PYTHON` to your virtual environment's Python executable when needed.
221
+
222
+ Export includes the Python files bound to the canvas. Install the Python SDK and any dependencies in the environment running the export. If an agent imports other project files, add those files to the exported project and make them importable in that environment. Run Python agents from projects whose source you trust.
223
+
224
+ ## Local memory
225
+
226
+ Local memory stores notes you explicitly record in `.lyra/memory/memory.db`. It works offline and does not need an AgentLyra account. Each new note is a candidate. Use a reviewed test receipt to verify a coding correction. Automatic capture is outside this release. Cloud sync is optional and record by record.
227
+
228
+ Run commands from the folder you want to associate with the database:
229
+
230
+ ```sh
231
+ npx agent-lyra memory init
232
+ npx agent-lyra memory record lesson.json
233
+ npx agent-lyra memory search "nullable GraphQL"
234
+ npx agent-lyra memory list
235
+ npx agent-lyra memory stats
236
+ ```
237
+
238
+ Example `lesson.json`:
239
+
240
+ ```json
241
+ {
242
+ "type": "corrective",
243
+ "title": "Handle nullable API fields",
244
+ "learning": "Show the fallback when the response field is null.",
245
+ "evidence": ["test:nullable-response"]
246
+ }
247
+ ```
248
+
249
+ Evidence IDs are references. Recording an ID does not verify the lesson. Copy the ID returned by `record` into `memory inspect <id>`, `memory archive <id>`, or `memory forget <id> --yes`. Archive keeps the record for inspection and excludes it from search. Forget removes the content from normal store access and retains a deletion marker with the ID, revision, and deletion time.
250
+
251
+ Set `LYRA_MEMORY=off` in the launching process to disable local memory. Store only information appropriate for your machine. The database is plain SQLite and the memory folder has its own Git ignore file. Use OS account protections or disk encryption as appropriate. Close all memory clients before copying the database for a backup or before restoring it to another project. WAL files and older backups may retain deleted content.
252
+
253
+
254
+ Use `openMemoryStore(projectPath)` from `agent-lyra/memory` for programmatic access. Close the store after use.
255
+
256
+ ### Verify a coding correction
257
+
258
+ Run your test, review whether it supports the correction, and record the test reference in the memory's `evidence` list. Save a receipt like this as `evidence.json`:
259
+
260
+ ```json
261
+ {
262
+ "adapter": "coding",
263
+ "evidenceId": "test:nullable-response",
264
+ "test": "nullable-response",
265
+ "result": "passed",
266
+ "reviewed": true,
267
+ "context": "graphql-client@1"
268
+ }
269
+ ```
270
+
271
+ ```sh
272
+ npx agent-lyra memory verify MEMORY_ID evidence.json
273
+ ```
274
+
275
+ This command checks the receipt and recorded evidence reference. The developer supplies the test result and attests to the review. The command does not run the test or independently prove the correction.
276
+
277
+ For model-backed local runs, set `LYRA_MEMORY_CONTEXT` to the same compatibility tag in the terminal that launches the Node CLI or Studio. Use a new tag when relevant dependencies or assumptions change. The runner includes a few relevant verified memories as historical context and keeps the current request intact. Starting without a tag leaves retrieval off. Native Python callers can use `MemoryStore.retrieve(query, context)` explicitly. Python skills, Cloud agents, and exported apps do not automatically retrieve project memory.
278
+
279
+
280
+ ### Practice exercise adapter
281
+
282
+ The experimental `practice` adapter supports self-contained training exercises. Record a procedural or corrective lesson with an `exercise:` evidence ID, then verify it with a reviewed passing receipt. For example:
283
+
284
+ ```json
285
+ {"adapter":"practice","evidenceId":"exercise:async-sequence","exercise":"async-sequence","result":"passed","reviewed":true,"context":"async-practice@1"}
286
+ ```
287
+
288
+ Set `LYRA_MEMORY_ADAPTER=practice` and `LYRA_MEMORY_CONTEXT=async-practice@1` for a model-backed local run. The default adapter is `coding`. Retrieval filters by both adapter and compatibility context. Skill proposal consolidation currently uses coding corrections.
289
+
290
+ From the AgentLyra source checkout, run `node packages/lyra/examples/evaluate-practice-memory.js` to compare a synthetic task with memory off, memory on, and a stale compatibility context. The example uses a fixed model response to test context assembly. It does not measure learning outcomes or live model quality.
291
+
292
+ ### Review a skill proposal
293
+
294
+ Consolidation groups verified corrections with matching wording, a shared compatibility tag, and distinct test references. It reports the groups without changing the source memories. Use a memory ID from one group to draft a proposal.
295
+
296
+ ```sh
297
+ npx agent-lyra memory consolidate graphql-client@1
298
+ npx agent-lyra skills evolve graphql-client@1 MEMORY_ID
299
+ npx agent-lyra skills proposal PROPOSAL_ID
300
+ ```
301
+
302
+ Review the draft Markdown and run a separate regression test. Save a receipt such as this one as `regression.json`:
303
+
304
+ ```json
305
+ {"evidenceId":"test:skill-regression","context":"graphql-client@1","result":"passed","reviewed":true}
306
+ ```
307
+
308
+ ```sh
309
+ npx agent-lyra skills approve PROPOSAL_ID regression.json
310
+ ```
311
+
312
+ The approval records your review. It does not install the proposal or edit any skill file. Use `skills proposals` to list drafts, `skills reject PROPOSAL_ID` to reject a pending proposal, or `skills withdraw PROPOSAL_ID` to revoke an approval. These commands do not run tests themselves. Forgetting a source memory removes its dependent proposals from the local store.
313
+
314
+ ### Sync selected memories to Cloud
315
+
316
+ Local memory stays on your machine by default. To sync a record, generate a **Memory sync key** in [Console → API Keys](https://console.agentlyra.in/mcp-servers). This key is separate from the keys for running agents and syncing other resources. In PowerShell, enter the key at the masked prompt:
317
+
318
+ ```powershell
319
+ $env:LYRA_MEMORY_KEY = (Read-Host 'Paste your Memory sync key' -MaskInput).Trim()
320
+ ```
321
+
322
+ From the same terminal, preview a verified record and then explicitly confirm the upload:
323
+
324
+ ```sh
325
+ npx agent-lyra memory cloud preview MEMORY_ID
326
+ npx agent-lyra memory cloud push MEMORY_ID --yes
327
+ ```
328
+
329
+ The preview shows the name, lesson, type, and evidence IDs that will be sent. Review it for personal or proprietary information. Model requests, run transcripts, files, approvals, and working state are outside this sync path.
330
+
331
+ In a second project or machine, use the same Cloud account and run:
332
+
333
+ ```sh
334
+ npx agent-lyra memory cloud list
335
+ npx agent-lyra memory cloud pull MEMORY_ID
336
+ ```
337
+
338
+ Imported records start as candidates and require local review before an agent can retrieve them. If the two copies changed, sync stops. Review both before changing either one. To propagate a deletion, run `memory forget MEMORY_ID --yes` locally. Preview and push that ID again to remove its Cloud content. In the other project, pull the ID to apply the deletion when its local copy has no conflicting changes.
339
+
340
+ Cloud sync is manual and uses Node.js for the shared CLI. Revoking the key blocks future requests. Previously downloaded local copies remain until removed from their workspaces.
341
+
342
+
343
+ ## CLI reference
344
+
345
+ Prefix each command with `npx agent-lyra`. Angle brackets indicate required arguments. Square brackets indicate optional arguments.
346
+
347
+ ### Project setup
348
+
349
+ | Command | What it does |
350
+ | --- | --- |
351
+ | `init [options]` | Scaffold a `.lyra` workspace and starter agents. Options include `--mode`, `--domains`, `--api-key`, `--api-base-url`, `--dir`, and `--force`. |
352
+ | `--help` | Show the init command and its options. The help alias does the same. Add `--help` to a specific command for its syntax. |
353
+
354
+ ### Studio and App Builder
355
+
356
+ | Command | What it does |
357
+ | --- | --- |
358
+ | `studio` | Open the drag-and-drop canvas. |
359
+ | `studio pull` | Import Cloud agents, workflows, and teams. Requires `LYRA_API_KEY`. |
360
+ | `app init [manifest.json]` | Select two saved Lyra agents. Defaults to `manifest.json` in your project. |
361
+ | `app validate <manifest.json>` | Check the app manifest before previewing or exporting. |
362
+ | `app preview <manifest.json>` | Preview the app in your browser on loopback. Set `LYRA_PREVIEW_PORT` to change its port. |
363
+ | `app export <manifest.json> <new-directory>` | Export editable app source into a new directory. |
364
+ | `app publish <manifest.json> --dry-run` | Print the proposed Marketplace payload for review. Submit the listing in the cloud. |
365
+ | `app use <listing-id> [new-manifest.json]` | Import a published app and save its manifest. Requires `LYRA_SESSION_TOKEN`. |
366
+
367
+ ### Agent runs and IDE integration
368
+
369
+ | Command | What it does |
370
+ | --- | --- |
371
+ | `agent run --model <model> --prompt <text>` | Run a local agent with an OpenAI model. Requires `OPENAI_API_KEY`. |
372
+ | `team run draft-review --model <model> --prompt <text>` | Run the built-in writer and reviewer team. Requires `OPENAI_API_KEY`. |
373
+ | `run status <run-id>` | Read the latest event for a run from local SQLite history. |
374
+ | `mcp serve --dir <absolute-project-directory>` | Expose saved runs to an IDE over read-only stdio MCP. |
375
+
376
+ ## Use the library from JavaScript
377
+
378
+ ```js
379
+ import { createLinearWorkflow, runWorkflow } from "agent-lyra/standalone";
380
+
381
+ const workflow = createLinearWorkflow(
382
+ async () => "collect",
383
+ async (context) => `${context.step_1}:analyze`,
384
+ );
385
+
386
+ console.log(await runWorkflow(workflow));
387
+ ```
388
+
389
+ The standalone entry point also includes retrieval utilities. The gated entry point is a compatibility client for deployments that expose the hosted invocation API. Check endpoint compatibility before using it with a cloud deployment.
390
+
391
+ ## Current scope
392
+
393
+ The App Builder supports two saved text agents in sequence. Publishing saved-agent app manifests to Marketplace is outside the current release. OpenAI-backed agent runs use your own provider key. Cloud accounts and AgentLyra API keys are managed in the [AgentLyra console](https://console.agentlyra.in/).
394
+
395
+ MIT licensed.
package/bin/agent-lyra.js CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { runSkillProposals } from "../src/memory/skills-cli.js";
4
+ import { runMemory } from "../src/memory/cli.js";
3
5
  import { runCli } from "../src/init.js";
4
6
  import { runLocalCli } from "../src/runtime/local-cli.js";
5
7
  import { serveSavedRuns } from "../src/runtime/mcp-stdio.js";
@@ -10,10 +12,21 @@ import { runAppPreview } from "../src/app-builder/preview.js";
10
12
  import { runAppPublish } from "../src/app-builder/publish.js";
11
13
  import { runAppUse } from "../src/app-builder/use.js";
12
14
 
13
- import { runStudio } from "../src/studio/server.js";
14
-
15
+ import { readMode, readSdkKey, requireCloudMode, switchMode } from "../src/studio/session.js";
16
+ import { runStudio } from "../src/studio/server.js";
17
+
15
18
  async function main() {
16
- const argv = process.argv.slice(2);
19
+ const argv = process.argv.slice(2);
20
+ if (argv[0] === "skills") return runSkillProposals(argv.slice(1));
21
+ if (argv[0] === "memory") return runMemory(argv.slice(1));
22
+ if (argv[0] === "connect-cloud") return switchMode(process.cwd(), "gated", argv.slice(1));
23
+ if (argv[0] === "work-locally") return switchMode(process.cwd(), "standalone", argv.slice(1));
24
+ if (["gated", "standalone"].includes(argv[0])) return switchMode(process.cwd(), argv[0], argv.slice(1));
25
+ if (argv[0] === "app" && ["init", "preview"].includes(argv[1]) && !argv.includes("--help")) {
26
+ if (argv[1] === "init") requireCloudMode(await readMode(process.cwd()));
27
+ const key = await readSdkKey(process.cwd());
28
+ if (key) process.env.LYRA_API_KEY = key;
29
+ }
17
30
  if (argv[0] === "studio") return runStudio(argv.slice(1));
18
31
  if (argv[0] === "app" && argv[1] === "use") return runAppUse(argv.slice(2));
19
32
  if (argv[0] === "app" && argv[1] === "init") return runAppInit(argv.slice(2));