@laburen/openclaw-plugin-whatsapp-api 0.7.0 → 0.8.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.
- package/index.js +3 -21
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1432,26 +1432,8 @@ const USER_PHONE_CONFIG_KEY = "userPhoneNumber";
|
|
|
1432
1432
|
const LABUREN_API_KEY_CONFIG_KEY = "laburenApiKey";
|
|
1433
1433
|
const USAGE_PATH = "/api/usage";
|
|
1434
1434
|
const POST_TIMEOUT_MS = 3e3;
|
|
1435
|
-
/**
|
|
1436
|
-
|
|
1437
|
-
* actions) should be billed as real product usage. Background runs initiated
|
|
1438
|
-
* by the runtime (`heartbeat`) or by scheduled jobs (`cron`, `memory`,
|
|
1439
|
-
* `overflow`) must be reported under a separate feature so the backend can
|
|
1440
|
-
* apply a different billing policy.
|
|
1441
|
-
*
|
|
1442
|
-
* Without this mapping every heartbeat and every duplicated wa-api cron tick
|
|
1443
|
-
* (which both fire every 30m) was charged to the user as `openclaw_run`,
|
|
1444
|
-
* draining credits without any real interaction.
|
|
1445
|
-
*/
|
|
1446
|
-
function resolveFeatureFromTrigger(trigger) {
|
|
1447
|
-
switch (trigger) {
|
|
1448
|
-
case "heartbeat":
|
|
1449
|
-
case "cron":
|
|
1450
|
-
case "memory":
|
|
1451
|
-
case "overflow": return "heartbeat_run";
|
|
1452
|
-
default: return "openclaw_run";
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1435
|
+
/** Fallback when OpenClaw's runtime did not surface a `trigger` in the hook ctx. */
|
|
1436
|
+
const DEFAULT_FEATURE = "openclaw_fallback";
|
|
1455
1437
|
function resolveUsageIngestUrl() {
|
|
1456
1438
|
let baseRaw;
|
|
1457
1439
|
try {
|
|
@@ -1509,7 +1491,7 @@ async function handleForwardLlmUsage(event, ctx) {
|
|
|
1509
1491
|
const cacheWrite = usage.cacheWrite ?? 0;
|
|
1510
1492
|
const total = usage.total ?? input + output + cacheRead + cacheWrite;
|
|
1511
1493
|
const body = {
|
|
1512
|
-
feature:
|
|
1494
|
+
feature: ctx.trigger ?? DEFAULT_FEATURE,
|
|
1513
1495
|
runId: event.runId,
|
|
1514
1496
|
sessionId: event.sessionId,
|
|
1515
1497
|
userPhoneNumber,
|