134 lines
5.3 KiB
TypeScript
134 lines
5.3 KiB
TypeScript
/**
|
|
* Gemini function declarations for the design agent.
|
|
* These map to Scribus bridge commands executed via the Python bridge server.
|
|
*/
|
|
|
|
export const DESIGN_TOOL_DECLARATIONS = [
|
|
{
|
|
name: "new_document",
|
|
description: "Create a new Scribus document with specified dimensions and margins.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
width: { type: "number", description: "Document width in mm (default: 210 for A4)" },
|
|
height: { type: "number", description: "Document height in mm (default: 297 for A4)" },
|
|
margins: { type: "number", description: "Page margins in mm (default: 10)" },
|
|
pages: { type: "integer", description: "Number of pages (default: 1)" },
|
|
},
|
|
required: [],
|
|
},
|
|
},
|
|
{
|
|
name: "add_text_frame",
|
|
description: "Add a text frame to the page at the specified position. Coordinates and dimensions in mm from top-left.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
x: { type: "number", description: "X position in mm from left edge" },
|
|
y: { type: "number", description: "Y position in mm from top edge" },
|
|
width: { type: "number", description: "Frame width in mm" },
|
|
height: { type: "number", description: "Frame height in mm" },
|
|
text: { type: "string", description: "Text content for the frame" },
|
|
fontSize: { type: "number", description: "Font size in points (default: 12)" },
|
|
fontName: { type: "string", description: "Font name. Safe fonts: Liberation Sans, Liberation Serif, DejaVu Sans" },
|
|
name: { type: "string", description: "Optional frame name for later reference" },
|
|
},
|
|
required: ["x", "y", "width", "height"],
|
|
},
|
|
},
|
|
{
|
|
name: "add_image_frame",
|
|
description: "Add an image frame to the page. If imagePath is provided, the image will be loaded into the frame.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
x: { type: "number", description: "X position in mm from left edge" },
|
|
y: { type: "number", description: "Y position in mm from top edge" },
|
|
width: { type: "number", description: "Frame width in mm" },
|
|
height: { type: "number", description: "Frame height in mm" },
|
|
imagePath: { type: "string", description: "Path to image file to load into frame" },
|
|
name: { type: "string", description: "Optional frame name for later reference" },
|
|
},
|
|
required: ["x", "y", "width", "height"],
|
|
},
|
|
},
|
|
{
|
|
name: "add_shape",
|
|
description: "Add a geometric shape (rectangle or ellipse) to the page.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
shapeType: { type: "string", description: "Shape type: 'rect' or 'ellipse'", enum: ["rect", "ellipse"] },
|
|
x: { type: "number", description: "X position in mm from left edge" },
|
|
y: { type: "number", description: "Y position in mm from top edge" },
|
|
width: { type: "number", description: "Shape width in mm" },
|
|
height: { type: "number", description: "Shape height in mm" },
|
|
fill: { type: "string", description: "Fill color as hex string (e.g. '#ff6600')" },
|
|
name: { type: "string", description: "Optional shape name for later reference" },
|
|
},
|
|
required: ["x", "y", "width", "height"],
|
|
},
|
|
},
|
|
{
|
|
name: "set_background_color",
|
|
description: "Set the page background color by creating a full-page rectangle.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
color: { type: "string", description: "Background color as hex string (e.g. '#1a1a2e')" },
|
|
},
|
|
required: ["color"],
|
|
},
|
|
},
|
|
{
|
|
name: "get_state",
|
|
description: "Get the current document state including all pages and frames. Use this to verify layout after making changes.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {},
|
|
required: [],
|
|
},
|
|
},
|
|
{
|
|
name: "save_document",
|
|
description: "Save the current document as a .sla file.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
space: { type: "string", description: "Space slug for the save directory" },
|
|
filename: { type: "string", description: "Filename for the .sla file" },
|
|
},
|
|
required: ["filename"],
|
|
},
|
|
},
|
|
{
|
|
name: "generate_image",
|
|
description: "Generate an AI image from a text prompt using fal.ai and place it in an image frame on the page.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: {
|
|
prompt: { type: "string", description: "Text prompt describing the image to generate" },
|
|
x: { type: "number", description: "X position for the image frame in mm" },
|
|
y: { type: "number", description: "Y position for the image frame in mm" },
|
|
width: { type: "number", description: "Image frame width in mm" },
|
|
height: { type: "number", description: "Image frame height in mm" },
|
|
},
|
|
required: ["prompt", "x", "y", "width", "height"],
|
|
},
|
|
},
|
|
];
|
|
|
|
export type DesignToolName = (typeof DESIGN_TOOL_DECLARATIONS)[number]["name"];
|
|
|
|
export const DESIGN_SYSTEM_PROMPT = `You are a professional graphic designer using Scribus DTP software. Given a design brief:
|
|
1. Create a document with appropriate dimensions
|
|
2. Establish visual hierarchy with text frames (heading > subheading > body)
|
|
3. Place image frames for visual elements
|
|
4. Add geometric shapes for structure and decoration
|
|
5. Verify layout with get_state
|
|
6. Save the document
|
|
|
|
Coordinates are in mm from top-left. Safe fonts: Liberation Sans, Liberation Serif, DejaVu Sans.
|
|
Minimum margins: 10mm. Standard sizes: A4 (210x297), A5 (148x210), Letter (216x279).
|
|
Always create the document first before adding frames.`;
|