import { z } from "zod" import { defineAction } from "../../../automation/actions" import { getGoogleMeetApi, GOOGLE_MEET_CONFERENCE_RECORD_REFERENCE_SCHEMA, GOOGLE_MEET_RECORDING_NAME_SCHEMA, GOOGLE_MEET_RECORDING_PAGE_SCHEMA, GOOGLE_MEET_RECORDING_SCHEMA, GOOGLE_MEET_SMART_NOTE_NAME_SCHEMA, GOOGLE_MEET_SMART_NOTE_PAGE_SCHEMA, GOOGLE_MEET_SMART_NOTE_SCHEMA, GOOGLE_MEET_TRANSCRIPT_ENTRY_NAME_SCHEMA, GOOGLE_MEET_TRANSCRIPT_ENTRY_PAGE_SCHEMA, GOOGLE_MEET_TRANSCRIPT_ENTRY_SCHEMA, GOOGLE_MEET_TRANSCRIPT_NAME_SCHEMA, GOOGLE_MEET_TRANSCRIPT_PAGE_SCHEMA, GOOGLE_MEET_TRANSCRIPT_SCHEMA, normalizeGoogleMeetConferenceRecordName, normalizeGoogleMeetRecording, normalizeGoogleMeetSmartNote, normalizeGoogleMeetTranscript, normalizeGoogleMeetTranscriptEntry, } from "@automate.ax/integration-contracts/google-meet" import { GOOGLE_MEET_READ_REQUIREMENT } from "../lib/scopes" /** Retrieves one recording artifact. */ export const getGoogleMeetRecording = defineAction("Get Google Meet recording") .describe("Gets recording timing, state, and Google Drive destination.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Full recording resource name returned by Meet. */ recording: GOOGLE_MEET_RECORDING_NAME_SCHEMA, }), ) .output(GOOGLE_MEET_RECORDING_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.recordings.get({ name: input.recording }) return normalizeGoogleMeetRecording(data) }) /** Lists one page of recording artifacts for a conference. */ export const listGoogleMeetRecordings = defineAction( "List Google Meet recordings", ) .describe("Lists recording sessions and generated Drive files.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Conference-record resource name or raw record ID. */ conferenceRecord: GOOGLE_MEET_CONFERENCE_RECORD_REFERENCE_SCHEMA, /** Maximum recordings returned in this page. */ pageSize: z.number().int().min(1).max(100).optional(), /** Token returned by a previous call. */ pageToken: z.string().min(1).optional(), }), ) .output(GOOGLE_MEET_RECORDING_PAGE_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.recordings.list({ pageSize: input.pageSize, pageToken: input.pageToken, parent: normalizeGoogleMeetConferenceRecordName(input.conferenceRecord), }) return { nextPageToken: data.nextPageToken ?? undefined, recordings: (data.recordings ?? []).map(normalizeGoogleMeetRecording), } }) /** Retrieves one transcript artifact. */ export const getGoogleMeetTranscript = defineAction( "Get Google Meet transcript", ) .describe("Gets transcript timing, state, and Google Docs destination.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Full transcript resource name returned by Meet. */ transcript: GOOGLE_MEET_TRANSCRIPT_NAME_SCHEMA, }), ) .output(GOOGLE_MEET_TRANSCRIPT_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.transcripts.get({ name: input.transcript }) return normalizeGoogleMeetTranscript(data) }) /** Lists one page of transcript artifacts for a conference. */ export const listGoogleMeetTranscripts = defineAction( "List Google Meet transcripts", ) .describe("Lists transcript sessions and generated Docs files.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Conference-record resource name or raw record ID. */ conferenceRecord: GOOGLE_MEET_CONFERENCE_RECORD_REFERENCE_SCHEMA, /** Maximum transcripts returned in this page. */ pageSize: z.number().int().min(1).max(100).optional(), /** Token returned by a previous call. */ pageToken: z.string().min(1).optional(), }), ) .output(GOOGLE_MEET_TRANSCRIPT_PAGE_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.transcripts.list({ pageSize: input.pageSize, pageToken: input.pageToken, parent: normalizeGoogleMeetConferenceRecordName(input.conferenceRecord), }) return { nextPageToken: data.nextPageToken ?? undefined, transcripts: (data.transcripts ?? []).map(normalizeGoogleMeetTranscript), } }) /** Retrieves one structured transcript speech segment. */ export const getGoogleMeetTranscriptEntry = defineAction( "Get Google Meet transcript entry", ) .describe("Gets one timed speaker segment from a Meet transcript.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Full transcript-entry resource name returned by Meet. */ transcriptEntry: GOOGLE_MEET_TRANSCRIPT_ENTRY_NAME_SCHEMA, }), ) .output(GOOGLE_MEET_TRANSCRIPT_ENTRY_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.transcripts.entries.get({ name: input.transcriptEntry, }) return normalizeGoogleMeetTranscriptEntry(data) }) /** Lists one page of structured speech segments from a transcript. */ export const listGoogleMeetTranscriptEntries = defineAction( "List Google Meet transcript entries", ) .describe("Lists timed, attributed speech segments in chronological order.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Maximum transcript entries returned in this page. */ pageSize: z.number().int().min(1).max(100).optional(), /** Token returned by a previous call. */ pageToken: z.string().min(1).optional(), /** Full transcript resource name returned by Meet. */ transcript: GOOGLE_MEET_TRANSCRIPT_NAME_SCHEMA, }), ) .output(GOOGLE_MEET_TRANSCRIPT_ENTRY_PAGE_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.transcripts.entries.list({ pageSize: input.pageSize, pageToken: input.pageToken, parent: input.transcript, }) return { nextPageToken: data.nextPageToken ?? undefined, transcriptEntries: (data.transcriptEntries ?? []).map( normalizeGoogleMeetTranscriptEntry, ), } }) /** Retrieves one Gemini smart-note artifact. */ export const getGoogleMeetSmartNote = defineAction("Get Google Meet smart note") .describe("Gets smart-note timing, state, and Google Docs destination.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Full smart-note resource name returned by Meet. */ smartNote: GOOGLE_MEET_SMART_NOTE_NAME_SCHEMA, }), ) .output(GOOGLE_MEET_SMART_NOTE_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.smartNotes.get({ name: input.smartNote }) return normalizeGoogleMeetSmartNote(data) }) /** Lists one page of Gemini smart-note artifacts for a conference. */ export const listGoogleMeetSmartNotes = defineAction( "List Google Meet smart notes", ) .describe("Lists smart-note sessions and generated Docs files.") .account("google", GOOGLE_MEET_READ_REQUIREMENT) .input( z.object({ /** Conference-record resource name or raw record ID. */ conferenceRecord: GOOGLE_MEET_CONFERENCE_RECORD_REFERENCE_SCHEMA, /** Maximum smart notes returned in this page. */ pageSize: z.number().int().min(1).max(100).optional(), /** Token returned by a previous call. */ pageToken: z.string().min(1).optional(), }), ) .output(GOOGLE_MEET_SMART_NOTE_PAGE_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => { const { data } = await getGoogleMeetApi( account.secret, ).conferenceRecords.smartNotes.list({ pageSize: input.pageSize, pageToken: input.pageToken, parent: normalizeGoogleMeetConferenceRecordName(input.conferenceRecord), }) return { nextPageToken: data.nextPageToken ?? undefined, smartNotes: (data.smartNotes ?? []).map(normalizeGoogleMeetSmartNote), } })