freebeat-mcp 0.4.0 → 0.4.2
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.
- package/CHANGELOG.md +21 -0
- package/README.md +88 -15
- package/dist/capabilities/agents/tools/generate-agent-videos.js +15 -10
- package/dist/capabilities/agents/tools/generate-agent-videos.js.map +1 -1
- package/dist/capabilities/assets/tools/upload-audio.js +3 -3
- package/dist/capabilities/assets/tools/upload-audio.js.map +1 -1
- package/dist/capabilities/assets/tools/upload-image.js +3 -3
- package/dist/capabilities/assets/tools/upload-image.js.map +1 -1
- package/dist/capabilities/assets/tools/upload-video.js +3 -3
- package/dist/capabilities/assets/tools/upload-video.js.map +1 -1
- package/dist/capabilities/credits/register.js +7 -6
- package/dist/capabilities/credits/register.js.map +1 -1
- package/dist/capabilities/effects/tools/generate-effect.js +8 -6
- package/dist/capabilities/effects/tools/generate-effect.js.map +1 -1
- package/dist/capabilities/effects/tools/list-effects.js +21 -8
- package/dist/capabilities/effects/tools/list-effects.js.map +1 -1
- package/dist/capabilities/media/tools/edit-image.js +7 -5
- package/dist/capabilities/media/tools/edit-image.js.map +1 -1
- package/dist/capabilities/media/tools/generate-image.js +7 -5
- package/dist/capabilities/media/tools/generate-image.js.map +1 -1
- package/dist/capabilities/media/tools/generate-text.js +8 -6
- package/dist/capabilities/media/tools/generate-text.js.map +1 -1
- package/dist/capabilities/media/tools/generate-video.js +7 -5
- package/dist/capabilities/media/tools/generate-video.js.map +1 -1
- package/dist/capabilities/media/tools/get-model-help.js +14 -9
- package/dist/capabilities/media/tools/get-model-help.js.map +1 -1
- package/dist/capabilities/media/tools/list-models.js +5 -4
- package/dist/capabilities/media/tools/list-models.js.map +1 -1
- package/dist/capabilities/media/tools/shared.d.ts +7 -7
- package/dist/capabilities/media/tools/shared.js +9 -8
- package/dist/capabilities/media/tools/shared.js.map +1 -1
- package/dist/capabilities/music/tools/generate-music.js +8 -6
- package/dist/capabilities/music/tools/generate-music.js.map +1 -1
- package/dist/capabilities/music/tools/list-music-models.js +6 -5
- package/dist/capabilities/music/tools/list-music-models.js.map +1 -1
- package/dist/capabilities/performance/tools/generate-lip-sync-video.js +8 -6
- package/dist/capabilities/performance/tools/generate-lip-sync-video.js.map +1 -1
- package/dist/capabilities/performance/tools/generate-singing-video.js +8 -6
- package/dist/capabilities/performance/tools/generate-singing-video.js.map +1 -1
- package/dist/capabilities/tasks/tools/get-task-result.js +40 -35
- package/dist/capabilities/tasks/tools/get-task-result.js.map +1 -1
- package/dist/capabilities/tasks/tools/get-task-status.js +44 -29
- package/dist/capabilities/tasks/tools/get-task-status.js.map +1 -1
- package/dist/core/agent-products.d.ts +19 -0
- package/dist/core/agent-products.js.map +1 -1
- package/dist/core/credit-approval.d.ts +3 -1
- package/dist/core/credit-approval.js +13 -4
- package/dist/core/credit-approval.js.map +1 -1
- package/dist/core/model-output.d.ts +571 -0
- package/dist/core/model-output.js +62 -0
- package/dist/core/model-output.js.map +1 -0
- package/dist/core/paid-tools.d.ts +1 -0
- package/dist/core/response.d.ts +67 -8
- package/dist/core/response.js +56 -19
- package/dist/core/response.js.map +1 -1
- package/dist/core/task-outcome.d.ts +47 -0
- package/dist/core/task-outcome.js +97 -0
- package/dist/core/task-outcome.js.map +1 -0
- package/dist/core/task-result.d.ts +35 -0
- package/dist/core/task-result.js +19 -0
- package/dist/core/task-result.js.map +1 -0
- package/dist/core/task-status.d.ts +4 -0
- package/dist/core/task-status.js +16 -0
- package/dist/core/task-status.js.map +1 -0
- package/dist/core/task-types.d.ts +2 -0
- package/dist/core/task-types.js +7 -1
- package/dist/core/task-types.js.map +1 -1
- package/dist/hosted.d.ts +5 -2
- package/dist/hosted.js +2 -1
- package/dist/hosted.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/services/freebeat-api.d.ts +29 -14
- package/dist/services/freebeat-api.js +303 -112
- package/dist/services/freebeat-api.js.map +1 -1
- package/dist/services/pricing.js +19 -2
- package/dist/services/pricing.js.map +1 -1
- package/dist/services/remote-media.d.ts +2 -0
- package/dist/services/remote-media.js +1 -1
- package/dist/services/remote-media.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,27 @@ 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
|
+
|
|
9
30
|
## [0.4.0] - 2026-10-26
|
|
10
31
|
|
|
11
32
|
### Added
|
package/README.md
CHANGED
|
@@ -78,12 +78,35 @@ npx -y freebeat-mcp
|
|
|
78
78
|
|
|
79
79
|
The hosted MCP endpoint is served by freebeat.ai.
|
|
80
80
|
The website mounts `freebeat-mcp/hosted`.
|
|
81
|
+
It supplies `HostedMcpRequestOptions.renderAgentFinalVideo`, an `AgentFinalVideoRenderer`
|
|
82
|
+
exported from that entry point. The callback receives `{ product, threadId, flowIndex, assetVersion, isCurrent }`
|
|
83
|
+
and returns `running`, `completed` with `video_url`, or `failed` with a safe
|
|
84
|
+
`failure: { stage, reason, retryable }`. It closes over the authenticated website
|
|
85
|
+
context; no credentials are passed to the callback. The website owns render
|
|
86
|
+
execution, shared deduplication and bounded waiting. Use `assetVersion` with stable
|
|
87
|
+
composition inputs to identify prepared assets. After preparing, call `isCurrent()`
|
|
88
|
+
immediately before recording or submitting a new render; false means return `running`
|
|
89
|
+
without submitting. MCP owns this check of the active run and final asset version.
|
|
90
|
+
|
|
91
|
+
Polling `get_task_status` or `get_task_result` can render an existing agent's final
|
|
92
|
+
assembly once its latest final asset reports status `102` or `2`; it does not
|
|
93
|
+
regenerate source assets. An active agent run prevents rendering. The client checks
|
|
94
|
+
the thread and selected final flow/version/readiness again after the callback before returning media.
|
|
95
|
+
Missing rendering capability or flow reference returns a `final_render` failure.
|
|
96
|
+
Completed status includes `video_url`; result includes `result.video_url`. An agent
|
|
97
|
+
video still rendering returns `running` with a polling message from either tool.
|
|
81
98
|
|
|
82
99
|
This package depends on Freebeat online services. Available source platforms, effect templates, and generation capabilities may change with backend updates.
|
|
83
100
|
|
|
84
101
|
## Tools
|
|
85
102
|
|
|
86
|
-
22 tools are available with full scopes.
|
|
103
|
+
22 tools are available with full scopes. Successful responses and tool errors are projected through their declared output schemas before both MCP text and structured content are built; undeclared object properties are excluded.
|
|
104
|
+
|
|
105
|
+
Tool errors set `isError: true` and return `success: false`, `error`, and `code`
|
|
106
|
+
in both representations. A rejected credit approval may also include
|
|
107
|
+
`submitted: false`, `quote`, and `max_credits`. Errors omit successful result
|
|
108
|
+
fields. Raw handler text and metadata are excluded; input validation errors return
|
|
109
|
+
fixed `INVALID_PARAMS` guidance without echoing the rejected values.
|
|
87
110
|
|
|
88
111
|
### `get_credit_balance` and `quote_generation`
|
|
89
112
|
|
|
@@ -95,11 +118,34 @@ account discounts or allowances and never charge credits. Missing or unsupported
|
|
|
95
118
|
rules are not treated as free. Text, effects, singing, and multi-stage agents do not
|
|
96
119
|
currently expose a complete upfront quote through their service contracts.
|
|
97
120
|
|
|
98
|
-
|
|
121
|
+
Every paid call needs one explicit user consent:
|
|
99
122
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
| Current quote | Consent to send | What is checked |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| `quoted` | `max_credits` with the user-approved numeric ceiling | The current quote must not exceed it. |
|
|
126
|
+
| `unavailable` | `accept_unknown_cost: true`, without `max_credits` | The user explicitly accepts an unknown total. No total cap is enforced. |
|
|
127
|
+
|
|
128
|
+
Missing consent or both consent modes are refused. Never remove or raise a ceiling,
|
|
129
|
+
or switch to unknown-cost consent, without new user approval. Agent videos charge
|
|
130
|
+
per stage; a submission-time check cannot cap the whole run.
|
|
131
|
+
|
|
132
|
+
After the user requests creation with Freebeat and approves the quote or explicitly
|
|
133
|
+
accepts an unknown total, call the appropriate Freebeat generation tool; do not
|
|
134
|
+
substitute another generator.
|
|
135
|
+
|
|
136
|
+
A production diagnosis on 2026-10-27 observed 855 credits for the video step alone
|
|
137
|
+
of a 15-second 720p dance, with planning and images extra: on the order of 1,000
|
|
138
|
+
credits. This is a historical configuration example, not a current quote or ceiling.
|
|
139
|
+
The agent's actual default model is resolved inside its backend and is not exposed
|
|
140
|
+
by the pricing contract, so this adapter does not invent a live minimum from a model list.
|
|
141
|
+
|
|
142
|
+
All task types expose `billing: { charged, refunded, net, refund_state }`.
|
|
143
|
+
Missing amounts or state are `null`; estimates and next-step requirements are not
|
|
144
|
+
charges. `net` is computed only when both charged and refunded are reported.
|
|
145
|
+
`used_credits` continues to expose the reported charge. Failed and paused tasks also
|
|
146
|
+
expose `failure: { stage, reason, retryable }`, with unknown stage or retryability
|
|
147
|
+
as `null`. A pending refund is not money already returned. Raw stacks and internal
|
|
148
|
+
identifiers are excluded from failure text.
|
|
103
149
|
|
|
104
150
|
### `upload_audio`
|
|
105
151
|
|
|
@@ -159,7 +205,11 @@ Generate original audio from a `model_id` and `prompt`, with optional lyrics, in
|
|
|
159
205
|
Pass the completed `result.music_id` (a reference such as `music:123`) straight into
|
|
160
206
|
`generate_music_video`, `generate_dance_video`, or `generate_lyric_video`. The video
|
|
161
207
|
call resolves and prepares your generated song automatically. If audio analysis is
|
|
162
|
-
still running
|
|
208
|
+
still running after a short bounded wait, the tool returns `status: preparing`, a numeric
|
|
209
|
+
`music_id`, and `retry_after_seconds`, without a `task_id`. Wait, then call the same
|
|
210
|
+
tool with the same approved inputs and the returned numeric `music_id`; do not send
|
|
211
|
+
the original `music:<task>` again. No paid video starts until ready. No download or
|
|
212
|
+
manual re-upload is required.
|
|
163
213
|
Music submissions require a current price rule; stale catalog credit amounts are
|
|
164
214
|
never sent as the price.
|
|
165
215
|
|
|
@@ -173,6 +223,16 @@ Lip-sync an existing clip to audio. Provide `video_url`, `video_duration_ms`, an
|
|
|
173
223
|
|
|
174
224
|
### `list_effects`
|
|
175
225
|
|
|
226
|
+
Returns one page of supported effects: `page` starts at `1` (default), and
|
|
227
|
+
`page_size` defaults to `20`, with an allowed range of `1`–`100`. The response
|
|
228
|
+
includes `total`, `page`, `page_size`, and `next_page`; follow `next_page` until it
|
|
229
|
+
is `null`. A page beyond the end returns an empty `effects` array and the actual
|
|
230
|
+
`total`, with `next_page: null`.
|
|
231
|
+
|
|
232
|
+
Each call reads the complete backend catalog within a shared 30-second deadline,
|
|
233
|
+
at most 100 backend pages and 10,000 effects. Exceeding any budget returns an
|
|
234
|
+
error without a partial catalog or total; repeated backend cursors also fail.
|
|
235
|
+
|
|
176
236
|
List supported effects with:
|
|
177
237
|
|
|
178
238
|
- `effect_id`
|
|
@@ -202,7 +262,7 @@ Recommended flow:
|
|
|
202
262
|
- optional `upload_image` if you want to replace the effect's default image
|
|
203
263
|
- `generate_effect`
|
|
204
264
|
- `get_task_status`
|
|
205
|
-
- `get_task_result`
|
|
265
|
+
- `get_task_result` after status is `completed`, `failed`, or `action_required`
|
|
206
266
|
|
|
207
267
|
Parameters:
|
|
208
268
|
|
|
@@ -250,7 +310,7 @@ List the models Freebeat publishes right now. `type` is `image` (for `generate_i
|
|
|
250
310
|
|
|
251
311
|
### `get_model_help`
|
|
252
312
|
|
|
253
|
-
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`
|
|
313
|
+
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.
|
|
254
314
|
|
|
255
315
|
### `generate_image`
|
|
256
316
|
|
|
@@ -275,15 +335,24 @@ Parameters:
|
|
|
275
335
|
|
|
276
336
|
Freebeat validates the options per model; check `get_model_help` first and read `message` if a request is rejected.
|
|
277
337
|
|
|
338
|
+
For image, image-edit, and video batches, `success: true` means the response was
|
|
339
|
+
retrieved; check `accepted_count` and `items[].accepted` to see what was accepted.
|
|
340
|
+
If Freebeat provides no specific rejection reason, the response says so without
|
|
341
|
+
guessing the cause. Structured required and available credit amounts can provide
|
|
342
|
+
actionable credit guidance. `accepted_credits` describes acceptance, not an actual
|
|
343
|
+
charge. When only accepted credits are reported, including `0`, check
|
|
344
|
+
`get_task_status` billing for actual charges and refunds. Zero-charge statements
|
|
345
|
+
require an explicitly reported charge of `0`.
|
|
346
|
+
|
|
278
347
|
### `generate_text`
|
|
279
348
|
|
|
280
|
-
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.
|
|
349
|
+
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.
|
|
281
350
|
|
|
282
351
|
### `get_task_status`
|
|
283
352
|
|
|
284
|
-
Poll a Freebeat async task or Open RPC batch until it reaches a terminal status.
|
|
353
|
+
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`.
|
|
285
354
|
|
|
286
|
-
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.
|
|
355
|
+
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.
|
|
287
356
|
|
|
288
357
|
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.
|
|
289
358
|
|
|
@@ -293,17 +362,16 @@ Returns a stable task envelope including:
|
|
|
293
362
|
- `task_type`
|
|
294
363
|
- `status`
|
|
295
364
|
- `error_message` optional, present when backend reports a failed task
|
|
296
|
-
- `error_code` optional, present when backend reports a failed task
|
|
297
365
|
- `message` optional, present when status is `completed` or `failed`
|
|
298
366
|
- `items` optional, present for Open RPC batches and containing `image_url`, `video_url`, or `edit_images` when available
|
|
299
367
|
|
|
300
368
|
### `get_task_result`
|
|
301
369
|
|
|
302
|
-
Retrieve the output for a completed task.
|
|
370
|
+
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`.
|
|
303
371
|
|
|
304
|
-
If the task is
|
|
372
|
+
If the task is pending or running, this tool returns error code `TASK_NOT_COMPLETED`.
|
|
305
373
|
|
|
306
|
-
If the task
|
|
374
|
+
If the task failed or paused, this tool returns the same `failure` and `billing` contract as status, without requiring media output.
|
|
307
375
|
|
|
308
376
|
For completed agent videos, `result` is an object containing:
|
|
309
377
|
|
|
@@ -314,3 +382,8 @@ Completed effect generation results use the same `result` object fields:
|
|
|
314
382
|
|
|
315
383
|
- `video_url`
|
|
316
384
|
- `cover_url`
|
|
385
|
+
|
|
386
|
+
Completed results return only the fields defined by the output schema: `video_url`,
|
|
387
|
+
`audio_url`, `cover_url`, `title`, `lyrics`, `duration_ms`, and `music_id`. Extra
|
|
388
|
+
upstream fields are excluded. Unmapped upstream error codes are not relayed; Open
|
|
389
|
+
RPC item code fields are `null`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { maxCreditsSchema, creditQuoteSchema } from "../../../core/credit-approval.js";
|
|
1
|
+
import { acceptUnknownCostSchema, CREDIT_APPROVAL_DESCRIPTION, maxCreditsSchema, creditQuoteSchema } from "../../../core/credit-approval.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { AGENT_PRODUCTS } from "../../../core/agent-products.js";
|
|
4
|
-
import { formatToolError,
|
|
4
|
+
import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
|
|
5
5
|
import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
|
|
6
6
|
const AGENT_VIDEO_TOOLS = {
|
|
7
7
|
music_video: {
|
|
@@ -12,7 +12,7 @@ const AGENT_VIDEO_TOOLS = {
|
|
|
12
12
|
dance: {
|
|
13
13
|
name: "generate_dance_video",
|
|
14
14
|
title: "Generate dance video",
|
|
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. 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
|
+
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.",
|
|
16
16
|
},
|
|
17
17
|
lyric_video: {
|
|
18
18
|
name: "generate_lyric_video",
|
|
@@ -23,13 +23,14 @@ const AGENT_VIDEO_TOOLS = {
|
|
|
23
23
|
export function registerGenerateAgentVideoTools(server, client) {
|
|
24
24
|
for (const product of Object.keys(AGENT_VIDEO_TOOLS)) {
|
|
25
25
|
const tool = AGENT_VIDEO_TOOLS[product];
|
|
26
|
-
|
|
27
|
-
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}`,
|
|
28
28
|
annotations: { title: tool.title, ...CREATE_TOOL_ANNOTATIONS },
|
|
29
29
|
inputSchema: {
|
|
30
30
|
max_credits: maxCreditsSchema,
|
|
31
|
+
accept_unknown_cost: acceptUnknownCostSchema,
|
|
31
32
|
music_id: z.union([z.number().int().positive(), z.string().regex(/^music:.+/)])
|
|
32
|
-
.describe("An analyzed music_id from upload_audio, or result.music_id from a completed generate_music task. Generated songs are prepared automatically; no
|
|
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."),
|
|
33
34
|
prompt: z
|
|
34
35
|
.string()
|
|
35
36
|
.trim()
|
|
@@ -71,20 +72,24 @@ export function registerGenerateAgentVideoTools(server, client) {
|
|
|
71
72
|
outputSchema: {
|
|
72
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
|
-
|
|
90
|
+
if ("music_id" in result)
|
|
91
|
+
return toolResult({ success: true, ...result });
|
|
92
|
+
return toolResult({
|
|
88
93
|
success: true,
|
|
89
94
|
quote: result.quote,
|
|
90
95
|
task_id: result.task_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-agent-videos.js","sourceRoot":"","sources":["../../../../src/capabilities/agents/tools/generate-agent-videos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,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,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K,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,
|
|
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
|
-
|
|
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
|
|
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,
|
|
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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AQ;oBACnD,uFAAuF;aAC1F,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,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,
|
|
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
|
-
|
|
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
|
|
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-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,
|
|
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,IAAI,CAAC;AAEzC,MAAM,UAAU,uBAAuB,CACrC,MAAiB,EACjB,MAA2E,EAC3E,eAAe,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AAI,CAAC;oBACH,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC;wBACzD,QAAQ;wBACR,SAAS,EAAE,iBAAiB;wBAC5B,WAAW,EAAE,mBAAmB,CAAC,QAAQ,CAAC;wBAC1C,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC;qBACzB,CAAC,CAAC;oBACH,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBACjC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACzB,OAAO,CAAC,KAAK,CACX,+BAA+B,KAAK,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI;4BAC/D,GAAG,SAAS,CAAC,MAAM,wDAAwD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpG,CAAC;oBACJ,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YAED,OAAO,UAAU,CAAC;gBAChB,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,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,
|
|
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
|
-
|
|
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
|
|
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,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,
|
|
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,EAAE,eAAe;YAC1B,CAAC,CAAC,qZAAqZ;YACvZ,CAAC,CAAC,mVAAmV;QACvV,WAAW,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,uBAAuB,EAAE;QAClE,KAAK,E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,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"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
+
import { CREDIT_APPROVAL_DESCRIPTION } from "../../core/credit-approval.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { PAID_TOOLS } from "../../core/paid-tools.js";
|
|
3
|
-
import { formatToolError,
|
|
4
|
+
import { formatToolError, toolResult, registerTool } from "../../core/response.js";
|
|
4
5
|
import { READ_ONLY_TOOL_ANNOTATIONS } from "../../core/tool-annotations.js";
|
|
5
6
|
export function registerCreditTools(server, client) {
|
|
6
|
-
|
|
7
|
+
registerTool(server, "get_credit_balance", {
|
|
7
8
|
description: "Read the signed-in Freebeat account's available credit balance. Does not charge credits or start generation.",
|
|
8
9
|
annotations: { title: "Get credit balance", ...READ_ONLY_TOOL_ANNOTATIONS },
|
|
9
10
|
inputSchema: {},
|
|
10
11
|
outputSchema: { credits: z.number().describe("Available Freebeat credits.") },
|
|
11
12
|
}, async () => {
|
|
12
13
|
try {
|
|
13
|
-
return
|
|
14
|
+
return toolResult(await client.getCreditBalance());
|
|
14
15
|
}
|
|
15
16
|
catch (error) {
|
|
16
17
|
return formatToolError(error);
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
description:
|
|
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.",
|
|
21
22
|
annotations: { title: "Quote generation", ...READ_ONLY_TOOL_ANNOTATIONS },
|
|
22
23
|
inputSchema: {
|
|
23
24
|
tool: z.enum(PAID_TOOLS).describe("The paid tool to quote."),
|
|
@@ -31,7 +32,7 @@ export function registerCreditTools(server, client) {
|
|
|
31
32
|
},
|
|
32
33
|
}, async ({ tool, parameters }) => {
|
|
33
34
|
try {
|
|
34
|
-
return
|
|
35
|
+
return toolResult(await client.quoteGeneration(tool, parameters));
|
|
35
36
|
}
|
|
36
37
|
catch (error) {
|
|
37
38
|
return formatToolError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/capabilities/credits/register.ts"],"names":[],"mappings":"
|
|
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,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAG5E,MAAM,UAAU,mB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ChC,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,12 +1,12 @@
|
|
|
1
|
-
import { maxCreditsSchema, creditQuoteSchema } from "../../../core/credit-approval.js";
|
|
1
|
+
import { acceptUnknownCostSchema, CREDIT_APPROVAL_DESCRIPTION, maxCreditsSchema, creditQuoteSchema } from "../../../core/credit-approval.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { AppError } from "../../../core/errors.js";
|
|
4
4
|
import { normalizeGenerationPrompt } from "../../../core/prompt.js";
|
|
5
|
-
import { formatToolError,
|
|
5
|
+
import { formatToolError, toolResult, registerTool } from "../../../core/response.js";
|
|
6
6
|
import { CREATE_TOOL_ANNOTATIONS } from "../../../core/tool-annotations.js";
|
|
7
7
|
export function registerGenerateEffectTool(server, client) {
|
|
8
|
-
|
|
9
|
-
description:
|
|
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.",
|
|
10
10
|
annotations: { title: "Generate effect", ...CREATE_TOOL_ANNOTATIONS },
|
|
11
11
|
outputSchema: {
|
|
12
12
|
quote: creditQuoteSchema.optional(),
|
|
@@ -28,6 +28,7 @@ export function registerGenerateEffectTool(server, client) {
|
|
|
28
28
|
},
|
|
29
29
|
inputSchema: {
|
|
30
30
|
max_credits: maxCreditsSchema,
|
|
31
|
+
accept_unknown_cost: acceptUnknownCostSchema,
|
|
31
32
|
effect_id: z.number().int().describe("Effect ID returned by list_effects."),
|
|
32
33
|
music_id: z
|
|
33
34
|
.number()
|
|
@@ -51,7 +52,7 @@ export function registerGenerateEffectTool(server, client) {
|
|
|
51
52
|
.length(1, "reference_image_urls must contain exactly one image URL")
|
|
52
53
|
.describe("Exactly one image URL. Recommended: use list_effects.image_url. You may also use a single uploaded image URL from upload_image."),
|
|
53
54
|
},
|
|
54
|
-
}, async ({ max_credits, 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, }) => {
|
|
55
56
|
try {
|
|
56
57
|
const normalizedPrompt = normalizeGenerationPrompt(prompt);
|
|
57
58
|
if (!Number.isInteger(effect_id)) {
|
|
@@ -64,6 +65,7 @@ export function registerGenerateEffectTool(server, client) {
|
|
|
64
65
|
return formatToolError(new AppError("reference_image_urls must contain exactly one image URL", "INVALID_PARAMS"));
|
|
65
66
|
}
|
|
66
67
|
const result = await client.generateEffect({
|
|
68
|
+
accept_unknown_cost,
|
|
67
69
|
max_credits,
|
|
68
70
|
effect_id,
|
|
69
71
|
music_id,
|
|
@@ -71,7 +73,7 @@ export function registerGenerateEffectTool(server, client) {
|
|
|
71
73
|
watermark: watermark ?? false,
|
|
72
74
|
reference_image_urls,
|
|
73
75
|
});
|
|
74
|
-
return
|
|
76
|
+
return toolResult({
|
|
75
77
|
success: true,
|
|
76
78
|
quote: result.quote,
|
|
77
79
|
task_id: result.task_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-effect.js","sourceRoot":"","sources":["../../../../src/capabilities/effects/tools/generate-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-effect.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