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
@@ -13,6 +13,7 @@ import {
|
||||
import { z } from 'zod'
|
||||
import type { SceneOperations } from '../../operations'
|
||||
import { appendLiveSceneEvent } from '../live-sync'
|
||||
import { measurement } from '../measurement'
|
||||
|
||||
/**
|
||||
* Input shape for the `photo_to_scene` orchestrator. `image` matches the
|
||||
@@ -23,8 +24,14 @@ export const photoToSceneInput = {
|
||||
scaleHint: z.string().optional().describe('e.g. "1 cm = 1 m" or "approx 80 m²"'),
|
||||
name: z.string().default('Scene from photo'),
|
||||
save: z.boolean().default(true),
|
||||
defaultWallThickness: z.number().default(0.2),
|
||||
defaultWallHeight: z.number().default(2.6),
|
||||
defaultWallThickness: measurement('length', 'm', {
|
||||
min: 0,
|
||||
description: 'Default wall thickness.',
|
||||
}).default(0.2),
|
||||
defaultWallHeight: measurement('length', 'm', {
|
||||
min: 0,
|
||||
description: 'Default wall height.',
|
||||
}).default(2.6),
|
||||
}
|
||||
|
||||
export const photoToSceneOutput = {
|
||||
|
||||
Reference in New Issue
Block a user