Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix: follow snake-case Composio calendar tokens

Afloata4d6c1133981
diff --git a/server/connected-calendar-pages.test.ts b/server/connected-calendar-pages.test.ts
index ec3c49548d..992f998614 100644
--- a/server/connected-calendar-pages.test.ts
+++ b/server/connected-calendar-pages.test.ts
@@ -21,6 +21,17 @@ function fixture(answer: (slug: string, args: Record<string, unknown>) => unknow
}
describe("complete calendar reads", () => {
+ it.each([false, true])("reads Composio's snake-case calendar token (nested: %s)", async (nested) => {
+ const { read, calls } = fixture((slug, args) => {
+ if (slug !== CALENDARS_TOOL) return { items: [event(String(args.calendarId))] };
+ const data = args.page_token ? { items: [{ id: "team", selected: true, accessRole: "reader" }] }
+ : { items: [primary], next_page_token: "next-calendar-page" };
+ return nested ? { response_data: data } : data;
+ });
+ expect((await read()).map((one) => one.calendarId)).toEqual(["primary", "team"]);
+ expect(calls.filter((one) => one.slug === CALENDARS_TOOL)[1]!.args).toEqual({ page_token: "next-calendar-page" });
+ });
+
it("reads later calendar and event pages with each tool's parameter spelling", async () => {
const { read, calls } = fixture((slug, args) => {
if (slug === CALENDARS_TOOL) return args.page_token
diff --git a/server/connected-reads.ts b/server/connected-reads.ts
index 26b04c517c..342cfb35b4 100644
--- a/server/connected-reads.ts
+++ b/server/connected-reads.ts
@@ -269,7 +269,7 @@ export function emailsFromData(data: unknown): EmailHeader[] {
/** Gmail or Calendar's page token for more results, or undefined on the last page. */
export function nextPageOf(data: unknown): string | undefined {
- const token = [record(data), record(record(data)?.response_data)].map((body) => body?.nextPageToken).find((value) => typeof value === "string" && value);
+ const token = [record(data), record(record(data)?.response_data)].flatMap((body) => [body?.nextPageToken, body?.next_page_token]).find((value) => typeof value === "string" && value);
return typeof token === "string" ? token : undefined;
}