@sentry/junior 0.123.0 → 0.124.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-hooks-7JCABN73.js → agent-hooks-2YRIRKNT.js} +7 -7
- package/dist/api/conversations/detail.d.ts +2 -2
- package/dist/api/conversations/event-list.d.ts +2 -2
- package/dist/api/conversations/events.d.ts +1 -1
- package/dist/api/schema/conversation.d.ts +8 -8
- package/dist/api/schema.js +1 -1
- package/dist/api.js +25 -22
- package/dist/app.js +23 -23
- package/dist/{catalog-runtime-SZAS6EVH.js → catalog-runtime-R4N3NYWQ.js} +5 -5
- package/dist/chat/conversations/history.d.ts +7 -7
- package/dist/chat/conversations/projection.d.ts +13 -0
- package/dist/chat/conversations/structured-events.d.ts +31 -0
- package/dist/chat/services/provider-error.d.ts +2 -0
- package/dist/chat/tools/query-conversation-events.d.ts +1 -1
- package/dist/{chunk-DVPWU77W.js → chunk-5FEVPYXP.js} +7 -7
- package/dist/{chunk-JPG43UG7.js → chunk-5HFV6BEV.js} +9 -4
- package/dist/{chunk-VTWLP6YS.js → chunk-6RHGQF6H.js} +1 -1
- package/dist/{chunk-QKYO7ZNS.js → chunk-7SCPUYHG.js} +1 -1
- package/dist/{chunk-JMUPEYKC.js → chunk-AYQZCJZJ.js} +4 -4
- package/dist/{chunk-A3TUEGKH.js → chunk-B3Y7UZVA.js} +1 -1
- package/dist/{chunk-7YOBVIHY.js → chunk-BBSB62UJ.js} +1 -1
- package/dist/{chunk-THYOK2SL.js → chunk-DVSAX7MS.js} +3 -3
- package/dist/{chunk-5P4QBMTY.js → chunk-GI56KFRQ.js} +57 -11
- package/dist/{chunk-RQ6BLJJD.js → chunk-J45CX6IY.js} +7 -7
- package/dist/{chunk-DQQCWMA2.js → chunk-LCIYVQBM.js} +10 -8
- package/dist/{chunk-2DZD6HX2.js → chunk-MXVTNDYF.js} +4 -4
- package/dist/{chunk-5EUADEG3.js → chunk-OAUFSZ54.js} +1 -1
- package/dist/{chunk-K5DCMBUV.js → chunk-P2RFRHJS.js} +48 -6
- package/dist/{chunk-MU6HHZEN.js → chunk-PR3M62LK.js} +74 -0
- package/dist/{chunk-DAMUPWYR.js → chunk-S7KM4EQY.js} +2 -2
- package/dist/{chunk-XLPETJXX.js → chunk-SFYFRZ6A.js} +1 -1
- package/dist/{chunk-3S2K7SYY.js → chunk-TWHNWGXY.js} +39 -16
- package/dist/{chunk-LEQXDCWK.js → chunk-V6O47TCR.js} +1 -1
- package/dist/{chunk-ZOOZ25BO.js → chunk-WTB3ATMR.js} +1 -1
- package/dist/{chunk-ZO4TL4OK.js → chunk-XDX3QTFA.js} +4 -4
- package/dist/{chunk-JCJN6TPV.js → chunk-ZOYZCEYE.js} +14 -1
- package/dist/cli/chat.js +22 -22
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +10 -10
- package/dist/cli/snapshot-create.js +8 -8
- package/dist/cli/upgrade.js +5 -5
- package/dist/{db-XKB2CHDW.js → db-NPESWXWE.js} +5 -5
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-EVMACH4G.js → oauth-callback-server-V6OVD7NI.js} +16 -16
- package/dist/{runner-BVHV5Y6L.js → runner-ORVU25XU.js} +11 -11
- package/dist/{skills-QTI6GGJ4.js → skills-Y3OSYR6V.js} +6 -6
- package/dist/{validation-SCQUYIUU.js → validation-4MRKY64W.js} +6 -6
- package/dist/version.js +1 -1
- package/migrations/0012_structured_conversation_events.sql +4 -0
- package/migrations/meta/0012_snapshot.json +1244 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./chunk-6GWA276C.js";
|
|
14
14
|
import {
|
|
15
15
|
getDeploymentTelemetryAttributes
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6RHGQF6H.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/logging.ts
|
|
19
19
|
import path from "path";
|
|
@@ -948,10 +948,15 @@ var log = {
|
|
|
948
948
|
if (typeof sentryWithScope === "function" && typeof sentryCaptureException === "function") {
|
|
949
949
|
sentryWithScope((scope) => {
|
|
950
950
|
setSentryScopeContext(scope, getBoundLogContext());
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
951
|
+
const mergedAttributes = mergeAttributes(
|
|
952
|
+
getBoundLogAttributes(),
|
|
953
|
+
attrs
|
|
954
|
+
);
|
|
955
|
+
for (const [key, value] of Object.entries(mergedAttributes)) {
|
|
954
956
|
scope.setExtra(key, value);
|
|
957
|
+
if (SENTRY_TAG_ATTRIBUTE_KEYS.has(key) && typeof value === "string" && value.length > 0) {
|
|
958
|
+
scope.setTag(key, value);
|
|
959
|
+
}
|
|
955
960
|
}
|
|
956
961
|
eventId = sentryCaptureException(normalizedError);
|
|
957
962
|
});
|
|
@@ -237,12 +237,12 @@ var conversationReportTurnContextEventDataSchema = z2.object({
|
|
|
237
237
|
version: z2.number().int().positive(),
|
|
238
238
|
content: z2.record(z2.string(), z2.unknown())
|
|
239
239
|
}).strict();
|
|
240
|
-
var
|
|
241
|
-
type: z2.literal("
|
|
240
|
+
var conversationReportStructuredEventDataSchema = z2.object({
|
|
241
|
+
type: z2.literal("structured_event"),
|
|
242
242
|
namespace: z2.string().min(1),
|
|
243
243
|
name: z2.string().min(1),
|
|
244
244
|
version: z2.number().int().positive(),
|
|
245
|
-
turnId: z2.string().min(1),
|
|
245
|
+
turnId: z2.string().min(1).optional(),
|
|
246
246
|
presentation: conversationEventPresentationSchema
|
|
247
247
|
}).strict();
|
|
248
248
|
var conversationReportCompactionEventDataSchema = z2.object({
|
|
@@ -285,7 +285,7 @@ var conversationReportEventDataSchema = z2.discriminatedUnion("type", [
|
|
|
285
285
|
conversationReportToolCallsEventDataSchema,
|
|
286
286
|
conversationReportTurnLifecycleEventDataSchema,
|
|
287
287
|
conversationReportTurnContextEventDataSchema,
|
|
288
|
-
|
|
288
|
+
conversationReportStructuredEventDataSchema,
|
|
289
289
|
conversationReportTurnRoutedEventDataSchema,
|
|
290
290
|
conversationReportGuardianActionReviewedEventDataSchema,
|
|
291
291
|
conversationReportCompactionEventDataSchema,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPlugins
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XDX3QTFA.js";
|
|
4
4
|
import {
|
|
5
5
|
getConversationEventStore
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5FEVPYXP.js";
|
|
7
7
|
|
|
8
8
|
// src/chat/plugins/conversation-events.ts
|
|
9
9
|
function registeredDefinition(plugin, value) {
|
|
@@ -26,7 +26,7 @@ function createPluginConversationEvents(args) {
|
|
|
26
26
|
createdAtMs: Date.now(),
|
|
27
27
|
idempotencyKey: `plugin:${args.plugin.manifest.name}:operation:${args.operationId}:event:${definition.eventName}@${definition.version}`,
|
|
28
28
|
data: {
|
|
29
|
-
type: "
|
|
29
|
+
type: "structured_event",
|
|
30
30
|
namespace: args.plugin.manifest.name,
|
|
31
31
|
name: definition.eventName,
|
|
32
32
|
version: definition.version,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
persistAuthPauseTurnState,
|
|
14
14
|
requireTurnFailureEventId,
|
|
15
15
|
scheduleSessionCompletedPluginTasks
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-LCIYVQBM.js";
|
|
17
17
|
import {
|
|
18
18
|
buildSentryConversationUrl
|
|
19
19
|
} from "./chunk-4CODA7P5.js";
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
resolveBaseUrl,
|
|
41
41
|
resolvePluginOAuthAccount,
|
|
42
42
|
truncateStatusText
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-J45CX6IY.js";
|
|
44
44
|
import {
|
|
45
45
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
46
46
|
TurnSliceLimitExceededError,
|
|
@@ -68,11 +68,12 @@ import {
|
|
|
68
68
|
persistThreadStateById,
|
|
69
69
|
persistWithRetry,
|
|
70
70
|
recordAgentTurnSessionSummary,
|
|
71
|
+
recordAuthenticationLinked,
|
|
71
72
|
recordAuthorizationCompleted,
|
|
72
73
|
recordDeliveredAssistantMessage,
|
|
73
74
|
turnHasReply,
|
|
74
75
|
updateConversationStats
|
|
75
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-P2RFRHJS.js";
|
|
76
77
|
import {
|
|
77
78
|
SlackActionError,
|
|
78
79
|
getDashboardConversationLink,
|
|
@@ -81,19 +82,19 @@ import {
|
|
|
81
82
|
getSlackClient,
|
|
82
83
|
isDmChannel,
|
|
83
84
|
normalizeSlackConversationId
|
|
84
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-XDX3QTFA.js";
|
|
85
86
|
import {
|
|
86
87
|
getConversationEventStore,
|
|
87
88
|
getConversationStore,
|
|
88
89
|
parseDestination,
|
|
89
90
|
requireSlackDestination,
|
|
90
91
|
sameDestination
|
|
91
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-5FEVPYXP.js";
|
|
92
93
|
import {
|
|
93
94
|
acquireActiveLock,
|
|
94
95
|
getDefaultRedisStateAdapterFor,
|
|
95
96
|
getStateAdapter
|
|
96
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-WTB3ATMR.js";
|
|
97
98
|
import {
|
|
98
99
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
99
100
|
botConfig,
|
|
@@ -102,7 +103,7 @@ import {
|
|
|
102
103
|
getRuntimeMetadata,
|
|
103
104
|
normalizeSlackEmojiName,
|
|
104
105
|
standardModelId
|
|
105
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-ZOYZCEYE.js";
|
|
106
107
|
import {
|
|
107
108
|
parseSlackThreadId,
|
|
108
109
|
readSlackRawMessageContext,
|
|
@@ -111,15 +112,15 @@ import {
|
|
|
111
112
|
} from "./chunk-S7G34U75.js";
|
|
112
113
|
import {
|
|
113
114
|
discoverSkills
|
|
114
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-S7KM4EQY.js";
|
|
115
116
|
import {
|
|
116
117
|
pluginCatalogRuntime
|
|
117
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-7SCPUYHG.js";
|
|
118
119
|
import {
|
|
119
120
|
buildOAuthTokenRequest,
|
|
120
121
|
hasRequiredOAuthScope,
|
|
121
122
|
parseOAuthTokenResponse
|
|
122
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-SFYFRZ6A.js";
|
|
123
124
|
import {
|
|
124
125
|
createSlackResumeActor,
|
|
125
126
|
isUserActor,
|
|
@@ -132,7 +133,7 @@ import {
|
|
|
132
133
|
logWarn,
|
|
133
134
|
setTags,
|
|
134
135
|
withLogContext
|
|
135
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-5HFV6BEV.js";
|
|
136
137
|
import {
|
|
137
138
|
isRecord,
|
|
138
139
|
toOptionalNumber,
|
|
@@ -3605,6 +3606,29 @@ async function GET(request, provider, waitUntil, options) {
|
|
|
3605
3606
|
mutation
|
|
3606
3607
|
)
|
|
3607
3608
|
);
|
|
3609
|
+
let providerLabel;
|
|
3610
|
+
try {
|
|
3611
|
+
providerLabel = formatProviderLabel(provider);
|
|
3612
|
+
} catch {
|
|
3613
|
+
providerLabel = void 0;
|
|
3614
|
+
}
|
|
3615
|
+
try {
|
|
3616
|
+
await recordAuthenticationLinked({
|
|
3617
|
+
conversationId: authSession.conversationId,
|
|
3618
|
+
provider,
|
|
3619
|
+
actorId: authSession.userId,
|
|
3620
|
+
authorizationId: mcpAuthorizationId({
|
|
3621
|
+
provider,
|
|
3622
|
+
sessionId: authSession.sessionId
|
|
3623
|
+
}),
|
|
3624
|
+
turnId: authSession.sessionId,
|
|
3625
|
+
...providerLabel ? { providerLabel } : {}
|
|
3626
|
+
});
|
|
3627
|
+
} catch (error2) {
|
|
3628
|
+
logException(error2, "mcp.oauth_callback.authentication_event.failed", {
|
|
3629
|
+
"app.credential.provider": provider
|
|
3630
|
+
});
|
|
3631
|
+
}
|
|
3608
3632
|
try {
|
|
3609
3633
|
await deleteMcpAuthSession(authSession.authSessionId);
|
|
3610
3634
|
} catch (cleanupError) {
|
|
@@ -4295,6 +4319,28 @@ async function GET2(request, provider, waitUntil, options) {
|
|
|
4295
4319
|
...parsedTokenResponse,
|
|
4296
4320
|
...account ? { account } : {}
|
|
4297
4321
|
});
|
|
4322
|
+
if (stored.resumeConversationId) {
|
|
4323
|
+
try {
|
|
4324
|
+
await recordAuthenticationLinked({
|
|
4325
|
+
conversationId: stored.resumeConversationId,
|
|
4326
|
+
provider,
|
|
4327
|
+
actorId: stored.userId,
|
|
4328
|
+
providerLabel,
|
|
4329
|
+
...account?.label ? { accountLabel: account.label } : {},
|
|
4330
|
+
...stored.resumeSessionId ? {
|
|
4331
|
+
authorizationId: pluginAuthorizationId({
|
|
4332
|
+
provider,
|
|
4333
|
+
sessionId: stored.resumeSessionId
|
|
4334
|
+
}),
|
|
4335
|
+
turnId: stored.resumeSessionId
|
|
4336
|
+
} : {}
|
|
4337
|
+
});
|
|
4338
|
+
} catch (error) {
|
|
4339
|
+
logException(error, "oauth.callback.authentication_event.failed", {
|
|
4340
|
+
"app.credential.provider": provider
|
|
4341
|
+
});
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4298
4344
|
if (stored.destination?.platform !== "local") {
|
|
4299
4345
|
waitUntil(async () => {
|
|
4300
4346
|
try {
|
|
@@ -6,29 +6,29 @@ import {
|
|
|
6
6
|
isDmChannel,
|
|
7
7
|
normalizeSlackConversationId,
|
|
8
8
|
withSlackRetries
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XDX3QTFA.js";
|
|
10
10
|
import {
|
|
11
11
|
getDb,
|
|
12
12
|
parseDestination
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5FEVPYXP.js";
|
|
14
14
|
import {
|
|
15
15
|
acquireActiveLock,
|
|
16
16
|
getStateAdapter,
|
|
17
17
|
sleep
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-WTB3ATMR.js";
|
|
19
19
|
import {
|
|
20
20
|
normalizeSlackEmojiName
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ZOYZCEYE.js";
|
|
22
22
|
import {
|
|
23
23
|
pluginCatalogRuntime
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-7SCPUYHG.js";
|
|
25
25
|
import {
|
|
26
26
|
fetchWithBoundedOAuthErrorBodies
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-SFYFRZ6A.js";
|
|
28
28
|
import {
|
|
29
29
|
logInfo,
|
|
30
30
|
logWarn
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-5HFV6BEV.js";
|
|
32
32
|
import {
|
|
33
33
|
isRecord
|
|
34
34
|
} from "./chunk-OB42YVAE.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPluginConversationEvents
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DVSAX7MS.js";
|
|
4
4
|
import {
|
|
5
5
|
pluginTaskId,
|
|
6
6
|
pluginTaskParamsSchema,
|
|
@@ -25,29 +25,30 @@ import {
|
|
|
25
25
|
persistThreadStateById,
|
|
26
26
|
stripRuntimeTurnContext,
|
|
27
27
|
updateConversationStats
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-P2RFRHJS.js";
|
|
29
29
|
import {
|
|
30
30
|
createPluginEmbedder,
|
|
31
31
|
createPluginLogger,
|
|
32
32
|
createPluginModel,
|
|
33
33
|
createPluginState,
|
|
34
34
|
getPlugins
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XDX3QTFA.js";
|
|
36
36
|
import {
|
|
37
37
|
getDb,
|
|
38
38
|
sameActorIdentity
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-5FEVPYXP.js";
|
|
40
40
|
import {
|
|
41
41
|
getStateAdapter
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-WTB3ATMR.js";
|
|
43
43
|
import {
|
|
44
44
|
ProviderError,
|
|
45
|
+
findProviderError,
|
|
45
46
|
getProviderErrorAttributes,
|
|
46
47
|
getProviderErrorUserMessage
|
|
47
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-ZOYZCEYE.js";
|
|
48
49
|
import {
|
|
49
50
|
buildTurnFailureResponse
|
|
50
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-5HFV6BEV.js";
|
|
51
52
|
import {
|
|
52
53
|
parseSlackMessageTs
|
|
53
54
|
} from "./chunk-F3B2YJ76.js";
|
|
@@ -410,12 +411,13 @@ function getExecutionFailureReason(reply) {
|
|
|
410
411
|
}
|
|
411
412
|
function getFailureCapture(reply) {
|
|
412
413
|
if (reply.diagnostics.outcome === "provider_error") {
|
|
414
|
+
const providerError = findProviderError(reply.diagnostics.providerError);
|
|
413
415
|
return {
|
|
414
416
|
eventName: "agent.turn.provider_error",
|
|
415
417
|
error: reply.diagnostics.providerError ?? new Error(
|
|
416
418
|
reply.diagnostics.errorMessage ?? "Provider error without explicit message"
|
|
417
419
|
),
|
|
418
|
-
attributes:
|
|
420
|
+
attributes: providerError ? getProviderErrorAttributes(providerError) : {},
|
|
419
421
|
body: "Agent turn failed with provider error"
|
|
420
422
|
};
|
|
421
423
|
}
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
SANDBOX_WORKSPACE_ROOT,
|
|
3
3
|
getStateAdapter,
|
|
4
4
|
sleep
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WTB3ATMR.js";
|
|
6
6
|
import {
|
|
7
7
|
toOptionalTrimmed
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZOYZCEYE.js";
|
|
9
9
|
import {
|
|
10
10
|
pluginCatalogRuntime
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7SCPUYHG.js";
|
|
12
12
|
import {
|
|
13
13
|
setSpanAttributes,
|
|
14
14
|
setSpanStatus,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-5HFV6BEV.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/snapshot/profile.ts
|
|
19
19
|
import { createHash } from "crypto";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
2
3
|
addAgentTurnUsage,
|
|
3
|
-
agentTurnUsageSchema
|
|
4
|
-
|
|
4
|
+
agentTurnUsageSchema,
|
|
5
|
+
authenticationLinkedEvent,
|
|
6
|
+
authenticationUnlinkedEvent
|
|
7
|
+
} from "./chunk-PR3M62LK.js";
|
|
5
8
|
import {
|
|
6
9
|
agentHistoryItemSchema,
|
|
7
10
|
contextProvenance,
|
|
@@ -13,17 +16,17 @@ import {
|
|
|
13
16
|
instructionProvenanceFor,
|
|
14
17
|
sanitizePostgresJson,
|
|
15
18
|
withConversationEventLock
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-5FEVPYXP.js";
|
|
17
20
|
import {
|
|
18
21
|
getStateAdapter,
|
|
19
22
|
sleep
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-WTB3ATMR.js";
|
|
21
24
|
import {
|
|
22
25
|
botConfig,
|
|
23
26
|
escapeXml,
|
|
24
27
|
resolveGatewayModel,
|
|
25
28
|
unwrapCurrentInstruction
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-ZOYZCEYE.js";
|
|
27
30
|
import {
|
|
28
31
|
toStoredSlackActor
|
|
29
32
|
} from "./chunk-HZF5P5UN.js";
|
|
@@ -32,7 +35,7 @@ import {
|
|
|
32
35
|
logException,
|
|
33
36
|
logWarn,
|
|
34
37
|
setSpanAttributes
|
|
35
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-5HFV6BEV.js";
|
|
36
39
|
import {
|
|
37
40
|
isRecord,
|
|
38
41
|
toOptionalNumber,
|
|
@@ -1137,6 +1140,44 @@ async function recordAuthorizationCompleted(args) {
|
|
|
1137
1140
|
}
|
|
1138
1141
|
]);
|
|
1139
1142
|
}
|
|
1143
|
+
function authenticationEventIdempotencyKey(args) {
|
|
1144
|
+
if (args.authorizationId) {
|
|
1145
|
+
return `native:${JUNIOR_NATIVE_EVENT_NAMESPACE}:authentication_${args.action}:authorization:${args.authorizationId}`;
|
|
1146
|
+
}
|
|
1147
|
+
return `native:${JUNIOR_NATIVE_EVENT_NAMESPACE}:authentication_${args.action}:${args.provider}:actor:${args.actorId}`;
|
|
1148
|
+
}
|
|
1149
|
+
async function recordAuthenticationAccountChange(action, args) {
|
|
1150
|
+
const definition = action === "linked" ? authenticationLinkedEvent : authenticationUnlinkedEvent;
|
|
1151
|
+
const content = definition.parse({
|
|
1152
|
+
actorId: args.actorId,
|
|
1153
|
+
provider: args.provider,
|
|
1154
|
+
...args.accountLabel ? { accountLabel: args.accountLabel } : {},
|
|
1155
|
+
...args.authorizationId ? { authorizationId: args.authorizationId } : {},
|
|
1156
|
+
...args.providerLabel ? { providerLabel: args.providerLabel } : {}
|
|
1157
|
+
});
|
|
1158
|
+
await getConversationEventStore().append(args.conversationId, [
|
|
1159
|
+
{
|
|
1160
|
+
createdAtMs: Date.now(),
|
|
1161
|
+
idempotencyKey: authenticationEventIdempotencyKey({
|
|
1162
|
+
action,
|
|
1163
|
+
actorId: args.actorId,
|
|
1164
|
+
authorizationId: args.authorizationId,
|
|
1165
|
+
provider: args.provider
|
|
1166
|
+
}),
|
|
1167
|
+
data: {
|
|
1168
|
+
type: "structured_event",
|
|
1169
|
+
namespace: JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
1170
|
+
name: definition.eventName,
|
|
1171
|
+
version: definition.version,
|
|
1172
|
+
...args.turnId ? { turnId: args.turnId } : {},
|
|
1173
|
+
content
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
]);
|
|
1177
|
+
}
|
|
1178
|
+
async function recordAuthenticationLinked(args) {
|
|
1179
|
+
await recordAuthenticationAccountChange("linked", args);
|
|
1180
|
+
}
|
|
1140
1181
|
async function loadTurnRoute(args) {
|
|
1141
1182
|
const event = await getConversationEventStore().loadByIdempotencyKey(
|
|
1142
1183
|
args.conversationId,
|
|
@@ -2886,6 +2927,7 @@ export {
|
|
|
2886
2927
|
recordMcpProviderConnected,
|
|
2887
2928
|
recordAuthorizationRequested,
|
|
2888
2929
|
recordAuthorizationCompleted,
|
|
2930
|
+
recordAuthenticationLinked,
|
|
2889
2931
|
loadTurnRoute,
|
|
2890
2932
|
recordTurnRoute,
|
|
2891
2933
|
recordToolExecutionStarted,
|
|
@@ -2,6 +2,76 @@ import {
|
|
|
2
2
|
usageSchema
|
|
3
3
|
} from "./chunk-PDO5BLNM.js";
|
|
4
4
|
|
|
5
|
+
// src/chat/conversations/structured-events.ts
|
|
6
|
+
import {
|
|
7
|
+
conversationEventPresentationSchema,
|
|
8
|
+
defineConversationEvent
|
|
9
|
+
} from "@sentry/junior-plugin-api";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
var JUNIOR_NATIVE_EVENT_NAMESPACE = "junior";
|
|
12
|
+
var authenticationEventContentSchema = z.object({
|
|
13
|
+
accountLabel: z.string().trim().min(1).max(120).optional(),
|
|
14
|
+
actorId: z.string().min(1),
|
|
15
|
+
authorizationId: z.string().min(1).optional(),
|
|
16
|
+
provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
17
|
+
providerLabel: z.string().trim().min(1).max(80).optional()
|
|
18
|
+
}).strict();
|
|
19
|
+
function providerTitle(content) {
|
|
20
|
+
return content.providerLabel?.trim() || content.provider;
|
|
21
|
+
}
|
|
22
|
+
var authenticationLinkedEvent = defineConversationEvent({
|
|
23
|
+
name: "authentication_linked",
|
|
24
|
+
version: 1,
|
|
25
|
+
schema: authenticationEventContentSchema,
|
|
26
|
+
renderEvent(event) {
|
|
27
|
+
const provider = providerTitle(event);
|
|
28
|
+
return {
|
|
29
|
+
icon: "link",
|
|
30
|
+
title: `${provider} connected`,
|
|
31
|
+
...event.accountLabel ? { preview: `Connected as \`${event.accountLabel}\`` } : {},
|
|
32
|
+
details: [
|
|
33
|
+
{
|
|
34
|
+
title: `${provider} connected`,
|
|
35
|
+
...event.accountLabel ? { description: `Connected as \`${event.accountLabel}\`` } : {},
|
|
36
|
+
metadata: [event.provider]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var authenticationUnlinkedEvent = defineConversationEvent({
|
|
43
|
+
name: "authentication_unlinked",
|
|
44
|
+
version: 1,
|
|
45
|
+
schema: authenticationEventContentSchema,
|
|
46
|
+
renderEvent(event) {
|
|
47
|
+
const provider = providerTitle(event);
|
|
48
|
+
return {
|
|
49
|
+
icon: "key",
|
|
50
|
+
title: `${provider} disconnected`,
|
|
51
|
+
details: [
|
|
52
|
+
{
|
|
53
|
+
title: `${provider} disconnected`,
|
|
54
|
+
metadata: [event.provider]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var NATIVE_EVENT_DEFINITIONS = [authenticationLinkedEvent, authenticationUnlinkedEvent];
|
|
61
|
+
function getJuniorNativeEventDefinition(args) {
|
|
62
|
+
return NATIVE_EVENT_DEFINITIONS.find(
|
|
63
|
+
(definition) => definition.eventName === args.name && definition.version === args.version
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function renderJuniorNativeConversationEvent(args) {
|
|
67
|
+
if (args.namespace !== JUNIOR_NATIVE_EVENT_NAMESPACE) return void 0;
|
|
68
|
+
const definition = getJuniorNativeEventDefinition(args);
|
|
69
|
+
if (!definition) return void 0;
|
|
70
|
+
return conversationEventPresentationSchema.parse(
|
|
71
|
+
definition.renderEvent(definition.parse(args.content))
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
5
75
|
// src/chat/usage.ts
|
|
6
76
|
var agentTurnUsageSchema = usageSchema;
|
|
7
77
|
var COMPONENT_USAGE_FIELDS = [
|
|
@@ -93,6 +163,10 @@ function addAgentTurnUsage(...usages) {
|
|
|
93
163
|
}
|
|
94
164
|
|
|
95
165
|
export {
|
|
166
|
+
JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
167
|
+
authenticationLinkedEvent,
|
|
168
|
+
authenticationUnlinkedEvent,
|
|
169
|
+
renderJuniorNativeConversationEvent,
|
|
96
170
|
agentTurnUsageSchema,
|
|
97
171
|
hasAgentTurnUsage,
|
|
98
172
|
addAgentTurnUsage
|