@sentry/junior-memory 0.91.0 → 0.92.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/src/recall.ts CHANGED
@@ -1,8 +1,4 @@
1
- import type {
2
- PromptMessage,
3
- Requester,
4
- Source,
5
- } from "@sentry/junior-plugin-api";
1
+ import type { PromptMessage, Actor, Source } from "@sentry/junior-plugin-api";
6
2
  import {
7
3
  createMemoryStore,
8
4
  type MemoryDb,
@@ -21,7 +17,7 @@ export interface MemoryRecallContext {
21
17
  embedder?: MemoryEmbeddingProvider;
22
18
  /** Maximum cosine distance for vector recall. Passed through to the memory store. */
23
19
  maxVectorDistance?: number;
24
- requester?: Requester;
20
+ actor?: Actor;
25
21
  source: Source;
26
22
  text: string;
27
23
  }
@@ -74,19 +70,15 @@ export async function createMemoryPromptMessages(
74
70
  ...(context.conversationId
75
71
  ? { conversationId: context.conversationId }
76
72
  : {}),
77
- ...(context.requester ? { requester: context.requester } : {}),
73
+ ...(context.actor ? { actor: context.actor } : {}),
78
74
  source: context.source,
79
75
  });
80
- const memories = await createMemoryStore(
81
- context.db,
82
- runtimeContext,
83
- {
84
- ...(context.embedder ? { embedder: context.embedder } : {}),
85
- ...(context.maxVectorDistance !== undefined
86
- ? { maxVectorDistance: context.maxVectorDistance }
87
- : {}),
88
- },
89
- ).searchMemories({
76
+ const memories = await createMemoryStore(context.db, runtimeContext, {
77
+ ...(context.embedder ? { embedder: context.embedder } : {}),
78
+ ...(context.maxVectorDistance !== undefined
79
+ ? { maxVectorDistance: context.maxVectorDistance }
80
+ : {}),
81
+ }).searchMemories({
90
82
  query: context.text,
91
83
  limit: DEFAULT_RECALL_LIMIT,
92
84
  });
package/src/scope.ts CHANGED
@@ -31,15 +31,15 @@ function sourceConversationKey(ctx: MemoryRuntimeContext): string | undefined {
31
31
  return `slack:${ctx.source.teamId}:${ctx.source.channelId}:${threadKey}`;
32
32
  }
33
33
 
34
- function requesterScopeKey(ctx: MemoryRuntimeContext): string | undefined {
35
- const requester = ctx.requester;
36
- if (!requester?.userId) {
34
+ function actorScopeKey(ctx: MemoryRuntimeContext): string | undefined {
35
+ const actor = ctx.actor;
36
+ if (!actor?.userId) {
37
37
  return undefined;
38
38
  }
39
- if (requester.platform === "slack") {
40
- return `slack:${requester.teamId}:${requester.userId}`;
39
+ if (actor.platform === "slack") {
40
+ return `slack:${actor.teamId}:${actor.userId}`;
41
41
  }
42
- return `local:${requester.userId}`;
42
+ return `local:${actor.userId}`;
43
43
  }
44
44
 
45
45
  /** Derive the authority-bearing key for a requested memory scope. */
@@ -48,9 +48,9 @@ export function deriveMemoryScope(
48
48
  scope: MemoryScope,
49
49
  ): ResolvedMemoryScope {
50
50
  if (scope === "personal") {
51
- const scopeKey = requesterScopeKey(ctx);
51
+ const scopeKey = actorScopeKey(ctx);
52
52
  if (!scopeKey) {
53
- throw new Error("Personal memory requires requester context.");
53
+ throw new Error("Personal memory requires actor context.");
54
54
  }
55
55
  return { scope, scopeKey };
56
56
  }
@@ -68,9 +68,9 @@ export function deriveMemorySubject(
68
68
  scope: ResolvedMemoryScope,
69
69
  ): ResolvedMemorySubject {
70
70
  if (scope.scope === "personal") {
71
- const subjectKey = requesterScopeKey(ctx);
71
+ const subjectKey = actorScopeKey(ctx);
72
72
  if (!subjectKey) {
73
- throw new Error("User-subject memory requires requester context.");
73
+ throw new Error("User-subject memory requires actor context.");
74
74
  }
75
75
  return { subjectType: "user", subjectKey };
76
76
  }
@@ -92,7 +92,7 @@ export function deriveVisibleMemoryScopes(
92
92
  try {
93
93
  scopes.push(deriveMemoryScope(ctx, "personal"));
94
94
  } catch {
95
- // Personal memory is optional when a runtime surface has no requester.
95
+ // Personal memory is optional when a runtime surface has no actor.
96
96
  }
97
97
  try {
98
98
  scopes.push(deriveMemoryScope(ctx, "conversation"));
package/src/store.ts CHANGED
@@ -290,7 +290,7 @@ export interface MemoryStore {
290
290
  ): Promise<ArchiveExpiredMemoriesResult>;
291
291
  /** Archive a visible memory in the current runtime context. */
292
292
  archiveMemory(input: ArchiveMemoryInput): Promise<MemoryRecord>;
293
- /** Store a personal memory for the current requester. */
293
+ /** Store a personal memory for the current actor. */
294
294
  createMemory(input: CreateMemoryInput): Promise<CreateMemoryResult>;
295
295
  /** Store a conversation memory for the current source conversation. */
296
296
  createConversationMemory(
package/src/tools.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  PluginToolInputError,
7
7
  type PluginToolResult,
8
8
  type Source,
9
- type Requester,
9
+ type Actor,
10
10
  pluginToolResultSchema,
11
11
  } from "@sentry/junior-plugin-api";
12
12
  import { z } from "zod";
@@ -43,8 +43,8 @@ const KNOWN_TOOL_INPUT_ERROR_MESSAGES = new Set([
43
43
  "Memory id is required.",
44
44
  "Memory was not found in the current context.",
45
45
  "Memory id prefix is ambiguous.",
46
- "Personal memory requires requester context.",
47
- "User-subject memory requires requester context.",
46
+ "Personal memory requires actor context.",
47
+ "User-subject memory requires actor context.",
48
48
  ]);
49
49
 
50
50
  /** Runtime-owned context used to bind memory tools to visible scopes. */
@@ -53,7 +53,7 @@ export interface MemoryToolContext {
53
53
  conversationId?: string;
54
54
  db: MemoryDb;
55
55
  embedder?: MemoryEmbeddingProvider;
56
- requester?: Requester;
56
+ actor?: Actor;
57
57
  source: Source;
58
58
  userText?: string;
59
59
  }
@@ -86,7 +86,7 @@ function memoryRuntimeContext(
86
86
  ...(context.conversationId
87
87
  ? { conversationId: context.conversationId }
88
88
  : {}),
89
- ...(context.requester ? { requester: context.requester } : {}),
89
+ ...(context.actor ? { actor: context.actor } : {}),
90
90
  source: context.source,
91
91
  });
92
92
  }
@@ -384,9 +384,9 @@ function createInput(
384
384
  } satisfies CreateMemoryInput;
385
385
  }
386
386
 
387
- function targetForKind(kind: MemoryKind): "requester" | "conversation" {
387
+ function targetForKind(kind: MemoryKind): "actor" | "conversation" {
388
388
  if (kind === "preference") {
389
- return "requester";
389
+ return "actor";
390
390
  }
391
391
  return "conversation";
392
392
  }
@@ -554,7 +554,7 @@ export function createMemoryListTool(context: MemoryToolContext) {
554
554
  export function createMemorySearchTool(context: MemoryToolContext) {
555
555
  return definePluginTool({
556
556
  description:
557
- "Search active memories visible in the current context. Use when the model needs targeted memory recall. The tool searches only the current requester and active conversation scopes.",
557
+ "Search active memories visible in the current context. Use when the model needs targeted memory recall. The tool searches only the current actor and active conversation scopes.",
558
558
  annotations: { readOnlyHint: true, destructiveHint: false },
559
559
  inputSchema: searchMemoriesInputSchema,
560
560
  outputSchema: memoryManyOutputSchema,
package/src/types.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
- localRequesterSchema,
2
+ localActorSchema,
3
3
  localSourceSchema,
4
4
  platformSchema,
5
- slackRequesterSchema,
5
+ slackActorSchema,
6
6
  slackSourceSchema,
7
7
  } from "@sentry/junior-plugin-api";
8
8
  import { z } from "zod";
@@ -34,7 +34,7 @@ const nonEmptyStringSchema = z.string().min(1);
34
34
  export const slackMemoryRuntimeContextSchema = z
35
35
  .object({
36
36
  conversationId: nonEmptyStringSchema.optional(),
37
- requester: slackRequesterSchema.optional(),
37
+ actor: slackActorSchema.optional(),
38
38
  source: slackSourceSchema,
39
39
  })
40
40
  .strict();
@@ -43,7 +43,7 @@ export const slackMemoryRuntimeContextSchema = z
43
43
  export const localMemoryRuntimeContextSchema = z
44
44
  .object({
45
45
  conversationId: nonEmptyStringSchema.optional(),
46
- requester: localRequesterSchema.optional(),
46
+ actor: localActorSchema.optional(),
47
47
  source: localSourceSchema,
48
48
  })
49
49
  .strict();