post-engineer-mcp 1.31.0 → 1.33.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 +51 -9
- package/dist/analytics.d.ts +1 -0
- package/dist/analytics.js +23 -1
- package/dist/analytics.js.map +1 -1
- package/dist/client-posts.d.ts +10 -0
- package/dist/client-posts.js +15 -0
- package/dist/client-posts.js.map +1 -0
- package/dist/client-publishing-accounts.d.ts +3 -0
- package/dist/client-publishing-accounts.js +18 -0
- package/dist/client-publishing-accounts.js.map +1 -0
- package/dist/client-types.d.ts +140 -0
- package/dist/client-types.js +2 -0
- package/dist/client-types.js.map +1 -0
- package/dist/client-user-media.d.ts +29 -0
- package/dist/client-user-media.js +135 -0
- package/dist/client-user-media.js.map +1 -0
- package/dist/client-video-task.d.ts +2 -0
- package/dist/client-video-task.js +9 -0
- package/dist/client-video-task.js.map +1 -0
- package/dist/client.d.ts +11 -134
- package/dist/client.js +32 -40
- package/dist/client.js.map +1 -1
- package/dist/cloned-voice-client.d.ts +11 -0
- package/dist/cloned-voice-client.js +134 -0
- package/dist/cloned-voice-client.js.map +1 -0
- package/dist/cloned-voice-tools.d.ts +70 -0
- package/dist/cloned-voice-tools.js +60 -0
- package/dist/cloned-voice-tools.js.map +1 -0
- package/dist/http-auth.d.ts +27 -0
- package/dist/http-auth.js +148 -0
- package/dist/http-auth.js.map +1 -0
- package/dist/http-rate-limit.d.ts +14 -0
- package/dist/http-rate-limit.js +28 -0
- package/dist/http-rate-limit.js.map +1 -0
- package/dist/http-transport.d.ts +13 -0
- package/dist/http-transport.js +311 -0
- package/dist/http-transport.js.map +1 -0
- package/dist/image-guards.d.ts +6 -0
- package/dist/image-guards.js +30 -0
- package/dist/image-guards.js.map +1 -0
- package/dist/index.js +69 -29
- package/dist/index.js.map +1 -1
- package/dist/language.d.ts +11 -0
- package/dist/language.js +19 -0
- package/dist/language.js.map +1 -0
- package/dist/limits.d.ts +39 -0
- package/dist/limits.js +39 -0
- package/dist/limits.js.map +1 -1
- package/dist/prompts.d.ts +9 -0
- package/dist/prompts.js +125 -0
- package/dist/prompts.js.map +1 -0
- package/dist/require-title.d.ts +1 -0
- package/dist/require-title.js +12 -0
- package/dist/require-title.js.map +1 -0
- package/dist/schedule-shapes.d.ts +70 -0
- package/dist/schedule-shapes.js +98 -0
- package/dist/schedule-shapes.js.map +1 -0
- package/dist/script-segments.d.ts +49 -0
- package/dist/script-segments.js +222 -0
- package/dist/script-segments.js.map +1 -0
- package/dist/single-video-shape.d.ts +340 -0
- package/dist/single-video-shape.js +74 -0
- package/dist/single-video-shape.js.map +1 -0
- package/dist/tools-call.d.ts +4 -0
- package/dist/tools-call.js +25 -0
- package/dist/tools-call.js.map +1 -0
- package/dist/tools-posts.d.ts +41 -0
- package/dist/tools-posts.js +45 -0
- package/dist/tools-posts.js.map +1 -0
- package/dist/tools-publishing-accounts.d.ts +29 -0
- package/dist/tools-publishing-accounts.js +38 -0
- package/dist/tools-publishing-accounts.js.map +1 -0
- package/dist/tools-single-video.d.ts +10 -0
- package/dist/tools-single-video.js +143 -0
- package/dist/tools-single-video.js.map +1 -0
- package/dist/tools-user-media.d.ts +27 -0
- package/dist/tools-user-media.js +38 -0
- package/dist/tools-user-media.js.map +1 -0
- package/dist/tools.d.ts +32 -230
- package/dist/tools.js +42 -295
- package/dist/tools.js.map +1 -1
- package/dist/video-task-tools.d.ts +14 -0
- package/dist/video-task-tools.js +20 -0
- package/dist/video-task-tools.js.map +1 -0
- package/dist/voice-filters.d.ts +21 -0
- package/dist/voice-filters.js +76 -0
- package/dist/voice-filters.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export type McpToolResponse = CallToolResult;
|
|
3
|
+
/** Shared wrapper for simple list/mutate handlers (try/catch + JSON text). */
|
|
4
|
+
export declare function handleLibraryCall(clientCall: () => Promise<unknown>, errorVerb: string, successPrefix?: string): Promise<McpToolResponse>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getErrorMessage } from './errors.js';
|
|
2
|
+
/** Shared wrapper for simple list/mutate handlers (try/catch + JSON text). */
|
|
3
|
+
export async function handleLibraryCall(clientCall, errorVerb, successPrefix) {
|
|
4
|
+
try {
|
|
5
|
+
const result = await clientCall();
|
|
6
|
+
const text = successPrefix
|
|
7
|
+
? `${successPrefix}: ${JSON.stringify(result, null, 2)}`
|
|
8
|
+
: JSON.stringify(result, null, 2);
|
|
9
|
+
return {
|
|
10
|
+
content: [{ type: 'text', text }],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: 'text',
|
|
18
|
+
text: `Error ${errorVerb}: ${getErrorMessage(error)}`,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
isError: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=tools-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-call.js","sourceRoot":"","sources":["../src/tools-call.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAkC,EAClC,SAAiB,EACjB,aAAsB;IAEtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,aAAa;YACxB,CAAC,CAAC,GAAG,aAAa,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;YACxD,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACpC,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAClC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS,SAAS,KAAK,eAAe,CAAC,KAAK,CAAC,EAAE;iBACtD;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PostEngineerClient } from './client.js';
|
|
3
|
+
import { type McpToolResponse } from './tools-call.js';
|
|
4
|
+
export declare const GetPostShape: {
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
};
|
|
7
|
+
export declare const GetPostSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
id: string;
|
|
11
|
+
}, {
|
|
12
|
+
id: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const GetPostMetricsShape: {
|
|
15
|
+
window: z.ZodEnum<["24h", "7d"]>;
|
|
16
|
+
persona: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
17
|
+
account: z.ZodOptional<z.ZodString>;
|
|
18
|
+
provider: z.ZodOptional<z.ZodEnum<["youtube", "instagram", "bluesky", "linkedin"]>>;
|
|
19
|
+
angle: z.ZodOptional<z.ZodString>;
|
|
20
|
+
};
|
|
21
|
+
export declare const GetPostMetricsSchema: z.ZodObject<{
|
|
22
|
+
window: z.ZodEnum<["24h", "7d"]>;
|
|
23
|
+
persona: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
24
|
+
account: z.ZodOptional<z.ZodString>;
|
|
25
|
+
provider: z.ZodOptional<z.ZodEnum<["youtube", "instagram", "bluesky", "linkedin"]>>;
|
|
26
|
+
angle: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
window: "24h" | "7d";
|
|
29
|
+
provider?: "youtube" | "instagram" | "bluesky" | "linkedin" | undefined;
|
|
30
|
+
persona?: string | undefined;
|
|
31
|
+
account?: string | undefined;
|
|
32
|
+
angle?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
window: "24h" | "7d";
|
|
35
|
+
provider?: "youtube" | "instagram" | "bluesky" | "linkedin" | undefined;
|
|
36
|
+
persona?: string | undefined;
|
|
37
|
+
account?: string | undefined;
|
|
38
|
+
angle?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function handleGetPost(client: PostEngineerClient, args: z.infer<typeof GetPostSchema>): Promise<McpToolResponse>;
|
|
41
|
+
export declare function handleGetPostMetrics(client: PostEngineerClient, args: z.infer<typeof GetPostMetricsSchema>): Promise<McpToolResponse>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getPost, getPostMetrics } from './client-posts.js';
|
|
3
|
+
import { METRICS_FILTER_MAX_LENGTH, METRICS_NONE, METRICS_PROVIDERS, METRICS_WINDOWS, } from './limits.js';
|
|
4
|
+
import { handleLibraryCall } from './tools-call.js';
|
|
5
|
+
//---------------
|
|
6
|
+
// get_post and get_post_metrics — MCP tools.
|
|
7
|
+
//
|
|
8
|
+
// Extracted from tools.ts so the tools module stays under the file-size
|
|
9
|
+
// ratchet.
|
|
10
|
+
//---------------
|
|
11
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
12
|
+
export const GetPostShape = {
|
|
13
|
+
id: z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1, 'id is required')
|
|
16
|
+
.describe('A post id of either kind: a slot id (slotId from list_posts / generate_persona_video) or a generation id (generationId from list_video_generations). The server resolves which one it is.'),
|
|
17
|
+
};
|
|
18
|
+
export const GetPostSchema = z.object(GetPostShape);
|
|
19
|
+
const metricsFilter = z.string().min(1).max(METRICS_FILTER_MAX_LENGTH);
|
|
20
|
+
export const GetPostMetricsShape = {
|
|
21
|
+
window: z
|
|
22
|
+
.enum(METRICS_WINDOWS)
|
|
23
|
+
.describe('Snapshot window: 24h (first day after publishing) or 7d (first week).'),
|
|
24
|
+
persona: metricsFilter
|
|
25
|
+
.refine((value) => value === METRICS_NONE || UUID.test(value), {
|
|
26
|
+
message: `persona must be a uuid or ${METRICS_NONE}`,
|
|
27
|
+
})
|
|
28
|
+
.optional()
|
|
29
|
+
.describe(`Optional persona id filter (uuid from list_personas), or ${METRICS_NONE} for posts with no persona.`),
|
|
30
|
+
account: metricsFilter
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Optional publishing account id filter (the account ids from list_social_accounts).'),
|
|
33
|
+
provider: z.enum(METRICS_PROVIDERS).optional().describe('Optional network filter.'),
|
|
34
|
+
angle: metricsFilter
|
|
35
|
+
.optional()
|
|
36
|
+
.describe(`Optional script angle filter (exact match), or ${METRICS_NONE} for posts with no angle.`),
|
|
37
|
+
};
|
|
38
|
+
export const GetPostMetricsSchema = z.object(GetPostMetricsShape);
|
|
39
|
+
export async function handleGetPost(client, args) {
|
|
40
|
+
return handleLibraryCall(() => getPost(client, args.id), 'getting post');
|
|
41
|
+
}
|
|
42
|
+
export async function handleGetPostMetrics(client, args) {
|
|
43
|
+
return handleLibraryCall(() => getPostMetrics(client, args), 'getting post metrics');
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=tools-posts.js.map
|
|
@@ -0,0 +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,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,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F,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA0B,EAC1B,IAAmC;IAEnC,OAAO,iBAAiB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,IAA0C;IAE1C,OAAO,iBAAiB,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PostEngineerClient } from './client.js';
|
|
3
|
+
import { type McpToolResponse } from './tools.js';
|
|
4
|
+
export declare const GetPersonaPublishingAccountsShape: {
|
|
5
|
+
personaId: z.ZodString;
|
|
6
|
+
};
|
|
7
|
+
export declare const GetPersonaPublishingAccountsSchema: z.ZodObject<{
|
|
8
|
+
personaId: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
personaId: string;
|
|
11
|
+
}, {
|
|
12
|
+
personaId: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const SetPersonaPublishingAccountsShape: {
|
|
15
|
+
personaId: z.ZodString;
|
|
16
|
+
accounts: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
};
|
|
18
|
+
export declare const SetPersonaPublishingAccountsSchema: z.ZodObject<{
|
|
19
|
+
personaId: z.ZodString;
|
|
20
|
+
accounts: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
personaId: string;
|
|
23
|
+
accounts: Record<string, string[]>;
|
|
24
|
+
}, {
|
|
25
|
+
personaId: string;
|
|
26
|
+
accounts: Record<string, string[]>;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function handleGetPersonaPublishingAccounts(client: PostEngineerClient, args: z.infer<typeof GetPersonaPublishingAccountsSchema>): Promise<McpToolResponse>;
|
|
29
|
+
export declare function handleSetPersonaPublishingAccounts(client: PostEngineerClient, args: z.infer<typeof SetPersonaPublishingAccountsSchema>): Promise<McpToolResponse>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getPersonaPublishingAccounts, setPersonaPublishingAccounts, } from './client-publishing-accounts.js';
|
|
3
|
+
import { handleLibraryCall } from './tools.js';
|
|
4
|
+
//---------------
|
|
5
|
+
// Per-persona default publishing accounts (issue #212) — MCP tools.
|
|
6
|
+
//
|
|
7
|
+
// Extracted from tools.ts so the tools module stays under the file-size
|
|
8
|
+
// ratchet. Since issue #212, omitting all four provider account-id fields
|
|
9
|
+
// in generate_persona_video falls back to the persona's default publishing
|
|
10
|
+
// accounts (set via set_persona_publishing_accounts); explicit ids always
|
|
11
|
+
// win.
|
|
12
|
+
//---------------
|
|
13
|
+
export const GetPersonaPublishingAccountsShape = {
|
|
14
|
+
personaId: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1, 'personaId is required')
|
|
17
|
+
.describe('The persona ID whose default publishing accounts to list.'),
|
|
18
|
+
};
|
|
19
|
+
export const GetPersonaPublishingAccountsSchema = z.object(GetPersonaPublishingAccountsShape);
|
|
20
|
+
export const SetPersonaPublishingAccountsShape = {
|
|
21
|
+
personaId: z
|
|
22
|
+
.string()
|
|
23
|
+
.min(1, 'personaId is required')
|
|
24
|
+
.describe('The persona ID whose default publishing accounts to replace.'),
|
|
25
|
+
accounts: z
|
|
26
|
+
.record(z.string(), z.array(z.string().min(1)))
|
|
27
|
+
.describe('Default publishing accounts per provider, e.g. { youtube: ["UC..."], bluesky: ["did:plc:..."] }. ' +
|
|
28
|
+
'Replaces the whole set: providers mapped to [] (or omitted) keep no defaults. ' +
|
|
29
|
+
'Account IDs come from list_social_accounts (channelId / igUserId / providerAccountId / did).'),
|
|
30
|
+
};
|
|
31
|
+
export const SetPersonaPublishingAccountsSchema = z.object(SetPersonaPublishingAccountsShape);
|
|
32
|
+
export async function handleGetPersonaPublishingAccounts(client, args) {
|
|
33
|
+
return handleLibraryCall(() => getPersonaPublishingAccounts(client, args.personaId), 'getting persona publishing accounts');
|
|
34
|
+
}
|
|
35
|
+
export async function handleSetPersonaPublishingAccounts(client, args) {
|
|
36
|
+
return handleLibraryCall(() => setPersonaPublishingAccounts(client, args.personaId, args.accounts), 'setting persona publishing accounts', 'Persona publishing accounts updated successfully');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=tools-publishing-accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-publishing-accounts.js","sourceRoot":"","sources":["../src/tools-publishing-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAwB,MAAM,YAAY,CAAC;AAErE,iBAAiB;AACjB,oEAAoE;AACpE,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,OAAO;AACP,iBAAiB;AAEjB,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,QAAQ,CAAC,2DAA2D,CAAC;CACzE,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,QAAQ,CAAC,8DAA8D,CAAC;IAC3E,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C,QAAQ,CACP,mGAAmG;QACjG,gFAAgF;QAChF,8FAA8F,CACjG;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC;AAE9F,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,MAA0B,EAC1B,IAAwD;IAExD,OAAO,iBAAiB,CACtB,GAAG,EAAE,CAAC,4BAA4B,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAC1D,qCAAqC,CACtC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,MAA0B,EAC1B,IAAwD;IAExD,OAAO,iBAAiB,CACtB,GAAG,EAAE,CAAC,4BAA4B,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,EACzE,qCAAqC,EACrC,kDAAkD,CACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PostEngineerClient } from './client.js';
|
|
3
|
+
import type { McpToolResponse } from './tools-call.js';
|
|
4
|
+
import { GeneratePersonaVideoSchema, ValidateScriptSchema } from './single-video-shape.js';
|
|
5
|
+
export { GeneratePersonaVideoShape, ValidateScriptShape } from './single-video-shape.js';
|
|
6
|
+
type GeneratePersonaVideoArgs = z.infer<typeof GeneratePersonaVideoSchema>;
|
|
7
|
+
type ValidateScriptArgs = z.infer<typeof ValidateScriptSchema>;
|
|
8
|
+
export declare function handleValidateScript(client: PostEngineerClient, args: ValidateScriptArgs): Promise<McpToolResponse>;
|
|
9
|
+
export declare function handleGeneratePersonaVideo(client: PostEngineerClient, args: GeneratePersonaVideoArgs): Promise<McpToolResponse>;
|
|
10
|
+
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.";
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { getErrorMessage } from './errors.js';
|
|
2
|
+
import { sanitizeEngineError } from './tools.js';
|
|
3
|
+
import { HOOK_MAX_SECONDS, HOOK_MIN_SECONDS, countWords, joinSegments, validateSegments, } from './script-segments.js';
|
|
4
|
+
export { GeneratePersonaVideoShape, ValidateScriptShape } from './single-video-shape.js';
|
|
5
|
+
function errorResponse(message) {
|
|
6
|
+
return { content: [{ type: 'text', text: message }], isError: true };
|
|
7
|
+
}
|
|
8
|
+
function narrowValidateScriptPayload(result) {
|
|
9
|
+
if (typeof result !== 'object' || result === null)
|
|
10
|
+
return null;
|
|
11
|
+
const record = result;
|
|
12
|
+
if (record.success !== true) {
|
|
13
|
+
return typeof record.error === 'string' && record.error.length > 0
|
|
14
|
+
? record.error
|
|
15
|
+
: 'The web validation endpoint rejected the script.';
|
|
16
|
+
}
|
|
17
|
+
const numbers = ['segmentCount', 'totalWords', 'hookWords', 'bodyWords', 'ctaWords'];
|
|
18
|
+
for (const key of numbers) {
|
|
19
|
+
if (typeof record[key] !== 'number')
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (record.measured !== 'pending' || record.measuredDurationSeconds !== null)
|
|
23
|
+
return null;
|
|
24
|
+
return {
|
|
25
|
+
segmentCount: record.segmentCount,
|
|
26
|
+
totalWords: record.totalWords,
|
|
27
|
+
hookWords: record.hookWords,
|
|
28
|
+
bodyWords: record.bodyWords,
|
|
29
|
+
ctaWords: record.ctaWords,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function handleValidateScript(client, args) {
|
|
33
|
+
// Mechanical pre-check first: a rejected script never reaches the web
|
|
34
|
+
// route and never debits tokens.
|
|
35
|
+
const result = validateSegments(args.segments);
|
|
36
|
+
if (!result.ok) {
|
|
37
|
+
return errorResponse(`Script validation failed: ${result.error.field}: ${result.error.rule} Fix: ${result.error.fix}`);
|
|
38
|
+
}
|
|
39
|
+
let payload;
|
|
40
|
+
try {
|
|
41
|
+
payload = narrowValidateScriptPayload(await client.validateScript(args.segments));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return errorResponse(`Error validating the script: ${sanitizeEngineError(getErrorMessage(error))}`);
|
|
45
|
+
}
|
|
46
|
+
if (typeof payload === 'string') {
|
|
47
|
+
return errorResponse(`Script validation failed: ${payload}`);
|
|
48
|
+
}
|
|
49
|
+
if (payload === null) {
|
|
50
|
+
return errorResponse('Script validation failed: the web validation endpoint returned an unexpected response.');
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
text: [
|
|
57
|
+
`Script valid: ${payload.segmentCount} segment(s), ${payload.totalWords} words total, hook ${payload.hookWords} words, body ${payload.bodyWords} words, CTA ${payload.ctaWords} words.`,
|
|
58
|
+
`Hook window: ${HOOK_MIN_SECONDS}-${HOOK_MAX_SECONDS} seconds spoken (target 20-30 words).`,
|
|
59
|
+
'Measured duration: pending — no hook-only TTS endpoint exists yet, so the measured hook duration cannot be checked in this phase; the hook word guard (15-40 words) already ran above.',
|
|
60
|
+
].join('\n'),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function handleGeneratePersonaVideo(client, args) {
|
|
66
|
+
try {
|
|
67
|
+
const mode = args.mode ?? 'scheduled';
|
|
68
|
+
if (mode === 'asap' && (args.startAt !== undefined || args.times !== undefined)) {
|
|
69
|
+
throw new Error("startAt and times must not be set when mode is 'asap'.");
|
|
70
|
+
}
|
|
71
|
+
if (mode === 'scheduled' && (args.startAt === undefined || args.times === undefined)) {
|
|
72
|
+
throw new Error("startAt and times are required when mode is 'scheduled'.");
|
|
73
|
+
}
|
|
74
|
+
// Mechanical validation before the client call: a rejected script
|
|
75
|
+
// never debits tokens and never reaches Modal.
|
|
76
|
+
const result = validateSegments(args.segments);
|
|
77
|
+
if (!result.ok) {
|
|
78
|
+
throw new Error(`${result.error.field}: ${result.error.rule} Fix: ${result.error.fix}`);
|
|
79
|
+
}
|
|
80
|
+
const script = joinSegments(args.segments);
|
|
81
|
+
// The shape advertises a top-level language, but the web route only
|
|
82
|
+
// reads options.language: forward it there unless options already
|
|
83
|
+
// sets one, or the top-level value is silently dropped.
|
|
84
|
+
const language = args.options?.language ?? args.language;
|
|
85
|
+
const narrowed = narrowScheduledVideos(await client.generatePersonaVideo({
|
|
86
|
+
personaId: args.personaId,
|
|
87
|
+
title: args.title,
|
|
88
|
+
providers: args.providers,
|
|
89
|
+
youtubeAccountIds: args.youtubeAccountIds,
|
|
90
|
+
instagramAccountIds: args.instagramAccountIds,
|
|
91
|
+
linkedinAccountIds: args.linkedinAccountIds,
|
|
92
|
+
blueskyAccountIds: args.blueskyAccountIds,
|
|
93
|
+
mode,
|
|
94
|
+
startAt: args.startAt,
|
|
95
|
+
times: args.times,
|
|
96
|
+
timezone: args.timezone,
|
|
97
|
+
options: {
|
|
98
|
+
...args.options,
|
|
99
|
+
segments: args.segments,
|
|
100
|
+
...(language === undefined ? {} : { language }),
|
|
101
|
+
},
|
|
102
|
+
idempotencyKey: args.idempotencyKey,
|
|
103
|
+
}));
|
|
104
|
+
const scheduleId = narrowed.schedule.id ?? '(unknown id)';
|
|
105
|
+
const humanSummary = mode === 'asap'
|
|
106
|
+
? `Generating 1 video in schedule ${scheduleId}: it publishes as soon as its generation finishes (ASAP mode).`
|
|
107
|
+
: `Scheduled 1 video in schedule ${scheduleId}: it is generated and auto-published at its slot.`;
|
|
108
|
+
const slotLines = narrowed.slots.map((slot, i) => `${i + 1}. ${slot.title ?? '(untitled)'} → ${slot.slotAt ?? '(unscheduled)'} [${slot.status ?? 'unknown'}${slot.taskId ? `, task ${slot.taskId}` : ''}]`);
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: 'text',
|
|
113
|
+
text: `${humanSummary}\nScript (${countWords(script)} words):\n${script}\n${slotLines.join('\n')}\n${JSON.stringify(narrowed, null, 2)}`,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return errorResponse(`Error generating the video: ${sanitizeEngineError(getErrorMessage(error))}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function narrowScheduledVideos(result) {
|
|
123
|
+
const record = typeof result === 'object' && result !== null ? result : {};
|
|
124
|
+
const schedule = typeof record.schedule === 'object' && record.schedule !== null ? record.schedule : {};
|
|
125
|
+
const rawSlots = Array.isArray(record.slots) ? record.slots : [];
|
|
126
|
+
const str = (value) => (typeof value === 'string' ? value : null);
|
|
127
|
+
return {
|
|
128
|
+
schedule: { id: str(schedule.id), mode: str(schedule.mode) },
|
|
129
|
+
slots: rawSlots.map((slot) => {
|
|
130
|
+
const s = typeof slot === 'object' && slot !== null ? slot : {};
|
|
131
|
+
return { slotId: str(s.slotId), slotAt: str(s.slotAt), title: str(s.title), taskId: str(s.taskId), status: str(s.status) };
|
|
132
|
+
}),
|
|
133
|
+
replayed: typeof record.replayed === 'boolean' ? record.replayed : null,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// NOTE: validate_script IS registered in index.ts (direct server.tool
|
|
137
|
+
// call, which the parity graph discovers) and maps to POST
|
|
138
|
+
// /api/videos/validate-script, which it really calls through the client
|
|
139
|
+
// after the local mechanical pre-check. generate_persona_video IS
|
|
140
|
+
// registered the same way and maps to POST
|
|
141
|
+
// /api/videos/generate-and-schedule.
|
|
142
|
+
export 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.';
|
|
143
|
+
//# sourceMappingURL=tools-single-video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-single-video.js","sourceRoot":"","sources":["../src/tools-single-video.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAKzF,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACvE,CAAC;AAUD,SAAS,2BAA2B,CAAC,MAAe;IAClD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAiC,CAAC;IACjD,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YAChE,CAAC,CAAC,MAAM,CAAC,KAAK;Y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0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PostEngineerClient } from './client.js';
|
|
3
|
+
import { type McpToolResponse } from './tools-call.js';
|
|
4
|
+
export declare const UploadMediaShape: {
|
|
5
|
+
path: z.ZodString;
|
|
6
|
+
};
|
|
7
|
+
export declare const UploadMediaSchema: z.ZodObject<{
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
path: string;
|
|
11
|
+
}, {
|
|
12
|
+
path: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const CheckMediaShape: {
|
|
15
|
+
url: z.ZodString;
|
|
16
|
+
};
|
|
17
|
+
export declare const CheckMediaSchema: z.ZodObject<{
|
|
18
|
+
url: z.ZodString;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
url: string;
|
|
21
|
+
}, {
|
|
22
|
+
url: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const UploadMediaDescription = "Upload a local image for a video segment and get a mediaId to use in a segment's media field (generate_persona_video). The file is stored as a temporary engine asset (1 hour TTL, same flow as debug uploads): upload shortly before generating, since a scheduled slot far in the future may outlive the asset and the segment then renders without it. JPG/JPEG, PNG, or WebP only, max 8MB (the engine photo limit). The real content type is validated, not the extension. Returns only the mediaId \u2014 never a local path or asset URL.";
|
|
25
|
+
export declare const CheckMediaDescription = "Mechanically check one public image URL for a segment, without an LLM and without judging relevance (the agent, who sees the image, decides relevance). Returns exactly one code: ok, blocked_403 (the host blocked the SSRF-safe download \u2014 retry with upload_media bytes fetched on your own machine), not_image, too_small, too_large, timeout, or face_detected. No fake User-Agent or Referer is sent to bypass hotlink blocks, and private addresses are never fetched. The URL never appears in the output.";
|
|
26
|
+
export declare function handleUploadMedia(client: PostEngineerClient, args: z.infer<typeof UploadMediaSchema>): Promise<McpToolResponse>;
|
|
27
|
+
export declare function handleCheckMedia(client: PostEngineerClient, args: z.infer<typeof CheckMediaSchema>): Promise<McpToolResponse>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { checkSegmentMedia, uploadSegmentMedia } from './client-user-media.js';
|
|
3
|
+
import { MAX_SEGMENT_MEDIA_MB } from './limits.js';
|
|
4
|
+
import { handleLibraryCall } from './tools-call.js';
|
|
5
|
+
//---------------
|
|
6
|
+
// Phase 2 user-media tools: upload_media (local file -> mediaId) and
|
|
7
|
+
// check_media (mechanical URL check, one code, no LLM). Kept in a new
|
|
8
|
+
// module so tools.ts stays under the file-size ratchet.
|
|
9
|
+
//---------------
|
|
10
|
+
export const UploadMediaShape = {
|
|
11
|
+
path: z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1, 'path is required')
|
|
14
|
+
.describe('Local image file path (JPG/JPEG, PNG, or WebP, max 8MB — the engine photo limit, not the 10MB library limit).'),
|
|
15
|
+
};
|
|
16
|
+
export const UploadMediaSchema = z.object(UploadMediaShape);
|
|
17
|
+
export const CheckMediaShape = {
|
|
18
|
+
url: z
|
|
19
|
+
.string()
|
|
20
|
+
.min(1, 'url is required')
|
|
21
|
+
.describe('Public image URL to check mechanically (no LLM, no relevance judgement).'),
|
|
22
|
+
};
|
|
23
|
+
export const CheckMediaSchema = z.object(CheckMediaShape);
|
|
24
|
+
export const UploadMediaDescription = `Upload a local image for a video segment and get a mediaId to use in a segment's media field (generate_persona_video). The file is stored as a temporary engine asset (1 hour TTL, same flow as debug uploads): upload shortly before generating, since a scheduled slot far in the future may outlive the asset and the segment then renders without it. JPG/JPEG, PNG, or WebP only, max ${MAX_SEGMENT_MEDIA_MB}MB (the engine photo limit). The real content type is validated, not the extension. Returns only the mediaId — never a local path or asset URL.`;
|
|
25
|
+
export const CheckMediaDescription = 'Mechanically check one public image URL for a segment, without an LLM and without judging relevance (the agent, who sees the image, decides relevance). Returns exactly one code: ok, blocked_403 (the host blocked the SSRF-safe download — retry with upload_media bytes fetched on your own machine), not_image, too_small, too_large, timeout, or face_detected. No fake User-Agent or Referer is sent to bypass hotlink blocks, and private addresses are never fetched. The URL never appears in the output.';
|
|
26
|
+
export async function handleUploadMedia(client, args) {
|
|
27
|
+
return handleLibraryCall(async () => {
|
|
28
|
+
const parsed = UploadMediaSchema.parse(args);
|
|
29
|
+
return uploadSegmentMedia(client, parsed.path);
|
|
30
|
+
}, 'uploading segment media', 'Segment media uploaded successfully');
|
|
31
|
+
}
|
|
32
|
+
export async function handleCheckMedia(client, args) {
|
|
33
|
+
return handleLibraryCall(async () => {
|
|
34
|
+
const parsed = CheckMediaSchema.parse(args);
|
|
35
|
+
return checkSegmentMedia(client, parsed.url);
|
|
36
|
+
}, 'checking segment media', 'Segment media check complete');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=tools-user-media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-user-media.js","sourceRoot":"","sources":["../src/tools-user-media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,iBAAiB,CAAC;AAE1E,iBAAiB;AACjB,qEAAqE;AACrE,sEAAsE;AACtE,wDAAwD;AACxD,iBAAiB;AAEjB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC;SAC1B,QAAQ,CAAC,+GAA+G,CAAC;CAC7H,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,CAAC;SACH,MAAM,EAAE;SACR,GAAG,CAAC,CAAC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