@j-o-r/hello-dave 0.1.1 → 0.1.4
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 +42 -25
- package/README.md +81 -221
- package/TODO.md +173 -35
- package/agents/agent_creator.js +105 -0
- package/agents/agent_creator.prompt.md +371 -0
- package/agents/ask_agent.js +64 -127
- package/agents/claude_agent.js +68 -0
- package/agents/code_agent.js +55 -135
- package/agents/code_agent.prompt.md +50 -0
- package/agents/echo_agent.js +76 -0
- package/agents/financial_expert.js +75 -0
- package/agents/gpt_agent.js +52 -103
- package/agents/gpt_code.js +81 -0
- package/agents/grok_agent.js +58 -114
- package/agents/minimax_agent.js +92 -0
- package/agents/mureka_agent.js +77 -0
- package/agents/planner_agent.js +172 -0
- package/agents/stability_agent.js +87 -0
- package/agents/test_agent.js +75 -157
- package/agents/weather_agent.js +73 -0
- package/agents/workflow_agent.js +189 -0
- package/bin/dave.js +436 -184
- package/docs/bin-dave.md +85 -35
- package/docs/cdn-ssh.md +100 -0
- package/docs/creating-agents.md +301 -0
- package/docs/creating-toolsets.md +336 -0
- package/docs/docs-organization.md +48 -0
- package/docs/project-overview.md +86 -51
- package/lib/API/elevenlabs.io/music.compose.md +441 -0
- package/lib/API/elevenlabs.io/music.create-composition-plan.md +370 -0
- package/lib/API/elevenlabs.io/music.stream.md +425 -0
- package/lib/API/lalal.ai/lalal.js +445 -0
- package/lib/API/lalal.ai/openapi.json +2614 -0
- package/lib/API/minimax/ImageToolset.js +82 -37
- package/lib/API/minimax/MusicToolset.js +125 -79
- package/lib/API/minimax/VideoToolset.js +170 -167
- package/lib/API/minimax/image.js +5 -1
- package/lib/API/minimax/music.js +210 -23
- package/lib/API/minimax/video.js +242 -53
- package/lib/API/mureka/MusicToolset.js +646 -0
- package/lib/API/mureka/README.md +41 -0
- package/lib/API/mureka/index.js +7 -0
- package/lib/API/mureka/music.js +658 -0
- package/lib/API/openai.com/index.js +7 -0
- package/lib/API/openai.com/{reponses/text.js → responses.js} +64 -18
- package/lib/API/openai.com/video.create.character.md +40 -0
- package/lib/API/openai.com/video.create.md +219 -0
- package/lib/API/openai.com/video.delete.md +44 -0
- package/lib/API/openai.com/video.download.md +31 -0
- package/lib/API/openai.com/video.edit.md +155 -0
- package/lib/API/openai.com/video.extend.md +166 -0
- package/lib/API/openai.com/video.fetch.character.md +43 -0
- package/lib/API/openai.com/video.js +784 -0
- package/lib/API/openai.com/video.list.md +201 -0
- package/lib/API/openai.com/video.remix.md +175 -0
- package/lib/API/openai.com/video.retrieve.md +139 -0
- package/lib/API/openai.com/videoToolset.js +616 -0
- package/lib/API/stability.ai/ImageToolset.js +131 -40
- package/lib/API/stability.ai/MusicToolset.js +79 -47
- package/lib/API/stability.ai/audio.js +63 -131
- package/lib/API/x.ai/chat.responses.md +1040 -0
- package/lib/API/x.ai/image.js +229 -59
- package/lib/API/x.ai/imageToolset.js +376 -0
- package/lib/API/x.ai/index.js +1 -1
- package/lib/API/x.ai/responses.js +9 -18
- package/lib/Agent.js +271 -0
- package/lib/Agent.js.old +284 -0
- package/lib/AgentLauncher.js +562 -0
- package/lib/Cli.js +87 -13
- package/lib/Prompt.js +23 -1
- package/lib/Session.js +5 -4
- package/lib/ToolSet.js +102 -6
- package/lib/agentLoader.js +369 -0
- package/lib/cdn.js +67 -231
- package/lib/{CdnToolset.js → cdnToolset.js} +47 -64
- package/lib/defaultToolsets.js +43 -0
- package/lib/fafs.js +1 -1
- package/lib/genericToolset.js +442 -119
- package/lib/handOffToolset.js +179 -0
- package/lib/index.js +34 -27
- package/lib/toolsetLoader.js +248 -0
- package/package.json +11 -5
- package/types/API/lalal.ai/lalal.d.ts +116 -0
- package/types/API/minimax/image.d.ts +2 -1
- package/types/API/minimax/music.d.ts +189 -26
- package/types/API/minimax/video.d.ts +100 -31
- package/types/API/mureka/index.d.ts +7 -0
- package/types/API/mureka/music.d.ts +472 -0
- package/types/API/openai.com/index.d.ts +7 -0
- package/types/API/openai.com/{reponses/text.d.ts → responses.d.ts} +11 -11
- package/types/API/openai.com/video.d.ts +409 -0
- package/types/API/openai.com/videoToolset.d.ts +24 -0
- package/types/API/stability.ai/audio.d.ts +14 -103
- package/types/API/stability.ai/image.d.ts +2 -2
- package/types/API/x.ai/image.d.ts +138 -26
- package/types/API/x.ai/imageToolset.d.ts +3 -0
- package/types/API/x.ai/index.d.ts +1 -1
- package/types/API/x.ai/responses.d.ts +4 -4
- package/types/Agent.d.ts +123 -0
- package/types/AgentLauncher.d.ts +222 -0
- package/types/Cli.d.ts +28 -8
- package/types/Prompt.d.ts +23 -5
- package/types/Session.d.ts +1 -1
- package/types/ToolSet.d.ts +10 -0
- package/types/agentLoader.d.ts +78 -0
- package/types/cdn.d.ts +15 -90
- package/types/defaultToolsets.d.ts +9 -0
- package/types/fafs.d.ts +1 -1
- package/types/genericToolset.d.ts +1 -1
- package/types/handOffToolset.d.ts +28 -0
- package/types/index.d.ts +19 -17
- package/types/toolsetLoader.d.ts +114 -0
- package/utils/format_log.js +101 -23
- package/utils/launch_agent.js +18 -0
- package/utils/list_sessions.sh +13 -5
- package/utils/search_sessions.sh +65 -29
- package/utils/toolsets.js +33 -0
- package/README.md.bak.1779452127 +0 -240
- package/agents/codeserver.sh +0 -47
- package/agents/daisy_agent.js +0 -173
- package/agents/docs_agent.js +0 -148
- package/agents/memory_agent.js +0 -263
- package/agents/minimax.js +0 -173
- package/agents/npm_agent.js +0 -202
- package/agents/prompt_agent.js +0 -133
- package/agents/readme_agent.js +0 -148
- package/agents/spawn_agent.js +0 -160
- package/agents/stability.js +0 -173
- package/agents/todo_agent.js +0 -175
- package/bin/codeDave +0 -58
- package/docs/agent-dave-websocket-protocol.md +0 -180
- package/docs/agent-manager.md +0 -244
- package/docs/codeserver-pattern.md +0 -191
- package/docs/generic-toolset.md +0 -326
- package/docs/howtos/agent-networking.md +0 -253
- package/docs/howtos/spawn-agents.md.bak +0 -200
- package/docs/howtos/spawn-agents.md.bak_new +0 -200
- package/docs/multi-agent-clusters.md +0 -265
- package/docs/music-toolsets.md +0 -137
- package/docs/path-resolution-best-practices.md +0 -104
- package/docs/plans/minimax-music-generation.md +0 -80
- package/docs/plans/unified-agent-architecture.md +0 -146
- package/docs/plans/websocket-streaming-plan.md.bak +0 -317
- package/docs/prompt/spawn_agent.md +0 -175
- package/docs/prompt/spawn_agent.md.bak +0 -201
- package/docs/prompt/task_clarification_and_documentation.md +0 -35
- package/docs/prompt-class.md +0 -141
- package/docs/todo-archive-infra-2026-04-21.md +0 -15
- package/docs/todo-archive-v0.0.8.md +0 -1
- package/docs/todo-archive-v0.1.0.md +0 -32
- package/docs/todo-archive.md +0 -44
- package/docs/tools-syntax-validation.md +0 -121
- package/docs/toolset.md +0 -164
- package/docs/xai-responses.md +0 -111
- package/docs/xai_collections.md +0 -106
- package/lib/API/x.ai/ImageToolset.js +0 -165
- package/lib/API/x.ai/text.js +0 -415
- package/lib/AgentClient.js +0 -248
- package/lib/AgentManager.js +0 -245
- package/lib/AgentServer.js +0 -404
- package/lib/wsCli.js +0 -287
- package/lib/wsIO.js +0 -90
- package/types/API/x.ai/text.d.ts +0 -286
- package/types/AgentClient.d.ts +0 -109
- package/types/AgentManager.d.ts +0 -100
- package/types/AgentServer.d.ts +0 -89
- package/types/wsCli.d.ts +0 -17
- package/types/wsIO.d.ts +0 -30
- package/utils/test.sh +0 -46
- /package/docs/{suggestions.md → _notes/token-counts.md} +0 -0
- /package/lib/API/openai.com/{reponses/MESSAGES.md → MESSAGES.md} +0 -0
- /package/types/API/{x.ai/ImageToolset.d.ts → mureka/MusicToolset.d.ts} +0 -0
- /package/types/{CdnToolset.d.ts → cdnToolset.d.ts} +0 -0
|
@@ -3,46 +3,169 @@
|
|
|
3
3
|
* @module minimax/VideoToolset
|
|
4
4
|
* @description Comprehensive ToolSet for the Minimax Video Generation API.
|
|
5
5
|
*
|
|
6
|
-
* This ToolSet exposes the
|
|
7
|
-
* and
|
|
8
|
-
*
|
|
6
|
+
* This ToolSet exposes the Minimax Video API with descriptive function-call
|
|
7
|
+
* schemas and compact, self-describing function responses. Tool responses
|
|
8
|
+
* preserve durable follow-up references such as task_id, file_id, video_url,
|
|
9
|
+
* local_path, source image URLs, model, mode, dimensions, and status so the
|
|
10
|
+
* assistant can repeat those values in a normal assistant message before old
|
|
11
|
+
* raw tool I/O is pruned.
|
|
9
12
|
*
|
|
10
|
-
*
|
|
13
|
+
* Video generation is asynchronous. The main `generate_video_minimax` tool
|
|
14
|
+
* automatically waits for completion and downloads the MP4 to .cache/minimax/.
|
|
11
15
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
16
|
+
* IMPORTANT: `wait_for_video_ready_minimax` is an emergency / last-chance tool.
|
|
17
|
+
* Use it only when `generate_video_minimax` has timed out. Timeout errors from
|
|
18
|
+
* the wrapper include the `task_id` so the task can be polled later.
|
|
19
|
+
*
|
|
20
|
+
* ============================================================
|
|
21
|
+
* CLEAR MODEL ↔ MODE MAPPING (enforced by the underlying video.js wrapper)
|
|
22
|
+
* ============================================================
|
|
23
|
+
* | Mode | Supported Models | Required Fields |
|
|
24
|
+
* |-----------------------|-------------------------------------------------------|-----------------------------|
|
|
25
|
+
* | Text-to-Video | MiniMax-Hailuo-2.3, MiniMax-Hailuo-02, T2V-01-* | prompt |
|
|
26
|
+
* | Image-to-Video | MiniMax-Hailuo-2.3 / 2.3-Fast / 02, I2V-01-* | first_frame_image |
|
|
27
|
+
* | First & Last Frame | MiniMax-Hailuo-02 ONLY | last_frame_image |
|
|
28
|
+
* | Subject-Reference | S2V-01 ONLY | subject_reference |
|
|
29
|
+
*
|
|
30
|
+
* IMAGE REFERENCE RULES:
|
|
31
|
+
* - `first_frame_image`, `last_frame_image`, and all images inside
|
|
32
|
+
* `subject_reference` MUST be public HTTP/HTTPS URLs.
|
|
33
|
+
* - Base64 / data: URLs are explicitly NOT supported and are rejected by the
|
|
34
|
+
* underlying wrapper before the API call.
|
|
14
35
|
*
|
|
15
36
|
* @example
|
|
16
37
|
* import videoToolset from './lib/API/minimax/VideoToolset.js';
|
|
17
38
|
*
|
|
18
|
-
* // Use in an agent:
|
|
19
39
|
* const toolset = agent.getToolset();
|
|
20
40
|
* toolset.merge(videoToolset);
|
|
21
41
|
*/
|
|
22
42
|
|
|
23
|
-
import ToolSet
|
|
43
|
+
import ToolSet from '../../ToolSet.js';
|
|
24
44
|
import * as minimax from './video.js';
|
|
25
45
|
|
|
26
46
|
const tools = new ToolSet('auto');
|
|
27
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Serialize a tool response as pretty JSON.
|
|
50
|
+
*
|
|
51
|
+
* @param {Record<string, unknown>} value Response payload to serialize.
|
|
52
|
+
* @returns {string} Pretty JSON response for function-calling output.
|
|
53
|
+
*/
|
|
54
|
+
function json(value) {
|
|
55
|
+
return JSON.stringify(value, null, 2);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Infer the Minimax video mode from submitted parameters.
|
|
60
|
+
*
|
|
61
|
+
* @param {Record<string, unknown>} params Tool parameters.
|
|
62
|
+
* @returns {'text'|'image'|'first-last'|'subject'} Inferred mode.
|
|
63
|
+
*/
|
|
64
|
+
function inferMode(params) {
|
|
65
|
+
if (params.last_frame_image) return 'first-last';
|
|
66
|
+
if (params.subject_reference) return 'subject';
|
|
67
|
+
if (params.first_frame_image) return 'image';
|
|
68
|
+
return 'text';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Return the first subject-reference image URL, if present.
|
|
73
|
+
*
|
|
74
|
+
* @param {unknown} subjectReference Subject reference parameter.
|
|
75
|
+
* @returns {string|undefined} First subject image URL.
|
|
76
|
+
*/
|
|
77
|
+
function firstSubjectImageUrl(subjectReference) {
|
|
78
|
+
if (!Array.isArray(subjectReference)) return undefined;
|
|
79
|
+
const first = subjectReference[0];
|
|
80
|
+
if (!first || !Array.isArray(first.image)) return undefined;
|
|
81
|
+
return first.image[0];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Build a compact, self-describing Minimax video generation response.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} tool Tool/function name that produced the response.
|
|
88
|
+
* @param {Record<string, unknown>} params Original tool parameters.
|
|
89
|
+
* @param {Record<string, unknown>} result Wrapper result object.
|
|
90
|
+
* @returns {string} JSON response containing durable references and assistant instructions.
|
|
91
|
+
*/
|
|
92
|
+
function videoGenerationResponse(tool, params, result) {
|
|
93
|
+
const mode = inferMode(params);
|
|
94
|
+
|
|
95
|
+
return json({
|
|
96
|
+
tool,
|
|
97
|
+
success: true,
|
|
98
|
+
mode,
|
|
99
|
+
prompt: params.prompt,
|
|
100
|
+
model: params.model || (mode === 'subject' ? 'S2V-01' : mode === 'first-last' ? 'MiniMax-Hailuo-02' : 'MiniMax-Hailuo-2.3'),
|
|
101
|
+
task_id: result.task_id,
|
|
102
|
+
taskId: result.task_id,
|
|
103
|
+
file_id: result.file_id,
|
|
104
|
+
fileId: result.file_id,
|
|
105
|
+
video_url: result.video_url,
|
|
106
|
+
videoUrl: result.video_url,
|
|
107
|
+
local_path: result.local_path,
|
|
108
|
+
localPath: result.local_path,
|
|
109
|
+
video_width: result.video_width,
|
|
110
|
+
video_height: result.video_height,
|
|
111
|
+
duration_seconds: params.duration || 6,
|
|
112
|
+
resolution: params.resolution,
|
|
113
|
+
total_duration_ms: result.duration,
|
|
114
|
+
first_frame_image: params.first_frame_image,
|
|
115
|
+
last_frame_image: params.last_frame_image,
|
|
116
|
+
subject_reference: params.subject_reference,
|
|
117
|
+
subject_image_url: firstSubjectImageUrl(params.subject_reference),
|
|
118
|
+
note:
|
|
119
|
+
'Assistant: tell the user the exact task_id, file_id, local_path, and video_url in your normal response. ' +
|
|
120
|
+
'Use local_path as the durable saved MP4 reference for follow-up file/CDN operations. ' +
|
|
121
|
+
'Use task_id for later polling/debugging, file_id for file retrieval, and video_url only while the provider download URL remains valid. ' +
|
|
122
|
+
'If first_frame_image, last_frame_image, or subject_reference was used, repeat the exact source URL(s) when relevant.'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Build a compact, self-describing Minimax video polling response.
|
|
128
|
+
*
|
|
129
|
+
* @param {Record<string, unknown>} params Tool parameters.
|
|
130
|
+
* @param {Record<string, unknown>} result Wrapper result object.
|
|
131
|
+
* @returns {string} JSON response containing status and follow-up references.
|
|
132
|
+
*/
|
|
133
|
+
function videoPollingResponse(params, result) {
|
|
134
|
+
return json({
|
|
135
|
+
tool: 'wait_for_video_ready_minimax',
|
|
136
|
+
success: true,
|
|
137
|
+
task_id: result.task_id || params.task_id,
|
|
138
|
+
taskId: result.task_id || params.task_id,
|
|
139
|
+
status: result.status,
|
|
140
|
+
file_id: result.file_id,
|
|
141
|
+
fileId: result.file_id,
|
|
142
|
+
video_width: result.video_width,
|
|
143
|
+
video_height: result.video_height,
|
|
144
|
+
note:
|
|
145
|
+
'Assistant: tell the user the exact task_id, status, and file_id when present in your normal response. ' +
|
|
146
|
+
'If status is Success, use file_id for retrieval/download follow-up. If status is not Success, keep task_id for later polling.'
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
28
150
|
/* ============================================================
|
|
29
151
|
CORE VIDEO GENERATION (Full async flow with auto-download)
|
|
30
152
|
============================================================ */
|
|
31
153
|
|
|
32
154
|
tools.add(
|
|
33
|
-
'
|
|
155
|
+
'generate_video_minimax',
|
|
34
156
|
'Generate a video using the Minimax Video Generation API. ' +
|
|
35
157
|
'Supports Text-to-Video, Image-to-Video, First & Last Frame, and Subject-Reference modes. ' +
|
|
36
158
|
'Automatically polls until the video is ready, then downloads the MP4 to .cache/minimax/. ' +
|
|
37
|
-
'This is the recommended high-level tool for video generation.'
|
|
159
|
+
'This is the recommended high-level tool for video generation. ' +
|
|
160
|
+
'After success, include the exact task_id, file_id, local_path, and video_url in your assistant response. ' +
|
|
161
|
+
'The local_path is the durable saved MP4 reference; video_url may be temporary. ' +
|
|
162
|
+
'The underlying wrapper enforces model↔mode mapping and strict public-URL validation for all image references. Base64/data: URLs are rejected.',
|
|
38
163
|
{
|
|
39
164
|
type: 'object',
|
|
40
165
|
properties: {
|
|
41
166
|
prompt: {
|
|
42
167
|
type: 'string',
|
|
43
|
-
description: 'Text description of the video, up to 2000 characters. '
|
|
44
|
-
'Supports camera movement commands in [brackets] for supported models. ' +
|
|
45
|
-
'Example: "A cute cat jumping on a wooden table [Static shot]"'
|
|
168
|
+
description: 'Text description of the video, up to 2000 characters. Supports camera movement commands in [brackets] for supported models. Example: "A cute cat jumping on a wooden table [Static shot]". Camera commands: [Truck left/right], [Pan left/right], [Push in/out], [Pedestal up/down], [Tilt up/down], [Zoom in/out], [Shake], [Tracking shot], [Static shot].'
|
|
46
169
|
},
|
|
47
170
|
model: {
|
|
48
171
|
type: 'string',
|
|
@@ -58,35 +181,35 @@ tools.add(
|
|
|
58
181
|
'S2V-01'
|
|
59
182
|
],
|
|
60
183
|
default: 'MiniMax-Hailuo-2.3',
|
|
61
|
-
description: 'Video generation model. '
|
|
62
|
-
'"MiniMax-Hailuo-2.3" = recommended for text-to-video and image-to-video. ' +
|
|
63
|
-
'"MiniMax-Hailuo-02" = good for first-last frame. ' +
|
|
64
|
-
'"S2V-01" = subject reference mode.'
|
|
184
|
+
description: 'Video generation model. The wrapper validates compatibility with the detected mode. Recommended defaults: Text-to-Video → MiniMax-Hailuo-2.3; Image-to-Video → MiniMax-Hailuo-2.3; First & Last Frame → MiniMax-Hailuo-02; Subject-Reference → S2V-01.'
|
|
65
185
|
},
|
|
66
186
|
first_frame_image: {
|
|
67
187
|
type: 'string',
|
|
68
|
-
description: '
|
|
69
|
-
'Formats: JPG, JPEG, PNG, WebP. Size < 20MB. Short side > 300px.'
|
|
188
|
+
description: 'PUBLIC HTTP/HTTPS image_url ONLY (no Base64/data URLs). URL of the first frame image for Image-to-Video or First-Last mode. Preserve this exact URL in the assistant response when relevant.'
|
|
70
189
|
},
|
|
71
190
|
last_frame_image: {
|
|
72
191
|
type: 'string',
|
|
73
|
-
description: '
|
|
192
|
+
description: 'PUBLIC HTTP/HTTPS image_url ONLY (no Base64/data URLs). URL of the last frame image for First & Last Frame mode only; requires model MiniMax-Hailuo-02. Preserve this exact URL in the assistant response when relevant.'
|
|
74
193
|
},
|
|
75
194
|
subject_reference: {
|
|
76
195
|
type: 'array',
|
|
77
196
|
items: {
|
|
78
197
|
type: 'object',
|
|
79
198
|
properties: {
|
|
80
|
-
type: {
|
|
199
|
+
type: {
|
|
200
|
+
type: 'string',
|
|
201
|
+
enum: ['character'],
|
|
202
|
+
description: 'Subject type. Currently only "character" supported.'
|
|
203
|
+
},
|
|
81
204
|
image: {
|
|
82
205
|
type: 'array',
|
|
83
206
|
items: { type: 'string' },
|
|
84
|
-
description: 'Array
|
|
207
|
+
description: 'Array containing exactly one public HTTP/HTTPS image_url. Base64/data URLs are not supported. Preserve exact subject image URL(s) in the assistant response when relevant.'
|
|
85
208
|
}
|
|
86
209
|
},
|
|
87
210
|
required: ['type', 'image']
|
|
88
211
|
},
|
|
89
|
-
description: 'For Subject-Reference to Video (S2V-01 model).
|
|
212
|
+
description: 'For Subject-Reference to Video (S2V-01 model only). Each reference must contain exactly one public HTTP/HTTPS image URL.'
|
|
90
213
|
},
|
|
91
214
|
prompt_optimizer: {
|
|
92
215
|
type: 'boolean',
|
|
@@ -107,12 +230,7 @@ tools.add(
|
|
|
107
230
|
resolution: {
|
|
108
231
|
type: 'string',
|
|
109
232
|
enum: ['512P', '720P', '768P', '1080P'],
|
|
110
|
-
description: 'Video resolution. Options depend on model and duration. '
|
|
111
|
-
'Example: "768P" or "1080P".'
|
|
112
|
-
},
|
|
113
|
-
callback_url: {
|
|
114
|
-
type: 'string',
|
|
115
|
-
description: 'Optional callback URL for async status updates.'
|
|
233
|
+
description: 'Video resolution. Options depend on model and duration. Examples: "768P" or "1080P".'
|
|
116
234
|
},
|
|
117
235
|
max_wait_ms: {
|
|
118
236
|
type: 'integer',
|
|
@@ -133,164 +251,49 @@ tools.add(
|
|
|
133
251
|
},
|
|
134
252
|
async (params) => {
|
|
135
253
|
const result = await minimax.generateVideo(params.prompt, params);
|
|
136
|
-
|
|
137
|
-
return JSON.stringify({
|
|
138
|
-
task_id: result.task_id,
|
|
139
|
-
file_id: result.file_id,
|
|
140
|
-
video_url: result.video_url,
|
|
141
|
-
local_path: result.local_path,
|
|
142
|
-
video_width: result.video_width,
|
|
143
|
-
video_height: result.video_height,
|
|
144
|
-
total_duration_ms: result.duration,
|
|
145
|
-
raw_responses: result.raw,
|
|
146
|
-
note: 'Video has been automatically saved to local_path. ' +
|
|
147
|
-
'The generation was polled until completion. Use max_wait_ms to adjust timeout.'
|
|
148
|
-
}, null, 2);
|
|
254
|
+
return videoGenerationResponse('generate_video_minimax', params, result);
|
|
149
255
|
}
|
|
150
256
|
);
|
|
151
257
|
|
|
152
258
|
/* ============================================================
|
|
153
|
-
|
|
259
|
+
EMERGENCY / LAST-CHANCE POLLING TOOL
|
|
154
260
|
============================================================ */
|
|
155
261
|
|
|
156
262
|
tools.add(
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'
|
|
160
|
-
'
|
|
263
|
+
'wait_for_video_ready_minimax',
|
|
264
|
+
'EMERGENCY / LAST-CHANCE tool to poll a video generation task that timed out during generate_video_minimax. ' +
|
|
265
|
+
'Use this only as a last resort when the main generation call has already timed out. ' +
|
|
266
|
+
'It continues polling until the video is ready (Success), fails, or max_wait_ms is reached. ' +
|
|
267
|
+
'After success or timeout recovery, include the exact task_id, status, and file_id when present in your assistant response.',
|
|
161
268
|
{
|
|
162
269
|
type: 'object',
|
|
163
270
|
properties: {
|
|
164
|
-
|
|
271
|
+
task_id: {
|
|
165
272
|
type: 'string',
|
|
166
|
-
description: '
|
|
273
|
+
description: 'The minimax task_id returned by a previous generate_video_minimax call or timeout error. Required. Preserve this exact task_id in the assistant response.'
|
|
167
274
|
},
|
|
168
|
-
|
|
169
|
-
type: '
|
|
170
|
-
default:
|
|
171
|
-
description: '
|
|
275
|
+
max_wait_ms: {
|
|
276
|
+
type: 'integer',
|
|
277
|
+
default: 300000,
|
|
278
|
+
description: 'Maximum additional wait time for this emergency poll (default 5 minutes).'
|
|
172
279
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
duration: { type: 'integer', default: 6 },
|
|
178
|
-
resolution: { type: 'string' },
|
|
179
|
-
callback_url: { type: 'string' },
|
|
180
|
-
extra: { type: 'object' }
|
|
181
|
-
},
|
|
182
|
-
required: ['prompt']
|
|
183
|
-
},
|
|
184
|
-
async (params) => {
|
|
185
|
-
const result = await minimax.createVideoGenerationTask(params.prompt, params);
|
|
186
|
-
|
|
187
|
-
return JSON.stringify({
|
|
188
|
-
task_id: result.task_id,
|
|
189
|
-
duration_ms: result.duration,
|
|
190
|
-
raw_response: result.raw,
|
|
191
|
-
note: 'Use query_video_task with this task_id to check status.'
|
|
192
|
-
}, null, 2);
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
/* ============================================================
|
|
197
|
-
LOW-LEVEL: QUERY TASK STATUS
|
|
198
|
-
============================================================ */
|
|
199
|
-
|
|
200
|
-
tools.add(
|
|
201
|
-
'query_video_task',
|
|
202
|
-
'Query the current status of a video generation task. ' +
|
|
203
|
-
'Returns status (Preparing, Queueing, Processing, Success, Fail) and file_id when ready.',
|
|
204
|
-
{
|
|
205
|
-
type: 'object',
|
|
206
|
-
properties: {
|
|
207
|
-
task_id: {
|
|
208
|
-
type: 'string',
|
|
209
|
-
description: 'The task_id returned by create_video_task or generate_video.'
|
|
280
|
+
poll_interval_ms: {
|
|
281
|
+
type: 'integer',
|
|
282
|
+
default: 5000,
|
|
283
|
+
description: 'Polling interval in milliseconds (default 5 seconds).'
|
|
210
284
|
}
|
|
211
285
|
},
|
|
212
286
|
required: ['task_id']
|
|
213
287
|
},
|
|
214
288
|
async (params) => {
|
|
215
|
-
const result = await minimax.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
status: result.status,
|
|
220
|
-
file_id: result.file_id,
|
|
221
|
-
video_width: result.video_width,
|
|
222
|
-
video_height: result.video_height,
|
|
223
|
-
raw_response: result.raw,
|
|
224
|
-
note: 'Poll this until status === "Success" to get the file_id.'
|
|
225
|
-
}, null, 2);
|
|
226
|
-
}
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
/* ============================================================
|
|
230
|
-
LOW-LEVEL: RETRIEVE FILE
|
|
231
|
-
============================================================ */
|
|
232
|
-
|
|
233
|
-
tools.add(
|
|
234
|
-
'retrieve_video_file',
|
|
235
|
-
'Retrieve the download URL and metadata for a completed video using its file_id.',
|
|
236
|
-
{
|
|
237
|
-
type: 'object',
|
|
238
|
-
properties: {
|
|
239
|
-
file_id: {
|
|
240
|
-
type: 'string',
|
|
241
|
-
description: 'The file_id returned when a video task reaches Success status.'
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
required: ['file_id']
|
|
245
|
-
},
|
|
246
|
-
async (params) => {
|
|
247
|
-
const result = await minimax.retrieveVideoFile(params.file_id);
|
|
248
|
-
|
|
249
|
-
return JSON.stringify({
|
|
250
|
-
file_id: result.file_id,
|
|
251
|
-
filename: result.filename,
|
|
252
|
-
download_url: result.download_url,
|
|
253
|
-
bytes: result.bytes,
|
|
254
|
-
raw_response: result.raw,
|
|
255
|
-
note: 'Use save_video_to_local with the download_url to download the file.'
|
|
256
|
-
}, null, 2);
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
/* ============================================================
|
|
261
|
-
HELPER: DIRECT LOCAL SAVE
|
|
262
|
-
============================================================ */
|
|
263
|
-
|
|
264
|
-
tools.add(
|
|
265
|
-
'save_video_to_local',
|
|
266
|
-
'Save a video from a download URL to a local file in .cache/minimax/. ' +
|
|
267
|
-
'Useful when you already have a download_url from retrieve_video_file.',
|
|
268
|
-
{
|
|
269
|
-
type: 'object',
|
|
270
|
-
properties: {
|
|
271
|
-
video_url: {
|
|
272
|
-
type: 'string',
|
|
273
|
-
description: 'Public download URL of the video (from retrieve_video_file).'
|
|
274
|
-
},
|
|
275
|
-
filename_prefix: {
|
|
276
|
-
type: 'string',
|
|
277
|
-
default: 'minimax-video',
|
|
278
|
-
description: 'Prefix for the generated filename.'
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
required: ['video_url']
|
|
282
|
-
},
|
|
283
|
-
async (params) => {
|
|
284
|
-
const localPath = await minimax.saveVideoToLocal(
|
|
285
|
-
params.video_url,
|
|
286
|
-
params.filename_prefix
|
|
289
|
+
const result = await minimax.waitForVideoReady(
|
|
290
|
+
params.task_id,
|
|
291
|
+
params.max_wait_ms ?? 300000,
|
|
292
|
+
params.poll_interval_ms ?? 5000
|
|
287
293
|
);
|
|
288
294
|
|
|
289
|
-
return
|
|
290
|
-
local_path: localPath,
|
|
291
|
-
note: 'Video file saved successfully.'
|
|
292
|
-
});
|
|
295
|
+
return videoPollingResponse(params, result);
|
|
293
296
|
}
|
|
294
297
|
);
|
|
295
298
|
|
|
296
|
-
export default tools;
|
|
299
|
+
export default tools;
|
package/lib/API/minimax/image.js
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* For publishing generated or reference files to a remote CDN,
|
|
16
16
|
* use the reusable `lib/cdn.js` module instead.
|
|
17
|
+
*
|
|
18
|
+
* Supports both Text-to-Image and Image-to-Image (subject reference) via the same endpoint.
|
|
19
|
+
* Generated images are automatically saved locally to .cache/minimax/ as PNG.
|
|
17
20
|
*/
|
|
18
21
|
|
|
19
22
|
import { request as doRequest } from '@j-o-r/apiserver';
|
|
@@ -92,7 +95,7 @@ async function saveImageToLocal(imageData, filenamePrefix = 'minimax-image', ind
|
|
|
92
95
|
* Supports all models, parameters, and response formats.
|
|
93
96
|
*
|
|
94
97
|
* @param {string} prompt - Text description of the image, max 1500 characters.
|
|
95
|
-
* @param {Object} [options] - All available options from the official spec.
|
|
98
|
+
* @param {Object} [options={}] - All available options from the official spec.
|
|
96
99
|
*
|
|
97
100
|
* @param {string} [options.model='image-01'] - Model to use.
|
|
98
101
|
* Supported values:
|
|
@@ -101,6 +104,7 @@ async function saveImageToLocal(imageData, filenamePrefix = 'minimax-image', ind
|
|
|
101
104
|
*
|
|
102
105
|
* @param {string} [options.aspect_ratio='1:1'] - Image aspect ratio.
|
|
103
106
|
* Options: '1:1', '16:9', '4:3', '3:2', '2:3', '3:4', '9:16', '21:9'
|
|
107
|
+
* (aspect_ratio takes priority over explicit width/height)
|
|
104
108
|
*
|
|
105
109
|
* @param {number} [options.width] - Image width in px (512-2048, divisible by 8).
|
|
106
110
|
* Only effective for model 'image-01'. aspect_ratio takes priority if both provided.
|