-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcapture-console-logs.ts
More file actions
89 lines (70 loc) · 2.39 KB
/
capture-console-logs.ts
File metadata and controls
89 lines (70 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Monitor console logs from Superhuman for AI-related activity
*/
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
async function main() {
console.log("=== Console Log Monitor ===\n");
const conn = await connectToSuperhuman(9333);
if (!conn) {
console.error("Failed to connect to Superhuman");
process.exit(1);
}
const { client, Runtime } = conn;
// Enable Runtime for console messages
await Runtime.enable();
// Listen for console messages
Runtime.consoleAPICalled((params: any) => {
const args = params.args.map((arg: any) => {
if (arg.type === "string") return arg.value;
if (arg.type === "object") {
if (arg.preview) {
return JSON.stringify(arg.preview.properties?.reduce((acc: any, p: any) => {
acc[p.name] = p.value;
return acc;
}, {}));
}
return arg.description || arg.className;
}
return arg.value || arg.description || arg.type;
}).join(" ");
const logLine = `[${params.type}] ${args}`;
// Show logs that might be AI-related
if (args.toLowerCase().includes("ai") ||
args.toLowerCase().includes("ask") ||
args.toLowerCase().includes("event") ||
args.toLowerCase().includes("session") ||
args.toLowerCase().includes("question") ||
args.includes("INTERCEPTED")) {
console.log(logLine);
}
});
console.log("Monitoring console logs for AI activity...");
console.log("Use 'Ask AI' in Superhuman (J key)\n");
console.log("-".repeat(60));
// Also try to trigger by pressing J
console.log("\nAttempting to simulate J key press to open Ask AI...\n");
await conn.Input.dispatchKeyEvent({
type: "keyDown",
key: "j",
code: "KeyJ",
windowsVirtualKeyCode: 74,
});
await new Promise(r => setTimeout(r, 100));
await conn.Input.dispatchKeyEvent({
type: "keyUp",
key: "j",
code: "KeyJ",
windowsVirtualKeyCode: 74,
});
console.log("Sent J key. Waiting for activity...\n");
// Keep running for 30 seconds
await new Promise(r => setTimeout(r, 30000));
// Try to get any captured data
const result = await Runtime.evaluate({
expression: `JSON.stringify(window.__capturedAIRequests || [], null, 2)`,
returnByValue: true
});
console.log("\nCaptured requests from window:", result.result.value);
await disconnect(conn);
}
main().catch(console.error);