memoryblock 0.1.0-beta → 0.1.2

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 ADDED
@@ -0,0 +1,221 @@
1
+ <div align="center">
2
+
3
+ <!-- PROJECT TITLE -->
4
+ <h3>
5
+ <img width="240" alt="memoryblock logo" src="https://github.com/memoryblock-io/memoryblock/blob/main/packages/web/public/images/memoryblock-logo.png?raw=true" />
6
+ </h3>
7
+
8
+ <!-- ONE LINE SUMMARY -->
9
+ <p>
10
+ <b>Run AI agents that remember, think, and work - without burning through your budget.</b>
11
+ </p>
12
+
13
+ <!-- BADGES -->
14
+ <p>
15
+ <a href="https://www.npmjs.com/package/memoryblock"><img src="https://img.shields.io/npm/v/memoryblock.svg?style=flat-square&color=CB3837" alt="npm version"></a>
16
+ <!--<a href="https://www.npmjs.com/package/memoryblock?activeTab=versions"><img src="https://img.shields.io/npm/dt/memoryblock.svg?style=flat-square&color=38bd24" alt="downloads"></a>-->
17
+ <a href="https://github.com/memoryblock-io/memoryblock/stargazers"><img src="https://img.shields.io/github/stars/memoryblock-io/memoryblock?style=flat-square&logo=github" alt="stars"></a>
18
+ <a href="https://github.com/memoryblock-io/memoryblock/blob/main/LICENSE"><img src="https://img.shields.io/github/license/memoryblock-io/memoryblock.svg?style=flat-square&color=A31F34" alt="license"></a>
19
+ </p>
20
+
21
+ <!-- MENU -->
22
+ <p>
23
+ <h4>
24
+ <a href="https://memoryblock.io">View Demo</a> •
25
+ <a href="https://docs.memoryblock.io/getting-started/installation/">Documentation</a> •
26
+ <a href="https://github.com/memoryblock-io/memoryblock/issues">Report Bug</a>
27
+ </h4>
28
+ </p>
29
+
30
+ <!-- PREVIEW -->
31
+ <p>
32
+ <br/>
33
+ <img width="800" alt="memoryblock preview" src="https://github.com/user-attachments/assets/f7cf1e5b-e05c-4f8b-8747-0ef13adde054" />
34
+ <br/>
35
+ <sup><i>memoryblock web client dashboard preview</i></sup>
36
+ </p>
37
+
38
+ </div>
39
+
40
+ Memoryblock lets you deploy AI agents as isolated **blocks** - independent workspaces, each with their own memory, tools, and personality. Think of a block as a private office for an AI. Give it a job, point it at a channel, and let it run.
41
+
42
+ One block can be your personal assistant. Another can monitor your infrastructure. A third can research topics and write summaries. They don't interfere with each other, they don't share memory, and they don't waste tokens re-learning what they already know.
43
+
44
+ Need them to collaborate? A block can spawn sub-agents, the temporary workers in sandboxed environments to handle specific tasks and report back. No shared state pollution, no context confusion.
45
+
46
+ ```
47
+ you ─── terminal ──── block "home" (your daily assistant)
48
+ ├── channel ───── block "devops" (monitors + alerts)
49
+ └── web ui ────── block "research" (deep dives + summaries)
50
+ ```
51
+
52
+ ## ✨ What Makes This Different
53
+
54
+ ### It's cheap to run. Seriously.
55
+
56
+ Most AI tools send the entire tool schema. Thousands of tokens. On *every single message*. For a background agent running all day, that's money on fire.
57
+
58
+ Memoryblock was engineered around this problem:
59
+
60
+ - **On-demand schema loading** - tool definitions are injected only when needed, then dropped. Payload sizes go from ~2,600 tokens to ~1,200 tokens per turn.
61
+ - **History trimming** - large tool outputs (log dumps, file contents) are read once, then truncated in memory to 500 characters. The LLM already saw it. No need to pay for it again.
62
+ - **Smart context recovery** - when context fills up, the engine summarizes everything into clean, actionable notes and starts fresh. No crash, no data loss, no compact context error loops.
63
+
64
+ > In testing, these optimizations reduce token growth between turns from 4.2× to under 2×, resulting in over 50% cost reduction on sustained sessions.
65
+
66
+ ### It runs on Bun. Nothing else.
67
+
68
+ No Node.js. No Electron. No heavy frameworks. The entire core, HTTP server, WebSocket streaming, static file serving, is built on native APIs. Cold starts are fast. Memory usage is small.
69
+
70
+ ### Every block is its own world.
71
+
72
+ Each block gets its own `config.json`, `memory.md`, `monitor.md`, `costs.json`, and log directory. Move a block between machines by copying its folder. Back it up by zipping it. There's no shared database, no centralized state, no magic.
73
+
74
+ ### Talk to it from anywhere.
75
+
76
+ Your blocks are accessible through the **CLI** (a simple interactive terminal), different **Channels** (including Telegram, Discord, Slack, and more), and a **Web Dashboard** (with live WebSocket updates). Same block, same memory, different surfaces.
77
+
78
+ ### Use any model you want.
79
+
80
+ Memoryblock doesn't lock you into one provider. Swap models per-block, per-task, or per-agent:
81
+
82
+ | Adapter | Auth |
83
+ |:---|:---|
84
+ | **AWS Bedrock** | AWS credentials |
85
+ | **OpenAI** | API key |
86
+ | **Google Gemini** | API key |
87
+ | **Anthropic** | API key |
88
+
89
+ Adding a new adapter is one file. See [adapter docs](https://docs.memoryblock.io/adapters/) for examples.
90
+
91
+ ## Quick Start
92
+
93
+ **Requirements:** [Bun](https://bun.sh) ≥ 1.0 and an API key from any supported provider.
94
+
95
+ ```bash
96
+ # clone and set up
97
+ git clone https://github.com/memoryblock-io/memoryblock.git
98
+ cd memoryblock
99
+ pnpm dev:onboard -gl
100
+
101
+ # run the setup wizard
102
+ mblk init
103
+
104
+ # start your first block
105
+ mblk start home
106
+ ```
107
+
108
+ That's it. The wizard handles credentials, verification, and creating your first block.
109
+
110
+ ### Web Dashboard
111
+
112
+ ```bash
113
+ mblk web
114
+ ```
115
+
116
+ Opens a live dashboard at `localhost:8420` with real-time block monitoring, cost tracking, and memory inspection.
117
+
118
+ ### Channels
119
+
120
+ ```bash
121
+ mblk start home --channel telegram
122
+ ```
123
+
124
+ Your block is now live on the channel you chose. Same memory, same tools, accessible from anywhere.
125
+
126
+ ## Commands
127
+
128
+ Everything you can do from the terminal, you can do from chat (and soon, the web UI too):
129
+
130
+ | CLI | In-Chat | What it does |
131
+ |:---|:---|:---|
132
+ | `mblk create <name>` | `/create-block <name>` | Create a new block |
133
+ | `mblk start <block>` | — | Start a block's monitor |
134
+ | `mblk stop <block>` | — | Stop a running monitor |
135
+ | `mblk status` | `/status` | Show all blocks and their state |
136
+ | `mblk delete <block>` | — | Archive a block safely |
137
+ | `mblk restore <archive>` | — | Restore from archive |
138
+ | `mblk reset <block>` | — | Reset memory and costs |
139
+ | `mblk add <plugin>` | — | Install a plugin |
140
+
141
+ Full reference: [command docs](https://docs.memoryblock.io/commands.md)
142
+
143
+ ## Plugins
144
+
145
+ Blocks come with a core set of tools. Need more? Add them:
146
+
147
+ ```bash
148
+ mblk add web-search # search the web
149
+ mblk add fetch-webpage # extract text from any URL
150
+ mblk add agents # multi-agent orchestration
151
+ ```
152
+
153
+ Plugins are just npm packages. The installer resolves, downloads, and wires them in automatically.
154
+
155
+ | Plugin | What it does |
156
+ |:---|:---|
157
+ | `web-search` | Search the web with your configured provider |
158
+ | `fetch-webpage` | Extract clean text from URLs |
159
+ | `agents` | Spawn sub-agents for delegated tasks |
160
+ | `aws` | Cloud SDK code generation tools |
161
+
162
+ ## Adapters
163
+
164
+ Each adapter is a single file that maps Memoryblock's internal message format to a provider's API. They handle authentication, request formatting, and response parsing. Writing a new adapter is straightforward — the interface is small and well-documented.
165
+
166
+ See all supported adapters and how to write your own: [adapters](https://docs.memoryblock.io/adapters/)
167
+
168
+ ## Channels
169
+
170
+ Channels are how your blocks talk to the outside world. The CLI, messaging platforms, and the web dashboard are all channels — equal citizens, not afterthoughts. Adding a new channel is a single file implementation.
171
+
172
+ Supported and upcoming channels are documented in [channels](https://docs.memoryblock.io/channels/).
173
+
174
+ ## Architecture
175
+
176
+ ```
177
+ packages/
178
+ ├── core/ # engine, CLI, schemas, monitor loop
179
+ ├── adapters/ # LLM provider adapters
180
+ ├── channels/ # messaging channel transports
181
+ ├── api/ # HTTP + WebSocket server
182
+ ├── web/ # static web dashboard
183
+ ├── tools/ # base tool registry and schema helpers
184
+ ├── daemon/ # background process management
185
+ └── plugins/ # extensible capability modules
186
+ ```
187
+
188
+ It's a pnpm monorepo. Every package builds independently with `tsc`. No bundlers, no magic.
189
+
190
+ ## Community & Support
191
+ - **Contributing**: We welcome PRs! See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
192
+ - **Support**: If you find `memoryblock` useful, please consider [sponsoring the project](https://github.com/sponsors/mgks) or giving it a star ⭐.
193
+
194
+ ## The `memoryblock` Ecosystem
195
+
196
+ **memoryblock** is a highly modular system. Here are the official packages:
197
+
198
+ **The Core**
199
+ * [**memoryblock**](https://www.npmjs.com/package/memoryblock) - The core engine interface and types.
200
+ * [**@memoryblock/daemon**](https://www.npmjs.com/package/@memoryblock/daemon) - Background daemon manager.
201
+ * [**@memoryblock/api**](https://www.npmjs.com/package/@memoryblock/api) - Core REST and WebSocket API server.
202
+
203
+ **Integrations & Tooling**
204
+ * [**@memoryblock/adapters**](https://www.npmjs.com/package/@memoryblock/adapters) - LLM adapters (OpenAI, Anthropic, Bedrock, etc).
205
+ * [**@memoryblock/channels**](https://www.npmjs.com/package/@memoryblock/channels) - Communication channels (CLI, Telegram, Web).
206
+ * [**@memoryblock/tools**](https://www.npmjs.com/package/@memoryblock/tools) - Standard tool definitions and schemas.
207
+ * [**@memoryblock/locale**](https://www.npmjs.com/package/@memoryblock/locale) - Localization strings and formatting.
208
+ * [**@memoryblock/web**](https://www.npmjs.com/package/@memoryblock/web) - Front-end dashboard and Web UI.
209
+
210
+ **Plugins**
211
+ * [**@memoryblock/plugin-installer**](https://www.npmjs.com/package/@memoryblock/plugin-installer) - Plugin installer and registry manager.
212
+ * [**@memoryblock/plugin-agents**](https://www.npmjs.com/package/@memoryblock/plugin-agents) - Secondary AI agents orchestrator.
213
+ * [**@memoryblock/plugin-aws**](https://www.npmjs.com/package/@memoryblock/plugin-aws) - AWS integrations.
214
+ * [**@memoryblock/plugin-fetch-webpage**](https://www.npmjs.com/package/@memoryblock/plugin-fetch-webpage) - Web content fetching and parsing.
215
+ * [**@memoryblock/plugin-web-search**](https://www.npmjs.com/package/@memoryblock/plugin-web-search) - Web search capabilities.
216
+
217
+ ## License
218
+
219
+ Distributed under the MIT License. See `LICENSE` for more information.
220
+
221
+ ![Website Badge](https://img.shields.io/badge/.*%20mgks.dev-blue?style=flat&link=https%3A%2F%2Fmgks.dev) ![Sponsor Badge](https://img.shields.io/badge/%20%20Become%20a%20Sponsor%20%20-red?style=flat&logo=github&link=https%3A%2F%2Fgithub.com%2Fsponsors%2Fmgks)
package/dist/bin/mblk.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "memoryblock",
3
- "version": "0.1.0-beta",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
+ "description": "Deploy isolated, multi-agent AI assistants on your local machine with extreme resource efficiency.",
6
+ "files": [
7
+ "dist/",
8
+ "bin/"
9
+ ],
5
10
  "exports": {
6
11
  ".": {
7
12
  "types": "./dist/index.d.ts",
@@ -12,29 +17,69 @@
12
17
  "mblk": "./bin/mblk.js",
13
18
  "memoryblock": "./bin/mblk.js"
14
19
  },
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "dev": "tsc -p tsconfig.json --watch"
23
+ },
15
24
  "dependencies": {
25
+ "@memoryblock/daemon": "^0.1.2",
26
+ "@memoryblock/adapters": "^0.1.2",
27
+ "@memoryblock/channels": "^0.1.2",
28
+ "@memoryblock/tools": "^0.1.2",
29
+ "@memoryblock/api": "^0.1.2",
30
+ "@memoryblock/web": "^0.1.2",
31
+ "@memoryblock/locale": "^0.1.2",
32
+ "@memoryblock/plugin-installer": "^0.1.2",
33
+ "@memoryblock/plugin-agents": "^0.1.2",
16
34
  "@clack/prompts": "^1.1.0",
17
35
  "commander": "^13.0.0",
18
36
  "chalk": "^5.4.0",
19
- "zod": "^3.24.0",
20
- "@memoryblock/adapters": "0.1.0-beta",
21
- "@memoryblock/tools": "0.1.0-beta",
22
- "@memoryblock/api": "0.1.0-beta",
23
- "@memoryblock/channels": "0.1.0-beta",
24
- "@memoryblock/plugin-agents": "0.1.0-beta",
25
- "@memoryblock/daemon": "0.1.0-beta",
26
- "@memoryblock/locale": "0.1.0-beta",
27
- "@memoryblock/web": "0.1.0-beta",
28
- "@memoryblock/plugin-installer": "0.1.0-beta"
37
+ "zod": "^3.24.0"
29
38
  },
30
39
  "optionalDependencies": {
31
- "@memoryblock/plugin-web-search": "0.1.0-beta"
40
+ "@memoryblock/plugin-web-search": "workspace:*"
32
41
  },
33
42
  "engines": {
34
43
  "node": ">=18.0.0"
35
44
  },
36
- "scripts": {
37
- "build": "tsc -p tsconfig.json",
38
- "dev": "tsc -p tsconfig.json --watch"
39
- }
45
+ "keywords": [
46
+ "memoryblock",
47
+ "mblk",
48
+ "ai-agent",
49
+ "assistants",
50
+ "agents",
51
+ "automation",
52
+ "multi-agent",
53
+ "agentic-framework",
54
+ "core",
55
+ "framework",
56
+ "interface",
57
+ "channels",
58
+ "adapters",
59
+ "tools",
60
+ "skills",
61
+ "local-ai",
62
+ "local-llm",
63
+ "openai",
64
+ "anthropic",
65
+ "gemini",
66
+ "groq",
67
+ "chatgpt",
68
+ "deepseek",
69
+ "ollama"
70
+ ],
71
+ "author": {
72
+ "name": "Ghazi",
73
+ "url": "https://mgks.dev"
74
+ },
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "git+https://github.com/memoryblock-io/memoryblock.git"
78
+ },
79
+ "bugs": {
80
+ "url": "https://github.com/memoryblock-io/memoryblock/issues"
81
+ },
82
+ "homepage": "https://memoryblock.io",
83
+ "funding": "https://github.com/sponsors/mgks",
84
+ "license": "MIT"
40
85
  }
package/src/bin/mblk.ts DELETED
@@ -1,347 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { Command } from 'commander';
4
- import { log } from '../cli/logger.js';
5
- import { initCommand } from '../cli/commands/init.js';
6
- import { createCommand } from '../cli/commands/create.js';
7
- import { startCommand } from '../cli/commands/start.js';
8
- import { stopCommand } from '../cli/commands/stop.js';
9
- import { statusCommand } from '../cli/commands/status.js';
10
- import { resetCommand } from '../cli/commands/reset.js';
11
- import { serverStartCommand, serverStopCommand, serverStatusCommand, serverTokenCommand, shutdownCommand, restartCommand } from '../cli/commands/server.js';
12
- import { addCommand, removeCommand } from '../cli/commands/plugins.js';
13
- import { deleteCommand, restoreCommand } from '../cli/commands/delete.js';
14
- import { permissionsCommand } from '../cli/commands/permissions.js';
15
- import { pluginSettingsCommand } from '../cli/commands/plugin-settings.js';
16
- import { serviceInstallCommand, serviceUninstallCommand, serviceStatusCommand } from '../cli/commands/service.js';
17
- import { getVersion, DEFAULT_PORT } from '../cli/constants.js';
18
-
19
- (async () => {
20
-
21
- const version = await getVersion();
22
- const program = new Command();
23
-
24
- program
25
- .name('mblk')
26
- .description('Deploy isolated, multi-agent AI assistants with extreme resource efficiency.')
27
- .version(version)
28
- .exitOverride(() => process.exit(0)) // Don't throw ELIFECYCLE when showing help
29
- .configureOutput({
30
- writeOut: (str) => process.stdout.write(str),
31
- writeErr: (str) => process.stdout.write(str), // Prevent stderr noise from Commander
32
- });
33
-
34
- program
35
- .command('init')
36
- .description('Interactive setup — configure credentials, verify connections, create your first block.')
37
- .option('-y, --yes', 'Non-interactive mode: create defaults without prompts')
38
- .action(async (opts: { yes?: boolean }) => {
39
- try {
40
- await initCommand({ nonInteractive: opts.yes });
41
- } catch (err) {
42
- log.error((err as Error).message);
43
- process.exit(0);
44
- }
45
- });
46
-
47
- program
48
- .command('create <name>')
49
- .description('Create a new block (isolated AI workspace).')
50
- .action(async (name: string) => {
51
- try {
52
- await createCommand(name);
53
- } catch (err) {
54
- log.error((err as Error).message);
55
- process.exit(0);
56
- }
57
- });
58
-
59
- program
60
- .command('start [block]')
61
- .description('Start the monitor loop for a block (or all blocks).')
62
- .option('-d, --daemon', 'Run the monitor in the background')
63
- .option('-c, --channel <channel>', 'Specify override channel (e.g. web, cli)')
64
- .action(async (block: string | undefined, opts: { daemon?: boolean; channel?: string }) => {
65
- try {
66
- await startCommand(block, opts);
67
- } catch (err) {
68
- const msg = (err as Error).message;
69
- // If not initialized, auto-route to init and then retry
70
- if (msg.includes('not initialized') || msg.includes('mblk init')) {
71
- log.warn('Workspace not initialized. Running setup first...\n');
72
- try {
73
- await initCommand();
74
- // Retry start after init completes
75
- await startCommand(block, opts);
76
- } catch (initErr) {
77
- log.error((initErr as Error).message);
78
- process.exit(0);
79
- }
80
- return;
81
- }
82
- log.error(msg);
83
- process.exit(0);
84
- }
85
- });
86
-
87
- program
88
- .command('stop [block]')
89
- .description('Stop a running block monitor (or all blocks).')
90
- .action(async (block?: string) => {
91
- try {
92
- await stopCommand(block);
93
- } catch (err) {
94
- log.error((err as Error).message);
95
- process.exit(0);
96
- }
97
- });
98
-
99
- program
100
- .command('status')
101
- .description('Show the status of all blocks.')
102
- .action(async () => {
103
- try {
104
- await statusCommand();
105
- } catch (err) {
106
- log.error((err as Error).message);
107
- process.exit(0);
108
- }
109
- });
110
-
111
- program
112
- .command('reset <block>')
113
- .description('Reset a block state (memory, pulse, costs). Use --hard to wipe logs.')
114
- .option('--hard', 'Wipe logs directory as well')
115
- .action(async (block: string, opts: { hard?: boolean }) => {
116
- try {
117
- await resetCommand(block, opts);
118
- } catch (err) {
119
- log.error((err as Error).message);
120
- process.exit(0);
121
- }
122
- });
123
-
124
-
125
- program
126
- .command('delete <block>')
127
- .description('Archive a block to prevent data loss. Use --hard to permanently delete.')
128
- .option('--hard', 'Permanently wipe the block from disk')
129
- .action(async (block: string, opts: { hard?: boolean }) => {
130
- try {
131
- await deleteCommand(block, opts);
132
- } catch (err) {
133
- log.error((err as Error).message);
134
- process.exit(0);
135
- }
136
- });
137
-
138
- program
139
- .command('restore <name>')
140
- .description('Restore an archived block by name.')
141
- .action(async (archive: string) => {
142
- try {
143
- await restoreCommand(archive);
144
- } catch (err) {
145
- log.error((err as Error).message);
146
- process.exit(0);
147
- }
148
- });
149
- program
150
- .command('permissions <block>')
151
- .description('View or update block permissions (CLI-only).')
152
- .option('-s, --scope <level>', 'Set scope: block, workspace, or system')
153
- .option('--allow-shell', 'Allow shell command execution')
154
- .option('--deny-shell', 'Deny shell command execution')
155
- .option('--allow-network', 'Allow network/fetch access')
156
- .option('--deny-network', 'Deny network/fetch access')
157
- .option('--max-timeout <seconds>', 'Max command timeout in seconds')
158
- .action(async (block: string, opts: any) => {
159
- try {
160
- await permissionsCommand(block, opts);
161
- } catch (err) {
162
- log.error((err as Error).message);
163
- process.exit(0);
164
- }
165
- });
166
- program
167
- .command('settings [plugin]')
168
- .description('View or edit plugin settings.')
169
- .action(async (pluginId?: string) => {
170
- try {
171
- await pluginSettingsCommand(pluginId);
172
- } catch (err) {
173
- log.error((err as Error).message);
174
- process.exit(0);
175
- }
176
- });
177
-
178
- // ===== Server Subcommand Group =====
179
-
180
- const server = program
181
- .command('server')
182
- .description('Manage the web/API server.');
183
-
184
- server
185
- .command('start')
186
- .description('Start the web UI and API server.')
187
- .option('-p, --port <port>', 'Port to listen on', DEFAULT_PORT)
188
- .option('--new-token', 'Generate a new auth token')
189
- .option('-d, --daemon', 'Run the server in the background')
190
- .action(async (opts: { port?: string; newToken?: boolean; daemon?: boolean }) => {
191
- try {
192
- await serverStartCommand(opts);
193
- } catch (err) {
194
- log.error((err as Error).message);
195
- process.exit(0);
196
- }
197
- });
198
-
199
- server
200
- .command('stop')
201
- .description('Stop the running server.')
202
- .action(async () => {
203
- try {
204
- await serverStopCommand();
205
- } catch (err) {
206
- log.error((err as Error).message);
207
- process.exit(0);
208
- }
209
- });
210
-
211
- server
212
- .command('status')
213
- .description('Show server status (PID, port, running state).')
214
- .action(async () => {
215
- try {
216
- await serverStatusCommand();
217
- } catch (err) {
218
- log.error((err as Error).message);
219
- process.exit(0);
220
- }
221
- });
222
-
223
- server
224
- .command('token')
225
- .description('View the current API token, or generate a new one.')
226
- .option('--new-token', 'Generate and set a new API token')
227
- .action(async (opts: { newToken?: boolean }) => {
228
- try {
229
- await serverTokenCommand(opts);
230
- } catch (err) {
231
- log.error((err as Error).message);
232
- process.exit(0);
233
- }
234
- });
235
-
236
- // ===== Service Subcommand Group =====
237
-
238
- const service = program
239
- .command('service')
240
- .description('Manage OS-level auto-start (launchd/systemd).');
241
-
242
- service
243
- .command('install')
244
- .description('Register memoryblock to start on boot/login.')
245
- .action(async () => {
246
- try {
247
- await serviceInstallCommand();
248
- } catch (err) {
249
- log.error((err as Error).message);
250
- process.exit(0);
251
- }
252
- });
253
-
254
- service
255
- .command('uninstall')
256
- .description('Remove memoryblock from system auto-start.')
257
- .action(async () => {
258
- try {
259
- await serviceUninstallCommand();
260
- } catch (err) {
261
- log.error((err as Error).message);
262
- process.exit(0);
263
- }
264
- });
265
-
266
- service
267
- .command('status')
268
- .description('Check if the auto-start service is installed.')
269
- .action(async () => {
270
- try {
271
- await serviceStatusCommand();
272
- } catch (err) {
273
- log.error((err as Error).message);
274
- process.exit(0);
275
- }
276
- });
277
-
278
- // ===== Lifecycle Commands =====
279
-
280
- program
281
- .command('shutdown')
282
- .description('Stop all blocks and the server.')
283
- .action(async () => {
284
- try {
285
- await shutdownCommand();
286
- } catch (err) {
287
- log.error((err as Error).message);
288
- process.exit(0);
289
- }
290
- });
291
-
292
- program
293
- .command('restart')
294
- .description('Restart: stop everything, then start server as daemon.')
295
- .option('-p, --port <port>', 'Port to listen on', DEFAULT_PORT)
296
- .action(async (opts: { port?: string }) => {
297
- try {
298
- await restartCommand(opts);
299
- } catch (err) {
300
- log.error((err as Error).message);
301
- process.exit(0);
302
- }
303
- });
304
-
305
- // Backward-compatible alias: `mblk web` = `mblk server start`
306
- program
307
- .command('web')
308
- .description('Alias for `mblk server start`.')
309
- .option('-p, --port <port>', 'Port to listen on', DEFAULT_PORT)
310
- .option('--new-token', 'Generate a new auth token')
311
- .option('-d, --daemon', 'Run the server in the background')
312
- .action(async (opts: { port?: string; newToken?: boolean; daemon?: boolean }) => {
313
- try {
314
- await serverStartCommand(opts);
315
- } catch (err) {
316
- log.error((err as Error).message);
317
- process.exit(0);
318
- }
319
- });
320
-
321
- program
322
- .command('add [plugin]')
323
- .description('Install a plugin (run without args to list available plugins).')
324
- .action(async (plugin: string) => {
325
- try {
326
- await addCommand(plugin);
327
- } catch (err) {
328
- log.error((err as Error).message);
329
- process.exit(0);
330
- }
331
- });
332
-
333
- program
334
- .command('remove <plugin>')
335
- .description('Remove an installed plugin.')
336
- .action(async (plugin: string) => {
337
- try {
338
- await removeCommand(plugin);
339
- } catch (err) {
340
- log.error((err as Error).message);
341
- process.exit(0);
342
- }
343
- });
344
-
345
- program.parse();
346
-
347
- })();