@mindstudio-ai/local-model-tunnel 0.5.7 → 0.5.9
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 +183 -11
- package/dist/{chunk-KLOTDVWL.js → chunk-253MU7UA.js} +56 -310
- package/dist/chunk-253MU7UA.js.map +1 -0
- package/dist/chunk-4CMGJFH3.js +1508 -0
- package/dist/chunk-4CMGJFH3.js.map +1 -0
- package/dist/chunk-UNG63WXC.js +368 -0
- package/dist/chunk-UNG63WXC.js.map +1 -0
- package/dist/cli.js +18 -2
- package/dist/cli.js.map +1 -1
- package/dist/headless.d.ts +113 -0
- package/dist/headless.js +8 -0
- package/dist/headless.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -2
- package/dist/{tui-UNFZSO7R.js → tui-343LXUFQ.js} +1454 -318
- package/dist/tui-343LXUFQ.js.map +1 -0
- package/package.json +4 -1
- package/dist/chunk-KLOTDVWL.js.map +0 -1
- package/dist/tui-UNFZSO7R.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MindStudio Local Tunnel
|
|
2
2
|
|
|
3
|
-
Local tunnel for MindStudio. Use your own locally-running AI models, and edit custom interfaces and scripts
|
|
3
|
+
Local tunnel for MindStudio. Use your own locally-running AI models, develop v2 apps with live preview, and edit custom interfaces and scripts — all from your own machine.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -41,6 +41,159 @@ The app will walk you through connecting your MindStudio account and getting set
|
|
|
41
41
|
|
|
42
42
|
## Features
|
|
43
43
|
|
|
44
|
+
### Apps v2 Local Dev Mode
|
|
45
|
+
|
|
46
|
+
Develop MindStudio Apps v2 locally with instant feedback. The CLI detects your `mindstudio.json`, starts a dev session, and gives you live preview with real auth, databases, and method execution — all running on your machine.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd my-app # must contain mindstudio.json with "appId"
|
|
50
|
+
mindstudio-local
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**What happens:**
|
|
54
|
+
|
|
55
|
+
1. The CLI reads `mindstudio.json` and enters dev mode automatically
|
|
56
|
+
2. Installs dependencies if needed (`npm install` in method/frontend dirs)
|
|
57
|
+
3. Starts your frontend dev server (Vite, webpack, etc.)
|
|
58
|
+
4. Connects to the MindStudio platform and syncs your table schemas
|
|
59
|
+
5. Starts a local proxy that serves your frontend with platform context injected
|
|
60
|
+
6. Polls for method execution requests and runs them locally (transpiled on the fly)
|
|
61
|
+
|
|
62
|
+
**The TUI shows:**
|
|
63
|
+
|
|
64
|
+
- Session status, branch, and preview URL
|
|
65
|
+
- Tabbed views: Info, Requests, Methods, Dev Server logs
|
|
66
|
+
- Schema sync results
|
|
67
|
+
- Live method execution log with timing and errors
|
|
68
|
+
|
|
69
|
+
**Key details:**
|
|
70
|
+
|
|
71
|
+
- Methods are transpiled with esbuild and executed in isolated Node.js child processes
|
|
72
|
+
- `@mindstudio-ai/agent` SDK works identically — database queries, auth checks, etc. all go through the real platform
|
|
73
|
+
- The local proxy injects `window.__MINDSTUDIO__` into HTML so the frontend SDK works
|
|
74
|
+
- Changes to `mindstudio.json` trigger an automatic session restart
|
|
75
|
+
- Frontend HMR works through the proxy (WebSocket upgrades are forwarded)
|
|
76
|
+
|
|
77
|
+
### Headless Mode
|
|
78
|
+
|
|
79
|
+
Run the dev tunnel without a TUI for programmatic control. Designed for hosted sandboxes, CI pipelines, or any automation that needs the tunnel as a background service.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
mindstudio-local --headless --port 5173 --bind 0.0.0.0
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Headless mode does NOT start a dev server** — the caller manages that separately. The `--port` flag tells the tunnel which port to proxy to.
|
|
86
|
+
|
|
87
|
+
#### CLI Flags
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
mindstudio-local --headless [options]
|
|
91
|
+
|
|
92
|
+
Options:
|
|
93
|
+
--headless Run without TUI, output JSON events to stdout
|
|
94
|
+
--port <n> Dev server port to proxy to (default: from web.json)
|
|
95
|
+
--proxy-port <n> Preferred proxy port (default: auto from app ID)
|
|
96
|
+
--bind <addr> Proxy bind address (default: 127.0.0.1)
|
|
97
|
+
--log-level <level> Log verbosity: error, warn, info, debug (default: info)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### JSON Event Protocol
|
|
101
|
+
|
|
102
|
+
Stdout emits newline-delimited JSON events — one object per line:
|
|
103
|
+
|
|
104
|
+
| Event | Key Fields | When |
|
|
105
|
+
|-------|-----------|------|
|
|
106
|
+
| `starting` | `appId`, `name` | Initializing |
|
|
107
|
+
| `session-started` | `sessionId`, `branch`, `proxyPort`, `proxyUrl` | Session active, proxy running |
|
|
108
|
+
| `schema-synced` | `created`, `altered`, `errors` | Table schema synced |
|
|
109
|
+
| `method-start` | `id`, `method` | Method execution received |
|
|
110
|
+
| `method-complete` | `id`, `success`, `duration`, `error?` | Method execution finished |
|
|
111
|
+
| `connection-warning` | `message` | Lost platform connection |
|
|
112
|
+
| `connection-restored` | | Reconnected |
|
|
113
|
+
| `session-expired` | | Platform expired session (exits with code 1) |
|
|
114
|
+
| `error` | `message` | Fatal error |
|
|
115
|
+
| `stopping` | | Graceful shutdown initiated |
|
|
116
|
+
| `stopped` | | Cleanup complete, exiting |
|
|
117
|
+
|
|
118
|
+
#### Spawning from a Parent Process
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
const { spawn } = require('child_process');
|
|
122
|
+
|
|
123
|
+
const tunnel = spawn('mindstudio-local', [
|
|
124
|
+
'--headless', '--port', '5173', '--bind', '0.0.0.0'
|
|
125
|
+
], {
|
|
126
|
+
cwd: '/path/to/app',
|
|
127
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// JSON events from stdout
|
|
131
|
+
let buffer = '';
|
|
132
|
+
tunnel.stdout.on('data', (chunk) => {
|
|
133
|
+
buffer += chunk.toString();
|
|
134
|
+
let idx;
|
|
135
|
+
while ((idx = buffer.indexOf('\n')) !== -1) {
|
|
136
|
+
const event = JSON.parse(buffer.slice(0, idx));
|
|
137
|
+
buffer = buffer.slice(idx + 1);
|
|
138
|
+
|
|
139
|
+
if (event.event === 'session-started') {
|
|
140
|
+
console.log('Preview:', event.proxyUrl);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Structured logs from stderr
|
|
146
|
+
tunnel.stderr.on('data', (chunk) => {
|
|
147
|
+
console.error('[tunnel]', chunk.toString().trimEnd());
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Graceful shutdown
|
|
151
|
+
process.on('SIGTERM', () => tunnel.kill('SIGTERM'));
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Programmatic API
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { startHeadless } from '@mindstudio-ai/local-model-tunnel';
|
|
158
|
+
|
|
159
|
+
await startHeadless({
|
|
160
|
+
cwd: '/path/to/app',
|
|
161
|
+
devPort: 5173,
|
|
162
|
+
bindAddress: '0.0.0.0',
|
|
163
|
+
logLevel: 'debug',
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Logging
|
|
168
|
+
|
|
169
|
+
The tunnel has structured logging throughout — API call timing, method execution lifecycle, transpilation, proxy requests, connection state, and errors.
|
|
170
|
+
|
|
171
|
+
**Headless mode:** logs go to **stderr** at `info` level by default. Stdout is reserved for the JSON event protocol. Override with `--log-level`:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
mindstudio-local --headless --log-level debug # verbose logs on stderr
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Interactive (TUI) mode:** logs go to `.mindstudio-dev.log` in the working directory at `error` level by default. This keeps logs out of the terminal UI.
|
|
178
|
+
|
|
179
|
+
**Log format:**
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
[2026-03-14T12:34:56.789Z] INFO api POST /dev/manage/start → 200 (142ms) {"sessionId":"848583c4","branch":"main"}
|
|
183
|
+
[2026-03-14T12:34:57.012Z] INFO runner Request received {"requestId":"req-1","method":"getDashboard"}
|
|
184
|
+
[2026-03-14T12:34:57.024Z] INFO transpiler Transpiled in 12ms {"methodPath":"dist/methods/src/getDashboard.ts"}
|
|
185
|
+
[2026-03-14T12:34:57.089Z] INFO runner Request complete {"requestId":"req-1","success":true,"duration":77}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Log levels:**
|
|
189
|
+
|
|
190
|
+
| Level | What you get |
|
|
191
|
+
|-------|-------------|
|
|
192
|
+
| `error` | Failures only — 403s, timeouts, crashes |
|
|
193
|
+
| `warn` | Errors + connection issues, port conflicts, invalid output |
|
|
194
|
+
| `info` | Warnings + API timing, request lifecycle, session state changes |
|
|
195
|
+
| `debug` | Everything — child process details, config resolution, proxy requests, transpile paths |
|
|
196
|
+
|
|
44
197
|
### Local Model Tunnel
|
|
45
198
|
|
|
46
199
|
Connect local AI providers to MindStudio Cloud so you can use your own hardware for text, image, and video generation.
|
|
@@ -75,22 +228,41 @@ Edit custom interfaces (SPAs) and scripts from your MindStudio apps locally. Ope
|
|
|
75
228
|
4. The CLI clones the scaffold and starts a local dev server
|
|
76
229
|
5. Edit with your preferred tools — the CLI provides ready-to-use commands for Claude Code and Codex
|
|
77
230
|
|
|
78
|
-
##
|
|
79
|
-
|
|
80
|
-
The fastest way to get running with text generation:
|
|
231
|
+
## Development
|
|
81
232
|
|
|
233
|
+
```bash
|
|
234
|
+
npm install
|
|
235
|
+
npm run build # Build with tsup
|
|
236
|
+
npm run dev # Build + run CLI
|
|
237
|
+
npm run local-update # Build + npm link for local testing
|
|
82
238
|
```
|
|
83
|
-
# Install Ollama (macOS/Linux)
|
|
84
|
-
curl -fsSL https://ollama.com/install.sh | sh
|
|
85
239
|
|
|
86
|
-
|
|
87
|
-
ollama pull llama3.2
|
|
240
|
+
### Install from a branch
|
|
88
241
|
|
|
89
|
-
|
|
90
|
-
mindstudio-local
|
|
242
|
+
```bash
|
|
243
|
+
npm i -g mindstudio-ai/mindstudio-local-model-tunnel#branch-name
|
|
91
244
|
```
|
|
92
245
|
|
|
93
|
-
|
|
246
|
+
The `prepare` script runs `npm run build` automatically after clone.
|
|
247
|
+
|
|
248
|
+
## Configuration
|
|
249
|
+
|
|
250
|
+
Credentials are stored in `~/.mindstudio-local-tunnel/config.json`. The config supports two environments (`prod` and `local`) with separate API keys and base URLs.
|
|
251
|
+
|
|
252
|
+
The TUI's onboarding flow handles initial setup. For headless/sandbox use, write the config file directly:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"environment": "prod",
|
|
257
|
+
"environments": {
|
|
258
|
+
"prod": {
|
|
259
|
+
"apiKey": "sk_...",
|
|
260
|
+
"userId": "...",
|
|
261
|
+
"apiBaseUrl": "https://api.mindstudio.ai"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
94
266
|
|
|
95
267
|
## Want a New Provider?
|
|
96
268
|
|