AI-native design editor. Open-source Figma alternative.
import * as v from 'valibot'
import { OpenPencilAPI } from '#core/openpencil-api'
import { nodeIdInputSchema, defineTool } from '#core/tools/schema'
export const unbindVariable = defineTool({
name: 'unbind_variable',
description: 'Remove a variable binding from a node property.',
execution: { kind: 'sync', mutation: 'properties' },
input: v.strictObject({
node_id: nodeIdInputSchema,
field: v.pipe(
v.string(),
v.description(
'Property field path to unbind. For fills/strokes use indexed format: "fills/0/color", "strokes/0/color". ' +
'For FLOAT scalars: "opacity", "width", "height", "cornerRadius", "fontSize", "letterSpacing", ' +
'"lineHeight", "itemSpacing", "strokeWeight", "paddingLeft/Right/Top/Bottom", "counterAxisSpacing", ' +
'"rotation", "x", "y", "minWidth", "maxWidth", "minHeight", "maxHeight", ' +
'"topLeftRadius", "topRightRadius", "bottomLeftRadius", "bottomRightRadius", ' +
'"borderTopWeight", "borderBottomWeight", "borderLeftWeight", "borderRightWeight", ' +
'"gridRowGap", "gridColumnGap". ' +
'Text: "text", "fontFamily". Visibility: "visible".'
)
)
}),
execute: (figma, args) => {
// Access raw scene node for boundVariables (not exposed on the proxy)
const rawNode = figma.graph.getNode(args.node_id)
if (!rawNode) return { error: `Node "${args.node_id}" not found` }
const boundValue = rawNode.boundVariables[args.field]
if (!boundValue) {
return { error: `No binding found for field "${args.field}" on node "${args.node_id}"` }
}
new OpenPencilAPI(figma).unbindVariable(args.node_id, args.field)
return { unbound: true, node_id: args.node_id, field: args.field }
}
})