spectrum-ts 3.0.0 → 4.0.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.
Files changed (32) hide show
  1. package/dist/{attachment-WePAHfcH.d.ts → attachment-CEpGtZLm.d.ts} +1 -1
  2. package/dist/{authoring-DDh3muGT.d.ts → authoring-CP3vRza8.d.ts} +2 -2
  3. package/dist/authoring.d.ts +3 -3
  4. package/dist/authoring.js +5 -5
  5. package/dist/{chunk-TXRWKSNH.js → chunk-57NECZQZ.js} +4 -4
  6. package/dist/{chunk-UXJ5OO6P.js → chunk-5VCWWPFW.js} +3 -3
  7. package/dist/{chunk-NZ5WCMTY.js → chunk-A37PM5N2.js} +1 -1
  8. package/dist/{chunk-77U6SH5A.js → chunk-FAIFTUV2.js} +1 -1
  9. package/dist/{chunk-MHGCPC2V.js → chunk-LZXPLXZF.js} +1 -1
  10. package/dist/{chunk-LX437ZTY.js → chunk-OGTHPDG7.js} +10 -3
  11. package/dist/{chunk-EZ5SNNFS.js → chunk-PV4AVMNN.js} +4 -4
  12. package/dist/{chunk-LQMDV75O.js → chunk-UXAKIXVM.js} +0 -45
  13. package/dist/{chunk-FULEQIRQ.js → chunk-VEF6FUE7.js} +2 -2
  14. package/dist/{chunk-AYCMTRVC.js → chunk-W5HNZ7YT.js} +133 -89
  15. package/dist/{chunk-CHY5YLLV.js → chunk-ZR3TKZMT.js} +1 -1
  16. package/dist/index.d.ts +7 -7
  17. package/dist/index.js +368 -25272
  18. package/dist/providers/imessage/index.d.ts +3 -2
  19. package/dist/providers/imessage/index.js +6 -6
  20. package/dist/providers/index.d.ts +3 -3
  21. package/dist/providers/index.js +11 -11
  22. package/dist/providers/slack/index.d.ts +1 -1
  23. package/dist/providers/slack/index.js +3 -3
  24. package/dist/providers/telegram/index.d.ts +2 -2
  25. package/dist/providers/telegram/index.js +5 -5
  26. package/dist/providers/terminal/index.d.ts +1 -1
  27. package/dist/providers/terminal/index.js +5 -5
  28. package/dist/providers/whatsapp-business/index.d.ts +1 -1
  29. package/dist/providers/whatsapp-business/index.js +4 -4
  30. package/dist/{types-YqCNUDIt.d.ts → types-Be0T6E0e.d.ts} +1 -0
  31. package/dist/{types-BujGKBin.d.ts → types-CDYXH2R7.d.ts} +1 -1
  32. package/package.json +1 -4
@@ -1,5 +1,5 @@
1
1
  import z__default from 'zod';
2
- import { C as ContentBuilder } from './types-YqCNUDIt.js';
2
+ import { C as ContentBuilder } from './types-Be0T6E0e.js';
3
3
 
4
4
  declare const attachmentSchema: z__default.ZodObject<{
5
5
  type: z__default.ZodLiteral<"attachment">;
@@ -1,7 +1,7 @@
1
- import './attachment-WePAHfcH.js';
1
+ import './attachment-CEpGtZLm.js';
2
2
  import vCard from 'vcf';
3
3
  import z__default from 'zod';
4
- import { U as User, C as ContentBuilder, M as Message, e as Space, h as ContentInput } from './types-YqCNUDIt.js';
4
+ import { U as User, C as ContentBuilder, M as Message, e as Space, h as ContentInput } from './types-Be0T6E0e.js';
5
5
 
6
6
  declare const nameSchema: z__default.ZodObject<{
7
7
  formatted: z__default.ZodOptional<z__default.ZodString>;
@@ -1,6 +1,6 @@
1
- export { c as asAttachment } from './attachment-WePAHfcH.js';
2
- export { q as asContact, s as asCustom, u as asGroup, w as asPoll, x as asPollOption, y as asRichlink, z as asText, A as asVoice } from './authoring-DDh3muGT.js';
3
- export { d as ProviderMessageRecord, $ as asReaction } from './types-YqCNUDIt.js';
1
+ export { c as asAttachment } from './attachment-CEpGtZLm.js';
2
+ export { q as asContact, s as asCustom, u as asGroup, w as asPoll, x as asPollOption, y as asRichlink, z as asText, A as asVoice } from './authoring-CP3vRza8.js';
3
+ export { d as ProviderMessageRecord, $ as asReaction } from './types-Be0T6E0e.js';
4
4
  import 'zod';
5
5
  import 'vcf';
6
6
  import 'hotscript';
package/dist/authoring.js CHANGED
@@ -1,27 +1,27 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  asRichlink
4
- } from "./chunk-CHY5YLLV.js";
4
+ } from "./chunk-ZR3TKZMT.js";
5
5
  import {
6
6
  asGroup
7
- } from "./chunk-MHGCPC2V.js";
7
+ } from "./chunk-LZXPLXZF.js";
8
8
  import {
9
9
  asVoice
10
- } from "./chunk-77U6SH5A.js";
10
+ } from "./chunk-FAIFTUV2.js";
11
11
  import {
12
12
  asPoll,
13
13
  asPollOption
14
14
  } from "./chunk-2D27WW5B.js";
15
15
  import {
16
16
  asContact
17
- } from "./chunk-NZ5WCMTY.js";
17
+ } from "./chunk-A37PM5N2.js";
18
18
  import "./chunk-6UZFVXQF.js";
19
19
  import {
20
20
  asAttachment,
21
21
  asCustom,
22
22
  asReaction,
23
23
  asText
24
- } from "./chunk-LQMDV75O.js";
24
+ } from "./chunk-UXAKIXVM.js";
25
25
  export {
26
26
  asAttachment,
27
27
  asContact,
@@ -4,10 +4,10 @@ import {
4
4
  } from "./chunk-34FQGGD7.js";
5
5
  import {
6
6
  asGroup
7
- } from "./chunk-MHGCPC2V.js";
7
+ } from "./chunk-LZXPLXZF.js";
8
8
  import {
9
9
  asVoice
10
- } from "./chunk-77U6SH5A.js";
10
+ } from "./chunk-FAIFTUV2.js";
11
11
  import {
12
12
  toVCard
13
13
  } from "./chunk-6UZFVXQF.js";
@@ -16,13 +16,13 @@ import {
16
16
  asMarkdown,
17
17
  definePlatform,
18
18
  renderInlineTokens
19
- } from "./chunk-LX437ZTY.js";
19
+ } from "./chunk-OGTHPDG7.js";
20
20
  import {
21
21
  asAttachment,
22
22
  asCustom,
23
23
  asReaction,
24
24
  asText
25
- } from "./chunk-LQMDV75O.js";
25
+ } from "./chunk-UXAKIXVM.js";
26
26
 
27
27
  // src/providers/telegram/config.ts
28
28
  import z from "zod";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-3GEJYGZK.js";
8
8
  import {
9
9
  asContact
10
- } from "./chunk-NZ5WCMTY.js";
10
+ } from "./chunk-A37PM5N2.js";
11
11
  import {
12
12
  mergeStreams,
13
13
  stream
@@ -15,13 +15,13 @@ import {
15
15
  import {
16
16
  UnsupportedError,
17
17
  definePlatform
18
- } from "./chunk-LX437ZTY.js";
18
+ } from "./chunk-OGTHPDG7.js";
19
19
  import {
20
20
  asAttachment,
21
21
  asCustom,
22
22
  asReaction,
23
23
  asText
24
- } from "./chunk-LQMDV75O.js";
24
+ } from "./chunk-UXAKIXVM.js";
25
25
 
26
26
  // src/providers/whatsapp-business/index.ts
27
27
  import { createClient as createClient2 } from "@photon-ai/whatsapp-business";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-6UZFVXQF.js";
5
5
  import {
6
6
  readSchema
7
- } from "./chunk-LQMDV75O.js";
7
+ } from "./chunk-UXAKIXVM.js";
8
8
 
9
9
  // src/content/contact.ts
10
10
  import vCard from "vcf";
@@ -4,7 +4,7 @@ import {
4
4
  fetchUrlBytes,
5
5
  readSchema,
6
6
  streamSchema
7
- } from "./chunk-LQMDV75O.js";
7
+ } from "./chunk-UXAKIXVM.js";
8
8
 
9
9
  // src/content/voice.ts
10
10
  import { createReadStream } from "fs";
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  resolveContents
4
- } from "./chunk-LQMDV75O.js";
4
+ } from "./chunk-UXAKIXVM.js";
5
5
 
6
6
  // src/content/group.ts
7
7
  import z from "zod";
@@ -8,7 +8,7 @@ import {
8
8
  readSchema,
9
9
  resolveContents,
10
10
  streamTextBuilder
11
- } from "./chunk-LQMDV75O.js";
11
+ } from "./chunk-UXAKIXVM.js";
12
12
 
13
13
  // src/content/avatar.ts
14
14
  import z2 from "zod";
@@ -742,6 +742,7 @@ async function sendWithFallbacks(send, item, platform) {
742
742
  }
743
743
  var providerMessageCoreKeys = /* @__PURE__ */ new Set([
744
744
  "content",
745
+ "direction",
745
746
  "id",
746
747
  "sender",
747
748
  "space",
@@ -754,8 +755,14 @@ var extractExtras = (raw, definition) => {
754
755
  const extra = Object.fromEntries(entries);
755
756
  return definition.message?.schema ? definition.message.schema.parse(extra) : extra;
756
757
  };
758
+ var rawDirection = (raw) => raw.direction === "inbound" || raw.direction === "outbound" ? raw.direction : void 0;
757
759
  function wrapProviderMessage(raw, ctx, direction) {
758
- const wrappedContent = wrapNestedContent(raw.content, ctx, direction);
760
+ const effectiveDirection = rawDirection(raw) ?? direction;
761
+ const wrappedContent = wrapNestedContent(
762
+ raw.content,
763
+ ctx,
764
+ effectiveDirection
765
+ );
759
766
  const base = {
760
767
  id: raw.id,
761
768
  content: wrappedContent,
@@ -768,7 +775,7 @@ function wrapProviderMessage(raw, ctx, direction) {
768
775
  config: ctx.config,
769
776
  store: ctx.store
770
777
  };
771
- if (direction === "inbound") {
778
+ if (effectiveDirection === "inbound") {
772
779
  return buildMessage({ ...base, sender: raw.sender, direction: "inbound" });
773
780
  }
774
781
  return buildMessage({ ...base, sender: raw.sender, direction: "outbound" });
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  asVoice
4
- } from "./chunk-77U6SH5A.js";
4
+ } from "./chunk-FAIFTUV2.js";
5
5
  import {
6
6
  asContact
7
- } from "./chunk-NZ5WCMTY.js";
7
+ } from "./chunk-A37PM5N2.js";
8
8
  import {
9
9
  stream
10
10
  } from "./chunk-5XEFJBN2.js";
@@ -15,12 +15,12 @@ import {
15
15
  import {
16
16
  UnsupportedError,
17
17
  definePlatform
18
- } from "./chunk-LX437ZTY.js";
18
+ } from "./chunk-OGTHPDG7.js";
19
19
  import {
20
20
  asAttachment,
21
21
  asCustom,
22
22
  reactionSchema
23
- } from "./chunk-LQMDV75O.js";
23
+ } from "./chunk-UXAKIXVM.js";
24
24
 
25
25
  // src/providers/terminal/index.ts
26
26
  import { spawn } from "child_process";
@@ -1,43 +1,4 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
- var __esm = (fn, res) => function __init() {
15
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
- };
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
- var __export = (target, all) => {
21
- for (var name in all)
22
- __defProp(target, name, { get: all[name], enumerable: true });
23
- };
24
- var __copyProps = (to, from, except, desc) => {
25
- if (from && typeof from === "object" || typeof from === "function") {
26
- for (let key of __getOwnPropNames(from))
27
- if (!__hasOwnProp.call(to, key) && key !== except)
28
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
- }
30
- return to;
31
- };
32
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
- // If the importer is in node compatibility mode or this is not an ESM
34
- // file that has been converted to a CommonJS file using a Babel-
35
- // compatible transform (i.e. "__esModule" has not been set), then set
36
- // "default" to the CommonJS "module.exports" for node compatibility.
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
- mod
39
- ));
40
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
2
 
42
3
  // src/content/attachment.ts
43
4
  import { randomUUID } from "crypto";
@@ -426,12 +387,6 @@ function reaction(emoji, target) {
426
387
  }
427
388
 
428
389
  export {
429
- __require,
430
- __esm,
431
- __commonJS,
432
- __export,
433
- __toESM,
434
- __toCommonJS,
435
390
  readSchema,
436
391
  streamSchema,
437
392
  bufferToStream,
@@ -9,13 +9,13 @@ import {
9
9
  import {
10
10
  UnsupportedError,
11
11
  definePlatform
12
- } from "./chunk-LX437ZTY.js";
12
+ } from "./chunk-OGTHPDG7.js";
13
13
  import {
14
14
  asAttachment,
15
15
  asCustom,
16
16
  asReaction,
17
17
  asText
18
- } from "./chunk-LQMDV75O.js";
18
+ } from "./chunk-UXAKIXVM.js";
19
19
 
20
20
  // src/providers/slack/index.ts
21
21
  import { createClient as createClient2, staticTokens } from "@photon-ai/slack";
@@ -1,11 +1,11 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  asRichlink
4
- } from "./chunk-CHY5YLLV.js";
4
+ } from "./chunk-ZR3TKZMT.js";
5
5
  import {
6
6
  asGroup,
7
7
  groupSchema
8
- } from "./chunk-MHGCPC2V.js";
8
+ } from "./chunk-LZXPLXZF.js";
9
9
  import {
10
10
  asPoll,
11
11
  asPollOption
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-3GEJYGZK.js";
16
16
  import {
17
17
  asContact
18
- } from "./chunk-NZ5WCMTY.js";
18
+ } from "./chunk-A37PM5N2.js";
19
19
  import {
20
20
  mergeStreams,
21
21
  stream
@@ -30,7 +30,7 @@ import {
30
30
  definePlatform,
31
31
  markdownSchema,
32
32
  photoActionSchema
33
- } from "./chunk-LX437ZTY.js";
33
+ } from "./chunk-OGTHPDG7.js";
34
34
  import {
35
35
  asAttachment,
36
36
  asCustom,
@@ -39,10 +39,13 @@ import {
39
39
  reactionSchema,
40
40
  text,
41
41
  textSchema
42
- } from "./chunk-LQMDV75O.js";
42
+ } from "./chunk-UXAKIXVM.js";
43
43
 
44
44
  // src/providers/imessage/index.ts
45
- import { createClient as createClient2, MessageEffect as MessageEffect2 } from "@photon-ai/advanced-imessage";
45
+ import {
46
+ createClient as createClient2,
47
+ MessageEffect as MessageEffect2
48
+ } from "@photon-ai/advanced-imessage";
46
49
  import { IMessageSDK as IMessageSDK2 } from "@photon-ai/imessage-kit";
47
50
  import { withSpan } from "@photon-ai/otel";
48
51
 
@@ -351,6 +354,77 @@ async function disposeCloudAuth(clients) {
351
354
  }
352
355
  }
353
356
 
357
+ // src/providers/imessage/cache.ts
358
+ var DEFAULT_MAX = 1e3;
359
+ var MessageCache = class {
360
+ map = /* @__PURE__ */ new Map();
361
+ max;
362
+ constructor(max = DEFAULT_MAX) {
363
+ this.max = max;
364
+ }
365
+ get(id) {
366
+ return this.map.get(id);
367
+ }
368
+ set(id, message) {
369
+ if (this.map.has(id)) {
370
+ this.map.delete(id);
371
+ }
372
+ this.map.set(id, message);
373
+ if (this.map.size > this.max) {
374
+ const first = this.map.keys().next().value;
375
+ if (first !== void 0) {
376
+ this.map.delete(first);
377
+ }
378
+ }
379
+ }
380
+ clear() {
381
+ this.map.clear();
382
+ }
383
+ };
384
+ var PollCache = class {
385
+ map = /* @__PURE__ */ new Map();
386
+ max;
387
+ constructor(max = DEFAULT_MAX) {
388
+ this.max = max;
389
+ }
390
+ get(id) {
391
+ return this.map.get(id);
392
+ }
393
+ set(id, poll) {
394
+ if (this.map.has(id)) {
395
+ this.map.delete(id);
396
+ }
397
+ this.map.set(id, poll);
398
+ if (this.map.size > this.max) {
399
+ const first = this.map.keys().next().value;
400
+ if (first !== void 0) {
401
+ this.map.delete(first);
402
+ }
403
+ }
404
+ }
405
+ clear() {
406
+ this.map.clear();
407
+ }
408
+ };
409
+ var messageCaches = /* @__PURE__ */ new WeakMap();
410
+ var pollCaches = /* @__PURE__ */ new WeakMap();
411
+ var getMessageCache = (owner) => {
412
+ let cache = messageCaches.get(owner);
413
+ if (!cache) {
414
+ cache = new MessageCache();
415
+ messageCaches.set(owner, cache);
416
+ }
417
+ return cache;
418
+ };
419
+ var getPollCache = (owner) => {
420
+ let cache = pollCaches.get(owner);
421
+ if (!cache) {
422
+ cache = new PollCache();
423
+ pollCaches.set(owner, cache);
424
+ }
425
+ return cache;
426
+ };
427
+
354
428
  // src/providers/imessage/local/inbound.ts
355
429
  import { setTimeout as sleep } from "timers/promises";
356
430
 
@@ -623,6 +697,7 @@ var sendCustomizedMiniApp = async (remote, spaceId, content) => {
623
697
  return {
624
698
  id: message.guid,
625
699
  content,
700
+ direction: "outbound",
626
701
  space: { id: spaceId },
627
702
  timestamp: message.dateCreated
628
703
  };
@@ -633,77 +708,6 @@ import {
633
708
  NotFoundError as NotFoundError2
634
709
  } from "@photon-ai/advanced-imessage";
635
710
 
636
- // src/providers/imessage/cache.ts
637
- var DEFAULT_MAX = 1e3;
638
- var MessageCache = class {
639
- map = /* @__PURE__ */ new Map();
640
- max;
641
- constructor(max = DEFAULT_MAX) {
642
- this.max = max;
643
- }
644
- get(id) {
645
- return this.map.get(id);
646
- }
647
- set(id, message) {
648
- if (this.map.has(id)) {
649
- this.map.delete(id);
650
- }
651
- this.map.set(id, message);
652
- if (this.map.size > this.max) {
653
- const first = this.map.keys().next().value;
654
- if (first !== void 0) {
655
- this.map.delete(first);
656
- }
657
- }
658
- }
659
- clear() {
660
- this.map.clear();
661
- }
662
- };
663
- var PollCache = class {
664
- map = /* @__PURE__ */ new Map();
665
- max;
666
- constructor(max = DEFAULT_MAX) {
667
- this.max = max;
668
- }
669
- get(id) {
670
- return this.map.get(id);
671
- }
672
- set(id, poll) {
673
- if (this.map.has(id)) {
674
- this.map.delete(id);
675
- }
676
- this.map.set(id, poll);
677
- if (this.map.size > this.max) {
678
- const first = this.map.keys().next().value;
679
- if (first !== void 0) {
680
- this.map.delete(first);
681
- }
682
- }
683
- }
684
- clear() {
685
- this.map.clear();
686
- }
687
- };
688
- var messageCaches = /* @__PURE__ */ new WeakMap();
689
- var pollCaches = /* @__PURE__ */ new WeakMap();
690
- var getMessageCache = (owner) => {
691
- let cache = messageCaches.get(owner);
692
- if (!cache) {
693
- cache = new MessageCache();
694
- messageCaches.set(owner, cache);
695
- }
696
- return cache;
697
- };
698
- var getPollCache = (owner) => {
699
- let cache = pollCaches.get(owner);
700
- if (!cache) {
701
- cache = new PollCache();
702
- pollCaches.set(owner, cache);
703
- }
704
- return cache;
705
- };
706
-
707
711
  // src/providers/imessage/remote/attachments.ts
708
712
  import {
709
713
  NotFoundError
@@ -799,12 +803,13 @@ var isIMessageMessage = (value) => {
799
803
  return false;
800
804
  }
801
805
  const record = value;
802
- return typeof record.id === "string" && record.id.length > 0 && typeof record.content === "object" && record.content !== null && typeof record.sender === "object" && record.sender !== null && typeof record.space === "object" && record.space !== null;
806
+ return typeof record.id === "string" && record.id.length > 0 && typeof record.content === "object" && record.content !== null && typeof record.space === "object" && record.space !== null;
803
807
  };
804
808
  var asProviderGroup = (items) => groupSchema.parse({ type: "group", items });
805
809
  var buildMessageBase = (message, chatGuidHint, timestamp, phone) => {
806
810
  const chat = resolveChatGuid(message, chatGuidHint);
807
811
  return {
812
+ direction: message.isFromMe ? "outbound" : "inbound",
808
813
  sender: { id: resolveSenderId(message) },
809
814
  space: {
810
815
  id: chat,
@@ -1122,6 +1127,7 @@ var reactToMessage = async (remote, spaceId, target, reaction) => {
1122
1127
  return {
1123
1128
  id: sent.guid,
1124
1129
  content: asProviderReaction(reaction, target),
1130
+ direction: "outbound",
1125
1131
  space: { id: spaceId },
1126
1132
  timestamp: sent.dateCreated
1127
1133
  };
@@ -1582,6 +1588,7 @@ var MAX_GROUP_TEXT_ITEMS = 1;
1582
1588
  var outboundRecord = (spaceId, id, content, timestamp, extras) => ({
1583
1589
  id,
1584
1590
  content,
1591
+ direction: "outbound",
1585
1592
  space: { id: spaceId },
1586
1593
  timestamp,
1587
1594
  ...extras
@@ -2501,6 +2508,7 @@ var sendStreamText = async (remote, spaceId, content) => {
2501
2508
  return {
2502
2509
  id: sent.guid,
2503
2510
  content: asText(full),
2511
+ direction: "outbound",
2504
2512
  space: { id: spaceId },
2505
2513
  timestamp: sent.dateCreated
2506
2514
  };
@@ -2574,6 +2582,22 @@ var randomPhone = (clients) => {
2574
2582
 
2575
2583
  // src/providers/imessage/index.ts
2576
2584
  var isPollContent = (content) => content.type === "poll" || content.type === "poll_option";
2585
+ var cacheRemoteOutbound = (remote, space, record) => {
2586
+ if (!record) {
2587
+ return record;
2588
+ }
2589
+ cacheMessage(getMessageCache(remote), {
2590
+ ...record,
2591
+ direction: record.direction ?? "outbound",
2592
+ space: {
2593
+ ...record.space,
2594
+ id: record.space.id,
2595
+ phone: space.phone,
2596
+ type: space.type
2597
+ }
2598
+ });
2599
+ return record;
2600
+ };
2577
2601
  var handleEdit = async (client, space, content) => {
2578
2602
  if (isLocal(client)) {
2579
2603
  throw UnsupportedError.action("edit", "iMessage (local mode)");
@@ -2621,7 +2645,11 @@ var handleStreamText = async (client, space, content) => {
2621
2645
  );
2622
2646
  }
2623
2647
  const remote = clientForPhone(client, space.phone);
2624
- return await sendStreamText2(remote, space.id, content);
2648
+ return cacheRemoteOutbound(
2649
+ remote,
2650
+ space,
2651
+ await sendStreamText2(remote, space.id, content)
2652
+ );
2625
2653
  };
2626
2654
  var handleBackground = async (client, space, content) => {
2627
2655
  if (isLocal(client)) {
@@ -2643,7 +2671,11 @@ var handleCustomizedMiniApp = async (client, space, content) => {
2643
2671
  );
2644
2672
  }
2645
2673
  const remote = clientForPhone(client, space.phone);
2646
- return await sendCustomizedMiniApp2(remote, space.id, content);
2674
+ return cacheRemoteOutbound(
2675
+ remote,
2676
+ space,
2677
+ await sendCustomizedMiniApp2(remote, space.id, content)
2678
+ );
2647
2679
  };
2648
2680
  var handleRead = async (client, space) => {
2649
2681
  if (isLocal(client)) {
@@ -2852,11 +2884,15 @@ var imessage = definePlatform("iMessage", {
2852
2884
  );
2853
2885
  }
2854
2886
  const remote2 = clientForPhone(client, space.phone);
2855
- return await replyToMessage2(
2887
+ return cacheRemoteOutbound(
2856
2888
  remote2,
2857
- space.id,
2858
- content.target.id,
2859
- content.content
2889
+ space,
2890
+ await replyToMessage2(
2891
+ remote2,
2892
+ space.id,
2893
+ content.target.id,
2894
+ content.content
2895
+ )
2860
2896
  );
2861
2897
  }
2862
2898
  if (content.type === "reaction") {
@@ -2871,11 +2907,15 @@ var imessage = definePlatform("iMessage", {
2871
2907
  );
2872
2908
  }
2873
2909
  const remote2 = clientForPhone(client, space.phone);
2874
- return await reactToMessage2(
2910
+ return cacheRemoteOutbound(
2875
2911
  remote2,
2876
- space.id,
2877
- content.target,
2878
- content.emoji
2912
+ space,
2913
+ await reactToMessage2(
2914
+ remote2,
2915
+ space.id,
2916
+ content.target,
2917
+ content.emoji
2918
+ )
2879
2919
  );
2880
2920
  }
2881
2921
  if (content.type === "typing") {
@@ -2916,7 +2956,11 @@ var imessage = definePlatform("iMessage", {
2916
2956
  return await send2(client, space.id, content);
2917
2957
  }
2918
2958
  const remote = clientForPhone(client, space.phone);
2919
- return await send4(remote, space.id, content);
2959
+ return cacheRemoteOutbound(
2960
+ remote,
2961
+ space,
2962
+ await send4(remote, space.id, content)
2963
+ );
2920
2964
  },
2921
2965
  actions: {
2922
2966
  getMessage: async ({ client }, space, messageId) => {
@@ -4,7 +4,7 @@ import {
4
4
  fetchUrlBytes,
5
5
  readSchema,
6
6
  streamSchema
7
- } from "./chunk-LQMDV75O.js";
7
+ } from "./chunk-UXAKIXVM.js";
8
8
 
9
9
  // src/content/richlink.ts
10
10
  import z from "zod";
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { A as Attachment, a as AttachmentInput, b as attachment } from './attachment-WePAHfcH.js';
1
+ export { A as Attachment, a as AttachmentInput, b as attachment } from './attachment-CEpGtZLm.js';
2
2
  import z__default from 'zod';
3
3
  import { P as PhotoInput } from './photo-content-BJKnqgN-.js';
4
- import { C as ContentBuilder, M as Message, U as User, e as Space, h as ContentInput, i as Content, g as ProviderMessage, E as EventProducer, j as SpaceActionFn, k as MessageActionFn, I as InstanceActionFn, l as CreateClientContext, c as Store, a as PlatformDef, P as Platform, m as PlatformProviderConfig, n as SpectrumLike, o as CustomEventStreams, A as AgentSender, b as ProjectData } from './types-YqCNUDIt.js';
5
- export { p as AnyPlatformDef, B as Broadcaster, q as CloudPlatform, D as DedicatedTokenData, F as FusorTokenData, r as ImessageInfoData, s as ManagedStream, t as PlatformInstance, u as PlatformMessage, v as PlatformRuntime, w as PlatformSpace, x as PlatformStatus, y as PlatformUser, z as PlatformsData, G as ProjectProfile, R as Reaction, H as ReactionBuilder, S as SchemaMessage, J as SharedTokenData, K as SlackTeamMeta, L as SlackTokenData, N as SpaceNamespace, O as SpectrumCloudError, Q as SubscriptionData, T as SubscriptionStatus, V as TokenData, W as broadcast, X as cloud, Y as mergeStreams, Z as reaction, _ as stream } from './types-YqCNUDIt.js';
6
- import { S as StreamTextSource, T as TextStreamOptions, C as ContactInput, a as Contact } from './authoring-DDh3muGT.js';
7
- export { b as ContactAddress, c as ContactDetails, d as ContactEmail, e as ContactName, f as ContactOrg, g as ContactPhone, D as DeltaExtractor, G as Group, P as Poll, h as PollChoice, i as PollChoiceInput, j as PollOption, R as Richlink, k as StreamText, V as Voice, l as contact, m as custom, n as group, o as option, p as poll, r as richlink, t as text, v as voice } from './authoring-DDh3muGT.js';
8
- import { a as FusorVerify, F as FusorClient, b as FusorMessages, W as WebhookHandler, c as WebhookRawRequest, d as WebhookRawResult } from './types-BujGKBin.js';
9
- export { e as FusorEvent, f as FusorMessagesCtx, g as FusorMessagesReturn, h as FusorReply, i as FusorRespond, j as FusorVerifyRequest, k as fusorEvent, l as isFusorEvent } from './types-BujGKBin.js';
4
+ import { C as ContentBuilder, M as Message, U as User, e as Space, h as ContentInput, i as Content, g as ProviderMessage, E as EventProducer, j as SpaceActionFn, k as MessageActionFn, I as InstanceActionFn, l as CreateClientContext, c as Store, a as PlatformDef, P as Platform, m as PlatformProviderConfig, n as SpectrumLike, o as CustomEventStreams, A as AgentSender, b as ProjectData } from './types-Be0T6E0e.js';
5
+ export { p as AnyPlatformDef, B as Broadcaster, q as CloudPlatform, D as DedicatedTokenData, F as FusorTokenData, r as ImessageInfoData, s as ManagedStream, t as PlatformInstance, u as PlatformMessage, v as PlatformRuntime, w as PlatformSpace, x as PlatformStatus, y as PlatformUser, z as PlatformsData, G as ProjectProfile, R as Reaction, H as ReactionBuilder, S as SchemaMessage, J as SharedTokenData, K as SlackTeamMeta, L as SlackTokenData, N as SpaceNamespace, O as SpectrumCloudError, Q as SubscriptionData, T as SubscriptionStatus, V as TokenData, W as broadcast, X as cloud, Y as mergeStreams, Z as reaction, _ as stream } from './types-Be0T6E0e.js';
6
+ import { S as StreamTextSource, T as TextStreamOptions, C as ContactInput, a as Contact } from './authoring-CP3vRza8.js';
7
+ export { b as ContactAddress, c as ContactDetails, d as ContactEmail, e as ContactName, f as ContactOrg, g as ContactPhone, D as DeltaExtractor, G as Group, P as Poll, h as PollChoice, i as PollChoiceInput, j as PollOption, R as Richlink, k as StreamText, V as Voice, l as contact, m as custom, n as group, o as option, p as poll, r as richlink, t as text, v as voice } from './authoring-CP3vRza8.js';
8
+ import { a as FusorVerify, F as FusorClient, b as FusorMessages, W as WebhookHandler, c as WebhookRawRequest, d as WebhookRawResult } from './types-CDYXH2R7.js';
9
+ export { e as FusorEvent, f as FusorMessagesCtx, g as FusorMessagesReturn, h as FusorReply, i as FusorRespond, j as FusorVerifyRequest, k as fusorEvent, l as isFusorEvent } from './types-CDYXH2R7.js';
10
10
  import 'hotscript';
11
11
  import 'vcf';
12
12