@sentry/junior 0.138.0 → 0.139.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 (71) hide show
  1. package/dist/{agent-hooks-SCR74Q3E.js → agent-hooks-MJXMD7JP.js} +10 -10
  2. package/dist/api/schema/task.d.ts +100 -1
  3. package/dist/api/schema.d.ts +2 -2
  4. package/dist/api/schema.js +9 -1
  5. package/dist/api.js +198 -54
  6. package/dist/app.js +288 -602
  7. package/dist/{catalog-runtime-IU3QF4GG.js → catalog-runtime-GCCFYPIK.js} +6 -6
  8. package/dist/chat/agent/request.d.ts +12 -2
  9. package/dist/chat/credentials/context.d.ts +14 -0
  10. package/dist/chat/resource-events/actor.d.ts +23 -0
  11. package/dist/chat/state/turn-session.d.ts +1 -3
  12. package/dist/chat/tasks/execution-stats.d.ts +34 -3
  13. package/dist/chat/tasks/read.d.ts +3 -1
  14. package/dist/{chunk-JNNJZURV.js → chunk-2ECYPYKP.js} +1 -1
  15. package/dist/chunk-3T2JAGRH.js +115 -0
  16. package/dist/{chunk-PB3CXNVL.js → chunk-4V4QIYJH.js} +1 -1
  17. package/dist/{chunk-FEUNPTGV.js → chunk-5GSZWRE2.js} +434 -12
  18. package/dist/{chunk-QS527AV5.js → chunk-6OHTDR4F.js} +1 -1
  19. package/dist/{chunk-TCS76X5D.js → chunk-6SU2DT27.js} +2 -2
  20. package/dist/{chunk-BYW4B4PR.js → chunk-75I3UBIL.js} +2 -2
  21. package/dist/{chunk-ZBSMCXKV.js → chunk-AEQISMMU.js} +7 -6
  22. package/dist/{chunk-KDCHVT25.js → chunk-C2N6MNO4.js} +9 -2
  23. package/dist/{chunk-KFRHRSCJ.js → chunk-CXH25EL4.js} +2 -2
  24. package/dist/{chunk-TDJCLNDH.js → chunk-DW4PMHNW.js} +3 -3
  25. package/dist/{chunk-A7WCHXZV.js → chunk-G52UXKGO.js} +4 -4
  26. package/dist/chunk-GI52BW74.js +207 -0
  27. package/dist/{chunk-ZXNTJJIE.js → chunk-GWQSZT4C.js} +2 -2
  28. package/dist/{chunk-EPBBYMNE.js → chunk-HUO3UTAQ.js} +1 -1
  29. package/dist/{chunk-5MXWHTCK.js → chunk-IIESAYDL.js} +6 -6
  30. package/dist/{chunk-YU5QUF67.js → chunk-J3S57AXY.js} +1 -1
  31. package/dist/{chunk-E5UYAIKJ.js → chunk-J6EJQCHY.js} +17 -19
  32. package/dist/{chunk-5LTJ4ITU.js → chunk-MQ5RYATN.js} +4 -4
  33. package/dist/{chunk-BOLJOV5T.js → chunk-MXTVUV3I.js} +1 -1
  34. package/dist/{chunk-FNLBTB4K.js → chunk-MXVD2BDS.js} +1 -1
  35. package/dist/{chunk-TUUDXEXU.js → chunk-PJW6U46K.js} +12 -15
  36. package/dist/{chunk-SIPKWSXK.js → chunk-QTBKPZDA.js} +3 -3
  37. package/dist/{chunk-77VDLF3Z.js → chunk-RUIXF3YQ.js} +10 -0
  38. package/dist/{chunk-SD3OFRWY.js → chunk-U27DSXKB.js} +6 -6
  39. package/dist/{chunk-C7ZVPO4Z.js → chunk-U7CMWQ7Z.js} +1 -1
  40. package/dist/{chunk-DCLLQGS6.js → chunk-UDBUS533.js} +8 -3
  41. package/dist/{chunk-HIWJWWMT.js → chunk-WQRX57EA.js} +3 -3
  42. package/dist/{chunk-LPVUNO2W.js → chunk-WZH4JV7R.js} +7 -7
  43. package/dist/{chunk-HCIVH3JS.js → chunk-YCTDA7BD.js} +28 -0
  44. package/dist/{chunk-VPZFVJND.js → chunk-YGZ2OLXL.js} +1 -1
  45. package/dist/{chunk-N7WARMC6.js → chunk-ZQCGQMF2.js} +7 -7
  46. package/dist/{chunk-RZIBSCYC.js → chunk-ZYQSPQYR.js} +25 -22
  47. package/dist/cli/chat.js +33 -33
  48. package/dist/cli/check.js +7 -7
  49. package/dist/cli/plugins.js +14 -14
  50. package/dist/cli/snapshot-create.js +10 -10
  51. package/dist/cli/upgrade.js +8 -8
  52. package/dist/db/schema/task-executions.d.ts +23 -2
  53. package/dist/db/schema.d.ts +20 -1
  54. package/dist/{db-UO2IWXGA.js → db-UXPPGHDF.js} +7 -7
  55. package/dist/instrumentation.js +4 -4
  56. package/dist/nitro.js +2 -2
  57. package/dist/{oauth-callback-server-MAQI43LX.js → oauth-callback-server-4ZYMD5UA.js} +22 -21
  58. package/dist/{runner-PIUQEXKE.js → runner-MZSEONRZ.js} +18 -16
  59. package/dist/{sandbox-egress-signals-A5HWIQH4.js → sandbox-egress-signals-EKPAVWQL.js} +2 -2
  60. package/dist/{skills-4ARJADHQ.js → skills-IMVPXSQ7.js} +7 -7
  61. package/dist/spawn-S5LSVOCE.js +38 -0
  62. package/dist/{validation-S3EE3HWL.js → validation-ZKCY2BVR.js} +7 -7
  63. package/dist/version.js +1 -1
  64. package/dist/{work-UARRUAW3.js → work-GG3XDYRX.js} +18 -18
  65. package/dist/{worker-DOCIRVD3.js → worker-23AUELCJ.js} +10 -10
  66. package/migrations/0022_task_execution_status.sql +3 -0
  67. package/migrations/meta/0022_snapshot.json +2186 -0
  68. package/migrations/meta/_journal.json +7 -0
  69. package/package.json +5 -5
  70. package/dist/chunk-ELKW5FIB.js +0 -233
  71. package/dist/spawn-G2AWPMCT.js +0 -38
@@ -4,18 +4,18 @@ import {
4
4
  } from "./chunk-EM225ITJ.js";
5
5
  import {
6
6
  getStateAdapter
7
- } from "./chunk-BOLJOV5T.js";
7
+ } from "./chunk-MXTVUV3I.js";
8
8
  import {
9
9
  toOptionalTrimmed
10
- } from "./chunk-BYW4B4PR.js";
10
+ } from "./chunk-75I3UBIL.js";
11
11
  import {
12
12
  pluginCatalogRuntime
13
- } from "./chunk-QS527AV5.js";
13
+ } from "./chunk-6OHTDR4F.js";
14
14
  import {
15
15
  setSpanAttributes,
16
16
  setSpanStatus,
17
17
  withSpan
18
- } from "./chunk-JNNJZURV.js";
18
+ } from "./chunk-2ECYPYKP.js";
19
19
 
20
20
  // src/chat/sandbox/resources.ts
21
21
  var configuredResources;
@@ -0,0 +1,207 @@
1
+ import {
2
+ getDb
3
+ } from "./chunk-QTBKPZDA.js";
4
+ import {
5
+ juniorConversations,
6
+ juniorTaskExecutions
7
+ } from "./chunk-UDBUS533.js";
8
+ import {
9
+ logWarn
10
+ } from "./chunk-2ECYPYKP.js";
11
+
12
+ // src/chat/tasks/execution-stats.ts
13
+ import { and, asc, count, desc, eq, gte, inArray, lte, max, sql } from "drizzle-orm";
14
+ var TASK_EXECUTION_STATUSES = [
15
+ "blocked",
16
+ "completed",
17
+ "failed"
18
+ ];
19
+ function utcDate(nowMs) {
20
+ return new Date(nowMs).toISOString().slice(0, 10);
21
+ }
22
+ function emptyDay(date) {
23
+ return { date, event: 0, scheduled: 0 };
24
+ }
25
+ function emptyStatusDay(date) {
26
+ return { blocked: 0, completed: 0, date, failed: 0 };
27
+ }
28
+ async function recordTaskExecution(type, taskId, options) {
29
+ const namespace = options.namespace ?? "junior";
30
+ const nowMs = options.nowMs ?? Date.now();
31
+ const status = options.status ?? "completed";
32
+ try {
33
+ await getDb().insert(juniorTaskExecutions).values({
34
+ ...options.conversationId ? { conversationId: options.conversationId } : {},
35
+ executedAtMs: nowMs,
36
+ executionId: options.executionId,
37
+ kind: type,
38
+ namespace,
39
+ status,
40
+ taskId
41
+ }).onConflictDoNothing({
42
+ target: [
43
+ juniorTaskExecutions.kind,
44
+ juniorTaskExecutions.namespace,
45
+ juniorTaskExecutions.executionId
46
+ ]
47
+ });
48
+ } catch (error) {
49
+ logWarn("task.execution.stat_failed", {
50
+ error,
51
+ "app.task.execution.id": options.executionId,
52
+ "app.task.execution.namespace": namespace,
53
+ "app.task.execution.status": status,
54
+ "app.task.execution.task_id": taskId,
55
+ "app.task.execution.type": type
56
+ });
57
+ }
58
+ }
59
+ async function readTaskExecutionSummaries(type, namespace, options = {}) {
60
+ const sevenDaysAgoMs = (options.nowMs ?? Date.now()) - 7 * 24 * 60 * 60 * 1e3;
61
+ const db = getDb();
62
+ const latest = db.selectDistinctOn([juniorTaskExecutions.taskId], {
63
+ conversationId: juniorTaskExecutions.conversationId,
64
+ taskId: juniorTaskExecutions.taskId
65
+ }).from(juniorTaskExecutions).where(
66
+ and(
67
+ eq(juniorTaskExecutions.kind, type),
68
+ eq(juniorTaskExecutions.namespace, namespace)
69
+ )
70
+ ).orderBy(
71
+ juniorTaskExecutions.taskId,
72
+ desc(juniorTaskExecutions.executedAtMs),
73
+ desc(juniorTaskExecutions.executionId)
74
+ ).as("latest_task_execution");
75
+ const rows = await db.select({
76
+ lastConversationId: latest.conversationId,
77
+ lastExecutedAtMs: max(juniorTaskExecutions.executedAtMs),
78
+ runsLast7Days: sql`count(*) filter (where ${juniorTaskExecutions.executedAtMs} >= ${sevenDaysAgoMs})::int`,
79
+ taskId: juniorTaskExecutions.taskId,
80
+ totalRuns: sql`count(*)::int`
81
+ }).from(juniorTaskExecutions).innerJoin(latest, eq(latest.taskId, juniorTaskExecutions.taskId)).where(
82
+ and(
83
+ eq(juniorTaskExecutions.kind, type),
84
+ eq(juniorTaskExecutions.namespace, namespace)
85
+ )
86
+ ).groupBy(juniorTaskExecutions.taskId, latest.conversationId);
87
+ return new Map(
88
+ rows.map((row) => [
89
+ row.taskId,
90
+ {
91
+ ...row.lastConversationId ? { lastConversationId: row.lastConversationId } : {},
92
+ ...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } : {},
93
+ runsLast7Days: row.runsLast7Days,
94
+ totalRuns: row.totalRuns
95
+ }
96
+ ])
97
+ );
98
+ }
99
+ async function readTaskExecutionDays(dayCount = 90, options = {}) {
100
+ const nowMs = options.nowMs ?? Date.now();
101
+ const end = utcDate(nowMs);
102
+ const endMs = Date.parse(`${end}T23:59:59.999Z`);
103
+ const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
104
+ const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
105
+ const rows = await getDb().select({
106
+ count: count(),
107
+ date: executionDate,
108
+ kind: juniorTaskExecutions.kind
109
+ }).from(juniorTaskExecutions).where(
110
+ and(
111
+ gte(juniorTaskExecutions.executedAtMs, startMs),
112
+ lte(juniorTaskExecutions.executedAtMs, endMs),
113
+ eq(juniorTaskExecutions.status, "completed")
114
+ )
115
+ ).groupBy(executionDate, juniorTaskExecutions.kind).orderBy(asc(executionDate), asc(juniorTaskExecutions.kind));
116
+ const byDate = /* @__PURE__ */ new Map();
117
+ for (let offset = 0; offset < dayCount; offset += 1) {
118
+ const date = utcDate(startMs + offset * 864e5);
119
+ byDate.set(date, emptyDay(date));
120
+ }
121
+ for (const row of rows) {
122
+ const day = byDate.get(row.date);
123
+ if (!day) continue;
124
+ if (row.kind === "scheduled") day.scheduled = row.count;
125
+ else if (row.kind === "event") day.event = row.count;
126
+ }
127
+ return [...byDate.values()];
128
+ }
129
+ async function readTaskExecutions(args) {
130
+ const namespace = args.namespace ?? "junior";
131
+ const rows = await getDb().select({
132
+ conversationId: juniorTaskExecutions.conversationId,
133
+ executedAtMs: juniorTaskExecutions.executedAtMs,
134
+ executionId: juniorTaskExecutions.executionId,
135
+ status: juniorTaskExecutions.status,
136
+ title: juniorConversations.title
137
+ }).from(juniorTaskExecutions).leftJoin(
138
+ juniorConversations,
139
+ eq(
140
+ juniorConversations.conversationId,
141
+ juniorTaskExecutions.conversationId
142
+ )
143
+ ).where(
144
+ and(
145
+ eq(juniorTaskExecutions.kind, args.kind),
146
+ eq(juniorTaskExecutions.namespace, namespace),
147
+ eq(juniorTaskExecutions.taskId, args.taskId)
148
+ )
149
+ ).orderBy(
150
+ desc(juniorTaskExecutions.executedAtMs),
151
+ desc(juniorTaskExecutions.executionId)
152
+ ).limit(args.limit);
153
+ return rows.map((row) => {
154
+ const title = row.title?.trim();
155
+ return {
156
+ ...row.conversationId ? { conversationId: row.conversationId } : {},
157
+ executedAt: new Date(row.executedAtMs).toISOString(),
158
+ executionId: row.executionId,
159
+ status: row.status,
160
+ ...title ? { title } : {}
161
+ };
162
+ });
163
+ }
164
+ async function readTaskExecutionStatusDays(args) {
165
+ const dayCount = args.dayCount ?? 90;
166
+ const namespace = args.namespace ?? "junior";
167
+ const nowMs = args.nowMs ?? Date.now();
168
+ const end = utcDate(nowMs);
169
+ const endMs = Date.parse(`${end}T23:59:59.999Z`);
170
+ const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
171
+ const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
172
+ const rows = await getDb().select({
173
+ count: count(),
174
+ date: executionDate,
175
+ status: juniorTaskExecutions.status
176
+ }).from(juniorTaskExecutions).where(
177
+ and(
178
+ eq(juniorTaskExecutions.kind, args.kind),
179
+ eq(juniorTaskExecutions.namespace, namespace),
180
+ eq(juniorTaskExecutions.taskId, args.taskId),
181
+ gte(juniorTaskExecutions.executedAtMs, startMs),
182
+ lte(juniorTaskExecutions.executedAtMs, endMs),
183
+ inArray(juniorTaskExecutions.status, [...TASK_EXECUTION_STATUSES])
184
+ )
185
+ ).groupBy(executionDate, juniorTaskExecutions.status).orderBy(asc(executionDate), asc(juniorTaskExecutions.status));
186
+ const byDate = /* @__PURE__ */ new Map();
187
+ for (let offset = 0; offset < dayCount; offset += 1) {
188
+ const date = utcDate(startMs + offset * 864e5);
189
+ byDate.set(date, emptyStatusDay(date));
190
+ }
191
+ for (const row of rows) {
192
+ const day = byDate.get(row.date);
193
+ if (!day) continue;
194
+ if (row.status === "completed") day.completed = row.count;
195
+ else if (row.status === "failed") day.failed = row.count;
196
+ else if (row.status === "blocked") day.blocked = row.count;
197
+ }
198
+ return [...byDate.values()];
199
+ }
200
+
201
+ export {
202
+ recordTaskExecution,
203
+ readTaskExecutionSummaries,
204
+ readTaskExecutionDays,
205
+ readTaskExecutions,
206
+ readTaskExecutionStatusDays
207
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-QS527AV5.js";
3
+ } from "./chunk-6OHTDR4F.js";
4
4
  import {
5
5
  logWarn
6
- } from "./chunk-JNNJZURV.js";
6
+ } from "./chunk-2ECYPYKP.js";
7
7
  import {
8
8
  skillRoots
9
9
  } from "./chunk-H4HBKISO.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  credentialContextSchema
3
- } from "./chunk-77VDLF3Z.js";
3
+ } from "./chunk-RUIXF3YQ.js";
4
4
 
5
5
  // src/chat/sandbox/egress/schemas.ts
6
6
  import { z } from "zod";
@@ -4,30 +4,30 @@ import {
4
4
  isConversationScopedChannel,
5
5
  isDmChannel,
6
6
  normalizeSlackConversationId
7
- } from "./chunk-TCS76X5D.js";
7
+ } from "./chunk-6SU2DT27.js";
8
8
  import {
9
9
  getConversationEventStore,
10
10
  getDb
11
- } from "./chunk-SIPKWSXK.js";
11
+ } from "./chunk-QTBKPZDA.js";
12
12
  import {
13
13
  juniorConversationAnnotations,
14
14
  juniorConversationEvents,
15
15
  juniorIdentities,
16
16
  juniorUsers
17
- } from "./chunk-DCLLQGS6.js";
17
+ } from "./chunk-UDBUS533.js";
18
18
  import {
19
19
  SANDBOX_WORKSPACE_ROOT
20
20
  } from "./chunk-EM225ITJ.js";
21
21
  import {
22
22
  getStateAdapter
23
- } from "./chunk-BOLJOV5T.js";
23
+ } from "./chunk-MXTVUV3I.js";
24
24
  import {
25
25
  botConfig,
26
26
  completeObject,
27
27
  embedTexts,
28
28
  getSlackBotToken,
29
29
  standardModelId
30
- } from "./chunk-BYW4B4PR.js";
30
+ } from "./chunk-75I3UBIL.js";
31
31
  import {
32
32
  isActorUserId,
33
33
  parseActorUserId
@@ -42,7 +42,7 @@ import {
42
42
  logInfo,
43
43
  logWarn,
44
44
  normalizeIdentityEmail
45
- } from "./chunk-JNNJZURV.js";
45
+ } from "./chunk-2ECYPYKP.js";
46
46
 
47
47
  // src/chat/plugins/agent-hooks.ts
48
48
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-QS527AV5.js";
3
+ } from "./chunk-6OHTDR4F.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  ensureConversationWake,
6
6
  requestConversationWork
7
- } from "./chunk-5LTJ4ITU.js";
7
+ } from "./chunk-MQ5RYATN.js";
8
8
  import {
9
9
  buildDeliveredTurnStatePatch,
10
10
  finalizeFailedTurnReplyWithEvent,
@@ -17,7 +17,7 @@ import {
17
17
  requireTurnFailureEventId,
18
18
  resolveTurnSessionRouting,
19
19
  scheduleSessionCompletedPluginTasks
20
- } from "./chunk-FEUNPTGV.js";
20
+ } from "./chunk-5GSZWRE2.js";
21
21
  import {
22
22
  ConversationTurnLifecycleService
23
23
  } from "./chunk-Q6QZTTLS.js";
@@ -35,7 +35,7 @@ import {
35
35
  getMcpProviderErrorAttributes,
36
36
  getMcpStoredOAuthCredentials,
37
37
  resolvePluginOAuthAccount
38
- } from "./chunk-N7WARMC6.js";
38
+ } from "./chunk-ZQCGQMF2.js";
39
39
  import {
40
40
  RetryableDeliveryError
41
41
  } from "./chunk-R776HKPK.js";
@@ -51,7 +51,7 @@ import {
51
51
  removeReactionFromMessage,
52
52
  resolveBaseUrl,
53
53
  truncateStatusText
54
- } from "./chunk-SD3OFRWY.js";
54
+ } from "./chunk-U27DSXKB.js";
55
55
  import {
56
56
  TurnSliceLimitExceededError,
57
57
  abandonAgentTurnSessionRecord,
@@ -82,32 +82,32 @@ import {
82
82
  recordDeliveredAssistantMessage,
83
83
  turnHasReply,
84
84
  updateConversationStats
85
- } from "./chunk-TUUDXEXU.js";
85
+ } from "./chunk-PJW6U46K.js";
86
86
  import {
87
87
  parseSlackThreadId,
88
88
  readSlackRawMessageContext,
89
89
  resolveSlackChannelIdFromMessage,
90
90
  resolveSlackChannelIdFromThreadId
91
- } from "./chunk-FNLBTB4K.js";
91
+ } from "./chunk-MXVD2BDS.js";
92
92
  import {
93
93
  getDashboardConversationLink,
94
94
  getPluginSlackConversationLink
95
- } from "./chunk-5MXWHTCK.js";
95
+ } from "./chunk-IIESAYDL.js";
96
96
  import {
97
97
  SlackActionError,
98
98
  getHeaderString,
99
99
  getSlackClient,
100
100
  isDmChannel,
101
101
  normalizeSlackConversationId
102
- } from "./chunk-TCS76X5D.js";
102
+ } from "./chunk-6SU2DT27.js";
103
103
  import {
104
104
  getConversationEventStore,
105
105
  requireSlackDestination
106
- } from "./chunk-SIPKWSXK.js";
106
+ } from "./chunk-QTBKPZDA.js";
107
107
  import {
108
108
  acquireActiveLock,
109
109
  getStateAdapter
110
- } from "./chunk-BOLJOV5T.js";
110
+ } from "./chunk-MXTVUV3I.js";
111
111
  import {
112
112
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
113
113
  botConfig,
@@ -116,18 +116,18 @@ import {
116
116
  getRuntimeMetadata,
117
117
  normalizeSlackEmojiName,
118
118
  standardModelId
119
- } from "./chunk-BYW4B4PR.js";
119
+ } from "./chunk-75I3UBIL.js";
120
120
  import {
121
121
  discoverSkills
122
- } from "./chunk-ZXNTJJIE.js";
122
+ } from "./chunk-GWQSZT4C.js";
123
123
  import {
124
124
  pluginCatalogRuntime
125
- } from "./chunk-QS527AV5.js";
125
+ } from "./chunk-6OHTDR4F.js";
126
126
  import {
127
127
  buildOAuthTokenRequest,
128
128
  hasRequiredOAuthScope,
129
129
  parseOAuthTokenResponse
130
- } from "./chunk-KFRHRSCJ.js";
130
+ } from "./chunk-CXH25EL4.js";
131
131
  import {
132
132
  createSlackResumeActor,
133
133
  isUserActor
@@ -143,7 +143,7 @@ import {
143
143
  setTags,
144
144
  toOptionalString,
145
145
  withLogContext
146
- } from "./chunk-JNNJZURV.js";
146
+ } from "./chunk-2ECYPYKP.js";
147
147
  import {
148
148
  homeDir
149
149
  } from "./chunk-H4HBKISO.js";
@@ -2044,7 +2044,6 @@ async function resumeAuthorizedMcpTurn(args) {
2044
2044
  let actor;
2045
2045
  try {
2046
2046
  actor = createSlackResumeActor({
2047
- actor: isUserActor(lockedSessionRecord.actor) ? lockedSessionRecord.actor : void 0,
2048
2047
  teamId: destination.teamId,
2049
2048
  userId: authSession.userId
2050
2049
  });
@@ -2053,7 +2052,7 @@ async function resumeAuthorizedMcpTurn(args) {
2053
2052
  conversationId: authSession.conversationId,
2054
2053
  expectedVersion: lockedSessionRecord.version,
2055
2054
  sessionId: lockedSessionId,
2056
- errorMessage: "Stored Slack actor identity did not match OAuth actor"
2055
+ errorMessage: "Unable to rebuild Slack actor for OAuth resume"
2057
2056
  });
2058
2057
  return false;
2059
2058
  }
@@ -2678,7 +2677,6 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2678
2677
  let actor;
2679
2678
  try {
2680
2679
  actor = createSlackResumeActor({
2681
- actor: isUserActor(lockedSessionRecord.actor) ? lockedSessionRecord.actor : void 0,
2682
2680
  teamId: destination.teamId,
2683
2681
  userId: lockedUserMessage.author.userId
2684
2682
  });
@@ -2687,7 +2685,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2687
2685
  conversationId: stored.resumeConversationId,
2688
2686
  expectedVersion: lockedSessionRecord.version,
2689
2687
  sessionId: lockedSessionId,
2690
- errorMessage: "Stored Slack actor identity did not match OAuth actor"
2688
+ errorMessage: "Unable to rebuild Slack actor for OAuth resume"
2691
2689
  });
2692
2690
  return false;
2693
2691
  }
@@ -5,14 +5,14 @@ import {
5
5
  getConversationStore,
6
6
  parseDestination,
7
7
  sameDestination
8
- } from "./chunk-SIPKWSXK.js";
8
+ } from "./chunk-QTBKPZDA.js";
9
9
  import {
10
10
  getDefaultRedisStateAdapterFor,
11
11
  getStateAdapter
12
- } from "./chunk-BOLJOV5T.js";
12
+ } from "./chunk-MXTVUV3I.js";
13
13
  import {
14
14
  getChatConfig
15
- } from "./chunk-BYW4B4PR.js";
15
+ } from "./chunk-75I3UBIL.js";
16
16
  import {
17
17
  parseStoredSlackActor
18
18
  } from "./chunk-HZF5P5UN.js";
@@ -20,7 +20,7 @@ import {
20
20
  isRecord,
21
21
  toOptionalNumber,
22
22
  toOptionalString
23
- } from "./chunk-JNNJZURV.js";
23
+ } from "./chunk-2ECYPYKP.js";
24
24
 
25
25
  // src/chat/task-execution/state.ts
26
26
  import { randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-BYW4B4PR.js";
3
+ } from "./chunk-75I3UBIL.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-F3B2YJ76.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-JNNJZURV.js";
8
+ } from "./chunk-2ECYPYKP.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";
@@ -21,20 +21,20 @@ import {
21
21
  instructionProvenanceFor,
22
22
  sanitizePostgresJson,
23
23
  withConversationEventLock
24
- } from "./chunk-SIPKWSXK.js";
24
+ } from "./chunk-QTBKPZDA.js";
25
25
  import {
26
26
  SANDBOX_WORKSPACE_ROOT,
27
27
  sleep
28
28
  } from "./chunk-EM225ITJ.js";
29
29
  import {
30
30
  getStateAdapter
31
- } from "./chunk-BOLJOV5T.js";
31
+ } from "./chunk-MXTVUV3I.js";
32
32
  import {
33
33
  botConfig,
34
34
  escapeXml,
35
35
  resolveGatewayModel,
36
36
  unwrapCurrentInstruction
37
- } from "./chunk-BYW4B4PR.js";
37
+ } from "./chunk-75I3UBIL.js";
38
38
  import {
39
39
  toStoredSlackActor
40
40
  } from "./chunk-HZF5P5UN.js";
@@ -49,7 +49,7 @@ import {
49
49
  setSpanAttributes,
50
50
  toOptionalNumber,
51
51
  toOptionalString
52
- } from "./chunk-JNNJZURV.js";
52
+ } from "./chunk-2ECYPYKP.js";
53
53
 
54
54
  // src/chat/turn-context-tag.ts
55
55
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -1808,8 +1808,6 @@ var agentTurnSessionSummarySchema = z2.object({
1808
1808
  loadedSkillNames: z2.array(z2.string()).optional(),
1809
1809
  modelId: z2.string().min(1).optional(),
1810
1810
  reasoningLevel: z2.string().min(1).optional(),
1811
- // TODO(#1267): Remove actor from this projection once resume rebuilds it.
1812
- actor: actorSchema.optional(),
1813
1811
  resumeReason: agentTurnResumeReasonSchema.optional(),
1814
1812
  resumedFromSliceId: z2.number().int().nonnegative().optional(),
1815
1813
  sessionId: z2.string().min(1),
@@ -1874,7 +1872,7 @@ async function recordConversationActivityMetadata(args) {
1874
1872
  conversationId: args.summary.conversationId,
1875
1873
  destination,
1876
1874
  nowMs: args.nowMs,
1877
- actor: sessionLogActor(args.summary.actor),
1875
+ actor: sessionLogActor(args.actor),
1878
1876
  ...definedProps({ source: activitySource }),
1879
1877
  ...args.source ? { sessionSource: args.source } : {},
1880
1878
  visibility: isChild ? void 0 : args.destinationVisibility
@@ -1890,7 +1888,7 @@ async function recordConversationActivityMetadata(args) {
1890
1888
  durationMs: args.summary.cumulativeDurationMs,
1891
1889
  ...args.summary.cumulativeUsage ? { usage: args.summary.cumulativeUsage } : {}
1892
1890
  },
1893
- actor: sessionLogActor(args.summary.actor),
1891
+ actor: sessionLogActor(args.actor),
1894
1892
  ...definedProps({ source: activitySource }),
1895
1893
  updatedAtMs: args.nowMs,
1896
1894
  visibility: isChild ? void 0 : args.destinationVisibility
@@ -1912,7 +1910,6 @@ function materializeAgentTurnSessionRecord(stored, piProjection, turnStartMessag
1912
1910
  actors: stored.actors ?? instructionActors(piProjection.provenance),
1913
1911
  cumulativeDurationMs: stored.cumulativeDurationMs,
1914
1912
  ...definedProps({
1915
- actor: stored.actor,
1916
1913
  channelName: stored.channelName,
1917
1914
  cumulativeUsage: stored.cumulativeUsage,
1918
1915
  dispatchId: stored.dispatchId,
@@ -2032,7 +2029,6 @@ function buildStoredRecord(args) {
2032
2029
  committedSeq: args.committedSeq,
2033
2030
  cumulativeDurationMs: args.cumulativeDurationMs,
2034
2031
  ...definedProps({
2035
- actor: args.actor,
2036
2032
  actors: args.actors,
2037
2033
  channelName: args.channelName,
2038
2034
  cumulativeUsage: args.cumulativeUsage,
@@ -2058,6 +2054,7 @@ async function setStoredRecord(args) {
2058
2054
  await stateAdapter.connect();
2059
2055
  const storedRecord = storedAgentTurnSessionRecordSchema.parse(args.record);
2060
2056
  await recordConversationActivityMetadata({
2057
+ actor: args.actor,
2061
2058
  conversationStore: args.conversationStore,
2062
2059
  destination: args.destination,
2063
2060
  destinationVisibility: args.destinationVisibility,
@@ -2116,7 +2113,6 @@ async function updateAgentTurnSessionState(args) {
2116
2113
  cumulativeDurationMs: args.existing.cumulativeDurationMs,
2117
2114
  actors: args.existing.actors,
2118
2115
  ...definedProps({
2119
- actor: args.existing.actor,
2120
2116
  channelName: parsed.channelName,
2121
2117
  cumulativeUsage: args.existing.cumulativeUsage,
2122
2118
  dispatchId: args.existing.dispatchId,
@@ -2149,7 +2145,7 @@ async function upsertAgentTurnSessionRecord(args) {
2149
2145
  );
2150
2146
  }
2151
2147
  const ttlMs = Math.max(1, args.ttlMs ?? AGENT_TURN_SESSION_TTL_MS);
2152
- const instructionActor = args.actor ?? existingRecord?.actor;
2148
+ const instructionActor = args.actor;
2153
2149
  const commit = await commitMessages({
2154
2150
  conversationId: args.conversationId,
2155
2151
  messages: args.piMessages,
@@ -2170,6 +2166,7 @@ async function upsertAgentTurnSessionRecord(args) {
2170
2166
  const turnStartSeq = durableTurnStartMessageIndex === void 0 ? existingRecord?.turnStartSeq : durableTurnStartMessageIndex <= 0 ? -1 : commit.messageSeqs[durableTurnStartMessageIndex - 1] ?? commit.committedSeq;
2171
2167
  const turnStartMessageIndex = durableTurnStartMessageIndex ?? (turnStartSeq === void 0 ? void 0 : commit.messageSeqs.filter((seq) => seq <= turnStartSeq).length);
2172
2168
  return await setStoredRecord({
2169
+ actor: args.actor,
2173
2170
  conversationStore: args.conversationStore,
2174
2171
  destination: args.destination,
2175
2172
  destinationVisibility: args.destinationVisibility,
@@ -2194,7 +2191,6 @@ async function upsertAgentTurnSessionRecord(args) {
2194
2191
  ...commit.provenance
2195
2192
  ]),
2196
2193
  ...definedProps({
2197
- actor: args.actor ?? existingRecord?.actor,
2198
2194
  channelName: args.channelName ?? existingRecord?.channelName,
2199
2195
  cumulativeUsage: args.cumulativeUsage,
2200
2196
  dispatchId: args.dispatchId ?? existingRecord?.dispatchId,
@@ -2243,7 +2239,6 @@ async function recordAgentTurnSessionSummary(args) {
2243
2239
  updatedAtMs: nowMs,
2244
2240
  cumulativeDurationMs: args.cumulativeDurationMs ?? existing?.cumulativeDurationMs ?? 0,
2245
2241
  ...definedProps({
2246
- actor: args.actor ?? existing?.actor,
2247
2242
  channelName: args.channelName ?? existing?.channelName,
2248
2243
  cumulativeUsage: args.cumulativeUsage ?? existing?.cumulativeUsage,
2249
2244
  dispatchId: args.dispatchId ?? existingDispatchId,
@@ -2258,6 +2253,7 @@ async function recordAgentTurnSessionSummary(args) {
2258
2253
  })
2259
2254
  };
2260
2255
  await recordConversationActivityMetadata({
2256
+ actor: args.actor,
2261
2257
  conversationStore: args.conversationStore,
2262
2258
  destination: args.destination,
2263
2259
  destinationVisibility: args.destinationVisibility,
@@ -2378,7 +2374,8 @@ function sessionWriteContext(args, latest) {
2378
2374
  modelId: args.modelId,
2379
2375
  sessionId: args.sessionId,
2380
2376
  ...definedProps2({
2381
- actor: args.actor ?? latest?.actor,
2377
+ // Live only: Redis no longer stores execution actor across resumes.
2378
+ actor: args.actor,
2382
2379
  channelName: args.channelName ?? latest?.channelName,
2383
2380
  destination: args.destination,
2384
2381
  destinationVisibility: args.destinationVisibility,
@@ -5,12 +5,12 @@ import {
5
5
  juniorConversations,
6
6
  juniorIdentities,
7
7
  juniorUsers
8
- } from "./chunk-DCLLQGS6.js";
8
+ } from "./chunk-UDBUS533.js";
9
9
  import {
10
10
  TURN_REASONING_LEVELS,
11
11
  getChatConfig,
12
12
  modelProfileSchema
13
- } from "./chunk-BYW4B4PR.js";
13
+ } from "./chunk-75I3UBIL.js";
14
14
  import {
15
15
  juniorDestinations
16
16
  } from "./chunk-VFUK3X5B.js";
@@ -20,7 +20,7 @@ import {
20
20
  } from "./chunk-F3B2YJ76.js";
21
21
  import {
22
22
  normalizeIdentityEmail
23
- } from "./chunk-JNNJZURV.js";
23
+ } from "./chunk-2ECYPYKP.js";
24
24
 
25
25
  // src/chat/conversations/sql/store.ts
26
26
  import { randomUUID as randomUUID2 } from "crypto";
@@ -74,6 +74,15 @@ var credentialContextSchema = z.union([
74
74
  subject: credentialSubjectSchema.optional()
75
75
  }).strict()
76
76
  ]);
77
+ function credentialContextForActor(actor, subject) {
78
+ if (actor.platform === "system") {
79
+ return subject ? { actor, subject } : { actor };
80
+ }
81
+ if (subject) {
82
+ throw new TypeError("Delegated credential subjects require a system actor");
83
+ }
84
+ return { actor: { type: "user", userId: actor.userId } };
85
+ }
77
86
  function credentialUserSubjectId(context) {
78
87
  if ("type" in context.actor) {
79
88
  return context.actor.userId;
@@ -84,5 +93,6 @@ function credentialUserSubjectId(context) {
84
93
  export {
85
94
  credentialSubjectSchema,
86
95
  credentialContextSchema,
96
+ credentialContextForActor,
87
97
  credentialUserSubjectId
88
98
  };