@segmentstream/agent 0.31.14 → 0.33.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.
- package/dist/_chunks/{build-metadata-frH1WOMT.mjs → build-metadata-DpwHNeNL.mjs} +1 -1
- package/dist/_chunks/{inbound-request-Dy7q3T23.mjs → inbound-request-BQQWCrWl.mjs} +7 -3
- package/dist/_chunks/{principal-CPOCTHBa.mjs → principal-VsmaJp1x.mjs} +1 -1
- package/dist/extension/channels/whatsapp.d.ts +7 -0
- package/dist/extension/channels/whatsapp.mjs +13 -0
- package/dist/extension/config.d.ts +12 -0
- package/dist/extension/config.mjs +31 -5
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/instructions.md +6 -2
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-context.mjs +1 -1
- package/dist/extension/lib/confirmation-description.d.ts +45 -0
- package/dist/extension/lib/confirmation-description.mjs +60 -1
- package/dist/extension/lib/confirmations.d.ts +7 -1
- package/dist/extension/lib/confirmations.mjs +5 -4
- package/dist/extension/lib/conversation-runtime.mjs +1 -1
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +3 -3
- package/dist/extension/lib/ontology-tools.d.ts +2 -1
- package/dist/extension/lib/ontology-tools.mjs +48 -4
- package/dist/extension/lib/runtime-envelope.mjs +1 -1
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +3 -3
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +2 -2
- package/dist/extension/lib/telegram/callbacks.mjs +2 -2
- package/dist/extension/lib/telegram/confirmation-text.d.ts +52 -4
- package/dist/extension/lib/telegram/confirmation-text.mjs +84 -15
- package/dist/extension/lib/telegram/confirmations.d.ts +9 -0
- package/dist/extension/lib/telegram/confirmations.mjs +46 -14
- package/dist/extension/lib/telegram/conversations.mjs +1 -1
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.mjs +2 -2
- package/dist/extension/lib/telegram/format.d.ts +4 -0
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/images.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +2 -2
- package/dist/extension/lib/telegram/lifecycle.mjs +3 -3
- package/dist/extension/lib/telegram/media-policy.mjs +1 -1
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
- package/dist/extension/lib/telegram/voice.mjs +1 -1
- package/dist/extension/lib/whatsapp/adapter.d.ts +81 -0
- package/dist/extension/lib/whatsapp/adapter.mjs +237 -0
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/tools/attachments_promote.mjs +3 -3
- package/dist/extension/tools/questions_ask.mjs +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { WhatsAppAdapter } from "@chat-adapter/whatsapp";
|
|
2
|
+
import { type Message, type WebhookOptions } from "chat";
|
|
3
|
+
import type { SessionAuthContext } from "eve/context";
|
|
4
|
+
import type { AdmissionSettings, WhatsAppSettings } from "../../config.js";
|
|
5
|
+
import { type ConnectionProxy } from "../connection-proxy.js";
|
|
6
|
+
import { type Environment } from "../environment.js";
|
|
7
|
+
import { type AgentIdentities, type PairedMember } from "../identities.js";
|
|
8
|
+
import { type RuntimeToken } from "../runtime-token.js";
|
|
9
|
+
/**
|
|
10
|
+
* The SegmentStream WhatsApp channel (`agent-design.md`, "Channels"): eve's Chat SDK bridge with
|
|
11
|
+
* the Chat SDK WhatsApp adapter, at `POST /eve/v1/whatsapp`. SegmentStream's Meta app receives the
|
|
12
|
+
* number's webhooks and relays its messages here, signed as Meta signs them with the project's
|
|
13
|
+
* `SEGMENTSTREAM_AGENT_WEBHOOK_SECRET`. Replies, read receipts, typing and media downloads go
|
|
14
|
+
* through the workspace's `WhatsAppConnection` by the connection proxy, which addresses the number
|
|
15
|
+
* as `/phone`: no Meta token or number ID enters this process.
|
|
16
|
+
*
|
|
17
|
+
* Only paired members are answered. A sender nobody paired gets the workspace's
|
|
18
|
+
* `replies.pairingRequired` text and a link to the app's `/agent/connect`.
|
|
19
|
+
*/
|
|
20
|
+
/** The authenticator of a WhatsApp session's principal. */
|
|
21
|
+
export declare const WHATSAPP_AUTHENTICATOR = "segmentstream-whatsapp";
|
|
22
|
+
/** The origin the adapter's Graph calls are aimed at. `.invalid` never resolves (RFC 6761). */
|
|
23
|
+
export declare const WHATSAPP_PROXY_ORIGIN = "https://whatsapp.segmentstream.invalid";
|
|
24
|
+
/** The adapter sent a request this channel does not route through the proxy. */
|
|
25
|
+
export declare class WhatsAppProxyRouteError extends Error {
|
|
26
|
+
readonly name = "WhatsAppProxyRouteError";
|
|
27
|
+
}
|
|
28
|
+
export interface WhatsAppChannelOptions {
|
|
29
|
+
/** The mounted `channels.whatsapp`, or `null` when the workspace has no WhatsApp channel. */
|
|
30
|
+
readonly settings: () => WhatsAppSettings | null;
|
|
31
|
+
readonly admission: () => AdmissionSettings;
|
|
32
|
+
readonly environment?: Environment;
|
|
33
|
+
readonly token?: RuntimeToken;
|
|
34
|
+
/** For the proxy and the ontology service; tests pass a fake. */
|
|
35
|
+
readonly fetch?: typeof fetch;
|
|
36
|
+
/** The ontology's pairing routes; tests pass a fake. */
|
|
37
|
+
readonly identities?: AgentIdentities;
|
|
38
|
+
}
|
|
39
|
+
/** What the adapter reads per request: eve binds the mount after it loads the channel. */
|
|
40
|
+
interface WhatsAppRuntime {
|
|
41
|
+
readonly enabled: () => boolean;
|
|
42
|
+
readonly secret: () => string | undefined;
|
|
43
|
+
readonly proxy: () => ConnectionProxy;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The Chat SDK WhatsApp adapter with its network replaced: it accepts only the platform's relayed
|
|
47
|
+
* deliveries and sends every Graph request through the connection proxy.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ProxiedWhatsAppAdapter extends WhatsAppAdapter {
|
|
50
|
+
#private;
|
|
51
|
+
constructor(runtime: WhatsAppRuntime);
|
|
52
|
+
/** 404 until the channel is configured in production; the platform never sends a handshake. */
|
|
53
|
+
handleWebhook(request: Request, options?: WebhookOptions): Promise<Response>;
|
|
54
|
+
/** The platform signs each relayed body with the project's agent webhook secret. */
|
|
55
|
+
protected verifySignature(body: string, signature: string | null): boolean;
|
|
56
|
+
protected graphApiRequest<T = unknown>(path: string, body: unknown): Promise<T>;
|
|
57
|
+
/** Uploads are not admitted by the connection; messages send media by link. */
|
|
58
|
+
protected graphApiUpload<T = unknown>(): Promise<T>;
|
|
59
|
+
/** The media's URL by `GET /media/{id}`, then its bytes through the connection's `media` API. */
|
|
60
|
+
downloadMedia(mediaId: string): Promise<Buffer>;
|
|
61
|
+
}
|
|
62
|
+
/** The adapter addresses the number by its ID, which here is the proxy's `/phone` alias. */
|
|
63
|
+
export declare function proxyPath(path: string): string;
|
|
64
|
+
/** The principal of a paired member's WhatsApp session, as the Telegram channel stamps one. */
|
|
65
|
+
export declare function whatsappPrincipal(member: PairedMember, sender: string): SessionAuthContext;
|
|
66
|
+
/** Builds the channel. Everything it reads from the mount is read per request. */
|
|
67
|
+
export declare function segmentstreamWhatsApp(options: WhatsAppChannelOptions): import("eve/channels/chat-sdk").ChatSdkChannel;
|
|
68
|
+
/**
|
|
69
|
+
* Admits one inbound message: the principal of a paired member who wrote something, or undefined
|
|
70
|
+
* after answering anyone else with the workspace's reply, if it has one.
|
|
71
|
+
*/
|
|
72
|
+
export declare function receive(input: {
|
|
73
|
+
readonly thread: {
|
|
74
|
+
readonly post: (text: string) => Promise<unknown>;
|
|
75
|
+
};
|
|
76
|
+
readonly message: Pick<Message, "author" | "text" | "attachments">;
|
|
77
|
+
readonly admission: AdmissionSettings;
|
|
78
|
+
readonly identities: AgentIdentities;
|
|
79
|
+
readonly environment: Environment;
|
|
80
|
+
}): Promise<SessionAuthContext | undefined>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,237 @@
|
|
|
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 { admitMessage, localizedText } from "../admission.mjs";
|
|
8
|
+
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
9
|
+
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
10
|
+
import { appOrigin, channelsEnabled, proxyEnvironment, webhookSecret } from "../environment.mjs";
|
|
11
|
+
import { agentIdentities } from "../identities.mjs";
|
|
12
|
+
import { runtimeToken } from "../runtime-token.mjs";
|
|
13
|
+
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
14
|
+
import { createMemoryState } from "@chat-adapter/state-memory";
|
|
15
|
+
import { WhatsAppAdapter, WhatsAppApiError } from "@chat-adapter/whatsapp";
|
|
16
|
+
import { ConsoleLogger } from "chat";
|
|
17
|
+
import { chatSdkChannel, messageContentOf } from "eve/channels/chat-sdk";
|
|
18
|
+
const WHATSAPP_AUTHENTICATOR = "segmentstream-whatsapp";
|
|
19
|
+
const WHATSAPP_PROXY_ORIGIN = "https://whatsapp.segmentstream.invalid";
|
|
20
|
+
const API_VERSION = "v26.0";
|
|
21
|
+
const PLACEHOLDER = "segmentstream-connection";
|
|
22
|
+
const PHONE_ALIAS = "phone";
|
|
23
|
+
const MEDIA_ORIGIN = "https://lookaside.fbsbx.com";
|
|
24
|
+
var WhatsAppProxyRouteError = class extends Error {
|
|
25
|
+
name = "WhatsAppProxyRouteError";
|
|
26
|
+
};
|
|
27
|
+
var ProxiedWhatsAppAdapter = class extends WhatsAppAdapter {
|
|
28
|
+
#runtime;
|
|
29
|
+
constructor(runtime) {
|
|
30
|
+
super({
|
|
31
|
+
accessToken: PLACEHOLDER,
|
|
32
|
+
appSecret: PLACEHOLDER,
|
|
33
|
+
verifyToken: PLACEHOLDER,
|
|
34
|
+
phoneNumberId: PHONE_ALIAS,
|
|
35
|
+
apiUrl: WHATSAPP_PROXY_ORIGIN,
|
|
36
|
+
apiVersion: API_VERSION,
|
|
37
|
+
userName: "agent",
|
|
38
|
+
logger: new ConsoleLogger("warn", "whatsapp")
|
|
39
|
+
});
|
|
40
|
+
this.#runtime = runtime;
|
|
41
|
+
}
|
|
42
|
+
async handleWebhook(request, options) {
|
|
43
|
+
if (!this.#runtime.enabled()) return new Response(null, { status: 404 });
|
|
44
|
+
if (request.method !== "POST") return new Response(null, { status: 405 });
|
|
45
|
+
return super.handleWebhook(request, options);
|
|
46
|
+
}
|
|
47
|
+
verifySignature(body, signature) {
|
|
48
|
+
const secret = this.#runtime.secret();
|
|
49
|
+
if (secret === void 0 || signature === null) return false;
|
|
50
|
+
const expected = `sha256=${createHmac("sha256", secret).update(body, "utf8").digest("hex")}`;
|
|
51
|
+
return timingSafeEqual(digest(expected), digest(signature.trim().toLowerCase()));
|
|
52
|
+
}
|
|
53
|
+
async graphApiRequest(path, body) {
|
|
54
|
+
return this.#graph({
|
|
55
|
+
api: "graph",
|
|
56
|
+
method: "POST",
|
|
57
|
+
path: proxyPath(path),
|
|
58
|
+
headers: [["content-type", "application/json"]],
|
|
59
|
+
body: new TextEncoder().encode(JSON.stringify(body))
|
|
60
|
+
}, "WhatsApp API error");
|
|
61
|
+
}
|
|
62
|
+
async graphApiUpload() {
|
|
63
|
+
throw new WhatsAppProxyRouteError("The WhatsApp connection does not admit media uploads; send media by link.");
|
|
64
|
+
}
|
|
65
|
+
async downloadMedia(mediaId) {
|
|
66
|
+
if (!/^[0-9]{1,32}$/.test(mediaId)) throw new WhatsAppProxyRouteError("A WhatsApp media ID is numeric.");
|
|
67
|
+
const described = await this.#graph({
|
|
68
|
+
api: "graph",
|
|
69
|
+
method: "GET",
|
|
70
|
+
path: `/media/${mediaId}`,
|
|
71
|
+
headers: [],
|
|
72
|
+
body: new Uint8Array()
|
|
73
|
+
}, "Failed to get media URL");
|
|
74
|
+
const url = typeof described.url === "string" ? new URL(described.url) : void 0;
|
|
75
|
+
if (url === void 0 || url.origin !== MEDIA_ORIGIN) throw new WhatsAppProxyRouteError("WhatsApp media is downloaded only from its own host.");
|
|
76
|
+
const reply = await this.#runtime.proxy().download({
|
|
77
|
+
api: "media",
|
|
78
|
+
method: "GET",
|
|
79
|
+
path: `${url.pathname}${url.search}`,
|
|
80
|
+
headers: [],
|
|
81
|
+
body: new Uint8Array()
|
|
82
|
+
}, MAXIMUM_DOWNLOAD_BYTES);
|
|
83
|
+
if (reply.status < 200 || reply.status >= 300) throw new WhatsAppApiError(`Failed to download media ${mediaId}`, reply.status, new TextDecoder().decode(reply.body));
|
|
84
|
+
return Buffer.from(reply.body);
|
|
85
|
+
}
|
|
86
|
+
async #graph(call, label) {
|
|
87
|
+
const reply = await this.#runtime.proxy().request(call);
|
|
88
|
+
const text = new TextDecoder().decode(reply.body);
|
|
89
|
+
if (reply.status < 200 || reply.status >= 300) throw new WhatsAppApiError(label, reply.status, text);
|
|
90
|
+
return JSON.parse(text);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function proxyPath(path) {
|
|
94
|
+
if (path !== `/${PHONE_ALIAS}` && !path.startsWith(`/${PHONE_ALIAS}/`)) throw new WhatsAppProxyRouteError("The WhatsApp channel sends only as the connected number.");
|
|
95
|
+
return path;
|
|
96
|
+
}
|
|
97
|
+
function report(operation, error) {
|
|
98
|
+
console.error("[segmentstream] WhatsApp delivery diagnostic", {
|
|
99
|
+
operation,
|
|
100
|
+
error: redactDiagnostic(error, new Set())
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function digest(value) {
|
|
104
|
+
return createHash("sha256").update(value, "utf8").digest();
|
|
105
|
+
}
|
|
106
|
+
function whatsappPrincipal(member, sender) {
|
|
107
|
+
return {
|
|
108
|
+
authenticator: WHATSAPP_AUTHENTICATOR,
|
|
109
|
+
issuer: "whatsapp",
|
|
110
|
+
principalId: `whatsapp:${sender}`,
|
|
111
|
+
principalType: "user",
|
|
112
|
+
subject: sender,
|
|
113
|
+
attributes: {
|
|
114
|
+
memberId: member.id,
|
|
115
|
+
identityProvider: "whatsapp",
|
|
116
|
+
roles: member.roles,
|
|
117
|
+
...member.name === null ? {} : { memberName: member.name },
|
|
118
|
+
...member.locale === void 0 ? {} : { locale: member.locale }
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function segmentstreamWhatsApp(options) {
|
|
123
|
+
const environment = options.environment ?? process.env;
|
|
124
|
+
const token = options.token ?? runtimeToken;
|
|
125
|
+
const proxies = new Map();
|
|
126
|
+
let identities = options.identities;
|
|
127
|
+
const runtime = {
|
|
128
|
+
enabled: () => channelsEnabled(environment) && options.settings() !== null && webhookSecret(environment) !== void 0,
|
|
129
|
+
secret: () => webhookSecret(environment),
|
|
130
|
+
proxy: () => {
|
|
131
|
+
const connection = options.settings()?.connection;
|
|
132
|
+
if (connection === void 0) throw new Error("The WhatsApp channel is not configured in agent/segmentstream.json.");
|
|
133
|
+
let existing = proxies.get(connection);
|
|
134
|
+
if (existing === void 0) {
|
|
135
|
+
existing = connectionProxy({
|
|
136
|
+
environment: proxyEnvironment(environment),
|
|
137
|
+
connection,
|
|
138
|
+
token,
|
|
139
|
+
...options.fetch === void 0 ? {} : { fetch: options.fetch }
|
|
140
|
+
});
|
|
141
|
+
proxies.set(connection, existing);
|
|
142
|
+
}
|
|
143
|
+
return existing;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const pairing = () => identities ??= agentIdentities({
|
|
147
|
+
origin: appOrigin(environment),
|
|
148
|
+
token,
|
|
149
|
+
...options.fetch === void 0 ? {} : { fetch: options.fetch }
|
|
150
|
+
});
|
|
151
|
+
async function pairedPrincipal(sender) {
|
|
152
|
+
const lookup = await pairing().lookup({
|
|
153
|
+
provider: "whatsapp",
|
|
154
|
+
externalId: sender
|
|
155
|
+
});
|
|
156
|
+
return lookup.status === "paired" ? whatsappPrincipal(lookup.member, sender) : null;
|
|
157
|
+
}
|
|
158
|
+
const bridge = chatSdkChannel({
|
|
159
|
+
userName: "agent",
|
|
160
|
+
adapters: { whatsapp: new ProxiedWhatsAppAdapter(runtime) },
|
|
161
|
+
state: createMemoryState(),
|
|
162
|
+
streaming: false,
|
|
163
|
+
resolveInputAuth: (event) => event.user?.userId === void 0 ? null : pairedPrincipal(event.user.userId)
|
|
164
|
+
});
|
|
165
|
+
bridge.bot.onDirectMessage((thread, message) => receive({
|
|
166
|
+
thread,
|
|
167
|
+
message,
|
|
168
|
+
admission: options.admission(),
|
|
169
|
+
identities: pairing(),
|
|
170
|
+
environment
|
|
171
|
+
}).then((admitted) => admitted === void 0 ? void 0 : bridge.send(messageContentOf(message), {
|
|
172
|
+
thread,
|
|
173
|
+
idempotencyKey: message.id,
|
|
174
|
+
auth: admitted
|
|
175
|
+
})).then(() => void 0));
|
|
176
|
+
return bridge.channel;
|
|
177
|
+
}
|
|
178
|
+
async function receive(input) {
|
|
179
|
+
const { thread, message, admission, identities } = input;
|
|
180
|
+
if (message.author.isMe) return;
|
|
181
|
+
const sender = message.author.userId;
|
|
182
|
+
const display = message.author.fullName.trim() || void 0;
|
|
183
|
+
const turn = message.text.trim() !== "" || message.attachments.length > 0;
|
|
184
|
+
const resolution = await admitMessage({
|
|
185
|
+
identity: {
|
|
186
|
+
provider: "whatsapp",
|
|
187
|
+
externalId: sender,
|
|
188
|
+
chat: "private",
|
|
189
|
+
turn,
|
|
190
|
+
...display === void 0 ? {} : { display }
|
|
191
|
+
},
|
|
192
|
+
identities,
|
|
193
|
+
settings: admission,
|
|
194
|
+
sendNotice: (text) => thread.post(text),
|
|
195
|
+
noticeFailed: (error) => report("notice_failed", error)
|
|
196
|
+
});
|
|
197
|
+
switch (resolution.status) {
|
|
198
|
+
case "existing":
|
|
199
|
+
case "created": return turn ? whatsappPrincipal(resolution.member, sender) : void 0;
|
|
200
|
+
case "pairing_required": {
|
|
201
|
+
const text = localizedText(admission.replies.pairingRequired);
|
|
202
|
+
if (text !== void 0) {
|
|
203
|
+
const code = (await identities.createPairing({
|
|
204
|
+
provider: "whatsapp",
|
|
205
|
+
externalId: sender,
|
|
206
|
+
...display === void 0 ? {} : { display }
|
|
207
|
+
})).code;
|
|
208
|
+
await thread.post(`${text}\n\n${appOrigin(input.environment)}/agent/connect?code=${encodeURIComponent(code)}`);
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
case "refused": {
|
|
213
|
+
const text = localizedText(admission.replies.refused);
|
|
214
|
+
if (text !== void 0) await thread.post(text);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
case "limited": {
|
|
218
|
+
const replies = admission.replies;
|
|
219
|
+
const configured = resolution.scope === "workspaceTurnsPerDay" ? replies.workspaceLimited : resolution.scope === "newUsersPerHour" ? replies.registrationsLimited : replies.perSenderLimited;
|
|
220
|
+
const text = resolution.notify ? localizedText(configured ?? replies.limited) : void 0;
|
|
221
|
+
if (text !== void 0) {
|
|
222
|
+
let delivered = false;
|
|
223
|
+
try {
|
|
224
|
+
await thread.post(text);
|
|
225
|
+
delivered = true;
|
|
226
|
+
} finally {
|
|
227
|
+
if (resolution.notificationId !== void 0) await identities.completeLimitNotice({
|
|
228
|
+
notificationId: resolution.notificationId,
|
|
229
|
+
delivered
|
|
230
|
+
}).catch((error) => report("limit_notice_completion_failed", error));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export { ProxiedWhatsAppAdapter, WHATSAPP_AUTHENTICATOR, WHATSAPP_PROXY_ORIGIN, WhatsAppProxyRouteError, proxyPath, receive, segmentstreamWhatsApp, whatsappPrincipal };
|
package/dist/extension/model.mjs
CHANGED
|
@@ -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-
|
|
9
|
+
import { a as rolesOf } from "../_chunks/principal-VsmaJp1x.mjs";
|
|
10
10
|
import { runs } from "eve/events";
|
|
11
11
|
import { defineDynamic } from "eve";
|
|
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-
|
|
7
|
+
import { u as runtimeEnvelope } from "../../_chunks/principal-VsmaJp1x.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";
|
|
@@ -37,9 +37,9 @@ const tool = defineTool({
|
|
|
37
37
|
const target = promotionTarget(input);
|
|
38
38
|
return ontologyTools().labels(actor, target.action, target.input);
|
|
39
39
|
},
|
|
40
|
-
describe: (actor, _tool, input) => {
|
|
40
|
+
describe: (actor, _tool, input, _hints, locale) => {
|
|
41
41
|
const target = promotionTarget(input);
|
|
42
|
-
return ontologyTools().describe(actor, target.action, target.input);
|
|
42
|
+
return ontologyTools().describe(actor, target.action, target.input, void 0, locale);
|
|
43
43
|
}
|
|
44
44
|
}),
|
|
45
45
|
description: "Keep a file the member sent by storing it in a record through an ontology action that takes a file, such as document.upload. Give the entity, the action and the action's input without the file field: the platform fills it with the attachment, and fills sha256 when the action takes one. Runs with the member's permissions. The same file promoted again through the same action returns the earlier result instead of a duplicate. With the sandbox on, give path instead of id to keep a file from /workspace, such as a result in /workspace/work.",
|
|
@@ -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-
|
|
11
|
+
import { i as memberIdOf } from "../../_chunks/principal-VsmaJp1x.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.
|
|
3
|
+
"version": "0.33.0",
|
|
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",
|
|
@@ -73,10 +73,13 @@
|
|
|
73
73
|
"eval:routing": "tsx tests/routing-eval/cli.ts"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
+
"@chat-adapter/state-memory": "4.42.0",
|
|
76
77
|
"@chat-adapter/telegram": "4.41.0",
|
|
77
|
-
"@
|
|
78
|
+
"@chat-adapter/whatsapp": "4.42.0",
|
|
79
|
+
"@segmentstream-cloud/ontology": "0.90.0",
|
|
78
80
|
"@vercel/oidc": "^3.8.4",
|
|
79
81
|
"ai": "^7.0.137",
|
|
82
|
+
"chat": "4.42.0",
|
|
80
83
|
"csv-parse": "^7.0.3",
|
|
81
84
|
"decimal.js": "^10.6.0",
|
|
82
85
|
"fast-xml-parser": "^5.11.2",
|
|
@@ -93,9 +96,9 @@
|
|
|
93
96
|
"devDependencies": {
|
|
94
97
|
"@types/node": "^24",
|
|
95
98
|
"eve": "1.0.0-rc.6",
|
|
99
|
+
"tsx": "^4",
|
|
96
100
|
"typescript": "^5.9",
|
|
97
|
-
"vitest": "^4.1.11"
|
|
98
|
-
"tsx": "^4"
|
|
101
|
+
"vitest": "^4.1.11"
|
|
99
102
|
},
|
|
100
103
|
"publishConfig": {
|
|
101
104
|
"access": "public"
|