spectrum-ts 0.8.0 → 0.9.1

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.
@@ -1,10 +1,10 @@
1
1
  import { M as ManagedStream } from '../../stream-B55k7W8-.js';
2
- import { AdvancedIMessage } from '@photon-ai/advanced-imessage';
3
- import { IMessageSDK } from '@photon-ai/imessage-kit';
2
+ import { l as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-D5KhSXLy.js';
3
+ import * as zod_v4_core from 'zod/v4/core';
4
4
  import * as z from 'zod';
5
5
  import z__default from 'zod';
6
- import { l as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-DLrsDzV-.js';
7
- import * as zod_v4_core from 'zod/v4/core';
6
+ import { AdvancedIMessage } from '@photon-ai/advanced-imessage';
7
+ import { IMessageSDK } from '@photon-ai/imessage-kit';
8
8
  import 'hotscript';
9
9
 
10
10
  type IMessageClient = IMessageSDK | AdvancedIMessage[];
@@ -16,7 +16,10 @@ declare const spaceSchema: z__default.ZodObject<{
16
16
  group: "group";
17
17
  }>;
18
18
  }, z__default.core.$strip>;
19
- type IMessageMessage = SchemaMessage<typeof userSchema, typeof spaceSchema>;
19
+ type IMessageMessage = SchemaMessage<typeof userSchema, typeof spaceSchema> & {
20
+ partIndex?: number;
21
+ parentId?: string;
22
+ };
20
23
 
21
24
  declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.ZodObject<{
22
25
  local: z.ZodLiteral<true>;
@@ -43,7 +46,10 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
43
46
  } | {
44
47
  id: string;
45
48
  type: "group";
46
- }, undefined, ProviderMessage<{
49
+ }, z.ZodObject<{
50
+ partIndex: z.ZodOptional<z.ZodNumber>;
51
+ parentId: z.ZodOptional<z.ZodString>;
52
+ }, zod_v4_core.$strip>, ProviderMessage<{
47
53
  id: string;
48
54
  }, {
49
55
  id: string;
@@ -51,7 +57,10 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
51
57
  } | {
52
58
  id: string;
53
59
  type: "group";
54
- }, Record<never, never>>, {
60
+ }, {
61
+ partIndex?: number | undefined;
62
+ parentId?: string | undefined;
63
+ }>, {
55
64
  messages: ({ client }: {
56
65
  client: IMessageClient;
57
66
  config: {
@@ -67,15 +76,6 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
67
76
  }[] | undefined;
68
77
  };
69
78
  }) => ManagedStream<IMessageMessage>;
70
- }>> & Readonly<{
71
- tapbacks: {
72
- readonly love: "love";
73
- readonly like: "like";
74
- readonly dislike: "dislike";
75
- readonly laugh: "laugh";
76
- readonly emphasize: "emphasize";
77
- readonly question: "question";
78
- };
79
- }>;
79
+ }>> & Readonly<Record<never, never>>;
80
80
 
81
81
  export { imessage };
@@ -1,21 +1,23 @@
1
1
  import {
2
+ asGroup,
2
3
  asRichlink
3
- } from "../../chunk-H5XYVRHM.js";
4
+ } from "../../chunk-HU2EOF3K.js";
4
5
  import {
5
6
  asAttachment,
6
7
  asContact,
7
8
  asCustom,
9
+ asReaction,
8
10
  cloud,
9
11
  fromVCard,
10
12
  mergeStreams,
11
13
  stream,
12
14
  toVCard
13
- } from "../../chunk-ZNUORCLB.js";
15
+ } from "../../chunk-OIXH5S65.js";
14
16
  import {
15
17
  UnsupportedError,
16
18
  asText,
17
19
  definePlatform
18
- } from "../../chunk-4O6MQC5Z.js";
20
+ } from "../../chunk-U6WCQVVX.js";
19
21
 
20
22
  // src/providers/imessage/index.ts
21
23
  import { createClient as createClient2, directChat } from "@photon-ai/advanced-imessage";
@@ -248,6 +250,7 @@ var send = async (client, spaceId, content) => {
248
250
  throw UnsupportedError.content(content.type, "iMessage (local mode)");
249
251
  }
250
252
  };
253
+ var getMessage = async (_client, _id) => void 0;
251
254
 
252
255
  // src/providers/imessage/remote.ts
253
256
  import {
@@ -379,10 +382,52 @@ var ensureM4a = async (buffer, mimeType) => {
379
382
  return transcodeToM4a(buffer);
380
383
  };
381
384
 
385
+ // src/providers/imessage/cache.ts
386
+ var DEFAULT_MAX = 1e3;
387
+ var MessageCache = class {
388
+ map = /* @__PURE__ */ new Map();
389
+ max;
390
+ constructor(max = DEFAULT_MAX) {
391
+ this.max = max;
392
+ }
393
+ get(id) {
394
+ return this.map.get(id);
395
+ }
396
+ set(id, message) {
397
+ if (this.map.has(id)) {
398
+ this.map.delete(id);
399
+ }
400
+ this.map.set(id, message);
401
+ if (this.map.size > this.max) {
402
+ const first = this.map.keys().next().value;
403
+ if (first !== void 0) {
404
+ this.map.delete(first);
405
+ }
406
+ }
407
+ }
408
+ clear() {
409
+ this.map.clear();
410
+ }
411
+ };
412
+ var caches = /* @__PURE__ */ new WeakMap();
413
+ var getMessageCache = (owner) => {
414
+ let cache = caches.get(owner);
415
+ if (!cache) {
416
+ cache = new MessageCache();
417
+ caches.set(owner, cache);
418
+ }
419
+ return cache;
420
+ };
421
+
382
422
  // src/providers/imessage/remote.ts
383
423
  var PLATFORM = "iMessage";
384
424
  var URL_BALLOON_BUNDLE_ID = "com.apple.messages.URLBalloonProvider";
385
- var unsupportedContent = (type) => UnsupportedError.content(type, PLATFORM);
425
+ var GROUP_ITEM_ALLOWED = /* @__PURE__ */ new Set([
426
+ "attachment",
427
+ "contact",
428
+ "voice"
429
+ ]);
430
+ var unsupportedContent = (type, detail) => UnsupportedError.content(type, PLATFORM, detail);
386
431
  var toSendResult = (receipt) => ({
387
432
  id: receipt.guid,
388
433
  timestamp: /* @__PURE__ */ new Date()
@@ -400,17 +445,60 @@ var isVCardAttachment2 = (mimeType, fileName) => {
400
445
  }
401
446
  return Boolean(fileName?.toLowerCase().endsWith(".vcf"));
402
447
  };
403
- var TAPBACK_NAMES = new Set(
404
- Object.values(Reaction).filter((r) => r !== "emoji" && r !== "sticker")
448
+ var EMOJI_TO_TAPBACK = {
449
+ "\u2764\uFE0F": Reaction.love,
450
+ "\u{1F44D}": Reaction.like,
451
+ "\u{1F44E}": Reaction.dislike,
452
+ "\u{1F602}": Reaction.laugh,
453
+ "\u203C\uFE0F": Reaction.emphasize,
454
+ "\u2753": Reaction.question
455
+ };
456
+ var TAPBACK_TO_EMOJI = Object.fromEntries(
457
+ Object.entries(EMOJI_TO_TAPBACK).map(([emoji, kind]) => [kind, emoji])
405
458
  );
406
- var baseMessage = (event) => ({
407
- sender: { id: event.message.sender?.address ?? "" },
408
- space: {
409
- id: event.chatGuid,
410
- type: event.chatGuid.includes(";+;") ? "group" : "dm"
411
- },
412
- timestamp: event.timestamp
413
- });
459
+ var TAPBACK_CODE_TO_KIND = {
460
+ "2000": Reaction.love,
461
+ "2001": Reaction.like,
462
+ "2002": Reaction.dislike,
463
+ "2003": Reaction.laugh,
464
+ "2004": Reaction.emphasize,
465
+ "2005": Reaction.question,
466
+ "2006": Reaction.emoji,
467
+ "2007": Reaction.sticker
468
+ };
469
+ var isTapbackRemoval = (code) => code.startsWith("3");
470
+ var resolveReactionEmoji = (type, emoji) => {
471
+ if (emoji) {
472
+ return emoji;
473
+ }
474
+ if (!type) {
475
+ return null;
476
+ }
477
+ const kind = TAPBACK_CODE_TO_KIND[type] ?? type;
478
+ return TAPBACK_TO_EMOJI[kind] ?? null;
479
+ };
480
+ var getAssociatedMessageType = (message) => {
481
+ const direct = message.associatedMessageType;
482
+ if (typeof direct === "string") {
483
+ return direct;
484
+ }
485
+ const raw = message._raw;
486
+ const fromRaw = raw?.associatedMessageType;
487
+ return typeof fromRaw === "string" ? fromRaw : void 0;
488
+ };
489
+ var getBalloonBundleId = (message) => {
490
+ const raw = message._raw;
491
+ const id = raw?.balloonBundleId;
492
+ return typeof id === "string" ? id : void 0;
493
+ };
494
+ var resolveChatGuid = (message, hint) => {
495
+ if (hint) {
496
+ return hint;
497
+ }
498
+ const first = message.chatGuids?.[0];
499
+ return first ?? "";
500
+ };
501
+ var resolveSenderId = (message) => message.sender?.address ?? "";
414
502
  var toAttachmentContent2 = (client, info) => asAttachment({
415
503
  name: info.fileName,
416
504
  mimeType: info.mimeType,
@@ -426,10 +514,87 @@ var toVCardContent2 = async (client, info) => {
426
514
  return toAttachmentContent2(client, info);
427
515
  }
428
516
  };
429
- var getBalloonBundleId = (message) => {
430
- const raw = message._raw;
431
- const id = raw?.balloonBundleId;
432
- return typeof id === "string" ? id : void 0;
517
+ var attachmentContent = async (client, info) => isVCardAttachment2(info.mimeType, info.fileName) ? await toVCardContent2(client, info) : toAttachmentContent2(client, info);
518
+ var baseShape = (message, chatGuidHint, timestamp) => {
519
+ const chat = resolveChatGuid(message, chatGuidHint);
520
+ return {
521
+ sender: { id: resolveSenderId(message) },
522
+ space: {
523
+ id: chat,
524
+ type: chat.includes(";+;") ? "group" : "dm"
525
+ },
526
+ timestamp
527
+ };
528
+ };
529
+ var buildAttachmentMessage = async (client, base, info, id, partIndex, parentId) => {
530
+ const content = await attachmentContent(client, info);
531
+ const msg = { ...base, id, content, partIndex };
532
+ if (parentId !== void 0) {
533
+ msg.parentId = parentId;
534
+ }
535
+ return msg;
536
+ };
537
+ var rebuildFromAppleMessage = async (client, message, chatGuidHint) => {
538
+ const messageGuidStr = message.guid;
539
+ const timestamp = message.dateCreated ?? /* @__PURE__ */ new Date();
540
+ const base = baseShape(message, chatGuidHint, timestamp);
541
+ if (message.attachments.length === 1) {
542
+ const info = message.attachments[0];
543
+ if (!info) {
544
+ throw new Error("Unreachable: attachments.length === 1 but no element");
545
+ }
546
+ return buildAttachmentMessage(client, base, info, messageGuidStr, 0);
547
+ }
548
+ if (message.attachments.length > 1) {
549
+ const items = [];
550
+ for (let i = 0; i < message.attachments.length; i++) {
551
+ const info = message.attachments[i];
552
+ if (!info) {
553
+ continue;
554
+ }
555
+ items.push(
556
+ await buildAttachmentMessage(
557
+ client,
558
+ base,
559
+ info,
560
+ formatChildId(i, messageGuidStr),
561
+ i,
562
+ messageGuidStr
563
+ )
564
+ );
565
+ }
566
+ return {
567
+ ...base,
568
+ id: messageGuidStr,
569
+ content: asGroup({ items })
570
+ };
571
+ }
572
+ const text = message.text;
573
+ if (getBalloonBundleId(message) === URL_BALLOON_BUNDLE_ID) {
574
+ const url = text ?? "";
575
+ try {
576
+ return { ...base, id: messageGuidStr, content: asRichlink({ url }) };
577
+ } catch {
578
+ return {
579
+ ...base,
580
+ id: messageGuidStr,
581
+ content: url ? asText(url) : asCustom(message)
582
+ };
583
+ }
584
+ }
585
+ return {
586
+ ...base,
587
+ id: messageGuidStr,
588
+ content: text ? asText(text) : asCustom(message)
589
+ };
590
+ };
591
+ var cacheMessage = (cache, message) => {
592
+ cache.set(message.id, message);
593
+ if (message.content.type === "group") {
594
+ for (const item of message.content.items) {
595
+ cache.set(item.id, item);
596
+ }
597
+ }
433
598
  };
434
599
  var toRichlinkMessage = (event, base, id) => {
435
600
  const url = event.message.text ?? "";
@@ -443,32 +608,136 @@ var toRichlinkMessage = (event, base, id) => {
443
608
  };
444
609
  }
445
610
  };
446
- var toMessages2 = async (client, event) => {
447
- const base = baseMessage(event);
448
- const messageGuidStr = event.message.guid;
449
- if (getBalloonBundleId(event.message) === URL_BALLOON_BUNDLE_ID) {
450
- return [toRichlinkMessage(event, base, messageGuidStr)];
611
+ var PART_PREFIX = /^p:(\d+)\//;
612
+ var formatChildId = (partIndex, parentGuid) => `p:${partIndex}/${parentGuid}`;
613
+ var parseTapbackTarget = (target) => {
614
+ const match = target.match(PART_PREFIX);
615
+ const guid = target.replace(PART_PREFIX, "");
616
+ const partIndex = match ? Number(match[1]) : 0;
617
+ return { guid, partIndex };
618
+ };
619
+ var parseChildId = (id) => {
620
+ const match = id.match(PART_PREFIX);
621
+ if (!match) {
622
+ return null;
451
623
  }
452
- if (event.message.attachments.length > 0) {
453
- return Promise.all(
454
- event.message.attachments.map(async (info) => ({
455
- ...base,
456
- id: `${messageGuidStr}:${info.guid}`,
457
- content: isVCardAttachment2(info.mimeType, info.fileName) ? await toVCardContent2(client, info) : toAttachmentContent2(client, info)
458
- }))
459
- );
624
+ return {
625
+ parentGuid: id.replace(PART_PREFIX, ""),
626
+ partIndex: Number(match[1])
627
+ };
628
+ };
629
+ var resolveReactionTarget = async (client, cache, strippedGuid, partIndex) => {
630
+ let candidate = cache.get(strippedGuid);
631
+ if (!candidate) {
632
+ try {
633
+ const fetched = await client.messages.get(messageGuid(strippedGuid));
634
+ candidate = await rebuildFromAppleMessage(client, fetched);
635
+ cacheMessage(cache, candidate);
636
+ } catch {
637
+ return;
638
+ }
639
+ }
640
+ if (candidate.content.type === "group") {
641
+ const item = candidate.content.items[partIndex];
642
+ return item ?? candidate;
643
+ }
644
+ return candidate;
645
+ };
646
+ var toReactionMessage = async (client, cache, event, base, id, target) => {
647
+ const type = getAssociatedMessageType(event.message);
648
+ if (type && isTapbackRemoval(type)) {
649
+ return [];
650
+ }
651
+ const emoji = resolveReactionEmoji(
652
+ type,
653
+ event.message.associatedMessageEmoji
654
+ );
655
+ if (!emoji) {
656
+ return [];
657
+ }
658
+ const { guid: strippedGuid, partIndex } = parseTapbackTarget(target);
659
+ const resolved = await resolveReactionTarget(
660
+ client,
661
+ cache,
662
+ strippedGuid,
663
+ partIndex
664
+ );
665
+ if (!resolved) {
666
+ return [];
460
667
  }
461
- const text = event.message.text;
462
668
  return [
463
669
  {
464
670
  ...base,
465
- id: messageGuidStr,
466
- content: text ? asText(text) : asCustom(event.message)
671
+ id,
672
+ content: asReaction({ emoji, target: resolved })
467
673
  }
468
674
  ];
469
675
  };
676
+ var toMessages2 = async (client, cache, event) => {
677
+ const base = baseShape(event.message, event.chatGuid, event.timestamp);
678
+ const messageGuidStr = event.message.guid;
679
+ const assoc = event.message.associatedMessageGuid;
680
+ if (assoc) {
681
+ return toReactionMessage(client, cache, event, base, messageGuidStr, assoc);
682
+ }
683
+ if (getBalloonBundleId(event.message) === URL_BALLOON_BUNDLE_ID) {
684
+ const msg2 = toRichlinkMessage(event, base, messageGuidStr);
685
+ cacheMessage(cache, msg2);
686
+ return [msg2];
687
+ }
688
+ if (event.message.attachments.length === 1) {
689
+ const info = event.message.attachments[0];
690
+ if (!info) {
691
+ throw new Error("Unreachable: attachments.length === 1 but no element");
692
+ }
693
+ const msg2 = await buildAttachmentMessage(
694
+ client,
695
+ base,
696
+ info,
697
+ messageGuidStr,
698
+ 0
699
+ );
700
+ cacheMessage(cache, msg2);
701
+ return [msg2];
702
+ }
703
+ if (event.message.attachments.length > 1) {
704
+ const items = [];
705
+ for (let i = 0; i < event.message.attachments.length; i++) {
706
+ const info = event.message.attachments[i];
707
+ if (!info) {
708
+ continue;
709
+ }
710
+ items.push(
711
+ await buildAttachmentMessage(
712
+ client,
713
+ base,
714
+ info,
715
+ formatChildId(i, messageGuidStr),
716
+ i,
717
+ messageGuidStr
718
+ )
719
+ );
720
+ }
721
+ const parent = {
722
+ ...base,
723
+ id: messageGuidStr,
724
+ content: asGroup({ items })
725
+ };
726
+ cacheMessage(cache, parent);
727
+ return [parent];
728
+ }
729
+ const text = event.message.text;
730
+ const msg = {
731
+ ...base,
732
+ id: messageGuidStr,
733
+ content: text ? asText(text) : asCustom(event.message)
734
+ };
735
+ cacheMessage(cache, msg);
736
+ return [msg];
737
+ };
470
738
  var clientStream = (client) => {
471
739
  const sub = client.messages.subscribe("message.received");
740
+ const cache = getMessageCache(client);
472
741
  return stream((emit, end) => {
473
742
  const pump = (async () => {
474
743
  try {
@@ -476,7 +745,7 @@ var clientStream = (client) => {
476
745
  if (event.message.isFromMe) {
477
746
  continue;
478
747
  }
479
- for (const message of await toMessages2(client, event)) {
748
+ for (const message of await toMessages2(client, cache, event)) {
480
749
  await emit(message);
481
750
  }
482
751
  }
@@ -520,12 +789,7 @@ var stopTyping = async (clients, spaceId) => {
520
789
  }
521
790
  await remote.chats.stopTyping(chatGuid(spaceId));
522
791
  };
523
- var send2 = async (clients, spaceId, content) => {
524
- const remote = clients[0];
525
- if (!remote) {
526
- throw new Error("No remote iMessage client available");
527
- }
528
- const chat = chatGuid(spaceId);
792
+ var sendSingle = async (remote, chat, content) => {
529
793
  switch (content.type) {
530
794
  case "text":
531
795
  return toSendResult(await remote.messages.send(chat, content.text));
@@ -540,9 +804,7 @@ var send2 = async (clients, spaceId, content) => {
540
804
  mimeType: content.mimeType
541
805
  });
542
806
  return toSendResult(
543
- await remote.messages.send(chat, "", {
544
- attachment: attachment.guid
545
- })
807
+ await remote.messages.send(chat, "", { attachment: attachment.guid })
546
808
  );
547
809
  }
548
810
  case "contact": {
@@ -570,6 +832,34 @@ var send2 = async (clients, spaceId, content) => {
570
832
  throw unsupportedContent(content.type);
571
833
  }
572
834
  };
835
+ var send2 = async (clients, spaceId, content) => {
836
+ const remote = clients[0];
837
+ if (!remote) {
838
+ throw new Error("No remote iMessage client available");
839
+ }
840
+ const chat = chatGuid(spaceId);
841
+ if (content.type === "group") {
842
+ for (const sub of content.items) {
843
+ const itemType = sub.content.type;
844
+ if (!GROUP_ITEM_ALLOWED.has(itemType)) {
845
+ throw unsupportedContent(
846
+ "group",
847
+ `"${itemType}" items are not supported inside a group`
848
+ );
849
+ }
850
+ }
851
+ const groupMembers = [];
852
+ for (const sub of content.items) {
853
+ groupMembers.push(await sendSingle(remote, chat, sub.content));
854
+ }
855
+ const first = groupMembers[0];
856
+ if (!first) {
857
+ throw new Error("Empty group");
858
+ }
859
+ return { ...first, groupMembers };
860
+ }
861
+ return sendSingle(remote, chat, content);
862
+ };
573
863
  var replyToMessage = async (clients, spaceId, msgId, content) => {
574
864
  const remote = clients[0];
575
865
  if (!remote) {
@@ -648,17 +938,56 @@ var editMessage = async (clients, spaceId, msgId, content) => {
648
938
  content.text
649
939
  );
650
940
  };
651
- var reactToMessage = async (clients, spaceId, msgId, reaction) => {
941
+ var reactToMessage = async (clients, spaceId, target, reaction) => {
652
942
  const remote = clients[0];
653
943
  if (!remote) {
654
944
  return;
655
945
  }
656
946
  const chat = chatGuid(spaceId);
657
- const msg = messageGuid(msgId);
658
- if (TAPBACK_NAMES.has(reaction)) {
659
- await remote.messages.react(chat, msg, reaction);
947
+ const parentGuid = target.parentId ?? target.id;
948
+ const guid = messageGuid(parentGuid);
949
+ const opts = typeof target.partIndex === "number" ? { partIndex: target.partIndex } : void 0;
950
+ const native = EMOJI_TO_TAPBACK[reaction];
951
+ if (native) {
952
+ await remote.messages.react(chat, guid, native, opts);
660
953
  } else {
661
- await remote.messages.reactEmoji(chat, msg, reaction);
954
+ await remote.messages.reactEmoji(chat, guid, reaction, opts);
955
+ }
956
+ };
957
+ var getMessage2 = async (clients, spaceId, msgId) => {
958
+ const remote = clients[0];
959
+ if (!remote) {
960
+ return;
961
+ }
962
+ const cache = getMessageCache(remote);
963
+ const cached = cache.get(msgId);
964
+ if (cached) {
965
+ return cached;
966
+ }
967
+ const childRef = parseChildId(msgId);
968
+ if (childRef) {
969
+ try {
970
+ const fetched = await remote.messages.get(
971
+ messageGuid(childRef.parentGuid)
972
+ );
973
+ const parent = await rebuildFromAppleMessage(remote, fetched, spaceId);
974
+ cacheMessage(cache, parent);
975
+ if (parent.content.type !== "group") {
976
+ return;
977
+ }
978
+ const items = parent.content.items;
979
+ return items[childRef.partIndex];
980
+ } catch {
981
+ return;
982
+ }
983
+ }
984
+ try {
985
+ const fetched = await remote.messages.get(messageGuid(msgId));
986
+ const rebuilt = await rebuildFromAppleMessage(remote, fetched, spaceId);
987
+ cacheMessage(cache, rebuilt);
988
+ return rebuilt;
989
+ } catch {
990
+ return;
662
991
  }
663
992
  };
664
993
 
@@ -679,20 +1008,14 @@ var spaceSchema = z.object({
679
1008
  id: z.string(),
680
1009
  type: z.enum(["dm", "group"])
681
1010
  });
1011
+ var messageSchema = z.object({
1012
+ partIndex: z.number().int().nonnegative().optional(),
1013
+ parentId: z.string().optional()
1014
+ });
682
1015
 
683
1016
  // src/providers/imessage/index.ts
684
1017
  var imessage = definePlatform("iMessage", {
685
1018
  config: configSchema,
686
- static: {
687
- tapbacks: {
688
- love: "love",
689
- like: "like",
690
- dislike: "dislike",
691
- laugh: "laugh",
692
- emphasize: "emphasize",
693
- question: "question"
694
- }
695
- },
696
1019
  user: {
697
1020
  resolve: async ({ input }) => ({ id: input.userID })
698
1021
  },
@@ -724,6 +1047,9 @@ var imessage = definePlatform("iMessage", {
724
1047
  return { id: chat.guid, type: "group" };
725
1048
  }
726
1049
  },
1050
+ message: {
1051
+ schema: messageSchema
1052
+ },
727
1053
  lifecycle: {
728
1054
  createClient: async ({
729
1055
  config,
@@ -777,11 +1103,16 @@ var imessage = definePlatform("iMessage", {
777
1103
  }
778
1104
  await stopTyping(client, space.id);
779
1105
  },
780
- reactToMessage: async ({ space, messageId, reaction, client }) => {
1106
+ reactToMessage: async ({ space, target, reaction, client }) => {
781
1107
  if (isLocal(client)) {
782
- return;
1108
+ throw UnsupportedError.action("react", "iMessage (local mode)");
783
1109
  }
784
- await reactToMessage(client, space.id, messageId, reaction);
1110
+ await reactToMessage(
1111
+ client,
1112
+ space.id,
1113
+ target,
1114
+ reaction
1115
+ );
785
1116
  },
786
1117
  replyToMessage: async ({ space, messageId, content, client }) => {
787
1118
  if (isLocal(client)) {
@@ -794,6 +1125,12 @@ var imessage = definePlatform("iMessage", {
794
1125
  throw UnsupportedError.action("edit", "iMessage (local mode)");
795
1126
  }
796
1127
  await editMessage(client, space.id, messageId, content);
1128
+ },
1129
+ getMessage: async ({ space, messageId, client }) => {
1130
+ if (isLocal(client)) {
1131
+ return getMessage(client, messageId);
1132
+ }
1133
+ return getMessage2(client, space.id, messageId);
797
1134
  }
798
1135
  }
799
1136
  });
@@ -1,4 +1,4 @@
1
- import { d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-DLrsDzV-.js';
1
+ import { d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-D5KhSXLy.js';
2
2
  import * as node_readline from 'node:readline';
3
3
  import z__default from 'zod';
4
4
  import 'hotscript';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  UnsupportedError,
3
3
  definePlatform
4
- } from "../../chunk-4O6MQC5Z.js";
4
+ } from "../../chunk-U6WCQVVX.js";
5
5
 
6
6
  // src/providers/terminal/index.ts
7
7
  import { createInterface } from "readline";
@@ -2,7 +2,7 @@ import { M as ManagedStream } from '../../stream-B55k7W8-.js';
2
2
  import { WhatsAppClient } from '@photon-ai/whatsapp-business';
3
3
  import * as z from 'zod';
4
4
  import z__default from 'zod';
5
- import { l as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-DLrsDzV-.js';
5
+ import { l as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-D5KhSXLy.js';
6
6
  import * as zod_v4_core from 'zod/v4/core';
7
7
  import 'hotscript';
8
8