@sentry/junior 0.78.0 → 0.80.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/{agent-hooks-OFDNZJB2.js → agent-hooks-ZGTDOXQY.js} +11 -10
- package/dist/api-reference.d.ts +1 -1
- package/dist/app.js +39 -41
- package/dist/catalog-runtime-IVWRAPSI.js +12 -0
- package/dist/chat/conversation-privacy.d.ts +4 -0
- package/dist/chat/plugins/catalog-runtime.d.ts +1 -0
- package/dist/chat/plugins/registry.d.ts +27 -26
- package/dist/chat/sentry-payload-filter.d.ts +14 -0
- package/dist/chat/sentry.d.ts +1 -1
- package/dist/chat/state/session-log.d.ts +84 -0
- package/dist/chat/tools/advisor/tool.d.ts +1 -0
- package/dist/chat/tools/definition.d.ts +6 -0
- package/dist/{chunk-LUNMJQ7D.js → chunk-2AJ4TEKE.js} +6 -6
- package/dist/{chunk-ST6YNAXG.js → chunk-3DA7X2U3.js} +6 -3
- package/dist/{chunk-PNGAJ75P.js → chunk-3JKTVW4R.js} +7 -8
- package/dist/{chunk-Q6XFTRV5.js → chunk-4XHCVBXH.js} +2 -2
- package/dist/{chunk-Z4CIQ3EB.js → chunk-66NX7MNW.js} +1 -1
- package/dist/{chunk-Q3XNY442.js → chunk-6APU57E6.js} +1 -3
- package/dist/{chunk-T77LUIX3.js → chunk-ABRNFE3N.js} +7 -211
- package/dist/chunk-DR75T7J3.js +225 -0
- package/dist/{chunk-KIDP757T.js → chunk-FAGWUF44.js} +17 -7
- package/dist/{chunk-OJ53FYVG.js → chunk-FTMXFBDC.js} +14 -0
- package/dist/{chunk-RARSKPVT.js → chunk-GUO4EE7L.js} +2 -2
- package/dist/{chunk-2ECJXSVQ.js → chunk-IOBSRZK5.js} +1 -1
- package/dist/{chunk-EJN6G5A2.js → chunk-KF7522P3.js} +5 -19
- package/dist/{chunk-C2YBH4S6.js → chunk-LX5GBMEP.js} +6 -6
- package/dist/{chunk-237T7XAN.js → chunk-PQ2U2AO3.js} +3 -3
- package/dist/{chunk-YLVJRYTD.js → chunk-TW23AT22.js} +190 -196
- package/dist/{chunk-2MSW5BZY.js → chunk-W2QGQCKG.js} +129 -62
- package/dist/{chunk-Y3EG7S7P.js → chunk-WCXVEQPI.js} +7 -8
- package/dist/{chunk-LXTPBU4K.js → chunk-X2FL5ZH5.js} +1 -1
- package/dist/{chunk-SSWBYEFH.js → chunk-Y3YUOEAZ.js} +13 -7
- package/dist/{chunk-QDQVOMBA.js → chunk-YA2JCC7G.js} +165 -14
- package/dist/{chunk-VALUBQ7R.js → chunk-ZPCGQRFJ.js} +1 -1
- package/dist/cli/chat.js +12 -10
- package/dist/cli/check.js +7 -7
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +17 -16
- package/dist/cli/snapshot-warmup.js +14 -15
- package/dist/cli/upgrade.js +20 -22
- package/dist/db-GQJKBX5W.js +18 -0
- package/dist/instrumentation.js +76 -3
- package/dist/nitro.js +8 -7
- package/dist/reporting/conversations.d.ts +30 -0
- package/dist/reporting.d.ts +1 -1
- package/dist/reporting.js +115 -24
- package/dist/{runner-WW4GJFUB.js → runner-JOVPVMIH.js} +18 -17
- package/dist/{sentry-4CP5NNQ5.js → sentry-EGFOV3DH.js} +5 -3
- package/dist/validation-TN6HMZAD.js +15 -0
- package/package.json +4 -4
- package/dist/db-NGQ3JCMF.js +0 -17
- package/dist/registry-RRIDPJBT.js +0 -46
- package/dist/validation-MDMYBRFB.js +0 -15
|
@@ -217,9 +217,6 @@ function listReferenceFiles() {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// src/chat/plugins/package-discovery.ts
|
|
221
|
-
import path3 from "path";
|
|
222
|
-
|
|
223
220
|
// src/package-resolution.ts
|
|
224
221
|
import { statSync as statSync2 } from "fs";
|
|
225
222
|
import { createRequire } from "module";
|
|
@@ -357,6 +354,7 @@ function resolvePackageDir(cwd, packageName) {
|
|
|
357
354
|
}
|
|
358
355
|
|
|
359
356
|
// src/chat/plugins/package-discovery.ts
|
|
357
|
+
import path3 from "path";
|
|
360
358
|
function normalizeForGlob(targetPath) {
|
|
361
359
|
return targetPath.split(path3.sep).join("/");
|
|
362
360
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveConversationPrivacy,
|
|
3
|
+
toGenAiMessageMetadata,
|
|
4
|
+
toGenAiMessagesTraceAttributes,
|
|
5
|
+
toGenAiTextMetadata
|
|
6
|
+
} from "./chunk-DR75T7J3.js";
|
|
1
7
|
import {
|
|
2
8
|
extractGenAiUsageAttributes,
|
|
3
9
|
logException,
|
|
4
10
|
logWarn,
|
|
5
11
|
serializeGenAiAttribute,
|
|
6
12
|
setSpanAttributes,
|
|
7
|
-
toOptionalString,
|
|
8
13
|
withSpan
|
|
9
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KF7522P3.js";
|
|
10
15
|
|
|
11
16
|
// src/chat/turn-context-tag.ts
|
|
12
17
|
var TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
@@ -253,205 +258,6 @@ import {
|
|
|
253
258
|
streamSimpleAnthropic
|
|
254
259
|
} from "@earendil-works/pi-ai/anthropic";
|
|
255
260
|
|
|
256
|
-
// src/chat/slack/context.ts
|
|
257
|
-
function toTrimmedSlackString(value) {
|
|
258
|
-
const normalized = toOptionalString(value);
|
|
259
|
-
return normalized?.trim() || void 0;
|
|
260
|
-
}
|
|
261
|
-
function parseSlackThreadId(threadId) {
|
|
262
|
-
const normalizedThreadId = toTrimmedSlackString(threadId);
|
|
263
|
-
if (!normalizedThreadId) {
|
|
264
|
-
return void 0;
|
|
265
|
-
}
|
|
266
|
-
const parts = normalizedThreadId.split(":");
|
|
267
|
-
if (parts.length !== 3 || parts[0] !== "slack") {
|
|
268
|
-
return void 0;
|
|
269
|
-
}
|
|
270
|
-
const channelId = toTrimmedSlackString(parts[1]);
|
|
271
|
-
const threadTs = toTrimmedSlackString(parts[2]);
|
|
272
|
-
if (!channelId || !threadTs) {
|
|
273
|
-
return void 0;
|
|
274
|
-
}
|
|
275
|
-
return { channelId, threadTs };
|
|
276
|
-
}
|
|
277
|
-
function resolveSlackChannelIdFromThreadId(threadId) {
|
|
278
|
-
return parseSlackThreadId(threadId)?.channelId;
|
|
279
|
-
}
|
|
280
|
-
function resolveSlackChannelIdFromMessage(message) {
|
|
281
|
-
const messageChannelId = toTrimmedSlackString(
|
|
282
|
-
message.channelId
|
|
283
|
-
);
|
|
284
|
-
if (messageChannelId) {
|
|
285
|
-
return messageChannelId;
|
|
286
|
-
}
|
|
287
|
-
const raw = message.raw;
|
|
288
|
-
if (raw && typeof raw === "object") {
|
|
289
|
-
const rawChannel = toTrimmedSlackString(
|
|
290
|
-
raw.channel
|
|
291
|
-
);
|
|
292
|
-
if (rawChannel) {
|
|
293
|
-
return rawChannel;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
const threadId = toTrimmedSlackString(
|
|
297
|
-
message.threadId
|
|
298
|
-
);
|
|
299
|
-
return resolveSlackChannelIdFromThreadId(threadId);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// src/chat/conversation-privacy.ts
|
|
303
|
-
var SAFE_METADATA_KEY_LIMIT = 20;
|
|
304
|
-
function conversationPrivacyFromChannelId(channelId) {
|
|
305
|
-
const normalized = channelId?.trim();
|
|
306
|
-
if (!normalized) return void 0;
|
|
307
|
-
return normalized.startsWith("C") ? "public" : "private";
|
|
308
|
-
}
|
|
309
|
-
function conversationPrivacyFromConversationId(conversationId) {
|
|
310
|
-
if (!conversationId?.trim()) return void 0;
|
|
311
|
-
const slackThread = parseSlackThreadId(conversationId);
|
|
312
|
-
if (slackThread) {
|
|
313
|
-
return conversationPrivacyFromChannelId(slackThread.channelId);
|
|
314
|
-
}
|
|
315
|
-
return "private";
|
|
316
|
-
}
|
|
317
|
-
function resolveConversationPrivacy(input) {
|
|
318
|
-
return conversationPrivacyFromChannelId(input.channelId) ?? conversationPrivacyFromConversationId(input.conversationId);
|
|
319
|
-
}
|
|
320
|
-
function canExposeConversationPayload(input) {
|
|
321
|
-
return resolveConversationPrivacy(input) === "public";
|
|
322
|
-
}
|
|
323
|
-
function contentMetadata(content) {
|
|
324
|
-
if (typeof content === "string") {
|
|
325
|
-
return [{ type: "text", chars: content.length }];
|
|
326
|
-
}
|
|
327
|
-
if (!Array.isArray(content)) {
|
|
328
|
-
return { type: typeof content };
|
|
329
|
-
}
|
|
330
|
-
return content.map((part) => {
|
|
331
|
-
if (!part || typeof part !== "object") {
|
|
332
|
-
return { type: typeof part };
|
|
333
|
-
}
|
|
334
|
-
const record = part;
|
|
335
|
-
const type = typeof record.type === "string" ? record.type : "unknown";
|
|
336
|
-
return {
|
|
337
|
-
type,
|
|
338
|
-
...typeof record.text === "string" ? { chars: record.text.length } : {},
|
|
339
|
-
...typeof record.mimeType === "string" ? { mimeType: record.mimeType } : {},
|
|
340
|
-
...typeof record.mediaType === "string" ? { mediaType: record.mediaType } : {},
|
|
341
|
-
...typeof record.data === "string" ? { dataChars: record.data.length } : {}
|
|
342
|
-
};
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
function toGenAiMessageMetadata(message) {
|
|
346
|
-
const record = message && typeof message === "object" ? message : {};
|
|
347
|
-
return {
|
|
348
|
-
role: record.role,
|
|
349
|
-
content: contentMetadata(record.content)
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function toGenAiTextMetadata(text) {
|
|
353
|
-
return { type: "text", chars: text.length };
|
|
354
|
-
}
|
|
355
|
-
function payloadType(payload) {
|
|
356
|
-
return Array.isArray(payload) ? "array" : typeof payload;
|
|
357
|
-
}
|
|
358
|
-
function payloadKeys(payload) {
|
|
359
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
360
|
-
return void 0;
|
|
361
|
-
}
|
|
362
|
-
const keys = Object.keys(payload).slice(
|
|
363
|
-
0,
|
|
364
|
-
SAFE_METADATA_KEY_LIMIT
|
|
365
|
-
);
|
|
366
|
-
return keys.length > 0 ? keys : void 0;
|
|
367
|
-
}
|
|
368
|
-
function serializedLength(payload) {
|
|
369
|
-
const serialized = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
370
|
-
return serialized?.length ?? 0;
|
|
371
|
-
}
|
|
372
|
-
function toGenAiPayloadMetadata(payload) {
|
|
373
|
-
const base = {
|
|
374
|
-
type: payloadType(payload),
|
|
375
|
-
chars: serializedLength(payload)
|
|
376
|
-
};
|
|
377
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
378
|
-
return base;
|
|
379
|
-
}
|
|
380
|
-
const keys = payloadKeys(payload);
|
|
381
|
-
return {
|
|
382
|
-
...base,
|
|
383
|
-
...keys ? { keys } : {}
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
function toGenAiPayloadTraceAttributes(prefix, payload) {
|
|
387
|
-
const attributes = {
|
|
388
|
-
[`${prefix}.type`]: payloadType(payload),
|
|
389
|
-
[`${prefix}.size_chars`]: serializedLength(payload)
|
|
390
|
-
};
|
|
391
|
-
const keys = payloadKeys(payload);
|
|
392
|
-
if (keys) {
|
|
393
|
-
attributes[`${prefix}.keys`] = keys;
|
|
394
|
-
}
|
|
395
|
-
return attributes;
|
|
396
|
-
}
|
|
397
|
-
function summarizeContent(content) {
|
|
398
|
-
if (typeof content === "string") {
|
|
399
|
-
return { chars: content.length, partTypes: ["text"] };
|
|
400
|
-
}
|
|
401
|
-
if (!Array.isArray(content)) {
|
|
402
|
-
return {
|
|
403
|
-
chars: serializedLength(content),
|
|
404
|
-
partTypes: [payloadType(content)]
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
let chars = 0;
|
|
408
|
-
const partTypes = /* @__PURE__ */ new Set();
|
|
409
|
-
for (const part of content) {
|
|
410
|
-
if (!part || typeof part !== "object") {
|
|
411
|
-
chars += serializedLength(part);
|
|
412
|
-
partTypes.add(payloadType(part));
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
const record = part;
|
|
416
|
-
const type = typeof record.type === "string" ? record.type : "unknown";
|
|
417
|
-
partTypes.add(type);
|
|
418
|
-
if (typeof record.text === "string") {
|
|
419
|
-
chars += record.text.length;
|
|
420
|
-
} else if (typeof record.data === "string") {
|
|
421
|
-
chars += record.data.length;
|
|
422
|
-
} else {
|
|
423
|
-
chars += serializedLength(part);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
return { chars, partTypes: [...partTypes] };
|
|
427
|
-
}
|
|
428
|
-
function toGenAiMessagesTraceAttributes(prefix, messages) {
|
|
429
|
-
let contentChars = 0;
|
|
430
|
-
const roles = /* @__PURE__ */ new Set();
|
|
431
|
-
const partTypes = /* @__PURE__ */ new Set();
|
|
432
|
-
for (const message of messages) {
|
|
433
|
-
if (!message || typeof message !== "object") {
|
|
434
|
-
contentChars += serializedLength(message);
|
|
435
|
-
continue;
|
|
436
|
-
}
|
|
437
|
-
const record = message;
|
|
438
|
-
if (typeof record.role === "string") {
|
|
439
|
-
roles.add(record.role);
|
|
440
|
-
}
|
|
441
|
-
const summary = summarizeContent(record.content);
|
|
442
|
-
contentChars += summary.chars;
|
|
443
|
-
for (const partType of summary.partTypes) {
|
|
444
|
-
partTypes.add(partType);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
return {
|
|
448
|
-
[`${prefix}.message_count`]: messages.length,
|
|
449
|
-
[`${prefix}.content_chars`]: contentChars,
|
|
450
|
-
...roles.size > 0 ? { [`${prefix}.roles`]: [...roles] } : {},
|
|
451
|
-
...partTypes.size > 0 ? { [`${prefix}.part_types`]: [...partTypes] } : {}
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
261
|
// src/chat/services/provider-retry.ts
|
|
456
262
|
var PROVIDER_RETRY_DELAYS_MS = [2e3, 4e3, 8e3];
|
|
457
263
|
var PROVIDER_ERROR_PREFIX = "AI provider error:";
|
|
@@ -1050,16 +856,6 @@ function setSlackReactionConfig(overrides) {
|
|
|
1050
856
|
|
|
1051
857
|
export {
|
|
1052
858
|
toOptionalTrimmed,
|
|
1053
|
-
parseSlackThreadId,
|
|
1054
|
-
resolveSlackChannelIdFromThreadId,
|
|
1055
|
-
resolveSlackChannelIdFromMessage,
|
|
1056
|
-
resolveConversationPrivacy,
|
|
1057
|
-
canExposeConversationPayload,
|
|
1058
|
-
toGenAiMessageMetadata,
|
|
1059
|
-
toGenAiTextMetadata,
|
|
1060
|
-
toGenAiPayloadMetadata,
|
|
1061
|
-
toGenAiPayloadTraceAttributes,
|
|
1062
|
-
toGenAiMessagesTraceAttributes,
|
|
1063
859
|
TURN_CONTEXT_TAG,
|
|
1064
860
|
getSessionIdentifiers,
|
|
1065
861
|
isExecutionEscapeResponse,
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toOptionalString
|
|
3
|
+
} from "./chunk-FTMXFBDC.js";
|
|
4
|
+
|
|
5
|
+
// src/chat/slack/context.ts
|
|
6
|
+
function toTrimmedSlackString(value) {
|
|
7
|
+
const normalized = toOptionalString(value);
|
|
8
|
+
return normalized?.trim() || void 0;
|
|
9
|
+
}
|
|
10
|
+
function parseSlackThreadId(threadId) {
|
|
11
|
+
const normalizedThreadId = toTrimmedSlackString(threadId);
|
|
12
|
+
if (!normalizedThreadId) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
const parts = normalizedThreadId.split(":");
|
|
16
|
+
if (parts.length !== 3 || parts[0] !== "slack") {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
const channelId = toTrimmedSlackString(parts[1]);
|
|
20
|
+
const threadTs = toTrimmedSlackString(parts[2]);
|
|
21
|
+
if (!channelId || !threadTs) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
return { channelId, threadTs };
|
|
25
|
+
}
|
|
26
|
+
function resolveSlackChannelIdFromThreadId(threadId) {
|
|
27
|
+
return parseSlackThreadId(threadId)?.channelId;
|
|
28
|
+
}
|
|
29
|
+
function resolveSlackChannelIdFromMessage(message) {
|
|
30
|
+
const messageChannelId = toTrimmedSlackString(
|
|
31
|
+
message.channelId
|
|
32
|
+
);
|
|
33
|
+
if (messageChannelId) {
|
|
34
|
+
return messageChannelId;
|
|
35
|
+
}
|
|
36
|
+
const raw = message.raw;
|
|
37
|
+
if (raw && typeof raw === "object") {
|
|
38
|
+
const rawChannel = toTrimmedSlackString(
|
|
39
|
+
raw.channel
|
|
40
|
+
);
|
|
41
|
+
if (rawChannel) {
|
|
42
|
+
return rawChannel;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const threadId = toTrimmedSlackString(
|
|
46
|
+
message.threadId
|
|
47
|
+
);
|
|
48
|
+
return resolveSlackChannelIdFromThreadId(threadId);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/chat/conversation-privacy.ts
|
|
52
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
53
|
+
var SAFE_METADATA_KEY_LIMIT = 20;
|
|
54
|
+
var conversationPrivacyStorage = new AsyncLocalStorage();
|
|
55
|
+
function conversationPrivacyFromChannelId(channelId) {
|
|
56
|
+
const normalized = channelId?.trim();
|
|
57
|
+
if (!normalized) return void 0;
|
|
58
|
+
return normalized.startsWith("C") ? "public" : "private";
|
|
59
|
+
}
|
|
60
|
+
function conversationPrivacyFromConversationId(conversationId) {
|
|
61
|
+
if (!conversationId?.trim()) return void 0;
|
|
62
|
+
const slackThread = parseSlackThreadId(conversationId);
|
|
63
|
+
if (slackThread) {
|
|
64
|
+
return conversationPrivacyFromChannelId(slackThread.channelId);
|
|
65
|
+
}
|
|
66
|
+
return "private";
|
|
67
|
+
}
|
|
68
|
+
function resolveConversationPrivacy(input) {
|
|
69
|
+
return conversationPrivacyFromChannelId(input.channelId) ?? conversationPrivacyFromConversationId(input.conversationId);
|
|
70
|
+
}
|
|
71
|
+
function canExposeConversationPayload(input) {
|
|
72
|
+
return resolveConversationPrivacy(input) === "public";
|
|
73
|
+
}
|
|
74
|
+
function getCurrentConversationPrivacy() {
|
|
75
|
+
return conversationPrivacyStorage.getStore();
|
|
76
|
+
}
|
|
77
|
+
function runWithConversationPrivacy(privacy, callback) {
|
|
78
|
+
return conversationPrivacyStorage.run(privacy, callback);
|
|
79
|
+
}
|
|
80
|
+
function contentMetadata(content) {
|
|
81
|
+
if (typeof content === "string") {
|
|
82
|
+
return [{ type: "text", chars: content.length }];
|
|
83
|
+
}
|
|
84
|
+
if (!Array.isArray(content)) {
|
|
85
|
+
return { type: typeof content };
|
|
86
|
+
}
|
|
87
|
+
return content.map((part) => {
|
|
88
|
+
if (!part || typeof part !== "object") {
|
|
89
|
+
return { type: typeof part };
|
|
90
|
+
}
|
|
91
|
+
const record = part;
|
|
92
|
+
const type = typeof record.type === "string" ? record.type : "unknown";
|
|
93
|
+
return {
|
|
94
|
+
type,
|
|
95
|
+
...typeof record.text === "string" ? { chars: record.text.length } : {},
|
|
96
|
+
...typeof record.mimeType === "string" ? { mimeType: record.mimeType } : {},
|
|
97
|
+
...typeof record.mediaType === "string" ? { mediaType: record.mediaType } : {},
|
|
98
|
+
...typeof record.data === "string" ? { dataChars: record.data.length } : {}
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function toGenAiMessageMetadata(message) {
|
|
103
|
+
const record = message && typeof message === "object" ? message : {};
|
|
104
|
+
return {
|
|
105
|
+
role: record.role,
|
|
106
|
+
content: contentMetadata(record.content)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function toGenAiTextMetadata(text) {
|
|
110
|
+
return { type: "text", chars: text.length };
|
|
111
|
+
}
|
|
112
|
+
function payloadType(payload) {
|
|
113
|
+
return Array.isArray(payload) ? "array" : typeof payload;
|
|
114
|
+
}
|
|
115
|
+
function payloadKeys(payload) {
|
|
116
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
const keys = Object.keys(payload).slice(
|
|
120
|
+
0,
|
|
121
|
+
SAFE_METADATA_KEY_LIMIT
|
|
122
|
+
);
|
|
123
|
+
return keys.length > 0 ? keys : void 0;
|
|
124
|
+
}
|
|
125
|
+
function serializedLength(payload) {
|
|
126
|
+
const serialized = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
127
|
+
return serialized?.length ?? 0;
|
|
128
|
+
}
|
|
129
|
+
function toGenAiPayloadMetadata(payload) {
|
|
130
|
+
const base = {
|
|
131
|
+
type: payloadType(payload),
|
|
132
|
+
chars: serializedLength(payload)
|
|
133
|
+
};
|
|
134
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
135
|
+
return base;
|
|
136
|
+
}
|
|
137
|
+
const keys = payloadKeys(payload);
|
|
138
|
+
return {
|
|
139
|
+
...base,
|
|
140
|
+
...keys ? { keys } : {}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function toGenAiPayloadTraceAttributes(prefix, payload) {
|
|
144
|
+
const attributes = {
|
|
145
|
+
[`${prefix}.type`]: payloadType(payload),
|
|
146
|
+
[`${prefix}.size_chars`]: serializedLength(payload)
|
|
147
|
+
};
|
|
148
|
+
const keys = payloadKeys(payload);
|
|
149
|
+
if (keys) {
|
|
150
|
+
attributes[`${prefix}.keys`] = keys;
|
|
151
|
+
}
|
|
152
|
+
return attributes;
|
|
153
|
+
}
|
|
154
|
+
function summarizeContent(content) {
|
|
155
|
+
if (typeof content === "string") {
|
|
156
|
+
return { chars: content.length, partTypes: ["text"] };
|
|
157
|
+
}
|
|
158
|
+
if (!Array.isArray(content)) {
|
|
159
|
+
return {
|
|
160
|
+
chars: serializedLength(content),
|
|
161
|
+
partTypes: [payloadType(content)]
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
let chars = 0;
|
|
165
|
+
const partTypes = /* @__PURE__ */ new Set();
|
|
166
|
+
for (const part of content) {
|
|
167
|
+
if (!part || typeof part !== "object") {
|
|
168
|
+
chars += serializedLength(part);
|
|
169
|
+
partTypes.add(payloadType(part));
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const record = part;
|
|
173
|
+
const type = typeof record.type === "string" ? record.type : "unknown";
|
|
174
|
+
partTypes.add(type);
|
|
175
|
+
if (typeof record.text === "string") {
|
|
176
|
+
chars += record.text.length;
|
|
177
|
+
} else if (typeof record.data === "string") {
|
|
178
|
+
chars += record.data.length;
|
|
179
|
+
} else {
|
|
180
|
+
chars += serializedLength(part);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return { chars, partTypes: [...partTypes] };
|
|
184
|
+
}
|
|
185
|
+
function toGenAiMessagesTraceAttributes(prefix, messages) {
|
|
186
|
+
let contentChars = 0;
|
|
187
|
+
const roles = /* @__PURE__ */ new Set();
|
|
188
|
+
const partTypes = /* @__PURE__ */ new Set();
|
|
189
|
+
for (const message of messages) {
|
|
190
|
+
if (!message || typeof message !== "object") {
|
|
191
|
+
contentChars += serializedLength(message);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const record = message;
|
|
195
|
+
if (typeof record.role === "string") {
|
|
196
|
+
roles.add(record.role);
|
|
197
|
+
}
|
|
198
|
+
const summary = summarizeContent(record.content);
|
|
199
|
+
contentChars += summary.chars;
|
|
200
|
+
for (const partType of summary.partTypes) {
|
|
201
|
+
partTypes.add(partType);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
[`${prefix}.message_count`]: messages.length,
|
|
206
|
+
[`${prefix}.content_chars`]: contentChars,
|
|
207
|
+
...roles.size > 0 ? { [`${prefix}.roles`]: [...roles] } : {},
|
|
208
|
+
...partTypes.size > 0 ? { [`${prefix}.part_types`]: [...partTypes] } : {}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export {
|
|
213
|
+
parseSlackThreadId,
|
|
214
|
+
resolveSlackChannelIdFromThreadId,
|
|
215
|
+
resolveSlackChannelIdFromMessage,
|
|
216
|
+
resolveConversationPrivacy,
|
|
217
|
+
canExposeConversationPayload,
|
|
218
|
+
getCurrentConversationPrivacy,
|
|
219
|
+
runWithConversationPrivacy,
|
|
220
|
+
toGenAiMessageMetadata,
|
|
221
|
+
toGenAiTextMetadata,
|
|
222
|
+
toGenAiPayloadMetadata,
|
|
223
|
+
toGenAiPayloadTraceAttributes,
|
|
224
|
+
toGenAiMessagesTraceAttributes
|
|
225
|
+
};
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
pluginCatalogRuntime
|
|
3
|
+
} from "./chunk-TW23AT22.js";
|
|
4
4
|
|
|
5
5
|
// src/chat/plugins/validation.ts
|
|
6
|
+
import { isDeepStrictEqual } from "util";
|
|
6
7
|
function validatePluginRegistrations(registrations) {
|
|
7
|
-
const loadedPlugins =
|
|
8
|
-
|
|
9
|
-
loadedPlugins.map((plugin) => plugin.manifest.name)
|
|
8
|
+
const loadedPlugins = new Map(
|
|
9
|
+
pluginCatalogRuntime.getProviders().map((plugin) => [plugin.manifest.name, plugin])
|
|
10
10
|
);
|
|
11
11
|
for (const registration of registrations) {
|
|
12
|
-
|
|
12
|
+
const loadedPlugin = loadedPlugins.get(registration.manifest.name);
|
|
13
|
+
if (!loadedPlugin) {
|
|
13
14
|
throw new Error(
|
|
14
15
|
`Plugin registration "${registration.manifest.name}" does not have a matching plugin manifest. Add an inline manifest, packageName, or app-local plugin.yaml with the same name.`
|
|
15
16
|
);
|
|
16
17
|
}
|
|
18
|
+
const effectiveRegistrationManifest = pluginCatalogRuntime.parseConfiguredInlineManifest(
|
|
19
|
+
registration.manifest,
|
|
20
|
+
loadedPlugin.dir
|
|
21
|
+
);
|
|
22
|
+
if (!isDeepStrictEqual(effectiveRegistrationManifest, loadedPlugin.manifest)) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Plugin registration "${registration.manifest.name}" manifest does not match the loaded plugin manifest. Use one canonical manifest source for runtime hook plugins.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
function validatePluginEgressCredentialHooks(registrations) {
|
|
@@ -23,7 +33,7 @@ function validatePluginEgressCredentialHooks(registrations) {
|
|
|
23
33
|
registration
|
|
24
34
|
])
|
|
25
35
|
);
|
|
26
|
-
for (const provider of
|
|
36
|
+
for (const provider of pluginCatalogRuntime.getProviders()) {
|
|
27
37
|
const hooks = plugins.get(provider.manifest.name)?.hooks;
|
|
28
38
|
const hasGrantHook = Boolean(hooks?.grantForEgress);
|
|
29
39
|
const hasIssueHook = Boolean(hooks?.issueCredential);
|
|
@@ -24,7 +24,21 @@ function getDeploymentTelemetryAttributes() {
|
|
|
24
24
|
return attributes;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// src/chat/coerce.ts
|
|
28
|
+
function toOptionalString(value) {
|
|
29
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
30
|
+
}
|
|
31
|
+
function toOptionalNumber(value) {
|
|
32
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
33
|
+
}
|
|
34
|
+
function isRecord(value) {
|
|
35
|
+
return typeof value === "object" && value !== null;
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
export {
|
|
39
|
+
toOptionalString,
|
|
40
|
+
toOptionalNumber,
|
|
41
|
+
isRecord,
|
|
28
42
|
JUNIOR_HEARTBEAT_ROUTE,
|
|
29
43
|
JUNIOR_HEARTBEAT_CRON_SCHEDULE,
|
|
30
44
|
JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getStateAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X2FL5ZH5.js";
|
|
4
4
|
import {
|
|
5
5
|
logException,
|
|
6
6
|
logInfo,
|
|
7
7
|
logWarn
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KF7522P3.js";
|
|
9
9
|
|
|
10
10
|
// src/chat/plugins/logging.ts
|
|
11
11
|
function createPluginLogger(plugin) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getDeploymentTelemetryAttributes
|
|
3
|
-
|
|
2
|
+
getDeploymentTelemetryAttributes,
|
|
3
|
+
toOptionalNumber,
|
|
4
|
+
toOptionalString
|
|
5
|
+
} from "./chunk-FTMXFBDC.js";
|
|
4
6
|
import {
|
|
5
7
|
captureException,
|
|
6
8
|
sentry_exports,
|
|
@@ -8,7 +10,7 @@ import {
|
|
|
8
10
|
setUser,
|
|
9
11
|
startSpan,
|
|
10
12
|
withScope
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-3DA7X2U3.js";
|
|
12
14
|
|
|
13
15
|
// src/chat/logging.ts
|
|
14
16
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -20,19 +22,6 @@ import {
|
|
|
20
22
|
getConfig,
|
|
21
23
|
getLogger
|
|
22
24
|
} from "@logtape/logtape";
|
|
23
|
-
|
|
24
|
-
// src/chat/coerce.ts
|
|
25
|
-
function toOptionalString(value) {
|
|
26
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
27
|
-
}
|
|
28
|
-
function toOptionalNumber(value) {
|
|
29
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
30
|
-
}
|
|
31
|
-
function isRecord(value) {
|
|
32
|
-
return typeof value === "object" && value !== null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/chat/logging.ts
|
|
36
25
|
var MAX_STRING_VALUE = 1200;
|
|
37
26
|
var SECRETS_RE = [
|
|
38
27
|
/\b(sk-[A-Za-z0-9_-]{20,})\b/g,
|
|
@@ -1355,9 +1344,6 @@ function isSlackConversationId(value) {
|
|
|
1355
1344
|
}
|
|
1356
1345
|
|
|
1357
1346
|
export {
|
|
1358
|
-
toOptionalString,
|
|
1359
|
-
toOptionalNumber,
|
|
1360
|
-
isRecord,
|
|
1361
1347
|
normalizeGenAiFinishReason,
|
|
1362
1348
|
createChatSdkLogger,
|
|
1363
1349
|
getLogContextAttributes,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getStateAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X2FL5ZH5.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeSlackConversationId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4XHCVBXH.js";
|
|
7
7
|
import {
|
|
8
8
|
parseSlackThreadId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DR75T7J3.js";
|
|
10
10
|
import {
|
|
11
11
|
parseStoredSlackRequester
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZPCGQRFJ.js";
|
|
13
13
|
import {
|
|
14
14
|
isRecord,
|
|
15
15
|
toOptionalNumber
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FTMXFBDC.js";
|
|
17
17
|
import {
|
|
18
18
|
getClient
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-3DA7X2U3.js";
|
|
20
20
|
|
|
21
21
|
// src/handlers/health.ts
|
|
22
22
|
function GET() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseDestination,
|
|
3
3
|
sameDestination
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4XHCVBXH.js";
|
|
5
5
|
import {
|
|
6
6
|
getChatConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ABRNFE3N.js";
|
|
8
8
|
import {
|
|
9
9
|
parseStoredSlackRequester
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZPCGQRFJ.js";
|
|
11
11
|
|
|
12
12
|
// src/chat/conversations/sql/store.ts
|
|
13
13
|
import { randomUUID } from "crypto";
|