@sentry/junior-memory 0.188.0 → 0.190.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,16 +37,10 @@ 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.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
- location: z.ZodOptional<z.ZodObject<{
45
- id: z.ZodString;
46
- provider: z.ZodString;
47
- tenantId: z.ZodOptional<z.ZodString>;
48
- providerId: z.ZodString;
49
- }, z.core.$strict>>;
50
44
  visibility: z.ZodEnum<{
51
45
  public: "public";
52
46
  private: "private";
@@ -54,29 +48,23 @@ declare const createMemoryRequestSchema: z.ZodObject<{
54
48
  messageTs: z.ZodOptional<z.ZodString>;
55
49
  threadTs: z.ZodOptional<z.ZodString>;
56
50
  }, z.core.$strict>, z.ZodObject<{
57
- location: z.ZodOptional<z.ZodObject<{
58
- id: z.ZodString;
59
- provider: z.ZodString;
60
- tenantId: z.ZodOptional<z.ZodString>;
61
- providerId: z.ZodString;
62
- }, z.core.$strict>>;
63
- platform: z.ZodLiteral<"local">;
51
+ kind: z.ZodLiteral<"local">;
64
52
  visibility: z.ZodLiteral<"private">;
65
53
  conversationId: z.ZodString;
66
54
  }, z.core.$strict>, z.ZodObject<{
67
- location: z.ZodOptional<z.ZodObject<{
68
- id: z.ZodString;
69
- provider: z.ZodString;
70
- tenantId: z.ZodOptional<z.ZodString>;
71
- providerId: z.ZodString;
72
- }, z.core.$strict>>;
73
- platform: z.ZodLiteral<"web">;
55
+ kind: z.ZodLiteral<"web">;
74
56
  visibility: z.ZodEnum<{
75
57
  public: "public";
76
58
  private: "private";
77
59
  }>;
78
60
  conversationId: z.ZodString;
79
- }, z.core.$strict>], "platform">;
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">>;
80
68
  userId: z.ZodOptional<z.ZodString>;
81
69
  }, z.core.$strict>;
82
70
  sourceContext: z.ZodOptional<z.ZodObject<{
@@ -136,16 +124,10 @@ declare const extractSessionRequestSchema: z.ZodObject<{
136
124
  platform: z.ZodLiteral<"system">;
137
125
  name: z.ZodString;
138
126
  }, z.core.$strict>], "platform">>;
139
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
140
- platform: z.ZodLiteral<"slack">;
127
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
128
+ kind: z.ZodLiteral<"slack">;
141
129
  teamId: z.ZodString;
142
130
  channelId: z.ZodString;
143
- location: z.ZodOptional<z.ZodObject<{
144
- id: z.ZodString;
145
- provider: z.ZodString;
146
- tenantId: z.ZodOptional<z.ZodString>;
147
- providerId: z.ZodString;
148
- }, z.core.$strict>>;
149
131
  visibility: z.ZodEnum<{
150
132
  public: "public";
151
133
  private: "private";
@@ -153,29 +135,23 @@ declare const extractSessionRequestSchema: z.ZodObject<{
153
135
  messageTs: z.ZodOptional<z.ZodString>;
154
136
  threadTs: z.ZodOptional<z.ZodString>;
155
137
  }, z.core.$strict>, z.ZodObject<{
156
- location: z.ZodOptional<z.ZodObject<{
157
- id: z.ZodString;
158
- provider: z.ZodString;
159
- tenantId: z.ZodOptional<z.ZodString>;
160
- providerId: z.ZodString;
161
- }, z.core.$strict>>;
162
- platform: z.ZodLiteral<"local">;
138
+ kind: z.ZodLiteral<"local">;
163
139
  visibility: z.ZodLiteral<"private">;
164
140
  conversationId: z.ZodString;
165
141
  }, z.core.$strict>, z.ZodObject<{
166
- location: z.ZodOptional<z.ZodObject<{
167
- id: z.ZodString;
168
- provider: z.ZodString;
169
- tenantId: z.ZodOptional<z.ZodString>;
170
- providerId: z.ZodString;
171
- }, z.core.$strict>>;
172
- platform: z.ZodLiteral<"web">;
142
+ kind: z.ZodLiteral<"web">;
173
143
  visibility: z.ZodEnum<{
174
144
  public: "public";
175
145
  private: "private";
176
146
  }>;
177
147
  conversationId: z.ZodString;
178
- }, z.core.$strict>], "platform">;
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">>;
179
155
  userId: z.ZodOptional<z.ZodString>;
180
156
  }, z.core.$strict>;
181
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(