clawaid 1.0.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/dist/rules.js ADDED
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runRules = runRules;
4
+ exports.formatRuleFindings = formatRuleFindings;
5
+ // ─── Critical Rules ──────────────────────────────────────────────────────────
6
+ const toolsProfileMessaging = (obs) => {
7
+ const config = obs.configContent || '';
8
+ // Match "profile": "messaging" or profile: "messaging" within a tools section context
9
+ // Also handle JSON5 unquoted keys
10
+ if (/["']?profile["']?\s*:\s*["']messaging["']/i.test(config)) {
11
+ // Verify it's plausibly in a tools section (look for "tools" nearby)
12
+ const toolsIdx = config.search(/["']?tools["']?\s*:/i);
13
+ const profileIdx = config.search(/["']?profile["']?\s*:\s*["']messaging["']/i);
14
+ // If there's a tools section and the profile is anywhere in config, flag it.
15
+ // Even without a tools section wrapper, "profile": "messaging" is the issue.
16
+ if (toolsIdx !== -1 || profileIdx !== -1) {
17
+ return [{
18
+ id: 'tools-profile-messaging',
19
+ severity: 'critical',
20
+ title: 'Tools restricted to messaging-only mode',
21
+ description: 'Your agent can chat but cannot execute commands, read files, or use any tools. ' +
22
+ 'This is the #1 issue after upgrading to OpenClaw v3.7 — the default changed from \'coding\' to \'messaging\'.',
23
+ fix: 'openclaw config set tools.profile full && openclaw gateway restart',
24
+ }];
25
+ }
26
+ }
27
+ return [];
28
+ };
29
+ const proxyInPlist = (obs) => {
30
+ const plist = obs.plistContent || '';
31
+ const hasProxy = /HTTP_PROXY|HTTPS_PROXY/i.test(plist);
32
+ if (hasProxy) {
33
+ return [{
34
+ id: 'proxy-in-plist',
35
+ severity: 'critical',
36
+ title: 'Proxy configuration in LaunchAgent will cause outage',
37
+ description: 'The LaunchAgent plist contains HTTP_PROXY or HTTPS_PROXY environment variables. ' +
38
+ 'This is a ticking time bomb: the gateway will fail to connect to AI providers on the next restart ' +
39
+ 'because traffic will be routed through a proxy that likely doesn\'t exist or blocks API calls. ' +
40
+ 'Remove these entries immediately.',
41
+ fix: '/usr/libexec/PlistBuddy -c "Delete :EnvironmentVariables:HTTP_PROXY" ~/Library/LaunchAgents/ai.openclaw.gateway.plist 2>/dev/null; ' +
42
+ '/usr/libexec/PlistBuddy -c "Delete :EnvironmentVariables:HTTPS_PROXY" ~/Library/LaunchAgents/ai.openclaw.gateway.plist 2>/dev/null; ' +
43
+ 'openclaw gateway restart',
44
+ }];
45
+ }
46
+ return [];
47
+ };
48
+ const configParseError = (obs) => {
49
+ const config = obs.configContent || '';
50
+ const logs = obs.recentLogs || '';
51
+ // Config is empty/missing
52
+ if (!config || config === '[config file not found - OpenClaw may not be configured]') {
53
+ return [{
54
+ id: 'config-parse-error',
55
+ severity: 'critical',
56
+ title: 'Config file missing or empty',
57
+ description: 'The OpenClaw config file (~/.openclaw/openclaw.json) is missing or could not be read. ' +
58
+ 'The gateway cannot start without a valid config.',
59
+ fix: 'openclaw doctor --yes',
60
+ }];
61
+ }
62
+ // JSON5 syntax error in logs
63
+ if (/SyntaxError/i.test(logs) && /JSON5/i.test(logs)) {
64
+ return [{
65
+ id: 'config-parse-error',
66
+ severity: 'critical',
67
+ title: 'Config file corrupted or has syntax error',
68
+ description: 'The gateway logs show a JSON5 SyntaxError when parsing the config file. ' +
69
+ 'The config has invalid syntax and the gateway cannot load it.',
70
+ fix: 'cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.broken && openclaw doctor --yes',
71
+ }];
72
+ }
73
+ return [];
74
+ };
75
+ const gatewayNotRunning = (obs) => {
76
+ const status = obs.gatewayStatus || '';
77
+ const lower = status.toLowerCase();
78
+ if (lower.includes('not running') && !lower.includes('config')) {
79
+ return [{
80
+ id: 'gateway-not-running',
81
+ severity: 'critical',
82
+ title: 'Gateway is not running',
83
+ description: 'The OpenClaw gateway service is stopped. No AI interactions will work until it is started.',
84
+ fix: 'openclaw gateway start',
85
+ }];
86
+ }
87
+ return [];
88
+ };
89
+ const portConflict = (obs) => {
90
+ const status = obs.gatewayStatus || '';
91
+ const logs = obs.recentLogs || '';
92
+ const combined = status + '\n' + logs;
93
+ if (/EADDRINUSE/i.test(combined)) {
94
+ // Try to extract PID from portCheck
95
+ let pidInfo = '';
96
+ const portCheck = obs.portCheck || '';
97
+ // lsof output: lines after header, PID is second column
98
+ const lines = portCheck.split('\n').filter(l => l.trim() && !l.startsWith('COMMAND'));
99
+ if (lines.length > 0) {
100
+ const parts = lines[0].trim().split(/\s+/);
101
+ if (parts.length >= 2) {
102
+ pidInfo = ` (conflicting process: ${parts[0]} PID ${parts[1]})`;
103
+ }
104
+ }
105
+ return [{
106
+ id: 'port-conflict',
107
+ severity: 'critical',
108
+ title: 'Port 18789 is already in use',
109
+ description: `Another process is occupying port 18789${pidInfo}. ` +
110
+ 'The gateway cannot bind to its default port and will fail to start.',
111
+ fix: pidInfo
112
+ ? `kill ${lines[0]?.trim().split(/\s+/)[1] || ''} 2>/dev/null; sleep 1; openclaw gateway restart`
113
+ : 'lsof -ti :18789 | xargs kill 2>/dev/null; sleep 1; openclaw gateway restart',
114
+ }];
115
+ }
116
+ return [];
117
+ };
118
+ // ─── High Rules ──────────────────────────────────────────────────────────────
119
+ const zombieGateway = (obs) => {
120
+ const status = obs.gatewayStatus || '';
121
+ const lower = status.toLowerCase();
122
+ const isRunning = lower.includes('running') && !lower.includes('not running');
123
+ const probeFailed = lower.includes('rpc probe: failed') || lower.includes('timeout');
124
+ if (isRunning && probeFailed) {
125
+ return [{
126
+ id: 'zombie-gateway',
127
+ severity: 'high',
128
+ title: 'Gateway process is alive but unresponsive (zombie)',
129
+ description: 'The gateway process is listed as running, but the RPC health probe failed or timed out. ' +
130
+ 'The gateway is in a zombie state and needs to be restarted.',
131
+ fix: 'openclaw gateway restart',
132
+ }];
133
+ }
134
+ return [];
135
+ };
136
+ const badModel = (obs) => {
137
+ const logs = obs.recentLogs || '';
138
+ // Count occurrences of 400 Bad Request or model not found
139
+ const badRequestMatches = logs.match(/400\s*(Bad Request)?/gi) || [];
140
+ const modelNotFoundMatches = logs.match(/model[\s_-]?not[\s_-]?found/gi) || [];
141
+ const totalErrors = badRequestMatches.length + modelNotFoundMatches.length;
142
+ if (totalErrors >= 2) {
143
+ // Try to extract model name
144
+ let modelName = '';
145
+ const modelMatch = logs.match(/model[:\s]+["']?([a-zA-Z0-9\/_.-]+)["']?\s*(not found|is not available|does not exist)/i);
146
+ if (modelMatch) {
147
+ modelName = modelMatch[1];
148
+ }
149
+ return [{
150
+ id: 'bad-model',
151
+ severity: 'high',
152
+ title: 'AI model errors detected' + (modelName ? ` (${modelName})` : ''),
153
+ description: `Found ${totalErrors} "400 Bad Request" or "model not found" errors in recent logs. ` +
154
+ (modelName
155
+ ? `The model "${modelName}" may be unavailable, deprecated, or misspelled.`
156
+ : 'The configured default model may be unavailable, deprecated, or misspelled.'),
157
+ fix: modelName
158
+ ? `openclaw models set default anthropic/claude-sonnet-4-6`
159
+ : `openclaw models set default anthropic/claude-sonnet-4-6`,
160
+ }];
161
+ }
162
+ return [];
163
+ };
164
+ const gatewayAuthConflict = (obs) => {
165
+ const config = obs.configContent || '';
166
+ // Check if config has gateway.auth section with both token and password but no mode
167
+ // Look for the auth section pattern
168
+ const authSectionMatch = config.match(/["']?auth["']?\s*:\s*\{([^}]*)\}/s);
169
+ if (authSectionMatch) {
170
+ const authSection = authSectionMatch[1];
171
+ const hasToken = /["']?token["']?\s*:/i.test(authSection);
172
+ const hasPassword = /["']?password["']?\s*:/i.test(authSection);
173
+ const hasMode = /["']?mode["']?\s*:/i.test(authSection);
174
+ if (hasToken && hasPassword && !hasMode) {
175
+ return [{
176
+ id: 'gateway-auth-conflict',
177
+ severity: 'high',
178
+ title: 'Gateway auth conflict: both token and password configured',
179
+ description: 'The gateway auth section has both "token" and "password" but no explicit "mode". ' +
180
+ 'In OpenClaw v3.7, this is a breaking change — the gateway won\'t know which auth method to use ' +
181
+ 'and may reject all connections.',
182
+ fix: 'openclaw config set gateway.auth.mode token',
183
+ }];
184
+ }
185
+ }
186
+ return [];
187
+ };
188
+ // ─── Warning Rules ───────────────────────────────────────────────────────────
189
+ const versionMismatch = (obs) => {
190
+ const desktopVer = obs.desktopAppVersion || '';
191
+ const cliVer = obs.openclawVersion || '';
192
+ // Extract version numbers (e.g., "3.7.1" or "2026.2.22")
193
+ const desktopMatch = desktopVer.match(/(\d+)\.(\d+)\.?(\d*)/);
194
+ const cliMatch = cliVer.match(/(\d+)\.(\d+)\.?(\d*)/);
195
+ if (desktopMatch && cliMatch) {
196
+ const dMajor = parseInt(desktopMatch[1], 10);
197
+ const dMinor = parseInt(desktopMatch[2], 10);
198
+ const cMajor = parseInt(cliMatch[1], 10);
199
+ const cMinor = parseInt(cliMatch[2], 10);
200
+ // Flag if major versions differ, or minor versions differ by 2+
201
+ const majorDiff = Math.abs(dMajor - cMajor);
202
+ const minorDiff = Math.abs(dMinor - cMinor);
203
+ if (majorDiff > 0 || minorDiff >= 2) {
204
+ return [{
205
+ id: 'version-mismatch',
206
+ severity: 'warning',
207
+ title: 'Desktop app and CLI version mismatch',
208
+ description: `Desktop app version (${desktopVer.trim()}) and CLI version (${cliVer.trim()}) differ significantly. ` +
209
+ 'This can cause compatibility issues. Consider updating the older one.',
210
+ }];
211
+ }
212
+ }
213
+ return [];
214
+ };
215
+ const whatsappAllowlistEmpty = (obs) => {
216
+ const config = obs.configContent || '';
217
+ // Check for groupPolicy: "allowlist"
218
+ const hasAllowlist = /["']?groupPolicy["']?\s*:\s*["']allowlist["']/i.test(config);
219
+ if (hasAllowlist) {
220
+ // Check if groupAllowFrom is empty/missing
221
+ const allowFromMatch = config.match(/["']?groupAllowFrom["']?\s*:\s*\[([^\]]*)\]/);
222
+ if (!allowFromMatch || allowFromMatch[1].trim() === '') {
223
+ return [{
224
+ id: 'whatsapp-allowlist-empty',
225
+ severity: 'warning',
226
+ title: 'WhatsApp groupPolicy is "allowlist" but no groups are allowed',
227
+ description: 'The WhatsApp channel has groupPolicy set to "allowlist", but groupAllowFrom is empty or missing. ' +
228
+ 'This means the bot will ignore ALL group messages. If you want to receive group messages, ' +
229
+ 'add group IDs to groupAllowFrom, or change groupPolicy to "all".',
230
+ }];
231
+ }
232
+ }
233
+ return [];
234
+ };
235
+ // ─── Rule Engine ─────────────────────────────────────────────────────────────
236
+ const ALL_RULES = [
237
+ // Critical
238
+ toolsProfileMessaging,
239
+ proxyInPlist,
240
+ configParseError,
241
+ gatewayNotRunning,
242
+ portConflict,
243
+ // High
244
+ zombieGateway,
245
+ badModel,
246
+ gatewayAuthConflict,
247
+ // Warning
248
+ versionMismatch,
249
+ whatsappAllowlistEmpty,
250
+ ];
251
+ const SEVERITY_ORDER = {
252
+ critical: 0,
253
+ high: 1,
254
+ warning: 2,
255
+ info: 3,
256
+ };
257
+ function runRules(obs) {
258
+ const findings = [];
259
+ for (const rule of ALL_RULES) {
260
+ try {
261
+ const results = rule(obs);
262
+ findings.push(...results);
263
+ }
264
+ catch {
265
+ // Individual rule failure should not break the engine
266
+ }
267
+ }
268
+ // Sort by severity: critical first, then high, warning, info
269
+ findings.sort((a, b) => (SEVERITY_ORDER[a.severity] ?? 99) - (SEVERITY_ORDER[b.severity] ?? 99));
270
+ return findings;
271
+ }
272
+ function formatRuleFindings(findings) {
273
+ if (findings.length === 0) {
274
+ return `=== AUTOMATED RULE CHECKS (deterministic, pre-AI) ===
275
+ [No known issues detected by rule engine]
276
+ === END RULE CHECKS ===`;
277
+ }
278
+ const severityEmoji = {
279
+ critical: '🔴 CRITICAL',
280
+ high: '🟠 HIGH',
281
+ warning: '⚠️ WARNING',
282
+ info: 'ℹ️ INFO',
283
+ };
284
+ const lines = [
285
+ '=== AUTOMATED RULE CHECKS (deterministic, pre-AI) ===',
286
+ '[These findings are 100% certain — verified by code, not AI inference]',
287
+ '',
288
+ ];
289
+ for (const f of findings) {
290
+ lines.push(`${severityEmoji[f.severity] || f.severity.toUpperCase()}: ${f.title}`);
291
+ lines.push(` ${f.description}`);
292
+ if (f.fix) {
293
+ lines.push(` Fix: ${f.fix}`);
294
+ }
295
+ lines.push('');
296
+ }
297
+ lines.push('=== END RULE CHECKS ===');
298
+ return lines.join('\n');
299
+ }
300
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":";;AAsTA,4BAgBC;AAED,gDAgCC;AA5VD,gFAAgF;AAEhF,MAAM,qBAAqB,GAAS,CAAC,GAAG,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;IACvC,sFAAsF;IACtF,kCAAkC;IAClC,IAAI,4CAA4C,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,qEAAqE;QACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACvD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,4CAA4C,CAAC,CAAC;QAC/E,6EAA6E;QAC7E,6EAA6E;QAC7E,IAAI,QAAQ,KAAK,CAAC,CAAC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC;oBACN,EAAE,EAAE,yBAAyB;oBAC7B,QAAQ,EAAE,UAAU;oBACpB,KAAK,EAAE,yCAAyC;oBAChD,WAAW,EACT,iFAAiF;wBACjF,+GAA+G;oBACjH,GAAG,EAAE,oEAAoE;iBAC1E,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAS,CAAC,GAAG,EAAE,EAAE;IACjC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,C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E,YAAY;QACrB,IAAI,EAAE,SAAS;KAChB,CAAC;IAEF,MAAM,KAAK,GAAa;QACtB,uDAAuD;QACvD,wEAAwE;QACxE,EAAE;KACH,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACnF,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare const app: import("express-serve-static-core").Express;
2
+ export declare function createServer(port: number): Promise<void>;
3
+ export default app;
4
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,GAAG,6CAAY,CAAC;AA4FtB,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxD;AAED,eAAe,GAAG,CAAC"}
package/dist/server.js ADDED
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createServer = createServer;
40
+ const express_1 = __importDefault(require("express"));
41
+ const path = __importStar(require("path"));
42
+ const fs = __importStar(require("fs"));
43
+ const loop_1 = require("./loop");
44
+ const app = (0, express_1.default)();
45
+ app.use(express_1.default.json());
46
+ // Serve the web UI
47
+ app.get('/', (_req, res) => {
48
+ const htmlPath = path.join(__dirname, '..', 'web', 'index.html');
49
+ if (fs.existsSync(htmlPath)) {
50
+ res.sendFile(htmlPath);
51
+ }
52
+ else {
53
+ res.status(404).send('Web UI not found. Please ensure web/index.html exists.');
54
+ }
55
+ });
56
+ // SSE endpoint - main diagnostic stream
57
+ const activeSessions = new Map();
58
+ app.get('/api/diagnose', (req, res) => {
59
+ const sessionId = Date.now().toString();
60
+ // Set SSE headers
61
+ res.setHeader('Content-Type', 'text/event-stream');
62
+ res.setHeader('Cache-Control', 'no-cache');
63
+ res.setHeader('Connection', 'keep-alive');
64
+ res.setHeader('Access-Control-Allow-Origin', '*');
65
+ res.flushHeaders();
66
+ const sendEvent = (type, data) => {
67
+ const json = JSON.stringify({ type, data, sessionId });
68
+ res.write(`data: ${json}\n\n`);
69
+ };
70
+ const loop = new loop_1.DoctorLoop((event) => {
71
+ sendEvent(event.type, event.data);
72
+ });
73
+ activeSessions.set(sessionId, { res, loop });
74
+ // Send session ID to client
75
+ sendEvent('session_start', { sessionId });
76
+ // Start diagnosis
77
+ loop.start().catch((err) => {
78
+ sendEvent('error', { message: err.message });
79
+ });
80
+ // Handle client disconnect
81
+ req.on('close', () => {
82
+ loop.stop();
83
+ activeSessions.delete(sessionId);
84
+ });
85
+ });
86
+ // Endpoint to provide user input (e.g., API key)
87
+ app.post('/api/input', (req, res) => {
88
+ const { sessionId, field, value } = req.body;
89
+ const session = activeSessions.get(sessionId);
90
+ if (!session) {
91
+ res.status(404).json({ error: 'Session not found' });
92
+ return;
93
+ }
94
+ session.loop.provideInput(field, value).catch((err) => {
95
+ console.error('Error providing input:', err);
96
+ });
97
+ res.json({ ok: true });
98
+ });
99
+ // Endpoint to trigger fix after user clicks "Fix" button
100
+ // Accepts optional optionId ("A", "B", "C") — defaults to recommended option
101
+ app.post('/api/fix', (req, res) => {
102
+ const { sessionId, optionId } = req.body;
103
+ const session = activeSessions.get(sessionId);
104
+ if (!session) {
105
+ res.status(404).json({ error: 'Session not found' });
106
+ return;
107
+ }
108
+ session.loop.startFix(optionId).catch((err) => {
109
+ console.error('Error starting fix:', err);
110
+ });
111
+ res.json({ ok: true });
112
+ });
113
+ // Health check
114
+ app.get('/api/health', (_req, res) => {
115
+ res.json({ ok: true, version: '1.0.0', name: 'ClawAid', sessions: activeSessions.size });
116
+ });
117
+ function createServer(port) {
118
+ return new Promise((resolve) => {
119
+ app.listen(port, '127.0.0.1', () => {
120
+ console.log(`🩺 ClawAid running at http://127.0.0.1:${port}`);
121
+ resolve();
122
+ });
123
+ });
124
+ }
125
+ exports.default = app;
126
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,oCAOC;AAxGD,sDAAqD;AACrD,2CAA6B;AAC7B,uCAAyB;AACzB,iCAA+C;AAE/C,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AACtB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAExB,mBAAmB;AACnB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAa,EAAE,GAAa,EAAE,EAAE;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACjE,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IACjF,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,wCAAwC;AACxC,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+C,CAAC;AAE9E,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IACvD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAExC,kBAAkB;IAClB,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IACnD,GAAG,CAAC,SAAS,CA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EH,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,eAAe;AACf,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,IAAa,EAAE,GAAa,EAAE,EAAE;IACtD,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;AAC3F,CAAC,CAAC,CAAC;AAEH,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;YACjC,OAAO,CAAC,GAAG,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;YAC9D,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ObservationResult } from './observe';
2
+ export interface VerifyResult {
3
+ fixed: boolean;
4
+ explanation: string;
5
+ newObservation: ObservationResult;
6
+ newObservationText: string;
7
+ }
8
+ export declare function verify(apiKey: string, originalObservationText: string, actionsPerformed: string[], onProgress?: (msg: string) => void): Promise<VerifyResult>;
9
+ export declare function quickHealthCheck(gatewayStatus: string): boolean;
10
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG1E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,iBAAiB,CAAC;IAClC,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAsB,MAAM,CAC1B,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,MAAM,EAC/B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACjC,OAAO,CAAC,YAAY,CAAC,CAuBvB;AAGD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAG/D"}
package/dist/verify.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verify = verify;
4
+ exports.quickHealthCheck = quickHealthCheck;
5
+ const observe_1 = require("./observe");
6
+ const diagnose_1 = require("./diagnose");
7
+ async function verify(apiKey, originalObservationText, actionsPerformed, onProgress) {
8
+ const progress = (msg) => {
9
+ if (onProgress)
10
+ onProgress(msg);
11
+ };
12
+ progress('Re-checking system state...');
13
+ const newObservation = await (0, observe_1.observe)((msg) => progress(` ${msg}`));
14
+ const newObservationText = (0, observe_1.formatObservation)(newObservation);
15
+ progress('Asking AI to verify if issue is resolved...');
16
+ const { fixed, explanation } = await (0, diagnose_1.verifyFix)(apiKey, originalObservationText, actionsPerformed, newObservationText);
17
+ return {
18
+ fixed,
19
+ explanation,
20
+ newObservation,
21
+ newObservationText,
22
+ };
23
+ }
24
+ // Quick heuristic check without AI (for speed)
25
+ function quickHealthCheck(gatewayStatus) {
26
+ const lower = gatewayStatus.toLowerCase();
27
+ return lower.includes('runtime: running') || lower.includes('rpc probe: ok');
28
+ }
29
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":";;AAUA,wBA4BC;AAGD,4CAGC;AA5CD,uCAA0E;AAC1E,yCAAuC;AAShC,KAAK,UAAU,MAAM,CAC1B,MAAc,EACd,uBAA+B,EAC/B,gBAA0B,EAC1B,UAAkC;IAElC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;QAC/B,IAAI,UAAU;YAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,QAAQ,CAAC,6BAA6B,CAAC,CAAC;IACxC,MAAM,cAAc,GAAG,MAAM,IAAA,iBAAO,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;IACpE,MAAM,kBAAkB,GAAG,IAAA,2BAAiB,EAAC,cAAc,CAAC,CAAC;IAE7D,QAAQ,CAAC,6CAA6C,CAAC,CAAC;IACxD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,oBAAS,EAC5C,MAAM,EACN,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,CACnB,CAAC;IAEF,OAAO;QACL,KAAK;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;KACnB,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,SAAgB,gBAAgB,CAAC,aAAqB;IACpD,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC/E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "clawaid",
3
+ "version": "1.0.0",
4
+ "description": "AI-powered diagnostic and repair tool for OpenClaw",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "clawaid": "./dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "start": "node dist/index.js",
12
+ "dev": "ts-node src/index.ts"
13
+ },
14
+ "keywords": ["openclaw", "diagnostics", "repair", "ai", "clawaid"],
15
+ "author": "clawaid",
16
+ "license": "MIT",
17
+ "files": ["dist", "web"],
18
+ "engines": { "node": ">=18" },
19
+ "repository": { "type": "git", "url": "https://github.com/jjj5666/clawaid" },
20
+ "dependencies": {
21
+ "express": "^4.18.2",
22
+ "axios": "^1.6.2",
23
+ "open": "^9.1.0",
24
+ "get-port": "^7.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/express": "^4.17.21",
28
+ "@types/node": "^20.10.0",
29
+ "typescript": "^5.3.2",
30
+ "ts-node": "^10.9.2"
31
+ }
32
+ }