@segmentstream/agent 0.10.0 → 0.10.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.
@@ -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.10.0";
7
+ var version = "0.10.1";
8
8
  function agentBuild(environment = process.env) {
9
9
  return {
10
10
  agent: version,
@@ -4,5 +4,5 @@ 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-CYEMFYjL.mjs";
7
+ import { t as agentBuild } from "../../_chunks/build-metadata-BD1PqnN9.mjs";
8
8
  export { agentBuild };
@@ -54,13 +54,18 @@ function archivedRoutingMessages(events, limit = 30) {
54
54
  const metadata = archivedMetadata(event);
55
55
  const prompt = metadata.confirmation;
56
56
  const decision = prompt?.mode === "deferred" ? deferredStates.get(prompt.requestId) : void 0;
57
- const parent = messages.find((candidate) => candidate.messageId !== null && candidate.messageId === event.replyToMessageId);
58
- const replyTo = metadata.replyTo ?? (event.replyToMessageId === null ? void 0 : {
57
+ const replyMessageId = metadata.replyTo?.messageId ?? event.replyToMessageId;
58
+ const parent = messages.find((candidate) => candidate.messageId !== null && candidate.messageId === replyMessageId);
59
+ const recordedReply = metadata.replyTo ?? (event.replyToMessageId === null ? void 0 : {
59
60
  messageId: event.replyToMessageId,
60
61
  kind: parent === void 0 ? "unknown" : parent.kind === "outbound" ? "bot" : parent.senderIsBot ? "other_bot" : "human",
61
62
  ...parent?.senderId == null ? {} : { id: parent.senderId },
62
63
  ...parent?.senderName == null ? {} : { name: parent.senderName }
63
64
  });
65
+ const replyTo = recordedReply !== void 0 && parent?.kind === "outbound" && recordedReply.messageId === parent.messageId ? {
66
+ ...recordedReply,
67
+ kind: "bot"
68
+ } : recordedReply;
64
69
  const derivedText = metadata.decoded?.flatMap((item) => item.content === void 0 ? [] : [item.content]).join("\n");
65
70
  const text = (event.text || derivedText || (metadata.media ? "" : "[attachment or service message]")).slice(0, 2e3);
66
71
  const common = {
@@ -14,7 +14,7 @@ import { runtimeToken } from "../runtime-token.mjs";
14
14
  import { groupSettings } from "../group-routing/settings.mjs";
15
15
  import { conversations } from "../conversations.mjs";
16
16
  import { archivedRoutingMessages } from "../group-routing/routing-context.mjs";
17
- import { t as agentBuild } from "../../../_chunks/build-metadata-CYEMFYjL.mjs";
17
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BD1PqnN9.mjs";
18
18
  import { confirmationLocale } from "./confirmation-text.mjs";
19
19
  import { telegramSendScope } from "./send-queue.mjs";
20
20
  import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-BrWspFw5.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 { t as agentBuild } from "../../../_chunks/build-metadata-CYEMFYjL.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BD1PqnN9.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";
@@ -463,7 +463,7 @@ async function handleInboundMessage(input) {
463
463
  ].filter((n) => !!n)];
464
464
  const freshConversation = async () => dependencies.recentConversation ? dependencies.recentConversation(sent.chat.id, sent.messageThreadId === void 0 ? void 0 : String(sent.messageThreadId)) : dependencies.observed.recent(chat);
465
465
  let conversationRecent = conversationPolicy ? await freshConversation() : dependencies.observed.recent(chat);
466
- if (conversationPolicy && input.request) {
466
+ if (conversationPolicy && input.request && input.request.lifecycleKey === void 0) {
467
467
  address = topicAddress;
468
468
  input.request.address = topicAddress;
469
469
  input.request.turnPolicy = "steer";
@@ -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-CYEMFYjL.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BD1PqnN9.mjs";
8
8
  import { object } from "../confirmation-description.mjs";
9
9
  import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-BrWspFw5.mjs";
10
10
  import { needsConfirmation } from "../confirmations.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
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",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@chat-adapter/telegram": "4.41.0",
65
- "@segmentstream-cloud/ontology": "0.44.0",
65
+ "@segmentstream-cloud/ontology": "0.44.1",
66
66
  "@vercel/oidc": "^3.8.4",
67
67
  "ai": "^7.0.128",
68
68
  "csv-parse": "^7.0.3",