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
106 lines
2.9 KiB
TypeScript
106 lines
2.9 KiB
TypeScript
import type {
|
|
GoogleForm,
|
|
GoogleFormsCreateFormParams,
|
|
GoogleFormsCreateFormResponse,
|
|
} from '@/tools/google_forms/types'
|
|
import { buildCreateFormUrl, getGoogleFormsErrorMessage } from '@/tools/google_forms/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const createFormTool: ToolConfig<
|
|
GoogleFormsCreateFormParams,
|
|
GoogleFormsCreateFormResponse
|
|
> = {
|
|
id: 'google_forms_create_form',
|
|
name: 'Google Forms: Create Form',
|
|
description: 'Create a new Google Form with a title',
|
|
version: '1.0.0',
|
|
|
|
oauth: {
|
|
required: true,
|
|
provider: 'google-forms',
|
|
},
|
|
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'OAuth access token',
|
|
},
|
|
title: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'The title of the form visible to responders',
|
|
},
|
|
documentTitle: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'The document title visible in Drive (defaults to form title)',
|
|
},
|
|
unpublished: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'If true, create an unpublished form that does not accept responses',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params: GoogleFormsCreateFormParams) => buildCreateFormUrl(params.unpublished),
|
|
method: 'POST',
|
|
headers: (params: GoogleFormsCreateFormParams) => ({
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params: GoogleFormsCreateFormParams) => ({
|
|
info: {
|
|
title: params.title,
|
|
...(params.documentTitle ? { documentTitle: params.documentTitle } : {}),
|
|
},
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = (await response.json()) as GoogleForm
|
|
|
|
if (!response.ok) {
|
|
return {
|
|
success: false,
|
|
output: {
|
|
formId: '',
|
|
title: null,
|
|
documentTitle: null,
|
|
responderUri: null,
|
|
revisionId: null,
|
|
},
|
|
error: getGoogleFormsErrorMessage(data, 'Failed to create form'),
|
|
}
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
formId: data.formId ?? '',
|
|
title: data.info?.title ?? null,
|
|
documentTitle: data.info?.documentTitle ?? null,
|
|
responderUri: data.responderUri ?? null,
|
|
revisionId: data.revisionId ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
formId: { type: 'string', description: 'The ID of the created form' },
|
|
title: { type: 'string', description: 'The form title', optional: true },
|
|
documentTitle: { type: 'string', description: 'The document title in Drive', optional: true },
|
|
responderUri: {
|
|
type: 'string',
|
|
description: 'The URI to share with responders',
|
|
optional: true,
|
|
},
|
|
revisionId: { type: 'string', description: 'The revision ID of the form', optional: true },
|
|
},
|
|
}
|