chore: import upstream snapshot with attribution
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
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
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
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { authJsonHeaders, batchUpdateUrl, presentationUrl } from '@/tools/google_slides/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const logger = createLogger('GoogleSlidesBatchUpdateTool')
|
||||
|
||||
interface BatchUpdateParams {
|
||||
accessToken: string
|
||||
presentationId: string
|
||||
requests: string
|
||||
writeControl?: string
|
||||
}
|
||||
|
||||
interface BatchUpdateResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
replies: unknown[]
|
||||
writeControl: unknown
|
||||
metadata: { presentationId: string; url: string; requestCount: number }
|
||||
}
|
||||
}
|
||||
|
||||
export const batchUpdateTool: ToolConfig<BatchUpdateParams, BatchUpdateResponse> = {
|
||||
id: 'google_slides_batch_update',
|
||||
name: 'Batch Update Google Slides (Raw)',
|
||||
description:
|
||||
'Run a raw Slides API batchUpdate with a list of Request objects. Use this when the higher-level tools do not cover an operation, or to bundle multiple operations into a single atomic batch (all-or-nothing).',
|
||||
version: '1.0.0',
|
||||
|
||||
oauth: { required: true, provider: 'google-drive' },
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Google Slides API',
|
||||
},
|
||||
presentationId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Google Slides presentation ID',
|
||||
},
|
||||
requests: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'JSON array of Slides API Request objects. Example: [{"replaceAllText":{"containsText":{"text":"{{title}}"},"replaceText":"Q3 Review"}}, {"updatePageProperties":{"objectId":"slide_1","pageProperties":{"pageBackgroundFill":{"solidFill":{"color":{"rgbColor":{"red":0.043,"green":0.122,"blue":0.231}}}}},"fields":"pageBackgroundFill"}}]',
|
||||
},
|
||||
writeControl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Optional JSON WriteControl object for optimistic concurrency, e.g. {"requiredRevisionId":"..."}',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => batchUpdateUrl(params.presentationId),
|
||||
method: 'POST',
|
||||
headers: (params) => authJsonHeaders(params.accessToken),
|
||||
body: (params) => {
|
||||
const raw = params.requests
|
||||
if (!raw) throw new Error('Requests JSON is required')
|
||||
|
||||
let requests: unknown
|
||||
try {
|
||||
requests = typeof raw === 'string' ? JSON.parse(raw) : raw
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid requests JSON: ${(e as Error).message}`)
|
||||
}
|
||||
if (!Array.isArray(requests)) {
|
||||
throw new Error('Requests must be a JSON array of Request objects')
|
||||
}
|
||||
if (requests.length === 0) {
|
||||
throw new Error('Requests array must contain at least one Request')
|
||||
}
|
||||
|
||||
const body: Record<string, unknown> = { requests }
|
||||
|
||||
if (params.writeControl?.trim()) {
|
||||
try {
|
||||
const wc = JSON.parse(params.writeControl)
|
||||
if (wc && typeof wc === 'object') body.writeControl = wc
|
||||
} catch (e) {
|
||||
logger.warn('Invalid writeControl JSON, ignoring:', { error: e })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response, params) => {
|
||||
const data = await response.json()
|
||||
if (!response.ok) {
|
||||
logger.error('Google Slides API error:', { data })
|
||||
throw new Error(data.error?.message || 'Batch update failed')
|
||||
}
|
||||
const presentationId = params?.presentationId?.trim() || ''
|
||||
const replies: unknown[] = Array.isArray(data.replies) ? data.replies : []
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
replies,
|
||||
writeControl: data.writeControl ?? null,
|
||||
metadata: {
|
||||
presentationId,
|
||||
url: presentationUrl(presentationId),
|
||||
requestCount: replies.length,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
replies: {
|
||||
type: 'array',
|
||||
description: 'Array of reply objects, one per request (parallel-indexed)',
|
||||
items: { type: 'json' },
|
||||
},
|
||||
writeControl: {
|
||||
type: 'json',
|
||||
description: 'WriteControl returned by the server (revision tracking)',
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
presentationId: { type: 'string', description: 'The presentation ID' },
|
||||
url: { type: 'string', description: 'URL to the presentation' },
|
||||
requestCount: { type: 'number', description: 'Number of replies returned' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user