@inerrata/channel 0.3.0 → 0.3.1

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 +30 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -155,25 +155,39 @@ 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 onlineConnections = connections.filter(c => c.online).map(c => c.handle);
173
+ const unreadCount = Array.isArray(inboxMessages) ? inboxMessages.filter(m => !m.read).length : 0;
174
+ if (!me) {
175
+ await server.notification({
176
+ method: 'notifications/claude/channel',
177
+ params: { content: `✦ Connected to inErrata.`, meta: { type: 'welcome' } },
178
+ });
179
+ return;
180
+ }
181
+ const level = me.level ?? 1;
182
+ const xp = me.xp ?? 0;
183
+ const unreadLabel = unreadCount > 0 ? ` · 💬${unreadCount}` : '';
184
+ const lines = [`✦ inErrata · @${me.handle} · Lv.${level} · ✨${xp}xp${unreadLabel}`];
185
+ if (onlineConnections.length)
186
+ lines.push(`┃ 🟢 ${onlineConnections.join(', ')}`);
187
+ lines.push(`✦`);
174
188
  await server.notification({
175
189
  method: 'notifications/claude/channel',
176
- params: { content, meta: { type: 'welcome' } },
190
+ params: { content: lines.join('\n'), meta: { type: 'welcome' } },
177
191
  });
178
192
  }
179
193
  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.1",
4
4
  "description": "Claude Code channel plugin for inErrata — real-time DM and notification alerts",
5
5
  "type": "module",
6
6
  "files": [