import { HybridArtEngine } from "@nexustools/hacanvas";
const engine = new HybridArtEngine(projectRootDir);createCanvas(canvasId, width?, height?, backgroundColor?, dpiOrLayers?): ArtCanvasStateCreates a new hybrid canvas with the specified dimensions and initial raster/vector layers.hasCanvas(canvasId): booleanReturnstrueifcanvasIdexists on disk.loadCanvas(canvasId): ArtCanvasStateLoads and returns the currentArtCanvasStateforcanvasId.deleteCanvas(canvasId): voidDeletes the canvas working directory and clears its undo/redo stacks.saveCanvas(canvasId, filePath): { filePath, format: "hacanvas", bytesWritten, sharedObjectCount, layerCount }Serializes the canvas, attached filters, embedded fonts, metadata, and all Shared Objects into a.hacanvasZIP+XML archive.loadFromFile(canvasId, filePath, options?): ImportResultLoads or imports.hacanvas,.psd,.xcf,.ai,.pdf,.svg,.ora,.png,.jpg,.webp,.tiff,.gif,.bmp,.tga,.pcx,.ico,.cur,.ppm, or.ffintocanvasId.exportCanvas(canvasId, filePath, format?, options?): ExportResultExports the composited canvas or animation to any of the 18 supported formats (hacanvas,png,jpg,jpeg,webp,tiff,pdf,svg,gif,ora,bmp,tga,pcx,ico,cur,ppm,farbfeld,sprite_sheet). Automatically renders all enabled dynamic attached filters (forExport: true) and selectively rasterizes filtered objects/layers in.svgand.pdfexports.
inspectScene(canvasId): Record<string, any>Returns complete scene graph metadata including canvas dimensions, DPI,previewDynamicFilters,layers(with vector objects,attachedFiltersenriched with resolvedsettings¶meterSchemas,filtersEnabled, andrasterBounds),sharedObjects(with reference counts,attachedFilters, andobjectCache), andanimation(enriched viainspectAnimationTimeline).inspectAnimationTimeline(canvasId, options?): Record<string, any>Returns full animation timeline details for the Main Canvas or a Shared Object:fps,durationFrames,loop,loopBackToFrame,tracks(each keyframe segment enriched witheasing,curvePresetId,curvePresetName, resolved[x1, y1, x2, y2]curveControlPoints, andrasterTransitiondetails includingblendPresetId,blendPresetName,category,targetLayerId,targetFrame,hasCustomCode,customCode),targetFrameRanges, and available curve & raster transition preset catalogs.inspectVectorObjectNodes(canvasId, objectId, sharedObjectId?): { objectId, kind, closed, vertices, segments, d }Returns all editable vertices ({ index, x, y }) and segments ({ segmentIndex, fromIndex, toIndex, p0, p1, curved, cx, cy }) for any vector shape or line.inspectPixels(canvasId, x, y, width?, height?, frame?): Record<string, any>Samples exact RGBA/hex pixel values at(x, y)or computes a color histogram and average RGBA over(x, y, width, height).takeSnapshot(options: SnapshotOptions): SnapshotResultRenders a PNG snapshot (canvas,layer,object,shared_object,region, orcontact_sheet) with optional grid overlay, bounding box highlights, onion-skinning, and filter preview controls.
undo(canvasId): { undone: boolean; label?: string; state: ArtCanvasState }redo(canvasId): { redone: boolean; label?: string; state: ArtCanvasState }canUndo(canvasId): boolean/canRedo(canvasId): booleangetUndoHistory(canvasId): { undoList: Array<{ id, label, timestamp }>; redoList: Array<{ id, label, timestamp }>; currentLabel: string }jumpToHistoryState(canvasId, targetStepsDelta): ArtCanvasStateclearUndoHistory(canvasId): void/resetUndoHistory(canvasId, baseLabel?): voidbeginUndoGroup(canvasId, label): void/endUndoGroup(canvasId, label?): voidwithUndoGroup<T>(canvasId, label, fn): T
createLayer(canvasId, name, type, options?): ArtLayerSpecmodifyLayer(canvasId, layerId, updates): ArtLayerSpecdeleteLayer(canvasId, layerId, sharedObjectId?): voidmanageLayer(canvasId, action, opts):"add" | "remove" | "duplicate" | "reorder" | "set_visibility" | "set_opacity" | "set_blend_mode" | "clear"mergeLayerDown(canvasId, layerId, sharedObjectId?): ArtLayerSpecmergeVisibleLayers(canvasId, sharedObjectId?): ArtLayerSpecflattenImage(canvasId): ArtLayerSpecnewLayerFromVisible(canvasId, sharedObjectId?): ArtLayerSpectransformLayer(canvasId, layerId, op, sharedObjectId?):"flip_h" | "flip_v" | "rotate_90_cw" | "rotate_90_ccw" | "rotate_180"offsetLayer(canvasId, layerId, dx, dy, wrapAround?, sharedObjectId?): ArtLayerSpectransformCanvas(canvasId, op):"flip_h" | "flip_v" | "rotate_90_cw" | "rotate_90_ccw" | "rotate_180"scaleCanvas(canvasId, newWidth, newHeight): ArtCanvasStateresizeCanvas(canvasId, newWidth, newHeight, offsetX?, offsetY?, backgroundColor?): ArtCanvasStatecropCanvasToSelection(canvasId): ArtCanvasState/cropCanvasToContent(canvasId): ArtCanvasState
drawShape(canvasId, layerId, spec): VectorObjectSpecDrawsrect,circle,ellipse,polygon,star, orline.drawPath(canvasId, layerId, spec): VectorObjectSpecDraws a polyline, polygon, or cubic/quadratic Bezier path (dorpoints).drawText(canvasId, layerId, spec): VectorObjectSpecPlaces a vector<text>node withfontFamily,fontSize,fill,stroke.modifyObject(canvasId, objectId, updates): VectorObjectSpecUpdates coordinates, dimensions, transform (rotation,scaleX,scaleY,skewX,skewY), timeline visibility (startFrame,endFrame), or style (fill,stroke,strokeWidth,opacity,fillOverride,strokeOverride).deformVectorObject(canvasId, objectId, options): VectorObjectSpecDeforms any vector object (line,path,polygon,star,rect,circle,ellipse):mode: "bend_segment": Bends a line or segment (segmentIndex) into a quadratic Bezier curve passing through(targetX, targetY)at parametertwhile keeping endpoints fixed.mode: "move_endpoint": Moves vertex/endpointpointIndexto(targetX, targetY)while retaining existing segment curves.mode: "straighten_segment": Removes curvature fromsegmentIndex.mode: "add_vertex": SplitssegmentIndexatt(or(targetX, targetY)) and inserts a new vertex.mode: "remove_vertex": Removes vertex atpointIndex.mode: "convert_to_path": Converts a primitive shape (rect,circle,ellipse,polygon,star,line) into an editable path with explicit vertices.
pathOperation(canvasId, operation, options): VectorObjectSpecExecutes Boolean CSG ("union" | "difference" | "intersection" | "exclusion") or path geometry ("simplify" | "offset").
rasterStroke(canvasId, layerId, spec)Strokes alongpointswithtool: "brush" | "pencil" | "airbrush" | "eraser",color,size,hardness,opacity.rasterFill(canvasId, layerId, spec)ExecutesfillType: "flood" | "linear_gradient" | "radial_gradient".rasterSelection(canvasId, op, bounds?)/modifySelectionBounds(canvasId, op, amountPx)Creates or modifies selection masks ("rect" | "ellipse" | "clear" | "invert" | "feather" | "grow" | "shrink" | "border").rasterFilter(canvasId, layerId, params, frame?, sharedObjectId?)Immediately applies any of the 85+ built-in or custom JS GIMP filters to mutate a raster layer's pixel buffer in-place.attachFilter(canvasId, spec): AttachedFilterSpecAttaches a non-destructive dynamic filter totargetType: "layer" | "object" | "shared_object".updateAttachedFilter(canvasId, spec): AttachedFilterSpecUpdatesparams,enabled, or stack order (moveDirection: "up" | "down") of an attached filter.removeAttachedFilter(canvasId, spec): numberRemoves a specific attached filter (filterIdorfilterType) or clears all (clearAll: true).listAttachedFilters(canvasId, spec)Lists all attached filters on a layer, object, or shared object with resolvedsettings(merged withparameterSchemasdefaults),parameterSchemas,category,effectiveInViewport, andeffectiveOnExport.setTargetFiltersEnabled(canvasId, spec): booleanToggles dynamic filter preview on a layer, object, shared object, or globally across the canvas (targetType: "canvas").bakeLayerFilters(canvasId, layerId?, frame?, sharedObjectId?)Permanently bakes attached dynamic filters on a layer into its raster pixel buffer and clears the attached filter stack.setObjectEditing(canvasId, objectId, isEditing)/setSharedObjectEditing(canvasId, sharedObjectId, isEditing)Pauses dynamic filter rendering on an object or Shared Object while it is actively being edited in the viewport.adjustLayerColors(canvasId, layerId, op, params, sharedObjectId?)Applies"desaturate" | "sepia" | "equalize" | "white_balance" | "posterize" | "colorize" | "color_balance" | "hue_saturation" | "color_to_alpha" | "remove_alpha".
All 29 AI tools live directly in @nexustools/hacanvas (src/ai/abstract-ai-tool.ts and src/ai/lm-studio-client.ts) and are exported from the root package so any project (AICore, HAEditor, or third-party applications) can add full AI support immediately.
| # | Category | Tool Name | Description |
|---|---|---|---|
| 1 | inspect |
inspect_canvas_status |
Inspects canvas dimensions, DPI, previewDynamicFilters, active editing mode, active layer, selection, metadata, embedded fonts, undo history, and all layers with their active attachedFilters & settings. |
| 2 | inspect |
inspect_scene_graph |
Inspects the complete scene graph: all layers, vector objects, bounding boxes, raster pixel coverage, attached dynamic filters & settings, object cache stats, Shared Objects, and full animation timeline tracks/curves/transitions. |
| 3 | inspect |
inspect_layer |
Inspects a single vector or raster layer in detail, returning its objects/pixel bounds and all attachedFilters with resolved settings and parameterSchemas. |
| 4 | inspect |
inspect_animation_timeline |
Inspects the animation timeline (Main Canvas or Shared Object), returning FPS, duration, loop settings, all tracks, keyframe segments with resolved cubic-Bezier [x1, y1, x2, y2] easing curves, raster cel transitions (blendPresetId, category, targetLayerId, customCode), visibility ranges (startFrame..endFrame), and available curve & transition preset catalogs. |
| 5 | inspect |
inspect_pixels |
Samples RGBA/hex colors and histograms at (x, y) or over (x, y, width, height). |
| 6 | inspect |
inspect_shared_objects_and_library |
Lists embedded Shared Objects (objects/<id>.xml, including their attachedFilters and objectCache) and OS Shared Object Library entries. |
| 7 | inspect |
capture_canvas_snapshot |
Renders a PNG snapshot of the canvas, layer, object, Shared Object, cropped region, or animation contact sheet (with forExport and previewFilters toggles). |
| 8 | canvas |
create_new_canvas |
Creates a fresh hybrid canvas (width, height, backgroundColor). |
| 9 | canvas |
set_canvas_properties |
Updates background color, dimensions, DPI, global previewDynamicFilters, zoom, or document metadata without losing layers/objects. |
| 10 | canvas |
undo_redo_and_transform |
Executes undo/redo history navigation, whole-image geometric transforms (flip_h, flip_v, rotate_90_cw, rotate_90_ccw, rotate_180, crop_to_selection, crop_to_content, scale_image, resize_canvas), direct raster color adjustments, vector object duplication, and tool option updates. |
| 11 | layer |
create_layer |
Creates a vector or raster layer on the Main Canvas or inside a Shared Object. |
| 12 | layer |
modify_layer |
Updates layer name, visibility, lock, opacity, blend mode, z-order, filtersEnabled, startFrame/endFrame, or runs duplicate, clear, delete, merge_down, merge_visible, flatten, new_from_visible, or transform (flip_h, flip_v, rotate_90_cw, rotate_90_ccw, rotate_180, offset). |
| 13 | vector |
draw_vector_shape |
Draws rect, circle, ellipse, polygon, star, or line shapes. |
| 14 | vector |
draw_bezier_path |
Draws an SVG Bezier/polygon path (d string or points array). |
| 15 | vector |
draw_text |
Draws a vector text element. |
| 16 | vector |
modify_vector_object |
Updates or deletes any vector object or <ObjectRef> instance by ID (x, y, width, height, r, rx, ry, fill, stroke, scaleX, scaleY, rotation, skewX, skewY, startFrame, endFrame). |
| 17 | vector |
deform_vector_object |
Deforms or inspects nodes on any vector object (line, path, polygon, star, rect, circle, ellipse) via bend_segment, move_endpoint, straighten_segment, add_vertex, remove_vertex, convert_to_path, or inspect_nodes. |
| 18 | vector |
boolean_path_operation |
Runs union, difference, intersection, exclusion, offset, or simplify. |
| 19 | raster |
select_region |
Creates, modifies, inverts, or clears a selection mask (rect, ellipse, invert, clear, all, feather, grow, shrink, border, by_color, from_alpha). |
| 20 | raster |
paint_raster_stroke |
Paints brush, pencil, airbrush, or eraser strokes along {x, y} points. |
| 21 | raster |
raster_fill |
Applies flood, linear_gradient, or radial_gradient fills. |
| 22 | filter |
apply_gimp_filter |
Applies any of the 85+ GIMP filters immediately (mode: "immediate") or manages dynamic non-destructive filters (`mode: "attach" |
| 23 | filter |
configure_gimp_filter_preset |
Lists, inspects JS source code, validates, creates/saves, deletes, or applies categorized JavaScript GIMP filter presets and internal helper docs (helpers.*, gimp.*, gegl.*). |
| 24 | shared_object |
create_shared_object |
Creates a reusable Shared Object sub-canvas (objects/<id>.xml) and optional <ObjectRef>. |
| 25 | shared_object |
manage_shared_object |
Instantiates <ObjectRef>, renames, duplicates, deletes, or switches In-Place / Isolated Tab editing modes. |
| 26 | library |
manage_library |
Saves, imports, or deletes .haso packages in the persistent OS Shared Object Library. |
| 27 | animation |
configure_timeline |
Configures fps, totalFrames, loop, loopBackToFrame, currentFrame, onionSkin, and target startFrame..endFrame visibility spans. |
| 28 | animation |
set_animation_keyframe |
Adds, updates, moves, or removes property keyframes with preset or custom cubic-Bezier ([x1, y1, x2, y2]) easing curves. |
| 29 | animation |
configure_animation_curve |
Lists, creates/saves, deletes, or applies cubic-Bezier movement/interpolation curve presets. |
| 30* | animation |
configure_raster_keyframe_blend |
Manages raster cel keyframes, cross-layer blending, and 27+ built-in/custom JavaScript raster transition blend presets. |
| 31* | file |
open_or_import_file |
Opens or imports .hacanvas, .ai, .pdf, .psd, .xcf, .ora, .svg, .png, .jpg, .webp, .tiff, .gif, .bmp, .tga, .ico, .cur, etc. |
| 32* | file |
save_or_export_artwork |
Saves .hacanvas or exports to any of the 18 supported formats with quality, compression, DPI, metadata, and font embedding options. |
| 33* | file |
manage_metadata_and_fonts |
Inspects, sets, or clears document EXIF/GPS/custom metadata and embeds, exports, or removes .ttf/.otf/.woff/.woff2 fonts. |
(All 33 tools are registered in HaCanvasAiToolRegistry.getAllTools()).