markdown-agent-studio 0.2.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/LICENSE +21 -0
- package/README.md +80 -0
- package/bin/markdown-agent-studio.js +282 -0
- package/dist/assets/index-C7HrwdLI.js +1188 -0
- package/dist/assets/index-DKT7U-mY.css +1 -0
- package/dist/assets/vendor-flow-DOjU6Ffq.js +7 -0
- package/dist/assets/vendor-google-eZp-A-GY.js +2 -0
- package/dist/assets/vendor-markdown-DmDC9MiR.js +37 -0
- package/dist/assets/vendor-monaco-DeQXaAoV.js +11 -0
- package/dist/assets/vendor-react-l0sNRNKZ.js +1 -0
- package/dist/index.html +22 -0
- package/dist/vite.svg +1 -0
- package/index.d.ts +4 -0
- package/index.js +8 -0
- package/package.json +117 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RobThePCGuy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Markdown Agent Studio
|
|
2
|
+
|
|
3
|
+
A browser IDE for defining, running, and observing multi-agent workflows from Markdown files.
|
|
4
|
+
|
|
5
|
+
## Highlights
|
|
6
|
+
|
|
7
|
+
- Agent definitions in `agents/*.md` with YAML frontmatter.
|
|
8
|
+
- Real-time run visualization in a graph view.
|
|
9
|
+
- Inspector panels for Chat, Events, and Memory.
|
|
10
|
+
- Event-log restore/replay support.
|
|
11
|
+
- Built-in scripted demo mode when no API key is provided.
|
|
12
|
+
- Gemini-backed live runs when an API key is set.
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
Requires Node.js `20.19+`.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git clone https://github.com/RobThePCGuy/markdown-agent-studio.git
|
|
20
|
+
cd markdown-agent-studio
|
|
21
|
+
npm install
|
|
22
|
+
npm run dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Open `http://localhost:5173`.
|
|
26
|
+
|
|
27
|
+
## Configuration
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cp .env.example .env.local
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Set:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
VITE_GEMINI_API_KEY=your_key_here
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## npm Usage
|
|
40
|
+
|
|
41
|
+
Install:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install markdown-agent-studio
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use exported `dist` path:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import distPath from 'markdown-agent-studio';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Run immediately with npx (starts local static server and opens your browser):
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx markdown-agent-studio
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
- `--port 4173`
|
|
61
|
+
- `--host 127.0.0.1`
|
|
62
|
+
- `--no-open`
|
|
63
|
+
|
|
64
|
+
Or host `distPath` with your own static server.
|
|
65
|
+
|
|
66
|
+
## Key Commands
|
|
67
|
+
|
|
68
|
+
- `npm run check:all`
|
|
69
|
+
- `npm run release -- patch` (or `minor` / `major`)
|
|
70
|
+
- `npm run commit:publish -- --message "chore(release): vX.Y.Z" --bump patch`
|
|
71
|
+
- `npm publish --access public` (use `--provenance` only in supported CI, e.g. GitHub Actions)
|
|
72
|
+
|
|
73
|
+
## Docs
|
|
74
|
+
|
|
75
|
+
- Full guide: <https://github.com/RobThePCGuy/markdown-agent-studio/blob/main/docs/README_FULL.md>
|
|
76
|
+
- Release script: `scripts/release.sh`
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { createReadStream, existsSync, statSync } from 'node:fs';
|
|
5
|
+
import { createServer } from 'node:http';
|
|
6
|
+
import { dirname, extname, join, normalize, sep } from 'node:path';
|
|
7
|
+
import { platform, release } from 'node:os';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_HOST = '127.0.0.1';
|
|
11
|
+
const DEFAULT_PORT = 4173;
|
|
12
|
+
const MAX_PORT_ATTEMPTS = 20;
|
|
13
|
+
|
|
14
|
+
const MIME_TYPES = {
|
|
15
|
+
'.css': 'text/css; charset=utf-8',
|
|
16
|
+
'.html': 'text/html; charset=utf-8',
|
|
17
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
18
|
+
'.json': 'application/json; charset=utf-8',
|
|
19
|
+
'.map': 'application/json; charset=utf-8',
|
|
20
|
+
'.png': 'image/png',
|
|
21
|
+
'.svg': 'image/svg+xml',
|
|
22
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
23
|
+
'.woff': 'font/woff',
|
|
24
|
+
'.woff2': 'font/woff2',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function usage() {
|
|
28
|
+
console.log('Usage: npx markdown-agent-studio [--port <number>] [--host <host>] [--no-open]');
|
|
29
|
+
console.log(' --port Server port (default: 4173)');
|
|
30
|
+
console.log(' --host Bind host (default: 127.0.0.1)');
|
|
31
|
+
console.log(' --no-open Do not auto-open browser');
|
|
32
|
+
console.log(' -h, --help Show this help');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseArgs(argv) {
|
|
36
|
+
const options = {
|
|
37
|
+
host: DEFAULT_HOST,
|
|
38
|
+
openBrowser: true,
|
|
39
|
+
port: DEFAULT_PORT,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
43
|
+
const arg = argv[index];
|
|
44
|
+
|
|
45
|
+
if (arg === '-h' || arg === '--help') {
|
|
46
|
+
usage();
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (arg === '--no-open') {
|
|
51
|
+
options.openBrowser = false;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (arg === '--port') {
|
|
56
|
+
const value = argv[index + 1];
|
|
57
|
+
if (!value) {
|
|
58
|
+
throw new Error('Missing value for --port');
|
|
59
|
+
}
|
|
60
|
+
const parsed = Number.parseInt(value, 10);
|
|
61
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65535) {
|
|
62
|
+
throw new Error(`Invalid --port value: ${value}`);
|
|
63
|
+
}
|
|
64
|
+
options.port = parsed;
|
|
65
|
+
index += 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (arg === '--host') {
|
|
70
|
+
const value = argv[index + 1];
|
|
71
|
+
if (!value) {
|
|
72
|
+
throw new Error('Missing value for --host');
|
|
73
|
+
}
|
|
74
|
+
options.host = value;
|
|
75
|
+
index += 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return options;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function safeResolveDistPath(distPath, requestPath) {
|
|
86
|
+
const relativePath = requestPath.replace(/^\/+/, '');
|
|
87
|
+
const resolvedPath = normalize(join(distPath, relativePath));
|
|
88
|
+
const inDistRoot = resolvedPath === distPath;
|
|
89
|
+
const inDistTree = resolvedPath.startsWith(`${distPath}${sep}`);
|
|
90
|
+
if (!inDistRoot && !inDistTree) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return resolvedPath;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getContentType(filePath) {
|
|
97
|
+
const extension = extname(filePath).toLowerCase();
|
|
98
|
+
return MIME_TYPES[extension] ?? 'application/octet-stream';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function serveFile(filePath, response, method) {
|
|
102
|
+
try {
|
|
103
|
+
const fileStat = statSync(filePath);
|
|
104
|
+
if (!fileStat.isFile()) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
response.writeHead(200, {
|
|
109
|
+
'Cache-Control': 'no-cache',
|
|
110
|
+
'Content-Length': fileStat.size,
|
|
111
|
+
'Content-Type': getContentType(filePath),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (method === 'HEAD') {
|
|
115
|
+
response.end();
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const stream = createReadStream(filePath);
|
|
120
|
+
stream.on('error', () => {
|
|
121
|
+
response.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
122
|
+
response.end('Internal server error');
|
|
123
|
+
});
|
|
124
|
+
stream.pipe(response);
|
|
125
|
+
return true;
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function browserCommands(url) {
|
|
132
|
+
if (platform() === 'darwin') {
|
|
133
|
+
return [['open', [url]]];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (platform() === 'win32') {
|
|
137
|
+
return [['cmd', ['/c', 'start', '', url]]];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const candidates = [];
|
|
141
|
+
if (/microsoft/i.test(release())) {
|
|
142
|
+
candidates.push(['wslview', [url]]);
|
|
143
|
+
}
|
|
144
|
+
candidates.push(['xdg-open', [url]]);
|
|
145
|
+
return candidates;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function openInBrowser(url) {
|
|
149
|
+
for (const [command, args] of browserCommands(url)) {
|
|
150
|
+
const result = spawnSync(command, args, { stdio: 'ignore' });
|
|
151
|
+
if (!result.error && result.status === 0) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function start() {
|
|
159
|
+
let options;
|
|
160
|
+
try {
|
|
161
|
+
options = parseArgs(process.argv.slice(2));
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
164
|
+
usage();
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
169
|
+
const distPath = join(packageDir, 'dist');
|
|
170
|
+
|
|
171
|
+
if (!existsSync(distPath)) {
|
|
172
|
+
console.error('Error: dist/ not found. Reinstall package or run a fresh publish build.');
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const indexHtmlPath = join(distPath, 'index.html');
|
|
177
|
+
if (!existsSync(indexHtmlPath)) {
|
|
178
|
+
console.error('Error: dist/index.html not found. Package appears incomplete.');
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const server = createServer((request, response) => {
|
|
183
|
+
const method = request.method ?? 'GET';
|
|
184
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
185
|
+
response.writeHead(405, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
186
|
+
response.end('Method not allowed');
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let pathname = '/';
|
|
191
|
+
try {
|
|
192
|
+
const url = new URL(request.url ?? '/', 'http://127.0.0.1');
|
|
193
|
+
pathname = decodeURIComponent(url.pathname || '/');
|
|
194
|
+
} catch {
|
|
195
|
+
response.writeHead(400, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
196
|
+
response.end('Bad request');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (pathname.endsWith('/')) {
|
|
201
|
+
pathname = `${pathname}index.html`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const assetPath = safeResolveDistPath(distPath, pathname);
|
|
205
|
+
if (!assetPath) {
|
|
206
|
+
response.writeHead(403, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
207
|
+
response.end('Forbidden');
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const requestHasExtension = extname(pathname).length > 0;
|
|
212
|
+
const servedAsset = serveFile(assetPath, response, method);
|
|
213
|
+
if (servedAsset) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!requestHasExtension) {
|
|
218
|
+
const servedIndex = serveFile(indexHtmlPath, response, method);
|
|
219
|
+
if (servedIndex) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
response.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
225
|
+
response.end('Not found');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
let listeningPort = options.port;
|
|
229
|
+
for (;;) {
|
|
230
|
+
try {
|
|
231
|
+
await new Promise((resolve, reject) => {
|
|
232
|
+
const onError = (error) => {
|
|
233
|
+
server.off('listening', onListening);
|
|
234
|
+
reject(error);
|
|
235
|
+
};
|
|
236
|
+
const onListening = () => {
|
|
237
|
+
server.off('error', onError);
|
|
238
|
+
resolve();
|
|
239
|
+
};
|
|
240
|
+
server.once('error', onError);
|
|
241
|
+
server.once('listening', onListening);
|
|
242
|
+
server.listen(listeningPort, options.host);
|
|
243
|
+
});
|
|
244
|
+
break;
|
|
245
|
+
} catch (error) {
|
|
246
|
+
const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
|
|
247
|
+
if (code !== 'EADDRINUSE' || listeningPort >= options.port + MAX_PORT_ATTEMPTS) {
|
|
248
|
+
console.error(
|
|
249
|
+
`Failed to start server on ${options.host}:${listeningPort}: ${
|
|
250
|
+
error instanceof Error ? error.message : String(error)
|
|
251
|
+
}`,
|
|
252
|
+
);
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
listeningPort += 1;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const browserHost = options.host === '0.0.0.0' ? '127.0.0.1' : options.host;
|
|
260
|
+
const url = `http://${browserHost}:${listeningPort}`;
|
|
261
|
+
|
|
262
|
+
console.log(`Markdown Agent Studio running at ${url}`);
|
|
263
|
+
if (options.openBrowser) {
|
|
264
|
+
const opened = openInBrowser(url);
|
|
265
|
+
if (opened) {
|
|
266
|
+
console.log('Opened browser.');
|
|
267
|
+
} else {
|
|
268
|
+
console.log('Could not auto-open browser on this system. Open the URL manually.');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
console.log('Press Ctrl+C to stop.');
|
|
272
|
+
|
|
273
|
+
const shutdown = () => {
|
|
274
|
+
server.close(() => {
|
|
275
|
+
process.exit(0);
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
process.on('SIGINT', shutdown);
|
|
279
|
+
process.on('SIGTERM', shutdown);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
start();
|