@sentry/junior 0.41.0 → 0.42.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/dist/app.js +99 -6
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -7103,9 +7103,86 @@ function parseSlackMessageReference(input) {
|
|
|
7103
7103
|
};
|
|
7104
7104
|
}
|
|
7105
7105
|
|
|
7106
|
+
// src/chat/slack/legacy-attachments.ts
|
|
7107
|
+
var MAX_ATTACHMENTS = 10;
|
|
7108
|
+
var MAX_FIELDS_PER_ATTACHMENT = 20;
|
|
7109
|
+
var MAX_FIELD_CHARS = 1e3;
|
|
7110
|
+
var MAX_ATTACHMENT_TEXT_CHARS = 4e3;
|
|
7111
|
+
function toStr(value) {
|
|
7112
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
7113
|
+
}
|
|
7114
|
+
function getAttachmentPayload(input) {
|
|
7115
|
+
if (Array.isArray(input)) return input;
|
|
7116
|
+
if (!input || typeof input !== "object") return [];
|
|
7117
|
+
const attachments = input.attachments;
|
|
7118
|
+
return Array.isArray(attachments) ? attachments : [];
|
|
7119
|
+
}
|
|
7120
|
+
function renderField(raw) {
|
|
7121
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
7122
|
+
const obj = raw;
|
|
7123
|
+
const title = toStr(obj.title);
|
|
7124
|
+
const value = toStr(obj.value)?.slice(0, MAX_FIELD_CHARS);
|
|
7125
|
+
if (title && value) return `${title}: ${value}`;
|
|
7126
|
+
return title || value;
|
|
7127
|
+
}
|
|
7128
|
+
function renderAttachment(raw) {
|
|
7129
|
+
if (!raw || typeof raw !== "object") return "";
|
|
7130
|
+
const obj = raw;
|
|
7131
|
+
const parts = [];
|
|
7132
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7133
|
+
const fallback = toStr(obj.fallback);
|
|
7134
|
+
const pretext = toStr(obj.pretext);
|
|
7135
|
+
const authorName = toStr(obj.author_name);
|
|
7136
|
+
const title = toStr(obj.title);
|
|
7137
|
+
const titleLink = toStr(obj.title_link);
|
|
7138
|
+
const text = toStr(obj.text);
|
|
7139
|
+
const footer = toStr(obj.footer);
|
|
7140
|
+
const fields = Array.isArray(obj.fields) ? obj.fields : [];
|
|
7141
|
+
const add = (value) => {
|
|
7142
|
+
if (!value) return;
|
|
7143
|
+
const normalized = value.trim();
|
|
7144
|
+
if (!normalized || seen.has(normalized)) return;
|
|
7145
|
+
seen.add(normalized);
|
|
7146
|
+
parts.push(normalized);
|
|
7147
|
+
};
|
|
7148
|
+
const hasRichContent = pretext || title || text;
|
|
7149
|
+
if (!hasRichContent) {
|
|
7150
|
+
add(fallback);
|
|
7151
|
+
}
|
|
7152
|
+
add(pretext);
|
|
7153
|
+
add(authorName);
|
|
7154
|
+
if (title && titleLink) {
|
|
7155
|
+
add(`${title} (${titleLink})`);
|
|
7156
|
+
seen.add(title.trim());
|
|
7157
|
+
} else {
|
|
7158
|
+
add(title);
|
|
7159
|
+
}
|
|
7160
|
+
add(text);
|
|
7161
|
+
for (const field of fields.slice(0, MAX_FIELDS_PER_ATTACHMENT)) {
|
|
7162
|
+
add(renderField(field));
|
|
7163
|
+
}
|
|
7164
|
+
add(footer);
|
|
7165
|
+
return parts.join(" | ");
|
|
7166
|
+
}
|
|
7167
|
+
function renderSlackLegacyAttachmentText(input) {
|
|
7168
|
+
const rendered = getAttachmentPayload(input).slice(0, MAX_ATTACHMENTS).map(renderAttachment).filter((line) => line.length > 0).map((line) => `[attachment] ${line}`).join("\n");
|
|
7169
|
+
return rendered.slice(0, MAX_ATTACHMENT_TEXT_CHARS);
|
|
7170
|
+
}
|
|
7171
|
+
function appendSlackLegacyAttachmentText(baseText, rawMessageOrAttachments) {
|
|
7172
|
+
const base = baseText?.trim() ?? "";
|
|
7173
|
+
const attachmentText = renderSlackLegacyAttachmentText(
|
|
7174
|
+
rawMessageOrAttachments
|
|
7175
|
+
);
|
|
7176
|
+
if (!attachmentText) return base;
|
|
7177
|
+
if (!base) return attachmentText;
|
|
7178
|
+
return `${base}
|
|
7179
|
+
${attachmentText}`;
|
|
7180
|
+
}
|
|
7181
|
+
|
|
7106
7182
|
// src/chat/tools/slack/thread-read.ts
|
|
7107
7183
|
var MAX_THREAD_READ_CHARS = 4e4;
|
|
7108
7184
|
function sanitizeMessage(msg) {
|
|
7185
|
+
const attachmentText = renderSlackLegacyAttachmentText(msg.attachments);
|
|
7109
7186
|
return {
|
|
7110
7187
|
ts: msg.ts,
|
|
7111
7188
|
user: msg.user,
|
|
@@ -7114,6 +7191,7 @@ function sanitizeMessage(msg) {
|
|
|
7114
7191
|
subtype: msg.subtype,
|
|
7115
7192
|
bot_id: msg.bot_id,
|
|
7116
7193
|
type: msg.type,
|
|
7194
|
+
...attachmentText ? { attachment_text: attachmentText } : {},
|
|
7117
7195
|
...msg.files?.length ? {
|
|
7118
7196
|
files: msg.files.map((f) => ({
|
|
7119
7197
|
id: f.id,
|
|
@@ -7128,7 +7206,7 @@ function truncateMessages(messages, maxChars) {
|
|
|
7128
7206
|
let chars = 0;
|
|
7129
7207
|
const kept = [];
|
|
7130
7208
|
for (const msg of messages) {
|
|
7131
|
-
const textLen = msg.text?.length ?? 0;
|
|
7209
|
+
const textLen = (msg.text?.length ?? 0) + (msg.attachment_text?.length ?? 0);
|
|
7132
7210
|
if (kept.length > 0 && chars + textLen > maxChars) {
|
|
7133
7211
|
break;
|
|
7134
7212
|
}
|
|
@@ -15087,10 +15165,20 @@ function createSlackTurnRuntime(deps) {
|
|
|
15087
15165
|
runId
|
|
15088
15166
|
}),
|
|
15089
15167
|
async () => {
|
|
15090
|
-
const
|
|
15091
|
-
|
|
15168
|
+
const legacyAttachmentText = renderSlackLegacyAttachmentText(
|
|
15169
|
+
message.raw
|
|
15170
|
+
);
|
|
15171
|
+
const rawUserText = appendSlackLegacyAttachmentText(
|
|
15172
|
+
message.text,
|
|
15173
|
+
message.raw
|
|
15174
|
+
);
|
|
15175
|
+
const strippedUserText = deps.stripLeadingBotMention(message.text, {
|
|
15092
15176
|
stripLeadingSlackMentionToken: Boolean(message.isMention)
|
|
15093
15177
|
});
|
|
15178
|
+
const userText = appendSlackLegacyAttachmentText(
|
|
15179
|
+
strippedUserText,
|
|
15180
|
+
message.raw
|
|
15181
|
+
);
|
|
15094
15182
|
const context = {
|
|
15095
15183
|
threadId,
|
|
15096
15184
|
requesterId: message.author.userId,
|
|
@@ -15129,7 +15217,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
15129
15217
|
rawText: rawUserText,
|
|
15130
15218
|
text: userText,
|
|
15131
15219
|
conversationContext: deps.getPreparedConversationContext(preparedState),
|
|
15132
|
-
hasAttachments: message.attachments.length > 0,
|
|
15220
|
+
hasAttachments: message.attachments.length > 0 || legacyAttachmentText !== "",
|
|
15133
15221
|
isExplicitMention: Boolean(message.isMention),
|
|
15134
15222
|
context
|
|
15135
15223
|
});
|
|
@@ -16084,9 +16172,13 @@ function createReplyToThread(deps) {
|
|
|
16084
16172
|
modelId: botConfig.modelId
|
|
16085
16173
|
},
|
|
16086
16174
|
async () => {
|
|
16087
|
-
const
|
|
16175
|
+
const strippedUserText = stripLeadingBotMention(message.text, {
|
|
16088
16176
|
stripLeadingSlackMentionToken: options.explicitMention || Boolean(message.isMention)
|
|
16089
16177
|
});
|
|
16178
|
+
const userText = appendSlackLegacyAttachmentText(
|
|
16179
|
+
strippedUserText,
|
|
16180
|
+
message.raw
|
|
16181
|
+
);
|
|
16090
16182
|
const preparedState = options.preparedState ?? await deps.prepareTurnState({
|
|
16091
16183
|
thread,
|
|
16092
16184
|
message,
|
|
@@ -16525,7 +16617,8 @@ function hasPendingImageHydration(conversation) {
|
|
|
16525
16617
|
);
|
|
16526
16618
|
}
|
|
16527
16619
|
function createConversationMessageFromSdkMessage(entry) {
|
|
16528
|
-
const
|
|
16620
|
+
const enrichedText = appendSlackLegacyAttachmentText(entry.text, entry.raw);
|
|
16621
|
+
const rawText = normalizeConversationText(enrichedText);
|
|
16529
16622
|
if (!rawText) {
|
|
16530
16623
|
return null;
|
|
16531
16624
|
}
|