@diegoaltoworks/chatter 0.54.2 → 0.56.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 +2 -1
- package/dist/channels/index.js +18 -1
- package/dist/channels/index.mjs +18 -1
- package/dist/channels/pipeline.d.ts +11 -1
- package/dist/channels/pipeline.d.ts.map +1 -1
- package/dist/channels/telegram/api.d.ts +122 -0
- package/dist/channels/telegram/api.d.ts.map +1 -0
- package/dist/channels/telegram/channel.d.ts +82 -0
- package/dist/channels/telegram/channel.d.ts.map +1 -0
- package/dist/channels/telegram/index.d.ts +26 -0
- package/dist/channels/telegram/index.d.ts.map +1 -0
- package/dist/channels/telegram/index.js +710 -0
- package/dist/channels/telegram/index.mjs +667 -0
- package/dist/channels/telegram/poll.d.ts +47 -0
- package/dist/channels/telegram/poll.d.ts.map +1 -0
- package/dist/channels/telegram/updates.d.ts +63 -0
- package/dist/channels/telegram/updates.d.ts.map +1 -0
- package/dist/channels/whatsapp/inbound.d.ts +4 -1
- package/dist/channels/whatsapp/inbound.d.ts.map +1 -1
- package/dist/channels/whatsapp/index.js +22 -2
- package/dist/channels/whatsapp/index.mjs +22 -2
- package/dist/core/answer.d.ts +31 -0
- package/dist/core/answer.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -10
- package/dist/index.mjs +53 -10
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +26 -4
- package/dist/mcp-server.mjs +26 -4
- package/dist/routes/demo.d.ts.map +1 -1
- package/dist/routes/openai.d.ts.map +1 -1
- package/dist/routes/private.d.ts.map +1 -1
- package/dist/routes/public.d.ts.map +1 -1
- package/dist/server.js +38 -6
- package/dist/server.mjs +38 -6
- package/dist/types.d.ts +17 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -2
package/dist/index.mjs
CHANGED
|
@@ -209,6 +209,18 @@ async function answerOnce({
|
|
|
209
209
|
}
|
|
210
210
|
return completeOnce({ client, system, messages, temperature, model });
|
|
211
211
|
}
|
|
212
|
+
async function applyTransformReply(transformReply, input, logger) {
|
|
213
|
+
if (!transformReply) return input.text;
|
|
214
|
+
try {
|
|
215
|
+
return await transformReply(input);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
logger?.error(
|
|
218
|
+
`transformReply threw for channel "${input.channel}"; sending the original reply`,
|
|
219
|
+
error
|
|
220
|
+
);
|
|
221
|
+
return input.text;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
212
224
|
async function* answerStream({
|
|
213
225
|
answerFn,
|
|
214
226
|
client,
|
|
@@ -929,6 +941,11 @@ async function createMCPServer(config) {
|
|
|
929
941
|
conversationId: convId,
|
|
930
942
|
model
|
|
931
943
|
});
|
|
944
|
+
const replyText = await applyTransformReply(
|
|
945
|
+
config.transformReply,
|
|
946
|
+
{ channel: "mcp-public", conversationId: convId, text: result.content },
|
|
947
|
+
log
|
|
948
|
+
);
|
|
932
949
|
const cost = calculateCost(result.usage, config.openai.pricing);
|
|
933
950
|
const duration = Date.now() - startTime;
|
|
934
951
|
await logger.logChatInteraction(
|
|
@@ -936,7 +953,7 @@ async function createMCPServer(config) {
|
|
|
936
953
|
convId,
|
|
937
954
|
conversationMessages,
|
|
938
955
|
ctx,
|
|
939
|
-
|
|
956
|
+
replyText ?? "",
|
|
940
957
|
duration,
|
|
941
958
|
cost
|
|
942
959
|
).catch((err) => log.error("Logging error:", err));
|
|
@@ -944,7 +961,7 @@ async function createMCPServer(config) {
|
|
|
944
961
|
content: [
|
|
945
962
|
{
|
|
946
963
|
type: "text",
|
|
947
|
-
text:
|
|
964
|
+
text: replyText ?? ""
|
|
948
965
|
}
|
|
949
966
|
],
|
|
950
967
|
_meta: {
|
|
@@ -1010,6 +1027,11 @@ async function createMCPServer(config) {
|
|
|
1010
1027
|
conversationId: convId,
|
|
1011
1028
|
model
|
|
1012
1029
|
});
|
|
1030
|
+
const replyText = await applyTransformReply(
|
|
1031
|
+
config.transformReply,
|
|
1032
|
+
{ channel: "mcp-private", conversationId: convId, text: result.content },
|
|
1033
|
+
log
|
|
1034
|
+
);
|
|
1013
1035
|
const cost = calculateCost(result.usage, config.openai.pricing);
|
|
1014
1036
|
const duration = Date.now() - startTime;
|
|
1015
1037
|
await logger.logChatInteraction(
|
|
@@ -1017,7 +1039,7 @@ async function createMCPServer(config) {
|
|
|
1017
1039
|
convId,
|
|
1018
1040
|
conversationMessages,
|
|
1019
1041
|
ctx,
|
|
1020
|
-
|
|
1042
|
+
replyText ?? "",
|
|
1021
1043
|
duration,
|
|
1022
1044
|
cost
|
|
1023
1045
|
).catch((err) => log.error("Logging error:", err));
|
|
@@ -1025,7 +1047,7 @@ async function createMCPServer(config) {
|
|
|
1025
1047
|
content: [
|
|
1026
1048
|
{
|
|
1027
1049
|
type: "text",
|
|
1028
|
-
text:
|
|
1050
|
+
text: replyText ?? ""
|
|
1029
1051
|
}
|
|
1030
1052
|
],
|
|
1031
1053
|
_meta: {
|
|
@@ -1498,7 +1520,12 @@ function demoRoutes(deps) {
|
|
|
1498
1520
|
mode: "public",
|
|
1499
1521
|
model
|
|
1500
1522
|
});
|
|
1501
|
-
|
|
1523
|
+
const reply = await applyTransformReply(
|
|
1524
|
+
config.transformReply,
|
|
1525
|
+
{ channel: "widget-demo", text: out.content },
|
|
1526
|
+
logger
|
|
1527
|
+
);
|
|
1528
|
+
return c.json({ reply: reply ?? "" });
|
|
1502
1529
|
} catch (error) {
|
|
1503
1530
|
const err = error;
|
|
1504
1531
|
logger.error("Demo chat error:", err);
|
|
@@ -1541,7 +1568,7 @@ function oversizedBodyError(message) {
|
|
|
1541
1568
|
return { error: { message, type: "invalid_request_error" } };
|
|
1542
1569
|
}
|
|
1543
1570
|
function openaiRoutes(deps) {
|
|
1544
|
-
const { client, store, config, prompts, apiKeyManager } = deps;
|
|
1571
|
+
const { client, store, config, prompts, apiKeyManager, logger } = deps;
|
|
1545
1572
|
const app = new Hono2();
|
|
1546
1573
|
const { limitPublic, limitPrivate } = createRateLimiter2(config);
|
|
1547
1574
|
const requirePrivateJWT = createJWTMiddleware(config);
|
|
@@ -1636,13 +1663,18 @@ function openaiRoutes(deps) {
|
|
|
1636
1663
|
temperature,
|
|
1637
1664
|
model: serverModel
|
|
1638
1665
|
});
|
|
1666
|
+
const reply = await applyTransformReply(
|
|
1667
|
+
config.transformReply,
|
|
1668
|
+
{ channel: `openai-compat-${mode}`, sender, conversationId, text: out.content },
|
|
1669
|
+
logger
|
|
1670
|
+
);
|
|
1639
1671
|
return c.json({
|
|
1640
1672
|
id,
|
|
1641
1673
|
object: "chat.completion",
|
|
1642
1674
|
created,
|
|
1643
1675
|
model: serverModel,
|
|
1644
1676
|
choices: [
|
|
1645
|
-
{ index: 0, message: { role: "assistant", content:
|
|
1677
|
+
{ index: 0, message: { role: "assistant", content: reply ?? "" }, finish_reason: "stop" }
|
|
1646
1678
|
],
|
|
1647
1679
|
usage: out.usage
|
|
1648
1680
|
});
|
|
@@ -1672,7 +1704,7 @@ function wantsStream(c) {
|
|
|
1672
1704
|
return acc.includes("text/event-stream");
|
|
1673
1705
|
}
|
|
1674
1706
|
function privateRoutes(deps) {
|
|
1675
|
-
const { client, store, config, prompts } = deps;
|
|
1707
|
+
const { client, store, config, prompts, logger } = deps;
|
|
1676
1708
|
const app = new Hono3();
|
|
1677
1709
|
const requirePrivateJWT = createJWTMiddleware(config);
|
|
1678
1710
|
const { limitPrivate } = createRateLimiter2(config);
|
|
@@ -1727,7 +1759,12 @@ function privateRoutes(deps) {
|
|
|
1727
1759
|
sender,
|
|
1728
1760
|
model
|
|
1729
1761
|
});
|
|
1730
|
-
|
|
1762
|
+
const reply = await applyTransformReply(
|
|
1763
|
+
config.transformReply,
|
|
1764
|
+
{ channel: "widget-private", sender, text: out.content },
|
|
1765
|
+
logger
|
|
1766
|
+
);
|
|
1767
|
+
return c.json({ reply: reply ?? "" });
|
|
1731
1768
|
});
|
|
1732
1769
|
return app;
|
|
1733
1770
|
}
|
|
@@ -1789,7 +1826,12 @@ function publicRoutes(deps) {
|
|
|
1789
1826
|
});
|
|
1790
1827
|
}
|
|
1791
1828
|
const out = await answerOnce({ answerFn, client, system, messages, mode: "public", model });
|
|
1792
|
-
|
|
1829
|
+
const reply = await applyTransformReply(
|
|
1830
|
+
config.transformReply,
|
|
1831
|
+
{ channel: "widget-public", text: out.content },
|
|
1832
|
+
logger
|
|
1833
|
+
);
|
|
1834
|
+
return c.json({ reply: reply ?? "" });
|
|
1793
1835
|
});
|
|
1794
1836
|
return app;
|
|
1795
1837
|
}
|
|
@@ -2126,6 +2168,7 @@ export {
|
|
|
2126
2168
|
VectorStore,
|
|
2127
2169
|
answerOnce,
|
|
2128
2170
|
answerStream,
|
|
2171
|
+
applyTransformReply,
|
|
2129
2172
|
chatBodyLimit,
|
|
2130
2173
|
completeOnce,
|
|
2131
2174
|
completeStream,
|
package/dist/mcp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH,YAAY,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH,YAAY,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,gBAAgB,qEAoT7D"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -104,6 +104,18 @@ async function answerOnce({
|
|
|
104
104
|
}
|
|
105
105
|
return completeOnce({ client, system, messages, temperature, model });
|
|
106
106
|
}
|
|
107
|
+
async function applyTransformReply(transformReply, input, logger) {
|
|
108
|
+
if (!transformReply) return input.text;
|
|
109
|
+
try {
|
|
110
|
+
return await transformReply(input);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
logger?.error(
|
|
113
|
+
`transformReply threw for channel "${input.channel}"; sending the original reply`,
|
|
114
|
+
error
|
|
115
|
+
);
|
|
116
|
+
return input.text;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
107
119
|
|
|
108
120
|
// src/core/buckets.ts
|
|
109
121
|
function defaultBuckets(mode) {
|
|
@@ -704,6 +716,11 @@ async function createMCPServer(config) {
|
|
|
704
716
|
conversationId: convId,
|
|
705
717
|
model
|
|
706
718
|
});
|
|
719
|
+
const replyText = await applyTransformReply(
|
|
720
|
+
config.transformReply,
|
|
721
|
+
{ channel: "mcp-public", conversationId: convId, text: result.content },
|
|
722
|
+
log
|
|
723
|
+
);
|
|
707
724
|
const cost = calculateCost(result.usage, config.openai.pricing);
|
|
708
725
|
const duration = Date.now() - startTime;
|
|
709
726
|
await logger.logChatInteraction(
|
|
@@ -711,7 +728,7 @@ async function createMCPServer(config) {
|
|
|
711
728
|
convId,
|
|
712
729
|
conversationMessages,
|
|
713
730
|
ctx,
|
|
714
|
-
|
|
731
|
+
replyText ?? "",
|
|
715
732
|
duration,
|
|
716
733
|
cost
|
|
717
734
|
).catch((err) => log.error("Logging error:", err));
|
|
@@ -719,7 +736,7 @@ async function createMCPServer(config) {
|
|
|
719
736
|
content: [
|
|
720
737
|
{
|
|
721
738
|
type: "text",
|
|
722
|
-
text:
|
|
739
|
+
text: replyText ?? ""
|
|
723
740
|
}
|
|
724
741
|
],
|
|
725
742
|
_meta: {
|
|
@@ -785,6 +802,11 @@ async function createMCPServer(config) {
|
|
|
785
802
|
conversationId: convId,
|
|
786
803
|
model
|
|
787
804
|
});
|
|
805
|
+
const replyText = await applyTransformReply(
|
|
806
|
+
config.transformReply,
|
|
807
|
+
{ channel: "mcp-private", conversationId: convId, text: result.content },
|
|
808
|
+
log
|
|
809
|
+
);
|
|
788
810
|
const cost = calculateCost(result.usage, config.openai.pricing);
|
|
789
811
|
const duration = Date.now() - startTime;
|
|
790
812
|
await logger.logChatInteraction(
|
|
@@ -792,7 +814,7 @@ async function createMCPServer(config) {
|
|
|
792
814
|
convId,
|
|
793
815
|
conversationMessages,
|
|
794
816
|
ctx,
|
|
795
|
-
|
|
817
|
+
replyText ?? "",
|
|
796
818
|
duration,
|
|
797
819
|
cost
|
|
798
820
|
).catch((err) => log.error("Logging error:", err));
|
|
@@ -800,7 +822,7 @@ async function createMCPServer(config) {
|
|
|
800
822
|
content: [
|
|
801
823
|
{
|
|
802
824
|
type: "text",
|
|
803
|
-
text:
|
|
825
|
+
text: replyText ?? ""
|
|
804
826
|
}
|
|
805
827
|
],
|
|
806
828
|
_meta: {
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -70,6 +70,18 @@ async function answerOnce({
|
|
|
70
70
|
}
|
|
71
71
|
return completeOnce({ client, system, messages, temperature, model });
|
|
72
72
|
}
|
|
73
|
+
async function applyTransformReply(transformReply, input, logger) {
|
|
74
|
+
if (!transformReply) return input.text;
|
|
75
|
+
try {
|
|
76
|
+
return await transformReply(input);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
logger?.error(
|
|
79
|
+
`transformReply threw for channel "${input.channel}"; sending the original reply`,
|
|
80
|
+
error
|
|
81
|
+
);
|
|
82
|
+
return input.text;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
73
85
|
|
|
74
86
|
// src/core/buckets.ts
|
|
75
87
|
function defaultBuckets(mode) {
|
|
@@ -670,6 +682,11 @@ async function createMCPServer(config) {
|
|
|
670
682
|
conversationId: convId,
|
|
671
683
|
model
|
|
672
684
|
});
|
|
685
|
+
const replyText = await applyTransformReply(
|
|
686
|
+
config.transformReply,
|
|
687
|
+
{ channel: "mcp-public", conversationId: convId, text: result.content },
|
|
688
|
+
log
|
|
689
|
+
);
|
|
673
690
|
const cost = calculateCost(result.usage, config.openai.pricing);
|
|
674
691
|
const duration = Date.now() - startTime;
|
|
675
692
|
await logger.logChatInteraction(
|
|
@@ -677,7 +694,7 @@ async function createMCPServer(config) {
|
|
|
677
694
|
convId,
|
|
678
695
|
conversationMessages,
|
|
679
696
|
ctx,
|
|
680
|
-
|
|
697
|
+
replyText ?? "",
|
|
681
698
|
duration,
|
|
682
699
|
cost
|
|
683
700
|
).catch((err) => log.error("Logging error:", err));
|
|
@@ -685,7 +702,7 @@ async function createMCPServer(config) {
|
|
|
685
702
|
content: [
|
|
686
703
|
{
|
|
687
704
|
type: "text",
|
|
688
|
-
text:
|
|
705
|
+
text: replyText ?? ""
|
|
689
706
|
}
|
|
690
707
|
],
|
|
691
708
|
_meta: {
|
|
@@ -751,6 +768,11 @@ async function createMCPServer(config) {
|
|
|
751
768
|
conversationId: convId,
|
|
752
769
|
model
|
|
753
770
|
});
|
|
771
|
+
const replyText = await applyTransformReply(
|
|
772
|
+
config.transformReply,
|
|
773
|
+
{ channel: "mcp-private", conversationId: convId, text: result.content },
|
|
774
|
+
log
|
|
775
|
+
);
|
|
754
776
|
const cost = calculateCost(result.usage, config.openai.pricing);
|
|
755
777
|
const duration = Date.now() - startTime;
|
|
756
778
|
await logger.logChatInteraction(
|
|
@@ -758,7 +780,7 @@ async function createMCPServer(config) {
|
|
|
758
780
|
convId,
|
|
759
781
|
conversationMessages,
|
|
760
782
|
ctx,
|
|
761
|
-
|
|
783
|
+
replyText ?? "",
|
|
762
784
|
duration,
|
|
763
785
|
cost
|
|
764
786
|
).catch((err) => log.error("Logging error:", err));
|
|
@@ -766,7 +788,7 @@ async function createMCPServer(config) {
|
|
|
766
788
|
content: [
|
|
767
789
|
{
|
|
768
790
|
type: "text",
|
|
769
|
-
text:
|
|
791
|
+
text: replyText ?? ""
|
|
770
792
|
}
|
|
771
793
|
],
|
|
772
794
|
_meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../src/routes/demo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAuFnD,wBAAgB,UAAU,CAAC,IAAI,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../src/routes/demo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAuFnD,wBAAgB,UAAU,CAAC,IAAI,EAAE,kBAAkB,8EAyHlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/routes/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAU5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsDnD,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/routes/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAU5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsDnD,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,8EAmKpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private.d.ts","sourceRoot":"","sources":["../../src/routes/private.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAS5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASnD,wBAAgB,aAAa,CAAC,IAAI,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"private.d.ts","sourceRoot":"","sources":["../../src/routes/private.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAS5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASnD,wBAAgB,aAAa,CAAC,IAAI,EAAE,kBAAkB,8EA4ErD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/routes/public.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASnD,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/routes/public.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASnD,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,8EA4EpD"}
|
package/dist/server.js
CHANGED
|
@@ -249,6 +249,18 @@ async function answerOnce({
|
|
|
249
249
|
}
|
|
250
250
|
return completeOnce({ client, system, messages, temperature, model });
|
|
251
251
|
}
|
|
252
|
+
async function applyTransformReply(transformReply, input, logger) {
|
|
253
|
+
if (!transformReply) return input.text;
|
|
254
|
+
try {
|
|
255
|
+
return await transformReply(input);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
logger?.error(
|
|
258
|
+
`transformReply threw for channel "${input.channel}"; sending the original reply`,
|
|
259
|
+
error
|
|
260
|
+
);
|
|
261
|
+
return input.text;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
252
264
|
async function* answerStream({
|
|
253
265
|
answerFn,
|
|
254
266
|
client,
|
|
@@ -1080,7 +1092,12 @@ function demoRoutes(deps) {
|
|
|
1080
1092
|
mode: "public",
|
|
1081
1093
|
model
|
|
1082
1094
|
});
|
|
1083
|
-
|
|
1095
|
+
const reply = await applyTransformReply(
|
|
1096
|
+
config.transformReply,
|
|
1097
|
+
{ channel: "widget-demo", text: out.content },
|
|
1098
|
+
logger
|
|
1099
|
+
);
|
|
1100
|
+
return c.json({ reply: reply ?? "" });
|
|
1084
1101
|
} catch (error) {
|
|
1085
1102
|
const err = error;
|
|
1086
1103
|
logger.error("Demo chat error:", err);
|
|
@@ -1204,7 +1221,7 @@ function oversizedBodyError(message) {
|
|
|
1204
1221
|
return { error: { message, type: "invalid_request_error" } };
|
|
1205
1222
|
}
|
|
1206
1223
|
function openaiRoutes(deps) {
|
|
1207
|
-
const { client, store, config, prompts, apiKeyManager } = deps;
|
|
1224
|
+
const { client, store, config, prompts, apiKeyManager, logger } = deps;
|
|
1208
1225
|
const app = new import_hono2.Hono();
|
|
1209
1226
|
const { limitPublic, limitPrivate } = createRateLimiter(config);
|
|
1210
1227
|
const requirePrivateJWT = createJWTMiddleware(config);
|
|
@@ -1299,13 +1316,18 @@ function openaiRoutes(deps) {
|
|
|
1299
1316
|
temperature,
|
|
1300
1317
|
model: serverModel
|
|
1301
1318
|
});
|
|
1319
|
+
const reply = await applyTransformReply(
|
|
1320
|
+
config.transformReply,
|
|
1321
|
+
{ channel: `openai-compat-${mode}`, sender, conversationId, text: out.content },
|
|
1322
|
+
logger
|
|
1323
|
+
);
|
|
1302
1324
|
return c.json({
|
|
1303
1325
|
id,
|
|
1304
1326
|
object: "chat.completion",
|
|
1305
1327
|
created,
|
|
1306
1328
|
model: serverModel,
|
|
1307
1329
|
choices: [
|
|
1308
|
-
{ index: 0, message: { role: "assistant", content:
|
|
1330
|
+
{ index: 0, message: { role: "assistant", content: reply ?? "" }, finish_reason: "stop" }
|
|
1309
1331
|
],
|
|
1310
1332
|
usage: out.usage
|
|
1311
1333
|
});
|
|
@@ -1335,7 +1357,7 @@ function wantsStream(c) {
|
|
|
1335
1357
|
return acc.includes("text/event-stream");
|
|
1336
1358
|
}
|
|
1337
1359
|
function privateRoutes(deps) {
|
|
1338
|
-
const { client, store, config, prompts } = deps;
|
|
1360
|
+
const { client, store, config, prompts, logger } = deps;
|
|
1339
1361
|
const app = new import_hono3.Hono();
|
|
1340
1362
|
const requirePrivateJWT = createJWTMiddleware(config);
|
|
1341
1363
|
const { limitPrivate } = createRateLimiter(config);
|
|
@@ -1390,7 +1412,12 @@ function privateRoutes(deps) {
|
|
|
1390
1412
|
sender,
|
|
1391
1413
|
model
|
|
1392
1414
|
});
|
|
1393
|
-
|
|
1415
|
+
const reply = await applyTransformReply(
|
|
1416
|
+
config.transformReply,
|
|
1417
|
+
{ channel: "widget-private", sender, text: out.content },
|
|
1418
|
+
logger
|
|
1419
|
+
);
|
|
1420
|
+
return c.json({ reply: reply ?? "" });
|
|
1394
1421
|
});
|
|
1395
1422
|
return app;
|
|
1396
1423
|
}
|
|
@@ -1548,7 +1575,12 @@ function publicRoutes(deps) {
|
|
|
1548
1575
|
});
|
|
1549
1576
|
}
|
|
1550
1577
|
const out = await answerOnce({ answerFn, client, system, messages, mode: "public", model });
|
|
1551
|
-
|
|
1578
|
+
const reply = await applyTransformReply(
|
|
1579
|
+
config.transformReply,
|
|
1580
|
+
{ channel: "widget-public", text: out.content },
|
|
1581
|
+
logger
|
|
1582
|
+
);
|
|
1583
|
+
return c.json({ reply: reply ?? "" });
|
|
1552
1584
|
});
|
|
1553
1585
|
return app;
|
|
1554
1586
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -215,6 +215,18 @@ async function answerOnce({
|
|
|
215
215
|
}
|
|
216
216
|
return completeOnce({ client, system, messages, temperature, model });
|
|
217
217
|
}
|
|
218
|
+
async function applyTransformReply(transformReply, input, logger) {
|
|
219
|
+
if (!transformReply) return input.text;
|
|
220
|
+
try {
|
|
221
|
+
return await transformReply(input);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
logger?.error(
|
|
224
|
+
`transformReply threw for channel "${input.channel}"; sending the original reply`,
|
|
225
|
+
error
|
|
226
|
+
);
|
|
227
|
+
return input.text;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
218
230
|
async function* answerStream({
|
|
219
231
|
answerFn,
|
|
220
232
|
client,
|
|
@@ -1045,7 +1057,12 @@ function demoRoutes(deps) {
|
|
|
1045
1057
|
mode: "public",
|
|
1046
1058
|
model
|
|
1047
1059
|
});
|
|
1048
|
-
|
|
1060
|
+
const reply = await applyTransformReply(
|
|
1061
|
+
config.transformReply,
|
|
1062
|
+
{ channel: "widget-demo", text: out.content },
|
|
1063
|
+
logger
|
|
1064
|
+
);
|
|
1065
|
+
return c.json({ reply: reply ?? "" });
|
|
1049
1066
|
} catch (error) {
|
|
1050
1067
|
const err = error;
|
|
1051
1068
|
logger.error("Demo chat error:", err);
|
|
@@ -1169,7 +1186,7 @@ function oversizedBodyError(message) {
|
|
|
1169
1186
|
return { error: { message, type: "invalid_request_error" } };
|
|
1170
1187
|
}
|
|
1171
1188
|
function openaiRoutes(deps) {
|
|
1172
|
-
const { client, store, config, prompts, apiKeyManager } = deps;
|
|
1189
|
+
const { client, store, config, prompts, apiKeyManager, logger } = deps;
|
|
1173
1190
|
const app = new Hono2();
|
|
1174
1191
|
const { limitPublic, limitPrivate } = createRateLimiter(config);
|
|
1175
1192
|
const requirePrivateJWT = createJWTMiddleware(config);
|
|
@@ -1264,13 +1281,18 @@ function openaiRoutes(deps) {
|
|
|
1264
1281
|
temperature,
|
|
1265
1282
|
model: serverModel
|
|
1266
1283
|
});
|
|
1284
|
+
const reply = await applyTransformReply(
|
|
1285
|
+
config.transformReply,
|
|
1286
|
+
{ channel: `openai-compat-${mode}`, sender, conversationId, text: out.content },
|
|
1287
|
+
logger
|
|
1288
|
+
);
|
|
1267
1289
|
return c.json({
|
|
1268
1290
|
id,
|
|
1269
1291
|
object: "chat.completion",
|
|
1270
1292
|
created,
|
|
1271
1293
|
model: serverModel,
|
|
1272
1294
|
choices: [
|
|
1273
|
-
{ index: 0, message: { role: "assistant", content:
|
|
1295
|
+
{ index: 0, message: { role: "assistant", content: reply ?? "" }, finish_reason: "stop" }
|
|
1274
1296
|
],
|
|
1275
1297
|
usage: out.usage
|
|
1276
1298
|
});
|
|
@@ -1300,7 +1322,7 @@ function wantsStream(c) {
|
|
|
1300
1322
|
return acc.includes("text/event-stream");
|
|
1301
1323
|
}
|
|
1302
1324
|
function privateRoutes(deps) {
|
|
1303
|
-
const { client, store, config, prompts } = deps;
|
|
1325
|
+
const { client, store, config, prompts, logger } = deps;
|
|
1304
1326
|
const app = new Hono3();
|
|
1305
1327
|
const requirePrivateJWT = createJWTMiddleware(config);
|
|
1306
1328
|
const { limitPrivate } = createRateLimiter(config);
|
|
@@ -1355,7 +1377,12 @@ function privateRoutes(deps) {
|
|
|
1355
1377
|
sender,
|
|
1356
1378
|
model
|
|
1357
1379
|
});
|
|
1358
|
-
|
|
1380
|
+
const reply = await applyTransformReply(
|
|
1381
|
+
config.transformReply,
|
|
1382
|
+
{ channel: "widget-private", sender, text: out.content },
|
|
1383
|
+
logger
|
|
1384
|
+
);
|
|
1385
|
+
return c.json({ reply: reply ?? "" });
|
|
1359
1386
|
});
|
|
1360
1387
|
return app;
|
|
1361
1388
|
}
|
|
@@ -1513,7 +1540,12 @@ function publicRoutes(deps) {
|
|
|
1513
1540
|
});
|
|
1514
1541
|
}
|
|
1515
1542
|
const out = await answerOnce({ answerFn, client, system, messages, mode: "public", model });
|
|
1516
|
-
|
|
1543
|
+
const reply = await applyTransformReply(
|
|
1544
|
+
config.transformReply,
|
|
1545
|
+
{ channel: "widget-public", text: out.content },
|
|
1546
|
+
logger
|
|
1547
|
+
);
|
|
1548
|
+
return c.json({ reply: reply ?? "" });
|
|
1517
1549
|
});
|
|
1518
1550
|
return app;
|
|
1519
1551
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Client as LibsqlClient } from "@libsql/client";
|
|
|
8
8
|
import type { Hono } from "hono";
|
|
9
9
|
import type OpenAI from "openai";
|
|
10
10
|
import type { Channel, ChannelSenderRegistry } from "./channels";
|
|
11
|
-
import type { AnswerFn } from "./core/answer";
|
|
11
|
+
import type { AnswerFn, TransformReply } from "./core/answer";
|
|
12
12
|
import type { BucketsFor } from "./core/buckets";
|
|
13
13
|
import type { Logger, LogLevel } from "./core/logger";
|
|
14
14
|
import type { PromptLoader } from "./core/prompts";
|
|
@@ -234,6 +234,22 @@ export interface ChatterConfig {
|
|
|
234
234
|
* errors. Unset: the built-in OpenAI completion is used.
|
|
235
235
|
*/
|
|
236
236
|
answerFn?: AnswerFn;
|
|
237
|
+
/**
|
|
238
|
+
* Modifies or vetoes an outgoing reply after it has already been produced
|
|
239
|
+
* (by `answerFn` or the built-in completion, past guardrails). Return a
|
|
240
|
+
* string to replace the reply, or `null` to veto it — a deliberate drop,
|
|
241
|
+
* treated the same as an empty answer: nothing is delivered, and the
|
|
242
|
+
* channel pipeline never records an assistant turn for it (the user's own
|
|
243
|
+
* turn, already appended before answering, stays recorded either way). A
|
|
244
|
+
* throw/rejection is logged and the ORIGINAL reply is sent.
|
|
245
|
+
*
|
|
246
|
+
* Consulted by the channel pipeline and every non-streaming HTTP chat
|
|
247
|
+
* surface (widget and demo routes, OpenAI-compatible endpoints, MCP chat
|
|
248
|
+
* tools). Streaming responses are delivered incrementally as they're
|
|
249
|
+
* produced, before a final answer exists to transform, so this hook is
|
|
250
|
+
* never consulted for them. Unset: replies pass through unchanged.
|
|
251
|
+
*/
|
|
252
|
+
transformReply?: TransformReply;
|
|
237
253
|
/**
|
|
238
254
|
* Decides which knowledge buckets each chat turn may retrieve from, given
|
|
239
255
|
* the pipeline mode and — where the surface knows it — the sender's
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEtD;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,CAAC;QACf,qBAAqB;QACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;QACrC,8BAA8B;QAC9B,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegoaltoworks/chatter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "Embeddable AI chatbot framework with RAG, authentication, and customizable widgets",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -63,6 +63,11 @@
|
|
|
63
63
|
"import": "./dist/channels/whatsapp/index.mjs",
|
|
64
64
|
"require": "./dist/channels/whatsapp/index.js"
|
|
65
65
|
},
|
|
66
|
+
"./telegram": {
|
|
67
|
+
"types": "./dist/channels/telegram/index.d.ts",
|
|
68
|
+
"import": "./dist/channels/telegram/index.mjs",
|
|
69
|
+
"require": "./dist/channels/telegram/index.js"
|
|
70
|
+
},
|
|
66
71
|
"./images": {
|
|
67
72
|
"types": "./dist/images/index.d.ts",
|
|
68
73
|
"import": "./dist/images/index.mjs",
|
|
@@ -83,7 +88,7 @@
|
|
|
83
88
|
],
|
|
84
89
|
"scripts": {
|
|
85
90
|
"dev": "bun --watch src/index.ts",
|
|
86
|
-
"build": "bun run build:clean && bun run build:types && bun run build:esm && bun run build:cjs && bun run build:server && bun run build:mcp && bun run build:usage && bun run build:history && bun run build:personas && bun run build:channels && bun run build:whatsapp && bun run build:flows && bun run build:images && bun run build:scheduler && bun run build:bin && bun run build:client && bun run build:copy-client",
|
|
91
|
+
"build": "bun run build:clean && bun run build:types && bun run build:esm && bun run build:cjs && bun run build:server && bun run build:mcp && bun run build:usage && bun run build:history && bun run build:personas && bun run build:channels && bun run build:whatsapp && bun run build:telegram && bun run build:flows && bun run build:images && bun run build:scheduler && bun run build:bin && bun run build:client && bun run build:copy-client",
|
|
87
92
|
"build:clean": "rm -rf dist",
|
|
88
93
|
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
|
|
89
94
|
"build:esm": "esbuild src/index.ts --bundle --format=esm --outfile=dist/index.mjs --external:@hono/node-server --external:hono --external:openai --external:@libsql/client --external:jose --external:@modelcontextprotocol/sdk --external:zod --platform=node --target=node24",
|
|
@@ -95,6 +100,7 @@
|
|
|
95
100
|
"build:personas": "esbuild src/personas/index.ts --bundle --format=esm --outfile=dist/personas/index.mjs --platform=node --target=node24 && esbuild src/personas/index.ts --bundle --format=cjs --outfile=dist/personas/index.js --platform=node --target=node24",
|
|
96
101
|
"build:channels": "esbuild src/channels/index.ts --bundle --format=esm --outfile=dist/channels/index.mjs --external:hono --external:openai --external:@libsql/client --platform=node --target=node24 && esbuild src/channels/index.ts --bundle --format=cjs --outfile=dist/channels/index.js --external:hono --external:openai --external:@libsql/client --platform=node --target=node24",
|
|
97
102
|
"build:whatsapp": "esbuild src/channels/whatsapp/index.ts --bundle --format=esm --outfile=dist/channels/whatsapp/index.mjs --external:@libsql/client --external:@whiskeysockets/baileys --platform=node --target=node24 && esbuild src/channels/whatsapp/index.ts --bundle --format=cjs --outfile=dist/channels/whatsapp/index.js --external:@libsql/client --external:@whiskeysockets/baileys --platform=node --target=node24",
|
|
103
|
+
"build:telegram": "esbuild src/channels/telegram/index.ts --bundle --format=esm --outfile=dist/channels/telegram/index.mjs --external:@libsql/client --external:openai --platform=node --target=node24 && esbuild src/channels/telegram/index.ts --bundle --format=cjs --outfile=dist/channels/telegram/index.js --external:@libsql/client --external:openai --platform=node --target=node24",
|
|
98
104
|
"build:flows": "esbuild src/flows/index.ts --bundle --format=esm --outfile=dist/flows/index.mjs --external:@libsql/client --external:openai --platform=node --target=node24 && esbuild src/flows/index.ts --bundle --format=cjs --outfile=dist/flows/index.js --external:@libsql/client --external:openai --platform=node --target=node24",
|
|
99
105
|
"build:images": "esbuild src/images/index.ts --bundle --format=esm --outfile=dist/images/index.mjs --external:@libsql/client --external:openai --platform=node --target=node24 && esbuild src/images/index.ts --bundle --format=cjs --outfile=dist/images/index.js --external:@libsql/client --external:openai --platform=node --target=node24",
|
|
100
106
|
"build:scheduler": "esbuild src/scheduler/index.ts --bundle --format=esm --outfile=dist/scheduler/index.mjs --external:@libsql/client --external:openai --platform=node --target=node24 && esbuild src/scheduler/index.ts --bundle --format=cjs --outfile=dist/scheduler/index.js --external:@libsql/client --external:openai --platform=node --target=node24",
|