@segmentstream/agent 0.53.0 → 0.55.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 (114) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +21 -8
  3. package/dist/_chunks/{build-metadata-Bc9qfC4D.mjs → build-metadata-CYSFZe6f.mjs} +1 -1
  4. package/dist/_chunks/{principal-JoaOmdFL.mjs → principal-DIgU-kPR.mjs} +71 -29
  5. package/dist/extension/channels/email.d.ts +4 -3
  6. package/dist/extension/channels/email.mjs +2 -1
  7. package/dist/extension/channels/slack.d.ts +4 -3
  8. package/dist/extension/channels/slack.mjs +2 -1
  9. package/dist/extension/channels/telegram.d.ts +3 -1
  10. package/dist/extension/channels/telegram.mjs +2 -1
  11. package/dist/extension/channels/whatsapp.d.ts +3 -2
  12. package/dist/extension/channels/whatsapp.mjs +2 -1
  13. package/dist/extension/config.d.ts +188 -67
  14. package/dist/extension/config.mjs +173 -36
  15. package/dist/extension/connections/ontology.mjs +1 -1
  16. package/dist/extension/hooks/authorization.mjs +1 -1
  17. package/dist/extension/hooks/guest-usage.d.ts +3 -0
  18. package/dist/extension/hooks/guest-usage.mjs +11 -0
  19. package/dist/extension/instructions/persona.mjs +1 -1
  20. package/dist/extension/lib/actor.mjs +1 -1
  21. package/dist/extension/lib/attachment-tools.d.ts +1 -1
  22. package/dist/extension/lib/attachment-tools.mjs +2 -2
  23. package/dist/extension/lib/attachments-send.mjs +1 -1
  24. package/dist/extension/lib/attachments.d.ts +1 -2
  25. package/dist/extension/lib/attachments.mjs +1 -1
  26. package/dist/extension/lib/build-metadata.mjs +1 -1
  27. package/dist/extension/lib/channel-scope.d.ts +67 -0
  28. package/dist/extension/lib/channel-scope.mjs +104 -0
  29. package/dist/extension/lib/chat-address.d.ts +27 -1
  30. package/dist/extension/lib/chat-address.mjs +1 -1
  31. package/dist/extension/lib/chat-archive.d.ts +6 -0
  32. package/dist/extension/lib/chat-archive.mjs +7 -2
  33. package/dist/extension/lib/chat-context.mjs +3 -3
  34. package/dist/extension/lib/chat-post-confirmation.d.ts +13 -2
  35. package/dist/extension/lib/chat-post-confirmation.mjs +8 -3
  36. package/dist/extension/lib/chat-recorder.d.ts +17 -0
  37. package/dist/extension/lib/chat-recorder.mjs +18 -9
  38. package/dist/extension/lib/chats.d.ts +7 -0
  39. package/dist/extension/lib/chats.mjs +31 -1
  40. package/dist/extension/lib/confirmations.d.ts +6 -1
  41. package/dist/extension/lib/confirmations.mjs +1 -1
  42. package/dist/extension/lib/email/attachments-send.d.ts +1 -1
  43. package/dist/extension/lib/email/attachments-send.mjs +1 -1
  44. package/dist/extension/lib/email/channel.d.ts +11 -3
  45. package/dist/extension/lib/email/channel.mjs +53 -42
  46. package/dist/extension/lib/guest-usage.d.ts +53 -0
  47. package/dist/extension/lib/guest-usage.mjs +52 -0
  48. package/dist/extension/lib/inbound-media/files.mjs +1 -1
  49. package/dist/extension/lib/inbound-media/index.mjs +1 -1
  50. package/dist/extension/lib/ontology-connection.mjs +1 -1
  51. package/dist/extension/lib/ontology-file-call.mjs +2 -1
  52. package/dist/extension/lib/ontology-tools.d.ts +2 -0
  53. package/dist/extension/lib/ontology-tools.mjs +1 -1
  54. package/dist/extension/lib/review/client.mjs +1 -0
  55. package/dist/extension/lib/review/hold.d.ts +7 -0
  56. package/dist/extension/lib/review/hold.mjs +2 -1
  57. package/dist/extension/lib/review/reply.mjs +3 -3
  58. package/dist/extension/lib/role-skill.mjs +1 -1
  59. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  60. package/dist/extension/lib/sent-files.mjs +1 -1
  61. package/dist/extension/lib/slack/adapter.d.ts +5 -4
  62. package/dist/extension/lib/slack/adapter.mjs +19 -15
  63. package/dist/extension/lib/slack/attachments-send.d.ts +1 -1
  64. package/dist/extension/lib/slack/attachments-send.mjs +1 -1
  65. package/dist/extension/lib/stored-files.mjs +1 -1
  66. package/dist/extension/lib/telegram/adapter.d.ts +8 -2
  67. package/dist/extension/lib/telegram/adapter.mjs +43 -31
  68. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  69. package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
  70. package/dist/extension/lib/telegram/callbacks.mjs +1 -1
  71. package/dist/extension/lib/telegram/chat-archive.mjs +11 -10
  72. package/dist/extension/lib/telegram/chat-post-card.mjs +4 -3
  73. package/dist/extension/lib/telegram/confirmations.mjs +3 -3
  74. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  75. package/dist/extension/lib/telegram/delivery-diagnostics.mjs +2 -1
  76. package/dist/extension/lib/telegram/files.d.ts +4 -1
  77. package/dist/extension/lib/telegram/files.mjs +3 -2
  78. package/dist/extension/lib/telegram/health.mjs +1 -1
  79. package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
  80. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  81. package/dist/extension/lib/telegram/inbound.mjs +4 -4
  82. package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
  83. package/dist/extension/lib/telegram/principal.mjs +1 -1
  84. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  85. package/dist/extension/lib/telegram/signals.mjs +2 -1
  86. package/dist/extension/lib/telegram/silent.mjs +1 -1
  87. package/dist/extension/lib/telegram/structured.mjs +1 -1
  88. package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
  89. package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
  90. package/dist/extension/lib/web/auth.d.ts +18 -4
  91. package/dist/extension/lib/web/auth.mjs +1 -1
  92. package/dist/extension/lib/web/channel.mjs +1 -1
  93. package/dist/extension/lib/whatsapp/adapter.d.ts +12 -6
  94. package/dist/extension/lib/whatsapp/adapter.mjs +17 -10
  95. package/dist/extension/lib/whatsapp/attachments-send.d.ts +1 -1
  96. package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
  97. package/dist/extension/lib/whatsapp/files.mjs +1 -1
  98. package/dist/extension/lib/workspace-source.d.ts +1 -1
  99. package/dist/extension/lib/workspace-source.mjs +3 -2
  100. package/dist/extension/model.mjs +1 -1
  101. package/dist/extension/tools/attachments_discard.mjs +1 -1
  102. package/dist/extension/tools/attachments_list.mjs +1 -1
  103. package/dist/extension/tools/attachments_promote.mjs +1 -1
  104. package/dist/extension/tools/attachments_read.mjs +1 -1
  105. package/dist/extension/tools/attachments_send.mjs +10 -6
  106. package/dist/extension/tools/attachments_stage.mjs +1 -1
  107. package/dist/extension/tools/attachments_table.mjs +1 -1
  108. package/dist/extension/tools/questions_ask.mjs +1 -1
  109. package/dist/extension/tools/unanswered.d.ts +2 -0
  110. package/dist/extension/tools/unanswered.mjs +39 -0
  111. package/dist/extension/tools/workspace_source.mjs +1 -1
  112. package/dist/tools/index.d.ts +1 -0
  113. package/dist/tools/index.mjs +2 -1
  114. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.55.0
4
+
5
+ An agent answers on several channels of one kind: two WhatsApp numbers, a few Telegram bots,
6
+ several mailboxes or Slack apps. `channels` names each one; a channel named after its kind
7
+ (`telegram`, `whatsapp`, `slack`, `email`) is that kind and stays valid as written, and any other
8
+ name, such as `sales_whatsapp`, says its `kind`. Each channel needs a connection of its own.
9
+
10
+ The channel named after its kind keeps every key its chats had: sessions, archive, review and
11
+ attachments are unchanged. Any other channel carries its name in its chats' keys, so two bots'
12
+ private chats with the same person never meet, and receives at its own route:
13
+ `/eve/segmentstream/v1/<kind>/<name>`, where SegmentStream points each bot's webhook, relays each
14
+ number's and app's events, and wakes each mailbox. Each channel's replies leave through its own
15
+ connection, and a reply held for review names its channel, so approving it sends it through that
16
+ channel. People are not per channel: one Telegram account, number or address is one person on
17
+ every channel of its kind. Only the bot of `channels.telegram` opens the app as a Mini App.
18
+
19
+ `attachments_send` sends through the connection of the channel the chat is on, and each email
20
+ channel keeps, retries and drains its own replies. The chat an ontology request comes from
21
+ (`X-SegmentStream-Agent-Chat`) names the channel by its name, as the archive does, so history
22
+ and chat figures show `sales_whatsapp` where a chat of `channels.whatsapp` shows `whatsapp`. A
23
+ post to another chat renders as the kind `chat_list` names for its channel; an ontology that names
24
+ none lists only channels named after their kind, as before.
25
+
26
+ Action required: before naming a channel other than its kind, upgrade the ontology SDK and declare
27
+ the channel in `defineOntology({ chat })` under the same name with its `kind`, such as
28
+ `chat: { sales_whatsapp: { kind: "whatsapp", connection: waSales } }`; an older ontology refuses
29
+ the replies held on it.
30
+
31
+ Pins @segmentstream/ontology 0.111.0.
32
+
33
+ ## 0.54.0
34
+
35
+ History keeps the chat an action came from. The app's agent names the chat it acts in and its
36
+ session there (`X-SegmentStream-Agent-Chat`, `X-SegmentStream-Agent-Session`, as on its attachment
37
+ routes) on every ontology request it makes for a member or a website's guest. With the
38
+ deployment's runtime token, the ontology keeps that chat as the principal's: an action's handler
39
+ sees it as `principal.chat` (`{ provider, chatId, sessionId? }`, as the chat archive names them,
40
+ such as `web` and `guest:<id>`), and every history entry the action writes carries it as `chat`,
41
+ in the runtime's action attribution table beside a pipeline's verified execution. A web chat counts
42
+ only as the acting member's or guest's own, a messenger's only on the provider the member wrote
43
+ from; any other chat is left out, never refused, and nothing else carries one. So a lead a guest
44
+ left, created by nobody, leads back to the guest's chat; an action can keep `principal.chat` on
45
+ the record for metrics by chat.
46
+
47
+ The next deploy's migration adds the nullable `chat` column to `_ontology_action_attribution` and
48
+ lets `execution` be empty, keeping every row. An agent built before this sends no chat, and an
49
+ ontology built before this ignores the headers. The app SDK's `HistoryEntry` type names `chat`.
50
+
51
+ Guests on websites: a money cap and confirmations.
52
+
53
+ - `limits.guest.usdPerDay` (each guest, at most 100) and `limits.guest.workspaceUsdPerDay` (every
54
+ guest together, at most 10000) in `agent/segmentstream.json` cap the model cost of guests' turns a
55
+ day, in US dollars. Left out, there is no money cap, as before. While either is set, the agent
56
+ reports what each model answer of a guest's turn cost to the ontology, and the web channel refuses
57
+ a guest's turn past a cap with `429 rate_limited`, `Retry-After` and the scope `guestUsdPerDay` or
58
+ `guestWorkspaceUsdPerDay`. Every `429` of the web channel now names the limit's `scope` in its
59
+ body, beside `retry_after_seconds`. The cap needs an ontology SDK that knows it.
60
+ - Where the ontology answers a guest's token with `confirmations: true` (its
61
+ `guest.confirmations`), an action that needs a confirmation is put to the guest with the web
62
+ chat's buttons, as to a member, and only that guest's click decides it. Otherwise guests stay
63
+ refused such actions, and chat posts stay refused for every guest.
64
+
65
+ `"unanswered": true` in `agent/segmentstream.json` gives the model `segmentstream__unanswered`,
66
+ with which it records a question it could not answer from its instructions, guides, tools or the
67
+ records it may read, in every chat, a guest's included, and never in a task. The tool changes and
68
+ sends nothing and shows no activity in a chat; the chat archive keeps the call with its chat,
69
+ session and turn, so builders list the questions with
70
+ `segmentstream agent logs --tool segmentstream__unanswered --all` and count them with
71
+ `segmentstream agent chats`. Off when absent.
72
+
73
+ Pins @segmentstream/ontology 0.110.0.
74
+
3
75
  ## 0.53.0
4
76
 
5
77
  `segmentstream__attachments_send` works in email and WhatsApp chats. In email the stored files go
package/README.md CHANGED
@@ -128,6 +128,7 @@ See [Sandbox](#sandbox).
128
128
  | `channels.telegram.additionalOwnOrigins` | `[]` | Additional exact HTTP(S) workspace origins, including local ports; no paths or credentials. |
129
129
  | `channels.telegram.appLinks` | `"web"` | `"miniApp"` opens links to the app's own pages in the bot's Main Mini App (`t.me/<bot>?startapp=…`) as messages are delivered; see `docs/agent.md` |
130
130
  | `channels.telegram.interimMessages` | `false` | `true` delivers the text the model writes before calling tools as its own message, like a reply; see [Telegram answer delivery](#telegram-answer-delivery) |
131
+ | `channels.<name>.kind` | the name | A channel not named after its kind, such as `sales_whatsapp`, says its kind and takes that kind's settings: several bots, numbers, apps or mailboxes on one agent; see `docs/agent.md`, "Channels by name" |
131
132
  | `models.stt` | `"spacexai/grok-stt"` | The AI Gateway transcription model for voice messages; `false` leaves them untranscribed |
132
133
  | `models.imageDescription` | `google/gemini-2.5-flash-lite` | Image evidence for group routing even with native vision; `false` disables descriptions |
133
134
  | `models.decision` | `"typesafe-ai/jev-1.14.0"` | The AI Gateway decision model of the inbound router |
@@ -222,7 +223,13 @@ stop processing. `groupPairingRequired` and `refused` may override existing pair
222
223
  Omitted limit fields use platform ceilings: 6 turns/minute and 80/day per sender, 30 new users/hour,
223
224
  and 3000 workspace turns/day; for a website's guests, `limits.guest`, 20 turns/day per guest and
224
225
  1000 guest turns/day for the workspace, counted apart. Overrides must be positive integers at or
225
- below each ceiling. The web channel sends the limits of the `config` it is given with each turn.
226
+ below each ceiling. The money caps `limits.guest.usdPerDay` (at most 100) and
227
+ `workspaceUsdPerDay` (at most 10000) limit the model cost of each guest's turns and of every
228
+ guest's together a day, in US dollars; left out, there is no money cap. While either is set, the
229
+ `usage.recorded` hook reports the cost of each model answer of a guest's turn to the ontology
230
+ (`POST /api/ontology/agent/guests/usage`, keyed by the event's place in the stream), and a
231
+ guest's turn past a cap is refused with `429 rate_limited` and its `scope`. The web channel sends
232
+ the limits of the `config` it is given with each turn.
226
233
  The trusted runtime submits these effective limits; the ontology clamps and persists them for other
227
234
  admission paths. Only self-registered users with exactly the member role consume sender/workspace
228
235
  turn quotas, keyed by user id across identities. Paired-only users and holders of named roles
@@ -308,7 +315,10 @@ A website's guest (the ontology's `guest`) holds the tools `guest.permissions` g
308
315
  `agent_tool:web`, never the sandbox, which the SDK drops from a guest's answer whatever it says.
309
316
  Their principal carries `kind: "guest"`, `guestId`, `roles: ["guest"]` and `agentTools`, no
310
317
  `memberId`; the tools only a member has (attachments, `questions_ask`, `workspace_source`, chat
311
- posts) are never offered to them.
318
+ posts) are never offered to them. An action that needs a confirmation is refused for a guest
319
+ unless the ontology's answer for their token says `confirmations: true` (its
320
+ `guest.confirmations`): then the guest gets the confirmation card in the web chat as a member does,
321
+ and only that guest's click decides it.
312
322
 
313
323
  `segmentstream__web_fetch` follows each redirect itself, since eve's `web_fetch` gives no hook to
314
324
  check a hop's host: every URL is `https://` on the default port, on a listed domain or its
@@ -799,14 +809,17 @@ ordinary tools use the compatible connection and no runtime arguments are added.
799
809
  missing/incomplete preview metadata is denied. The versioned connection has its own instance key.
800
810
 
801
811
  The runtime reads `me` for the server-derived `attribution`, and `chat_list({ chat })` for exactly
802
- one eligible destination: `{ items: [{ id, title, provider, external_id }], next_cursor: null }`.
803
- Provider is `telegram`, `slack` or `whatsapp`; the agent refuses a destination on any other
804
- provider when it describes the post, as agents before Slack and WhatsApp destinations refuse
805
- theirs, and refuses a `reply_to` for WhatsApp. The final text is computed as the ontology renders
812
+ one eligible destination: `{ items: [{ id, title, provider, kind?, external_id }], next_cursor:
813
+ null }`. `provider` is the destination's channel by its name and `kind` that channel's kind; an
814
+ ontology that sends no `kind` lists only channels named after their kind, whose name is the kind.
815
+ The kind is `telegram`, `slack` or `whatsapp`; the agent refuses a destination of any other kind
816
+ when it describes the post, as agents before Slack and WhatsApp destinations refuse theirs, and
817
+ refuses a `reply_to` for WhatsApp. The final text is computed as the ontology renders
806
818
  it: Telegram's MarkdownV2, `renderSlack` from `@segmentstream/ontology/slack`, or `renderWhatsApp`
807
819
  from `@segmentstream/ontology/whatsapp`. The final plain text is `text + separator + attribution`, with a blank line as the neutral separator;
808
- `reply_to` is optional. A preview digest is SHA-256 of the JSON array of chat ID, provider,
809
- external ID, title, attribution, text, final text and nullable reply target, in that order.
820
+ `reply_to` is optional. A preview digest is SHA-256 of the JSON array of chat ID, provider (the
821
+ channel's name), external ID, title, attribution, text, final text and nullable reply target, in
822
+ that order.
810
823
  The target/attribution are resolved again immediately before executing the frozen call.
811
824
 
812
825
  The SDK constructs model-hidden `_segmentstream` metadata for approved runtime posts.
@@ -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
- var version = "0.53.0";
7
+ var version = "0.55.0";
8
8
  function agentBuild(environment = process.env) {
9
9
  return {
10
10
  agent: version,
@@ -7,12 +7,14 @@ __eveCreateRequire(import.meta.url);
7
7
  import { telegramText, withTelegramTexts } from "../extension/lib/telegram/texts.mjs";
8
8
  import { isTechnicalText } from "../extension/lib/customer-text-safety.mjs";
9
9
  import { miniAppLinks, originalLinkPreview, withMiniAppLinks } from "../extension/lib/telegram/app-links.mjs";
10
- import { admissionLimitsOf } from "../extension/config.mjs";
10
+ import { CHANNEL_NAME, admissionLimitsOf } from "../extension/config.mjs";
11
11
  import { appOrigin } from "../extension/lib/environment.mjs";
12
+ import { channelAttributes, currentChannel, principalChannel } from "../extension/lib/channel-scope.mjs";
12
13
  import { redactDiagnostic } from "../extension/lib/diagnostics.mjs";
13
14
  import { redactTelegramDiagnostic } from "../extension/lib/telegram/diagnostic-redaction.mjs";
14
15
  import { CONFIRMATION_FACTS, CONFIRMATION_PREVIEW_METHOD, ConfirmationRefused, UnsafeConfirmationTarget, confirmationCard, describeConfirmation, factsConfirmation, object } from "../extension/lib/confirmation-description.mjs";
15
16
  import { confirmationCopy, confirmationCopyIssue, confirmationEntities, confirmationLocale, renderConfirmation } from "../extension/lib/telegram/confirmation-text.mjs";
17
+ import { CHAT_POST_ENVELOPE, CHAT_POST_TOOL, chatPostDigest, chatPostOperationId, describeChatPost, isChatPost, supportsChatPost } from "../extension/lib/chat-post-confirmation.mjs";
16
18
  import { chatPostCard, chatPostCardLinks, chatPostPrompt, isExactChatPostCard } from "../extension/lib/telegram/chat-post-card.mjs";
17
19
  import { plainTelegramText, splitTelegramText, telegramMarkdown } from "../extension/lib/telegram/format.mjs";
18
20
  import { inTelegramSendQueue } from "../extension/lib/telegram/send-queue.mjs";
@@ -22,7 +24,6 @@ import { MAXIMUM_DOWNLOAD_BYTES } from "../extension/lib/connection-proxy.mjs";
22
24
  import { AGENT_TOOLS_ATTRIBUTE, SANDBOX_TOOL, agentToolsAnswer, agentToolsAttribute } from "../extension/lib/agent-tools.mjs";
23
25
  import { AGENT_TASK_HEADER, agentTaskIdOf, taskSecret } from "../extension/lib/agent-task.mjs";
24
26
  import { promptFits, withButtonDecision } from "../extension/lib/confirmation-buttons.mjs";
25
- import { CHAT_POST_ENVELOPE, CHAT_POST_TOOL, chatPostDigest, chatPostOperationId, describeChatPost, isChatPost, supportsChatPost } from "../extension/lib/chat-post-confirmation.mjs";
26
27
  import { describableImage, describeReceivedImage } from "../extension/lib/inbound-media/images.mjs";
27
28
  import { NATIVE_AUDIO_NOTE, isSpeech, transcribeSpeech } from "../extension/lib/inbound-media/speech.mjs";
28
29
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -57,8 +58,10 @@ function telegramRuntimeSource(message, files, callbackQueryId) {
57
58
  media_type: staged.attachment.contentType
58
59
  });
59
60
  }
61
+ const channel = currentChannel("telegram");
60
62
  return {
61
63
  provider: "telegram",
64
+ ...channel === "telegram" ? {} : { channel },
62
65
  chat_id: message.chat.id,
63
66
  thread_id: String(message.messageThreadId ?? ""),
64
67
  message_id: message.messageId,
@@ -93,6 +96,7 @@ function compatibleRuntimeEnvelope(envelope, extended) {
93
96
  ...envelope,
94
97
  source: {
95
98
  provider: source.provider,
99
+ ...source.channel === void 0 ? {} : { channel: source.channel },
96
100
  chat_id: source.chat_id,
97
101
  thread_id: source.thread_id
98
102
  }
@@ -352,6 +356,8 @@ function safeTelegramFetch(fetchImpl, scope = "telegram", previews = {}, appLink
352
356
  return typeof body.chat_id === "string" || typeof body.chat_id === "number" ? inTelegramSendQueue(scope, String(body.chat_id), send) : send();
353
357
  };
354
358
  }
359
+ const CHAT_HEADER = "X-SegmentStream-Agent-Chat";
360
+ const SESSION_HEADER = "X-SegmentStream-Agent-Session";
355
361
  const CHAT_ATTRIBUTE = "segmentstreamChat";
356
362
  const EARLIER_CHAT_ATTRIBUTE = "segmentstreamConversation";
357
363
  function withChatAddress(principal, chat) {
@@ -370,6 +376,7 @@ function chatAddressOf(principal) {
370
376
  const chatId = attributes.chatId;
371
377
  return typeof chatId !== "string" || chatId === "" ? void 0 : {
372
378
  provider: "telegram",
379
+ ...principalChannel(principal) === void 0 ? {} : { channel: principalChannel(principal) },
373
380
  chatId,
374
381
  threadId: String(attributes.messageThreadId ?? ""),
375
382
  kind: chatId.startsWith("-") ? "group" : "private"
@@ -383,21 +390,32 @@ function chatAddressOf(principal) {
383
390
  return;
384
391
  }
385
392
  }
393
+ function chatHeaders(principal, sessionId) {
394
+ const chat = chatAddressOf(principal);
395
+ return chat === void 0 ? {} : {
396
+ [CHAT_HEADER]: `${chatChannel(chat)}:${chat.chatId}`,
397
+ ...sessionId === void 0 || sessionId === "" ? {} : { [SESSION_HEADER]: sessionId }
398
+ };
399
+ }
386
400
  function parsedChatAddress(value, provider) {
387
401
  if (typeof value !== "object" || value === null || Array.isArray(value)) return;
388
402
  const item = value;
389
403
  const text = (field, empty = false) => typeof field === "string" && (empty || field !== "") && field.length <= 512;
390
- if (item.provider !== "slack" && item.provider !== "whatsapp" && item.provider !== "web" && item.provider !== "email" || item.provider !== provider || !text(item.chatId) || !text(item.threadId, true) || item.kind !== "private" && item.kind !== "group" || item.peer !== void 0 && !text(item.peer)) return;
404
+ if (item.provider !== "slack" && item.provider !== "whatsapp" && item.provider !== "web" && item.provider !== "email" || item.provider !== provider || !text(item.chatId) || !text(item.threadId, true) || item.kind !== "private" && item.kind !== "group" || item.peer !== void 0 && !text(item.peer) || item.channel !== void 0 && (typeof item.channel !== "string" || !CHANNEL_NAME.test(item.channel) || item.channel === item.provider)) return;
391
405
  return {
392
406
  provider: item.provider,
407
+ ...item.channel === void 0 ? {} : { channel: item.channel },
393
408
  chatId: item.chatId,
394
409
  threadId: item.threadId,
395
410
  kind: item.kind,
396
411
  ...item.peer === void 0 ? {} : { peer: item.peer }
397
412
  };
398
413
  }
414
+ function chatChannel(chat) {
415
+ return chat.channel ?? chat.provider;
416
+ }
399
417
  function isSameChat(chat, destination) {
400
- if (chat.provider !== destination.provider) return false;
418
+ if (chatChannel(chat) !== destination.provider) return false;
401
419
  return chat.chatId === destination.externalId || chat.provider !== "telegram" && chat.kind === "private" && chat.peer === destination.externalId;
402
420
  }
403
421
  const WEB_AUTHENTICATOR = "segmentstream-web";
@@ -406,6 +424,7 @@ const AGENT_GRANT_HEADER = "X-SegmentStream-Agent-Grant";
406
424
  const WEB_GRANT_ATTRIBUTE = "webGrant";
407
425
  const KIND_ATTRIBUTE = "kind";
408
426
  const GUEST_ID_ATTRIBUTE = "guestId";
427
+ const GUEST_CONFIRMATIONS_ATTRIBUTE = "guestConfirmations";
409
428
  const GUEST_ROLE = "guest";
410
429
  const ACCESS_TOKEN_PREFIX = "sso_";
411
430
  const INTROSPECTION_PATH = "/api/ontology/agent/tokens/introspect";
@@ -415,18 +434,21 @@ const ANSWER_LIMIT = 1e3;
415
434
  const TURN_LIMITED_CODE = "rate_limited";
416
435
  var TurnLimitedError = class extends ForbiddenError {
417
436
  retryAfterSeconds;
437
+ scope;
418
438
  response;
419
- constructor(retryAfterSeconds) {
439
+ constructor(retryAfterSeconds, scope) {
420
440
  super({
421
441
  code: TURN_LIMITED_CODE,
422
442
  message: TURN_LIMITED_CODE
423
443
  });
424
444
  this.retryAfterSeconds = retryAfterSeconds;
445
+ this.scope = scope;
425
446
  this.name = "TurnLimitedError";
426
447
  this.response = Response.json({
427
448
  code: TURN_LIMITED_CODE,
428
449
  ok: false,
429
- retry_after_seconds: retryAfterSeconds
450
+ retry_after_seconds: retryAfterSeconds,
451
+ ...scope === void 0 || scope === "" ? {} : { scope }
430
452
  }, {
431
453
  status: 429,
432
454
  headers: {
@@ -460,6 +482,7 @@ function webMemberOf(body) {
460
482
  chat: answer.chat,
461
483
  roles,
462
484
  agentTools,
485
+ ...answer.confirmations === true ? { confirmations: true } : {},
463
486
  ...limitedOf(answer.limited)
464
487
  } : void 0;
465
488
  }
@@ -524,10 +547,14 @@ function guestPrincipal(guest) {
524
547
  identityProvider: "web",
525
548
  roles: guest.roles,
526
549
  [WEB_GRANT_ATTRIBUTE]: guest.grant,
527
- [AGENT_TOOLS_ATTRIBUTE]: guest.agentTools
550
+ [AGENT_TOOLS_ATTRIBUTE]: guest.agentTools,
551
+ ...guest.confirmations === true ? { [GUEST_CONFIRMATIONS_ATTRIBUTE]: "true" } : {}
528
552
  }
529
553
  }, chat);
530
554
  }
555
+ function guestConfirms(principal) {
556
+ return guestIdOf(principal) !== void 0 && principal?.attributes["guestConfirmations"] === "true";
557
+ }
531
558
  function guestIdOf(principal) {
532
559
  const guestId = principal?.attributes[GUEST_ID_ATTRIBUTE];
533
560
  return principal?.authenticator === "segmentstream-web" && principal.attributes["kind"] === "guest" && typeof guestId === "string" && guestId !== "" ? guestId : void 0;
@@ -614,7 +641,7 @@ function webAuth(options = {}) {
614
641
  code: "agent_token_invalid",
615
642
  message: "The agent token is invalid or expired."
616
643
  });
617
- if (member.limited !== void 0) throw new TurnLimitedError(member.limited.retryAfterSeconds);
644
+ if (member.limited !== void 0) throw new TurnLimitedError(member.limited.retryAfterSeconds, member.limited.scope);
618
645
  return withButtonDecision(webPrincipal(member), answersOf(body));
619
646
  };
620
647
  }
@@ -700,8 +727,15 @@ function canonical(value) {
700
727
  function inputHash(input) {
701
728
  return createHash("sha256").update(canonical(input)).digest("hex");
702
729
  }
730
+ function ownedBy(saved, actor) {
731
+ switch (actor?.kind) {
732
+ case "member": return saved.guestId === void 0 && saved.memberId === actor.memberId;
733
+ case "guest": return saved.memberId === void 0 && saved.guestId === actor.guestId;
734
+ default: return false;
735
+ }
736
+ }
703
737
  function isSameSource(saved, current) {
704
- return current !== void 0 && saved.provider === current.provider && saved.chatId === current.chatId && saved.threadId === current.threadId;
738
+ return current !== void 0 && chatChannel(saved) === chatChannel(current) && saved.chatId === current.chatId && saved.threadId === current.threadId;
705
739
  }
706
740
  const confirmations = defineState("segmentstream.confirmations", () => ({}));
707
741
  function connectionHints(ctx) {
@@ -736,8 +770,8 @@ function actionApproval(options) {
736
770
  }
737
771
  return "approved";
738
772
  }
739
- if (actor?.kind === "guest") {
740
- if (isChatPost(ctx.toolName)) return denied("Chat posting is unavailable to a guest.");
773
+ if (actor?.kind === "guest" && isChatPost(ctx.toolName)) return denied("Chat posting is unavailable to a guest.");
774
+ if (actor?.kind === "guest" && !guestConfirms(ctx.session.auth.current)) {
741
775
  let annotations = connectionHints(ctx);
742
776
  if (annotations === void 0) try {
743
777
  annotations = await options.labels(actor, ctx.toolName, ctx.toolInput ?? {});
@@ -747,13 +781,14 @@ function actionApproval(options) {
747
781
  }
748
782
  return needsConfirmation(annotations) ? denied("This action needs a confirmation, which a guest cannot give.") : "approved";
749
783
  }
750
- const memberId = actor?.memberId;
751
- if (memberId === void 0) return denied("A paired member is required.");
784
+ const confirmer = actor?.kind === "member" || actor?.kind === "guest" ? actor : void 0;
785
+ if (confirmer === void 0) return denied("A paired member is required.");
786
+ const owner = confirmer.kind === "guest" ? { guestId: confirmer.guestId } : { memberId: confirmer.memberId };
752
787
  const present = (run) => options.texts === void 0 ? run() : withTelegramTexts(options.texts(), run, () => confirmationLocale(ctx.session.auth.current));
753
788
  const hash = inputHash(ctx.toolInput ?? {});
754
789
  const saved = state.get()[ctx.callId];
755
790
  if (saved !== void 0) {
756
- if (saved.memberId !== memberId || saved.action !== ctx.toolName || saved.inputHash !== hash) return denied("The confirmation belongs to another member, action or input.");
791
+ if (!ownedBy(saved, confirmer) || saved.action !== ctx.toolName || saved.inputHash !== hash) return denied("The confirmation belongs to another member, action or input.");
757
792
  if (saved.expiresAt <= now()) return denied("The confirmation expired. Make a new call.");
758
793
  if (saved.status === "consumed" || saved.status === "cancelled") return denied("The confirmation has already been used or cancelled.");
759
794
  }
@@ -761,12 +796,12 @@ function actionApproval(options) {
761
796
  if (saved === void 0 && !isChatPost(ctx.toolName) && hints !== void 0 && !needsConfirmation(hints)) return "approved";
762
797
  let labels;
763
798
  try {
764
- labels = await options.labels(member(memberId), ctx.toolName, ctx.toolInput ?? {}, void 0, hints);
799
+ labels = await options.labels(confirmer, ctx.toolName, ctx.toolInput ?? {}, void 0, hints);
765
800
  } catch (error) {
766
801
  console.warn("The ontology action permission check failed.", error);
767
802
  return denied("The action is unavailable or the member no longer has permission.");
768
803
  }
769
- const offered = options.copy === void 0 ? ctx.toolInput?._confirmation : options.copy(member(memberId), ctx.toolInput ?? {});
804
+ const offered = options.copy === void 0 ? ctx.toolInput?._confirmation : options.copy(confirmer, ctx.toolInput ?? {});
770
805
  const copy = labels.confirmation === false ? void 0 : confirmationCopy(offered);
771
806
  const businessInput = Object.fromEntries(Object.entries(ctx.toolInput ?? {}).filter(([key]) => key !== "_confirmation"));
772
807
  const posting = isChatPost(ctx.toolName);
@@ -776,7 +811,7 @@ function actionApproval(options) {
776
811
  let prompt;
777
812
  const chat = chatAddressOf(ctx.session.auth.current);
778
813
  if (posting) try {
779
- description = await options.describe?.(member(memberId), ctx.toolName, businessInput, hints);
814
+ description = await options.describe?.(confirmer, ctx.toolName, businessInput, hints);
780
815
  const preview = description?.chatPost;
781
816
  if (description === void 0 || preview === void 0 || chat === void 0 || isSameChat(chat, preview)) return denied("A complete preview for a different chat is required. Reply normally in this chat.");
782
817
  const previewDescription = {
@@ -808,7 +843,7 @@ function actionApproval(options) {
808
843
  if (chat?.provider === "email") return denied("Email shows no confirmation buttons, so this action cannot run from mail. Say in your reply what you would do; a member can run it.");
809
844
  if (labels.confirmation === true && labels.preview !== true && copy === void 0) return missingCopy();
810
845
  try {
811
- if (!posting) description = await options.describe?.(member(memberId), ctx.toolName, businessInput, hints, confirmationLocale(ctx.session.auth.current));
846
+ if (!posting) description = await options.describe?.(confirmer, ctx.toolName, businessInput, hints, confirmationLocale(ctx.session.auth.current));
812
847
  if (description === void 0) throw new Error("A trusted confirmation description is required.");
813
848
  } catch (error) {
814
849
  if (error instanceof ConfirmationRefused) return denied(`The action refuses this input, so no card was shown and nothing ran: ${error.reason} Tell the member why in their language, in a short message; do not ask them to confirm it and do not make the same call again.`);
@@ -829,7 +864,7 @@ function actionApproval(options) {
829
864
  state.update((all) => ({
830
865
  ...all,
831
866
  [ctx.callId]: {
832
- memberId,
867
+ ...owner,
833
868
  action: ctx.toolName,
834
869
  inputHash: hash,
835
870
  expiresAt: now() + CONFIRMATION_TTL_MS,
@@ -850,7 +885,8 @@ function actionApproval(options) {
850
885
  });
851
886
  if (saved === void 0 || saved.status !== "pending") return reject("This confirmation is no longer pending.");
852
887
  if (ctx.response.principal.attributes.confirmationRequestId !== ctx.request.interactionId || ctx.response.principal.attributes.confirmationDecision !== (ctx.response.decision === "deny" ? "cancel" : "approve")) return reject("Use the Confirm or Cancel button on the action's message.");
853
- if (memberIdOf(ctx.response.principal) !== saved.memberId || memberIdOf(ctx.request.principal) !== saved.memberId) return reject("Only the requesting member can confirm or cancel this action.");
888
+ const responder = actorOf(ctx.response.principal);
889
+ if (!ownedBy(saved, responder) || !ownedBy(saved, actorOf(ctx.request.principal)) || responder?.kind === "guest" && !guestConfirms(ctx.response.principal)) return reject("Only the requesting member can confirm or cancel this action.");
854
890
  if (saved.action !== ctx.request.toolName || saved.inputHash !== inputHash(ctx.request.toolInput ?? {})) return reject("The action or input changed. Make a new call.");
855
891
  if (ctx.response.decision === "approve" && saved.expiresAt <= now()) return reject("This confirmation expired.");
856
892
  state.update((all) => ({
@@ -903,9 +939,10 @@ function ontologyTools(options = {}) {
903
939
  async function post(actor, method, params, credential, secrets, signal) {
904
940
  const key = actorKey(actor);
905
941
  const current = actorOf(options.principal);
942
+ const own = current !== void 0 && actorKey(current) === key ? options.principal : null;
906
943
  const acting = actorHeaders({
907
944
  actor,
908
- principal: current !== void 0 && actorKey(current) === key ? options.principal : null,
945
+ principal: own,
909
946
  secret: options.secret
910
947
  });
911
948
  secrets.add(acting["X-SegmentStream-Agent-Task"] ?? "");
@@ -914,6 +951,7 @@ function ontologyTools(options = {}) {
914
951
  headers: {
915
952
  authorization: `Bearer ${credential}`,
916
953
  ...acting,
954
+ ...chatHeaders(own, options.sessionId),
917
955
  "content-type": "application/json",
918
956
  accept: "application/json, text/event-stream",
919
957
  "mcp-protocol-version": "2025-11-25"
@@ -1247,10 +1285,13 @@ function ontologyConnection(input) {
1247
1285
  if (actor === void 0) return null;
1248
1286
  const origin = appOrigin(input.environment ?? process.env);
1249
1287
  const token = input.token ?? runtimeToken;
1250
- const headers = (context) => actAsHeaders({
1251
- principal: context.session.auth.current,
1252
- expected: actor,
1253
- secret: input.secret
1288
+ const headers = (context) => ({
1289
+ ...actAsHeaders({
1290
+ principal: context.session.auth.current,
1291
+ expected: actor,
1292
+ secret: input.secret
1293
+ }),
1294
+ ...chatHeaders(context.session.auth.current, context.session.id)
1254
1295
  });
1255
1296
  const common = {
1256
1297
  url: `${origin}/mcp`,
@@ -1309,11 +1350,13 @@ function ontologyConnection(input) {
1309
1350
  operation_id: chatPostOperationId(ctx.session.id, ctx.callId),
1310
1351
  source: source.provider === "telegram" ? {
1311
1352
  provider: "telegram",
1353
+ ...source.channel === void 0 ? {} : { channel: source.channel },
1312
1354
  chat_id: source.chatId,
1313
1355
  thread_id: source.threadId,
1314
1356
  ...base.source
1315
1357
  } : {
1316
1358
  provider: source.provider,
1359
+ ...source.channel === void 0 ? {} : { channel: source.channel },
1317
1360
  chat_id: source.chatId,
1318
1361
  thread_id: source.threadId,
1319
1362
  kind: source.kind,
@@ -1329,9 +1372,7 @@ function ontologyConnection(input) {
1329
1372
  }
1330
1373
  const MAXIMUM_ATTACHMENT_BYTES = MAXIMUM_DOWNLOAD_BYTES;
1331
1374
  const ATTACHMENT_TTL_HOURS = 24;
1332
- const CHAT_HEADER = "X-SegmentStream-Agent-Chat";
1333
1375
  const EARLIER_CHAT_HEADER = "X-SegmentStream-Agent-Conversation";
1334
- const SESSION_HEADER = "X-SegmentStream-Agent-Session";
1335
1376
  const ATTACHMENT_URL_PROTOCOL = "segmentstream-attachment:";
1336
1377
  const CALL_TIMEOUT_MS = 3e4;
1337
1378
  const TRANSFER_TIMEOUT_MS = 12e4;
@@ -1915,7 +1956,8 @@ function telegramPrincipal(input) {
1915
1956
  roles: member.roles,
1916
1957
  ...agentToolsAttribute(member.agentTools),
1917
1958
  chatId: message.chat.id,
1918
- chatType: message.chat.type
1959
+ chatType: message.chat.type,
1960
+ ...channelAttributes("telegram")
1919
1961
  };
1920
1962
  if (member.name !== null) attributes.memberName = member.name;
1921
1963
  if (message.messageThreadId !== void 0) attributes.messageThreadId = String(message.messageThreadId);
@@ -1953,4 +1995,4 @@ function identityProviderOf(principal) {
1953
1995
  const provider = principal?.attributes.identityProvider;
1954
1996
  return typeof provider === "string" && provider !== "" ? provider : void 0;
1955
1997
  }
1956
- export { INTROSPECTION_PATH as $, OntologyToolRejected as A, principalRuntimeSource as At, ACT_AS_HEADER as B, attachmentUrl as C, failureText as Ct, ontologyConnection as D, withDeliveryLocale as Dt, actAsHeaders as E, safeTelegramFetch as Et, CONFIRMATION_TTL_MS as F, isGuestSession as G, actorHeaders as H, actionApproval as I, notForGuests as J, member as K, confirmations as L, ontologyToolLabels as M, telegramRuntimeSource as Mt, ontologyTools as N, OntologyActionNotPermitted as O, RUNTIME_SOURCE_PROTOCOL as Ot, promotionTarget as P, GUEST_ROLE as Q, inputHash as R, agentAttachments as S, customerText as St, parseAttachmentUrl as T, reportTelegramError as Tt, actorKey as U, ActorRequiredError as V, actorOf as W, AGENT_GRANT_HEADER as X, ACCESS_TOKEN_PREFIX as Y, GUEST_ID_ATTRIBUTE as Z, AttachmentError as _, TelegramDeliveryError as _t, rolesOf as a, WEB_PROVIDER as at, MAXIMUM_ATTACHMENT_BYTES as b, customerCopy as bt, currentInboundRequest as c, ontologyIntrospection as ct, prepareInboundMedia as d, webMemberOf as dt, KIND_ATTRIBUTE as et, attachmentsContext as f, webPrincipal as ft, ATTACHMENT_URL_PROTOCOL as g, withChatAddress as gt, ATTACHMENT_TTL_HOURS as h, isSameChat as ht, memberIdOf as i, WEB_GRANT_ATTRIBUTE as it, actionToolName as j, runtimeEnvelope as jt, OntologyFileUnavailable as k, compatibleRuntimeEnvelope as kt, runInboundRequest as l, webAuth as lt, turnContent as m, chatAddressOf as mt, chatLanguage as n, TurnLimitedError as nt, telegramPrincipal as o, guestIdOf as ot, storeFiles as p, CHAT_ATTRIBUTE as pt, memberTool as q, identityProviderOf as r, WEB_AUTHENTICATOR as rt, InboundRequest as s, guestPrincipal as st, TELEGRAM_AUTHENTICATOR as t, TURN_LIMITED_CODE as tt, withReplacedText as u, webGrantOf as ut, CHAT_HEADER as v, currentLocale as vt, fetchStoredAttachment as w, formattingRefused as wt, SESSION_HEADER as x, customerMessage as xt, EARLIER_CHAT_HEADER as y, currentThreadId as yt, needsConfirmation as z };
1998
+ export { KIND_ATTRIBUTE as $, ontologyToolLabels as A, safeTelegramFetch as At, actorHeaders as B, parseAttachmentUrl as C, currentThreadId as Ct, OntologyFileUnavailable as D, failureText as Dt, OntologyActionNotPermitted as E, customerText as Et, confirmations as F, runtimeEnvelope as Ft, memberTool as G, actorOf as H, inputHash as I, telegramRuntimeSource as It, AGENT_GRANT_HEADER as J, notForGuests as K, needsConfirmation as L, promotionTarget as M, RUNTIME_SOURCE_PROTOCOL as Mt, CONFIRMATION_TTL_MS as N, compatibleRuntimeEnvelope as Nt, OntologyToolRejected as O, formattingRefused as Ot, actionApproval as P, principalRuntimeSource as Pt, INTROSPECTION_PATH as Q, ACT_AS_HEADER as R, fetchStoredAttachment as S, currentLocale as St, ontologyConnection as T, customerMessage as Tt, isGuestSession as U, actorKey as V, member as W, GUEST_ID_ATTRIBUTE as X, GUEST_CONFIRMATIONS_ATTRIBUTE as Y, GUEST_ROLE as Z, AttachmentError as _, chatChannel as _t, rolesOf as a, guestConfirms as at, agentAttachments as b, withChatAddress as bt, currentInboundRequest as c, ontologyIntrospection as ct, prepareInboundMedia as d, webMemberOf as dt, TURN_LIMITED_CODE as et, attachmentsContext as f, webPrincipal as ft, ATTACHMENT_URL_PROTOCOL as g, chatAddressOf as gt, ATTACHMENT_TTL_HOURS as h, SESSION_HEADER as ht, memberIdOf as i, WEB_PROVIDER as it, ontologyTools as j, withDeliveryLocale as jt, actionToolName as k, reportTelegramError as kt, runInboundRequest as l, webAuth as lt, turnContent as m, CHAT_HEADER as mt, chatLanguage as n, WEB_AUTHENTICATOR as nt, telegramPrincipal as o, guestIdOf as ot, storeFiles as p, CHAT_ATTRIBUTE as pt, ACCESS_TOKEN_PREFIX as q, identityProviderOf as r, WEB_GRANT_ATTRIBUTE as rt, InboundRequest as s, guestPrincipal as st, TELEGRAM_AUTHENTICATOR as t, TurnLimitedError as tt, withReplacedText as u, webGrantOf as ut, EARLIER_CHAT_HEADER as v, chatHeaders as vt, actAsHeaders as w, customerCopy as wt, attachmentUrl as x, TelegramDeliveryError as xt, MAXIMUM_ATTACHMENT_BYTES as y, isSameChat as yt, ActorRequiredError as z };
@@ -1,7 +1,8 @@
1
1
  /**
2
- * `POST /eve/segmentstream/v1/email`: the mailbox of the connection named in `channels.email`.
3
- * SegmentStream wakes it when Gmail pushes a change and at least every `checkAfterMinutes`.
4
- * Without that setting, or outside production, the route answers 404.
2
+ * `POST /eve/segmentstream/v1/email`: the mailbox of the connection named in `channels.email`, and
3
+ * `POST /eve/segmentstream/v1/email/<name>` that of every other channel of kind `email`.
4
+ * SegmentStream wakes each when Gmail pushes a change and at least every `checkAfterMinutes`.
5
+ * Without such a channel, or outside production, the route answers 404.
5
6
  */
6
7
  declare const _default: import("eve/channels").Channel<undefined, Record<string, unknown>, Record<string, unknown>>;
7
8
  export default _default;
@@ -4,11 +4,12 @@ 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 { channelOf } from "../config.mjs";
7
8
  import segmentstream from "../extension.mjs";
8
9
  import { segmentstreamEmail } from "../lib/email/channel.mjs";
9
10
  import { decide } from "eve/ai";
10
11
  var email_default = segmentstreamEmail({
11
- settings: () => segmentstream.config.channels.email,
12
+ settings: (name) => channelOf(segmentstream.config.channels, "email", name),
12
13
  admission: () => segmentstream.config,
13
14
  models: () => segmentstream.config.models,
14
15
  review: {
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * `POST /eve/v1/slack`: the bot of the workspace's `SlackConnection`, through the Slack app
3
- * SegmentStream created for it and named in `channels.slack`. SegmentStream relays the app's
4
- * events, interactions and slash commands here. Without that setting, or outside production, the
5
- * route answers 404.
3
+ * SegmentStream created for it and named in `channels.slack`, and
4
+ * `POST /eve/segmentstream/v1/slack/<name>` the app of every other channel of kind `slack`.
5
+ * SegmentStream relays each app's events, interactions and slash commands to its channel. Without
6
+ * such a channel, or outside production, the route answers 404.
6
7
  */
7
8
  declare const _default: import("eve/channels/slack").SlackChannel;
8
9
  export default _default;
@@ -4,10 +4,11 @@ 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 { channelOf } from "../config.mjs";
7
8
  import segmentstream from "../extension.mjs";
8
9
  import { segmentstreamSlack } from "../lib/slack/adapter.mjs";
9
10
  var slack_default = segmentstreamSlack({
10
- settings: () => segmentstream.config.channels.slack,
11
+ settings: (name) => channelOf(segmentstream.config.channels, "slack", name),
11
12
  admission: () => segmentstream.config,
12
13
  groups: () => segmentstream.config.groups,
13
14
  models: () => segmentstream.config.models
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * `segmentstream__telegram` at `POST /eve/v1/telegram`: the workspace's Telegram bot, reached
3
- * through the connection named in `channels.telegram`. Without that setting the route answers 404.
3
+ * through the connection named in `channels.telegram`, and at
4
+ * `POST /eve/segmentstream/v1/telegram/<name>` the bot of every other channel of kind `telegram`.
5
+ * Without such a channel the route answers 404.
4
6
  */
5
7
  declare const _default: import("eve/channels/telegram").TelegramChannel;
6
8
  export default _default;
@@ -4,11 +4,12 @@ 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 { channelOf } from "../config.mjs";
7
8
  import segmentstream from "../extension.mjs";
8
9
  import { segmentstreamTelegram } from "../lib/telegram/adapter.mjs";
9
10
  import { decide } from "eve/ai";
10
11
  var telegram_default = segmentstreamTelegram({
11
- settings: () => segmentstream.config.channels.telegram,
12
+ settings: (name) => channelOf(segmentstream.config.channels, "telegram", name),
12
13
  groups: () => segmentstream.config.groups,
13
14
  models: () => segmentstream.config.models,
14
15
  confirmationMode: () => "native",
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `POST /eve/v1/whatsapp`: the workspace's WhatsApp number, through the connection named in
3
- * `channels.whatsapp`. SegmentStream relays the number's messages here. Without that setting, or
4
- * outside production, the route answers 404.
3
+ * `channels.whatsapp`, and `POST /eve/segmentstream/v1/whatsapp/<name>` the number of every other
4
+ * channel of kind `whatsapp`. SegmentStream relays each number's messages to its channel. Without
5
+ * such a channel, or outside production, the route answers 404.
5
6
  */
6
7
  declare const _default: import("eve/channels/chat-sdk").ChatSdkChannel;
7
8
  export default _default;
@@ -4,11 +4,12 @@ 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 { channelOf } from "../config.mjs";
7
8
  import segmentstream from "../extension.mjs";
8
9
  import { segmentstreamWhatsApp } from "../lib/whatsapp/adapter.mjs";
9
10
  import { decide } from "eve/ai";
10
11
  var whatsapp_default = segmentstreamWhatsApp({
11
- settings: () => segmentstream.config.channels.whatsapp,
12
+ settings: (name) => channelOf(segmentstream.config.channels, "whatsapp", name),
12
13
  admission: () => segmentstream.config,
13
14
  models: () => segmentstream.config.models,
14
15
  review: {