@segmentstream/agent 0.88.1 → 0.89.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/CHANGELOG.md +13 -0
- package/dist/_chunks/{build-metadata-Djjj4OeZ.mjs → build-metadata-CAvJnFt2.mjs} +1 -1
- package/dist/extension/config.d.ts +2 -0
- package/dist/extension/config.mjs +8 -2
- package/dist/extension/lib/attachments-dispatch.mjs +2 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/email/attachments-send.d.ts +2 -0
- package/dist/extension/lib/email/attachments-send.mjs +1 -0
- package/dist/extension/lib/email/channel.mjs +5 -2
- package/dist/extension/lib/email/gmail.d.ts +3 -1
- package/dist/extension/lib/email/gmail.mjs +10 -2
- package/dist/extension/lib/telegram/adapter.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.89.0
|
|
4
|
+
|
|
5
|
+
The email channel takes `signature: true` in `agent/segmentstream.json`: each reply the agent
|
|
6
|
+
sends from the mailbox, files included, ends its HTML with the mailbox's own signature, as its
|
|
7
|
+
owner set it in Gmail, read through the channel's connection and kept for 10 minutes per mailbox.
|
|
8
|
+
A reply whose signature Gmail refuses to read goes unsigned. Off when absent.
|
|
9
|
+
|
|
10
|
+
Pins @segmentstream/ontology 0.168.0.
|
|
11
|
+
|
|
12
|
+
## 0.88.2
|
|
13
|
+
|
|
14
|
+
Pins @segmentstream/ontology 0.167.0.
|
|
15
|
+
|
|
3
16
|
## 0.88.1
|
|
4
17
|
|
|
5
18
|
Pins @segmentstream/ontology 0.166.1.
|
|
@@ -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.89.0";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -643,6 +643,8 @@ export interface EmailSettings {
|
|
|
643
643
|
readonly reply?: "all";
|
|
644
644
|
/** `thread` when a Gmail thread is one chat; absent, each person has their own in it. */
|
|
645
645
|
readonly chats?: "thread";
|
|
646
|
+
/** `true` when the agent's replies end with the mailbox's own signature; absent, they do not. */
|
|
647
|
+
readonly signature?: true;
|
|
646
648
|
}
|
|
647
649
|
/**
|
|
648
650
|
* A channel the workspace defines in its own code (`defineChannel`): the connection its code calls
|
|
@@ -425,7 +425,8 @@ function emailSettings(value, issues, path = ["channels", "email"]) {
|
|
|
425
425
|
"record",
|
|
426
426
|
"recordQuery",
|
|
427
427
|
"reply",
|
|
428
|
-
"chats"
|
|
428
|
+
"chats",
|
|
429
|
+
"signature"
|
|
429
430
|
],
|
|
430
431
|
issues
|
|
431
432
|
});
|
|
@@ -486,6 +487,10 @@ function emailSettings(value, issues, path = ["channels", "email"]) {
|
|
|
486
487
|
message: "needs reply \"all\": a thread's chat is everyone's in it",
|
|
487
488
|
path: [...path, "chats"]
|
|
488
489
|
});
|
|
490
|
+
if (email.signature !== void 0 && typeof email.signature !== "boolean") issues.push({
|
|
491
|
+
message: "must be true or false",
|
|
492
|
+
path: [...path, "signature"]
|
|
493
|
+
});
|
|
489
494
|
if (issues.length > before) return null;
|
|
490
495
|
return {
|
|
491
496
|
connection: email.connection,
|
|
@@ -497,7 +502,8 @@ function emailSettings(value, issues, path = ["channels", "email"]) {
|
|
|
497
502
|
...email.recordQuery === void 0 ? {} : { recordQuery: email.recordQuery.trim() }
|
|
498
503
|
} : {},
|
|
499
504
|
...reply === "all" ? { reply: "all" } : {},
|
|
500
|
-
...chats === "thread" ? { chats: "thread" } : {}
|
|
505
|
+
...chats === "thread" ? { chats: "thread" } : {},
|
|
506
|
+
...email.signature === true ? { signature: true } : {}
|
|
501
507
|
};
|
|
502
508
|
}
|
|
503
509
|
function telegramSettings(value, issues, path = ["channels", "telegram"]) {
|
|
@@ -31,7 +31,8 @@ async function sendStoredFiles(input) {
|
|
|
31
31
|
...options,
|
|
32
32
|
callId: input.callId,
|
|
33
33
|
connection: channelOf(channels, "email", name)?.connection,
|
|
34
|
-
cc: replyCopies(principal, channelOf(channels, "email", name))
|
|
34
|
+
cc: replyCopies(principal, channelOf(channels, "email", name)),
|
|
35
|
+
signature: channelOf(channels, "email", name)?.signature === true
|
|
35
36
|
});
|
|
36
37
|
if (provider === "whatsapp") return sendWhatsAppAttachments({
|
|
37
38
|
...options,
|
|
@@ -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-CAvJnFt2.mjs";
|
|
@@ -36,6 +36,8 @@ export declare function sendEmailAttachments(options: {
|
|
|
36
36
|
readonly connection: string | undefined;
|
|
37
37
|
/** The thread's other people the reply copies, as the channel's text replies do. */
|
|
38
38
|
readonly cc?: ReadonlyArray<string>;
|
|
39
|
+
/** Whether the reply ends with the mailbox's own signature, as the channel's text replies do. */
|
|
40
|
+
readonly signature?: boolean;
|
|
39
41
|
readonly environment?: Environment;
|
|
40
42
|
readonly token?: RuntimeToken;
|
|
41
43
|
readonly fetch?: typeof fetch;
|
|
@@ -106,6 +106,7 @@ async function sendEmailAttachments(options) {
|
|
|
106
106
|
...options.cc === void 0 || options.cc.length === 0 ? {} : { cc: options.cc },
|
|
107
107
|
text: input.caption ?? "",
|
|
108
108
|
key: replyKeyOf(options.sessionId, options.callId, "files"),
|
|
109
|
+
...options.signature === true ? { signature: true } : {},
|
|
109
110
|
attachments: read.map(({ file }) => ({
|
|
110
111
|
filename: file.filename,
|
|
111
112
|
contentType: file.contentType,
|
|
@@ -237,6 +237,7 @@ function emailChannelDefinition(options) {
|
|
|
237
237
|
environment,
|
|
238
238
|
...transport
|
|
239
239
|
});
|
|
240
|
+
const withSignature = () => settings()?.signature === true ? { signature: true } : {};
|
|
240
241
|
const archive = () => chats ??= chatArchive({
|
|
241
242
|
environment,
|
|
242
243
|
...transport
|
|
@@ -244,7 +245,8 @@ function emailChannelDefinition(options) {
|
|
|
244
245
|
const answer = (threadId, to, text) => mailbox().reply({
|
|
245
246
|
threadId,
|
|
246
247
|
to,
|
|
247
|
-
text
|
|
248
|
+
text,
|
|
249
|
+
...withSignature()
|
|
248
250
|
});
|
|
249
251
|
async function deliver(reply, attempts) {
|
|
250
252
|
for (let attempt = 1;; attempt++) try {
|
|
@@ -253,7 +255,8 @@ function emailChannelDefinition(options) {
|
|
|
253
255
|
to: reply.to,
|
|
254
256
|
...reply.cc.length === 0 ? {} : { cc: reply.cc },
|
|
255
257
|
text: reply.text,
|
|
256
|
-
key: reply.key
|
|
258
|
+
key: reply.key,
|
|
259
|
+
...withSignature()
|
|
257
260
|
});
|
|
258
261
|
} catch (error) {
|
|
259
262
|
if (!retryable(error) || attempt >= attempts) throw error;
|
|
@@ -70,7 +70,8 @@ export interface Gmail {
|
|
|
70
70
|
* Markdown as HTML and as plain text and the files after it, marked
|
|
71
71
|
* `Auto-Submitted: auto-replied`. Resolves the sent message's id. With `key`, a message in the
|
|
72
72
|
* thread that already carries it is the reply, sent by an earlier attempt whose answer was lost:
|
|
73
|
-
* its id is returned and nothing is sent.
|
|
73
|
+
* its id is returned and nothing is sent. With `signature`, the HTML ends with the mailbox's own
|
|
74
|
+
* signature, read from Gmail and kept a while per mailbox; a refused read sends it unsigned.
|
|
74
75
|
*/
|
|
75
76
|
reply(input: {
|
|
76
77
|
readonly threadId: string;
|
|
@@ -80,6 +81,7 @@ export interface Gmail {
|
|
|
80
81
|
readonly text: string;
|
|
81
82
|
readonly key?: string;
|
|
82
83
|
readonly attachments?: ReadonlyArray<EmailAttachment>;
|
|
84
|
+
readonly signature?: boolean;
|
|
83
85
|
}): Promise<string>;
|
|
84
86
|
}
|
|
85
87
|
export declare function gmail(proxy: () => ConnectionProxy): Gmail;
|
|
@@ -4,8 +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 { redactDiagnostic } from "../diagnostics.mjs";
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
|
-
import { GmailError, REPLY_KEY_HEADER, emailReplyMessage, gmailExplanation, renderEmailHtml, sendGmailMessage } from "@segmentstream/ontology/email";
|
|
9
|
+
import { GmailError, REPLY_KEY_HEADER, emailReplyMessage, gmailExplanation, mailboxSignature, renderEmailHtml, sendGmailMessage, withEmailSignature } from "@segmentstream/ontology/email";
|
|
9
10
|
const GMAIL_ID = /^[A-Za-z0-9_-]{1,512}$/;
|
|
10
11
|
function replyKeyOf(...parts) {
|
|
11
12
|
return createHash("sha256").update(parts.join(":")).digest("base64url").slice(0, 32);
|
|
@@ -178,6 +179,13 @@ function gmail(proxy) {
|
|
|
178
179
|
const id = text(sent?.id);
|
|
179
180
|
if (sent !== void 0) return id ?? "";
|
|
180
181
|
}
|
|
182
|
+
const html = renderEmailHtml(input.text);
|
|
183
|
+
const signature = input.signature === true ? await mailboxSignature({
|
|
184
|
+
mailbox: proxy().connection,
|
|
185
|
+
request: (call) => proxy().request(call)
|
|
186
|
+
}).catch((error) => {
|
|
187
|
+
console.warn("[segmentstream] email signature unavailable", { error: redactDiagnostic(error, new Set()) });
|
|
188
|
+
}) : void 0;
|
|
181
189
|
const raw = emailReplyMessage({
|
|
182
190
|
to: input.to,
|
|
183
191
|
...input.cc === void 0 || input.cc.length === 0 ? {} : { cc: input.cc },
|
|
@@ -185,7 +193,7 @@ function gmail(proxy) {
|
|
|
185
193
|
inReplyTo: header(messages.at(-1), "Message-ID") ?? null,
|
|
186
194
|
references: header(messages.at(-1), "References") ?? null,
|
|
187
195
|
text: input.text,
|
|
188
|
-
html:
|
|
196
|
+
html: withEmailSignature(html, signature),
|
|
189
197
|
autoSubmitted: true,
|
|
190
198
|
...input.key === void 0 ? {} : { replyKey: input.key },
|
|
191
199
|
...input.attachments === void 0 || input.attachments.length === 0 ? {} : { attachments: input.attachments }
|
|
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback } from "./callbacks.mjs";
|
|
12
12
|
import { telegramText, withTelegramTexts } from "./texts.mjs";
|
|
13
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
13
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-CAvJnFt2.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-
|
|
7
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-CAvJnFt2.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 { E as OntologyActionNotPermitted, Et as principalRuntimeSource, L as needsConfirmation, Ot as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName, kt as telegramRuntimeSource } from "../../../_chunks/principal-h5knGNwo.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-CAvJnFt2.mjs";
|
|
9
9
|
import { object } from "../confirmation-description.mjs";
|
|
10
10
|
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
11
11
|
code = "attachment_lifecycle_not_permitted";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0",
|
|
4
4
|
"description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@chat-adapter/state-memory": "4.42.0",
|
|
89
89
|
"@chat-adapter/telegram": "4.41.0",
|
|
90
90
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
91
|
-
"@segmentstream/ontology": "0.
|
|
91
|
+
"@segmentstream/ontology": "0.168.0",
|
|
92
92
|
"@vercel/oidc": "^3.8.4",
|
|
93
93
|
"ai": "^7.0.172",
|
|
94
94
|
"chat": "4.42.0",
|