spectrum-ts 1.18.0 → 3.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.
- package/README.md +11 -1
- package/dist/{attachment-DfWSZS5L.d.ts → attachment-WePAHfcH.d.ts} +1 -1
- package/dist/{authoring-C9uDdZ2F.d.ts → authoring-DDh3muGT.d.ts} +61 -26
- package/dist/authoring.d.ts +3 -3
- package/dist/authoring.js +8 -5
- package/dist/chunk-34FQGGD7.js +34 -0
- package/dist/chunk-3GEJYGZK.js +84 -0
- package/dist/{chunk-MC6ZKFSG.js → chunk-5XEFJBN2.js} +25 -103
- package/dist/{chunk-QGJFZMD5.js → chunk-6UZFVXQF.js} +17 -101
- package/dist/{chunk-NNY6LMSC.js → chunk-77U6SH5A.js} +1 -1
- package/dist/{chunk-YN6WOTBF.js → chunk-AYCMTRVC.js} +622 -79
- package/dist/{chunk-JQN6CRSC.js → chunk-CHY5YLLV.js} +11 -40
- package/dist/{chunk-5BKZJMZV.js → chunk-EZ5SNNFS.js} +79 -38
- package/dist/{chunk-3OTECDNH.js → chunk-FULEQIRQ.js} +31 -23
- package/dist/{chunk-2ILTJC35.js → chunk-LQMDV75O.js} +205 -11
- package/dist/{chunk-IPOFBAIM.js → chunk-LX437ZTY.js} +439 -154
- package/dist/chunk-MHGCPC2V.js +35 -0
- package/dist/chunk-NZ5WCMTY.js +91 -0
- package/dist/chunk-TXRWKSNH.js +927 -0
- package/dist/{chunk-5TIF3FIE.js → chunk-UXJ5OO6P.js} +16 -14
- package/dist/index.d.ts +125 -129
- package/dist/index.js +180 -73
- package/dist/manifest.json +6 -0
- package/dist/providers/imessage/index.d.ts +6 -14
- package/dist/providers/imessage/index.js +9 -6
- package/dist/providers/index.d.ts +5 -2
- package/dist/providers/index.js +18 -10
- package/dist/providers/slack/index.d.ts +1 -2
- package/dist/providers/slack/index.js +5 -4
- package/dist/providers/telegram/index.d.ts +45 -0
- package/dist/providers/telegram/index.js +13 -0
- package/dist/providers/terminal/index.d.ts +18 -422
- package/dist/providers/terminal/index.js +7 -5
- package/dist/providers/whatsapp-business/index.d.ts +1 -1
- package/dist/providers/whatsapp-business/index.js +7 -5
- package/dist/types-BujGKBin.d.ts +82 -0
- package/dist/{types-DcQ5a7PK.d.ts → types-YqCNUDIt.d.ts} +204 -26
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,42 +1,56 @@
|
|
|
1
1
|
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
group,
|
|
4
3
|
richlink
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CHY5YLLV.js";
|
|
5
|
+
import {
|
|
6
|
+
FUSOR_MESSAGES_CHANNEL,
|
|
7
|
+
fusor,
|
|
8
|
+
fusorEvent,
|
|
9
|
+
isFusorClient,
|
|
10
|
+
isFusorEvent
|
|
11
|
+
} from "./chunk-34FQGGD7.js";
|
|
12
|
+
import {
|
|
13
|
+
group
|
|
14
|
+
} from "./chunk-MHGCPC2V.js";
|
|
6
15
|
import {
|
|
7
16
|
voice
|
|
8
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-77U6SH5A.js";
|
|
9
18
|
import {
|
|
10
19
|
option,
|
|
11
20
|
poll
|
|
12
21
|
} from "./chunk-2D27WW5B.js";
|
|
13
22
|
import {
|
|
14
23
|
SpectrumCloudError,
|
|
24
|
+
cloud
|
|
25
|
+
} from "./chunk-3GEJYGZK.js";
|
|
26
|
+
import {
|
|
27
|
+
contact
|
|
28
|
+
} from "./chunk-NZ5WCMTY.js";
|
|
29
|
+
import {
|
|
15
30
|
broadcast,
|
|
16
|
-
cloud,
|
|
17
31
|
createAsyncQueue,
|
|
18
32
|
mergeStreams,
|
|
19
33
|
stream
|
|
20
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-5XEFJBN2.js";
|
|
21
35
|
import {
|
|
22
|
-
contact,
|
|
23
36
|
fromVCard,
|
|
24
37
|
toVCard
|
|
25
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-6UZFVXQF.js";
|
|
26
39
|
import {
|
|
27
40
|
UnsupportedError,
|
|
28
41
|
avatar,
|
|
29
42
|
buildSpace,
|
|
30
43
|
contentAttrs,
|
|
31
|
-
defineFusorPlatform,
|
|
32
44
|
definePlatform,
|
|
33
45
|
edit,
|
|
46
|
+
markdown,
|
|
34
47
|
rename,
|
|
35
48
|
reply,
|
|
36
49
|
senderAttrs,
|
|
37
50
|
typing,
|
|
51
|
+
unsend,
|
|
38
52
|
wrapProviderMessage
|
|
39
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-LX437ZTY.js";
|
|
40
54
|
import {
|
|
41
55
|
__commonJS,
|
|
42
56
|
__esm,
|
|
@@ -49,7 +63,7 @@ import {
|
|
|
49
63
|
reaction,
|
|
50
64
|
resolveContents,
|
|
51
65
|
text
|
|
52
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-LQMDV75O.js";
|
|
53
67
|
|
|
54
68
|
// ../../node_modules/@grpc/grpc-js/build/src/constants.js
|
|
55
69
|
var require_constants = __commonJS({
|
|
@@ -26124,21 +26138,6 @@ var aliases = {
|
|
|
26124
26138
|
};
|
|
26125
26139
|
var Emoji = { ...GeneratedEmoji, ...aliases };
|
|
26126
26140
|
|
|
26127
|
-
// src/fusor/types.ts
|
|
26128
|
-
var FUSOR_BRAND = /* @__PURE__ */ Symbol.for("spectrum.fusor.client");
|
|
26129
|
-
|
|
26130
|
-
// src/fusor/index.ts
|
|
26131
|
-
function fusor(platform, verify) {
|
|
26132
|
-
return {
|
|
26133
|
-
[FUSOR_BRAND]: true,
|
|
26134
|
-
platform,
|
|
26135
|
-
verify
|
|
26136
|
-
};
|
|
26137
|
-
}
|
|
26138
|
-
function isFusorClient(value) {
|
|
26139
|
-
return typeof value === "object" && value !== null && value[FUSOR_BRAND] === true;
|
|
26140
|
-
}
|
|
26141
|
-
|
|
26142
26141
|
// src/spectrum.ts
|
|
26143
26142
|
import {
|
|
26144
26143
|
createLogger as createLogger2,
|
|
@@ -27282,6 +27281,23 @@ function combineReplies(outcomes) {
|
|
|
27282
27281
|
body
|
|
27283
27282
|
};
|
|
27284
27283
|
}
|
|
27284
|
+
function routeHandlerResult(result, handler, deliver) {
|
|
27285
|
+
if (result === void 0) {
|
|
27286
|
+
return;
|
|
27287
|
+
}
|
|
27288
|
+
const items = Array.isArray(result) ? result : [result];
|
|
27289
|
+
for (const item of items) {
|
|
27290
|
+
if (!isFusorEvent(item)) {
|
|
27291
|
+
deliver(item);
|
|
27292
|
+
continue;
|
|
27293
|
+
}
|
|
27294
|
+
if (item.name === FUSOR_MESSAGES_CHANNEL) {
|
|
27295
|
+
deliver(item.data);
|
|
27296
|
+
} else {
|
|
27297
|
+
handler.pushEvent(item.name, item.data);
|
|
27298
|
+
}
|
|
27299
|
+
}
|
|
27300
|
+
}
|
|
27285
27301
|
function runHandlerOnce(handler, parsedRequest, deliver = handler.pushMessage) {
|
|
27286
27302
|
return (async () => {
|
|
27287
27303
|
try {
|
|
@@ -27302,12 +27318,7 @@ function runHandlerOnce(handler, parsedRequest, deliver = handler.pushMessage) {
|
|
|
27302
27318
|
};
|
|
27303
27319
|
const result = await handler.messages({ payload, respond });
|
|
27304
27320
|
returned = true;
|
|
27305
|
-
|
|
27306
|
-
const records = Array.isArray(result) ? result : [result];
|
|
27307
|
-
for (const record of records) {
|
|
27308
|
-
deliver(record);
|
|
27309
|
-
}
|
|
27310
|
-
}
|
|
27321
|
+
routeHandlerResult(result, handler, deliver);
|
|
27311
27322
|
return { ok: true, reply: reply2 };
|
|
27312
27323
|
} catch (error) {
|
|
27313
27324
|
const errorReason = error instanceof Error ? error.message : String(error);
|
|
@@ -27403,7 +27414,7 @@ var FusorCore = class {
|
|
|
27403
27414
|
const { iterable: requestIterable, sink } = createRequestSink();
|
|
27404
27415
|
this.requestSink = sink;
|
|
27405
27416
|
sink.push({ init: { startSeq: 0 }, reply: void 0 });
|
|
27406
|
-
const metadata = Metadata().set("
|
|
27417
|
+
const metadata = Metadata().set("access_token", token);
|
|
27407
27418
|
const stream2 = client.subscribe(requestIterable, { metadata });
|
|
27408
27419
|
try {
|
|
27409
27420
|
for await (const response of stream2) {
|
|
@@ -27558,6 +27569,7 @@ function createStore() {
|
|
|
27558
27569
|
|
|
27559
27570
|
// src/spectrum.ts
|
|
27560
27571
|
var PHOTON_OTEL_ENDPOINT = "https://otlp.photon.codes";
|
|
27572
|
+
var STREAM_CLOSE_TIMEOUT_MS = 5e3;
|
|
27561
27573
|
var lifecycleLog = createLogger2("spectrum.lifecycle");
|
|
27562
27574
|
var ignoreCleanupError = () => void 0;
|
|
27563
27575
|
var spectrumOptionsSchema = z.object({
|
|
@@ -27614,15 +27626,21 @@ async function Spectrum(options) {
|
|
|
27614
27626
|
const platformStates = /* @__PURE__ */ new Map();
|
|
27615
27627
|
const fusorMessageSources = /* @__PURE__ */ new Map();
|
|
27616
27628
|
const messageBroadcasters = /* @__PURE__ */ new Map();
|
|
27629
|
+
const fusorEventSources = /* @__PURE__ */ new Map();
|
|
27630
|
+
const eventBroadcasters = /* @__PURE__ */ new Map();
|
|
27617
27631
|
const customEventStreams = /* @__PURE__ */ new Map();
|
|
27618
27632
|
let stopped = false;
|
|
27619
|
-
const adaptIterable = (iterable) => stream((emit, end) => {
|
|
27633
|
+
const adaptIterable = (iterable, project) => stream((emit, end) => {
|
|
27620
27634
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
27621
27635
|
const pump = (async () => {
|
|
27622
27636
|
try {
|
|
27623
27637
|
let result = await iterator.next();
|
|
27624
27638
|
while (!result.done) {
|
|
27625
|
-
|
|
27639
|
+
if (project) {
|
|
27640
|
+
await project(result.value, emit);
|
|
27641
|
+
} else {
|
|
27642
|
+
await emit(result.value);
|
|
27643
|
+
}
|
|
27626
27644
|
result = await iterator.next();
|
|
27627
27645
|
}
|
|
27628
27646
|
end();
|
|
@@ -27694,20 +27712,20 @@ async function Spectrum(options) {
|
|
|
27694
27712
|
projectConfig,
|
|
27695
27713
|
store
|
|
27696
27714
|
});
|
|
27697
|
-
|
|
27698
|
-
|
|
27699
|
-
|
|
27715
|
+
return adaptIterable(
|
|
27716
|
+
raw,
|
|
27717
|
+
async (record, emit) => {
|
|
27718
|
+
const tuples = await resolveRecordToMessages(record, {
|
|
27700
27719
|
client,
|
|
27701
27720
|
config,
|
|
27702
27721
|
definition,
|
|
27703
27722
|
store
|
|
27704
27723
|
});
|
|
27705
27724
|
for (const tuple of tuples) {
|
|
27706
|
-
|
|
27725
|
+
await emit(tuple);
|
|
27707
27726
|
}
|
|
27708
27727
|
}
|
|
27709
|
-
|
|
27710
|
-
return adaptIterable(bindSend());
|
|
27728
|
+
);
|
|
27711
27729
|
};
|
|
27712
27730
|
const getOrCreateMessageBroadcast = (state) => {
|
|
27713
27731
|
if (stopped) {
|
|
@@ -27723,6 +27741,24 @@ async function Spectrum(options) {
|
|
|
27723
27741
|
}
|
|
27724
27742
|
return broadcaster;
|
|
27725
27743
|
};
|
|
27744
|
+
const getOrCreateEventBroadcast = (platform, channel) => {
|
|
27745
|
+
const queue = fusorEventSources.get(platform)?.get(channel);
|
|
27746
|
+
if (!queue) {
|
|
27747
|
+
return;
|
|
27748
|
+
}
|
|
27749
|
+
if (stopped) {
|
|
27750
|
+
throw new Error(
|
|
27751
|
+
`Spectrum instance has been stopped; cannot subscribe to "${platform}" event "${channel}"`
|
|
27752
|
+
);
|
|
27753
|
+
}
|
|
27754
|
+
const key = `${platform}\0${channel}`;
|
|
27755
|
+
let broadcaster = eventBroadcasters.get(key);
|
|
27756
|
+
if (!broadcaster) {
|
|
27757
|
+
broadcaster = broadcast(adaptIterable(queue.iterable));
|
|
27758
|
+
eventBroadcasters.set(key, broadcaster);
|
|
27759
|
+
}
|
|
27760
|
+
return broadcaster;
|
|
27761
|
+
};
|
|
27726
27762
|
await withSpan(
|
|
27727
27763
|
"spectrum.init",
|
|
27728
27764
|
{
|
|
@@ -27744,6 +27780,7 @@ async function Spectrum(options) {
|
|
|
27744
27780
|
config: userConfig,
|
|
27745
27781
|
projectId,
|
|
27746
27782
|
projectSecret,
|
|
27783
|
+
projectConfig,
|
|
27747
27784
|
store
|
|
27748
27785
|
})
|
|
27749
27786
|
);
|
|
@@ -27755,7 +27792,13 @@ async function Spectrum(options) {
|
|
|
27755
27792
|
};
|
|
27756
27793
|
platformStates.set(def.name, {
|
|
27757
27794
|
...state,
|
|
27758
|
-
|
|
27795
|
+
projectConfig,
|
|
27796
|
+
subscribeMessages: () => getOrCreateMessageBroadcast(state).subscribe(),
|
|
27797
|
+
// Fanout subscription to a fusor event channel. Returns undefined for
|
|
27798
|
+
// regular platforms (no per-channel queue) — callers fall back to the
|
|
27799
|
+
// producer path. Resolved lazily, after the fusor bootstrap below has
|
|
27800
|
+
// created the per-(platform, channel) queues.
|
|
27801
|
+
subscribeEvent: (channel) => getOrCreateEventBroadcast(def.name, channel)?.subscribe()
|
|
27759
27802
|
});
|
|
27760
27803
|
}
|
|
27761
27804
|
}
|
|
@@ -27778,10 +27821,36 @@ async function Spectrum(options) {
|
|
|
27778
27821
|
continue;
|
|
27779
27822
|
}
|
|
27780
27823
|
const userMessages = runtime.definition.messages;
|
|
27824
|
+
const declaredEvents = runtime.definition.events ?? {};
|
|
27825
|
+
const eventQueues = /* @__PURE__ */ new Map();
|
|
27826
|
+
for (const channel of Object.keys(declaredEvents)) {
|
|
27827
|
+
eventQueues.set(channel, createAsyncQueue());
|
|
27828
|
+
}
|
|
27829
|
+
fusorEventSources.set(name, eventQueues);
|
|
27781
27830
|
const handler = {
|
|
27782
27831
|
verify: client.verify,
|
|
27783
|
-
|
|
27784
|
-
|
|
27832
|
+
// Enrich the transport-level `{ payload, respond }` ctx with the same
|
|
27833
|
+
// runtime context every other platform callback receives, so fusor
|
|
27834
|
+
// handlers can read config/store/projectConfig directly instead of
|
|
27835
|
+
// smuggling state through the payload.
|
|
27836
|
+
messages: async (ctx) => userMessages({
|
|
27837
|
+
...ctx,
|
|
27838
|
+
config: runtime.config,
|
|
27839
|
+
store: runtime.store,
|
|
27840
|
+
projectConfig: runtime.projectConfig
|
|
27841
|
+
}),
|
|
27842
|
+
pushMessage: (record) => queue.push(record),
|
|
27843
|
+
pushEvent: (channel, data) => {
|
|
27844
|
+
const eventQueue = eventQueues.get(channel);
|
|
27845
|
+
if (!eventQueue) {
|
|
27846
|
+
lifecycleLog.warn(
|
|
27847
|
+
`spectrum: fusorEvent("${channel}", \u2026) names a channel not declared in "${name}".events; dropping`,
|
|
27848
|
+
{ platform: name, channel }
|
|
27849
|
+
);
|
|
27850
|
+
return;
|
|
27851
|
+
}
|
|
27852
|
+
eventQueue.push(data);
|
|
27853
|
+
}
|
|
27785
27854
|
};
|
|
27786
27855
|
fusorCore.register(client.platform, handler);
|
|
27787
27856
|
}
|
|
@@ -27828,30 +27897,35 @@ async function Spectrum(options) {
|
|
|
27828
27897
|
const providerStreams = [];
|
|
27829
27898
|
for (const state of platformStates.values()) {
|
|
27830
27899
|
const { client, config, definition, store } = state;
|
|
27831
|
-
|
|
27832
|
-
if (!
|
|
27833
|
-
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
client,
|
|
27837
|
-
config,
|
|
27838
|
-
projectConfig,
|
|
27839
|
-
store
|
|
27840
|
-
});
|
|
27841
|
-
const annotatePlatform = async function* () {
|
|
27842
|
-
for await (const value of providerEvents) {
|
|
27843
|
-
const annotated = await withSpan(
|
|
27844
|
-
"spectrum.event",
|
|
27845
|
-
{
|
|
27846
|
-
"spectrum.provider": definition.name,
|
|
27847
|
-
"spectrum.event.name": eventName
|
|
27848
|
-
},
|
|
27849
|
-
() => ({ ...value, platform: definition.name })
|
|
27850
|
-
);
|
|
27851
|
-
yield annotated;
|
|
27900
|
+
let source = state.subscribeEvent?.(eventName);
|
|
27901
|
+
if (!source) {
|
|
27902
|
+
const producer = definition.events?.[eventName];
|
|
27903
|
+
if (typeof producer !== "function") {
|
|
27904
|
+
continue;
|
|
27852
27905
|
}
|
|
27853
|
-
|
|
27854
|
-
|
|
27906
|
+
source = producer({ client, config, projectConfig, store });
|
|
27907
|
+
}
|
|
27908
|
+
const providerEvents = source;
|
|
27909
|
+
providerStreams.push(
|
|
27910
|
+
adaptIterable(
|
|
27911
|
+
providerEvents,
|
|
27912
|
+
async (value, emit2) => {
|
|
27913
|
+
const annotated = await withSpan(
|
|
27914
|
+
"spectrum.event",
|
|
27915
|
+
{
|
|
27916
|
+
"spectrum.provider": definition.name,
|
|
27917
|
+
"spectrum.event.name": eventName
|
|
27918
|
+
},
|
|
27919
|
+
// Object payloads are flattened and tagged with `platform`. A
|
|
27920
|
+
// primitive/null payload can't be spread (a string would mangle
|
|
27921
|
+
// into indexed chars, a number/bool would vanish), so wrap it
|
|
27922
|
+
// under `payload` instead.
|
|
27923
|
+
() => typeof value === "object" && value !== null ? { ...value, platform: definition.name } : { platform: definition.name, payload: value }
|
|
27924
|
+
);
|
|
27925
|
+
await emit2(annotated);
|
|
27926
|
+
}
|
|
27927
|
+
)
|
|
27928
|
+
);
|
|
27855
27929
|
}
|
|
27856
27930
|
const merged = mergeStreams(providerStreams);
|
|
27857
27931
|
const pump = (async () => {
|
|
@@ -27870,6 +27944,18 @@ async function Spectrum(options) {
|
|
|
27870
27944
|
};
|
|
27871
27945
|
});
|
|
27872
27946
|
const messagesStream = createMessagesStream();
|
|
27947
|
+
const closeFusorSources = () => {
|
|
27948
|
+
for (const queue of fusorMessageSources.values()) {
|
|
27949
|
+
queue.close();
|
|
27950
|
+
}
|
|
27951
|
+
fusorMessageSources.clear();
|
|
27952
|
+
for (const queues of fusorEventSources.values()) {
|
|
27953
|
+
for (const queue of queues.values()) {
|
|
27954
|
+
queue.close();
|
|
27955
|
+
}
|
|
27956
|
+
}
|
|
27957
|
+
fusorEventSources.clear();
|
|
27958
|
+
};
|
|
27873
27959
|
const stopOnce = async () => {
|
|
27874
27960
|
if (stopped) {
|
|
27875
27961
|
return;
|
|
@@ -27884,13 +27970,31 @@ async function Spectrum(options) {
|
|
|
27884
27970
|
...Array.from(
|
|
27885
27971
|
messageBroadcasters.values(),
|
|
27886
27972
|
(broadcaster) => broadcaster.close()
|
|
27973
|
+
),
|
|
27974
|
+
...Array.from(
|
|
27975
|
+
eventBroadcasters.values(),
|
|
27976
|
+
(broadcaster) => broadcaster.close()
|
|
27887
27977
|
)
|
|
27888
27978
|
];
|
|
27889
27979
|
process.off("SIGINT", handleSignal);
|
|
27890
27980
|
process.off("SIGTERM", handleSignal);
|
|
27891
27981
|
const streamCloseStart = performance.now();
|
|
27892
|
-
|
|
27893
|
-
|
|
27982
|
+
const streamSettled = Promise.allSettled(streamShutdowns);
|
|
27983
|
+
let streamTimedOut = false;
|
|
27984
|
+
await Promise.race([
|
|
27985
|
+
streamSettled,
|
|
27986
|
+
new Promise((resolve) => {
|
|
27987
|
+
setTimeout(() => {
|
|
27988
|
+
streamTimedOut = true;
|
|
27989
|
+
resolve();
|
|
27990
|
+
}, STREAM_CLOSE_TIMEOUT_MS).unref();
|
|
27991
|
+
})
|
|
27992
|
+
]);
|
|
27993
|
+
if (streamTimedOut) {
|
|
27994
|
+
lifecycleLog.warn("stream close timed out; proceeding to teardown", {
|
|
27995
|
+
timeoutMs: STREAM_CLOSE_TIMEOUT_MS
|
|
27996
|
+
});
|
|
27997
|
+
}
|
|
27894
27998
|
let fusorCloseMs = 0;
|
|
27895
27999
|
if (fusorCore) {
|
|
27896
28000
|
const fusorCloseStart = performance.now();
|
|
@@ -27901,10 +28005,7 @@ async function Spectrum(options) {
|
|
|
27901
28005
|
lifecycleLog.warn("fusor core close failed", { error });
|
|
27902
28006
|
});
|
|
27903
28007
|
fusorCloseMs = Math.round(performance.now() - fusorCloseStart);
|
|
27904
|
-
|
|
27905
|
-
queue.close();
|
|
27906
|
-
}
|
|
27907
|
-
fusorMessageSources.clear();
|
|
28008
|
+
closeFusorSources();
|
|
27908
28009
|
}
|
|
27909
28010
|
const clientShutdowns = [];
|
|
27910
28011
|
for (const state of platformStates.values()) {
|
|
@@ -27928,8 +28029,11 @@ async function Spectrum(options) {
|
|
|
27928
28029
|
const clientCloseStart = performance.now();
|
|
27929
28030
|
await Promise.allSettled(clientShutdowns);
|
|
27930
28031
|
const clientCloseMs = Math.round(performance.now() - clientCloseStart);
|
|
28032
|
+
await streamSettled.catch(() => void 0);
|
|
28033
|
+
const streamCloseMs = Math.round(performance.now() - streamCloseStart);
|
|
27931
28034
|
customEventStreams.clear();
|
|
27932
28035
|
messageBroadcasters.clear();
|
|
28036
|
+
eventBroadcasters.clear();
|
|
27933
28037
|
platformStates.clear();
|
|
27934
28038
|
lifecycleLog.info("Spectrum stopped", {
|
|
27935
28039
|
providers: providerNames,
|
|
@@ -28102,13 +28206,15 @@ export {
|
|
|
28102
28206
|
cloud,
|
|
28103
28207
|
contact,
|
|
28104
28208
|
custom,
|
|
28105
|
-
defineFusorPlatform,
|
|
28106
28209
|
definePlatform,
|
|
28107
28210
|
edit,
|
|
28108
28211
|
fromVCard,
|
|
28109
28212
|
fusor,
|
|
28213
|
+
fusorEvent,
|
|
28110
28214
|
group,
|
|
28111
28215
|
isFusorClient,
|
|
28216
|
+
isFusorEvent,
|
|
28217
|
+
markdown,
|
|
28112
28218
|
mergeStreams,
|
|
28113
28219
|
option,
|
|
28114
28220
|
poll,
|
|
@@ -28121,6 +28227,7 @@ export {
|
|
|
28121
28227
|
text,
|
|
28122
28228
|
toVCard,
|
|
28123
28229
|
typing,
|
|
28230
|
+
unsend,
|
|
28124
28231
|
voice
|
|
28125
28232
|
};
|
|
28126
28233
|
/*! Bundled license information:
|
package/dist/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ContentBuilder,
|
|
1
|
+
import { C as ContentBuilder, h as ContentInput, M as Message, S as SchemaMessage, P as Platform, a as PlatformDef, e as Space, c as Store } from '../../types-YqCNUDIt.js';
|
|
2
2
|
import * as zod_v4_core from 'zod/v4/core';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import z__default from 'zod';
|
|
5
|
-
import { A as Attachment } from '../../attachment-
|
|
5
|
+
import { A as Attachment } from '../../attachment-WePAHfcH.js';
|
|
6
6
|
import { P as PhotoInput } from '../../photo-content-BJKnqgN-.js';
|
|
7
7
|
import { MessageEffect, AdvancedIMessage } from '@photon-ai/advanced-imessage';
|
|
8
8
|
import { IMessageSDK } from '@photon-ai/imessage-kit';
|
|
@@ -179,11 +179,7 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
|
|
|
179
179
|
id: string;
|
|
180
180
|
}, {
|
|
181
181
|
id: string;
|
|
182
|
-
type: "dm";
|
|
183
|
-
phone: string;
|
|
184
|
-
} | {
|
|
185
|
-
id: string;
|
|
186
|
-
type: "group";
|
|
182
|
+
type: "group" | "dm";
|
|
187
183
|
phone: string;
|
|
188
184
|
}, z.ZodObject<{
|
|
189
185
|
partIndex: z.ZodOptional<z.ZodNumber>;
|
|
@@ -213,15 +209,11 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
|
|
|
213
209
|
}[] | undefined;
|
|
214
210
|
};
|
|
215
211
|
store: Store;
|
|
216
|
-
}, space:
|
|
217
|
-
id: string;
|
|
218
|
-
type: "dm";
|
|
219
|
-
phone: string;
|
|
220
|
-
} | {
|
|
212
|
+
}, space: {
|
|
221
213
|
id: string;
|
|
222
|
-
type: "group";
|
|
214
|
+
type: "group" | "dm";
|
|
223
215
|
phone: string;
|
|
224
|
-
}
|
|
216
|
+
} & {
|
|
225
217
|
id: string;
|
|
226
218
|
__platform: string;
|
|
227
219
|
}, messageId: string) => Promise<IMessageMessage | undefined>;
|
|
@@ -5,13 +5,16 @@ import {
|
|
|
5
5
|
effect,
|
|
6
6
|
imessage,
|
|
7
7
|
read
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-AYCMTRVC.js";
|
|
9
|
+
import "../../chunk-CHY5YLLV.js";
|
|
10
|
+
import "../../chunk-MHGCPC2V.js";
|
|
10
11
|
import "../../chunk-2D27WW5B.js";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-3GEJYGZK.js";
|
|
13
|
+
import "../../chunk-NZ5WCMTY.js";
|
|
14
|
+
import "../../chunk-5XEFJBN2.js";
|
|
15
|
+
import "../../chunk-6UZFVXQF.js";
|
|
16
|
+
import "../../chunk-LX437ZTY.js";
|
|
17
|
+
import "../../chunk-LQMDV75O.js";
|
|
15
18
|
export {
|
|
16
19
|
background,
|
|
17
20
|
customizedMiniApp,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
export { imessage } from './imessage/index.js';
|
|
2
2
|
export { slack } from './slack/index.js';
|
|
3
|
+
export { telegram } from './telegram/index.js';
|
|
3
4
|
export { terminal } from './terminal/index.js';
|
|
4
5
|
export { whatsappBusiness } from './whatsapp-business/index.js';
|
|
5
|
-
import '../types-
|
|
6
|
+
import '../types-YqCNUDIt.js';
|
|
6
7
|
import 'hotscript';
|
|
7
8
|
import 'zod';
|
|
8
9
|
import 'zod/v4/core';
|
|
9
|
-
import '../attachment-
|
|
10
|
+
import '../attachment-WePAHfcH.js';
|
|
10
11
|
import '../photo-content-BJKnqgN-.js';
|
|
11
12
|
import '@photon-ai/advanced-imessage';
|
|
12
13
|
import '@photon-ai/imessage-kit';
|
|
13
14
|
import '@photon-ai/slack';
|
|
15
|
+
import '@photon-ai/telegram-ts';
|
|
16
|
+
import '../types-BujGKBin.js';
|
|
14
17
|
import 'node:child_process';
|
|
15
18
|
import 'node:net';
|
|
16
19
|
import '@photon-ai/whatsapp-business';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
imessage
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-AYCMTRVC.js";
|
|
5
|
+
import "../chunk-CHY5YLLV.js";
|
|
6
6
|
import {
|
|
7
7
|
slack
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-FULEQIRQ.js";
|
|
9
|
+
import {
|
|
10
|
+
telegram
|
|
11
|
+
} from "../chunk-TXRWKSNH.js";
|
|
12
|
+
import "../chunk-34FQGGD7.js";
|
|
13
|
+
import "../chunk-MHGCPC2V.js";
|
|
9
14
|
import {
|
|
10
15
|
terminal
|
|
11
|
-
} from "../chunk-
|
|
12
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-EZ5SNNFS.js";
|
|
17
|
+
import "../chunk-77U6SH5A.js";
|
|
13
18
|
import {
|
|
14
19
|
whatsappBusiness
|
|
15
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-UXJ5OO6P.js";
|
|
16
21
|
import "../chunk-2D27WW5B.js";
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-3GEJYGZK.js";
|
|
23
|
+
import "../chunk-NZ5WCMTY.js";
|
|
24
|
+
import "../chunk-5XEFJBN2.js";
|
|
25
|
+
import "../chunk-6UZFVXQF.js";
|
|
26
|
+
import "../chunk-LX437ZTY.js";
|
|
27
|
+
import "../chunk-LQMDV75O.js";
|
|
21
28
|
export {
|
|
22
29
|
imessage,
|
|
23
30
|
slack,
|
|
31
|
+
telegram,
|
|
24
32
|
terminal,
|
|
25
33
|
whatsappBusiness
|
|
26
34
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SchemaMessage, P as Platform, a as PlatformDef } from '../../types-
|
|
1
|
+
import { S as SchemaMessage, P as Platform, a as PlatformDef } from '../../types-YqCNUDIt.js';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import z__default from 'zod';
|
|
4
4
|
import * as _photon_ai_slack from '@photon-ai/slack';
|
|
@@ -30,7 +30,6 @@ declare const slack: Platform<PlatformDef<"Slack", z.ZodUnion<readonly [z.ZodObj
|
|
|
30
30
|
id: z.ZodString;
|
|
31
31
|
teamId: z.ZodString;
|
|
32
32
|
}, zod_v4_core.$strip>, z.ZodObject<{
|
|
33
|
-
channel: z.ZodOptional<z.ZodString>;
|
|
34
33
|
teamId: z.ZodString;
|
|
35
34
|
}, zod_v4_core.$strip>, _photon_ai_slack.SlackClient, {
|
|
36
35
|
id: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
slack
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-FULEQIRQ.js";
|
|
5
|
+
import "../../chunk-3GEJYGZK.js";
|
|
6
|
+
import "../../chunk-5XEFJBN2.js";
|
|
7
|
+
import "../../chunk-LX437ZTY.js";
|
|
8
|
+
import "../../chunk-LQMDV75O.js";
|
|
8
9
|
export {
|
|
9
10
|
slack
|
|
10
11
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { P as Platform, a as PlatformDef, g as ProviderMessage } from '../../types-YqCNUDIt.js';
|
|
2
|
+
import * as _photon_ai_telegram_ts from '@photon-ai/telegram-ts';
|
|
3
|
+
import * as zod_v4_core from 'zod/v4/core';
|
|
4
|
+
import * as z from 'zod';
|
|
5
|
+
import z__default from 'zod';
|
|
6
|
+
import { F as FusorClient } from '../../types-BujGKBin.js';
|
|
7
|
+
import 'hotscript';
|
|
8
|
+
|
|
9
|
+
interface TelegramSpace {
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare const configSchema: z__default.ZodObject<{
|
|
14
|
+
botToken: z__default.ZodString;
|
|
15
|
+
webhookSecret: z__default.ZodOptional<z__default.ZodString>;
|
|
16
|
+
baseUrl: z__default.ZodDefault<z__default.ZodURL>;
|
|
17
|
+
}, z__default.core.$strip>;
|
|
18
|
+
type TelegramConfig = z__default.infer<typeof configSchema>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Telegram provider for Spectrum.
|
|
22
|
+
*
|
|
23
|
+
* Inbound is delivered through Fusor: `createClient` returns a `fusor(...)`
|
|
24
|
+
* client whose `verify` checks the Telegram webhook secret token and parses the
|
|
25
|
+
* `Update` (pure parsing — no client). The `messages` handler reads `config`
|
|
26
|
+
* from its ctx and builds a photon client inline only to download media bytes.
|
|
27
|
+
* Outbound (`send`) also builds a photon client inline. Both go through
|
|
28
|
+
* `@photon-ai/telegram-ts`. Drop `telegram.config({...})` into
|
|
29
|
+
* `Spectrum({ providers: [...] })`.
|
|
30
|
+
*
|
|
31
|
+
* In cloud mode (`projectConfig` present), `createClient` also self-registers
|
|
32
|
+
* the bot's webhook against the Fusor edge for the project slug — see
|
|
33
|
+
* `ensureWebhook`. Without a slug (local/direct mode) registration is skipped.
|
|
34
|
+
*/
|
|
35
|
+
declare const telegram: Platform<PlatformDef<"telegram", z.ZodObject<{
|
|
36
|
+
botToken: z.ZodString;
|
|
37
|
+
webhookSecret: z.ZodOptional<z.ZodString>;
|
|
38
|
+
baseUrl: z.ZodDefault<z.ZodURL>;
|
|
39
|
+
}, zod_v4_core.$strip>, z.ZodType<object, unknown, zod_v4_core.$ZodTypeInternals<object, unknown>> | undefined, z.ZodType<object, unknown, zod_v4_core.$ZodTypeInternals<object, unknown>> | undefined, z.ZodType<object, unknown, zod_v4_core.$ZodTypeInternals<object, unknown>> | undefined, FusorClient<_photon_ai_telegram_ts.Update>, {
|
|
40
|
+
id: string;
|
|
41
|
+
}, TelegramSpace, undefined, ProviderMessage<{
|
|
42
|
+
id: string;
|
|
43
|
+
}, TelegramSpace, Record<never, never>>, undefined, Record<never, never>, Record<never, never>, Record<never, never>>> & Readonly<Record<never, never>>;
|
|
44
|
+
|
|
45
|
+
export { type TelegramConfig, telegram };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
telegram
|
|
4
|
+
} from "../../chunk-TXRWKSNH.js";
|
|
5
|
+
import "../../chunk-34FQGGD7.js";
|
|
6
|
+
import "../../chunk-MHGCPC2V.js";
|
|
7
|
+
import "../../chunk-77U6SH5A.js";
|
|
8
|
+
import "../../chunk-6UZFVXQF.js";
|
|
9
|
+
import "../../chunk-LX437ZTY.js";
|
|
10
|
+
import "../../chunk-LQMDV75O.js";
|
|
11
|
+
export {
|
|
12
|
+
telegram
|
|
13
|
+
};
|