feat: add MQTT journal server for session persistence

Implement a journal server that uses an Aedes MQTT broker to
persist stream messages to JSONL files and manage session metadata
via a manifest.

- Add `aedes`, `mqtt`, and `zod` dependencies
- Implement `createJournalServer` in `src/cli/journal.ts`
- Integrate journal server into the `serve` command
- Add `--mqtt-port` option to the CLI
- Add session lifecycle management (create, update, delete) via
  retained MQTT topics
This commit is contained in:
2026-07-06 14:19:16 +08:00
parent 08389601ac
commit 21f8fbcd0b
6 changed files with 952 additions and 41 deletions
+19 -19
View File
@@ -1,33 +1,33 @@
#!/usr/bin/env node
import { Command } from 'commander';
import { serveCommand } from './commands/serve.js';
import { compileCommand } from './commands/compile.js';
import { mcpCommand } from './commands/mcp.js';
import type { ServeOptions, CompileOptions } from './types.js';
import { Command } from "commander";
import { serveCommand } from "./commands/serve.js";
import { compileCommand } from "./commands/compile.js";
import { mcpCommand } from "./commands/mcp.js";
import type { ServeOptions, CompileOptions } from "./types.js";
const program = new Command();
program
.name('ttrpg')
.description('TTRPG 工具箱 - 用于编译和预览 TTRPG 文档')
.version('0.0.1');
.name("ttrpg")
.description("TTRPG 工具箱 - 用于编译和预览 TTRPG 文档")
.version("0.0.1");
program
.command('serve')
.description('运行一个 web 服务器预览目录中的内容,并实时监听更新')
.argument('[dir]', '要预览的目录', '.')
.option('-p, --port <port>', '端口号', '3000')
.option('-h, --host <host>', '主机地址', '0.0.0.0')
.command("serve")
.description("运行一个 web 服务器预览目录中的内容,并实时监听更新")
.argument("[dir]", "要预览的目录", ".")
.option("-p, --port <port>", "HTTP 端口号", "3000")
.option("--mqtt-port <port>", "MQTT 代理端口号", "1883")
.option("-h, --host <host>", "主机地址", "0.0.0.0")
.action(serveCommand);
program
.command('compile')
.description('将目录中的内容输出为带 hash 路由、单个 html 入口的 web 应用')
.argument('[dir]', '要编译的目录', '.')
.option('-o, --output <dir>', '输出目录', './dist/output')
.command("compile")
.description("将目录中的内容输出为带 hash 路由、单个 html 入口的 web 应用")
.argument("[dir]", "要编译的目录", ".")
.option("-o, --output <dir>", "输出目录", "./dist/output")
.action(compileCommand);
program
.addCommand(mcpCommand);
program.addCommand(mcpCommand);
program.parse();