Skip to content

Commit 92f4168

Browse files
authored
Merge pull request #5 from twilio-internal/refactor-to-ts
refactor to ts
2 parents 73aacf0 + 17de26d commit 92f4168

28 files changed

+7861
-6460
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ Thumbs.db
2424

2525
.logs/
2626

27-
example_task_logs/
27+
example_task_logs/
28+
dist/

dashboard/server.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import http from "http";
2+
import fs from "fs";
3+
import path from "path";
4+
5+
const PORT = 3001;
6+
7+
interface MimeTypes {
8+
[key: string]: string;
9+
}
10+
11+
const MIME_TYPES: MimeTypes = {
12+
".html": "text/html",
13+
".js": "text/javascript",
14+
".css": "text/css",
15+
".json": "application/json",
16+
".png": "image/png",
17+
".jpg": "image/jpg",
18+
".gif": "image/gif",
19+
".svg": "image/svg+xml",
20+
".ico": "image/x-icon",
21+
};
22+
23+
const server = http.createServer((req, res) => {
24+
console.log(`${req.method} ${req.url}`);
25+
26+
if (!req.url) {
27+
res.writeHead(400);
28+
res.end("Bad request: URL missing");
29+
return;
30+
}
31+
32+
// Handle the root path
33+
let filePath: string;
34+
if (req.url === "/") {
35+
filePath = path.join(__dirname, "../public/dashboard.html");
36+
} else if (req.url === "/index.js") {
37+
// Serve the main JS file from public folder
38+
filePath = path.join(__dirname, "../public/index.js");
39+
} else if (req.url === "/index.css") {
40+
// Serve the main CSS file from public folder
41+
filePath = path.join(__dirname, "../public/index.css");
42+
} else if (req.url.startsWith("/metrics/")) {
43+
// Serve metrics files from the metrics directory
44+
const metricsPath =
45+
req.url === "/metrics/summary.json"
46+
? path.join(__dirname, "../metrics", req.url.replace("/metrics/", ""))
47+
: path.join(
48+
__dirname,
49+
"../metrics/tasks",
50+
req.url.replace("/metrics/", ""),
51+
);
52+
filePath = metricsPath;
53+
} else if (req.url.startsWith("/docs/")) {
54+
// Serve docs assets
55+
filePath = path.join(__dirname, "../public", req.url);
56+
} else {
57+
// Serve other static files from the public directory
58+
filePath = path.join(__dirname, "../public", req.url);
59+
}
60+
61+
// Get the file extension
62+
const extname = path.extname(filePath);
63+
const contentType = MIME_TYPES[extname] || "application/octet-stream";
64+
65+
// Read the file
66+
fs.readFile(filePath, (err, content) => {
67+
if (err) {
68+
if (err.code === "ENOENT") {
69+
// Page not found
70+
console.error(`File not found: ${filePath}`);
71+
res.writeHead(404);
72+
res.end("404 Not Found");
73+
} else {
74+
// Server error
75+
console.error(`Server error: ${err.code}`);
76+
res.writeHead(500);
77+
res.end(`Server Error: ${err.code}`);
78+
}
79+
} else {
80+
// Success
81+
res.writeHead(200, { "Content-Type": contentType });
82+
res.end(content, "utf-8");
83+
}
84+
});
85+
});
86+
87+
server.listen(PORT, () => {
88+
console.log(`Server running at http://localhost:${PORT}/`);
89+
console.log("Press Ctrl+C to stop the server");
90+
});

metrics/summary.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,28 @@
373373
"success": true,
374374
"notes": ""
375375
},
376+
{
377+
"taskId": 1,
378+
"directoryId": "1744055487177",
379+
"mode": "mcp",
380+
"model": "claude-3.7-sonnet",
381+
"mcpServer": "Twilio",
382+
"mcpClient": "Cline",
383+
"startTime": 1744055487180,
384+
"endTime": 1744055550305,
385+
"duration": 63125,
386+
"apiCalls": 7,
387+
"interactions": 1,
388+
"tokensIn": 28,
389+
"tokensOut": 2317,
390+
"totalTokens": 2345,
391+
"cacheWrites": 31980,
392+
"cacheReads": 173262,
393+
"conversationHistoryIndex": 12,
394+
"cost": 0.2067426,
395+
"success": true,
396+
"notes": ""
397+
},
376398
{
377399
"taskId": 2,
378400
"directoryId": "1743272264340",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"mode": "mcp",
3+
"taskNumber": 1,
4+
"directoryId": "1744055487177",
5+
"model": "claude-3.7-sonnet",
6+
"startTime": 1744055487180,
7+
"completed": true,
8+
"apiCalls": 7,
9+
"interactions": 1,
10+
"tokensIn": 28,
11+
"tokensOut": 2317,
12+
"totalTokens": 2345,
13+
"cacheWrites": 31980,
14+
"cacheReads": 173262,
15+
"conversationHistoryIndex": 12,
16+
"cost": 0.2067426,
17+
"success": true,
18+
"endTime": 1744055550305,
19+
"duration": 63125
20+
}

0 commit comments

Comments
 (0)