@segmentstream/agent 0.84.0 → 0.86.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 (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/_chunks/{build-metadata-CFe-5i6d.mjs → build-metadata-CKp7rmO0.mjs} +1 -1
  3. package/dist/_chunks/silent-C9x3GcMg.mjs +262 -0
  4. package/dist/extension/channels/email.mjs +3 -1
  5. package/dist/extension/channels/slack.mjs +3 -1
  6. package/dist/extension/channels/telegram.mjs +3 -1
  7. package/dist/extension/channels/whatsapp.mjs +3 -1
  8. package/dist/extension/lib/attachments-dispatch.d.ts +23 -0
  9. package/dist/extension/lib/attachments-dispatch.mjs +79 -0
  10. package/dist/extension/lib/build-metadata.mjs +1 -1
  11. package/dist/extension/lib/chat-recorder.mjs +1 -1
  12. package/dist/extension/lib/email/channel.d.ts +2 -0
  13. package/dist/extension/lib/email/channel.mjs +39 -5
  14. package/dist/extension/lib/evals.d.ts +3 -1
  15. package/dist/extension/lib/evals.mjs +3 -1
  16. package/dist/extension/lib/review/client.mjs +5 -0
  17. package/dist/extension/lib/review/files.d.ts +101 -0
  18. package/dist/extension/lib/review/files.mjs +7 -0
  19. package/dist/extension/lib/review/hold.d.ts +7 -0
  20. package/dist/extension/lib/review/hold.mjs +1 -0
  21. package/dist/extension/lib/review/judge.d.ts +2 -0
  22. package/dist/extension/lib/review/judge.mjs +1 -0
  23. package/dist/extension/lib/review/reply.d.ts +66 -0
  24. package/dist/extension/lib/review/reply.mjs +90 -8
  25. package/dist/extension/lib/telegram/adapter.mjs +9 -4
  26. package/dist/extension/lib/telegram/health.mjs +1 -1
  27. package/dist/extension/lib/telegram/lifecycle.mjs +1 -1
  28. package/dist/extension/lib/telegram/routing-context.mjs +1 -1
  29. package/dist/extension/lib/telegram/silent.mjs +1 -84
  30. package/dist/extension/lib/whatsapp/adapter.mjs +1 -1
  31. package/dist/extension/lib/workspace-channel/channel.mjs +23 -4
  32. package/dist/extension/tools/attachments_send.mjs +18 -38
  33. package/package.json +2 -2
@@ -20,9 +20,10 @@ import { gatewayMediaCapabilities, turnMediaPlan } from "../inbound-media/plan.m
20
20
  import { gatewayImageDescriber } from "../inbound-media/images.mjs";
21
21
  import { gatewayTranscriber } from "../inbound-media/speech.mjs";
22
22
  import { channelReview } from "../review/reply.mjs";
23
+ import { g as turnFiles, n as completionKind } from "../../../_chunks/silent-C9x3GcMg.mjs";
24
+ import { replyFilesSender } from "../attachments-dispatch.mjs";
23
25
  import { runtimeTokenVerifier } from "../runtime-identity.mjs";
24
26
  import { runtimeToken } from "../runtime-token.mjs";
25
- import { completionKind } from "../telegram/silent.mjs";
26
27
  import { runtimeRequestFailure } from "../telegram/runtime-request.mjs";
27
28
  import { channelConnection } from "./connection.mjs";
28
29
  import { ChannelCheckUnavailable, channelChecks } from "./secrets.mjs";
@@ -252,7 +253,8 @@ function workspaceChannelDefinition(options) {
252
253
  decide: options.review.decide,
253
254
  model: () => config.models.decision,
254
255
  ...options.review.archive === void 0 ? {} : { archive: options.review.archive },
255
- ...options.review.hold === void 0 ? {} : { hold: options.review.hold }
256
+ ...options.review.hold === void 0 ? {} : { hold: options.review.hold },
257
+ sendFiles: replyFilesSender(() => config.channels)
256
258
  }, {
257
259
  environment,
258
260
  ...transport
@@ -666,14 +668,24 @@ function workspaceChannelDefinition(options) {
666
668
  const chat = chatAddressOf(principal);
667
669
  if (outcome !== "completed" || chat?.provider !== "custom" || chat.channel !== name || chat.peer === void 0) return;
668
670
  const text = replyText(ctx.view, turnId);
669
- if (completionKind(text) !== "reply") return;
670
671
  const reviewing = review()?.review;
672
+ const files = reviewing === void 0 ? void 0 : turnFiles(ctx.view, turnId);
673
+ if (completionKind(text) !== "reply") {
674
+ if (files !== void 0 && files.files.length > 0 && reviewing.reviewed(principal)) await reviewing.holdFiles({
675
+ principal,
676
+ sessionId: ctx.session.id,
677
+ turnId,
678
+ files
679
+ });
680
+ return;
681
+ }
671
682
  if (!(reviewing === void 0 ? true : await reviewing.sendOrHold({
672
683
  principal,
673
684
  sessionId: ctx.session.id,
674
685
  turnId,
675
686
  partId: turnId,
676
- text
687
+ text,
688
+ ...files === void 0 || files.files.length === 0 ? {} : { files }
677
689
  }))) return;
678
690
  let parts;
679
691
  try {
@@ -704,6 +716,13 @@ function workspaceChannelDefinition(options) {
704
716
  senderIsBot: true,
705
717
  status: "completed"
706
718
  }));
719
+ if (files !== void 0 && files.files.length > 0) await reviewing.sendFiles({
720
+ principal,
721
+ sessionId: ctx.session.id,
722
+ turnId,
723
+ partId: turnId,
724
+ files
725
+ });
707
726
  } },
708
727
  fetchFile: (url, context) => fetchStoredAttachment(stored(), url, context)
709
728
  };
@@ -6,18 +6,15 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { n as workflowToolResult } from "../../_chunks/workflow-serializable-gzv5MZ5P.mjs";
8
8
  import segmentstream from "../extension.mjs";
9
- import { Ft as chatAddressOf, G as memberTool, It as chatChannel } from "../../_chunks/principal-C1g8wCIg.mjs";
10
- import { channelOf } from "../config.mjs";
11
- import { sendEmailAttachments } from "../lib/email/attachments-send.mjs";
12
- import { replyCopies } from "../lib/email/channel.mjs";
13
- import { sendSlackAttachments } from "../lib/slack/attachments-send.mjs";
14
- import { sendAttachments, sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
15
- import { sendWhatsAppAttachments } from "../lib/whatsapp/attachments-send.mjs";
16
- import { sendChannelAttachments } from "../lib/workspace-channel/attachments-send.mjs";
9
+ import { Ft as chatAddressOf, G as memberTool } from "../../_chunks/principal-C1g8wCIg.mjs";
10
+ import { sendStoredFiles } from "../lib/attachments-dispatch.mjs";
11
+ import { sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
12
+ import { d as attachToReply } from "../../_chunks/silent-C9x3GcMg.mjs";
13
+ import { repliesReviewed } from "../lib/review/hold.mjs";
17
14
  import { defineTool } from "eve/tools";
18
15
  const tool = defineTool({
19
16
  availableInSubagents: false,
20
- description: "Send 1 to 10 stored ontology files to this turn's Telegram, Slack, WhatsApp, email or workspace channel chat, as the paired member. Bare ids are document record ids; use entity/id/property references for other file records. In Telegram, images use sendPhoto, other files sendDocument, with compatible albums when possible; in Slack the files are shared together in the thread, with the caption; Telegram and Slack uploads are limited to 2 MiB by the connection proxy. In WhatsApp each file is its own message, the caption on the first. In email the files go in one reply in the person's thread, at most 20 MiB together, the caption as its text. In a workspace channel's chat they go in one message, at most 3 MiB together, when the channel takes files. Use the question as caption when sending documents with a question; one question per message. In groups follow the chat's purpose and never send restricted documents.",
17
+ description: "Send 1 to 10 stored ontology files to this turn's Telegram, Slack, WhatsApp, email or workspace channel chat, as the paired member. Bare ids are document record ids; use entity/id/property references for other file records. In Telegram, images use sendPhoto, other files sendDocument, with compatible albums when possible; in Slack the files are shared together in the thread, with the caption; Telegram and Slack uploads are limited to 2 MiB by the connection proxy. In WhatsApp each file is its own message, the caption on the first. In email the files go in one reply in the person's thread, at most 20 MiB together, the caption as its text. In a workspace channel's chat they go in one message, at most 3 MiB together, when the channel takes files. Use the question as caption when sending documents with a question; one question per message. In a chat whose replies a member reviews nothing is sent at once: the answer is { attached: true } and the files go with your reply, as the member approves it. In groups follow the chat's purpose and never send restricted documents.",
21
18
  inputSchema: {
22
19
  type: "object",
23
20
  properties: {
@@ -57,37 +54,20 @@ const tool = defineTool({
57
54
  label: { start: () => "Send stored attachments" },
58
55
  async execute(input, ctx) {
59
56
  const principal = ctx.session.auth.current;
60
- const provider = chatAddressOf(principal)?.provider;
61
- if (provider === "web") throw new Error("Stored attachments cannot be sent in a web chat; link to them instead.");
62
- const options = {
63
- input: sendAttachmentsInput(input),
57
+ if (chatAddressOf(principal)?.provider === "web") throw new Error("Stored attachments cannot be sent in a web chat; link to them instead.");
58
+ const parsed = sendAttachmentsInput(input);
59
+ if (repliesReviewed(segmentstream.config.review, principal)) return workflowToolResult(await attachToReply({
60
+ files: parsed.documentIds,
61
+ ...parsed.caption === void 0 ? {} : { caption: parsed.caption },
62
+ principal
63
+ }), ctx);
64
+ return workflowToolResult(await sendStoredFiles({
65
+ channels: segmentstream.config.channels,
66
+ files: parsed,
64
67
  principal,
65
- sessionId: ctx.session.id
66
- };
67
- const chat = chatAddressOf(principal);
68
- const channels = segmentstream.config.channels;
69
- const name = chat === void 0 ? "telegram" : chatChannel(chat);
70
- const telegram = channelOf(channels, "telegram", name);
71
- return workflowToolResult(provider === "slack" ? await sendSlackAttachments({
72
- ...options,
73
- connection: channelOf(channels, "slack", name)?.connection
74
- }) : provider === "email" ? await sendEmailAttachments({
75
- ...options,
76
- callId: ctx.callId,
77
- connection: channelOf(channels, "email", name)?.connection,
78
- cc: replyCopies(principal, channelOf(channels, "email", name))
79
- }) : provider === "whatsapp" ? await sendWhatsAppAttachments({
80
- ...options,
68
+ sessionId: ctx.session.id,
81
69
  turnId: ctx.session.turn.id,
82
- connection: channelOf(channels, "whatsapp", name)?.connection
83
- }) : provider === "custom" ? await sendChannelAttachments({
84
- ...options,
85
- connection: channelOf(channels, "custom", name)?.connection
86
- }) : await sendAttachments({
87
- ...options,
88
- connection: telegram?.connection,
89
- appLinks: telegram,
90
- identifiers: telegram?.identifiers ?? "block"
70
+ callId: ctx.callId
91
71
  }), ctx);
92
72
  }
93
73
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.84.0",
3
+ "version": "0.86.0",
4
4
  "description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",
@@ -88,7 +88,7 @@
88
88
  "@chat-adapter/state-memory": "4.42.0",
89
89
  "@chat-adapter/telegram": "4.41.0",
90
90
  "@chat-adapter/whatsapp": "4.42.0",
91
- "@segmentstream/ontology": "0.163.0",
91
+ "@segmentstream/ontology": "0.164.0",
92
92
  "@vercel/oidc": "^3.8.4",
93
93
  "ai": "^7.0.172",
94
94
  "chat": "4.42.0",