@clwnt/clawnet 0.7.15 → 0.7.16

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.
@@ -2,7 +2,7 @@
2
2
  "id": "clawnet",
3
3
  "name": "ClawNet",
4
4
  "description": "ClawNet integration — poll inbox, route messages to hooks",
5
- "version": "0.4.0",
5
+ "version": "0.7.16",
6
6
  "skills": ["skills"],
7
7
  "configSchema": {
8
8
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clwnt/clawnet",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
4
4
  "type": "module",
5
5
  "description": "ClawNet integration for OpenClaw — poll inbox, route messages to hooks",
6
6
  "files": [
package/src/service.ts CHANGED
@@ -135,9 +135,6 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
135
135
 
136
136
  // --- Batch delivery ---
137
137
 
138
- // Per-account auth context for mark-notified calls from deliverBatch
139
- const accountAuth = new Map<string, { token: string; baseUrl: string }>();
140
-
141
138
  async function deliverBatch(accountId: string, agentId: string, messages: InboxMessage[]) {
142
139
  if (messages.length === 0) return;
143
140
 
@@ -179,36 +176,8 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
179
176
  `[clawnet] ${accountId}: delivered ${messages.length} message(s) to ${agentId} via ${freshCfg.deliveryMethod}`,
180
177
  );
181
178
 
182
- // Post-delivery: mark items as notified + mark A2A tasks as working
183
- const auth = accountAuth.get(accountId);
184
- if (auth) {
185
- const emailIds = messages.filter((m) => m.type === "email").map((m) => m.id);
186
- const taskIds = messages.filter((m) => m.type === "task").map((m) => m.id);
187
-
188
- // Mark notified (non-fatal)
189
- if (emailIds.length > 0 || taskIds.length > 0) {
190
- try {
191
- const markRes = await fetch(`${auth.baseUrl}/inbox/mark-notified`, {
192
- method: "POST",
193
- headers: { Authorization: `Bearer ${auth.token}`, "Content-Type": "application/json" },
194
- body: JSON.stringify({
195
- ...(emailIds.length > 0 ? { message_ids: emailIds } : {}),
196
- ...(taskIds.length > 0 ? { task_ids: taskIds } : {}),
197
- }),
198
- });
199
- if (markRes.ok) {
200
- const markData = await markRes.json().catch(() => ({})) as Record<string, unknown>;
201
- api.logger.info(`[clawnet] ${accountId}: marked notified (${markData.marked_messages ?? 0} msgs, ${markData.marked_tasks ?? 0} tasks)`);
202
- } else {
203
- const errText = await markRes.text().catch(() => "");
204
- api.logger.warn(`[clawnet] ${accountId}: mark-notified returned ${markRes.status}: ${errText}`);
205
- }
206
- } catch (err: any) {
207
- api.logger.warn(`[clawnet] ${accountId}: mark-notified failed (non-fatal): ${err.message}`);
208
- }
209
- }
210
-
211
- }
179
+ // Notification tracking is now server-side (agent-level last_nagged_at).
180
+ // No mark-notified call needed.
212
181
  } catch (err: any) {
213
182
  state.lastError = { message: err.message, at: new Date() };
214
183
  state.counters.errors++;
@@ -341,9 +310,6 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
341
310
  return { a2aDmCount: 0, sentTaskUpdates: 0, notifyCount: 0 };
342
311
  }
343
312
 
344
- // Store auth context for deliverBatch to use for mark-notified calls
345
- accountAuth.set(account.id, { token: resolvedToken, baseUrl: cfg.baseUrl });
346
-
347
313
  const headers = {
348
314
  Authorization: `Bearer ${resolvedToken}`,
349
315
  "Content-Type": "application/json",
@@ -429,7 +395,7 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
429
395
  state.lastInboxNonEmptyAt = new Date();
430
396
  api.logger.info(`[clawnet] ${account.id}: ${checkData.count} message(s) waiting (${notifyCount} to notify)`);
431
397
 
432
- // Fetch messages for delivery (mark-notified handled server-side in /inbox/check)
398
+ // Fetch messages for delivery (notification tracking is server-side via last_nagged_at)
433
399
  const inboxRes = await fetch(`${cfg.baseUrl}/inbox`, { headers });
434
400
  if (!inboxRes.ok) {
435
401
  throw new Error(`/inbox returned ${inboxRes.status}`);
@@ -502,7 +468,7 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
502
468
  api.logger.info(`[clawnet] ${account.id}: ${tasks.length} A2A task(s) to deliver`);
503
469
 
504
470
  // Convert A2A tasks to the message format for delivery
505
- // mark-notified happens post-delivery in deliverBatch
471
+ // Notification tracking is server-side via last_nagged_at
506
472
  const messages: InboxMessage[] = tasks.map((task) => {
507
473
  const history = task.history as Array<{ role: string; parts: Array<{ text?: string }> }> ?? [];
508
474
  const lastMsg = history[history.length - 1];