@segmentstream/agent 0.50.3 → 0.51.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.
- package/CHANGELOG.md +17 -0
- package/README.md +1 -0
- package/dist/_chunks/{build-metadata-CUHPCFCT.mjs → build-metadata-BDr_toej.mjs} +1 -1
- package/dist/_chunks/{principal-D5Tualrk.mjs → principal-ie0lHCpn.mjs} +19 -2
- package/dist/extension/channels/email.d.ts +7 -0
- package/dist/extension/channels/email.mjs +20 -0
- package/dist/extension/config.d.ts +36 -0
- package/dist/extension/config.mjs +64 -3
- package/dist/extension/connections/ontology.mjs +1 -1
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.mjs +1 -1
- package/dist/extension/lib/attachments.d.ts +11 -1
- package/dist/extension/lib/attachments.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-address.d.ts +1 -1
- package/dist/extension/lib/chat-address.mjs +1 -1
- package/dist/extension/lib/chat-context.mjs +1 -1
- package/dist/extension/lib/chat-recorder.mjs +9 -1
- package/dist/extension/lib/confirmations.mjs +1 -1
- package/dist/extension/lib/email/channel.d.ts +80 -0
- package/dist/extension/lib/email/channel.mjs +524 -0
- package/dist/extension/lib/email/gmail.d.ts +68 -0
- package/dist/extension/lib/email/gmail.mjs +188 -0
- package/dist/extension/lib/email/message.d.ts +44 -0
- package/dist/extension/lib/email/message.mjs +78 -0
- package/dist/extension/lib/identities.d.ts +5 -0
- package/dist/extension/lib/identities.mjs +3 -2
- package/dist/extension/lib/inbound-media/files.mjs +1 -1
- package/dist/extension/lib/inbound-media/index.mjs +1 -1
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +1 -1
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/hold.d.ts +1 -1
- package/dist/extension/lib/review/hold.mjs +6 -2
- package/dist/extension/lib/review/reply.mjs +1 -1
- package/dist/extension/lib/role-skill.mjs +1 -1
- package/dist/extension/lib/runtime-envelope.mjs +1 -1
- package/dist/extension/lib/sent-files.mjs +1 -1
- package/dist/extension/lib/slack/adapter.mjs +1 -1
- package/dist/extension/lib/slack/attachments-send.mjs +1 -1
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +3 -19
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- package/dist/extension/lib/telegram/callbacks.mjs +1 -1
- package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.mjs +1 -1
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
- 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 +1 -1
- package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
- package/dist/extension/lib/web/auth.mjs +1 -1
- package/dist/extension/lib/web/channel.mjs +1 -1
- package/dist/extension/lib/whatsapp/adapter.mjs +1 -1
- package/dist/extension/lib/whatsapp/files.mjs +1 -1
- package/dist/extension/lib/workspace-source.mjs +1 -1
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/tools/attachments_discard.mjs +1 -1
- package/dist/extension/tools/attachments_list.mjs +1 -1
- package/dist/extension/tools/attachments_promote.mjs +1 -1
- package/dist/extension/tools/attachments_read.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +1 -1
- package/dist/extension/tools/attachments_stage.mjs +1 -1
- package/dist/extension/tools/attachments_table.mjs +1 -1
- package/dist/extension/tools/questions_ask.mjs +1 -1
- package/dist/extension/tools/workspace_source.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.51.1
|
|
4
|
+
|
|
5
|
+
Pins @segmentstream/ontology 0.106.3.
|
|
6
|
+
|
|
7
|
+
## 0.51.0
|
|
8
|
+
|
|
9
|
+
The agent answers email. `channels.email` names a `GmailConnection` mailbox: SegmentStream wakes
|
|
10
|
+
the channel when Gmail pushes a change (`push.topic`, a Pub/Sub topic in the Google project of the
|
|
11
|
+
connection's OAuth client) and at least every `checkAfterMinutes` (10 to 60, 10 by default), and
|
|
12
|
+
each wake reads what arrived since the last one. Only mail `query` finds reaches the agent;
|
|
13
|
+
auto-replies, bounces, mailing lists, the mailbox's own mail and mail that failed DMARC never do.
|
|
14
|
+
One Gmail thread is one chat with one person, admitted as their `email` account; the reply stays in
|
|
15
|
+
the thread, as HTML and plain text, and reply review holds it as on WhatsApp. Mail shows no
|
|
16
|
+
buttons, so an action that needs a confirmation is not run from it.
|
|
17
|
+
|
|
18
|
+
Pins @segmentstream/ontology 0.106.2.
|
|
19
|
+
|
|
3
20
|
## 0.50.3
|
|
4
21
|
|
|
5
22
|
Pins @segmentstream/ontology 0.106.1.
|
package/README.md
CHANGED
|
@@ -267,6 +267,7 @@ continue using GET lookup. Starter templates and pins remain unchanged in this s
|
|
|
267
267
|
| `segmentstream__ontology` | `connections` | Direct MCP tools through Eve search, calls and approvals, acting as the current member or task. |
|
|
268
268
|
| `segmentstream__telegram` | `channels` | `POST /eve/v1/telegram`: Telegram through the connection, with pairing, routing and voice. |
|
|
269
269
|
| `segmentstream__tasks` | `channels` | `POST /eve/segmentstream/v1/tasks`: a workflow's `agentTask`, run as the workflow's user; see [Workflow tasks](#workflow-tasks). |
|
|
270
|
+
| `segmentstream__email` | `channels` | `POST /eve/segmentstream/v1/email`: the `GmailConnection` mailbox in `channels.email`, which SegmentStream wakes; one Gmail thread is one chat with one person. |
|
|
270
271
|
| `segmentstream__attachments_list`, `_read`, `_promote`, `_discard` | `tools` | The member's temporary attachments in this chat: list, read, keep through an action, drop. |
|
|
271
272
|
| `segmentstream__attachments_send` | `tools` | Sends readable stored ontology files into the current Telegram chat and topic. |
|
|
272
273
|
| `segmentstream__no_reply` | `tools` | Eve's `no_reply`: ends the turn without a message and keeps the model's reason in the session and the archive. |
|
|
@@ -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.
|
|
7
|
+
var version = "0.51.1";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -385,7 +385,7 @@ function parsedChatAddress(value, provider) {
|
|
|
385
385
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return;
|
|
386
386
|
const item = value;
|
|
387
387
|
const text = (field, empty = false) => typeof field === "string" && (empty || field !== "") && field.length <= 512;
|
|
388
|
-
if (item.provider !== "slack" && item.provider !== "whatsapp" && item.provider !== "web" || item.provider !== provider || !text(item.chatId) || !text(item.threadId, true) || item.kind !== "private" && item.kind !== "group" || item.peer !== void 0 && !text(item.peer)) return;
|
|
388
|
+
if (item.provider !== "slack" && item.provider !== "whatsapp" && item.provider !== "web" && item.provider !== "email" || item.provider !== provider || !text(item.chatId) || !text(item.threadId, true) || item.kind !== "private" && item.kind !== "group" || item.peer !== void 0 && !text(item.peer)) return;
|
|
389
389
|
return {
|
|
390
390
|
provider: item.provider,
|
|
391
391
|
chatId: item.chatId,
|
|
@@ -708,6 +708,7 @@ function actionApproval(options) {
|
|
|
708
708
|
}
|
|
709
709
|
if (saved !== void 0) return denied("The original call is waiting for its Confirm / Cancel buttons.");
|
|
710
710
|
if (!posting && !needsConfirmation(labels)) return "approved";
|
|
711
|
+
if (chat?.provider === "email") return denied("Email shows no confirmation buttons, so this action cannot run from mail. Say in your reply what you would do; a member can run it.");
|
|
711
712
|
if (labels.confirmation === true && labels.preview !== true && copy === void 0) return missingCopy();
|
|
712
713
|
try {
|
|
713
714
|
if (!posting) description = await options.describe?.(member(memberId), ctx.toolName, businessInput, hints, confirmationLocale(ctx.session.auth.current));
|
|
@@ -1450,6 +1451,22 @@ function parseAttachmentUrl(url) {
|
|
|
1450
1451
|
chat
|
|
1451
1452
|
};
|
|
1452
1453
|
}
|
|
1454
|
+
async function fetchStoredAttachment(attachments, url, context) {
|
|
1455
|
+
const reference = parseAttachmentUrl(url);
|
|
1456
|
+
if (reference === void 0) return null;
|
|
1457
|
+
const session = typeof context === "object" && context !== null ? context.session : void 0;
|
|
1458
|
+
const sessionId = typeof session?.id === "string" && session.id !== "" ? session.id : void 0;
|
|
1459
|
+
const { attachment, bytes } = await attachments.read({
|
|
1460
|
+
memberId: reference.memberId,
|
|
1461
|
+
chat: reference.chat,
|
|
1462
|
+
...sessionId === void 0 ? {} : { sessionId }
|
|
1463
|
+
}, reference.id);
|
|
1464
|
+
return {
|
|
1465
|
+
bytes: Buffer.from(bytes),
|
|
1466
|
+
mediaType: attachment.contentType,
|
|
1467
|
+
filename: attachment.filename
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1453
1470
|
function megabytes(bytes) {
|
|
1454
1471
|
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
1455
1472
|
}
|
|
@@ -1833,4 +1850,4 @@ function identityProviderOf(principal) {
|
|
|
1833
1850
|
const provider = principal?.attributes.identityProvider;
|
|
1834
1851
|
return typeof provider === "string" && provider !== "" ? provider : void 0;
|
|
1835
1852
|
}
|
|
1836
|
-
export {
|
|
1853
|
+
export { WEB_GRANT_ATTRIBUTE as $, OntologyToolRejected as A, ACT_AS_HEADER as B, attachmentUrl as C, principalRuntimeSource as Ct, ontologyConnection as D, actAsHeaders as E, CONFIRMATION_TTL_MS as F, member as G, actorHeaders as H, actionApproval as I, AGENT_GRANT_HEADER as J, memberTool as K, confirmations as L, ontologyToolLabels as M, ontologyTools as N, OntologyActionNotPermitted as O, promotionTarget as P, WEB_AUTHENTICATOR as Q, inputHash as R, agentAttachments as S, compatibleRuntimeEnvelope as St, parseAttachmentUrl as T, telegramRuntimeSource as Tt, actorKey as U, ActorRequiredError as V, actorOf as W, TURN_LIMITED_CODE as X, INTROSPECTION_PATH as Y, TurnLimitedError as Z, AttachmentError as _, formattingRefused as _t, rolesOf as a, webPrincipal as at, MAXIMUM_ATTACHMENT_BYTES as b, withDeliveryLocale as bt, currentInboundRequest as c, isSameChat as ct, prepareInboundMedia as d, currentLocale as dt, WEB_PROVIDER as et, attachmentsContext as f, currentThreadId as ft, ATTACHMENT_URL_PROTOCOL as g, failureText as gt, ATTACHMENT_TTL_HOURS as h, customerText as ht, memberIdOf as i, webMemberOf as it, actionToolName as j, OntologyFileUnavailable as k, runInboundRequest as l, withChatAddress as lt, turnContent as m, customerMessage as mt, chatLanguage as n, webAuth as nt, telegramPrincipal as o, CHAT_ATTRIBUTE as ot, storeFiles as p, customerCopy as pt, ACCESS_TOKEN_PREFIX as q, identityProviderOf as r, webGrantOf as rt, InboundRequest as s, chatAddressOf as st, TELEGRAM_AUTHENTICATOR as t, ontologyIntrospection as tt, withReplacedText as u, TelegramDeliveryError as ut, CHAT_HEADER as v, reportTelegramError as vt, fetchStoredAttachment as w, runtimeEnvelope as wt, SESSION_HEADER as x, RUNTIME_SOURCE_PROTOCOL as xt, EARLIER_CHAT_HEADER as y, safeTelegramFetch as yt, needsConfirmation as z };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `POST /eve/segmentstream/v1/email`: the mailbox of the connection named in `channels.email`.
|
|
3
|
+
* SegmentStream wakes it when Gmail pushes a change and at least every `checkAfterMinutes`.
|
|
4
|
+
* Without that setting, or outside production, the route answers 404.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: import("eve/channels").Channel<undefined, Record<string, unknown>, Record<string, unknown>>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 segmentstream from "../extension.mjs";
|
|
8
|
+
import { segmentstreamEmail } from "../lib/email/channel.mjs";
|
|
9
|
+
import { decide } from "eve/ai";
|
|
10
|
+
var email_default = segmentstreamEmail({
|
|
11
|
+
settings: () => segmentstream.config.channels.email,
|
|
12
|
+
admission: () => segmentstream.config,
|
|
13
|
+
models: () => segmentstream.config.models,
|
|
14
|
+
review: {
|
|
15
|
+
settings: () => segmentstream.config.review,
|
|
16
|
+
decide: (options) => decide(options),
|
|
17
|
+
model: () => segmentstream.config.models.decision
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
export { email_default as default };
|
|
@@ -112,6 +112,18 @@ export interface SegmentStreamAgentConfigInput {
|
|
|
112
112
|
/** The key of the workspace's `SlackConnection`, such as `slack`. */
|
|
113
113
|
readonly connection: string;
|
|
114
114
|
};
|
|
115
|
+
readonly email?: {
|
|
116
|
+
/** The key of the workspace's `GmailConnection`: the mailbox the agent reads and answers. */
|
|
117
|
+
readonly connection: string;
|
|
118
|
+
/** Which mail reaches the agent, as Gmail's search; `in:inbox` when absent. */
|
|
119
|
+
readonly query?: string;
|
|
120
|
+
/** How long the mailbox may go unread, in minutes: 10 to 60, 10 when absent. */
|
|
121
|
+
readonly checkAfterMinutes?: number;
|
|
122
|
+
/** Gmail push to a Pub/Sub topic in the Google project of the connection's OAuth client. */
|
|
123
|
+
readonly push?: {
|
|
124
|
+
readonly topic: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
115
127
|
};
|
|
116
128
|
readonly models?: {
|
|
117
129
|
/**
|
|
@@ -250,6 +262,7 @@ export interface SegmentStreamAgentConfig extends AdmissionSettings {
|
|
|
250
262
|
readonly telegram: TelegramSettings | null;
|
|
251
263
|
readonly whatsapp: WhatsAppSettings | null;
|
|
252
264
|
readonly slack: SlackSettings | null;
|
|
265
|
+
readonly email: EmailSettings | null;
|
|
253
266
|
};
|
|
254
267
|
readonly models: {
|
|
255
268
|
/**
|
|
@@ -320,6 +333,29 @@ export interface WhatsAppSettings {
|
|
|
320
333
|
export interface SlackSettings {
|
|
321
334
|
readonly connection: string;
|
|
322
335
|
}
|
|
336
|
+
/** The fewest and most minutes `checkAfterMinutes` may name, and its default. */
|
|
337
|
+
export declare const EMAIL_CHECK_MINUTES: {
|
|
338
|
+
readonly min: 10;
|
|
339
|
+
readonly max: 60;
|
|
340
|
+
readonly default: 10;
|
|
341
|
+
};
|
|
342
|
+
/** The mail that reaches the agent when `query` is absent. */
|
|
343
|
+
export declare const DEFAULT_EMAIL_QUERY = "in:inbox";
|
|
344
|
+
/** A Pub/Sub topic's full name, as Gmail's watch takes it. */
|
|
345
|
+
export declare const PUBSUB_TOPIC: RegExp;
|
|
346
|
+
/**
|
|
347
|
+
* The email channel: the mailbox of the workspace's `GmailConnection` answers the people who write
|
|
348
|
+
* to it. SegmentStream wakes the channel when Gmail pushes a change and at least every
|
|
349
|
+
* `checkAfterMinutes`; each wake reads what arrived since the last.
|
|
350
|
+
*/
|
|
351
|
+
export interface EmailSettings {
|
|
352
|
+
readonly connection: string;
|
|
353
|
+
readonly query: string;
|
|
354
|
+
readonly checkAfterMinutes: number;
|
|
355
|
+
readonly push: {
|
|
356
|
+
readonly topic: string;
|
|
357
|
+
} | null;
|
|
358
|
+
}
|
|
323
359
|
/**
|
|
324
360
|
* The chat model choice `agent.ts` passes to `segmentstream.model()`, validated like `models.chat`
|
|
325
361
|
* of `agent/segmentstream.json`, where it normally comes from.
|
|
@@ -177,6 +177,64 @@ function slackSettings(value, issues) {
|
|
|
177
177
|
}
|
|
178
178
|
return { connection: slack.connection };
|
|
179
179
|
}
|
|
180
|
+
const EMAIL_CHECK_MINUTES = {
|
|
181
|
+
min: 10,
|
|
182
|
+
max: 60,
|
|
183
|
+
default: 10
|
|
184
|
+
};
|
|
185
|
+
const DEFAULT_EMAIL_QUERY = "in:inbox";
|
|
186
|
+
const PUBSUB_TOPIC = /^projects\/[a-z][a-z0-9-]{4,28}[a-z0-9]\/topics\/[A-Za-z][A-Za-z0-9._~%+-]{2,254}$/;
|
|
187
|
+
function emailSettings(value, issues) {
|
|
188
|
+
const path = ["channels", "email"];
|
|
189
|
+
const email = section({
|
|
190
|
+
value,
|
|
191
|
+
path,
|
|
192
|
+
allowed: [
|
|
193
|
+
"connection",
|
|
194
|
+
"query",
|
|
195
|
+
"checkAfterMinutes",
|
|
196
|
+
"push"
|
|
197
|
+
],
|
|
198
|
+
issues
|
|
199
|
+
});
|
|
200
|
+
if (email === void 0) return null;
|
|
201
|
+
const before = issues.length;
|
|
202
|
+
if (typeof email.connection !== "string" || !CONNECTION_KEY.test(email.connection)) issues.push({
|
|
203
|
+
message: "must be a connection key such as gmail",
|
|
204
|
+
path: [...path, "connection"]
|
|
205
|
+
});
|
|
206
|
+
const query = email.query ?? "in:inbox";
|
|
207
|
+
if (typeof query !== "string" || query.trim() === "" || query.length > 1e3) issues.push({
|
|
208
|
+
message: "must be a Gmail search of at most 1000 characters",
|
|
209
|
+
path: [...path, "query"]
|
|
210
|
+
});
|
|
211
|
+
const minutes = email.checkAfterMinutes ?? EMAIL_CHECK_MINUTES.default;
|
|
212
|
+
if (typeof minutes !== "number" || !Number.isInteger(minutes) || minutes < EMAIL_CHECK_MINUTES.min || minutes > EMAIL_CHECK_MINUTES.max) issues.push({
|
|
213
|
+
message: `must be a whole number of minutes from ${EMAIL_CHECK_MINUTES.min} to ${EMAIL_CHECK_MINUTES.max}`,
|
|
214
|
+
path: [...path, "checkAfterMinutes"]
|
|
215
|
+
});
|
|
216
|
+
const push = section({
|
|
217
|
+
value: email.push,
|
|
218
|
+
path: [...path, "push"],
|
|
219
|
+
allowed: ["topic"],
|
|
220
|
+
issues
|
|
221
|
+
});
|
|
222
|
+
if (push !== void 0 && (typeof push.topic !== "string" || !PUBSUB_TOPIC.test(push.topic))) issues.push({
|
|
223
|
+
message: "must be a Pub/Sub topic such as projects/my-project/topics/gmail",
|
|
224
|
+
path: [
|
|
225
|
+
...path,
|
|
226
|
+
"push",
|
|
227
|
+
"topic"
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
if (issues.length > before) return null;
|
|
231
|
+
return {
|
|
232
|
+
connection: email.connection,
|
|
233
|
+
query: query.trim(),
|
|
234
|
+
checkAfterMinutes: minutes,
|
|
235
|
+
push: push === void 0 ? null : { topic: push.topic }
|
|
236
|
+
};
|
|
237
|
+
}
|
|
180
238
|
function telegramSettings(value, issues) {
|
|
181
239
|
const path = ["channels", "telegram"];
|
|
182
240
|
const telegram = section({
|
|
@@ -655,7 +713,8 @@ function validateConfig(input, options = {}) {
|
|
|
655
713
|
allowed: [
|
|
656
714
|
"telegram",
|
|
657
715
|
"whatsapp",
|
|
658
|
-
"slack"
|
|
716
|
+
"slack",
|
|
717
|
+
"email"
|
|
659
718
|
],
|
|
660
719
|
issues
|
|
661
720
|
});
|
|
@@ -690,6 +749,7 @@ function validateConfig(input, options = {}) {
|
|
|
690
749
|
const telegram = telegramSettings(channels?.telegram, issues);
|
|
691
750
|
const whatsapp = whatsappSettings(channels?.whatsapp, issues);
|
|
692
751
|
const slack = slackSettings(channels?.slack, issues);
|
|
752
|
+
const email = emailSettings(channels?.email, issues);
|
|
693
753
|
const authoredGroupsInput = currentGroupPolicyInput(root?.groups);
|
|
694
754
|
for (const issue of groupPolicyIssues(authoredGroupsInput)) issues.push({
|
|
695
755
|
...issue,
|
|
@@ -851,7 +911,8 @@ function validateConfig(input, options = {}) {
|
|
|
851
911
|
policy: groups.mode
|
|
852
912
|
},
|
|
853
913
|
whatsapp,
|
|
854
|
-
slack
|
|
914
|
+
slack,
|
|
915
|
+
email
|
|
855
916
|
},
|
|
856
917
|
models: {
|
|
857
918
|
chat,
|
|
@@ -893,4 +954,4 @@ function manifestOf(config) {
|
|
|
893
954
|
if (validation.issues !== void 0) throw new SegmentStreamAgentConfigError(validation.issues);
|
|
894
955
|
return validation.value;
|
|
895
956
|
}
|
|
896
|
-
export { ADMISSION_REPLY_KEYS, DEFAULT_ADMISSION_LIMITS, DEFAULT_ATTACHMENTS_MODEL, DEFAULT_DECISION_MODEL, DEFAULT_IMAGE_DESCRIPTION_MODEL, DEFAULT_STT_MODEL, SESSION_SCOPES, SegmentStreamAgentConfigError, TELEGRAM_POLICIES, chatModelChoiceOf, configSchema, configWarnings, isLegacyAgentArchive, manifestOf, validateConfig };
|
|
957
|
+
export { ADMISSION_REPLY_KEYS, DEFAULT_ADMISSION_LIMITS, DEFAULT_ATTACHMENTS_MODEL, DEFAULT_DECISION_MODEL, DEFAULT_EMAIL_QUERY, DEFAULT_IMAGE_DESCRIPTION_MODEL, DEFAULT_STT_MODEL, EMAIL_CHECK_MINUTES, PUBSUB_TOPIC, SESSION_SCOPES, SegmentStreamAgentConfigError, TELEGRAM_POLICIES, chatModelChoiceOf, configSchema, configWarnings, isLegacyAgentArchive, manifestOf, validateConfig };
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { D as ontologyConnection } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
9
9
|
import { defineDynamic } from "eve/connections";
|
|
10
10
|
var ontology_default = defineDynamic(async (context) => {
|
|
11
11
|
if (!segmentstream.config.ontology.connection) return null;
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
8
|
import { localizedText } from "../lib/admission.mjs";
|
|
9
9
|
import { confirmationLocale } from "../lib/telegram/confirmation-text.mjs";
|
|
10
|
-
import "../../_chunks/principal-
|
|
10
|
+
import "../../_chunks/principal-ie0lHCpn.mjs";
|
|
11
11
|
import { defineHook } from "eve/hooks";
|
|
12
12
|
var authorization_default = defineHook({ events: { "interaction.opened": (event, context) => {
|
|
13
13
|
const principal = context.session.auth.current;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import { a as rolesOf } from "../../_chunks/principal-
|
|
8
|
+
import { a as rolesOf } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
9
9
|
import { personaFor } from "../personas.mjs";
|
|
10
10
|
import { defineDynamic, defineInstructions } from "eve/instructions";
|
|
11
11
|
var persona_default = defineDynamic((context) => {
|
|
@@ -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 {
|
|
7
|
+
export { B as ACT_AS_HEADER, V as ActorRequiredError, H as actorHeaders, U as actorKey, W as actorOf, G as member, K as memberTool } from "../../_chunks/principal-ie0lHCpn.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 { S as agentAttachments, i as memberIdOf,
|
|
7
|
+
import { S as agentAttachments, i as memberIdOf, st as chatAddressOf } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
8
8
|
import { detectFile, documentText } from "./attachment-formats.mjs";
|
|
9
9
|
import { readSheets, typedTable } from "./attachment-tables.mjs";
|
|
10
10
|
import { appOrigin } from "./environment.mjs";
|
|
@@ -21,7 +21,7 @@ export declare const SESSION_HEADER = "X-SegmentStream-Agent-Session";
|
|
|
21
21
|
/** The URL protocol of a file part that names a stored attachment instead of a Telegram file. */
|
|
22
22
|
export declare const ATTACHMENT_URL_PROTOCOL = "segmentstream-attachment:";
|
|
23
23
|
/** Where an attachment comes from: a channel's message, or the agent's sandbox. */
|
|
24
|
-
export type AttachmentSource = "telegram" | "slack" | "whatsapp" | "sandbox";
|
|
24
|
+
export type AttachmentSource = "telegram" | "slack" | "whatsapp" | "email" | "sandbox";
|
|
25
25
|
/** Who asks for attachment access, from the turn: the member, chat and agent session. */
|
|
26
26
|
export interface AttachmentOwner {
|
|
27
27
|
readonly memberId: string;
|
|
@@ -105,3 +105,13 @@ export declare function parseAttachmentUrl(url: string): {
|
|
|
105
105
|
readonly memberId: string;
|
|
106
106
|
readonly chat: string;
|
|
107
107
|
} | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* A channel's `fetchFile` for the file parts {@link attachmentUrl} names: the attachment is read
|
|
110
|
+
* from the store as the member the URL names, for the session eve stages it in, which then owns
|
|
111
|
+
* it. `null` for any other URL, which the channel resolves itself or eve downloads.
|
|
112
|
+
*/
|
|
113
|
+
export declare function fetchStoredAttachment(attachments: AgentAttachments, url: string, context?: unknown): Promise<{
|
|
114
|
+
readonly bytes: Buffer;
|
|
115
|
+
readonly mediaType: string;
|
|
116
|
+
readonly filename: string;
|
|
117
|
+
} | null>;
|
|
@@ -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 { h as ATTACHMENT_TTL_HOURS, g as ATTACHMENT_URL_PROTOCOL, _ as AttachmentError, v as CHAT_HEADER, y as EARLIER_CHAT_HEADER, b as MAXIMUM_ATTACHMENT_BYTES, x as SESSION_HEADER, S as agentAttachments, C as attachmentUrl, w as parseAttachmentUrl } from "../../_chunks/principal-
|
|
7
|
+
export { h as ATTACHMENT_TTL_HOURS, g as ATTACHMENT_URL_PROTOCOL, _ as AttachmentError, v as CHAT_HEADER, y as EARLIER_CHAT_HEADER, b as MAXIMUM_ATTACHMENT_BYTES, x as SESSION_HEADER, S as agentAttachments, C as attachmentUrl, w as fetchStoredAttachment, T as parseAttachmentUrl } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
@@ -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-
|
|
7
|
+
export { t as agentBuild } from "../../_chunks/build-metadata-BDr_toej.mjs";
|
|
@@ -5,7 +5,7 @@ import type { SessionAuthContext } from "eve/context";
|
|
|
5
5
|
* there the member's id on the provider, which a private destination on that provider names.
|
|
6
6
|
*/
|
|
7
7
|
export interface ChatAddress {
|
|
8
|
-
readonly provider: "telegram" | "slack" | "whatsapp" | "web";
|
|
8
|
+
readonly provider: "telegram" | "slack" | "whatsapp" | "web" | "email";
|
|
9
9
|
readonly chatId: string;
|
|
10
10
|
/** `""` without a thread. */
|
|
11
11
|
readonly threadId: string;
|
|
@@ -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 {
|
|
7
|
+
export { ot as CHAT_ATTRIBUTE, st as chatAddressOf, ct as isSameChat, lt as withChatAddress } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { agentTaskIdOf } from "./agent-task.mjs";
|
|
8
8
|
import { chatCoordinates } from "./chat-recorder.mjs";
|
|
9
9
|
import { chatArchive, collapseChatEvents, topicContext } from "./chat-archive.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { vt as reportTelegramError } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { deliveries, runs, turns } from "eve/events";
|
|
13
13
|
import { defineState } from "eve/context";
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { n as contentText, t as CONTENT_CAPS } from "../../_chunks/content-cDtVnr8Y.mjs";
|
|
8
8
|
import { chatArchive, chatEvent, sessionFailureEventId, summarizeArguments } from "./chat-archive.mjs";
|
|
9
9
|
import { agentTaskIdOf } from "./agent-task.mjs";
|
|
10
|
-
import { i as memberIdOf,
|
|
10
|
+
import { i as memberIdOf, st as chatAddressOf } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
11
11
|
import { parseAddress } from "./telegram/sessions.mjs";
|
|
12
12
|
import { completionKind } from "./telegram/silent.mjs";
|
|
13
13
|
import { recordModelServiceAlert } from "./model-service-alert.mjs";
|
|
@@ -33,6 +33,14 @@ function chatCoordinates(context) {
|
|
|
33
33
|
participantIds: [webMemberId],
|
|
34
34
|
senderId: webMemberId
|
|
35
35
|
};
|
|
36
|
+
if (chat?.provider === "email" && webMemberId !== void 0) return {
|
|
37
|
+
provider: "email",
|
|
38
|
+
chatId: chat.chatId,
|
|
39
|
+
chatType: "private",
|
|
40
|
+
threadId: chat.threadId === "" ? null : chat.threadId,
|
|
41
|
+
participantIds: [webMemberId],
|
|
42
|
+
senderId: chat.peer ?? null
|
|
43
|
+
};
|
|
36
44
|
const telegram = principal?.authenticator === "segmentstream-telegram" || context.channel.kind?.includes("telegram");
|
|
37
45
|
const address = context.channel.continuationToken;
|
|
38
46
|
const attributes = principal?.attributes;
|
|
@@ -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 {
|
|
7
|
+
export { F as CONFIRMATION_TTL_MS, I as actionApproval, L as confirmations, R as inputHash, z as needsConfirmation } from "../../_chunks/principal-ie0lHCpn.mjs";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Channel, type ChannelEvents } from "eve/channels";
|
|
2
|
+
import type { SessionAuthContext } from "eve/context";
|
|
3
|
+
import { type AdmissionSettings, type EmailSettings, type SegmentStreamAgentConfig } from "../../config.js";
|
|
4
|
+
import type { ReviewSettings } from "../../review.js";
|
|
5
|
+
import { type AgentAttachments } from "../attachments.js";
|
|
6
|
+
import { type ChatArchive } from "../chat-archive.js";
|
|
7
|
+
import { type Environment } from "../environment.js";
|
|
8
|
+
import { type AgentIdentities, type PairedMember } from "../identities.js";
|
|
9
|
+
import { type CapabilityLookup } from "../inbound-media/plan.js";
|
|
10
|
+
import { type ImageDescriber } from "../inbound-media/images.js";
|
|
11
|
+
import { type Transcriber } from "../inbound-media/speech.js";
|
|
12
|
+
import { channelReview } from "../review/reply.js";
|
|
13
|
+
import type { ReviewDecideFunction } from "../review/judge.js";
|
|
14
|
+
import { type RuntimeToken } from "../runtime-token.js";
|
|
15
|
+
import { type Gmail } from "./gmail.js";
|
|
16
|
+
/**
|
|
17
|
+
* The email channel (`docs/agent.md`, "Email"). The mailbox of the workspace's `GmailConnection`
|
|
18
|
+
* answers the people who write to it. SegmentStream wakes the channel at `POST` {@link EMAIL_ROUTE}
|
|
19
|
+
* when Gmail pushes a change and at least every `checkAfterMinutes`, signing the request with the
|
|
20
|
+
* project's agent webhook secret. A wake carries the cursor the last one answered; the channel
|
|
21
|
+
* reads what the mailbox received since, starts a turn per message in the person's thread, and
|
|
22
|
+
* answers the next cursor. One Gmail thread is one chat with one person. The reply leaves in the
|
|
23
|
+
* same thread, or waits for a member when the person's review holds it.
|
|
24
|
+
*/
|
|
25
|
+
/** Where SegmentStream wakes the channel. */
|
|
26
|
+
export declare const EMAIL_ROUTE = "/eve/segmentstream/v1/email";
|
|
27
|
+
/** The authenticator of an email session's principal. */
|
|
28
|
+
export declare const EMAIL_AUTHENTICATOR = "segmentstream-email";
|
|
29
|
+
/**
|
|
30
|
+
* The longest cursor the platform keeps for a channel. A recovery's list of messages still to read
|
|
31
|
+
* fits it: 500 Gmail ids take about 9,500 characters.
|
|
32
|
+
*/
|
|
33
|
+
export declare const MAXIMUM_CURSOR_LENGTH = 16384;
|
|
34
|
+
export interface EmailChannelOptions {
|
|
35
|
+
readonly settings: () => EmailSettings | null;
|
|
36
|
+
readonly admission: () => AdmissionSettings;
|
|
37
|
+
readonly models?: () => SegmentStreamAgentConfig["models"];
|
|
38
|
+
readonly review?: {
|
|
39
|
+
readonly settings: () => ReviewSettings | undefined;
|
|
40
|
+
readonly decide: ReviewDecideFunction;
|
|
41
|
+
readonly model: () => string;
|
|
42
|
+
/** Tests pass an archive and a hold in place of the ontology's. */
|
|
43
|
+
readonly archive?: ChatArchive;
|
|
44
|
+
readonly hold?: Parameters<typeof channelReview>[0]["hold"];
|
|
45
|
+
};
|
|
46
|
+
readonly environment?: Environment;
|
|
47
|
+
readonly token?: RuntimeToken;
|
|
48
|
+
readonly fetch?: typeof fetch;
|
|
49
|
+
/** Tests pass fakes for the mailbox, the ontology's identities and attachments. */
|
|
50
|
+
readonly gmail?: Gmail;
|
|
51
|
+
readonly identities?: AgentIdentities;
|
|
52
|
+
readonly attachments?: AgentAttachments;
|
|
53
|
+
readonly transcribe?: Transcriber;
|
|
54
|
+
readonly describeImage?: ImageDescriber;
|
|
55
|
+
/** What each chat model reads natively; tests pass a fake. */
|
|
56
|
+
readonly modelCapabilities?: CapabilityLookup;
|
|
57
|
+
readonly log?: (message: string, detail: unknown) => void;
|
|
58
|
+
readonly now?: () => number;
|
|
59
|
+
/** Waits between attempts to send a reply; tests pass one that does not wait. */
|
|
60
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One person's private chat in a Gmail thread: the thread and the sender's address. Two people who
|
|
64
|
+
* write in the same thread have a chat and a session each, as replies reach only their sender.
|
|
65
|
+
*/
|
|
66
|
+
export declare function emailChatId(threadId: string, sender: string): string;
|
|
67
|
+
/** The principal of an email session: the member who writes from the address. */
|
|
68
|
+
export declare function emailPrincipal(member: PairedMember, sender: string, threadId: string): SessionAuthContext;
|
|
69
|
+
/** The email channel of the extension. */
|
|
70
|
+
export declare function segmentstreamEmail(options: EmailChannelOptions): Channel;
|
|
71
|
+
/** The email channel's route and events, which {@link segmentstreamEmail} defines as a channel. */
|
|
72
|
+
export declare function emailChannelDefinition(options: EmailChannelOptions): {
|
|
73
|
+
routes: import("eve/channels").HttpRouteDefinition<unknown>[];
|
|
74
|
+
events: ChannelEvents;
|
|
75
|
+
fetchFile: (url: string, context?: unknown) => Promise<{
|
|
76
|
+
readonly bytes: Buffer;
|
|
77
|
+
readonly mediaType: string;
|
|
78
|
+
readonly filename: string;
|
|
79
|
+
} | null>;
|
|
80
|
+
};
|