@segmentstream/agent 0.43.0 → 0.44.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 (55) hide show
  1. package/CHANGELOG.md +1033 -0
  2. package/README.md +1 -0
  3. package/dist/_chunks/{build-metadata-CkBdh-TE.mjs → build-metadata-BnufKOxq.mjs} +1 -1
  4. package/dist/_chunks/{inbound-request-DgQB4g1J.mjs → inbound-request-CK0QqEOP.mjs} +36 -1
  5. package/dist/_chunks/{principal-nQ_gwLJs.mjs → principal-BXvelsZk.mjs} +1 -1
  6. package/dist/extension/config.d.ts +13 -3
  7. package/dist/extension/config.mjs +8 -0
  8. package/dist/extension/hooks/authorization.mjs +1 -1
  9. package/dist/extension/instructions/persona.mjs +1 -1
  10. package/dist/extension/lib/actor.mjs +1 -1
  11. package/dist/extension/lib/attachment-tools.mjs +1 -1
  12. package/dist/extension/lib/build-metadata.mjs +1 -1
  13. package/dist/extension/lib/chat-address.mjs +1 -1
  14. package/dist/extension/lib/chat-context.mjs +1 -1
  15. package/dist/extension/lib/chat-recorder.mjs +1 -1
  16. package/dist/extension/lib/confirmations.mjs +1 -1
  17. package/dist/extension/lib/ontology-connection.mjs +1 -1
  18. package/dist/extension/lib/ontology-file-call.mjs +1 -1
  19. package/dist/extension/lib/ontology-tools.mjs +1 -1
  20. package/dist/extension/lib/review/hold.mjs +1 -1
  21. package/dist/extension/lib/review/reply.mjs +1 -1
  22. package/dist/extension/lib/role-skill.mjs +1 -1
  23. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  24. package/dist/extension/lib/slack/attachments-send.mjs +1 -1
  25. package/dist/extension/lib/stored-files.mjs +1 -1
  26. package/dist/extension/lib/telegram/adapter.mjs +27 -7
  27. package/dist/extension/lib/telegram/app-links.d.ts +39 -0
  28. package/dist/extension/lib/telegram/app-links.mjs +53 -0
  29. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  30. package/dist/extension/lib/telegram/attachments-send.mjs +2 -2
  31. package/dist/extension/lib/telegram/callbacks.mjs +2 -2
  32. package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
  33. package/dist/extension/lib/telegram/confirmations.mjs +2 -2
  34. package/dist/extension/lib/telegram/customer-text.d.ts +2 -1
  35. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  36. package/dist/extension/lib/telegram/files.mjs +2 -2
  37. package/dist/extension/lib/telegram/health.mjs +1 -1
  38. package/dist/extension/lib/telegram/images.mjs +1 -1
  39. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  40. package/dist/extension/lib/telegram/inbound.mjs +2 -2
  41. package/dist/extension/lib/telegram/lifecycle.mjs +3 -3
  42. package/dist/extension/lib/telegram/media-policy.mjs +1 -1
  43. package/dist/extension/lib/telegram/principal.mjs +1 -1
  44. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  45. package/dist/extension/lib/telegram/silent.mjs +1 -1
  46. package/dist/extension/lib/telegram/structured.mjs +1 -1
  47. package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
  48. package/dist/extension/lib/telegram/voice.mjs +1 -1
  49. package/dist/extension/lib/whatsapp/adapter.mjs +2 -0
  50. package/dist/extension/lib/whatsapp/links.d.ts +12 -0
  51. package/dist/extension/lib/whatsapp/links.mjs +34 -0
  52. package/dist/extension/model.mjs +1 -1
  53. package/dist/extension/tools/attachments_promote.mjs +1 -1
  54. package/dist/extension/tools/questions_ask.mjs +1 -1
  55. package/package.json +3 -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 { t as agentBuild } from "../../../_chunks/build-metadata-CkBdh-TE.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BnufKOxq.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 { p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
7
+ import { p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
8
8
  import { gateway, generateText } from "ai";
9
9
  const MAXIMUM_IMAGE_DESCRIPTION_BYTES = 5242880;
10
10
  const MAXIMUM_NATIVE_IMAGE_BYTES = 3145728;
@@ -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 InboundRequest, n as currentInboundRequest, r as runInboundRequest, i as withReplacedText } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
7
+ export { t as InboundRequest, n as currentInboundRequest, r as runInboundRequest, i as withReplacedText } from "../../../_chunks/inbound-request-CK0QqEOP.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 { d as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-nQ_gwLJs.mjs";
9
+ import { d as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-BXvelsZk.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";
@@ -30,7 +30,7 @@ import { MAXIMUM_ROUTING_ATTACHMENT_BYTES, describeRoutingAttachment, routingAtt
30
30
  import { recordGateDecision, recordInboundContent, recordRouteDecision } from "./chat-archive.mjs";
31
31
  import { contentShape, messageContent } from "./content.mjs";
32
32
  import { messageAudience } from "./audience.mjs";
33
- import { p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
33
+ import { p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
34
34
  const MAXIMUM_QUOTE_LENGTH = 500;
35
35
  function buttonTo(text, url) {
36
36
  return { inline_keyboard: [[{
@@ -4,9 +4,9 @@ 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 { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-nQ_gwLJs.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-CkBdh-TE.mjs";
9
- import { n as currentInboundRequest } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
7
+ import { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-BXvelsZk.mjs";
8
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BnufKOxq.mjs";
9
+ import { n as currentInboundRequest } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
10
10
  import { object } from "../confirmation-description.mjs";
11
11
  import { needsConfirmation } from "../confirmations.mjs";
12
12
  import { OntologyActionNotPermitted, actionToolName, ontologyTools } from "../ontology-tools.mjs";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { DEFAULT_IMAGE_DESCRIPTION_MODEL } from "../../config.mjs";
8
- import { p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
8
+ import { p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
9
9
  function planMedia(capabilities, descriptionModel = null) {
10
10
  if (typeof descriptionModel === "string") return {
11
11
  images: "describe",
@@ -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-nQ_gwLJs.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-BXvelsZk.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 { p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
7
+ import { p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.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 { a as TelegramDeliveryError, l as customerMessage, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
8
+ import { a as TelegramDeliveryError, l as customerMessage, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.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 { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-nQ_gwLJs.mjs";
7
+ import { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-BXvelsZk.mjs";
8
8
  import { workspaceAction } from "./workspace-action.mjs";
9
9
  import { STRUCTURED_KINDS } from "./structured-settings.mjs";
10
10
  const record = (value) => {
@@ -7,8 +7,8 @@ __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 { c as customerCopy, d as failureText, o as currentLocale, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
11
- import { i as memberIdOf } from "../../../_chunks/principal-nQ_gwLJs.mjs";
10
+ import { c as customerCopy, d as failureText, o as currentLocale, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
11
+ import { i as memberIdOf } from "../../../_chunks/principal-BXvelsZk.mjs";
12
12
  import { modelServiceFailure } from "../model-service-failure.mjs";
13
13
  function telegramFailureEvents(input) {
14
14
  return {
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import "../connection-proxy.mjs";
8
- import { p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
8
+ import { p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
9
9
  import { gateway, transcribe } from "ai";
10
10
  const LABELS = {
11
11
  voice: "voice message",
@@ -13,6 +13,7 @@ import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs
13
13
  import { appOrigin, channelsEnabled, proxyEnvironment, webhookSecret } from "../environment.mjs";
14
14
  import { agentIdentities } from "../identities.mjs";
15
15
  import { runtimeToken } from "../runtime-token.mjs";
16
+ import { withPlainLinks } from "./links.mjs";
16
17
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
17
18
  import { createMemoryState } from "@chat-adapter/state-memory";
18
19
  import { WhatsAppAdapter, WhatsAppApiError } from "@chat-adapter/whatsapp";
@@ -41,6 +42,7 @@ var ProxiedWhatsAppAdapter = class extends WhatsAppAdapter {
41
42
  logger: new ConsoleLogger("warn", "whatsapp")
42
43
  });
43
44
  this.#runtime = runtime;
45
+ this.formatConverter = withPlainLinks(this.formatConverter);
44
46
  }
45
47
  async handleWebhook(request, options) {
46
48
  if (!this.#runtime.enabled()) return new Response(null, { status: 404 });
@@ -0,0 +1,12 @@
1
+ import { type Root } from "chat";
2
+ /** What this module needs of the Chat SDK adapter's Markdown converter. */
3
+ export interface AstRenderer {
4
+ fromAst(ast: Root): string;
5
+ }
6
+ /**
7
+ * The converter with every link written as WhatsApp shows it. WhatsApp has no Markdown link, so a
8
+ * link written `[label](url)` reached the person as written, and a bare URL in angle brackets.
9
+ * Each link becomes `label: url`, or the URL alone when its label is the URL, which WhatsApp makes
10
+ * tappable. The links go in after the Markdown is written, so no character of a URL is escaped.
11
+ */
12
+ export declare function withPlainLinks<T extends AstRenderer>(converter: T): T;
@@ -0,0 +1,34 @@
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 { isLinkNode, walkAst } from "chat";
8
+ const TOKEN = /(\d+)/gu;
9
+ function withPlainLinks(converter) {
10
+ const plain = Object.create(converter);
11
+ plain.fromAst = function fromAst(ast) {
12
+ const links = [];
13
+ const tokenized = walkAst(structuredClone(ast), (node) => {
14
+ if (!isLinkNode(node)) return node;
15
+ links.push(plainLink(textOf(node), node.url));
16
+ return {
17
+ type: "text",
18
+ value: `${links.length - 1}`
19
+ };
20
+ });
21
+ return converter.fromAst.call(this, tokenized).replace(TOKEN, (token, index) => links[Number(index)] ?? token);
22
+ };
23
+ return plain;
24
+ }
25
+ function plainLink(label, url) {
26
+ const text = label.trim();
27
+ const bare = url.replace(/^[a-z][a-z0-9+.-]*:(?:\/\/)?/iu, "");
28
+ return text === "" || text === url ? url : text === bare ? text : `${text}: ${url}`;
29
+ }
30
+ function textOf(node) {
31
+ if ("value" in node && typeof node.value === "string") return node.value;
32
+ return "children" in node && Array.isArray(node.children) ? node.children.map(textOf).join("") : "";
33
+ }
34
+ export { withPlainLinks };
@@ -6,7 +6,7 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { chatModelChoiceOf } from "./config.mjs";
8
8
  import { isPreview } from "./lib/environment.mjs";
9
- import { a as rolesOf } from "../_chunks/principal-nQ_gwLJs.mjs";
9
+ import { a as rolesOf } from "../_chunks/principal-BXvelsZk.mjs";
10
10
  import { defineDynamic } from "eve";
11
11
  import { runs } from "eve/events";
12
12
  function chooseModel(input) {
@@ -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 { u as runtimeEnvelope } from "../../_chunks/principal-nQ_gwLJs.mjs";
7
+ import { u as runtimeEnvelope } from "../../_chunks/principal-BXvelsZk.mjs";
8
8
  import segmentstream from "../extension.mjs";
9
9
  import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DU7WeCIW.mjs";
10
10
  import { actionApproval } from "../lib/confirmations.mjs";
@@ -9,7 +9,7 @@ import { agentTaskIdOf, agentTaskSessions } from "../lib/agent-task.mjs";
9
9
  import { stringArgument } from "../lib/attachment-tools.mjs";
10
10
  import { chatAddressOf } from "../lib/chat-address.mjs";
11
11
  import { pendingQuestions, questionKey } from "../lib/questions.mjs";
12
- import { i as memberIdOf } from "../../_chunks/principal-nQ_gwLJs.mjs";
12
+ import { i as memberIdOf } from "../../_chunks/principal-BXvelsZk.mjs";
13
13
  import { defineTool } from "eve/tools";
14
14
  var questions_ask_default = defineTool({
15
15
  availableInSubagents: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.43.0",
3
+ "version": "0.44.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",
@@ -57,6 +57,7 @@
57
57
  "files": [
58
58
  "dist",
59
59
  "README.md",
60
+ "CHANGELOG.md",
60
61
  "LICENSE",
61
62
  "NOTICE"
62
63
  ],
@@ -76,7 +77,7 @@
76
77
  "@chat-adapter/state-memory": "4.42.0",
77
78
  "@chat-adapter/telegram": "4.41.0",
78
79
  "@chat-adapter/whatsapp": "4.42.0",
79
- "@segmentstream/ontology": "0.99.0",
80
+ "@segmentstream/ontology": "0.99.1",
80
81
  "@vercel/oidc": "^3.8.4",
81
82
  "ai": "^7.0.137",
82
83
  "chat": "4.42.0",