post-engineer-mcp 1.41.0 → 1.43.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 +64 -26
- package/dist/analytics.d.ts +5 -3
- package/dist/analytics.js +42 -124
- package/dist/analytics.js.map +1 -1
- 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 +5 -1
- package/dist/client-posts.js +4 -0
- package/dist/client-posts.js.map +1 -1
- package/dist/client-prompts.d.ts +16 -0
- package/dist/client-prompts.js +50 -0
- package/dist/client-prompts.js.map +1 -0
- package/dist/client-types.d.ts +14 -4
- package/dist/client.d.ts +1 -1
- package/dist/client.js +22 -94
- package/dist/client.js.map +1 -1
- package/dist/cloned-voice-client.d.ts +12 -0
- package/dist/cloned-voice-client.js +103 -20
- package/dist/cloned-voice-client.js.map +1 -1
- package/dist/cloned-voice-tools.d.ts +40 -6
- package/dist/cloned-voice-tools.js +76 -6
- package/dist/cloned-voice-tools.js.map +1 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +43 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +35 -36
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +40 -1
- package/dist/limits.js +40 -1
- package/dist/limits.js.map +1 -1
- package/dist/persona-avatar.d.ts +29 -0
- package/dist/persona-avatar.js +115 -0
- package/dist/persona-avatar.js.map +1 -0
- 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/prompts.d.ts +5 -8
- package/dist/prompts.js +45 -46
- package/dist/prompts.js.map +1 -1
- package/dist/recipe-session.d.ts +46 -0
- package/dist/recipe-session.js +126 -0
- package/dist/recipe-session.js.map +1 -0
- package/dist/schedule-shapes.d.ts +1 -1
- package/dist/schedule-shapes.js +4 -4
- 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 +75 -17
- package/dist/single-video-shape.js +25 -1
- package/dist/single-video-shape.js.map +1 -1
- 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 +19 -4
- package/dist/tools-posts.js +15 -4
- package/dist/tools-posts.js.map +1 -1
- package/dist/tools-prompts.d.ts +16 -0
- package/dist/tools-prompts.js +89 -0
- package/dist/tools-prompts.js.map +1 -0
- package/dist/tools-single-video.d.ts +5 -0
- package/dist/tools-single-video.js +21 -12
- package/dist/tools-single-video.js.map +1 -1
- package/dist/tools.d.ts +46 -52
- package/dist/tools.js +10 -32
- package/dist/tools.js.map +1 -1
- package/dist/voice-filters.d.ts +5 -6
- package/dist/voice-filters.js +12 -43
- package/dist/voice-filters.js.map +1 -1
- package/package.json +1 -2
- package/dist/prompt-base.d.ts +0 -4
- package/dist/prompt-base.js +0 -134
- package/dist/prompt-base.js.map +0 -1
package/README.md
CHANGED
|
@@ -21,20 +21,37 @@ credits is billed by Modal.
|
|
|
21
21
|
- Generate videos with those personas.
|
|
22
22
|
- Connect YouTube / Instagram / LinkedIn / Threads accounts.
|
|
23
23
|
- Schedule automated posting.
|
|
24
|
-
- Generate and manage API keys at [https://post-engineer.com/
|
|
24
|
+
- Generate and manage API keys at [https://post-engineer.com/recipes](https://post-engineer.com/recipes).
|
|
25
25
|
|
|
26
26
|
## Requirements
|
|
27
27
|
|
|
28
28
|
- Node.js 20.10+
|
|
29
|
-
- API key generated at https://post-engineer.com/
|
|
29
|
+
- API key generated at https://post-engineer.com/recipes
|
|
30
30
|
|
|
31
|
-
### Telemetry
|
|
31
|
+
### Telemetry
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
Each request to the post-engineer API includes the calling tool's name and
|
|
34
|
+
the server version, recorded against your account for product analytics.
|
|
35
|
+
No script content, media or credentials are sent. The server itself never
|
|
36
|
+
contacts any analytics service.
|
|
37
|
+
|
|
38
|
+
To measure whether agents use the recipes, the requests of the recipe-aware
|
|
39
|
+
tools (`list_prompts`, `get_prompt`, `create_persona`, `list_personas`,
|
|
40
|
+
`list_social_accounts`, `get_token_balance`, `validate_script`,
|
|
41
|
+
`generate_persona_video`) also carry:
|
|
42
|
+
|
|
43
|
+
| Header | Value |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `X-MCP-Session-Id` | Random id of this server instance (one stdio connection; one request over HTTP, which is stateless) |
|
|
46
|
+
| `X-MCP-Transport` | `stdio` or `http` |
|
|
47
|
+
| `X-MCP-Nudged-By` | The last tool whose result showed the recipe nudge, or `none` |
|
|
48
|
+
| `X-MCP-Recipes-Known` | `true` once the agent listed or fetched a recipe |
|
|
49
|
+
| `X-MCP-Recipe-Fetched` | The last recipe slug `get_prompt` returned, or `none` |
|
|
50
|
+
| `X-MCP-Script-Rejections` | Scripts the local validator rejected so far in the session |
|
|
51
|
+
| `X-MCP-Recipe` | The recipe slug of this call (`get_prompt`'s slug, `generate_persona_video`'s `recipe`) |
|
|
52
|
+
|
|
53
|
+
The web API records them as `mcp_tool_called` properties; a slug that is not
|
|
54
|
+
a hub slug is recorded as `unknown`.
|
|
38
55
|
|
|
39
56
|
## Use
|
|
40
57
|
|
|
@@ -54,7 +71,7 @@ Configure your agent (`opencode.json`, `claude_desktop_config.json`, `.mcp.json`
|
|
|
54
71
|
}
|
|
55
72
|
```
|
|
56
73
|
|
|
57
|
-
Replace `<MY_API_KEY>` with the key you generated on https://post-engineer.com/
|
|
74
|
+
Replace `<MY_API_KEY>` with the key you generated on https://post-engineer.com/recipes. No repository clone or local build is required.
|
|
58
75
|
|
|
59
76
|
> The `@latest` tag matters: `npx` caches the package on first run and reuses the cached copy on later runs without checking for updates. Without `@latest` you can stay stuck on an old version (e.g. pre-1.12.0 tools that no longer exist server-side) with no error telling you why.
|
|
60
77
|
|
|
@@ -102,19 +119,22 @@ The `Authorization: Bearer` API key header is sent to the configured base URL, s
|
|
|
102
119
|
- `list_personas`: list existing personas.
|
|
103
120
|
- `list_voices`: list available persona voices (live catalog: 65 English house voices with `gender`/`accent`/`kind`, plus your ready clones). Each voice has a `description` of how it sounds. Optional filters: `gender` (`female`|`male`), `origin` (`us`|`gb`|`character`), `search` (words matched in name/description, e.g. `"deep calm"`). The response never contains `openrouter:` or `elevenlabs:` ids — the picker is house voices + your clones only.
|
|
104
121
|
- `list_cloned_voices`: list your per-user Chatterbox voice clones (status and `voice_id` when ready).
|
|
105
|
-
- `create_cloned_voice`: register a voice clone from a short HTTPS
|
|
122
|
+
- `create_cloned_voice`: register a voice clone from a short reference recording — exactly one of `audioUrl` (HTTPS URL) or `audioPath` (local `.mp3`/`.wav`/`.m4a`/`.webm` file, max 20MB, checked before it is read; errors name only the file, never the full path) (requires `consent: true` and `denoise`: `true` cleans background noise first, `false` keeps the original).
|
|
106
123
|
- `get_cloned_voice`: get one voice clone by id — poll its `status` after `create_cloned_voice` until `ready` (then `voice_id` is set) or `failed`.
|
|
107
124
|
- `delete_cloned_voice`: delete a voice clone by id.
|
|
108
125
|
- `preview_cloned_voice`: synthesize a short MP3 preview for a ready clone (returns base64 audio). Optional `text` (1-300 chars, English) makes the clone speak your words instead of the fixed sample; previews are free and limited to 10 per user per day.
|
|
126
|
+
- `preview_house_voice`: synthesize a short MP3 preview for a house voice from `list_voices` (returns base64 audio). Optional `text` (1-300 chars, English) makes the voice speak your words instead of the fixed sample; previews are free and limited to 10 per user per day.
|
|
109
127
|
- `list_faces`: list default/stock persona faces (live catalog from `/api/persona/faces`). Each item has `id`, `url`, `name`, `gender`, `age` (single number, e.g. 23), `ethnicity`, `hair`, and `description` (English) so agents can choose without the photo; pass a face `url` as `avatarUrl` on `create_persona`.
|
|
110
|
-
- `create_persona`: create an AI persona (avatar, voice, language, niche). `avatarUrl`
|
|
111
|
-
- `update_persona`: update an existing persona (only the provided fields change).
|
|
128
|
+
- `create_persona`: create an AI persona (avatar, voice, language, niche). A face is REQUIRED, from exactly one source: `avatarUrl` (a public image URL or a `list_faces` url) or `avatarPath` (a local JPG/PNG/WebP file, max 10MB, uploaded directly as the persona photo, so the server never has to download a link). Passing both is rejected before anything is sent. "No face" is a per-video choice (`options.faceless` on `generate_persona_video`). `voiceId` takes a house name or label from `list_voices` (`phonon_zoey`, `Zoey`) or a clone id/key you copied from `list_voices`; never type a provider prefix (`elevenlabs:`/`openrouter:`) — an unknown voice is rejected before anything is sent.
|
|
129
|
+
- `update_persona`: update an existing persona (only the provided fields change). Replace the face with `avatarUrl` or `avatarPath` (local photo file, uploaded directly); at most one of the two. `faceQuality` (`ok` 480p / `very_good` 720p) can be changed without recreating the persona: future videos price at the new quality, already-scheduled posts keep the quality they were charged for.
|
|
112
130
|
- `get_token_balance`: get the prepaid token wallet balance. Check before generating videos, which cost tokens.
|
|
113
|
-
- `
|
|
131
|
+
- `list_prompts`: list the recipe prompts this server can run — one entry per recipe with `slug`, `title`, and `description` (news, place spotlight, subject spotlight, GitHub PRs, full setup), no prompt text (cheap discovery). Call this first when the request is a topic instead of a ready script; then fetch the matching recipe with `get_prompt`.
|
|
132
|
+
- `get_prompt`: get one recipe prompt by its `slug` (from `list_prompts`) as ready-to-run instructions covering the full validated flow (script limits, media checks, the generation call), ending with a line asking the agent to pass the slug as `recipe` on `generate_persona_video`. Unknown slugs return an error naming the valid slugs.
|
|
133
|
+
- `validate_script`: validate a segments script mechanically, without spending tokens — hook first, CTA last, exactly one of each, 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. Optional `facelessMaterial` (`broll`, `svg`, `images`): with `images` it also checks that every segment carries `media` (up to 12).
|
|
114
134
|
- `score_draft`: score a draft mechanically against the caller's own measured posts, without spending tokens. Returns a 0-100 score where every point is explained (hook, length, hashtags, slop markers, links, top-theme match, call to action), the baseline it was scored against (top angles by engagement), and the publish check for the requested network (linkedin, youtube, instagram, bluesky, threads): it fails only on an empty draft or the network's own ceiling where this repo has evidence for it (LinkedIn 3000 characters, Threads 500 characters, Bluesky 300 graphemes); the rest are warnings. A failing publish check means: fix the draft before scheduling it for that network. Pass kind 'script' for a video script (segments joined by newlines, hook first, CTA last): hashtags are not scored and publishCheck is null.
|
|
115
135
|
- `upload_media`: upload a local image for a video segment and get a `mediaId` to use in a segment's `media` field. JPG/JPEG, PNG, or WebP, max 8MB (the engine photo limit, not the 10MB library limit); the real content type is validated, not the extension. The file is stored as a temporary engine asset (1 hour TTL): upload shortly before generating, since a scheduled slot far in the future may outlive the asset and the segment then renders without it. Returns only the `mediaId`. A segment's `media` may also carry an `overlay` (`title`, optional `subtitle` and `badge`, at most 60, 80 and 30 characters): an info card with the real place name, address and price, painted at the top of the photo. The photo is shown over the video for the seconds its segment is spoken, with the subtitles on top: full frame on faceless videos and over b-roll (the whole photo over a blurred copy of itself, so it never leaves black bars), and as a framed panel (about 38% of the frame, 30 px from the bottom edge) where a persona's face is on screen, so the face still shows behind it. That means the hook of a hook-only lip-sync video and every segment of a full lip-sync video get the panel; once a hook-only video switches to b-roll the photo goes full frame. In the react layout the persona fills the top half, so the panel sits at the bottom. A card that cannot be drawn is skipped with a task warning while the photo still ships.
|
|
116
136
|
- `check_media`: 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`, `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.
|
|
117
|
-
- `generate_persona_video`: generate and schedule ONE persona video from a complete script — generation is always tied to publishing (one call = generate + schedule + auto-publish; no orphan videos, no separate schedule step). Send the full script as `segments` (first `hook`, then body segments, last `cta`; 60-200 words total, body at least 30, CTA 5-20, hook 15-40 words ending with terminal punctuation) — no LLM expands it. `title` is the slot label for this video. `personaId` is optional: omit it for a faceless post with no persona, in which case set `options.faceless` and `options.voiceId` (or `options.audioUrl`), plus `videoAspect` / `language` / `niche` as needed. `options.voiceId` takes a house name or label from `list_voices` (`phonon_zoey`, `Zoey`) or a clone id/key from `list_voices`; never type a provider prefix — an unknown voice is rejected before generation (no tokens spent). Pass `providers` plus per-provider account IDs (see the account ID table below), `startAt` + `times` in `timezone` (or `mode: 'asap'` with no `startAt`/`times`). The slot must be 3h–30d ahead. `idempotencyKey` is generated automatically; reuse it to retry without generating twice (`replayed: true`). Poll the slot's `taskId` with `get_video_task_progress`.
|
|
137
|
+
- `generate_persona_video`: generate and schedule ONE persona video from a complete script — generation is always tied to publishing (one call = generate + schedule + auto-publish; no orphan videos, no separate schedule step). Send the full script as `segments` (first `hook`, then body segments, last `cta`; 60-200 words total, body at least 30, CTA 5-20, hook 15-40 words ending with terminal punctuation) — no LLM expands it. `title` is the slot label for this video. `personaId` is optional: omit it for a faceless post with no persona, in which case set `options.faceless` and `options.voiceId` (or `options.audioUrl`), plus `videoAspect` / `language` / `niche` as needed. `options.voiceId` takes a house name or label from `list_voices` (`phonon_zoey`, `Zoey`) or a clone id/key from `list_voices`; never type a provider prefix — an unknown voice is rejected before generation (no tokens spent). Pass `providers` plus per-provider account IDs (see the account ID table below), `startAt` + `times` in `timezone` (or `mode: 'asap'` with no `startAt`/`times`). The slot must be 3h–30d ahead. `idempotencyKey` is generated automatically; reuse it to retry without generating twice (`replayed: true`). Optional `recipe`: the recipe slug the script was written with — sent only as the `X-MCP-Recipe` telemetry header, never in the request body. Poll the slot's `taskId` with `get_video_task_progress`. `options.facelessMaterial` picks what fills the video: `broll` (real stock footage, the default), `svg` (drawn illustrations) or `images` (only the images you send on the segments: no stock and no drawings). With `images`, every segment must carry `media` (from `upload_media` or a public image `url`, up to 12), checked before any token is spent; each image is shown full frame with a slow zoom for the seconds its segment is spoken. If an image fails at render time the neighbouring image covers its seconds and the task gets a warning; if no image survives, the task fails with `images_do_not_cover_audio` and the tokens are refunded. The images are third-party content you supply: use only images you have the rights to.
|
|
118
138
|
- `get_video_status`: check generation status and get the final video URL.
|
|
119
139
|
- `get_video_task_progress`: poll one video task for machine-readable progress: returns `{task_id, state, progress, stage, error}`. `error` is the engine failure reason when `state` is `-1` (failed), `null` otherwise. Use per-video after `generate_persona_video`; prefer this over `get_video_status` when only progress matters.
|
|
120
140
|
- `cancel_video_task`: cancel/remove one of your video tasks on the engine by `taskId` (from `get_video_status`, `get_video_task_progress`, `get_post` or `list_posts`). Only your own task can be cancelled; a persona-scoped API key can only cancel tasks belonging to its personas. Unknown or already-finished tasks return an error; no token refund is issued by this call.
|
|
@@ -126,7 +146,7 @@ The `Authorization: Bearer` API key header is sent to the configured base URL, s
|
|
|
126
146
|
- `list_social_accounts`: list connected social accounts with the account IDs needed for scheduling.
|
|
127
147
|
- `get_persona_publishing_accounts`: list a persona's default publishing accounts per provider. `generate_persona_video` falls back to these when no account IDs are passed; explicit IDs always win.
|
|
128
148
|
- `set_persona_publishing_accounts`: replace a persona's default publishing accounts per provider (account IDs from `list_social_accounts`; providers mapped to `[]` keep no defaults).
|
|
129
|
-
- `connect_account`: connect a social account. For youtube/instagram/linkedin/threads: returns an authorization URL — the user must open it in a browser and authorize
|
|
149
|
+
- `connect_account`: connect a social account. For youtube/instagram/linkedin/threads: returns an authorization URL — the user must open it in a browser where they are signed in to Post Engineer with the same account, and authorize; the account then connects automatically (verify with `list_social_accounts`). A browser that is not signed in, or signed in as another user, is rejected. For bluesky: connects directly with handle + app password.
|
|
130
150
|
- `list_schedules`: list automation schedules.
|
|
131
151
|
- `list_posts`: list upcoming (scheduled) and past (published/failed) posts across all connected accounts.
|
|
132
152
|
- `cancel_schedule`: cancel a schedule by its ID.
|
|
@@ -136,7 +156,12 @@ The `Authorization: Bearer` API key header is sent to the configured base URL, s
|
|
|
136
156
|
- `list_video_generations`: list the video generation history, newest first (status, error code, token refunds).
|
|
137
157
|
- `get_video_generation`: get one video generation's detail by generation ID.
|
|
138
158
|
- `get_post`: get one post's full detail by id, whether the id is a slot id or a generation id (the server resolves it; the response says `kind: "slot"` or `kind: "generation"`). Both kinds carry live generation progress.
|
|
139
|
-
- `get_post_metrics`: per-video performance snapshots (views, likes, comments, saves) for a `window` of `24h` or `
|
|
159
|
+
- `get_post_metrics`: per-video performance snapshots (views, likes, comments, saves) for a `window` of `24h`, `7d` or `28d`, newest first. Optional exact-match filters: `persona` (uuid, or `^@none` for posts without a persona), `account`, `provider`, `angle` (or `^@none`). Returns `rows` and `truncated`. YouTube rows also carry YouTube Analytics retention for your own videos: `engagedViews`, `stayedToWatchPct` (derived: engaged views / views, not a native metric), `averageViewPercentage`, `contentType`, `provisional` (Analytics data is not final for ~3 days; `28d` rows are final), and `analyticsStatus` (`scope_missing` = reconnect YouTube to grant `yt-analytics.readonly`).
|
|
160
|
+
- `get_youtube_retention_curve`: the audience retention curve of one of your own published YouTube videos (`account` + `video` from a youtube `get_post_metrics` row), read live from YouTube Analytics: `points` of `ratio` (0.01–1.0 of the video), `audienceWatchRatio`, `relativeRetentionPerformance`. Only your own channel is queried. Shorts have no per-second curve in YouTube Studio; long-form videos do.
|
|
161
|
+
- `create_experiment`: create a paired A/B test of ONE script variable (the hook): a name, an optional `personaId`, `targetPairs` (3–20, default 6) and exactly two variants, each with a slug `variantId` (e.g. `hook-aggressive`, never "A"/"B"), a `name` and a style `description` you follow when writing its hooks. Nothing is charged.
|
|
162
|
+
- `list_experiments`: your experiments with their two variants and target pairs.
|
|
163
|
+
- `add_experiment_pair`: create both videos of one pair: same `title`, body and CTA (`segments` without the hook) and one hook per variant in `hooks`, plus the usual delivery fields of `generate_persona_video`. Each video is a normal charged video; the second starts `spacingHours` (default 24) after the first and the order alternates per pair. The server rejects the second video of a pair (before charging; a concurrent race is caught after the insert and refunded) unless it matches the first in: the same providers and accounts, the same title, voice (id and audio URL), faceless and faceless material, full lip-sync, video aspect and layout, paragraph number, face quality, language, niche and CTA text, and identical body and CTA segments, with a different hook. The pinned options.imageId is not stored, so it is not compared: pass the same imageId (or none) to both videos yourself; calling again with the same arguments replays what was already created; if a video's dispatch failed (its slot is `failed`, tokens refunded) the call reports an error and that pair number stays taken (a single-video schedule's only slot cannot be removed with `delete_slot`), so continue with the next free pair number.
|
|
164
|
+
- `get_experiment_results`: the experiment's videos by pair and, per provider, each pair's views/likes/comments/average view duration, wins per variant, a sign-test `pValue` and a `label`: `pending`, `indicative` (not proven yet) or `clear` (every target pair decided and p < 0.05). `window` is `24h`, `7d` (default) or `28d`.
|
|
140
165
|
- `list_token_transactions`: list the token ledger — every credit and debit (purchases, generation spends, refunds), newest first.
|
|
141
166
|
- `get_persona_delete_preview`: preview what deleting a persona would remove (counts + per-video download links). Read-only.
|
|
142
167
|
- `delete_persona`: DESTRUCTIVE — delete a persona with all its schedules, slots, videos, and image library. No token refunds.
|
|
@@ -164,22 +189,35 @@ The server serves the prompts hub from the Post Engineer web platform over
|
|
|
164
189
|
the MCP [prompts capability](https://modelcontextprotocol.io/docs/concepts/prompts),
|
|
165
190
|
so MCP clients (Cursor, Claude) list them as slash commands. Each prompt is
|
|
166
191
|
zero-arg: the agent asks you for the persona, accounts, and timing when you
|
|
167
|
-
run it. The
|
|
168
|
-
|
|
192
|
+
run it. The list and the text are fetched from the web API on demand
|
|
193
|
+
(`GET /api/prompts`, `GET /api/prompts/{slug}`), so a recipe edit on the
|
|
194
|
+
web reaches every install without a package update.
|
|
169
195
|
|
|
170
196
|
- `/daily-news`: Daily news becomes a video — turn one top GNews story of the day into one persona video, validated before any token is spent.
|
|
197
|
+
- `/place-spotlight`: Place spotlight becomes a video — turn one real place into one persona video with the place's own photos checked and attached as segment media, validated before any token is spent.
|
|
198
|
+
- `/subject-spotlight`: Subject spotlight becomes a video — turn one concrete subject (a car, a product, a gadget) into one persona video with its own photos and its real price on screen, validated before any token is spent.
|
|
171
199
|
- `/github-prs`: GitHub PRs become videos — turn a GitHub pull request into one persona video.
|
|
200
|
+
- `/last-30-days`: Last 30 days become a video — turn what happened in your niche in the last 30 days into one persona video, validated before any token is spent.
|
|
201
|
+
- `/multi-rede`: One week, one video per network — publish one video per network this week: LinkedIn, YouTube, Instagram, Bluesky, each scored for its own network.
|
|
202
|
+
- `/viral-shorts`: A viral video becomes your Short — learn from the most-viewed video in your niche and write a fresh Shorts script in your own voice, hook, content, CTA.
|
|
172
203
|
- `/full-setup`: Full setup becomes videos — connect accounts, create a persona, validate the script, and publish your first video without skipping a step.
|
|
173
204
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
205
|
+
An agent that arrives without a human typing a slash command can still self-serve
|
|
206
|
+
the same hub through MCP **tools**: `list_prompts` lists the recipes
|
|
207
|
+
(slug/title/description) and `get_prompt` returns one recipe's full text by
|
|
208
|
+
`slug`. The server's initialize instructions point agents there for
|
|
209
|
+
topic-shaped requests. Until the agent lists or fetches a recipe, the results
|
|
210
|
+
of `create_persona`, `list_personas`, `list_social_accounts`, and
|
|
211
|
+
`get_token_balance` end with a short next-step block pointing at
|
|
212
|
+
`list_prompts`, and a script rejected by `validate_script` or
|
|
213
|
+
`generate_persona_video` gets a hint that recipes produce scripts that pass.
|
|
214
|
+
|
|
215
|
+
To add a prompt, add its text to `shared/prompt-base/prompt-base.ts` and its
|
|
216
|
+
entry to the web hub (`apps/web/app/recipes/prompts.ts` + its i18n title and
|
|
217
|
+
objective). The MCP needs no change: it serves whatever the web hub lists.
|
|
180
218
|
|
|
181
219
|
## Links
|
|
182
220
|
|
|
183
221
|
- Platform: https://post-engineer.com/
|
|
184
|
-
- API keys: https://post-engineer.com/
|
|
185
|
-
- Recipes: [docs/recipes/daily-news.md](../../docs/recipes/daily-news.md) (daily news becomes a video)
|
|
222
|
+
- API keys: https://post-engineer.com/recipes
|
|
223
|
+
- Recipes: [docs/recipes/daily-news.md](../../docs/recipes/daily-news.md) (daily news becomes a video), [docs/recipes/place-spotlight.md](../../docs/recipes/place-spotlight.md) (place spotlight becomes a video), [docs/recipes/subject-spotlight.md](../../docs/recipes/subject-spotlight.md) (subject spotlight becomes a video), [docs/recipes/last-30-days.md](../../docs/recipes/last-30-days.md) (last 30 days become a video), [docs/recipes/multi-rede.md](../../docs/recipes/multi-rede.md) (one week, one video per network) and [docs/recipes/viral-shorts.md](../../docs/recipes/viral-shorts.md) (a viral video becomes your Short)
|
package/dist/analytics.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
1
|
+
export declare const MCP_TOOL_HEADER = "X-MCP-Tool";
|
|
2
|
+
export declare const MCP_CALL_ID_HEADER = "X-MCP-Call-Id";
|
|
3
|
+
export declare const MCP_VERSION_HEADER = "X-MCP-Version";
|
|
4
|
+
export declare function withTelemetryHeaders<TResult>(headers: () => Record<string, string>, run: () => Promise<TResult>): Promise<TResult>;
|
|
5
|
+
export declare function mcpTelemetryHeaders(): Record<string, string>;
|
|
4
6
|
export declare function withTracking<TArgs extends Record<string, unknown>, TResult>(toolName: string, handler: (args: TArgs) => Promise<TResult>): (args: TArgs) => Promise<TResult>;
|
package/dist/analytics.js
CHANGED
|
@@ -1,137 +1,55 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
1
3
|
//---------------
|
|
2
|
-
// MCP
|
|
4
|
+
// MCP tool telemetry, reported through the web API.
|
|
3
5
|
//
|
|
4
|
-
// The MCP server
|
|
5
|
-
//
|
|
6
|
+
// The MCP server never talks to PostHog. Every request the server sends to
|
|
7
|
+
// the post-engineer API carries headers naming the MCP tool that triggered
|
|
8
|
+
// it; the web API validates them and records `mcp_tool_called` against the
|
|
9
|
+
// authenticated user (apps/web/lib/mcp-tool-telemetry.ts). Nothing to
|
|
10
|
+
// configure on the user side, and no analytics key ships in the package.
|
|
6
11
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return scrubbed;
|
|
12
|
+
// withTracking() opens a per-invocation context (AsyncLocalStorage, so
|
|
13
|
+
// concurrent tool calls in the HTTP transport never mix their names) and
|
|
14
|
+
// mcpTelemetryHeaders() reads it when the API client builds its headers.
|
|
15
|
+
// One tool call can send several API requests; they share one call id so
|
|
16
|
+
// PostHog counts calls with count(distinct call_id).
|
|
17
|
+
//---------------
|
|
18
|
+
const { default: pkg } = await import('../package.json', { with: { type: 'json' } });
|
|
19
|
+
export const MCP_TOOL_HEADER = 'X-MCP-Tool';
|
|
20
|
+
export const MCP_CALL_ID_HEADER = 'X-MCP-Call-Id';
|
|
21
|
+
export const MCP_VERSION_HEADER = 'X-MCP-Version';
|
|
22
|
+
const toolCallContext = new AsyncLocalStorage();
|
|
23
|
+
//---------------
|
|
24
|
+
// Extra telemetry headers for the current call, set by recipe-session.ts
|
|
25
|
+
// (recipe-adoption attribution). A function, not a snapshot, so a request
|
|
26
|
+
// sent late in the call reports the session state at send time. A
|
|
27
|
+
// separate store from toolCallContext: the extras wrap the handler inside
|
|
28
|
+
// withTracking and never replace the tool name or call id.
|
|
29
|
+
//---------------
|
|
30
|
+
const extraHeadersContext = new AsyncLocalStorage();
|
|
31
|
+
export function withTelemetryHeaders(headers, run) {
|
|
32
|
+
return extraHeadersContext.run(headers, run);
|
|
29
33
|
}
|
|
30
34
|
//---------------
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// fallback when POSTHOG_HOST is not set. Keep in sync with the web
|
|
34
|
-
// (apps/web/lib/posthog-config.ts) and engine
|
|
35
|
-
// (apps/engine/app/services/analytics.py) constants —
|
|
36
|
-
// apps/web/lib/__tests__/posthog-config.test.ts enforces it.
|
|
35
|
+
// Headers for the current API request: the server version always, plus the
|
|
36
|
+
// tool name and call id when the request runs inside a tracked tool call.
|
|
37
37
|
//---------------
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Cache the in-flight promise: concurrent trackEvent calls during the
|
|
46
|
-
// lazy import wait for the same load instead of dropping events.
|
|
47
|
-
if (clientPromise !== null)
|
|
48
|
-
return clientPromise;
|
|
49
|
-
clientPromise = (async () => {
|
|
50
|
-
const apiKey = process.env['POSTHOG_API_KEY'];
|
|
51
|
-
if (typeof apiKey !== 'string' || apiKey.length === 0) {
|
|
52
|
-
if (!warned) {
|
|
53
|
-
warned = true;
|
|
54
|
-
console.warn('[mcp-analytics] POSTHOG_API_KEY not set — analytics disabled');
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
// Dynamic import: a missing or incompatible posthog-node never breaks
|
|
60
|
-
// module load. The MCP server declares node >=20.10; posthog-node 5.x
|
|
61
|
-
// wants >=20.20 — on older Node this catch degrades to disabled.
|
|
62
|
-
const { PostHog } = await import('posthog-node');
|
|
63
|
-
const host = process.env['POSTHOG_HOST'] ?? DEFAULT_POSTHOG_HOST;
|
|
64
|
-
client = new PostHog(apiKey, { host });
|
|
65
|
-
return client;
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (!warned) {
|
|
69
|
-
warned = true;
|
|
70
|
-
console.warn('[mcp-analytics] PostHog init failed — analytics disabled:', error);
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
})();
|
|
75
|
-
return clientPromise;
|
|
76
|
-
}
|
|
77
|
-
//---------------
|
|
78
|
-
// Track a product-analytics event (e.g. 'mcp_tool_called').
|
|
79
|
-
// eventName should be snake_case. properties carries safe context only:
|
|
80
|
-
// tool names, counts, validated enums — never credentials or raw bodies.
|
|
81
|
-
//---------------
|
|
82
|
-
export function trackEvent(eventName, properties) {
|
|
83
|
-
try {
|
|
84
|
-
const props = scrubSecrets({ ...(properties ?? {}) });
|
|
85
|
-
// Fire-and-forget: the lazy SDK load happens async. Telemetry must
|
|
86
|
-
// never block or break the MCP server.
|
|
87
|
-
void getClient().then((posthog) => {
|
|
88
|
-
if (posthog === null)
|
|
89
|
-
return;
|
|
90
|
-
try {
|
|
91
|
-
posthog.capture({
|
|
92
|
-
distinctId: 'post-engineer-mcp',
|
|
93
|
-
event: eventName,
|
|
94
|
-
// Origin tags: ours win over caller-supplied values — the origin
|
|
95
|
-
// of an event is a pipeline fact, not caller input, so it can
|
|
96
|
-
// never be spoofed away.
|
|
97
|
-
properties: { ...props, source: 'mcp', environment: getEnvironment() },
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
// Telemetry must never break the MCP server.
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// Telemetry must never break the MCP server.
|
|
38
|
+
export function mcpTelemetryHeaders() {
|
|
39
|
+
const extras = extraHeadersContext.getStore();
|
|
40
|
+
const headers = { ...(extras === undefined ? {} : extras()), [MCP_VERSION_HEADER]: pkg.version };
|
|
41
|
+
const context = toolCallContext.getStore();
|
|
42
|
+
if (context !== undefined) {
|
|
43
|
+
headers[MCP_TOOL_HEADER] = context.toolName;
|
|
44
|
+
headers[MCP_CALL_ID_HEADER] = context.callId;
|
|
107
45
|
}
|
|
46
|
+
return headers;
|
|
108
47
|
}
|
|
109
48
|
//---------------
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
// MCP events report 'development' — which is what they are.
|
|
113
|
-
//---------------
|
|
114
|
-
function getEnvironment() {
|
|
115
|
-
return process.env['NODE_ENV'] === 'production' ? 'production' : 'development';
|
|
116
|
-
}
|
|
117
|
-
//---------------
|
|
118
|
-
// Test seam: reset the cached client between tests.
|
|
119
|
-
// Not used in production code.
|
|
120
|
-
//---------------
|
|
121
|
-
export function resetAnalyticsForTesting() {
|
|
122
|
-
client = null;
|
|
123
|
-
warned = false;
|
|
124
|
-
clientPromise = null;
|
|
125
|
-
}
|
|
126
|
-
//---------------
|
|
127
|
-
// Wrap a tool handler so every invocation is tracked (never throws,
|
|
128
|
-
// never blocks): the PostHog event carries only the tool name.
|
|
129
|
-
// Moved here from index.ts so that file stays under the 500-line cap.
|
|
49
|
+
// Wrap a tool (or prompt) handler so every API request it sends is tagged
|
|
50
|
+
// with its name and a fresh call id.
|
|
130
51
|
//---------------
|
|
131
52
|
export function withTracking(toolName, handler) {
|
|
132
|
-
return async (args) => {
|
|
133
|
-
trackEvent('mcp_tool_called', { toolName });
|
|
134
|
-
return handler(args);
|
|
135
|
-
};
|
|
53
|
+
return async (args) => toolCallContext.run({ toolName, callId: randomUUID() }, () => handler(args));
|
|
136
54
|
}
|
|
137
55
|
//# sourceMappingURL=analytics.js.map
|
package/dist/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,iBAAiB
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,iBAAiB;AACjB,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AACtE,yEAAyE;AACzE,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,qDAAqD;AACrD,iBAAiB;AAEjB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,i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AAiB;AACjB,MAAM,UAAU,YAAY,CAAiD,QAAgB,EAAE,OAA0C;IACvI,OAAO,KAAK,EAAE,IAAW,EAAoB,EAAE,CAC7C,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PostEngineerClient } from './client.js';
|
|
2
|
+
export interface CreateExperimentInput {
|
|
3
|
+
name: string;
|
|
4
|
+
variable: 'hook';
|
|
5
|
+
personaId: string | null;
|
|
6
|
+
targetPairs: number;
|
|
7
|
+
variants: Array<{
|
|
8
|
+
variantId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createExperiment(client: PostEngineerClient, input: CreateExperimentInput): Promise<unknown>;
|
|
14
|
+
export declare function listExperiments(client: PostEngineerClient): Promise<unknown>;
|
|
15
|
+
export declare function getExperimentResults(client: PostEngineerClient, experimentId: string, window: string | undefined): Promise<unknown>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export async function createExperiment(client, input) {
|
|
2
|
+
return client.request('/api/experiments', { method: 'POST', headers: client.getHeaders(), body: JSON.stringify(input) }, 'create experiment');
|
|
3
|
+
}
|
|
4
|
+
export async function listExperiments(client) {
|
|
5
|
+
return client.request('/api/experiments', { method: 'GET', headers: client.getHeaders() }, 'list experiments');
|
|
6
|
+
}
|
|
7
|
+
export async function getExperimentResults(client, experimentId, window) {
|
|
8
|
+
const query = window === undefined ? '' : `?${new URLSearchParams({ window }).toString()}`;
|
|
9
|
+
return client.request(`/api/experiments/${encodeURIComponent(experimentId)}${query}`, { method: 'GET', headers: client.getHeaders() }, 'get experiment results');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=client-experiments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-experiments.js","sourceRoot":"","sources":["../src/client-experiments.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAA0B,EAAE,KAA4B;IAC7F,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,EAClB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAC7E,mBAAmB,CACpB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAA0B;IAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACjH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,YAAoB,EACpB,MAA0B;IAE1B,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC3F,OAAO,MAAM,CAAC,OAAO,CACnB,oBAAoB,kBAAkB,CAAC,YAAY,CAAC,GAAG,KAAK,EAAE,EAC9D,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,EAC/C,wBAAwB,CACzB,CAAC;AACJ,CAAC"}
|
package/dist/client-posts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PostEngineerClient } from './client.js';
|
|
2
2
|
export interface PostMetricsQuery {
|
|
3
|
-
window: '24h' | '7d';
|
|
3
|
+
window: '24h' | '7d' | '28d';
|
|
4
4
|
persona?: string;
|
|
5
5
|
account?: string;
|
|
6
6
|
provider?: string;
|
|
@@ -8,6 +8,10 @@ export interface PostMetricsQuery {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function getPost(client: PostEngineerClient, id: string): Promise<unknown>;
|
|
10
10
|
export declare function getPostMetrics(client: PostEngineerClient, query: PostMetricsQuery): Promise<unknown>;
|
|
11
|
+
export declare function getYouTubeRetentionCurve(client: PostEngineerClient, query: {
|
|
12
|
+
account: string;
|
|
13
|
+
video: string;
|
|
14
|
+
}): Promise<unknown>;
|
|
11
15
|
export interface ScoreDraftInput {
|
|
12
16
|
draft: string;
|
|
13
17
|
network?: string;
|
package/dist/client-posts.js
CHANGED
|
@@ -12,6 +12,10 @@ export async function getPostMetrics(client, query) {
|
|
|
12
12
|
}
|
|
13
13
|
return client.request(`/api/metrics?${params.toString()}`, { method: 'GET', headers: client.getHeaders() }, 'get post metrics');
|
|
14
14
|
}
|
|
15
|
+
export async function getYouTubeRetentionCurve(client, query) {
|
|
16
|
+
const params = new URLSearchParams({ account: query.account, video: query.video });
|
|
17
|
+
return client.request(`/api/metrics/retention-curve?${params.toString()}`, { method: 'GET', headers: client.getHeaders() }, 'get YouTube retention curve');
|
|
18
|
+
}
|
|
15
19
|
export async function scoreDraft(client, input) {
|
|
16
20
|
// Same parameter names as the route's body; omitted optionals are not
|
|
17
21
|
// sent (the route rejects empty parameters).
|
package/dist/client-posts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-posts.js","sourceRoot":"","sources":["../src/client-posts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-posts.js","sourceRoot":"","sources":["../src/client-posts.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAA0B,EAAE,EAAU;IAClE,OAAO,MAAM,CAAC,OAAO,CACnB,cAAc,kBAAkB,CAAC,EAAE,CAAC,EAAE,EACtC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,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E,KAAK,CAAC,KAAK,EAAE,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9D,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;QAAE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IACpE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACrD,OAAO,MAAM,CAAC,OAAO,CACnB,yBAAyB,EACzB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAC5E,aAAa,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PostEngineerClient } from './client.js';
|
|
2
|
+
export interface PromptSummary {
|
|
3
|
+
slug: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PromptDetail extends PromptSummary {
|
|
8
|
+
prompt: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class UnknownPromptSlugError extends Error {
|
|
11
|
+
readonly slug: string;
|
|
12
|
+
readonly validSlugs: string[];
|
|
13
|
+
constructor(slug: string, validSlugs: string[]);
|
|
14
|
+
}
|
|
15
|
+
export declare function listPrompts(client: PostEngineerClient): Promise<PromptSummary[]>;
|
|
16
|
+
export declare function getPrompt(client: PostEngineerClient, slug: string): Promise<PromptDetail>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ApiError } from './errors.js';
|
|
2
|
+
// Thrown by getPrompt on a 404: fetches the valid slugs with a follow-up
|
|
3
|
+
// listPrompts request so the agent can recover.
|
|
4
|
+
export class UnknownPromptSlugError extends Error {
|
|
5
|
+
slug;
|
|
6
|
+
validSlugs;
|
|
7
|
+
constructor(slug, validSlugs) {
|
|
8
|
+
super(`unknown prompt slug ${JSON.stringify(slug)}. Valid slugs: ${validSlugs.join(', ')}.`);
|
|
9
|
+
this.slug = slug;
|
|
10
|
+
this.validSlugs = validSlugs;
|
|
11
|
+
this.name = 'UnknownPromptSlugError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function isRecord(value) {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
function narrowSummary(value) {
|
|
18
|
+
if (!isRecord(value) ||
|
|
19
|
+
typeof value.slug !== 'string' ||
|
|
20
|
+
typeof value.title !== 'string' ||
|
|
21
|
+
typeof value.description !== 'string') {
|
|
22
|
+
throw new Error('Malformed prompts response from the API.');
|
|
23
|
+
}
|
|
24
|
+
return { slug: value.slug, title: value.title, description: value.description };
|
|
25
|
+
}
|
|
26
|
+
export async function listPrompts(client) {
|
|
27
|
+
const payload = await client.request('/api/prompts', { method: 'GET', headers: client.getHeaders() }, 'list prompts');
|
|
28
|
+
if (!isRecord(payload) || payload.success !== true || !Array.isArray(payload.prompts)) {
|
|
29
|
+
throw new Error('Malformed prompts response from the API.');
|
|
30
|
+
}
|
|
31
|
+
return payload.prompts.map(narrowSummary);
|
|
32
|
+
}
|
|
33
|
+
export async function getPrompt(client, slug) {
|
|
34
|
+
let payload;
|
|
35
|
+
try {
|
|
36
|
+
payload = await client.request(`/api/prompts/${encodeURIComponent(slug)}`, { method: 'GET', headers: client.getHeaders() }, 'get prompt');
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error instanceof ApiError && error.code === 'PROMPT_NOT_FOUND') {
|
|
40
|
+
throw new UnknownPromptSlugError(slug, (await listPrompts(client)).map((entry) => entry.slug));
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
const prompt = isRecord(payload) && payload.success === true ? payload.prompt : undefined;
|
|
45
|
+
if (!isRecord(prompt) || typeof prompt.prompt !== 'string') {
|
|
46
|
+
throw new Error('Malformed prompt response from the API.');
|
|
47
|
+
}
|
|
48
|
+
return { ...narrowSummary(prompt), prompt: prompt.prompt };
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=client-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-prompts.js","sourceRoot":"","sources":["../src/client-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqBvC,yEAAyE;AACzE,gDAAgD;AAChD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC1B;IAAuB;IAA5C,YAAqB,IAAY,EAAW,UAAoB;QAC9D,KAAK,CAAC,uBAAuB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kBAAkB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAD1E,SAAI,GAAJ,IAAI,CAAQ;QAAW,eAAU,GAAV,UAAU,CAAU;QAE9D,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IACE,CAAC,QAAQ,CAAC,KAAK,CAAC;QAChB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC/B,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,EACrC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,KAA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AAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/client-types.d.ts
CHANGED
|
@@ -22,8 +22,10 @@ export interface PersonaLibraryImageInput {
|
|
|
22
22
|
export type VideoLayout = (typeof VIDEO_LAYOUTS)[number];
|
|
23
23
|
export interface CreatePersonaInput {
|
|
24
24
|
name: string;
|
|
25
|
-
/**
|
|
26
|
-
avatarUrl
|
|
25
|
+
/** Every persona has a face: exactly one of avatarUrl or avatarPath. */
|
|
26
|
+
avatarUrl?: string;
|
|
27
|
+
/** Local face photo, uploaded as the multipart `photo` file. */
|
|
28
|
+
avatarPath?: string;
|
|
27
29
|
voiceId: string;
|
|
28
30
|
language?: string;
|
|
29
31
|
videoAspect?: '9:16' | '16:9';
|
|
@@ -47,6 +49,12 @@ export interface GeneratePersonaVideoInput {
|
|
|
47
49
|
personaId?: string;
|
|
48
50
|
/** The slot label for the single video. */
|
|
49
51
|
title: string;
|
|
52
|
+
/** Paired A/B experiment link (issue #476); checked server-side before the charge. */
|
|
53
|
+
experiment?: {
|
|
54
|
+
experimentId: string;
|
|
55
|
+
variantId: string;
|
|
56
|
+
pair: number;
|
|
57
|
+
};
|
|
50
58
|
providers: ('youtube' | 'instagram' | 'linkedin' | 'bluesky' | 'threads')[];
|
|
51
59
|
youtubeAccountIds?: string[];
|
|
52
60
|
instagramAccountIds?: string[];
|
|
@@ -67,8 +75,8 @@ export interface GeneratePersonaVideoInput {
|
|
|
67
75
|
timezone?: string;
|
|
68
76
|
options?: {
|
|
69
77
|
faceless?: boolean;
|
|
70
|
-
/** Stock footage only ('broll')
|
|
71
|
-
facelessMaterial?: 'broll' | 'svg';
|
|
78
|
+
/** Stock footage only ('broll'), drawn illustrations only ('svg') or only the segment images ('images'), with or without a face. */
|
|
79
|
+
facelessMaterial?: 'broll' | 'svg' | 'images';
|
|
72
80
|
/** Render the whole video as the persona talking, with no b-roll: every narration window is lip-synced to the persona face. Requires a persona with a photo and lip-sync enabled; cannot be combined with faceless. */
|
|
73
81
|
fullLipsync?: boolean;
|
|
74
82
|
audioUrl?: string;
|
|
@@ -103,6 +111,7 @@ export interface UpdatePersonaInput {
|
|
|
103
111
|
personaId: string;
|
|
104
112
|
name?: string;
|
|
105
113
|
avatarUrl?: string;
|
|
114
|
+
avatarPath?: string;
|
|
106
115
|
voiceId?: string;
|
|
107
116
|
language?: string;
|
|
108
117
|
videoAspect?: '9:16' | '16:9';
|
|
@@ -110,6 +119,7 @@ export interface UpdatePersonaInput {
|
|
|
110
119
|
scriptPrompt?: string;
|
|
111
120
|
paragraphNumber?: number;
|
|
112
121
|
niche?: string;
|
|
122
|
+
faceQuality?: 'ok' | 'very_good';
|
|
113
123
|
}
|
|
114
124
|
/** Input for publishing a user-provided video directly, without generation. */
|
|
115
125
|
export interface PublishVideoDirectInput {
|
package/dist/client.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare class PostEngineerClient {
|
|
|
40
40
|
getPersonaDeletePreview(personaId: string): Promise<unknown>;
|
|
41
41
|
deletePersona(personaId: string): Promise<unknown>;
|
|
42
42
|
disconnectAccount(provider: string, providerAccountId: string): Promise<unknown>;
|
|
43
|
-
validateScript(segments: unknown): Promise<unknown>;
|
|
43
|
+
validateScript(segments: unknown, facelessMaterial?: string): Promise<unknown>;
|
|
44
44
|
generatePersonaVideo(input: GeneratePersonaVideoInput): Promise<unknown>;
|
|
45
45
|
getVideoStatus(taskId: string): Promise<unknown>;
|
|
46
46
|
listPersonaImages(personaId: string): Promise<unknown>;
|