post-engineer-mcp 1.52.584 → 1.52.586
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 +87 -98
- package/dist/account-shapes.js +2 -2
- package/dist/account-shapes.js.map +1 -1
- package/dist/action-tool.d.ts +32 -0
- package/dist/action-tool.js +90 -0
- package/dist/action-tool.js.map +1 -0
- package/dist/analytics.d.ts +2 -0
- package/dist/analytics.js +10 -0
- package/dist/analytics.js.map +1 -1
- package/dist/client-types.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/cloned-voice-tools.d.ts +1 -3
- package/dist/cloned-voice-tools.js +4 -33
- package/dist/cloned-voice-tools.js.map +1 -1
- package/dist/connect-account.js +3 -3
- package/dist/connect-account.js.map +1 -1
- package/dist/direct-publish-form.js +1 -1
- package/dist/direct-publish-form.js.map +1 -1
- package/dist/generate-video.d.ts +254 -0
- package/dist/generate-video.js +195 -0
- package/dist/generate-video.js.map +1 -0
- package/dist/http-transport.js +3 -4
- package/dist/http-transport.js.map +1 -1
- package/dist/index.js +27 -151
- package/dist/index.js.map +1 -1
- package/dist/intent-accounts.d.ts +5 -0
- package/dist/intent-accounts.js +66 -0
- package/dist/intent-accounts.js.map +1 -0
- package/dist/intent-content.d.ts +4 -0
- package/dist/intent-content.js +54 -0
- package/dist/intent-content.js.map +1 -0
- package/dist/intent-library.d.ts +4 -0
- package/dist/intent-library.js +41 -0
- package/dist/intent-library.js.map +1 -0
- package/dist/intent-personas.d.ts +6 -0
- package/dist/intent-personas.js +79 -0
- package/dist/intent-personas.js.map +1 -0
- package/dist/intent-video.d.ts +5 -0
- package/dist/intent-video.js +28 -0
- package/dist/intent-video.js.map +1 -0
- package/dist/{publish-uploaded-tools.d.ts → intent-voices.d.ts} +1 -1
- package/dist/intent-voices.js +33 -0
- package/dist/intent-voices.js.map +1 -0
- package/dist/limits.d.ts +2 -2
- package/dist/limits.js +2 -2
- package/dist/persona-avatar.d.ts +2 -2
- package/dist/persona-avatar.js +5 -5
- package/dist/persona-avatar.js.map +1 -1
- package/dist/persona-delete.d.ts +6 -0
- package/dist/persona-delete.js +41 -0
- package/dist/persona-delete.js.map +1 -0
- package/dist/persona-update.js +3 -3
- package/dist/persona-update.js.map +1 -1
- package/dist/publish-direct-shape.js +3 -3
- package/dist/publish-direct-shape.js.map +1 -1
- package/dist/publish-notices.js +1 -1
- package/dist/publish-notices.js.map +1 -1
- package/dist/publish-uploaded-shape.js +6 -6
- package/dist/publish-uploaded-shape.js.map +1 -1
- package/dist/recipe-session.d.ts +7 -10
- package/dist/recipe-session.js +17 -25
- package/dist/recipe-session.js.map +1 -1
- package/dist/refs.d.ts +54 -0
- package/dist/refs.js +158 -0
- package/dist/refs.js.map +1 -0
- package/dist/remote-shapes.d.ts +2 -2
- package/dist/remote-shapes.js +6 -6
- package/dist/remote-shapes.js.map +1 -1
- package/dist/require-publishing-accounts.js +1 -1
- package/dist/require-publishing-accounts.js.map +1 -1
- package/dist/schedule-shapes.js +7 -7
- package/dist/schedule-shapes.js.map +1 -1
- package/dist/script-segments.js +1 -1
- package/dist/script-segments.js.map +1 -1
- package/dist/single-video-shape.d.ts +5 -5
- package/dist/single-video-shape.js +20 -20
- package/dist/single-video-shape.js.map +1 -1
- package/dist/tool-annotations.js.map +1 -1
- package/dist/tools-batch.d.ts +63 -64
- package/dist/tools-batch.js +7 -8
- package/dist/tools-batch.js.map +1 -1
- package/dist/tools-experiments.d.ts +48 -66
- package/dist/tools-experiments.js +26 -13
- package/dist/tools-experiments.js.map +1 -1
- package/dist/tools-pinterest.d.ts +0 -1
- package/dist/tools-pinterest.js +5 -6
- package/dist/tools-pinterest.js.map +1 -1
- package/dist/tools-posts.js +7 -7
- package/dist/tools-posts.js.map +1 -1
- package/dist/tools-prompts.d.ts +2 -2
- package/dist/tools-prompts.js +31 -31
- package/dist/tools-prompts.js.map +1 -1
- package/dist/tools-publish-uploaded.d.ts +0 -3
- package/dist/tools-publish-uploaded.js +7 -10
- package/dist/tools-publish-uploaded.js.map +1 -1
- package/dist/tools-publishing-accounts.js +3 -3
- package/dist/tools-publishing-accounts.js.map +1 -1
- package/dist/tools-single-video.d.ts +0 -2
- package/dist/tools-single-video.js +11 -15
- package/dist/tools-single-video.js.map +1 -1
- package/dist/tools-user-media.d.ts +0 -2
- package/dist/tools-user-media.js +2 -5
- package/dist/tools-user-media.js.map +1 -1
- package/dist/tools.d.ts +25 -28
- package/dist/tools.js +10 -85
- package/dist/tools.js.map +1 -1
- package/dist/video-task-tools.d.ts +2 -2
- package/dist/video-task-tools.js +14 -12
- package/dist/video-task-tools.js.map +1 -1
- package/dist/voice-filters.d.ts +1 -1
- package/dist/voice-filters.js +4 -4
- package/dist/voice-filters.js.map +1 -1
- package/package.json +1 -1
- package/dist/local-file-tools.d.ts +0 -3
- package/dist/local-file-tools.js +0 -15
- package/dist/local-file-tools.js.map +0 -1
- package/dist/publish-uploaded-tools.js +0 -10
- package/dist/publish-uploaded-tools.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persona-update.js","sourceRoot":"","sources":["../src/persona-update.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"persona-update.js","sourceRoot":"","sources":["../src/persona-update.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAwB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,oBAA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AC;SACX,IAAI,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACzB,QAAQ,EAAE;SACV,QAAQ,CAAC,oNAAoN,CAAC;CAClO,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;AAExG,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAA0B,EAC1B,IAAyC;IAEzC,mGAAmG;IACnG,OAAO,iBAAiB,CACtB,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,iCAAiC,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAClH,kBAAkB,EAAE,8BAA8B,CACnD,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Shape for
|
|
1
|
+
// Shape for publish_video (action: from_file) (publish a user-provided video without
|
|
2
2
|
// generation or schedule). Kept in a new module so tools.ts stays under the
|
|
3
3
|
// file-size ratchet; tools.ts re-exports it so existing import sites
|
|
4
4
|
// (`./tools.js`) keep working.
|
|
@@ -15,7 +15,7 @@ export const PublishVideoDirectShape = {
|
|
|
15
15
|
accountIds: z
|
|
16
16
|
.array(z.string().min(1))
|
|
17
17
|
.min(1, 'At least one account ID is required')
|
|
18
|
-
.describe('Target accounts: the IDs from
|
|
18
|
+
.describe('Target accounts: the IDs from accounts (action: list) (channel IDs for YouTube, IG user IDs for Instagram, DIDs for Bluesky, member IDs or org URNs for LinkedIn, user IDs for Threads, Page IDs for Facebook, user IDs for Pinterest, Fanvue account IDs, Hive usernames for 3Speak, Channel IDs for Rumble).'),
|
|
19
19
|
title: z
|
|
20
20
|
.string()
|
|
21
21
|
.optional()
|
|
@@ -39,7 +39,7 @@ export const PublishVideoDirectShape = {
|
|
|
39
39
|
boardId: z
|
|
40
40
|
.string()
|
|
41
41
|
.optional()
|
|
42
|
-
.describe('Pinterest only: the board to publish the pin to (the id from
|
|
42
|
+
.describe('Pinterest only: the board to publish the pin to (the id from accounts (action: list_boards)). Required for pinterest.'),
|
|
43
43
|
idempotencyKey: z
|
|
44
44
|
.string()
|
|
45
45
|
.min(1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-direct-shape.js","sourceRoot":"","sources":["../src/publish-direct-shape.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"publish-direct-shape.js","sourceRoot":"","sources":["../src/publish-direct-shape.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,4EAA4E;AAC5E,qEAAqE;AACrE,+BAA+B;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,CAAC;SACR,IAAI,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;SACvH,QAAQ,CAAC,8CAA8C,CAAC;IAC3D,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,QAAQ,CACP,mDAAmD,mBAAmB,gEAAgE,CACvI;IACH,UAAU,EAAE,CAAC;SACV,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACxB,GAAG,CAAC,CAAC,EAAE,qCAAqC,CAAC;SAC7C,QAAQ,CACP,gTAAgT,CACjT;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,+EAA+E,CAAC;IAC5F,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,yHAAyH,CAAC;IACtI,IAAI,EAAE,CAAC;SACJ,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CAAC,sCAAsC,CAAC;IACnD,aAAa,EAAE,CAAC;SACb,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;SACvC,QAAQ,EAAE;SACV,QAAQ,CAAC,wCAAwC,CAAC;IACrD,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,2IAA2I,CAAC;IACxJ,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,uHAAuH,CAAC;IACpI,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SACV,QAAQ,CACP,iNAAiN,CAClN;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC"}
|
package/dist/publish-notices.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// User-account notices on
|
|
1
|
+
// User-account notices on posts (action: list) / schedules (action: get_slot) (issue #500). The sentences
|
|
2
2
|
// are already safe to show. The agent must relay them and must not retry.
|
|
3
3
|
export function readNoticeList(value) {
|
|
4
4
|
return Array.isArray(value) ? value : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-notices.js","sourceRoot":"","sources":["../src/publish-notices.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"publish-notices.js","sourceRoot":"","sources":["../src/publish-notices.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,0EAA0E;AAE1E,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,WAAsB;IAClD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;YAAE,SAAS;QACxD,MAAM,MAAM,GAAI,IAA6B,CAAC,MAAM,CAAC;QACrD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oDAAoD,CAAC;AACjF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Shapes for the signed-upload publish flow (issue #561): the remote
|
|
2
|
-
// (HTTP) replacement for
|
|
2
|
+
// (HTTP) replacement for publish_video (action: from_file). JSON only — no field
|
|
3
3
|
// names a file on disk. The caller first mints a signed upload with
|
|
4
|
-
//
|
|
5
|
-
// completes it with
|
|
6
|
-
// with
|
|
4
|
+
// publish_video (action: create_upload), PUTs the video bytes to the returned signedUrl,
|
|
5
|
+
// completes it with publish_video (action: complete_upload), and finally publishes by id
|
|
6
|
+
// with publish_video (action: publish_upload). Kept in a new module so tools.ts stays
|
|
7
7
|
// under the file-size ratchet.
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { MAX_UPLOAD_VIDEO_BYTES, MAX_UPLOAD_VIDEO_GB } from './limits.js';
|
|
@@ -24,7 +24,7 @@ export const CompleteVideoUploadShape = {
|
|
|
24
24
|
uploadId: z
|
|
25
25
|
.string()
|
|
26
26
|
.min(1, 'uploadId is required')
|
|
27
|
-
.describe('The uploadId returned by
|
|
27
|
+
.describe('The uploadId returned by publish_video (action: create_upload), after the bytes were PUT to its signedUrl.'),
|
|
28
28
|
};
|
|
29
29
|
export const CompleteVideoUploadSchema = z.object(CompleteVideoUploadShape).strict();
|
|
30
30
|
export const PublishUploadedVideoShape = {
|
|
@@ -32,7 +32,7 @@ export const PublishUploadedVideoShape = {
|
|
|
32
32
|
uploadId: z
|
|
33
33
|
.string()
|
|
34
34
|
.min(1, 'uploadId is required')
|
|
35
|
-
.describe('The uploadId of a completed signed upload (
|
|
35
|
+
.describe('The uploadId of a completed signed upload (publish_video (action: create_upload) + publish_video (action: complete_upload)). Single-use: one publish consumes it.'),
|
|
36
36
|
accountIds: PublishVideoDirectShape.accountIds,
|
|
37
37
|
title: PublishVideoDirectShape.title,
|
|
38
38
|
description: PublishVideoDirectShape.description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-uploaded-shape.js","sourceRoot":"","sources":["../src/publish-uploaded-shape.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"publish-uploaded-shape.js","sourceRoot":"","sources":["../src/publish-uploaded-shape.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,iFAAiF;AACjF,oEAAoE;AACpE,yFAAyF;AACzF,yFAAyF;AACzF,sFAAsF;AACtF,+BAA+B;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW,EAAE,CAAC;SACX,IAAI,CAAC,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;SACtC,QAAQ,CAAC,wHAAwH,CAAC;IACrI,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,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type McpTransportKind = 'stdio' | 'http';
|
|
4
|
-
export declare const RECIPE_NUDGE_SURFACES: readonly ["
|
|
4
|
+
export declare const RECIPE_NUDGE_SURFACES: readonly ["personas_create", "personas_list", "accounts_list", "billing_balance", "check_script_validate", "generate_video"];
|
|
5
5
|
export type RecipeNudgeSurface = (typeof RECIPE_NUDGE_SURFACES)[number];
|
|
6
|
-
export type ScriptTool = '
|
|
6
|
+
export type ScriptTool = 'check_script_validate' | 'generate_video';
|
|
7
7
|
export declare const MCP_SESSION_ID_HEADER = "X-MCP-Session-Id";
|
|
8
8
|
export declare const MCP_TRANSPORT_HEADER = "X-MCP-Transport";
|
|
9
9
|
export declare const MCP_NUDGED_BY_HEADER = "X-MCP-Nudged-By";
|
|
@@ -12,8 +12,8 @@ export declare const MCP_RECIPE_FETCHED_HEADER = "X-MCP-Recipe-Fetched";
|
|
|
12
12
|
export declare const MCP_SCRIPT_REJECTIONS_HEADER = "X-MCP-Script-Rejections";
|
|
13
13
|
export declare const MCP_RECIPE_HEADER = "X-MCP-Recipe";
|
|
14
14
|
export declare const RECIPE_SLUG_PATTERN: RegExp;
|
|
15
|
-
export declare const RECIPE_NUDGE_TEXT = "Next step for a video about a topic (news, a place, a product, GitHub PRs): call
|
|
16
|
-
export declare const SCRIPT_REJECTED_RECIPE_HINT = "Recipes produce scripts that pass these limits: call
|
|
15
|
+
export declare const RECIPE_NUDGE_TEXT = "Next step for a video about a topic (news, a place, a product, GitHub PRs): call prompts (action: list) and follow the matching recipe with prompts (action: get) instead of improvising the script \u2014 recipes pre-validate the script, media, and price facts before any token is spent.";
|
|
16
|
+
export declare const SCRIPT_REJECTED_RECIPE_HINT = "Recipes produce scripts that pass these limits: call prompts (action: list) and follow the matching recipe with prompts (action: get).";
|
|
17
17
|
export declare function recipeRunText(slug: string, prompt: string): string;
|
|
18
18
|
export declare function isRecipeSlug(value: unknown): value is string;
|
|
19
19
|
export declare class RecipeSession {
|
|
@@ -37,11 +37,8 @@ export declare class RecipeSession {
|
|
|
37
37
|
run<TResult>(recipe: unknown, call: () => Promise<TResult>): Promise<TResult>;
|
|
38
38
|
}
|
|
39
39
|
export declare function withRecipeNudge<TArgs>(session: RecipeSession, surface: RecipeNudgeSurface, handler: (args: TArgs) => Promise<McpToolResponse>): (args: TArgs) => Promise<McpToolResponse>;
|
|
40
|
-
export
|
|
40
|
+
export interface ScriptView {
|
|
41
41
|
segments: unknown;
|
|
42
|
-
recipe?: string;
|
|
43
42
|
videoType?: VideoType;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
}>(session: RecipeSession, toolName: ScriptTool, handler: (args: TArgs) => Promise<McpToolResponse>): (args: TArgs) => Promise<McpToolResponse>;
|
|
43
|
+
}
|
|
44
|
+
export declare function withScriptOutcome<TArgs extends object>(session: RecipeSession, toolName: ScriptTool, handler: (args: TArgs) => Promise<McpToolResponse>, scriptsOf: (args: TArgs) => ScriptView[]): (args: TArgs) => Promise<McpToolResponse>;
|
package/dist/recipe-session.js
CHANGED
|
@@ -2,12 +2,12 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { withTelemetryHeaders } from './analytics.js';
|
|
3
3
|
import { validateSegments } from './script-segments.js';
|
|
4
4
|
export const RECIPE_NUDGE_SURFACES = [
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
5
|
+
'personas_create',
|
|
6
|
+
'personas_list',
|
|
7
|
+
'accounts_list',
|
|
8
|
+
'billing_balance',
|
|
9
|
+
'check_script_validate',
|
|
10
|
+
'generate_video',
|
|
11
11
|
];
|
|
12
12
|
export const MCP_SESSION_ID_HEADER = 'X-MCP-Session-Id';
|
|
13
13
|
export const MCP_TRANSPORT_HEADER = 'X-MCP-Transport';
|
|
@@ -20,15 +20,15 @@ export const MCP_RECIPE_HEADER = 'X-MCP-Recipe';
|
|
|
20
20
|
export const RECIPE_SLUG_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
21
21
|
// Header values stay bounded: the counter saturates instead of growing.
|
|
22
22
|
const MAX_SCRIPT_REJECTIONS = 999;
|
|
23
|
-
export const RECIPE_NUDGE_TEXT = 'Next step for a video about a topic (news, a place, a product, GitHub PRs): call
|
|
24
|
-
export const SCRIPT_REJECTED_RECIPE_HINT = 'Recipes produce scripts that pass these limits: call
|
|
23
|
+
export const RECIPE_NUDGE_TEXT = 'Next step for a video about a topic (news, a place, a product, GitHub PRs): call prompts (action: list) and follow the matching recipe with prompts (action: get) instead of improvising the script — recipes pre-validate the script, media, and price facts before any token is spent.';
|
|
24
|
+
export const SCRIPT_REJECTED_RECIPE_HINT = 'Recipes produce scripts that pass these limits: call prompts (action: list) and follow the matching recipe with prompts (action: get).';
|
|
25
25
|
//---------------
|
|
26
26
|
// The text an agent runs for a recipe: the hub text plus a footer asking
|
|
27
|
-
// it to declare the recipe on
|
|
28
|
-
// carries X-MCP-Recipe. Shared by
|
|
27
|
+
// it to declare the recipe on generate_video, so its request
|
|
28
|
+
// carries X-MCP-Recipe. Shared by prompts (action: get) and the slash commands.
|
|
29
29
|
//---------------
|
|
30
30
|
export function recipeRunText(slug, prompt) {
|
|
31
|
-
return `${prompt}\n\nWhen you call
|
|
31
|
+
return `${prompt}\n\nWhen you call generate_video for this recipe, pass recipe: "${slug}".`;
|
|
32
32
|
}
|
|
33
33
|
export function isRecipeSlug(value) {
|
|
34
34
|
return typeof value === 'string' && RECIPE_SLUG_PATTERN.test(value);
|
|
@@ -99,24 +99,16 @@ export function withRecipeNudge(session, surface, handler) {
|
|
|
99
99
|
return withExtraText(response, RECIPE_NUDGE_TEXT);
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
// Wrap a script tool (validate_script, generate_persona_video): its
|
|
104
|
-
// requests carry the session headers plus the declared recipe; a script
|
|
105
|
-
// the mechanical validator rejects (no API request is sent then) bumps the
|
|
106
|
-
// session's rejection counter, which the next request reports, and gets
|
|
107
|
-
// the recipe hint unless a recipe is already in play. The classification
|
|
108
|
-
// re-runs the same pure validator the handler runs, so it never parses
|
|
109
|
-
// the handler's error text.
|
|
110
|
-
//---------------
|
|
111
|
-
export function withScriptOutcome(session, toolName, handler) {
|
|
102
|
+
export function withScriptOutcome(session, toolName, handler, scriptsOf) {
|
|
112
103
|
return async (args) => {
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
104
|
+
const recipe = 'recipe' in args ? args.recipe : undefined;
|
|
105
|
+
const response = await session.run(recipe, () => handler(args));
|
|
106
|
+
const rejected = scriptsOf(args).some((script) => !validateSegments(script.segments, script.videoType ?? 'hook_lipsync').ok);
|
|
107
|
+
if (response.isError !== true || !rejected) {
|
|
116
108
|
return response;
|
|
117
109
|
}
|
|
118
110
|
session.recordScriptRejected();
|
|
119
|
-
if (
|
|
111
|
+
if (recipe !== undefined || session.knowsRecipes()) {
|
|
120
112
|
return response;
|
|
121
113
|
}
|
|
122
114
|
session.recordNudgeShown(toolName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipe-session.js","sourceRoot":"","sources":["../src/recipe-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA6BxD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,
|
|
1
|
+
{"version":3,"file":"recipe-session.js","sourceRoot":"","sources":["../src/recipe-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA6BxD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,eAAe;IACf,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,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;QAC7H,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3C,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,oBAAoB,EAAE,CAAC;QAC/B,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;YACnD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,aAAa,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/refs.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PostEngineerClient } from './client.js';
|
|
3
|
+
import type { McpToolResponse } from './tools-call.js';
|
|
4
|
+
export type RefOutcome<T> = {
|
|
5
|
+
kind: 'ok';
|
|
6
|
+
value: T;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'response';
|
|
9
|
+
response: McpToolResponse;
|
|
10
|
+
};
|
|
11
|
+
export interface ResolvedPersona {
|
|
12
|
+
id: string;
|
|
13
|
+
/** The display name when it was resolved by name; null when the id was taken as given. */
|
|
14
|
+
name: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface ResolvedAccount {
|
|
17
|
+
provider: string;
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
export interface RefResolvers {
|
|
22
|
+
persona: (ref: string) => Promise<RefOutcome<ResolvedPersona>>;
|
|
23
|
+
account: (ref: string, provider?: string) => Promise<RefOutcome<ResolvedAccount>>;
|
|
24
|
+
}
|
|
25
|
+
/** Resolvers that share one personas listing and one accounts listing (a batch resolves many refs). */
|
|
26
|
+
export declare function createRefResolvers(client: PostEngineerClient): RefResolvers;
|
|
27
|
+
export declare function resolvePersonaRef(client: PostEngineerClient, ref: string): Promise<RefOutcome<ResolvedPersona>>;
|
|
28
|
+
export declare function resolveAccountRef(client: PostEngineerClient, ref: string, provider?: string): Promise<RefOutcome<ResolvedAccount>>;
|
|
29
|
+
/** The `persona` field of every action that acts on one persona. */
|
|
30
|
+
export declare const PERSONA_REF: z.ZodString;
|
|
31
|
+
/** A shape with its `personaId` replaced by the `persona` reference (the other fields are kept as they are). */
|
|
32
|
+
export declare function personaRefShape<TShape extends Record<string, z.ZodType>>(shape: TShape): {
|
|
33
|
+
persona: typeof PERSONA_REF;
|
|
34
|
+
} & Omit<TShape, 'personaId'>;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves `args.persona` and runs `run` with the persona id as `personaId`
|
|
37
|
+
* (and the other fields untouched). An unknown or ambiguous persona ends the
|
|
38
|
+
* call with the resolver's response, before `run`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function withPersona<TArgs extends {
|
|
41
|
+
persona: string;
|
|
42
|
+
}, TResult extends McpToolResponse>(client: PostEngineerClient, args: TArgs, run: (args: Omit<TArgs, 'persona'> & {
|
|
43
|
+
personaId: string;
|
|
44
|
+
}, persona: ResolvedPersona) => Promise<TResult>): Promise<McpToolResponse>;
|
|
45
|
+
/** Like personaRefShape, for an action where the persona is optional. */
|
|
46
|
+
export declare function optionalPersonaRefShape<TShape extends Record<string, z.ZodType>>(shape: TShape): {
|
|
47
|
+
persona: z.ZodOptional<typeof PERSONA_REF>;
|
|
48
|
+
} & Omit<TShape, 'personaId'>;
|
|
49
|
+
/** Like withPersona, when the persona is optional: absent stays absent (no personaId). */
|
|
50
|
+
export declare function withOptionalPersona<TArgs extends {
|
|
51
|
+
persona?: string | undefined;
|
|
52
|
+
}>(client: PostEngineerClient, args: TArgs, run: (args: Omit<TArgs, 'persona'> & {
|
|
53
|
+
personaId?: string;
|
|
54
|
+
}) => Promise<McpToolResponse>): Promise<McpToolResponse>;
|
package/dist/refs.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getErrorMessage } from './errors.js';
|
|
3
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4
|
+
function fail(message) {
|
|
5
|
+
return { kind: 'response', response: { content: [{ type: 'text', text: message }], isError: true } };
|
|
6
|
+
}
|
|
7
|
+
function candidates(kind, ref, entries) {
|
|
8
|
+
const body = {
|
|
9
|
+
ambiguous: true,
|
|
10
|
+
actionTaken: false,
|
|
11
|
+
message: `More than one ${kind} matches "${ref}". Nothing was done. Call again with the id of the one you mean.`,
|
|
12
|
+
candidates: entries.map((entry) => ({ id: entry.id, name: entry.name, summary: entry.summary })),
|
|
13
|
+
};
|
|
14
|
+
return { kind: 'response', response: { content: [{ type: 'text', text: JSON.stringify(body, null, 2) }] } };
|
|
15
|
+
}
|
|
16
|
+
function normalize(value) {
|
|
17
|
+
return value.trim().replace(/^@/, '').toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
function record(value) {
|
|
20
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
21
|
+
}
|
|
22
|
+
function text(value) {
|
|
23
|
+
return typeof value === 'string' && value.trim() !== '' ? value : null;
|
|
24
|
+
}
|
|
25
|
+
async function resolvePersona(listPersonas, ref) {
|
|
26
|
+
const wanted = ref.trim();
|
|
27
|
+
if (wanted === '')
|
|
28
|
+
return fail('persona is empty. Pass a persona name or id; call personas (action: list) to see them.');
|
|
29
|
+
if (UUID.test(wanted))
|
|
30
|
+
return { kind: 'ok', value: { id: wanted, name: null } };
|
|
31
|
+
let listing;
|
|
32
|
+
try {
|
|
33
|
+
listing = await listPersonas();
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return fail(`Error resolving persona "${wanted}": ${getErrorMessage(error)}`);
|
|
37
|
+
}
|
|
38
|
+
const personas = record(listing)?.personas;
|
|
39
|
+
if (!Array.isArray(personas)) {
|
|
40
|
+
return fail(`Error resolving persona "${wanted}": the personas listing was malformed. Call personas (action: list) and pass the persona id.`);
|
|
41
|
+
}
|
|
42
|
+
const matches = personas.flatMap((entry) => {
|
|
43
|
+
const item = record(entry);
|
|
44
|
+
const id = text(item?.id);
|
|
45
|
+
const name = text(item?.name);
|
|
46
|
+
if (item === null || id === null || name === null || normalize(name) !== normalize(wanted))
|
|
47
|
+
return [];
|
|
48
|
+
const niche = text(item.niche);
|
|
49
|
+
return [{ id, name, summary: niche === null ? name : `${name} (${niche})` }];
|
|
50
|
+
});
|
|
51
|
+
if (matches.length === 0)
|
|
52
|
+
return fail(`No persona named "${wanted}". Call personas (action: list) to see the names and ids.`);
|
|
53
|
+
if (matches.length > 1)
|
|
54
|
+
return candidates('persona', wanted, matches);
|
|
55
|
+
return { kind: 'ok', value: { id: matches[0].id, name: matches[0].name } };
|
|
56
|
+
}
|
|
57
|
+
// The id and the names of one listed account, by provider (the fields of the
|
|
58
|
+
// web registry's toPublicAccount: apps/web/lib/providers/registry.ts).
|
|
59
|
+
function accountOf(entry) {
|
|
60
|
+
const item = record(entry);
|
|
61
|
+
const provider = text(item?.provider);
|
|
62
|
+
if (item === null || provider === null)
|
|
63
|
+
return null;
|
|
64
|
+
const id = text(provider === 'youtube' ? item.channelId : provider === 'instagram' ? item.igUserId : provider === 'bluesky' ? item.did : item.providerAccountId);
|
|
65
|
+
if (id === null)
|
|
66
|
+
return null;
|
|
67
|
+
const names = [item.channelName, item.username, item.name, item.handle, item.displayName, item.accountName].flatMap((name) => {
|
|
68
|
+
const value = text(name);
|
|
69
|
+
return value === null ? [] : [value];
|
|
70
|
+
});
|
|
71
|
+
return { provider, id, names, label: names[0] ?? id };
|
|
72
|
+
}
|
|
73
|
+
async function resolveAccount(listAccounts, ref, provider) {
|
|
74
|
+
const wanted = ref.trim();
|
|
75
|
+
if (wanted === '')
|
|
76
|
+
return fail('An account reference is empty. Pass an account name or id; call accounts (action: list) to see them.');
|
|
77
|
+
let listing;
|
|
78
|
+
try {
|
|
79
|
+
listing = await listAccounts();
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return fail(`Error resolving account "${wanted}": ${getErrorMessage(error)}`);
|
|
83
|
+
}
|
|
84
|
+
const accounts = record(listing)?.accounts;
|
|
85
|
+
if (!Array.isArray(accounts)) {
|
|
86
|
+
return fail(`Error resolving account "${wanted}": the accounts listing was malformed. Call accounts (action: list) and pass the account id.`);
|
|
87
|
+
}
|
|
88
|
+
const all = accounts.flatMap((entry) => {
|
|
89
|
+
const account = accountOf(entry);
|
|
90
|
+
return account === null || (provider !== undefined && account.provider !== provider) ? [] : [account];
|
|
91
|
+
});
|
|
92
|
+
const byId = all.filter((account) => account.id === wanted);
|
|
93
|
+
const matches = byId.length > 0 ? byId : all.filter((account) => account.names.some((name) => normalize(name) === normalize(wanted)));
|
|
94
|
+
if (matches.length === 0)
|
|
95
|
+
return fail(`No account matches "${wanted}"${provider === undefined ? '' : ` on ${provider}`}. Call accounts (action: list) to see the names and ids.`);
|
|
96
|
+
if (matches.length > 1) {
|
|
97
|
+
return candidates('account', wanted, matches.map((account) => ({ id: account.id, name: account.label, summary: `${account.label} on ${account.provider}` })));
|
|
98
|
+
}
|
|
99
|
+
return { kind: 'ok', value: { provider: matches[0].provider, id: matches[0].id, label: matches[0].label } };
|
|
100
|
+
}
|
|
101
|
+
/** Reads a listing once, whatever the number of references resolved against it. */
|
|
102
|
+
function once(read) {
|
|
103
|
+
let pending = null;
|
|
104
|
+
return () => {
|
|
105
|
+
pending ??= read();
|
|
106
|
+
return pending;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Resolvers that share one personas listing and one accounts listing (a batch resolves many refs). */
|
|
110
|
+
export function createRefResolvers(client) {
|
|
111
|
+
const personas = once(() => client.listPersonas());
|
|
112
|
+
const accounts = once(() => client.listSocialAccounts());
|
|
113
|
+
return {
|
|
114
|
+
persona: (ref) => resolvePersona(personas, ref),
|
|
115
|
+
account: (ref, provider) => resolveAccount(accounts, ref, provider),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function resolvePersonaRef(client, ref) {
|
|
119
|
+
return createRefResolvers(client).persona(ref);
|
|
120
|
+
}
|
|
121
|
+
export function resolveAccountRef(client, ref, provider) {
|
|
122
|
+
return createRefResolvers(client).account(ref, provider);
|
|
123
|
+
}
|
|
124
|
+
/** The `persona` field of every action that acts on one persona. */
|
|
125
|
+
export const PERSONA_REF = z.string().min(1, 'persona is required').describe('The persona, by name or id (personas list shows both).');
|
|
126
|
+
/** A shape with its `personaId` replaced by the `persona` reference (the other fields are kept as they are). */
|
|
127
|
+
export function personaRefShape(shape) {
|
|
128
|
+
const { personaId: _replaced, ...rest } = shape;
|
|
129
|
+
return { persona: PERSONA_REF, ...rest };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Resolves `args.persona` and runs `run` with the persona id as `personaId`
|
|
133
|
+
* (and the other fields untouched). An unknown or ambiguous persona ends the
|
|
134
|
+
* call with the resolver's response, before `run`.
|
|
135
|
+
*/
|
|
136
|
+
export async function withPersona(client, args, run) {
|
|
137
|
+
const outcome = await resolvePersonaRef(client, args.persona);
|
|
138
|
+
if (outcome.kind === 'response')
|
|
139
|
+
return outcome.response;
|
|
140
|
+
const { persona: _ref, ...rest } = args;
|
|
141
|
+
return run({ ...rest, personaId: outcome.value.id }, outcome.value);
|
|
142
|
+
}
|
|
143
|
+
/** Like personaRefShape, for an action where the persona is optional. */
|
|
144
|
+
export function optionalPersonaRefShape(shape) {
|
|
145
|
+
const { personaId: _replaced, ...rest } = shape;
|
|
146
|
+
return { persona: PERSONA_REF.optional(), ...rest };
|
|
147
|
+
}
|
|
148
|
+
/** Like withPersona, when the persona is optional: absent stays absent (no personaId). */
|
|
149
|
+
export async function withOptionalPersona(client, args, run) {
|
|
150
|
+
const { persona, ...rest } = args;
|
|
151
|
+
if (persona === undefined)
|
|
152
|
+
return run(rest);
|
|
153
|
+
const outcome = await resolvePersonaRef(client, persona);
|
|
154
|
+
if (outcome.kind === 'response')
|
|
155
|
+
return outcome.response;
|
|
156
|
+
return run({ ...rest, personaId: outcome.value.id });
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=refs.js.map
|
package/dist/refs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmC9C,MAAM,IAAI,GAAG,iEAAiE,CAAC;AAE/E,SAAS,IAAI,CAAC,OAAe;IAC3B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;AACvG,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,GAAW,EAAE,OAA6D;IAC1G,MAAM,IAAI,GAAG;QACX,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,KAAK;QAClB,OAAO,EAAE,iBAAiB,IAAI,aAAa,GAAG,kEAAkE;QAChH,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;KACjG,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,OAAO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E,OAAO,OAAO,CAAC,QAAQ,CAAC;IACzD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACxC,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,uBAAuB,CAA2C,KAAa;IAC7F,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAChD,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC;AACtD,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAA0B,EAC1B,IAAW,EACX,GAAwF;IAExF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAClC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC;IACzD,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/remote-shapes.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
/**
|
|
2
|
+
/** personas (action: create) over HTTP: avatarUrl only, no library image files. */
|
|
3
3
|
export declare const CreatePersonaRemoteShape: {
|
|
4
4
|
name: z.ZodString;
|
|
5
5
|
avatarUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -50,7 +50,7 @@ export declare const CreatePersonaRemoteSchema: z.ZodObject<{
|
|
|
50
50
|
}>>;
|
|
51
51
|
accounts: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
52
52
|
}, z.core.$strict>;
|
|
53
|
-
/**
|
|
53
|
+
/** personas (action: update) over HTTP: avatarUrl only. */
|
|
54
54
|
export declare const UpdatePersonaRemoteShape: {
|
|
55
55
|
personaId: z.ZodString;
|
|
56
56
|
name: z.ZodOptional<z.ZodString>;
|
package/dist/remote-shapes.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
// A path served over HTTP would resolve on the MCP server's filesystem,
|
|
5
5
|
// not on the agent's machine, so the remote surface cannot carry one:
|
|
6
|
-
//
|
|
7
|
-
// and
|
|
6
|
+
// personas (action: create) keeps only avatarUrl (no avatarPath, no library images),
|
|
7
|
+
// and personas (action: update) keeps only avatarUrl. The SDK parses tool args with
|
|
8
8
|
// the registered raw shape, which strips unknown keys before the handler
|
|
9
9
|
// runs — so a smuggled path is dropped (never read), not loudly rejected.
|
|
10
10
|
// The strict re-parse is defense-in-depth for direct handler callers only.
|
|
@@ -12,14 +12,14 @@ import { z } from 'zod';
|
|
|
12
12
|
import { UpdatePersonaAvatarFields, refinePersonaAvatar } from './persona-avatar.js';
|
|
13
13
|
import { UpdatePersonaShape } from './persona-update.js';
|
|
14
14
|
import { CreatePersonaShape } from './tools.js';
|
|
15
|
-
/**
|
|
15
|
+
/** personas (action: create) over HTTP: avatarUrl only, no library image files. */
|
|
16
16
|
export const CreatePersonaRemoteShape = {
|
|
17
17
|
name: CreatePersonaShape.name,
|
|
18
18
|
avatarUrl: z
|
|
19
19
|
.string()
|
|
20
20
|
.url()
|
|
21
21
|
.optional()
|
|
22
|
-
.describe('Public URL to the persona avatar image (use list_faces for stock face URLs). Required: every persona has a face; "no face" is chosen per video with
|
|
22
|
+
.describe('Public URL to the persona avatar image (use persona_media (action: list_faces) for stock face URLs). Required: every persona has a face; "no face" is chosen per video with generate_video options.videoType: \'faceless\'.'),
|
|
23
23
|
voiceId: CreatePersonaShape.voiceId,
|
|
24
24
|
language: CreatePersonaShape.language,
|
|
25
25
|
videoAspect: CreatePersonaShape.videoAspect,
|
|
@@ -31,14 +31,14 @@ export const CreatePersonaRemoteShape = {
|
|
|
31
31
|
// Issue #572: same binding rule as the local shape — a persona is born
|
|
32
32
|
// bound to at least one publishing account. Without this field the
|
|
33
33
|
// handler's re-parse against CreatePersonaSchema (which requires
|
|
34
|
-
// accounts) would reject every remote
|
|
34
|
+
// accounts) would reject every remote personas (action: create) call.
|
|
35
35
|
accounts: CreatePersonaShape.accounts,
|
|
36
36
|
};
|
|
37
37
|
export const CreatePersonaRemoteSchema = z
|
|
38
38
|
.object(CreatePersonaRemoteShape)
|
|
39
39
|
.strict()
|
|
40
40
|
.superRefine(refinePersonaAvatar(true));
|
|
41
|
-
/**
|
|
41
|
+
/** personas (action: update) over HTTP: avatarUrl only. */
|
|
42
42
|
export const UpdatePersonaRemoteShape = {
|
|
43
43
|
personaId: UpdatePersonaShape.personaId,
|
|
44
44
|
name: UpdatePersonaShape.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-shapes.js","sourceRoot":"","sources":["../src/remote-shapes.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+CAA+C;AAC/C,EAAE;AACF,wEAAwE;AACxE,sEAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"remote-shapes.js","sourceRoot":"","sources":["../src/remote-shapes.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+CAA+C;AAC/C,EAAE;AACF,wEAAwE;AACxE,sEAAsE;AACtE,qFAAqF;AACrF,oFAAoF;AACpF,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAA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C3C,YAAY,EAAE,kBAAkB,CAAC,YAAY;IAC7C,eAAe,EAAE,kBAAkB,CAAC,eAAe;IACnD,KAAK,EAAE,kBAAkB,CAAC,KAAK;IAC/B,WAAW,EAAE,kBAAkB,CAAC,WAAW;CAC5C,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC,wBAAwB,CAAC;KAChC,MAAM,EAAE;KACR,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export function requirePublishingAccounts(accounts) {
|
|
9
9
|
const total = Object.values(accounts ?? {}).reduce((sum, ids) => sum + (Array.isArray(ids) ? ids.length : 0), 0);
|
|
10
10
|
if (total === 0) {
|
|
11
|
-
throw new Error('Select at least one publishing account for this persona: pass accounts, e.g. { youtube: ["UC..."] }. Account IDs come from
|
|
11
|
+
throw new Error('Select at least one publishing account for this persona: pass accounts, e.g. { youtube: ["UC..."] }. Account IDs come from accounts (action: list).');
|
|
12
12
|
}
|
|
13
13
|
return accounts ?? {};
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-publishing-accounts.js","sourceRoot":"","sources":["../src/require-publishing-accounts.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,oEAAoE;AACpE,oEAAoE;AACpE,wEAAwE;AACxE,sEAAsE;AACtE,4DAA4D;AAC5D,iBAAiB;AACjB,MAAM,UAAU,yBAAyB,CACvC,QAA8C;IAE9C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAChD,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EACzD,CAAC,CACF,CAAC;IACF,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,
|
|
1
|
+
{"version":3,"file":"require-publishing-accounts.js","sourceRoot":"","sources":["../src/require-publishing-accounts.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,oEAAoE;AACpE,oEAAoE;AACpE,wEAAwE;AACxE,sEAAsE;AACtE,4DAA4D;AAC5D,iBAAiB;AACjB,MAAM,UAAU,yBAAyB,CACvC,QAA8C;IAE9C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAChD,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EACzD,CAAC,CACF,CAAC;IACF,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,qJAAqJ,CACtJ,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/schedule-shapes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Schedule/slot tool shapes, plus the
|
|
1
|
+
// Schedule/slot tool shapes, plus the generate_video options
|
|
2
2
|
// shape and the URL-field helpers only it uses.
|
|
3
3
|
//
|
|
4
4
|
// Extracted from tools.ts so the tools module stays under the file-size
|
|
@@ -26,21 +26,21 @@ export const CancelScheduleShape = {
|
|
|
26
26
|
scheduleId: z
|
|
27
27
|
.string()
|
|
28
28
|
.min(1, 'scheduleId is required')
|
|
29
|
-
.describe('The ID of the schedule to cancel. Unpublished slots (pending, generating, or ready) are removed
|
|
29
|
+
.describe('The ID of the schedule to cancel. Unpublished slots (pending, generating, or ready) are removed. Only slots whose generation never ran get their prepaid tokens back — a generating or ready slot keeps its charge, because the GPU cost is already spent. A post already publishing or published is not recalled.'),
|
|
30
30
|
};
|
|
31
31
|
export const CancelScheduleSchema = z.object(CancelScheduleShape);
|
|
32
32
|
export const GetSlotShape = {
|
|
33
33
|
slotId: z
|
|
34
34
|
.string()
|
|
35
35
|
.min(1, 'slotId is required')
|
|
36
|
-
.describe('The slot ID (the slotId field from
|
|
36
|
+
.describe('The slot ID (the slotId field from posts (action: list) or generate_video).'),
|
|
37
37
|
};
|
|
38
38
|
export const GetSlotSchema = z.object(GetSlotShape);
|
|
39
39
|
export const UpdateSlotTitleShape = {
|
|
40
40
|
slotId: z
|
|
41
41
|
.string()
|
|
42
42
|
.min(1, 'slotId is required')
|
|
43
|
-
.describe('The slot ID (the slotId field from
|
|
43
|
+
.describe('The slot ID (the slotId field from posts (action: list) or generate_video).'),
|
|
44
44
|
title: z
|
|
45
45
|
.string()
|
|
46
46
|
.min(1, 'title is required')
|
|
@@ -51,7 +51,7 @@ export const DeleteSlotShape = {
|
|
|
51
51
|
slotId: z
|
|
52
52
|
.string()
|
|
53
53
|
.min(1, 'slotId is required')
|
|
54
|
-
.describe('The slot ID to delete. Only pending (awaiting) or failed slots can be deleted; published or mid-flight slots are rejected. The schedule\'s last slot cannot be deleted — delete the whole schedule with
|
|
54
|
+
.describe('The slot ID to delete. Only pending (awaiting) or failed slots can be deleted; published or mid-flight slots are rejected. The schedule\'s last slot cannot be deleted — delete the whole schedule with schedules (action: cancel) instead.'),
|
|
55
55
|
};
|
|
56
56
|
export const DeleteSlotSchema = z.object(DeleteSlotShape);
|
|
57
57
|
// Loopback hosts for which a plain http: media/webhook URL is tolerated
|
|
@@ -94,8 +94,8 @@ export const GeneratePersonaVideoOptionsShape = {
|
|
|
94
94
|
.describe('The one video mode: full_lipsync = the whole video is the persona talking (requires a persona with a photo; 8 tokens at face quality ok, 15 at very_good); hook_lipsync = lip sync on the hook only, agent images after (requires a persona with a photo; 2 tokens ok, 3 very_good); faceless = agent images only, no face (persona optional — with one, its voice and niche still apply; 1 token). Required: the mode decides the render path and the price.'),
|
|
95
95
|
musicMood: musicMoodField,
|
|
96
96
|
audioUrl: httpsUrlField('audioUrl').optional().describe('Public URL of custom audio for the videos (overrides the persona voice).'),
|
|
97
|
-
imageId: z.string().min(1, 'imageId must be a non-empty string').optional().describe('Library image ID to use for every video (overrides the deterministic per-video selection; see
|
|
98
|
-
voiceId: personaVoiceField().optional().describe('Voice ID override: id or label from
|
|
97
|
+
imageId: z.string().min(1, 'imageId must be a non-empty string').optional().describe('Library image ID to use for every video (overrides the deterministic per-video selection; see persona_media (action: list_images)).'),
|
|
98
|
+
voiceId: personaVoiceField().optional().describe('Voice ID override: id or label from voices (action: list). Never type a provider prefix.'),
|
|
99
99
|
webhookUrl: httpsUrlField('webhookUrl').optional().describe('Callback URL the server POSTs to when each video reaches a terminal state (completed/failed).'),
|
|
100
100
|
videoAspect: z.enum(['9:16', '16:9', '1:1']).optional().describe('Frame shape. Overrides the persona when one is given; a post without a persona defaults to 9:16.'),
|
|
101
101
|
videoLayout: z
|