@segmentstream/agent 0.55.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 (87) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +2 -0
  3. package/dist/_chunks/{build-metadata-CYSFZe6f.mjs → build-metadata-DqDm9a2E.mjs} +1 -1
  4. package/dist/_chunks/{principal-DIgU-kPR.mjs → principal-TJ6zB2rF.mjs} +6 -2
  5. package/dist/extension/config.d.ts +54 -7
  6. package/dist/extension/config.mjs +65 -6
  7. package/dist/extension/connections/ontology.mjs +1 -1
  8. package/dist/extension/extension.d.ts +7 -1
  9. package/dist/extension/extension.mjs +2 -1
  10. package/dist/extension/hooks/authorization.mjs +1 -1
  11. package/dist/extension/instructions/persona.mjs +1 -1
  12. package/dist/extension/lib/actor.mjs +1 -1
  13. package/dist/extension/lib/attachment-tools.mjs +1 -1
  14. package/dist/extension/lib/attachments-send.mjs +1 -1
  15. package/dist/extension/lib/attachments.d.ts +1 -1
  16. package/dist/extension/lib/attachments.mjs +1 -1
  17. package/dist/extension/lib/build-metadata.mjs +1 -1
  18. package/dist/extension/lib/chat-address.d.ts +10 -2
  19. package/dist/extension/lib/chat-address.mjs +1 -1
  20. package/dist/extension/lib/chat-archive.d.ts +10 -0
  21. package/dist/extension/lib/chat-archive.mjs +15 -0
  22. package/dist/extension/lib/chat-context.mjs +1 -1
  23. package/dist/extension/lib/chat-post-confirmation.d.ts +1 -1
  24. package/dist/extension/lib/chat-post-confirmation.mjs +3 -2
  25. package/dist/extension/lib/chat-recorder.mjs +7 -3
  26. package/dist/extension/lib/confirmations.mjs +1 -1
  27. package/dist/extension/lib/email/attachments-send.mjs +1 -1
  28. package/dist/extension/lib/email/channel.mjs +1 -1
  29. package/dist/extension/lib/guest-usage.mjs +1 -1
  30. package/dist/extension/lib/inbound-media/files.mjs +1 -1
  31. package/dist/extension/lib/inbound-media/index.mjs +1 -1
  32. package/dist/extension/lib/ontology-connection.mjs +1 -1
  33. package/dist/extension/lib/ontology-file-call.mjs +1 -1
  34. package/dist/extension/lib/ontology-tools.mjs +1 -1
  35. package/dist/extension/lib/review/hold.d.ts +1 -1
  36. package/dist/extension/lib/review/hold.mjs +3 -2
  37. package/dist/extension/lib/review/reply.mjs +1 -1
  38. package/dist/extension/lib/role-skill.mjs +1 -1
  39. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  40. package/dist/extension/lib/sent-files.mjs +1 -1
  41. package/dist/extension/lib/slack/adapter.mjs +1 -1
  42. package/dist/extension/lib/slack/attachments-send.mjs +1 -1
  43. package/dist/extension/lib/stored-files.mjs +1 -1
  44. package/dist/extension/lib/telegram/adapter.mjs +2 -2
  45. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  46. package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
  47. package/dist/extension/lib/telegram/callbacks.mjs +1 -1
  48. package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
  49. package/dist/extension/lib/telegram/confirmations.mjs +1 -1
  50. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  51. package/dist/extension/lib/telegram/files.mjs +1 -1
  52. package/dist/extension/lib/telegram/health.mjs +1 -1
  53. package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
  54. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  55. package/dist/extension/lib/telegram/inbound.mjs +1 -1
  56. package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
  57. package/dist/extension/lib/telegram/principal.mjs +1 -1
  58. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  59. package/dist/extension/lib/telegram/silent.mjs +1 -1
  60. package/dist/extension/lib/telegram/structured.mjs +1 -1
  61. package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
  62. package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
  63. package/dist/extension/lib/web/auth.mjs +1 -1
  64. package/dist/extension/lib/web/channel.mjs +1 -1
  65. package/dist/extension/lib/whatsapp/adapter.mjs +1 -1
  66. package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
  67. package/dist/extension/lib/whatsapp/files.mjs +1 -1
  68. package/dist/extension/lib/workspace-channel/attachments-send.d.ts +35 -0
  69. package/dist/extension/lib/workspace-channel/attachments-send.mjs +119 -0
  70. package/dist/extension/lib/workspace-channel/channel.d.ts +229 -0
  71. package/dist/extension/lib/workspace-channel/channel.mjs +525 -0
  72. package/dist/extension/lib/workspace-channel/connection.d.ts +55 -0
  73. package/dist/extension/lib/workspace-channel/connection.mjs +68 -0
  74. package/dist/extension/lib/workspace-channel/secrets.d.ts +32 -0
  75. package/dist/extension/lib/workspace-channel/secrets.mjs +55 -0
  76. package/dist/extension/lib/workspace-source.mjs +1 -1
  77. package/dist/extension/model.mjs +1 -1
  78. package/dist/extension/tools/attachments_discard.mjs +1 -1
  79. package/dist/extension/tools/attachments_list.mjs +1 -1
  80. package/dist/extension/tools/attachments_promote.mjs +1 -1
  81. package/dist/extension/tools/attachments_read.mjs +1 -1
  82. package/dist/extension/tools/attachments_send.mjs +6 -2
  83. package/dist/extension/tools/attachments_stage.mjs +1 -1
  84. package/dist/extension/tools/attachments_table.mjs +1 -1
  85. package/dist/extension/tools/questions_ask.mjs +1 -1
  86. package/dist/extension/tools/workspace_source.mjs +1 -1
  87. package/package.json +2 -2
@@ -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-DIgU-kPR.mjs";
7
+ import { _ as AttachmentError } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { sendStoredAttachments } from "../attachments-send.mjs";
9
9
  import { ConnectionProxyError, connectionProxy } from "../connection-proxy.mjs";
10
10
  import { redactDiagnostic } from "../diagnostics.mjs";
@@ -8,7 +8,7 @@ import { PUBSUB_TOPIC } from "../../config.mjs";
8
8
  import { admitMessage, localizedText } from "../admission.mjs";
9
9
  import { agentToolsAttribute } from "../agent-tools.mjs";
10
10
  import { providerChat } from "../attachment-tools.mjs";
11
- import { S as fetchStoredAttachment, b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, gt as chatAddressOf, i as memberIdOf, m as turnContent } from "../../../_chunks/principal-DIgU-kPR.mjs";
11
+ import { S as fetchStoredAttachment, b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, gt as chatAddressOf, i as memberIdOf, m as turnContent } from "../../../_chunks/principal-TJ6zB2rF.mjs";
12
12
  import { channelAttributes, currentChannel, currentKey, inHandlerChannels, withNamedRoutes } from "../channel-scope.mjs";
13
13
  import { chatArchive, chatEvent, replyEvent } from "../chat-archive.mjs";
14
14
  import { ConnectionProxyError, connectionProxy } from "../connection-proxy.mjs";
@@ -6,7 +6,7 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { appOrigin } from "./environment.mjs";
8
8
  import { runtimeToken } from "./runtime-token.mjs";
9
- import { ot as guestIdOf } from "../../_chunks/principal-DIgU-kPR.mjs";
9
+ import { ot as guestIdOf } from "../../_chunks/principal-TJ6zB2rF.mjs";
10
10
  const GUEST_USAGE_PATH = "/api/ontology/agent/guests/usage";
11
11
  const REPORT_TIMEOUT_MS = 5e3;
12
12
  function ontologyGuestUsage(options = {}) {
@@ -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 { f as attachmentsContext, p as storeFiles, m as turnContent } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ export { f as attachmentsContext, p as storeFiles, m as turnContent } from "../../../_chunks/principal-TJ6zB2rF.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 { f as attachmentsContext, d as prepareInboundMedia, p as storeFiles, m as turnContent } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ export { f as attachmentsContext, d as prepareInboundMedia, p as storeFiles, m as turnContent } from "../../../_chunks/principal-TJ6zB2rF.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 { R as ACT_AS_HEADER, w as actAsHeaders, T as ontologyConnection } from "../../_chunks/principal-DIgU-kPR.mjs";
7
+ export { R as ACT_AS_HEADER, w as actAsHeaders, T as ontologyConnection } from "../../_chunks/principal-TJ6zB2rF.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 { F as confirmations, Ft as runtimeEnvelope, H as actorOf, I as inputHash, P as actionApproval, V as actorKey, j as ontologyTools } from "../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { F as confirmations, H as actorOf, I as inputHash, It as runtimeEnvelope, P as actionApproval, V as actorKey, j as ontologyTools } from "../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { isChatPost } from "./chat-post-confirmation.mjs";
9
9
  import { sandboxFile } from "./sandbox-session.mjs";
10
10
  import { saveOntologyResult } from "./ontology-result-file.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 { E as OntologyActionNotPermitted, D as OntologyFileUnavailable, O as OntologyToolRejected, k as actionToolName, A as ontologyToolLabels, j as ontologyTools, M as promotionTarget } from "../../_chunks/principal-DIgU-kPR.mjs";
7
+ export { E as OntologyActionNotPermitted, D as OntologyFileUnavailable, O as OntologyToolRejected, k as actionToolName, A as ontologyToolLabels, j as ontologyTools, M as promotionTarget } from "../../_chunks/principal-TJ6zB2rF.mjs";
@@ -8,7 +8,7 @@ import { type ReviewSettings, type Review } from "../../review.js";
8
8
  export interface HeldReply {
9
9
  /** Names the reply, so a report repeated after a failure creates one review. */
10
10
  readonly key: string;
11
- readonly provider: "telegram" | "slack" | "whatsapp" | "email";
11
+ readonly provider: "telegram" | "slack" | "whatsapp" | "email" | "custom";
12
12
  /**
13
13
  * The channel the chat is on, by name, when it is not the one named after its kind: approval
14
14
  * sends the reply through its connection in the ontology's `chat`. Absent for the channel named
@@ -5,14 +5,15 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { reviewFor } from "../../review.mjs";
8
- import { a as rolesOf, gt as chatAddressOf, i as memberIdOf } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { a as rolesOf, gt as chatAddressOf, i as memberIdOf } from "../../../_chunks/principal-TJ6zB2rF.mjs";
9
9
  function reviewOf(settings, principal) {
10
10
  return reviewFor(settings, rolesOf(principal));
11
11
  }
12
12
  const REVIEWED_PROVIDERS = new Set([
13
13
  "telegram",
14
14
  "whatsapp",
15
- "email"
15
+ "email",
16
+ "custom"
16
17
  ]);
17
18
  function repliesReviewed(settings, principal) {
18
19
  const provider = chatAddressOf(principal)?.provider;
@@ -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 chatChannel, gt as chatAddressOf, i as memberIdOf } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { _t as chatChannel, gt as chatAddressOf, i as memberIdOf } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { chatArchive, chatEvent } from "../chat-archive.mjs";
9
9
  import { appOrigin } from "../environment.mjs";
10
10
  import { agentReviews } from "./client.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 { a as rolesOf } from "../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { a as rolesOf } from "../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { defineDynamic, defineSkill } from "eve/skills";
9
9
  function forRoles(roles, skill) {
10
10
  if (!Array.isArray(roles) || roles.length === 0 || !roles.every((role) => typeof role === "string" && role.trim() !== "")) throw new TypeError("forRoles() needs at least one role name; a skill for everyone is an ordinary skill file.");
@@ -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 { Mt as RUNTIME_SOURCE_PROTOCOL, Nt as compatibleRuntimeEnvelope, Pt as principalRuntimeSource, Ft as runtimeEnvelope, It as telegramRuntimeSource } from "../../_chunks/principal-DIgU-kPR.mjs";
7
+ export { Nt as RUNTIME_SOURCE_PROTOCOL, Pt as compatibleRuntimeEnvelope, Ft as principalRuntimeSource, It as runtimeEnvelope, Lt as telegramRuntimeSource } from "../../_chunks/principal-TJ6zB2rF.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 { R as ACT_AS_HEADER, _ as AttachmentError, ht as SESSION_HEADER, mt as CHAT_HEADER, v as EARLIER_CHAT_HEADER } from "../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { R as ACT_AS_HEADER, _ as AttachmentError, ht as SESSION_HEADER, mt as CHAT_HEADER, v as EARLIER_CHAT_HEADER } from "../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { fetchFileGrant, transientFileStatus } from "./file-grant.mjs";
9
9
  var StoredFileError = class extends AttachmentError {
10
10
  filename;
@@ -8,7 +8,7 @@ import { admitMessage, localizedText } from "../admission.mjs";
8
8
  import { agentToolsAttribute } from "../agent-tools.mjs";
9
9
  import { agentChats, channelChats } from "../chats.mjs";
10
10
  import { withButtonDecision } from "../confirmation-buttons.mjs";
11
- import { b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, m as turnContent } from "../../../_chunks/principal-DIgU-kPR.mjs";
11
+ import { b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, m as turnContent } from "../../../_chunks/principal-TJ6zB2rF.mjs";
12
12
  import { channelAttributes, currentChannel, withNamedRoutes, withSessionChannels } from "../channel-scope.mjs";
13
13
  import { redactDiagnostic } from "../diagnostics.mjs";
14
14
  import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.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 { _ as AttachmentError } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { _ as AttachmentError } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { sendStoredAttachments } from "../attachments-send.mjs";
9
9
  import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
10
10
  import { redactDiagnostic } from "../diagnostics.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-DIgU-kPR.mjs";
8
+ import { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-TJ6zB2rF.mjs";
9
9
  import { redactDiagnostic } from "./diagnostics.mjs";
10
10
  import { createHash } from "node:crypto";
11
11
  async function readStoredFile(input, principal, options = {}) {
@@ -10,12 +10,12 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
10
10
  import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
11
11
  import { handleWorkspaceCallback, isWorkspaceCallback } from "./callbacks.mjs";
12
12
  import { telegramText, withTelegramTexts } from "./texts.mjs";
13
- import { t as agentBuild } from "../../../_chunks/build-metadata-CYSFZe6f.mjs";
13
+ import { t as agentBuild } from "../../../_chunks/build-metadata-DqDm9a2E.mjs";
14
14
  import { attachmentLifecycle } from "./lifecycle.mjs";
15
15
  import { manifestOf } from "../../config.mjs";
16
16
  import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
17
17
  import { chooseModel } from "../../model.mjs";
18
- import { At as safeTelegramFetch, Dt as failureText, S as fetchStoredAttachment, St as currentLocale, b as agentAttachments, c as currentInboundRequest, jt as withDeliveryLocale, kt as reportTelegramError, l as runInboundRequest, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText } from "../../../_chunks/principal-DIgU-kPR.mjs";
18
+ import { At as reportTelegramError, Ct as currentLocale, Mt as withDeliveryLocale, Ot as failureText, S as fetchStoredAttachment, b as agentAttachments, c as currentInboundRequest, jt as safeTelegramFetch, l as runInboundRequest, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText } from "../../../_chunks/principal-TJ6zB2rF.mjs";
19
19
  import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
20
20
  import { appOrigin, channelsEnabled, proxyEnvironment, runtimeIdentityEnvironment, webhookSecret } from "../environment.mjs";
21
21
  import { agentIdentities } from "../identities.mjs";
@@ -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 { kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError } from "../../../_chunks/principal-TJ6zB2rF.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 { Dt as failureText, Ot as formattingRefused, Tt as customerMessage, _ as AttachmentError, kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError, Et as customerMessage, Ot as failureText, _ as AttachmentError, kt as formattingRefused } from "../../../_chunks/principal-TJ6zB2rF.mjs";
9
9
  import { attachmentFailure } from "../attachments-send.mjs";
10
10
  import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
11
11
  import { redactDiagnostic } from "../diagnostics.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 { Ft as runtimeEnvelope, It as telegramRuntimeSource, c as currentInboundRequest, i as memberIdOf, kt as reportTelegramError, o as telegramPrincipal } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError, It as runtimeEnvelope, Lt as telegramRuntimeSource, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-TJ6zB2rF.mjs";
9
9
  import { formatAddress, parseAddress, scopedAddress } from "./sessions.mjs";
10
10
  import { telegramText } from "./texts.mjs";
11
11
  import { workspaceAction } from "./workspace-action.mjs";
@@ -10,7 +10,7 @@ import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cD
10
10
  import { chatEvent, sessionFailureEventId } from "../chat-archive.mjs";
11
11
  import { currentConfirmationPrompt } from "../group-routing/messages.mjs";
12
12
  import { messageMetadata } from "./message-metadata.mjs";
13
- import { Ct as currentThreadId, c as currentInboundRequest, kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
13
+ import { At as reportTelegramError, c as currentInboundRequest, wt as currentThreadId } from "../../../_chunks/principal-TJ6zB2rF.mjs";
14
14
  import { reportMembership } from "./membership.mjs";
15
15
  import { currentDeliveryScope } from "./delivery-diagnostics.mjs";
16
16
  import { contentShape, messageContent } from "./content.mjs";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { telegramText } from "./texts.mjs";
8
- import { F as confirmations, _t as chatChannel, c as currentInboundRequest, i as memberIdOf, kt as reportTelegramError, o as telegramPrincipal } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError, F as confirmations, _t as chatChannel, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-TJ6zB2rF.mjs";
9
9
  import { humanText } from "../confirmation-description.mjs";
10
10
  import { withConfirmationPrompt } from "../group-routing/messages.mjs";
11
11
  import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
@@ -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 { At as safeTelegramFetch, Ct as currentThreadId, Dt as failureText, Et as customerText, Ot as formattingRefused, St as currentLocale, Tt as customerMessage, jt as withDeliveryLocale, kt as reportTelegramError, wt as customerCopy, xt as TelegramDeliveryError } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError, Ct as currentLocale, Dt as customerText, Et as customerMessage, Mt as withDeliveryLocale, Ot as failureText, St as TelegramDeliveryError, Tt as customerCopy, jt as safeTelegramFetch, kt as formattingRefused, wt as currentThreadId } from "../../../_chunks/principal-TJ6zB2rF.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 { currentChannel } from "../channel-scope.mjs";
8
- import { kt as reportTelegramError, p as storeFiles } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError, p as storeFiles } from "../../../_chunks/principal-TJ6zB2rF.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-CYSFZe6f.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-DqDm9a2E.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-DIgU-kPR.mjs";
7
+ import { N as CONFIRMATION_TTL_MS } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { object } from "../confirmation-description.mjs";
9
9
  import { SessionNotActiveError } from "eve/sessions";
10
10
  function heldApprovals(events) {
@@ -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-DIgU-kPR.mjs";
7
+ export { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-TJ6zB2rF.mjs";
@@ -6,7 +6,7 @@ __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 { Ft as runtimeEnvelope, It as telegramRuntimeSource, f as attachmentsContext, kt as reportTelegramError, n as chatLanguage, o as telegramPrincipal, x as attachmentUrl } from "../../../_chunks/principal-DIgU-kPR.mjs";
9
+ import { At as reportTelegramError, It as runtimeEnvelope, Lt as telegramRuntimeSource, f as attachmentsContext, n as chatLanguage, o as telegramPrincipal, x as attachmentUrl } from "../../../_chunks/principal-TJ6zB2rF.mjs";
10
10
  import { routingBurst } from "../group-routing/burst.mjs";
11
11
  import { telegramSignals } from "./signals.mjs";
12
12
  import { addressingReason, chatKey, otherRecipient } from "../group-routing/signals.mjs";
@@ -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, Ft as runtimeEnvelope, It as telegramRuntimeSource, L as needsConfirmation, Pt as principalRuntimeSource, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-CYSFZe6f.mjs";
7
+ import { E as OntologyActionNotPermitted, Ft as principalRuntimeSource, It as runtimeEnvelope, L as needsConfirmation, Lt as telegramRuntimeSource, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
+ import { t as agentBuild } from "../../../_chunks/build-metadata-DqDm9a2E.mjs";
9
9
  import { object } from "../confirmation-description.mjs";
10
10
  var AttachmentLifecycleNotPermitted = class extends Error {
11
11
  code = "attachment_lifecycle_not_permitted";
@@ -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-DIgU-kPR.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-TJ6zB2rF.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 { kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { At as reportTelegramError } from "../../../_chunks/principal-TJ6zB2rF.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;
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { confirmationLocale } from "./confirmation-text.mjs";
8
- import { St as currentLocale, Tt as customerMessage, kt as reportTelegramError, xt as TelegramDeliveryError } from "../../../_chunks/principal-DIgU-kPR.mjs";
8
+ import { At as reportTelegramError, Ct as currentLocale, Et as customerMessage, St as TelegramDeliveryError } from "../../../_chunks/principal-TJ6zB2rF.mjs";
9
9
  import { splitTelegramText } from "./format.mjs";
10
10
  import { inTelegramSendQueue } from "./send-queue.mjs";
11
11
  const NO_REPLY_TOOL = "no_reply";
@@ -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 { Ft as runtimeEnvelope, It as telegramRuntimeSource } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { It as runtimeEnvelope, Lt as telegramRuntimeSource } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { workspaceAction } from "./workspace-action.mjs";
9
9
  import { STRUCTURED_KINDS } from "./structured-settings.mjs";
10
10
  const record = (value) => {
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
7
7
  import { telegramText } from "./texts.mjs";
8
8
  import { confirmationLocale } from "./confirmation-text.mjs";
9
9
  import { recordSessionFailure } from "./chat-archive.mjs";
10
- import { Ct as currentThreadId, Dt as failureText, St as currentLocale, i as memberIdOf, kt as reportTelegramError, wt as customerCopy } from "../../../_chunks/principal-DIgU-kPR.mjs";
10
+ import { At as reportTelegramError, Ct as currentLocale, Ot as failureText, Tt as customerCopy, i as memberIdOf, wt as currentThreadId } from "../../../_chunks/principal-TJ6zB2rF.mjs";
11
11
  import { modelServiceFailure } from "../model-service-failure.mjs";
12
12
  function telegramFailureEvents(input) {
13
13
  return {
@@ -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 { L as needsConfirmation, W as member, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { L as needsConfirmation, W as member, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  import { object } from "../confirmation-description.mjs";
9
9
  var WorkspaceActionAlreadyDispatched = class extends Error {};
10
10
  async function workspaceAction(input) {
@@ -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-DIgU-kPR.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-TJ6zB2rF.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-DIgU-kPR.mjs";
7
+ import { it as WEB_PROVIDER, lt as webAuth } from "../../../_chunks/principal-TJ6zB2rF.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 = [
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
7
7
  import { admitMessage, localizedText } from "../admission.mjs";
8
8
  import { agentToolsAttribute } from "../agent-tools.mjs";
9
9
  import { providerChat } from "../attachment-tools.mjs";
10
- import { b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, i as memberIdOf } from "../../../_chunks/principal-DIgU-kPR.mjs";
10
+ import { b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, i as memberIdOf } from "../../../_chunks/principal-TJ6zB2rF.mjs";
11
11
  import { gatewayImageDescriber } from "../inbound-media/images.mjs";
12
12
  import { gatewayMediaCapabilities, turnMediaPlan } from "../inbound-media/plan.mjs";
13
13
  import { gatewayTranscriber } from "../inbound-media/speech.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 { _ as AttachmentError } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { _ as AttachmentError } from "../../../_chunks/principal-TJ6zB2rF.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 { m as turnContent } from "../../../_chunks/principal-DIgU-kPR.mjs";
7
+ import { m as turnContent } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
8
  function record(value) {
9
9
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
10
10
  }
@@ -0,0 +1,35 @@
1
+ import type { SessionAuthContext } from "eve/context";
2
+ import { type AttachmentSendFailure, type AttachmentSendRefusal } from "../attachments-send.js";
3
+ import type { Environment } from "../environment.js";
4
+ import type { RuntimeToken } from "../runtime-token.js";
5
+ import type { SendAttachmentsInput } from "../telegram/attachments-send.js";
6
+ /** The most bytes of files one message carries, encoded, under the platform's request bound. */
7
+ export declare const MAXIMUM_SENT_FILE_BYTES: number;
8
+ /**
9
+ * `attachments_send` in a chat of a channel the workspace defines in its own code: the stored
10
+ * files go in one message, the caption as its text, through the channel's own `send`, which the
11
+ * agent reaches at the channel's send route as the deployment, as the ontology does. A channel
12
+ * whose code takes no files (`limits.files`) refuses them. The checks and failures are every
13
+ * channel's (`../attachments-send.ts`).
14
+ */
15
+ /** What became of one requested file. */
16
+ export interface ChannelSentFile extends Partial<AttachmentSendFailure> {
17
+ readonly id: string;
18
+ readonly filename: string;
19
+ /** The provider's id of the message that carries it, when it gave one. */
20
+ readonly messageId?: string;
21
+ }
22
+ type ChannelSendResult = {
23
+ readonly files: ReadonlyArray<ChannelSentFile>;
24
+ } | AttachmentSendRefusal;
25
+ export declare function sendChannelAttachments(options: {
26
+ readonly input: SendAttachmentsInput;
27
+ readonly principal: SessionAuthContext | null;
28
+ readonly sessionId: string;
29
+ /** The connection of the workspace channel the chat is on. */
30
+ readonly connection: string | undefined;
31
+ readonly environment?: Environment;
32
+ readonly token?: RuntimeToken;
33
+ readonly fetch?: typeof fetch;
34
+ }): Promise<ChannelSendResult>;
35
+ export {};
@@ -0,0 +1,119 @@
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
+ import { _ as AttachmentError, _t as chatChannel } from "../../../_chunks/principal-TJ6zB2rF.mjs";
8
+ import { sendStoredAttachments } from "../attachments-send.mjs";
9
+ import { redactDiagnostic } from "../diagnostics.mjs";
10
+ import { StoredFileError, fetchStoredFile } from "../sent-files.mjs";
11
+ import { randomUUID } from "node:crypto";
12
+ import { workspaceChannelSendRoute } from "@segmentstream/ontology/workspace-channel";
13
+ const MAXIMUM_SENT_FILE_BYTES = 3145728;
14
+ const TOO_LARGE = `One message carries at most ${MAXIMUM_SENT_FILE_BYTES / 1024 / 1024} MiB of files.`;
15
+ function reportChannelError(operation, error, secrets) {
16
+ const reference = randomUUID();
17
+ console.error("[segmentstream] workspace channel delivery diagnostic", {
18
+ operation,
19
+ reference,
20
+ error: redactDiagnostic(error, secrets)
21
+ });
22
+ return reference;
23
+ }
24
+ async function sendChannelAttachments(options) {
25
+ return sendStoredAttachments({
26
+ ...options,
27
+ provider: "custom",
28
+ channel: "custom",
29
+ report: (operation, error, _metadata, secrets) => reportChannelError(operation, error, secrets),
30
+ async send(context) {
31
+ const { input, chat, owner, origin, fetch, token, secrets, failed } = context;
32
+ const results = input.documentIds.map(({ id }) => ({
33
+ id,
34
+ filename: ""
35
+ }));
36
+ const read = [];
37
+ let total = 0;
38
+ for (const [index, reference] of input.documentIds.entries()) try {
39
+ const file = await fetchStoredFile({
40
+ reference,
41
+ owner,
42
+ origin,
43
+ token,
44
+ fetch,
45
+ secrets,
46
+ tooLarge: () => new AttachmentError({
47
+ code: "too_large",
48
+ message: TOO_LARGE
49
+ }),
50
+ limit: ({ size }) => {
51
+ if (total + size > 3145728) throw new AttachmentError({
52
+ code: "too_large",
53
+ message: TOO_LARGE
54
+ });
55
+ return MAXIMUM_SENT_FILE_BYTES - total;
56
+ }
57
+ });
58
+ total += file.bytes.byteLength;
59
+ read.push({
60
+ index,
61
+ file
62
+ });
63
+ results[index] = {
64
+ id: reference.id,
65
+ filename: file.filename
66
+ };
67
+ } catch (error) {
68
+ results[index] = {
69
+ id: reference.id,
70
+ filename: error instanceof StoredFileError ? error.filename : "",
71
+ ...failed(error, "stored_attachment_fetch_failed")
72
+ };
73
+ }
74
+ if (read.length === 0) return { files: results };
75
+ let messageId;
76
+ let failure;
77
+ try {
78
+ const bearer = await token();
79
+ const response = await fetch(new URL(workspaceChannelSendRoute(chatChannel(chat)), origin), {
80
+ method: "POST",
81
+ headers: {
82
+ authorization: `Bearer ${bearer}`,
83
+ "content-type": "application/json"
84
+ },
85
+ body: JSON.stringify({
86
+ operation_id: `${options.sessionId}:files:${randomUUID()}`,
87
+ chat_id: chat.chatId,
88
+ recipient: chat.peer ?? chat.chatId,
89
+ thread_id: null,
90
+ reply_to: null,
91
+ text: input.caption ?? "",
92
+ files: read.map(({ file }) => ({
93
+ filename: file.filename,
94
+ content_type: file.contentType,
95
+ data: Buffer.from(file.bytes).toString("base64")
96
+ }))
97
+ })
98
+ });
99
+ const answer = await response.json().catch(() => ({}));
100
+ if (!response.ok) throw new AttachmentError({
101
+ code: answer.error === "files_unsupported" ? "unsupported" : "send_failed",
102
+ message: `The channel did not take the files (${String(answer.error ?? response.status)}).`
103
+ });
104
+ messageId = typeof answer.message_id === "string" ? answer.message_id : void 0;
105
+ } catch (error) {
106
+ failure = failed(error, "channel_attachment_send_failed");
107
+ }
108
+ for (const { index } of read) results[index] = failure === void 0 ? {
109
+ ...results[index],
110
+ ...messageId === void 0 ? {} : { messageId }
111
+ } : {
112
+ ...results[index],
113
+ ...failure
114
+ };
115
+ return { files: results };
116
+ }
117
+ });
118
+ }
119
+ export { MAXIMUM_SENT_FILE_BYTES, sendChannelAttachments };