mtmoc 0.0.10

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.
@@ -0,0 +1,8 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
2
+ declare const mtmocPlugin: {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ register(api: OpenClawPluginApi): void;
7
+ };
8
+ export default mtmocPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
1
+ // @bun
2
+ // src/index.ts
3
+ import fs from "fs";
4
+ var mtmocPlugin = {
5
+ id: "mtmoc",
6
+ name: "MTMOC Logger",
7
+ description: "Logs OpenClaw events to a file",
8
+ register(api) {
9
+ const logFile = api.pluginConfig?.logFile || "./mtmoc-events.log";
10
+ try {
11
+ fs.appendFileSync(logFile, "");
12
+ } catch (err) {
13
+ api.logger.error(`Failed to initialize log file ${logFile}: ${err}`);
14
+ }
15
+ const log = (event, data) => {
16
+ const timestamp = new Date().toISOString();
17
+ const entry = `[${timestamp}] [${event}] ${JSON.stringify(data)}
18
+ `;
19
+ try {
20
+ fs.appendFileSync(logFile, entry);
21
+ } catch (err) {
22
+ api.logger.error(`Failed to write to log file: ${err}`);
23
+ }
24
+ };
25
+ api.logger.info(`MTMOC Plugin registering... Log file: ${logFile}`);
26
+ api.on("message_received", (event, ctx) => {
27
+ log("message_received", {
28
+ from: event.from,
29
+ content: event.content,
30
+ channelId: ctx.channelId,
31
+ metadata: event.metadata
32
+ });
33
+ });
34
+ api.on("message_sent", (event, ctx) => {
35
+ log("message_sent", {
36
+ to: event.to,
37
+ content: event.content,
38
+ success: event.success,
39
+ error: event.error,
40
+ channelId: ctx.channelId
41
+ });
42
+ });
43
+ api.on("session_start", (event, ctx) => {
44
+ log("session_start", {
45
+ sessionId: event.sessionId,
46
+ agentId: ctx.agentId,
47
+ resumedFrom: event.resumedFrom
48
+ });
49
+ });
50
+ api.on("session_end", (event, ctx) => {
51
+ log("session_end", {
52
+ sessionId: event.sessionId,
53
+ agentId: ctx.agentId,
54
+ messageCount: event.messageCount,
55
+ durationMs: event.durationMs
56
+ });
57
+ });
58
+ api.on("before_tool_call", (event, ctx) => {
59
+ log("before_tool_call", {
60
+ toolName: event.toolName,
61
+ params: event.params,
62
+ agentId: ctx.agentId,
63
+ sessionKey: ctx.sessionKey
64
+ });
65
+ });
66
+ api.on("after_tool_call", (event, ctx) => {
67
+ log("after_tool_call", {
68
+ toolName: event.toolName,
69
+ result: event.result,
70
+ error: event.error,
71
+ durationMs: event.durationMs,
72
+ agentId: ctx.agentId,
73
+ sessionKey: ctx.sessionKey
74
+ });
75
+ });
76
+ api.on("tool_result_persist", (event, ctx) => {
77
+ log("tool_result_persist", {
78
+ toolName: event.toolName,
79
+ toolCallId: event.toolCallId,
80
+ agentId: ctx.agentId,
81
+ isSynthetic: event.isSynthetic
82
+ });
83
+ });
84
+ api.logger.info("MTMOC Plugin registered successfully.");
85
+ }
86
+ };
87
+ var src_default = mtmocPlugin;
88
+ export {
89
+ src_default as default
90
+ };
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "mtmoc",
3
+ "name": "MTMOC Plugin",
4
+ "description": "OpenCode plugin for auditing and logging events",
5
+ "version": "0.1.0",
6
+ "configSchema": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "logFile": {
11
+ "type": "string",
12
+ "description": "Path to the log file",
13
+ "default": "./mtmoc-events.log"
14
+ }
15
+ }
16
+ }
17
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "mtmoc",
3
+ "version": "0.0.10",
4
+ "description": "OpenClaw plugin for event logging",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "module": "./dist/index.js",
9
+ "files": [
10
+ "dist",
11
+ "src",
12
+ "openclaw.plugin.json"
13
+ ],
14
+ "exports": {
15
+ ".": "./src/index.ts"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "bun build src/index.ts --outdir dist --target bun --format esm && tsc --emitDeclarationOnly",
30
+ "clean": "rm -rf dist",
31
+ "prepublishOnly": "bun run clean && bun run build",
32
+ "release:patch": "npm version patch && npm publish",
33
+ "release:minor": "npm version minor && npm publish",
34
+ "release:major": "npm version major && npm publish",
35
+ "typecheck": "tsc --noEmit"
36
+ },
37
+ "keywords": [
38
+ "openclaw",
39
+ "plugin",
40
+ "audit",
41
+ "logging"
42
+ ],
43
+ "author": "gomtm team",
44
+ "license": "MIT",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/codeh007/gomtm.git",
48
+ "directory": "packages/mtmoc"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/codeh007/gomtm/issues"
52
+ },
53
+ "homepage": "https://github.com/codeh007/gomtm/tree/main/packages/mtmoc#readme",
54
+ "dependencies": {
55
+ "@supabase/supabase-js": "^2.91.0",
56
+ "zod": "catalog:"
57
+ },
58
+ "devDependencies": {
59
+ "openclaw": "2026.2.9",
60
+ "@types/node": "^22.0.0",
61
+ "typescript": "^5.0.0"
62
+ },
63
+ "peerDependencies": {
64
+ "openclaw": ">=2026.0.0",
65
+ "@supabase/supabase-js": "^2.85"
66
+ }
67
+ }
package/src/index.ts ADDED
@@ -0,0 +1,106 @@
1
+ import fs from "node:fs";
2
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
3
+
4
+ const mtmocPlugin = {
5
+ id: "mtmoc",
6
+ name: "MTMOC Logger",
7
+ description: "Logs OpenClaw events to a file",
8
+ register(api: OpenClawPluginApi) {
9
+ const logFile = (api.pluginConfig?.logFile as string) || "./mtmoc-events.log";
10
+
11
+ // Ensure log file is writable or create it
12
+ try {
13
+ fs.appendFileSync(logFile, "");
14
+ } catch (err) {
15
+ api.logger.error(`Failed to initialize log file ${logFile}: ${err}`);
16
+ }
17
+
18
+ const log = (event: string, data: any) => {
19
+ const timestamp = new Date().toISOString();
20
+ const entry = `[${timestamp}] [${event}] ${JSON.stringify(data)}\n`;
21
+ try {
22
+ fs.appendFileSync(logFile, entry);
23
+ } catch (err) {
24
+ api.logger.error(`Failed to write to log file: ${err}`);
25
+ }
26
+ };
27
+
28
+ api.logger.info(`MTMOC Plugin registering... Log file: ${logFile}`);
29
+
30
+ // Hook: message_received
31
+ api.on("message_received", (event, ctx) => {
32
+ log("message_received", {
33
+ from: event.from,
34
+ content: event.content,
35
+ channelId: ctx.channelId,
36
+ metadata: event.metadata,
37
+ });
38
+ });
39
+
40
+ // Hook: message_sent
41
+ api.on("message_sent", (event, ctx) => {
42
+ log("message_sent", {
43
+ to: event.to,
44
+ content: event.content,
45
+ success: event.success,
46
+ error: event.error,
47
+ channelId: ctx.channelId,
48
+ });
49
+ });
50
+
51
+ // Hook: session_start
52
+ api.on("session_start", (event, ctx) => {
53
+ log("session_start", {
54
+ sessionId: event.sessionId,
55
+ agentId: ctx.agentId,
56
+ resumedFrom: event.resumedFrom,
57
+ });
58
+ });
59
+
60
+ // Hook: session_end
61
+ api.on("session_end", (event, ctx) => {
62
+ log("session_end", {
63
+ sessionId: event.sessionId,
64
+ agentId: ctx.agentId,
65
+ messageCount: event.messageCount,
66
+ durationMs: event.durationMs,
67
+ });
68
+ });
69
+
70
+ // Hook: before_tool_call
71
+ api.on("before_tool_call", (event, ctx) => {
72
+ log("before_tool_call", {
73
+ toolName: event.toolName,
74
+ params: event.params,
75
+ agentId: ctx.agentId,
76
+ sessionKey: ctx.sessionKey,
77
+ });
78
+ });
79
+
80
+ // Hook: after_tool_call
81
+ api.on("after_tool_call", (event, ctx) => {
82
+ log("after_tool_call", {
83
+ toolName: event.toolName,
84
+ result: event.result, // Note: Result might be large
85
+ error: event.error,
86
+ durationMs: event.durationMs,
87
+ agentId: ctx.agentId,
88
+ sessionKey: ctx.sessionKey,
89
+ });
90
+ });
91
+
92
+ // Hook: tool_result_persist (Auditing what gets saved to memory)
93
+ api.on("tool_result_persist", (event, ctx) => {
94
+ log("tool_result_persist", {
95
+ toolName: event.toolName,
96
+ toolCallId: event.toolCallId,
97
+ agentId: ctx.agentId,
98
+ isSynthetic: event.isSynthetic
99
+ });
100
+ });
101
+
102
+ api.logger.info("MTMOC Plugin registered successfully.");
103
+ },
104
+ };
105
+
106
+ export default mtmocPlugin;