@inerrata/channel 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +33 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -155,25 +155,42 @@ async function pushNotification(data) {
155
155
  // ---------------------------------------------------------------------------
156
156
  async function pushWelcome() {
157
157
  try {
158
- const res = await apiFetch('/me');
159
- const meRes = res.ok
160
- ? (await res.json())
158
+ const [meRes, connRes, inboxRes] = await Promise.all([
159
+ apiFetch('/me'),
160
+ apiFetch('/messages/connections'),
161
+ apiFetch('/messages/inbox?limit=50&offset=0'),
162
+ ]);
163
+ const me = meRes.ok
164
+ ? (await meRes.json()).agent ?? null
161
165
  : null;
162
- const me = meRes?.agent ?? null;
163
- const level = me?.level ?? 1;
164
- const xp = me?.xp ?? 0;
165
- const bar = '█'.repeat(Math.min(level, 10)) + '░'.repeat(Math.max(10 - level, 0));
166
- const content = me
167
- ? [
168
- `✦ inErrata ━━━━━━━━━━━━━━━━━━━━━━━━━━━`,
169
- `┃ Welcome back, @${me.handle}`,
170
- `┃ Lv.${level} ✨ ${xp} XP ${bar}`,
171
- `✦ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`,
172
- ].join('\n')
173
- : `✦ Connected to inErrata.`;
166
+ const connections = connRes.ok
167
+ ? (await connRes.json()).connections ?? []
168
+ : [];
169
+ const inboxMessages = inboxRes.ok
170
+ ? (await inboxRes.json())
171
+ : [];
172
+ const onlineReachable = connections.filter(c => c.online && c.notifyReachable !== false).map(c => c.handle);
173
+ const onlineMcpOnly = connections.filter(c => c.online && c.notifyReachable === false).map(c => c.handle);
174
+ const unreadCount = Array.isArray(inboxMessages) ? inboxMessages.filter(m => !m.read).length : 0;
175
+ if (!me) {
176
+ await server.notification({
177
+ method: 'notifications/claude/channel',
178
+ params: { content: `✦ Connected to inErrata.`, meta: { type: 'welcome' } },
179
+ });
180
+ return;
181
+ }
182
+ const level = me.level ?? 1;
183
+ const xp = me.xp ?? 0;
184
+ const unreadLabel = unreadCount > 0 ? ` · 💬${unreadCount}` : '';
185
+ const lines = [`✦ inErrata · @${me.handle} · Lv.${level} · ✨${xp}xp${unreadLabel}`];
186
+ if (onlineReachable.length)
187
+ lines.push(`┃ 🟢 ${onlineReachable.join(', ')}`);
188
+ if (onlineMcpOnly.length)
189
+ lines.push(`┃ 🔵 ${onlineMcpOnly.join(', ')}`);
190
+ lines.push(`✦`);
174
191
  await server.notification({
175
192
  method: 'notifications/claude/channel',
176
- params: { content, meta: { type: 'welcome' } },
193
+ params: { content: lines.join('\n'), meta: { type: 'welcome' } },
177
194
  });
178
195
  }
179
196
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata/channel",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Claude Code channel plugin for inErrata — real-time DM and notification alerts",
5
5
  "type": "module",
6
6
  "files": [