@segmentstream/agent 0.8.3 → 0.8.5
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 +14 -0
- package/dist/_chunks/{build-metadata-BLyaHLJW.mjs → build-metadata-BYl-5kFi.mjs} +1 -1
- package/dist/_chunks/{inbound-request-CYSoY6pu.mjs → inbound-request-B98tr4Pd.mjs} +1 -0
- package/dist/_chunks/workflow-serializable-BwttWNmY.mjs +715 -0
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/conversations.mjs +10 -4
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +11 -3
- 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/confirmation-expiry.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.mjs +1 -1
- package/dist/extension/lib/telegram/conversations.mjs +1 -1
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/deferred-confirmations.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/images.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.d.ts +2 -0
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +3 -2
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
- package/dist/extension/lib/telegram/media-policy.mjs +1 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
- package/dist/extension/lib/telegram/voice.mjs +1 -1
- package/dist/extension/lib/workflow-serializable.d.ts +29 -0
- package/dist/extension/lib/workflow-serializable.mjs +8 -0
- package/dist/extension/tools/attachments_discard.d.ts +2 -24
- package/dist/extension/tools/attachments_discard.mjs +2 -1
- package/dist/extension/tools/attachments_list.d.ts +2 -24
- package/dist/extension/tools/attachments_list.mjs +3 -1
- package/dist/extension/tools/attachments_promote.d.ts +2 -28
- package/dist/extension/tools/attachments_promote.mjs +3 -2
- package/dist/extension/tools/attachments_read.mjs +3 -2
- package/dist/extension/tools/attachments_send.d.ts +1 -7
- package/dist/extension/tools/attachments_send.mjs +4 -3
- package/dist/extension/tools/attachments_table.d.ts +2 -62
- package/dist/extension/tools/attachments_table.mjs +3 -2
- package/dist/extension/tools/questions_ask.d.ts +3 -13
- package/dist/extension/tools/questions_ask.mjs +2 -1
- package/package.json +1 -1
|
@@ -4,5 +4,5 @@ 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-BYl-5kFi.mjs";
|
|
8
8
|
export { agentBuild };
|
|
@@ -6,6 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { proxyEnvironment } from "./environment.mjs";
|
|
8
8
|
import { runtimeToken } from "./runtime-token.mjs";
|
|
9
|
+
import { r as workflowValue } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
9
10
|
function collapseConversationEvents(events) {
|
|
10
11
|
const latest = new Map();
|
|
11
12
|
for (const event of events) {
|
|
@@ -20,7 +21,7 @@ function collapseConversationEvents(events) {
|
|
|
20
21
|
return [...latest.values()];
|
|
21
22
|
}
|
|
22
23
|
function conversationEvent(input) {
|
|
23
|
-
return {
|
|
24
|
+
return workflowValue({
|
|
24
25
|
threadId: null,
|
|
25
26
|
participantIds: [],
|
|
26
27
|
senderId: null,
|
|
@@ -40,7 +41,12 @@ function conversationEvent(input) {
|
|
|
40
41
|
attachments: [],
|
|
41
42
|
at: new Date().toISOString(),
|
|
42
43
|
...input
|
|
43
|
-
}
|
|
44
|
+
}, {
|
|
45
|
+
boundary: "SDK conversation event",
|
|
46
|
+
eventType: input.kind,
|
|
47
|
+
toolName: input.toolName ?? void 0,
|
|
48
|
+
toolCallId: input.toolCallId ?? void 0
|
|
49
|
+
});
|
|
44
50
|
}
|
|
45
51
|
function conversations(input = {}) {
|
|
46
52
|
const environment = input.environment ?? process.env;
|
|
@@ -58,7 +64,7 @@ function conversations(input = {}) {
|
|
|
58
64
|
"x-segmentstream-organization-id": env.organizationId,
|
|
59
65
|
"x-segmentstream-runtime-identity": identity
|
|
60
66
|
},
|
|
61
|
-
body: JSON.stringify(body),
|
|
67
|
+
body: JSON.stringify(workflowValue(body, { boundary: "conversation archive" })),
|
|
62
68
|
signal: AbortSignal.timeout(15e3)
|
|
63
69
|
});
|
|
64
70
|
if (!response.ok) throw new Error(`Conversation archive ${path} failed (${response.status}); request ${response.headers.get("x-request-id") ?? "unknown"}.`);
|
|
@@ -88,7 +94,7 @@ function summarizeArguments(value) {
|
|
|
88
94
|
if (item !== null && typeof item === "object") return Object.fromEntries(Object.entries(item).slice(0, 30).map(([key, entry]) => [key, sensitive.test(key) ? "[redacted]" : visit(entry, depth + 1)]));
|
|
89
95
|
return typeof item === "string" ? item.replace(/(https?:\/\/)[^/@\s]+:[^/@\s]+@/gu, "$1[redacted]@").replace(/([?&](?:token|access_token|api_key|signature|secret|password)=)[^&#\s]*/giu, "$1[redacted]").replace(/\bBearer [A-Za-z0-9_.~+/-]+=*/giu, "Bearer [redacted]").slice(0, 500) : item;
|
|
90
96
|
};
|
|
91
|
-
return
|
|
97
|
+
return JSON.stringify(workflowValue(visit(value, 0), { boundary: "conversation arguments" })).slice(0, 4e3);
|
|
92
98
|
}
|
|
93
99
|
function retainedInboundEvidence(event) {
|
|
94
100
|
if (event.kind !== "inbound") return;
|
|
@@ -180,7 +180,7 @@ function actionToolName(entity, action) {
|
|
|
180
180
|
function promotionTarget(input) {
|
|
181
181
|
const entity = input.entity;
|
|
182
182
|
const action = input.action;
|
|
183
|
-
if (typeof entity !== "string" || typeof action !== "string" || !/^[a-z][a-zA-Z0-
|
|
183
|
+
if (typeof entity !== "string" || typeof action !== "string" || !/^(?:[a-z][a-zA-Z0-9]*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$/.test(entity) || !/^(?:[a-z][a-zA-Z0-9]*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$/.test(action)) throw new Error("A valid attachment target entity and action are required.");
|
|
184
184
|
return {
|
|
185
185
|
action: actionToolName(entity, action),
|
|
186
186
|
input: {
|
|
@@ -8,10 +8,10 @@ import { manifestOf } from "../../config.mjs";
|
|
|
8
8
|
import { appOrigin, channelsEnabled, proxyEnvironment, runtimeIdentityEnvironment, webhookSecret } from "../environment.mjs";
|
|
9
9
|
import { conversationLanguage, telegramPrincipal } from "./principal.mjs";
|
|
10
10
|
import { chooseModel } from "../../model.mjs";
|
|
11
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
11
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BYl-5kFi.mjs";
|
|
12
12
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
13
13
|
import { telegramSendScope } from "./send-queue.mjs";
|
|
14
|
-
import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-
|
|
14
|
+
import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
15
15
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
16
16
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
17
17
|
import { conversations } from "../conversations.mjs";
|
|
@@ -252,7 +252,8 @@ function segmentstreamTelegram(options) {
|
|
|
252
252
|
} catch (error) {
|
|
253
253
|
recordGateDecision("inbound_message_failed");
|
|
254
254
|
const errorId = reportTelegramError("inbound_message_failed", error, { chatId: message.chat.id });
|
|
255
|
-
|
|
255
|
+
if (inbound?.lifecycleKey !== void 0) inbound.retryReference = errorId;
|
|
256
|
+
else await context.telegram.post(failureText(errorId));
|
|
256
257
|
return null;
|
|
257
258
|
} finally {
|
|
258
259
|
inbound?.stopTyping?.();
|
|
@@ -464,6 +465,13 @@ function gatedRoute(input) {
|
|
|
464
465
|
completed = tasks.length;
|
|
465
466
|
await Promise.all(pending);
|
|
466
467
|
}
|
|
468
|
+
if (inbound.retryReference !== void 0) return Response.json({
|
|
469
|
+
error: "attachment_intake_retry",
|
|
470
|
+
reference: inbound.retryReference
|
|
471
|
+
}, {
|
|
472
|
+
status: 503,
|
|
473
|
+
headers: { "retry-after": "1" }
|
|
474
|
+
});
|
|
467
475
|
return response;
|
|
468
476
|
}));
|
|
469
477
|
}
|
|
@@ -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 { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
8
8
|
import { describableImage } from "./images.mjs";
|
|
9
9
|
import { MAXIMUM_ROUTING_PDF_CHARACTERS, extractRoutingPdf } from "./pdf-text.mjs";
|
|
10
10
|
import { gateway, generateText } from "ai";
|
|
@@ -9,7 +9,7 @@ import "./principal.mjs";
|
|
|
9
9
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
10
10
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
11
11
|
import { inTelegramSendQueue, telegramSendScope } from "./send-queue.mjs";
|
|
12
|
-
import { c as customerCopy, f as formattingRefused, l as customerMessage, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
12
|
+
import { c as customerCopy, f as formattingRefused, l as customerMessage, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
13
13
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
14
14
|
import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
15
15
|
import { ACT_AS_HEADER } from "../ontology-connection.mjs";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { proxyEnvironment } from "../environment.mjs";
|
|
8
8
|
import { telegramSendScope } from "./send-queue.mjs";
|
|
9
|
-
import { m as safeTelegramFetch, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
9
|
+
import { m as safeTelegramFetch, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
10
10
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
11
11
|
import { deferredConfirmations } from "../deferred-confirmations.mjs";
|
|
12
12
|
import { conversations } from "../conversations.mjs";
|
|
@@ -8,7 +8,7 @@ import { memberIdOf, telegramPrincipal } from "./principal.mjs";
|
|
|
8
8
|
import { humanText } from "../confirmation-description.mjs";
|
|
9
9
|
import { renderConfirmation, withConfirmationText } from "./confirmation-text.mjs";
|
|
10
10
|
import { chatPostCard, chatPostCardStatus, chatPostReceipt, withChatPostCard } from "./chat-post-card.mjs";
|
|
11
|
-
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
11
|
+
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
12
12
|
import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
|
|
13
13
|
import { confirmations } from "../confirmations.mjs";
|
|
14
14
|
import { conversationEvent } from "../conversations.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 { n as currentInboundRequest, s as currentThreadId } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { n as currentInboundRequest, s as currentThreadId } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
8
8
|
import { conversationEvent } from "../conversations.mjs";
|
|
9
9
|
import { contentShape, messageContent } from "./content.mjs";
|
|
10
10
|
import { currentConfirmationPrompt, messageMetadata, observedChatKey } from "./observed.mjs";
|
|
@@ -5,5 +5,5 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { isTechnicalText } from "../customer-text-safety.mjs";
|
|
8
|
-
import { a as TelegramDeliveryError, c as customerCopy, d as failureText, f as formattingRefused, h as withDeliveryLocale, l as customerMessage, m as safeTelegramFetch, o as currentLocale, p as reportTelegramError, s as currentThreadId, u as customerText } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { a as TelegramDeliveryError, c as customerCopy, d as failureText, f as formattingRefused, h as withDeliveryLocale, l as customerMessage, m as safeTelegramFetch, o as currentLocale, p as reportTelegramError, s as currentThreadId, u as customerText } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
9
9
|
export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
|
|
@@ -8,7 +8,7 @@ import { telegramPrincipal } from "./principal.mjs";
|
|
|
8
8
|
import { humanText } from "../confirmation-description.mjs";
|
|
9
9
|
import { renderConfirmation, withConfirmationText } from "./confirmation-text.mjs";
|
|
10
10
|
import { chatPostCard, chatPostCardStatus, chatPostReceipt, withChatPostCard } from "./chat-post-card.mjs";
|
|
11
|
-
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
11
|
+
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
12
12
|
import { CONFIRMATION_TTL_MS, inputHash } from "../confirmations.mjs";
|
|
13
13
|
import { confirmationOutcome } from "../confirmation-outcome.mjs";
|
|
14
14
|
import { deferredConfirmations, deferredKey, runDeferredAction } from "../deferred-confirmations.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { conversationLanguage } from "./principal.mjs";
|
|
8
|
-
import { d as failureText, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { d as failureText, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
9
9
|
import { describableImage, describeReceivedImage } from "./images.mjs";
|
|
10
10
|
import { MAXIMUM_ATTACHMENT_BYTES, attachmentUrl } from "../attachments.mjs";
|
|
11
11
|
function telegramConversation(chatId) {
|
|
@@ -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-BYl-5kFi.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";
|
|
@@ -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 { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
8
8
|
import { gateway, generateText } from "ai";
|
|
9
9
|
const MAXIMUM_IMAGE_DESCRIPTION_BYTES = 5242880;
|
|
10
10
|
const MAXIMUM_NATIVE_IMAGE_BYTES = 3145728;
|
|
@@ -37,6 +37,8 @@ export declare class InboundRequest {
|
|
|
37
37
|
stopTyping: (() => void) | undefined;
|
|
38
38
|
lifecycle: ReturnType<typeof import("./lifecycle.js").attachmentLifecycle> | undefined;
|
|
39
39
|
lifecycleKey: string | undefined;
|
|
40
|
+
/** An admitted task must be redelivered if processing did not reach durable queue admission. */
|
|
41
|
+
retryReference: string | undefined;
|
|
40
42
|
lifecycleContext: string | undefined;
|
|
41
43
|
monitor: ((session: Awaited<ReturnType<ChannelSource<unknown>["send"]>>, marker: string) => void) | undefined;
|
|
42
44
|
previousText: string | undefined;
|
|
@@ -4,5 +4,5 @@ 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 { i as withReplacedText, n as currentInboundRequest, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { i as withReplacedText, n as currentInboundRequest, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
8
8
|
export { InboundRequest, currentInboundRequest, runInboundRequest, withReplacedText };
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { conversationLanguage, telegramPrincipal } from "./principal.mjs";
|
|
8
|
-
import { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
9
9
|
import { startTypingHeartbeat, typingUntilComplete } from "./lifecycle.mjs";
|
|
10
10
|
import { formatAddress, messageAddress, scopedAddress } from "./sessions.mjs";
|
|
11
11
|
import { contentShape, messageContent } from "./content.mjs";
|
|
@@ -401,11 +401,12 @@ async function handleInboundMessage(input) {
|
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
403
|
} catch (error) {
|
|
404
|
-
reportTelegramError("intake_admission_failed", error, {
|
|
404
|
+
input.request.retryReference = reportTelegramError("intake_admission_failed", error, {
|
|
405
405
|
chatId: sent.chat.id,
|
|
406
406
|
messageId: sent.messageId
|
|
407
407
|
});
|
|
408
408
|
input.request.lifecycle = void 0;
|
|
409
|
+
return null;
|
|
409
410
|
}
|
|
410
411
|
}
|
|
411
412
|
if (input.request !== void 0) {
|
|
@@ -4,9 +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 { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BYl-5kFi.mjs";
|
|
8
8
|
import { object } from "../confirmation-description.mjs";
|
|
9
|
-
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
9
|
+
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
10
10
|
import { needsConfirmation } from "../confirmations.mjs";
|
|
11
11
|
import { actionToolName, ontologyTools } from "../ontology-tools.mjs";
|
|
12
12
|
function attachmentLifecycle(options) {
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { DEFAULT_IMAGE_DESCRIPTION_MODEL } from "../../config.mjs";
|
|
8
|
-
import { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
9
9
|
function planMedia(capabilities, descriptionModel = null) {
|
|
10
10
|
if (typeof descriptionModel === "string") return {
|
|
11
11
|
images: "describe",
|
|
@@ -8,7 +8,7 @@ import "./principal.mjs";
|
|
|
8
8
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
9
9
|
import { splitTelegramText } from "./format.mjs";
|
|
10
10
|
import { inTelegramSendQueue } from "./send-queue.mjs";
|
|
11
|
-
import { a as TelegramDeliveryError, l as customerMessage, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
11
|
+
import { a as TelegramDeliveryError, l as customerMessage, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
12
12
|
import { agentMessage, observedChatKey } from "./observed.mjs";
|
|
13
13
|
const SILENT_MARKERS = new Set(["[silent]", "no_reply"]);
|
|
14
14
|
function isSilentReply(text) {
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { memberIdOf } from "./principal.mjs";
|
|
8
8
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
9
|
-
import { c as customerCopy, d as failureText, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
9
|
+
import { c as customerCopy, d as failureText, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
10
10
|
const telegramFailureEvents = {
|
|
11
11
|
async "turn.cancelled"(event, channel, context) {
|
|
12
12
|
const errorId = reportTelegramError("turn_cancelled", event, {
|
|
@@ -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 { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B98tr4Pd.mjs";
|
|
8
8
|
import "../connection-proxy.mjs";
|
|
9
9
|
import { gateway, transcribe } from "ai";
|
|
10
10
|
const LABELS = {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** JSON data produced by SDK tools and conversation archive events. */
|
|
2
|
+
export type WorkflowSerializable = null | boolean | number | string | WorkflowSerializable[] | {
|
|
3
|
+
[key: string]: WorkflowSerializable;
|
|
4
|
+
};
|
|
5
|
+
export interface SerializationIssue {
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly reason: string;
|
|
8
|
+
readonly cause?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface SerializationContext {
|
|
11
|
+
readonly boundary: string;
|
|
12
|
+
readonly toolName?: string;
|
|
13
|
+
readonly toolCallId?: string;
|
|
14
|
+
readonly eventType?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Never mutate a provider result; read own data fields without invoking their getters.
|
|
18
|
+
* Undefined/functions/symbols disappear from
|
|
19
|
+
* objects and become null in arrays. An active-ancestor set breaks cycles without losing shared
|
|
20
|
+
* references. Limits also protect the durable writer from hostile proxies or excessively deep data.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toWorkflowSerializable(value: unknown, report?: (issue: SerializationIssue) => void): WorkflowSerializable;
|
|
23
|
+
/** Log paths and types, never payloads, provider bodies or credential values. */
|
|
24
|
+
export declare function workflowValue(value: unknown, context: SerializationContext): WorkflowSerializable;
|
|
25
|
+
/** Normalize only results authored by this SDK; leave Eve's execution and approval policy intact. */
|
|
26
|
+
export declare function workflowToolResult(value: unknown, context: {
|
|
27
|
+
readonly toolName: string;
|
|
28
|
+
readonly callId: string;
|
|
29
|
+
}): WorkflowSerializable;
|
|
@@ -0,0 +1,8 @@
|
|
|
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 { n as workflowToolResult, r as workflowValue, t as toWorkflowSerializable } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
8
|
+
export { toWorkflowSerializable, workflowToolResult, workflowValue };
|
|
@@ -2,29 +2,7 @@
|
|
|
2
2
|
* `segmentstream__attachments_discard`: drops an attachment at once. It can no longer be read or
|
|
3
3
|
* promoted, and its file is deleted by the platform's maintenance.
|
|
4
4
|
*/
|
|
5
|
-
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, {
|
|
6
|
-
|
|
7
|
-
promotion?: {} | undefined;
|
|
8
|
-
expires_at?: string | undefined;
|
|
9
|
-
state?: string | undefined;
|
|
10
|
-
id: string;
|
|
11
|
-
filename: string;
|
|
12
|
-
content_type: string;
|
|
13
|
-
size: number;
|
|
14
|
-
sha256: string;
|
|
15
|
-
};
|
|
16
|
-
}> & {
|
|
17
|
-
execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
|
|
18
|
-
attachment: {
|
|
19
|
-
promotion?: {} | undefined;
|
|
20
|
-
expires_at?: string | undefined;
|
|
21
|
-
state?: string | undefined;
|
|
22
|
-
id: string;
|
|
23
|
-
filename: string;
|
|
24
|
-
content_type: string;
|
|
25
|
-
size: number;
|
|
26
|
-
sha256: string;
|
|
27
|
-
};
|
|
28
|
-
}>;
|
|
5
|
+
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, import("../lib/workflow-serializable.js").WorkflowSerializable> & {
|
|
6
|
+
execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<import("../lib/workflow-serializable.js").WorkflowSerializable>;
|
|
29
7
|
};
|
|
30
8
|
export default _default;
|
|
@@ -4,6 +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 { n as workflowToolResult } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
7
8
|
import { ID_INPUT, attachmentForModel, attachmentOwner, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
|
|
8
9
|
import { defineTool } from "eve/tools";
|
|
9
10
|
var attachments_discard_default = defineTool({
|
|
@@ -16,7 +17,7 @@ var attachments_discard_default = defineTool({
|
|
|
16
17
|
sessionId: ctx.session.id
|
|
17
18
|
});
|
|
18
19
|
const attachment = await toolAttachments().discard(owner, stringArgument(input, "id"));
|
|
19
|
-
return { attachment: attachmentForModel(attachment) };
|
|
20
|
+
return workflowToolResult({ attachment: attachmentForModel(attachment) }, ctx);
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
export { attachments_discard_default as default };
|
|
@@ -2,29 +2,7 @@
|
|
|
2
2
|
* `segmentstream__attachments_list`: the files the member sent in this chat and session that are
|
|
3
3
|
* still available. Mounted with the extension, so it is there even with `defaultTools: false`.
|
|
4
4
|
*/
|
|
5
|
-
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, {
|
|
6
|
-
|
|
7
|
-
promotion?: {} | undefined;
|
|
8
|
-
expires_at?: string | undefined;
|
|
9
|
-
state?: string | undefined;
|
|
10
|
-
id: string;
|
|
11
|
-
filename: string;
|
|
12
|
-
content_type: string;
|
|
13
|
-
size: number;
|
|
14
|
-
sha256: string;
|
|
15
|
-
}[];
|
|
16
|
-
}> & {
|
|
17
|
-
execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
|
|
18
|
-
attachments: {
|
|
19
|
-
promotion?: {} | undefined;
|
|
20
|
-
expires_at?: string | undefined;
|
|
21
|
-
state?: string | undefined;
|
|
22
|
-
id: string;
|
|
23
|
-
filename: string;
|
|
24
|
-
content_type: string;
|
|
25
|
-
size: number;
|
|
26
|
-
sha256: string;
|
|
27
|
-
}[];
|
|
28
|
-
}>;
|
|
5
|
+
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, import("../lib/workflow-serializable.js").WorkflowSerializable> & {
|
|
6
|
+
execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<import("../lib/workflow-serializable.js").WorkflowSerializable>;
|
|
29
7
|
};
|
|
30
8
|
export default _default;
|
|
@@ -4,6 +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 { n as workflowToolResult } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
7
8
|
import { attachmentForModel, attachmentOwner, toolAttachments } from "../lib/attachment-tools.mjs";
|
|
8
9
|
import { defineTool } from "eve/tools";
|
|
9
10
|
var attachments_list_default = defineTool({
|
|
@@ -19,7 +20,8 @@ var attachments_list_default = defineTool({
|
|
|
19
20
|
principal: ctx.session.auth.current,
|
|
20
21
|
sessionId: ctx.session.id
|
|
21
22
|
});
|
|
22
|
-
|
|
23
|
+
const attachments = await toolAttachments().list(owner);
|
|
24
|
+
return workflowToolResult({ attachments: attachments.map(attachmentForModel) }, ctx);
|
|
23
25
|
}
|
|
24
26
|
});
|
|
25
27
|
export { attachments_list_default as default };
|
|
@@ -4,33 +4,7 @@
|
|
|
4
4
|
* hands the action the file already stored, so nothing is uploaded again, and a file whose SHA-256
|
|
5
5
|
* was already promoted through the same action is not stored twice.
|
|
6
6
|
*/
|
|
7
|
-
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, {
|
|
8
|
-
|
|
9
|
-
promotion?: {} | undefined;
|
|
10
|
-
expires_at?: string | undefined;
|
|
11
|
-
state?: string | undefined;
|
|
12
|
-
id: string;
|
|
13
|
-
filename: string;
|
|
14
|
-
content_type: string;
|
|
15
|
-
size: number;
|
|
16
|
-
sha256: string;
|
|
17
|
-
};
|
|
18
|
-
deduplicated: boolean;
|
|
19
|
-
result: unknown;
|
|
20
|
-
}> & {
|
|
21
|
-
execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
|
|
22
|
-
attachment: {
|
|
23
|
-
promotion?: {} | undefined;
|
|
24
|
-
expires_at?: string | undefined;
|
|
25
|
-
state?: string | undefined;
|
|
26
|
-
id: string;
|
|
27
|
-
filename: string;
|
|
28
|
-
content_type: string;
|
|
29
|
-
size: number;
|
|
30
|
-
sha256: string;
|
|
31
|
-
};
|
|
32
|
-
deduplicated: boolean;
|
|
33
|
-
result: unknown;
|
|
34
|
-
}>;
|
|
7
|
+
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, import("../lib/workflow-serializable.js").WorkflowSerializable> & {
|
|
8
|
+
execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<import("../lib/workflow-serializable.js").WorkflowSerializable>;
|
|
35
9
|
};
|
|
36
10
|
export default _default;
|
|
@@ -6,6 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { actionApproval } from "../lib/confirmations.mjs";
|
|
8
8
|
import { ontologyTools, promotionTarget } from "../lib/ontology-tools.mjs";
|
|
9
|
+
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
9
10
|
import { attachmentForModel, attachmentOwner, optionalObject, optionalString, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
|
|
10
11
|
import { defineTool } from "eve/tools";
|
|
11
12
|
var attachments_promote_default = defineTool({
|
|
@@ -76,11 +77,11 @@ var attachments_promote_default = defineTool({
|
|
|
76
77
|
...field === void 0 ? {} : { field },
|
|
77
78
|
...recordId === void 0 ? {} : { recordId }
|
|
78
79
|
});
|
|
79
|
-
return {
|
|
80
|
+
return workflowToolResult({
|
|
80
81
|
attachment: attachmentForModel(promoted.attachment),
|
|
81
82
|
deduplicated: promoted.deduplicated,
|
|
82
83
|
result: promoted.result
|
|
83
|
-
};
|
|
84
|
+
}, ctx);
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
export { attachments_promote_default as default };
|
|
@@ -4,6 +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 { n as workflowToolResult } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
7
8
|
import { ID_INPUT, attachmentOwner, headerArgument, optionalString, pageInteger, readOutput, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
|
|
8
9
|
import { readStoredFile } from "../lib/stored-files.mjs";
|
|
9
10
|
import { defineTool } from "eve/tools";
|
|
@@ -64,14 +65,14 @@ var attachments_read_default = defineTool({
|
|
|
64
65
|
id: stringArgument(input, "id"),
|
|
65
66
|
...optionalString(input, "property") === void 0 ? {} : { property: optionalString(input, "property") }
|
|
66
67
|
}, ctx.session.auth.current);
|
|
67
|
-
return readOutput(attachment, bytes, {
|
|
68
|
+
return workflowToolResult(await readOutput(attachment, bytes, {
|
|
68
69
|
sheet: optionalString(input, "sheet"),
|
|
69
70
|
offset: pageInteger(input.offset, 0),
|
|
70
71
|
...input.limit === void 0 ? {} : { limit: pageInteger(input.limit, 100, 5e4) },
|
|
71
72
|
character_offset: pageInteger(input.character_offset, 0),
|
|
72
73
|
...input.header_row === void 0 ? {} : { header_row: headerArgument(input.header_row) },
|
|
73
74
|
...input.date_order === "day_first" || input.date_order === "month_first" ? { date_order: input.date_order } : {}
|
|
74
|
-
});
|
|
75
|
+
}), ctx);
|
|
75
76
|
},
|
|
76
77
|
toModelOutput(output) {
|
|
77
78
|
if (output.kind !== "file") return {
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>,
|
|
2
|
-
readonly files: ReadonlyArray<import("../lib/telegram/attachments-send.js").SentFile>;
|
|
3
|
-
} | {
|
|
4
|
-
readonly error: string;
|
|
5
|
-
readonly detail: string;
|
|
6
|
-
readonly reference: string;
|
|
7
|
-
}>;
|
|
1
|
+
declare const _default: import("eve/tools").ToolDefinition<Record<string, unknown>, import("../lib/workflow-serializable.js").WorkflowSerializable>;
|
|
8
2
|
export default _default;
|
|
@@ -5,6 +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 { n as workflowToolResult } from "../../_chunks/workflow-serializable-BwttWNmY.mjs";
|
|
8
9
|
import { sendAttachments, sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
|
|
9
10
|
import { defineTool } from "eve/tools";
|
|
10
11
|
var attachments_send_default = defineTool({
|
|
@@ -47,13 +48,13 @@ var attachments_send_default = defineTool({
|
|
|
47
48
|
additionalProperties: false
|
|
48
49
|
},
|
|
49
50
|
label: { start: () => "Send stored attachments to Telegram" },
|
|
50
|
-
execute(input, ctx) {
|
|
51
|
-
return sendAttachments({
|
|
51
|
+
async execute(input, ctx) {
|
|
52
|
+
return workflowToolResult(await sendAttachments({
|
|
52
53
|
input: sendAttachmentsInput(input),
|
|
53
54
|
principal: ctx.session.auth.current,
|
|
54
55
|
sessionId: ctx.session.id,
|
|
55
56
|
connection: segmentstream.config.channels.telegram?.connection
|
|
56
|
-
});
|
|
57
|
+
}), ctx);
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
60
|
export { attachments_send_default as default };
|