Add MiniMax API support, Apple Container runtime, and stop script
Some checks failed
Bump version / bump-version (push) Has been cancelled
Sync upstream & merge-forward skill branches / sync-and-merge (push) Has been cancelled
Merge-forward skill branches / merge-forward (push) Has been cancelled
Update token count / update-tokens (push) Has been cancelled
Some checks failed
Bump version / bump-version (push) Has been cancelled
Sync upstream & merge-forward skill branches / sync-and-merge (push) Has been cancelled
Merge-forward skill branches / merge-forward (push) Has been cancelled
Update token count / update-tokens (push) Has been cancelled
- Add ASSISTANT_NAME and claude-minimax.sh for MiniMax API usage - Switch container runtime from Docker to Apple Container - Add CJK character restriction notice to CLAUDE.md files - Add stop.sh for graceful shutdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
80
src/db.ts
80
src/db.ts
@@ -73,6 +73,16 @@ function createSchema(database: Database.Database): void {
|
||||
group_folder TEXT PRIMARY KEY,
|
||||
session_id TEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS outbound_messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
chat_jid TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
sent_at TEXT NOT NULL,
|
||||
message_type TEXT DEFAULT 'response'
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_outbound_chat ON outbound_messages(chat_jid, sent_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_outbound_sent_at ON outbound_messages(sent_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS registered_groups (
|
||||
jid TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
@@ -695,3 +705,73 @@ function migrateJsonState(): void {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outbound message history for dashboard
|
||||
*/
|
||||
export interface OutboundMessage {
|
||||
id: number;
|
||||
chat_jid: string;
|
||||
content: string;
|
||||
sent_at: string;
|
||||
message_type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an outbound message (agent response)
|
||||
*/
|
||||
export function storeOutboundMessage(
|
||||
chatJid: string,
|
||||
content: string,
|
||||
messageType: string = 'response',
|
||||
): void {
|
||||
db.prepare(
|
||||
`INSERT INTO outbound_messages (chat_jid, content, sent_at, message_type) VALUES (?, ?, ?, ?)`,
|
||||
).run(chatJid, content, new Date().toISOString(), messageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recent outbound messages (default: last 100)
|
||||
*/
|
||||
export function getOutboundMessages(limit: number = 100): OutboundMessage[] {
|
||||
return db
|
||||
.prepare(
|
||||
`SELECT id, chat_jid, content, sent_at, message_type
|
||||
FROM outbound_messages
|
||||
ORDER BY sent_at DESC
|
||||
LIMIT ?`,
|
||||
)
|
||||
.all(limit) as OutboundMessage[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get outbound messages by chat JID
|
||||
*/
|
||||
export function getOutboundMessagesByChat(
|
||||
chatJid: string,
|
||||
limit: number = 50,
|
||||
): OutboundMessage[] {
|
||||
return db
|
||||
.prepare(
|
||||
`SELECT id, chat_jid, content, sent_at, message_type
|
||||
FROM outbound_messages
|
||||
WHERE chat_jid = ?
|
||||
ORDER BY sent_at DESC
|
||||
LIMIT ?`,
|
||||
)
|
||||
.all(chatJid, limit) as OutboundMessage[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup outbound messages older than retention days (default: 7)
|
||||
*/
|
||||
export function cleanupOldOutboundMessages(retentionDays: number = 7): number {
|
||||
const cutoff = new Date();
|
||||
cutoff.setDate(cutoff.getDate() - retentionDays);
|
||||
const cutoffStr = cutoff.toISOString();
|
||||
|
||||
const result = db
|
||||
.prepare(`DELETE FROM outbound_messages WHERE sent_at < ?`)
|
||||
.run(cutoffStr);
|
||||
return result.changes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user