|
@@ -1,21 +1,25 @@
|
|
|
import { delay, http, HttpResponse } from "msw";
|
|
import { delay, http, HttpResponse } from "msw";
|
|
|
|
|
|
|
|
-export const handlers = [
|
|
|
|
|
- http.get("https://api.github.com/user/repos", ({ request }) => {
|
|
|
|
|
- const token = request.headers
|
|
|
|
|
- .get("Authorization")
|
|
|
|
|
- ?.replace("Bearer", "")
|
|
|
|
|
- .trim();
|
|
|
|
|
-
|
|
|
|
|
- if (!token) {
|
|
|
|
|
- return HttpResponse.json([], { status: 401 });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+const openHandsHandlers = [
|
|
|
|
|
+ http.get("http://localhost:3000/api/options/models", async () => {
|
|
|
|
|
+ await delay();
|
|
|
return HttpResponse.json([
|
|
return HttpResponse.json([
|
|
|
- { id: 1, full_name: "octocat/hello-world" },
|
|
|
|
|
- { id: 2, full_name: "octocat/earth" },
|
|
|
|
|
|
|
+ "gpt-3.5-turbo",
|
|
|
|
|
+ "gpt-4o",
|
|
|
|
|
+ "anthropic/claude-3.5",
|
|
|
]);
|
|
]);
|
|
|
}),
|
|
}),
|
|
|
|
|
+
|
|
|
|
|
+ http.get("http://localhost:3000/api/options/agents", async () => {
|
|
|
|
|
+ await delay();
|
|
|
|
|
+ return HttpResponse.json(["CodeActAgent", "CoActAgent"]);
|
|
|
|
|
+ }),
|
|
|
|
|
+
|
|
|
|
|
+ http.get("http://localhost:3000/api/options/security-analyzers", async () => {
|
|
|
|
|
+ await delay();
|
|
|
|
|
+ return HttpResponse.json(["mock-invariant"]);
|
|
|
|
|
+ }),
|
|
|
|
|
+
|
|
|
http.get("http://localhost:3000/api/list-files", async ({ request }) => {
|
|
http.get("http://localhost:3000/api/list-files", async ({ request }) => {
|
|
|
await delay();
|
|
await delay();
|
|
|
|
|
|
|
@@ -24,14 +28,16 @@ export const handlers = [
|
|
|
?.replace("Bearer", "")
|
|
?.replace("Bearer", "")
|
|
|
.trim();
|
|
.trim();
|
|
|
|
|
|
|
|
- if (!token) {
|
|
|
|
|
- return HttpResponse.json([], { status: 401 });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (!token) return HttpResponse.json([], { status: 401 });
|
|
|
return HttpResponse.json(["file1.ts", "dir1/file2.ts", "file3.ts"]);
|
|
return HttpResponse.json(["file1.ts", "dir1/file2.ts", "file3.ts"]);
|
|
|
}),
|
|
}),
|
|
|
|
|
+
|
|
|
|
|
+ http.post("http://localhost:3000/api/save-file", () =>
|
|
|
|
|
+ HttpResponse.json(null, { status: 200 }),
|
|
|
|
|
+ ),
|
|
|
|
|
+
|
|
|
http.get("http://localhost:3000/api/select-file", async ({ request }) => {
|
|
http.get("http://localhost:3000/api/select-file", async ({ request }) => {
|
|
|
- await delay(500);
|
|
|
|
|
|
|
+ await delay();
|
|
|
|
|
|
|
|
const token = request.headers
|
|
const token = request.headers
|
|
|
.get("Authorization")
|
|
.get("Authorization")
|
|
@@ -51,26 +57,26 @@ export const handlers = [
|
|
|
|
|
|
|
|
return HttpResponse.json(null, { status: 404 });
|
|
return HttpResponse.json(null, { status: 404 });
|
|
|
}),
|
|
}),
|
|
|
- http.get("http://localhost:3000/api/options/agents", async () => {
|
|
|
|
|
- await delay();
|
|
|
|
|
- return HttpResponse.json(["CodeActAgent", "CoActAgent"]);
|
|
|
|
|
- }),
|
|
|
|
|
- http.get("http://localhost:3000/api/options/models", async () => {
|
|
|
|
|
- await delay();
|
|
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+export const handlers = [
|
|
|
|
|
+ ...openHandsHandlers,
|
|
|
|
|
+ http.get("https://api.github.com/user/repos", ({ request }) => {
|
|
|
|
|
+ const token = request.headers
|
|
|
|
|
+ .get("Authorization")
|
|
|
|
|
+ ?.replace("Bearer", "")
|
|
|
|
|
+ .trim();
|
|
|
|
|
+
|
|
|
|
|
+ if (!token) {
|
|
|
|
|
+ return HttpResponse.json([], { status: 401 });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return HttpResponse.json([
|
|
return HttpResponse.json([
|
|
|
- "gpt-3.5-turbo",
|
|
|
|
|
- "gpt-4o",
|
|
|
|
|
- "anthropic/claude-3.5",
|
|
|
|
|
|
|
+ { id: 1, full_name: "octocat/hello-world" },
|
|
|
|
|
+ { id: 2, full_name: "octocat/earth" },
|
|
|
]);
|
|
]);
|
|
|
}),
|
|
}),
|
|
|
http.post("http://localhost:3000/api/submit-feedback", async () =>
|
|
http.post("http://localhost:3000/api/submit-feedback", async () =>
|
|
|
HttpResponse.json({ statusCode: 200 }, { status: 200 }),
|
|
HttpResponse.json({ statusCode: 200 }, { status: 200 }),
|
|
|
),
|
|
),
|
|
|
- http.post("http://localhost:3000/api/save-file", () =>
|
|
|
|
|
- HttpResponse.json(null, { status: 200 }),
|
|
|
|
|
- ),
|
|
|
|
|
- http.get("http://localhost:3000/api/options/security-analyzers", async () => {
|
|
|
|
|
- await delay();
|
|
|
|
|
- return HttpResponse.json(["mock-invariant"]);
|
|
|
|
|
- }),
|
|
|
|
|
];
|
|
];
|