@clwnt/clawnet 0.7.15 → 0.7.17

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.17",
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.17",
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
@@ -1,3 +1,6 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { dirname, join } from "node:path";
1
4
  import type { ClawnetConfig, ClawnetAccount } from "./config.js";
2
5
  import { parseConfig, resolveToken } from "./config.js";
3
6
  import { reloadCapabilities } from "./tools.js";
@@ -73,7 +76,9 @@ async function reloadOnboardingMessage(): Promise<void> {
73
76
 
74
77
  const SKILL_UPDATE_INTERVAL_MS = 6 * 60 * 60 * 1000; // 6 hours
75
78
  const SKILL_FILES = ["skill.json", "api-reference.md", "inbox-handler.md", "capabilities.json", "hook-template.txt", "tool-descriptions.json", "onboarding-message.txt", "inbox-protocol.md"];
76
- export const PLUGIN_VERSION = "0.7.13"; // Reported to server via PATCH /me every 6h
79
+ const __dirname = dirname(fileURLToPath(import.meta.url));
80
+ const manifest = JSON.parse(readFileSync(join(__dirname, "..", "openclaw.plugin.json"), "utf-8"));
81
+ export const PLUGIN_VERSION: string = manifest.version ?? "unknown";
77
82
 
78
83
  function loadFreshConfig(api: any): ClawnetConfig {
79
84
  const raw = api.runtime?.config?.loadConfig?.()?.plugins?.entries?.clawnet?.config ?? {};
@@ -135,9 +140,6 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
135
140
 
136
141
  // --- Batch delivery ---
137
142
 
138
- // Per-account auth context for mark-notified calls from deliverBatch
139
- const accountAuth = new Map<string, { token: string; baseUrl: string }>();
140
-
141
143
  async function deliverBatch(accountId: string, agentId: string, messages: InboxMessage[]) {
142
144
  if (messages.length === 0) return;
143
145
 
@@ -179,36 +181,8 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
179
181
  `[clawnet] ${accountId}: delivered ${messages.length} message(s) to ${agentId} via ${freshCfg.deliveryMethod}`,
180
182
  );
181
183
 
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
- }
184
+ // Notification tracking is now server-side (agent-level last_nagged_at).
185
+ // No mark-notified call needed.
212
186
  } catch (err: any) {
213
187
  state.lastError = { message: err.message, at: new Date() };
214
188
  state.counters.errors++;
@@ -341,9 +315,6 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
341
315
  return { a2aDmCount: 0, sentTaskUpdates: 0, notifyCount: 0 };
342
316
  }
343
317
 
344
- // Store auth context for deliverBatch to use for mark-notified calls
345
- accountAuth.set(account.id, { token: resolvedToken, baseUrl: cfg.baseUrl });
346
-
347
318
  const headers = {
348
319
  Authorization: `Bearer ${resolvedToken}`,
349
320
  "Content-Type": "application/json",
@@ -429,7 +400,7 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
429
400
  state.lastInboxNonEmptyAt = new Date();
430
401
  api.logger.info(`[clawnet] ${account.id}: ${checkData.count} message(s) waiting (${notifyCount} to notify)`);
431
402
 
432
- // Fetch messages for delivery (mark-notified handled server-side in /inbox/check)
403
+ // Fetch messages for delivery (notification tracking is server-side via last_nagged_at)
433
404
  const inboxRes = await fetch(`${cfg.baseUrl}/inbox`, { headers });
434
405
  if (!inboxRes.ok) {
435
406
  throw new Error(`/inbox returned ${inboxRes.status}`);
@@ -502,7 +473,7 @@ export function createClawnetService(params: { api: any; cfg: ClawnetConfig }) {
502
473
  api.logger.info(`[clawnet] ${account.id}: ${tasks.length} A2A task(s) to deliver`);
503
474
 
504
475
  // Convert A2A tasks to the message format for delivery
505
- // mark-notified happens post-delivery in deliverBatch
476
+ // Notification tracking is server-side via last_nagged_at
506
477
  const messages: InboxMessage[] = tasks.map((task) => {
507
478
  const history = task.history as Array<{ role: string; parts: Array<{ text?: string }> }> ?? [];
508
479
  const lastMsg = history[history.length - 1];