Skip to content

Open source CapCut alternative.

TypeScript
7.5 KB
Raw Blame
/**
 * The assistant's side-panel tools — opening and collapsing the tabs, the
 * Media panel's filing and trash, and the Details tab's publish metadata —
 * kept beside the side panel that hosts those views
 * (`MediaPanel` and `PublishPanel` live inside it). The catalog spreads this
 * list into the model's toolset and `aiTools.ts` keys its handlers on
 * `SidePanelToolName`.
 */

import { num, obj, str, type AiToolDef } from "@/cut/lib/aiToolDef";
import { CONVERT_MODES } from "@/cut/lib/convertMode";
import { SIDE_PANEL_TABS } from "@/cut/lib/types";

export const SIDE_PANEL_TOOLS = [
  {
    name: "set_side_panel",
    description:
      "Open a side-panel tab, or collapse the panel to the icon rail with 'none' so the preview canvas takes the freed width — use 'none' when the user asks to clean up or maximize the workspace. 'publish' is the Details tab; 'media' holds the project's files and the shared Library.",
    inputSchema: obj({
      panel: {
        type: "string",
        enum: [...SIDE_PANEL_TABS, "none"],
        description: "Tab to open, or 'none' to collapse the panel",
      },
    }, ["panel"]),
  },
  {
    name: "file_asset",
    description:
      "File a project asset where the user keeps things: to \"media\" moves created media (generated, chat, voiceover…) into the Media panel by clearing its origin tag; to \"library\" copies any project asset into the shared Library for reuse. The same moves as each card's \"…\" menu — make them when the user asks.",
    inputSchema: obj({
      asset_id: str("Project asset id from `media`"),
      to: { type: "string", enum: ["media", "library"], description: "Destination" },
    }, ["asset_id", "to"]),
  },
  {
    name: "convert_media",
    description:
      "Convert project media to MP4 — H.264 picture, AAC sound — replacing each asset's file in place, so clips already cut from it keep playing. This is the fix for footage that previews black or refuses to play: a phone's HEVC .mov, a screen recorder's ProRes, a camera file with raw PCM sound. It is also the whole answer to \"turn these into mp4\": the user drops the files on this chat, you convert them, and each converted file is on its own card right here for them to download or drag in — nothing to go looking for. A file already in Media stays in Media. Streams that already fit the container are copied packet for packet, so a .mov of H.264 converts in seconds and loses nothing, and a file that is already an MP4 of those streams comes back untouched. `mode` \"reencode\" rewrites the picture even when it fits: the fix for H.264 that stays black after a plain conversion. `max_height` shrinks the picture at the same time (1080 for a 4K source that only needs to be a timeline clip). Conversion runs automatically through the project backend. A browser missing a required codec uses hosted preparation and saves the result back into its own project.",
    inputSchema: obj({
      asset_ids: {
        type: "array",
        items: { type: "string" },
        description: "Project asset ids from `media`, converted in order",
      },
      max_height: num("Cap the output height in pixels (e.g. 1080); omit to keep the source size"),
      mode: {
        type: "string",
        enum: [...CONVERT_MODES],
        description: "fit (default) copies streams that already fit; reencode rewrites the picture from what the converter decodes",
      },
    }, ["asset_ids"]),
  },
  {
    name: "media_organize",
    description:
      "Organize the Media panel's Project Files with folders (this project only; the shared Library has library_organize): create_folder / rename_folder / delete_folder (permanent: every file in the folder is removed from the project, and the timeline clips made from them go too), move_asset files user-imported media into a folder (omit folder_id for the top level), rename_asset renames any project asset. Folders and each asset's folderId are in `media` / `mediaFolders` from get_state. create_folder can take asset_ids to file into the new folder in the same call.",
    inputSchema: obj({
      action: {
        type: "string",
        enum: ["create_folder", "rename_folder", "delete_folder", "move_asset", "rename_asset"],
        description: "The organize operation",
      },
      name: str("New name (create_folder, rename_folder, rename_asset)"),
      asset_id: str("Project asset id from `media` (rename_asset)"),
      folder_id: str("Media folder id (rename_folder, delete_folder, move_asset destination — omit for the top level)"),
      asset_ids: {
        type: "array",
        items: { type: "string" },
        description: "Project asset ids to file (move_asset; optional on create_folder)",
      },
    }, ["action"]),
  },
  {
    name: "delete_asset",
    description:
      "Remove project assets and every timeline clip that uses them — the Media panel's trash. Pass asset_id for one, asset_ids for several in one call, or unused:true to clear every asset no timeline uses, open or parked (leftover imports, replaced footage, reference images) without touching placed media; another chat thread's unplaced media is out of this chat's reach, and the sweep counts it as heldByOtherChats. Removed media does not come back with undo, so call it only when the user explicitly asked to remove that media, and report how many assets and clips went.",
    inputSchema: obj({
      asset_id: str("Project asset id from `media`"),
      asset_ids: { type: "array", items: { type: "string" }, description: "Several project asset ids, removed in one call" },
      unused: { type: "boolean", description: "true removes every asset that no timeline (open or parked) uses" },
    }),
  },
  {
    name: "set_publish",
    description:
      "Set the TikTok publish metadata: caption (4,000 char limit incl. tags), tags (space-separated words, # added automatically), soundTitle, handle.",
    inputSchema: obj({
      caption: str("Caption text"),
      tags: str("Space or comma separated tags"),
      soundTitle: str("Sound title"),
      handle: str("Creator handle without @"),
    }),
  },
  {
    name: "set_project_notes",
    description:
      "Write this project's own notes — the Details tab's date, links and text, saved with the project for anyone who opens it. Put a cut's sources here: the original video a template copies, the post it was published as, a reference. note_save writes the account's Notes instead, which travel with no project. add_links appends (skipping links already there); links replaces the whole list.",
    inputSchema: obj({
      add_links: { type: "array", items: { type: "string" }, description: "Links to append, kept in order, duplicates skipped" },
      links: { type: "array", items: { type: "string" }, description: "The whole link list, replacing what is there ([] clears it)" },
      text: str("Free text, replacing what is there"),
      published_at: str("Published date, yyyy-mm-dd ('' clears it)"),
    }),
  },
  {
    name: "set_background",
    description:
      "Set the color of the video frame itself — what sits behind every clip and element. It fills the frame wherever no footage covers it: a cut made only of titles and shapes plays over it end to end, a fitted clip letterboxes into it, and a gap on track 0 shows it. Use this for \"make the background white/orange\" rather than laying a full-frame rectangle over the timeline. Default is black.",
    inputSchema: obj({ color: str("Hex color, e.g. #FFFFFF") }, ["color"]),
  },
] as const satisfies readonly AiToolDef[];

export type SidePanelToolName = (typeof SIDE_PANEL_TOOLS)[number]["name"];