Files
simstudioai--sim/apps/sim/tools/google_calendar/create_calendar.ts
T
wehub-resource-sync d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

143 lines
4.1 KiB
TypeScript

import {
CALENDAR_API_BASE,
type GoogleCalendarApiCalendarResponse,
type GoogleCalendarCreateCalendarParams,
type GoogleCalendarCreateCalendarResponse,
} from '@/tools/google_calendar/types'
import type { ToolConfig } from '@/tools/types'
export const createCalendarTool: ToolConfig<
GoogleCalendarCreateCalendarParams,
GoogleCalendarCreateCalendarResponse
> = {
id: 'google_calendar_create_calendar',
name: 'Google Calendar Create Calendar',
description: 'Create a new secondary calendar',
version: '1.0.0',
oauth: {
required: true,
provider: 'google-calendar',
},
params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Access token for Google Calendar API',
},
summary: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Title of the new calendar',
},
description: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Description of the new calendar',
},
location: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Geographic location of the calendar as free-form text',
},
timeZone: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Time zone of the calendar as an IANA name (e.g., America/Los_Angeles)',
},
},
request: {
url: () => `${CALENDAR_API_BASE}/calendars`,
method: 'POST',
headers: (params: GoogleCalendarCreateCalendarParams) => ({
Authorization: `Bearer ${params.accessToken}`,
'Content-Type': 'application/json',
}),
body: (params: GoogleCalendarCreateCalendarParams) => {
const body: Record<string, string> = { summary: params.summary }
if (params.description) body.description = params.description
if (params.location) body.location = params.location
if (params.timeZone) body.timeZone = params.timeZone
return body
},
},
transformResponse: async (response: Response) => {
const data: GoogleCalendarApiCalendarResponse = await response.json()
return {
success: true,
output: {
content: `Calendar "${data.summary}" created successfully`,
metadata: {
id: data.id,
summary: data.summary,
description: data.description,
location: data.location,
timeZone: data.timeZone,
},
},
}
},
outputs: {
content: { type: 'string', description: 'Calendar creation confirmation message' },
metadata: {
type: 'json',
description: 'Created calendar metadata (id, summary, description, location, timeZone)',
},
},
}
interface GoogleCalendarCreateCalendarV2Response {
success: boolean
output: {
id: string
summary: string
description: string | null
location: string | null
timeZone: string | null
}
}
export const createCalendarV2Tool: ToolConfig<
GoogleCalendarCreateCalendarParams,
GoogleCalendarCreateCalendarV2Response
> = {
id: 'google_calendar_create_calendar_v2',
name: 'Google Calendar Create Calendar',
description: 'Create a new secondary calendar. Returns API-aligned fields only.',
version: '2.0.0',
oauth: createCalendarTool.oauth,
params: createCalendarTool.params,
request: createCalendarTool.request,
transformResponse: async (response: Response) => {
const data: GoogleCalendarApiCalendarResponse = await response.json()
return {
success: true,
output: {
id: data.id,
summary: data.summary,
description: data.description ?? null,
location: data.location ?? null,
timeZone: data.timeZone ?? null,
},
}
},
outputs: {
id: { type: 'string', description: 'Calendar ID' },
summary: { type: 'string', description: 'Calendar title' },
description: { type: 'string', description: 'Calendar description', optional: true },
location: { type: 'string', description: 'Calendar location', optional: true },
timeZone: { type: 'string', description: 'Calendar time zone', optional: true },
},
}