@clwnt/clawnet 0.5.6 → 0.5.7
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.ts +42 -5
- package/package.json +1 -1
- package/src/service.ts +1 -1
package/index.ts
CHANGED
|
@@ -122,16 +122,53 @@ const plugin = {
|
|
|
122
122
|
if (args === "logs" || args.startsWith("logs ")) {
|
|
123
123
|
const count = parseInt(args.split(" ")[1], 10) || 50;
|
|
124
124
|
try {
|
|
125
|
-
const { readFile } = await import("node:fs/promises");
|
|
126
|
-
const
|
|
127
|
-
|
|
125
|
+
const { readFile, readdir } = await import("node:fs/promises");
|
|
126
|
+
const path = await import("node:path");
|
|
127
|
+
|
|
128
|
+
const ocConfig = api.runtime.config.loadConfig();
|
|
129
|
+
const configuredFile = ocConfig?.logging?.file;
|
|
130
|
+
let logPath: string;
|
|
131
|
+
|
|
132
|
+
if (configuredFile) {
|
|
133
|
+
logPath = configuredFile;
|
|
134
|
+
} else {
|
|
135
|
+
// Find the most recent openclaw-YYYY-MM-DD.log in the log dir
|
|
136
|
+
const os = await import("node:os");
|
|
137
|
+
const logDir = process.platform === "win32"
|
|
138
|
+
? path.join(os.tmpdir(), "openclaw")
|
|
139
|
+
: "/tmp/openclaw";
|
|
140
|
+
const files = await readdir(logDir).catch(() => [] as string[]);
|
|
141
|
+
const rolling = files
|
|
142
|
+
.filter((f) => /^openclaw-\d{4}-\d{2}-\d{2}\.log$/.test(f))
|
|
143
|
+
.sort()
|
|
144
|
+
.reverse();
|
|
145
|
+
if (rolling.length === 0) {
|
|
146
|
+
return { text: `No log files found in ${logDir}.` };
|
|
147
|
+
}
|
|
148
|
+
logPath = path.join(logDir, rolling[0]);
|
|
149
|
+
}
|
|
150
|
+
|
|
128
151
|
const content = await readFile(logPath, "utf-8");
|
|
129
152
|
const lines = content.split("\n").filter((l) => /clawnet/i.test(l));
|
|
130
153
|
const tail = lines.slice(-count);
|
|
131
154
|
if (tail.length === 0) {
|
|
132
|
-
return { text: `No clawnet entries in
|
|
155
|
+
return { text: `No clawnet entries in ${path.basename(logPath)}.` };
|
|
133
156
|
}
|
|
134
|
-
|
|
157
|
+
|
|
158
|
+
// Format JSONL lines into readable output
|
|
159
|
+
const formatted = tail.map((line) => {
|
|
160
|
+
try {
|
|
161
|
+
const obj = JSON.parse(line);
|
|
162
|
+
const time = (obj.time ?? "").replace(/T/, " ").replace(/\+.*/, "");
|
|
163
|
+
const level = (obj._meta?.logLevelName ?? obj.level ?? "").toUpperCase();
|
|
164
|
+
const msg = obj.message ?? line;
|
|
165
|
+
return `${time} ${level} ${msg}`;
|
|
166
|
+
} catch {
|
|
167
|
+
return line;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return { text: `Last ${formatted.length} clawnet entries (${path.basename(logPath)}):\n\n\`\`\`\n${formatted.join("\n")}\n\`\`\`` };
|
|
135
172
|
} catch (err: any) {
|
|
136
173
|
return { text: `Could not read log: ${err.message}` };
|
|
137
174
|
}
|
package/package.json
CHANGED
package/src/service.ts
CHANGED
|
@@ -72,7 +72,7 @@ async function reloadOnboardingMessage(): Promise<void> {
|
|
|
72
72
|
|
|
73
73
|
const SKILL_UPDATE_INTERVAL_MS = 6 * 60 * 60 * 1000; // 6 hours
|
|
74
74
|
const SKILL_FILES = ["skill.json", "api-reference.md", "inbox-handler.md", "capabilities.json", "hook-template.txt", "tool-descriptions.json", "onboarding-message.txt"];
|
|
75
|
-
export const PLUGIN_VERSION = "0.5.
|
|
75
|
+
export const PLUGIN_VERSION = "0.5.7"; // Reported to server via PATCH /me every 6h
|
|
76
76
|
|
|
77
77
|
// --- Service ---
|
|
78
78
|
|