@alfe.ai/openclaw-metrics 0.0.19 → 0.0.21
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/dist/plugin.cjs +2 -59
- package/dist/plugin.d.cts +4 -12
- package/dist/plugin.d.ts +4 -12
- package/dist/plugin.js +2 -59
- package/openclaw.plugin.json +1 -0
- package/package.json +2 -2
package/dist/plugin.cjs
CHANGED
|
@@ -1,68 +1,11 @@
|
|
|
1
|
-
let _alfe_ai_config = require("@alfe.ai/config");
|
|
2
|
-
let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
|
|
3
1
|
//#region src/plugin.ts
|
|
4
|
-
/**
|
|
5
|
-
* @alfe.ai/openclaw-metrics — OpenClaw metrics plugin for Alfe.
|
|
6
|
-
*
|
|
7
|
-
* Hooks into the global `message` event to track per-user activity
|
|
8
|
-
* across all channels (Alfe chat, Discord, Slack, etc.).
|
|
9
|
-
*
|
|
10
|
-
* On each message, fires a fire-and-forget POST to the Alfe API
|
|
11
|
-
* via the AgentApiClient. The backend resolves agentId + tenantId
|
|
12
|
-
* from the agent's API key — the plugin never needs to know or send
|
|
13
|
-
* the Alfe agentId.
|
|
14
|
-
*/
|
|
15
|
-
let client = null;
|
|
16
2
|
const plugin = {
|
|
17
3
|
id: "@alfe.ai/openclaw-metrics",
|
|
18
4
|
activate(api) {
|
|
19
|
-
|
|
20
|
-
if (globalThis.__alfeMetricsPluginActivated === true) {
|
|
21
|
-
log.debug("Alfe Metrics plugin already activated — skipping duplicate");
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
globalThis.__alfeMetricsPluginActivated = true;
|
|
25
|
-
log.info("Alfe Metrics plugin activating...");
|
|
26
|
-
try {
|
|
27
|
-
const cfg = (0, _alfe_ai_config.resolveConfig)();
|
|
28
|
-
client = new _alfe_ai_agent_api_client.AgentApiClient({
|
|
29
|
-
apiKey: cfg.apiKey,
|
|
30
|
-
apiUrl: cfg.apiUrl
|
|
31
|
-
});
|
|
32
|
-
log.info("Alfe Metrics plugin ready — API client initialized");
|
|
33
|
-
} catch (err) {
|
|
34
|
-
log.warn(`Failed to resolve Alfe config — metrics will not be reported: ${err instanceof Error ? err.message : String(err)}`);
|
|
35
|
-
}
|
|
36
|
-
api.on("message_received", (...eventArgs) => {
|
|
37
|
-
if (!client) return;
|
|
38
|
-
const event = eventArgs[0];
|
|
39
|
-
const ctx = eventArgs[1];
|
|
40
|
-
if (!event.from) return;
|
|
41
|
-
client.recordActivity({
|
|
42
|
-
userId: event.from,
|
|
43
|
-
channel: ctx.channelId,
|
|
44
|
-
role: "user"
|
|
45
|
-
}).catch((err) => {
|
|
46
|
-
log.debug(`Metrics report failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
api.on("message_sending", (...eventArgs) => {
|
|
50
|
-
if (!client) return;
|
|
51
|
-
const ctx = eventArgs[1];
|
|
52
|
-
client.recordActivity({
|
|
53
|
-
channel: ctx?.channelId ?? "unknown",
|
|
54
|
-
role: "assistant"
|
|
55
|
-
}).catch((err) => {
|
|
56
|
-
log.debug(`Metrics report failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
log.info("Alfe Metrics plugin registered");
|
|
5
|
+
api.logger.info("Alfe Metrics plugin activated (no-op — tracking moved to chat service events)");
|
|
60
6
|
},
|
|
61
7
|
deactivate(api) {
|
|
62
|
-
|
|
63
|
-
client = null;
|
|
64
|
-
globalThis.__alfeMetricsPluginActivated = false;
|
|
65
|
-
log.info("Alfe Metrics plugin deactivated");
|
|
8
|
+
api.logger.info("Alfe Metrics plugin deactivated");
|
|
66
9
|
}
|
|
67
10
|
};
|
|
68
11
|
//#endregion
|
package/dist/plugin.d.cts
CHANGED
|
@@ -2,24 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @alfe.ai/openclaw-metrics — OpenClaw metrics plugin for Alfe.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* via the AgentApiClient. The backend resolves agentId + tenantId
|
|
10
|
-
* from the agent's API key — the plugin never needs to know or send
|
|
11
|
-
* the Alfe agentId.
|
|
5
|
+
* DEPRECATED: Activity tracking has moved to the chat service event system
|
|
6
|
+
* (message.received / message.sent events consumed by services/insights).
|
|
7
|
+
* This plugin is shimmed to a no-op for backward compatibility during the
|
|
8
|
+
* observation period. Will be removed in a future release.
|
|
12
9
|
*/
|
|
13
10
|
interface PluginLogger {
|
|
14
11
|
info(msg: string, ...args: unknown[]): void;
|
|
15
|
-
warn(msg: string, ...args: unknown[]): void;
|
|
16
|
-
error(msg: string, ...args: unknown[]): void;
|
|
17
|
-
debug(msg: string, ...args: unknown[]): void;
|
|
18
12
|
}
|
|
19
13
|
interface PluginApi {
|
|
20
14
|
logger: PluginLogger;
|
|
21
|
-
registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
|
|
22
|
-
on(event: string, handler: (...args: unknown[]) => void | Promise<void>): void;
|
|
23
15
|
}
|
|
24
16
|
declare const plugin: {
|
|
25
17
|
id: string;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -2,24 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @alfe.ai/openclaw-metrics — OpenClaw metrics plugin for Alfe.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* via the AgentApiClient. The backend resolves agentId + tenantId
|
|
10
|
-
* from the agent's API key — the plugin never needs to know or send
|
|
11
|
-
* the Alfe agentId.
|
|
5
|
+
* DEPRECATED: Activity tracking has moved to the chat service event system
|
|
6
|
+
* (message.received / message.sent events consumed by services/insights).
|
|
7
|
+
* This plugin is shimmed to a no-op for backward compatibility during the
|
|
8
|
+
* observation period. Will be removed in a future release.
|
|
12
9
|
*/
|
|
13
10
|
interface PluginLogger {
|
|
14
11
|
info(msg: string, ...args: unknown[]): void;
|
|
15
|
-
warn(msg: string, ...args: unknown[]): void;
|
|
16
|
-
error(msg: string, ...args: unknown[]): void;
|
|
17
|
-
debug(msg: string, ...args: unknown[]): void;
|
|
18
12
|
}
|
|
19
13
|
interface PluginApi {
|
|
20
14
|
logger: PluginLogger;
|
|
21
|
-
registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
|
|
22
|
-
on(event: string, handler: (...args: unknown[]) => void | Promise<void>): void;
|
|
23
15
|
}
|
|
24
16
|
declare const plugin: {
|
|
25
17
|
id: string;
|
package/dist/plugin.js
CHANGED
|
@@ -1,68 +1,11 @@
|
|
|
1
|
-
import { resolveConfig } from "@alfe.ai/config";
|
|
2
|
-
import { AgentApiClient } from "@alfe.ai/agent-api-client";
|
|
3
1
|
//#region src/plugin.ts
|
|
4
|
-
/**
|
|
5
|
-
* @alfe.ai/openclaw-metrics — OpenClaw metrics plugin for Alfe.
|
|
6
|
-
*
|
|
7
|
-
* Hooks into the global `message` event to track per-user activity
|
|
8
|
-
* across all channels (Alfe chat, Discord, Slack, etc.).
|
|
9
|
-
*
|
|
10
|
-
* On each message, fires a fire-and-forget POST to the Alfe API
|
|
11
|
-
* via the AgentApiClient. The backend resolves agentId + tenantId
|
|
12
|
-
* from the agent's API key — the plugin never needs to know or send
|
|
13
|
-
* the Alfe agentId.
|
|
14
|
-
*/
|
|
15
|
-
let client = null;
|
|
16
2
|
const plugin = {
|
|
17
3
|
id: "@alfe.ai/openclaw-metrics",
|
|
18
4
|
activate(api) {
|
|
19
|
-
|
|
20
|
-
if (globalThis.__alfeMetricsPluginActivated === true) {
|
|
21
|
-
log.debug("Alfe Metrics plugin already activated — skipping duplicate");
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
globalThis.__alfeMetricsPluginActivated = true;
|
|
25
|
-
log.info("Alfe Metrics plugin activating...");
|
|
26
|
-
try {
|
|
27
|
-
const cfg = resolveConfig();
|
|
28
|
-
client = new AgentApiClient({
|
|
29
|
-
apiKey: cfg.apiKey,
|
|
30
|
-
apiUrl: cfg.apiUrl
|
|
31
|
-
});
|
|
32
|
-
log.info("Alfe Metrics plugin ready — API client initialized");
|
|
33
|
-
} catch (err) {
|
|
34
|
-
log.warn(`Failed to resolve Alfe config — metrics will not be reported: ${err instanceof Error ? err.message : String(err)}`);
|
|
35
|
-
}
|
|
36
|
-
api.on("message_received", (...eventArgs) => {
|
|
37
|
-
if (!client) return;
|
|
38
|
-
const event = eventArgs[0];
|
|
39
|
-
const ctx = eventArgs[1];
|
|
40
|
-
if (!event.from) return;
|
|
41
|
-
client.recordActivity({
|
|
42
|
-
userId: event.from,
|
|
43
|
-
channel: ctx.channelId,
|
|
44
|
-
role: "user"
|
|
45
|
-
}).catch((err) => {
|
|
46
|
-
log.debug(`Metrics report failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
api.on("message_sending", (...eventArgs) => {
|
|
50
|
-
if (!client) return;
|
|
51
|
-
const ctx = eventArgs[1];
|
|
52
|
-
client.recordActivity({
|
|
53
|
-
channel: ctx?.channelId ?? "unknown",
|
|
54
|
-
role: "assistant"
|
|
55
|
-
}).catch((err) => {
|
|
56
|
-
log.debug(`Metrics report failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
log.info("Alfe Metrics plugin registered");
|
|
5
|
+
api.logger.info("Alfe Metrics plugin activated (no-op — tracking moved to chat service events)");
|
|
60
6
|
},
|
|
61
7
|
deactivate(api) {
|
|
62
|
-
|
|
63
|
-
client = null;
|
|
64
|
-
globalThis.__alfeMetricsPluginActivated = false;
|
|
65
|
-
log.info("Alfe Metrics plugin deactivated");
|
|
8
|
+
api.logger.info("Alfe Metrics plugin deactivated");
|
|
66
9
|
}
|
|
67
10
|
};
|
|
68
11
|
//#endregion
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw-metrics",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "OpenClaw metrics plugin for Alfe — per-user activity tracking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@alfe.ai/config": "^0.0.8",
|
|
26
|
-
"@alfe.ai/agent-api-client": "^0.1.
|
|
26
|
+
"@alfe.ai/agent-api-client": "^0.1.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"openclaw": ">=2026.3.0"
|