@segmentstream/agent 0.54.0 → 0.56.1

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 +63 -0
  2. package/README.md +12 -6
  3. package/dist/_chunks/{build-metadata-2TyBXJEt.mjs → build-metadata-DqDm9a2E.mjs} +1 -1
  4. package/dist/_chunks/{principal-DUla0Xge.mjs → principal-TJ6zB2rF.mjs} +24 -8
  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 +212 -66
  14. package/dist/extension/config.mjs +196 -34
  15. package/dist/extension/connections/ontology.mjs +1 -1
  16. package/dist/extension/extension.d.ts +7 -1
  17. package/dist/extension/extension.mjs +2 -1
  18. package/dist/extension/hooks/authorization.mjs +1 -1
  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 -1
  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 -4
  30. package/dist/extension/lib/chat-address.mjs +1 -1
  31. package/dist/extension/lib/chat-archive.d.ts +16 -0
  32. package/dist/extension/lib/chat-archive.mjs +22 -2
  33. package/dist/extension/lib/chat-context.mjs +3 -3
  34. package/dist/extension/lib/chat-post-confirmation.d.ts +14 -3
  35. package/dist/extension/lib/chat-post-confirmation.mjs +9 -3
  36. package/dist/extension/lib/chat-recorder.d.ts +17 -0
  37. package/dist/extension/lib/chat-recorder.mjs +24 -11
  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.mjs +1 -1
  41. package/dist/extension/lib/email/attachments-send.d.ts +1 -1
  42. package/dist/extension/lib/email/attachments-send.mjs +1 -1
  43. package/dist/extension/lib/email/channel.d.ts +11 -3
  44. package/dist/extension/lib/email/channel.mjs +53 -42
  45. package/dist/extension/lib/guest-usage.mjs +1 -1
  46. package/dist/extension/lib/inbound-media/files.mjs +1 -1
  47. package/dist/extension/lib/inbound-media/index.mjs +1 -1
  48. package/dist/extension/lib/ontology-connection.mjs +1 -1
  49. package/dist/extension/lib/ontology-file-call.mjs +1 -1
  50. package/dist/extension/lib/ontology-tools.mjs +1 -1
  51. package/dist/extension/lib/review/client.mjs +1 -0
  52. package/dist/extension/lib/review/hold.d.ts +8 -1
  53. package/dist/extension/lib/review/hold.mjs +4 -2
  54. package/dist/extension/lib/review/reply.mjs +3 -3
  55. package/dist/extension/lib/role-skill.mjs +1 -1
  56. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  57. package/dist/extension/lib/sent-files.mjs +1 -1
  58. package/dist/extension/lib/slack/adapter.d.ts +5 -4
  59. package/dist/extension/lib/slack/adapter.mjs +19 -15
  60. package/dist/extension/lib/slack/attachments-send.d.ts +1 -1
  61. package/dist/extension/lib/slack/attachments-send.mjs +1 -1
  62. package/dist/extension/lib/stored-files.mjs +1 -1
  63. package/dist/extension/lib/telegram/adapter.d.ts +8 -2
  64. package/dist/extension/lib/telegram/adapter.mjs +43 -31
  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/callbacks.mjs +1 -1
  68. package/dist/extension/lib/telegram/chat-archive.mjs +11 -10
  69. package/dist/extension/lib/telegram/chat-post-card.mjs +4 -3
  70. package/dist/extension/lib/telegram/confirmations.mjs +2 -2
  71. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  72. package/dist/extension/lib/telegram/delivery-diagnostics.mjs +2 -1
  73. package/dist/extension/lib/telegram/files.d.ts +4 -1
  74. package/dist/extension/lib/telegram/files.mjs +3 -2
  75. package/dist/extension/lib/telegram/health.mjs +1 -1
  76. package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
  77. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  78. package/dist/extension/lib/telegram/inbound.mjs +4 -4
  79. package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
  80. package/dist/extension/lib/telegram/principal.mjs +1 -1
  81. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  82. package/dist/extension/lib/telegram/signals.mjs +2 -1
  83. package/dist/extension/lib/telegram/silent.mjs +1 -1
  84. package/dist/extension/lib/telegram/structured.mjs +1 -1
  85. package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
  86. package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
  87. package/dist/extension/lib/web/auth.mjs +1 -1
  88. package/dist/extension/lib/web/channel.mjs +1 -1
  89. package/dist/extension/lib/whatsapp/adapter.d.ts +12 -6
  90. package/dist/extension/lib/whatsapp/adapter.mjs +17 -10
  91. package/dist/extension/lib/whatsapp/attachments-send.d.ts +1 -1
  92. package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
  93. package/dist/extension/lib/whatsapp/files.mjs +1 -1
  94. package/dist/extension/lib/workspace-channel/attachments-send.d.ts +35 -0
  95. package/dist/extension/lib/workspace-channel/attachments-send.mjs +119 -0
  96. package/dist/extension/lib/workspace-channel/channel.d.ts +229 -0
  97. package/dist/extension/lib/workspace-channel/channel.mjs +525 -0
  98. package/dist/extension/lib/workspace-channel/connection.d.ts +55 -0
  99. package/dist/extension/lib/workspace-channel/connection.mjs +68 -0
  100. package/dist/extension/lib/workspace-channel/secrets.d.ts +32 -0
  101. package/dist/extension/lib/workspace-channel/secrets.mjs +55 -0
  102. package/dist/extension/lib/workspace-source.d.ts +1 -1
  103. package/dist/extension/lib/workspace-source.mjs +3 -2
  104. package/dist/extension/model.mjs +1 -1
  105. package/dist/extension/tools/attachments_discard.mjs +1 -1
  106. package/dist/extension/tools/attachments_list.mjs +1 -1
  107. package/dist/extension/tools/attachments_promote.mjs +1 -1
  108. package/dist/extension/tools/attachments_read.mjs +1 -1
  109. package/dist/extension/tools/attachments_send.mjs +15 -7
  110. package/dist/extension/tools/attachments_stage.mjs +1 -1
  111. package/dist/extension/tools/attachments_table.mjs +1 -1
  112. package/dist/extension/tools/questions_ask.mjs +1 -1
  113. package/dist/extension/tools/workspace_source.mjs +1 -1
  114. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.56.1
4
+
5
+ Pins @segmentstream/ontology 0.113.0.
6
+
7
+ ## 0.56.0
8
+
9
+ A workspace can define a channel in its own code for any provider with an API, such as a CRM
10
+ inbox or a marketplace's buyer chat. `defineChannel({ name, config, receive, parse, send, limits })`
11
+ in `agent/agent/channels/<name>.ts` supplies the provider's part: a webhook `verify`, or a
12
+ `poll.read` the platform wakes with a cursor; `parse`, which maps an event to
13
+ `{ id, chatId, sender, text, files }`; and `send`, which sends through the channel's connection.
14
+ The platform does the rest as on its own channels: admission and sign-up, limits, sessions and
15
+ chat keys, the archive, review holds, attachments both ways with `limits.files`, chat provenance
16
+ and figures. `agent/segmentstream.json` declares it as
17
+ `channels.<name>: { kind: "custom", connection, receive?: "webhook" | "poll", checkAfterMinutes?,
18
+ secret? }`. `verify(request, { signedWith, matches })` checks a delivery against the workspace
19
+ secret `secret` names, which only the platform reads, as the ontology's webhooks are checked.
20
+
21
+ Its people's accounts are its own, `channel:<name>`: it can claim no Telegram, WhatsApp or email
22
+ account. Its chats are private, and the channel shows no confirmation buttons. A reply a member
23
+ approves, or a chat post to one of its chats, reaches the person through the channel's
24
+ `/eve/segmentstream/v1/custom/<name>/send`, which only the deployment's own functions may call;
25
+ a chat post goes to the chat the person last wrote from there. The agent previews a chat post to a
26
+ workspace channel with the text as written. The archive shows a reply once `send` returned. A
27
+ delivery or a read holding more than 50 messages is refused whole, before any starts a turn.
28
+ `custom` is a kind, never a channel's name.
29
+
30
+ Action required: before deploying a workspace channel, upgrade the ontology SDK and declare it in
31
+ `defineOntology({ chat: { <name>: { kind: "custom" } } })`, so approved replies and chat posts
32
+ reach it; list `channel:<name>` in `signUp.channels` for its strangers to sign up.
33
+
34
+ Pins @segmentstream/ontology 0.112.0.
35
+
36
+ ## 0.55.0
37
+
38
+ An agent answers on several channels of one kind: two WhatsApp numbers, a few Telegram bots,
39
+ several mailboxes or Slack apps. `channels` names each one; a channel named after its kind
40
+ (`telegram`, `whatsapp`, `slack`, `email`) is that kind and stays valid as written, and any other
41
+ name, such as `sales_whatsapp`, says its `kind`. Each channel needs a connection of its own.
42
+
43
+ The channel named after its kind keeps every key its chats had: sessions, archive, review and
44
+ attachments are unchanged. Any other channel carries its name in its chats' keys, so two bots'
45
+ private chats with the same person never meet, and receives at its own route:
46
+ `/eve/segmentstream/v1/<kind>/<name>`, where SegmentStream points each bot's webhook, relays each
47
+ number's and app's events, and wakes each mailbox. Each channel's replies leave through its own
48
+ connection, and a reply held for review names its channel, so approving it sends it through that
49
+ channel. People are not per channel: one Telegram account, number or address is one person on
50
+ every channel of its kind. Only the bot of `channels.telegram` opens the app as a Mini App.
51
+
52
+ `attachments_send` sends through the connection of the channel the chat is on, and each email
53
+ channel keeps, retries and drains its own replies. The chat an ontology request comes from
54
+ (`X-SegmentStream-Agent-Chat`) names the channel by its name, as the archive does, so history
55
+ and chat figures show `sales_whatsapp` where a chat of `channels.whatsapp` shows `whatsapp`. A
56
+ post to another chat renders as the kind `chat_list` names for its channel; an ontology that names
57
+ none lists only channels named after their kind, as before.
58
+
59
+ Action required: before naming a channel other than its kind, upgrade the ontology SDK and declare
60
+ the channel in `defineOntology({ chat })` under the same name with its `kind`, such as
61
+ `chat: { sales_whatsapp: { kind: "whatsapp", connection: waSales } }`; an older ontology refuses
62
+ the replies held on it.
63
+
64
+ Pins @segmentstream/ontology 0.111.0.
65
+
3
66
  ## 0.54.0
4
67
 
5
68
  History keeps the chat an action came from. The app's agent names the chat it acts in and its
package/README.md CHANGED
@@ -128,6 +128,9 @@ 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" |
132
+ | `channels.<name>.receive` | `"webhook"` | A workspace channel (`kind: "custom"`, defined with `defineChannel`): `webhook`, its provider calls it, or `poll`, the platform wakes it every `checkAfterMinutes`; see `docs/agent.md`, "Workspace channels" |
133
+ | `channels.<name>.secret` | none | A workspace channel's workspace secret, which its `verify` checks deliveries against with `signedWith` or `matches`; only the platform reads it |
131
134
  | `models.stt` | `"spacexai/grok-stt"` | The AI Gateway transcription model for voice messages; `false` leaves them untranscribed |
132
135
  | `models.imageDescription` | `google/gemini-2.5-flash-lite` | Image evidence for group routing even with native vision; `false` disables descriptions |
133
136
  | `models.decision` | `"typesafe-ai/jev-1.14.0"` | The AI Gateway decision model of the inbound router |
@@ -808,14 +811,17 @@ ordinary tools use the compatible connection and no runtime arguments are added.
808
811
  missing/incomplete preview metadata is denied. The versioned connection has its own instance key.
809
812
 
810
813
  The runtime reads `me` for the server-derived `attribution`, and `chat_list({ chat })` for exactly
811
- one eligible destination: `{ items: [{ id, title, provider, external_id }], next_cursor: null }`.
812
- Provider is `telegram`, `slack` or `whatsapp`; the agent refuses a destination on any other
813
- provider when it describes the post, as agents before Slack and WhatsApp destinations refuse
814
- theirs, and refuses a `reply_to` for WhatsApp. The final text is computed as the ontology renders
814
+ one eligible destination: `{ items: [{ id, title, provider, kind?, external_id }], next_cursor:
815
+ null }`. `provider` is the destination's channel by its name and `kind` that channel's kind; an
816
+ ontology that sends no `kind` lists only channels named after their kind, whose name is the kind.
817
+ The kind is `telegram`, `slack` or `whatsapp`; the agent refuses a destination of any other kind
818
+ when it describes the post, as agents before Slack and WhatsApp destinations refuse theirs, and
819
+ refuses a `reply_to` for WhatsApp. The final text is computed as the ontology renders
815
820
  it: Telegram's MarkdownV2, `renderSlack` from `@segmentstream/ontology/slack`, or `renderWhatsApp`
816
821
  from `@segmentstream/ontology/whatsapp`. The final plain text is `text + separator + attribution`, with a blank line as the neutral separator;
817
- `reply_to` is optional. A preview digest is SHA-256 of the JSON array of chat ID, provider,
818
- external ID, title, attribution, text, final text and nullable reply target, in that order.
822
+ `reply_to` is optional. A preview digest is SHA-256 of the JSON array of chat ID, provider (the
823
+ channel's name), external ID, title, attribution, text, final text and nullable reply target, in
824
+ that order.
819
825
  The target/attribution are resolved again immediately before executing the frozen call.
820
826
 
821
827
  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.54.0";
7
+ var version = "0.56.1";
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
  }
@@ -372,6 +376,7 @@ function chatAddressOf(principal) {
372
376
  const chatId = attributes.chatId;
373
377
  return typeof chatId !== "string" || chatId === "" ? void 0 : {
374
378
  provider: "telegram",
379
+ ...principalChannel(principal) === void 0 ? {} : { channel: principalChannel(principal) },
375
380
  chatId,
376
381
  threadId: String(attributes.messageThreadId ?? ""),
377
382
  kind: chatId.startsWith("-") ? "group" : "private"
@@ -388,7 +393,7 @@ function chatAddressOf(principal) {
388
393
  function chatHeaders(principal, sessionId) {
389
394
  const chat = chatAddressOf(principal);
390
395
  return chat === void 0 ? {} : {
391
- [CHAT_HEADER]: `${chat.provider}:${chat.chatId}`,
396
+ [CHAT_HEADER]: `${chatChannel(chat)}:${chat.chatId}`,
392
397
  ...sessionId === void 0 || sessionId === "" ? {} : { [SESSION_HEADER]: sessionId }
393
398
  };
394
399
  }
@@ -396,17 +401,24 @@ function parsedChatAddress(value, provider) {
396
401
  if (typeof value !== "object" || value === null || Array.isArray(value)) return;
397
402
  const item = value;
398
403
  const text = (field, empty = false) => typeof field === "string" && (empty || field !== "") && field.length <= 512;
399
- 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 !== "custom" || (item.provider === "custom" ? typeof item.channel !== "string" || provider !== workspaceIdentityProvider(item.channel) : 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;
400
405
  return {
401
406
  provider: item.provider,
407
+ ...item.channel === void 0 ? {} : { channel: item.channel },
402
408
  chatId: item.chatId,
403
409
  threadId: item.threadId,
404
410
  kind: item.kind,
405
411
  ...item.peer === void 0 ? {} : { peer: item.peer }
406
412
  };
407
413
  }
414
+ function workspaceIdentityProvider(channel) {
415
+ return `channel:${channel}`;
416
+ }
417
+ function chatChannel(chat) {
418
+ return chat.channel ?? chat.provider;
419
+ }
408
420
  function isSameChat(chat, destination) {
409
- if (chat.provider !== destination.provider) return false;
421
+ if (chatChannel(chat) !== destination.provider) return false;
410
422
  return chat.chatId === destination.externalId || chat.provider !== "telegram" && chat.kind === "private" && chat.peer === destination.externalId;
411
423
  }
412
424
  const WEB_AUTHENTICATOR = "segmentstream-web";
@@ -726,7 +738,7 @@ function ownedBy(saved, actor) {
726
738
  }
727
739
  }
728
740
  function isSameSource(saved, current) {
729
- return current !== void 0 && saved.provider === current.provider && saved.chatId === current.chatId && saved.threadId === current.threadId;
741
+ return current !== void 0 && chatChannel(saved) === chatChannel(current) && saved.chatId === current.chatId && saved.threadId === current.threadId;
730
742
  }
731
743
  const confirmations = defineState("segmentstream.confirmations", () => ({}));
732
744
  function connectionHints(ctx) {
@@ -832,6 +844,7 @@ function actionApproval(options) {
832
844
  if (saved !== void 0) return denied("The original call is waiting for its Confirm / Cancel buttons.");
833
845
  if (!posting && !needsConfirmation(labels)) return "approved";
834
846
  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.");
847
+ if (chat?.provider === "custom") return denied("This chat shows no confirmation buttons, so this action cannot run from it. Say in your reply what you would do; a member can run it.");
835
848
  if (labels.confirmation === true && labels.preview !== true && copy === void 0) return missingCopy();
836
849
  try {
837
850
  if (!posting) description = await options.describe?.(confirmer, ctx.toolName, businessInput, hints, confirmationLocale(ctx.session.auth.current));
@@ -1341,11 +1354,13 @@ function ontologyConnection(input) {
1341
1354
  operation_id: chatPostOperationId(ctx.session.id, ctx.callId),
1342
1355
  source: source.provider === "telegram" ? {
1343
1356
  provider: "telegram",
1357
+ ...source.channel === void 0 ? {} : { channel: source.channel },
1344
1358
  chat_id: source.chatId,
1345
1359
  thread_id: source.threadId,
1346
1360
  ...base.source
1347
1361
  } : {
1348
1362
  provider: source.provider,
1363
+ ...source.channel === void 0 ? {} : { channel: source.channel },
1349
1364
  chat_id: source.chatId,
1350
1365
  thread_id: source.threadId,
1351
1366
  kind: source.kind,
@@ -1945,7 +1960,8 @@ function telegramPrincipal(input) {
1945
1960
  roles: member.roles,
1946
1961
  ...agentToolsAttribute(member.agentTools),
1947
1962
  chatId: message.chat.id,
1948
- chatType: message.chat.type
1963
+ chatType: message.chat.type,
1964
+ ...channelAttributes("telegram")
1949
1965
  };
1950
1966
  if (member.name !== null) attributes.memberName = member.name;
1951
1967
  if (message.messageThreadId !== void 0) attributes.messageThreadId = String(message.messageThreadId);
@@ -1983,4 +1999,4 @@ function identityProviderOf(principal) {
1983
1999
  const provider = principal?.attributes.identityProvider;
1984
2000
  return typeof provider === "string" && provider !== "" ? provider : void 0;
1985
2001
  }
1986
- export { KIND_ATTRIBUTE as $, ontologyToolLabels as A, withDeliveryLocale as At, actorHeaders as B, parseAttachmentUrl as C, customerCopy as Ct, OntologyFileUnavailable as D, formattingRefused as Dt, OntologyActionNotPermitted as E, failureText as Et, confirmations as F, telegramRuntimeSource as Ft, memberTool as G, actorOf as H, inputHash as I, AGENT_GRANT_HEADER as J, notForGuests as K, needsConfirmation as L, promotionTarget as M, compatibleRuntimeEnvelope as Mt, CONFIRMATION_TTL_MS as N, principalRuntimeSource as Nt, OntologyToolRejected as O, reportTelegramError as Ot, actionApproval as P, runtimeEnvelope as Pt, INTROSPECTION_PATH as Q, ACT_AS_HEADER as R, fetchStoredAttachment as S, currentThreadId as St, ontologyConnection as T, customerText 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 _, chatHeaders as _t, rolesOf as a, guestConfirms as at, agentAttachments as b, TelegramDeliveryError 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, RUNTIME_SOURCE_PROTOCOL as jt, actionToolName as k, safeTelegramFetch 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, isSameChat as vt, actAsHeaders as w, customerMessage as wt, attachmentUrl as x, currentLocale as xt, MAXIMUM_ATTACHMENT_BYTES as y, withChatAddress as yt, ActorRequiredError as z };
2002
+ export { KIND_ATTRIBUTE as $, ontologyToolLabels as A, reportTelegramError as At, actorHeaders as B, parseAttachmentUrl as C, currentLocale as Ct, OntologyFileUnavailable as D, customerText as Dt, OntologyActionNotPermitted as E, customerMessage as Et, confirmations as F, principalRuntimeSource as Ft, memberTool as G, actorOf as H, inputHash as I, runtimeEnvelope as It, AGENT_GRANT_HEADER as J, notForGuests as K, needsConfirmation as L, telegramRuntimeSource as Lt, promotionTarget as M, withDeliveryLocale as Mt, CONFIRMATION_TTL_MS as N, RUNTIME_SOURCE_PROTOCOL as Nt, OntologyToolRejected as O, failureText as Ot, actionApproval as P, compatibleRuntimeEnvelope as Pt, INTROSPECTION_PATH as Q, ACT_AS_HEADER as R, fetchStoredAttachment as S, TelegramDeliveryError as St, ontologyConnection as T, customerCopy 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, safeTelegramFetch as jt, actionToolName as k, formattingRefused 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, currentThreadId as wt, attachmentUrl as x, workspaceIdentityProvider 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: {