@segmentstream/agent 0.36.2 → 0.37.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 (50) hide show
  1. package/README.md +23 -4
  2. package/dist/_chunks/{build-metadata-Cmrq0o5K.mjs → build-metadata-CnjDv9p8.mjs} +1 -1
  3. package/dist/_chunks/{principal-UlkbLrgQ.mjs → principal-BIX7T6Hh.mjs} +1 -1
  4. package/dist/extension/hooks/authorization.mjs +1 -1
  5. package/dist/extension/instructions.md +3 -3
  6. package/dist/extension/lib/actor.mjs +1 -1
  7. package/dist/extension/lib/attachment-tools.mjs +1 -1
  8. package/dist/extension/lib/build-metadata.mjs +1 -1
  9. package/dist/extension/lib/chat-post-confirmation.d.ts +3 -1
  10. package/dist/extension/lib/chat-post-confirmation.mjs +8 -5
  11. package/dist/extension/lib/{telegram/chats.d.ts → chats.d.ts} +14 -4
  12. package/dist/extension/lib/{telegram/chats.mjs → chats.mjs} +33 -17
  13. package/dist/extension/lib/confirmation-buttons.d.ts +22 -0
  14. package/dist/extension/lib/confirmation-buttons.mjs +44 -0
  15. package/dist/extension/lib/confirmations.d.ts +5 -4
  16. package/dist/extension/lib/confirmations.mjs +27 -11
  17. package/dist/extension/lib/conversation-runtime.mjs +1 -1
  18. package/dist/extension/lib/conversation.d.ts +33 -0
  19. package/dist/extension/lib/conversation.mjs +55 -0
  20. package/dist/extension/lib/ontology-connection.mjs +11 -4
  21. package/dist/extension/lib/ontology-file-call.mjs +1 -1
  22. package/dist/extension/lib/ontology-tools.mjs +1 -1
  23. package/dist/extension/lib/runtime-envelope.d.ts +5 -1
  24. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  25. package/dist/extension/lib/slack/adapter.d.ts +34 -1
  26. package/dist/extension/lib/slack/adapter.mjs +138 -16
  27. package/dist/extension/lib/stored-files.mjs +1 -1
  28. package/dist/extension/lib/telegram/adapter.mjs +7 -4
  29. package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
  30. package/dist/extension/lib/telegram/callbacks.mjs +1 -1
  31. package/dist/extension/lib/telegram/chat-post-card.d.ts +11 -0
  32. package/dist/extension/lib/telegram/chat-post-card.mjs +27 -12
  33. package/dist/extension/lib/telegram/confirmations.mjs +1 -1
  34. package/dist/extension/lib/telegram/conversations.d.ts +1 -1
  35. package/dist/extension/lib/telegram/files.mjs +1 -1
  36. package/dist/extension/lib/telegram/health.d.ts +1 -1
  37. package/dist/extension/lib/telegram/health.mjs +1 -1
  38. package/dist/extension/lib/telegram/inbound.d.ts +1 -1
  39. package/dist/extension/lib/telegram/inbound.mjs +2 -2
  40. package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
  41. package/dist/extension/lib/telegram/membership.d.ts +1 -1
  42. package/dist/extension/lib/telegram/principal.mjs +1 -1
  43. package/dist/extension/lib/telegram/structured.mjs +1 -1
  44. package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
  45. package/dist/extension/lib/whatsapp/adapter.d.ts +2 -0
  46. package/dist/extension/lib/whatsapp/adapter.mjs +14 -2
  47. package/dist/extension/model.mjs +1 -1
  48. package/dist/extension/tools/attachments_promote.mjs +1 -1
  49. package/dist/extension/tools/questions_ask.mjs +1 -1
  50. package/package.json +2 -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 { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-UlkbLrgQ.mjs";
7
+ import { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-BIX7T6Hh.mjs";
8
8
  import { workspaceAction } from "./workspace-action.mjs";
9
9
  import { STRUCTURED_KINDS } from "./structured-settings.mjs";
10
10
  const record = (value) => {
@@ -8,7 +8,7 @@ import { telegramText } from "./texts.mjs";
8
8
  import { confirmationLocale } from "./confirmation-text.mjs";
9
9
  import { recordSessionFailure } from "./conversations.mjs";
10
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-UlkbLrgQ.mjs";
11
+ import { i as memberIdOf } from "../../../_chunks/principal-BIX7T6Hh.mjs";
12
12
  import { modelServiceFailure } from "../model-service-failure.mjs";
13
13
  function telegramFailureEvents(input) {
14
14
  return {
@@ -70,7 +70,9 @@ export declare function segmentstreamWhatsApp(options: WhatsAppChannelOptions):
70
70
  * after answering anyone else with the workspace's reply, if it has one.
71
71
  */
72
72
  export declare function receive(input: {
73
+ /** The Chat SDK thread: its id names the conversation, one person's chat with the number. */
73
74
  readonly thread: {
75
+ readonly id: string;
74
76
  readonly post: (text: string) => Promise<unknown>;
75
77
  };
76
78
  readonly message: Pick<Message, "author" | "text" | "attachments">;
@@ -5,6 +5,8 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { admitMessage, localizedText } from "../admission.mjs";
8
+ import { chatSdkButtonAnswer, withButtonDecision } from "../confirmation-buttons.mjs";
9
+ import { withConversation } from "../conversation.mjs";
8
10
  import { redactDiagnostic } from "../diagnostics.mjs";
9
11
  import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
10
12
  import { appOrigin, channelsEnabled, proxyEnvironment, webhookSecret } from "../environment.mjs";
@@ -160,7 +162,11 @@ function segmentstreamWhatsApp(options) {
160
162
  adapters: { whatsapp: new ProxiedWhatsAppAdapter(runtime) },
161
163
  state: createMemoryState(),
162
164
  streaming: false,
163
- resolveInputAuth: (event) => event.user?.userId === void 0 ? null : pairedPrincipal(event.user.userId)
165
+ resolveInputAuth: async (event) => {
166
+ const principal = event.user?.userId === void 0 ? null : await pairedPrincipal(event.user.userId);
167
+ const answer = chatSdkButtonAnswer(event.actionId, event.value);
168
+ return principal === null || answer === void 0 ? principal : withButtonDecision(principal, [answer]);
169
+ }
164
170
  });
165
171
  bridge.bot.onDirectMessage((thread, message) => receive({
166
172
  thread,
@@ -196,7 +202,13 @@ async function receive(input) {
196
202
  });
197
203
  switch (resolution.status) {
198
204
  case "existing":
199
- case "created": return turn ? whatsappPrincipal(resolution.member, sender) : void 0;
205
+ case "created": return turn ? withConversation(whatsappPrincipal(resolution.member, sender), {
206
+ provider: "whatsapp",
207
+ chatId: thread.id,
208
+ threadId: "",
209
+ kind: "private",
210
+ peer: sender
211
+ }) : void 0;
200
212
  case "pairing_required": {
201
213
  const text = localizedText(admission.replies.pairingRequired);
202
214
  if (text !== void 0) {
@@ -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-UlkbLrgQ.mjs";
9
+ import { a as rolesOf } from "../_chunks/principal-BIX7T6Hh.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-UlkbLrgQ.mjs";
7
+ import { u as runtimeEnvelope } from "../../_chunks/principal-BIX7T6Hh.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";
@@ -8,7 +8,7 @@ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DU7
8
8
  import { agentTaskIdOf, agentTaskSessions } from "../lib/agent-task.mjs";
9
9
  import { stringArgument } from "../lib/attachment-tools.mjs";
10
10
  import { pendingQuestions, questionKey } from "../lib/questions.mjs";
11
- import { i as memberIdOf } from "../../_chunks/principal-UlkbLrgQ.mjs";
11
+ import { i as memberIdOf } from "../../_chunks/principal-BIX7T6Hh.mjs";
12
12
  import { defineTool } from "eve/tools";
13
13
  var questions_ask_default = defineTool({
14
14
  availableInSubagents: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.36.2",
3
+ "version": "0.37.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",
@@ -76,7 +76,7 @@
76
76
  "@chat-adapter/state-memory": "4.42.0",
77
77
  "@chat-adapter/telegram": "4.41.0",
78
78
  "@chat-adapter/whatsapp": "4.42.0",
79
- "@segmentstream/ontology": "0.92.1",
79
+ "@segmentstream/ontology": "0.93.0",
80
80
  "@vercel/oidc": "^3.8.4",
81
81
  "ai": "^7.0.137",
82
82
  "chat": "4.42.0",