feat: @agor/stores package (3 stores) + 58 BackendAdapter tests
@agor/stores: - theme.svelte.ts, notifications.svelte.ts, health.svelte.ts extracted - Original files replaced with re-exports (zero consumer changes needed) - pnpm workspace + Vite/tsconfig aliases configured BackendAdapter tests (58 new): - backend-adapter.test.ts: 9 tests (lifecycle, singleton, testing seam) - tauri-adapter.test.ts: 28 tests (invoke mapping, command names, params) - electrobun-adapter.test.ts: 21 tests (RPC names, capabilities, stubs) Total: 523 tests passing (was 465, +58)
This commit is contained in:
parent
5e1fd62ed9
commit
f0850f0785
22 changed files with 1389 additions and 25 deletions
|
|
@ -334,6 +334,42 @@ export class BtmsgDb {
|
|||
return id;
|
||||
}
|
||||
|
||||
// ── Feature 7: Channel membership management ─────────────────────────────
|
||||
|
||||
joinChannel(channelId: string, agentId: string): void {
|
||||
// Validate channel exists
|
||||
const ch = this.db.query<{ id: string }, [string]>(
|
||||
"SELECT id FROM channels WHERE id = ?"
|
||||
).get(channelId);
|
||||
if (!ch) throw new Error(`Channel '${channelId}' not found`);
|
||||
|
||||
this.db.query(
|
||||
"INSERT OR IGNORE INTO channel_members (channel_id, agent_id) VALUES (?1, ?2)"
|
||||
).run(channelId, agentId);
|
||||
}
|
||||
|
||||
leaveChannel(channelId: string, agentId: string): void {
|
||||
this.db.query(
|
||||
"DELETE FROM channel_members WHERE channel_id = ? AND agent_id = ?"
|
||||
).run(channelId, agentId);
|
||||
}
|
||||
|
||||
getChannelMembers(channelId: string): Array<{ agentId: string; name: string; role: string }> {
|
||||
return this.db.query<{
|
||||
agent_id: string; name: string; role: string;
|
||||
}, [string]>(
|
||||
`SELECT cm.agent_id, a.name, a.role
|
||||
FROM channel_members cm
|
||||
JOIN agents a ON cm.agent_id = a.id
|
||||
WHERE cm.channel_id = ?
|
||||
ORDER BY a.name`
|
||||
).all(channelId).map(r => ({
|
||||
agentId: r.agent_id,
|
||||
name: r.name,
|
||||
role: r.role,
|
||||
}));
|
||||
}
|
||||
|
||||
// ── Heartbeats ───────────────────────────────────────────────────────────
|
||||
|
||||
heartbeat(agentId: string): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue