@agent-wechat/agent-wechat 0.15.1 → 0.15.4

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.
Files changed (2) hide show
  1. package/dist/index.js +20 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5521,11 +5521,15 @@ var getMediaParamsSchema = external_exports.object({
5521
5521
  quality: external_exports.enum(["full", "thumbnail"]).optional()
5522
5522
  });
5523
5523
  var mediaResultSchema = external_exports.object({
5524
- type: external_exports.enum(["image", "emoji", "voice", "video", "file", "pending", "unsupported"]),
5524
+ type: external_exports.enum(["image", "emoji", "voice", "video", "file", "pending", "expired", "unsupported"]),
5525
5525
  data: external_exports.string().optional(),
5526
5526
  url: external_exports.string().optional(),
5527
5527
  format: external_exports.string(),
5528
- filename: external_exports.string()
5528
+ filename: external_exports.string(),
5529
+ quality: external_exports.enum(["full", "standard", "thumbnail"]).optional(),
5530
+ reason: external_exports.string().optional(),
5531
+ expiresAt: external_exports.number().int().positive().optional(),
5532
+ retryable: external_exports.boolean().optional()
5529
5533
  });
5530
5534
  var agentConfigSchema = external_exports.object({
5531
5535
  maxTurns: external_exports.number().int().positive().default(30),
@@ -5603,6 +5607,9 @@ function renderAttachmentBody(originalBody, attachment, exposeNonVisualPath = tr
5603
5607
  if (attachment.status === "pending") {
5604
5608
  return appendReference(originalBody, `[${label} pending: ${name}]`);
5605
5609
  }
5610
+ if (attachment.status === "expired") {
5611
+ return appendReference(originalBody, `[${label} expired: ${name}; no cached copy available. Ask the sender to resend.]`);
5612
+ }
5606
5613
  return appendReference(originalBody, `[${label} unavailable: ${name} (${attachment.status})]`);
5607
5614
  }
5608
5615
  if (attachment.kind === "file") {
@@ -5906,7 +5913,7 @@ async function pollMedia(client, chatId, localId, quality, log, maxAttempts = 15
5906
5913
  let result;
5907
5914
  if (legacyImageServer) {
5908
5915
  const full = await client.getMedia(chatId, localId, "full");
5909
- if (full.data || full.type === "unsupported") return full;
5916
+ if (full.data || full.type === "unsupported" || full.type === "expired") return full;
5910
5917
  const preview = await client.getMedia(chatId, localId, "thumbnail");
5911
5918
  result = preview.data ? { ...preview, quality: "thumbnail" } : full;
5912
5919
  } else {
@@ -5921,7 +5928,7 @@ async function pollMedia(client, chatId, localId, quality, log, maxAttempts = 15
5921
5928
  }
5922
5929
  }
5923
5930
  lastResult = result;
5924
- if (result.type === "unsupported" || result.data) return result;
5931
+ if (result.type === "unsupported" || result.type === "expired" || result.data) return result;
5925
5932
  if (attempt < maxAttempts) {
5926
5933
  log?.info?.(`[media] Attempt ${attempt}/${maxAttempts} for ${chatId}:${localId} returned no data, retrying...`);
5927
5934
  await new Promise((resolve) => setTimeout(resolve, intervalMs));
@@ -6178,6 +6185,14 @@ async function retrieveAttachment(client, chatId, msg, liveAccount, log, maxAtte
6178
6185
  if (!result) {
6179
6186
  return { kind: expectedKind, status: "unavailable", filename: fallbackFilename };
6180
6187
  }
6188
+ if (result.type === "expired") {
6189
+ return {
6190
+ kind: expectedKind,
6191
+ status: "expired",
6192
+ filename: result.filename || fallbackFilename,
6193
+ expiresAt: result.expiresAt
6194
+ };
6195
+ }
6181
6196
  if (result.type === "unsupported") {
6182
6197
  if (baseType === 49) return void 0;
6183
6198
  return { kind: expectedKind, status: "unsupported", filename: fallbackFilename };
@@ -6415,6 +6430,7 @@ ${replyBlock}` : replyBlock;
6415
6430
  }
6416
6431
  async function refreshAttachment(message, client, chatId, liveAccount, log) {
6417
6432
  if (!message.attachment) return message;
6433
+ if (message.attachment.status === "expired") return message;
6418
6434
  if (message.attachment.status === "ready" && await attachmentPathExists(message.attachment.path)) {
6419
6435
  return message;
6420
6436
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-wechat/agent-wechat",
3
- "version": "0.15.1",
3
+ "version": "0.15.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",