@sentry/junior 0.188.0 → 0.189.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 (109) hide show
  1. package/dist/{agent-hooks-5RQEVLQD.js → agent-hooks-6QRYH6PX.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 +41 -52
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1003 -346
  8. package/dist/{catalog-runtime-L4A6BJ3U.js → catalog-runtime-IETJLJFG.js} +4 -4
  9. package/dist/chat/agent/resume.d.ts +0 -2
  10. package/dist/chat/agent/types.d.ts +8 -9
  11. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  12. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  13. package/dist/chat/agent-invocations/types.d.ts +296 -96
  14. package/dist/chat/app/conversation-work.d.ts +16 -8
  15. package/dist/chat/conversation-privacy.d.ts +7 -7
  16. package/dist/chat/conversations/destination.d.ts +12 -0
  17. package/dist/chat/conversations/projection.d.ts +2 -2
  18. package/dist/chat/conversations/sql/location.d.ts +13 -4
  19. package/dist/chat/{api-turns → conversations}/stop.d.ts +2 -2
  20. package/dist/chat/conversations/store.d.ts +4 -4
  21. package/dist/chat/conversations/structured-events.d.ts +1 -1
  22. package/dist/chat/{api-turns/authorization.d.ts → conversations/web-authorization.d.ts} +1 -0
  23. package/dist/chat/conversations/web-input.d.ts +98 -0
  24. package/dist/chat/conversations/web-mailbox.d.ts +12 -0
  25. package/dist/chat/event-tasks/tool-support.d.ts +0 -6
  26. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  27. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  28. package/dist/chat/resource-events/actor.d.ts +13 -12
  29. package/dist/chat/resource-events/notification.d.ts +1 -1
  30. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  31. package/dist/chat/services/turn-session-routing.d.ts +2 -2
  32. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  33. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  34. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  35. package/dist/chat/task-execution/mailbox-turn.d.ts +42 -0
  36. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  37. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  38. package/dist/{chunk-AW77HH54.js → chunk-4RHJ3CXR.js} +14 -295
  39. package/dist/{chunk-ZX7RSBQ6.js → chunk-5CXCGDIL.js} +1 -1
  40. package/dist/{chunk-QVH6FW3T.js → chunk-5VWAY27R.js} +7 -3
  41. package/dist/{chunk-XJIPMHKI.js → chunk-6AUR6PWR.js} +3 -3
  42. package/dist/{chunk-QDHJTKPE.js → chunk-7R5JRPCY.js} +8 -6
  43. package/dist/{chunk-6JZGXLL2.js → chunk-AC7MDOJW.js} +5 -7
  44. package/dist/{chunk-Q7O74WOO.js → chunk-BYBSI5TI.js} +2 -2
  45. package/dist/{chunk-VFZAUQ5V.js → chunk-CMWIMFM6.js} +4 -182
  46. package/dist/{chunk-IUUQWIG2.js → chunk-CUYFCI4G.js} +59 -11
  47. package/dist/chunk-DA2KGZZI.js +13 -0
  48. package/dist/{chunk-FIUCHYT6.js → chunk-DYXVAO2E.js} +1 -1
  49. package/dist/{chunk-NZLZ4KYZ.js → chunk-E3PDZPGV.js} +1 -1
  50. package/dist/{chunk-Z5SKZE5B.js → chunk-GP32KD2J.js} +4 -12
  51. package/dist/{chunk-XI4PVY2T.js → chunk-KN32OWL2.js} +5 -5
  52. package/dist/chunk-LHKZKAZ4.js +285 -0
  53. package/dist/{chunk-6YGFBU3A.js → chunk-MFSET7Q7.js} +44 -334
  54. package/dist/{chunk-QCGNHSMA.js → chunk-MI6ZBDTS.js} +6 -6
  55. package/dist/{chunk-CIG6WI7Q.js → chunk-MRXMFB4L.js} +5 -5
  56. package/dist/{chunk-CVBDVIF4.js → chunk-MVPLEPSI.js} +1 -1
  57. package/dist/{chunk-32XSSFZV.js → chunk-NY2F7BZA.js} +1 -1
  58. package/dist/chunk-O35GZCKL.js +311 -0
  59. package/dist/{chunk-HCIVBCP5.js → chunk-OEIITG5F.js} +1 -1
  60. package/dist/{chunk-UVUXFRYN.js → chunk-PCPSX4ES.js} +209 -7
  61. package/dist/{chunk-QIMN3FXL.js → chunk-PY3EIEAF.js} +1 -1
  62. package/dist/{chunk-RMB7CERI.js → chunk-QNIOBNOY.js} +282 -121
  63. package/dist/{chunk-WGZJ5SU4.js → chunk-S3SGZUOI.js} +1 -1
  64. package/dist/chunk-SR6OMO5C.js +703 -0
  65. package/dist/{chunk-CDSLOYOR.js → chunk-UCWO5MKP.js} +6 -6
  66. package/dist/{chunk-PSHMPRIU.js → chunk-VKQWU4PO.js} +2 -2
  67. package/dist/{chunk-X55FOVZO.js → chunk-WDHPN2GH.js} +3 -3
  68. package/dist/{chunk-WW2Y7JIA.js → chunk-WMUAKAIF.js} +43 -44
  69. package/dist/{chunk-MQDIIFZM.js → chunk-WN6VLHOU.js} +12 -5
  70. package/dist/{chunk-W42ENMJW.js → chunk-WWYUYKKV.js} +1 -1
  71. package/dist/{chunk-ERZMACYA.js → chunk-WYDF6PGK.js} +3 -3
  72. package/dist/{chunk-SC67CH3C.js → chunk-YNZPOFF3.js} +14 -17
  73. package/dist/{chunk-3HEZWDS5.js → chunk-YYSEH2WC.js} +2 -2
  74. package/dist/{chunk-W2DDJCPS.js → chunk-YYZNESC3.js} +8 -8
  75. package/dist/{chunk-CZRWU4ZM.js → chunk-ZUPDSJUE.js} +2 -5
  76. package/dist/{chunk-QIOUTXTZ.js → chunk-ZV6PFUA4.js} +1 -1
  77. package/dist/cli/chat.js +34 -33
  78. package/dist/cli/check.js +5 -5
  79. package/dist/cli/plugins.js +12 -12
  80. package/dist/cli/snapshot-create.js +9 -9
  81. package/dist/cli/upgrade.js +6 -6
  82. package/dist/db/schema/agent-invocations.d.ts +0 -36
  83. package/dist/db/schema/conversations.d.ts +62 -0
  84. package/dist/db/schema.d.ts +31 -36
  85. package/dist/{db-YPRZAA2T.js → db-LPJKR2EO.js} +6 -6
  86. package/dist/instrumentation.js +3 -3
  87. package/dist/nitro.js +6 -6
  88. package/dist/{oauth-callback-server-DBBIR3XG.js → oauth-callback-server-DMXF4TTQ.js} +30 -28
  89. package/dist/{runner-FKVFFPLO.js → runner-L5DPVYCN.js} +25 -21
  90. package/dist/{skills-4RBAZEMV.js → skills-NXG3LBCK.js} +5 -5
  91. package/dist/spawn-VRUIGKWW.js +42 -0
  92. package/dist/task-runner-7YTBSPXW.js +36 -0
  93. package/dist/{validation-E6Z5LHZM.js → validation-CH36LTOS.js} +5 -5
  94. package/dist/version.js +1 -1
  95. package/dist/{work-OFTXWOK4.js → work-HBC5Y5VZ.js} +22 -21
  96. package/dist/{worker-OMWNOKTJ.js → worker-5RDZHLXH.js} +10 -10
  97. package/migrations/0037_conversation_location.sql +23 -0
  98. package/migrations/meta/0037_snapshot.json +3192 -0
  99. package/migrations/meta/_journal.json +7 -0
  100. package/package.json +5 -5
  101. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  102. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  103. package/dist/chat/api-turns/routing.d.ts +0 -51
  104. package/dist/chat/api-turns/work.d.ts +0 -99
  105. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -55
  106. package/dist/chunk-6FGN7ZEG.js +0 -221
  107. package/dist/chunk-LODJKINF.js +0 -1502
  108. package/dist/spawn-CO7QFCNJ.js +0 -41
  109. package/dist/task-runner-DUGZGI7V.js +0 -34
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState
4
- } from "./chunk-CIG6WI7Q.js";
4
+ } from "./chunk-MRXMFB4L.js";
5
+ import {
6
+ recordTaskExecution
7
+ } from "./chunk-LHKZKAZ4.js";
5
8
  import {
6
9
  pluginTaskId,
7
10
  pluginTaskParamsSchema,
8
11
  sendVercelPluginTask
9
- } from "./chunk-XI4PVY2T.js";
12
+ } from "./chunk-KN32OWL2.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-MFSET7Q7.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-MI6ZBDTS.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-CUYFCI4G.js";
40
39
  import {
41
40
  getStateAdapter
42
- } from "./chunk-ZX7RSBQ6.js";
41
+ } from "./chunk-5CXCGDIL.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";
@@ -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-LPJKR2EO.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;
@@ -1064,13 +791,6 @@ async function processPluginTask(message, options = {}) {
1064
791
  }
1065
792
 
1066
793
  export {
1067
- recordTaskExecution,
1068
- readTaskExecutionSummaries,
1069
- readTaskExecutionDays,
1070
- readTaskExecutionByConversationId,
1071
- readTaskExecutions,
1072
- readTaskRuns,
1073
- readTaskExecutionStatusDays,
1074
794
  getDispatchConversationId,
1075
795
  getDispatchInputMessageId,
1076
796
  getDispatchTurnId,
@@ -1086,7 +806,6 @@ export {
1086
806
  listPendingDispatchMailboxAppends,
1087
807
  claimDispatchMailboxAppend,
1088
808
  getPluginDispatchProjection,
1089
- resolveConversationRouting,
1090
809
  resolveTurnSessionRouting,
1091
810
  scheduleSessionCompletedPluginTasks,
1092
811
  processPluginTask
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-Q7O74WOO.js";
3
+ } from "./chunk-BYBSI5TI.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-VFUK3X5B.js";
5
5
  import {
6
6
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS
7
- } from "./chunk-Q7O74WOO.js";
7
+ } from "./chunk-BYBSI5TI.js";
8
8
 
9
9
  // src/db/neon.ts
10
10
  import { AsyncLocalStorage } from "async_hooks";
@@ -137,12 +137,14 @@ var juniorConversations = pgTable4(
137
137
  schemaVersion: integer2("schema_version").notNull().default(1),
138
138
  source: text4("source").$type(),
139
139
  /** Structured session Source locator; set-once on the conversation root. */
140
- // TODO(dcramer): Remove source_json after every stored Conversation has a
141
- // complete Location and all readers use it for provider context.
140
+ // TODO(dcramer): Remove source_json after resume reads the saved Turn Source
141
+ // and all provider context readers use Conversation Location.
142
142
  sessionSource: jsonb2("source_json").$type(),
143
143
  originType: text4("origin_type"),
144
144
  originId: text4("origin_id"),
145
145
  originRunId: text4("origin_run_id"),
146
+ /** Complete Location associated with this Conversation. */
147
+ location: jsonb2("location_json").$type(),
146
148
  // TODO(dcramer): Rename destination_id to location_id after all deployed
147
149
  // readers and writers use the singular Conversation Location contract.
148
150
  destinationId: text4("destination_id").references(
@@ -518,6 +520,8 @@ var juniorAgentInvocations = pgTable12(
518
520
  ).$type(),
519
521
  source: jsonb5("source_json").$type().notNull(),
520
522
  destination: jsonb5("destination_json").$type().notNull(),
523
+ // TODO(dcramer): Remove destinationVisibility after all deployed Agent
524
+ // invocation readers ignore the destination_visibility SQL column.
521
525
  destinationVisibility: text12(
522
526
  "destination_visibility"
523
527
  ).$type(),
@@ -6,14 +6,14 @@ import {
6
6
  isStale,
7
7
  runNonInteractiveCommand,
8
8
  sleep
9
- } from "./chunk-X55FOVZO.js";
9
+ } from "./chunk-WDHPN2GH.js";
10
10
  import {
11
11
  getStateAdapter
12
- } from "./chunk-ZX7RSBQ6.js";
12
+ } from "./chunk-5CXCGDIL.js";
13
13
  import {
14
14
  setSpanAttributes,
15
15
  withSpan
16
- } from "./chunk-QIMN3FXL.js";
16
+ } from "./chunk-PY3EIEAF.js";
17
17
 
18
18
  // src/chat/sandbox/resources.ts
19
19
  var configuredResources;
@@ -2,29 +2,31 @@ import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState,
4
4
  persistThreadStateById
5
- } from "./chunk-CIG6WI7Q.js";
5
+ } from "./chunk-MRXMFB4L.js";
6
6
  import {
7
- buildDeterministicTurnId,
8
7
  clearPendingAuth,
9
8
  markTurnClosed,
10
9
  markTurnCompleted
11
- } from "./chunk-Z5SKZE5B.js";
10
+ } from "./chunk-GP32KD2J.js";
12
11
  import {
13
12
  hydrateConversationMessages,
14
13
  markConversationMessage
15
- } from "./chunk-6YGFBU3A.js";
14
+ } from "./chunk-MFSET7Q7.js";
15
+ import {
16
+ buildDeterministicTurnId
17
+ } from "./chunk-DA2KGZZI.js";
16
18
  import {
17
19
  ProviderError,
18
20
  findProviderError,
19
21
  getProviderErrorAttributes,
20
22
  getProviderErrorUserMessage
21
- } from "./chunk-Q7O74WOO.js";
23
+ } from "./chunk-BYBSI5TI.js";
22
24
  import {
23
25
  parseSlackMessageTs
24
26
  } from "./chunk-N7TMSOZH.js";
25
27
  import {
26
28
  buildTurnFailureResponse
27
- } from "./chunk-QIMN3FXL.js";
29
+ } from "./chunk-PY3EIEAF.js";
28
30
 
29
31
  // src/chat/runtime/delivered-turn-state.ts
30
32
  function buildDeliveredTurnStatePatch(args) {
@@ -7,23 +7,23 @@ import {
7
7
  import {
8
8
  formatProviderLabel,
9
9
  startOAuthFlow
10
- } from "./chunk-UVUXFRYN.js";
10
+ } from "./chunk-PCPSX4ES.js";
11
11
  import {
12
12
  abandonReplacedPendingAuth,
13
13
  canReusePendingAuthLink
14
- } from "./chunk-Z5SKZE5B.js";
14
+ } from "./chunk-GP32KD2J.js";
15
15
  import {
16
16
  recordAuthorizationRequested
17
- } from "./chunk-6YGFBU3A.js";
17
+ } from "./chunk-MFSET7Q7.js";
18
18
  import {
19
19
  AGENT_INVOCATION_MAILBOX_STATUSES
20
- } from "./chunk-QVH6FW3T.js";
20
+ } from "./chunk-5VWAY27R.js";
21
21
  import {
22
22
  TURN_REASONING_LEVELS
23
23
  } from "./chunk-D4YV5TDV.js";
24
24
  import {
25
25
  pluginCatalogRuntime
26
- } from "./chunk-NZLZ4KYZ.js";
26
+ } from "./chunk-E3PDZPGV.js";
27
27
  import {
28
28
  credentialContextSchema
29
29
  } from "./chunk-CEMMLV5L.js";
@@ -271,7 +271,6 @@ var agentInvocationBaseSchema = z.object({
271
271
  createdAtMs: z.number().finite(),
272
272
  credentialContext: credentialContextSchema.optional(),
273
273
  destination: destinationSchema,
274
- destinationVisibility: z.enum(["public", "private"]).optional(),
275
274
  input: exactStringSchema,
276
275
  invocationId: exactStringSchema,
277
276
  mailboxStatus: agentInvocationMailboxStatusSchema,
@@ -300,7 +299,6 @@ var createAgentInvocationSchema = z.object({
300
299
  agentName: agentNameSchema.optional(),
301
300
  credentialContext: credentialContextSchema.optional(),
302
301
  destination: destinationSchema,
303
- destinationVisibility: z.enum(["public", "private"]).optional(),
304
302
  idempotencyKey: exactStringSchema,
305
303
  input: exactStringSchema,
306
304
  parentConversationId: exactStringSchema,
@@ -7,7 +7,7 @@ import {
7
7
  toCanonicalInputMessage,
8
8
  toCanonicalOutputMessage,
9
9
  toGenAiMessagesTraceAttributes
10
- } from "./chunk-FIUCHYT6.js";
10
+ } from "./chunk-DYXVAO2E.js";
11
11
  import {
12
12
  extractGenAiUsageAttributes,
13
13
  logException,
@@ -15,7 +15,7 @@ import {
15
15
  normalizeGenAiFinishReason,
16
16
  serializeGenAiAttribute,
17
17
  withSpan
18
- } from "./chunk-QIMN3FXL.js";
18
+ } from "./chunk-PY3EIEAF.js";
19
19
 
20
20
  // src/chat/services/provider-error.ts
21
21
  var ProviderError = class extends Error {