@sentry/junior 0.108.0 → 0.110.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.
Files changed (109) hide show
  1. package/dist/{agent-hooks-NU5HK3PS.js → agent-hooks-ELT4ODFF.js} +12 -13
  2. package/dist/api/conversations/access.d.ts +9 -0
  3. package/dist/api/conversations/aggregate.d.ts +12 -1
  4. package/dist/api/conversations/archive.d.ts +3 -5
  5. package/dist/api/conversations/detail.d.ts +156 -7
  6. package/dist/api/conversations/events.d.ts +2 -2
  7. package/dist/api/conversations/list.d.ts +57 -6
  8. package/dist/api/conversations/projection.d.ts +6 -7
  9. package/dist/api/conversations/reporting.d.ts +10 -4
  10. package/dist/api/conversations/routes.d.ts +2 -1
  11. package/dist/api/conversations/shared.d.ts +1 -1
  12. package/dist/api/conversations/stats.d.ts +37 -6
  13. package/dist/api/conversations/stats.query.d.ts +1 -1
  14. package/dist/api/conversations/usage.d.ts +9 -0
  15. package/dist/api/http.d.ts +7 -0
  16. package/dist/api/locations/detail.d.ts +102 -6
  17. package/dist/api/locations/list.d.ts +43 -5
  18. package/dist/api/locations/query.d.ts +4 -2
  19. package/dist/api/locations/routes.d.ts +2 -1
  20. package/dist/api/people/list.d.ts +28 -6
  21. package/dist/api/people/list.query.d.ts +1 -1
  22. package/dist/api/people/profile.d.ts +96 -7
  23. package/dist/api/people/profile.query.d.ts +4 -2
  24. package/dist/api/people/routes.d.ts +2 -1
  25. package/dist/api/people/shared.d.ts +1219 -2
  26. package/dist/api/route.d.ts +18 -4
  27. package/dist/api/schema/common.d.ts +6 -0
  28. package/dist/api/{conversations/schema.d.ts → schema/conversation.d.ts} +88 -9
  29. package/dist/api/{locations/schema.d.ts → schema/location.d.ts} +5 -0
  30. package/dist/api/{people/schema.d.ts → schema/person.d.ts} +37 -45
  31. package/dist/api/schema.d.ts +8 -22
  32. package/dist/api/schema.js +10 -2
  33. package/dist/api.d.ts +5 -1
  34. package/dist/api.js +838 -369
  35. package/dist/app.d.ts +1 -0
  36. package/dist/app.js +1564 -486
  37. package/dist/catalog-runtime-4GI22PXK.js +16 -0
  38. package/dist/chat/agent/resume.d.ts +11 -12
  39. package/dist/chat/conversations/history.d.ts +3 -0
  40. package/dist/chat/conversations/sql/privacy.d.ts +3 -15
  41. package/dist/chat/conversations/sql/store.d.ts +0 -7
  42. package/dist/chat/log-context.d.ts +40 -0
  43. package/dist/chat/logging.d.ts +3 -26
  44. package/dist/chat/pi/messages.d.ts +2 -2
  45. package/dist/chat/pi/sql-model-usage.d.ts +4 -1
  46. package/dist/chat/runtime/slack-resume.d.ts +2 -2
  47. package/dist/chat/services/auth-pause.d.ts +4 -0
  48. package/dist/chat/services/context-compaction.d.ts +1 -0
  49. package/dist/chat/services/turn-session-record.d.ts +0 -2
  50. package/dist/chat/slack/reply.d.ts +7 -19
  51. package/dist/chat/state/conversation.d.ts +1 -0
  52. package/dist/chat/task-execution/queue-signing.d.ts +10 -8
  53. package/dist/chat/task-execution/queue.d.ts +9 -7
  54. package/dist/chat/task-execution/slack-work.d.ts +6 -6
  55. package/dist/{chunk-UD6THJ2I.js → chunk-2T7TIEXI.js} +197 -12
  56. package/dist/{chunk-CEA3A3UA.js → chunk-2ZTTXTSZ.js} +24 -1
  57. package/dist/{chunk-XKB7LGIW.js → chunk-3S7YYHBI.js} +3 -139
  58. package/dist/chunk-3TV7OEHL.js +10 -0
  59. package/dist/{chunk-A5CO2EHL.js → chunk-3UBQI73J.js} +11 -15
  60. package/dist/{chunk-7FBGKXPE.js → chunk-42WRQLJ6.js} +10 -33
  61. package/dist/{chunk-TE4QHJH4.js → chunk-4QU44P7Q.js} +135 -595
  62. package/dist/{chunk-RT5BUHR5.js → chunk-6Y5L4BOM.js} +3 -5
  63. package/dist/{chunk-VIXFG2VC.js → chunk-C4MZ3GP5.js} +1 -2
  64. package/dist/{chunk-3RGQLX2F.js → chunk-C5XAFTHY.js} +1011 -29
  65. package/dist/{chunk-PUAMO4PI.js → chunk-FPK7XY3F.js} +139 -99
  66. package/dist/{chunk-H3QYZL7K.js → chunk-GK47NBDE.js} +28 -3
  67. package/dist/{chunk-O24R4DCK.js → chunk-IYKPU7H6.js} +94 -56
  68. package/dist/chunk-JQFJO5WH.js +477 -0
  69. package/dist/{chunk-VH6KWKG2.js → chunk-L5XQPJ7T.js} +3 -3
  70. package/dist/{chunk-2XXEKR44.js → chunk-MIAKQNYX.js} +43 -31
  71. package/dist/{chunk-KPMPQ6AA.js → chunk-RHHRKSPI.js} +249 -223
  72. package/dist/{chunk-YT72TOEK.js → chunk-SBOBTS27.js} +2 -2
  73. package/dist/{chunk-B5I5LMSP.js → chunk-W6RJZG7F.js} +5 -7
  74. package/dist/chunk-W75ZPAGG.js +44 -0
  75. package/dist/{chunk-SS67LUOK.js → chunk-WNOVRQ67.js} +6 -7
  76. package/dist/{chunk-YIPD3L6L.js → chunk-Y3H2DN6F.js} +8 -10
  77. package/dist/{chunk-DY7TRYB5.js → chunk-Y5FK3CNG.js} +1 -1
  78. package/dist/chunk-ZKIOWEFL.js +125 -0
  79. package/dist/cli/chat.js +23 -24
  80. package/dist/cli/check.js +9 -7
  81. package/dist/cli/plugins.js +16 -17
  82. package/dist/cli/snapshot-warmup.js +11 -10
  83. package/dist/cli/upgrade.js +314 -3505
  84. package/dist/db/db.d.ts +1 -1
  85. package/dist/db/schema/conversations.d.ts +17 -0
  86. package/dist/db/schema.d.ts +17 -0
  87. package/dist/{db-AMRBAT5D.js → db-Y6W6CWWW.js} +8 -7
  88. package/dist/instrumentation.js +4 -3
  89. package/dist/nitro.js +4 -4
  90. package/dist/reporting-schema.d.ts +46 -0
  91. package/dist/{runner-TQH5GAJ4.js → runner-BBFV5GLR.js} +17 -21
  92. package/dist/{skills-ITNHBARB.js → skills-AR4AF32L.js} +8 -6
  93. package/dist/{validation-AGQ46ZGV.js → validation-FBIEPTC2.js} +8 -6
  94. package/dist/version.d.ts +2 -0
  95. package/dist/version.js +7 -0
  96. package/migrations/0006_drop_legacy_conversation_messages.sql +1 -0
  97. package/migrations/0007_thick_sugar_man.sql +23 -0
  98. package/migrations/README.md +12 -9
  99. package/migrations/meta/0006_snapshot.json +948 -0
  100. package/migrations/meta/0007_snapshot.json +1013 -0
  101. package/migrations/meta/_journal.json +14 -0
  102. package/package.json +9 -5
  103. package/dist/catalog-runtime-FOFNPR3P.js +0 -14
  104. package/dist/chunk-AHJR2IFF.js +0 -115
  105. package/dist/chunk-B7PUBQQM.js +0 -53
  106. package/dist/chunk-G3E7SCME.js +0 -28
  107. package/dist/chunk-J3B3FPP2.js +0 -1061
  108. package/dist/chunk-OB42YVAE.js +0 -16
  109. package/dist/chunk-TWINAEZQ.js +0 -1283
@@ -5,39 +5,11 @@ import {
5
5
  juniorDestinationKindSchema
6
6
  } from "./chunk-VFUK3X5B.js";
7
7
 
8
- // src/api/activity.ts
8
+ // src/api/schema/common.ts
9
9
  import { z } from "zod";
10
- var dailyConversationActivitySchema = z.object({
11
- active: z.number(),
12
- conversations: z.number(),
13
- date: z.string(),
14
- durationMs: z.number(),
15
- failed: z.number(),
16
- tokens: z.number().optional()
17
- }).strict();
18
- function emptyActivityDay(date) {
19
- return {
20
- active: 0,
21
- conversations: 0,
22
- date,
23
- durationMs: 0,
24
- failed: 0
25
- };
26
- }
27
- function activityDays(days, nowMs, count) {
28
- const items = [];
29
- const end = new Date(nowMs);
30
- end.setUTCHours(0, 0, 0, 0);
31
- const start = new Date(end);
32
- start.setUTCDate(start.getUTCDate() - (count - 1));
33
- for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
34
- const date = cursor.toISOString().slice(0, 10);
35
- items.push(days.get(date) ?? emptyActivityDay(date));
36
- }
37
- return items;
38
- }
10
+ var apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
39
11
 
40
- // src/api/conversations/schema.ts
12
+ // src/api/schema/conversation.ts
41
13
  import { z as z2 } from "zod";
42
14
  var conversationReportStatusSchema = z2.enum([
43
15
  "active",
@@ -51,6 +23,12 @@ var conversationSurfaceSchema = z2.enum([
51
23
  "slack"
52
24
  ]);
53
25
  var conversationUsageSchema = usageSchema;
26
+ var conversationParamsSchema = z2.object({ conversationId: z2.string().min(1) }).strict();
27
+ var conversationFeedQuerySchema = z2.object({
28
+ actorEmail: z2.string().trim().email().transform((value) => value.toLowerCase()).optional()
29
+ }).strict();
30
+ var archiveConversationBodySchema = z2.object({ archived: z2.boolean(), lastSeenAt: z2.string().datetime() }).strict();
31
+ var archiveConversationResponseSchema = z2.object({ archived: z2.boolean() }).strict();
54
32
  var actorIdentitySchema = z2.object({
55
33
  email: z2.string().optional(),
56
34
  fullName: z2.string().optional(),
@@ -62,6 +40,7 @@ var conversationSummaryReportSchema = z2.object({
62
40
  cumulativeDurationMs: z2.number(),
63
41
  cumulativeUsage: conversationUsageSchema.optional(),
64
42
  conversationId: z2.string(),
43
+ isParticipant: z2.boolean(),
65
44
  status: conversationReportStatusSchema,
66
45
  startedAt: z2.string(),
67
46
  lastSeenAt: z2.string(),
@@ -80,6 +59,7 @@ var conversationReportMessageEventDataSchema = z2.object({
80
59
  type: z2.literal("message"),
81
60
  messageId: z2.string().min(1),
82
61
  role: z2.enum(["assistant", "system", "user"]),
62
+ eventType: z2.string().min(1).optional(),
83
63
  text: z2.string().optional(),
84
64
  redacted: z2.literal(true).optional()
85
65
  }).strict().superRefine((data, context) => {
@@ -96,8 +76,24 @@ var conversationReportMessageHandledEventDataSchema = z2.object({
96
76
  }).strict();
97
77
  var conversationReportToolStartedEventDataSchema = z2.object({
98
78
  type: z2.literal("tool_started"),
79
+ toolCallId: z2.string().min(1),
99
80
  name: z2.string().min(1)
100
81
  }).strict();
82
+ var conversationReportToolCallSchema = z2.object({
83
+ toolCallId: z2.string().min(1),
84
+ name: z2.string().min(1),
85
+ input: z2.unknown().optional()
86
+ }).strict();
87
+ var conversationReportToolCallsEventDataSchema = z2.object({
88
+ type: z2.literal("tool_calls"),
89
+ calls: z2.array(conversationReportToolCallSchema).min(1)
90
+ }).strict();
91
+ var conversationReportToolResultEventDataSchema = z2.object({
92
+ type: z2.literal("tool_result"),
93
+ toolCallId: z2.string().min(1),
94
+ outcome: z2.enum(["completed", "error"]),
95
+ output: z2.unknown().optional()
96
+ }).strict();
101
97
  var conversationReportTurnLifecycleEventDataSchema = z2.discriminatedUnion(
102
98
  "state",
103
99
  [
@@ -117,13 +113,16 @@ var conversationReportTurnLifecycleEventDataSchema = z2.discriminatedUnion(
117
113
  var conversationReportCompactionEventDataSchema = z2.object({ type: z2.literal("compaction") }).strict();
118
114
  var conversationReportHandoffEventDataSchema = z2.object({
119
115
  type: z2.literal("handoff"),
120
- toolStartedSeq: z2.number().int().nonnegative().optional()
116
+ modelProfile: z2.string().min(1),
117
+ modelId: z2.string().min(1),
118
+ reasoningLevel: z2.string().min(1).optional(),
119
+ triggeringToolCallId: z2.string().min(1).optional()
121
120
  }).strict();
122
121
  var conversationReportSubagentStartedEventDataSchema = z2.object({
123
122
  type: z2.literal("subagent_started"),
124
123
  childConversationId: z2.string().min(1),
125
124
  subagentKind: z2.string().min(1),
126
- toolStartedSeq: z2.number().int().nonnegative().optional()
125
+ parentToolCallId: z2.string().min(1).optional()
127
126
  }).strict();
128
127
  var conversationReportSubagentEndedEventDataSchema = z2.object({
129
128
  type: z2.literal("subagent_ended"),
@@ -134,6 +133,8 @@ var conversationReportEventDataSchema = z2.discriminatedUnion("type", [
134
133
  conversationReportMessageEventDataSchema,
135
134
  conversationReportMessageHandledEventDataSchema,
136
135
  conversationReportToolStartedEventDataSchema,
136
+ conversationReportToolCallsEventDataSchema,
137
+ conversationReportToolResultEventDataSchema,
137
138
  conversationReportTurnLifecycleEventDataSchema,
138
139
  conversationReportCompactionEventDataSchema,
139
140
  conversationReportHandoffEventDataSchema,
@@ -184,19 +185,34 @@ var conversationDetailReportSchema = conversationSummaryReportSchema.extend({
184
185
  }
185
186
  }
186
187
  for (const [index, event] of report.events.entries()) {
187
- if (event.data.type !== "message") continue;
188
- if (report.eventHistory.status === "redacted" && event.data.redacted !== true) {
188
+ if (event.data.type === "message") {
189
+ if (report.eventHistory.status === "redacted" && event.data.redacted !== true) {
190
+ context.addIssue({
191
+ code: "custom",
192
+ path: ["events", index, "data"],
193
+ message: "redacted event history must redact messages"
194
+ });
195
+ }
196
+ if (report.eventHistory.status === "available" && event.data.redacted === true) {
197
+ context.addIssue({
198
+ code: "custom",
199
+ path: ["events", index, "data"],
200
+ message: "available event history must expose messages"
201
+ });
202
+ }
203
+ }
204
+ if (report.eventHistory.status === "redacted" && event.data.type === "tool_calls" && event.data.calls.some((call) => call.input !== void 0)) {
189
205
  context.addIssue({
190
206
  code: "custom",
191
207
  path: ["events", index, "data"],
192
- message: "redacted event history must redact messages"
208
+ message: "redacted event history must redact tool inputs"
193
209
  });
194
210
  }
195
- if (report.eventHistory.status === "available" && event.data.redacted === true) {
211
+ if (report.eventHistory.status === "redacted" && event.data.type === "tool_result" && event.data.output !== void 0) {
196
212
  context.addIssue({
197
213
  code: "custom",
198
214
  path: ["events", index, "data"],
199
- message: "available event history must expose messages"
215
+ message: "redacted event history must redact tool outputs"
200
216
  });
201
217
  }
202
218
  }
@@ -237,15 +253,9 @@ var conversationStatsReportSchema = z2.object({
237
253
  windowStart: z2.string()
238
254
  }).strict();
239
255
 
240
- // src/api/people/schema.ts
256
+ // src/api/activity.ts
241
257
  import { z as z3 } from "zod";
242
- var peopleConversationSummaryReportSchema = conversationSummaryReportSchema.omit({
243
- cumulativeUsage: true,
244
- sentryTraceUrl: true,
245
- traceId: true
246
- });
247
- var peopleConversationStatsItemSchema = conversationStatsItemSchema.omit({ costUsd: true });
248
- var actorActivityDayReportSchema = z3.object({
258
+ var dailyConversationActivitySchema = z3.object({
249
259
  active: z3.number(),
250
260
  conversations: z3.number(),
251
261
  date: z3.string(),
@@ -253,48 +263,31 @@ var actorActivityDayReportSchema = z3.object({
253
263
  failed: z3.number(),
254
264
  tokens: z3.number().optional()
255
265
  }).strict();
256
- var peopleActivityDayReportSchema = z3.object({
257
- activePeople: z3.number(),
258
- conversations: z3.number(),
259
- date: z3.string()
260
- }).strict();
261
- var actorTotalsReportSchema = z3.object({
262
- active: z3.number(),
263
- activeDays: z3.number(),
264
- conversations: z3.number(),
265
- durationMs: z3.number(),
266
- failed: z3.number(),
267
- tokens: z3.number().optional()
268
- }).strict();
269
- var identifiedActorSchema = actorIdentitySchema.extend({ email: z3.string().min(1) }).strict();
270
- var actorSummaryReportSchema = actorTotalsReportSchema.extend({
271
- firstSeenAt: z3.string(),
272
- lastSeenAt: z3.string(),
273
- actor: identifiedActorSchema
274
- }).strict();
275
- var actorDirectoryReportSchema = z3.object({
276
- activityDays: z3.array(peopleActivityDayReportSchema),
277
- generatedAt: z3.string(),
278
- people: z3.array(actorSummaryReportSchema),
279
- source: z3.literal("conversation_index"),
280
- windowEnd: z3.string(),
281
- windowStart: z3.string()
282
- }).strict();
283
- var actorProfileReportSchema = z3.object({
284
- activityDays: z3.array(actorActivityDayReportSchema),
285
- generatedAt: z3.string(),
286
- locations: z3.array(peopleConversationStatsItemSchema),
287
- recentConversations: z3.array(peopleConversationSummaryReportSchema),
288
- actor: identifiedActorSchema,
289
- source: z3.literal("conversation_index"),
290
- surfaces: z3.array(peopleConversationStatsItemSchema),
291
- totals: actorTotalsReportSchema,
292
- windowEnd: z3.string(),
293
- windowStart: z3.string()
294
- }).strict();
266
+ function emptyActivityDay(date) {
267
+ return {
268
+ active: 0,
269
+ conversations: 0,
270
+ date,
271
+ durationMs: 0,
272
+ failed: 0
273
+ };
274
+ }
275
+ function activityDays(days, nowMs, count) {
276
+ const items = [];
277
+ const end = new Date(nowMs);
278
+ end.setUTCHours(0, 0, 0, 0);
279
+ const start = new Date(end);
280
+ start.setUTCDate(start.getUTCDate() - (count - 1));
281
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
282
+ const date = cursor.toISOString().slice(0, 10);
283
+ items.push(days.get(date) ?? emptyActivityDay(date));
284
+ }
285
+ return items;
286
+ }
295
287
 
296
- // src/api/locations/schema.ts
288
+ // src/api/schema/location.ts
297
289
  import { z as z4 } from "zod";
290
+ var locationParamsSchema = z4.object({ locationId: z4.string().min(1) }).strict();
298
291
  var locationSummaryReportSchema = conversationStatsItemSchema.extend({
299
292
  id: z4.string(),
300
293
  firstSeenAt: z4.string(),
@@ -329,31 +322,78 @@ var locationDetailReportSchema = locationSummaryReportSchema.extend({
329
322
  windowStart: z4.string()
330
323
  }).strict();
331
324
 
332
- // src/api/schema.ts
325
+ // src/api/schema/person.ts
333
326
  import { z as z5 } from "zod";
334
- var conversationParamsSchema = z5.object({ conversationId: z5.string().min(1) }).strict();
335
- var conversationFeedQuerySchema = z5.object({
336
- actorEmail: z5.string().trim().email().transform((value) => value.toLowerCase()).optional()
337
- }).strict();
338
327
  var personParamsSchema = z5.object({ email: z5.string().trim().min(1) }).strict();
339
- var locationParamsSchema = z5.object({ locationId: z5.string().min(1) }).strict();
328
+ var peopleConversationStatsItemSchema = conversationStatsItemSchema.omit({ costUsd: true });
329
+ var actorActivityDayReportSchema = z5.object({
330
+ active: z5.number(),
331
+ conversations: z5.number(),
332
+ date: z5.string(),
333
+ durationMs: z5.number(),
334
+ failed: z5.number(),
335
+ tokens: z5.number().optional()
336
+ }).strict();
337
+ var peopleActivityDayReportSchema = z5.object({
338
+ activePeople: z5.number(),
339
+ conversations: z5.number(),
340
+ date: z5.string()
341
+ }).strict();
342
+ var actorTotalsReportSchema = z5.object({
343
+ active: z5.number(),
344
+ activeDays: z5.number(),
345
+ conversations: z5.number(),
346
+ durationMs: z5.number(),
347
+ failed: z5.number(),
348
+ tokens: z5.number().optional()
349
+ }).strict();
350
+ var identifiedActorSchema = actorIdentitySchema.extend({ email: z5.string().min(1) }).strict();
351
+ var actorSummaryReportSchema = actorTotalsReportSchema.extend({
352
+ firstSeenAt: z5.string(),
353
+ lastSeenAt: z5.string(),
354
+ actor: identifiedActorSchema
355
+ }).strict();
356
+ var actorDirectoryReportSchema = z5.object({
357
+ activityDays: z5.array(peopleActivityDayReportSchema),
358
+ generatedAt: z5.string(),
359
+ people: z5.array(actorSummaryReportSchema),
360
+ source: z5.literal("conversation_index"),
361
+ windowEnd: z5.string(),
362
+ windowStart: z5.string()
363
+ }).strict();
364
+ var actorProfileReportSchema = z5.object({
365
+ activityDays: z5.array(actorActivityDayReportSchema),
366
+ generatedAt: z5.string(),
367
+ locations: z5.array(peopleConversationStatsItemSchema),
368
+ recentConversations: z5.array(conversationSummaryReportSchema),
369
+ actor: identifiedActorSchema,
370
+ source: z5.literal("conversation_index"),
371
+ surfaces: z5.array(peopleConversationStatsItemSchema),
372
+ totals: actorTotalsReportSchema,
373
+ windowEnd: z5.string(),
374
+ windowStart: z5.string()
375
+ }).strict();
340
376
 
341
377
  export {
342
- dailyConversationActivitySchema,
343
- activityDays,
378
+ apiErrorSchema,
379
+ conversationParamsSchema,
380
+ conversationFeedQuerySchema,
381
+ archiveConversationBodySchema,
382
+ archiveConversationResponseSchema,
383
+ conversationSummaryReportSchema,
344
384
  conversationReportEventDataSchema,
345
385
  conversationReportEventSchema,
346
386
  conversationEventHistorySchema,
347
387
  conversationDetailReportSchema,
348
388
  conversationFeedSchema,
349
389
  conversationStatsReportSchema,
350
- actorDirectoryReportSchema,
351
- actorProfileReportSchema,
390
+ dailyConversationActivitySchema,
391
+ activityDays,
392
+ locationParamsSchema,
352
393
  locationActivityDayReportSchema,
353
394
  locationDirectoryReportSchema,
354
395
  locationDetailReportSchema,
355
- conversationParamsSchema,
356
- conversationFeedQuerySchema,
357
396
  personParamsSchema,
358
- locationParamsSchema
397
+ actorDirectoryReportSchema,
398
+ actorProfileReportSchema
359
399
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-SS67LUOK.js";
3
+ } from "./chunk-WNOVRQ67.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -271,10 +271,35 @@ async function disconnectStateAdapter() {
271
271
  }
272
272
  }
273
273
 
274
+ // src/chat/sandbox/paths.ts
275
+ function normalizeWorkspaceRoot(input) {
276
+ const candidate = (input ?? "").trim();
277
+ if (!candidate) {
278
+ return "/vercel/sandbox";
279
+ }
280
+ const normalized = candidate.replace(/\/+$/, "");
281
+ return normalized.startsWith("/") ? normalized : `/${normalized}`;
282
+ }
283
+ var SANDBOX_WORKSPACE_ROOT = normalizeWorkspaceRoot(
284
+ process.env.VERCEL_SANDBOX_WORKSPACE_DIR
285
+ );
286
+ var SANDBOX_SKILLS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/skills`;
287
+ var SANDBOX_DATA_ROOT = `${SANDBOX_WORKSPACE_ROOT}/data`;
288
+ function sandboxSkillDir(skillName) {
289
+ return `${SANDBOX_SKILLS_ROOT}/${skillName}`;
290
+ }
291
+ function sandboxSkillFile(skillName) {
292
+ return `${sandboxSkillDir(skillName)}/SKILL.md`;
293
+ }
294
+
274
295
  export {
275
296
  acquireActiveLock,
276
- getConnectedStateContext,
277
297
  getDefaultRedisStateAdapterFor,
278
298
  getStateAdapter,
279
- disconnectStateAdapter
299
+ disconnectStateAdapter,
300
+ SANDBOX_WORKSPACE_ROOT,
301
+ SANDBOX_SKILLS_ROOT,
302
+ SANDBOX_DATA_ROOT,
303
+ sandboxSkillDir,
304
+ sandboxSkillFile
280
305
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  toOptionalNumber,
3
3
  toOptionalString
4
- } from "./chunk-OB42YVAE.js";
4
+ } from "./chunk-42WRQLJ6.js";
5
5
  import {
6
6
  captureException,
7
7
  getActiveSpan,
@@ -13,10 +13,9 @@ import {
13
13
  } from "./chunk-6GWA276C.js";
14
14
  import {
15
15
  getDeploymentTelemetryAttributes
16
- } from "./chunk-7FBGKXPE.js";
16
+ } from "./chunk-W75ZPAGG.js";
17
17
 
18
18
  // src/chat/logging.ts
19
- import { AsyncLocalStorage } from "async_hooks";
20
19
  import path from "path";
21
20
  import { styleText } from "util";
22
21
  import {
@@ -26,6 +25,73 @@ import {
26
25
  getLogger
27
26
  } from "@logtape/logtape";
28
27
 
28
+ // src/chat/log-context.ts
29
+ import { AsyncLocalStorage } from "async_hooks";
30
+ var logContextStorage = new AsyncLocalStorage();
31
+ var typedLogContextStorage = new AsyncLocalStorage();
32
+ function definedLogContext(context) {
33
+ return Object.fromEntries(
34
+ Object.entries(context).filter(([, value]) => value !== void 0)
35
+ );
36
+ }
37
+ function definedAttributes(attributes) {
38
+ return Object.fromEntries(
39
+ Object.entries(attributes).filter(
40
+ (entry) => entry[1] !== void 0
41
+ )
42
+ );
43
+ }
44
+ function logContextToAttributes(context) {
45
+ return definedAttributes({
46
+ "gen_ai.conversation.id": context.conversationId,
47
+ "app.platform": context.platform,
48
+ "app.request.id": context.requestId,
49
+ "messaging.system": context.platform === "slack" ? "slack" : context.platform,
50
+ "messaging.message.conversation_id": context.messageConversationId,
51
+ "messaging.destination.name": context.destinationName,
52
+ "enduser.id": context.userId,
53
+ "enduser.pseudo.id": context.userName,
54
+ "app.run.id": context.runId,
55
+ "app.actor.type": context.actorType,
56
+ "app.actor.id": context.actorId,
57
+ "gen_ai.agent.name": context.assistantUserName,
58
+ "gen_ai.request.model": context.modelId,
59
+ "app.skill.name": context.skillName,
60
+ "http.request.method": context.httpMethod,
61
+ "url.path": context.httpPath,
62
+ "url.full": context.urlFull,
63
+ "user_agent.original": context.userAgent
64
+ });
65
+ }
66
+ function runWithLogContext(context, attributes, callback) {
67
+ return typedLogContextStorage.run(
68
+ {
69
+ ...typedLogContextStorage.getStore(),
70
+ ...definedLogContext(context)
71
+ },
72
+ () => logContextStorage.run(
73
+ { ...logContextStorage.getStore(), ...attributes },
74
+ callback
75
+ )
76
+ );
77
+ }
78
+ function updateLogContext(context, attributes) {
79
+ const currentContext = typedLogContextStorage.getStore();
80
+ if (currentContext) {
81
+ Object.assign(currentContext, definedLogContext(context));
82
+ }
83
+ const currentAttributes = logContextStorage.getStore();
84
+ if (currentAttributes) {
85
+ Object.assign(currentAttributes, attributes);
86
+ }
87
+ }
88
+ function getBoundLogContext() {
89
+ return typedLogContextStorage.getStore() ?? {};
90
+ }
91
+ function getBoundLogAttributes() {
92
+ return logContextStorage.getStore() ?? {};
93
+ }
94
+
29
95
  // src/chat/identities/identity.ts
30
96
  function normalizeIdentityEmail(email) {
31
97
  const normalized = email?.trim().toLowerCase();
@@ -89,7 +155,6 @@ function normalizeGenAiFinishReasons(value) {
89
155
  (reason) => typeof reason === "string" ? normalizeGenAiFinishReason(reason) : reason
90
156
  );
91
157
  }
92
- var contextStorage = new AsyncLocalStorage();
93
158
  var logRecordSinks = /* @__PURE__ */ new Set();
94
159
  var deploymentLogAttributes = getDeploymentTelemetryAttributes();
95
160
  var LOGTAPE_BODY_KEY = "__logtape_body";
@@ -322,32 +387,7 @@ function sanitizeValue(value) {
322
387
  return sanitizePrimitive(value);
323
388
  }
324
389
  function contextToAttributes(context) {
325
- const attributes = {
326
- "gen_ai.conversation.id": context.conversationId,
327
- "app.platform": context.platform,
328
- "app.request.id": context.requestId,
329
- "messaging.system": context.platform === "slack" ? "slack" : context.platform,
330
- "messaging.message.conversation_id": context.slackThreadId,
331
- "messaging.destination.name": context.slackChannelId,
332
- "enduser.id": context.slackUserId,
333
- "enduser.pseudo.id": context.slackUserName,
334
- "app.run.id": context.runId,
335
- "app.actor.type": context.actorType,
336
- "app.actor.id": context.actorId,
337
- "gen_ai.agent.name": context.assistantUserName,
338
- "gen_ai.request.model": context.modelId,
339
- "app.skill.name": context.skillName,
340
- "http.request.method": context.httpMethod,
341
- "url.path": context.httpPath,
342
- "url.full": context.urlFull,
343
- "user_agent.original": context.userAgent
344
- };
345
- const normalized = {};
346
- for (const [key, value] of Object.entries(attributes)) {
347
- const sanitized = sanitizeValue(value);
348
- if (sanitized !== void 0) normalized[key] = sanitized;
349
- }
350
- return normalized;
390
+ return mergeAttributes(logContextToAttributes(context));
351
391
  }
352
392
  function getTraceCorrelationAttributes() {
353
393
  const sentry = sentry_exports;
@@ -479,7 +519,7 @@ function ensureLoggerBackend() {
479
519
  lowestLevel: "error"
480
520
  }
481
521
  ],
482
- contextLocalStorage: contextStorage
522
+ contextLocalStorage: logContextStorage
483
523
  });
484
524
  ownsLogTapeBackend = true;
485
525
  rootLogger = getLogger([...ROOT_LOGGER_CATEGORY]);
@@ -835,7 +875,7 @@ function emitRecord(category, level, eventName, attrs = {}, body) {
835
875
  const normalizedEventName = toSnakeCase(eventName);
836
876
  const message = body ? redactSecrets(body) : normalizedEventName;
837
877
  const source = getLogSource([...ROOT_LOGGER_CATEGORY, ...category]);
838
- const contextAttributes = ownsLogTapeBackend ? void 0 : contextStorage.getStore();
878
+ const contextAttributes = ownsLogTapeBackend ? void 0 : getBoundLogAttributes();
839
879
  const attributes = mergeAttributes(
840
880
  contextAttributes,
841
881
  traceAttributes,
@@ -905,11 +945,12 @@ var log = {
905
945
  const sentryCaptureException = captureException;
906
946
  if (typeof sentryWithScope === "function" && typeof sentryCaptureException === "function") {
907
947
  sentryWithScope((scope) => {
908
- if (context) {
909
- setSentryScopeContext(scope, context);
910
- }
948
+ setSentryScopeContext(scope, {
949
+ ...getBoundLogContext(),
950
+ ...context
951
+ });
911
952
  for (const [key, value] of Object.entries(
912
- mergeAttributes(contextStorage.getStore(), attrs)
953
+ mergeAttributes(getBoundLogAttributes(), attrs)
913
954
  )) {
914
955
  scope.setExtra(key, value);
915
956
  }
@@ -918,9 +959,12 @@ var log = {
918
959
  return eventId;
919
960
  }
920
961
  if (typeof sentryCaptureException === "function") {
921
- if (context) {
922
- setSentryUser(sentryUserIdentityFromContext(context));
923
- }
962
+ setSentryUser(
963
+ sentryUserIdentityFromContext({
964
+ ...getBoundLogContext(),
965
+ ...context
966
+ })
967
+ );
924
968
  eventId = sentryCaptureException(normalizedError);
925
969
  }
926
970
  return eventId;
@@ -1004,21 +1048,14 @@ function createChatSdkLogger() {
1004
1048
  return createChatSdkLoggerImpl(["chat-sdk"], resolveChatSdkLogLevel());
1005
1049
  }
1006
1050
  function withLogContext(context, callback) {
1007
- const next = mergeAttributes(
1008
- contextStorage.getStore(),
1009
- contextToAttributes(context)
1010
- );
1011
- return contextStorage.run(next, callback);
1012
- }
1013
- function setLogContext(context) {
1014
- const merged = mergeAttributes(
1015
- contextStorage.getStore(),
1016
- contextToAttributes(context)
1051
+ return runWithLogContext(
1052
+ context,
1053
+ contextToAttributes(context),
1054
+ callback
1017
1055
  );
1018
- contextStorage.enterWith(merged);
1019
1056
  }
1020
1057
  function getLogContextAttributes() {
1021
- return contextStorage.getStore() ?? {};
1058
+ return getBoundLogAttributes();
1022
1059
  }
1023
1060
  function getLogContextAttributesForSpan(op) {
1024
1061
  const attributes = { ...getLogContextAttributes() };
@@ -1066,11 +1103,11 @@ function setSentryTagsFromContext(context) {
1066
1103
  }
1067
1104
  }
1068
1105
  function sentryUserIdentityFromContext(context) {
1069
- if (context.slackUserId) {
1070
- const email = normalizeIdentityEmail(context.slackUserEmail);
1106
+ if (context.userId) {
1107
+ const email = normalizeIdentityEmail(context.userEmail);
1071
1108
  return {
1072
- id: context.slackUserId,
1073
- ...context.slackUserName ? { username: context.slackUserName } : {},
1109
+ id: context.userId,
1110
+ ...context.userName ? { username: context.userName } : {},
1074
1111
  ...email ? { email } : {}
1075
1112
  };
1076
1113
  }
@@ -1156,7 +1193,7 @@ function logException(error, eventName, context = {}, attributes = {}, body) {
1156
1193
  );
1157
1194
  }
1158
1195
  function setTags(context = {}) {
1159
- setLogContext(context);
1196
+ updateLogContext(context, contextToAttributes(context));
1160
1197
  setSentryTagsFromContext(context);
1161
1198
  setSentryUser(sentryUserIdentityFromContext(context));
1162
1199
  }
@@ -1437,6 +1474,7 @@ export {
1437
1474
  normalizeGenAiFinishReason,
1438
1475
  summarizeMessageText,
1439
1476
  createChatSdkLogger,
1477
+ withLogContext,
1440
1478
  getLogContextAttributesForSpan,
1441
1479
  setSentryUser,
1442
1480
  logInfo,