diff --git a/container/agent-runner/src/db/connection.ts b/container/agent-runner/src/db/connection.ts
index a59d731..46f4a70 100644
--- a/container/agent-runner/src/db/connection.ts
+++ b/container/agent-runner/src/db/connection.ts
@@ -8,6 +8,7 @@ export function getSessionDb(): Database.Database {
if (!_db) {
_db = new Database(process.env.SESSION_DB_PATH || SESSION_DB_PATH);
_db.pragma('journal_mode = DELETE');
+ _db.pragma('busy_timeout = 5000');
_db.pragma('foreign_keys = ON');
}
return _db;
@@ -20,6 +21,7 @@ export function initTestSessionDb(): Database.Database {
_db.exec(`
CREATE TABLE messages_in (
id TEXT PRIMARY KEY,
+ seq INTEGER UNIQUE,
kind TEXT NOT NULL,
timestamp TEXT NOT NULL,
status TEXT DEFAULT 'pending',
@@ -34,6 +36,7 @@ export function initTestSessionDb(): Database.Database {
);
CREATE TABLE messages_out (
id TEXT PRIMARY KEY,
+ seq INTEGER UNIQUE,
in_reply_to TEXT,
timestamp TEXT NOT NULL,
delivered INTEGER DEFAULT 0,
diff --git a/container/agent-runner/src/db/messages-in.ts b/container/agent-runner/src/db/messages-in.ts
index d97a4ba..579eb15 100644
--- a/container/agent-runner/src/db/messages-in.ts
+++ b/container/agent-runner/src/db/messages-in.ts
@@ -2,6 +2,7 @@ import { getSessionDb } from './connection.js';
export interface MessageInRow {
id: string;
+ seq: number | null;
kind: string;
timestamp: string;
status: string;
diff --git a/container/agent-runner/src/db/messages-out.ts b/container/agent-runner/src/db/messages-out.ts
index 97db901..df6ebef 100644
--- a/container/agent-runner/src/db/messages-out.ts
+++ b/container/agent-runner/src/db/messages-out.ts
@@ -2,6 +2,7 @@ import { getSessionDb } from './connection.js';
export interface MessageOutRow {
id: string;
+ seq: number | null;
in_reply_to: string | null;
timestamp: string;
delivered: number;
@@ -26,22 +27,44 @@ export interface WriteMessageOut {
content: string;
}
-/** Write a new outbound message. */
-export function writeMessageOut(msg: WriteMessageOut): void {
- getSessionDb()
- .prepare(
- `INSERT INTO messages_out (id, in_reply_to, timestamp, delivered, deliver_after, recurrence, kind, platform_id, channel_type, thread_id, content)
- VALUES (@id, @in_reply_to, datetime('now'), 0, @deliver_after, @recurrence, @kind, @platform_id, @channel_type, @thread_id, @content)`,
- )
- .run({
- in_reply_to: null,
- deliver_after: null,
- recurrence: null,
- platform_id: null,
- channel_type: null,
- thread_id: null,
- ...msg,
- });
+/** Write a new outbound message, auto-assigning a seq number. */
+export function writeMessageOut(msg: WriteMessageOut): number {
+ const db = getSessionDb();
+ const nextSeq = (
+ db
+ .prepare(
+ `SELECT COALESCE(MAX(seq), 0) + 1 AS next FROM (
+ SELECT seq FROM messages_in WHERE seq IS NOT NULL
+ UNION ALL
+ SELECT seq FROM messages_out WHERE seq IS NOT NULL
+ )`,
+ )
+ .get() as { next: number }
+ ).next;
+
+ db.prepare(
+ `INSERT INTO messages_out (id, seq, in_reply_to, timestamp, delivered, deliver_after, recurrence, kind, platform_id, channel_type, thread_id, content)
+ VALUES (@id, @seq, @in_reply_to, datetime('now'), 0, @deliver_after, @recurrence, @kind, @platform_id, @channel_type, @thread_id, @content)`,
+ ).run({
+ in_reply_to: null,
+ deliver_after: null,
+ recurrence: null,
+ platform_id: null,
+ channel_type: null,
+ thread_id: null,
+ ...msg,
+ seq: nextSeq,
+ });
+
+ return nextSeq;
+}
+
+/** Look up a message's platform ID by seq number. */
+export function getMessageIdBySeq(seq: number): string | null {
+ const inRow = getSessionDb().prepare('SELECT id FROM messages_in WHERE seq = ?').get(seq) as { id: string } | undefined;
+ if (inRow) return inRow.id;
+ const outRow = getSessionDb().prepare('SELECT id FROM messages_out WHERE seq = ?').get(seq) as { id: string } | undefined;
+ return outRow?.id ?? null;
}
/** Get undelivered messages (for host polling). */
diff --git a/container/agent-runner/src/formatter.ts b/container/agent-runner/src/formatter.ts
index f3bb5a8..ce48030 100644
--- a/container/agent-runner/src/formatter.ts
+++ b/container/agent-runner/src/formatter.ts
@@ -67,7 +67,8 @@ function formatChatMessages(messages: MessageInRow[]): string {
const sender = content.sender || content.author?.fullName || content.author?.userName || 'Unknown';
const time = formatTime(msg.timestamp);
const text = content.text || '';
- lines.push(`${escapeXml(text)}`);
+ const idAttr = msg.seq != null ? ` id="${msg.seq}"` : '';
+ lines.push(`${escapeXml(text)}`);
}
lines.push('');
return lines.join('\n');
@@ -78,7 +79,8 @@ function formatSingleChat(msg: MessageInRow): string {
const sender = content.sender || content.author?.fullName || content.author?.userName || 'Unknown';
const time = formatTime(msg.timestamp);
const text = content.text || '';
- return `${escapeXml(text)}`;
+ const idAttr = msg.seq != null ? ` id="${msg.seq}"` : '';
+ return `${escapeXml(text)}`;
}
function formatTaskMessage(msg: MessageInRow): string {
diff --git a/container/agent-runner/src/index-v2.ts b/container/agent-runner/src/index-v2.ts
index 1005e56..db6523a 100644
--- a/container/agent-runner/src/index-v2.ts
+++ b/container/agent-runner/src/index-v2.ts
@@ -64,7 +64,7 @@ async function main(): Promise {
// MCP server path
const __dirname = path.dirname(fileURLToPath(import.meta.url));
- const mcpServerPath = path.join(__dirname, 'mcp-tools.js');
+ const mcpServerPath = path.join(__dirname, 'mcp-tools', 'index.js');
// SDK env
const env: Record = {
diff --git a/container/agent-runner/src/mcp-tools/agents.ts b/container/agent-runner/src/mcp-tools/agents.ts
new file mode 100644
index 0000000..54e50b6
--- /dev/null
+++ b/container/agent-runner/src/mcp-tools/agents.ts
@@ -0,0 +1,58 @@
+/**
+ * Agent-to-agent MCP tools: send_to_agent.
+ */
+import { writeMessageOut } from '../db/messages-out.js';
+import type { McpToolDefinition } from './types.js';
+
+function log(msg: string): void {
+ console.error(`[mcp-tools] ${msg}`);
+}
+
+function generateId(): string {
+ return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
+}
+
+function ok(text: string) {
+ return { content: [{ type: 'text' as const, text }] };
+}
+
+function err(text: string) {
+ return { content: [{ type: 'text' as const, text: `Error: ${text}` }], isError: true };
+}
+
+export const sendToAgent: McpToolDefinition = {
+ tool: {
+ name: 'send_to_agent',
+ description: 'Send a message to another agent group.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ agentGroupId: { type: 'string', description: 'Target agent group ID' },
+ text: { type: 'string', description: 'Message content' },
+ sessionId: { type: 'string', description: 'Target specific session (optional)' },
+ },
+ required: ['agentGroupId', 'text'],
+ },
+ },
+ async handler(args) {
+ const agentGroupId = args.agentGroupId as string;
+ const text = args.text as string;
+ if (!agentGroupId || !text) return err('agentGroupId and text are required');
+
+ const id = generateId();
+
+ writeMessageOut({
+ id,
+ kind: 'chat',
+ channel_type: 'agent',
+ platform_id: agentGroupId,
+ thread_id: (args.sessionId as string) || null,
+ content: JSON.stringify({ text }),
+ });
+
+ log(`send_to_agent: ${id} → ${agentGroupId}`);
+ return ok(`Message sent to agent ${agentGroupId} (id: ${id})`);
+ },
+};
+
+export const agentTools: McpToolDefinition[] = [sendToAgent];
diff --git a/container/agent-runner/src/mcp-tools/core.ts b/container/agent-runner/src/mcp-tools/core.ts
new file mode 100644
index 0000000..c607c6c
--- /dev/null
+++ b/container/agent-runner/src/mcp-tools/core.ts
@@ -0,0 +1,190 @@
+/**
+ * Core MCP tools: send_message, send_file, edit_message, add_reaction.
+ */
+import fs from 'fs';
+import path from 'path';
+
+import { writeMessageOut, getMessageIdBySeq } from '../db/messages-out.js';
+import type { McpToolDefinition } from './types.js';
+
+function log(msg: string): void {
+ console.error(`[mcp-tools] ${msg}`);
+}
+
+function generateId(): string {
+ return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
+}
+
+function routing() {
+ return {
+ platform_id: process.env.NANOCLAW_PLATFORM_ID || null,
+ channel_type: process.env.NANOCLAW_CHANNEL_TYPE || null,
+ thread_id: process.env.NANOCLAW_THREAD_ID || null,
+ };
+}
+
+function ok(text: string) {
+ return { content: [{ type: 'text' as const, text }] };
+}
+
+function err(text: string) {
+ return { content: [{ type: 'text' as const, text: `Error: ${text}` }], isError: true };
+}
+
+export const sendMessage: McpToolDefinition = {
+ tool: {
+ name: 'send_message',
+ description: 'Send a chat message to the current conversation or a specified destination.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ text: { type: 'string', description: 'Message content' },
+ channel: { type: 'string', description: 'Target channel type (default: reply to origin)' },
+ platformId: { type: 'string', description: 'Target platform ID' },
+ threadId: { type: 'string', description: 'Target thread ID' },
+ },
+ required: ['text'],
+ },
+ },
+ async handler(args) {
+ const text = args.text as string;
+ if (!text) return err('text is required');
+
+ const id = generateId();
+ const r = routing();
+
+ const seq = writeMessageOut({
+ id,
+ kind: 'chat',
+ platform_id: (args.platformId as string) || r.platform_id,
+ channel_type: (args.channel as string) || r.channel_type,
+ thread_id: (args.threadId as string) || r.thread_id,
+ content: JSON.stringify({ text }),
+ });
+
+ log(`send_message: #${seq} ${id} → ${r.channel_type || 'default'}/${r.platform_id || 'default'}`);
+ return ok(`Message sent (id: ${seq})`);
+ },
+};
+
+export const sendFile: McpToolDefinition = {
+ tool: {
+ name: 'send_file',
+ description: 'Send a file to the current conversation.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ path: { type: 'string', description: 'File path (relative to /workspace/agent/ or absolute)' },
+ text: { type: 'string', description: 'Optional accompanying message' },
+ filename: { type: 'string', description: 'Display name (default: basename of path)' },
+ },
+ required: ['path'],
+ },
+ },
+ async handler(args) {
+ const filePath = args.path as string;
+ if (!filePath) return err('path is required');
+
+ const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve('/workspace/agent', filePath);
+ if (!fs.existsSync(resolvedPath)) return err(`File not found: ${filePath}`);
+
+ const id = generateId();
+ const filename = (args.filename as string) || path.basename(resolvedPath);
+ const r = routing();
+
+ // Copy file to outbox
+ const outboxDir = path.join('/workspace/outbox', id);
+ fs.mkdirSync(outboxDir, { recursive: true });
+ fs.copyFileSync(resolvedPath, path.join(outboxDir, filename));
+
+ writeMessageOut({
+ id,
+ kind: 'chat',
+ platform_id: r.platform_id,
+ channel_type: r.channel_type,
+ thread_id: r.thread_id,
+ content: JSON.stringify({ text: (args.text as string) || '', files: [filename] }),
+ });
+
+ log(`send_file: ${id} → ${filename}`);
+ return ok(`File sent (id: ${id}, filename: ${filename})`);
+ },
+};
+
+export const editMessage: McpToolDefinition = {
+ tool: {
+ name: 'edit_message',
+ description: 'Edit a previously sent message.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ messageId: { type: 'integer', description: 'Message ID (the numeric id shown in messages)' },
+ text: { type: 'string', description: 'New message content' },
+ },
+ required: ['messageId', 'text'],
+ },
+ },
+ async handler(args) {
+ const seq = Number(args.messageId);
+ const text = args.text as string;
+ if (!seq || !text) return err('messageId and text are required');
+
+ const platformId = getMessageIdBySeq(seq);
+ if (!platformId) return err(`Message #${seq} not found`);
+
+ const id = generateId();
+ const r = routing();
+
+ writeMessageOut({
+ id,
+ kind: 'chat',
+ platform_id: r.platform_id,
+ channel_type: r.channel_type,
+ thread_id: r.thread_id,
+ content: JSON.stringify({ operation: 'edit', messageId: platformId, text }),
+ });
+
+ log(`edit_message: #${seq} → ${platformId}`);
+ return ok(`Message edit queued for #${seq}`);
+ },
+};
+
+export const addReaction: McpToolDefinition = {
+ tool: {
+ name: 'add_reaction',
+ description: 'Add an emoji reaction to a message.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ messageId: { type: 'integer', description: 'Message ID (the numeric id shown in messages)' },
+ emoji: { type: 'string', description: 'Emoji name (e.g., thumbs_up, heart, check)' },
+ },
+ required: ['messageId', 'emoji'],
+ },
+ },
+ async handler(args) {
+ const seq = Number(args.messageId);
+ const emoji = args.emoji as string;
+ if (!seq || !emoji) return err('messageId and emoji are required');
+
+ const platformId = getMessageIdBySeq(seq);
+ if (!platformId) return err(`Message #${seq} not found`);
+
+ const id = generateId();
+ const r = routing();
+
+ writeMessageOut({
+ id,
+ kind: 'chat',
+ platform_id: r.platform_id,
+ channel_type: r.channel_type,
+ thread_id: r.thread_id,
+ content: JSON.stringify({ operation: 'reaction', messageId: platformId, emoji }),
+ });
+
+ log(`add_reaction: #${seq} → ${emoji} on ${platformId}`);
+ return ok(`Reaction queued for #${seq}`);
+ },
+};
+
+export const coreTools: McpToolDefinition[] = [sendMessage, sendFile, editMessage, addReaction];
diff --git a/container/agent-runner/src/mcp-tools/index.ts b/container/agent-runner/src/mcp-tools/index.ts
new file mode 100644
index 0000000..254d802
--- /dev/null
+++ b/container/agent-runner/src/mcp-tools/index.ts
@@ -0,0 +1,53 @@
+/**
+ * MCP tools barrel — collects all tool modules and starts the server.
+ *
+ * Each module exports a McpToolDefinition[] array. This file registers
+ * them all with the MCP server. Adding a new tool module requires only
+ * importing it here and spreading its tools array.
+ */
+import { Server } from '@modelcontextprotocol/sdk/server/index.js';
+import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
+import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
+
+import type { McpToolDefinition } from './types.js';
+import { coreTools } from './core.js';
+import { schedulingTools } from './scheduling.js';
+import { interactiveTools } from './interactive.js';
+import { agentTools } from './agents.js';
+
+function log(msg: string): void {
+ console.error(`[mcp-tools] ${msg}`);
+}
+
+const allTools: McpToolDefinition[] = [...coreTools, ...schedulingTools, ...interactiveTools, ...agentTools];
+
+const toolMap = new Map();
+for (const t of allTools) {
+ toolMap.set(t.tool.name, t);
+}
+
+async function startMcpServer(): Promise {
+ const server = new Server({ name: 'nanoclaw', version: '2.0.0' }, { capabilities: { tools: {} } });
+
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
+ tools: allTools.map((t) => t.tool),
+ }));
+
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
+ const { name, arguments: args } = request.params;
+ const tool = toolMap.get(name);
+ if (!tool) {
+ return { content: [{ type: 'text', text: `Unknown tool: ${name}` }] };
+ }
+ return tool.handler(args ?? {});
+ });
+
+ const transport = new StdioServerTransport();
+ await server.connect(transport);
+ log(`MCP server started with ${allTools.length} tools: ${allTools.map((t) => t.tool.name).join(', ')}`);
+}
+
+startMcpServer().catch((err) => {
+ log(`MCP server error: ${err instanceof Error ? err.message : String(err)}`);
+ process.exit(1);
+});
diff --git a/container/agent-runner/src/mcp-tools/interactive.ts b/container/agent-runner/src/mcp-tools/interactive.ts
new file mode 100644
index 0000000..dbd6ad6
--- /dev/null
+++ b/container/agent-runner/src/mcp-tools/interactive.ts
@@ -0,0 +1,147 @@
+/**
+ * Interactive MCP tools: ask_user_question, send_card.
+ *
+ * ask_user_question is a blocking tool call — it writes a messages_out row
+ * with a question card, then polls messages_in for the response.
+ */
+import { getSessionDb } from '../db/connection.js';
+import { writeMessageOut } from '../db/messages-out.js';
+import type { McpToolDefinition } from './types.js';
+
+function log(msg: string): void {
+ console.error(`[mcp-tools] ${msg}`);
+}
+
+function generateId(): string {
+ return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
+}
+
+function routing() {
+ return {
+ platform_id: process.env.NANOCLAW_PLATFORM_ID || null,
+ channel_type: process.env.NANOCLAW_CHANNEL_TYPE || null,
+ thread_id: process.env.NANOCLAW_THREAD_ID || null,
+ };
+}
+
+function ok(text: string) {
+ return { content: [{ type: 'text' as const, text }] };
+}
+
+function err(text: string) {
+ return { content: [{ type: 'text' as const, text: `Error: ${text}` }], isError: true };
+}
+
+function sleep(ms: number): Promise {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
+
+export const askUserQuestion: McpToolDefinition = {
+ tool: {
+ name: 'ask_user_question',
+ description:
+ 'Ask the user a multiple-choice question and wait for their response. This is a blocking call — execution pauses until the user responds or the timeout expires.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ question: { type: 'string', description: 'The question to ask' },
+ options: {
+ type: 'array',
+ items: { type: 'string' },
+ description: 'Button labels for the user to choose from',
+ },
+ timeout: { type: 'number', description: 'Timeout in seconds (default: 300)' },
+ },
+ required: ['question', 'options'],
+ },
+ },
+ async handler(args) {
+ const question = args.question as string;
+ const options = args.options as string[];
+ const timeout = ((args.timeout as number) || 300) * 1000;
+ if (!question || !options?.length) return err('question and options are required');
+
+ const questionId = generateId();
+ const r = routing();
+
+ // Write question card to messages_out
+ writeMessageOut({
+ id: questionId,
+ kind: 'chat-sdk',
+ platform_id: r.platform_id,
+ channel_type: r.channel_type,
+ thread_id: r.thread_id,
+ content: JSON.stringify({
+ type: 'ask_question',
+ questionId,
+ question,
+ options,
+ }),
+ });
+
+ log(`ask_user_question: ${questionId} → "${question}" [${options.join(', ')}]`);
+
+ // Poll for response in messages_in
+ const deadline = Date.now() + timeout;
+ while (Date.now() < deadline) {
+ const response = getSessionDb()
+ .prepare("SELECT content FROM messages_in WHERE kind = 'system' AND content LIKE ? AND status = 'pending' LIMIT 1")
+ .get(`%"questionId":"${questionId}"%`) as { content: string } | undefined;
+
+ if (response) {
+ const parsed = JSON.parse(response.content);
+ // Mark the response as completed so the poll loop doesn't pick it up
+ getSessionDb()
+ .prepare("UPDATE messages_in SET status = 'completed', status_changed = datetime('now') WHERE kind = 'system' AND content LIKE ?")
+ .run(`%"questionId":"${questionId}"%`);
+
+ log(`ask_user_question response: ${questionId} → ${parsed.selectedOption}`);
+ return ok(parsed.selectedOption);
+ }
+
+ await sleep(1000);
+ }
+
+ log(`ask_user_question timeout: ${questionId}`);
+ return err(`Question timed out after ${timeout / 1000}s`);
+ },
+};
+
+export const sendCard: McpToolDefinition = {
+ tool: {
+ name: 'send_card',
+ description: 'Send a structured card (interactive or display-only) to the current conversation.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ card: {
+ type: 'object',
+ description: 'Card structure with title, description, and optional children/actions',
+ },
+ fallbackText: { type: 'string', description: 'Text fallback for platforms without card support' },
+ },
+ required: ['card'],
+ },
+ },
+ async handler(args) {
+ const card = args.card as Record;
+ if (!card) return err('card is required');
+
+ const id = generateId();
+ const r = routing();
+
+ writeMessageOut({
+ id,
+ kind: 'chat-sdk',
+ platform_id: r.platform_id,
+ channel_type: r.channel_type,
+ thread_id: r.thread_id,
+ content: JSON.stringify({ type: 'card', card, fallbackText: (args.fallbackText as string) || '' }),
+ });
+
+ log(`send_card: ${id}`);
+ return ok(`Card sent (id: ${id})`);
+ },
+};
+
+export const interactiveTools: McpToolDefinition[] = [askUserQuestion, sendCard];
diff --git a/container/agent-runner/src/mcp-tools/scheduling.ts b/container/agent-runner/src/mcp-tools/scheduling.ts
new file mode 100644
index 0000000..3f3d0d0
--- /dev/null
+++ b/container/agent-runner/src/mcp-tools/scheduling.ts
@@ -0,0 +1,199 @@
+/**
+ * Scheduling MCP tools: schedule_task, list_tasks, cancel_task, pause_task, resume_task.
+ *
+ * Tasks are messages_in rows with process_after timestamps and optional recurrence.
+ * The host sweep detects due tasks and wakes the container.
+ */
+import { getSessionDb } from '../db/connection.js';
+import type { McpToolDefinition } from './types.js';
+
+function log(msg: string): void {
+ console.error(`[mcp-tools] ${msg}`);
+}
+
+function generateId(): string {
+ return `task-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
+}
+
+function routing() {
+ return {
+ platform_id: process.env.NANOCLAW_PLATFORM_ID || null,
+ channel_type: process.env.NANOCLAW_CHANNEL_TYPE || null,
+ thread_id: process.env.NANOCLAW_THREAD_ID || null,
+ };
+}
+
+function ok(text: string) {
+ return { content: [{ type: 'text' as const, text }] };
+}
+
+function err(text: string) {
+ return { content: [{ type: 'text' as const, text: `Error: ${text}` }], isError: true };
+}
+
+export const scheduleTask: McpToolDefinition = {
+ tool: {
+ name: 'schedule_task',
+ description:
+ 'Schedule a one-shot or recurring task. The task will be processed at the specified time. Use cron expressions for recurring tasks.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ prompt: { type: 'string', description: 'Task instructions/prompt' },
+ processAfter: { type: 'string', description: 'ISO timestamp for first run (e.g., 2024-01-15T09:00:00Z)' },
+ recurrence: { type: 'string', description: 'Cron expression for recurring tasks (e.g., "0 9 * * 1-5" for weekdays at 9am)' },
+ script: { type: 'string', description: 'Optional pre-agent script to run before processing' },
+ },
+ required: ['prompt', 'processAfter'],
+ },
+ },
+ async handler(args) {
+ const prompt = args.prompt as string;
+ const processAfter = args.processAfter as string;
+ if (!prompt || !processAfter) return err('prompt and processAfter are required');
+
+ const id = generateId();
+ const r = routing();
+ const recurrence = (args.recurrence as string) || null;
+ const script = (args.script as string) || null;
+
+ const content = JSON.stringify({ prompt, script });
+
+ getSessionDb()
+ .prepare(
+ `INSERT INTO messages_in (id, timestamp, status, status_changed, tries, process_after, recurrence, kind, platform_id, channel_type, thread_id, content)
+ VALUES (@id, datetime('now'), 'pending', datetime('now'), 0, @process_after, @recurrence, 'task', @platform_id, @channel_type, @thread_id, @content)`,
+ )
+ .run({
+ id,
+ process_after: processAfter,
+ recurrence,
+ platform_id: r.platform_id,
+ channel_type: r.channel_type,
+ thread_id: r.thread_id,
+ content,
+ });
+
+ log(`schedule_task: ${id} at ${processAfter}${recurrence ? ` (recurring: ${recurrence})` : ''}`);
+ return ok(`Task scheduled (id: ${id}, runs at: ${processAfter}${recurrence ? `, recurrence: ${recurrence}` : ''})`);
+ },
+};
+
+export const listTasks: McpToolDefinition = {
+ tool: {
+ name: 'list_tasks',
+ description: 'List scheduled and pending tasks.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ status: { type: 'string', description: 'Filter by status: pending, processing, completed, paused (default: all non-completed)' },
+ },
+ },
+ },
+ async handler(args) {
+ const status = args.status as string | undefined;
+ let rows;
+ if (status) {
+ rows = getSessionDb()
+ .prepare("SELECT id, status, process_after, recurrence, content FROM messages_in WHERE kind = 'task' AND status = ? ORDER BY process_after ASC")
+ .all(status);
+ } else {
+ rows = getSessionDb()
+ .prepare("SELECT id, status, process_after, recurrence, content FROM messages_in WHERE kind = 'task' AND status NOT IN ('completed') ORDER BY process_after ASC")
+ .all();
+ }
+
+ if ((rows as unknown[]).length === 0) return ok('No tasks found.');
+
+ const lines = (rows as Array<{ id: string; status: string; process_after: string | null; recurrence: string | null; content: string }>).map((r) => {
+ const content = JSON.parse(r.content);
+ const prompt = (content.prompt as string || '').slice(0, 80);
+ return `- ${r.id} [${r.status}] at=${r.process_after || 'now'} ${r.recurrence ? `recur=${r.recurrence} ` : ''}→ ${prompt}`;
+ });
+
+ return ok(lines.join('\n'));
+ },
+};
+
+export const cancelTask: McpToolDefinition = {
+ tool: {
+ name: 'cancel_task',
+ description: 'Cancel a scheduled task.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ taskId: { type: 'string', description: 'Task ID to cancel' },
+ },
+ required: ['taskId'],
+ },
+ },
+ async handler(args) {
+ const taskId = args.taskId as string;
+ if (!taskId) return err('taskId is required');
+
+ const result = getSessionDb()
+ .prepare("UPDATE messages_in SET status = 'completed', status_changed = datetime('now') WHERE id = ? AND kind = 'task' AND status IN ('pending', 'paused')")
+ .run(taskId);
+
+ if (result.changes === 0) return err(`Task not found or not cancellable: ${taskId}`);
+
+ log(`cancel_task: ${taskId}`);
+ return ok(`Task cancelled: ${taskId}`);
+ },
+};
+
+export const pauseTask: McpToolDefinition = {
+ tool: {
+ name: 'pause_task',
+ description: 'Pause a scheduled task. It will not run until resumed.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ taskId: { type: 'string', description: 'Task ID to pause' },
+ },
+ required: ['taskId'],
+ },
+ },
+ async handler(args) {
+ const taskId = args.taskId as string;
+ if (!taskId) return err('taskId is required');
+
+ const result = getSessionDb()
+ .prepare("UPDATE messages_in SET status = 'paused', status_changed = datetime('now') WHERE id = ? AND kind = 'task' AND status = 'pending'")
+ .run(taskId);
+
+ if (result.changes === 0) return err(`Task not found or not pausable: ${taskId}`);
+
+ log(`pause_task: ${taskId}`);
+ return ok(`Task paused: ${taskId}`);
+ },
+};
+
+export const resumeTask: McpToolDefinition = {
+ tool: {
+ name: 'resume_task',
+ description: 'Resume a paused task.',
+ inputSchema: {
+ type: 'object' as const,
+ properties: {
+ taskId: { type: 'string', description: 'Task ID to resume' },
+ },
+ required: ['taskId'],
+ },
+ },
+ async handler(args) {
+ const taskId = args.taskId as string;
+ if (!taskId) return err('taskId is required');
+
+ const result = getSessionDb()
+ .prepare("UPDATE messages_in SET status = 'pending', status_changed = datetime('now') WHERE id = ? AND kind = 'task' AND status = 'paused'")
+ .run(taskId);
+
+ if (result.changes === 0) return err(`Task not found or not paused: ${taskId}`);
+
+ log(`resume_task: ${taskId}`);
+ return ok(`Task resumed: ${taskId}`);
+ },
+};
+
+export const schedulingTools: McpToolDefinition[] = [scheduleTask, listTasks, cancelTask, pauseTask, resumeTask];
diff --git a/container/agent-runner/src/mcp-tools/types.ts b/container/agent-runner/src/mcp-tools/types.ts
new file mode 100644
index 0000000..d4637d0
--- /dev/null
+++ b/container/agent-runner/src/mcp-tools/types.ts
@@ -0,0 +1,6 @@
+import type { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
+
+export interface McpToolDefinition {
+ tool: Tool;
+ handler: (args: Record) => Promise;
+}
diff --git a/package-lock.json b/package-lock.json
index ebd7b83..97b055e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,8 +8,11 @@
"name": "nanoclaw",
"version": "1.2.52",
"dependencies": {
+ "@chat-adapter/discord": "^4.24.0",
+ "@chat-adapter/state-memory": "^4.24.0",
"@onecli-sh/sdk": "^0.2.0",
"better-sqlite3": "11.10.0",
+ "chat": "^4.24.0",
"cron-parser": "5.5.0"
},
"devDependencies": {
@@ -30,6 +33,183 @@
"node": ">=20"
}
},
+ "node_modules/@chat-adapter/discord": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@chat-adapter/discord/-/discord-4.24.0.tgz",
+ "integrity": "sha512-nyLLBClOjzkzsCDOXoZvYJ91GA3EEYEQA7YsDHthra7YjEpPo4Osl65bdm54z/5Rl6VW7QofK6B5DSN4UJzQPA==",
+ "license": "MIT",
+ "dependencies": {
+ "@chat-adapter/shared": "4.24.0",
+ "chat": "4.24.0",
+ "discord-api-types": "^0.37.119",
+ "discord-interactions": "^4.4.0",
+ "discord.js": "^14.25.1"
+ }
+ },
+ "node_modules/@chat-adapter/discord/node_modules/discord-api-types": {
+ "version": "0.37.120",
+ "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.120.tgz",
+ "integrity": "sha512-7xpNK0EiWjjDFp2nAhHXezE4OUWm7s1zhc/UXXN6hnFFU8dfoPHgV0Hx0RPiCa3ILRpdeh152icc68DGCyXYIw==",
+ "license": "MIT"
+ },
+ "node_modules/@chat-adapter/shared": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@chat-adapter/shared/-/shared-4.24.0.tgz",
+ "integrity": "sha512-TINx2tGIb7R76LWRII7LUclRFGUAB4ytosEaL054bYm0T1t52suQAHSqCZrLjlc060TNhBNUFJY3Fd9YpTantw==",
+ "license": "MIT",
+ "dependencies": {
+ "chat": "4.24.0"
+ }
+ },
+ "node_modules/@chat-adapter/state-memory": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@chat-adapter/state-memory/-/state-memory-4.24.0.tgz",
+ "integrity": "sha512-K/o1KfZ7DH0Y7wcn8aCxD+QmfGaZ4yj5Qyk4VdvLGcUZTUkgS1how8DkcYBDcX3NoKv9DsqM+joQnWc3Pe8dbA==",
+ "license": "MIT",
+ "dependencies": {
+ "chat": "4.24.0"
+ }
+ },
+ "node_modules/@discordjs/builders": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.14.1.tgz",
+ "integrity": "sha512-gSKkhXLqs96TCzk66VZuHHl8z2bQMJFGwrXC0f33ngK+FLNau4hU1PYny3DNJfNdSH+gVMzE85/d5FQ2BpcNwQ==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@discordjs/formatters": "^0.6.2",
+ "@discordjs/util": "^1.2.0",
+ "@sapphire/shapeshift": "^4.0.0",
+ "discord-api-types": "^0.38.40",
+ "fast-deep-equal": "^3.1.3",
+ "ts-mixer": "^6.0.4",
+ "tslib": "^2.6.3"
+ },
+ "engines": {
+ "node": ">=16.11.0"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
+ "node_modules/@discordjs/collection": {
+ "version": "1.5.3",
+ "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz",
+ "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=16.11.0"
+ }
+ },
+ "node_modules/@discordjs/formatters": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.2.tgz",
+ "integrity": "sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "discord-api-types": "^0.38.33"
+ },
+ "engines": {
+ "node": ">=16.11.0"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
+ "node_modules/@discordjs/rest": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.1.tgz",
+ "integrity": "sha512-wwQdgjeaoYFiaG+atbqx6aJDpqW7JHAo0HrQkBTbYzM3/PJ3GweQIpgElNcGZ26DCUOXMyawYd0YF7vtr+fZXg==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@discordjs/collection": "^2.1.1",
+ "@discordjs/util": "^1.2.0",
+ "@sapphire/async-queue": "^1.5.3",
+ "@sapphire/snowflake": "^3.5.5",
+ "@vladfrangu/async_event_emitter": "^2.4.6",
+ "discord-api-types": "^0.38.40",
+ "magic-bytes.js": "^1.13.0",
+ "tslib": "^2.6.3",
+ "undici": "6.24.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
+ "node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
+ "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
+ "node_modules/@discordjs/rest/node_modules/@sapphire/snowflake": {
+ "version": "3.5.5",
+ "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.5.tgz",
+ "integrity": "sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=v14.0.0",
+ "npm": ">=7.0.0"
+ }
+ },
+ "node_modules/@discordjs/util": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz",
+ "integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "discord-api-types": "^0.38.33"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
+ "node_modules/@discordjs/ws": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.3.tgz",
+ "integrity": "sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@discordjs/collection": "^2.1.0",
+ "@discordjs/rest": "^2.5.1",
+ "@discordjs/util": "^1.1.0",
+ "@sapphire/async-queue": "^1.5.2",
+ "@types/ws": "^8.5.10",
+ "@vladfrangu/async_event_emitter": "^2.2.4",
+ "discord-api-types": "^0.38.1",
+ "tslib": "^2.6.2",
+ "ws": "^8.17.0"
+ },
+ "engines": {
+ "node": ">=16.11.0"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
+ "node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
+ "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
"node_modules/@esbuild/aix-ppc64": {
"version": "0.27.3",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",
@@ -1043,6 +1223,39 @@
"win32"
]
},
+ "node_modules/@sapphire/async-queue": {
+ "version": "1.5.5",
+ "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz",
+ "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=v14.0.0",
+ "npm": ">=7.0.0"
+ }
+ },
+ "node_modules/@sapphire/shapeshift": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz",
+ "integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==",
+ "license": "MIT",
+ "dependencies": {
+ "fast-deep-equal": "^3.1.3",
+ "lodash": "^4.17.21"
+ },
+ "engines": {
+ "node": ">=v16"
+ }
+ },
+ "node_modules/@sapphire/snowflake": {
+ "version": "3.5.3",
+ "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz",
+ "integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=v14.0.0",
+ "npm": ">=7.0.0"
+ }
+ },
"node_modules/@standard-schema/spec": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
@@ -1071,6 +1284,15 @@
"assertion-error": "^2.0.1"
}
},
+ "node_modules/@types/debug": {
+ "version": "4.1.13",
+ "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz",
+ "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/ms": "*"
+ }
+ },
"node_modules/@types/deep-eql": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
@@ -1091,16 +1313,45 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"dev": true
},
+ "node_modules/@types/mdast": {
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
+ "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "*"
+ }
+ },
+ "node_modules/@types/ms": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz",
+ "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
+ "license": "MIT"
+ },
"node_modules/@types/node": {
"version": "22.19.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.11.tgz",
"integrity": "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w==",
- "dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.21.0"
}
},
+ "node_modules/@types/unist": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
+ "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
+ "license": "MIT"
+ },
+ "node_modules/@types/ws": {
+ "version": "8.18.1",
+ "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
+ "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.57.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.57.2.tgz",
@@ -1479,6 +1730,22 @@
"url": "https://opencollective.com/vitest"
}
},
+ "node_modules/@vladfrangu/async_event_emitter": {
+ "version": "2.4.7",
+ "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.7.tgz",
+ "integrity": "sha512-Xfe6rpCTxSxfbswi/W/Pz7zp1WWSNn4A0eW4mLkQUewCrXXtMj31lCg+iQyTkh/CkusZSq9eDflu7tjEDXUY6g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=v14.0.0",
+ "npm": ">=7.0.0"
+ }
+ },
+ "node_modules/@workflow/serde": {
+ "version": "4.1.0-beta.2",
+ "resolved": "https://registry.npmjs.org/@workflow/serde/-/serde-4.1.0-beta.2.tgz",
+ "integrity": "sha512-8kkeoQKLDaKXefjV5dbhBj2aErfKp1Mc4pb6tj8144cF+Em5SPbyMbyLCHp+BVrFfFVCBluCtMx+jjvaFVZGww==",
+ "license": "Apache-2.0"
+ },
"node_modules/acorn": {
"version": "8.16.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
@@ -1547,6 +1814,16 @@
"node": ">=12"
}
},
+ "node_modules/bail": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
+ "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -1648,6 +1925,16 @@
"node": ">=6"
}
},
+ "node_modules/ccount": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
+ "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/chai": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",
@@ -1674,6 +1961,31 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
+ "node_modules/character-entities": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz",
+ "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
+ "node_modules/chat": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/chat/-/chat-4.24.0.tgz",
+ "integrity": "sha512-0TxglwtGRMGlqERuHVZZ27Z4YBeZH3oRXCqHZYuI41L7xcSHF5C3wEHTMdVqHp3p8ZKQcKYQPOwYWvaeFVa4+g==",
+ "license": "MIT",
+ "dependencies": {
+ "@workflow/serde": "4.1.0-beta.2",
+ "mdast-util-to-string": "^4.0.0",
+ "remark-gfm": "^4.0.0",
+ "remark-parse": "^11.0.0",
+ "remark-stringify": "^11.0.0",
+ "remend": "^1.2.1",
+ "unified": "^11.0.5"
+ }
+ },
"node_modules/chownr": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
@@ -1734,7 +2046,6 @@
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
- "dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
@@ -1748,6 +2059,19 @@
}
}
},
+ "node_modules/decode-named-character-reference": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz",
+ "integrity": "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==",
+ "license": "MIT",
+ "dependencies": {
+ "character-entities": "^2.0.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/decompress-response": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
@@ -1778,6 +2102,15 @@
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
"dev": true
},
+ "node_modules/dequal": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/detect-libc": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
@@ -1787,6 +2120,64 @@
"node": ">=8"
}
},
+ "node_modules/devlop": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",
+ "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==",
+ "license": "MIT",
+ "dependencies": {
+ "dequal": "^2.0.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
+ "node_modules/discord-api-types": {
+ "version": "0.38.44",
+ "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.44.tgz",
+ "integrity": "sha512-q91MgBzP/gRaCLIbQTaOrOhbD8uVIaPKxpgX2sfFB2nZ9nSiTYM9P3NFQ7cbO6NCxctI6ODttc67MI+YhIfILg==",
+ "license": "MIT",
+ "workspaces": [
+ "scripts/actions/documentation"
+ ]
+ },
+ "node_modules/discord-interactions": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/discord-interactions/-/discord-interactions-4.4.0.tgz",
+ "integrity": "sha512-jjJx8iwAeJcj8oEauV43fue9lNqkf38fy60aSs2+G8D1nJmDxUIrk08o3h0F3wgwuBWWJUZO+X/VgfXsxpCiJA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18.4.0"
+ }
+ },
+ "node_modules/discord.js": {
+ "version": "14.26.2",
+ "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.26.2.tgz",
+ "integrity": "sha512-feShi+gULJ6R2MAA4/KkCFnkJcuVrROJrKk4czplzq8gE1oqhqgOy9K0Scu44B8oGeWKe04egquzf+ia6VtXAw==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@discordjs/builders": "^1.14.1",
+ "@discordjs/collection": "1.5.3",
+ "@discordjs/formatters": "^0.6.2",
+ "@discordjs/rest": "^2.6.1",
+ "@discordjs/util": "^1.2.0",
+ "@discordjs/ws": "^1.2.3",
+ "@sapphire/snowflake": "3.5.3",
+ "discord-api-types": "^0.38.40",
+ "fast-deep-equal": "3.1.3",
+ "lodash.snakecase": "4.1.1",
+ "magic-bytes.js": "^1.13.0",
+ "tslib": "^2.6.3",
+ "undici": "6.24.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/discordjs/discord.js?sponsor"
+ }
+ },
"node_modules/end-of-stream": {
"version": "1.4.5",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
@@ -2041,11 +2432,16 @@
"node": ">=12.0.0"
}
},
+ "node_modules/extend": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
+ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
+ "license": "MIT"
+ },
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
- "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
- "dev": true
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
},
"node_modules/fast-json-stable-stringify": {
"version": "2.1.0",
@@ -2307,6 +2703,18 @@
"node": ">=0.10.0"
}
},
+ "node_modules/is-plain-obj": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
+ "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@@ -2380,12 +2788,34 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/lodash": {
+ "version": "4.18.1",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
+ "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
+ "license": "MIT"
+ },
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true
},
+ "node_modules/lodash.snakecase": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
+ "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==",
+ "license": "MIT"
+ },
+ "node_modules/longest-streak": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
+ "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/luxon": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.2.tgz",
@@ -2395,6 +2825,12 @@
"node": ">=12"
}
},
+ "node_modules/magic-bytes.js": {
+ "version": "1.13.0",
+ "resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.13.0.tgz",
+ "integrity": "sha512-afO2mnxW7GDTXMm5/AoN1WuOcdoKhtgXjIvHmobqTD1grNplhGdv3PFOyjCVmrnOZBIT/gD/koDKpYG+0mvHcg==",
+ "license": "MIT"
+ },
"node_modules/magic-string": {
"version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
@@ -2405,6 +2841,780 @@
"@jridgewell/sourcemap-codec": "^1.5.5"
}
},
+ "node_modules/markdown-table": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz",
+ "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
+ "node_modules/mdast-util-find-and-replace": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz",
+ "integrity": "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "escape-string-regexp": "^5.0.0",
+ "unist-util-is": "^6.0.0",
+ "unist-util-visit-parents": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
+ "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mdast-util-from-markdown": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz",
+ "integrity": "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "@types/unist": "^3.0.0",
+ "decode-named-character-reference": "^1.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-to-string": "^4.0.0",
+ "micromark": "^4.0.0",
+ "micromark-util-decode-numeric-character-reference": "^2.0.0",
+ "micromark-util-decode-string": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0",
+ "unist-util-stringify-position": "^4.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz",
+ "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==",
+ "license": "MIT",
+ "dependencies": {
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-gfm-autolink-literal": "^2.0.0",
+ "mdast-util-gfm-footnote": "^2.0.0",
+ "mdast-util-gfm-strikethrough": "^2.0.0",
+ "mdast-util-gfm-table": "^2.0.0",
+ "mdast-util-gfm-task-list-item": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-autolink-literal": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz",
+ "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "ccount": "^2.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-find-and-replace": "^3.0.0",
+ "micromark-util-character": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-footnote": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz",
+ "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.1.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-strikethrough": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz",
+ "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-table": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz",
+ "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.0.0",
+ "markdown-table": "^3.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-task-list-item": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz",
+ "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-phrasing": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz",
+ "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "unist-util-is": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-to-markdown": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz",
+ "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "@types/unist": "^3.0.0",
+ "longest-streak": "^3.0.0",
+ "mdast-util-phrasing": "^4.0.0",
+ "mdast-util-to-string": "^4.0.0",
+ "micromark-util-classify-character": "^2.0.0",
+ "micromark-util-decode-string": "^2.0.0",
+ "unist-util-visit": "^5.0.0",
+ "zwitch": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-to-string": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz",
+ "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz",
+ "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "@types/debug": "^4.0.0",
+ "debug": "^4.0.0",
+ "decode-named-character-reference": "^1.0.0",
+ "devlop": "^1.0.0",
+ "micromark-core-commonmark": "^2.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-chunked": "^2.0.0",
+ "micromark-util-combine-extensions": "^2.0.0",
+ "micromark-util-decode-numeric-character-reference": "^2.0.0",
+ "micromark-util-encode": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0",
+ "micromark-util-resolve-all": "^2.0.0",
+ "micromark-util-sanitize-uri": "^2.0.0",
+ "micromark-util-subtokenize": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-core-commonmark": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz",
+ "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "decode-named-character-reference": "^1.0.0",
+ "devlop": "^1.0.0",
+ "micromark-factory-destination": "^2.0.0",
+ "micromark-factory-label": "^2.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-factory-title": "^2.0.0",
+ "micromark-factory-whitespace": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-chunked": "^2.0.0",
+ "micromark-util-classify-character": "^2.0.0",
+ "micromark-util-html-tag-name": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0",
+ "micromark-util-resolve-all": "^2.0.0",
+ "micromark-util-subtokenize": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-extension-gfm": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz",
+ "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==",
+ "license": "MIT",
+ "dependencies": {
+ "micromark-extension-gfm-autolink-literal": "^2.0.0",
+ "micromark-extension-gfm-footnote": "^2.0.0",
+ "micromark-extension-gfm-strikethrough": "^2.0.0",
+ "micromark-extension-gfm-table": "^2.0.0",
+ "micromark-extension-gfm-tagfilter": "^2.0.0",
+ "micromark-extension-gfm-task-list-item": "^2.0.0",
+ "micromark-util-combine-extensions": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-autolink-literal": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz",
+ "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==",
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-sanitize-uri": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-footnote": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz",
+ "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-core-commonmark": "^2.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0",
+ "micromark-util-sanitize-uri": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-strikethrough": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz",
+ "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-util-chunked": "^2.0.0",
+ "micromark-util-classify-character": "^2.0.0",
+ "micromark-util-resolve-all": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-table": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz",
+ "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-tagfilter": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz",
+ "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==",
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-extension-gfm-task-list-item": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz",
+ "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==",
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/micromark-factory-destination": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz",
+ "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-factory-label": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz",
+ "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-factory-space": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz",
+ "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-factory-title": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz",
+ "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-factory-whitespace": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz",
+ "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-factory-space": "^2.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-character": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz",
+ "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-chunked": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz",
+ "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-symbol": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-classify-character": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz",
+ "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-combine-extensions": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz",
+ "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-chunked": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-decode-numeric-character-reference": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz",
+ "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-symbol": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-decode-string": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz",
+ "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "decode-named-character-reference": "^1.0.0",
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-decode-numeric-character-reference": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-encode": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz",
+ "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/micromark-util-html-tag-name": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz",
+ "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/micromark-util-normalize-identifier": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz",
+ "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-symbol": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-resolve-all": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz",
+ "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-sanitize-uri": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz",
+ "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "micromark-util-character": "^2.0.0",
+ "micromark-util-encode": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-subtokenize": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz",
+ "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "devlop": "^1.0.0",
+ "micromark-util-chunked": "^2.0.0",
+ "micromark-util-symbol": "^2.0.0",
+ "micromark-util-types": "^2.0.0"
+ }
+ },
+ "node_modules/micromark-util-symbol": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz",
+ "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/micromark-util-types": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz",
+ "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==",
+ "funding": [
+ {
+ "type": "GitHub Sponsors",
+ "url": "https://github.com/sponsors/unifiedjs"
+ },
+ {
+ "type": "OpenCollective",
+ "url": "https://opencollective.com/unified"
+ }
+ ],
+ "license": "MIT"
+ },
"node_modules/mimic-response": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
@@ -2448,7 +3658,6 @@
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
- "dev": true,
"license": "MIT"
},
"node_modules/nanoid": {
@@ -2755,6 +3964,61 @@
"node": ">= 6"
}
},
+ "node_modules/remark-gfm": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz",
+ "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-gfm": "^3.0.0",
+ "micromark-extension-gfm": "^3.0.0",
+ "remark-parse": "^11.0.0",
+ "remark-stringify": "^11.0.0",
+ "unified": "^11.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/remark-parse": {
+ "version": "11.0.0",
+ "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz",
+ "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "micromark-util-types": "^2.0.0",
+ "unified": "^11.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/remark-stringify": {
+ "version": "11.0.0",
+ "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz",
+ "integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-to-markdown": "^2.0.0",
+ "unified": "^11.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/remend": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/remend/-/remend-1.3.0.tgz",
+ "integrity": "sha512-iIhggPkhW3hFImKtB10w0dz4EZbs28mV/dmbcYVonWEJ6UGHHpP+bFZnTh6GNWJONg5m+U56JrL+8IxZRdgWjw==",
+ "license": "Apache-2.0"
+ },
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@@ -3042,6 +4306,16 @@
"node": ">=14.0.0"
}
},
+ "node_modules/trough": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz",
+ "integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/ts-api-utils": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
@@ -3054,6 +4328,18 @@
"typescript": ">=4.8.4"
}
},
+ "node_modules/ts-mixer": {
+ "version": "6.0.4",
+ "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
+ "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==",
+ "license": "MIT"
+ },
+ "node_modules/tslib": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "license": "0BSD"
+ },
"node_modules/tsx": {
"version": "4.21.0",
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz",
@@ -3135,13 +4421,95 @@
"typescript": ">=4.8.4 <6.0.0"
}
},
+ "node_modules/undici": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-6.24.1.tgz",
+ "integrity": "sha512-sC+b0tB1whOCzbtlx20fx3WgCXwkW627p4EA9uM+/tNNPkSS+eSEld6pAs9nDv7WbY1UUljBMYPtu9BCOrCWKA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18.17"
+ }
+ },
"node_modules/undici-types": {
"version": "6.21.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
- "dev": true,
"license": "MIT"
},
+ "node_modules/unified": {
+ "version": "11.0.5",
+ "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
+ "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "bail": "^2.0.0",
+ "devlop": "^1.0.0",
+ "extend": "^3.0.0",
+ "is-plain-obj": "^4.0.0",
+ "trough": "^2.0.0",
+ "vfile": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/unist-util-is": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz",
+ "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/unist-util-stringify-position": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
+ "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/unist-util-visit": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz",
+ "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "unist-util-is": "^6.0.0",
+ "unist-util-visit-parents": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/unist-util-visit-parents": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz",
+ "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "unist-util-is": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@@ -3157,6 +4525,34 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
+ "node_modules/vfile": {
+ "version": "6.0.3",
+ "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz",
+ "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "vfile-message": "^4.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/vfile-message": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz",
+ "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "unist-util-stringify-position": "^4.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/vite": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.2.tgz",
@@ -3357,6 +4753,27 @@
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"license": "ISC"
},
+ "node_modules/ws": {
+ "version": "8.20.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.20.0.tgz",
+ "integrity": "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": ">=5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
@@ -3368,6 +4785,16 @@
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
+ },
+ "node_modules/zwitch": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
+ "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
}
}
}
diff --git a/package.json b/package.json
index be913a9..91bbfbb 100644
--- a/package.json
+++ b/package.json
@@ -21,8 +21,11 @@
"test:watch": "vitest"
},
"dependencies": {
+ "@chat-adapter/discord": "^4.24.0",
+ "@chat-adapter/state-memory": "^4.24.0",
"@onecli-sh/sdk": "^0.2.0",
"better-sqlite3": "11.10.0",
+ "chat": "^4.24.0",
"cron-parser": "5.5.0"
},
"devDependencies": {
diff --git a/scripts/seed-discord.ts b/scripts/seed-discord.ts
new file mode 100644
index 0000000..410570b
--- /dev/null
+++ b/scripts/seed-discord.ts
@@ -0,0 +1,78 @@
+/**
+ * Seed the v2 central DB with a Discord agent group + messaging group.
+ *
+ * Usage: npx tsx scripts/seed-discord.ts
+ */
+import path from 'path';
+
+import { DATA_DIR } from '../src/config.js';
+import { initDb } from '../src/db/connection.js';
+import { runMigrations } from '../src/db/migrations/index.js';
+import { createAgentGroup, getAgentGroup } from '../src/db/agent-groups.js';
+import {
+ createMessagingGroup,
+ createMessagingGroupAgent,
+ getMessagingGroup,
+} from '../src/db/messaging-groups.js';
+
+const db = initDb(path.join(DATA_DIR, 'v2.db'));
+runMigrations(db);
+
+const AGENT_GROUP_ID = 'ag-main';
+const MESSAGING_GROUP_ID = 'mg-discord';
+const CHANNEL_ID = 'discord:1470188214710046894:1491569326447132673';
+
+// Agent group
+if (!getAgentGroup(AGENT_GROUP_ID)) {
+ createAgentGroup({
+ id: AGENT_GROUP_ID,
+ name: 'Main',
+ folder: 'main',
+ is_admin: 1,
+ agent_provider: 'claude',
+ container_config: null,
+ created_at: new Date().toISOString(),
+ });
+ console.log('Created agent group:', AGENT_GROUP_ID);
+} else {
+ console.log('Agent group already exists:', AGENT_GROUP_ID);
+}
+
+// Messaging group
+if (!getMessagingGroup(MESSAGING_GROUP_ID)) {
+ createMessagingGroup({
+ id: MESSAGING_GROUP_ID,
+ channel_type: 'discord',
+ platform_id: CHANNEL_ID,
+ name: 'Discord Test',
+ is_group: 1,
+ admin_user_id: null,
+ created_at: new Date().toISOString(),
+ });
+ console.log('Created messaging group:', MESSAGING_GROUP_ID);
+} else {
+ console.log('Messaging group already exists:', MESSAGING_GROUP_ID);
+}
+
+// Link
+try {
+ createMessagingGroupAgent({
+ id: 'mga-discord',
+ messaging_group_id: MESSAGING_GROUP_ID,
+ agent_group_id: AGENT_GROUP_ID,
+ trigger_rules: null,
+ response_scope: 'all',
+ session_mode: 'shared',
+ priority: 0,
+ created_at: new Date().toISOString(),
+ });
+ console.log('Created messaging_group_agent link');
+} catch (err: any) {
+ if (err.message?.includes('UNIQUE')) {
+ console.log('Messaging group agent link already exists');
+ } else {
+ throw err;
+ }
+}
+
+console.log('Done! Run: npm run build && node dist/index-v2.js');
diff --git a/scripts/test-v2-channel-e2e.ts b/scripts/test-v2-channel-e2e.ts
new file mode 100644
index 0000000..15f84e3
--- /dev/null
+++ b/scripts/test-v2-channel-e2e.ts
@@ -0,0 +1,257 @@
+/**
+ * End-to-end test of v2 channel adapter pipeline:
+ *
+ * Mock adapter → onInbound → router → session DB → Docker container →
+ * agent-runner → Claude → messages_out → delivery → mock adapter.deliver()
+ *
+ * Usage: npx tsx scripts/test-v2-channel-e2e.ts
+ */
+import Database from 'better-sqlite3';
+import fs from 'fs';
+import path from 'path';
+
+const TEST_DIR = '/tmp/nanoclaw-v2-channel-e2e';
+if (fs.existsSync(TEST_DIR)) fs.rmSync(TEST_DIR, { recursive: true });
+fs.mkdirSync(TEST_DIR, { recursive: true });
+
+// --- Step 1: Init central DB ---
+console.log('\n=== Step 1: Init central DB ===');
+
+import { initDb } from '../src/db/connection.js';
+import { runMigrations } from '../src/db/migrations/index.js';
+import { createAgentGroup } from '../src/db/agent-groups.js';
+import { createMessagingGroup, createMessagingGroupAgent } from '../src/db/messaging-groups.js';
+
+const centralDb = initDb(path.join(TEST_DIR, 'v2.db'));
+runMigrations(centralDb);
+
+// Create groups dir for agent folder mount
+const groupsDir = path.resolve(process.cwd(), 'groups');
+const testGroupDir = path.join(groupsDir, 'test-channel-e2e');
+fs.mkdirSync(testGroupDir, { recursive: true });
+fs.writeFileSync(path.join(testGroupDir, 'CLAUDE.md'), '# Test Agent\nYou are a test agent. Be brief.\n');
+
+createAgentGroup({
+ id: 'ag-chan',
+ name: 'Channel E2E Agent',
+ folder: 'test-channel-e2e',
+ is_admin: 1, // admin so OneCLI uses default agent for auth
+ agent_provider: 'claude',
+ container_config: null,
+ created_at: new Date().toISOString(),
+});
+
+createMessagingGroup({
+ id: 'mg-chan',
+ channel_type: 'mock',
+ platform_id: 'mock-channel-1',
+ name: 'Mock Channel',
+ is_group: 0,
+ admin_user_id: null,
+ created_at: new Date().toISOString(),
+});
+
+createMessagingGroupAgent({
+ id: 'mga-chan',
+ messaging_group_id: 'mg-chan',
+ agent_group_id: 'ag-chan',
+ trigger_rules: null,
+ response_scope: 'all',
+ session_mode: 'shared',
+ priority: 0,
+ created_at: new Date().toISOString(),
+});
+
+console.log('✓ Central DB initialized');
+
+// --- Step 2: Set up mock channel adapter + delivery ---
+console.log('\n=== Step 2: Set up mock channel adapter & delivery ===');
+
+import { routeInbound } from '../src/router-v2.js';
+import { setDeliveryAdapter, startActiveDeliveryPoll, stopDeliveryPolls } from '../src/delivery.js';
+import { getChannelAdapter, registerChannelAdapter, initChannelAdapters } from '../src/channels/channel-registry.js';
+import { findSession } from '../src/db/sessions.js';
+import { sessionDbPath } from '../src/session-manager.js';
+import type { ChannelAdapter, ChannelSetup, OutboundMessage } from '../src/channels/adapter.js';
+
+// Track delivered messages
+const deliveredMessages: Array<{ platformId: string; threadId: string | null; message: OutboundMessage }> = [];
+let lastDeliveryTime = 0;
+const startTime = Date.now();
+
+// Create mock adapter
+const mockAdapter: ChannelAdapter = {
+ name: 'mock',
+ channelType: 'mock',
+
+ async setup(config: ChannelSetup) {
+ console.log(` ✓ Mock adapter setup with ${config.conversations.length} conversations`);
+ },
+
+ async deliver(platformId, threadId, message) {
+ deliveredMessages.push({ platformId, threadId, message });
+ lastDeliveryTime = Date.now();
+ const elapsed = Math.floor((Date.now() - startTime) / 1000);
+ const content = message.content as Record;
+ const text = ((content.text as string) || '').slice(0, 120);
+ console.log(` ✓ [${elapsed}s] Delivered #${deliveredMessages.length}: ${text}...`);
+ },
+
+ async setTyping() {},
+ async teardown() {},
+ isConnected() { return true; },
+};
+
+// Register mock adapter
+registerChannelAdapter('mock', { factory: () => mockAdapter });
+
+// Init channel adapters — this calls setup() with conversation configs from central DB
+await initChannelAdapters((adapter) => ({
+ conversations: [{ platformId: 'mock-channel-1', agentGroupId: 'ag-chan', requiresTrigger: false, sessionMode: 'shared' }],
+ onInbound(platformId, threadId, message) {
+ routeInbound({
+ channelType: adapter.channelType,
+ platformId,
+ threadId,
+ message: {
+ id: message.id,
+ kind: message.kind,
+ content: JSON.stringify(message.content),
+ timestamp: message.timestamp,
+ },
+ }).catch((err) => console.error('Route error:', err));
+ },
+ onMetadata() {},
+}));
+
+// Set up delivery adapter bridge
+setDeliveryAdapter({
+ async deliver(channelType, platformId, threadId, kind, content) {
+ const adapter = getChannelAdapter(channelType);
+ if (!adapter) return;
+ await adapter.deliver(platformId, threadId, { kind, content: JSON.parse(content) });
+ },
+});
+
+// Start delivery polling
+startActiveDeliveryPoll();
+console.log('✓ Mock adapter & delivery configured');
+
+// --- Step 3: Simulate inbound message through adapter ---
+console.log('\n=== Step 3: Simulate inbound message ===');
+
+// This is what a real adapter would do when receiving a platform message
+const adapterSetup = (mockAdapter as { _setup?: ChannelSetup })._setup;
+
+// Call routeInbound directly (simulating onInbound callback)
+await routeInbound({
+ channelType: 'mock',
+ platformId: 'mock-channel-1',
+ threadId: null,
+ message: {
+ id: 'msg-chan-1',
+ kind: 'chat',
+ content: JSON.stringify({
+ sender: 'Gavriel',
+ text: 'Call the send_message tool 3 times: text="Update 1", text="Update 2", text="Update 3". Make each call separately. After all 3, say "Done".',
+ }),
+ timestamp: new Date().toISOString(),
+ },
+});
+
+const session = findSession('mg-chan', null);
+if (!session) {
+ console.log('✗ No session created!');
+ cleanup();
+ process.exit(1);
+}
+console.log(`✓ Session: ${session.id}`);
+console.log(`✓ Container status: ${session.container_status}`);
+
+import { execSync } from 'child_process';
+const checkContainerLogs = () => {
+ try {
+ const containers = execSync('docker ps -a --filter name=nanoclaw-v2-test-channel --format "{{.Names}}"').toString().trim();
+ for (const name of containers.split('\n').filter(Boolean)) {
+ console.log(`\nContainer logs (${name}):`);
+ console.log(execSync(`docker logs ${name} 2>&1`).toString());
+ }
+ } catch { /* ignore */ }
+};
+
+const sessDbPath = sessionDbPath('ag-chan', session.id);
+console.log(`✓ Session DB: ${sessDbPath}`);
+
+// --- Step 4: Wait for delivery through mock adapter ---
+console.log('\n=== Step 4: Waiting for delivery through mock adapter... ===');
+const TIMEOUT_MS = 300_000;
+
+// Wait for deliveries — resolve when no new ones for 30s after first delivery
+await new Promise((resolve) => {
+ const poll = () => {
+ if (lastDeliveryTime > 0 && Date.now() - lastDeliveryTime > 30_000) {
+ resolve();
+ return;
+ }
+ if (Date.now() - startTime > TIMEOUT_MS) {
+ console.log(`\n✗ Timed out after ${TIMEOUT_MS / 1000}s`);
+ // Check session DB directly
+ try {
+ const db = new Database(sessDbPath, { readonly: true });
+ const out = db.prepare('SELECT * FROM messages_out').all();
+ console.log(` messages_out rows: ${out.length}`);
+ if (out.length > 0) console.log(' (messages exist but delivery failed)');
+ db.close();
+ } catch { /* ignore */ }
+ checkContainerLogs();
+ cleanup();
+ process.exit(1);
+ }
+ const elapsed = Math.floor((Date.now() - startTime) / 1000);
+ if (elapsed > 0 && elapsed % 10 === 0) {
+ process.stdout.write(` ${elapsed}s...`);
+ }
+ setTimeout(poll, 1000);
+ };
+ poll();
+});
+
+// --- Step 5: Print results ---
+console.log('\n\n=== Results ===');
+
+console.log('\nSession DB:');
+try {
+ const db = new Database(sessDbPath, { readonly: true });
+ const inRows = db.prepare('SELECT * FROM messages_in').all() as Array>;
+ const outRows = db.prepare('SELECT * FROM messages_out').all() as Array>;
+ db.close();
+
+ console.log(` messages_in: ${inRows.length} row(s)`);
+ for (const r of inRows) {
+ console.log(` [${r.id}] status=${r.status} kind=${r.kind}`);
+ }
+ console.log(` messages_out: ${outRows.length} row(s)`);
+ for (const r of outRows) {
+ const content = JSON.parse(r.content as string);
+ console.log(` [${r.id}] kind=${r.kind} delivered=${r.delivered}`);
+ console.log(` → ${content.text}`);
+ }
+} catch (err) {
+ console.log(` (could not read session DB: ${err})`);
+}
+
+console.log('\nDelivered through mock adapter:');
+for (const d of deliveredMessages) {
+ const content = d.message.content as Record;
+ console.log(` → [${d.platformId}] ${content.text}`);
+}
+
+console.log('\n✓ Full channel adapter pipeline verified!');
+
+cleanup();
+process.exit(0);
+
+function cleanup() {
+ stopDeliveryPolls();
+ fs.rmSync(testGroupDir, { recursive: true, force: true });
+}
diff --git a/src/channels/chat-sdk-bridge.ts b/src/channels/chat-sdk-bridge.ts
new file mode 100644
index 0000000..50b6f27
--- /dev/null
+++ b/src/channels/chat-sdk-bridge.ts
@@ -0,0 +1,189 @@
+/**
+ * Chat SDK bridge — wraps a Chat SDK adapter + Chat instance
+ * to conform to the NanoClaw ChannelAdapter interface.
+ *
+ * Used by Discord, Slack, and other Chat SDK-supported platforms.
+ */
+import { Chat, type Adapter, type ConcurrencyStrategy, type Message as ChatMessage } from 'chat';
+import { createMemoryState } from '@chat-adapter/state-memory';
+
+import { log } from '../log.js';
+import type { ChannelAdapter, ChannelSetup, ConversationConfig, InboundMessage } from './adapter.js';
+
+/** Adapter with optional gateway support (e.g., Discord). */
+interface GatewayAdapter extends Adapter {
+ startGatewayListener?(
+ options: { waitUntil?: (task: Promise) => void },
+ durationMs?: number,
+ abortSignal?: AbortSignal,
+ ): Promise;
+}
+
+export interface ChatSdkBridgeConfig {
+ adapter: GatewayAdapter;
+ concurrency?: ConcurrencyStrategy;
+}
+
+export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter {
+ const { adapter } = config;
+ let chat: Chat;
+ let state: ReturnType;
+ let setupConfig: ChannelSetup;
+ let conversations: Map;
+ let gatewayAbort: AbortController | null = null;
+
+ function buildConversationMap(configs: ConversationConfig[]): Map {
+ const map = new Map();
+ for (const conv of configs) {
+ map.set(conv.platformId, conv);
+ }
+ return map;
+ }
+
+ function messageToInbound(message: ChatMessage): InboundMessage {
+ return {
+ id: message.id,
+ kind: 'chat-sdk',
+ content: message.toJSON(),
+ timestamp: message.metadata.dateSent.toISOString(),
+ };
+ }
+
+ return {
+ name: adapter.name,
+ channelType: adapter.name,
+
+ async setup(hostConfig: ChannelSetup) {
+ setupConfig = hostConfig;
+ conversations = buildConversationMap(hostConfig.conversations);
+
+ state = createMemoryState();
+
+ chat = new Chat({
+ adapters: { [adapter.name]: adapter },
+ userName: adapter.userName || 'NanoClaw',
+ concurrency: config.concurrency ?? 'concurrent',
+ state,
+ logger: 'silent',
+ });
+
+ // Subscribed threads — forward all messages
+ chat.onSubscribedMessage(async (thread, message) => {
+ const channelId = adapter.channelIdFromThreadId(thread.id);
+ setupConfig.onInbound(channelId, thread.id, messageToInbound(message));
+ });
+
+ // @mention in unsubscribed thread — forward + subscribe
+ chat.onNewMention(async (thread, message) => {
+ const channelId = adapter.channelIdFromThreadId(thread.id);
+ setupConfig.onInbound(channelId, thread.id, messageToInbound(message));
+ await thread.subscribe();
+ });
+
+ // DMs — always forward + subscribe
+ chat.onDirectMessage(async (thread, message) => {
+ const channelId = adapter.channelIdFromThreadId(thread.id);
+ setupConfig.onInbound(channelId, null, messageToInbound(message));
+ await thread.subscribe();
+ });
+
+ await chat.initialize();
+
+ // Subscribe registered conversations (after initialize connects state)
+ for (const conv of hostConfig.conversations) {
+ if (conv.agentGroupId) {
+ const threadId = adapter.encodeThreadId({ guildId: '', channelId: conv.platformId } as never);
+ await state.subscribe(threadId);
+ }
+ }
+
+ // Start Gateway listener for adapters that support it (e.g., Discord)
+ if (adapter.startGatewayListener) {
+ gatewayAbort = new AbortController();
+ const startGateway = () => {
+ if (gatewayAbort?.signal.aborted) return;
+ // Capture the long-running listener promise via waitUntil
+ let listenerPromise: Promise | undefined;
+ adapter
+ .startGatewayListener!(
+ { waitUntil: (p: Promise) => { listenerPromise = p; } },
+ 24 * 60 * 60 * 1000,
+ gatewayAbort!.signal,
+ )
+ .then(() => {
+ // startGatewayListener resolves immediately with a Response;
+ // the actual work is in the listenerPromise passed to waitUntil
+ if (listenerPromise) {
+ listenerPromise
+ .then(() => {
+ if (!gatewayAbort?.signal.aborted) {
+ log.info('Gateway listener expired, restarting', { adapter: adapter.name });
+ startGateway();
+ }
+ })
+ .catch((err) => {
+ if (!gatewayAbort?.signal.aborted) {
+ log.error('Gateway listener error, restarting in 5s', { adapter: adapter.name, err });
+ setTimeout(startGateway, 5000);
+ }
+ });
+ }
+ });
+ };
+ startGateway();
+ log.info('Gateway listener started', { adapter: adapter.name });
+ }
+
+ log.info('Chat SDK bridge initialized', { adapter: adapter.name });
+ },
+
+ async deliver(platformId: string, threadId: string | null, message) {
+ const tid = threadId ?? adapter.encodeThreadId({ guildId: '', channelId: platformId } as never);
+ const content = message.content as Record;
+
+ if (content.operation === 'edit' && content.messageId) {
+ await adapter.editMessage(tid, content.messageId as string, {
+ markdown: (content.text as string) || (content.markdown as string) || '',
+ });
+ return;
+ }
+
+ if (content.operation === 'reaction' && content.messageId && content.emoji) {
+ await adapter.addReaction(tid, content.messageId as string, content.emoji as string);
+ return;
+ }
+
+ // Normal message
+ const text = (content.markdown as string) || (content.text as string);
+ if (text) {
+ await adapter.postMessage(tid, { markdown: text });
+ }
+ },
+
+ async setTyping(platformId: string, threadId: string | null) {
+ const tid = threadId ?? adapter.encodeThreadId({ guildId: '', channelId: platformId } as never);
+ await adapter.startTyping(tid);
+ },
+
+ async teardown() {
+ gatewayAbort?.abort();
+ await chat.shutdown();
+ log.info('Chat SDK bridge shut down', { adapter: adapter.name });
+ },
+
+ isConnected() {
+ return true;
+ },
+
+ updateConversations(configs: ConversationConfig[]) {
+ conversations = buildConversationMap(configs);
+ // Subscribe new conversations
+ for (const conv of configs) {
+ if (conv.agentGroupId) {
+ const threadId = adapter.encodeThreadId({ guildId: '', channelId: conv.platformId } as never);
+ state.subscribe(threadId).catch(() => {});
+ }
+ }
+ },
+ };
+}
diff --git a/src/channels/discord-v2.ts b/src/channels/discord-v2.ts
new file mode 100644
index 0000000..5eb32ed
--- /dev/null
+++ b/src/channels/discord-v2.ts
@@ -0,0 +1,22 @@
+/**
+ * Discord channel adapter (v2) — uses Chat SDK bridge.
+ * Self-registers on import.
+ */
+import { createDiscordAdapter } from '@chat-adapter/discord';
+
+import { readEnvFile } from '../env.js';
+import { createChatSdkBridge } from './chat-sdk-bridge.js';
+import { registerChannelAdapter } from './channel-registry.js';
+
+registerChannelAdapter('discord', {
+ factory: () => {
+ const env = readEnvFile(['DISCORD_BOT_TOKEN', 'DISCORD_PUBLIC_KEY', 'DISCORD_APPLICATION_ID']);
+ if (!env.DISCORD_BOT_TOKEN) return null;
+ const discordAdapter = createDiscordAdapter({
+ botToken: env.DISCORD_BOT_TOKEN,
+ publicKey: env.DISCORD_PUBLIC_KEY,
+ applicationId: env.DISCORD_APPLICATION_ID,
+ });
+ return createChatSdkBridge({ adapter: discordAdapter, concurrency: 'concurrent' });
+ },
+});
diff --git a/src/container-runner-v2.ts b/src/container-runner-v2.ts
index dac9c4c..c1b0aac 100644
--- a/src/container-runner-v2.ts
+++ b/src/container-runner-v2.ts
@@ -185,15 +185,8 @@ function buildMounts(agentGroup: AgentGroup, session: Session): VolumeMount[] {
const agentRunnerSrc = path.join(projectRoot, 'container', 'agent-runner', 'src');
const groupRunnerDir = path.join(DATA_DIR, 'v2-sessions', agentGroup.id, 'agent-runner-src');
if (fs.existsSync(agentRunnerSrc)) {
- const srcIndex = path.join(agentRunnerSrc, 'index-v2.ts');
- const cachedIndex = path.join(groupRunnerDir, 'index-v2.ts');
- const needsCopy =
- !fs.existsSync(groupRunnerDir) ||
- !fs.existsSync(cachedIndex) ||
- fs.statSync(srcIndex).mtimeMs > fs.statSync(cachedIndex).mtimeMs;
- if (needsCopy) {
- fs.cpSync(agentRunnerSrc, groupRunnerDir, { recursive: true });
- }
+ // Always copy — source files may have changed beyond just the index
+ fs.cpSync(agentRunnerSrc, groupRunnerDir, { recursive: true });
}
mounts.push({ hostPath: groupRunnerDir, containerPath: '/app/src', readonly: false });
diff --git a/src/db/schema.ts b/src/db/schema.ts
index 2d50d18..bf8ff19 100644
--- a/src/db/schema.ts
+++ b/src/db/schema.ts
@@ -74,6 +74,7 @@ CREATE TABLE pending_questions (
export const SESSION_SCHEMA = `
CREATE TABLE messages_in (
id TEXT PRIMARY KEY,
+ seq INTEGER UNIQUE,
kind TEXT NOT NULL,
timestamp TEXT NOT NULL,
status TEXT DEFAULT 'pending',
@@ -89,6 +90,7 @@ CREATE TABLE messages_in (
CREATE TABLE messages_out (
id TEXT PRIMARY KEY,
+ seq INTEGER UNIQUE,
in_reply_to TEXT,
timestamp TEXT NOT NULL,
delivered INTEGER DEFAULT 0,
diff --git a/src/index-v2.ts b/src/index-v2.ts
index 396acd8..e4d6ec4 100644
--- a/src/index-v2.ts
+++ b/src/index-v2.ts
@@ -17,7 +17,7 @@ import { routeInbound } from './router-v2.js';
import { log } from './log.js';
// Channel imports — each triggers self-registration
-// import './channels/discord-v2.js';
+import './channels/discord-v2.js';
import type { ChannelAdapter, ChannelSetup, ConversationConfig } from './channels/adapter.js';
import { initChannelAdapters, teardownChannelAdapters, getChannelAdapter } from './channels/channel-registry.js';
diff --git a/src/session-manager.ts b/src/session-manager.ts
index 4048cfb..4498198 100644
--- a/src/session-manager.ts
+++ b/src/session-manager.ts
@@ -108,11 +108,23 @@ export function writeSessionMessage(
db.pragma('journal_mode = DELETE');
try {
+ const nextSeq = (
+ db
+ .prepare(
+ `SELECT COALESCE(MAX(seq), 0) + 1 AS next FROM (
+ SELECT seq FROM messages_in WHERE seq IS NOT NULL
+ UNION ALL
+ SELECT seq FROM messages_out WHERE seq IS NOT NULL
+ )`,
+ )
+ .get() as { next: number }
+ ).next;
db.prepare(
- `INSERT INTO messages_in (id, kind, timestamp, status, platform_id, channel_type, thread_id, content, process_after, recurrence)
- VALUES (@id, @kind, @timestamp, 'pending', @platformId, @channelType, @threadId, @content, @processAfter, @recurrence)`,
+ `INSERT INTO messages_in (id, seq, kind, timestamp, status, platform_id, channel_type, thread_id, content, process_after, recurrence)
+ VALUES (@id, @seq, @kind, @timestamp, 'pending', @platformId, @channelType, @threadId, @content, @processAfter, @recurrence)`,
).run({
id: message.id,
+ seq: nextSeq,
kind: message.kind,
timestamp: message.timestamp,
platformId: message.platformId ?? null,