@sentry/junior 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.
Files changed (115) hide show
  1. package/dist/{agent-hooks-5RQEVLQD.js → agent-hooks-3IG2FQW2.js} +11 -11
  2. package/dist/api/acp/conversations.d.ts +2 -2
  3. package/dist/api/conversations/list.d.ts +7 -0
  4. package/dist/api/people/shared.d.ts +54 -0
  5. package/dist/api.js +44 -55
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1025 -349
  8. package/dist/{catalog-runtime-L4A6BJ3U.js → catalog-runtime-2OT7S3ZC.js} +4 -4
  9. package/dist/chat/actor.d.ts +7 -2
  10. package/dist/chat/agent/resume.d.ts +0 -2
  11. package/dist/chat/agent/types.d.ts +8 -9
  12. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  13. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  14. package/dist/chat/agent-invocations/types.d.ts +44 -108
  15. package/dist/chat/app/conversation-work.d.ts +16 -8
  16. package/dist/chat/conversation-privacy.d.ts +7 -7
  17. package/dist/chat/conversations/destination.d.ts +12 -0
  18. package/dist/chat/conversations/projection.d.ts +2 -2
  19. package/dist/chat/conversations/sql/location.d.ts +13 -4
  20. package/dist/chat/{api-turns → conversations}/stop.d.ts +2 -2
  21. package/dist/chat/conversations/store.d.ts +4 -4
  22. package/dist/chat/conversations/structured-events.d.ts +1 -1
  23. package/dist/chat/{api-turns/authorization.d.ts → conversations/web-authorization.d.ts} +1 -0
  24. package/dist/chat/conversations/web-input.d.ts +98 -0
  25. package/dist/chat/conversations/web-mailbox.d.ts +12 -0
  26. package/dist/chat/event-tasks/tool-support.d.ts +1 -7
  27. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  28. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  29. package/dist/chat/resource-events/actor.d.ts +13 -12
  30. package/dist/chat/resource-events/notification.d.ts +1 -1
  31. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  32. package/dist/chat/services/turn-session-routing.d.ts +2 -2
  33. package/dist/chat/source.d.ts +3 -3
  34. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  35. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  36. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  37. package/dist/chat/task-execution/mailbox-turn.d.ts +52 -0
  38. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  39. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  40. package/dist/chat/task-execution/state.d.ts +2 -2
  41. package/dist/chat/task-execution/store.d.ts +1 -1
  42. package/dist/chat/task-execution/turn-cursor.d.ts +10 -1
  43. package/dist/chat/tools/types.d.ts +9 -2
  44. package/dist/{chunk-XJIPMHKI.js → chunk-2MKHYSYL.js} +3 -3
  45. package/dist/{chunk-QCGNHSMA.js → chunk-2MRF22J4.js} +25 -10
  46. package/dist/{chunk-HCIVBCP5.js → chunk-3J3BCB4J.js} +1 -1
  47. package/dist/chunk-4BLFIYVK.js +703 -0
  48. package/dist/{chunk-NZLZ4KYZ.js → chunk-4PKEJK5B.js} +1 -1
  49. package/dist/{chunk-VFZAUQ5V.js → chunk-62DRKZQU.js} +5 -183
  50. package/dist/{chunk-QIOUTXTZ.js → chunk-663DQH5W.js} +1 -1
  51. package/dist/{chunk-Z5SKZE5B.js → chunk-67MMSYSE.js} +4 -12
  52. package/dist/{chunk-ZX7RSBQ6.js → chunk-6BXUSF7J.js} +1 -1
  53. package/dist/{chunk-W42ENMJW.js → chunk-6H7YU6XH.js} +1 -1
  54. package/dist/{chunk-WGZJ5SU4.js → chunk-7UJ6IJCK.js} +1 -1
  55. package/dist/{chunk-QDHJTKPE.js → chunk-7Y7XMI6P.js} +8 -6
  56. package/dist/{chunk-6YGFBU3A.js → chunk-BGOLRC36.js} +62 -336
  57. package/dist/{chunk-CVBDVIF4.js → chunk-BUJU6C2J.js} +1 -1
  58. package/dist/{chunk-XI4PVY2T.js → chunk-CZXZKTAI.js} +5 -5
  59. package/dist/chunk-DA2KGZZI.js +13 -0
  60. package/dist/{chunk-RMB7CERI.js → chunk-DJZGQ7OL.js} +311 -137
  61. package/dist/{chunk-FIUCHYT6.js → chunk-DVX6U6GI.js} +1 -1
  62. package/dist/{chunk-AW77HH54.js → chunk-ECOR3OXY.js} +19 -299
  63. package/dist/{chunk-WW2Y7JIA.js → chunk-F3K2267N.js} +51 -50
  64. package/dist/{chunk-W2DDJCPS.js → chunk-FVFJ57RK.js} +8 -8
  65. package/dist/{chunk-UVUXFRYN.js → chunk-GWCFXTB6.js} +211 -7
  66. package/dist/{chunk-X55FOVZO.js → chunk-HI5KXE3C.js} +3 -3
  67. package/dist/{chunk-ERZMACYA.js → chunk-IRQ3RSX3.js} +3 -3
  68. package/dist/{chunk-32XSSFZV.js → chunk-JV7U4665.js} +1 -1
  69. package/dist/chunk-MNHJ4WLE.js +285 -0
  70. package/dist/{chunk-SC67CH3C.js → chunk-OJFX2FP7.js} +14 -17
  71. package/dist/{chunk-IUUQWIG2.js → chunk-OKAHLUSU.js} +70 -19
  72. package/dist/{chunk-PSHMPRIU.js → chunk-OON4IQHH.js} +2 -2
  73. package/dist/{chunk-6JZGXLL2.js → chunk-OYCOLHCR.js} +5 -7
  74. package/dist/{chunk-3HEZWDS5.js → chunk-REVH4BZU.js} +2 -2
  75. package/dist/{chunk-CDSLOYOR.js → chunk-RLYJYEIY.js} +6 -6
  76. package/dist/{chunk-CZRWU4ZM.js → chunk-T66GV7A3.js} +2 -5
  77. package/dist/{chunk-Q7O74WOO.js → chunk-VWNIDTFR.js} +2 -2
  78. package/dist/{chunk-CIG6WI7Q.js → chunk-W2C4TPLB.js} +5 -5
  79. package/dist/{chunk-QIMN3FXL.js → chunk-Y4WL4OYD.js} +1 -1
  80. package/dist/{chunk-MQDIIFZM.js → chunk-YFU4DGZY.js} +12 -5
  81. package/dist/chunk-YKIAUKYH.js +311 -0
  82. package/dist/{chunk-QVH6FW3T.js → chunk-ZFCO2TMB.js} +7 -3
  83. package/dist/cli/chat.js +34 -33
  84. package/dist/cli/check.js +5 -5
  85. package/dist/cli/plugins.js +12 -12
  86. package/dist/cli/snapshot-create.js +9 -9
  87. package/dist/cli/upgrade.js +6 -6
  88. package/dist/db/schema/agent-invocations.d.ts +18 -42
  89. package/dist/db/schema/conversations.d.ts +62 -0
  90. package/dist/db/schema.d.ts +49 -42
  91. package/dist/{db-YPRZAA2T.js → db-2IFDMDDY.js} +6 -6
  92. package/dist/instrumentation.js +3 -3
  93. package/dist/nitro.js +6 -6
  94. package/dist/{oauth-callback-server-DBBIR3XG.js → oauth-callback-server-SZSS2KH6.js} +30 -28
  95. package/dist/{runner-FKVFFPLO.js → runner-2N4QU77X.js} +25 -21
  96. package/dist/{skills-4RBAZEMV.js → skills-VU2LZAKX.js} +5 -5
  97. package/dist/spawn-3K7RV4T5.js +42 -0
  98. package/dist/task-runner-52DYFHW3.js +36 -0
  99. package/dist/{validation-E6Z5LHZM.js → validation-IJGHK7NI.js} +5 -5
  100. package/dist/version.js +1 -1
  101. package/dist/{work-OFTXWOK4.js → work-DI45MLRL.js} +22 -21
  102. package/dist/{worker-OMWNOKTJ.js → worker-FY7KWG2M.js} +10 -10
  103. package/migrations/0037_conversation_location.sql +23 -0
  104. package/migrations/meta/0037_snapshot.json +3192 -0
  105. package/migrations/meta/_journal.json +7 -0
  106. package/package.json +4 -4
  107. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  108. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  109. package/dist/chat/api-turns/routing.d.ts +0 -51
  110. package/dist/chat/api-turns/work.d.ts +0 -99
  111. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -55
  112. package/dist/chunk-6FGN7ZEG.js +0 -221
  113. package/dist/chunk-LODJKINF.js +0 -1502
  114. package/dist/spawn-CO7QFCNJ.js +0 -41
  115. package/dist/task-runner-DUGZGI7V.js +0 -34
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logWarn
3
- } from "./chunk-QIMN3FXL.js";
3
+ } from "./chunk-Y4WL4OYD.js";
4
4
 
5
5
  // src/chat/conversation-privacy.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState
4
- } from "./chunk-CIG6WI7Q.js";
4
+ } from "./chunk-W2C4TPLB.js";
5
+ import {
6
+ recordTaskExecution
7
+ } from "./chunk-MNHJ4WLE.js";
5
8
  import {
6
9
  pluginTaskId,
7
10
  pluginTaskParamsSchema,
8
11
  sendVercelPluginTask
9
- } from "./chunk-XI4PVY2T.js";
12
+ } from "./chunk-CZXZKTAI.js";
10
13
  import {
11
14
  getPiMessageRole,
12
15
  getTurnRecord,
@@ -16,7 +19,7 @@ import {
16
19
  isToolResultMessage,
17
20
  normalizeToolNameFromResult,
18
21
  stripRuntimeTurnContext
19
- } from "./chunk-6YGFBU3A.js";
22
+ } from "./chunk-BGOLRC36.js";
20
23
  import {
21
24
  createPluginConversationEvents,
22
25
  createPluginEmbedder,
@@ -25,21 +28,17 @@ import {
25
28
  createPluginState,
26
29
  getPlugins,
27
30
  readActorIdentity
28
- } from "./chunk-QCGNHSMA.js";
31
+ } from "./chunk-2MRF22J4.js";
29
32
  import {
30
33
  JUNIOR_THREAD_STATE_TTL_MS
31
34
  } from "./chunk-3Y47VMHV.js";
32
35
  import {
33
36
  getConversationStore,
34
37
  getDb
35
- } from "./chunk-IUUQWIG2.js";
36
- import {
37
- juniorConversations,
38
- juniorTaskExecutions
39
- } from "./chunk-QVH6FW3T.js";
38
+ } from "./chunk-OKAHLUSU.js";
40
39
  import {
41
40
  getStateAdapter
42
- } from "./chunk-ZX7RSBQ6.js";
41
+ } from "./chunk-6BXUSF7J.js";
43
42
  import {
44
43
  sameActorIdentity
45
44
  } from "./chunk-GFBR4S3Q.js";
@@ -49,9 +48,6 @@ import {
49
48
  import {
50
49
  parseSlackMessageTs
51
50
  } from "./chunk-N7TMSOZH.js";
52
- import {
53
- logWarn
54
- } from "./chunk-QIMN3FXL.js";
55
51
 
56
52
  // src/chat/plugins/task-runner.ts
57
53
  import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
@@ -75,12 +71,12 @@ async function loadConversationChain(conversationId, conversationStore) {
75
71
  return chain;
76
72
  }
77
73
  function slackSourceForDestination(args) {
78
- if (args.source?.platform !== "slack" || args.source.channelId !== args.destination.channelId) {
74
+ if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) {
79
75
  return void 0;
80
76
  }
81
77
  const threadTs = args.source.threadTs?.trim();
82
78
  return {
83
- platform: "slack",
79
+ kind: "slack",
84
80
  visibility: args.source.visibility ?? "public",
85
81
  teamId: args.source.teamId?.trim() || args.destination.teamId,
86
82
  channelId: args.source.channelId,
@@ -88,7 +84,7 @@ function slackSourceForDestination(args) {
88
84
  };
89
85
  }
90
86
  async function resolveConversationRouting(args) {
91
- const conversationStore = args.conversationStore ?? (await import("./db-YPRZAA2T.js")).getConversationStore();
87
+ const conversationStore = args.conversationStore ?? (await import("./db-2IFDMDDY.js")).getConversationStore();
92
88
  const chain = await loadConversationChain(
93
89
  args.conversationId,
94
90
  conversationStore
@@ -112,15 +108,13 @@ async function resolveConversationRouting(args) {
112
108
  return {
113
109
  destination,
114
110
  ...location ? { location } : void 0,
115
- ...slackSource ? {
116
- source: location ? { ...slackSource, location } : slackSource
117
- } : void 0
111
+ ...slackSource ? { source: slackSource } : void 0
118
112
  };
119
113
  }
120
114
  return {
121
115
  destination,
122
116
  ...location ? { location } : void 0,
123
- ...source ? { source: location ? { ...source, location } : source } : void 0
117
+ ...source ? { source } : void 0
124
118
  };
125
119
  }
126
120
  async function resolveTurnSessionRouting(args) {
@@ -132,8 +126,8 @@ async function resolveTurnSessionRouting(args) {
132
126
  }
133
127
  return {
134
128
  destination: routing.destination,
135
- source: routing.source,
136
- ...routing.location ? { location: routing.location } : void 0
129
+ ...routing.location ? { location: routing.location } : void 0,
130
+ source: routing.source
137
131
  };
138
132
  }
139
133
 
@@ -147,273 +141,6 @@ import {
147
141
  sourceSchema
148
142
  } from "@sentry/junior-plugin-api";
149
143
  import { z } from "zod";
150
-
151
- // src/chat/tasks/execution-stats.ts
152
- import {
153
- and,
154
- asc,
155
- count,
156
- desc,
157
- eq,
158
- gte,
159
- inArray,
160
- lte,
161
- max,
162
- or,
163
- sql
164
- } from "drizzle-orm";
165
- var TASK_EXECUTION_TYPES = ["scheduled", "event"];
166
- var TASK_EXECUTION_STATUSES = [
167
- "blocked",
168
- "completed",
169
- "failed"
170
- ];
171
- function utcDate(nowMs) {
172
- return new Date(nowMs).toISOString().slice(0, 10);
173
- }
174
- function emptyDay(date) {
175
- return { date, event: 0, scheduled: 0 };
176
- }
177
- function emptyStatusDay(date) {
178
- return { blocked: 0, completed: 0, date, failed: 0 };
179
- }
180
- async function recordTaskExecution(type, taskId, options) {
181
- const namespace = options.namespace ?? "junior";
182
- const nowMs = options.nowMs ?? Date.now();
183
- const status = options.status ?? "completed";
184
- try {
185
- await getDb().insert(juniorTaskExecutions).values({
186
- ...options.conversationId ? { conversationId: options.conversationId } : void 0,
187
- executedAtMs: nowMs,
188
- executionId: options.executionId,
189
- kind: type,
190
- namespace,
191
- status,
192
- taskId
193
- }).onConflictDoNothing({
194
- target: [
195
- juniorTaskExecutions.kind,
196
- juniorTaskExecutions.namespace,
197
- juniorTaskExecutions.executionId
198
- ]
199
- });
200
- } catch (error) {
201
- logWarn("task.execution.stat_failed", {
202
- error,
203
- "app.task.execution.id": options.executionId,
204
- "app.task.execution.namespace": namespace,
205
- "app.task.execution.status": status,
206
- "app.task.execution.task_id": taskId,
207
- "app.task.execution.type": type
208
- });
209
- }
210
- }
211
- async function readTaskExecutionSummaries(type, namespace, options = {}) {
212
- const sevenDaysAgoMs = (options.nowMs ?? Date.now()) - 7 * 24 * 60 * 60 * 1e3;
213
- const db = getDb();
214
- const latest = db.selectDistinctOn([juniorTaskExecutions.taskId], {
215
- conversationId: juniorTaskExecutions.conversationId,
216
- taskId: juniorTaskExecutions.taskId
217
- }).from(juniorTaskExecutions).where(
218
- and(
219
- eq(juniorTaskExecutions.kind, type),
220
- eq(juniorTaskExecutions.namespace, namespace)
221
- )
222
- ).orderBy(
223
- juniorTaskExecutions.taskId,
224
- desc(juniorTaskExecutions.executedAtMs),
225
- desc(juniorTaskExecutions.executionId)
226
- ).as("latest_task_execution");
227
- const rows = await db.select({
228
- lastConversationId: latest.conversationId,
229
- lastExecutedAtMs: max(juniorTaskExecutions.executedAtMs),
230
- runsLast7Days: sql`count(*) filter (where ${juniorTaskExecutions.executedAtMs} >= ${sevenDaysAgoMs})::int`,
231
- taskId: juniorTaskExecutions.taskId,
232
- totalRuns: sql`count(*)::int`
233
- }).from(juniorTaskExecutions).innerJoin(latest, eq(latest.taskId, juniorTaskExecutions.taskId)).where(
234
- and(
235
- eq(juniorTaskExecutions.kind, type),
236
- eq(juniorTaskExecutions.namespace, namespace)
237
- )
238
- ).groupBy(juniorTaskExecutions.taskId, latest.conversationId);
239
- return new Map(
240
- rows.map((row) => [
241
- row.taskId,
242
- {
243
- ...row.lastConversationId ? { lastConversationId: row.lastConversationId } : void 0,
244
- ...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } : void 0,
245
- runsLast7Days: row.runsLast7Days,
246
- totalRuns: row.totalRuns
247
- }
248
- ])
249
- );
250
- }
251
- async function readTaskExecutionDays(dayCount = 90, options = {}) {
252
- const nowMs = options.nowMs ?? Date.now();
253
- const end = utcDate(nowMs);
254
- const endMs = Date.parse(`${end}T23:59:59.999Z`);
255
- const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
256
- const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
257
- const rows = await getDb().select({
258
- count: count(),
259
- date: executionDate,
260
- kind: juniorTaskExecutions.kind
261
- }).from(juniorTaskExecutions).where(
262
- and(
263
- gte(juniorTaskExecutions.executedAtMs, startMs),
264
- lte(juniorTaskExecutions.executedAtMs, endMs),
265
- eq(juniorTaskExecutions.status, "completed")
266
- )
267
- ).groupBy(executionDate, juniorTaskExecutions.kind).orderBy(asc(executionDate), asc(juniorTaskExecutions.kind));
268
- const byDate = /* @__PURE__ */ new Map();
269
- for (let offset = 0; offset < dayCount; offset += 1) {
270
- const date = utcDate(startMs + offset * 864e5);
271
- byDate.set(date, emptyDay(date));
272
- }
273
- for (const row of rows) {
274
- const day = byDate.get(row.date);
275
- if (!day) continue;
276
- if (row.kind === "scheduled") day.scheduled = row.count;
277
- else if (row.kind === "event") day.event = row.count;
278
- }
279
- return [...byDate.values()];
280
- }
281
- async function readTaskExecutionByConversationId(args) {
282
- const namespace = args.namespace ?? "junior";
283
- const rows = await getDb().select({
284
- kind: juniorTaskExecutions.kind,
285
- taskId: juniorTaskExecutions.taskId
286
- }).from(juniorTaskExecutions).where(
287
- and(
288
- eq(juniorTaskExecutions.conversationId, args.conversationId),
289
- eq(juniorTaskExecutions.namespace, namespace),
290
- inArray(juniorTaskExecutions.kind, [...TASK_EXECUTION_TYPES])
291
- )
292
- ).orderBy(
293
- desc(juniorTaskExecutions.executedAtMs),
294
- desc(juniorTaskExecutions.executionId)
295
- ).limit(1);
296
- const row = rows[0];
297
- if (!row) return void 0;
298
- if (row.kind !== "scheduled" && row.kind !== "event") return void 0;
299
- return { kind: row.kind, taskId: row.taskId };
300
- }
301
- async function readTaskExecutions(args) {
302
- const namespace = args.namespace ?? "junior";
303
- const rows = await getDb().select({
304
- conversationId: juniorTaskExecutions.conversationId,
305
- executedAtMs: juniorTaskExecutions.executedAtMs,
306
- executionId: juniorTaskExecutions.executionId,
307
- status: juniorTaskExecutions.status,
308
- title: juniorConversations.title
309
- }).from(juniorTaskExecutions).leftJoin(
310
- juniorConversations,
311
- eq(
312
- juniorConversations.conversationId,
313
- juniorTaskExecutions.conversationId
314
- )
315
- ).where(
316
- and(
317
- eq(juniorTaskExecutions.kind, args.kind),
318
- eq(juniorTaskExecutions.namespace, namespace),
319
- eq(juniorTaskExecutions.taskId, args.taskId)
320
- )
321
- ).orderBy(
322
- desc(juniorTaskExecutions.executedAtMs),
323
- desc(juniorTaskExecutions.executionId)
324
- ).limit(args.limit);
325
- return rows.map((row) => {
326
- const title = row.title?.trim();
327
- return {
328
- ...row.conversationId ? { conversationId: row.conversationId } : void 0,
329
- executedAt: new Date(row.executedAtMs).toISOString(),
330
- executionId: row.executionId,
331
- status: row.status,
332
- ...title ? { title } : void 0
333
- };
334
- });
335
- }
336
- async function readTaskRuns(args) {
337
- if (args.tasks.length === 0) return [];
338
- const namespace = args.namespace ?? "junior";
339
- const selectors = args.tasks.map(
340
- (task) => and(
341
- eq(juniorTaskExecutions.kind, task.kind),
342
- eq(juniorTaskExecutions.taskId, task.taskId)
343
- )
344
- );
345
- const rows = await getDb().select({
346
- conversationId: juniorTaskExecutions.conversationId,
347
- executedAtMs: juniorTaskExecutions.executedAtMs,
348
- executionId: juniorTaskExecutions.executionId,
349
- kind: juniorTaskExecutions.kind,
350
- status: juniorTaskExecutions.status,
351
- taskId: juniorTaskExecutions.taskId,
352
- title: juniorConversations.title
353
- }).from(juniorTaskExecutions).leftJoin(
354
- juniorConversations,
355
- eq(
356
- juniorConversations.conversationId,
357
- juniorTaskExecutions.conversationId
358
- )
359
- ).where(and(eq(juniorTaskExecutions.namespace, namespace), or(...selectors))).orderBy(
360
- desc(juniorTaskExecutions.executedAtMs),
361
- desc(juniorTaskExecutions.executionId)
362
- ).limit(args.limit);
363
- return rows.flatMap((row) => {
364
- if (row.kind !== "scheduled" && row.kind !== "event") return [];
365
- const title = row.title?.trim();
366
- return [
367
- {
368
- ...row.conversationId ? { conversationId: row.conversationId } : void 0,
369
- executedAt: new Date(row.executedAtMs).toISOString(),
370
- executionId: row.executionId,
371
- kind: row.kind,
372
- status: row.status,
373
- taskId: row.taskId,
374
- ...title ? { title } : void 0
375
- }
376
- ];
377
- });
378
- }
379
- async function readTaskExecutionStatusDays(args) {
380
- const dayCount = args.dayCount ?? 90;
381
- const namespace = args.namespace ?? "junior";
382
- const nowMs = args.nowMs ?? Date.now();
383
- const end = utcDate(nowMs);
384
- const endMs = Date.parse(`${end}T23:59:59.999Z`);
385
- const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
386
- const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
387
- const rows = await getDb().select({
388
- count: count(),
389
- date: executionDate,
390
- status: juniorTaskExecutions.status
391
- }).from(juniorTaskExecutions).where(
392
- and(
393
- eq(juniorTaskExecutions.kind, args.kind),
394
- eq(juniorTaskExecutions.namespace, namespace),
395
- eq(juniorTaskExecutions.taskId, args.taskId),
396
- gte(juniorTaskExecutions.executedAtMs, startMs),
397
- lte(juniorTaskExecutions.executedAtMs, endMs),
398
- inArray(juniorTaskExecutions.status, [...TASK_EXECUTION_STATUSES])
399
- )
400
- ).groupBy(executionDate, juniorTaskExecutions.status).orderBy(asc(executionDate), asc(juniorTaskExecutions.status));
401
- const byDate = /* @__PURE__ */ new Map();
402
- for (let offset = 0; offset < dayCount; offset += 1) {
403
- const date = utcDate(startMs + offset * 864e5);
404
- byDate.set(date, emptyStatusDay(date));
405
- }
406
- for (const row of rows) {
407
- const day = byDate.get(row.date);
408
- if (!day) continue;
409
- if (row.status === "completed") day.completed = row.count;
410
- else if (row.status === "failed") day.failed = row.count;
411
- else if (row.status === "blocked") day.blocked = row.count;
412
- }
413
- return [...byDate.values()];
414
- }
415
-
416
- // src/chat/agent-dispatch/store.ts
417
144
  var DISPATCH_PREFIX = "junior:agent_dispatch";
418
145
  var DISPATCH_LOCK_TTL_MS = 10 * 60 * 1e3;
419
146
  var DISPATCH_MAILBOX_APPEND_INDEX_LOCK_TTL_MS = 1e4;
@@ -884,7 +611,7 @@ function messageExistedAtRunCompletion(message, completedAtMs) {
884
611
  return messageTimestampMs !== void 0 && messageTimestampMs <= completedAtMs;
885
612
  }
886
613
  async function loadConversationContextTranscriptEntries(record, source, runActor) {
887
- switch (source.platform) {
614
+ switch (source.kind) {
888
615
  case "slack":
889
616
  if (source.visibility === "private") {
890
617
  return [];
@@ -892,6 +619,7 @@ async function loadConversationContextTranscriptEntries(record, source, runActor
892
619
  break;
893
620
  case "web":
894
621
  case "local":
622
+ case "resource_event":
895
623
  return [];
896
624
  }
897
625
  const state = await getPersistedThreadState(record.conversationId);
@@ -953,7 +681,7 @@ async function loadPluginRun(params) {
953
681
  const routing = await resolveTurnSessionRouting({
954
682
  conversationId: params.conversationId
955
683
  });
956
- const runActor = record.actors[0] ?? (record.dispatchId ? (await getDispatchRecord(record.dispatchId))?.actor : void 0);
684
+ const runActor = record.actor ?? record.actors[0] ?? (record.dispatchId ? (await getDispatchRecord(record.dispatchId))?.actor : void 0);
957
685
  const actorUser = runActor ? (await readActorIdentity(runActor))?.user : void 0;
958
686
  const runEntries = turnMessagesWithProvenance(record).map(
959
687
  ({ message, provenance }) => runTranscriptEntry(message, provenance, runActor)
@@ -1064,13 +792,6 @@ async function processPluginTask(message, options = {}) {
1064
792
  }
1065
793
 
1066
794
  export {
1067
- recordTaskExecution,
1068
- readTaskExecutionSummaries,
1069
- readTaskExecutionDays,
1070
- readTaskExecutionByConversationId,
1071
- readTaskExecutions,
1072
- readTaskRuns,
1073
- readTaskExecutionStatusDays,
1074
795
  getDispatchConversationId,
1075
796
  getDispatchInputMessageId,
1076
797
  getDispatchTurnId,
@@ -1086,7 +807,6 @@ export {
1086
807
  listPendingDispatchMailboxAppends,
1087
808
  claimDispatchMailboxAppend,
1088
809
  getPluginDispatchProjection,
1089
- resolveConversationRouting,
1090
810
  resolveTurnSessionRouting,
1091
811
  scheduleSessionCompletedPluginTasks,
1092
812
  processPluginTask