post-engineer-mcp 1.42.0 → 1.44.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/README.md +10 -5
- package/dist/client-batch.d.ts +6 -0
- package/dist/client-batch.js +4 -0
- package/dist/client-batch.js.map +1 -0
- package/dist/client-experiments.d.ts +15 -0
- package/dist/client-experiments.js +11 -0
- package/dist/client-experiments.js.map +1 -0
- package/dist/client-posts.d.ts +4 -0
- package/dist/client-posts.js +7 -0
- package/dist/client-posts.js.map +1 -1
- package/dist/client-types.d.ts +9 -2
- package/dist/client.d.ts +1 -1
- package/dist/client.js +7 -6
- package/dist/client.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +30 -0
- package/dist/limits.js +30 -0
- package/dist/limits.js.map +1 -1
- package/dist/persona-update.d.ts +84 -0
- package/dist/persona-update.js +37 -0
- package/dist/persona-update.js.map +1 -0
- package/dist/recipe-session.d.ts +4 -0
- package/dist/recipe-session.js +2 -1
- package/dist/recipe-session.js.map +1 -1
- package/dist/schedule-shapes.d.ts +18 -2
- package/dist/schedule-shapes.js +12 -6
- package/dist/schedule-shapes.js.map +1 -1
- package/dist/script-segments.d.ts +4 -2
- package/dist/script-segments.js +19 -7
- package/dist/script-segments.js.map +1 -1
- package/dist/single-video-shape.d.ts +62 -8
- package/dist/single-video-shape.js +16 -1
- package/dist/single-video-shape.js.map +1 -1
- package/dist/tools-batch.d.ts +755 -0
- package/dist/tools-batch.js +141 -0
- package/dist/tools-batch.js.map +1 -0
- package/dist/tools-experiments.d.ts +724 -0
- package/dist/tools-experiments.js +165 -0
- package/dist/tools-experiments.js.map +1 -0
- package/dist/tools-posts.d.ts +1 -0
- package/dist/tools-posts.js +17 -1
- package/dist/tools-posts.js.map +1 -1
- package/dist/tools-single-video.d.ts +9 -0
- package/dist/tools-single-video.js +31 -13
- package/dist/tools-single-video.js.map +1 -1
- package/dist/tools.d.ts +17 -92
- package/dist/tools.js +6 -27
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createExperiment, getExperimentResults, listExperiments } from './client-experiments.js';
|
|
3
|
+
import { EXPERIMENT_NAME_MAX_LENGTH, EXPERIMENT_TARGET_PAIRS_MAX, EXPERIMENT_TARGET_PAIRS_MIN, EXPERIMENT_VARIANT_DESCRIPTION_MAX_LENGTH, EXPERIMENT_VARIANT_ID_PATTERN, EXPERIMENT_VARIANT_NAME_MAX_LENGTH, METRICS_WINDOWS, } from './limits.js';
|
|
4
|
+
import { GeneratePersonaVideoShape, ScriptSegmentShape } from './single-video-shape.js';
|
|
5
|
+
import { generatePersonaVideoOutcome } from './tools-single-video.js';
|
|
6
|
+
import { handleLibraryCall } from './tools-call.js';
|
|
7
|
+
//---------------
|
|
8
|
+
// Paired A/B content experiments (issue #476): create_experiment,
|
|
9
|
+
// list_experiments, add_experiment_pair and get_experiment_results.
|
|
10
|
+
//
|
|
11
|
+
// An experiment tests ONE variable (the hook) with two variants. It is a
|
|
12
|
+
// set of pairs: inside a pair both videos share topic, body and CTA and only
|
|
13
|
+
// the hook differs; across pairs the topic changes. add_experiment_pair
|
|
14
|
+
// creates both videos of one pair through generate-and-schedule (two normal
|
|
15
|
+
// charged videos) and the server rejects a pair that differs in anything
|
|
16
|
+
// but the hook, before charging.
|
|
17
|
+
//---------------
|
|
18
|
+
const variantId = z
|
|
19
|
+
.string()
|
|
20
|
+
.regex(EXPERIMENT_VARIANT_ID_PATTERN, 'variantId must be a lowercase slug such as hook-aggressive (never "A"/"B")');
|
|
21
|
+
export const CreateExperimentShape = {
|
|
22
|
+
name: z.string().min(1).max(EXPERIMENT_NAME_MAX_LENGTH).describe('Experiment name, e.g. "Calm vs aggressive hook".'),
|
|
23
|
+
personaId: z
|
|
24
|
+
.string()
|
|
25
|
+
.uuid()
|
|
26
|
+
.nullable()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Persona every video of the experiment uses. Null or omitted = faceless experiment with no persona.'),
|
|
29
|
+
targetPairs: z
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.min(EXPERIMENT_TARGET_PAIRS_MIN)
|
|
33
|
+
.max(EXPERIMENT_TARGET_PAIRS_MAX)
|
|
34
|
+
.default(6)
|
|
35
|
+
.describe('Pairs to publish (each pair = 2 charged videos). The result can only be "clear" once all pairs are in; with 6 pairs one variant must win all 6, a moderate effect needs about 10-12.'),
|
|
36
|
+
variants: z
|
|
37
|
+
.array(z
|
|
38
|
+
.object({
|
|
39
|
+
variantId: variantId.describe('Slug that identifies the variant in results and PostHog, e.g. hook-aggressive.'),
|
|
40
|
+
name: z.string().min(1).max(EXPERIMENT_VARIANT_NAME_MAX_LENGTH).describe('Human name, e.g. "Aggressive hook".'),
|
|
41
|
+
description: z
|
|
42
|
+
.string()
|
|
43
|
+
.min(1)
|
|
44
|
+
.max(EXPERIMENT_VARIANT_DESCRIPTION_MAX_LENGTH)
|
|
45
|
+
.describe('The style rule you will follow when writing this variant\'s hooks, e.g. "direct, provocative, calls out a mistake".'),
|
|
46
|
+
})
|
|
47
|
+
.strict())
|
|
48
|
+
.length(2)
|
|
49
|
+
.refine((variants) => new Set(variants.map((variant) => variant.variantId)).size === variants.length, {
|
|
50
|
+
message: 'variantId values must differ',
|
|
51
|
+
})
|
|
52
|
+
.describe('Exactly two variants of the hook.'),
|
|
53
|
+
};
|
|
54
|
+
export const CreateExperimentSchema = z.object(CreateExperimentShape);
|
|
55
|
+
export const ListExperimentsShape = {};
|
|
56
|
+
export const GetExperimentResultsShape = {
|
|
57
|
+
experimentId: z.string().uuid().describe('Experiment id from create_experiment / list_experiments.'),
|
|
58
|
+
window: z.enum(METRICS_WINDOWS).optional().describe('Metrics window to compare: 24h, 7d (default) or 28d.'),
|
|
59
|
+
};
|
|
60
|
+
export const GetExperimentResultsSchema = z.object(GetExperimentResultsShape);
|
|
61
|
+
const { segments: _segments, title: _title, idempotencyKey: _key, recipe: _recipe, experiment: _experiment, ...deliveryShape } = GeneratePersonaVideoShape;
|
|
62
|
+
export const AddExperimentPairShape = {
|
|
63
|
+
experimentId: z.string().uuid().describe('Experiment id from create_experiment.'),
|
|
64
|
+
pair: z.number().int().min(1).max(EXPERIMENT_TARGET_PAIRS_MAX).describe('Pair number: 1 for the first pair, then 2, 3... up to targetPairs.'),
|
|
65
|
+
title: z.string().min(1).describe('Slot label for both videos (the pair topic).'),
|
|
66
|
+
segments: z
|
|
67
|
+
.array(z.object(ScriptSegmentShape).strict())
|
|
68
|
+
.min(2)
|
|
69
|
+
.max(11)
|
|
70
|
+
.refine((list) => list.every((segment) => segment.kind !== 'hook'), { message: 'segments must not contain the hook: put each variant\'s hook in hooks' })
|
|
71
|
+
.describe('The shared script WITHOUT the hook: body segments, then the CTA. Identical for both videos of the pair.'),
|
|
72
|
+
hooks: z
|
|
73
|
+
.array(z
|
|
74
|
+
.object({
|
|
75
|
+
variantId,
|
|
76
|
+
text: ScriptSegmentShape.text.describe('This variant\'s hook, written following the variant description (15-40 words, ending with terminal punctuation).'),
|
|
77
|
+
media: ScriptSegmentShape.media,
|
|
78
|
+
})
|
|
79
|
+
.strict())
|
|
80
|
+
.length(2)
|
|
81
|
+
.refine((list) => list[0].variantId !== list[1].variantId, { message: 'hooks must cover both variants' })
|
|
82
|
+
.refine((list) => list[0].text.trim() !== list[1].text.trim(), { message: 'the two hooks must differ' })
|
|
83
|
+
.describe('One hook per variant. Only the hook differs inside a pair.'),
|
|
84
|
+
spacingHours: z
|
|
85
|
+
.number()
|
|
86
|
+
.int()
|
|
87
|
+
.min(1)
|
|
88
|
+
.max(72)
|
|
89
|
+
.default(24)
|
|
90
|
+
.describe('Scheduled mode: the second video starts this many hours after the first (default 24 = next day, same time). Ignored in asap mode.'),
|
|
91
|
+
...deliveryShape,
|
|
92
|
+
};
|
|
93
|
+
export const AddExperimentPairSchema = z.object(AddExperimentPairShape);
|
|
94
|
+
export async function handleCreateExperiment(client, args) {
|
|
95
|
+
return handleLibraryCall(() => createExperiment(client, {
|
|
96
|
+
name: args.name,
|
|
97
|
+
variable: 'hook',
|
|
98
|
+
personaId: args.personaId ?? null,
|
|
99
|
+
targetPairs: args.targetPairs,
|
|
100
|
+
variants: args.variants,
|
|
101
|
+
}), 'creating experiment', 'Experiment created. Next: add_experiment_pair for pair 1, 2, ... (each pair = 2 charged videos)');
|
|
102
|
+
}
|
|
103
|
+
export async function handleListExperiments(client) {
|
|
104
|
+
return handleLibraryCall(() => listExperiments(client), 'listing experiments');
|
|
105
|
+
}
|
|
106
|
+
export async function handleGetExperimentResults(client, args) {
|
|
107
|
+
return handleLibraryCall(() => getExperimentResults(client, args.experimentId, args.window), 'getting experiment results');
|
|
108
|
+
}
|
|
109
|
+
/** Shift a startAt by hours, keeping it naive (wall clock) when it was naive. */
|
|
110
|
+
export function shiftStartAt(startAt, hours) {
|
|
111
|
+
const absolute = /(?:[zZ]|[+-]\d{2}:?\d{2})$/.test(startAt);
|
|
112
|
+
const ms = Date.parse(absolute ? startAt : `${startAt}Z`) + hours * 3_600_000;
|
|
113
|
+
const shifted = new Date(ms).toISOString();
|
|
114
|
+
return absolute ? shifted : shifted.replace(/\.\d{3}Z$/, '');
|
|
115
|
+
}
|
|
116
|
+
function textOf(response) {
|
|
117
|
+
return response.content.map((part) => (part.type === 'text' ? part.text : '')).join('\n');
|
|
118
|
+
}
|
|
119
|
+
export async function handleAddExperimentPair(client, args) {
|
|
120
|
+
const { experimentId, pair, title, segments, hooks, spacingHours, ...delivery } = args;
|
|
121
|
+
// Alternate which variant goes first (A,B / B,A) so publish order never
|
|
122
|
+
// favours one variant.
|
|
123
|
+
const ordered = pair % 2 === 1 ? hooks : [hooks[1], hooks[0]];
|
|
124
|
+
const parts = [];
|
|
125
|
+
for (const [index, hook] of ordered.entries()) {
|
|
126
|
+
const startAt = index === 1 && delivery.mode !== 'asap' && delivery.startAt !== undefined
|
|
127
|
+
? shiftStartAt(delivery.startAt, spacingHours)
|
|
128
|
+
: delivery.startAt;
|
|
129
|
+
const { response, failedSlotIds } = await generatePersonaVideoOutcome(client, {
|
|
130
|
+
...delivery,
|
|
131
|
+
startAt,
|
|
132
|
+
title,
|
|
133
|
+
segments: [{ kind: 'hook', text: hook.text, ...(hook.media === undefined ? {} : { media: hook.media }) }, ...segments],
|
|
134
|
+
// Deterministic per (experiment, pair, variant): calling this tool
|
|
135
|
+
// again replays the videos already created instead of charging twice.
|
|
136
|
+
idempotencyKey: `exp-${experimentId}-p${pair}-${hook.variantId}`,
|
|
137
|
+
experiment: { experimentId, variantId: hook.variantId, pair },
|
|
138
|
+
});
|
|
139
|
+
if (response.isError === true) {
|
|
140
|
+
const done = index === 1 ? ` The ${ordered[0].variantId} video of pair ${pair} was created; call add_experiment_pair again with the same arguments after fixing the error — it replays that video and only creates the missing one.` : '';
|
|
141
|
+
return { content: [{ type: 'text', text: `Pair ${pair}, variant ${hook.variantId}: ${textOf(response)}${done}` }], isError: true };
|
|
142
|
+
}
|
|
143
|
+
if (failedSlotIds.length > 0) {
|
|
144
|
+
// A 2xx can carry a failed slot: a dispatch failure (502) leaves the
|
|
145
|
+
// failed slot behind and a retry on the same key replays it. The slot
|
|
146
|
+
// is its schedule's only slot, so delete_slot answers 409 (last slot)
|
|
147
|
+
// and cancel_schedule leaves a failed row alone, which keeps the
|
|
148
|
+
// (experiment, pair, variant) unique key taken: this pair number
|
|
149
|
+
// cannot be redone, so the recovery is a new pair number.
|
|
150
|
+
const done = index === 1 ? ` The ${ordered[0].variantId} video of pair ${pair} was created and stays; it is left without a partner and does not count toward the result.` : '';
|
|
151
|
+
return {
|
|
152
|
+
content: [
|
|
153
|
+
{
|
|
154
|
+
type: 'text',
|
|
155
|
+
text: `Pair ${pair}, variant ${hook.variantId}: the video failed (slot ${failedSlotIds.join(', ')}, its tokens are refunded), so this pair was NOT created. The failed slot cannot be removed (delete_slot refuses a schedule's last slot and cancel_schedule leaves failed slots in place) and it keeps pair ${pair} taken, so calling add_experiment_pair again with pair ${pair} only replays the failed video. Call add_experiment_pair with the next free pair number instead (up to the experiment's targetPairs).${done}`,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
isError: true,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
parts.push(`Variant ${hook.variantId}:\n${textOf(response)}`);
|
|
162
|
+
}
|
|
163
|
+
return { content: [{ type: 'text', text: `Pair ${pair} of experiment ${experimentId} created (2 videos).\n\n${parts.join('\n\n')}` }] };
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=tools-experiments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-experiments.js","sourceRoot":"","sources":["../src/tools-experiments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,yCAAyC,EACzC,6BAA6B,EAC7B,kCAAkC,EAClC,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAwB,MAAM,iBAAiB,CAAC;AAE1E,iBAAiB;AACjB,kEAAkE;AAClE,oEAAoE;AACpE,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,wEAAwE;AACxE,4EAA4E;AAC5E,yEAAyE;AACzE,iCAAiC;AACjC,iBAAiB;AAEjB,MAAM,SAAS,GAAG,CAAC;KAChB,MAAM,EAAE;KACR,KAAK,CAAC,6BAA6B,EAAE,4EAA4E,CAAC,CAAC;AAEtH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IA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,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,SAAS,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,IAAI,kBAAkB,YAAY,2BAA2B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAC1I,CAAC"}
|
package/dist/tools-posts.d.ts
CHANGED
|
@@ -54,3 +54,4 @@ export declare const GetYouTubeRetentionCurveSchema: z.ZodObject<{
|
|
|
54
54
|
export declare function handleGetPost(client: PostEngineerClient, args: z.infer<typeof GetPostSchema>): Promise<McpToolResponse>;
|
|
55
55
|
export declare function handleGetPostMetrics(client: PostEngineerClient, args: z.infer<typeof GetPostMetricsSchema>): Promise<McpToolResponse>;
|
|
56
56
|
export declare function handleGetYouTubeRetentionCurve(client: PostEngineerClient, args: z.infer<typeof GetYouTubeRetentionCurveSchema>): Promise<McpToolResponse>;
|
|
57
|
+
export declare function handleListPosts(client: PostEngineerClient, args: unknown): Promise<McpToolResponse>;
|
package/dist/tools-posts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { getPost, getPostMetrics, getYouTubeRetentionCurve } from './client-posts.js';
|
|
2
|
+
import { getPost, getPostMetrics, getYouTubeRetentionCurve, listPostsInRange } from './client-posts.js';
|
|
3
|
+
import { ListPostsSchema } from './schedule-shapes.js';
|
|
3
4
|
import { METRICS_FILTER_MAX_LENGTH, METRICS_NONE, METRICS_PROVIDERS, METRICS_WINDOWS, YOUTUBE_VIDEO_ID, } from './limits.js';
|
|
4
5
|
import { handleLibraryCall } from './tools-call.js';
|
|
5
6
|
//---------------
|
|
@@ -53,4 +54,19 @@ export async function handleGetPostMetrics(client, args) {
|
|
|
53
54
|
export async function handleGetYouTubeRetentionCurve(client, args) {
|
|
54
55
|
return handleLibraryCall(() => getYouTubeRetentionCurve(client, args), 'getting YouTube retention curve');
|
|
55
56
|
}
|
|
57
|
+
// list_posts — the upcoming/recent lists, or (with from + to) every post in a
|
|
58
|
+
// window. The schema's from/to pairing is a .refine, which the SDK's shape
|
|
59
|
+
// validation does not run, so the args are re-parsed here.
|
|
60
|
+
export async function handleListPosts(client, args) {
|
|
61
|
+
const parsed = ListPostsSchema.safeParse(args);
|
|
62
|
+
if (!parsed.success) {
|
|
63
|
+
const message = parsed.error.issues.map((issue) => issue.message).join('; ');
|
|
64
|
+
return { content: [{ type: 'text', text: `Error listing posts: ${message}` }], isError: true };
|
|
65
|
+
}
|
|
66
|
+
const { from, to, limit } = parsed.data;
|
|
67
|
+
if (from !== undefined && to !== undefined) {
|
|
68
|
+
return handleLibraryCall(() => listPostsInRange(client, { from, to }), 'listing posts');
|
|
69
|
+
}
|
|
70
|
+
return handleLibraryCall(() => client.listPosts(limit), 'listing posts');
|
|
71
|
+
}
|
|
56
72
|
//# sourceMappingURL=tools-posts.js.map
|
package/dist/tools-posts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-posts.js","sourceRoot":"","sources":["../src/tools-posts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"tools-posts.js","sourceRoot":"","sources":["../src/tools-posts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL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AC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7E,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACjG,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IACxC,IAAI,IAAI,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,iBAAiB,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,iBAAiB,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -7,6 +7,15 @@ type GeneratePersonaVideoArgs = z.infer<typeof GeneratePersonaVideoSchema>;
|
|
|
7
7
|
type ValidateScriptArgs = z.infer<typeof ValidateScriptSchema>;
|
|
8
8
|
export declare function handleValidateScript(client: PostEngineerClient, args: ValidateScriptArgs): Promise<McpToolResponse>;
|
|
9
9
|
export declare function handleGeneratePersonaVideo(client: PostEngineerClient, args: GeneratePersonaVideoArgs): Promise<McpToolResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* The tool response, the ids of slots the route reported as `failed` (a 2xx
|
|
12
|
+
* replay of a failed dispatch) and the created schedule id (null on error).
|
|
13
|
+
*/
|
|
14
|
+
export declare function generatePersonaVideoOutcome(client: PostEngineerClient, args: GeneratePersonaVideoArgs): Promise<{
|
|
15
|
+
response: McpToolResponse;
|
|
16
|
+
failedSlotIds: string[];
|
|
17
|
+
scheduleId: string | null;
|
|
18
|
+
}>;
|
|
10
19
|
export declare const ValidateScriptDescription = "Validate a segments script mechanically, without spending tokens: hook first, CTA last, exactly one of each, no placeholders/links/markdown/emoji/stage directions, hook terminal punctuation, word limits (total 60-200, body at least 30, CTA 5-20, hook 15-40 words before TTS). Returns the word counts and the hook window (8-12 seconds spoken). Measured hook duration is pending a hook-only TTS endpoint and is reported as pending, never invented.";
|
|
11
20
|
export declare const ScoreDraftShape: {
|
|
12
21
|
draft: z.ZodString;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Singular MCP-first tools: generate_persona_video and validate_script.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// One call is one video, with a title and a complete segments script.
|
|
3
|
+
// generate_persona_video_batch (tools-batch.ts) creates several videos by
|
|
4
|
+
// running generatePersonaVideoOutcome once per video.
|
|
4
5
|
// Validation runs mechanically before the client call, so a rejected script
|
|
5
6
|
// never reaches the web route and never debits tokens. validate_script
|
|
6
7
|
// then calls POST /api/videos/validate-script, which re-runs the same
|
|
@@ -47,13 +48,13 @@ function narrowValidateScriptPayload(result) {
|
|
|
47
48
|
export async function handleValidateScript(client, args) {
|
|
48
49
|
// Mechanical pre-check first: a rejected script never reaches the web
|
|
49
50
|
// route and never debits tokens.
|
|
50
|
-
const result = validateSegments(args.segments);
|
|
51
|
+
const result = validateSegments(args.segments, args.facelessMaterial);
|
|
51
52
|
if (!result.ok) {
|
|
52
53
|
return errorResponse(`Script validation failed: ${result.error.field}: ${result.error.rule} Fix: ${result.error.fix}`);
|
|
53
54
|
}
|
|
54
55
|
let payload;
|
|
55
56
|
try {
|
|
56
|
-
payload = narrowValidateScriptPayload(await client.validateScript(args.segments));
|
|
57
|
+
payload = narrowValidateScriptPayload(await client.validateScript(args.segments, args.facelessMaterial));
|
|
57
58
|
}
|
|
58
59
|
catch (error) {
|
|
59
60
|
return errorResponse(`Error validating the script: ${sanitizeEngineError(getErrorMessage(error))}`);
|
|
@@ -78,6 +79,13 @@ export async function handleValidateScript(client, args) {
|
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
81
|
export async function handleGeneratePersonaVideo(client, args) {
|
|
82
|
+
return (await generatePersonaVideoOutcome(client, args)).response;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The tool response, the ids of slots the route reported as `failed` (a 2xx
|
|
86
|
+
* replay of a failed dispatch) and the created schedule id (null on error).
|
|
87
|
+
*/
|
|
88
|
+
export async function generatePersonaVideoOutcome(client, args) {
|
|
81
89
|
try {
|
|
82
90
|
const mode = args.mode ?? 'scheduled';
|
|
83
91
|
if (mode === 'asap' && (args.startAt !== undefined || args.times !== undefined)) {
|
|
@@ -88,7 +96,8 @@ export async function handleGeneratePersonaVideo(client, args) {
|
|
|
88
96
|
}
|
|
89
97
|
// Mechanical validation before the client call: a rejected script
|
|
90
98
|
// never debits tokens and never reaches Modal.
|
|
91
|
-
const
|
|
99
|
+
const material = args.options?.facelessMaterial;
|
|
100
|
+
const result = validateSegments(args.segments, material);
|
|
92
101
|
if (!result.ok) {
|
|
93
102
|
throw new Error(`${result.error.field}: ${result.error.rule} Fix: ${result.error.fix}`);
|
|
94
103
|
}
|
|
@@ -102,7 +111,7 @@ export async function handleGeneratePersonaVideo(client, args) {
|
|
|
102
111
|
if (args.options?.fullLipsync === true && args.personaId === undefined) {
|
|
103
112
|
throw new Error('options.fullLipsync requires a persona with a photo and lip-sync enabled.');
|
|
104
113
|
}
|
|
105
|
-
const script = joinSegments(args.segments);
|
|
114
|
+
const script = joinSegments(args.segments, material);
|
|
106
115
|
// Voice resolution is an explicit pre-step after mechanical validation
|
|
107
116
|
// and before the generating call: an unknown voice fails without
|
|
108
117
|
// debiting tokens. A bare name/label resolves here (issue #353); with
|
|
@@ -136,6 +145,7 @@ export async function handleGeneratePersonaVideo(client, args) {
|
|
|
136
145
|
...(language === undefined ? {} : { language }),
|
|
137
146
|
},
|
|
138
147
|
idempotencyKey: args.idempotencyKey,
|
|
148
|
+
experiment: args.experiment,
|
|
139
149
|
}));
|
|
140
150
|
const scheduleId = narrowed.schedule.id ?? '(unknown id)';
|
|
141
151
|
const humanSummary = mode === 'asap'
|
|
@@ -143,16 +153,24 @@ export async function handleGeneratePersonaVideo(client, args) {
|
|
|
143
153
|
: `Scheduled 1 video in schedule ${scheduleId}: it is generated and auto-published at its slot.`;
|
|
144
154
|
const slotLines = narrowed.slots.map((slot, i) => `${i + 1}. ${slot.title ?? '(untitled)'} → ${slot.slotAt ?? '(unscheduled)'} [${slot.status ?? 'unknown'}${slot.taskId ? `, task ${slot.taskId}` : ''}]`);
|
|
145
155
|
return {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
response: {
|
|
157
|
+
content: [
|
|
158
|
+
{
|
|
159
|
+
type: 'text',
|
|
160
|
+
text: `${humanSummary}\nScript (${countWords(script)} words):\n${script}\n${slotLines.join('\n')}\n${JSON.stringify(narrowed, null, 2)}`,
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
failedSlotIds: narrowed.slots.filter((slot) => slot.status === 'failed').map((slot) => slot.slotId ?? '(unknown slot id)'),
|
|
165
|
+
scheduleId: narrowed.schedule.id,
|
|
152
166
|
};
|
|
153
167
|
}
|
|
154
168
|
catch (error) {
|
|
155
|
-
return
|
|
169
|
+
return {
|
|
170
|
+
response: errorResponse(`Error generating the video: ${sanitizeEngineError(getErrorMessage(error))}`),
|
|
171
|
+
failedSlotIds: [],
|
|
172
|
+
scheduleId: null,
|
|
173
|
+
};
|
|
156
174
|
}
|
|
157
175
|
}
|
|
158
176
|
function narrowScheduledVideos(result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-single-video.js","sourceRoot":"","sources":["../src/tools-single-video.ts"],"names":[],"mappings":"AAAA,wEAAwE;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AM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA0B,EAC1B,IAAsC;IAEtC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+DAA+D;QAC/D,oEAAoE;QACpE,SAAS;QACT,OAAO,aAAa,CAAC,wBAAwB,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -68,17 +68,22 @@ export declare const CreatePersonaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
68
68
|
paragraphNumber: number;
|
|
69
69
|
niche: string;
|
|
70
70
|
faceQuality: "ok" | "very_good";
|
|
71
|
-
avatarUrl?: string | undefined;
|
|
72
|
-
avatarPath?: string | undefined;
|
|
73
|
-
imagePrimaryIndex?: number | undefined;
|
|
74
71
|
images?: {
|
|
75
72
|
path: string;
|
|
76
73
|
tag?: string | undefined;
|
|
77
74
|
description?: string | undefined;
|
|
78
75
|
}[] | undefined;
|
|
76
|
+
avatarUrl?: string | undefined;
|
|
77
|
+
avatarPath?: string | undefined;
|
|
78
|
+
imagePrimaryIndex?: number | undefined;
|
|
79
79
|
}, {
|
|
80
80
|
name: string;
|
|
81
81
|
voiceId: string;
|
|
82
|
+
images?: {
|
|
83
|
+
path: string;
|
|
84
|
+
tag?: string | undefined;
|
|
85
|
+
description?: string | undefined;
|
|
86
|
+
}[] | undefined;
|
|
82
87
|
avatarUrl?: string | undefined;
|
|
83
88
|
avatarPath?: string | undefined;
|
|
84
89
|
language?: string | undefined;
|
|
@@ -89,11 +94,6 @@ export declare const CreatePersonaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
89
94
|
niche?: string | undefined;
|
|
90
95
|
faceQuality?: "ok" | "very_good" | undefined;
|
|
91
96
|
imagePrimaryIndex?: number | undefined;
|
|
92
|
-
images?: {
|
|
93
|
-
path: string;
|
|
94
|
-
tag?: string | undefined;
|
|
95
|
-
description?: string | undefined;
|
|
96
|
-
}[] | undefined;
|
|
97
97
|
}>, {
|
|
98
98
|
name: string;
|
|
99
99
|
voiceId: string;
|
|
@@ -104,17 +104,22 @@ export declare const CreatePersonaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
104
104
|
paragraphNumber: number;
|
|
105
105
|
niche: string;
|
|
106
106
|
faceQuality: "ok" | "very_good";
|
|
107
|
-
avatarUrl?: string | undefined;
|
|
108
|
-
avatarPath?: string | undefined;
|
|
109
|
-
imagePrimaryIndex?: number | undefined;
|
|
110
107
|
images?: {
|
|
111
108
|
path: string;
|
|
112
109
|
tag?: string | undefined;
|
|
113
110
|
description?: string | undefined;
|
|
114
111
|
}[] | undefined;
|
|
112
|
+
avatarUrl?: string | undefined;
|
|
113
|
+
avatarPath?: string | undefined;
|
|
114
|
+
imagePrimaryIndex?: number | undefined;
|
|
115
115
|
}, {
|
|
116
116
|
name: string;
|
|
117
117
|
voiceId: string;
|
|
118
|
+
images?: {
|
|
119
|
+
path: string;
|
|
120
|
+
tag?: string | undefined;
|
|
121
|
+
description?: string | undefined;
|
|
122
|
+
}[] | undefined;
|
|
118
123
|
avatarUrl?: string | undefined;
|
|
119
124
|
avatarPath?: string | undefined;
|
|
120
125
|
language?: string | undefined;
|
|
@@ -125,11 +130,6 @@ export declare const CreatePersonaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
125
130
|
niche?: string | undefined;
|
|
126
131
|
faceQuality?: "ok" | "very_good" | undefined;
|
|
127
132
|
imagePrimaryIndex?: number | undefined;
|
|
128
|
-
images?: {
|
|
129
|
-
path: string;
|
|
130
|
-
tag?: string | undefined;
|
|
131
|
-
description?: string | undefined;
|
|
132
|
-
}[] | undefined;
|
|
133
133
|
}>;
|
|
134
134
|
export declare const ListPersonasShape: {};
|
|
135
135
|
export declare const ListPersonasSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
@@ -137,80 +137,7 @@ export { ListVoicesShape, ListVoicesSchema } from './voice-filters.js';
|
|
|
137
137
|
export { ListClonedVoicesShape, ListClonedVoicesSchema, CreateClonedVoiceShape, CreateClonedVoiceSchema, DeleteClonedVoiceShape, DeleteClonedVoiceSchema, PreviewClonedVoiceShape, PreviewClonedVoiceSchema, } from './cloned-voice-tools.js';
|
|
138
138
|
export declare const ListFacesShape: {};
|
|
139
139
|
export declare const ListFacesSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
140
|
-
export
|
|
141
|
-
voiceId: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodEnum<[string, ...string[]]>, z.ZodString]>, string, string>>;
|
|
142
|
-
language: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
143
|
-
videoAspect: z.ZodOptional<z.ZodEnum<["9:16", "16:9"]>>;
|
|
144
|
-
videoLayout: z.ZodOptional<z.ZodEnum<["standard", "react"]>>;
|
|
145
|
-
scriptPrompt: z.ZodOptional<z.ZodString>;
|
|
146
|
-
paragraphNumber: z.ZodOptional<z.ZodNumber>;
|
|
147
|
-
niche: z.ZodOptional<z.ZodString>;
|
|
148
|
-
avatarUrl: z.ZodOptional<z.ZodString>;
|
|
149
|
-
avatarPath: z.ZodOptional<z.ZodString>;
|
|
150
|
-
personaId: z.ZodString;
|
|
151
|
-
name: z.ZodOptional<z.ZodString>;
|
|
152
|
-
};
|
|
153
|
-
export declare const UpdatePersonaSchema: z.ZodEffects<z.ZodObject<{
|
|
154
|
-
voiceId: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodEnum<[string, ...string[]]>, z.ZodString]>, string, string>>;
|
|
155
|
-
language: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
156
|
-
videoAspect: z.ZodOptional<z.ZodEnum<["9:16", "16:9"]>>;
|
|
157
|
-
videoLayout: z.ZodOptional<z.ZodEnum<["standard", "react"]>>;
|
|
158
|
-
scriptPrompt: z.ZodOptional<z.ZodString>;
|
|
159
|
-
paragraphNumber: z.ZodOptional<z.ZodNumber>;
|
|
160
|
-
niche: z.ZodOptional<z.ZodString>;
|
|
161
|
-
avatarUrl: z.ZodOptional<z.ZodString>;
|
|
162
|
-
avatarPath: z.ZodOptional<z.ZodString>;
|
|
163
|
-
personaId: z.ZodString;
|
|
164
|
-
name: z.ZodOptional<z.ZodString>;
|
|
165
|
-
}, "strip", z.ZodTypeAny, {
|
|
166
|
-
personaId: string;
|
|
167
|
-
avatarUrl?: string | undefined;
|
|
168
|
-
avatarPath?: string | undefined;
|
|
169
|
-
name?: string | undefined;
|
|
170
|
-
voiceId?: string | undefined;
|
|
171
|
-
language?: string | undefined;
|
|
172
|
-
videoAspect?: "9:16" | "16:9" | undefined;
|
|
173
|
-
videoLayout?: "standard" | "react" | undefined;
|
|
174
|
-
scriptPrompt?: string | undefined;
|
|
175
|
-
paragraphNumber?: number | undefined;
|
|
176
|
-
niche?: string | undefined;
|
|
177
|
-
}, {
|
|
178
|
-
personaId: string;
|
|
179
|
-
avatarUrl?: string | undefined;
|
|
180
|
-
avatarPath?: string | undefined;
|
|
181
|
-
name?: string | undefined;
|
|
182
|
-
voiceId?: string | undefined;
|
|
183
|
-
language?: string | undefined;
|
|
184
|
-
videoAspect?: "9:16" | "16:9" | undefined;
|
|
185
|
-
videoLayout?: "standard" | "react" | undefined;
|
|
186
|
-
scriptPrompt?: string | undefined;
|
|
187
|
-
paragraphNumber?: number | undefined;
|
|
188
|
-
niche?: string | undefined;
|
|
189
|
-
}>, {
|
|
190
|
-
personaId: string;
|
|
191
|
-
avatarUrl?: string | undefined;
|
|
192
|
-
avatarPath?: string | undefined;
|
|
193
|
-
name?: string | undefined;
|
|
194
|
-
voiceId?: string | undefined;
|
|
195
|
-
language?: string | undefined;
|
|
196
|
-
videoAspect?: "9:16" | "16:9" | undefined;
|
|
197
|
-
videoLayout?: "standard" | "react" | undefined;
|
|
198
|
-
scriptPrompt?: string | undefined;
|
|
199
|
-
paragraphNumber?: number | undefined;
|
|
200
|
-
niche?: string | undefined;
|
|
201
|
-
}, {
|
|
202
|
-
personaId: string;
|
|
203
|
-
avatarUrl?: string | undefined;
|
|
204
|
-
avatarPath?: string | undefined;
|
|
205
|
-
name?: string | undefined;
|
|
206
|
-
voiceId?: string | undefined;
|
|
207
|
-
language?: string | undefined;
|
|
208
|
-
videoAspect?: "9:16" | "16:9" | undefined;
|
|
209
|
-
videoLayout?: "standard" | "react" | undefined;
|
|
210
|
-
scriptPrompt?: string | undefined;
|
|
211
|
-
paragraphNumber?: number | undefined;
|
|
212
|
-
niche?: string | undefined;
|
|
213
|
-
}>;
|
|
140
|
+
export { UpdatePersonaShape, UpdatePersonaSchema, handleUpdatePersona } from './persona-update.js';
|
|
214
141
|
export declare const ListSocialAccountsShape: {};
|
|
215
142
|
export declare const ListSocialAccountsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
216
143
|
export declare const ConnectAccountShape: {
|
|
@@ -404,11 +331,9 @@ export declare function handleListPersonas(client: PostEngineerClient): Promise<
|
|
|
404
331
|
export declare function handleListVoices(client: PostEngineerClient, args?: ListVoicesArgs): Promise<McpToolResponse>;
|
|
405
332
|
export { handleListClonedVoices, handleCreateClonedVoice, handleDeleteClonedVoice, handlePreviewClonedVoice, } from './cloned-voice-tools.js';
|
|
406
333
|
export declare function handleListFaces(client: PostEngineerClient): Promise<McpToolResponse>;
|
|
407
|
-
export declare function handleUpdatePersona(client: PostEngineerClient, args: z.infer<typeof UpdatePersonaSchema>): Promise<McpToolResponse>;
|
|
408
334
|
export declare function handleListSocialAccounts(client: PostEngineerClient): Promise<McpToolResponse>;
|
|
409
335
|
export declare function handleConnectAccount(client: PostEngineerClient, args: z.infer<typeof ConnectAccountSchema>): Promise<McpToolResponse>;
|
|
410
336
|
export declare function handleListSchedules(client: PostEngineerClient): Promise<McpToolResponse>;
|
|
411
|
-
export declare function handleListPosts(client: PostEngineerClient, args: z.infer<typeof ListPostsSchema>): Promise<McpToolResponse>;
|
|
412
337
|
export declare function handleCancelSchedule(client: PostEngineerClient, args: z.infer<typeof CancelScheduleSchema>): Promise<McpToolResponse>;
|
|
413
338
|
export declare function handleGetSlot(client: PostEngineerClient, args: z.infer<typeof GetSlotSchema>): Promise<McpToolResponse>;
|
|
414
339
|
export declare function handleUpdateSlotTitle(client: PostEngineerClient, args: z.infer<typeof UpdateSlotTitleSchema>): Promise<McpToolResponse>;
|
package/dist/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { filterVoicesPayload, ListVoicesSchema } from './voice-filters.js';
|
|
3
|
-
import { personaVoiceField, withResolvedPersonaVoice
|
|
3
|
+
import { personaVoiceField, withResolvedPersonaVoice } from './voice-filters.js';
|
|
4
4
|
import { CancelScheduleSchema, CancelScheduleShape, DeleteSlotSchema, DeleteSlotShape, GeneratePersonaVideoOptionsShape, GetSlotSchema, GetSlotShape, ListPostsSchema, ListPostsShape, ListSchedulesSchema, ListSchedulesShape, UpdateSlotTitleSchema, UpdateSlotTitleShape, } from './schedule-shapes.js';
|
|
5
5
|
// Re-exported so existing import sites (`./tools.js`) keep working.
|
|
6
6
|
export { CancelScheduleSchema, CancelScheduleShape, DeleteSlotSchema, DeleteSlotShape, GeneratePersonaVideoOptionsShape, GetSlotSchema, GetSlotShape, ListPostsSchema, ListPostsShape, ListSchedulesSchema, ListSchedulesShape, UpdateSlotTitleSchema, UpdateSlotTitleShape, };
|
|
@@ -8,7 +8,7 @@ import { handleLibraryCall } from './tools-call.js';
|
|
|
8
8
|
import { MAX_LIBRARY_IMAGES, MAX_LIBRARY_IMAGE_MB, MAX_LIBRARY_TAG_LENGTH, MAX_LIBRARY_DESCRIPTION_LENGTH, MAX_UPLOAD_VIDEO_GB, VIDEO_LAYOUTS, } from './client.js';
|
|
9
9
|
import { getErrorMessage, ApiError } from './errors.js';
|
|
10
10
|
import { isEnglishLanguage, ONLY_ENGLISH_VIDEOS_MESSAGE } from './language.js';
|
|
11
|
-
import { CreatePersonaAvatarFields, refinePersonaAvatar
|
|
11
|
+
import { CreatePersonaAvatarFields, refinePersonaAvatar } from './persona-avatar.js';
|
|
12
12
|
// Shared field definitions: path/tag/description limits appear in both the
|
|
13
13
|
// create-persona images array and add_persona_image — define once so the
|
|
14
14
|
// limits and descriptions can't drift apart.
|
|
@@ -49,23 +49,9 @@ export { ListVoicesShape, ListVoicesSchema } from './voice-filters.js';
|
|
|
49
49
|
export { ListClonedVoicesShape, ListClonedVoicesSchema, CreateClonedVoiceShape, CreateClonedVoiceSchema, DeleteClonedVoiceShape, DeleteClonedVoiceSchema, PreviewClonedVoiceShape, PreviewClonedVoiceSchema, } from './cloned-voice-tools.js';
|
|
50
50
|
export const ListFacesShape = {};
|
|
51
51
|
export const ListFacesSchema = z.object(ListFacesShape);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
...UpdatePersonaAvatarFields,
|
|
56
|
-
voiceId: personaVoiceField().optional().describe('New voice id or label from list_voices. Never type a provider prefix.'),
|
|
57
|
-
language: z
|
|
58
|
-
.string()
|
|
59
|
-
.refine(isEnglishLanguage, { message: ONLY_ENGLISH_VIDEOS_MESSAGE })
|
|
60
|
-
.optional()
|
|
61
|
-
.describe('New language code — English only for now (e.g. en-US, en-GB)'),
|
|
62
|
-
videoAspect: z.enum(['9:16', '16:9']).optional().describe('New video aspect ratio'),
|
|
63
|
-
videoLayout: z.enum(VIDEO_LAYOUTS).optional().describe('New persona-hook layout (standard or react)'),
|
|
64
|
-
scriptPrompt: z.string().optional().describe('New system prompt instructions for video scripts'),
|
|
65
|
-
paragraphNumber: z.number().int().min(1).max(10).optional().describe('New number of paragraphs'),
|
|
66
|
-
niche: z.string().max(300).optional().describe('New content niche'),
|
|
67
|
-
};
|
|
68
|
-
export const UpdatePersonaSchema = z.object(UpdatePersonaShape).superRefine(refinePersonaAvatar(false));
|
|
52
|
+
// update_persona lives in persona-update.ts (shape, schema and handler);
|
|
53
|
+
// re-exported here so existing import sites keep working.
|
|
54
|
+
export { UpdatePersonaShape, UpdatePersonaSchema, handleUpdatePersona } from './persona-update.js';
|
|
69
55
|
export const ListSocialAccountsShape = {};
|
|
70
56
|
export const ListSocialAccountsSchema = z.object(ListSocialAccountsShape);
|
|
71
57
|
export const ConnectAccountShape = {
|
|
@@ -198,10 +184,6 @@ export { handleListClonedVoices, handleCreateClonedVoice, handleDeleteClonedVoic
|
|
|
198
184
|
export async function handleListFaces(client) {
|
|
199
185
|
return handleLibraryCall(() => client.listFaces(), 'listing faces');
|
|
200
186
|
}
|
|
201
|
-
export async function handleUpdatePersona(client, args) {
|
|
202
|
-
// Full-schema parse, then voice routing BEFORE the POST; no voiceId keeps the stored voice (#353).
|
|
203
|
-
return handleLibraryCall(async () => client.updatePersona(await withResolvedPersonaVoiceForUpdate(client, UpdatePersonaSchema.parse(args))), 'updating persona', 'Persona updated successfully');
|
|
204
|
-
}
|
|
205
187
|
export async function handleListSocialAccounts(client) {
|
|
206
188
|
return handleLibraryCall(() => client.listSocialAccounts(), 'listing social accounts');
|
|
207
189
|
}
|
|
@@ -272,7 +254,7 @@ export async function handleConnectAccount(client, args) {
|
|
|
272
254
|
content: [
|
|
273
255
|
{
|
|
274
256
|
type: 'text',
|
|
275
|
-
text: `To connect your ${args.provider} account, open this URL in
|
|
257
|
+
text: `To connect your ${args.provider} account, open this URL in a browser where you are signed in to Post Engineer with the same account as this API key, and authorize Post Engineer:\n\n` +
|
|
276
258
|
`${result.auth_url}\n\n` +
|
|
277
259
|
`Once you authorize, the account is connected automatically. Verify with list_social_accounts.`,
|
|
278
260
|
},
|
|
@@ -294,9 +276,6 @@ export async function handleConnectAccount(client, args) {
|
|
|
294
276
|
export async function handleListSchedules(client) {
|
|
295
277
|
return handleLibraryCall(() => client.listSchedules(), 'listing schedules');
|
|
296
278
|
}
|
|
297
|
-
export async function handleListPosts(client, args) {
|
|
298
|
-
return handleLibraryCall(() => client.listPosts(args.limit), 'listing posts');
|
|
299
|
-
}
|
|
300
279
|
export async function handleCancelSchedule(client, args) {
|
|
301
280
|
return handleLibraryCall(() => client.cancelSchedule(args.scheduleId), 'cancelling schedule', 'Schedule cancelled successfully');
|
|
302
281
|
}
|