@segmentstream/agent 0.76.1 → 0.77.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 +10 -0
- package/dist/_chunks/{build-metadata-rKN9hmJm.mjs → build-metadata-DeFy9vS5.mjs} +1 -1
- package/dist/extension/lib/admission.d.ts +12 -0
- package/dist/extension/lib/admission.mjs +7 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/email/channel.mjs +29 -10
- 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,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.77.1
|
|
4
|
+
|
|
5
|
+
Pins @segmentstream/ontology 0.153.1.
|
|
6
|
+
|
|
7
|
+
## 0.77.0
|
|
8
|
+
|
|
9
|
+
An email channel with `record: "all"` takes the mailbox's chats into the inbox. A verified sender's chat that has no member joins the inbox without members when the ontology's `inbox.channels` lists the channel, which may now name an email channel. Mail that failed DMARC never joins. Mail staff send from the mailbox is recorded in each recipient's chat, including a chat the agent has none of yet, when `recordQuery`, if any, finds it.
|
|
10
|
+
|
|
11
|
+
Pins @segmentstream/ontology 0.153.0.
|
|
12
|
+
|
|
3
13
|
## 0.76.1
|
|
4
14
|
|
|
5
15
|
`agent_chat.importHistory` writes a chat's earlier history into the workspace's own database once
|
|
@@ -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.77.1";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -11,6 +11,18 @@ export interface AdmittedChat {
|
|
|
11
11
|
/** Whom a reply is sent to, where it differs from the chat's id. */
|
|
12
12
|
readonly recipient?: string;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Reports the private chat of someone the channel recorded without admitting them, such as mail
|
|
16
|
+
* the agent does not take on a mailbox it records, so that the inbox registers it without members
|
|
17
|
+
* where the ontology's `inbox.channels` lists the channel. At most every few minutes per chat; a
|
|
18
|
+
* failure only goes to `failed`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reportUnadmittedChat(input: {
|
|
21
|
+
readonly identity: ResolveIdentityInput;
|
|
22
|
+
readonly identities: AgentIdentities;
|
|
23
|
+
readonly chat: AdmittedChat;
|
|
24
|
+
readonly failed?: (error: unknown) => void;
|
|
25
|
+
}): Promise<void>;
|
|
14
26
|
/**
|
|
15
27
|
* Channel-independent admission and at-least-once versioned notice delivery. A private chat a
|
|
16
28
|
* member of staff took over comes back `handled`: the channel records the message with
|
|
@@ -56,6 +56,12 @@ async function reportInboxChat(input) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
async function reportUnadmittedChat(input) {
|
|
60
|
+
await reportInboxChat({
|
|
61
|
+
...input,
|
|
62
|
+
every: false
|
|
63
|
+
});
|
|
64
|
+
}
|
|
59
65
|
function noUser(resolution) {
|
|
60
66
|
return resolution.status === "pairing_required" || resolution.status === "limited" && resolution.scope === "newUsersPerHour";
|
|
61
67
|
}
|
|
@@ -105,4 +111,4 @@ async function admitMessage(input) {
|
|
|
105
111
|
});
|
|
106
112
|
return resolved;
|
|
107
113
|
}
|
|
108
|
-
export { admitMessage, localizedText };
|
|
114
|
+
export { admitMessage, localizedText, reportUnadmittedChat };
|
|
@@ -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-DeFy9vS5.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { PUBSUB_TOPIC } from "../../config.mjs";
|
|
8
|
-
import { admitMessage, localizedText } from "../admission.mjs";
|
|
8
|
+
import { admitMessage, localizedText, reportUnadmittedChat } from "../admission.mjs";
|
|
9
9
|
import { agentToolsAttribute } from "../agent-tools.mjs";
|
|
10
10
|
import { providerChat } from "../attachment-tools.mjs";
|
|
11
11
|
import { Pt as chatAddressOf, S as fetchStoredAttachment, b as agentAttachments, d as prepareInboundMedia, i as memberIdOf, m as turnContent, zt as withChatAddress } from "../../../_chunks/principal-C7aAjyt4.mjs";
|
|
@@ -464,7 +464,7 @@ function emailChannelDefinition(options) {
|
|
|
464
464
|
...media.context.length === 0 ? {} : { context: media.context }
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
|
-
async function recordSent(id, own, known) {
|
|
467
|
+
async function recordSent(id, own, current, known) {
|
|
468
468
|
const gmail = mailbox();
|
|
469
469
|
let threadId = known?.threadId;
|
|
470
470
|
if (known === void 0) {
|
|
@@ -482,6 +482,7 @@ function emailChannelDefinition(options) {
|
|
|
482
482
|
}
|
|
483
483
|
const mail = sentMail(parsed, own);
|
|
484
484
|
if (mail.automated || parsed.headers.some((header) => header.key === REPLY_KEY_HEADER.toLowerCase()) || threadId === void 0 || mail.text === "" && mail.attachments.length === 0) return;
|
|
485
|
+
const record = current.record === "all" && (current.recordQuery === void 0 || await finds(current.recordQuery, id, parsed.messageId)) ? "all" : "agent";
|
|
485
486
|
for (const recipient of mail.recipients) await recordSentOutside(archive(), {
|
|
486
487
|
provider: currentChannel("email"),
|
|
487
488
|
chatId: emailChatId(threadId, recipient),
|
|
@@ -497,16 +498,16 @@ function emailChannelDefinition(options) {
|
|
|
497
498
|
mimeType: file.contentType,
|
|
498
499
|
size: file.size
|
|
499
500
|
}))
|
|
500
|
-
});
|
|
501
|
+
}, { record });
|
|
501
502
|
}
|
|
502
|
-
async function finds(query, id,
|
|
503
|
-
if (
|
|
504
|
-
return (await mailbox().search(`(${query}) rfc822msgid:${
|
|
503
|
+
async function finds(query, id, messageId) {
|
|
504
|
+
if (messageId === void 0) return false;
|
|
505
|
+
return (await mailbox().search(`(${query}) rfc822msgid:${messageId.replace(/[<>"]/gu, "")}`, 5)).includes(id);
|
|
505
506
|
}
|
|
506
507
|
async function recordSkipped(current, message, mail, reason) {
|
|
507
508
|
if (current.record !== "all") return;
|
|
508
509
|
const store = await storeOf(archive());
|
|
509
|
-
if (store === void 0 || current.recordQuery !== void 0 && !await finds(current.recordQuery, message.id, mail)) return;
|
|
510
|
+
if (store === void 0 || current.recordQuery !== void 0 && !await finds(current.recordQuery, message.id, mail.messageId)) return;
|
|
510
511
|
const chat = {
|
|
511
512
|
channel: currentChannel("email"),
|
|
512
513
|
chatId: emailChatId(message.threadId, mail.from),
|
|
@@ -544,13 +545,31 @@ function emailChannelDefinition(options) {
|
|
|
544
545
|
disposition: "skipped",
|
|
545
546
|
reason
|
|
546
547
|
});
|
|
548
|
+
if (!unverified && (latest === void 0 || latest.participantIds.length === 0)) await reportUnadmittedChat({
|
|
549
|
+
identity: {
|
|
550
|
+
provider: "email",
|
|
551
|
+
externalId: mail.from,
|
|
552
|
+
chat: "private",
|
|
553
|
+
turn: false,
|
|
554
|
+
addressVerified: true,
|
|
555
|
+
...mail.fromName === void 0 ? {} : { display: mail.fromName }
|
|
556
|
+
},
|
|
557
|
+
identities: people(),
|
|
558
|
+
chat: {
|
|
559
|
+
channel: chat.channel,
|
|
560
|
+
chatId: chat.chatId,
|
|
561
|
+
threadId: message.threadId,
|
|
562
|
+
recipient: mail.from
|
|
563
|
+
},
|
|
564
|
+
failed: (error) => log("[segmentstream] email inbox report failed", { error: redactDiagnostic(error, new Set()) })
|
|
565
|
+
});
|
|
547
566
|
}
|
|
548
567
|
async function handle(added, restarted, own, current, args) {
|
|
549
568
|
if (added.labelIds.some((label) => DISCARDED.has(label))) return;
|
|
550
|
-
if (added.labelIds.includes("SENT")) return recordSent(added.id, own);
|
|
569
|
+
if (added.labelIds.includes("SENT")) return recordSent(added.id, own, current);
|
|
551
570
|
const raw = await mailbox().raw(added.id);
|
|
552
571
|
if (raw.labelIds.some((label) => DISCARDED.has(label))) return;
|
|
553
|
-
if (raw.labelIds.includes("SENT")) return recordSent(added.id, own, raw);
|
|
572
|
+
if (raw.labelIds.includes("SENT")) return recordSent(added.id, own, current, raw);
|
|
554
573
|
let parsed;
|
|
555
574
|
try {
|
|
556
575
|
parsed = await parseMail(raw.bytes);
|
|
@@ -566,7 +585,7 @@ function emailChannelDefinition(options) {
|
|
|
566
585
|
if (mail.skip === "no_sender" || mail.skip === "own_address") return;
|
|
567
586
|
if (!mail.verified) return skipped(UNVERIFIED);
|
|
568
587
|
if (mail.skip !== void 0) return skipped(mail.skip);
|
|
569
|
-
if (!restarted && !await finds(current.query, added.id, mail)) return skipped("not_addressed");
|
|
588
|
+
if (!restarted && !await finds(current.query, added.id, mail.messageId)) return skipped("not_addressed");
|
|
570
589
|
await dispatch(message, mail, args, skipped);
|
|
571
590
|
}
|
|
572
591
|
async function wake(request, args) {
|
|
@@ -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-DeFy9vS5.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-DeFy9vS5.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-C7aAjyt4.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-DeFy9vS5.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.77.1",
|
|
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",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@chat-adapter/state-memory": "4.42.0",
|
|
85
85
|
"@chat-adapter/telegram": "4.41.0",
|
|
86
86
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
87
|
-
"@segmentstream/ontology": "0.
|
|
87
|
+
"@segmentstream/ontology": "0.153.1",
|
|
88
88
|
"@vercel/oidc": "^3.8.4",
|
|
89
89
|
"ai": "^7.0.172",
|
|
90
90
|
"chat": "4.42.0",
|