post-engineer-mcp 1.0.0 → 1.3.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 +40 -11
- package/dist/client.d.ts +68 -3
- package/dist/client.js +359 -49
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +36 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +76 -47
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +14 -0
- package/dist/limits.js +15 -0
- package/dist/limits.js.map +1 -0
- package/dist/tools.d.ts +347 -6
- package/dist/tools.js +342 -71
- package/dist/tools.js.map +1 -1
- package/package.json +12 -3
package/dist/client.js
CHANGED
|
@@ -1,10 +1,153 @@
|
|
|
1
1
|
import { validateScheduleAdvance } from './validator.js';
|
|
2
|
+
import { getErrorMessage, ImageTooLargeError } from './errors.js';
|
|
3
|
+
import { MAX_LIBRARY_IMAGE_BYTES, MAX_LIBRARY_IMAGE_MB } from './limits.js';
|
|
4
|
+
// Re-exported so existing import sites (`../client.js`) keep working.
|
|
5
|
+
export { MAX_LIBRARY_IMAGE_BYTES, MAX_LIBRARY_IMAGE_MB };
|
|
6
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
7
|
+
import { basename, extname } from 'node:path';
|
|
8
|
+
const PRODUCTION_API_URL = 'https://post-engineer.com';
|
|
9
|
+
// Hung requests must not block the stdio tool call (and the agent session) forever.
|
|
10
|
+
const REQUEST_TIMEOUT_MS = 30_000;
|
|
11
|
+
// Multipart uploads can legitimately exceed the default budget: up to 10
|
|
12
|
+
// 10MB library images on one request.
|
|
13
|
+
const UPLOAD_TIMEOUT_MS = 120_000;
|
|
14
|
+
// Bound how much of an upstream error body can flow into agent-visible output.
|
|
15
|
+
const MAX_ERROR_BODY_CHARS = 200;
|
|
16
|
+
// Shared with tools.ts so the client-side guards, the Zod schema limits,
|
|
17
|
+
// and the field description strings can't drift apart.
|
|
18
|
+
export const MAX_LIBRARY_IMAGES = 10;
|
|
19
|
+
// Mirrors the server-side addLibraryImages limits: checked in createPersona
|
|
20
|
+
// so an oversized tag/description fails locally before the multipart upload.
|
|
21
|
+
export const MAX_LIBRARY_TAG_LENGTH = 100;
|
|
22
|
+
export const MAX_LIBRARY_DESCRIPTION_LENGTH = 500;
|
|
23
|
+
/**
|
|
24
|
+
* Shared size guard for both image-read call sites (the stat pre-check and
|
|
25
|
+
* the post-read check) so the limit and the message text can't drift apart.
|
|
26
|
+
* Throws the typed ImageTooLargeError carrying the full path.
|
|
27
|
+
*/
|
|
28
|
+
export function assertImageSize(sizeBytes, path) {
|
|
29
|
+
if (sizeBytes > MAX_LIBRARY_IMAGE_BYTES) {
|
|
30
|
+
throw new ImageTooLargeError(path, sizeBytes);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function mimeTypeForImagePath(path) {
|
|
34
|
+
const extension = extname(path).toLowerCase();
|
|
35
|
+
// No special hidden-file check needed: Node's extname('.PNG') is ''
|
|
36
|
+
// (a leading dot with no other dots is not an extension), so dotfiles
|
|
37
|
+
// fall through to the unsupported-extension rejection below.
|
|
38
|
+
if (extension === '.png')
|
|
39
|
+
return 'image/png';
|
|
40
|
+
if (extension === '.webp')
|
|
41
|
+
return 'image/webp';
|
|
42
|
+
if (extension === '.jpg' || extension === '.jpeg')
|
|
43
|
+
return 'image/jpeg';
|
|
44
|
+
throw new Error(`Unsupported image extension "${extension || '(none)'}": use JPG/JPEG, PNG, or WebP.`);
|
|
45
|
+
}
|
|
46
|
+
async function imageFormFile(path) {
|
|
47
|
+
// Validate before uploading: the API rejects the file anyway, so an
|
|
48
|
+
// oversized or unsupported image fails fast locally instead of wasting an
|
|
49
|
+
// upload. A stat() pre-check bounds memory before readFile — a multi-GB
|
|
50
|
+
// file misnamed .png would otherwise load fully into this stdio process.
|
|
51
|
+
// The TOCTOU window is benign: the authoritative size check still runs on
|
|
52
|
+
// the buffer after read. Any failure surfaces with the full path for a
|
|
53
|
+
// consistent, actionable message.
|
|
54
|
+
// Note: the extension is trusted as a hint only; the server re-validates
|
|
55
|
+
// content via magic bytes, so a mislabeled file still fails server-side
|
|
56
|
+
// (duplicating magic-byte sniffing locally would be a second source of
|
|
57
|
+
// truth that can drift).
|
|
58
|
+
const mimeType = mimeTypeForImagePath(path);
|
|
59
|
+
try {
|
|
60
|
+
const fileStat = await stat(path);
|
|
61
|
+
assertImageSize(fileStat.size, path);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Discriminate by type, not by message text: the typed size error
|
|
65
|
+
// passes through untouched, while stat failures become the actionable
|
|
66
|
+
// "Failed to read image" wrapper. Message sniffing would misclassify
|
|
67
|
+
// any future error whose prose happens to match.
|
|
68
|
+
if (error instanceof ImageTooLargeError)
|
|
69
|
+
throw error;
|
|
70
|
+
throw new Error(`Failed to read image "${path}": ${getErrorMessage(error)}`);
|
|
71
|
+
}
|
|
72
|
+
let buffer;
|
|
73
|
+
try {
|
|
74
|
+
buffer = await readFile(path);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new Error(`Failed to read image "${path}": ${getErrorMessage(error)}`);
|
|
78
|
+
}
|
|
79
|
+
if (buffer.length === 0) {
|
|
80
|
+
// A 0-byte file would pass the local gate but shift the index-aligned
|
|
81
|
+
// imageTags/imageDescriptions (the server 400s when the tag/description
|
|
82
|
+
// counts don't match the file count), so reject it here with a clear
|
|
83
|
+
// message instead of a confusing server 400.
|
|
84
|
+
throw new Error(`Image "${path}" is empty.`);
|
|
85
|
+
}
|
|
86
|
+
// The post-read check reuses the shared guard: same limit, same message,
|
|
87
|
+
// full path — and it covers the (benign) TOCTOU window after stat.
|
|
88
|
+
assertImageSize(buffer.length, path);
|
|
89
|
+
return new Blob([buffer], { type: mimeType });
|
|
90
|
+
}
|
|
91
|
+
// Normalize library metadata: trim; empty/whitespace-only values normalize
|
|
92
|
+
// to ''. Both upload paths (the create-persona imageTags/imageDescriptions
|
|
93
|
+
// arrays and the add-persona-image tag/description fields) send '' for empty
|
|
94
|
+
// metadata, and the server stores '' verbatim (the tag column is text not
|
|
95
|
+
// null default ''), so the stored values are identical on both paths.
|
|
96
|
+
// Lengths are checked here so an oversized tag fails before the multipart
|
|
97
|
+
// upload, not server-side after all bytes transfer. The label (e.g.
|
|
98
|
+
// filename) is included in the error when available.
|
|
99
|
+
function checkLibraryMetadataLengths(tag, description, label) {
|
|
100
|
+
const where = label ? ` for "${label}"` : '';
|
|
101
|
+
if (tag !== undefined && tag.length > MAX_LIBRARY_TAG_LENGTH) {
|
|
102
|
+
throw new Error(`Image tag${where} exceeds ${MAX_LIBRARY_TAG_LENGTH} characters.`);
|
|
103
|
+
}
|
|
104
|
+
if (description !== undefined && description.length > MAX_LIBRARY_DESCRIPTION_LENGTH) {
|
|
105
|
+
throw new Error(`Image description${where} exceeds ${MAX_LIBRARY_DESCRIPTION_LENGTH} characters.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function normalizeLibraryMetadata(image, label) {
|
|
109
|
+
const tag = image.tag?.trim() ?? '';
|
|
110
|
+
const description = image.description?.trim() ?? '';
|
|
111
|
+
checkLibraryMetadataLengths(tag, description, label);
|
|
112
|
+
return { tag, description };
|
|
113
|
+
}
|
|
114
|
+
// The bearer key is sent to this URL, so fail fast on a malformed or
|
|
115
|
+
// non-https override instead of silently targeting it. Loopback http is
|
|
116
|
+
// allowed for local staging; anything else must be https so the key never
|
|
117
|
+
// travels in cleartext.
|
|
118
|
+
function resolveBaseUrl(override) {
|
|
119
|
+
const raw = override ?? PRODUCTION_API_URL;
|
|
120
|
+
let url;
|
|
121
|
+
try {
|
|
122
|
+
url = new URL(raw);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw new Error('Invalid POST_ENGINEER_API_URL: not an absolute URL (use https:)');
|
|
126
|
+
}
|
|
127
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
128
|
+
throw new Error(`Invalid POST_ENGINEER_API_URL: protocol "${url.protocol}" is not allowed (use https:)`);
|
|
129
|
+
}
|
|
130
|
+
const loopback = url.hostname === 'localhost' ||
|
|
131
|
+
url.hostname === '127.0.0.1' ||
|
|
132
|
+
url.hostname === '::1' ||
|
|
133
|
+
url.hostname === '[::1]';
|
|
134
|
+
if (url.protocol === 'http:' && !loopback) {
|
|
135
|
+
throw new Error('Invalid POST_ENGINEER_API_URL: http: is only allowed for loopback hosts (use https:)');
|
|
136
|
+
}
|
|
137
|
+
// Never echo the raw value: it may embed credentials (userinfo/query).
|
|
138
|
+
// Return the normalized form so the validated value and the used value are
|
|
139
|
+
// identical: origin drops userinfo, trailing slashes are stripped so
|
|
140
|
+
// `${baseUrl}${path}` never yields `//api/...`.
|
|
141
|
+
return url.origin + url.pathname.replace(/\/+$/, '');
|
|
142
|
+
}
|
|
2
143
|
export class PostEngineerClient {
|
|
3
144
|
baseUrl;
|
|
4
145
|
apiKey;
|
|
146
|
+
now;
|
|
5
147
|
constructor(options = {}) {
|
|
6
|
-
this.baseUrl = (options.baseUrl ?? process.env.POST_ENGINEER_API_URL
|
|
7
|
-
this.apiKey = options.apiKey
|
|
148
|
+
this.baseUrl = resolveBaseUrl(options.baseUrl ?? process.env.POST_ENGINEER_API_URL);
|
|
149
|
+
this.apiKey = options.apiKey;
|
|
150
|
+
this.now = options.now ?? (() => new Date());
|
|
8
151
|
}
|
|
9
152
|
getHeaders(includeContentType = true) {
|
|
10
153
|
const headers = {
|
|
@@ -17,8 +160,35 @@ export class PostEngineerClient {
|
|
|
17
160
|
}
|
|
18
161
|
return headers;
|
|
19
162
|
}
|
|
163
|
+
async request(path, init, action, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
164
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
165
|
+
...init,
|
|
166
|
+
// init.signal, if provided, intentionally wins over timeoutMs; no
|
|
167
|
+
// current caller passes one, so UPLOAD_TIMEOUT_MS always applies on
|
|
168
|
+
// the upload paths this parameter exists for.
|
|
169
|
+
signal: init.signal ?? AbortSignal.timeout(timeoutMs),
|
|
170
|
+
});
|
|
171
|
+
if (!response.ok) {
|
|
172
|
+
const errorText = await response.text();
|
|
173
|
+
throw new Error(`Failed to ${action}: ${response.status} ${errorText.slice(0, MAX_ERROR_BODY_CHARS)}`);
|
|
174
|
+
}
|
|
175
|
+
// Some endpoints answer 204 No Content. An empty or non-JSON body on any
|
|
176
|
+
// other status is a real failure: surfacing it beats reporting success
|
|
177
|
+
// with an undefined payload (e.g. a paid video job the agent thinks started).
|
|
178
|
+
// The { ok: true } sentinel keeps handlers from rendering "undefined".
|
|
179
|
+
if (response.status === 204)
|
|
180
|
+
return { ok: true };
|
|
181
|
+
const successText = await response.text();
|
|
182
|
+
if (successText.length === 0)
|
|
183
|
+
return { ok: true };
|
|
184
|
+
try {
|
|
185
|
+
return JSON.parse(successText);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
throw new Error(`Failed to ${action}: response was not valid JSON (status ${response.status}).`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
20
191
|
async createPersona(input) {
|
|
21
|
-
const url = `${this.baseUrl}/api/persona`;
|
|
22
192
|
const formData = new FormData();
|
|
23
193
|
const hasAvatar = input.avatarUrl !== undefined && input.avatarUrl !== null && input.avatarUrl.length > 0;
|
|
24
194
|
formData.set('name', input.name);
|
|
@@ -32,68 +202,212 @@ export class PostEngineerClient {
|
|
|
32
202
|
formData.set('scriptPrompt', input.scriptPrompt);
|
|
33
203
|
formData.set('paragraphNumber', String(input.paragraphNumber ?? 1));
|
|
34
204
|
formData.set('niche', input.niche ?? 'General');
|
|
35
|
-
|
|
205
|
+
// The effective mix is computed once: the server treats 0 as faceless
|
|
206
|
+
// and rejects library images for it, so the local guard below must see
|
|
207
|
+
// the same value the form sends.
|
|
208
|
+
const effectiveFaceMixPercent = hasAvatar ? input.faceMixPercent ?? 50 : 0;
|
|
209
|
+
formData.set('faceMixPercent', String(effectiveFaceMixPercent));
|
|
36
210
|
formData.set('faceQuality', hasAvatar ? input.faceQuality ?? 'very_good' : 'ok');
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const errorText = await response.text();
|
|
44
|
-
throw new Error(`Failed to create persona: ${response.status} ${errorText}`);
|
|
211
|
+
const images = input.images ?? [];
|
|
212
|
+
// An imagePrimaryIndex without images is a caller bug (typo'd `images`
|
|
213
|
+
// or a lone index): fail fast instead of a silent successful creation
|
|
214
|
+
// with no primary image.
|
|
215
|
+
if (input.imagePrimaryIndex !== undefined && images.length === 0) {
|
|
216
|
+
throw new Error('imagePrimaryIndex requires images: provide at least one library image.');
|
|
45
217
|
}
|
|
46
|
-
|
|
218
|
+
if (images.length > 0) {
|
|
219
|
+
if (!hasAvatar) {
|
|
220
|
+
throw new Error('Library images require a persona avatar: provide avatarUrl together with images.');
|
|
221
|
+
}
|
|
222
|
+
// The server rejects library images when the stored face mix is 0
|
|
223
|
+
// (faceless), even with an avatarUrl. Fail fast here instead of
|
|
224
|
+
// uploading the bytes first.
|
|
225
|
+
if (effectiveFaceMixPercent === 0) {
|
|
226
|
+
throw new Error('Library images require a non-zero face mix: faceMixPercent must be greater than 0 when images are provided.');
|
|
227
|
+
}
|
|
228
|
+
if (images.length > MAX_LIBRARY_IMAGES) {
|
|
229
|
+
throw new Error(`At most ${MAX_LIBRARY_IMAGES} library images are allowed per persona.`);
|
|
230
|
+
}
|
|
231
|
+
if (input.imagePrimaryIndex !== undefined) {
|
|
232
|
+
// Fail fast before reading any file: pure-argument checks come first.
|
|
233
|
+
if (input.imagePrimaryIndex < 0 || input.imagePrimaryIndex >= images.length) {
|
|
234
|
+
throw new Error(`imagePrimaryIndex ${input.imagePrimaryIndex} is out of range: ${images.length} images provided.`);
|
|
235
|
+
}
|
|
236
|
+
formData.set('imagePrimaryIndex', String(input.imagePrimaryIndex));
|
|
237
|
+
}
|
|
238
|
+
const tags = [];
|
|
239
|
+
const descriptions = [];
|
|
240
|
+
// Sequential reads bound memory: at most one 10MB image is resident at
|
|
241
|
+
// a time (10 in parallel would hold ~100MB in this stdio process), and
|
|
242
|
+
// upload time is dominated by network transfer anyway. Order is
|
|
243
|
+
// preserved, so tags/descriptions stay aligned with the entries.
|
|
244
|
+
for (const image of images) {
|
|
245
|
+
const { tag, description } = normalizeLibraryMetadata(image, basename(image.path));
|
|
246
|
+
formData.append('images', await imageFormFile(image.path), basename(image.path));
|
|
247
|
+
tags.push(tag);
|
|
248
|
+
descriptions.push(description);
|
|
249
|
+
}
|
|
250
|
+
formData.set('imageTags', JSON.stringify(tags));
|
|
251
|
+
formData.set('imageDescriptions', JSON.stringify(descriptions));
|
|
252
|
+
}
|
|
253
|
+
return this.request('/api/persona', { method: 'POST', headers: this.getHeaders(false), body: formData }, 'create persona', UPLOAD_TIMEOUT_MS);
|
|
47
254
|
}
|
|
48
255
|
async listPersonas() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
256
|
+
return this.request('/api/persona/list', { method: 'GET', headers: this.getHeaders() }, 'list personas');
|
|
257
|
+
}
|
|
258
|
+
async listVoices() {
|
|
259
|
+
return this.request('/api/persona/voices', { method: 'GET', headers: this.getHeaders() }, 'list voices');
|
|
260
|
+
}
|
|
261
|
+
async listFaces() {
|
|
262
|
+
return this.request('/api/persona/faces', { method: 'GET', headers: this.getHeaders() }, 'list faces');
|
|
263
|
+
}
|
|
264
|
+
async updatePersona(input) {
|
|
265
|
+
const formData = new FormData();
|
|
266
|
+
if (input.name !== undefined)
|
|
267
|
+
formData.set('name', input.name);
|
|
268
|
+
if (input.avatarUrl !== undefined && input.avatarUrl.length > 0)
|
|
269
|
+
formData.set('avatarUrl', input.avatarUrl);
|
|
270
|
+
if (input.voiceId !== undefined)
|
|
271
|
+
formData.set('voiceId', input.voiceId);
|
|
272
|
+
if (input.language !== undefined)
|
|
273
|
+
formData.set('language', input.language);
|
|
274
|
+
if (input.videoAspect !== undefined)
|
|
275
|
+
formData.set('videoAspect', input.videoAspect);
|
|
276
|
+
if (input.scriptPrompt !== undefined)
|
|
277
|
+
formData.set('scriptPrompt', input.scriptPrompt);
|
|
278
|
+
if (input.paragraphNumber !== undefined)
|
|
279
|
+
formData.set('paragraphNumber', String(input.paragraphNumber));
|
|
280
|
+
if (input.niche !== undefined)
|
|
281
|
+
formData.set('niche', input.niche);
|
|
282
|
+
return this.request(`/api/persona?personaId=${encodeURIComponent(input.personaId)}`, { method: 'PATCH', headers: this.getHeaders(false), body: formData }, 'update persona');
|
|
283
|
+
}
|
|
284
|
+
async listSocialAccounts() {
|
|
285
|
+
return this.request('/api/account', { method: 'GET', headers: this.getHeaders() }, 'list social accounts');
|
|
286
|
+
}
|
|
287
|
+
async getOAuthConnectUrl(provider) {
|
|
288
|
+
return this.request('/api/account/connect-url', { method: 'POST', headers: this.getHeaders(), body: JSON.stringify({ provider }) }, 'get OAuth connect URL');
|
|
289
|
+
}
|
|
290
|
+
async connectBlueskyAccount(handle, appPassword) {
|
|
291
|
+
try {
|
|
292
|
+
return await this.request('/api/bluesky-connect', { method: 'POST', headers: this.getHeaders(), body: JSON.stringify({ handle, appPassword }) }, 'connect Bluesky account');
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
// The upstream error body may echo the request payload: never let the
|
|
296
|
+
// app password surface in agent-visible error text — raw, percent-encoded,
|
|
297
|
+
// or JSON-escaped.
|
|
298
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
299
|
+
if (appPassword.length === 0)
|
|
300
|
+
throw new Error(message);
|
|
301
|
+
const variants = [
|
|
302
|
+
appPassword,
|
|
303
|
+
encodeURIComponent(appPassword),
|
|
304
|
+
JSON.stringify(appPassword).slice(1, -1),
|
|
305
|
+
];
|
|
306
|
+
throw new Error(variants.reduce((text, variant) => text.replaceAll(variant, '[redacted]'), message));
|
|
57
307
|
}
|
|
58
|
-
|
|
308
|
+
}
|
|
309
|
+
async listSchedules() {
|
|
310
|
+
return this.request('/api/schedule', { method: 'GET', headers: this.getHeaders() }, 'list schedules');
|
|
311
|
+
}
|
|
312
|
+
async listPosts(limit = 20) {
|
|
313
|
+
return this.request(`/api/schedule/status?limit=${encodeURIComponent(String(limit))}`, { method: 'GET', headers: this.getHeaders() }, 'list posts');
|
|
314
|
+
}
|
|
315
|
+
async cancelSchedule(scheduleId) {
|
|
316
|
+
return this.request(`/api/schedule?id=${encodeURIComponent(scheduleId)}`, { method: 'DELETE', headers: this.getHeaders() }, 'cancel schedule');
|
|
317
|
+
}
|
|
318
|
+
async getTokenBalance() {
|
|
319
|
+
return this.request('/api/billing/tokens', { method: 'GET', headers: this.getHeaders() }, 'get token balance');
|
|
59
320
|
}
|
|
60
321
|
async generateVideoJob(input) {
|
|
61
|
-
|
|
62
|
-
const response = await fetch(url, {
|
|
322
|
+
return this.request('/api/persona/video-job', {
|
|
63
323
|
method: 'POST',
|
|
64
324
|
headers: this.getHeaders(),
|
|
65
325
|
body: JSON.stringify({
|
|
66
|
-
|
|
326
|
+
// Explicit null (not a dropped key): the web route treats both as
|
|
327
|
+
// the faceless flow, and null survives serialization explicitly.
|
|
328
|
+
personaId: input.personaId ?? null,
|
|
329
|
+
video_subject: input.videoSubject,
|
|
330
|
+
voice_id: input.voiceId,
|
|
67
331
|
video_script_prompt: input.scriptPrompt,
|
|
332
|
+
audio_url: input.audioUrl,
|
|
333
|
+
image_id: input.imageId,
|
|
68
334
|
}),
|
|
69
|
-
});
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
const errorText = await response.text();
|
|
72
|
-
throw new Error(`Failed to generate video job: ${response.status} ${errorText}`);
|
|
73
|
-
}
|
|
74
|
-
return response.json();
|
|
335
|
+
}, 'generate video job');
|
|
75
336
|
}
|
|
76
337
|
async getVideoStatus(taskId) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
338
|
+
return this.request(`/api/persona/video-status/${encodeURIComponent(taskId)}`, { method: 'GET', headers: this.getHeaders() }, 'get video status');
|
|
339
|
+
}
|
|
340
|
+
async listPersonaImages(personaId) {
|
|
341
|
+
return this.request(`/api/persona/images?personaId=${encodeURIComponent(personaId)}`, { method: 'GET', headers: this.getHeaders() }, 'list persona images');
|
|
342
|
+
}
|
|
343
|
+
async addPersonaImage(personaId, image) {
|
|
344
|
+
const formData = new FormData();
|
|
345
|
+
formData.set('personaId', personaId);
|
|
346
|
+
formData.append('image', await imageFormFile(image.path), basename(image.path));
|
|
347
|
+
// Empty/whitespace-only metadata normalizes to '' (see
|
|
348
|
+
// normalizeLibraryMetadata): the server stores '' verbatim on both
|
|
349
|
+
// upload paths, so the add path simply omits the keys — an empty tag
|
|
350
|
+
// can never match the deterministic keyword selection.
|
|
351
|
+
const { tag, description } = normalizeLibraryMetadata(image);
|
|
352
|
+
if (tag)
|
|
353
|
+
formData.set('tag', tag);
|
|
354
|
+
if (description)
|
|
355
|
+
formData.set('description', description);
|
|
356
|
+
// isPrimary is typed as `true` only (swap-only, symmetric with
|
|
357
|
+
// update_persona_image): an explicit false is rejected at schema parse
|
|
358
|
+
// time and can never reach this branch.
|
|
359
|
+
if (image.isPrimary)
|
|
360
|
+
formData.set('isPrimary', 'true');
|
|
361
|
+
return this.request('/api/persona/images', { method: 'POST', headers: this.getHeaders(false), body: formData }, 'add persona image', UPLOAD_TIMEOUT_MS);
|
|
362
|
+
}
|
|
363
|
+
async updatePersonaImage(input) {
|
|
364
|
+
if (input.tag === undefined &&
|
|
365
|
+
input.description === undefined &&
|
|
366
|
+
input.isPrimary === undefined) {
|
|
367
|
+
throw new Error('updatePersonaImage requires at least one of tag, description, or isPrimary.');
|
|
85
368
|
}
|
|
86
|
-
|
|
369
|
+
// The server PATCH is swap-only: isPrimary:false always 400s there.
|
|
370
|
+
// The tool schema already rejects false (z.literal(true)); this guard
|
|
371
|
+
// is for direct programmatic callers of the client library, where
|
|
372
|
+
// isPrimary?: boolean still permits false. Fail fast with an
|
|
373
|
+
// actionable message instead of the wasted round-trip.
|
|
374
|
+
if (input.isPrimary === false) {
|
|
375
|
+
throw new Error('updatePersonaImage: isPrimary cannot be false — mark another image as primary instead (the swap atomically demotes the old one).');
|
|
376
|
+
}
|
|
377
|
+
// Trim metadata like the add paths do: an untrimmed tag can never match
|
|
378
|
+
// the deterministic keyword selection. undefined = leave unchanged (the
|
|
379
|
+
// key is dropped by JSON.stringify); empty string = clear the stored
|
|
380
|
+
// value (server convention). A whitespace-only value trims to '' and
|
|
381
|
+
// therefore clears too — the field descriptions in tools.ts say so,
|
|
382
|
+
// since a caller passing " " likely did not intend to wipe the value.
|
|
383
|
+
const tag = input.tag?.trim();
|
|
384
|
+
const description = input.description?.trim();
|
|
385
|
+
// Fail fast on oversized metadata before the round-trip, symmetric with
|
|
386
|
+
// the add/create paths (undefined = leave unchanged, so the check must
|
|
387
|
+
// skip undefined instead of defaulting to '').
|
|
388
|
+
checkLibraryMetadataLengths(tag, description);
|
|
389
|
+
return this.request('/api/persona/images', {
|
|
390
|
+
method: 'PATCH',
|
|
391
|
+
headers: this.getHeaders(),
|
|
392
|
+
body: JSON.stringify({
|
|
393
|
+
id: input.id,
|
|
394
|
+
...(tag !== undefined ? { tag } : {}),
|
|
395
|
+
...(description !== undefined ? { description } : {}),
|
|
396
|
+
...(input.isPrimary !== undefined ? { isPrimary: input.isPrimary } : {}),
|
|
397
|
+
}),
|
|
398
|
+
}, 'update persona image');
|
|
399
|
+
}
|
|
400
|
+
async deletePersonaImage(id) {
|
|
401
|
+
return this.request(`/api/persona/images?id=${encodeURIComponent(id)}`, { method: 'DELETE', headers: this.getHeaders() }, 'delete persona image');
|
|
87
402
|
}
|
|
88
403
|
async createSchedule(input) {
|
|
89
404
|
if (input.scheduledAt) {
|
|
90
|
-
const validation = validateScheduleAdvance(input.scheduledAt,
|
|
405
|
+
const validation = validateScheduleAdvance(input.scheduledAt, this.now());
|
|
91
406
|
if (!validation.isValid) {
|
|
92
407
|
throw new Error(validation.error);
|
|
93
408
|
}
|
|
94
409
|
}
|
|
95
|
-
|
|
96
|
-
const response = await fetch(url, {
|
|
410
|
+
return this.request('/api/schedule', {
|
|
97
411
|
method: 'POST',
|
|
98
412
|
headers: this.getHeaders(),
|
|
99
413
|
body: JSON.stringify({
|
|
@@ -102,6 +416,7 @@ export class PostEngineerClient {
|
|
|
102
416
|
youtubeAccountIds: input.youtubeAccountIds ?? [],
|
|
103
417
|
instagramAccountIds: input.instagramAccountIds ?? [],
|
|
104
418
|
linkedinAccountIds: input.linkedinAccountIds ?? [],
|
|
419
|
+
blueskyAccountIds: input.blueskyAccountIds ?? [],
|
|
105
420
|
scheduledAt: input.scheduledAt,
|
|
106
421
|
daysOfWeek: input.daysOfWeek,
|
|
107
422
|
startHour: input.startHour,
|
|
@@ -109,12 +424,7 @@ export class PostEngineerClient {
|
|
|
109
424
|
postsPerDay: input.postsPerDay,
|
|
110
425
|
timezone: input.timezone ?? 'UTC',
|
|
111
426
|
}),
|
|
112
|
-
});
|
|
113
|
-
if (!response.ok) {
|
|
114
|
-
const errorText = await response.text();
|
|
115
|
-
throw new Error(`Failed to create schedule: ${response.status} ${errorText}`);
|
|
116
|
-
}
|
|
117
|
-
return response.json();
|
|
427
|
+
}, 'create schedule');
|
|
118
428
|
}
|
|
119
429
|
}
|
|
120
430
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAwCzD,MAAM,OAAO,kBAAkB;IACZ,OAAO,CAAS;IAChB,MAAM,CAAU;IAEjC,YAAY,UAAqC,EAAE;QACjD,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,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,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,eAAe,EACf;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,EAAE;gBAChD,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,IAAI,EAAE;gBACpD,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,EAAE;gBAClD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,EAAE;gBAChD,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK;aAClC,CAAC;SACH,EACD,iBAAiB,CAClB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared error-formatting helpers.
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own module because both `client.ts` and `tools.ts` need it:
|
|
5
|
+
* `tools.ts` already imports the exported limit constants from `client.ts`,
|
|
6
|
+
* so defining it in `tools.ts` would create a client↔tools import cycle.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
9
|
+
export declare class ImageTooLargeError extends Error {
|
|
10
|
+
/** Full local path of the oversized image. */
|
|
11
|
+
readonly path: string;
|
|
12
|
+
/** Observed size in bytes (from stat, or from the read buffer). */
|
|
13
|
+
readonly sizeBytes: number;
|
|
14
|
+
constructor(path: string, sizeBytes: number);
|
|
15
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared error-formatting helpers.
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own module because both `client.ts` and `tools.ts` need it:
|
|
5
|
+
* `tools.ts` already imports the exported limit constants from `client.ts`,
|
|
6
|
+
* so defining it in `tools.ts` would create a client↔tools import cycle.
|
|
7
|
+
*/
|
|
8
|
+
export function getErrorMessage(error) {
|
|
9
|
+
if (error instanceof Error)
|
|
10
|
+
return error.message;
|
|
11
|
+
return String(error);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Thrown when a library image exceeds the size limit. Carries the path and
|
|
15
|
+
* the observed size so the catch block in imageFormFile can discriminate by
|
|
16
|
+
* type (`instanceof`) instead of sniffing the error message text — message
|
|
17
|
+
* sniffing misclassifies any future error whose prose happens to match, or
|
|
18
|
+
* silently re-wraps the size error if the message is ever reworded.
|
|
19
|
+
*/
|
|
20
|
+
import { MAX_LIBRARY_IMAGE_MB } from './limits.js';
|
|
21
|
+
export class ImageTooLargeError extends Error {
|
|
22
|
+
/** Full local path of the oversized image. */
|
|
23
|
+
path;
|
|
24
|
+
/** Observed size in bytes (from stat, or from the read buffer). */
|
|
25
|
+
sizeBytes;
|
|
26
|
+
constructor(path, sizeBytes) {
|
|
27
|
+
// The max is the shared derived constant (never a hardcoded literal
|
|
28
|
+
// or a locally recomputed divisor) so the message can't drift from the
|
|
29
|
+
// enforced bound.
|
|
30
|
+
super(`Image "${path}" is too large (${sizeBytes} bytes; max ${MAX_LIBRARY_IMAGE_MB}MB).`);
|
|
31
|
+
this.name = 'ImageTooLargeError';
|
|
32
|
+
this.path = path;
|
|
33
|
+
this.sizeBytes = sizeBytes;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,8CAA8C;IACrC,IAAI,CAAS;IACtB,mEAAmE;IAC1D,SAAS,CAAS;IAE3B,YAAY,IAAY,EAAE,SAAiB;QACzC,oEAAoE;QACpE,uEAAuE;QACvE,kBAAkB;QAClB,KAAK,CAAC,UAAU,IAAI,mBAAmB,SAAS,eAAe,oBAAoB,MAAM,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { PostEngineerClient } from './client.js';
|
|
4
|
+
export declare function requireApiKey(env?: NodeJS.ProcessEnv): string;
|
|
4
5
|
export declare function createPostEngineerMcpServer(client?: PostEngineerClient): McpServer;
|
|
5
6
|
export declare function isMainModule(): boolean;
|