freebeat-mcp 0.3.0 → 0.4.1

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 (89) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +67 -14
  3. package/dist/capabilities/agents/tools/generate-agent-videos.js +21 -15
  4. package/dist/capabilities/agents/tools/generate-agent-videos.js.map +1 -1
  5. package/dist/capabilities/assets/tools/upload-audio.js +3 -3
  6. package/dist/capabilities/assets/tools/upload-audio.js.map +1 -1
  7. package/dist/capabilities/assets/tools/upload-image.js +3 -3
  8. package/dist/capabilities/assets/tools/upload-image.js.map +1 -1
  9. package/dist/capabilities/assets/tools/upload-video.js +3 -3
  10. package/dist/capabilities/assets/tools/upload-video.js.map +1 -1
  11. package/dist/capabilities/credits/register.d.ts +3 -0
  12. package/dist/capabilities/credits/register.js +42 -0
  13. package/dist/capabilities/credits/register.js.map +1 -0
  14. package/dist/capabilities/effects/tools/generate-effect.js +12 -5
  15. package/dist/capabilities/effects/tools/generate-effect.js.map +1 -1
  16. package/dist/capabilities/effects/tools/list-effects.js +3 -3
  17. package/dist/capabilities/effects/tools/list-effects.js.map +1 -1
  18. package/dist/capabilities/media/tools/edit-image.js +13 -22
  19. package/dist/capabilities/media/tools/edit-image.js.map +1 -1
  20. package/dist/capabilities/media/tools/generate-image.js +13 -21
  21. package/dist/capabilities/media/tools/generate-image.js.map +1 -1
  22. package/dist/capabilities/media/tools/generate-text.js +12 -5
  23. package/dist/capabilities/media/tools/generate-text.js.map +1 -1
  24. package/dist/capabilities/media/tools/generate-video.js +13 -24
  25. package/dist/capabilities/media/tools/generate-video.js.map +1 -1
  26. package/dist/capabilities/media/tools/get-model-help.js +14 -9
  27. package/dist/capabilities/media/tools/get-model-help.js.map +1 -1
  28. package/dist/capabilities/media/tools/list-models.js +5 -4
  29. package/dist/capabilities/media/tools/list-models.js.map +1 -1
  30. package/dist/capabilities/media/tools/shared.d.ts +25 -9
  31. package/dist/capabilities/media/tools/shared.js +11 -7
  32. package/dist/capabilities/media/tools/shared.js.map +1 -1
  33. package/dist/capabilities/music/tools/generate-music.js +12 -5
  34. package/dist/capabilities/music/tools/generate-music.js.map +1 -1
  35. package/dist/capabilities/music/tools/list-music-models.js +11 -7
  36. package/dist/capabilities/music/tools/list-music-models.js.map +1 -1
  37. package/dist/capabilities/performance/tools/generate-lip-sync-video.js +12 -5
  38. package/dist/capabilities/performance/tools/generate-lip-sync-video.js.map +1 -1
  39. package/dist/capabilities/performance/tools/generate-singing-video.js +12 -5
  40. package/dist/capabilities/performance/tools/generate-singing-video.js.map +1 -1
  41. package/dist/capabilities/tasks/tools/get-task-result.js +38 -37
  42. package/dist/capabilities/tasks/tools/get-task-result.js.map +1 -1
  43. package/dist/capabilities/tasks/tools/get-task-status.js +40 -24
  44. package/dist/capabilities/tasks/tools/get-task-status.js.map +1 -1
  45. package/dist/core/credit-approval.d.ts +28 -0
  46. package/dist/core/credit-approval.js +37 -0
  47. package/dist/core/credit-approval.js.map +1 -0
  48. package/dist/core/model-output.d.ts +571 -0
  49. package/dist/core/model-output.js +62 -0
  50. package/dist/core/model-output.js.map +1 -0
  51. package/dist/core/paid-tools.d.ts +12 -0
  52. package/dist/core/paid-tools.js +6 -0
  53. package/dist/core/paid-tools.js.map +1 -0
  54. package/dist/core/response.d.ts +12 -5
  55. package/dist/core/response.js +29 -12
  56. package/dist/core/response.js.map +1 -1
  57. package/dist/core/task-outcome.d.ts +47 -0
  58. package/dist/core/task-outcome.js +97 -0
  59. package/dist/core/task-outcome.js.map +1 -0
  60. package/dist/core/task-result.d.ts +35 -0
  61. package/dist/core/task-result.js +19 -0
  62. package/dist/core/task-result.js.map +1 -0
  63. package/dist/core/task-status.d.ts +4 -0
  64. package/dist/core/task-status.js +16 -0
  65. package/dist/core/task-status.js.map +1 -0
  66. package/dist/core/task-types.d.ts +2 -0
  67. package/dist/core/task-types.js +7 -1
  68. package/dist/core/task-types.js.map +1 -1
  69. package/dist/core/tool-annotations.d.ts +1 -1
  70. package/dist/core/tool-annotations.js +2 -1
  71. package/dist/core/tool-annotations.js.map +1 -1
  72. package/dist/server.js +5 -3
  73. package/dist/server.js.map +1 -1
  74. package/dist/services/freebeat-api.d.ts +230 -82
  75. package/dist/services/freebeat-api.js +375 -159
  76. package/dist/services/freebeat-api.js.map +1 -1
  77. package/dist/services/generation-requests.d.ts +26 -0
  78. package/dist/services/generation-requests.js +86 -0
  79. package/dist/services/generation-requests.js.map +1 -0
  80. package/dist/services/media-validation.d.ts +1 -0
  81. package/dist/services/media-validation.js +221 -0
  82. package/dist/services/media-validation.js.map +1 -0
  83. package/dist/services/pricing.d.ts +14 -0
  84. package/dist/services/pricing.js +294 -0
  85. package/dist/services/pricing.js.map +1 -0
  86. package/dist/services/remote-media.d.ts +0 -1
  87. package/dist/services/remote-media.js +22 -52
  88. package/dist/services/remote-media.js.map +1 -1
  89. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -6,6 +6,49 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.1] - 2026-10-27
10
+
11
+ ### Fixed
12
+ - All 22 tools use one registration boundary: successful results are parsed with their declared output schema before either MCP text or structured content is returned. Unknown object properties are stripped recursively.
13
+ - Model help and music parameters use defined parameter/value-domain/condition contracts; text usage returns numeric token counts and defined count breakdowns. Pricing preserves evaluator fields, with combination tables under `prices.map`.
14
+ - Missing-price hints name only recognized request inputs; unknown task types become `unknown`; agent startup transport errors return owned guidance and the created session link without Axios codes.
15
+ - Completed task results share one schema projection across all task types: only documented media URLs and metadata are returned; extra upstream fields cannot enter MCP text or structured results.
16
+ - Task and Open RPC statuses are normalized to defined states; unrecognized values use owned unknown-state guidance, including result-tool errors. Unmapped upstream task and Open RPC codes are omitted or null instead of relayed.
17
+ - Agent task billing comes only from the authoritative task record; final-asset charges and refunds cannot fill unknown task totals.
18
+ - Structured upstream failure facts take precedence over credit notices and chat; fallback facts only fill missing values.
19
+ - Failure text is trusted by source: agent assistant messages, website-facing credit notices, and Singing task display messages are relayed unchanged, including timecodes and Unicode punctuation. Raw error reasons, provider diagnostics and exception details are never relayed or classified by regex; missing user-facing reasons use a plain stage-based failure sentence.
20
+ - Failed and paused task tools retain user-facing messages alongside structured failure and billing facts, with a session link or library link when no session is available.
21
+ - Paid tools require explicit consent: a numeric `max_credits` for a known quote, or `accept_unknown_cost: true` for an unknown total. Missing or conflicting consent is refused; agents charge per stage and do not enforce a whole-run ceiling.
22
+ - Generated-song video handoff waits briefly for audio readiness, then returns `preparing` with the numeric `music_id` if needed. Continuations reuse that asset without registering it again; no paid video starts before readiness.
23
+ - An agent final assembly without a playable URL reports a structured export pause instead of generic failure or an older video.
24
+ - Task status and results preserve structured failure stage, safe reason, retryability, and actual charged/refunded/net/refund state. Failed and paused results retain accounting; missing values remain unknown and raw diagnostics stay out of user messages.
25
+ - Singing requests carry the configured Freebeat account backend to the performance service so account authentication and billing use the intended environment.
26
+
27
+ ### Changed
28
+ - Tool descriptions, submission fixtures, and skills explain both consent modes, preparation continuation, and realistic agent costs without promising a fixed total.
29
+
30
+ ## [0.4.0] - 2026-10-26
31
+
32
+ ### Added
33
+ - Optional `max_credits` on every paid tool, checked against the current quote before submission; refused calls return the quote and reason, and submitted calls report their quote separately from actual charges.
34
+ - Read-only `get_credit_balance` and `quote_generation` tools, covering every paid tool with a current list-price quote or an explicit unavailable result.
35
+ - Backend price-rule evaluation for fixed, duration, combination, formula and branch rules without executing backend scripts as code.
36
+ - Actual credit charges on task results when reported by Freebeat; missing charges remain explicitly unknown.
37
+
38
+ ### Fixed
39
+ - Remote uploads require an accepted declared Content-Type and a matching leading-byte signature. Only Freebeat media hosts `static.freebeat.ai` and `static.freebeatfit.com` may serve `application/octet-stream`; third-party links must serve a proper media type or use the generated-song `music_id` handoff.
40
+ - Removed deep audio/video container parsing, its concurrency limiter, the media worker, and unused `mediabunny`, `jpeg-js` and `pngjs` dependencies. PNG/JPEG structural checks and image size/dimension limits remain, without pixel decoding; internal validation failures stay distinct from invalid files.
41
+ - Server version metadata uses a static JSON import so webpack standalone output no longer reads the original build directory. Node support is `^18.20.0 || >=20.10.0` for JSON import attributes.
42
+ - Quotes and submissions share normalized media/music/lip-sync requests; reference-image counts come from the submitted inputs. Missing price-rule variables now return unavailable instead of selecting a cheaper branch.
43
+ - Lip-sync status parsing no longer requires unrelated display metadata; unreadable task responses report unknown state and a viewing link. Lip-sync generation uses the backend's configured default model.
44
+ - Generated music results can feed the three song-driven video tools directly, with automatic audio preparation.
45
+ - All three agent tools relay the agent's own pause reason and next step with structured credit notices.
46
+ - Music capabilities and submission prices come from current catalog/rule data instead of model-ID lists and stale prices. Missing length control is explained before generation.
47
+ - Backend errors use user-facing recovery guidance instead of exposing account identifiers or backend fields.
48
+
49
+ ### Changed
50
+ - Write tools set `openWorldHint: true`: they send prompts and media to third-party model providers and accept arbitrary URLs, which OpenAI's tool scan flagged.
51
+
9
52
  ## [0.3.0] - 2026-10-23
10
53
 
11
54
  ### Changed
package/README.md CHANGED
@@ -83,7 +83,42 @@ This package depends on Freebeat online services. Available source platforms, ef
83
83
 
84
84
  ## Tools
85
85
 
86
- 20 tools are available with full scopes.
86
+ 22 tools are available with full scopes. Every successful response is projected through its declared output schema before both MCP text and structured content are built; undeclared object properties are excluded.
87
+
88
+ ### `get_credit_balance` and `quote_generation`
89
+
90
+ Read the current credit balance with `get_credit_balance`. Before any paid call, use
91
+ `quote_generation` with `tool` and `parameters` containing the planned generation
92
+ inputs. It evaluates Freebeat's current pricing rules and returns `status: quoted`
93
+ with `credits`, or `status: unavailable` with a reason. Quotes are list prices before
94
+ account discounts or allowances and never charge credits. Missing or unsupported
95
+ rules are not treated as free. Text, effects, singing, and multi-stage agents do not
96
+ currently expose a complete upfront quote through their service contracts.
97
+
98
+ Every paid call needs one explicit user consent:
99
+
100
+ | Current quote | Consent to send | What is checked |
101
+ | --- | --- | --- |
102
+ | `quoted` | `max_credits` with the user-approved numeric ceiling | The current quote must not exceed it. |
103
+ | `unavailable` | `accept_unknown_cost: true`, without `max_credits` | The user explicitly accepts an unknown total. No total cap is enforced. |
104
+
105
+ Missing consent or both consent modes are refused. Never remove or raise a ceiling,
106
+ or switch to unknown-cost consent, without new user approval. Agent videos charge
107
+ per stage; a submission-time check cannot cap the whole run.
108
+
109
+ A production diagnosis on 2026-10-27 observed 855 credits for the video step alone
110
+ of a 15-second 720p dance, with planning and images extra: on the order of 1,000
111
+ credits. This is a historical configuration example, not a current quote or ceiling.
112
+ The agent's actual default model is resolved inside its backend and is not exposed
113
+ by the pricing contract, so this adapter does not invent a live minimum from a model list.
114
+
115
+ All task types expose `billing: { charged, refunded, net, refund_state }`.
116
+ Missing amounts or state are `null`; estimates and next-step requirements are not
117
+ charges. `net` is computed only when both charged and refunded are reported.
118
+ `used_credits` continues to expose the reported charge. Failed and paused tasks also
119
+ expose `failure: { stage, reason, retryable }`, with unknown stage or retryability
120
+ as `null`. A pending refund is not money already returned. Raw stacks and internal
121
+ identifiers are excluded from failure text.
87
122
 
88
123
  ### `upload_audio`
89
124
 
@@ -126,17 +161,31 @@ Upload one MP4, MOV, or WebM clip and receive a `video_url` for
126
161
 
127
162
  Hosted HTTP mode never reads caller-provided local file paths. Attachment and
128
163
  URL downloads require HTTPS, reject private or reserved network addresses and
129
- redirects, enforce media content types, and stream to size-limited temporary
130
- files that are removed after upload.
164
+ redirects, identify allowed media types from the file bytes, and stream to size-limited temporary
165
+ files that are removed after upload. Remote uploads require a declared Content-Type accepted by the upload tool and a matching file signature. Only the exact Freebeat media hosts `static.freebeat.ai` and `static.freebeatfit.com` may serve `application/octet-stream`; their bytes must still match an accepted media type. Audio/video checks read only the first 16 bytes, without parsing tracks or packets; MP4/MOV must also have data beyond the leading ftyp box. PNG/JPEG structure and dimensions are checked without decoding pixels: PNG chunk CRCs and required chunks, or JPEG frame/scan/end markers, with a 10 MiB encoded-file and 16-million-pixel limit. Image scans yield every 64 KiB of work and check a cooperative 5-second deadline. Internal failures return a separate temporary validation error. These checks do not prove full playback or pixel integrity; downstream services decode the media. For Freebeat-generated songs, pass the `music_id` from `get_task_result` directly to video tools.
131
166
 
132
167
  ### `list_music_models`
133
168
 
134
- List music-generation models and supported inputs before calling `generate_music`.
169
+ List music-generation models, published input capabilities and current pricing before
170
+ calling `generate_music`. Unknown capabilities are `null`, not guessed from model IDs.
171
+ When length control is not offered, a prompt cannot guarantee the song's duration.
172
+ Use `quote_generation` with the prompt and other planned inputs for a specific quote.
135
173
 
136
174
  ### `generate_music`
137
175
 
138
176
  Generate original audio from a `model_id` and `prompt`, with optional lyrics, instrumental mode, and duration when supported by the model. Poll `get_task_status`, then call `get_task_result` after completion. This does not turn an existing song into a video.
139
177
 
178
+ Pass the completed `result.music_id` (a reference such as `music:123`) straight into
179
+ `generate_music_video`, `generate_dance_video`, or `generate_lyric_video`. The video
180
+ call resolves and prepares your generated song automatically. If audio analysis is
181
+ still running after a short bounded wait, the tool returns `status: preparing`, a numeric
182
+ `music_id`, and `retry_after_seconds`, without a `task_id`. Wait, then call the same
183
+ tool with the same approved inputs and the returned numeric `music_id`; do not send
184
+ the original `music:<task>` again. No paid video starts until ready. No download or
185
+ manual re-upload is required.
186
+ Music submissions require a current price rule; stale catalog credit amounts are
187
+ never sent as the price.
188
+
140
189
  ### `generate_singing_video`
141
190
 
142
191
  Make a photo, pet, or duet sing a track as a short performance. Provide `mode`, `image_urls`, `duration_seconds`, and exactly one of `music_id` or `audio_url`. Poll `get_task_status`, then call `get_task_result` after completion.
@@ -176,7 +225,7 @@ Recommended flow:
176
225
  - optional `upload_image` if you want to replace the effect's default image
177
226
  - `generate_effect`
178
227
  - `get_task_status`
179
- - `get_task_result` only after status is `completed`
228
+ - `get_task_result` after status is `completed`, `failed`, or `action_required`
180
229
 
181
230
  Parameters:
182
231
 
@@ -208,7 +257,7 @@ All three tools use the existing agents in Auto mode, usually take 15–60 minut
208
257
 
209
258
  Parameters:
210
259
 
211
- - `music_id` required, from `upload_audio`
260
+ - `music_id` required, from `upload_audio` or a completed `generate_music` result
212
261
  - `prompt` optional creative direction
213
262
  - `start_ms` / `end_ms` optional song window, default the first 15 seconds, or up to the song's end if shorter; the selected window must fit the song and account limits
214
263
  - `aspect_ratio` optional, default `16:9`
@@ -224,7 +273,7 @@ List the models Freebeat publishes right now. `type` is `image` (for `generate_i
224
273
 
225
274
  ### `get_model_help`
226
275
 
227
- Show what one image, image edit, or video model accepts and what it costs, read live from Freebeat. Parameters: `type` and `model_id`. The response has the model description, per-generation-type options (aspect ratios, resolutions, durations, and credits when Freebeat publishes them), and pricing rules: `keys` name the parameters that change the price and `prices` lists the allowed combinations.
276
+ Show what one image, image edit, or video model accepts and what it costs, read live from Freebeat. Parameters: `type` and `model_id`. The response has the model description, per-generation-type options (aspect ratios, resolutions, durations, and credits when Freebeat publishes them), and pricing rules: `keys` name the parameters that change the price and `prices` contains the rule body, with combination tables in `prices.map`. Numeric prices, formula/branch fields, variables, count multipliers, and duration settings follow the pricing protocol. Parameter definitions preserve code, component, data type, default, label, required flag, value domains, and conditions; dynamic parameter names and values are retained.
228
277
 
229
278
  ### `generate_image`
230
279
 
@@ -251,13 +300,13 @@ Freebeat validates the options per model; check `get_model_help` first and read
251
300
 
252
301
  ### `generate_text`
253
302
 
254
- Ask any text model from `list_models(type=text)` and get its reply. Parameters: `model`, `messages` (`role` and `content`, oldest first), optional `max_tokens` and `temperature`. Usage is billed to the user's Freebeat credits through the user's own gateway token.
303
+ Ask any text model from `list_models(type=text)` and get its reply. Parameters: `model`, `messages` (`role` and `content`, oldest first), optional `max_tokens` and `temperature`. Usage is billed to the user's Freebeat credits through the user's own gateway token. The response preserves numeric prompt/completion/total token counts and their defined numeric breakdowns, not arbitrary provider usage metadata.
255
304
 
256
305
  ### `get_task_status`
257
306
 
258
- Poll a Freebeat async task or Open RPC batch until it reaches a terminal status. Current MCP endpoints return lowercase status values such as `pending`, `completed`, and `failed`; older backends may still return uppercase variants.
307
+ Poll a Freebeat async task or Open RPC batch until it reaches a terminal status. Task types are mapped to the MCP task categories, with `unknown` for unrecognized types. Status values are normalized to the MCP status set, including lowercase `pending`, `completed`, and `failed`; unrecognized upstream values become `unknown`.
259
308
 
260
- For agent videos, effects, music, singing, and lip-sync tasks, continue polling while the status is still in progress. Agent videos may also report `action_required` with a `session_url` for the user. Only call `get_task_result` after the status is `completed`.
309
+ For agent videos, effects, music, singing, and lip-sync tasks, continue polling while the status is still in progress. Agent videos may also report `action_required` with their own last message, any structured credit notice, and a `session_url` for reviewing and continuing. Call `get_task_result` after `completed`, `failed`, or `action_required`. If a task response cannot be read, `get_task_status` reports `unknown` and a viewing link; this is not a generation failure and must not trigger another paid submission.
261
310
 
262
311
  For Open RPC image/video batches, pass the returned `batch_id` as `task_id`. You can also pass `serial_no` to query a single batch item. Completed batch items include result URLs directly in `get_task_status`, so `get_task_result` is not used for Open RPC batches.
263
312
 
@@ -267,17 +316,16 @@ Returns a stable task envelope including:
267
316
  - `task_type`
268
317
  - `status`
269
318
  - `error_message` optional, present when backend reports a failed task
270
- - `error_code` optional, present when backend reports a failed task
271
319
  - `message` optional, present when status is `completed` or `failed`
272
320
  - `items` optional, present for Open RPC batches and containing `image_url`, `video_url`, or `edit_images` when available
273
321
 
274
322
  ### `get_task_result`
275
323
 
276
- Retrieve the output for a completed task. Only call this after `get_task_status` returns `completed`. The response uses a stable envelope with `task_id`, `task_type`, `status`, and `result`.
324
+ Retrieve the output for a completed task. Call after `get_task_status` returns `completed`, `failed`, or `action_required`. The response uses a stable envelope with `task_id`, `task_type`, `status`, and `billing`; completed tasks also include `result`.
277
325
 
278
- If the task is not completed yet, this tool returns error code `TASK_NOT_COMPLETED`.
326
+ If the task is pending or running, this tool returns error code `TASK_NOT_COMPLETED`.
279
327
 
280
- If the task has failed, this tool surfaces the backend failure as an error.
328
+ If the task failed or paused, this tool returns the same `failure` and `billing` contract as status, without requiring media output.
281
329
 
282
330
  For completed agent videos, `result` is an object containing:
283
331
 
@@ -288,3 +336,8 @@ Completed effect generation results use the same `result` object fields:
288
336
 
289
337
  - `video_url`
290
338
  - `cover_url`
339
+
340
+ Completed results return only the fields defined by the output schema: `video_url`,
341
+ `audio_url`, `cover_url`, `title`, `lyrics`, `duration_ms`, and `music_id`. Extra
342
+ upstream fields are excluded. Unmapped upstream error codes are not relayed; Open
343
+ RPC item code fields are `null`.
@@ -1,36 +1,36 @@
1
+ import { acceptUnknownCostSchema, CREDIT_APPROVAL_DESCRIPTION, maxCreditsSchema, creditQuoteSchema } from "../../../core/credit-approval.js";
1
2
  import { z } from "zod";
2
3
  import { AGENT_PRODUCTS } from "../../../core/agent-products.js";
3
- import { formatToolError, jsonContent } from "../../../core/response.js";
4
+ import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
4
5
  import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
5
6
  const AGENT_VIDEO_TOOLS = {
6
7
  music_video: {
7
8
  name: "generate_music_video",
8
9
  title: "Generate music video",
9
- description: "Use this for music video generation: the user wants a music video (MV) for a song. Freebeat's music video agent plans scenes and generates and edits a multi-scene video timed to the song; people or characters from optional photos can appear. Requires music_id from upload_audio; optional photos via upload_image. Starts a generation job that uses the user's existing Freebeat credits and usually takes 15–60 minutes; by default it uses the first 15 seconds of the song, or up to the song's end if shorter. Returns task_id and session_url; poll get_task_status every few minutes, call get_task_result after completed; on action_required relay the message and session_url. Do not use for dance videos, lyric videos, short singing-photo clips, lip-sync of an existing clip, standalone video clips without a song, or generating audio.",
10
+ description: "Use this for music video generation: the user wants a music video (MV) for a song. Freebeat's music video agent plans scenes and generates and edits a multi-scene video timed to the song; people or characters from optional photos can appear. Requires music_id from upload_audio or a completed generate_music result; optional photos via upload_image. Starts a generation job that uses the user's existing Freebeat credits and usually takes 15–60 minutes; by default it uses the first 15 seconds of the song, or up to the song's end if shorter. Returns task_id and session_url; poll get_task_status every few minutes, call get_task_result after completed; on action_required relay the message and session_url. Do not use for dance videos, lyric videos, short singing-photo clips, lip-sync of an existing clip, standalone video clips without a song, or generating audio.",
10
11
  },
11
12
  dance: {
12
13
  name: "generate_dance_video",
13
14
  title: "Generate dance video",
14
- description: "Use this for dance video generation: the user wants dancers performing to a song. Freebeat's dance video agent plans and generates a dance video timed to the song; people in optional photos become the dancers. Supports vertical 9:16 and 3:4 formats. Requires music_id from upload_audio; optional photos via upload_image. Starts a generation job that uses the user's existing Freebeat credits and usually takes 15–60 minutes; by default it uses the first 15 seconds of the song, or up to the song's end if shorter. Returns task_id and session_url; poll get_task_status every few minutes, call get_task_result after completed; on action_required relay the message and session_url. Do not use for story-based music videos, lyric videos, short singing-photo clips, lip-sync of an existing clip, standalone video clips without a song, or generating audio.",
15
+ description: "Use this for dance video generation: the user wants dancers performing to a song. Freebeat's dance video agent plans and generates a dance video timed to the song; people in optional photos become the dancers. Supports vertical 9:16 and 3:4 formats. A 2026-10-27 production diagnosis found 855 credits for the video step alone of a 15-second 720p dance, with planning and images extra: budget on the order of 1,000 credits, not a fixed quote or cap. Requires music_id from upload_audio or a completed generate_music result; optional photos via upload_image. Starts a generation job that uses the user's existing Freebeat credits and usually takes 15–60 minutes; by default it uses the first 15 seconds of the song, or up to the song's end if shorter. Returns task_id and session_url; poll get_task_status every few minutes, call get_task_result after completed; on action_required relay the message and session_url. Do not use for story-based music videos, lyric videos, short singing-photo clips, lip-sync of an existing clip, standalone video clips without a song, or generating audio.",
15
16
  },
16
17
  lyric_video: {
17
18
  name: "generate_lyric_video",
18
19
  title: "Generate lyric video",
19
- description: "Use this for lyric video generation: the user wants animated lyrics timed to the vocals of a song. Freebeat's lyric video agent plans, generates, and edits the lyric video. Requires music_id from upload_audio; optional reference photos via upload_image. Starts a generation job that uses the user's existing Freebeat credits and usually takes 15–60 minutes; by default it uses the first 15 seconds of the song, or up to the song's end if shorter. Returns task_id and session_url; poll get_task_status every few minutes, call get_task_result after completed; on action_required relay the message and session_url. Do not use for story-based music videos, dance videos, short singing-photo clips, lip-sync of an existing clip, standalone video clips without a song, or generating audio.",
20
+ description: "Use this for lyric video generation: the user wants animated lyrics timed to the vocals of a song. Freebeat's lyric video agent plans, generates, and edits the lyric video. Requires music_id from upload_audio or a completed generate_music result; optional reference photos via upload_image. Starts a generation job that uses the user's existing Freebeat credits and usually takes 15–60 minutes; by default it uses the first 15 seconds of the song, or up to the song's end if shorter. Returns task_id and session_url; poll get_task_status every few minutes, call get_task_result after completed; on action_required relay the message and session_url. Do not use for story-based music videos, dance videos, short singing-photo clips, lip-sync of an existing clip, standalone video clips without a song, or generating audio.",
20
21
  },
21
22
  };
22
23
  export function registerGenerateAgentVideoTools(server, client) {
23
24
  for (const product of Object.keys(AGENT_VIDEO_TOOLS)) {
24
25
  const tool = AGENT_VIDEO_TOOLS[product];
25
- server.registerTool(tool.name, {
26
- description: tool.description,
26
+ registerTool(server, tool.name, {
27
+ description: CREDIT_APPROVAL_DESCRIPTION + `Generated songs may return preparing with a numeric music_id and retry_after_seconds instead of a task_id. Retry with that music_id and unchanged approved parameters; no paid video starts before readiness. ${tool.description}`,
27
28
  annotations: { title: tool.title, ...CREATE_TOOL_ANNOTATIONS },
28
29
  inputSchema: {
29
- music_id: z
30
- .number()
31
- .int()
32
- .positive()
33
- .describe("An analyzed music_id from upload_audio."),
30
+ max_credits: maxCreditsSchema,
31
+ accept_unknown_cost: acceptUnknownCostSchema,
32
+ music_id: z.union([z.number().int().positive(), z.string().regex(/^music:.+/)])
33
+ .describe("An analyzed music_id from upload_audio, or result.music_id from a completed generate_music task. Generated songs are prepared automatically. On preparing, reuse the returned numeric music_id in the same tool after retry_after_seconds; no paid video has started."),
34
34
  prompt: z
35
35
  .string()
36
36
  .trim()
@@ -70,22 +70,28 @@ export function registerGenerateAgentVideoTools(server, client) {
70
70
  .describe("Remove the Freebeat watermark if the account allows it."),
71
71
  },
72
72
  outputSchema: {
73
+ quote: creditQuoteSchema.optional(),
73
74
  success: z.literal(true),
75
+ music_id: z.number().optional().describe("Prepared audio asset to reuse on a preparing response."),
76
+ retry_after_seconds: z.number().optional(),
74
77
  task_id: z
75
- .string()
78
+ .string().optional()
76
79
  .describe("The scoped task ID for get_task_status and get_task_result."),
77
- task_type: z.string().describe("The task category."),
80
+ task_type: z.string().optional().describe("The task category."),
78
81
  status: z.string().describe("The initial task status, typically pending."),
79
82
  session_url: z
80
- .string()
83
+ .string().optional()
81
84
  .describe("The freebeat.ai page where the user can watch, review, or continue this session."),
82
85
  message: z.string().describe("What to do next."),
83
86
  },
84
87
  }, async (params) => {
85
88
  try {
86
89
  const result = await client.createAgentVideo({ ...params, product });
87
- return jsonContent({
90
+ if ("music_id" in result)
91
+ return toolResult({ success: true, ...result });
92
+ return toolResult({
88
93
  success: true,
94
+ quote: result.quote,
89
95
  task_id: result.task_id,
90
96
  task_type: result.task_type,
91
97
  status: result.status,
@@ -1 +1 @@
1
- {"version":3,"file":"generate-agent-videos.js","sourceRoot":"","sources":["../../../../src/capabilities/agents/tools/generate-agent-videos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAqB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,MAAM,iBAAiB,GAAG;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,g0BAAg0B;KACn0B;IACD,KAAK,EAAE;QACL,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,o1BAAo1B;KACv1B;IACD,WAAW,EAAE;QACX,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,ixBAAixB;KACpxB;CACO,CAAC;AAEX,MAAM,UAAU,+BAA+B,CAC7C,MAAiB,EACjB,MAAmD;IAEnD,KAA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AAC;YACL,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;AAEH,CAAC"}
1
+ {"version":3,"file":"generate-agent-videos.js","sourceRoot":"","sources":["../../../../src/capabilities/agents/tools/generate-agent-videos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE7I,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAqB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,MAAM,iBAAiB,GAAG;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,q2BAAq2B;KACx2B;IACD,KAAK,EAAE;QACL,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,ikCAAikC;KACpkC;IACD,WAAW,EAAE;QACX,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,szBAAszB;KACzzB;CACO,CAAC;AAEX,MAAM,UAAU,+BAA+B,CAC7C,MAAiB,EACjB,MAAmD;IAEnD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAmB,EAAE,CAAC;QACvE,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACxC,YAAY,CAAC,MAAM,EACjB,IAAI,CAAC,IAAI,EACT;YACE,WAAW,EAAE,2BAA2B,GAAG,iNAAiN,IAAI,CAAC,WAAW,EAAE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,IAAI,MAAM;oBAAE,OAAO,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;gBAC1E,OAAO,UAAU,CAAC;oBAChB,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,WAAW,EAAE,MAAM,CAAC,WAAW;oBAC/B,OAAO,EACL,mKAAmK;iBACtK,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;AAEH,CAAC"}
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { AppError } from "../../../core/errors.js";
3
3
  import { validateSupportedMusicSourceUrl } from "../../../core/music-source-url.js";
4
4
  import { openAiFileSchema } from "../../../core/openai-file.js";
5
- import { formatToolError, jsonContent } from "../../../core/response.js";
5
+ import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
6
6
  import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
7
7
  import { downloadRemoteMedia, removeRemoteMedia, } from "../../../services/remote-media.js";
8
8
  import { UploadService } from "../../../services/upload-service.js";
@@ -20,7 +20,7 @@ const REMOTE_AUDIO_TYPES = {
20
20
  const MAX_AUDIO_BYTES = 50 * 1024 * 1024;
21
21
  export function registerUploadAudioTool(server, client, allowLocalFiles = true) {
22
22
  const uploadService = new UploadService(client);
23
- server.registerTool("upload_audio", {
23
+ registerTool(server, "upload_audio", {
24
24
  description: "Use this when the user needs to upload an attached audio file, upload a local audio file in stdio mode, or import from a supported music URL. Supported platforms: SoundCloud, YouTube, Suno, Udio, TikTok, Stable Audio, and Riffusion. Provide exactly one of file, file_path, or url. Returns music_id for generate_music_video, generate_dance_video, generate_lyric_video and other audio workflows. Does not generate audio or video.",
25
25
  annotations: { title: "Upload audio", ...CREATE_TOOL_ANNOTATIONS },
26
26
  _meta: { "openai/fileParams": ["file"] },
@@ -84,7 +84,7 @@ export function registerUploadAudioTool(server, client, allowLocalFiles = true)
84
84
  validateSupportedMusicSourceUrl(url);
85
85
  musicId = await client.saveMusicSource(url);
86
86
  }
87
- return jsonContent({
87
+ return toolResult({
88
88
  success: true,
89
89
  music_id: musicId,
90
90
  message: `Audio source ready. Use music_id=${musicId} with ` +
@@ -1 +1 @@
1
- {"version":3,"file":"upload-audio.js","sourceRoot":"","sources":["../../../../src/capabilities/assets/tools/upload-audio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,kBAAkB,GAAG;IACzB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,MAAM;IACpB,cAAc,EAAE,MAAM;IACtB,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,KAAK;CACrB,CAAC;AACF,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI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AC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;gBAAS,CAAC;YACT,IAAI,UAAU;gBAAE,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"upload-audio.js","sourceRoot":"","sources":["../../../../src/capabilities/assets/tools/upload-audio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,kBAAkB,GAAG;IACzB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,MAAM;IACpB,cAAc,EAAE,MAAM;IACtB,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,KAAK;CACrB,CAAC;AACF,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,MAAM,UAAU,uBAAuB,CACrC,MAAiB,EACjB,MAGC,EACD,eAAe,G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K,CAAC,CAAC;QAChC,CAAC;gBAAS,CAAC;YACT,IAAI,UAAU;gBAAE,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { AppError } from "../../../core/errors.js";
3
3
  import { openAiFileSchema } from "../../../core/openai-file.js";
4
- import { formatToolError, jsonContent } from "../../../core/response.js";
4
+ import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
5
5
  import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
6
6
  import { downloadRemoteMedia, removeRemoteMedia, } from "../../../services/remote-media.js";
7
7
  import { UploadService } from "../../../services/upload-service.js";
@@ -13,7 +13,7 @@ const REMOTE_IMAGE_TYPES = {
13
13
  const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
14
14
  export function registerUploadImageTool(server, client, allowLocalFiles = true) {
15
15
  const uploadService = new UploadService(client);
16
- server.registerTool("upload_image", {
16
+ registerTool(server, "upload_image", {
17
17
  description: "Use this when the user needs to upload one or two image files (PNG/JPG/JPEG, max 10MB each) for Freebeat workflows. Use returned image_urls with generate_music_video, generate_dance_video, or generate_lyric_video for song-driven videos, or pass a single uploaded image URL to generate_effect.reference_image_urls to replace the default list_effects.image_url. Does not generate or edit images.",
18
18
  annotations: { title: "Upload images", ...CREATE_TOOL_ANNOTATIONS },
19
19
  _meta: { "openai/fileParams": ["files"] },
@@ -93,7 +93,7 @@ export function registerUploadImageTool(server, client, allowLocalFiles = true)
93
93
  throw error;
94
94
  }
95
95
  }
96
- return jsonContent({
96
+ return toolResult({
97
97
  success: true,
98
98
  image_urls: imageUrls,
99
99
  message: `Uploaded ${imageUrls.length} image(s). Use image_urls with ` +
@@ -1 +1 @@
1
- {"version":3,"file":"upload-image.js","sourceRoot":"","sources":["../../../../src/capabilities/assets/tools/upload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C;oBACJ,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YAED,OAAO,WAAW,CAAC;gBACjB,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,SAAS;gBACrB,OAAO,EACL,YAAY,SAAS,CAAC,MAAM,iCAAiC;oBAC7D,wGAAwG;oBACxG,2EAA2E;aAC9E,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;gBAAS,CAAC;YACT,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"upload-image.js","sourceRoot":"","sources":["../../../../src/capabilities/assets/tools/upload-image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,kBAAkB,GAAG;IACzB,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;CACpB,CAAC;AACF,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IA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3
3
  import { openAiFileSchema } from "../../../core/openai-file.js";
4
- import { formatToolError, jsonContent } from "../../../core/response.js";
4
+ import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
5
5
  import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
6
6
  import { downloadRemoteMedia, removeRemoteMedia, } from "../../../services/remote-media.js";
7
7
  import { UploadService } from "../../../services/upload-service.js";
@@ -14,7 +14,7 @@ const REMOTE_VIDEO_TYPES = {
14
14
  const MAX_VIDEO_BYTES = 100 * 1024 * 1024;
15
15
  export function registerUploadVideoTool(server, client, allowLocalFiles = true) {
16
16
  const uploadService = new UploadService(client);
17
- server.registerTool("upload_video", {
17
+ registerTool(server, "upload_video", {
18
18
  description: allowLocalFiles
19
19
  ? "Use this when the user needs to upload an MP4, MOV, or WebM video for a Freebeat lip-sync workflow from an attachment, local file path, or public HTTPS url. Provide exactly one of file, file_path, or url. Returns a video_url for generate_lip_sync_video. Does not generate a new clip. For song-driven music, dance, or lyric videos, use generate_music_video, generate_dance_video, or generate_lyric_video."
20
20
  : "Use this when the user needs to upload an MP4, MOV, or WebM video for a Freebeat lip-sync workflow from an attachment or public HTTPS url. Returns a video_url for generate_lip_sync_video. Does not generate a new clip. For song-driven music, dance, or lyric videos, use generate_music_video, generate_dance_video, or generate_lyric_video.",
@@ -61,7 +61,7 @@ export function registerUploadVideoTool(server, client, allowLocalFiles = true)
61
61
  keyPrefix: "agent/video",
62
62
  contentType: detectVideoMimeType(localPath),
63
63
  });
64
- return jsonContent({
64
+ return toolResult({
65
65
  success: true,
66
66
  video_url: videoUrl,
67
67
  message: "Video uploaded. Pass video_url and the clip duration to generate_lip_sync_video.",
@@ -1 +1 @@
1
- {"version":3,"file":"upload-video.js","sourceRoot":"","sources":["../../../../src/capabilities/assets/tools/upload-video.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CA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;gBACnB,OAAO,EACL,kFAAkF;aACrF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;gBAAS,CAAC;YACT,IAAI,UAAU;gBAAE,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"upload-video.js","sourceRoot":"","sources":["../../../../src/capabilities/assets/tools/upload-video.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,kBAAkB,GAAG;IACzB,WAAW,EAAE,KAAK;IAClB,iBAAiB,EAAE,KAAK;IACxB,YAAY,EAAE,MAAM;CACrB,CAAC;AACF,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C,MAAM,UAAU,uBAAuB,CACrC,MAAiB,EACjB,MAA2E,EAC3E,eAAe,GAAG,IAAI;IAEtB,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAEhD,YAAY,CAAC,MAAM,EACjB,cAAc,EACd;QACE,WAAW,EA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AAM,SAAS,GAAG,IAAI,EAAE,YAAY,IAAI,GAAG,CAAC;YAC5C,MAAM,SAAS,GAAG,SAAS;mBACtB,CAAC,UAAU,GAAG,MAAM,mBAAmB,CAAC,SAAU,EAAE;oBACrD,aAAa,EAAE,kBAAkB;oBACjC,QAAQ,EAAE,eAAe;iBAC1B,CAAC,CAAC,CAAC;YACN,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC7B,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC;gBACnD,QAAQ,EAAE,SAAS;gBACnB,SAAS,EAAE,aAAa;gBACxB,WAAW,EAAE,mBAAmB,CAAC,SAAS,CAAC;aAC5C,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;gBAChB,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,QAAQ;gBACnB,OAAO,EACL,kFAAkF;aACrF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;gBAAS,CAAC;YACT,IAAI,UAAU;gBAAE,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { FreebeatApiClient } from "../../services/freebeat-api.js";
3
+ export declare function registerCreditTools(server: McpServer, client: Pick<FreebeatApiClient, "getCreditBalance" | "quoteGeneration">): void;
@@ -0,0 +1,42 @@
1
+ import { CREDIT_APPROVAL_DESCRIPTION } from "../../core/credit-approval.js";
2
+ import { z } from "zod";
3
+ import { PAID_TOOLS } from "../../core/paid-tools.js";
4
+ import { formatToolError, toolResult, registerTool } from "../../core/response.js";
5
+ import { READ_ONLY_TOOL_ANNOTATIONS } from "../../core/tool-annotations.js";
6
+ export function registerCreditTools(server, client) {
7
+ registerTool(server, "get_credit_balance", {
8
+ description: "Read the signed-in Freebeat account's available credit balance. Does not charge credits or start generation.",
9
+ annotations: { title: "Get credit balance", ...READ_ONLY_TOOL_ANNOTATIONS },
10
+ inputSchema: {},
11
+ outputSchema: { credits: z.number().describe("Available Freebeat credits.") },
12
+ }, async () => {
13
+ try {
14
+ return toolResult(await client.getCreditBalance());
15
+ }
16
+ catch (error) {
17
+ return formatToolError(error);
18
+ }
19
+ });
20
+ registerTool(server, "quote_generation", {
21
+ description: CREDIT_APPROVAL_DESCRIPTION + "Supply the intended tool and its planned input parameters. Reads current Freebeat pricing rules, without starting or charging for generation. Quoted credits are list price before account discounts or allowances. Unavailable means unknown, never free; agent totals depend on stages and retries. For music, check list_music_models for length control before quoting.",
22
+ annotations: { title: "Quote generation", ...READ_ONLY_TOOL_ANNOTATIONS },
23
+ inputSchema: {
24
+ tool: z.enum(PAID_TOOLS).describe("The paid tool to quote."),
25
+ parameters: z.record(z.unknown()).describe("The same input parameters planned for the paid tool, including the model, prompt, duration, and other price-changing options."),
26
+ },
27
+ outputSchema: {
28
+ status: z.enum(["quoted", "unavailable"]),
29
+ credits: z.number().optional(),
30
+ source: z.string(),
31
+ message: z.string(),
32
+ },
33
+ }, async ({ tool, parameters }) => {
34
+ try {
35
+ return toolResult(await client.quoteGeneration(tool, parameters));
36
+ }
37
+ catch (error) {
38
+ return formatToolError(error);
39
+ }
40
+ });
41
+ }
42
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/capabilities/credits/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,C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EAAE;SACpB;KACF,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE;QAChC,IAAI,CAAC;YAAC,OAAO,UAAU,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAAC,CAAC;QAC1E,OAAO,KAAK,EAAE,CAAC;YAAC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,13 +1,15 @@
1
+ import { acceptUnknownCostSchema, CREDIT_APPROVAL_DESCRIPTION, maxCreditsSchema, creditQuoteSchema } from "../../../core/credit-approval.js";
1
2
  import { z } from "zod";
2
3
  import { AppError } from "../../../core/errors.js";
3
4
  import { normalizeGenerationPrompt } from "../../../core/prompt.js";
4
- import { formatToolError, jsonContent } from "../../../core/response.js";
5
+ import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
5
6
  import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
6
7
  export function registerGenerateEffectTool(server, client) {
7
- server.registerTool("generate_effect", {
8
- description: "Use this when the user wants an effect-template video from a music_id and exactly one reference image URL. Flow: list_effects -> optional upload_audio -> optional upload_image -> generate_effect -> get_task_status -> get_task_result. By default, use list_effects.image_url. You can also use a single uploaded image URL from upload_image. Only call get_task_result after get_task_status returns completed. For song-driven music, dance, or lyric videos, use generate_music_video, generate_dance_video, or generate_lyric_video.",
8
+ registerTool(server, "generate_effect", {
9
+ description: CREDIT_APPROVAL_DESCRIPTION + "Use this when the user wants an effect-template video from a music_id and exactly one reference image URL. Flow: list_effects -> optional upload_audio -> optional upload_image -> generate_effect -> get_task_status -> get_task_result. By default, use list_effects.image_url. You can also use a single uploaded image URL from upload_image. Call get_task_result after get_task_status returns completed, failed, or action_required; failure and billing remain available without final media. For song-driven music, dance, or lyric videos, use generate_music_video, generate_dance_video, or generate_lyric_video.",
9
10
  annotations: { title: "Generate effect", ...CREATE_TOOL_ANNOTATIONS },
10
11
  outputSchema: {
12
+ quote: creditQuoteSchema.optional(),
11
13
  success: z
12
14
  .literal(true)
13
15
  .describe("Whether the effect task was created successfully."),
@@ -25,6 +27,8 @@ export function registerGenerateEffectTool(server, client) {
25
27
  .describe("A human-readable summary of the task creation result."),
26
28
  },
27
29
  inputSchema: {
30
+ max_credits: maxCreditsSchema,
31
+ accept_unknown_cost: acceptUnknownCostSchema,
28
32
  effect_id: z.number().int().describe("Effect ID returned by list_effects."),
29
33
  music_id: z
30
34
  .number()
@@ -48,7 +52,7 @@ export function registerGenerateEffectTool(server, client) {
48
52
  .length(1, "reference_image_urls must contain exactly one image URL")
49
53
  .describe("Exactly one image URL. Recommended: use list_effects.image_url. You may also use a single uploaded image URL from upload_image."),
50
54
  },
51
- }, async ({ effect_id, music_id, prompt, watermark, reference_image_urls, }) => {
55
+ }, async ({ accept_unknown_cost, max_credits, effect_id, music_id, prompt, watermark, reference_image_urls, }) => {
52
56
  try {
53
57
  const normalizedPrompt = normalizeGenerationPrompt(prompt);
54
58
  if (!Number.isInteger(effect_id)) {
@@ -61,14 +65,17 @@ export function registerGenerateEffectTool(server, client) {
61
65
  return formatToolError(new AppError("reference_image_urls must contain exactly one image URL", "INVALID_PARAMS"));
62
66
  }
63
67
  const result = await client.generateEffect({
68
+ accept_unknown_cost,
69
+ max_credits,
64
70
  effect_id,
65
71
  music_id,
66
72
  prompt: normalizedPrompt,
67
73
  watermark: watermark ?? false,
68
74
  reference_image_urls,
69
75
  });
70
- return jsonContent({
76
+ return toolResult({
71
77
  success: true,
78
+ quote: result.quote,
72
79
  task_id: result.task_id,
73
80
  task_type: result.task_type,
74
81
  status: result.status,
@@ -1 +1 @@
1
- {"version":3,"file":"generate-effect.js","sourceRoot":"","sources":["../../../../src/capabilities/effects/tools/generate-effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAA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S;gBAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,+DAA+D,MAAM,CAAC,OAAO,oBAAoB;aAC3G,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"generate-effect.js","sourceRoot":"","sources":["../../../../src/capabilities/effects/tools/generate-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE7I,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,MAAM,UAAU,0BAA0B,CACxC,MAAiB,EACjB,MAAiD;IAEjD,YAAY,CAAC,MAAM,EACjB,iBAAiB,EACjB;QACE,WAAW,EACT,2BAA2B,GAAG,+lBAA+lB;QAC/nB,WAAW,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,uBAAuB,EAAE;QACrE,YAAY,EAAE;YACZ,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE;YACnC,OAAO,EAAE,CAAC;iBACP,OAAO,CAAC,IAAI,CAAC;iBACb,QAAQ,CAAC,mDAAmD,CAAC;YAChE,OAAO,EAAE,CAAC;iBACP,MAAM,EAAE;iBACR,QAAQ,CAAC,yDAAyD,CAAC;YACtE,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,QAAQ,CAAC,yCAAyC,CAAC;YACt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C,8BAA8B,EAAE,gBAAgB,CAAC,CAC/D,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAChC,OAAO,eAAe,CACpB,IAAI,QAAQ,CAAC,6BAA6B,EAAE,gBAAgB,CAAC,CAC9D,CAAC;YACJ,CAAC;YAED,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtC,OAAO,eAAe,CACpB,IAAI,QAAQ,CACV,yDAAyD,EACzD,gBAAgB,CACjB,CACF,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC;gBACzC,mBAAmB;gBACnB,WAAW;gBACX,SAAS;gBACT,QAAQ;gBACR,MAAM,EAAE,gBAAgB;gBACxB,SAAS,EAAE,SAAS,IAAI,KAAK;gBAC7B,oBAAoB;aACrB,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;gBAChB,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,+DAA+D,MAAM,CAAC,OAAO,oBAAoB;aAC3G,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { formatToolError, jsonContent } from "../../../core/response.js";
2
+ import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
3
3
  import { READ_ONLY_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
4
4
  function normalizeEffect(effect) {
5
5
  return {
@@ -13,7 +13,7 @@ function normalizeEffect(effect) {
13
13
  };
14
14
  }
15
15
  export function registerListEffectsTool(server, client) {
16
- server.registerTool("list_effects", {
16
+ registerTool(server, "list_effects", {
17
17
  description: "Use this when the user wants effect templates and the metadata needed to select an effect and create an effect task. Each effect includes a default image_url and default_music_id you can use directly. This lists templates rather than generating a video. For song-driven music, dance, or lyric videos, use generate_music_video, generate_dance_video, or generate_lyric_video.",
18
18
  annotations: { title: "List effects", ...READ_ONLY_TOOL_ANNOTATIONS },
19
19
  outputSchema: {
@@ -43,7 +43,7 @@ export function registerListEffectsTool(server, client) {
43
43
  }, async () => {
44
44
  try {
45
45
  const effects = await client.listEffects();
46
- return jsonContent({
46
+ return toolResult({
47
47
  success: true,
48
48
  effects: effects.map(normalizeEffect),
49
49
  message: `Retrieved ${effects.length} effect(s).`,