@sentry/junior-memory 0.206.0 → 0.208.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/index.d.ts +6 -6
- package/dist/index.js +206 -151
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -551,15 +551,15 @@ declare const memoryRuntimeContextSchema: z.ZodObject<{
|
|
|
551
551
|
}>;
|
|
552
552
|
conversationId: z.ZodString;
|
|
553
553
|
}, z.core.$strict>, z.ZodObject<{
|
|
554
|
-
kind: z.ZodLiteral<"
|
|
554
|
+
kind: z.ZodLiteral<"event">;
|
|
555
555
|
eventKey: z.ZodString;
|
|
556
556
|
eventType: z.ZodString;
|
|
557
557
|
identifier: z.ZodString;
|
|
558
558
|
namespace: z.ZodString;
|
|
559
559
|
}, z.core.$strict>, z.ZodObject<{
|
|
560
|
-
kind: z.ZodLiteral<"
|
|
560
|
+
kind: z.ZodLiteral<"scheduled_automation">;
|
|
561
561
|
}, z.core.$strict>, z.ZodObject<{
|
|
562
|
-
kind: z.ZodLiteral<"
|
|
562
|
+
kind: z.ZodLiteral<"event_automation">;
|
|
563
563
|
}, z.core.$strict>, z.ZodObject<{
|
|
564
564
|
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
565
565
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -677,15 +677,15 @@ declare const memorySupersessionInputSchema: z.ZodObject<{
|
|
|
677
677
|
}>;
|
|
678
678
|
conversationId: z.ZodString;
|
|
679
679
|
}, z.core.$strict>, z.ZodObject<{
|
|
680
|
-
kind: z.ZodLiteral<"
|
|
680
|
+
kind: z.ZodLiteral<"event">;
|
|
681
681
|
eventKey: z.ZodString;
|
|
682
682
|
eventType: z.ZodString;
|
|
683
683
|
identifier: z.ZodString;
|
|
684
684
|
namespace: z.ZodString;
|
|
685
685
|
}, z.core.$strict>, z.ZodObject<{
|
|
686
|
-
kind: z.ZodLiteral<"
|
|
686
|
+
kind: z.ZodLiteral<"scheduled_automation">;
|
|
687
687
|
}, z.core.$strict>, z.ZodObject<{
|
|
688
|
-
kind: z.ZodLiteral<"
|
|
688
|
+
kind: z.ZodLiteral<"event_automation">;
|
|
689
689
|
}, z.core.$strict>, z.ZodObject<{
|
|
690
690
|
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
691
691
|
}, z.core.$strict>, z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -373,9 +373,9 @@ function storedMemorySource(source) {
|
|
|
373
373
|
case "local":
|
|
374
374
|
case "web":
|
|
375
375
|
return source.kind;
|
|
376
|
-
case "
|
|
377
|
-
case "
|
|
378
|
-
case "
|
|
376
|
+
case "event":
|
|
377
|
+
case "scheduled_automation":
|
|
378
|
+
case "event_automation":
|
|
379
379
|
case "plugin_dispatch":
|
|
380
380
|
case "agent_invocation":
|
|
381
381
|
throw new Error(`${source.kind} Source cannot own a Memory.`);
|
|
@@ -1469,10 +1469,10 @@ function sourceLabel(source) {
|
|
|
1469
1469
|
case "web":
|
|
1470
1470
|
case "local":
|
|
1471
1471
|
return `${source.kind}:${source.conversationId}`;
|
|
1472
|
-
case "
|
|
1473
|
-
return `
|
|
1474
|
-
case "
|
|
1475
|
-
case "
|
|
1472
|
+
case "event":
|
|
1473
|
+
return `event:${source.namespace}:${source.eventKey}`;
|
|
1474
|
+
case "scheduled_automation":
|
|
1475
|
+
case "event_automation":
|
|
1476
1476
|
case "plugin_dispatch":
|
|
1477
1477
|
case "agent_invocation":
|
|
1478
1478
|
return source.kind;
|
|
@@ -1783,7 +1783,7 @@ function parseCreateMemoryRequest(request) {
|
|
|
1783
1783
|
}
|
|
1784
1784
|
|
|
1785
1785
|
// src/api.ts
|
|
1786
|
-
import { z as
|
|
1786
|
+
import { z as z6 } from "zod";
|
|
1787
1787
|
import {
|
|
1788
1788
|
pluginApiRouteRequestContextSchema
|
|
1789
1789
|
} from "@sentry/junior-plugin-api";
|
|
@@ -2080,58 +2080,151 @@ async function getMemoryTimelineHours(db, userId, hours = 24) {
|
|
|
2080
2080
|
});
|
|
2081
2081
|
}
|
|
2082
2082
|
|
|
2083
|
-
// src/
|
|
2084
|
-
|
|
2083
|
+
// src/events.ts
|
|
2084
|
+
import { defineConversationEvent } from "@sentry/junior-plugin-api";
|
|
2085
|
+
import { z as z5 } from "zod";
|
|
2086
|
+
var capturedMemoryFields = {
|
|
2085
2087
|
content: z5.string().min(1),
|
|
2086
|
-
createdAt: z5.iso.datetime(),
|
|
2087
|
-
expiresAt: z5.iso.datetime().optional(),
|
|
2088
2088
|
id: z5.string().min(1),
|
|
2089
|
-
kind: z5.enum(
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2089
|
+
kind: z5.enum(MEMORY_KINDS),
|
|
2090
|
+
observedAtMs: z5.number().finite()
|
|
2091
|
+
};
|
|
2092
|
+
var legacyCapturedMemorySchema = z5.object({
|
|
2093
|
+
...capturedMemoryFields,
|
|
2094
|
+
scope: z5.enum(["personal", "conversation"])
|
|
2094
2095
|
}).strict();
|
|
2095
|
-
var
|
|
2096
|
-
|
|
2097
|
-
|
|
2096
|
+
var capturedMemorySchema = z5.object({
|
|
2097
|
+
...capturedMemoryFields,
|
|
2098
|
+
scope: z5.enum(MEMORY_SCOPES)
|
|
2099
|
+
}).strict();
|
|
2100
|
+
var legacyCapturedMemoriesSchema = z5.object({
|
|
2101
|
+
memories: z5.array(legacyCapturedMemorySchema).min(1).max(100)
|
|
2102
|
+
}).strict();
|
|
2103
|
+
var capturedMemoriesSchema = z5.object({
|
|
2104
|
+
memories: z5.array(capturedMemorySchema).max(100),
|
|
2105
|
+
costUsd: z5.number().finite().nonnegative().optional()
|
|
2106
|
+
}).strict();
|
|
2107
|
+
var recalledMemoriesSchema = z5.object({
|
|
2108
|
+
// Matches the automatic-recall candidate window; admission packs by char budget.
|
|
2109
|
+
memories: z5.array(z5.string().min(1)).max(20),
|
|
2110
|
+
costUsd: z5.number().finite().nonnegative().optional()
|
|
2098
2111
|
}).strict();
|
|
2099
|
-
|
|
2100
|
-
|
|
2112
|
+
function currentScope(scope) {
|
|
2113
|
+
if (scope === "personal") return "private";
|
|
2114
|
+
if (scope === "conversation") return "public";
|
|
2115
|
+
return scope;
|
|
2116
|
+
}
|
|
2117
|
+
function renderCapturedMemories(event) {
|
|
2118
|
+
const count = event.memories.length;
|
|
2119
|
+
if (count === 0) return void 0;
|
|
2120
|
+
return {
|
|
2121
|
+
icon: "brain",
|
|
2122
|
+
title: `${count} ${count === 1 ? "memory" : "memories"} captured`,
|
|
2123
|
+
details: event.memories.map((memory) => ({
|
|
2124
|
+
title: memory.content,
|
|
2125
|
+
metadata: [memory.kind, currentScope(memory.scope)]
|
|
2126
|
+
}))
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
var memoriesCapturedEventV1 = defineConversationEvent({
|
|
2130
|
+
name: "memories_captured",
|
|
2131
|
+
version: 1,
|
|
2132
|
+
schema: legacyCapturedMemoriesSchema,
|
|
2133
|
+
renderEvent: renderCapturedMemories
|
|
2134
|
+
});
|
|
2135
|
+
var memoriesCapturedEvent = defineConversationEvent({
|
|
2136
|
+
name: "memories_captured",
|
|
2137
|
+
version: 2,
|
|
2138
|
+
schema: capturedMemoriesSchema,
|
|
2139
|
+
renderEvent: renderCapturedMemories
|
|
2140
|
+
});
|
|
2141
|
+
var memoriesRecalledEvent = defineConversationEvent({
|
|
2142
|
+
name: "memories_recalled",
|
|
2143
|
+
version: 1,
|
|
2144
|
+
schema: recalledMemoriesSchema,
|
|
2145
|
+
renderEvent() {
|
|
2146
|
+
return void 0;
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
function parseCapturedMemories(version, content) {
|
|
2150
|
+
if (version === memoriesCapturedEventV1.version) {
|
|
2151
|
+
return legacyCapturedMemoriesSchema.parse(content).memories;
|
|
2152
|
+
}
|
|
2153
|
+
if (version === memoriesCapturedEvent.version) {
|
|
2154
|
+
return capturedMemoriesSchema.parse(content).memories;
|
|
2155
|
+
}
|
|
2156
|
+
return [];
|
|
2157
|
+
}
|
|
2158
|
+
function capturedMemory(memory) {
|
|
2159
|
+
return {
|
|
2160
|
+
content: memory.content,
|
|
2161
|
+
id: memory.id,
|
|
2162
|
+
kind: memory.kind,
|
|
2163
|
+
observedAtMs: memory.observedAtMs,
|
|
2164
|
+
scope: memory.scope
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
// src/api.ts
|
|
2169
|
+
var memoryApiSchema = z6.object({
|
|
2170
|
+
content: z6.string().min(1),
|
|
2171
|
+
createdAt: z6.iso.datetime(),
|
|
2172
|
+
expiresAt: z6.iso.datetime().optional(),
|
|
2173
|
+
id: z6.string().min(1),
|
|
2174
|
+
kind: z6.enum(["preference", "procedure", "knowledge"]),
|
|
2175
|
+
observedAt: z6.iso.datetime(),
|
|
2176
|
+
origin: z6.enum(["automatic", "explicit", "other"]),
|
|
2177
|
+
sourcePlatform: z6.enum(MEMORY_SOURCE_PLATFORMS),
|
|
2178
|
+
visibility: z6.enum(["private", "public"])
|
|
2179
|
+
}).strict();
|
|
2180
|
+
var memoryListResponseSchema = z6.object({
|
|
2181
|
+
memories: z6.array(memoryApiSchema),
|
|
2182
|
+
nextCursor: z6.string().min(1).optional()
|
|
2183
|
+
}).strict();
|
|
2184
|
+
var conversationMemorySchema = z6.object({
|
|
2185
|
+
capturedAt: z6.iso.datetime(),
|
|
2186
|
+
content: z6.string().min(1),
|
|
2187
|
+
id: z6.string().min(1),
|
|
2188
|
+
kind: z6.enum(["preference", "procedure", "knowledge"]),
|
|
2189
|
+
visibility: z6.enum(["private", "public"])
|
|
2190
|
+
}).strict();
|
|
2191
|
+
var conversationMemoryListResponseSchema = z6.object({ memories: z6.array(conversationMemorySchema) }).strict();
|
|
2192
|
+
var memoryBucketSchema = z6.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
|
|
2193
|
+
var memoryDashboardDaySchema = z6.object({
|
|
2101
2194
|
date: memoryBucketSchema,
|
|
2102
|
-
personal:
|
|
2103
|
-
public:
|
|
2195
|
+
personal: z6.number().int().min(0),
|
|
2196
|
+
public: z6.number().int().min(0)
|
|
2104
2197
|
}).strict();
|
|
2105
|
-
var memoryCostDaySchema =
|
|
2106
|
-
costUsd:
|
|
2198
|
+
var memoryCostDaySchema = z6.object({
|
|
2199
|
+
costUsd: z6.number().finite().nonnegative(),
|
|
2107
2200
|
date: memoryBucketSchema,
|
|
2108
|
-
events:
|
|
2201
|
+
events: z6.number().int().min(0)
|
|
2109
2202
|
}).strict();
|
|
2110
|
-
var memoryDashboardResponseSchema =
|
|
2111
|
-
days:
|
|
2112
|
-
extractionDays:
|
|
2113
|
-
extractionHours:
|
|
2114
|
-
generatedAt:
|
|
2115
|
-
hours:
|
|
2116
|
-
recallDays:
|
|
2117
|
-
recallHours:
|
|
2118
|
-
stats:
|
|
2119
|
-
active:
|
|
2120
|
-
automatic:
|
|
2121
|
-
createdThirtyDays:
|
|
2122
|
-
embedded:
|
|
2123
|
-
explicit:
|
|
2124
|
-
knowledge:
|
|
2125
|
-
personal:
|
|
2126
|
-
preference:
|
|
2127
|
-
procedure:
|
|
2128
|
-
public:
|
|
2203
|
+
var memoryDashboardResponseSchema = z6.object({
|
|
2204
|
+
days: z6.array(memoryDashboardDaySchema).length(90),
|
|
2205
|
+
extractionDays: z6.array(memoryCostDaySchema).length(90),
|
|
2206
|
+
extractionHours: z6.array(memoryCostDaySchema).min(24).optional(),
|
|
2207
|
+
generatedAt: z6.iso.datetime(),
|
|
2208
|
+
hours: z6.array(memoryDashboardDaySchema).min(24).optional(),
|
|
2209
|
+
recallDays: z6.array(memoryCostDaySchema).length(90),
|
|
2210
|
+
recallHours: z6.array(memoryCostDaySchema).min(24).optional(),
|
|
2211
|
+
stats: z6.object({
|
|
2212
|
+
active: z6.number().int().min(0),
|
|
2213
|
+
automatic: z6.number().int().min(0),
|
|
2214
|
+
createdThirtyDays: z6.number().int().min(0),
|
|
2215
|
+
embedded: z6.number().int().min(0),
|
|
2216
|
+
explicit: z6.number().int().min(0),
|
|
2217
|
+
knowledge: z6.number().int().min(0),
|
|
2218
|
+
personal: z6.number().int().min(0),
|
|
2219
|
+
preference: z6.number().int().min(0),
|
|
2220
|
+
procedure: z6.number().int().min(0),
|
|
2221
|
+
public: z6.number().int().min(0)
|
|
2129
2222
|
}).strict()
|
|
2130
2223
|
}).strict();
|
|
2131
|
-
var memoryListQuerySchema =
|
|
2132
|
-
cursor:
|
|
2133
|
-
limit:
|
|
2134
|
-
q:
|
|
2224
|
+
var memoryListQuerySchema = z6.object({
|
|
2225
|
+
cursor: z6.string().min(1).max(1e3).optional(),
|
|
2226
|
+
limit: z6.coerce.number().int().min(1).max(50).default(25),
|
|
2227
|
+
q: z6.string().trim().max(200).optional()
|
|
2135
2228
|
}).strict();
|
|
2136
2229
|
function json(body, status = 200) {
|
|
2137
2230
|
return Response.json(body, {
|
|
@@ -2152,6 +2245,9 @@ function apiMemory(memory) {
|
|
|
2152
2245
|
visibility: memory.visibility
|
|
2153
2246
|
};
|
|
2154
2247
|
}
|
|
2248
|
+
function currentMemoryVisibility(scope) {
|
|
2249
|
+
return scope === "personal" || scope === "private" ? "private" : "public";
|
|
2250
|
+
}
|
|
2155
2251
|
function viewerEmail(context) {
|
|
2156
2252
|
const parsed = pluginApiRouteRequestContextSchema.safeParse(context);
|
|
2157
2253
|
if (!parsed.success || parsed.data.auth.user.emailVerified !== true) {
|
|
@@ -2168,9 +2264,12 @@ function createMemoryApi(options) {
|
|
|
2168
2264
|
}
|
|
2169
2265
|
const url = new URL(request.url);
|
|
2170
2266
|
const memoryPath = /^\/memories\/([^/]+)$/.exec(url.pathname);
|
|
2267
|
+
const conversationPath = /^\/conversations\/([^/]+)\/memories$/.exec(
|
|
2268
|
+
url.pathname
|
|
2269
|
+
);
|
|
2171
2270
|
const isCollection = url.pathname === "/memories";
|
|
2172
2271
|
const isDashboard = url.pathname === "/dashboard";
|
|
2173
|
-
if (!isCollection && !isDashboard && !memoryPath) {
|
|
2272
|
+
if (!isCollection && !isDashboard && !memoryPath && !conversationPath) {
|
|
2174
2273
|
return json({ error: "Not found." }, 404);
|
|
2175
2274
|
}
|
|
2176
2275
|
const isRead = request.method === "GET" || request.method === "HEAD";
|
|
@@ -2233,6 +2332,38 @@ function createMemoryApi(options) {
|
|
|
2233
2332
|
status: 200
|
|
2234
2333
|
}) : json(body);
|
|
2235
2334
|
}
|
|
2335
|
+
if (conversationPath && isRead) {
|
|
2336
|
+
const events = await options.conversationEvents.list({
|
|
2337
|
+
conversationId: decodeURIComponent(conversationPath[1]),
|
|
2338
|
+
eventName: "memories_captured",
|
|
2339
|
+
viewer
|
|
2340
|
+
});
|
|
2341
|
+
if (!events) return json({ error: "Conversation not found." }, 404);
|
|
2342
|
+
const memories = /* @__PURE__ */ new Map();
|
|
2343
|
+
for (const event of events) {
|
|
2344
|
+
for (const memory of parseCapturedMemories(
|
|
2345
|
+
event.version,
|
|
2346
|
+
event.content
|
|
2347
|
+
)) {
|
|
2348
|
+
if (!memories.has(memory.id)) {
|
|
2349
|
+
memories.set(memory.id, {
|
|
2350
|
+
capturedAt: event.createdAt,
|
|
2351
|
+
content: memory.content,
|
|
2352
|
+
id: memory.id,
|
|
2353
|
+
kind: memory.kind,
|
|
2354
|
+
visibility: currentMemoryVisibility(memory.scope)
|
|
2355
|
+
});
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
const body = conversationMemoryListResponseSchema.parse({
|
|
2360
|
+
memories: [...memories.values()]
|
|
2361
|
+
});
|
|
2362
|
+
return request.method === "HEAD" ? new Response(null, {
|
|
2363
|
+
headers: { "cache-control": "no-store" },
|
|
2364
|
+
status: 200
|
|
2365
|
+
}) : json(body);
|
|
2366
|
+
}
|
|
2236
2367
|
if (isCollection && isRead) {
|
|
2237
2368
|
const query = memoryListQuerySchema.parse({
|
|
2238
2369
|
cursor: url.searchParams.get("cursor") ?? void 0,
|
|
@@ -2274,7 +2405,7 @@ function createMemoryApi(options) {
|
|
|
2274
2405
|
});
|
|
2275
2406
|
}
|
|
2276
2407
|
} catch (error) {
|
|
2277
|
-
if (error instanceof
|
|
2408
|
+
if (error instanceof z6.ZodError || error instanceof InvalidMemoryCursorError) {
|
|
2278
2409
|
return json({ error: "Invalid memory request." }, 400);
|
|
2279
2410
|
}
|
|
2280
2411
|
if (error instanceof MemoryNotFoundError) {
|
|
@@ -2425,7 +2556,7 @@ import {
|
|
|
2425
2556
|
PluginToolInputError,
|
|
2426
2557
|
pluginToolOutputSchema
|
|
2427
2558
|
} from "@sentry/junior-plugin-api";
|
|
2428
|
-
import { z as
|
|
2559
|
+
import { z as z7 } from "zod";
|
|
2429
2560
|
var MAX_TOOL_CONTENT_CHARS = 4e3;
|
|
2430
2561
|
var DEFAULT_RESULT_LIMIT = 20;
|
|
2431
2562
|
var DEFAULT_SEARCH_LIMIT2 = 10;
|
|
@@ -2555,23 +2686,23 @@ function requireMemoryContent(value) {
|
|
|
2555
2686
|
}
|
|
2556
2687
|
return value;
|
|
2557
2688
|
}
|
|
2558
|
-
var createMemoryInputSchema2 =
|
|
2559
|
-
content:
|
|
2689
|
+
var createMemoryInputSchema2 = z7.object({
|
|
2690
|
+
content: z7.string().min(1).max(MAX_TOOL_CONTENT_CHARS).describe(
|
|
2560
2691
|
"Self-contained memory candidate. Include the subject in natural language when it matters; do not rely on surrounding chat context."
|
|
2561
2692
|
),
|
|
2562
|
-
expires_at:
|
|
2693
|
+
expires_at: z7.string().min(1).describe(
|
|
2563
2694
|
'Expiration selector. Omit or use "never" when the memory should not expire, or use an exact ISO timestamp such as "2027-06-21T00:00:00Z".'
|
|
2564
2695
|
).optional()
|
|
2565
2696
|
}).strict();
|
|
2566
|
-
var archiveMemoryInputSchema2 =
|
|
2567
|
-
id:
|
|
2697
|
+
var archiveMemoryInputSchema2 = z7.object({
|
|
2698
|
+
id: z7.string().min(1).describe("Memory id or unambiguous short id prefix to remove.")
|
|
2568
2699
|
}).strict();
|
|
2569
|
-
var listMemoriesInputSchema2 =
|
|
2570
|
-
limit:
|
|
2700
|
+
var listMemoriesInputSchema2 = z7.object({
|
|
2701
|
+
limit: z7.number().min(1).max(50).describe("Maximum number of visible memories to return.").optional()
|
|
2571
2702
|
}).strict();
|
|
2572
|
-
var searchMemoriesInputSchema2 =
|
|
2573
|
-
query:
|
|
2574
|
-
limit:
|
|
2703
|
+
var searchMemoriesInputSchema2 = z7.object({
|
|
2704
|
+
query: z7.string().min(1).describe("Search query for visible memory content."),
|
|
2705
|
+
limit: z7.number().min(1).max(50).describe("Maximum number of matching memories to return.").optional()
|
|
2575
2706
|
}).strict();
|
|
2576
2707
|
var memoryToolProjectionSchema = Type.Object(
|
|
2577
2708
|
{
|
|
@@ -2583,25 +2714,25 @@ var memoryToolProjectionSchema = Type.Object(
|
|
|
2583
2714
|
},
|
|
2584
2715
|
{ additionalProperties: false }
|
|
2585
2716
|
);
|
|
2586
|
-
var memoryProjectionOutputSchema =
|
|
2587
|
-
id:
|
|
2588
|
-
content:
|
|
2589
|
-
createdAtMs:
|
|
2590
|
-
observedAtMs:
|
|
2591
|
-
expiresAtMs:
|
|
2717
|
+
var memoryProjectionOutputSchema = z7.object({
|
|
2718
|
+
id: z7.string(),
|
|
2719
|
+
content: z7.string(),
|
|
2720
|
+
createdAtMs: z7.number(),
|
|
2721
|
+
observedAtMs: z7.number(),
|
|
2722
|
+
expiresAtMs: z7.number().optional()
|
|
2592
2723
|
});
|
|
2593
2724
|
var memoryCreateOutputSchema = pluginToolOutputSchema.extend({
|
|
2594
|
-
target:
|
|
2595
|
-
created:
|
|
2725
|
+
target: z7.string(),
|
|
2726
|
+
created: z7.boolean(),
|
|
2596
2727
|
memory: memoryProjectionOutputSchema
|
|
2597
2728
|
});
|
|
2598
2729
|
var memorySingleOutputSchema = pluginToolOutputSchema.extend({
|
|
2599
|
-
target:
|
|
2730
|
+
target: z7.string(),
|
|
2600
2731
|
memory: memoryProjectionOutputSchema
|
|
2601
2732
|
});
|
|
2602
2733
|
var memoryManyOutputSchema = pluginToolOutputSchema.extend({
|
|
2603
|
-
target:
|
|
2604
|
-
memories:
|
|
2734
|
+
target: z7.string(),
|
|
2735
|
+
memories: z7.array(memoryProjectionOutputSchema)
|
|
2605
2736
|
});
|
|
2606
2737
|
function parseMemoryToolInput(schema, input) {
|
|
2607
2738
|
const result = schema.safeParse(input);
|
|
@@ -2821,83 +2952,6 @@ import {
|
|
|
2821
2952
|
getSourceKey as getSourceKey3
|
|
2822
2953
|
} from "@sentry/junior-plugin-api";
|
|
2823
2954
|
import { z as z8 } from "zod";
|
|
2824
|
-
|
|
2825
|
-
// src/events.ts
|
|
2826
|
-
import { defineConversationEvent } from "@sentry/junior-plugin-api";
|
|
2827
|
-
import { z as z7 } from "zod";
|
|
2828
|
-
var capturedMemoryFields = {
|
|
2829
|
-
content: z7.string().min(1),
|
|
2830
|
-
id: z7.string().min(1),
|
|
2831
|
-
kind: z7.enum(MEMORY_KINDS),
|
|
2832
|
-
observedAtMs: z7.number().finite()
|
|
2833
|
-
};
|
|
2834
|
-
var legacyCapturedMemorySchema = z7.object({
|
|
2835
|
-
...capturedMemoryFields,
|
|
2836
|
-
scope: z7.enum(["personal", "conversation"])
|
|
2837
|
-
}).strict();
|
|
2838
|
-
var capturedMemorySchema = z7.object({
|
|
2839
|
-
...capturedMemoryFields,
|
|
2840
|
-
scope: z7.enum(MEMORY_SCOPES)
|
|
2841
|
-
}).strict();
|
|
2842
|
-
var capturedMemoriesSchema = z7.object({
|
|
2843
|
-
memories: z7.array(capturedMemorySchema).max(100),
|
|
2844
|
-
costUsd: z7.number().finite().nonnegative().optional()
|
|
2845
|
-
}).strict();
|
|
2846
|
-
var recalledMemoriesSchema = z7.object({
|
|
2847
|
-
// Matches the automatic-recall candidate window; admission packs by char budget.
|
|
2848
|
-
memories: z7.array(z7.string().min(1)).max(20),
|
|
2849
|
-
costUsd: z7.number().finite().nonnegative().optional()
|
|
2850
|
-
}).strict();
|
|
2851
|
-
function currentScope(scope) {
|
|
2852
|
-
if (scope === "personal") return "private";
|
|
2853
|
-
if (scope === "conversation") return "public";
|
|
2854
|
-
return scope;
|
|
2855
|
-
}
|
|
2856
|
-
function renderCapturedMemories(event) {
|
|
2857
|
-
const count = event.memories.length;
|
|
2858
|
-
if (count === 0) return void 0;
|
|
2859
|
-
return {
|
|
2860
|
-
icon: "brain",
|
|
2861
|
-
title: `${count} ${count === 1 ? "memory" : "memories"} captured`,
|
|
2862
|
-
details: event.memories.map((memory) => ({
|
|
2863
|
-
title: memory.content,
|
|
2864
|
-
metadata: [memory.kind, currentScope(memory.scope)]
|
|
2865
|
-
}))
|
|
2866
|
-
};
|
|
2867
|
-
}
|
|
2868
|
-
var memoriesCapturedEventV1 = defineConversationEvent({
|
|
2869
|
-
name: "memories_captured",
|
|
2870
|
-
version: 1,
|
|
2871
|
-
schema: z7.object({
|
|
2872
|
-
memories: z7.array(legacyCapturedMemorySchema).min(1).max(100)
|
|
2873
|
-
}).strict(),
|
|
2874
|
-
renderEvent: renderCapturedMemories
|
|
2875
|
-
});
|
|
2876
|
-
var memoriesCapturedEvent = defineConversationEvent({
|
|
2877
|
-
name: "memories_captured",
|
|
2878
|
-
version: 2,
|
|
2879
|
-
schema: capturedMemoriesSchema,
|
|
2880
|
-
renderEvent: renderCapturedMemories
|
|
2881
|
-
});
|
|
2882
|
-
var memoriesRecalledEvent = defineConversationEvent({
|
|
2883
|
-
name: "memories_recalled",
|
|
2884
|
-
version: 1,
|
|
2885
|
-
schema: recalledMemoriesSchema,
|
|
2886
|
-
renderEvent() {
|
|
2887
|
-
return void 0;
|
|
2888
|
-
}
|
|
2889
|
-
});
|
|
2890
|
-
function capturedMemory(memory) {
|
|
2891
|
-
return {
|
|
2892
|
-
content: memory.content,
|
|
2893
|
-
id: memory.id,
|
|
2894
|
-
kind: memory.kind,
|
|
2895
|
-
observedAtMs: memory.observedAtMs,
|
|
2896
|
-
scope: memory.scope
|
|
2897
|
-
};
|
|
2898
|
-
}
|
|
2899
|
-
|
|
2900
|
-
// src/process-session.ts
|
|
2901
2955
|
var MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
2902
2956
|
"archiveMemory",
|
|
2903
2957
|
"createMemory",
|
|
@@ -3548,6 +3602,7 @@ function memoryPlugin(options = {}) {
|
|
|
3548
3602
|
},
|
|
3549
3603
|
apiRoutes(ctx) {
|
|
3550
3604
|
return createMemoryApi({
|
|
3605
|
+
conversationEvents: ctx.conversationEvents,
|
|
3551
3606
|
db: ctx.db,
|
|
3552
3607
|
eventStats: ctx.eventStats,
|
|
3553
3608
|
users: ctx.users
|