@indreamai/openclaw-plugin 0.1.0
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/LICENSE +21 -0
- package/README.md +6 -0
- package/dist/chunk-ENGUNMFI.js +196 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +781 -0
- package/dist/setup-entry.d.ts +11 -0
- package/dist/setup-entry.js +20 -0
- package/openclaw.plugin.json +98 -0
- package/package.json +58 -0
- package/skills/indream-editor-json/SKILL.md +157 -0
- package/skills/indream-editor-json/references/asset-mapping.md +147 -0
- package/skills/indream-editor-json/references/common-items.md +280 -0
- package/skills/indream-editor-json/references/editor-state.v1.schema.json +1491 -0
- package/skills/indream-editor-json/references/keyframes.md +102 -0
- package/skills/indream-editor-json/references/material-libraries.md +97 -0
- package/skills/indream-editor-json/references/minimal-editor-state.json +36 -0
- package/skills/indream-editor-json/references/motion-effects-and-transitions.md +235 -0
- package/skills/indream-editor-json/references/recipes.md +122 -0
- package/skills/indream-editor-json/references/structure-and-principles.md +159 -0
- package/skills/indream-editor-json/references/template-catalog.md +45 -0
- package/skills/indream-editor-json/references/templates/chart-showcase.json +654 -0
- package/skills/indream-editor-json/references/templates/gallery-carousel.json +538 -0
- package/skills/indream-editor-json/references/templates/hello-world.json +212 -0
- package/skills/indream-editor-json/references/templates/illustration-board.json +480 -0
- package/skills/indream-editor-json/references/templates/keyframe-motion-lab.json +362 -0
- package/skills/indream-editor-json/references/templates/product-intro.json +614 -0
- package/skills/indream-editor-json/references/templates/subtitle-promo.json +341 -0
- package/skills/indream-editor-json/references/text-and-captions.md +211 -0
- package/skills/indream-editor-json/references/validation-repair.md +134 -0
- package/skills/indream-render-workflow/SKILL.md +57 -0
- package/skills/indream-render-workflow/references/workflow.md +19 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_BASE_URL,
|
|
3
|
+
DEFAULT_POLL_INTERVAL_MS,
|
|
4
|
+
DEFAULT_TIMEOUT_MS,
|
|
5
|
+
PLUGIN_DESCRIPTION,
|
|
6
|
+
PLUGIN_ID,
|
|
7
|
+
PLUGIN_NAME,
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues,
|
|
10
|
+
buildMissingApiKeyMessage,
|
|
11
|
+
pluginConfigSchema,
|
|
12
|
+
resolvePluginConfig
|
|
13
|
+
} from "./chunk-ENGUNMFI.js";
|
|
14
|
+
|
|
15
|
+
// src/index.ts
|
|
16
|
+
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
17
|
+
|
|
18
|
+
// src/tools.ts
|
|
19
|
+
import { IndreamClient } from "@indreamai/client";
|
|
20
|
+
import { Type } from "@sinclair/typebox";
|
|
21
|
+
|
|
22
|
+
// src/results.ts
|
|
23
|
+
import { APIError } from "@indreamai/client";
|
|
24
|
+
var stringifyPayload = (payload) => {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.stringify(payload, null, 2);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return String(payload);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var createJsonResult = (payload) => {
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: stringifyPayload(payload)
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
details: payload
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
var normalizeToolError = (error) => {
|
|
43
|
+
if (error instanceof APIError) {
|
|
44
|
+
return {
|
|
45
|
+
status: "failed",
|
|
46
|
+
message: error.message,
|
|
47
|
+
detail: error.detail,
|
|
48
|
+
errorName: error.name,
|
|
49
|
+
errorCode: error.errorCode,
|
|
50
|
+
errorType: error.type,
|
|
51
|
+
httpStatus: error.status,
|
|
52
|
+
retriable: error.status === 429 || error.status >= 500
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
return {
|
|
57
|
+
status: "failed",
|
|
58
|
+
message: error.message,
|
|
59
|
+
detail: error.message,
|
|
60
|
+
errorName: error.name
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
status: "failed",
|
|
65
|
+
message: "Unknown plugin error",
|
|
66
|
+
detail: "Unknown plugin error"
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var createErrorResult = (error) => {
|
|
70
|
+
return createJsonResult(normalizeToolError(error));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/upload-source.ts
|
|
74
|
+
import { readFile } from "fs/promises";
|
|
75
|
+
import { basename, extname, resolve } from "path";
|
|
76
|
+
import { lookup as lookupMimeType } from "mime-types";
|
|
77
|
+
var readOptionalString = (value) => {
|
|
78
|
+
if (typeof value !== "string") {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
return trimmed ? trimmed : void 0;
|
|
83
|
+
};
|
|
84
|
+
var inferMimeTypeFromPath = (value) => {
|
|
85
|
+
const mimeType = lookupMimeType(value);
|
|
86
|
+
return typeof mimeType === "string" ? mimeType : void 0;
|
|
87
|
+
};
|
|
88
|
+
var parseContentDispositionFilename = (value) => {
|
|
89
|
+
if (!value) {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
const utf8Match = value.match(/filename\*\s*=\s*UTF-8''([^;]+)/i);
|
|
93
|
+
if (utf8Match == null ? void 0 : utf8Match[1]) {
|
|
94
|
+
try {
|
|
95
|
+
return decodeURIComponent(utf8Match[1].trim().replace(/^"+|"+$/g, ""));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return utf8Match[1].trim().replace(/^"+|"+$/g, "");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const basicMatch = value.match(/filename\s*=\s*"?(.*?)"?(?:;|$)/i);
|
|
101
|
+
return readOptionalString(basicMatch == null ? void 0 : basicMatch[1]);
|
|
102
|
+
};
|
|
103
|
+
var inferFilenameFromUrl = (value) => {
|
|
104
|
+
const parsed = new URL(value);
|
|
105
|
+
return readOptionalString(basename(parsed.pathname));
|
|
106
|
+
};
|
|
107
|
+
var inferFilenameFromPath = (value) => {
|
|
108
|
+
return readOptionalString(basename(value));
|
|
109
|
+
};
|
|
110
|
+
var resolveLocalFilePath = (value, workspaceDir) => {
|
|
111
|
+
if (value.startsWith("~")) {
|
|
112
|
+
throw new Error('filePath does not support "~". Use an absolute path or a workspace-relative path.');
|
|
113
|
+
}
|
|
114
|
+
return value.startsWith("/") ? value : resolve(workspaceDir || process.cwd(), value);
|
|
115
|
+
};
|
|
116
|
+
var resolveUploadSource = async (params) => {
|
|
117
|
+
var _a;
|
|
118
|
+
const filePath = readOptionalString(params.filePath);
|
|
119
|
+
const sourceUrl = readOptionalString(params.sourceUrl);
|
|
120
|
+
const explicitFilename = readOptionalString(params.filename);
|
|
121
|
+
const explicitContentType = readOptionalString(params.contentType);
|
|
122
|
+
if (filePath && sourceUrl || !filePath && !sourceUrl) {
|
|
123
|
+
throw new Error("Exactly one of filePath or sourceUrl must be provided.");
|
|
124
|
+
}
|
|
125
|
+
if (filePath) {
|
|
126
|
+
if (!params.allowLocalPaths) {
|
|
127
|
+
throw new Error("Local file uploads are disabled in the plugin config.");
|
|
128
|
+
}
|
|
129
|
+
const resolvedPath = resolveLocalFilePath(filePath, params.workspaceDir);
|
|
130
|
+
const body2 = await readFile(resolvedPath);
|
|
131
|
+
const filename2 = explicitFilename || inferFilenameFromPath(resolvedPath);
|
|
132
|
+
if (!filename2) {
|
|
133
|
+
throw new Error("Could not infer filename from filePath. Pass filename explicitly.");
|
|
134
|
+
}
|
|
135
|
+
const contentType2 = explicitContentType || inferMimeTypeFromPath(filename2) || inferMimeTypeFromPath(resolvedPath);
|
|
136
|
+
if (!contentType2) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Could not infer contentType for ${basename(resolvedPath) || resolvedPath}. Pass contentType explicitly.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
body: body2,
|
|
143
|
+
filename: filename2,
|
|
144
|
+
contentType: contentType2,
|
|
145
|
+
sourceKind: "filePath",
|
|
146
|
+
source: resolvedPath
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (!params.allowRemoteUrls) {
|
|
150
|
+
throw new Error("Remote URL uploads are disabled in the plugin config.");
|
|
151
|
+
}
|
|
152
|
+
const parsedUrl = new URL(sourceUrl);
|
|
153
|
+
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
|
|
154
|
+
throw new Error("sourceUrl must use http or https.");
|
|
155
|
+
}
|
|
156
|
+
const fetchFn = params.fetchFn || fetch;
|
|
157
|
+
const response = await fetchFn(parsedUrl, {
|
|
158
|
+
redirect: "follow"
|
|
159
|
+
});
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
throw new Error(`Failed to download sourceUrl. HTTP ${response.status}.`);
|
|
162
|
+
}
|
|
163
|
+
const body = Buffer.from(await response.arrayBuffer());
|
|
164
|
+
const filename = explicitFilename || parseContentDispositionFilename(response.headers.get("content-disposition")) || inferFilenameFromUrl(sourceUrl) || `download${extname(parsedUrl.pathname) || ".bin"}`;
|
|
165
|
+
const contentType = explicitContentType || readOptionalString((_a = response.headers.get("content-type")) == null ? void 0 : _a.split(";")[0]) || inferMimeTypeFromPath(filename) || inferMimeTypeFromPath(parsedUrl.pathname);
|
|
166
|
+
if (!contentType) {
|
|
167
|
+
throw new Error("Could not infer contentType from sourceUrl. Pass contentType explicitly.");
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
body,
|
|
171
|
+
filename,
|
|
172
|
+
contentType,
|
|
173
|
+
sourceKind: "sourceUrl",
|
|
174
|
+
source: sourceUrl
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/tools.ts
|
|
179
|
+
var EXPORT_RATIO_VALUES = ["16:9", "9:16", "1:1", "4:3", "3:4", "custom"];
|
|
180
|
+
var EXPORT_FORMAT_VALUES = ["mp4", "webm"];
|
|
181
|
+
var FPS_VALUES = [30, 60];
|
|
182
|
+
var readRecord = (value) => {
|
|
183
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
184
|
+
};
|
|
185
|
+
var readOptionalString2 = (params, key) => {
|
|
186
|
+
const value = params[key];
|
|
187
|
+
if (typeof value !== "string") {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
const trimmed = value.trim();
|
|
191
|
+
return trimmed ? trimmed : void 0;
|
|
192
|
+
};
|
|
193
|
+
var readRequiredString = (params, key) => {
|
|
194
|
+
const value = readOptionalString2(params, key);
|
|
195
|
+
if (!value) {
|
|
196
|
+
throw new Error(`${key} is required.`);
|
|
197
|
+
}
|
|
198
|
+
return value;
|
|
199
|
+
};
|
|
200
|
+
var readOptionalInteger = (params, key) => {
|
|
201
|
+
const value = params[key];
|
|
202
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
203
|
+
return void 0;
|
|
204
|
+
}
|
|
205
|
+
return value;
|
|
206
|
+
};
|
|
207
|
+
var readOptionalNumber = (params, key) => {
|
|
208
|
+
const value = params[key];
|
|
209
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
210
|
+
};
|
|
211
|
+
var readRequiredNumber = (params, key) => {
|
|
212
|
+
const value = readOptionalNumber(params, key);
|
|
213
|
+
if (value === void 0) {
|
|
214
|
+
throw new Error(`${key} is required.`);
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
};
|
|
218
|
+
var readRequiredLiteralString = (params, key, values) => {
|
|
219
|
+
const value = readRequiredString(params, key);
|
|
220
|
+
if (!values.includes(value)) {
|
|
221
|
+
throw new Error(`${key} must be one of ${values.join(", ")}.`);
|
|
222
|
+
}
|
|
223
|
+
return value;
|
|
224
|
+
};
|
|
225
|
+
var readRequiredLiteralNumber = (params, key, values) => {
|
|
226
|
+
const value = readRequiredNumber(params, key);
|
|
227
|
+
if (!values.includes(value)) {
|
|
228
|
+
throw new Error(`${key} must be one of ${values.join(", ")}.`);
|
|
229
|
+
}
|
|
230
|
+
return value;
|
|
231
|
+
};
|
|
232
|
+
var readOptionalStringRecord = (params, key) => {
|
|
233
|
+
const value = params[key];
|
|
234
|
+
if (value === void 0) {
|
|
235
|
+
return void 0;
|
|
236
|
+
}
|
|
237
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
238
|
+
throw new Error(`${key} must be an object of string values.`);
|
|
239
|
+
}
|
|
240
|
+
const result = {};
|
|
241
|
+
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
242
|
+
if (typeof entryValue !== "string") {
|
|
243
|
+
throw new Error(`${key}.${entryKey} must be a string.`);
|
|
244
|
+
}
|
|
245
|
+
result[entryKey] = entryValue;
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
var readEditorState = (params, key) => {
|
|
250
|
+
const value = params[key];
|
|
251
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
252
|
+
throw new Error(`${key} must be an object.`);
|
|
253
|
+
}
|
|
254
|
+
return value;
|
|
255
|
+
};
|
|
256
|
+
var createClient = (config) => {
|
|
257
|
+
if (!config.apiKey) {
|
|
258
|
+
throw new Error(buildMissingApiKeyMessage());
|
|
259
|
+
}
|
|
260
|
+
return new IndreamClient({
|
|
261
|
+
apiKey: config.apiKey,
|
|
262
|
+
baseURL: config.baseURL || DEFAULT_BASE_URL,
|
|
263
|
+
timeout: config.timeoutMs || DEFAULT_TIMEOUT_MS,
|
|
264
|
+
pollIntervalMs: config.pollIntervalMs || DEFAULT_POLL_INTERVAL_MS
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
var ensureClient = (api, deps) => {
|
|
268
|
+
const config = resolvePluginConfig(api.pluginConfig);
|
|
269
|
+
const clientFactory = deps.createClient || createClient;
|
|
270
|
+
return {
|
|
271
|
+
config,
|
|
272
|
+
client: clientFactory(config)
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
var executeWithClient = async (api, deps, handler) => {
|
|
276
|
+
try {
|
|
277
|
+
const { client, config } = ensureClient(api, deps);
|
|
278
|
+
return createJsonResult(await handler(client, config));
|
|
279
|
+
} catch (error) {
|
|
280
|
+
return createErrorResult(error);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var executeUploadWithClient = async (api, deps, ctx, params) => {
|
|
284
|
+
try {
|
|
285
|
+
const { client, config } = ensureClient(api, deps);
|
|
286
|
+
const uploadSource = await resolveUploadSource({
|
|
287
|
+
filePath: readOptionalString2(params, "filePath"),
|
|
288
|
+
sourceUrl: readOptionalString2(params, "sourceUrl"),
|
|
289
|
+
filename: readOptionalString2(params, "filename"),
|
|
290
|
+
contentType: readOptionalString2(params, "contentType"),
|
|
291
|
+
workspaceDir: ctx.workspaceDir,
|
|
292
|
+
allowLocalPaths: config.uploads.allowLocalPaths,
|
|
293
|
+
allowRemoteUrls: config.uploads.allowRemoteUrls,
|
|
294
|
+
fetchFn: deps.fetchFn
|
|
295
|
+
});
|
|
296
|
+
const asset = await client.uploads.upload(uploadSource.body, {
|
|
297
|
+
filename: uploadSource.filename,
|
|
298
|
+
contentType: uploadSource.contentType,
|
|
299
|
+
projectId: readOptionalString2(params, "projectId")
|
|
300
|
+
});
|
|
301
|
+
return createJsonResult(__spreadProps(__spreadValues({}, asset), {
|
|
302
|
+
uploadSource: {
|
|
303
|
+
kind: uploadSource.sourceKind,
|
|
304
|
+
source: uploadSource.source
|
|
305
|
+
},
|
|
306
|
+
editorAssetMapping: {
|
|
307
|
+
assetId: asset.assetId,
|
|
308
|
+
remoteUrl: asset.fileUrl,
|
|
309
|
+
remoteKey: asset.fileKey,
|
|
310
|
+
filename: asset.filename,
|
|
311
|
+
type: asset.type
|
|
312
|
+
}
|
|
313
|
+
}));
|
|
314
|
+
} catch (error) {
|
|
315
|
+
return createErrorResult(error);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
var exportRatioSchema = Type.Union(EXPORT_RATIO_VALUES.map((value) => Type.Literal(value)));
|
|
319
|
+
var exportFormatSchema = Type.Union(EXPORT_FORMAT_VALUES.map((value) => Type.Literal(value)));
|
|
320
|
+
var fpsSchema = Type.Union(FPS_VALUES.map((value) => Type.Literal(value)));
|
|
321
|
+
var paginationSchema = {
|
|
322
|
+
pageSize: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
323
|
+
pageCursor: Type.Optional(Type.String())
|
|
324
|
+
};
|
|
325
|
+
var registerIndreamTools = (api, deps = {}) => {
|
|
326
|
+
const required = [];
|
|
327
|
+
const optional = [];
|
|
328
|
+
const withDefaultLabel = (name, tool) => {
|
|
329
|
+
if (typeof tool === "function") {
|
|
330
|
+
return ((ctx) => {
|
|
331
|
+
const created = tool(ctx);
|
|
332
|
+
if (!created) {
|
|
333
|
+
return created;
|
|
334
|
+
}
|
|
335
|
+
if (Array.isArray(created)) {
|
|
336
|
+
return created.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
337
|
+
label: item.label || item.name || name
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
return __spreadProps(__spreadValues({}, created), {
|
|
341
|
+
label: created.label || created.name || name
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return __spreadProps(__spreadValues({}, tool), {
|
|
346
|
+
label: tool.label || tool.name || name
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
const register = (name, tool, toolIsOptional = false) => {
|
|
350
|
+
api.registerTool(
|
|
351
|
+
withDefaultLabel(name, tool),
|
|
352
|
+
toolIsOptional ? { optional: true } : void 0
|
|
353
|
+
);
|
|
354
|
+
const collection = toolIsOptional ? optional : required;
|
|
355
|
+
collection.push({
|
|
356
|
+
name,
|
|
357
|
+
optional: toolIsOptional
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
register("indream_editor_capabilities", {
|
|
361
|
+
name: "indream_editor_capabilities",
|
|
362
|
+
label: "Indream Editor Capabilities",
|
|
363
|
+
description: "Fetch the current Indream editor capability catalog.",
|
|
364
|
+
parameters: Type.Object({}),
|
|
365
|
+
async execute() {
|
|
366
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
367
|
+
return await client.editor.capabilities();
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
register("indream_editor_validate", {
|
|
372
|
+
name: "indream_editor_validate",
|
|
373
|
+
label: "Validate Indream Editor JSON",
|
|
374
|
+
description: "Validate an Indream editor JSON payload before saving or exporting.",
|
|
375
|
+
parameters: Type.Object({
|
|
376
|
+
editorState: Type.Unknown()
|
|
377
|
+
}),
|
|
378
|
+
async execute(_id, rawParams) {
|
|
379
|
+
const params = readRecord(rawParams);
|
|
380
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
381
|
+
return await client.editor.validate(readEditorState(params, "editorState"));
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
register("indream_projects_list", {
|
|
386
|
+
name: "indream_projects_list",
|
|
387
|
+
label: "List Indream Projects",
|
|
388
|
+
description: "List Indream projects.",
|
|
389
|
+
parameters: Type.Object(__spreadValues({}, paginationSchema)),
|
|
390
|
+
async execute(_id, rawParams) {
|
|
391
|
+
const params = readRecord(rawParams);
|
|
392
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
393
|
+
return await client.projects.list({
|
|
394
|
+
pageSize: readOptionalInteger(params, "pageSize"),
|
|
395
|
+
pageCursor: readOptionalString2(params, "pageCursor")
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
register("indream_projects_get", {
|
|
401
|
+
name: "indream_projects_get",
|
|
402
|
+
label: "Get Indream Project",
|
|
403
|
+
description: "Get a single Indream project, including editorState.",
|
|
404
|
+
parameters: Type.Object({
|
|
405
|
+
projectId: Type.String()
|
|
406
|
+
}),
|
|
407
|
+
async execute(_id, rawParams) {
|
|
408
|
+
const params = readRecord(rawParams);
|
|
409
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
410
|
+
return await client.projects.get(readRequiredString(params, "projectId"));
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
register("indream_projects_list_assets", {
|
|
415
|
+
name: "indream_projects_list_assets",
|
|
416
|
+
label: "List Indream Project Assets",
|
|
417
|
+
description: "List assets attached to a project.",
|
|
418
|
+
parameters: Type.Object(__spreadValues({
|
|
419
|
+
projectId: Type.String()
|
|
420
|
+
}, paginationSchema)),
|
|
421
|
+
async execute(_id, rawParams) {
|
|
422
|
+
const params = readRecord(rawParams);
|
|
423
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
424
|
+
return await client.projects.listAssets({
|
|
425
|
+
projectId: readRequiredString(params, "projectId"),
|
|
426
|
+
pageSize: readOptionalInteger(params, "pageSize"),
|
|
427
|
+
pageCursor: readOptionalString2(params, "pageCursor")
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
register("indream_assets_get", {
|
|
433
|
+
name: "indream_assets_get",
|
|
434
|
+
label: "Get Indream Asset",
|
|
435
|
+
description: "Fetch a reusable Indream asset.",
|
|
436
|
+
parameters: Type.Object({
|
|
437
|
+
assetId: Type.String()
|
|
438
|
+
}),
|
|
439
|
+
async execute(_id, rawParams) {
|
|
440
|
+
const params = readRecord(rawParams);
|
|
441
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
442
|
+
return await client.assets.get(readRequiredString(params, "assetId"));
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
register("indream_exports_get", {
|
|
447
|
+
name: "indream_exports_get",
|
|
448
|
+
label: "Get Indream Export",
|
|
449
|
+
description: "Fetch a single export task.",
|
|
450
|
+
parameters: Type.Object({
|
|
451
|
+
taskId: Type.String()
|
|
452
|
+
}),
|
|
453
|
+
async execute(_id, rawParams) {
|
|
454
|
+
const params = readRecord(rawParams);
|
|
455
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
456
|
+
return await client.exports.get(readRequiredString(params, "taskId"));
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
register("indream_exports_list", {
|
|
461
|
+
name: "indream_exports_list",
|
|
462
|
+
label: "List Indream Exports",
|
|
463
|
+
description: "List export tasks.",
|
|
464
|
+
parameters: Type.Object(__spreadProps(__spreadValues({}, paginationSchema), {
|
|
465
|
+
createdByApiKeyId: Type.Optional(Type.String())
|
|
466
|
+
})),
|
|
467
|
+
async execute(_id, rawParams) {
|
|
468
|
+
const params = readRecord(rawParams);
|
|
469
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
470
|
+
return await client.exports.list({
|
|
471
|
+
pageSize: readOptionalInteger(params, "pageSize"),
|
|
472
|
+
pageCursor: readOptionalString2(params, "pageCursor"),
|
|
473
|
+
createdByApiKeyId: readOptionalString2(params, "createdByApiKeyId")
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
register("indream_exports_wait", {
|
|
479
|
+
name: "indream_exports_wait",
|
|
480
|
+
label: "Wait For Indream Export",
|
|
481
|
+
description: "Poll an export task until it reaches a terminal state.",
|
|
482
|
+
parameters: Type.Object({
|
|
483
|
+
taskId: Type.String(),
|
|
484
|
+
timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
485
|
+
pollIntervalMs: Type.Optional(Type.Integer({ minimum: 1 }))
|
|
486
|
+
}),
|
|
487
|
+
async execute(_id, rawParams) {
|
|
488
|
+
const params = readRecord(rawParams);
|
|
489
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
490
|
+
return await client.exports.wait(readRequiredString(params, "taskId"), {
|
|
491
|
+
timeoutMs: readOptionalInteger(params, "timeoutMs"),
|
|
492
|
+
pollIntervalMs: readOptionalInteger(params, "pollIntervalMs")
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
register(
|
|
498
|
+
"indream_projects_create",
|
|
499
|
+
{
|
|
500
|
+
name: "indream_projects_create",
|
|
501
|
+
label: "Create Indream Project",
|
|
502
|
+
description: "Create a new persisted Indream project.",
|
|
503
|
+
parameters: Type.Object({
|
|
504
|
+
title: Type.Optional(Type.String()),
|
|
505
|
+
description: Type.Optional(Type.String()),
|
|
506
|
+
editorState: Type.Unknown(),
|
|
507
|
+
stateVersion: Type.Optional(Type.String()),
|
|
508
|
+
idempotencyKey: Type.Optional(Type.String())
|
|
509
|
+
}),
|
|
510
|
+
async execute(_id, rawParams) {
|
|
511
|
+
const params = readRecord(rawParams);
|
|
512
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
513
|
+
var _a;
|
|
514
|
+
return await client.projects.create(
|
|
515
|
+
{
|
|
516
|
+
title: readOptionalString2(params, "title"),
|
|
517
|
+
description: (_a = readOptionalString2(params, "description")) != null ? _a : null,
|
|
518
|
+
editorState: readEditorState(params, "editorState"),
|
|
519
|
+
stateVersion: readOptionalString2(params, "stateVersion")
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
idempotencyKey: readOptionalString2(params, "idempotencyKey")
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
true
|
|
529
|
+
);
|
|
530
|
+
register(
|
|
531
|
+
"indream_projects_update",
|
|
532
|
+
{
|
|
533
|
+
name: "indream_projects_update",
|
|
534
|
+
label: "Update Indream Project",
|
|
535
|
+
description: "Update project title and description.",
|
|
536
|
+
parameters: Type.Object({
|
|
537
|
+
projectId: Type.String(),
|
|
538
|
+
title: Type.Optional(Type.String()),
|
|
539
|
+
description: Type.Optional(Type.String())
|
|
540
|
+
}),
|
|
541
|
+
async execute(_id, rawParams) {
|
|
542
|
+
const params = readRecord(rawParams);
|
|
543
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
544
|
+
var _a;
|
|
545
|
+
return await client.projects.update(readRequiredString(params, "projectId"), {
|
|
546
|
+
title: readOptionalString2(params, "title"),
|
|
547
|
+
description: (_a = readOptionalString2(params, "description")) != null ? _a : null
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
true
|
|
553
|
+
);
|
|
554
|
+
register(
|
|
555
|
+
"indream_projects_sync",
|
|
556
|
+
{
|
|
557
|
+
name: "indream_projects_sync",
|
|
558
|
+
label: "Sync Indream Project",
|
|
559
|
+
description: "Replace the latest persisted editorState for a project.",
|
|
560
|
+
parameters: Type.Object({
|
|
561
|
+
projectId: Type.String(),
|
|
562
|
+
editorState: Type.Unknown(),
|
|
563
|
+
stateVersion: Type.Optional(Type.String())
|
|
564
|
+
}),
|
|
565
|
+
async execute(_id, rawParams) {
|
|
566
|
+
const params = readRecord(rawParams);
|
|
567
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
568
|
+
return await client.projects.sync(readRequiredString(params, "projectId"), {
|
|
569
|
+
editorState: readEditorState(params, "editorState"),
|
|
570
|
+
stateVersion: readOptionalString2(params, "stateVersion")
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
true
|
|
576
|
+
);
|
|
577
|
+
register(
|
|
578
|
+
"indream_projects_delete",
|
|
579
|
+
{
|
|
580
|
+
name: "indream_projects_delete",
|
|
581
|
+
label: "Delete Indream Project",
|
|
582
|
+
description: "Delete a project.",
|
|
583
|
+
parameters: Type.Object({
|
|
584
|
+
projectId: Type.String()
|
|
585
|
+
}),
|
|
586
|
+
async execute(_id, rawParams) {
|
|
587
|
+
const params = readRecord(rawParams);
|
|
588
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
589
|
+
return await client.projects.delete(readRequiredString(params, "projectId"));
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
true
|
|
594
|
+
);
|
|
595
|
+
register(
|
|
596
|
+
"indream_projects_add_asset",
|
|
597
|
+
{
|
|
598
|
+
name: "indream_projects_add_asset",
|
|
599
|
+
label: "Add Asset To Indream Project",
|
|
600
|
+
description: "Attach an existing asset to a project.",
|
|
601
|
+
parameters: Type.Object({
|
|
602
|
+
projectId: Type.String(),
|
|
603
|
+
assetId: Type.String()
|
|
604
|
+
}),
|
|
605
|
+
async execute(_id, rawParams) {
|
|
606
|
+
const params = readRecord(rawParams);
|
|
607
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
608
|
+
return await client.projects.addAsset(
|
|
609
|
+
readRequiredString(params, "projectId"),
|
|
610
|
+
readRequiredString(params, "assetId")
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
true
|
|
616
|
+
);
|
|
617
|
+
register(
|
|
618
|
+
"indream_projects_remove_asset",
|
|
619
|
+
{
|
|
620
|
+
name: "indream_projects_remove_asset",
|
|
621
|
+
label: "Remove Asset From Indream Project",
|
|
622
|
+
description: "Detach an asset from a project.",
|
|
623
|
+
parameters: Type.Object({
|
|
624
|
+
projectId: Type.String(),
|
|
625
|
+
assetId: Type.String()
|
|
626
|
+
}),
|
|
627
|
+
async execute(_id, rawParams) {
|
|
628
|
+
const params = readRecord(rawParams);
|
|
629
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
630
|
+
return await client.projects.removeAsset(
|
|
631
|
+
readRequiredString(params, "projectId"),
|
|
632
|
+
readRequiredString(params, "assetId")
|
|
633
|
+
);
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
true
|
|
638
|
+
);
|
|
639
|
+
register(
|
|
640
|
+
"indream_assets_upload",
|
|
641
|
+
(ctx) => ({
|
|
642
|
+
name: "indream_assets_upload",
|
|
643
|
+
label: "Upload Indream Asset",
|
|
644
|
+
description: "Upload a local file path or remote HTTP/HTTPS URL and return editor JSON asset mapping fields.",
|
|
645
|
+
parameters: Type.Object({
|
|
646
|
+
filePath: Type.Optional(Type.String()),
|
|
647
|
+
sourceUrl: Type.Optional(Type.String()),
|
|
648
|
+
filename: Type.Optional(Type.String()),
|
|
649
|
+
contentType: Type.Optional(Type.String()),
|
|
650
|
+
projectId: Type.Optional(Type.String())
|
|
651
|
+
}),
|
|
652
|
+
async execute(_id, rawParams) {
|
|
653
|
+
const params = readRecord(rawParams);
|
|
654
|
+
return await executeUploadWithClient(api, deps, ctx, params);
|
|
655
|
+
}
|
|
656
|
+
}),
|
|
657
|
+
true
|
|
658
|
+
);
|
|
659
|
+
register(
|
|
660
|
+
"indream_assets_delete",
|
|
661
|
+
{
|
|
662
|
+
name: "indream_assets_delete",
|
|
663
|
+
label: "Delete Indream Asset",
|
|
664
|
+
description: "Delete an asset.",
|
|
665
|
+
parameters: Type.Object({
|
|
666
|
+
assetId: Type.String()
|
|
667
|
+
}),
|
|
668
|
+
async execute(_id, rawParams) {
|
|
669
|
+
const params = readRecord(rawParams);
|
|
670
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
671
|
+
return await client.assets.delete(readRequiredString(params, "assetId"));
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
true
|
|
676
|
+
);
|
|
677
|
+
register(
|
|
678
|
+
"indream_exports_create",
|
|
679
|
+
{
|
|
680
|
+
name: "indream_exports_create",
|
|
681
|
+
label: "Create Indream Export",
|
|
682
|
+
description: "Create a stateless export directly from editor JSON.",
|
|
683
|
+
parameters: Type.Object({
|
|
684
|
+
editorState: Type.Unknown(),
|
|
685
|
+
stateVersion: Type.Optional(Type.String()),
|
|
686
|
+
clientTaskId: Type.Optional(Type.String()),
|
|
687
|
+
fps: fpsSchema,
|
|
688
|
+
compositionWidth: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
689
|
+
compositionHeight: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
690
|
+
ratio: exportRatioSchema,
|
|
691
|
+
scale: Type.Number({ exclusiveMinimum: 0 }),
|
|
692
|
+
format: exportFormatSchema,
|
|
693
|
+
callbackUrl: Type.Optional(Type.String()),
|
|
694
|
+
callbackHeaders: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
695
|
+
idempotencyKey: Type.Optional(Type.String())
|
|
696
|
+
}),
|
|
697
|
+
async execute(_id, rawParams) {
|
|
698
|
+
const params = readRecord(rawParams);
|
|
699
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
700
|
+
return await client.exports.create(
|
|
701
|
+
{
|
|
702
|
+
editorState: readEditorState(params, "editorState"),
|
|
703
|
+
stateVersion: readOptionalString2(params, "stateVersion"),
|
|
704
|
+
clientTaskId: readOptionalString2(params, "clientTaskId"),
|
|
705
|
+
fps: readRequiredLiteralNumber(params, "fps", FPS_VALUES),
|
|
706
|
+
compositionWidth: readOptionalInteger(params, "compositionWidth"),
|
|
707
|
+
compositionHeight: readOptionalInteger(params, "compositionHeight"),
|
|
708
|
+
ratio: readRequiredLiteralString(params, "ratio", EXPORT_RATIO_VALUES),
|
|
709
|
+
scale: readRequiredNumber(params, "scale"),
|
|
710
|
+
format: readRequiredLiteralString(params, "format", EXPORT_FORMAT_VALUES),
|
|
711
|
+
callbackUrl: readOptionalString2(params, "callbackUrl"),
|
|
712
|
+
callbackHeaders: readOptionalStringRecord(params, "callbackHeaders")
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
idempotencyKey: readOptionalString2(params, "idempotencyKey")
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
true
|
|
722
|
+
);
|
|
723
|
+
register(
|
|
724
|
+
"indream_projects_create_export",
|
|
725
|
+
{
|
|
726
|
+
name: "indream_projects_create_export",
|
|
727
|
+
label: "Create Indream Project Export",
|
|
728
|
+
description: "Create an export task from the latest saved project state.",
|
|
729
|
+
parameters: Type.Object({
|
|
730
|
+
projectId: Type.String(),
|
|
731
|
+
clientTaskId: Type.Optional(Type.String()),
|
|
732
|
+
fps: fpsSchema,
|
|
733
|
+
ratio: exportRatioSchema,
|
|
734
|
+
scale: Type.Number({ exclusiveMinimum: 0 }),
|
|
735
|
+
format: exportFormatSchema,
|
|
736
|
+
callbackUrl: Type.Optional(Type.String()),
|
|
737
|
+
callbackHeaders: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
738
|
+
idempotencyKey: Type.Optional(Type.String())
|
|
739
|
+
}),
|
|
740
|
+
async execute(_id, rawParams) {
|
|
741
|
+
const params = readRecord(rawParams);
|
|
742
|
+
return await executeWithClient(api, deps, async (client) => {
|
|
743
|
+
return await client.projects.createExport(
|
|
744
|
+
readRequiredString(params, "projectId"),
|
|
745
|
+
{
|
|
746
|
+
clientTaskId: readOptionalString2(params, "clientTaskId"),
|
|
747
|
+
fps: readRequiredLiteralNumber(params, "fps", FPS_VALUES),
|
|
748
|
+
ratio: readRequiredLiteralString(params, "ratio", EXPORT_RATIO_VALUES),
|
|
749
|
+
scale: readRequiredNumber(params, "scale"),
|
|
750
|
+
format: readRequiredLiteralString(params, "format", EXPORT_FORMAT_VALUES),
|
|
751
|
+
callbackUrl: readOptionalString2(params, "callbackUrl"),
|
|
752
|
+
callbackHeaders: readOptionalStringRecord(params, "callbackHeaders")
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
idempotencyKey: readOptionalString2(params, "idempotencyKey")
|
|
756
|
+
}
|
|
757
|
+
);
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
true
|
|
762
|
+
);
|
|
763
|
+
return {
|
|
764
|
+
required,
|
|
765
|
+
optional
|
|
766
|
+
};
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
// src/index.ts
|
|
770
|
+
var index_default = definePluginEntry({
|
|
771
|
+
id: PLUGIN_ID,
|
|
772
|
+
name: PLUGIN_NAME,
|
|
773
|
+
description: PLUGIN_DESCRIPTION,
|
|
774
|
+
configSchema: pluginConfigSchema,
|
|
775
|
+
register(api) {
|
|
776
|
+
registerIndreamTools(api);
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
export {
|
|
780
|
+
index_default as default
|
|
781
|
+
};
|