Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge origin/main into train/nov16-u1
milind-soni5ea55faafa62
diff --cc server/testing/fake-connected-apps.tsindex c035252efd,b5eb519595..5eb3b31500--- a/server/testing/fake-connected-apps.ts+++ b/server/testing/fake-connected-apps.ts@@@ -38,7 -36,7 +40,7 @@@ const field = (value: unknown, name: stexport async function startFakeConnectedApps(): Promise<FakeConnectedApps> {const fake: Omit<FakeConnectedApps, "url" | "token" | "close"> = {- connected: { gmail: true, googlecalendar: true }, accounts: {}, address: "[email protected]", events: [], emails: [], calls: [], threads: {}, outlook: [],- connected: { gmail: true, googlecalendar: true }, address: "[email protected]", events: [], emails: [], calls: [], threads: {}, outlook: [], uploads: [],++ connected: { gmail: true, googlecalendar: true }, accounts: {}, address: "[email protected]", events: [], emails: [], calls: [], threads: {}, outlook: [], uploads: [],calendars: [{ id: "[email protected]", primary: true, accessRole: "owner", selected: true }],};@@@ -73,16 -71,23 +75,28 @@@}const server = createServer(async (req, res) => {- let raw = "";- for await (const chunk of req) raw += chunk;+ const chunks: Buffer[] = [];+ for await (const chunk of req) chunks.push(chunk as Buffer);+ const raw = Buffer.concat(chunks).toString("utf8");res.setHeader("content-type", "application/json");+ // Composio's upload link, then the bytes put to it (cloudflare/composio-broker/src/files.ts).+ if (req.method === "POST" && req.url === "/v1/files/upload") {+ const key = `fake-files/${fake.uploads.length + 1}`;+ fake.uploads.push({ request: JSON.parse(raw), key });+ return res.end(JSON.stringify({ key, url: `http://127.0.0.1:${(server.address() as { port: number }).port}/upload/${fake.uploads.length}` }));+ }+ const put = req.method === "PUT" ? /^\/upload\/(\d+)$/.exec(req.url ?? "") : null;+ if (put && fake.uploads[Number(put[1]) - 1]) {+ Object.assign(fake.uploads[Number(put[1]) - 1]!, { bytes: Buffer.concat(chunks), contentType: req.headers["content-type"] });+ return res.end("{}");+ }if (req.method === "GET" && req.url === "/v1/connectors/connected") {- return res.end(JSON.stringify({ services: Object.fromEntries(Object.entries(fake.connected).map(([slug, connected]) => [slug, { connected }])) }));+ if (fake.inventoryFailsAfter !== undefined && fake.inventoryFailsAfter-- <= 0) {+ res.statusCode = 503;+ return res.end(JSON.stringify({ error: "fake connected apps: account inventory down" }));+ }+ return res.end(JSON.stringify({ services: Object.fromEntries(Object.entries(fake.connected).map(([slug, connected]) =>+ [slug, { connected, ...(fake.accounts[slug] ? { accounts: fake.accounts[slug] } : {}) }])) }));}// A connection card's status check: the services it names.if (req.method === "GET" && req.url?.startsWith("/v1/connectors?")) {