@agent-wechat/agent-wechat 2.4.1 → 2.5.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/dist/index.js +62 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1583,6 +1583,10 @@ var NativeWeChatClient = class {
|
|
|
1583
1583
|
const response = await this.response(`v1/accounts/${id(accountId)}/uploads`, { method: "POST", body: form, signal }, false, this.mediaTimeoutMs);
|
|
1584
1584
|
return JSON.parse(new TextDecoder().decode(await this.readBounded(response)));
|
|
1585
1585
|
}
|
|
1586
|
+
/** Delete an upload you have finished with, such as the source of an added sticker. Uploads a pending send or preparation needs are kept (`upload_in_use`). */
|
|
1587
|
+
releaseUpload(accountId, sourceId, signal) {
|
|
1588
|
+
return this.request(`v1/accounts/${id(accountId)}/uploads/${id(sourceId)}`, { method: "DELETE", signal });
|
|
1589
|
+
}
|
|
1586
1590
|
/** Derive Saved and all added official pack tabs from the account profile. */
|
|
1587
1591
|
stickerCollections(accountId, signal) {
|
|
1588
1592
|
return this.request(`v1/accounts/${id(accountId)}/sticker-collections`, { signal });
|
|
@@ -2144,15 +2148,6 @@ function collectWeChatStatusIssues(accounts) {
|
|
|
2144
2148
|
fix: "Select native.readPolicy=on_inbound to mark successfully handled conversations read without model hooks, or use a compatible prepared-run SDK hook."
|
|
2145
2149
|
});
|
|
2146
2150
|
}
|
|
2147
|
-
if ((snapshot.needsReview ?? 0) > 0) {
|
|
2148
|
-
issues.push({
|
|
2149
|
-
channel: "agent-wechat",
|
|
2150
|
-
accountId: snapshot.accountId,
|
|
2151
|
-
kind: "runtime",
|
|
2152
|
-
message: "Native consumer work needs review after an uncertain model dispatch or reply.",
|
|
2153
|
-
fix: "Inspect the retained consumer receipts before retrying; do not automatically resend uncertain work."
|
|
2154
|
-
});
|
|
2155
|
-
}
|
|
2156
2151
|
if (snapshot.connected === false) {
|
|
2157
2152
|
issues.push({
|
|
2158
2153
|
channel: "agent-wechat",
|
|
@@ -2796,7 +2791,11 @@ async function prepareImageRepresentation(bytes, mime, cfg) {
|
|
|
2796
2791
|
async function prepareNativeLink(params) {
|
|
2797
2792
|
const { message } = params;
|
|
2798
2793
|
const link = message.link;
|
|
2799
|
-
const
|
|
2794
|
+
const channels = message.appMessageType === 51;
|
|
2795
|
+
const body = (channels ? [
|
|
2796
|
+
message.body?.trim() || "[Channels]",
|
|
2797
|
+
message.body?.startsWith("[Channels video]") ? "[Video not downloaded: call wechat_media with this message's ID to retrieve it]" : void 0
|
|
2798
|
+
] : [`[Link]${link.title ? ` ${link.title}` : ""}`, link.description, link.url]).filter(Boolean).join("\n").slice(0, 65536);
|
|
2800
2799
|
const unavailable = (status, reason) => ({
|
|
2801
2800
|
body: `${body}
|
|
2802
2801
|
[Link preview ${status}]`,
|
|
@@ -2901,6 +2900,16 @@ async function prepareNativeAttachmentInput(params) {
|
|
|
2901
2900
|
if (message.type === 48) return { body: message.location && message.body ? message.body.slice(0, 32768) : "[Location unavailable]", pending: false };
|
|
2902
2901
|
if (message.type === 49 && [1, 17, 74, 87].includes(message.appMessageType ?? 0)) return { body: message.body?.slice(0, 32768) || "[Shared text unavailable]", pending: false };
|
|
2903
2902
|
if (message.type === 49 && message.appMessageType === 19) return { body: message.body?.slice(0, 65536) || "[Forwarded chat history unavailable]", pending: false };
|
|
2903
|
+
if (message.type === 49 && message.appMessageType === 51 && message.link && params.channelsVideo && (params.quality ?? "best") !== "thumbnail") {
|
|
2904
|
+
const prepared = await prepareNativeAttachment({
|
|
2905
|
+
...params,
|
|
2906
|
+
channelsVideo: false,
|
|
2907
|
+
quality: "normal",
|
|
2908
|
+
message: { ...message, type: 43, appMessageType: void 0, quote: void 0, link: void 0 }
|
|
2909
|
+
});
|
|
2910
|
+
return { ...prepared, body: `${message.body?.trim() || "[Channels video]"}
|
|
2911
|
+
${prepared.body}`.slice(0, 65536) };
|
|
2912
|
+
}
|
|
2904
2913
|
if (message.type === 49 && [3, 4, 5, 51].includes(message.appMessageType ?? 0) && message.link) return prepareNativeLink(params);
|
|
2905
2914
|
if (message.type === 49 && message.appMessageType != null && message.appMessageType !== 6) return { body: `[Unsupported WeChat app message subtype ${message.appMessageType}]`, pending: false, retryable: false };
|
|
2906
2915
|
if (!attachmentKind) return { body: message.type === 1 ? message.body ?? "" : `[Unsupported WeChat message type ${message.type}]`, pending: false };
|
|
@@ -3641,8 +3650,8 @@ async function handleNativeStickerAction(ctx, dependencies = { host: ensureNativ
|
|
|
3641
3650
|
if (!account?.enabled || !account.native) throw Error("No native WeChat account configured");
|
|
3642
3651
|
const binding = nativeConfigurationKey(account.native);
|
|
3643
3652
|
const guard2 = async () => {
|
|
3644
|
-
if (ctx.senderIsOwner !== true || !ctx.
|
|
3645
|
-
await ctx.onPlatformSendDispatch();
|
|
3653
|
+
if (ctx.senderIsOwner !== true || !ctx.assertDirectAdapterHandoff) throw Error("WeChat sticker send requires live host handoff authority");
|
|
3654
|
+
await ctx.onPlatformSendDispatch?.();
|
|
3646
3655
|
ctx.assertDirectAdapterHandoff();
|
|
3647
3656
|
const current = resolveWeChatAccount(ctx.cfg, ctx.accountId ?? void 0);
|
|
3648
3657
|
if (!current?.enabled || !current.native || current.accountId !== account.accountId || nativeConfigurationKey(current.native) !== binding) throw Error("WeChat account configuration changed");
|
|
@@ -3929,7 +3938,7 @@ var NativeConsumerState = class {
|
|
|
3929
3938
|
const existing = message ? this.value.items[message.id] : void 0;
|
|
3930
3939
|
replaced = !!message && !nativeRecallInfo(message) && !!existing && (existing.message.threadId !== message.threadId || existing.message.serverId !== message.serverId);
|
|
3931
3940
|
if (message && (!existing || replaced)) {
|
|
3932
|
-
const completed = Object.entries(this.value.items).filter(([, item]) => !item.readPending && !item.groupContext &&
|
|
3941
|
+
const completed = Object.entries(this.value.items).filter(([, item]) => !item.readPending && !item.groupContext && ["completed", "ignored", "needs_review"].includes(item.state));
|
|
3933
3942
|
for (const [key2] of completed.slice(0, Math.max(0, completed.length - 1e3))) delete this.value.items[key2];
|
|
3934
3943
|
if (!existing && Object.keys(this.value.items).length >= 5e3) throw new Error("Native custody queue is full; operator review required");
|
|
3935
3944
|
if (replaced) {
|
|
@@ -4527,7 +4536,7 @@ async function startNativeMonitor(opts) {
|
|
|
4527
4536
|
const account = resolveWeChatAccount(cfg, opts.account.accountId) ?? opts.account;
|
|
4528
4537
|
if (account.backend !== "native" || JSON.stringify(account.native) !== JSON.stringify(native)) throw new Error("Native service configuration changed; restart required before processing");
|
|
4529
4538
|
for (const item of state.items().filter((value) => value.state === "received")) {
|
|
4530
|
-
await dispatchNativeMessage({
|
|
4539
|
+
const outcome = await dispatchNativeMessage({
|
|
4531
4540
|
client: host2.client,
|
|
4532
4541
|
state,
|
|
4533
4542
|
account,
|
|
@@ -4537,13 +4546,17 @@ async function startNativeMonitor(opts) {
|
|
|
4537
4546
|
signal: opts.abortSignal,
|
|
4538
4547
|
onDelivered: () => opts.setStatus({ accountId: account.accountId, lastOutboundAt: Date.now() })
|
|
4539
4548
|
});
|
|
4549
|
+
if (outcome === "needs_review") {
|
|
4550
|
+
const line = `WeChat message ${item.message.id} was not retried: its model dispatch or reply could not be confirmed`;
|
|
4551
|
+
if (opts.log?.warn) opts.log.warn(line);
|
|
4552
|
+
else opts.log?.error?.(line);
|
|
4553
|
+
}
|
|
4540
4554
|
}
|
|
4541
4555
|
try {
|
|
4542
4556
|
await flushRead();
|
|
4543
4557
|
} catch {
|
|
4544
4558
|
opts.log?.error?.("Native read projection is pending; thread read receipt retained for retry");
|
|
4545
4559
|
}
|
|
4546
|
-
const needsReview = state.items().filter((value) => value.state === "needs_review" || value.phoneReadState === "needs_review" || value.phoneReadState === "rejected").length;
|
|
4547
4560
|
const handoffUnconfirmed = native.readPolicy === "on_model_dispatch" && state.items().some((value) => value.handoffUnconfirmed);
|
|
4548
4561
|
const accountStatus = await host2.client.account(native.accountId);
|
|
4549
4562
|
opts.setStatus({
|
|
@@ -4551,7 +4564,6 @@ async function startNativeMonitor(opts) {
|
|
|
4551
4564
|
running: true,
|
|
4552
4565
|
connected: true,
|
|
4553
4566
|
linked: accountStatus.authenticated === true && accountStatus.connection === "online",
|
|
4554
|
-
needsReview,
|
|
4555
4567
|
handoffUnconfirmed
|
|
4556
4568
|
});
|
|
4557
4569
|
};
|
|
@@ -4597,7 +4609,7 @@ async function startNativeMonitor(opts) {
|
|
|
4597
4609
|
} catch (error) {
|
|
4598
4610
|
if (opts.abortSignal.aborted) break;
|
|
4599
4611
|
if (error instanceof NativeApiError && error.code === "event_cursor_expired") {
|
|
4600
|
-
opts.setStatus({ accountId: opts.account.accountId, connected: false, running: false,
|
|
4612
|
+
opts.setStatus({ accountId: opts.account.accountId, connected: false, running: false, lastError: "event_cursor_expired" });
|
|
4601
4613
|
throw new Error("Native journal cursor expired; explicit snapshot/replay is required before resuming");
|
|
4602
4614
|
}
|
|
4603
4615
|
opts.setStatus({ accountId: opts.account.accountId, connected: false, running: true });
|
|
@@ -5008,7 +5020,6 @@ var wechatPlugin = {
|
|
|
5008
5020
|
accountId: account?.accountId ?? "default",
|
|
5009
5021
|
backend: "native",
|
|
5010
5022
|
handoffUnconfirmed: runtime2?.handoffUnconfirmed,
|
|
5011
|
-
needsReview: runtime2?.needsReview,
|
|
5012
5023
|
enabled: account?.enabled ?? false,
|
|
5013
5024
|
configured: Boolean(account?.native),
|
|
5014
5025
|
running: runtime2?.running ?? false,
|
|
@@ -5255,8 +5266,9 @@ function messageResult(message, retrievalTool = "wechat_media", quotePermitted =
|
|
|
5255
5266
|
const isQuote = message.type === 49 && message.appMessageType === 57;
|
|
5256
5267
|
const isForward = message.type === 49 && message.appMessageType === 19;
|
|
5257
5268
|
const isLink = message.type === 49 && [3, 4, 5].includes(message.appMessageType ?? 0) && !!message.link;
|
|
5258
|
-
const
|
|
5259
|
-
const
|
|
5269
|
+
const isChannels = message.type === 49 && message.appMessageType === 51 && !!message.link;
|
|
5270
|
+
const kind2 = isQuote ? "quote" : isForward ? "forwarded_history" : isLink ? "link_preview" : isChannels ? "channels_video" : message.type === 3 ? "image" : message.type === 47 ? "sticker" : message.type === 34 ? "voice" : message.type === 43 ? "video" : message.type === 49 && (message.appMessageType == null || message.appMessageType === 6) ? "file" : "unsupported";
|
|
5271
|
+
const body = message.type === 1 || isForward || isLink || isChannels ? message.body ?? "" : isQuote ? renderEmbeddedQuote(message, quotePermitted).body : `[WeChat ${kind2} message; attachment content has not been retrieved by this tool]`;
|
|
5260
5272
|
const quote = message.quote && {
|
|
5261
5273
|
serverId: message.quote.serverId,
|
|
5262
5274
|
type: message.quote.type,
|
|
@@ -5274,7 +5286,7 @@ function messageResult(message, retrievalTool = "wechat_media", quotePermitted =
|
|
|
5274
5286
|
type: message.type,
|
|
5275
5287
|
appMessageType: message.appMessageType,
|
|
5276
5288
|
quote,
|
|
5277
|
-
link: isLink ? message.link : void 0,
|
|
5289
|
+
link: isLink || isChannels ? message.link : void 0,
|
|
5278
5290
|
createdAt: message.createdAt,
|
|
5279
5291
|
body: body.slice(0, 4e3),
|
|
5280
5292
|
bodyTruncated: body.length > 4e3,
|
|
@@ -5413,6 +5425,7 @@ function createLookupTools(context, dependencies, archive) {
|
|
|
5413
5425
|
waitMs: 2e3,
|
|
5414
5426
|
signal,
|
|
5415
5427
|
assertCurrent: guard2,
|
|
5428
|
+
channelsVideo: true,
|
|
5416
5429
|
allowQuotedMessage: async (original) => original.direction === "outgoing" || await allowed(original.senderId ?? void 0),
|
|
5417
5430
|
beforeMediaAccess: async () => {
|
|
5418
5431
|
if (!await allowed(requesterSenderId) || message.direction !== "outgoing" && !await allowed(message.senderId ?? void 0)) throw Error("WeChat conversation access is no longer allowed");
|
|
@@ -5433,11 +5446,13 @@ function createLookupTools(context, dependencies, archive) {
|
|
|
5433
5446
|
}
|
|
5434
5447
|
guard2();
|
|
5435
5448
|
if (!await allowed(requesterSenderId) || message.direction !== "outgoing" && !await allowed(message.senderId ?? void 0)) throw Error("WeChat conversation access is no longer allowed");
|
|
5449
|
+
const unreachable = context.sandboxed === true && prepared.attachment?.status === "ready" && prepared.attachment.kind !== "image";
|
|
5450
|
+
const attachment = unreachable ? { ...prepared.attachment, path: void 0, reachableFromSandbox: false } : prepared.attachment;
|
|
5436
5451
|
const details = {
|
|
5437
5452
|
messageId: message.id,
|
|
5438
5453
|
threadId: message.threadId,
|
|
5439
5454
|
status: prepared.reason === "message_recalled" ? "recalled" : prepared.pending ? "pending" : prepared.attachment?.status ?? prepared.quote?.state ?? "unsupported",
|
|
5440
|
-
attachment
|
|
5455
|
+
attachment,
|
|
5441
5456
|
quote: prepared.quote,
|
|
5442
5457
|
link: ["message_recalled", "media_identity_unavailable", "media_source_changed"].includes(prepared.reason ?? "") ? void 0 : message.link,
|
|
5443
5458
|
variant: prepared.variant,
|
|
@@ -5491,13 +5506,13 @@ function createLookupTools(context, dependencies, archive) {
|
|
|
5491
5506
|
tool(archiveNames[1], "search", "Search locally stored messages across every thread in the configured WeChat account, including other senders. Optional threadId narrows the search. Follow nextCursor with the same query and thread selection; no remote backfill or read marking.", { query: querySchema, threadId: threadIdSchema, ...pageSchema }, ["query"]),
|
|
5492
5507
|
tool(archiveNames[2], "history", "Read the locally stored history of any thread in the configured WeChat account, newest first, without sender filtering or read marking. Use wechat_archive_threads to find thread IDs.", { threadId: threadIdSchema, ...pageSchema }, ["threadId"]),
|
|
5493
5508
|
tool(archiveNames[3], "message", "Look up a stored message in any thread of the configured WeChat account by its exact opaque message ID. Use wechat_archive_media to retrieve its attachment.", { messageId: messageIdSchema }, ["messageId"]),
|
|
5494
|
-
tool(archiveNames[4], "media", "Retrieve an attachment or quoted text/image/link from any thread in the configured WeChat account by its message ID. Use the parent quote message ID for quotes. Returns verified managed file paths and an image preview for vision. Cached bytes first; missing media requests a bounded server-owned download unless download=false. Preserve pending/expired/unavailable results and never automatically retry retryable=false. No sends or read marking.", mediaSchema, ["messageId"])
|
|
5509
|
+
tool(archiveNames[4], "media", "Retrieve an attachment, a Channels card's video, or quoted text/image/link from any thread in the configured WeChat account by its message ID. Use the parent quote message ID for quotes; quality thumbnail returns a Channels card's cover. Returns verified managed file paths and an image preview for vision. Cached bytes first; missing media requests a bounded server-owned download unless download=false. Preserve pending/expired/unavailable results and never automatically retry retryable=false. No sends or read marking.", mediaSchema, ["messageId"])
|
|
5495
5510
|
];
|
|
5496
5511
|
return [
|
|
5497
5512
|
tool(names2[0], "history", "Read the current WeChat conversation's locally stored messages, newest first, beyond the recent inbound buffer. Follow nextCursor for older history; no remote history backfill or read marking.", { ...pageSchema }),
|
|
5498
5513
|
tool(names2[1], "search", "Search the current WeChat conversation's locally stored message text by case-insensitive substring, beyond buffered messages. Follow nextCursor with the same query in this conversation.", { query: querySchema, ...pageSchema }, ["query"]),
|
|
5499
5514
|
tool(names2[2], "message", "Look up a stored message by its exact opaque message ID in the current WeChat conversation. Media is described without downloading it; use wechat_media to retrieve its attachment. Long text is bounded.", { messageId: messageIdSchema }, ["messageId"]),
|
|
5500
|
-
tool(names2[3], "media", "Retrieve a message attachment or quoted text/image/link from the current WeChat conversation. Use the parent quote message ID for quotes. Returns a verified local file path and an image preview for vision when applicable. Uses cached bytes first; download defaults to true and requests a bounded server-owned transfer if missing. Pending results may be checked again; never automatically retry confirmed expiry or retryable=false. Does not send messages or mark the thread read.", mediaSchema, ["messageId"])
|
|
5515
|
+
tool(names2[3], "media", "Retrieve a message attachment, a Channels card's video, or quoted text/image/link from the current WeChat conversation. Use the parent quote message ID for quotes; quality thumbnail returns a Channels card's cover. Returns a verified local file path and an image preview for vision when applicable. Uses cached bytes first; download defaults to true and requests a bounded server-owned transfer if missing. Pending results may be checked again; never automatically retry confirmed expiry or retryable=false. Does not send messages or mark the thread read.", mediaSchema, ["messageId"])
|
|
5501
5516
|
];
|
|
5502
5517
|
}
|
|
5503
5518
|
function registerNativeHistoryTools(api) {
|
|
@@ -5832,6 +5847,12 @@ function text3(value, label2) {
|
|
|
5832
5847
|
if (typeof value !== "string" || !value || value.length > 4096 || /[\u0000-\u001f\u007f]/.test(value)) throw Error(`Invalid ${label2}`);
|
|
5833
5848
|
return value;
|
|
5834
5849
|
}
|
|
5850
|
+
async function receivedStickerOriginal(client, accountId, messageId, signal) {
|
|
5851
|
+
const { items } = await client.mediaAssets(accountId, messageId, signal);
|
|
5852
|
+
const originals = (Array.isArray(items) ? items : []).filter((item) => item.accountId === accountId && item.messageId === messageId && item.kind === "sticker" && item.variant === "original");
|
|
5853
|
+
if (originals.length !== 1) throw Error(originals.length ? "The message has more than one original sticker" : "The message has no received sticker to add");
|
|
5854
|
+
return text3(originals[0].id, "asset identity");
|
|
5855
|
+
}
|
|
5835
5856
|
function createNativeStickerTools(context, dependencies = { host: ensureNativeHost, files: withStickerFiles }) {
|
|
5836
5857
|
if (context.senderIsOwner !== true || !context.assertInvocationCurrent) return [];
|
|
5837
5858
|
const config = () => context.getRuntimeConfig?.() ?? context.runtimeConfig ?? context.config;
|
|
@@ -5855,7 +5876,9 @@ function createNativeStickerTools(context, dependencies = { host: ensureNativeHo
|
|
|
5855
5876
|
file: { type: "string", description: "Workspace-relative source file for prepare; resolved on the session execution host." },
|
|
5856
5877
|
sourceId: { type: "string", description: "Existing daemon-owned upload instead of a workspace file." },
|
|
5857
5878
|
output: { type: "string", description: "New workspace-relative output for download, using the original format extension; existing files are never replaced." },
|
|
5858
|
-
fit: { type: "boolean", description: "
|
|
5879
|
+
fit: { type: "boolean", description: "Shrink a source larger than 1024 pixels to fit. Smaller sources keep their size and encoding." },
|
|
5880
|
+
maxEdge: { type: "integer", minimum: 16, maximum: 1024, description: "Shrink so the longest edge is at most this many pixels; never enlarges. Video defaults to 240." },
|
|
5881
|
+
fps: { type: "integer", minimum: 1, maximum: 30, description: "Frame rate for a sticker made from video; default 10. Not accepted for images or GIFs." },
|
|
5859
5882
|
startMs: { type: "integer", minimum: 0, maximum: 4294967295, description: "Explicit segment start in milliseconds; requires durationMs." },
|
|
5860
5883
|
durationMs: { type: "integer", minimum: 1, maximum: 1e4, description: "Explicit retained duration in milliseconds; omitted means preserve duration." },
|
|
5861
5884
|
idempotencyKey: { type: "string", minLength: 1, maxLength: 200, description: "Required stable key for prepare/add/move/remove and downloads that need acquisition. Reuse the key and identical intent after uncertain responses." }
|
|
@@ -5863,7 +5886,7 @@ function createNativeStickerTools(context, dependencies = { host: ensureNativeHo
|
|
|
5863
5886
|
execute: async (_id, input, signal) => {
|
|
5864
5887
|
if (!input || typeof input !== "object" || Array.isArray(input)) throw Error("Invalid sticker arguments");
|
|
5865
5888
|
const args = input;
|
|
5866
|
-
const fields = ["action", "stickerId", "preparationId", "file", "sourceId", "output", "fit", "startMs", "durationMs", "idempotencyKey", "revision", "afterId", "messageId", "assetId"];
|
|
5889
|
+
const fields = ["action", "stickerId", "preparationId", "file", "sourceId", "output", "fit", "maxEdge", "fps", "startMs", "durationMs", "idempotencyKey", "revision", "afterId", "messageId", "assetId"];
|
|
5867
5890
|
if (Object.keys(args).some((key2) => !fields.includes(key2))) throw Error("Unknown sticker argument");
|
|
5868
5891
|
const guard2 = () => {
|
|
5869
5892
|
signal?.throwIfAborted();
|
|
@@ -5892,8 +5915,16 @@ function createNativeStickerTools(context, dependencies = { host: ensureNativeHo
|
|
|
5892
5915
|
context.assertInputCommitAllowed?.();
|
|
5893
5916
|
let job2;
|
|
5894
5917
|
if (args.action === "add") {
|
|
5895
|
-
if (args.preparationId != null === (args.messageId != null || args.assetId != null)) throw Error("Provide a preparation or
|
|
5896
|
-
|
|
5918
|
+
if (args.preparationId != null === (args.messageId != null || args.assetId != null)) throw Error("Provide a preparation or a received sticker message");
|
|
5919
|
+
let source;
|
|
5920
|
+
if (args.preparationId != null) source = { kind: "prepared", preparationId: text3(args.preparationId, "preparation identity") };
|
|
5921
|
+
else {
|
|
5922
|
+
const messageId = text3(args.messageId, "message identity");
|
|
5923
|
+
const assetId = args.assetId != null ? text3(args.assetId, "asset identity") : await receivedStickerOriginal(client, accountId, messageId, signal);
|
|
5924
|
+
guard2();
|
|
5925
|
+
context.assertInputCommitAllowed?.();
|
|
5926
|
+
source = { kind: "message", messageId, assetId };
|
|
5927
|
+
}
|
|
5897
5928
|
job2 = await client.addCustomSticker(accountId, { source }, key2, signal);
|
|
5898
5929
|
} else {
|
|
5899
5930
|
const stickerId = text3(args.stickerId, "sticker identity"), revision = text3(args.revision, "collection revision");
|
|
@@ -5910,6 +5941,8 @@ function createNativeStickerTools(context, dependencies = { host: ensureNativeHo
|
|
|
5910
5941
|
if (args.action === "prepare") {
|
|
5911
5942
|
const key2 = text3(args.idempotencyKey, "idempotency key");
|
|
5912
5943
|
if (key2.length > 200 || args.fit != null && typeof args.fit !== "boolean") throw Error("Invalid sticker preparation options");
|
|
5944
|
+
const whole = (value, min, max) => value == null || Number.isInteger(value) && value >= min && value <= max;
|
|
5945
|
+
if (!whole(args.maxEdge, 16, 1024) || !whole(args.fps, 1, 30)) throw Error("Invalid sticker preparation options");
|
|
5913
5946
|
if (args.startMs != null && typeof args.startMs !== "number" || args.durationMs != null && typeof args.durationMs !== "number") throw Error("Invalid sticker segment");
|
|
5914
5947
|
const trim = args.durationMs == null ? null : { startMs: Number(args.startMs ?? 0), durationMs: Number(args.durationMs) };
|
|
5915
5948
|
if (args.startMs != null && !trim || trim && (!Number.isInteger(trim.startMs) || trim.startMs < 0 || trim.startMs > 4294967295 || !Number.isInteger(trim.durationMs) || trim.durationMs < 1 || trim.durationMs > 1e4)) throw Error("Invalid sticker segment");
|
|
@@ -5928,7 +5961,7 @@ function createNativeStickerTools(context, dependencies = { host: ensureNativeHo
|
|
|
5928
5961
|
} else sourceId = text3(args.sourceId, "source identity");
|
|
5929
5962
|
guard2();
|
|
5930
5963
|
context.assertInputCommitAllowed?.();
|
|
5931
|
-
const job2 = await client.prepareSticker(accountId, { sourceId, fit: args.fit === true, trim }, key2, signal);
|
|
5964
|
+
const job2 = await client.prepareSticker(accountId, { sourceId, fit: args.fit === true, maxEdge: args.maxEdge == null ? null : Number(args.maxEdge), fps: args.fps == null ? null : Number(args.fps), trim }, key2, signal);
|
|
5932
5965
|
guard2();
|
|
5933
5966
|
return result({ ...job2, idempotencyKey: key2 });
|
|
5934
5967
|
}
|