feat(mcp): natural-language measurements for tool inputs via @pascal-app/lingo
Measurement/angle parameters on the scene tools now accept a bare number OR a
natural-language string ("6 in", "180cm", "45°", "1.57rad"), canonicalized to
the unit the handler already expects (meters for length, radians/degrees for
angles) with min/max bounds and model-readable errors. Makes LLM tool calls
safer — "6 in" no longer has to be pre-converted to 0.1524, and a bad value is
rejected with a message the model can self-correct from.
A shared `measurement(kind, unit)` zod field wraps lingo's parseQuantity as a
`number | string` union+transform; numbers pass through unchanged (backward
compatible), so no handler changes were needed. Covers create_wall, cut_opening,
place_item, create_level, create_story_shell, create_roof,
create_stair_between_levels, create_room, add_door, add_window, photo_to_scene.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
a5963560b1
commit
f66dcd438b
@@ -6,14 +6,15 @@ import type { SceneOperations } from '../operations'
|
||||
import { ErrorCode, throwMcpError } from './errors'
|
||||
import { wallLength, wallLocalXFromT } from './geometry'
|
||||
import { publishLiveSceneSnapshot } from './live-sync'
|
||||
import { measurement } from './measurement'
|
||||
import { NodeIdSchema } from './schemas'
|
||||
|
||||
export const cutOpeningInput = {
|
||||
wallId: NodeIdSchema,
|
||||
type: z.enum(['door', 'window']),
|
||||
position: z.number().min(0).max(1),
|
||||
width: z.number().positive(),
|
||||
height: z.number().positive(),
|
||||
width: measurement('length', 'm', { min: 0, description: 'Opening width.' }),
|
||||
height: measurement('length', 'm', { min: 0, description: 'Opening height.' }),
|
||||
}
|
||||
|
||||
export const cutOpeningOutput = {
|
||||
|
||||
Reference in New Issue
Block a user