@segmentstream/agent 0.31.6 → 0.31.7

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.
@@ -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.31.6";
7
+ var version = "0.31.7";
8
8
  function agentBuild(environment = process.env) {
9
9
  return {
10
10
  agent: version,
@@ -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 agentBuild } from "../../_chunks/build-metadata-yjnSDWKY.mjs";
7
+ export { t as agentBuild } from "../../_chunks/build-metadata-D7dNTYhe.mjs";
@@ -10,7 +10,7 @@ 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-yjnSDWKY.mjs";
13
+ import { t as agentBuild } from "../../../_chunks/build-metadata-D7dNTYhe.mjs";
14
14
  import { attachmentLifecycle } from "./lifecycle.mjs";
15
15
  import { manifestOf } from "../../config.mjs";
16
16
  import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
@@ -178,7 +178,7 @@ async function captureTelegramWebhook(input) {
178
178
  const inbound = currentInboundRequest();
179
179
  if (inbound !== void 0) captures.set(inbound, capture);
180
180
  const automated = message.from === void 0 || message.from.isBot || message.chat.type === "channel";
181
- if (automated || edited !== void 0 || message.raw.left_chat_member || message.raw.migrate_to_chat_id || message.raw.migrate_from_chat_id) await capture.persist();
181
+ if (automated || edited !== void 0 || message.raw.left_chat_member || message.raw.new_chat_members || message.raw.migrate_to_chat_id || message.raw.migrate_from_chat_id) await capture.persist();
182
182
  const messageHistory = automated ? [] : (await input.archive.context({
183
183
  provider: "telegram",
184
184
  chatId: message.chat.id,
@@ -416,7 +416,7 @@ async function captureTelegramWebhook(input) {
416
416
  }),
417
417
  text: capture.note ?? (edited !== void 0 ? "Message edit recorded as context; no agent turn started." : null),
418
418
  decision: capture.decision ?? "silent",
419
- reason: capture.reason ?? (message.raw.left_chat_member ? "member_departure" : message.raw.migrate_to_chat_id || message.raw.migrate_from_chat_id ? "chat_migration" : "unpaired_refused_or_empty_message"),
419
+ reason: capture.reason ?? (message.raw.left_chat_member ? "member_departure" : message.raw.new_chat_members ? "member_arrival" : message.raw.migrate_to_chat_id || message.raw.migrate_from_chat_id ? "chat_migration" : "unpaired_refused_or_empty_message"),
420
420
  attachments: []
421
421
  });
422
422
  await finishRevision(capture.reason === "inbound_message_failed" || capture.reason === "decision_model_failed" || capture.reason === "decision_model_timeout" ? "failed" : "completed");
@@ -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-yjnSDWKY.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-D7dNTYhe.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";
@@ -180,6 +180,23 @@ async function reportDeparture(input) {
180
180
  memberId: lookup.member.id
181
181
  });
182
182
  }
183
+ async function reportArrivals(input) {
184
+ const { message, joined, dependencies } = input;
185
+ for (const person of joined) {
186
+ if (!isRecord(person) || person.is_bot === true) continue;
187
+ const id = person.id;
188
+ if (typeof id !== "number" && typeof id !== "string") continue;
189
+ const lookup = await dependencies.identities.lookup({
190
+ provider: "telegram",
191
+ externalId: String(id)
192
+ });
193
+ if (lookup.status === "paired") await dependencies.chats.seen({
194
+ chatId: message.chat.id,
195
+ title: message.chat.title ?? "",
196
+ memberId: lookup.member.id
197
+ });
198
+ }
199
+ }
183
200
  function rawChatId(value) {
184
201
  return typeof value === "number" || typeof value === "string" && value !== "" ? String(value) : void 0;
185
202
  }
@@ -204,6 +221,7 @@ async function handleInboundMessage(input) {
204
221
  } : input.message;
205
222
  if (content.source === "rich_message" && input.request !== void 0) input.request.text = content.text;
206
223
  const left = message.raw.left_chat_member;
224
+ const joined = message.raw.new_chat_members;
207
225
  const migration = isGroupChat(message) ? migrationOf(message) : void 0;
208
226
  if (isGroupChat(message) && isRecord(left)) {
209
227
  recordGateDecision("member_departure");
@@ -215,6 +233,15 @@ async function handleInboundMessage(input) {
215
233
  });
216
234
  return null;
217
235
  }
236
+ if (isGroupChat(message) && Array.isArray(joined) && joined.length > 0) {
237
+ recordGateDecision("member_arrival");
238
+ await reportArrivals({
239
+ message,
240
+ joined,
241
+ dependencies
242
+ });
243
+ return null;
244
+ }
218
245
  if (migration !== void 0) {
219
246
  recordGateDecision("chat_migration");
220
247
  await dependencies.chats.migrated({
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-CPOCTHBa.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-yjnSDWKY.mjs";
8
+ import { t as agentBuild } from "../../../_chunks/build-metadata-D7dNTYhe.mjs";
9
9
  import { n as currentInboundRequest } from "../../../_chunks/inbound-request-Dy7q3T23.mjs";
10
10
  import { object } from "../confirmation-description.mjs";
11
11
  import { needsConfirmation } from "../confirmations.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.31.6",
3
+ "version": "0.31.7",
4
4
  "description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram through the workspace's connection.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@chat-adapter/telegram": "4.41.0",
77
- "@segmentstream-cloud/ontology": "0.84.2",
77
+ "@segmentstream-cloud/ontology": "0.85.0",
78
78
  "@vercel/oidc": "^3.8.4",
79
79
  "ai": "^7.0.137",
80
80
  "csv-parse": "^7.0.3",