import { TLShapeId } from 'tldraw' import { SendToBackAction } from '../../shared/schema/AgentActionSchemas' import { Streaming } from '../../shared/types/Streaming' import { AgentHelpers } from '../AgentHelpers' import { AgentActionUtil, registerActionUtil } from './AgentActionUtil' export const SendToBackActionUtil = registerActionUtil( class SendToBackActionUtil extends AgentActionUtil { static override type = 'sendToBack' as const override getInfo(action: Streaming) { return { icon: 'cursor' as const, description: action.intent ?? '', } } override sanitizeAction(action: Streaming, helpers: AgentHelpers) { action.shapeIds = helpers.ensureShapeIdsExist(action.shapeIds ?? []) return action } override applyAction(action: Streaming) { if (!action.shapeIds) return this.editor.sendToBack(action.shapeIds.map((shapeId) => `shape:${shapeId}` as TLShapeId)) } } )