@sentry/junior-memory 0.191.0 → 0.193.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
@@ -64,6 +64,14 @@ declare const createMemoryRequestSchema: z.ZodObject<{
64
64
  eventType: z.ZodString;
65
65
  identifier: z.ZodString;
66
66
  namespace: z.ZodString;
67
+ }, z.core.$strict>, z.ZodObject<{
68
+ kind: z.ZodLiteral<"scheduled_task">;
69
+ }, z.core.$strict>, z.ZodObject<{
70
+ kind: z.ZodLiteral<"event_task">;
71
+ }, z.core.$strict>, z.ZodObject<{
72
+ kind: z.ZodLiteral<"plugin_dispatch">;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ kind: z.ZodLiteral<"agent_invocation">;
67
75
  }, z.core.$strict>], "kind">, unknown>;
68
76
  userId: z.ZodOptional<z.ZodString>;
69
77
  }, z.core.$strict>;
@@ -151,6 +159,14 @@ declare const extractSessionRequestSchema: z.ZodObject<{
151
159
  eventType: z.ZodString;
152
160
  identifier: z.ZodString;
153
161
  namespace: z.ZodString;
162
+ }, z.core.$strict>, z.ZodObject<{
163
+ kind: z.ZodLiteral<"scheduled_task">;
164
+ }, z.core.$strict>, z.ZodObject<{
165
+ kind: z.ZodLiteral<"event_task">;
166
+ }, z.core.$strict>, z.ZodObject<{
167
+ kind: z.ZodLiteral<"plugin_dispatch">;
168
+ }, z.core.$strict>, z.ZodObject<{
169
+ kind: z.ZodLiteral<"agent_invocation">;
154
170
  }, z.core.$strict>], "kind">, unknown>;
155
171
  userId: z.ZodOptional<z.ZodString>;
156
172
  }, z.core.$strict>;
package/dist/api.d.ts CHANGED
@@ -63,21 +63,36 @@ export declare const memoryListResponseSchema: z.ZodObject<{
63
63
  }, z.core.$strict>;
64
64
  export declare const memoryDashboardResponseSchema: z.ZodObject<{
65
65
  days: z.ZodArray<z.ZodObject<{
66
- date: z.ZodISODate;
66
+ date: z.ZodString;
67
67
  personal: z.ZodNumber;
68
68
  public: z.ZodNumber;
69
69
  }, z.core.$strict>>;
70
70
  extractionDays: z.ZodArray<z.ZodObject<{
71
71
  costUsd: z.ZodNumber;
72
- date: z.ZodISODate;
72
+ date: z.ZodString;
73
73
  events: z.ZodNumber;
74
74
  }, z.core.$strict>>;
75
+ extractionHours: z.ZodOptional<z.ZodArray<z.ZodObject<{
76
+ costUsd: z.ZodNumber;
77
+ date: z.ZodString;
78
+ events: z.ZodNumber;
79
+ }, z.core.$strict>>>;
75
80
  generatedAt: z.ZodISODateTime;
81
+ hours: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ date: z.ZodString;
83
+ personal: z.ZodNumber;
84
+ public: z.ZodNumber;
85
+ }, z.core.$strict>>>;
76
86
  recallDays: z.ZodArray<z.ZodObject<{
77
87
  costUsd: z.ZodNumber;
78
- date: z.ZodISODate;
88
+ date: z.ZodString;
79
89
  events: z.ZodNumber;
80
90
  }, z.core.$strict>>;
91
+ recallHours: z.ZodOptional<z.ZodArray<z.ZodObject<{
92
+ costUsd: z.ZodNumber;
93
+ date: z.ZodString;
94
+ events: z.ZodNumber;
95
+ }, z.core.$strict>>>;
81
96
  stats: z.ZodObject<{
82
97
  active: z.ZodNumber;
83
98
  automatic: z.ZodNumber;
package/dist/index.js CHANGED
@@ -368,10 +368,18 @@ var memoryRowSchema = z2.object({
368
368
  }
369
369
  });
370
370
  function storedMemorySource(source) {
371
- if (source.kind === "resource_event") {
372
- throw new Error("Resource event Source cannot own a Memory.");
371
+ switch (source.kind) {
372
+ case "slack":
373
+ case "local":
374
+ case "web":
375
+ return source.kind;
376
+ case "resource_event":
377
+ case "scheduled_task":
378
+ case "event_task":
379
+ case "plugin_dispatch":
380
+ case "agent_invocation":
381
+ throw new Error(`${source.kind} Source cannot own a Memory.`);
373
382
  }
374
- return source.kind;
375
383
  }
376
384
  var memoryRecordSchema = z2.object({
377
385
  archivedAtMs: numberSchema.optional(),
@@ -1465,6 +1473,11 @@ function sourceLabel(source) {
1465
1473
  return `${source.kind}:${source.conversationId}`;
1466
1474
  case "resource_event":
1467
1475
  return `resource-event:${source.namespace}:${source.eventKey}`;
1476
+ case "scheduled_task":
1477
+ case "event_task":
1478
+ case "plugin_dispatch":
1479
+ case "agent_invocation":
1480
+ return source.kind;
1468
1481
  }
1469
1482
  }
1470
1483
  function runtimeDescription(request) {
@@ -2035,6 +2048,39 @@ async function getMemoryTimeline(db, userId, days) {
2035
2048
  };
2036
2049
  });
2037
2050
  }
2051
+ async function getMemoryTimelineHours(db, userId, hours = 24) {
2052
+ const end = /* @__PURE__ */ new Date();
2053
+ end.setUTCMinutes(0, 0, 0);
2054
+ const startMs = end.getTime() - (hours - 1) * 60 * 60 * 1e3;
2055
+ const rows = await db.select({
2056
+ date: sql3`to_char(to_timestamp(${juniorMemoryMemories.createdAtMs} / 1000.0) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24')`.as(
2057
+ "date"
2058
+ ),
2059
+ private: sql3`count(*) filter (where ${juniorMemoryMemories.scope} = 'private')`.mapWith(
2060
+ Number
2061
+ ),
2062
+ public: sql3`count(*) filter (where ${juniorMemoryMemories.scope} = 'public')`.mapWith(
2063
+ Number
2064
+ )
2065
+ }).from(juniorMemoryMemories).where(
2066
+ and2(
2067
+ visibleScopePredicate2(userId),
2068
+ gt2(juniorMemoryMemories.createdAtMs, startMs - 1)
2069
+ )
2070
+ ).groupBy(
2071
+ sql3`to_char(to_timestamp(${juniorMemoryMemories.createdAtMs} / 1000.0) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24')`
2072
+ );
2073
+ const byHour = new Map(rows.map((row) => [row.date, row]));
2074
+ return Array.from({ length: hours }, (_, index2) => {
2075
+ const date = new Date(startMs + index2 * 60 * 60 * 1e3).toISOString().slice(0, 13);
2076
+ const row = byHour.get(date);
2077
+ return {
2078
+ date,
2079
+ private: row?.private ?? 0,
2080
+ public: row?.public ?? 0
2081
+ };
2082
+ });
2083
+ }
2038
2084
 
2039
2085
  // src/api.ts
2040
2086
  var memoryApiSchema = z5.object({
@@ -2052,21 +2098,25 @@ var memoryListResponseSchema = z5.object({
2052
2098
  memories: z5.array(memoryApiSchema),
2053
2099
  nextCursor: z5.string().min(1).optional()
2054
2100
  }).strict();
2101
+ var memoryBucketSchema = z5.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
2055
2102
  var memoryDashboardDaySchema = z5.object({
2056
- date: z5.iso.date(),
2103
+ date: memoryBucketSchema,
2057
2104
  personal: z5.number().int().min(0),
2058
2105
  public: z5.number().int().min(0)
2059
2106
  }).strict();
2060
2107
  var memoryCostDaySchema = z5.object({
2061
2108
  costUsd: z5.number().finite().nonnegative(),
2062
- date: z5.iso.date(),
2109
+ date: memoryBucketSchema,
2063
2110
  events: z5.number().int().min(0)
2064
2111
  }).strict();
2065
2112
  var memoryDashboardResponseSchema = z5.object({
2066
2113
  days: z5.array(memoryDashboardDaySchema).length(90),
2067
2114
  extractionDays: z5.array(memoryCostDaySchema).length(90),
2115
+ extractionHours: z5.array(memoryCostDaySchema).length(24).optional(),
2068
2116
  generatedAt: z5.iso.datetime(),
2117
+ hours: z5.array(memoryDashboardDaySchema).length(24).optional(),
2069
2118
  recallDays: z5.array(memoryCostDaySchema).length(90),
2119
+ recallHours: z5.array(memoryCostDaySchema).length(24).optional(),
2070
2120
  stats: z5.object({
2071
2121
  active: z5.number().int().min(0),
2072
2122
  automatic: z5.number().int().min(0),
@@ -2134,16 +2184,31 @@ function createMemoryApi(options) {
2134
2184
  const userId = viewer.id;
2135
2185
  try {
2136
2186
  if (isDashboard && isRead) {
2137
- const [stats, days, extractionDays, recallDays] = await Promise.all([
2187
+ const [
2188
+ stats,
2189
+ days,
2190
+ hours,
2191
+ extractionDays,
2192
+ extractionHours,
2193
+ recallDays,
2194
+ recallHours
2195
+ ] = await Promise.all([
2138
2196
  getMemoryStats(options.db, userId),
2139
2197
  getMemoryTimeline(options.db, userId, 90),
2198
+ getMemoryTimelineHours(options.db, userId, 24),
2140
2199
  options.eventStats.costsByDay({
2141
2200
  days: 90,
2142
2201
  eventName: "memories_captured"
2143
2202
  }),
2203
+ options.eventStats.costsByHour({
2204
+ eventName: "memories_captured"
2205
+ }),
2144
2206
  options.eventStats.costsByDay({
2145
2207
  days: 90,
2146
2208
  eventName: "memories_recalled"
2209
+ }),
2210
+ options.eventStats.costsByHour({
2211
+ eventName: "memories_recalled"
2147
2212
  })
2148
2213
  ]);
2149
2214
  const { private: personal, ...dashboardStats } = stats;
@@ -2153,8 +2218,14 @@ function createMemoryApi(options) {
2153
2218
  personal: personal2
2154
2219
  })),
2155
2220
  extractionDays,
2221
+ extractionHours,
2156
2222
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2223
+ hours: hours.map(({ private: personal2, ...day }) => ({
2224
+ ...day,
2225
+ personal: personal2
2226
+ })),
2157
2227
  recallDays,
2228
+ recallHours,
2158
2229
  stats: { ...dashboardStats, personal }
2159
2230
  });
2160
2231
  return request.method === "HEAD" ? new Response(null, {
@@ -2926,7 +2997,7 @@ async function getTaskExtraction(context, extract) {
2926
2997
  }
2927
2998
  async function processMemorySession(context) {
2928
2999
  const run = await context.run.load();
2929
- if (run.source.kind === "local" || run.source.kind === "resource_event") {
3000
+ if (run.source.kind !== "slack" && run.source.kind !== "web") {
2930
3001
  return;
2931
3002
  }
2932
3003
  if (run.transcript.some(
@@ -3310,7 +3381,7 @@ async function buildMemoryOperationalReport(args) {
3310
3381
  public: day.public
3311
3382
  }
3312
3383
  })),
3313
- description: "Memories stored per day by scope",
3384
+ description: "Memories stored by scope",
3314
3385
  id: "memories-created",
3315
3386
  series: [
3316
3387
  { key: "private", label: "Private" },