spectrum-ts 1.1.1 → 1.2.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/{chunk-PXX7ISZ6.js → chunk-FF2R4EP3.js} +82 -0
- package/dist/{chunk-7VSE6V3Q.js → chunk-I7EKZS5C.js} +1 -1
- package/dist/{chunk-TY3RT4OB.js → chunk-K3CTEGCZ.js} +2 -1
- package/dist/{chunk-7D6FHYKT.js → chunk-UQPIWAHH.js} +122 -71
- package/dist/index.d.ts +2 -3
- package/dist/index.js +60 -27
- package/dist/providers/imessage/index.d.ts +25 -5
- package/dist/providers/imessage/index.js +248 -100
- package/dist/providers/terminal/index.d.ts +18 -4
- package/dist/providers/terminal/index.js +12 -4
- package/dist/providers/whatsapp-business/index.d.ts +1 -2
- package/dist/providers/whatsapp-business/index.js +41 -22
- package/dist/{types-BZhWdyLk.d.ts → types-Dvp0I86h.d.ts} +66 -21
- package/package.json +2 -2
- package/dist/stream-B55k7W8-.d.ts +0 -8
|
@@ -1,30 +1,81 @@
|
|
|
1
1
|
import {
|
|
2
|
+
asGroup,
|
|
2
3
|
asRichlink,
|
|
3
4
|
groupSchema
|
|
4
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-K3CTEGCZ.js";
|
|
5
6
|
import {
|
|
6
7
|
asPoll,
|
|
7
8
|
asPollOption,
|
|
8
9
|
cloud,
|
|
9
10
|
mergeStreams,
|
|
10
11
|
stream
|
|
11
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-FF2R4EP3.js";
|
|
12
13
|
import {
|
|
13
14
|
UnsupportedError,
|
|
14
15
|
asAttachment,
|
|
15
16
|
asContact,
|
|
16
17
|
asCustom,
|
|
17
18
|
asText,
|
|
19
|
+
attachmentSchema,
|
|
18
20
|
definePlatform,
|
|
19
21
|
fromVCard,
|
|
20
22
|
reactionSchema,
|
|
23
|
+
text,
|
|
24
|
+
textSchema,
|
|
21
25
|
toVCard
|
|
22
|
-
} from "../../chunk-
|
|
26
|
+
} from "../../chunk-UQPIWAHH.js";
|
|
23
27
|
|
|
24
28
|
// src/providers/imessage/index.ts
|
|
25
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createClient as createClient2,
|
|
31
|
+
directChat,
|
|
32
|
+
MessageEffect as MessageEffect2
|
|
33
|
+
} from "@photon-ai/advanced-imessage";
|
|
26
34
|
import { IMessageSDK as IMessageSDK2 } from "@photon-ai/imessage-kit";
|
|
27
35
|
|
|
36
|
+
// src/providers/imessage/content/effect.ts
|
|
37
|
+
import {
|
|
38
|
+
MessageEffect
|
|
39
|
+
} from "@photon-ai/advanced-imessage";
|
|
40
|
+
|
|
41
|
+
// src/content/effect.ts
|
|
42
|
+
import z from "zod";
|
|
43
|
+
var effectInnerSchema = z.discriminatedUnion("type", [
|
|
44
|
+
textSchema,
|
|
45
|
+
attachmentSchema
|
|
46
|
+
]);
|
|
47
|
+
var messageEffectSchema = z.object({
|
|
48
|
+
type: z.literal("effect"),
|
|
49
|
+
content: effectInnerSchema,
|
|
50
|
+
effect: z.string().nonempty()
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// src/providers/imessage/content/effect.ts
|
|
54
|
+
var SUPPORTED_EFFECTS = new Set(Object.values(MessageEffect));
|
|
55
|
+
var resolveContent = (input) => typeof input === "string" ? text(input).build() : input.build();
|
|
56
|
+
function effect(input, messageEffect) {
|
|
57
|
+
return {
|
|
58
|
+
build: async () => {
|
|
59
|
+
if (!SUPPORTED_EFFECTS.has(messageEffect)) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Unsupported iMessage message effect "${messageEffect}"`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const inner = await resolveContent(input);
|
|
65
|
+
if (inner.type !== "text" && inner.type !== "attachment") {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`imessage effect() only supports text and attachment content, got "${inner.type}"`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return messageEffectSchema.parse({
|
|
71
|
+
type: "effect",
|
|
72
|
+
content: inner,
|
|
73
|
+
effect: messageEffect
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
28
79
|
// src/providers/imessage/auth.ts
|
|
29
80
|
import {
|
|
30
81
|
createClient
|
|
@@ -229,11 +280,13 @@ import { basename, join } from "path";
|
|
|
229
280
|
var IMESSAGE_PLATFORM = "iMessage";
|
|
230
281
|
var LOCAL_IMESSAGE_PLATFORM = "iMessage (local mode)";
|
|
231
282
|
var unsupportedRemoteContent = (type, detail) => UnsupportedError.content(type, IMESSAGE_PLATFORM, detail);
|
|
232
|
-
var unsupportedLocalContent = (type) => UnsupportedError.content(type, LOCAL_IMESSAGE_PLATFORM);
|
|
283
|
+
var unsupportedLocalContent = (type, detail) => UnsupportedError.content(type, LOCAL_IMESSAGE_PLATFORM, detail);
|
|
233
284
|
|
|
234
285
|
// src/providers/imessage/local/send.ts
|
|
235
|
-
var
|
|
286
|
+
var synthRecord = (spaceId, content) => ({
|
|
236
287
|
id: crypto.randomUUID(),
|
|
288
|
+
content,
|
|
289
|
+
space: { id: spaceId },
|
|
237
290
|
timestamp: /* @__PURE__ */ new Date()
|
|
238
291
|
});
|
|
239
292
|
var sendTempFile = async (client, spaceId, name, data) => {
|
|
@@ -252,10 +305,10 @@ var send = async (client, spaceId, content) => {
|
|
|
252
305
|
switch (content.type) {
|
|
253
306
|
case "text":
|
|
254
307
|
await client.send({ to: spaceId, text: content.text });
|
|
255
|
-
return
|
|
308
|
+
return synthRecord(spaceId, content);
|
|
256
309
|
case "attachment":
|
|
257
310
|
await sendTempFile(client, spaceId, content.name, await content.read());
|
|
258
|
-
return
|
|
311
|
+
return synthRecord(spaceId, content);
|
|
259
312
|
case "contact": {
|
|
260
313
|
const vcf = await toVCard(content);
|
|
261
314
|
await sendTempFile(
|
|
@@ -264,8 +317,13 @@ var send = async (client, spaceId, content) => {
|
|
|
264
317
|
vcardFileName(content),
|
|
265
318
|
Buffer.from(vcf, "utf8")
|
|
266
319
|
);
|
|
267
|
-
return
|
|
320
|
+
return synthRecord(spaceId, content);
|
|
268
321
|
}
|
|
322
|
+
case "effect":
|
|
323
|
+
throw unsupportedLocalContent(
|
|
324
|
+
"effect",
|
|
325
|
+
"message effects require remote iMessage"
|
|
326
|
+
);
|
|
269
327
|
case "poll":
|
|
270
328
|
throw unsupportedLocalContent("poll");
|
|
271
329
|
default:
|
|
@@ -561,11 +619,11 @@ var rebuildFromAppleMessage = async (client, message, chatGuidHint) => {
|
|
|
561
619
|
if (getBalloonBundleId(message) === URL_BALLOON_BUNDLE_ID) {
|
|
562
620
|
return toRichlinkMessage(message, base, messageGuidStr);
|
|
563
621
|
}
|
|
564
|
-
const
|
|
622
|
+
const text2 = message.text;
|
|
565
623
|
return {
|
|
566
624
|
...base,
|
|
567
625
|
id: messageGuidStr,
|
|
568
|
-
content:
|
|
626
|
+
content: text2 ? asText(text2) : asCustom(message)
|
|
569
627
|
};
|
|
570
628
|
};
|
|
571
629
|
var cacheMessage = (cache, message) => {
|
|
@@ -627,11 +685,11 @@ var toInboundMessages = async (client, cache, event) => {
|
|
|
627
685
|
cacheMessage(cache, parent);
|
|
628
686
|
return [parent];
|
|
629
687
|
}
|
|
630
|
-
const
|
|
688
|
+
const text2 = event.message.text;
|
|
631
689
|
const msg = {
|
|
632
690
|
...base,
|
|
633
691
|
id: messageGuidStr,
|
|
634
|
-
content:
|
|
692
|
+
content: text2 ? asText(text2) : asCustom(event.message)
|
|
635
693
|
};
|
|
636
694
|
cacheMessage(cache, msg);
|
|
637
695
|
return [msg];
|
|
@@ -876,9 +934,9 @@ var runFfmpeg = (ffmpegPath, args) => {
|
|
|
876
934
|
);
|
|
877
935
|
proc.on("exit", (code) => resolve(code ?? -1));
|
|
878
936
|
});
|
|
879
|
-
return Promise.all([exit, stderr]).then(([code,
|
|
937
|
+
return Promise.all([exit, stderr]).then(([code, text2]) => ({
|
|
880
938
|
code,
|
|
881
|
-
stderr:
|
|
939
|
+
stderr: text2
|
|
882
940
|
}));
|
|
883
941
|
};
|
|
884
942
|
var DURATION_PATTERN = /Duration:\s*(\d+):(\d{2}):(\d{2})(?:\.(\d{1,3}))?/;
|
|
@@ -927,20 +985,12 @@ var ensureM4a = async (buffer, mimeType) => {
|
|
|
927
985
|
|
|
928
986
|
// src/providers/imessage/remote/send.ts
|
|
929
987
|
var GROUP_ITEM_ALLOWED = /* @__PURE__ */ new Set([
|
|
988
|
+
"text",
|
|
930
989
|
"attachment",
|
|
931
990
|
"contact",
|
|
932
991
|
"voice"
|
|
933
992
|
]);
|
|
934
|
-
var
|
|
935
|
-
cause;
|
|
936
|
-
groupMembers;
|
|
937
|
-
constructor(groupMembers, cause) {
|
|
938
|
-
super("iMessage group send failed after one or more items were sent");
|
|
939
|
-
this.name = "PartialGroupSendError";
|
|
940
|
-
this.cause = cause;
|
|
941
|
-
this.groupMembers = groupMembers;
|
|
942
|
-
}
|
|
943
|
-
};
|
|
993
|
+
var MAX_GROUP_TEXT_ITEMS = 1;
|
|
944
994
|
var toDate = (value) => {
|
|
945
995
|
if (value instanceof Date) {
|
|
946
996
|
return value;
|
|
@@ -951,17 +1001,22 @@ var toDate = (value) => {
|
|
|
951
1001
|
}
|
|
952
1002
|
};
|
|
953
1003
|
var receiptTimestamp = (receipt) => toDate(receipt.timestamp) ?? toDate(receipt.date) ?? toDate(receipt.dateCreated) ?? /* @__PURE__ */ new Date();
|
|
954
|
-
var
|
|
1004
|
+
var receiptGuid = (receipt) => {
|
|
955
1005
|
if (typeof receipt.guid !== "string" || receipt.guid.length === 0) {
|
|
956
1006
|
throw new Error("iMessage send receipt is missing a message guid");
|
|
957
1007
|
}
|
|
958
|
-
return
|
|
959
|
-
id: receipt.guid,
|
|
960
|
-
timestamp: receiptTimestamp(receipt)
|
|
961
|
-
};
|
|
1008
|
+
return receipt.guid;
|
|
962
1009
|
};
|
|
1010
|
+
var outboundRecord = (spaceId, id, content, timestamp, extras) => ({
|
|
1011
|
+
id,
|
|
1012
|
+
content,
|
|
1013
|
+
space: { id: spaceId },
|
|
1014
|
+
timestamp,
|
|
1015
|
+
...extras
|
|
1016
|
+
});
|
|
963
1017
|
var withReply = (options, replyTo) => replyTo ? { ...options, replyTo } : options;
|
|
964
1018
|
var replyOptions = (replyTo) => replyTo ? { replyTo } : void 0;
|
|
1019
|
+
var effectOption = (effect2) => effect2 ? { effect: effect2 } : {};
|
|
965
1020
|
var sendVCardAttachment = (remote, name, vcf) => remote.attachments.upload({
|
|
966
1021
|
data: Buffer.from(vcf, "utf8"),
|
|
967
1022
|
fileName: name,
|
|
@@ -969,8 +1024,9 @@ var sendVCardAttachment = (remote, name, vcf) => remote.attachments.upload({
|
|
|
969
1024
|
});
|
|
970
1025
|
var sendContactAttachment = async (remote, content) => {
|
|
971
1026
|
const vcf = await toVCard(content);
|
|
972
|
-
const
|
|
973
|
-
|
|
1027
|
+
const name = vcardFileName(content);
|
|
1028
|
+
const upload = await sendVCardAttachment(remote, name, vcf);
|
|
1029
|
+
return { guid: upload.guid, name };
|
|
974
1030
|
};
|
|
975
1031
|
var uploadAttachment = async (remote, content) => {
|
|
976
1032
|
const attachment = await remote.attachments.upload({
|
|
@@ -978,53 +1034,96 @@ var uploadAttachment = async (remote, content) => {
|
|
|
978
1034
|
fileName: content.name,
|
|
979
1035
|
mimeType: content.mimeType
|
|
980
1036
|
});
|
|
981
|
-
return attachment.guid;
|
|
1037
|
+
return { guid: attachment.guid, name: content.name };
|
|
982
1038
|
};
|
|
983
1039
|
var uploadVoice = async (remote, content) => {
|
|
984
1040
|
const { buffer } = await ensureM4a(await content.read(), content.mimeType);
|
|
1041
|
+
const name = content.name ?? "voice.m4a";
|
|
985
1042
|
const attachment = await remote.attachments.upload({
|
|
986
1043
|
data: buffer,
|
|
987
|
-
fileName:
|
|
1044
|
+
fileName: name,
|
|
988
1045
|
mimeType: "audio/x-m4a"
|
|
989
1046
|
});
|
|
990
|
-
return attachment.guid;
|
|
1047
|
+
return { guid: attachment.guid, name };
|
|
991
1048
|
};
|
|
992
|
-
var sendContent = async (remote, chat, content, replyTo) => {
|
|
1049
|
+
var sendContent = async (remote, spaceId, chat, content, replyTo, effect2) => {
|
|
993
1050
|
switch (content.type) {
|
|
994
|
-
case "
|
|
995
|
-
return
|
|
996
|
-
|
|
1051
|
+
case "effect":
|
|
1052
|
+
return sendContent(
|
|
1053
|
+
remote,
|
|
1054
|
+
spaceId,
|
|
1055
|
+
chat,
|
|
1056
|
+
content.content,
|
|
1057
|
+
replyTo,
|
|
1058
|
+
content.effect
|
|
997
1059
|
);
|
|
998
|
-
case "
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
withReply({ richLink: true }, replyTo)
|
|
1004
|
-
)
|
|
1060
|
+
case "text": {
|
|
1061
|
+
const receipt = await remote.messages.send(
|
|
1062
|
+
chat,
|
|
1063
|
+
content.text,
|
|
1064
|
+
withReply(effectOption(effect2), replyTo)
|
|
1005
1065
|
);
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
})
|
|
1066
|
+
return outboundRecord(
|
|
1067
|
+
spaceId,
|
|
1068
|
+
receiptGuid(receipt),
|
|
1069
|
+
content,
|
|
1070
|
+
receiptTimestamp(receipt)
|
|
1012
1071
|
);
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
})
|
|
1072
|
+
}
|
|
1073
|
+
case "richlink": {
|
|
1074
|
+
const receipt = await remote.messages.send(
|
|
1075
|
+
chat,
|
|
1076
|
+
content.url,
|
|
1077
|
+
withReply({ richLink: true }, replyTo)
|
|
1019
1078
|
);
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1079
|
+
return outboundRecord(
|
|
1080
|
+
spaceId,
|
|
1081
|
+
receiptGuid(receipt),
|
|
1082
|
+
content,
|
|
1083
|
+
receiptTimestamp(receipt)
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
case "attachment": {
|
|
1087
|
+
const { guid } = await uploadAttachment(remote, content);
|
|
1088
|
+
const receipt = await remote.messages.send(chat, "", {
|
|
1089
|
+
attachment: guid,
|
|
1090
|
+
...effectOption(effect2),
|
|
1091
|
+
...replyOptions(replyTo)
|
|
1092
|
+
});
|
|
1093
|
+
return outboundRecord(
|
|
1094
|
+
spaceId,
|
|
1095
|
+
receiptGuid(receipt),
|
|
1096
|
+
content,
|
|
1097
|
+
receiptTimestamp(receipt)
|
|
1027
1098
|
);
|
|
1099
|
+
}
|
|
1100
|
+
case "contact": {
|
|
1101
|
+
const { guid } = await sendContactAttachment(remote, content);
|
|
1102
|
+
const receipt = await remote.messages.send(chat, "", {
|
|
1103
|
+
attachment: guid,
|
|
1104
|
+
...replyOptions(replyTo)
|
|
1105
|
+
});
|
|
1106
|
+
return outboundRecord(
|
|
1107
|
+
spaceId,
|
|
1108
|
+
receiptGuid(receipt),
|
|
1109
|
+
content,
|
|
1110
|
+
receiptTimestamp(receipt)
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
case "voice": {
|
|
1114
|
+
const { guid } = await uploadVoice(remote, content);
|
|
1115
|
+
const receipt = await remote.messages.send(chat, "", {
|
|
1116
|
+
attachment: guid,
|
|
1117
|
+
audioMessage: true,
|
|
1118
|
+
...replyOptions(replyTo)
|
|
1119
|
+
});
|
|
1120
|
+
return outboundRecord(
|
|
1121
|
+
spaceId,
|
|
1122
|
+
receiptGuid(receipt),
|
|
1123
|
+
content,
|
|
1124
|
+
receiptTimestamp(receipt)
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1028
1127
|
case "poll":
|
|
1029
1128
|
if (replyTo) {
|
|
1030
1129
|
throw unsupportedRemoteContent(
|
|
@@ -1032,18 +1131,24 @@ var sendContent = async (remote, chat, content, replyTo) => {
|
|
|
1032
1131
|
"polls cannot be sent as replies"
|
|
1033
1132
|
);
|
|
1034
1133
|
}
|
|
1035
|
-
return
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1134
|
+
return outboundRecord(
|
|
1135
|
+
spaceId,
|
|
1136
|
+
receiptGuid(
|
|
1137
|
+
await remote.polls.create(
|
|
1138
|
+
chat,
|
|
1139
|
+
content.title,
|
|
1140
|
+
content.options.map((option) => option.title)
|
|
1141
|
+
)
|
|
1142
|
+
),
|
|
1143
|
+
content,
|
|
1144
|
+
/* @__PURE__ */ new Date()
|
|
1041
1145
|
);
|
|
1042
1146
|
default:
|
|
1043
1147
|
throw unsupportedRemoteContent(content.type);
|
|
1044
1148
|
}
|
|
1045
1149
|
};
|
|
1046
1150
|
var validateGroupContent = (content) => {
|
|
1151
|
+
let textCount = 0;
|
|
1047
1152
|
for (const sub of content.items) {
|
|
1048
1153
|
const itemType = sub.content.type;
|
|
1049
1154
|
if (!GROUP_ITEM_ALLOWED.has(itemType)) {
|
|
@@ -1052,32 +1157,69 @@ var validateGroupContent = (content) => {
|
|
|
1052
1157
|
`"${itemType}" items are not supported inside a group`
|
|
1053
1158
|
);
|
|
1054
1159
|
}
|
|
1160
|
+
if (itemType === "text" && ++textCount > MAX_GROUP_TEXT_ITEMS) {
|
|
1161
|
+
throw unsupportedRemoteContent(
|
|
1162
|
+
"group",
|
|
1163
|
+
`groups can contain at most ${MAX_GROUP_TEXT_ITEMS} text item`
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
var resolvePart = async (remote, content) => {
|
|
1169
|
+
switch (content.type) {
|
|
1170
|
+
case "text":
|
|
1171
|
+
return { text: content.text };
|
|
1172
|
+
case "attachment": {
|
|
1173
|
+
const { guid, name } = await uploadAttachment(remote, content);
|
|
1174
|
+
return { attachmentGuid: guid, attachmentName: name };
|
|
1175
|
+
}
|
|
1176
|
+
case "contact": {
|
|
1177
|
+
const { guid, name } = await sendContactAttachment(remote, content);
|
|
1178
|
+
return { attachmentGuid: guid, attachmentName: name };
|
|
1179
|
+
}
|
|
1180
|
+
case "voice": {
|
|
1181
|
+
const { guid, name } = await uploadVoice(remote, content);
|
|
1182
|
+
return { attachmentGuid: guid, attachmentName: name };
|
|
1183
|
+
}
|
|
1184
|
+
default:
|
|
1185
|
+
throw unsupportedRemoteContent(content.type);
|
|
1055
1186
|
}
|
|
1056
1187
|
};
|
|
1057
1188
|
var send3 = async (remote, spaceId, content) => {
|
|
1058
1189
|
const chat = chatGuid2(spaceId);
|
|
1059
1190
|
if (content.type === "group") {
|
|
1060
1191
|
validateGroupContent(content);
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1192
|
+
const resolved = await Promise.all(
|
|
1193
|
+
content.items.map((sub) => resolvePart(remote, sub.content))
|
|
1194
|
+
);
|
|
1195
|
+
const receipt = await remote.messages.sendMultipart(
|
|
1196
|
+
chat,
|
|
1197
|
+
resolved.map((part, idx) => ({ ...part, partIndex: idx }))
|
|
1198
|
+
);
|
|
1199
|
+
const parentGuid = receiptGuid(receipt);
|
|
1200
|
+
const timestamp = receiptTimestamp(receipt);
|
|
1201
|
+
const items = content.items.map(
|
|
1202
|
+
(sub, idx) => outboundRecord(
|
|
1203
|
+
spaceId,
|
|
1204
|
+
formatChildId(idx, parentGuid),
|
|
1205
|
+
sub.content,
|
|
1206
|
+
timestamp,
|
|
1207
|
+
{ partIndex: idx, parentId: parentGuid }
|
|
1208
|
+
)
|
|
1209
|
+
);
|
|
1210
|
+
return outboundRecord(
|
|
1211
|
+
spaceId,
|
|
1212
|
+
parentGuid,
|
|
1213
|
+
asGroup({ items }),
|
|
1214
|
+
timestamp
|
|
1215
|
+
);
|
|
1074
1216
|
}
|
|
1075
|
-
return sendContent(remote, chat, content);
|
|
1217
|
+
return sendContent(remote, spaceId, chat, content);
|
|
1076
1218
|
};
|
|
1077
1219
|
var replyToMessage = async (remote, spaceId, msgId, content) => {
|
|
1078
1220
|
const chat = chatGuid2(spaceId);
|
|
1079
1221
|
const replyTo = messageGuid3(msgId);
|
|
1080
|
-
return sendContent(remote, chat, content, replyTo);
|
|
1222
|
+
return sendContent(remote, spaceId, chat, content, replyTo);
|
|
1081
1223
|
};
|
|
1082
1224
|
var editMessage = async (remote, spaceId, msgId, content) => {
|
|
1083
1225
|
if (content.type !== "text") {
|
|
@@ -1686,30 +1828,35 @@ var getMessage4 = async (clients, spaceId, msgId) => {
|
|
|
1686
1828
|
|
|
1687
1829
|
// src/providers/imessage/types.ts
|
|
1688
1830
|
import { IMessageSDK } from "@photon-ai/imessage-kit";
|
|
1689
|
-
import
|
|
1831
|
+
import z2 from "zod";
|
|
1690
1832
|
var isLocal = (client) => client instanceof IMessageSDK;
|
|
1691
|
-
var clientEntry =
|
|
1692
|
-
var configSchema =
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
local:
|
|
1696
|
-
clients: clientEntry.or(
|
|
1833
|
+
var clientEntry = z2.object({ address: z2.string(), token: z2.string() });
|
|
1834
|
+
var configSchema = z2.union([
|
|
1835
|
+
z2.object({ local: z2.literal(true) }),
|
|
1836
|
+
z2.object({
|
|
1837
|
+
local: z2.literal(false).optional().default(false),
|
|
1838
|
+
clients: clientEntry.or(z2.array(clientEntry)).optional()
|
|
1697
1839
|
})
|
|
1698
1840
|
]);
|
|
1699
|
-
var userSchema =
|
|
1700
|
-
var spaceSchema =
|
|
1701
|
-
id:
|
|
1702
|
-
type:
|
|
1841
|
+
var userSchema = z2.object({});
|
|
1842
|
+
var spaceSchema = z2.object({
|
|
1843
|
+
id: z2.string(),
|
|
1844
|
+
type: z2.enum(["dm", "group"])
|
|
1703
1845
|
});
|
|
1704
|
-
var messageSchema =
|
|
1705
|
-
partIndex:
|
|
1706
|
-
parentId:
|
|
1846
|
+
var messageSchema = z2.object({
|
|
1847
|
+
partIndex: z2.number().int().nonnegative().optional(),
|
|
1848
|
+
parentId: z2.string().optional()
|
|
1707
1849
|
});
|
|
1708
1850
|
|
|
1709
1851
|
// src/providers/imessage/index.ts
|
|
1710
1852
|
var isPollContent = (content) => content.type === "poll" || content.type === "poll_option";
|
|
1711
1853
|
var imessage = definePlatform("iMessage", {
|
|
1712
1854
|
config: configSchema,
|
|
1855
|
+
static: {
|
|
1856
|
+
effect: {
|
|
1857
|
+
message: MessageEffect2
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1713
1860
|
user: {
|
|
1714
1861
|
resolve: async ({ input }) => ({ id: input.userID })
|
|
1715
1862
|
},
|
|
@@ -1843,5 +1990,6 @@ var imessage = definePlatform("iMessage", {
|
|
|
1843
1990
|
}
|
|
1844
1991
|
});
|
|
1845
1992
|
export {
|
|
1993
|
+
effect,
|
|
1846
1994
|
imessage
|
|
1847
1995
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Platform, c as PlatformDef, P as ProviderMessage, M as Message } from '../../types-
|
|
1
|
+
import { d as Platform, c as PlatformDef, P as ProviderMessage, M as Message } from '../../types-Dvp0I86h.js';
|
|
2
2
|
import z__default from 'zod';
|
|
3
3
|
import 'hotscript';
|
|
4
4
|
|
|
@@ -42,9 +42,6 @@ declare const terminal: Platform<PlatformDef<"terminal", z__default.ZodObject<{
|
|
|
42
42
|
content: {
|
|
43
43
|
type: "text";
|
|
44
44
|
text: string;
|
|
45
|
-
} | {
|
|
46
|
-
type: "custom";
|
|
47
|
-
raw: unknown;
|
|
48
45
|
} | {
|
|
49
46
|
type: "attachment";
|
|
50
47
|
name: string;
|
|
@@ -52,6 +49,9 @@ declare const terminal: Platform<PlatformDef<"terminal", z__default.ZodObject<{
|
|
|
52
49
|
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
53
50
|
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
54
51
|
size?: number | undefined;
|
|
52
|
+
} | {
|
|
53
|
+
type: "custom";
|
|
54
|
+
raw: unknown;
|
|
55
55
|
} | {
|
|
56
56
|
type: "contact";
|
|
57
57
|
user?: {
|
|
@@ -140,6 +140,20 @@ declare const terminal: Platform<PlatformDef<"terminal", z__default.ZodObject<{
|
|
|
140
140
|
};
|
|
141
141
|
selected: boolean;
|
|
142
142
|
title: string;
|
|
143
|
+
} | {
|
|
144
|
+
type: "effect";
|
|
145
|
+
content: {
|
|
146
|
+
type: "text";
|
|
147
|
+
text: string;
|
|
148
|
+
} | {
|
|
149
|
+
type: "attachment";
|
|
150
|
+
name: string;
|
|
151
|
+
mimeType: string;
|
|
152
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
153
|
+
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
154
|
+
size?: number | undefined;
|
|
155
|
+
};
|
|
156
|
+
effect: string;
|
|
143
157
|
};
|
|
144
158
|
sender: {
|
|
145
159
|
id: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
asVoice
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-I7EKZS5C.js";
|
|
4
4
|
import {
|
|
5
5
|
UnsupportedError,
|
|
6
6
|
asAttachment,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
fromVCard,
|
|
11
11
|
reactionSchema,
|
|
12
12
|
toVCard
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-UQPIWAHH.js";
|
|
14
14
|
|
|
15
15
|
// src/providers/terminal/index.ts
|
|
16
16
|
import { spawn } from "child_process";
|
|
@@ -601,6 +601,14 @@ function parseTimestamp(s) {
|
|
|
601
601
|
const t = Date.parse(s);
|
|
602
602
|
return Number.isNaN(t) ? /* @__PURE__ */ new Date() : new Date(t);
|
|
603
603
|
}
|
|
604
|
+
function buildOutboundRecord(result, content, spaceId) {
|
|
605
|
+
return {
|
|
606
|
+
id: result.id,
|
|
607
|
+
content,
|
|
608
|
+
space: { id: spaceId },
|
|
609
|
+
timestamp: parseTimestamp(result.timestamp)
|
|
610
|
+
};
|
|
611
|
+
}
|
|
604
612
|
function reactionTargetFromProtocol(reaction) {
|
|
605
613
|
const target = {
|
|
606
614
|
id: reaction.messageId,
|
|
@@ -810,7 +818,7 @@ var terminal = definePlatform("terminal", {
|
|
|
810
818
|
"send",
|
|
811
819
|
{ spaceId: space.id, content: proto }
|
|
812
820
|
);
|
|
813
|
-
return
|
|
821
|
+
return buildOutboundRecord(result, content, space.id);
|
|
814
822
|
},
|
|
815
823
|
startTyping: async ({ client, space }) => {
|
|
816
824
|
const c = client;
|
|
@@ -835,7 +843,7 @@ var terminal = definePlatform("terminal", {
|
|
|
835
843
|
"replyToMessage",
|
|
836
844
|
{ spaceId: space.id, messageId, content: proto }
|
|
837
845
|
);
|
|
838
|
-
return
|
|
846
|
+
return buildOutboundRecord(result, content, space.id);
|
|
839
847
|
}
|
|
840
848
|
}
|
|
841
849
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage, i as ManagedStream } from '../../types-Dvp0I86h.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-BZhWdyLk.js';
|
|
6
5
|
import * as zod_v4_core from 'zod/v4/core';
|
|
7
6
|
import 'hotscript';
|
|
8
7
|
|