@sentry/junior-memory 0.189.0 → 0.191.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.d.ts CHANGED
@@ -37,8 +37,8 @@ declare const createMemoryRequestSchema: z.ZodObject<{
37
37
  platform: z.ZodLiteral<"system">;
38
38
  name: z.ZodString;
39
39
  }, z.core.$strict>], "platform">>;
40
- source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
41
- platform: z.ZodLiteral<"slack">;
40
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
41
+ kind: z.ZodLiteral<"slack">;
42
42
  teamId: z.ZodString;
43
43
  channelId: z.ZodString;
44
44
  visibility: z.ZodEnum<{
@@ -47,90 +47,24 @@ declare const createMemoryRequestSchema: z.ZodObject<{
47
47
  }>;
48
48
  messageTs: z.ZodOptional<z.ZodString>;
49
49
  threadTs: z.ZodOptional<z.ZodString>;
50
- location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
51
- id: z.ZodString;
52
- provider: z.ZodLiteral<"slack">;
53
- teamId: z.ZodString;
54
- channelId: z.ZodString;
55
- threadTs: z.ZodOptional<z.ZodString>;
56
- }, z.core.$strict>], "provider">>;
57
50
  }, z.core.$strict>, z.ZodObject<{
58
- platform: z.ZodLiteral<"local">;
51
+ kind: z.ZodLiteral<"local">;
59
52
  visibility: z.ZodLiteral<"private">;
60
53
  conversationId: z.ZodString;
61
- location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
62
- id: z.ZodString;
63
- provider: z.ZodLiteral<"slack">;
64
- teamId: z.ZodString;
65
- channelId: z.ZodString;
66
- threadTs: z.ZodOptional<z.ZodString>;
67
- }, z.core.$strict>], "provider">>;
68
54
  }, z.core.$strict>, z.ZodObject<{
69
- platform: z.ZodLiteral<"web">;
55
+ kind: z.ZodLiteral<"web">;
70
56
  visibility: z.ZodEnum<{
71
57
  public: "public";
72
58
  private: "private";
73
59
  }>;
74
60
  conversationId: z.ZodString;
75
- location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
76
- id: z.ZodString;
77
- provider: z.ZodLiteral<"slack">;
78
- teamId: z.ZodString;
79
- channelId: z.ZodString;
80
- threadTs: z.ZodOptional<z.ZodString>;
81
- }, z.core.$strict>], "provider">>;
82
- }, z.core.$strict>], "platform">, z.ZodTransform<{
83
- platform: "slack";
84
- teamId: string;
85
- channelId: string;
86
- visibility: "public" | "private";
87
- messageTs?: string | undefined;
88
- threadTs?: string | undefined;
89
- } | {
90
- platform: "local";
91
- visibility: "private";
92
- conversationId: string;
93
- } | {
94
- platform: "web";
95
- visibility: "public" | "private";
96
- conversationId: string;
97
- }, {
98
- platform: "slack";
99
- teamId: string;
100
- channelId: string;
101
- visibility: "public" | "private";
102
- messageTs?: string | undefined;
103
- threadTs?: string | undefined;
104
- location?: {
105
- id: string;
106
- provider: "slack";
107
- teamId: string;
108
- channelId: string;
109
- threadTs?: string | undefined;
110
- } | undefined;
111
- } | {
112
- platform: "local";
113
- visibility: "private";
114
- conversationId: string;
115
- location?: {
116
- id: string;
117
- provider: "slack";
118
- teamId: string;
119
- channelId: string;
120
- threadTs?: string | undefined;
121
- } | undefined;
122
- } | {
123
- platform: "web";
124
- visibility: "public" | "private";
125
- conversationId: string;
126
- location?: {
127
- id: string;
128
- provider: "slack";
129
- teamId: string;
130
- channelId: string;
131
- threadTs?: string | undefined;
132
- } | undefined;
133
- }>>;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ kind: z.ZodLiteral<"resource_event">;
63
+ eventKey: z.ZodString;
64
+ eventType: z.ZodString;
65
+ identifier: z.ZodString;
66
+ namespace: z.ZodString;
67
+ }, z.core.$strict>], "kind">, unknown>;
134
68
  userId: z.ZodOptional<z.ZodString>;
135
69
  }, z.core.$strict>;
136
70
  sourceContext: z.ZodOptional<z.ZodObject<{
@@ -190,8 +124,8 @@ declare const extractSessionRequestSchema: z.ZodObject<{
190
124
  platform: z.ZodLiteral<"system">;
191
125
  name: z.ZodString;
192
126
  }, z.core.$strict>], "platform">>;
193
- source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
194
- platform: z.ZodLiteral<"slack">;
127
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
128
+ kind: z.ZodLiteral<"slack">;
195
129
  teamId: z.ZodString;
196
130
  channelId: z.ZodString;
197
131
  visibility: z.ZodEnum<{
@@ -200,90 +134,24 @@ declare const extractSessionRequestSchema: z.ZodObject<{
200
134
  }>;
201
135
  messageTs: z.ZodOptional<z.ZodString>;
202
136
  threadTs: z.ZodOptional<z.ZodString>;
203
- location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
204
- id: z.ZodString;
205
- provider: z.ZodLiteral<"slack">;
206
- teamId: z.ZodString;
207
- channelId: z.ZodString;
208
- threadTs: z.ZodOptional<z.ZodString>;
209
- }, z.core.$strict>], "provider">>;
210
137
  }, z.core.$strict>, z.ZodObject<{
211
- platform: z.ZodLiteral<"local">;
138
+ kind: z.ZodLiteral<"local">;
212
139
  visibility: z.ZodLiteral<"private">;
213
140
  conversationId: z.ZodString;
214
- location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
215
- id: z.ZodString;
216
- provider: z.ZodLiteral<"slack">;
217
- teamId: z.ZodString;
218
- channelId: z.ZodString;
219
- threadTs: z.ZodOptional<z.ZodString>;
220
- }, z.core.$strict>], "provider">>;
221
141
  }, z.core.$strict>, z.ZodObject<{
222
- platform: z.ZodLiteral<"web">;
142
+ kind: z.ZodLiteral<"web">;
223
143
  visibility: z.ZodEnum<{
224
144
  public: "public";
225
145
  private: "private";
226
146
  }>;
227
147
  conversationId: z.ZodString;
228
- location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
229
- id: z.ZodString;
230
- provider: z.ZodLiteral<"slack">;
231
- teamId: z.ZodString;
232
- channelId: z.ZodString;
233
- threadTs: z.ZodOptional<z.ZodString>;
234
- }, z.core.$strict>], "provider">>;
235
- }, z.core.$strict>], "platform">, z.ZodTransform<{
236
- platform: "slack";
237
- teamId: string;
238
- channelId: string;
239
- visibility: "public" | "private";
240
- messageTs?: string | undefined;
241
- threadTs?: string | undefined;
242
- } | {
243
- platform: "local";
244
- visibility: "private";
245
- conversationId: string;
246
- } | {
247
- platform: "web";
248
- visibility: "public" | "private";
249
- conversationId: string;
250
- }, {
251
- platform: "slack";
252
- teamId: string;
253
- channelId: string;
254
- visibility: "public" | "private";
255
- messageTs?: string | undefined;
256
- threadTs?: string | undefined;
257
- location?: {
258
- id: string;
259
- provider: "slack";
260
- teamId: string;
261
- channelId: string;
262
- threadTs?: string | undefined;
263
- } | undefined;
264
- } | {
265
- platform: "local";
266
- visibility: "private";
267
- conversationId: string;
268
- location?: {
269
- id: string;
270
- provider: "slack";
271
- teamId: string;
272
- channelId: string;
273
- threadTs?: string | undefined;
274
- } | undefined;
275
- } | {
276
- platform: "web";
277
- visibility: "public" | "private";
278
- conversationId: string;
279
- location?: {
280
- id: string;
281
- provider: "slack";
282
- teamId: string;
283
- channelId: string;
284
- threadTs?: string | undefined;
285
- } | undefined;
286
- }>>;
148
+ }, z.core.$strict>, z.ZodObject<{
149
+ kind: z.ZodLiteral<"resource_event">;
150
+ eventKey: z.ZodString;
151
+ eventType: z.ZodString;
152
+ identifier: z.ZodString;
153
+ namespace: z.ZodString;
154
+ }, z.core.$strict>], "kind">, unknown>;
287
155
  userId: z.ZodOptional<z.ZodString>;
288
156
  }, z.core.$strict>;
289
157
  transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
package/dist/index.js CHANGED
@@ -239,7 +239,7 @@ function privateMemoryScope(userId) {
239
239
  return { scope: "private", scopeKey: userId };
240
240
  }
241
241
  function deriveMemoryScope(ctx) {
242
- if (ctx.source.visibility === "public") {
242
+ if ("visibility" in ctx.source && ctx.source.visibility === "public") {
243
243
  return publicMemoryScope;
244
244
  }
245
245
  if (!ctx.userId) {
@@ -367,6 +367,12 @@ var memoryRowSchema = z2.object({
367
367
  });
368
368
  }
369
369
  });
370
+ function storedMemorySource(source) {
371
+ if (source.kind === "resource_event") {
372
+ throw new Error("Resource event Source cannot own a Memory.");
373
+ }
374
+ return source.kind;
375
+ }
370
376
  var memoryRecordSchema = z2.object({
371
377
  archivedAtMs: numberSchema.optional(),
372
378
  archiveReason: nonEmptyStringSchema2.optional(),
@@ -705,7 +711,7 @@ async function rememberDuplicateIdempotency(args) {
705
711
  scope: args.scope.scope,
706
712
  scopeKey: args.scope.scopeKey,
707
713
  sourceKey: sourceKey(args.runtimeContext),
708
- sourcePlatform: args.runtimeContext.source.platform,
714
+ sourcePlatform: storedMemorySource(args.runtimeContext.source),
709
715
  subjectKey: args.subject.subjectKey,
710
716
  subjectType: args.subject.subjectType,
711
717
  supersededAtMs: args.nowMs,
@@ -1078,7 +1084,7 @@ function createMemoryStore(db, context, options = {}) {
1078
1084
  scope: scope.scope,
1079
1085
  scopeKey: scope.scopeKey,
1080
1086
  sourceKey: sourceKey(runtimeContext),
1081
- sourcePlatform: runtimeContext.source.platform,
1087
+ sourcePlatform: storedMemorySource(runtimeContext.source),
1082
1088
  subjectKey: subject.subjectKey,
1083
1089
  subjectType: subject.subjectType,
1084
1090
  kind: input.kind
@@ -1451,12 +1457,14 @@ function actorLabel(actor) {
1451
1457
  }
1452
1458
  }
1453
1459
  function sourceLabel(source) {
1454
- switch (source.platform) {
1460
+ switch (source.kind) {
1455
1461
  case "slack":
1456
1462
  return `slack:${source.teamId}:${source.channelId}`;
1457
1463
  case "web":
1458
1464
  case "local":
1459
- return `${source.platform}:${source.conversationId}`;
1465
+ return `${source.kind}:${source.conversationId}`;
1466
+ case "resource_event":
1467
+ return `resource-event:${source.namespace}:${source.eventKey}`;
1460
1468
  }
1461
1469
  }
1462
1470
  function runtimeDescription(request) {
@@ -2918,7 +2926,7 @@ async function getTaskExtraction(context, extract) {
2918
2926
  }
2919
2927
  async function processMemorySession(context) {
2920
2928
  const run = await context.run.load();
2921
- if (run.source.platform === "local") {
2929
+ if (run.source.kind === "local" || run.source.kind === "resource_event") {
2922
2930
  return;
2923
2931
  }
2924
2932
  if (run.transcript.some(