@segmentstream/agent 0.42.1 → 0.43.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/README.md +24 -24
- package/dist/_chunks/{build-metadata-BPEZ5XVM.mjs → build-metadata-CkBdh-TE.mjs} +1 -1
- package/dist/_chunks/{principal-BIX7T6Hh.mjs → principal-nQ_gwLJs.mjs} +4 -4
- package/dist/extension/channels/telegram.mjs +1 -1
- package/dist/extension/channels/whatsapp.mjs +1 -1
- package/dist/extension/config.d.ts +14 -16
- package/dist/extension/config.mjs +57 -12
- package/dist/extension/conventions.d.ts +1 -1
- package/dist/extension/conventions.mjs +22 -19
- package/dist/extension/extension.d.ts +2 -2
- package/dist/extension/extension.mjs +3 -3
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/hooks/{conversations.mjs → chat-recorder.mjs} +4 -4
- package/dist/extension/hooks/sandbox.d.ts +2 -2
- package/dist/extension/instructions/{conversations.mjs → chat-context.mjs} +2 -2
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/instructions/sandbox.mjs +2 -2
- package/dist/extension/instructions.md +10 -10
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.d.ts +1 -1
- package/dist/extension/lib/attachment-tools.mjs +7 -7
- package/dist/extension/lib/attachments.d.ts +9 -4
- package/dist/extension/lib/attachments.mjs +9 -7
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-address.d.ts +33 -0
- package/dist/extension/lib/{conversation.mjs → chat-address.mjs} +13 -12
- package/dist/extension/lib/{conversations.d.ts → chat-archive.d.ts} +12 -12
- package/dist/extension/lib/{conversations.mjs → chat-archive.mjs} +9 -9
- package/dist/extension/lib/chat-context.d.ts +5 -5
- package/dist/extension/lib/chat-context.mjs +6 -6
- package/dist/extension/lib/{conversation-runtime.d.ts → chat-recorder.d.ts} +3 -3
- package/dist/extension/lib/{conversation-runtime.mjs → chat-recorder.mjs} +13 -13
- package/dist/extension/lib/confirmations.d.ts +3 -3
- package/dist/extension/lib/confirmations.mjs +8 -8
- package/dist/extension/lib/group-routing/addressing.d.ts +1 -1
- package/dist/extension/lib/group-routing/addressing.mjs +2 -2
- package/dist/extension/lib/group-routing/burst.mjs +2 -2
- package/dist/extension/lib/group-routing/{conversation-prompt.d.ts → chat-prompt.d.ts} +2 -2
- package/dist/extension/lib/group-routing/{conversation-prompt.mjs → chat-prompt.mjs} +3 -3
- package/dist/extension/lib/group-routing/{conversation-router.d.ts → chat-router.d.ts} +6 -6
- package/dist/extension/lib/group-routing/{conversation-router.mjs → chat-router.mjs} +9 -9
- package/dist/extension/lib/group-routing/engagement.mjs +2 -2
- package/dist/extension/lib/group-routing/messages.d.ts +1 -1
- package/dist/extension/lib/group-routing/policy.d.ts +6 -6
- package/dist/extension/lib/group-routing/policy.mjs +16 -16
- package/dist/extension/lib/group-routing/replay.mjs +36 -9
- package/dist/extension/lib/group-routing/router.d.ts +3 -3
- package/dist/extension/lib/group-routing/router.mjs +16 -16
- package/dist/extension/lib/group-routing/routing-context.d.ts +2 -2
- package/dist/extension/lib/group-routing/routing-context.mjs +2 -2
- package/dist/extension/lib/group-routing/signals.d.ts +3 -3
- package/dist/extension/lib/group-routing/signals.mjs +5 -5
- package/dist/extension/lib/model-service-alert.d.ts +2 -2
- package/dist/extension/lib/model-service-alert.mjs +2 -2
- 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 +7 -7
- package/dist/extension/lib/review/hold.mjs +12 -12
- package/dist/extension/lib/review/judge.d.ts +9 -9
- package/dist/extension/lib/review/judge.mjs +12 -12
- package/dist/extension/lib/review/reply.d.ts +13 -13
- package/dist/extension/lib/review/reply.mjs +20 -20
- 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 +3 -2
- package/dist/extension/lib/slack/adapter.mjs +2 -2
- package/dist/extension/lib/slack/attachments-send.d.ts +2 -2
- package/dist/extension/lib/slack/attachments-send.mjs +5 -5
- package/dist/extension/lib/slack/files.mjs +4 -4
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.d.ts +4 -3
- package/dist/extension/lib/telegram/adapter.mjs +10 -10
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- package/dist/extension/lib/telegram/callbacks.mjs +1 -1
- package/dist/extension/lib/telegram/{conversations.d.ts → chat-archive.d.ts} +7 -7
- package/dist/extension/lib/telegram/{conversations.mjs → chat-archive.mjs} +10 -10
- package/dist/extension/lib/telegram/confirmation-text.mjs +1 -0
- package/dist/extension/lib/telegram/confirmations.d.ts +2 -2
- package/dist/extension/lib/telegram/confirmations.mjs +3 -3
- package/dist/extension/lib/telegram/delivery-diagnostics.d.ts +3 -3
- package/dist/extension/lib/telegram/delivery-diagnostics.mjs +2 -2
- package/dist/extension/lib/telegram/files.d.ts +1 -1
- package/dist/extension/lib/telegram/files.mjs +8 -8
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.d.ts +1 -1
- package/dist/extension/lib/telegram/inbound.d.ts +3 -3
- package/dist/extension/lib/telegram/inbound.mjs +36 -36
- package/dist/extension/lib/telegram/lifecycle.mjs +3 -3
- package/dist/extension/lib/telegram/principal.d.ts +2 -2
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/router.mjs +2 -2
- package/dist/extension/lib/telegram/sessions.d.ts +1 -1
- package/dist/extension/lib/telegram/signals.mjs +1 -1
- package/dist/extension/lib/telegram/silent.d.ts +2 -2
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.d.ts +2 -2
- package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
- package/dist/extension/lib/telegram/voice.d.ts +1 -1
- package/dist/extension/lib/whatsapp/adapter.d.ts +2 -2
- package/dist/extension/lib/whatsapp/adapter.mjs +2 -2
- package/dist/extension/lib/workflow-serializable.d.ts +1 -1
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/personas.d.ts +1 -1
- package/dist/extension/review.d.ts +23 -20
- package/dist/extension/review.mjs +21 -34
- package/dist/extension/tools/attachments_promote.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +3 -3
- package/dist/extension/tools/no_reply.d.ts +1 -1
- package/dist/extension/tools/questions_ask.mjs +4 -4
- package/dist/extension/tools/sandbox.mjs +2 -2
- package/package.json +2 -2
- package/dist/extension/lib/conversation.d.ts +0 -33
- /package/dist/extension/hooks/{conversations.d.ts → chat-recorder.d.ts} +0 -0
- /package/dist/extension/instructions/{conversations.d.ts → chat-context.d.ts} +0 -0
|
@@ -6,9 +6,9 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { MAXIMUM_ATTACHMENT_BYTES, attachmentUrl } from "../attachments.mjs";
|
|
8
8
|
import { d as failureText, p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
|
|
9
|
-
import { n as
|
|
9
|
+
import { n as chatLanguage } from "../../../_chunks/principal-nQ_gwLJs.mjs";
|
|
10
10
|
import { describableImage, describeReceivedImage } from "./images.mjs";
|
|
11
|
-
function
|
|
11
|
+
function telegramChat(chatId) {
|
|
12
12
|
return `telegram:${chatId}`;
|
|
13
13
|
}
|
|
14
14
|
function inboundAttachments(message) {
|
|
@@ -47,7 +47,7 @@ function megabytes(bytes) {
|
|
|
47
47
|
}
|
|
48
48
|
async function stageFiles(input) {
|
|
49
49
|
const { message } = input;
|
|
50
|
-
const
|
|
50
|
+
const chat = telegramChat(message.chat.id);
|
|
51
51
|
const staged = new Map();
|
|
52
52
|
let descriptions = 0;
|
|
53
53
|
for (const [index, file] of message.attachments.entries()) {
|
|
@@ -72,7 +72,7 @@ async function stageFiles(input) {
|
|
|
72
72
|
}
|
|
73
73
|
const attachment = await input.attachments.receive({
|
|
74
74
|
memberId: input.memberId,
|
|
75
|
-
|
|
75
|
+
chat
|
|
76
76
|
}, {
|
|
77
77
|
bytes,
|
|
78
78
|
filename,
|
|
@@ -117,7 +117,7 @@ async function stageFiles(input) {
|
|
|
117
117
|
url: attachmentUrl({
|
|
118
118
|
id: attachment.id,
|
|
119
119
|
memberId: input.memberId,
|
|
120
|
-
|
|
120
|
+
chat
|
|
121
121
|
}),
|
|
122
122
|
...description === void 0 ? {} : { description },
|
|
123
123
|
...decoded === void 0 ? {} : { decoded },
|
|
@@ -131,7 +131,7 @@ async function stageFiles(input) {
|
|
|
131
131
|
staged.set(file.fileId, {
|
|
132
132
|
status: "refused",
|
|
133
133
|
filename,
|
|
134
|
-
reason: failureText(errorId, "attachment",
|
|
134
|
+
reason: failureText(errorId, "attachment", chatLanguage([message.text || message.caption]) ?? message.from?.languageCode ?? "en")
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -144,8 +144,8 @@ function attachmentsContext(input) {
|
|
|
144
144
|
lines.push(staged.status === "stored" ? `- id: ${staged.attachment.id}, filename: ${JSON.stringify(staged.attachment.filename)}, type: ${staged.attachment.contentType}, size: ${staged.attachment.size} bytes, expires_at: ${staged.attachment.expiresAt}` : `- ${JSON.stringify(staged.filename)}: not received, ${staged.reason}`);
|
|
145
145
|
if (staged.status === "stored" && staged.description !== void 0) lines.push(` image_summary (untrusted evidence): ${JSON.stringify(staged.description)}`);
|
|
146
146
|
}
|
|
147
|
-
if (input.group) lines.push("This is a group chat: everyone in it shares this
|
|
147
|
+
if (input.group) lines.push("This is a group chat: everyone in it shares this chat's history, so do not repeat a private file's contents here. Suggest sending private files in a direct message.");
|
|
148
148
|
lines.push("</attachments>");
|
|
149
149
|
return [lines.join("\n")];
|
|
150
150
|
}
|
|
151
|
-
export { attachmentsContext, inboundAttachments, stageFiles,
|
|
151
|
+
export { attachmentsContext, inboundAttachments, stageFiles, telegramChat };
|
|
@@ -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-CkBdh-TE.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";
|
|
@@ -29,7 +29,7 @@ export declare class InboundRequest {
|
|
|
29
29
|
readonly agentDescription: () => Promise<string>;
|
|
30
30
|
readonly agentName: () => Promise<string>;
|
|
31
31
|
readonly traceId: `${string}-${string}-${string}-${string}-${string}`;
|
|
32
|
-
/**
|
|
32
|
+
/** Chat policy steers the active caller's turn; Eve queues other callers. */
|
|
33
33
|
turnPolicy: "queue" | "steer";
|
|
34
34
|
edited: boolean;
|
|
35
35
|
triggeringMessageId: string | undefined;
|
|
@@ -29,7 +29,7 @@ import { type AttachmentDescriber } from "./attachment-description.js";
|
|
|
29
29
|
* 3. The router answers or observes. Group files follow the same addressing rules as text;
|
|
30
30
|
* captionless uploads use smart routing and recent agent requests. Files are stored after the
|
|
31
31
|
* registry knows the sender. Observing starts no session or typing indication; the
|
|
32
|
-
*
|
|
32
|
+
* chat archive keeps the message and its stored files' references for routing, the
|
|
33
33
|
* next turn's chat context and the native images that turn carries.
|
|
34
34
|
* 4. An answered message continues the session its address names under the configured scope; eve
|
|
35
35
|
* compacts and expires sessions itself.
|
|
@@ -49,8 +49,8 @@ export interface InboundDependencies {
|
|
|
49
49
|
readonly policy: TelegramPolicy;
|
|
50
50
|
readonly decisionModel?: string;
|
|
51
51
|
readonly groups?: GroupPolicy;
|
|
52
|
-
/** The chat's or forum topic's recent messages from the
|
|
53
|
-
readonly
|
|
52
|
+
/** The chat's or forum topic's recent messages from the chat archive, oldest first. */
|
|
53
|
+
readonly recentChat?: (chatId: string, threadId?: string) => Promise<ReadonlyArray<RecentMessage>>;
|
|
54
54
|
readonly signalSettings?: TelegramSettings["groups"];
|
|
55
55
|
readonly lifecycle?: (principal: import("eve/context").SessionAuthContext, memberId: string, message: TelegramMessage) => ReturnType<typeof attachmentLifecycle>;
|
|
56
56
|
readonly admission: () => AdmissionSettings;
|
|
@@ -6,10 +6,10 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { WorkspaceActionAlreadyDispatched } from "./workspace-action.mjs";
|
|
8
8
|
import { structuredMessage } from "./structured.mjs";
|
|
9
|
-
import { d as telegramRuntimeSource, n as
|
|
9
|
+
import { d as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-nQ_gwLJs.mjs";
|
|
10
10
|
import { routingBurst } from "../group-routing/burst.mjs";
|
|
11
11
|
import { telegramSignals } from "./signals.mjs";
|
|
12
|
-
import { addressingReason,
|
|
12
|
+
import { addressingReason, chatKey, otherRecipient } from "../group-routing/signals.mjs";
|
|
13
13
|
import { effectiveGroupPolicy, groupPolicy } from "../group-routing/policy.mjs";
|
|
14
14
|
import { questionInvitation } from "../group-routing/engagement.mjs";
|
|
15
15
|
import { AttachmentLifecycleNotPermitted } from "./lifecycle.mjs";
|
|
@@ -27,7 +27,7 @@ import { routingContext } from "./routing-context.mjs";
|
|
|
27
27
|
import { formatAddress, messageAddress, scopedAddress } from "./sessions.mjs";
|
|
28
28
|
import { voiceOf, voiceText } from "./voice.mjs";
|
|
29
29
|
import { MAXIMUM_ROUTING_ATTACHMENT_BYTES, describeRoutingAttachment, routingAttachmentDeadline } from "./attachment-description.mjs";
|
|
30
|
-
import { recordGateDecision, recordInboundContent, recordRouteDecision } from "./
|
|
30
|
+
import { recordGateDecision, recordInboundContent, recordRouteDecision } from "./chat-archive.mjs";
|
|
31
31
|
import { contentShape, messageContent } from "./content.mjs";
|
|
32
32
|
import { messageAudience } from "./audience.mjs";
|
|
33
33
|
import { p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
|
|
@@ -91,7 +91,7 @@ function speakerBlock(input) {
|
|
|
91
91
|
if (isRecord(raw)) {
|
|
92
92
|
const from = isRecord(raw.from) ? raw.from : {};
|
|
93
93
|
const author = from.is_bot === true && bot !== void 0 && String(from.id) === bot.id ? "the agent" : typeof from.username === "string" ? `@${from.username}` : typeof from.first_name === "string" ? from.first_name : "unknown sender";
|
|
94
|
-
const text = input.omitQuote ? "[confirmation; see
|
|
94
|
+
const text = input.omitQuote ? "[confirmation; see chat context]" : messageContent(raw).text;
|
|
95
95
|
const quoted = text.length > MAXIMUM_QUOTE_LENGTH ? `${text.slice(0, MAXIMUM_QUOTE_LENGTH)}…` : text;
|
|
96
96
|
lines.push(`reply_to: ${author}: ${JSON.stringify(quoted)}`);
|
|
97
97
|
}
|
|
@@ -298,16 +298,16 @@ async function handleInboundMessage(input) {
|
|
|
298
298
|
const turn = structured === void 0 && input.request?.structuredContext === void 0 && addressed !== void 0 && hasContent && (addressed !== "reply-to-bot" || elsewhere === void 0);
|
|
299
299
|
const lookup = await resolve(turn);
|
|
300
300
|
const group = isGroupChat(sent);
|
|
301
|
-
const
|
|
301
|
+
const freshChat = async () => await dependencies.recentChat?.(sent.chat.id, sent.messageThreadId === void 0 ? void 0 : String(sent.messageThreadId)) ?? [];
|
|
302
302
|
let archived;
|
|
303
|
-
const
|
|
303
|
+
const recentChat = () => archived ??= freshChat();
|
|
304
304
|
const languageOf = async (current) => {
|
|
305
|
-
const own =
|
|
305
|
+
const own = chatLanguage([current]);
|
|
306
306
|
if (own !== void 0) return own;
|
|
307
307
|
try {
|
|
308
|
-
return
|
|
308
|
+
return chatLanguage((await recentChat()).map((message) => message.text).reverse());
|
|
309
309
|
} catch (error) {
|
|
310
|
-
reportTelegramError("
|
|
310
|
+
reportTelegramError("chat_language_unavailable", error, { chatId: sent.chat.id });
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
@@ -439,7 +439,7 @@ async function handleInboundMessage(input) {
|
|
|
439
439
|
const principal = telegramPrincipal({
|
|
440
440
|
message: sent,
|
|
441
441
|
member,
|
|
442
|
-
|
|
442
|
+
chatLanguage: await languageOf(sent.text || sent.caption)
|
|
443
443
|
});
|
|
444
444
|
input.request.lifecycle = dependencies.lifecycle(principal, member.id, sent);
|
|
445
445
|
await context.telegram.startTyping();
|
|
@@ -520,10 +520,10 @@ async function handleInboundMessage(input) {
|
|
|
520
520
|
const groups = effectiveGroupPolicy(dependencies.groups ?? groupPolicy({}, {
|
|
521
521
|
mode: dependencies.policy,
|
|
522
522
|
model: dependencies.decisionModel
|
|
523
|
-
}),
|
|
524
|
-
const
|
|
525
|
-
let
|
|
526
|
-
if (
|
|
523
|
+
}), chatKey(policySignals));
|
|
524
|
+
const chatPolicy = group && groups.smart.engagement.policy === "chat";
|
|
525
|
+
let chatRecent = chatPolicy ? await recentChat() : [];
|
|
526
|
+
if (chatPolicy && input.request && input.request.lifecycleKey === void 0 && input.request.structuredContext === void 0) {
|
|
527
527
|
address = topicAddress;
|
|
528
528
|
input.request.address = topicAddress;
|
|
529
529
|
input.request.turnPolicy = "steer";
|
|
@@ -537,12 +537,12 @@ async function handleInboundMessage(input) {
|
|
|
537
537
|
});
|
|
538
538
|
const questionAge = Date.parse(sentAt(sent)) - Date.parse(asked?.meta.at ?? "");
|
|
539
539
|
if (answering && addressed === void 0 && !questionInvitation(asked?.meta.at, sentAt(sent), groups.smart.engagement.openQuestionMinutes)) answering = false;
|
|
540
|
-
const recipientAnswer = !
|
|
541
|
-
if (!
|
|
540
|
+
const recipientAnswer = !chatPolicy && answering && (groups.smart.engagement.policy === "engaged" || questionAge >= 0 && questionAge <= groups.smart.engagement.followUpMinutes * 6e4) && audience.replyTo?.kind === "bot" && isRecipientAnswer(audience);
|
|
541
|
+
if (!chatPolicy && answering && pending !== void 0 && input.request !== void 0) {
|
|
542
542
|
address = pending.address || (questionSession === void 0 ? topicAddress : memberQuestionAddress);
|
|
543
543
|
input.request.address = address;
|
|
544
544
|
}
|
|
545
|
-
if (input.request?.lifecycleKey === void 0 && input.request?.structuredContext === void 0 && group && (addressed === void 0 && !answering && groups.mode === "mention" || !
|
|
545
|
+
if (input.request?.lifecycleKey === void 0 && input.request?.structuredContext === void 0 && group && (addressed === void 0 && !answering && groups.mode === "mention" || !chatPolicy && elsewhere !== void 0 && (addressed === void 0 || addressed === "reply-to-bot" && !recipientAnswer))) {
|
|
546
546
|
await recordContent({
|
|
547
547
|
text: text || (structured === void 0 ? text : `[${structured.kind}]`),
|
|
548
548
|
decoded
|
|
@@ -553,7 +553,7 @@ async function handleInboundMessage(input) {
|
|
|
553
553
|
});
|
|
554
554
|
return null;
|
|
555
555
|
}
|
|
556
|
-
if (!
|
|
556
|
+
if (!chatPolicy && hasContent && answering && !await admitTurn(true)) {
|
|
557
557
|
await observeRaw();
|
|
558
558
|
return null;
|
|
559
559
|
}
|
|
@@ -561,11 +561,11 @@ async function handleInboundMessage(input) {
|
|
|
561
561
|
await observeRaw();
|
|
562
562
|
return null;
|
|
563
563
|
}
|
|
564
|
-
if (group && !
|
|
564
|
+
if (group && !chatPolicy) chatRecent = (await recentChat()).filter((message) => message.messageId !== sent.messageId).map(({ signedAuthor, ...message }) => signedAuthor === void 0 ? message : {
|
|
565
565
|
...message,
|
|
566
566
|
author: signedAuthor
|
|
567
567
|
});
|
|
568
|
-
const carried = observedImages(
|
|
568
|
+
const carried = observedImages(chatRecent, sent.messageId);
|
|
569
569
|
const mediaPlan = voice !== void 0 || sent.attachments.length > 0 || carried.length > 0 ? await dependencies.mediaPlan?.(member, owner?.id) : void 0;
|
|
570
570
|
if (voice !== void 0 && !group) await transcribeVoice(false);
|
|
571
571
|
if (voice !== void 0 && mediaPlan?.audio) notes.push("[The chat model supports audio, but this host cannot deliver native audio. The configured speech-to-text fallback was used if enabled.]");
|
|
@@ -602,7 +602,7 @@ async function handleInboundMessage(input) {
|
|
|
602
602
|
let classified = false;
|
|
603
603
|
let uncertain = false;
|
|
604
604
|
let question;
|
|
605
|
-
const
|
|
605
|
+
const routeQuestion = async () => {
|
|
606
606
|
if (question !== void 0) return question;
|
|
607
607
|
await report;
|
|
608
608
|
const context = await routingContext({
|
|
@@ -611,7 +611,7 @@ async function handleInboundMessage(input) {
|
|
|
611
611
|
address,
|
|
612
612
|
operations,
|
|
613
613
|
read: dependencies.history ?? dependencies.readHistory,
|
|
614
|
-
remembered:
|
|
614
|
+
remembered: chatRecent,
|
|
615
615
|
at: sentAt(sent),
|
|
616
616
|
questionHistory,
|
|
617
617
|
questionSessionId: owner?.id
|
|
@@ -640,7 +640,7 @@ async function handleInboundMessage(input) {
|
|
|
640
640
|
aliases
|
|
641
641
|
},
|
|
642
642
|
chat: group ? chatContext(dependencies.chats.chat(sent.chat.id)) : [],
|
|
643
|
-
recent:
|
|
643
|
+
recent: chatPolicy ? chatRecent : context.recent,
|
|
644
644
|
pendingConfirmations: context.pendingConfirmations,
|
|
645
645
|
pendingQuestions: context.pendingQuestions.filter((question) => question.chatId === sent.chat.id && question.messageThreadId === String(sent.messageThreadId ?? "")),
|
|
646
646
|
message: observedMessage(sent, text, member, media, bot),
|
|
@@ -649,7 +649,7 @@ async function handleInboundMessage(input) {
|
|
|
649
649
|
};
|
|
650
650
|
return question;
|
|
651
651
|
};
|
|
652
|
-
if (
|
|
652
|
+
if (chatPolicy && input.request?.lifecycleKey === void 0 && input.request?.structuredContext === void 0) {
|
|
653
653
|
if (voice !== void 0) await transcribeVoice(true);
|
|
654
654
|
const routingSignals = {
|
|
655
655
|
...policySignals,
|
|
@@ -658,8 +658,8 @@ async function handleInboundMessage(input) {
|
|
|
658
658
|
text
|
|
659
659
|
}
|
|
660
660
|
};
|
|
661
|
-
const burst = routingBurst(routingSignals,
|
|
662
|
-
const q = await
|
|
661
|
+
const burst = routingBurst(routingSignals, chatRecent, groups);
|
|
662
|
+
const q = await routeQuestion();
|
|
663
663
|
question = {
|
|
664
664
|
...q,
|
|
665
665
|
signals: routingSignals,
|
|
@@ -739,8 +739,8 @@ async function handleInboundMessage(input) {
|
|
|
739
739
|
decoded,
|
|
740
740
|
...processedMedia === void 0 ? {} : { media: processedMedia }
|
|
741
741
|
});
|
|
742
|
-
if (
|
|
743
|
-
const current = await
|
|
742
|
+
if (chatPolicy) {
|
|
743
|
+
const current = await routeQuestion();
|
|
744
744
|
const message = {
|
|
745
745
|
...current.message,
|
|
746
746
|
text,
|
|
@@ -752,7 +752,7 @@ async function handleInboundMessage(input) {
|
|
|
752
752
|
messagesToClassify: current.messagesToClassify?.map((m) => m.messageId === message.messageId ? message : m)
|
|
753
753
|
};
|
|
754
754
|
}
|
|
755
|
-
return
|
|
755
|
+
return routeQuestion();
|
|
756
756
|
}
|
|
757
757
|
});
|
|
758
758
|
if (route === "reply" && input.request !== void 0) input.request.engaged = true;
|
|
@@ -799,7 +799,7 @@ async function handleInboundMessage(input) {
|
|
|
799
799
|
memberId: member.id
|
|
800
800
|
};
|
|
801
801
|
try {
|
|
802
|
-
if (input.request?.recordStructuredContext === void 0) throw new Error("A structured continuation requires durable
|
|
802
|
+
if (input.request?.recordStructuredContext === void 0) throw new Error("A structured continuation requires durable chat capture.");
|
|
803
803
|
await input.request.recordStructuredContext(result.context, member.id);
|
|
804
804
|
} catch (error) {
|
|
805
805
|
reportTelegramError("workspace_structured_context_recording_failed", error);
|
|
@@ -880,7 +880,7 @@ async function handleInboundMessage(input) {
|
|
|
880
880
|
try {
|
|
881
881
|
outcome = { result: (await dependencies.attachments.promote({
|
|
882
882
|
memberId: member.id,
|
|
883
|
-
|
|
883
|
+
chat: `telegram:${sent.chat.id}`
|
|
884
884
|
}, file.attachment.id, {
|
|
885
885
|
...stored.retain,
|
|
886
886
|
runtime: runtimeEnvelope({ source: telegramRuntimeSource(sent, files) })
|
|
@@ -1001,7 +1001,7 @@ async function handleInboundMessage(input) {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
if (voice !== void 0 && input.request !== void 0) input.request.text = text;
|
|
1003
1003
|
else if (voice !== void 0) notes.push(text);
|
|
1004
|
-
if (!
|
|
1004
|
+
if (!chatPolicy && answering && pending !== void 0 && input.request !== void 0) {
|
|
1005
1005
|
input.request.replyTo = pending.replyToMessageId ?? input.request.replyTo;
|
|
1006
1006
|
input.request.lifecycleKey = pending.taskId ?? input.request.lifecycleKey;
|
|
1007
1007
|
input.request.text = `${answerMarker(pending.id)}\n${text}`;
|
|
@@ -1027,7 +1027,7 @@ async function handleInboundMessage(input) {
|
|
|
1027
1027
|
data: attachmentUrl({
|
|
1028
1028
|
id: image.id,
|
|
1029
1029
|
memberId: member.id,
|
|
1030
|
-
|
|
1030
|
+
chat: `telegram:${sent.chat.id}`
|
|
1031
1031
|
}),
|
|
1032
1032
|
mediaType: image.contentType,
|
|
1033
1033
|
filename: image.filename
|
|
@@ -1035,7 +1035,7 @@ async function handleInboundMessage(input) {
|
|
|
1035
1035
|
});
|
|
1036
1036
|
}
|
|
1037
1037
|
const language = await languageOf(text);
|
|
1038
|
-
const confirmationReply = (group ? await
|
|
1038
|
+
const confirmationReply = (group ? await routeQuestion() : void 0)?.recent.some((entry) => "role" in entry && entry.confirmation !== void 0 && entry.messageId === audience.replyTo?.messageId) === true;
|
|
1039
1039
|
const beginTurnDispatch = structuredDispatched ? input.request?.beginStructuredContinuation : input.request?.beginDispatch;
|
|
1040
1040
|
if (beginTurnDispatch !== void 0 && !await beginTurnDispatch()) {
|
|
1041
1041
|
recordGateDecision("message_already_handled");
|
|
@@ -1047,7 +1047,7 @@ async function handleInboundMessage(input) {
|
|
|
1047
1047
|
text
|
|
1048
1048
|
},
|
|
1049
1049
|
member,
|
|
1050
|
-
|
|
1050
|
+
chatLanguage: language
|
|
1051
1051
|
});
|
|
1052
1052
|
const [guidance] = group ? chatContext(dependencies.chats.chat(sent.chat.id)) : [];
|
|
1053
1053
|
if (guidance !== void 0) principal = {
|
|
@@ -1095,7 +1095,7 @@ async function handleInboundMessage(input) {
|
|
|
1095
1095
|
bot_tagged: audience.botTagged,
|
|
1096
1096
|
reply_target: confirmationReply && audience.replyTo !== null ? Object.fromEntries(Object.entries(audience.replyTo).filter(([key]) => key !== "text")) : audience.replyTo,
|
|
1097
1097
|
tagged_users: audience.mentions,
|
|
1098
|
-
...
|
|
1098
|
+
...chatPolicy ? { engagement_policy: "chat" } : {},
|
|
1099
1099
|
...uncertain ? { routing: "uncertain" } : {}
|
|
1100
1100
|
}) + "\n</message_audience>",
|
|
1101
1101
|
...attachmentsContext({
|
|
@@ -4,8 +4,8 @@ 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, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-nQ_gwLJs.mjs";
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-CkBdh-TE.mjs";
|
|
9
9
|
import { n as currentInboundRequest } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
|
|
10
10
|
import { object } from "../confirmation-description.mjs";
|
|
11
11
|
import { needsConfirmation } from "../confirmations.mjs";
|
|
@@ -39,7 +39,7 @@ function attachmentLifecycle(options) {
|
|
|
39
39
|
topic: String(options.message.messageThreadId ?? ""),
|
|
40
40
|
message: options.message.messageId,
|
|
41
41
|
sender: options.message.from.id,
|
|
42
|
-
locale: String(options.principal.attributes.conversationLanguage ?? options.principal.attributes.locale ?? "en")
|
|
42
|
+
locale: String(options.principal.attributes.chatLanguage ?? options.principal.attributes.conversationLanguage ?? options.principal.attributes.locale ?? "en")
|
|
43
43
|
},
|
|
44
44
|
data: {
|
|
45
45
|
...data,
|
|
@@ -13,11 +13,11 @@ export declare function telegramPrincipal(input: {
|
|
|
13
13
|
readonly from: NonNullable<TelegramMessage["from"]>;
|
|
14
14
|
};
|
|
15
15
|
readonly member: PairedMember;
|
|
16
|
-
readonly
|
|
16
|
+
readonly chatLanguage?: string;
|
|
17
17
|
readonly callbackQueryId?: string;
|
|
18
18
|
}): SessionAuthContext;
|
|
19
19
|
/** Short answers and attachment-only turns retain the recent chat language when known. */
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function chatLanguage(texts: readonly string[]): "ru" | "en" | undefined;
|
|
21
21
|
/**
|
|
22
22
|
* The member a session principal acts for: `memberId` stamped by a SegmentStream channel. A task
|
|
23
23
|
* session acts for no member; `actorOf` in `lib/actor.ts` names whom any session acts for.
|
|
@@ -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 TELEGRAM_AUTHENTICATOR, n as
|
|
7
|
+
export { t as TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-nQ_gwLJs.mjs";
|
|
@@ -6,11 +6,11 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { telegramSignals } from "./signals.mjs";
|
|
8
8
|
import { addressingReason as addressingReason$1 } from "../group-routing/signals.mjs";
|
|
9
|
-
import { FOLLOW_UP_WINDOW_MS,
|
|
9
|
+
import { FOLLOW_UP_WINDOW_MS, decisionRouter, routeMessage, routingEvidence } from "../group-routing/router.mjs";
|
|
10
10
|
function addressingReason(message, bot) {
|
|
11
11
|
return addressingReason$1(telegramSignals(message, bot));
|
|
12
12
|
}
|
|
13
13
|
function isAddressed(message, bot) {
|
|
14
14
|
return addressingReason(message, bot) !== void 0;
|
|
15
15
|
}
|
|
16
|
-
export { FOLLOW_UP_WINDOW_MS, addressingReason,
|
|
16
|
+
export { FOLLOW_UP_WINDOW_MS, addressingReason, decisionRouter, isAddressed, routeMessage, routingEvidence };
|
|
@@ -7,7 +7,7 @@ import type { SessionSettings } from "../../config.js";
|
|
|
7
7
|
* a group session spans. Compaction and idle expiry are eve's own: automatic compaction near the
|
|
8
8
|
* context window and `limits.sessionTimeoutMs` in the workspace's `agent.ts`.
|
|
9
9
|
*/
|
|
10
|
-
/** eve's Telegram continuation address: `chat:thread:
|
|
10
|
+
/** eve's Telegram continuation address: `chat:thread:conversationId` (eve's names), the last two possibly empty. */
|
|
11
11
|
export interface TelegramAddress {
|
|
12
12
|
readonly chatId: string;
|
|
13
13
|
readonly messageThreadId: string;
|
|
@@ -13,7 +13,7 @@ function telegramSignals(message, bot, settings) {
|
|
|
13
13
|
const command = /^\/[A-Za-z0-9_]+(?:@(?<target>[A-Za-z0-9_]+))?(?:\s|$)/u.exec(message.text || message.caption);
|
|
14
14
|
return {
|
|
15
15
|
provider: "telegram",
|
|
16
|
-
|
|
16
|
+
chat: {
|
|
17
17
|
externalId: message.chat.id,
|
|
18
18
|
kind: message.chat.type === "private" ? "direct" : "group",
|
|
19
19
|
title: message.chat.title,
|
|
@@ -32,9 +32,9 @@ export interface InterimMessages {
|
|
|
32
32
|
* The channel's final reply: formatted and split before Eve's plain-text splitter, with one
|
|
33
33
|
* queue slot for the whole reply. Explicit silence markers have no delivery. Tool-call steps have
|
|
34
34
|
* none either unless `interim` is enabled: then their text is delivered exactly like a reply. The
|
|
35
|
-
*
|
|
35
|
+
* chat archive records every delivery for routing and chat context. A text already
|
|
36
36
|
* delivered as an interim message in the same turn, whether a repeat or the final reply, is not
|
|
37
|
-
* delivered again. With `review`, a
|
|
37
|
+
* delivered again. With `review`, a chat whose replies are reviewed gets no interim
|
|
38
38
|
* messages, and its final reply is sent only when the review allows it.
|
|
39
39
|
*/
|
|
40
40
|
export declare function replyDelivery(scope?: () => string, interim?: InterimMessages, review?: ReplyReview): MessageCompleted;
|
|
@@ -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-
|
|
7
|
+
import { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-nQ_gwLJs.mjs";
|
|
8
8
|
import { workspaceAction } from "./workspace-action.mjs";
|
|
9
9
|
import { STRUCTURED_KINDS } from "./structured-settings.mjs";
|
|
10
10
|
const record = (value) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TelegramChannelEvents } from "eve/channels/telegram";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ChatArchive } from "../chat-archive.js";
|
|
3
3
|
import type { AgentIdentities } from "../identities.js";
|
|
4
4
|
/** Failure notices for members; an unrecoverable session failure is also recorded to the archive. */
|
|
5
5
|
export declare function telegramFailureEvents(input: {
|
|
6
|
-
readonly archive:
|
|
6
|
+
readonly archive: ChatArchive;
|
|
7
7
|
readonly identities: () => AgentIdentities;
|
|
8
8
|
}): Pick<TelegramChannelEvents, "turn.settled" | "session.ended" | "interaction.settled" | "interaction.opened">;
|
|
@@ -6,9 +6,9 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
8
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
9
|
-
import { recordSessionFailure } from "./
|
|
9
|
+
import { recordSessionFailure } from "./chat-archive.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-
|
|
11
|
+
import { i as memberIdOf } from "../../../_chunks/principal-nQ_gwLJs.mjs";
|
|
12
12
|
import { modelServiceFailure } from "../model-service-failure.mjs";
|
|
13
13
|
function telegramFailureEvents(input) {
|
|
14
14
|
return {
|
|
@@ -3,7 +3,7 @@ import { type ConnectionProxy } from "../connection-proxy.js";
|
|
|
3
3
|
* Voice, audio and video notes. eve's Telegram parser reads only photos and documents, so these
|
|
4
4
|
* arrive as a message with no text; the adapter reads them from the raw update, downloads them
|
|
5
5
|
* through the connection's `file` API and turns them into text with the configured speech-to-text
|
|
6
|
-
* model before the
|
|
6
|
+
* model before the session sees them, whatever the main model accepts.
|
|
7
7
|
*/
|
|
8
8
|
export type VoiceKind = "voice" | "audio" | "video_note";
|
|
9
9
|
export interface VoiceMessage {
|
|
@@ -37,7 +37,7 @@ export interface WhatsAppChannelOptions {
|
|
|
37
37
|
readonly fetch?: typeof fetch;
|
|
38
38
|
/** The ontology's pairing routes; tests pass a fake. */
|
|
39
39
|
readonly identities?: AgentIdentities;
|
|
40
|
-
/** Who sends the agent's replies, from `
|
|
40
|
+
/** Who sends the agent's replies, from `review`; without it every reply is sent. */
|
|
41
41
|
readonly review?: ChannelReviewOptions;
|
|
42
42
|
}
|
|
43
43
|
/** What the adapter reads per request: eve binds the mount after it loads the channel. */
|
|
@@ -74,7 +74,7 @@ export declare function segmentstreamWhatsApp(options: WhatsAppChannelOptions):
|
|
|
74
74
|
* after answering anyone else with the workspace's reply, if it has one.
|
|
75
75
|
*/
|
|
76
76
|
export declare function receive(input: {
|
|
77
|
-
/** The Chat SDK thread: its id names the
|
|
77
|
+
/** The Chat SDK thread: its id names the chat, one person's chat with the number. */
|
|
78
78
|
readonly thread: {
|
|
79
79
|
readonly id: string;
|
|
80
80
|
readonly post: (message: string | PostableCard) => Promise<unknown>;
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { admitMessage, localizedText } from "../admission.mjs";
|
|
8
8
|
import { chatSdkButtonAnswer, withButtonDecision } from "../confirmation-buttons.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { withChatAddress } from "../chat-address.mjs";
|
|
10
10
|
import { channelReview, withReviewedReplies } from "../review/reply.mjs";
|
|
11
11
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
12
12
|
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
@@ -209,7 +209,7 @@ async function receive(input) {
|
|
|
209
209
|
});
|
|
210
210
|
switch (resolution.status) {
|
|
211
211
|
case "existing":
|
|
212
|
-
case "created": return turn ?
|
|
212
|
+
case "created": return turn ? withChatAddress(whatsappPrincipal(resolution.member, sender), {
|
|
213
213
|
provider: "whatsapp",
|
|
214
214
|
chatId: thread.id,
|
|
215
215
|
threadId: "",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** JSON data produced by SDK tools and
|
|
1
|
+
/** JSON data produced by SDK tools and chat archive events. */
|
|
2
2
|
export type WorkflowSerializable = null | boolean | number | string | WorkflowSerializable[] | {
|
|
3
3
|
[key: string]: WorkflowSerializable;
|
|
4
4
|
};
|
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-nQ_gwLJs.mjs";
|
|
10
10
|
import { defineDynamic } from "eve";
|
|
11
11
|
import { runs } from "eve/events";
|
|
12
12
|
function chooseModel(input) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Personas: what the agent is to the person in a
|
|
2
|
+
* Personas: what the agent is to the person in a chat. `agent/segmentstream.json` says
|
|
3
3
|
* which roles get which persona; each persona's text is `agent/personas/<persona>.md`, which the
|
|
4
4
|
* SDK reads when the agent is built and the platform puts inline (`personas.texts`) when it
|
|
5
5
|
* deploys, so the running agent, which has no files, reads the same text. Selection reads only the
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Review: who sends the agent's replies in
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Review: who sends the agent's replies. `review` in `agent/segmentstream.json` sets it per role of
|
|
3
|
+
* the person the agent replies to, the first role they hold winning in the order written, and a
|
|
4
|
+
* `default` for everyone else:
|
|
5
5
|
*
|
|
6
6
|
* - `never`: the agent sends its replies itself;
|
|
7
7
|
* - `always`: every reply waits for a member to approve, edit or reject it;
|
|
8
|
-
* - `whenUnsure`: a decision model judges each reply from the
|
|
8
|
+
* - `whenUnsure`: a decision model judges each reply from the chat and the criteria in
|
|
9
9
|
* `agent/review/<role>.md` (`default.md` for `default`); the agent sends it when the model gives
|
|
10
10
|
* at least `minConfidence` that staff would send it as written, and holds it otherwise.
|
|
11
11
|
*
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
export declare const REVIEW_DIRECTORY = "review";
|
|
18
18
|
/** The longest criteria the decision model reads; longer ones fail validation. */
|
|
19
19
|
export declare const MAXIMUM_CRITERIA_LENGTH = 8000;
|
|
20
|
-
/** The key of the
|
|
21
|
-
export declare const
|
|
20
|
+
/** The key of the review for everyone no role matches, and the name of its criteria file. */
|
|
21
|
+
export declare const DEFAULT_REVIEW = "default";
|
|
22
22
|
export declare const REVIEW_MODES: readonly ["never", "always", "whenUnsure"];
|
|
23
23
|
export type ReviewMode = (typeof REVIEW_MODES)[number];
|
|
24
24
|
export type Review = {
|
|
@@ -32,17 +32,14 @@ export type Review = {
|
|
|
32
32
|
/** `agent/review/<role>.md`: what staff check a reply for. Put inline, not written by hand. */
|
|
33
33
|
readonly criteria?: string;
|
|
34
34
|
};
|
|
35
|
-
export interface
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export interface ConversationsSettings {
|
|
39
|
-
/** Settings per role of the person the agent replies to; the first role they hold wins. */
|
|
40
|
-
readonly byRole: Readonly<Record<string, ConversationSettings>>;
|
|
35
|
+
export interface ReviewSettings {
|
|
36
|
+
/** The review per role of the person the agent replies to; the first role they hold wins. */
|
|
37
|
+
readonly byRole: Readonly<Record<string, Review>>;
|
|
41
38
|
/** Everyone no role matches, including a person with no roles. */
|
|
42
|
-
readonly default:
|
|
39
|
+
readonly default: Review;
|
|
43
40
|
}
|
|
44
|
-
/** Without `
|
|
45
|
-
export declare const SEND_REPLIES:
|
|
41
|
+
/** Without `review`, or for a key it leaves out: the agent sends its replies itself. */
|
|
42
|
+
export declare const SEND_REPLIES: Review;
|
|
46
43
|
/** One validation failure, in Standard Schema's issue shape. */
|
|
47
44
|
interface Issue {
|
|
48
45
|
readonly message: string;
|
|
@@ -50,12 +47,18 @@ interface Issue {
|
|
|
50
47
|
}
|
|
51
48
|
/** The path of a key's criteria, relative to the directory of `segmentstream.json`. */
|
|
52
49
|
export declare function reviewFile(key: string): string | undefined;
|
|
53
|
-
/** The
|
|
54
|
-
export declare function
|
|
55
|
-
/** Validates `
|
|
56
|
-
export declare function
|
|
50
|
+
/** The review for a person with `roles`: the first `byRole` entry they hold, or the default. */
|
|
51
|
+
export declare function reviewFor(settings: ReviewSettings | undefined, roles: ReadonlyArray<string>): Review;
|
|
52
|
+
/** Validates `review` of `agent/segmentstream.json`; `undefined` when absent. */
|
|
53
|
+
export declare function reviewSettings(value: unknown, issues: Issue[]): ReviewSettings | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* @legacy agent.conversations-review-settings
|
|
56
|
+
* `review` as the first SDK release with it wrote it: `conversations`, with each role's and the
|
|
57
|
+
* default's review one level deeper, under `review`. Anything else is returned as it is.
|
|
58
|
+
*/
|
|
59
|
+
export declare function earlierReviewInput(value: unknown): unknown;
|
|
57
60
|
/**
|
|
58
|
-
* The keys `
|
|
61
|
+
* The keys `review` names whose reply a model judges, with each one's criteria file:
|
|
59
62
|
* `byRole`'s roles, then `default`.
|
|
60
63
|
*/
|
|
61
64
|
export declare function criteriaFiles(value: unknown): ReadonlyArray<{
|