@sentry/junior-memory 0.135.0 → 0.136.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.d.ts CHANGED
@@ -11,17 +11,26 @@ declare const memoryRecallInputSchema: z.ZodObject<{
11
11
  declare const createMemoryRequestSchema: z.ZodObject<{
12
12
  content: z.ZodString;
13
13
  expiresAtMs: z.ZodOptional<z.ZodNumber>;
14
- runtimeContext: z.ZodUnion<readonly [z.ZodObject<{
14
+ runtimeContext: z.ZodObject<{
15
15
  conversationId: z.ZodOptional<z.ZodString>;
16
- actor: z.ZodOptional<z.ZodObject<{
16
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
17
17
  platform: z.ZodLiteral<"slack">;
18
18
  teamId: z.ZodString;
19
19
  email: z.ZodOptional<z.ZodString>;
20
20
  fullName: z.ZodOptional<z.ZodString>;
21
21
  userId: z.ZodString;
22
22
  userName: z.ZodOptional<z.ZodString>;
23
- }, z.core.$strict>>;
24
- source: z.ZodObject<{
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ platform: z.ZodLiteral<"local">;
25
+ email: z.ZodOptional<z.ZodString>;
26
+ fullName: z.ZodOptional<z.ZodString>;
27
+ userId: z.ZodString;
28
+ userName: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ platform: z.ZodLiteral<"system">;
31
+ name: z.ZodString;
32
+ }, z.core.$strict>], "platform">>;
33
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
25
34
  platform: z.ZodLiteral<"slack">;
26
35
  teamId: z.ZodString;
27
36
  channelId: z.ZodString;
@@ -31,22 +40,12 @@ declare const createMemoryRequestSchema: z.ZodObject<{
31
40
  }>;
32
41
  messageTs: z.ZodOptional<z.ZodString>;
33
42
  threadTs: z.ZodOptional<z.ZodString>;
34
- }, z.core.$strict>;
35
- }, z.core.$strict>, z.ZodObject<{
36
- conversationId: z.ZodOptional<z.ZodString>;
37
- actor: z.ZodOptional<z.ZodObject<{
38
- platform: z.ZodLiteral<"local">;
39
- email: z.ZodOptional<z.ZodString>;
40
- fullName: z.ZodOptional<z.ZodString>;
41
- userId: z.ZodString;
42
- userName: z.ZodOptional<z.ZodString>;
43
- }, z.core.$strict>>;
44
- source: z.ZodObject<{
43
+ }, z.core.$strict>, z.ZodObject<{
45
44
  platform: z.ZodLiteral<"local">;
46
45
  visibility: z.ZodLiteral<"private">;
47
46
  conversationId: z.ZodString;
48
- }, z.core.$strict>;
49
- }, z.core.$strict>]>;
47
+ }, z.core.$strict>], "platform">;
48
+ }, z.core.$strict>;
50
49
  sourceContext: z.ZodOptional<z.ZodObject<{
51
50
  currentUserText: z.ZodOptional<z.ZodString>;
52
51
  }, z.core.$strict>>;
@@ -72,17 +71,26 @@ declare const extractSessionRequestSchema: z.ZodObject<{
72
71
  platform: z.ZodLiteral<"system">;
73
72
  name: z.ZodString;
74
73
  }, z.core.$strict>], "platform">>;
75
- runtimeContext: z.ZodUnion<readonly [z.ZodObject<{
74
+ runtimeContext: z.ZodObject<{
76
75
  conversationId: z.ZodOptional<z.ZodString>;
77
- actor: z.ZodOptional<z.ZodObject<{
76
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
78
77
  platform: z.ZodLiteral<"slack">;
79
78
  teamId: z.ZodString;
80
79
  email: z.ZodOptional<z.ZodString>;
81
80
  fullName: z.ZodOptional<z.ZodString>;
82
81
  userId: z.ZodString;
83
82
  userName: z.ZodOptional<z.ZodString>;
84
- }, z.core.$strict>>;
85
- source: z.ZodObject<{
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ platform: z.ZodLiteral<"local">;
85
+ email: z.ZodOptional<z.ZodString>;
86
+ fullName: z.ZodOptional<z.ZodString>;
87
+ userId: z.ZodString;
88
+ userName: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strict>, z.ZodObject<{
90
+ platform: z.ZodLiteral<"system">;
91
+ name: z.ZodString;
92
+ }, z.core.$strict>], "platform">>;
93
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
86
94
  platform: z.ZodLiteral<"slack">;
87
95
  teamId: z.ZodString;
88
96
  channelId: z.ZodString;
@@ -92,22 +100,12 @@ declare const extractSessionRequestSchema: z.ZodObject<{
92
100
  }>;
93
101
  messageTs: z.ZodOptional<z.ZodString>;
94
102
  threadTs: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strict>;
96
- }, z.core.$strict>, z.ZodObject<{
97
- conversationId: z.ZodOptional<z.ZodString>;
98
- actor: z.ZodOptional<z.ZodObject<{
99
- platform: z.ZodLiteral<"local">;
100
- email: z.ZodOptional<z.ZodString>;
101
- fullName: z.ZodOptional<z.ZodString>;
102
- userId: z.ZodString;
103
- userName: z.ZodOptional<z.ZodString>;
104
- }, z.core.$strict>>;
105
- source: z.ZodObject<{
103
+ }, z.core.$strict>, z.ZodObject<{
106
104
  platform: z.ZodLiteral<"local">;
107
105
  visibility: z.ZodLiteral<"private">;
108
106
  conversationId: z.ZodString;
109
- }, z.core.$strict>;
110
- }, z.core.$strict>]>;
107
+ }, z.core.$strict>], "platform">;
108
+ }, z.core.$strict>;
111
109
  transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
112
110
  type: z.ZodLiteral<"message">;
113
111
  role: z.ZodEnum<{
package/dist/api.d.ts CHANGED
@@ -18,6 +18,15 @@ export declare const memoryApiSchema: z.ZodObject<{
18
18
  knowledge: "knowledge";
19
19
  }>;
20
20
  observedAt: z.ZodISODateTime;
21
+ origin: z.ZodEnum<{
22
+ automatic: "automatic";
23
+ explicit: "explicit";
24
+ other: "other";
25
+ }>;
26
+ sourcePlatform: z.ZodEnum<{
27
+ slack: "slack";
28
+ local: "local";
29
+ }>;
21
30
  visibility: z.ZodEnum<{
22
31
  public: "public";
23
32
  private: "private";
@@ -35,6 +44,15 @@ export declare const memoryListResponseSchema: z.ZodObject<{
35
44
  knowledge: "knowledge";
36
45
  }>;
37
46
  observedAt: z.ZodISODateTime;
47
+ origin: z.ZodEnum<{
48
+ automatic: "automatic";
49
+ explicit: "explicit";
50
+ other: "other";
51
+ }>;
52
+ sourcePlatform: z.ZodEnum<{
53
+ slack: "slack";
54
+ local: "local";
55
+ }>;
38
56
  visibility: z.ZodEnum<{
39
57
  public: "public";
40
58
  private: "private";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { defineJuniorPlugin } from "@sentry/junior-plugin-api";
3
3
 
4
4
  // src/agent.ts
5
- import { actorSchema } from "@sentry/junior-plugin-api";
5
+ import { actorSchema as actorSchema2 } from "@sentry/junior-plugin-api";
6
6
  import { z as z3 } from "zod";
7
7
 
8
8
  // src/store.ts
@@ -40,10 +40,8 @@ import {
40
40
 
41
41
  // src/types.ts
42
42
  import {
43
- localActorSchema,
44
- localSourceSchema,
45
- slackActorSchema,
46
- slackSourceSchema
43
+ actorSchema,
44
+ sourceSchema
47
45
  } from "@sentry/junior-plugin-api";
48
46
  import { z } from "zod";
49
47
  var MEMORY_KINDS = ["preference", "procedure", "knowledge"];
@@ -60,20 +58,11 @@ var MEMORY_SOURCE_PLATFORMS = [
60
58
  var MEMORY_EMBEDDING_METRICS = ["cosine"];
61
59
  var MEMORY_EMBEDDING_DIMENSIONS = 1536;
62
60
  var nonEmptyStringSchema = z.string().min(1);
63
- var slackMemoryRuntimeContextSchema = z.object({
61
+ var memoryRuntimeContextSchema = z.object({
64
62
  conversationId: nonEmptyStringSchema.optional(),
65
- actor: slackActorSchema.optional(),
66
- source: slackSourceSchema
63
+ actor: actorSchema.optional(),
64
+ source: sourceSchema
67
65
  }).strict();
68
- var localMemoryRuntimeContextSchema = z.object({
69
- conversationId: nonEmptyStringSchema.optional(),
70
- actor: localActorSchema.optional(),
71
- source: localSourceSchema
72
- }).strict();
73
- var memoryRuntimeContextSchema = z.union([
74
- slackMemoryRuntimeContextSchema,
75
- localMemoryRuntimeContextSchema
76
- ]);
77
66
 
78
67
  // src/db/schema.ts
79
68
  var tsvector = customType({
@@ -302,7 +291,7 @@ function sourceConversationKey(ctx) {
302
291
  }
303
292
  function actorScopeKey(ctx) {
304
293
  const actor = ctx.actor;
305
- if (!actor?.userId) {
294
+ if (!actor || actor.platform === "system") {
306
295
  return void 0;
307
296
  }
308
297
  if (actor.platform === "slack") {
@@ -1421,7 +1410,7 @@ var createMemoryRequestSchema = z3.object({
1421
1410
  }).strict();
1422
1411
  var transcriptProvenanceSchema = z3.object({
1423
1412
  authority: z3.enum(["instruction", "context"]),
1424
- actor: actorSchema.optional()
1413
+ actor: actorSchema2.optional()
1425
1414
  }).strict();
1426
1415
  var evidenceMessageIndicesSchema = z3.array(z3.number().int().nonnegative()).min(1).max(10).describe("Indices from <run-transcript> that directly support this memory.");
1427
1416
  var extractSessionRequestSchema = z3.object({
@@ -1430,7 +1419,7 @@ var extractSessionRequestSchema = z3.object({
1430
1419
  content: z3.string().min(1)
1431
1420
  }).strict()
1432
1421
  ).max(10).default([]),
1433
- actors: z3.array(actorSchema),
1422
+ actors: z3.array(actorSchema2),
1434
1423
  runtimeContext: memoryRuntimeContextSchema,
1435
1424
  transcript: z3.array(
1436
1425
  z3.discriminatedUnion("type", [
@@ -2213,6 +2202,8 @@ var memoryApiSchema = z6.object({
2213
2202
  id: z6.string().min(1),
2214
2203
  kind: z6.enum(["preference", "procedure", "knowledge"]),
2215
2204
  observedAt: z6.iso.datetime(),
2205
+ origin: z6.enum(["automatic", "explicit", "other"]),
2206
+ sourcePlatform: z6.enum(["local", "slack"]),
2216
2207
  visibility: z6.enum(["private", "public"])
2217
2208
  }).strict();
2218
2209
  var memoryListResponseSchema = z6.object({
@@ -2266,6 +2257,8 @@ function apiMemory(memory) {
2266
2257
  id: memory.id,
2267
2258
  kind: memory.kind,
2268
2259
  observedAt: new Date(memory.observedAtMs).toISOString(),
2260
+ origin: memory.origin,
2261
+ sourcePlatform: memory.sourcePlatform,
2269
2262
  visibility: memory.visibility
2270
2263
  };
2271
2264
  }
@@ -3025,8 +3018,8 @@ function routeExtractedMemory(memory, transcript, run) {
3025
3018
  return "drop";
3026
3019
  }
3027
3020
  if (memory.kind === "preference") {
3028
- const exactlyOneRunActor = Boolean(run.actor) && run.actors.length === 1;
3029
- if (!exactlyOneRunActor) {
3021
+ const exactlyOneHumanRunActor = run.actor !== void 0 && run.actor.platform !== "system" && run.actors.length === 1 && run.actors[0]?.platform !== "system";
3022
+ if (!exactlyOneHumanRunActor) {
3030
3023
  return "drop";
3031
3024
  }
3032
3025
  return cited.entries.every(isRunActorInstruction) ? "personal" : "drop";