@segmentstream/agent 0.41.0 → 0.42.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.
@@ -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.41.0";
7
+ var version = "0.42.0";
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-9jG_pSFP.mjs";
7
+ export { t as agentBuild } from "../../_chunks/build-metadata-CUyA2hlu.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-9jG_pSFP.mjs";
13
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CUyA2hlu.mjs";
14
14
  import { attachmentLifecycle } from "./lifecycle.mjs";
15
15
  import { manifestOf } from "../../config.mjs";
16
16
  import { gatewayAttachmentDescriber } from "./attachment-description.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-9jG_pSFP.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CUyA2hlu.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";
@@ -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-BIX7T6Hh.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-9jG_pSFP.mjs";
8
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CUyA2hlu.mjs";
9
9
  import { n as currentInboundRequest } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
10
10
  import { object } from "../confirmation-description.mjs";
11
11
  import { needsConfirmation } from "../confirmations.mjs";
@@ -1,5 +1,5 @@
1
1
  import { WhatsAppAdapter } from "@chat-adapter/whatsapp";
2
- import { type Message, type WebhookOptions } from "chat";
2
+ import { type Message, type PostableCard, type WebhookOptions } from "chat";
3
3
  import type { SessionAuthContext } from "eve/context";
4
4
  import type { AdmissionSettings, WhatsAppSettings } from "../../config.js";
5
5
  import { type ChannelReviewOptions } from "../review/reply.js";
@@ -16,7 +16,8 @@ import { type RuntimeToken } from "../runtime-token.js";
16
16
  * as `/phone`: no Meta token or number ID enters this process.
17
17
  *
18
18
  * Only paired members are answered. A sender nobody paired gets the workspace's
19
- * `replies.pairingRequired` text and a link to the app's `/agent/connect`.
19
+ * `replies.pairingRequired` text with a button labelled `replies.pairingButton` that opens the
20
+ * app's `/agent/connect`, or the text followed by the link where the workspace sets no label.
20
21
  */
21
22
  /** The authenticator of a WhatsApp session's principal. */
22
23
  export declare const WHATSAPP_AUTHENTICATOR = "segmentstream-whatsapp";
@@ -76,11 +77,17 @@ export declare function receive(input: {
76
77
  /** The Chat SDK thread: its id names the conversation, one person's chat with the number. */
77
78
  readonly thread: {
78
79
  readonly id: string;
79
- readonly post: (text: string) => Promise<unknown>;
80
+ readonly post: (message: string | PostableCard) => Promise<unknown>;
80
81
  };
81
82
  readonly message: Pick<Message, "author" | "text" | "attachments">;
82
83
  readonly admission: AdmissionSettings;
83
84
  readonly identities: AgentIdentities;
84
85
  readonly environment: Environment;
85
86
  }): Promise<SessionAuthContext | undefined>;
87
+ /**
88
+ * The pairing reply: the workspace's text with a button opening the link, which WhatsApp shows as
89
+ * a call-to-action URL button, or the text followed by the link where the workspace labels no
90
+ * button. Every word is the workspace's; WhatsApp shows at most 20 characters of the label.
91
+ */
92
+ export declare function pairingMessage(text: string, label: string | undefined, url: string): string | PostableCard;
86
93
  export {};
@@ -16,7 +16,7 @@ import { runtimeToken } from "../runtime-token.mjs";
16
16
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
17
17
  import { createMemoryState } from "@chat-adapter/state-memory";
18
18
  import { WhatsAppAdapter, WhatsAppApiError } from "@chat-adapter/whatsapp";
19
- import { ConsoleLogger } from "chat";
19
+ import { Actions, Card, CardText, ConsoleLogger, LinkButton } from "chat";
20
20
  import { chatSdkChannel, messageContentOf } from "eve/channels/chat-sdk";
21
21
  const WHATSAPP_AUTHENTICATOR = "segmentstream-whatsapp";
22
22
  const WHATSAPP_PROXY_ORIGIN = "https://whatsapp.segmentstream.invalid";
@@ -224,7 +224,7 @@ async function receive(input) {
224
224
  externalId: sender,
225
225
  ...display === void 0 ? {} : { display }
226
226
  })).code;
227
- await thread.post(`${text}\n\n${appOrigin(input.environment)}/agent/connect?code=${encodeURIComponent(code)}`);
227
+ await thread.post(pairingMessage(text, localizedText(admission.replies.pairingButton), `${appOrigin(input.environment)}/agent/connect?code=${encodeURIComponent(code)}`));
228
228
  }
229
229
  return;
230
230
  }
@@ -253,4 +253,14 @@ async function receive(input) {
253
253
  }
254
254
  }
255
255
  }
256
- export { ProxiedWhatsAppAdapter, WHATSAPP_AUTHENTICATOR, WHATSAPP_PROXY_ORIGIN, WhatsAppProxyRouteError, proxyPath, receive, segmentstreamWhatsApp, whatsappPrincipal };
256
+ function pairingMessage(text, label, url) {
257
+ const fallback = `${text}\n\n${url}`;
258
+ return label === void 0 || label.trim() === "" ? fallback : {
259
+ card: Card({ children: [CardText(text), Actions([LinkButton({
260
+ url,
261
+ label
262
+ })])] }),
263
+ fallbackText: fallback
264
+ };
265
+ }
266
+ export { ProxiedWhatsAppAdapter, WHATSAPP_AUTHENTICATOR, WHATSAPP_PROXY_ORIGIN, WhatsAppProxyRouteError, pairingMessage, proxyPath, receive, segmentstreamWhatsApp, whatsappPrincipal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram, WhatsApp and Slack through the workspace's connections.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",