@segmentstream/agent 0.91.2 → 0.93.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 (118) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -3
  3. package/dist/_chunks/{build-metadata-CsM7GfS1.mjs → build-metadata-CP0iLqzp.mjs} +1 -1
  4. package/dist/_chunks/{chat-archive-Btd3gajb.mjs → chat-archive-DmCXcI8G.mjs} +44 -10
  5. package/dist/_chunks/{chat-archive-DavfKJDI.mjs → chat-archive-_IBU0CXG.mjs} +7 -2
  6. package/dist/_chunks/{principal-CY72xYFi.mjs → principal-DL9NdRRP.mjs} +5 -1
  7. package/dist/_chunks/{silent-DK7m_iab.mjs → silent-xJcJ8SNJ.mjs} +1 -1
  8. package/dist/extension/_manifest.json +1 -1
  9. package/dist/extension/config.d.ts +9 -0
  10. package/dist/extension/config.mjs +25 -0
  11. package/dist/extension/connections/ontology.mjs +1 -1
  12. package/dist/extension/hooks/authorization.mjs +1 -1
  13. package/dist/extension/hooks/chat-context.mjs +1 -1
  14. package/dist/extension/hooks/chat-recorder.mjs +1 -1
  15. package/dist/extension/instructions/persona.mjs +1 -1
  16. package/dist/extension/lib/actor.mjs +1 -1
  17. package/dist/extension/lib/attachment-tools.mjs +1 -1
  18. package/dist/extension/lib/attachments-dispatch.mjs +2 -2
  19. package/dist/extension/lib/attachments-send.mjs +1 -1
  20. package/dist/extension/lib/attachments.mjs +1 -1
  21. package/dist/extension/lib/build-metadata.mjs +1 -1
  22. package/dist/extension/lib/chat-address.mjs +1 -1
  23. package/dist/extension/lib/chat-archive.d.ts +1 -0
  24. package/dist/extension/lib/chat-archive.mjs +1 -1
  25. package/dist/extension/lib/chat-context.mjs +6 -5
  26. package/dist/extension/lib/chat-messages.d.ts +1 -1
  27. package/dist/extension/lib/chat-messages.mjs +3 -2
  28. package/dist/extension/lib/chat-persona.d.ts +2 -0
  29. package/dist/extension/lib/chat-persona.mjs +6 -6
  30. package/dist/extension/lib/chat-recorder.mjs +13 -10
  31. package/dist/extension/lib/chat-store.d.ts +21 -10
  32. package/dist/extension/lib/chats.d.ts +2 -0
  33. package/dist/extension/lib/chats.mjs +4 -2
  34. package/dist/extension/lib/confirmations.mjs +1 -1
  35. package/dist/extension/lib/email/attachments-send.mjs +1 -1
  36. package/dist/extension/lib/email/channel.mjs +3 -3
  37. package/dist/extension/lib/group-routing/messages.d.ts +1 -0
  38. package/dist/extension/lib/group-routing/routing-context.mjs +6 -4
  39. package/dist/extension/lib/guest-usage.mjs +1 -1
  40. package/dist/extension/lib/inbound-media/files.mjs +1 -1
  41. package/dist/extension/lib/inbound-media/index.mjs +1 -1
  42. package/dist/extension/lib/model-service-alert.mjs +1 -1
  43. package/dist/extension/lib/ontology-connection.mjs +1 -1
  44. package/dist/extension/lib/ontology-file-call.mjs +1 -1
  45. package/dist/extension/lib/ontology-recall.mjs +1 -1
  46. package/dist/extension/lib/ontology-tools.mjs +1 -1
  47. package/dist/extension/lib/public-group.d.ts +19 -0
  48. package/dist/extension/lib/public-group.mjs +77 -0
  49. package/dist/extension/lib/review/files.mjs +1 -1
  50. package/dist/extension/lib/review/hold.mjs +1 -1
  51. package/dist/extension/lib/review/judge.mjs +1 -1
  52. package/dist/extension/lib/review/reply.mjs +3 -3
  53. package/dist/extension/lib/review/revision-channel.mjs +1 -1
  54. package/dist/extension/lib/role-skill.mjs +1 -1
  55. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  56. package/dist/extension/lib/sent-files.mjs +1 -1
  57. package/dist/extension/lib/slack/adapter.d.ts +1 -0
  58. package/dist/extension/lib/slack/adapter.mjs +22 -6
  59. package/dist/extension/lib/slack/attachments-send.mjs +1 -1
  60. package/dist/extension/lib/slack/callbacks.mjs +1 -1
  61. package/dist/extension/lib/slack/changes.mjs +1 -1
  62. package/dist/extension/lib/slack/confirmation-card.mjs +1 -1
  63. package/dist/extension/lib/stored-files.mjs +1 -1
  64. package/dist/extension/lib/telegram/adapter.mjs +20 -8
  65. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  66. package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
  67. package/dist/extension/lib/telegram/bot.d.ts +1 -1
  68. package/dist/extension/lib/telegram/bot.mjs +2 -2
  69. package/dist/extension/lib/telegram/callbacks.mjs +1 -1
  70. package/dist/extension/lib/telegram/chat-archive.d.ts +3 -1
  71. package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
  72. package/dist/extension/lib/telegram/confirmations.mjs +3 -3
  73. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  74. package/dist/extension/lib/telegram/delivery-diagnostics.mjs +1 -1
  75. package/dist/extension/lib/telegram/files.mjs +1 -1
  76. package/dist/extension/lib/telegram/health.mjs +1 -1
  77. package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
  78. package/dist/extension/lib/telegram/inbound-request.d.ts +1 -0
  79. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  80. package/dist/extension/lib/telegram/inbound.mjs +28 -3
  81. package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
  82. package/dist/extension/lib/telegram/membership.mjs +8 -2
  83. package/dist/extension/lib/telegram/message-reference.d.ts +3 -0
  84. package/dist/extension/lib/telegram/message-reference.mjs +11 -0
  85. package/dist/extension/lib/telegram/principal.mjs +1 -1
  86. package/dist/extension/lib/telegram/routing-context.mjs +1 -1
  87. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  88. package/dist/extension/lib/telegram/silent.mjs +1 -1
  89. package/dist/extension/lib/telegram/store-capture.mjs +1 -1
  90. package/dist/extension/lib/telegram/structured.mjs +1 -1
  91. package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
  92. package/dist/extension/lib/web/auth.mjs +1 -1
  93. package/dist/extension/lib/web/channel.mjs +1 -1
  94. package/dist/extension/lib/web-search.d.ts +2 -0
  95. package/dist/extension/lib/web-search.mjs +1 -1
  96. package/dist/extension/lib/whatsapp/adapter.mjs +2 -2
  97. package/dist/extension/lib/whatsapp/attachments-send.mjs +2 -2
  98. package/dist/extension/lib/whatsapp/callbacks.mjs +1 -1
  99. package/dist/extension/lib/whatsapp/changes.mjs +1 -1
  100. package/dist/extension/lib/whatsapp/files.mjs +1 -1
  101. package/dist/extension/lib/whatsapp/sent.mjs +1 -1
  102. package/dist/extension/lib/workspace-action.mjs +1 -1
  103. package/dist/extension/lib/workspace-channel/attachments-send.mjs +1 -1
  104. package/dist/extension/lib/workspace-channel/channel.mjs +3 -3
  105. package/dist/extension/lib/workspace-chat-archive.mjs +1 -1
  106. package/dist/extension/lib/workspace-source.mjs +1 -1
  107. package/dist/extension/model.mjs +1 -1
  108. package/dist/extension/tools/attachments_discard.mjs +1 -1
  109. package/dist/extension/tools/attachments_list.mjs +1 -1
  110. package/dist/extension/tools/attachments_promote.mjs +1 -1
  111. package/dist/extension/tools/attachments_read.mjs +1 -1
  112. package/dist/extension/tools/attachments_send.mjs +2 -2
  113. package/dist/extension/tools/attachments_stage.mjs +1 -1
  114. package/dist/extension/tools/attachments_table.mjs +1 -1
  115. package/dist/extension/tools/handoff.mjs +1 -1
  116. package/dist/extension/tools/questions_ask.mjs +1 -1
  117. package/dist/extension/tools/workspace_source.mjs +1 -1
  118. package/package.json +4 -4
@@ -4,12 +4,13 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
+ import { answerPublicGroup, isPublicGroup, publicGroupInvite } from "../public-group.mjs";
7
8
  import { admitMessage, localizedText } from "../admission.mjs";
8
9
  import { agentToolsAttribute } from "../agent-tools.mjs";
9
10
  import { agentChats, channelChats } from "../chats.mjs";
10
11
  import { withButtonDecision } from "../confirmation-buttons.mjs";
11
12
  import { personaPrincipal } from "../chat-persona.mjs";
12
- import { Vt as withChatAddress, b as agentAttachments, d as prepareInboundMedia, m as turnContent } from "../../../_chunks/principal-CY72xYFi.mjs";
13
+ import { Vt as withChatAddress, b as agentAttachments, d as prepareInboundMedia, m as turnContent } from "../../../_chunks/principal-DL9NdRRP.mjs";
13
14
  import { channelAttributes, currentChannel, withNamedRoutes, withSessionChannels } from "../channel-scope.mjs";
14
15
  import { redactDiagnostic } from "../diagnostics.mjs";
15
16
  import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
@@ -26,7 +27,7 @@ import { pairingNotice } from "./pairing.mjs";
26
27
  import { recordThreadHistory } from "./thread-history.mjs";
27
28
  import { channelReview, withReviewedReplies } from "../review/reply.mjs";
28
29
  import { runtimeToken } from "../runtime-token.mjs";
29
- import { r as chatArchive } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
30
+ import { r as chatArchive } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
30
31
  import { recordHandledMessage, recordReceivedMessage, stagedFiles } from "../chat-messages.mjs";
31
32
  import { recordSlackChange, slackChange, slackTime } from "./changes.mjs";
32
33
  import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
@@ -77,7 +78,8 @@ async function reportMembership(input) {
77
78
  if (typeof bot === "string" && user === bot) {
78
79
  if (joined) await input.chats.joined({
79
80
  chatId,
80
- title
81
+ title,
82
+ ...typeof event.inviter === "string" && event.inviter !== bot && event.inviter ? { inviter: event.inviter } : {}
81
83
  });
82
84
  else await input.chats.agentLeft({
83
85
  chatId,
@@ -229,7 +231,8 @@ function segmentstreamSlack(options) {
229
231
  });
230
232
  const registry = options.chats ?? channelChats("slack", (provider) => agentChats({
231
233
  provider,
232
- identities: pairing
234
+ identities: pairing,
235
+ onInvite: (chat, inviter) => publicGroupInvite(options.admission(), "slack", provider, chat, inviter)
233
236
  }));
234
237
  const chats = () => registry;
235
238
  let records = options.archive;
@@ -275,12 +278,13 @@ function segmentstreamSlack(options) {
275
278
  report: reportWithReference
276
279
  }) }
277
280
  };
278
- const admit = (direct) => (ctx, message) => {
281
+ const admit = (direct, mention = false) => (ctx, message) => {
279
282
  const work = requestWork.getStore();
280
283
  return receive({
281
284
  ctx,
282
285
  message,
283
286
  direct,
287
+ mention,
284
288
  admission: options.admission(),
285
289
  identities: pairing(),
286
290
  environment,
@@ -350,7 +354,7 @@ function segmentstreamSlack(options) {
350
354
  fetch: slackFetch
351
355
  },
352
356
  renderers: [slackConfirmationRenderer(options.texts ?? (() => ({})))],
353
- onAppMention: admit(false),
357
+ onAppMention: admit(false, true),
354
358
  onDirectMessage: admit(true),
355
359
  onMessage: async (ctx, message) => {
356
360
  if (!await followsThreadReply({
@@ -476,6 +480,18 @@ async function receive(input) {
476
480
  } } : {},
477
481
  inboxFailed: (error) => report("inbox_report_failed", error)
478
482
  });
483
+ if (!input.direct && (resolution.status === "pairing_required" || resolution.status === "existing" || resolution.status === "created") && await isPublicGroup(admission, currentChannel("slack"), ctx.slack.channelId, user)) {
484
+ if (input.mention && ctx.edit === void 0) await answerPublicGroup({
485
+ admission,
486
+ channel: currentChannel("slack"),
487
+ chat: ctx.slack.channelId,
488
+ sender: user,
489
+ message: message.ts,
490
+ text: message.text,
491
+ post: (text) => ctx.thread.post(text)
492
+ });
493
+ return null;
494
+ }
479
495
  switch (resolution.status) {
480
496
  case "existing":
481
497
  case "created":
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { _ as AttachmentError } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { _ as AttachmentError } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { sendStoredAttachments } from "../attachments-send.mjs";
9
9
  import { connectionProxy } from "../connection-proxy.mjs";
10
10
  import { redactDiagnostic } from "../diagnostics.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { Ot as runtimeEnvelope, Rt as chatRuntimeSource, Vt as withChatAddress } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { Ot as runtimeEnvelope, Rt as chatRuntimeSource, Vt as withChatAddress } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { currentChannel } from "../channel-scope.mjs";
9
9
  import { pressWorkspaceButton, queueWorkspaceButtonTurn, workspaceAction, workspaceButtonToken } from "../workspace-action.mjs";
10
10
  import { pairingNotice } from "./pairing.mjs";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { currentChannel } from "../channel-scope.mjs";
8
- import { p as storeOf } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
8
+ import { p as storeOf } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
9
9
  import { applyChatChange } from "../chat-messages.mjs";
10
10
  import { defaultEmojiResolver } from "chat";
11
11
  function record(value) {
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { object } from "../confirmation-description.mjs";
8
- import { F as confirmations } from "../../../_chunks/principal-CY72xYFi.mjs";
8
+ import { F as confirmations } from "../../../_chunks/principal-DL9NdRRP.mjs";
9
9
  import { chatPostReceipt } from "../telegram/chat-post-card.mjs";
10
10
  import { renderConfirmation } from "../telegram/confirmation-text.mjs";
11
11
  import { telegramText, withTelegramTexts } from "../telegram/texts.mjs";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { object } from "./confirmation-description.mjs";
8
- import { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-CY72xYFi.mjs";
8
+ import { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-DL9NdRRP.mjs";
9
9
  import { redactDiagnostic } from "./diagnostics.mjs";
10
10
  import { createHash } from "node:crypto";
11
11
  async function readStoredFile(input, principal, options = {}) {
@@ -4,6 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
+ import { publicGroupInvite } from "../public-group.mjs";
7
8
  import { logConfirmationPress } from "./confirmation-press.mjs";
8
9
  import { object } from "../confirmation-description.mjs";
9
10
  import { archivedRoutingMessages } from "../group-routing/routing-context.mjs";
@@ -11,22 +12,22 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
11
12
  import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
12
13
  import { handleWorkspaceCallback } from "./callbacks.mjs";
13
14
  import { telegramText, withTelegramTexts } from "./texts.mjs";
14
- import { t as agentBuild } from "../../../_chunks/build-metadata-CsM7GfS1.mjs";
15
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CP0iLqzp.mjs";
15
16
  import { attachmentLifecycle } from "./lifecycle.mjs";
16
17
  import { manifestOf } from "../../config.mjs";
17
18
  import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
18
19
  import { chooseModel } from "../../model.mjs";
19
- import { Ct as withDeliveryLocale, S as fetchStoredAttachment, St as safeTelegramFetch, b as agentAttachments, c as currentInboundRequest, l as runInboundRequest, mt as currentLocale, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-CY72xYFi.mjs";
20
+ import { Ct as withDeliveryLocale, S as fetchStoredAttachment, St as safeTelegramFetch, b as agentAttachments, c as currentInboundRequest, l as runInboundRequest, mt as currentLocale, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-DL9NdRRP.mjs";
20
21
  import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
21
22
  import { appOrigin, channelsEnabled, proxyEnvironment, runtimeIdentityEnvironment, webhookSecret } from "../environment.mjs";
22
23
  import { agentIdentities } from "../identities.mjs";
23
- import { h as topicContext, r as chatArchive } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
24
- import { a as captureTelegramFetch, h as telegramChatCapture, i as captureRouteDecider, s as chatIdentities, u as recordGateDecision } from "../../../_chunks/chat-archive-Btd3gajb.mjs";
24
+ import { h as topicContext, r as chatArchive } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
25
+ import { a as captureTelegramFetch, h as telegramChatCapture, i as captureRouteDecider, s as chatIdentities, u as recordGateDecision } from "../../../_chunks/chat-archive-DmCXcI8G.mjs";
25
26
  import { runtimeTokenVerifier } from "../runtime-identity.mjs";
26
27
  import { runtimeToken } from "../runtime-token.mjs";
27
28
  import { botIdentityCache, proxiedBotRequest, runtimeBotIdentity } from "./bot.mjs";
28
- import { handleConfirmationCallback, telegramConfirmationEvents } from "./confirmations.mjs";
29
29
  import { isWorkspaceCallback } from "../workspace-action.mjs";
30
+ import { handleConfirmationCallback, telegramConfirmationEvents } from "./confirmations.mjs";
30
31
  import { confirmationLocale } from "./confirmation-text.mjs";
31
32
  import { telegramAppLinkContext } from "./app-links.mjs";
32
33
  import { gatewayImageDescriber } from "../inbound-media/images.mjs";
@@ -40,7 +41,7 @@ import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch }
40
41
  import { healthRoute } from "./health.mjs";
41
42
  import { decisionRouter } from "../group-routing/router.mjs";
42
43
  import { scopedAddress } from "./sessions.mjs";
43
- import { a as isNoReplyCall, i as interimTexts, s as replyDelivery } from "../../../_chunks/silent-DK7m_iab.mjs";
44
+ import { a as isNoReplyCall, i as interimTexts, s as replyDelivery } from "../../../_chunks/silent-xJcJ8SNJ.mjs";
44
45
  import { channelReview, holdFilesAfterTurn } from "../review/reply.mjs";
45
46
  import { telegramSendScope } from "./send-queue.mjs";
46
47
  import { telegramFailureEvents } from "./turn-errors.mjs";
@@ -139,6 +140,15 @@ function segmentstreamTelegram(options) {
139
140
  }
140
141
  return runtimeBotIdentity(telegramSendScope(environment, connection), own);
141
142
  }
143
+ function telegramBotId() {
144
+ const inbound = currentInboundRequest();
145
+ const resolve = async () => {
146
+ const bot = await botIdentity()({ request: botRequest }, true);
147
+ if (bot === void 0 || !/^[1-9]\d*$/u.test(bot.id)) throw new Error("Telegram did not identify the bot for message capture.");
148
+ return bot.id;
149
+ };
150
+ return inbound === void 0 ? resolve() : inbound.telegramBotId ??= resolve();
151
+ }
142
152
  function pairing() {
143
153
  identities ??= agentIdentities({
144
154
  origin: appOrigin(environment),
@@ -149,10 +159,12 @@ function segmentstreamTelegram(options) {
149
159
  }
150
160
  const chats = channelChats("telegram", (provider) => agentChats({
151
161
  provider,
152
- identities: pairing
162
+ identities: pairing,
163
+ onInvite: (chat, inviter) => publicGroupInvite(options.admission?.() ?? manifestOf({}), "telegram", provider, chat, inviter)
153
164
  }));
154
165
  const capture = telegramChatCapture({
155
166
  archive,
167
+ telegramBotId,
156
168
  identities: pairing,
157
169
  chats,
158
170
  structured: (raw) => {
@@ -204,7 +216,7 @@ function segmentstreamTelegram(options) {
204
216
  api: {
205
217
  apiBaseUrl: TELEGRAM_PROXY_ORIGIN,
206
218
  fileBaseUrl: TELEGRAM_PROXY_ORIGIN,
207
- fetch: (input, init) => safeTelegramFetch(captureTelegramFetch(telegramProxyFetch(proxy(), telegramSendScope(environment, settings().connection)), archive, pairing), telegramSendScope(environment, settings().connection), {
219
+ fetch: (input, init) => safeTelegramFetch(captureTelegramFetch(telegramProxyFetch(proxy(), telegramSendScope(environment, settings().connection)), archive, pairing, telegramBotId), telegramSendScope(environment, settings().connection), {
208
220
  settings: settings(),
209
221
  ownOrigins: telegramPreviewEnvironment(environment).appOrigins
210
222
  }, telegramAppLinkContext(settings(), environment, async () => (await botIdentity()({ request: botRequest }))?.username), settings().identifiers ?? "block")(input, init)
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { describableImage } from "../inbound-media/images.mjs";
8
- import { xt as reportTelegramError } from "../../../_chunks/principal-CY72xYFi.mjs";
8
+ import { xt as reportTelegramError } from "../../../_chunks/principal-DL9NdRRP.mjs";
9
9
  import { gateway, generateText } from "ai";
10
10
  const MAXIMUM_ROUTING_ATTACHMENT_BYTES = 5242880;
11
11
  const ROUTING_ATTACHMENT_TIMEOUT_MS = 15e3;
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { attachmentOwner } from "../attachment-tools.mjs";
8
- import { _ as AttachmentError, _t as customerMessage, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-CY72xYFi.mjs";
8
+ import { _ as AttachmentError, _t as customerMessage, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-DL9NdRRP.mjs";
9
9
  import { attachmentFailure } from "../attachments-send.mjs";
10
10
  import { connectionProxy } from "../connection-proxy.mjs";
11
11
  import { StoredFileError, fetchStoredFile } from "../sent-files.mjs";
@@ -1,7 +1,7 @@
1
1
  import type { TelegramHandle } from "eve/channels/telegram";
2
2
  import type { ConnectionProxy } from "../connection-proxy.js";
3
3
  import type { BotIdentity } from "./router.js";
4
- export type BotIdentityLookup = (telegram: Pick<TelegramHandle, "request">) => Promise<BotIdentity | undefined>;
4
+ export type BotIdentityLookup = (telegram: Pick<TelegramHandle, "request">, refresh?: boolean) => Promise<BotIdentity | undefined>;
5
5
  export declare function botIdentityCache(now?: () => number): BotIdentityLookup;
6
6
  /**
7
7
  * A Bot API call outside any chat, through the connection proxy, for the bot identity cache when it
@@ -21,8 +21,8 @@ function identityFrom(body) {
21
21
  }
22
22
  function botIdentityCache(now = Date.now) {
23
23
  let cached;
24
- return async (telegram) => {
25
- if (cached !== void 0 && cached.until > now()) return cached.identity;
24
+ return async (telegram, refresh = false) => {
25
+ if (!refresh && cached !== void 0 && cached.until > now()) return cached.identity;
26
26
  let identity;
27
27
  try {
28
28
  const response = await telegram.request("getMe");
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { Ot as runtimeEnvelope, c as currentInboundRequest, i as memberIdOf, kt as telegramRuntimeSource, o as telegramPrincipal, xt as reportTelegramError } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { Ot as runtimeEnvelope, c as currentInboundRequest, i as memberIdOf, kt as telegramRuntimeSource, o as telegramPrincipal, xt as reportTelegramError } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { formatAddress, parseAddress, scopedAddress } from "./sessions.mjs";
9
9
  import { telegramText } from "./texts.mjs";
10
10
  import { isWorkspaceCallback, pressWorkspaceButton, queueWorkspaceButtonTurn, workspaceAction, workspaceButtonToken } from "../workspace-action.mjs";
@@ -37,6 +37,7 @@ export declare function attachmentIdentity(files: ChatEvent["attachments"]): str
37
37
  export declare function participants(message: TelegramMessage, identities: AgentIdentities, resolved: (lookup: IdentityLookup) => void): Promise<ReadonlyArray<string>>;
38
38
  /** Runs after webhook verification, before eve drops bot/channel/service updates. */
39
39
  export declare function captureTelegramWebhook(input: {
40
+ readonly telegramBotId?: () => Promise<string>;
40
41
  readonly answerCallback?: (id: string, locale?: string) => Promise<unknown>;
41
42
  readonly structured?: (raw: Readonly<Record<string, unknown>>) => StructuredMessage | undefined;
42
43
  readonly request: Request;
@@ -86,11 +87,12 @@ export declare function recordSessionFailure(input: {
86
87
  };
87
88
  }): Promise<void>;
88
89
  /** Captures message sends and button/status edits, including pairing and proactive replies. */
89
- export declare function captureTelegramFetch(fetchImpl: typeof fetch, archive: ChatArchive, identities: () => AgentIdentities): typeof fetch;
90
+ export declare function captureTelegramFetch(fetchImpl: typeof fetch, archive: ChatArchive, identities: () => AgentIdentities, telegramBotId?: () => Promise<string>): typeof fetch;
90
91
  /** Reuses the request's verified lookup; it never survives into another inbound request. */
91
92
  export declare function chatIdentities(identities: AgentIdentities): AgentIdentities;
92
93
  /** Verification and failure acknowledgement stay outside eve's swallowed onMessage failures. */
93
94
  export declare function telegramChatCapture(input: {
95
+ readonly telegramBotId?: () => Promise<string>;
94
96
  readonly answerCallback?: (id: string, locale?: string) => Promise<unknown>;
95
97
  readonly structured?: (raw: Readonly<Record<string, unknown>>) => StructuredMessage | undefined;
96
98
  readonly archive: ChatArchive;
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { t as REVISION_CLAIM_TTL_MS, n as attachmentIdentity, r as attachmentRefs, i as captureRouteDecider, a as captureTelegramFetch, o as captureTelegramWebhook, s as chatIdentities, c as currentCapture, l as participants, u as recordGateDecision, d as recordInboundContent, f as recordRouteDecision, p as recordSessionFailure, m as registerCapture, h as telegramChatCapture } from "../../../_chunks/chat-archive-Btd3gajb.mjs";
7
+ export { t as REVISION_CLAIM_TTL_MS, n as attachmentIdentity, r as attachmentRefs, i as captureRouteDecider, a as captureTelegramFetch, o as captureTelegramWebhook, s as chatIdentities, c as currentCapture, l as participants, u as recordGateDecision, d as recordInboundContent, f as recordRouteDecision, p as recordSessionFailure, m as registerCapture, h as telegramChatCapture } from "../../../_chunks/chat-archive-DmCXcI8G.mjs";
@@ -6,11 +6,11 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { CONFIRMATION_PREFIX, logConfirmationPress } from "./confirmation-press.mjs";
8
8
  import { telegramText } from "./texts.mjs";
9
- import { F as confirmations, It as chatChannel, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal, xt as reportTelegramError } from "../../../_chunks/principal-CY72xYFi.mjs";
9
+ import { F as confirmations, It as chatChannel, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal, xt as reportTelegramError } from "../../../_chunks/principal-DL9NdRRP.mjs";
10
10
  import { humanText } from "../confirmation-description.mjs";
11
11
  import { withConfirmationPrompt } from "../group-routing/messages.mjs";
12
12
  import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
13
- import { a as chatEvent } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
13
+ import { a as chatEvent } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
14
14
  import { chatPostCard, chatPostCardStatus, chatPostReceipt, withChatPostCard } from "./chat-post-card.mjs";
15
15
  import { answerMarker, isPendingQuestion, pendingQuestions, questionKey } from "../questions.mjs";
16
16
  import { confirmationStatus, renderConfirmation, withConfirmationText } from "./confirmation-text.mjs";
@@ -157,7 +157,7 @@ function questionsFromHistory(events) {
157
157
  if (calls.get(String(data.callId))?.endsWith("__questions_ask") && isPendingQuestion(candidate)) pending.set(questionKey(candidate), candidate);
158
158
  }
159
159
  if (event.type === "delivery.consumed" && Array.isArray(data.parts)) {
160
- const message = data.parts.filter((part) => object(part).kind === "text").map((part) => object(part).text).join("\n").replace(/^\[source-message:\d+;trigger:\d+\]\r?\n/u, "");
160
+ const message = data.parts.filter((part) => object(part).kind === "text").map((part) => object(part).text).join("\n").replace(/^\[source-message:\d+;trigger:\d+(?:;bot:\d+)?\]\r?\n/u, "");
161
161
  for (const [key, question] of pending) if (message.startsWith(answerMarker(question.id))) pending.delete(key);
162
162
  }
163
163
  }
@@ -5,5 +5,5 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { isTechnicalText } from "../customer-text-safety.mjs";
8
- import { Ct as withDeliveryLocale, St as safeTelegramFetch, _t as customerMessage, bt as formattingRefused, gt as customerCopy, ht as currentThreadId, mt as currentLocale, pt as TelegramDeliveryError, vt as customerText, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-CY72xYFi.mjs";
8
+ import { Ct as withDeliveryLocale, St as safeTelegramFetch, _t as customerMessage, bt as formattingRefused, gt as customerCopy, ht as currentThreadId, mt as currentLocale, pt as TelegramDeliveryError, vt as customerText, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-DL9NdRRP.mjs";
9
9
  export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cDtVnr8Y.mjs";
8
- import { a as chatEvent } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
8
+ import { a as chatEvent } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
9
9
  import { currentChannel } from "../channel-scope.mjs";
10
10
  import { redactTelegramDiagnostic } from "./diagnostic-redaction.mjs";
11
11
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { currentChannel } from "../channel-scope.mjs";
8
- import { p as storeFiles, xt as reportTelegramError } from "../../../_chunks/principal-CY72xYFi.mjs";
8
+ import { p as storeFiles, xt as reportTelegramError } from "../../../_chunks/principal-DL9NdRRP.mjs";
9
9
  function telegramChat(chatId) {
10
10
  return `${currentChannel("telegram")}:${chatId}`;
11
11
  }
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { t as agentBuild } from "../../../_chunks/build-metadata-CsM7GfS1.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CP0iLqzp.mjs";
8
8
  import { runtimeRequestFailure } from "./runtime-request.mjs";
9
9
  import { GET } from "eve/channels";
10
10
  const HEALTH_ROUTE = "/eve/v1/telegram/health";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { N as CONFIRMATION_TTL_MS } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { N as CONFIRMATION_TTL_MS } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { object } from "../confirmation-description.mjs";
9
9
  import { SessionNotActiveError } from "eve/sessions";
10
10
  function heldApprovals(events) {
@@ -23,6 +23,7 @@ export declare class InboundRequest {
23
23
  readonly agentDescription: () => Promise<string>;
24
24
  readonly agentName: () => Promise<string>;
25
25
  readonly traceId: `${string}-${string}-${string}-${string}-${string}`;
26
+ telegramBotId?: Promise<string>;
26
27
  edited: boolean;
27
28
  triggeringMessageId: string | undefined;
28
29
  chatId: string | undefined;
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ export { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-DL9NdRRP.mjs";
@@ -6,8 +6,9 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { WorkspaceActionAlreadyDispatched } from "../workspace-action.mjs";
8
8
  import { structuredMessage } from "./structured.mjs";
9
+ import { answerPublicGroup, isPublicGroup } from "../public-group.mjs";
9
10
  import { currentChannel } from "../channel-scope.mjs";
10
- import { Ot as runtimeEnvelope, f as attachmentsContext, kt as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, x as attachmentUrl, xt as reportTelegramError } from "../../../_chunks/principal-CY72xYFi.mjs";
11
+ import { Ot as runtimeEnvelope, f as attachmentsContext, kt as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, x as attachmentUrl, xt as reportTelegramError } from "../../../_chunks/principal-DL9NdRRP.mjs";
11
12
  import { routingBurst } from "../group-routing/burst.mjs";
12
13
  import { telegramSignals } from "./signals.mjs";
13
14
  import { addressingReason, chatKey, otherRecipient } from "../group-routing/signals.mjs";
@@ -29,7 +30,7 @@ import { routingContext } from "./routing-context.mjs";
29
30
  import { formatAddress, messageAddress, scopedAddress } from "./sessions.mjs";
30
31
  import { voiceOf } from "./voice.mjs";
31
32
  import { MAXIMUM_ROUTING_ATTACHMENT_BYTES, describeRoutingAttachment, routingAttachmentDeadline } from "./attachment-description.mjs";
32
- import { d as recordInboundContent, f as recordRouteDecision, u as recordGateDecision } from "../../../_chunks/chat-archive-Btd3gajb.mjs";
33
+ import { d as recordInboundContent, f as recordRouteDecision, u as recordGateDecision } from "../../../_chunks/chat-archive-DmCXcI8G.mjs";
33
34
  import { contentShape, messageContent } from "./content.mjs";
34
35
  import { messageAudience } from "./audience.mjs";
35
36
  const MAXIMUM_QUOTE_LENGTH = 500;
@@ -57,6 +58,7 @@ function authorOf(user, member) {
57
58
  function observedMessage(message, text, member, media, bot) {
58
59
  return {
59
60
  ...messageMetadata(message, bot),
61
+ ...bot === void 0 ? {} : { telegramBotId: bot.id },
60
62
  author: authorOf(message.from, member),
61
63
  authorId: message.from.id,
62
64
  ...message.from.username === void 0 ? {} : { username: message.from.username },
@@ -300,7 +302,14 @@ async function handleInboundMessage(input) {
300
302
  const turn = structured === void 0 && input.request?.structuredContext === void 0 && addressed !== void 0 && hasContent && (addressed !== "reply-to-bot" || elsewhere === void 0);
301
303
  const lookup = await resolve(turn);
302
304
  const group = isGroupChat(sent);
303
- const freshChat = async () => await dependencies.recentChat?.(sent.chat.id, sent.messageThreadId === void 0 ? void 0 : String(sent.messageThreadId)) ?? [];
305
+ const freshChat = async () => {
306
+ return (await dependencies.recentChat?.(sent.chat.id, sent.messageThreadId === void 0 ? void 0 : String(sent.messageThreadId)) ?? []).map((entry) => {
307
+ if (entry.telegramBotId === void 0 || entry.telegramBotId === bot?.id) return entry;
308
+ const history = { ...entry };
309
+ delete history.messageId;
310
+ return history;
311
+ });
312
+ };
304
313
  let archived;
305
314
  const recentChat = () => archived ??= freshChat();
306
315
  const languageOf = async (current) => {
@@ -398,6 +407,22 @@ async function handleInboundMessage(input) {
398
407
  author: authorOf(sent.from, void 0)
399
408
  });
400
409
  }
410
+ if (group && (lookup.status === "pairing_required" || lookup.status === "existing" || lookup.status === "created") && await isPublicGroup(dependencies.admission(), currentChannel("telegram"), String(sent.chat.id), String(sent.from.id))) {
411
+ if (turn && !input.request?.edited) await answerPublicGroup({
412
+ admission: dependencies.admission(),
413
+ channel: currentChannel("telegram"),
414
+ chat: String(sent.chat.id),
415
+ sender: String(sent.from.id),
416
+ message: String(sent.messageId),
417
+ text: sent.text,
418
+ locale: sent.from.languageCode,
419
+ post: (value) => context.telegram.post(value),
420
+ ...input.request?.claimTurn && { claim: input.request.claimTurn },
421
+ ...input.request?.finishClaim && { finish: input.request.finishClaim }
422
+ });
423
+ await observeRaw();
424
+ return null;
425
+ }
401
426
  if (lookup.status !== "existing" && lookup.status !== "created") {
402
427
  const configuredGroupPairing = lookup.status === "pairing_required" && localizedText(dependencies.admission().replies.groupPairingRequired, sent.from.languageCode) !== void 0;
403
428
  await reject(lookup, addressed !== void 0 && (!group || lookup.status === "limited" || configuredGroupPairing));
@@ -4,8 +4,8 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { E as OntologyActionNotPermitted, Et as principalRuntimeSource, L as needsConfirmation, Ot as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName, kt as telegramRuntimeSource } from "../../../_chunks/principal-CY72xYFi.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-CsM7GfS1.mjs";
7
+ import { E as OntologyActionNotPermitted, Et as principalRuntimeSource, L as needsConfirmation, Ot as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName, kt as telegramRuntimeSource } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CP0iLqzp.mjs";
9
9
  import { object } from "../confirmation-description.mjs";
10
10
  var AttachmentLifecycleNotPermitted = class extends Error {
11
11
  code = "attachment_lifecycle_not_permitted";
@@ -22,8 +22,14 @@ async function reportMembership(input) {
22
22
  title: typeof chat.title === "string" ? chat.title : ""
23
23
  };
24
24
  if (mine) {
25
- if (isMember(next)) await input.chats.joined(report);
26
- else if (isMember(previous) && (next.status === "left" || next.status === "kicked" || next.status === "restricted")) await input.chats.agentLeft(report);
25
+ if (isMember(next)) {
26
+ const actor = record(update.from);
27
+ const newlyJoined = previous.status === "left" || previous.status === "kicked" || previous.status === "restricted" && previous.is_member === false;
28
+ await input.chats.joined({
29
+ ...report,
30
+ ...newlyJoined && actor.is_bot === false && typeof actor.id === "number" && Number.isSafeInteger(actor.id) && actor.id > 0 ? { inviter: String(actor.id) } : {}
31
+ });
32
+ } else if (isMember(previous) && (next.status === "left" || next.status === "kicked" || next.status === "restricted")) await input.chats.agentLeft(report);
27
33
  return;
28
34
  }
29
35
  const user = record(next.user);
@@ -0,0 +1,3 @@
1
+ /** Telegram's raw message number is local to the receiving bot in a basic group. */
2
+ export declare const TELEGRAM_SOURCE_MARKER: RegExp;
3
+ export declare function telegramMessageKey(messageId: string, botId?: string): string;
@@ -0,0 +1,11 @@
1
+ import { fileURLToPath as __eveFileURLToPath } from "node:url";
2
+ import { dirname as __eveDirname } from "node:path";
3
+ import { createRequire as __eveCreateRequire } from "node:module";
4
+ const __filename = __eveFileURLToPath(import.meta.url);
5
+ __eveDirname(__filename);
6
+ __eveCreateRequire(import.meta.url);
7
+ const TELEGRAM_SOURCE_MARKER = /^\[source-message:\d+;trigger:(\d+)(?:;bot:(\d+))?\]/u;
8
+ function telegramMessageKey(messageId, botId) {
9
+ return botId === void 0 ? messageId : `${botId}:${messageId}`;
10
+ }
11
+ export { TELEGRAM_SOURCE_MARKER, telegramMessageKey };
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { t as TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ export { t as TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-DL9NdRRP.mjs";
@@ -6,7 +6,7 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { agentMessage } from "../group-routing/messages.mjs";
8
8
  import "../group-routing/router.mjs";
9
- import { o as isSilentReply } from "../../../_chunks/silent-DK7m_iab.mjs";
9
+ import { o as isSilentReply } from "../../../_chunks/silent-xJcJ8SNJ.mjs";
10
10
  import { questionsFromHistory, routingConfirmationState, routingConfirmations } from "./confirmations.mjs";
11
11
  import { questionKey } from "../questions.mjs";
12
12
  import { archivedRoutingMessages } from "../group-routing/routing-context.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { xt as reportTelegramError } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { xt as reportTelegramError } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { createHash } from "node:crypto";
9
9
  function strandedRun(error) {
10
10
  if (!(error instanceof Error) || error.name !== "RunKeyFetchError" || !("status" in error) || error.status !== 404) return;
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { t as INTERIM_TURNS, n as completionKind, r as deliverUnlessSilent, i as interimTexts, a as isNoReplyCall, o as isSilentReply, s as replyDelivery } from "../../../_chunks/silent-DK7m_iab.mjs";
7
+ export { t as INTERIM_TURNS, n as completionKind, r as deliverUnlessSilent, i as interimTexts, a as isNoReplyCall, o as isSilentReply, s as replyDelivery } from "../../../_chunks/silent-xJcJ8SNJ.mjs";
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { g as captureInStore, _ as storeSend } from "../../../_chunks/chat-archive-Btd3gajb.mjs";
7
+ export { g as captureInStore, _ as storeSend } from "../../../_chunks/chat-archive-DmCXcI8G.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { Ot as runtimeEnvelope, kt as telegramRuntimeSource } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { Ot as runtimeEnvelope, kt as telegramRuntimeSource } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { workspaceAction } from "../workspace-action.mjs";
9
9
  import { STRUCTURED_KINDS } from "./structured-settings.mjs";
10
10
  const record = (value) => {
@@ -6,8 +6,8 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { telegramText } from "./texts.mjs";
8
8
  import { confirmationLocale } from "./confirmation-text.mjs";
9
- import { p as recordSessionFailure } from "../../../_chunks/chat-archive-Btd3gajb.mjs";
10
- import { gt as customerCopy, ht as currentThreadId, i as memberIdOf, mt as currentLocale, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-CY72xYFi.mjs";
9
+ import { p as recordSessionFailure } from "../../../_chunks/chat-archive-DmCXcI8G.mjs";
10
+ import { gt as customerCopy, ht as currentThreadId, i as memberIdOf, mt as currentLocale, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-DL9NdRRP.mjs";
11
11
  import { modelServiceFailure } from "../model-service-failure.mjs";
12
12
  function telegramFailureEvents(input) {
13
13
  return {
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { q as ACCESS_TOKEN_PREFIX, J as AGENT_GRANT_HEADER, Y as GUEST_CONFIRMATIONS_ATTRIBUTE, X as GUEST_ID_ATTRIBUTE, Z as GUEST_ROLE, Q as INTROSPECTION_PATH, $ as KIND_ATTRIBUTE, et as TURN_LIMITED_CODE, tt as TurnLimitedError, nt as WEB_AUTHENTICATOR, rt as WEB_GRANT_ATTRIBUTE, it as WEB_PROVIDER, at as guestConfirms, ot as guestIdOf, st as guestPrincipal, ct as ontologyIntrospection, lt as webAuth, ut as webGrantOf, dt as webMemberOf, ft as webPrincipal } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ export { q as ACCESS_TOKEN_PREFIX, J as AGENT_GRANT_HEADER, Y as GUEST_CONFIRMATIONS_ATTRIBUTE, X as GUEST_ID_ATTRIBUTE, Z as GUEST_ROLE, Q as INTROSPECTION_PATH, $ as KIND_ATTRIBUTE, et as TURN_LIMITED_CODE, tt as TurnLimitedError, nt as WEB_AUTHENTICATOR, rt as WEB_GRANT_ATTRIBUTE, it as WEB_PROVIDER, at as guestConfirms, ot as guestIdOf, st as guestPrincipal, ct as ontologyIntrospection, lt as webAuth, ut as webGrantOf, dt as webMemberOf, ft as webPrincipal } from "../../../_chunks/principal-DL9NdRRP.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { it as WEB_PROVIDER, lt as webAuth } from "../../../_chunks/principal-CY72xYFi.mjs";
7
+ import { it as WEB_PROVIDER, lt as webAuth } from "../../../_chunks/principal-DL9NdRRP.mjs";
8
8
  import { localDev, placeholderAuth, vercelOidc } from "eve/channels/auth";
9
9
  import { eveChannel } from "eve/channels/eve";
10
10
  const WEB_EXPOSED_HEADERS = [
@@ -51,6 +51,8 @@ export interface SearchAnswer {
51
51
  }
52
52
  /** Runs one search. Tests pass their own. */
53
53
  export type Searcher = (input: WebSearchInput, signal?: AbortSignal) => Promise<SearchAnswer>;
54
+ /** The cost AI Gateway reports in a model answer's metadata, as eve reads it. */
55
+ export declare function gatewayCostOf(metadata: unknown): number;
54
56
  /** The search through AI Gateway, with the deployment's own Gateway identity. */
55
57
  export declare const gatewaySearcher: Searcher;
56
58
  /** The pages of the provider's output, or why there are none. */