@pixerate/editor 0.80.0 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +13 -3
  2. package/dist/agent/index.cjs +102 -6
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +4 -2
  5. package/dist/agent/index.d.ts +4 -2
  6. package/dist/agent/index.js +101 -5
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/{builtins-BKYlHH1s.d.ts → builtins-CV1fDj64.d.ts} +5 -1
  9. package/dist/{builtins-1kqwLUnb.d.cts → builtins-c4w0eAYl.d.cts} +5 -1
  10. package/dist/{chunk-2CJ3LPYQ.js → chunk-424H3P4I.js} +13 -295
  11. package/dist/chunk-424H3P4I.js.map +1 -0
  12. package/dist/{chunk-UN33YOXW.cjs → chunk-PA5S7KPC.cjs} +293 -2
  13. package/dist/chunk-PA5S7KPC.cjs.map +1 -0
  14. package/dist/{chunk-IB3ZHQAX.js → chunk-PTYWCFFW.js} +29 -4
  15. package/dist/chunk-PTYWCFFW.js.map +1 -0
  16. package/dist/{chunk-JQ3BB3E6.js → chunk-PXDEFEG2.js} +293 -2
  17. package/dist/chunk-PXDEFEG2.js.map +1 -0
  18. package/dist/{chunk-YU4WQE5M.cjs → chunk-TAPXWP2B.cjs} +95 -377
  19. package/dist/chunk-TAPXWP2B.cjs.map +1 -0
  20. package/dist/{chunk-HXDMZQTD.cjs → chunk-TPOT575P.cjs} +29 -4
  21. package/dist/{chunk-IB3ZHQAX.js.map → chunk-TPOT575P.cjs.map} +1 -1
  22. package/dist/commands/index.cjs +2 -2
  23. package/dist/commands/index.d.cts +1 -1
  24. package/dist/commands/index.d.ts +1 -1
  25. package/dist/commands/index.js +1 -1
  26. package/dist/generation/index.cjs +932 -791
  27. package/dist/generation/index.cjs.map +1 -1
  28. package/dist/generation/index.d.cts +266 -240
  29. package/dist/generation/index.d.ts +266 -240
  30. package/dist/generation/index.js +926 -785
  31. package/dist/generation/index.js.map +1 -1
  32. package/dist/image-editor/index.cjs +266 -2
  33. package/dist/image-editor/index.cjs.map +1 -1
  34. package/dist/image-editor/index.d.cts +12 -1
  35. package/dist/image-editor/index.d.ts +12 -1
  36. package/dist/image-editor/index.js +265 -1
  37. package/dist/image-editor/index.js.map +1 -1
  38. package/dist/index.cjs +3 -3
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.js +16 -16
  41. package/dist/spreadsheet/index.cjs +3 -3
  42. package/dist/spreadsheet/index.cjs.map +1 -1
  43. package/dist/spreadsheet/index.js +16 -16
  44. package/package.json +2 -1
  45. package/skills/README.md +55 -0
  46. package/skills/pixerate-agent-tools/SKILL.md +75 -0
  47. package/skills/pixerate-animation-editor/SKILL.md +155 -0
  48. package/skills/pixerate-animation-editor/references/commands.md +123 -0
  49. package/skills/pixerate-canvas/SKILL.md +230 -0
  50. package/skills/pixerate-chart/SKILL.md +190 -0
  51. package/skills/pixerate-diagram/SKILL.md +134 -0
  52. package/skills/pixerate-generation/SKILL.md +109 -0
  53. package/skills/pixerate-image-editor/SKILL.md +139 -0
  54. package/skills/pixerate-parameters/SKILL.md +83 -0
  55. package/skills/pixerate-rich-text/SKILL.md +160 -0
  56. package/skills/pixerate-spreadsheet/SKILL.md +146 -0
  57. package/skills/pixerate-vector/SKILL.md +191 -0
  58. package/skills/pixerate-vector/references/commands.md +138 -0
  59. package/skills/pixerate-video-editor/SKILL.md +173 -0
  60. package/dist/chunk-2CJ3LPYQ.js.map +0 -1
  61. package/dist/chunk-HXDMZQTD.cjs.map +0 -1
  62. package/dist/chunk-JQ3BB3E6.js.map +0 -1
  63. package/dist/chunk-UN33YOXW.cjs.map +0 -1
  64. package/dist/chunk-YU4WQE5M.cjs.map +0 -1
@@ -1640,6 +1640,9 @@ interface ImageEditorToolProviderOptions {
1640
1640
  * - `render_preview {maxSide}`: the rendered image as a PNG, longest side at most `maxSide`.
1641
1641
  * - Selections and masks: `get_selection`, `select_region`, `select_by_color`, `modify_selection`,
1642
1642
  * `refine_selection`, `apply_selection_as_mask` (see `createImageSelectionTools`).
1643
+ * - Layers, geometry and history: `get_image_info`, `get_histogram`, `update_adjustment_layer`,
1644
+ * `remove_adjustment_layer`, `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`,
1645
+ * `flip_image`, `undo_image`, `redo_image` (see `createImageEditTools`).
1643
1646
  */
1644
1647
  declare function createImageEditorToolProvider(controller: ImageEditorController, options?: ImageEditorToolProviderOptions): AgentToolProvider;
1645
1648
 
@@ -1768,6 +1771,14 @@ declare class SelectionGesture {
1768
1771
  */
1769
1772
  declare function createImageSelectionTools(controller: ImageEditorController): AgentTool[];
1770
1773
 
1774
+ /**
1775
+ * Agent tools for the image editor's layers, geometry and history: `get_image_info`,
1776
+ * `get_histogram`, `update_adjustment_layer`, `remove_adjustment_layer`,
1777
+ * `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`, `flip_image`,
1778
+ * `undo_image` and `redo_image`. Each write is one undo step and returns what changed.
1779
+ */
1780
+ declare function createImageEditTools(controller: ImageEditorController): AgentTool[];
1781
+
1771
1782
  /**
1772
1783
  * Region-based mosaic (pixelation) and box-blur filters for redacting or anonymizing
1773
1784
  * rectangular bounding boxes on an ImageData-like buffer.
@@ -1809,4 +1820,4 @@ declare function applyRegionMosaic<T extends MosaicImageDataLike>(imageData: T,
1809
1820
  */
1810
1821
  declare function applyRegionBlur<T extends MosaicImageDataLike>(imageData: T, regions: MosaicRegion[], radius?: number): T;
1811
1822
 
1812
- export { ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationType, type ArrowAnnotation, type AspectRatio, BLEND_MODES, type BaseAnnotation, type BlackWhiteParams, type BlendMode, type BlendModeInfo, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DIRECT_GAUSSIAN_MAX_SIGMA, type DepthMaskOptions, EMPTY_DISTANCE, type ExportOptions, GUIDED_FILTER_EPS, type GestureModifiers, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, type HueRange, type HueSaturationParams, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_SCHEMA_VERSION, IMAGE_EDITOR_STATE_VERSION, type ImageAdjustments, type ImageAnnotation, type ImageDimensions, type ImageEditorAIHooks, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerMaskProps, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelOp, type PosterizeParams, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RectAnnotation, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type Rgb$1 as Rgb, type Rgba, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializedImageEditorState, type SerializedSelection, type ShapeSelectionOptions, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, activeAdjustmentLayers, adjustmentKindLabel, adjustmentLayersKey, applyAdjustmentLayers, applyAdjustments, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, blackWhiteGray, blendChannel, blendImageData, blendLum, blendPixel, blendRgb, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasCompositeOperation, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, createAdjustmentLayer, createImageEditorToolProvider, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerMask, decodeSelectionRle, defaultAdjustmentParams, describeSelection, deserializeSelection, distanceTransform, edgeWidth, ellipsePoints, ellipseSelection, encodeSelectionRle, evaluateAdjustmentLayers, expandCoverage, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, gaussianBlur, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, guidePlanes, guidedFilterColor, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, insertCurvePoint, invertMatrix3, invertSelection, isAdjustmentKind, isBlendMode, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSeparableBlendMode, kelvinToTemperature, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, migrateSerializedImageEditorState, modifySelection, moveCurvePoint, mulMatrix3, neutralHueRange, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeBlendMode, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, parseSelectionMode, photoFilterMatrix, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, quickMaskPixels, rangeLightness, readAdjustmentControls, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, resizeSelection, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeSelection, setControlPath, setLum, shiftCoverage, smoothCoverage, srgb8ToLab, srgbToLinear, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, toneRange, unprojectCanvasPoint, updateLayerMaskProps, uvToXy, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, xyToTempTint, xyToUv };
1823
+ export { ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationType, type ArrowAnnotation, type AspectRatio, BLEND_MODES, type BaseAnnotation, type BlackWhiteParams, type BlendMode, type BlendModeInfo, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DIRECT_GAUSSIAN_MAX_SIGMA, type DepthMaskOptions, EMPTY_DISTANCE, type ExportOptions, GUIDED_FILTER_EPS, type GestureModifiers, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, type HueRange, type HueSaturationParams, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_SCHEMA_VERSION, IMAGE_EDITOR_STATE_VERSION, type ImageAdjustments, type ImageAnnotation, type ImageDimensions, type ImageEditorAIHooks, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerMaskProps, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelOp, type PosterizeParams, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RectAnnotation, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type Rgb$1 as Rgb, type Rgba, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializedImageEditorState, type SerializedSelection, type ShapeSelectionOptions, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, activeAdjustmentLayers, adjustmentKindLabel, adjustmentLayersKey, applyAdjustmentLayers, applyAdjustments, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, blackWhiteGray, blendChannel, blendImageData, blendLum, blendPixel, blendRgb, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasCompositeOperation, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, createAdjustmentLayer, createImageEditTools, createImageEditorToolProvider, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerMask, decodeSelectionRle, defaultAdjustmentParams, describeSelection, deserializeSelection, distanceTransform, edgeWidth, ellipsePoints, ellipseSelection, encodeSelectionRle, evaluateAdjustmentLayers, expandCoverage, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, gaussianBlur, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, guidePlanes, guidedFilterColor, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, insertCurvePoint, invertMatrix3, invertSelection, isAdjustmentKind, isBlendMode, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSeparableBlendMode, kelvinToTemperature, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, migrateSerializedImageEditorState, modifySelection, moveCurvePoint, mulMatrix3, neutralHueRange, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeBlendMode, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, parseSelectionMode, photoFilterMatrix, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, quickMaskPixels, rangeLightness, readAdjustmentControls, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, resizeSelection, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeSelection, setControlPath, setLum, shiftCoverage, smoothCoverage, srgb8ToLab, srgbToLinear, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, toneRange, unprojectCanvasPoint, updateLayerMaskProps, uvToXy, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, xyToTempTint, xyToUv };
@@ -1640,6 +1640,9 @@ interface ImageEditorToolProviderOptions {
1640
1640
  * - `render_preview {maxSide}`: the rendered image as a PNG, longest side at most `maxSide`.
1641
1641
  * - Selections and masks: `get_selection`, `select_region`, `select_by_color`, `modify_selection`,
1642
1642
  * `refine_selection`, `apply_selection_as_mask` (see `createImageSelectionTools`).
1643
+ * - Layers, geometry and history: `get_image_info`, `get_histogram`, `update_adjustment_layer`,
1644
+ * `remove_adjustment_layer`, `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`,
1645
+ * `flip_image`, `undo_image`, `redo_image` (see `createImageEditTools`).
1643
1646
  */
1644
1647
  declare function createImageEditorToolProvider(controller: ImageEditorController, options?: ImageEditorToolProviderOptions): AgentToolProvider;
1645
1648
 
@@ -1768,6 +1771,14 @@ declare class SelectionGesture {
1768
1771
  */
1769
1772
  declare function createImageSelectionTools(controller: ImageEditorController): AgentTool[];
1770
1773
 
1774
+ /**
1775
+ * Agent tools for the image editor's layers, geometry and history: `get_image_info`,
1776
+ * `get_histogram`, `update_adjustment_layer`, `remove_adjustment_layer`,
1777
+ * `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`, `flip_image`,
1778
+ * `undo_image` and `redo_image`. Each write is one undo step and returns what changed.
1779
+ */
1780
+ declare function createImageEditTools(controller: ImageEditorController): AgentTool[];
1781
+
1771
1782
  /**
1772
1783
  * Region-based mosaic (pixelation) and box-blur filters for redacting or anonymizing
1773
1784
  * rectangular bounding boxes on an ImageData-like buffer.
@@ -1809,4 +1820,4 @@ declare function applyRegionMosaic<T extends MosaicImageDataLike>(imageData: T,
1809
1820
  */
1810
1821
  declare function applyRegionBlur<T extends MosaicImageDataLike>(imageData: T, regions: MosaicRegion[], radius?: number): T;
1811
1822
 
1812
- export { ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationType, type ArrowAnnotation, type AspectRatio, BLEND_MODES, type BaseAnnotation, type BlackWhiteParams, type BlendMode, type BlendModeInfo, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DIRECT_GAUSSIAN_MAX_SIGMA, type DepthMaskOptions, EMPTY_DISTANCE, type ExportOptions, GUIDED_FILTER_EPS, type GestureModifiers, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, type HueRange, type HueSaturationParams, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_SCHEMA_VERSION, IMAGE_EDITOR_STATE_VERSION, type ImageAdjustments, type ImageAnnotation, type ImageDimensions, type ImageEditorAIHooks, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerMaskProps, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelOp, type PosterizeParams, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RectAnnotation, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type Rgb$1 as Rgb, type Rgba, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializedImageEditorState, type SerializedSelection, type ShapeSelectionOptions, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, activeAdjustmentLayers, adjustmentKindLabel, adjustmentLayersKey, applyAdjustmentLayers, applyAdjustments, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, blackWhiteGray, blendChannel, blendImageData, blendLum, blendPixel, blendRgb, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasCompositeOperation, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, createAdjustmentLayer, createImageEditorToolProvider, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerMask, decodeSelectionRle, defaultAdjustmentParams, describeSelection, deserializeSelection, distanceTransform, edgeWidth, ellipsePoints, ellipseSelection, encodeSelectionRle, evaluateAdjustmentLayers, expandCoverage, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, gaussianBlur, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, guidePlanes, guidedFilterColor, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, insertCurvePoint, invertMatrix3, invertSelection, isAdjustmentKind, isBlendMode, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSeparableBlendMode, kelvinToTemperature, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, migrateSerializedImageEditorState, modifySelection, moveCurvePoint, mulMatrix3, neutralHueRange, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeBlendMode, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, parseSelectionMode, photoFilterMatrix, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, quickMaskPixels, rangeLightness, readAdjustmentControls, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, resizeSelection, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeSelection, setControlPath, setLum, shiftCoverage, smoothCoverage, srgb8ToLab, srgbToLinear, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, toneRange, unprojectCanvasPoint, updateLayerMaskProps, uvToXy, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, xyToTempTint, xyToUv };
1823
+ export { ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationType, type ArrowAnnotation, type AspectRatio, BLEND_MODES, type BaseAnnotation, type BlackWhiteParams, type BlendMode, type BlendModeInfo, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DIRECT_GAUSSIAN_MAX_SIGMA, type DepthMaskOptions, EMPTY_DISTANCE, type ExportOptions, GUIDED_FILTER_EPS, type GestureModifiers, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, type HueRange, type HueSaturationParams, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_SCHEMA_VERSION, IMAGE_EDITOR_STATE_VERSION, type ImageAdjustments, type ImageAnnotation, type ImageDimensions, type ImageEditorAIHooks, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerMaskProps, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelOp, type PosterizeParams, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RectAnnotation, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type Rgb$1 as Rgb, type Rgba, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializedImageEditorState, type SerializedSelection, type ShapeSelectionOptions, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, activeAdjustmentLayers, adjustmentKindLabel, adjustmentLayersKey, applyAdjustmentLayers, applyAdjustments, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, blackWhiteGray, blendChannel, blendImageData, blendLum, blendPixel, blendRgb, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasCompositeOperation, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, createAdjustmentLayer, createImageEditTools, createImageEditorToolProvider, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerMask, decodeSelectionRle, defaultAdjustmentParams, describeSelection, deserializeSelection, distanceTransform, edgeWidth, ellipsePoints, ellipseSelection, encodeSelectionRle, evaluateAdjustmentLayers, expandCoverage, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, gaussianBlur, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, guidePlanes, guidedFilterColor, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, insertCurvePoint, invertMatrix3, invertSelection, isAdjustmentKind, isBlendMode, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSeparableBlendMode, kelvinToTemperature, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, migrateSerializedImageEditorState, modifySelection, moveCurvePoint, mulMatrix3, neutralHueRange, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeBlendMode, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, parseSelectionMode, photoFilterMatrix, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, quickMaskPixels, rangeLightness, readAdjustmentControls, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, resizeSelection, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeSelection, setControlPath, setLum, shiftCoverage, smoothCoverage, srgb8ToLab, srgbToLinear, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, toneRange, unprojectCanvasPoint, updateLayerMaskProps, uvToXy, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, xyToTempTint, xyToUv };
@@ -5357,6 +5357,261 @@ function createImageSelectionTools(controller) {
5357
5357
  return [getSelection, selectRegion, selectByColor, modify, refine, applyMask];
5358
5358
  }
5359
5359
 
5360
+ // src/image-editor/edit-tools.ts
5361
+ var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
5362
+ var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
5363
+ var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
5364
+ var LAYER_ID = { type: "string", description: 'Adjustment layer id from get_adjustments (e.g. "adj_1").' };
5365
+ var round = (n, digits = 2) => Math.round(n * 10 ** digits) / 10 ** digits;
5366
+ function binStats(bins, samples) {
5367
+ if (!samples) return { mean: null, p1: null, p99: null };
5368
+ let sum = 0;
5369
+ let seen = 0;
5370
+ let p1 = null;
5371
+ let p99 = null;
5372
+ for (let i = 0; i < bins.length; i++) {
5373
+ sum += i * bins[i];
5374
+ seen += bins[i];
5375
+ if (p1 === null && seen >= samples * 0.01) p1 = i;
5376
+ if (p99 === null && seen >= samples * 0.99) p99 = i;
5377
+ }
5378
+ return { mean: round(sum / samples, 1), p1, p99 };
5379
+ }
5380
+ function rebin(bins, count) {
5381
+ const out = new Array(count).fill(0);
5382
+ const width = bins.length / count;
5383
+ for (let i = 0; i < bins.length; i++) out[Math.floor(i / width)] += bins[i];
5384
+ return out;
5385
+ }
5386
+ function histogramSummary(h, bins) {
5387
+ const pct = (n) => h.samples ? round(n / h.samples * 100) : 0;
5388
+ const channels = { red: h.red, green: h.green, blue: h.blue, luminance: h.luminance };
5389
+ return {
5390
+ samples: h.samples,
5391
+ transparent: h.transparent,
5392
+ clipping: {
5393
+ shadowsPercent: { red: pct(h.shadows[0]), green: pct(h.shadows[1]), blue: pct(h.shadows[2]) },
5394
+ highlightsPercent: { red: pct(h.highlights[0]), green: pct(h.highlights[1]), blue: pct(h.highlights[2]) }
5395
+ },
5396
+ stats: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, binStats(v, h.samples)])),
5397
+ ...bins ? { bins: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, rebin(v, bins)])) } : {}
5398
+ };
5399
+ }
5400
+ function createImageEditTools(controller) {
5401
+ const layerOrThrow = (id) => {
5402
+ const layers = controller.getAdjustmentLayers();
5403
+ const index = layers.findIndex((l) => l.id === id);
5404
+ if (index === -1) {
5405
+ const ids = layers.map((l) => l.id);
5406
+ throw new Error(`Unknown adjustment layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "There are no adjustment layers."}`);
5407
+ }
5408
+ return { layer: layers[index], index };
5409
+ };
5410
+ const layerJson = (id) => JSON.parse(JSON.stringify(controller.getAdjustmentLayer(id)));
5411
+ const geometry = () => {
5412
+ const s = controller.getState();
5413
+ const region = s.crop ?? { x: 0, y: 0, ...s.imageDimensions };
5414
+ const out = getRotatedSize(region.width, region.height, s.transform);
5415
+ return {
5416
+ image: { ...s.imageDimensions },
5417
+ crop: s.crop ? { ...s.crop } : null,
5418
+ rotation: normalizeAngle(s.transform.rotate),
5419
+ flipH: s.transform.flipH,
5420
+ flipV: s.transform.flipV,
5421
+ output: { width: Math.round(out.width), height: Math.round(out.height) }
5422
+ };
5423
+ };
5424
+ const history = () => ({ canUndo: controller.canUndo, canRedo: controller.canRedo });
5425
+ const requireImage = () => {
5426
+ const { width, height } = controller.getState().imageDimensions;
5427
+ if (!width || !height) throw new Error("No image is loaded. Ask the user to open one first.");
5428
+ return { width, height };
5429
+ };
5430
+ const getImageInfo = {
5431
+ name: "get_image_info",
5432
+ title: "Read image geometry",
5433
+ description: "Returns the source image size in pixels, the crop box (natural image pixels, or null for the whole image), rotation in degrees, flips, the output size after crop and rotation, the number of adjustment layers and whether undo / redo are available.",
5434
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
5435
+ annotations: { title: "Read image geometry", ...READ },
5436
+ handler: () => ({ ...geometry(), layers: controller.getAdjustmentLayers().length, ...history() })
5437
+ };
5438
+ const getHistogram = {
5439
+ name: "get_histogram",
5440
+ title: "Read the histogram",
5441
+ description: "Returns the histogram of the last rendered preview (after adjustments and layers): per channel and luminance mean and 1st / 99th percentiles (0-255), and the percentage of pixels clipped to pure black or white per channel. Use it to judge exposure and clipping numerically. Pass bins for the counts themselves. Fails before the first render: call render_preview first.",
5442
+ inputSchema: {
5443
+ type: "object",
5444
+ properties: {
5445
+ bins: { type: "integer", enum: [16, 32, 64, 256], description: "Also return the counts in this many buckets per channel (default: no counts)." }
5446
+ },
5447
+ additionalProperties: false
5448
+ },
5449
+ annotations: { title: "Read the histogram", ...READ },
5450
+ handler: ({ bins }) => {
5451
+ const h = controller.getHistogram();
5452
+ if (!h) throw new Error("No histogram yet: it comes from the rendered preview. Call render_preview, then try again.");
5453
+ return histogramSummary(h, bins);
5454
+ }
5455
+ };
5456
+ const updateLayer = {
5457
+ name: "update_adjustment_layer",
5458
+ title: "Change an adjustment layer",
5459
+ description: 'Shows or hides a layer, renames it, or changes its blend mode or opacity, as one undo step. Change its parameters with set_adjustments ("layers.<id>.<control>"). Returns the updated layer.',
5460
+ inputSchema: {
5461
+ type: "object",
5462
+ properties: {
5463
+ layer: LAYER_ID,
5464
+ enabled: { type: "boolean", description: "false hides the layer without deleting it." },
5465
+ blend: { type: "string", enum: BLEND_MODES.map((m) => m.id), description: "Blend mode (see list_controls)." },
5466
+ opacity: { type: "number", minimum: 0, maximum: 1, description: "Layer opacity 0-1." },
5467
+ name: { type: "string", description: "Layer name shown in the layers panel." }
5468
+ },
5469
+ required: ["layer"],
5470
+ additionalProperties: false
5471
+ },
5472
+ annotations: { title: "Change an adjustment layer", ...WRITE_IDEMPOTENT },
5473
+ handler: ({ layer, enabled, blend, opacity, name }) => {
5474
+ layerOrThrow(layer);
5475
+ if (enabled === void 0 && blend === void 0 && opacity === void 0 && name === void 0) {
5476
+ throw new Error("Nothing to change. Pass enabled, blend, opacity or name.");
5477
+ }
5478
+ if (blend !== void 0 && !isBlendMode(blend)) throw new Error(`Unknown blend mode "${blend}".`);
5479
+ controller.updateAdjustmentLayer(layer, { enabled, blend, opacity, name });
5480
+ return { layer: layerJson(layer) };
5481
+ }
5482
+ };
5483
+ const removeLayer = {
5484
+ name: "remove_adjustment_layer",
5485
+ title: "Delete an adjustment layer",
5486
+ description: "Deletes an adjustment layer and its mask as one undo step. To hide it instead, use update_adjustment_layer with enabled false. Returns the remaining layer ids, bottom to top.",
5487
+ inputSchema: { type: "object", properties: { layer: LAYER_ID }, required: ["layer"], additionalProperties: false },
5488
+ annotations: { title: "Delete an adjustment layer", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
5489
+ handler: ({ layer }) => {
5490
+ layerOrThrow(layer);
5491
+ controller.removeAdjustmentLayer(layer);
5492
+ return { removed: layer, layers: controller.getAdjustmentLayers().map((l) => l.id) };
5493
+ }
5494
+ };
5495
+ const moveLayer = {
5496
+ name: "move_adjustment_layer",
5497
+ title: "Reorder an adjustment layer",
5498
+ description: "Moves an adjustment layer to a position in the stack (0 = bottom, applied first) as one undo step. Layers apply bottom to top, so order changes the result. Returns the layer ids, bottom to top.",
5499
+ inputSchema: {
5500
+ type: "object",
5501
+ properties: {
5502
+ layer: LAYER_ID,
5503
+ to: { type: "integer", minimum: 0, description: "New index, 0 = bottom; past the top means the top." }
5504
+ },
5505
+ required: ["layer", "to"],
5506
+ additionalProperties: false
5507
+ },
5508
+ annotations: { title: "Reorder an adjustment layer", ...WRITE_IDEMPOTENT },
5509
+ handler: ({ layer, to }) => {
5510
+ const { index } = layerOrThrow(layer);
5511
+ const top = controller.getAdjustmentLayers().length - 1;
5512
+ const target = Math.min(to, top);
5513
+ if (target === index) throw new Error(`Layer "${layer}" is already at index ${index} (0 = bottom, ${top} = top).`);
5514
+ controller.moveAdjustmentLayer(layer, target);
5515
+ return { layer, index: target, layers: controller.getAdjustmentLayers().map((l) => l.id) };
5516
+ }
5517
+ };
5518
+ const setCrop = {
5519
+ name: "set_crop",
5520
+ title: "Crop the image",
5521
+ description: "Sets the crop box in natural image pixels of the un-rotated source (origin top-left; see get_image_info for the size) as one undo step. Non-destructive: reset_crop restores the whole image. Returns the new geometry and output size.",
5522
+ inputSchema: {
5523
+ type: "object",
5524
+ properties: {
5525
+ x: { type: "number", minimum: 0, description: "Left edge in source pixels." },
5526
+ y: { type: "number", minimum: 0, description: "Top edge in source pixels." },
5527
+ width: { type: "number", exclusiveMinimum: 0, description: "Width in source pixels." },
5528
+ height: { type: "number", exclusiveMinimum: 0, description: "Height in source pixels." }
5529
+ },
5530
+ required: ["x", "y", "width", "height"],
5531
+ additionalProperties: false
5532
+ },
5533
+ annotations: { title: "Crop the image", ...WRITE_IDEMPOTENT },
5534
+ handler: ({ x, y, width, height }) => {
5535
+ const image = requireImage();
5536
+ if (x + width > image.width + 0.5 || y + height > image.height + 0.5) {
5537
+ throw new Error(`The crop box (${x}, ${y}, ${width} \xD7 ${height}) goes outside the ${image.width} \xD7 ${image.height} image.`);
5538
+ }
5539
+ controller.setCrop({ x: Math.round(x), y: Math.round(y), width: Math.round(width), height: Math.round(height) });
5540
+ return geometry();
5541
+ }
5542
+ };
5543
+ const resetCrop = {
5544
+ name: "reset_crop",
5545
+ title: "Remove the crop",
5546
+ description: "Removes the crop so the whole image shows again, as one undo step. Returns the new geometry.",
5547
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
5548
+ annotations: { title: "Remove the crop", ...WRITE_IDEMPOTENT },
5549
+ handler: () => {
5550
+ if (!controller.getState().crop) throw new Error("The image is not cropped.");
5551
+ controller.resetCrop();
5552
+ return geometry();
5553
+ }
5554
+ };
5555
+ const setRotation = {
5556
+ name: "set_rotation",
5557
+ title: "Rotate the image",
5558
+ description: "Sets the image rotation in degrees clockwise, as one undo step. Quarter turns (90, 180, 270) keep every pixel; other angles straighten the image inside a larger frame with transparent corners, so crop afterwards. Returns the new geometry.",
5559
+ inputSchema: {
5560
+ type: "object",
5561
+ properties: { degrees: { type: "number", minimum: -360, maximum: 360, description: "Absolute rotation in degrees clockwise (0 = upright)." } },
5562
+ required: ["degrees"],
5563
+ additionalProperties: false
5564
+ },
5565
+ annotations: { title: "Rotate the image", ...WRITE_IDEMPOTENT },
5566
+ handler: ({ degrees }) => {
5567
+ requireImage();
5568
+ controller.setRotation(degrees);
5569
+ return geometry();
5570
+ }
5571
+ };
5572
+ const flipImage = {
5573
+ name: "flip_image",
5574
+ title: "Flip the image",
5575
+ description: "Mirrors the image horizontally (left-right) or vertically (top-bottom), as one undo step. Flipping twice restores it. Returns the new geometry.",
5576
+ inputSchema: {
5577
+ type: "object",
5578
+ properties: { axis: { type: "string", enum: ["horizontal", "vertical"], description: "horizontal mirrors left-right; vertical mirrors top-bottom." } },
5579
+ required: ["axis"],
5580
+ additionalProperties: false
5581
+ },
5582
+ annotations: { title: "Flip the image", ...WRITE },
5583
+ handler: ({ axis }) => {
5584
+ requireImage();
5585
+ if (axis === "horizontal") controller.flipHorizontal();
5586
+ else controller.flipVertical();
5587
+ return geometry();
5588
+ }
5589
+ };
5590
+ const undo = {
5591
+ name: "undo_image",
5592
+ title: "Undo an image edit",
5593
+ description: "Undoes the last image edit (one tool call is one step). Returns whether undo and redo are still available.",
5594
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
5595
+ annotations: { title: "Undo an image edit", ...WRITE },
5596
+ handler: () => {
5597
+ if (!controller.undo()) throw new Error("Nothing to undo.");
5598
+ return history();
5599
+ }
5600
+ };
5601
+ const redo = {
5602
+ name: "redo_image",
5603
+ title: "Redo an image edit",
5604
+ description: "Redoes the last undone image edit. Returns whether undo and redo are still available.",
5605
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
5606
+ annotations: { title: "Redo an image edit", ...WRITE },
5607
+ handler: () => {
5608
+ if (!controller.redo()) throw new Error("Nothing to redo.");
5609
+ return history();
5610
+ }
5611
+ };
5612
+ return [getImageInfo, getHistogram, updateLayer, removeLayer, moveLayer, setCrop, resetCrop, setRotation, flipImage, undo, redo];
5613
+ }
5614
+
5360
5615
  // src/image-editor/tools.ts
5361
5616
  var LAYER_PATH = /^layers\.([^.]+)\.(.+)$/;
5362
5617
  function adjustmentsSummary(adjustments) {
@@ -5574,7 +5829,15 @@ function createImageEditorToolProvider(controller, options = {}) {
5574
5829
  return {
5575
5830
  id: options.id ?? "image-editor",
5576
5831
  namespace: options.namespace,
5577
- tools: [getAdjustments, listControls, setAdjustments, addLayer, renderPreview, ...createImageSelectionTools(controller)]
5832
+ tools: [
5833
+ getAdjustments,
5834
+ listControls,
5835
+ setAdjustments,
5836
+ addLayer,
5837
+ renderPreview,
5838
+ ...createImageSelectionTools(controller),
5839
+ ...createImageEditTools(controller)
5840
+ ]
5578
5841
  };
5579
5842
  }
5580
5843
 
@@ -5950,6 +6213,7 @@ export {
5950
6213
  controlTrackBackground,
5951
6214
  coverageToByte,
5952
6215
  createAdjustmentLayer,
6216
+ createImageEditTools,
5953
6217
  createImageEditorToolProvider,
5954
6218
  createImageSelectionTools,
5955
6219
  createSelectionMask,