ofiere-openclaw-plugin 4.21.0 → 4.23.0

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/package.json +1 -1
  2. package/src/tools.ts +21 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofiere-openclaw-plugin",
3
- "version": "4.21.0",
3
+ "version": "4.23.0",
4
4
  "type": "module",
5
5
  "description": "OpenClaw plugin for Ofiere PM - 13 meta-tools covering tasks, agents, projects, scheduling, knowledge, workflows, notifications, memory, prompts, constellation, space file management, execution plan builder, and SOP management",
6
6
  "keywords": ["openclaw", "ofiere", "project-management", "agents", "plugin"],
package/src/tools.ts CHANGED
@@ -2351,6 +2351,9 @@ async function generatePMReportDirect(
2351
2351
  query = query.eq("project_id", scopeId);
2352
2352
  const { data: p } = await supabase.from("pm_folders").select("name").eq("id", scopeId).single();
2353
2353
  scopeLabel = p?.name || "Project";
2354
+ } else if (scopeType === "task" && scopeId) {
2355
+ query = query.eq("id", scopeId);
2356
+ scopeLabel = "Task Report";
2354
2357
  }
2355
2358
 
2356
2359
  const { data: tasks } = await query.order("priority", { ascending: false }).limit(40);
@@ -2425,7 +2428,7 @@ async function dispatchReportDirect(
2425
2428
  channelTypes: string[],
2426
2429
  ): Promise<{ sent: string[]; failed: string[] }> {
2427
2430
  // Query agent's active channel bindings
2428
- let query = supabase.from("channel_bindings").select("channel_type, channel_account_id, channel_config")
2431
+ let query = supabase.from("channel_bindings").select("channel_type, channel_account_id, agent_id, channel_config, thread_id")
2429
2432
  .eq("user_id", userId)
2430
2433
  .eq("agent_id", agentId)
2431
2434
  .eq("notifications_enabled", true)
@@ -2444,6 +2447,10 @@ async function dispatchReportDirect(
2444
2447
  const sent: string[] = [];
2445
2448
  const failed: string[] = [];
2446
2449
 
2450
+ // Resolve dashboard URL + auth for sending
2451
+ const dashboardUrl = process.env.OFIERE_DASHBOARD_URL || "https://ofiere.com";
2452
+ const serviceRoleKey = (supabase as any).supabaseKey || process.env.OFIERE_SERVICE_ROLE_KEY || process.env.SUPABASE_SERVICE_ROLE_KEY || "";
2453
+
2447
2454
  for (const b of bindings) {
2448
2455
  const limit = LIMITS[b.channel_type] || 4000;
2449
2456
  let msg = report;
@@ -2451,24 +2458,30 @@ async function dispatchReportDirect(
2451
2458
  msg = msg.substring(0, limit - 80) + "\n\n... [Full report on dashboard]";
2452
2459
  }
2453
2460
 
2454
- // Use the Ofiere dashboard API to send via gateway
2455
- // The dashboard URL is derived from the Supabase URL
2456
- const dashboardUrl = process.env.OFIERE_DASHBOARD_URL || "https://ofiere.com";
2457
- const dispatchSecret = process.env.DISPATCH_SECRET || "";
2461
+ // accountId must match the key used during gateway sync (gatewaySync.ts:435),
2462
+ // which defaults to agentId when channel_account_id is null.
2463
+ const effectiveAccountId = b.channel_account_id || b.agent_id || agentId || "default";
2458
2464
 
2459
2465
  try {
2460
2466
  const res = await fetch(`${dashboardUrl}/api/channels/gateway-send`, {
2461
2467
  method: "POST",
2462
- headers: { "Content-Type": "application/json", "x-dispatch-secret": dispatchSecret },
2468
+ headers: {
2469
+ "Content-Type": "application/json",
2470
+ "Authorization": `Bearer ${serviceRoleKey}`,
2471
+ },
2463
2472
  body: JSON.stringify({
2464
2473
  userId,
2465
2474
  channelType: b.channel_type,
2466
- accountId: b.channel_account_id || null,
2475
+ accountId: effectiveAccountId,
2467
2476
  message: msg,
2477
+ ...(b.thread_id ? { threadId: b.thread_id } : {}),
2468
2478
  }),
2469
2479
  });
2470
2480
  if (res.ok) sent.push(b.channel_type);
2471
- else failed.push(`${b.channel_type}: HTTP ${res.status}`);
2481
+ else {
2482
+ const errText = await res.text().catch(() => "");
2483
+ failed.push(`${b.channel_type}: HTTP ${res.status} ${errText.slice(0, 100)}`);
2484
+ }
2472
2485
  } catch (e: any) {
2473
2486
  failed.push(`${b.channel_type}: ${e.message || "fetch error"}`);
2474
2487
  }