@sentry/junior 0.258.0 → 0.260.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 (77) hide show
  1. package/dist/adapter-Dj5BTJRd.js +270 -0
  2. package/dist/{admin-My1SLGVO.js → admin-tzkZDqrH.js} +1 -1
  3. package/dist/{agent-hooks-BJ_5mlRH.js → agent-hooks-V4Hfc2tB.js} +711 -697
  4. package/dist/{agent-runner-DGsFQw72.js → agent-runner-DvTUyGTY.js} +751 -2508
  5. package/dist/api/schema.d.ts +239 -54
  6. package/dist/api/schema.js +4 -4
  7. package/dist/api.js +218 -57
  8. package/dist/{app-PX2H1PxU.d.ts → app-BsBUs3rF.d.ts} +6 -3
  9. package/dist/app.d.ts +2 -2
  10. package/dist/app.js +31 -31
  11. package/dist/{assistant-reply-H1M-91oF.js → assistant-reply-CEOMzsWy.js} +1 -1
  12. package/dist/{automation-DWBFBenG.js → automation-DrpcA-SX.js} +3 -0
  13. package/dist/{briefs-vYoK85rJ.js → briefs-BSCkyYqs.js} +4 -4
  14. package/dist/{catalog-runtime-BN4DVxco.js → catalog-runtime-Bpcs2b2L.js} +1 -1
  15. package/dist/cli/chat.d.ts +1 -1
  16. package/dist/cli/chat.js +16 -16
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +6 -2
  19. package/dist/cli/plugins.d.ts +1 -1
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/run.d.ts +2 -1
  22. package/dist/cli/run.js +2 -1
  23. package/dist/cli/snapshot-create.js +4 -3
  24. package/dist/cli/upgrade.d.ts +1 -1
  25. package/dist/cli/upgrade.js +3 -3
  26. package/dist/{client-DbyHuMFU.js → client-JeyzRwsT.js} +57 -4
  27. package/dist/{config-_WO_AjCB.js → config-ULs6Zl9b.js} +5 -2
  28. package/dist/{connections-ag_1JOhB.js → connections-CZ7HhEmN.js} +174 -10
  29. package/dist/{conversation-DjN3mlog.js → conversation-CvuKJ3tA.js} +108 -155
  30. package/dist/{conversation-privacy-DHP_xnVj.js → conversation-privacy-BQSlZXgV.js} +1 -1
  31. package/dist/{credential-sync-B-CPX_ag.js → credential-sync-BKcv5rBe.js} +14 -177
  32. package/dist/{executor-RvG6kVe1.js → executor-BoGNVEDn.js} +3 -2
  33. package/dist/{images-C2J_bj2g.js → images-BBmDXQCB.js} +3 -3
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{job-queue-DVe37it2.js → job-queue-CbdVyaCo.js} +1 -1
  36. package/dist/{logging-DsHONhVm.js → logging-DSMmkHXG.js} +1 -1
  37. package/dist/{message-DyitL8no.js → message-zaj5gBbS.js} +3 -3
  38. package/dist/nitro.d.ts +2 -2
  39. package/dist/nitro.js +3 -3
  40. package/dist/{oauth-callback-server-CDby-pCn.js → oauth-callback-server-yYFG8Own.js} +2 -2
  41. package/dist/{plugins-B11Mfkmv.d.ts → plugins-B_0Cr0MO.d.ts} +5 -1
  42. package/dist/{profile-DpYjfKke.js → profile-ByWkAY7L.js} +24 -293
  43. package/dist/{prompt-xgpyMtg7.js → prompt-DeVax2qO.js} +1 -1
  44. package/dist/{registry-Du566MtJ.js → registry-BL-osYWN.js} +41 -2
  45. package/dist/{resolve-ClCIgh8E.js → resolve-HuPG2VMB.js} +9 -4
  46. package/dist/{result-BBbKA61B.js → result-DS7V4a3-.js} +9 -14
  47. package/dist/{runner-CCuqFSqx.js → runner-Cba_OfGl.js} +11 -11
  48. package/dist/{sandbox-egress-signals-DY1mbKF4.js → sandbox-egress-signals-C7NcPzea.js} +1 -1
  49. package/dist/{schema-DrMh3NtR.js → schema-OzL8Zw4H.js} +82 -3
  50. package/dist/service-account-DqwHhwJA.js +120 -0
  51. package/dist/service-account-Ko1Xs--F.js +661 -0
  52. package/dist/{session-stop-CIoFiwwe.js → session-stop-HfKx-pky.js} +180 -22
  53. package/dist/{skills-DyQBLIrK.js → skills-D6_bcAuW.js} +2 -2
  54. package/dist/{spawn-Dqfeo7XP.js → spawn-BWqK6EwM.js} +2 -2
  55. package/dist/{store-DJLwq4x8.js → store-DzRbd5VT.js} +6 -6
  56. package/dist/{task-queue-BzW4MaWU.js → task-queue-9LICOzcL.js} +3 -3
  57. package/dist/{task-runner-D3qJh4fK.js → task-runner-DGnd_B5X.js} +10 -10
  58. package/dist/{tasks-CEXKTASS.js → tasks-CjrS098O.js} +4928 -2389
  59. package/dist/thread-state-CqkYowEz.js +184 -0
  60. package/dist/{turn-failure-response-CWx7aNIh.js → turn-failure-response-BkKmGqFt.js} +8 -9
  61. package/dist/{turn-lifecycle-C9JFst7-.js → turn-lifecycle-DYv8IV6w.js} +1 -1
  62. package/dist/{turn-session-routing-CUxtfpr7.js → turn-session-routing-TaVhKmdz.js} +1 -1
  63. package/dist/{validation-BHRxa5G4.js → validation-BrXMYPyo.js} +1 -1
  64. package/dist/{version-C0U6rHg0.js → version-Ct049vav.js} +1 -1
  65. package/dist/version.js +1 -1
  66. package/dist/{viewer-CGvvRqKp.js → viewer-C-J0ewlH.js} +19 -10
  67. package/dist/{web-input-Keb5GRWj.js → web-input-C_xB3RXp.js} +41 -37
  68. package/dist/{work-DRcsJ3hV.js → work-D829Ue7k.js} +9 -10
  69. package/dist/{worker-Cjo-QqPq.js → worker-BRTYzlpk.js} +5 -5
  70. package/migrations/0061_workspace_vcpus.sql +1 -0
  71. package/migrations/meta/0061_snapshot.json +3471 -0
  72. package/migrations/meta/_journal.json +7 -0
  73. package/package.json +6 -6
  74. package/dist/experimental-BNK1l1jv.js +0 -49
  75. package/dist/oauth-authorization-djQn5Nhy.js +0 -97
  76. package/dist/pending-auth-D8J1uJUS.js +0 -442
  77. package/dist/thread-state-W3f6kAtz.js +0 -426
@@ -0,0 +1,184 @@
1
+ import { Q as persistConversationMessages, er as createDurableLocationConfigurationService } from "./tasks-CjrS098O.js";
2
+ import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-DSMmkHXG.js";
3
+ import { d as getDb } from "./viewer-C-J0ewlH.js";
4
+ import { gt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-V4Hfc2tB.js";
5
+ import { r as getStateAdapter } from "./adapter-Dj5BTJRd.js";
6
+ // src/chat/state/conversation.ts
7
+ function defaultConversationState() {
8
+ return {
9
+ schemaVersion: 1,
10
+ messages: [],
11
+ compactions: [],
12
+ processing: {},
13
+ vision: { byFileId: {} }
14
+ };
15
+ }
16
+ function coercePendingAuthState(value) {
17
+ if (!isRecord(value)) return;
18
+ const kind = value.kind;
19
+ const provider = toOptionalString(value.provider);
20
+ const actorId = toOptionalString(value.actorId);
21
+ const authSessionId = toOptionalString(value.authSessionId);
22
+ const scope = toOptionalString(value.scope);
23
+ const sessionId = toOptionalString(value.sessionId);
24
+ const linkSentAtMs = toOptionalNumber(value.linkSentAtMs);
25
+ if (kind !== "mcp" && kind !== "plugin" || !provider || !actorId || kind === "mcp" && !authSessionId || !sessionId || typeof linkSentAtMs !== "number") return;
26
+ const base = {
27
+ provider,
28
+ actorId,
29
+ ...scope ? { scope } : void 0,
30
+ sessionId,
31
+ linkSentAtMs
32
+ };
33
+ return kind === "mcp" ? {
34
+ ...base,
35
+ authSessionId,
36
+ kind
37
+ } : {
38
+ ...base,
39
+ kind
40
+ };
41
+ }
42
+ /** Safely coerce an unknown persisted value into a ThreadConversationState. */
43
+ function coerceThreadConversationState(value) {
44
+ if (!isRecord(value)) return defaultConversationState();
45
+ const root = value;
46
+ const rawConversation = isRecord(root.conversation) ? root.conversation : {};
47
+ const messages = [];
48
+ const compactions = [];
49
+ const rawProcessing = isRecord(rawConversation.processing) ? rawConversation.processing : {};
50
+ const processing = {
51
+ activeTurnId: toOptionalString(rawProcessing.activeTurnId),
52
+ lastCompletedAtMs: toOptionalNumber(rawProcessing.lastCompletedAtMs),
53
+ pendingAuth: coercePendingAuthState(rawProcessing.pendingAuth)
54
+ };
55
+ const rawVision = isRecord(rawConversation.vision) ? rawConversation.vision : {};
56
+ const rawVisionByFileId = isRecord(rawVision.byFileId) ? rawVision.byFileId : {};
57
+ const byFileId = {};
58
+ for (const [fileId, value] of Object.entries(rawVisionByFileId)) {
59
+ if (typeof fileId !== "string" || fileId.trim().length === 0) continue;
60
+ if (!isRecord(value)) continue;
61
+ const summary = toOptionalString(value.summary);
62
+ const analyzedAtMs = toOptionalNumber(value.analyzedAtMs);
63
+ if (!summary || !analyzedAtMs) continue;
64
+ byFileId[fileId] = {
65
+ summary,
66
+ analyzedAtMs
67
+ };
68
+ }
69
+ return {
70
+ schemaVersion: 1,
71
+ messages,
72
+ compactions,
73
+ processing,
74
+ vision: {
75
+ backfillCompletedAtMs: toOptionalNumber(rawVision.backfillCompletedAtMs),
76
+ byFileId
77
+ }
78
+ };
79
+ }
80
+ /**
81
+ * Wrap active conversation control into the thread scratch envelope.
82
+ *
83
+ * Visible history lives in SQL. Image summaries use a separate disposable
84
+ * cache, so thread scratch does not retain them.
85
+ */
86
+ function buildConversationStatePatch(conversation) {
87
+ return { conversation: {
88
+ schemaVersion: 1,
89
+ processing: { ...conversation.processing }
90
+ } };
91
+ }
92
+ // src/chat/runtime/thread-state.ts
93
+ function threadStateKey(threadId) {
94
+ return `thread-state:${threadId}`;
95
+ }
96
+ function channelStateKey(channelId) {
97
+ return `channel-state:${channelId}`;
98
+ }
99
+ function buildThreadStatePayload(patch) {
100
+ const payload = {};
101
+ if (patch.conversation) Object.assign(payload, buildConversationStatePatch(patch.conversation));
102
+ if (patch.sandboxRef !== void 0) {
103
+ payload.app_sandbox_id = patch.sandboxRef?.id ?? "";
104
+ payload.app_sandbox_dependency_profile_hash = patch.sandboxRef?.profileHash ?? "";
105
+ payload.app_sandbox_workspace_id = patch.sandboxRef?.workspaceId ?? "";
106
+ }
107
+ return payload;
108
+ }
109
+ /**
110
+ * Merge a payload into thread scratch with Junior's TTL.
111
+ *
112
+ * Chat SDK state writes hardcode a 30-day TTL. This boundary owns Junior's
113
+ * shorter retention policy for the same scratch keys.
114
+ */
115
+ async function mergePersistedState(key, payload) {
116
+ if (Object.keys(payload).length === 0) return;
117
+ const stateAdapter = getStateAdapter();
118
+ await stateAdapter.connect();
119
+ const existing = await stateAdapter.get(key) ?? {};
120
+ await stateAdapter.set(key, {
121
+ ...existing,
122
+ ...payload
123
+ }, JUNIOR_THREAD_STATE_TTL_MS);
124
+ }
125
+ /** Extract persisted sandbox metadata from thread state payload. */
126
+ function getPersistedSandboxState(state) {
127
+ const id = toOptionalString(state.app_sandbox_id);
128
+ if (!id) return;
129
+ const profileHash = toOptionalString(state.app_sandbox_dependency_profile_hash);
130
+ const workspaceId = toOptionalString(state.app_sandbox_workspace_id);
131
+ return {
132
+ id,
133
+ ...profileHash ? { profileHash } : void 0,
134
+ ...workspaceId ? { workspaceId } : void 0
135
+ };
136
+ }
137
+ /** Persist a thread-state patch for a Chat thread handle. */
138
+ async function persistThreadState(thread, patch) {
139
+ if (patch.conversation) await persistConversationMessages({
140
+ conversation: patch.conversation,
141
+ conversationId: toOptionalString(thread.id) ?? toOptionalString(thread.runId)
142
+ });
143
+ await persistThreadRuntimeState(thread, patch);
144
+ }
145
+ /** Persist only the Redis-backed runtime scratch in a thread-state patch. */
146
+ async function persistThreadRuntimeState(thread, patch) {
147
+ const threadId = toOptionalString(thread.id) ?? toOptionalString(thread.runId);
148
+ if (!threadId) throw new Error("thread id is required to persist runtime scratch");
149
+ await mergePersistedState(threadStateKey(threadId), buildThreadStatePayload(patch));
150
+ }
151
+ /** Load the persisted state payload for a thread without requiring a Chat singleton. */
152
+ async function getPersistedThreadState(threadId) {
153
+ const stateAdapter = getStateAdapter();
154
+ await stateAdapter.connect();
155
+ return await stateAdapter.get(threadStateKey(threadId)) ?? {};
156
+ }
157
+ /** Persist a thread-state patch by thread id without constructing a Chat thread. */
158
+ async function persistThreadStateById(threadId, patch) {
159
+ if (patch.conversation) await persistConversationMessages({
160
+ conversation: patch.conversation,
161
+ conversationId: threadId
162
+ });
163
+ await mergePersistedState(threadStateKey(threadId), buildThreadStatePayload(patch));
164
+ }
165
+ /** Load legacy Redis-backed channel state during the SQL cutover. */
166
+ async function getLegacyChannelState(channelId) {
167
+ const stateAdapter = getStateAdapter();
168
+ await stateAdapter.connect();
169
+ return await stateAdapter.get(channelStateKey(channelId)) ?? {};
170
+ }
171
+ /**
172
+ * Resolve durable location configuration.
173
+ *
174
+ * Slack still reads the old channel-id Redis bag once during cutover.
175
+ */
176
+ function getLocationConfigurationService(destination) {
177
+ if (destination.platform !== "slack") throw new Error("Location configuration requires a Slack Location");
178
+ return createDurableLocationConfigurationService({
179
+ destination,
180
+ db: getDb(),
181
+ loadLegacy: async () => await getLegacyChannelState(destination.channelId)
182
+ });
183
+ }
184
+ export { persistThreadState as a, persistThreadRuntimeState as i, getPersistedSandboxState as n, persistThreadStateById as o, getPersistedThreadState as r, coerceThreadConversationState as s, getLocationConfigurationService as t };
@@ -1,13 +1,12 @@
1
- import { _ as getProviderErrorUserMessage, g as getProviderErrorAttributes, h as findProviderError, p as ProviderError } from "./client-DbyHuMFU.js";
2
- import { t as buildTurnFailureResponse, z as isRecord } from "./logging-DsHONhVm.js";
1
+ import { Tt as clearPendingAuth, Z as hydrateConversationMessages, dt as markConversationMessage, sn as buildDeterministicTurnId } from "./tasks-CjrS098O.js";
2
+ import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-JeyzRwsT.js";
3
+ import { t as buildTurnFailureResponse, z as isRecord } from "./logging-DSMmkHXG.js";
3
4
  import { g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
4
- import { c as getConversationEventStore, d as getDb } from "./viewer-CGvvRqKp.js";
5
- import { Wt as hydrateConversationMessages, in as markConversationMessage } from "./tasks-CEXKTASS.js";
6
- import { Nt as listConversationAnnotations } from "./agent-hooks-BJ_5mlRH.js";
7
- import { J as removedCardSchema, Y as resolveMessageCards, q as readMessageCardRefs } from "./conversation-DjN3mlog.js";
8
- import { d as buildDeterministicTurnId, r as clearPendingAuth } from "./pending-auth-D8J1uJUS.js";
9
- import { d as markTurnCompleted, u as markTurnClosed } from "./oauth-authorization-djQn5Nhy.js";
10
- import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-W3f6kAtz.js";
5
+ import { c as getConversationEventStore, d as getDb } from "./viewer-C-J0ewlH.js";
6
+ import { Ft as markTurnCompleted, Pt as markTurnClosed } from "./agent-runner-DvTUyGTY.js";
7
+ import { Gt as listConversationAnnotations } from "./agent-hooks-V4Hfc2tB.js";
8
+ import { F as readMessageCardRefs, I as removedCardSchema, L as resolveMessageCards } from "./conversation-CvuKJ3tA.js";
9
+ import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-CqkYowEz.js";
11
10
  // src/chat/conversations/pending-cards.ts
12
11
  /** Select undelivered cards and load their latest saved facts. */
13
12
  async function loadPendingMessageCards(conversationId) {
@@ -1,4 +1,4 @@
1
- import { c as getConversationEventStore } from "./viewer-CGvvRqKp.js";
1
+ import { c as getConversationEventStore } from "./viewer-C-J0ewlH.js";
2
2
  // src/chat/conversations/turn-lifecycle.ts
3
3
  /** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
4
4
  var ConversationTurnLifecycleService = class {
@@ -34,7 +34,7 @@ function slackSourceForDestination(args) {
34
34
  * Reads parent Conversations when this Conversation has no Destination.
35
35
  */
36
36
  async function resolveConversationRouting(args) {
37
- const conversationStore = args.conversationStore ?? (await import("./viewer-CGvvRqKp.js").then((n) => n.s)).getConversationStore();
37
+ const conversationStore = args.conversationStore ?? (await import("./viewer-C-J0ewlH.js").then((n) => n.s)).getConversationStore();
38
38
  const chain = await loadConversationChain(args.conversationId, conversationStore);
39
39
  let destination;
40
40
  let source;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-BN4DVxco.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-Bpcs2b2L.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  // src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.258.0";
2
+ var version = "0.260.0";
3
3
  // src/version.ts
4
4
  /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
5
5
  const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export { t as JUNIOR_VERSION } from "./version-C0U6rHg0.js";
1
+ export { t as JUNIOR_VERSION } from "./version-Ct049vav.js";
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-DsHONhVm.js";
3
- import { i as getChatConfig } from "./config-_WO_AjCB.js";
2
+ import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-DSMmkHXG.js";
3
+ import { i as getChatConfig } from "./config-ULs6Zl9b.js";
4
4
  import { d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-tlxzqaRe.js";
5
5
  import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-Qfz7dWgU.js";
6
- import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-RvG6kVe1.js";
6
+ import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-BoGNVEDn.js";
7
7
  import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-AY8rs-FR.js";
8
8
  import { randomUUID } from "node:crypto";
9
9
  import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
@@ -1067,14 +1067,23 @@ function readAuthor(meta) {
1067
1067
  }
1068
1068
  /** Read the Slack workspace that owns a conversation, when it has one. */
1069
1069
  async function loadConversationSlackTenantId(executor, conversationId) {
1070
- const [row] = await executor.db().select({
1070
+ return (await loadConversationSlackTenantIds(executor, [conversationId])).get(conversationId);
1071
+ }
1072
+ /** Read the Slack workspace that owns each conversation, with one query. */
1073
+ async function loadConversationSlackTenantIds(executor, conversationIds) {
1074
+ if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
1075
+ const rows = await executor.db().select({
1076
+ conversationId: juniorConversations.conversationId,
1071
1077
  providerTenantId: juniorDestinations.providerTenantId,
1072
1078
  sessionSource: juniorConversations.sessionSource
1073
- }).from(juniorConversations).leftJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).where(eq(juniorConversations.conversationId, conversationId)).limit(1);
1074
- const destinationTenant = row?.providerTenantId?.trim();
1075
- if (destinationTenant) return destinationTenant;
1076
- const sessionSource = parseSessionSource(row?.sessionSource);
1077
- if (sessionSource?.kind === "slack") return sessionSource.teamId;
1079
+ }).from(juniorConversations).leftJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).where(inArray(juniorConversations.conversationId, [...conversationIds]));
1080
+ const tenants = /* @__PURE__ */ new Map();
1081
+ for (const row of rows) {
1082
+ const sessionSource = parseSessionSource(row.sessionSource);
1083
+ const tenantId = row.providerTenantId?.trim() || (sessionSource?.kind === "slack" ? sessionSource.teamId : void 0);
1084
+ if (tenantId) tenants.set(row.conversationId, tenantId);
1085
+ }
1086
+ return tenants;
1078
1087
  }
1079
1088
  async function findIdentityIdByProviderSubject(executor, args) {
1080
1089
  return (await executor.db().select({ id: juniorIdentities.id }).from(juniorIdentities).where(and(eq(juniorIdentities.provider, args.provider), eq(juniorIdentities.providerSubjectId, args.providerSubjectId), args.providerTenantId === void 0 ? void 0 : eq(juniorIdentities.providerTenantId, args.providerTenantId))).limit(1))[0]?.id;
@@ -1637,4 +1646,4 @@ async function readActorIdentityFromSql(db, actor) {
1637
1646
  async function readActorIdentity(actor) {
1638
1647
  return await readActorIdentityFromSql(getDb(), actor);
1639
1648
  }
1640
- export { deleteProviderIdentityForUser as A, sameDestination as B, addAgentTurnUsage as C, hasAgentTurnUsage as D, agentTurnUsageSchema as E, upsertIdentity as F, upsertLinkedIdentity as I, createSlackDestination as L, readUserTimezone as M, recordGoogleSignIn as N, resolveRootConversationId as O, saveUserTimezone as P, parseDestination as R, parseSessionSource as S, agentTurnTotalTokens as T, withConversationMutationLock as _, setUserAdminFromSql as a, identityFromActor as b, getConversationEventStore as c, getDb as d, getSqlExecutor as f, createSqlStore as g, loadConversationSlackTenantId as h, resolveViewerUser as i, findUserByVerifiedEmails as j, deleteProviderIdentityForSlackUser as k, getConversationMessageSearchStore as l, withConversationEventLock as m, listAdminUsersFromSql as n, updateViewerDisplayName as o, createSqlConversationEventStore as p, readActorIdentity as r, db_exports as s, findUserByEmail as t, getConversationStore as u, locationFromRow as v, agentTurnCostUsd as w, bindProviderConversation as x, startLocationThread as y, requireSlackDestination as z };
1649
+ export { deleteProviderIdentityForUser as A, sameDestination as B, addAgentTurnUsage as C, hasAgentTurnUsage as D, agentTurnUsageSchema as E, upsertIdentity as F, upsertLinkedIdentity as I, createSlackDestination as L, readUserTimezone as M, recordGoogleSignIn as N, resolveRootConversationId as O, saveUserTimezone as P, parseDestination as R, parseSessionSource as S, agentTurnTotalTokens as T, withConversationMutationLock as _, setUserAdminFromSql as a, identityFromActor as b, getConversationEventStore as c, getDb as d, getSqlExecutor as f, createSqlStore as g, loadConversationSlackTenantIds as h, resolveViewerUser as i, findUserByVerifiedEmails as j, deleteProviderIdentityForSlackUser as k, getConversationMessageSearchStore as l, withConversationEventLock as m, listAdminUsersFromSql as n, updateViewerDisplayName as o, createSqlConversationEventStore as p, readActorIdentity as r, db_exports as s, findUserByEmail as t, getConversationStore as u, locationFromRow as v, agentTurnCostUsd as w, bindProviderConversation as x, startLocationThread as y, requireSlackDestination as z };
@@ -1,39 +1,36 @@
1
- import { A as resolveSlackChannelIdFromMessage, B as effectiveTaskOutcomes, Bt as RetryableDeliveryError, C as renderBlockText, D as storeAttachment, Gt as shouldEmitDevAgentTrace, Lt as createUserTokenStore, M as getConversationInfo, N as listThreadReplies, O as parseSlackThreadId, Rt as buildSteeringPiMessage, S as renderAttachmentText, Ut as AuthorizationFlowDisabledError, a as buildAuthPauseResponse, h as latestProgressStatus, j as resolveSlackChannelIdFromThreadId, k as readSlackRawMessageContext, m as PluginCredentialFailureError, n as executeAgentRun, r as createContextCompactor, t as createAgentRunner, z as eventAutomationTriggerAvailable, zt as withoutSavedSteeringMessages } from "./agent-runner-DGsFQw72.js";
2
- import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client-DbyHuMFU.js";
3
- import { B as toOptionalNumber, T as withSpan, V as toOptionalString, d as logError, f as logException, m as logWarn, n as createChatSdkLogger, o as getActiveTraceId, p as logInfo, t as buildTurnFailureResponse, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord } from "./logging-DsHONhVm.js";
4
- import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-_WO_AjCB.js";
1
+ import { At as saveTurnCheckpoint, Bn as normalizeSlackReplyMarkdown, Dt as wasPendingAuthStopped, E as sameDefinitionValue, Ft as listTurnSummaries, I as loadProjection, It as recordTurnSummary, Jn as removeReactionFromMessage, M as commitMessages, Mt as completeTurnRecord, Nt as failTurnRecord, P as loadConversationProjection, Pt as getTurnRecord, Q as persistConversationMessages, Rn as escapeSlackMrkdwnText, S as automationDefinition, Tt as clearPendingAuth, U as recordAuthorizationCompleted, Un as truncateStatusText, Vn as normalizeSlackStatusText, Vt as buildTurnErrorResponse, Wn as addReactionToMessage, Wt as persistWithRetry, Z as hydrateConversationMessages, _ as parseEventAutomationRow, _n as isExperimentalFeatureEnabled, _t as PluginCredentialFailureError, at as appendThreadContextMessages, bn as createUserTokenStore, c as withScheduledAutomationLock, ct as estimateConversationContextTokens, dn as getThreadStopDecision, dt as markConversationMessage, et as persistConversationMessageSummaries, f as deleteEventAutomation, ft as normalizeConversationText, h as listDeletedEventAutomationsCreatedBy, ht as upsertConversationMessage, i as readScheduledAutomation, in as trimTrailingAssistantMessages, j as commitAcceptedReply, jt as abandonTurnRecord, kt as loadTurnCheckpoint, ln as decideSubscribedThreadReply, lt as getConversationMessageSlackTs, mt as turnHasReply, o as saveScheduledAutomationInLock, on as buildDeterministicAssistantMessageId, ot as buildConversationContext, pt as recordDeliveredAssistantMessage, q as recordSubscribedReplyRoute, qn as postSlackMessage, r as parseScheduledAutomationRow, rt as fallbackShortTitle, sn as buildDeterministicTurnId, st as createConversationMemoryService, tr as configValueSchema, tt as resolveConversationTitle, un as getSubscribedReplyPreflightDecision, ut as isHumanConversationMessage, w as listAutomationVersions, xt as AuthorizationFlowDisabledError, zn as formatSlackLink } from "./tasks-CjrS098O.js";
2
+ import { a as completeText, p as escapeXml, r as completeDecision, y as isProviderRetryError } from "./client-JeyzRwsT.js";
3
+ import { B as toOptionalNumber, T as withSpan, V as toOptionalString, d as logError, f as logException, m as logWarn, n as createChatSdkLogger, o as getActiveTraceId, p as logInfo, t as buildTurnFailureResponse, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord } from "./logging-DSMmkHXG.js";
4
+ import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-ULs6Zl9b.js";
5
5
  import { o as modelIdForProfile, r as defaultModelId } from "./model-profile-Bg8EoCKD.js";
6
6
  import { a as isUserActor, g as parseSlackMessageTs, i as isActorUserId, l as parseSlackChannelId, n as createSlackActor, o as parseActorUserId, r as createSlackResumeActor, t as createActor } from "./actor-tlxzqaRe.js";
7
- import { L as createSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore, z as requireSlackDestination } from "./viewer-CGvvRqKp.js";
7
+ import { L as createSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore, z as requireSlackDestination } from "./viewer-C-J0ewlH.js";
8
8
  import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-Qfz7dWgU.js";
9
- import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-RvG6kVe1.js";
9
+ import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-BoGNVEDn.js";
10
10
  import { p as instructionProvenanceFor } from "./history-AY8rs-FR.js";
11
- import { d as actorLogContext, f as credentialContextForActor } from "./registry-Du566MtJ.js";
12
- import { $ as recordTurnSummary, $t as buildConversationContext, A as escapeSlackMrkdwnText, B as postSlackMessage, Bt as recordSubscribedReplyRoute, Dt as loadConversationProjection, E as sameDefinitionValue, F as truncateStatusText, Gt as persistConversationMessages, I as addReactionToMessage, It as recordAuthorizationCompleted, J as abandonTurnRecord, Jt as resolveConversationTitle, K as loadTurnCheckpoint, M as normalizeSlackReplyMarkdown, N as normalizeSlackStatusText, Q as listTurnSummaries, Qt as appendThreadContextMessages, S as automationDefinition, Tt as commitMessages, V as removeReactionFromMessage, Wt as hydrateConversationMessages, X as failTurnRecord, Xt as fallbackShortTitle, Y as completeTurnRecord, Z as getTurnRecord, _ as parseEventAutomationRow, an as normalizeConversationText, at as buildTurnErrorResponse, c as withScheduledAutomationLock, cn as upsertConversationMessage, en as createConversationMemoryService, et as persistWithRetry, f as deleteEventAutomation, h as listDeletedEventAutomationsCreatedBy, i as readScheduledAutomation, in as markConversationMessage, j as formatSlackLink, kt as loadProjection, nn as getConversationMessageSlackTs, o as saveScheduledAutomationInLock, on as recordDeliveredAssistantMessage, q as saveTurnCheckpoint, qt as persistConversationMessageSummaries, r as parseScheduledAutomationRow, rn as isHumanConversationMessage, sn as turnHasReply, tn as estimateConversationContextTokens, w as listAutomationVersions, wt as commitAcceptedReply, xt as trimTrailingAssistantMessages } from "./tasks-CEXKTASS.js";
13
- import { Et as getSlackFileId, Gt as normalizeSlackConversationId, Ht as getSlackClient, Kt as runWithSlackInstallationToken, Lt as lookupSlackUser, Ot as readAttachmentVisionSummary, Rt as SlackActionError, Tt as buildSentryConversationUrl, V as cancelSubscriptions, Vt as getHeaderString, Wt as isDmChannel, at as getDashboardConversationLink, it as JUNIOR_THREAD_STATE_TTL_MS, kt as recordSlackAttachment, o as getPluginSlackConversationLink, ot as getDashboardObjectIconLink, rt as verifyTimerWatchCredentialSubject, zt as downloadPrivateSlackFile } from "./agent-hooks-BJ_5mlRH.js";
14
- import { F as readMessageAttachments, R as isVisionImageMediaType } from "./conversation-DjN3mlog.js";
15
- import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-DpYjfKke.js";
16
- import { a as wasPendingAuthStopped, c as getSubscribedReplyPreflightDecision, d as buildDeterministicTurnId, l as getThreadStopDecision, r as clearPendingAuth, s as decideSubscribedThreadReply, u as buildDeterministicAssistantMessageId } from "./pending-auth-D8J1uJUS.js";
17
- import { a as TurnInputDeferredError, c as isTurnInputCommitLostError, d as markTurnCompleted, f as markTurnFailed, i as TurnInputCommitLostError, l as isTurnInputDeferredError, n as ConversationTurnBoundaryError, o as getConversationTurnBoundaryError, p as startActiveTurn, r as CooperativeTurnYieldError, s as isCooperativeTurnYieldError, u as markTurnClosed } from "./oauth-authorization-djQn5Nhy.js";
18
- import { n as getAssistantReplyText } from "./assistant-reply-H1M-91oF.js";
19
- import { A as maybePostAutomatedTurnLimitNotice, F as deliversFinalText, I as finishedRunReply, c as timerWatchCredentialSubject, i as skipInputBeforeConversationStop, j as recordFinishedTurnForAutomatedLimit, l as getEventCatalog, s as isEventMailboxMetadata, y as automationEventCatalog, z as runDispatchOutcome } from "./session-stop-CIoFiwwe.js";
20
- import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-xgpyMtg7.js";
21
- import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-DVe37it2.js";
22
- import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-DJLwq4x8.js";
23
- import { l as automationListQuerySchema } from "./automation-DWBFBenG.js";
24
- import { r as isExperimentalFeatureEnabled } from "./experimental-BNK1l1jv.js";
11
+ import { d as actorLogContext, f as credentialContextForActor } from "./registry-BL-osYWN.js";
12
+ import { A as listThreadReplies, At as getConversationTurnBoundaryError, D as resolveSlackChannelIdFromMessage, Dt as CooperativeTurnYieldError, E as readSlackRawMessageContext, Et as ConversationTurnBoundaryError, Ft as markTurnCompleted, I as eventAutomationTriggerAvailable, It as markTurnFailed, L as effectiveTaskOutcomes, Lt as startActiveTurn, Mt as isTurnInputCommitLostError, Nt as isTurnInputDeferredError, O as resolveSlackChannelIdFromThreadId, Ot as TurnInputCommitLostError, Pt as markTurnClosed, Rt as shouldEmitDevAgentTrace, St as RetryableDeliveryError, T as parseSlackThreadId, b as renderBlockText, bt as buildSteeringPiMessage, i as buildAuthPauseResponse, jt as isCooperativeTurnYieldError, k as getConversationInfo, kt as TurnInputDeferredError, n as executeAgentRun, p as latestProgressStatus, r as createContextCompactor, t as createAgentRunner, w as storeAttachment, xt as withoutSavedSteeringMessages, y as renderAttachmentText } from "./agent-runner-DvTUyGTY.js";
13
+ import { Bt as readAttachmentVisionSummary, Lt as buildSentryConversationUrl, Rt as getSlackFileId, V as cancelSubscriptions, Vt as recordSlackAttachment, Yt as lookupSlackUser, _t as getDashboardConversationLink, at as downloadPrivateSlackFile, ct as getSlackClient, dt as normalizeSlackConversationId, ft as runWithSlackInstallationToken, gt as JUNIOR_THREAD_STATE_TTL_MS, it as SlackActionError, o as getPluginSlackConversationLink, rt as verifyTimerWatchCredentialSubject, st as getHeaderString, ut as isDmChannel, vt as getDashboardObjectIconLink } from "./agent-hooks-V4Hfc2tB.js";
14
+ import { B as readMessageAttachments, U as isVisionImageMediaType } from "./conversation-CvuKJ3tA.js";
15
+ import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-DeVax2qO.js";
16
+ import { a as acquireActiveLock, i as MUTATION_LOCK_TTL_MS, r as getStateAdapter, s as withLock } from "./adapter-Dj5BTJRd.js";
17
+ import { n as getAssistantReplyText } from "./assistant-reply-CEOMzsWy.js";
18
+ import { H as runDispatchOutcome, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit, R as deliversFinalText, c as isEventMailboxMetadata, d as getEventCatalog, i as skipInputBeforeConversationStop, j as joinMailboxText, l as renderEventBatchText, s as eventBatchMessageEvents, u as timerWatchCredentialSubject, x as automationEventCatalog, z as finishedRunReply } from "./session-stop-HfKx-pky.js";
19
+ import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-CbdVyaCo.js";
20
+ import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-DzRbd5VT.js";
21
+ import { l as automationListQuerySchema } from "./automation-DrpcA-SX.js";
25
22
  import { c as sumUtcHoursIntoSixHours, m as healthReportSchema, t as webMessageId } from "./web-message-id-CJSUiksE.js";
26
- import { A as readAutomationExecutions, D as readAutomationExecutionStatusDays, E as readAutomationExecutionHours, O as readAutomationExecutionStatusHours, S as emptyAutomationRunWindows, T as readAutomationExecutionDays, _ as markDispatchBlocked, a as claimDispatchMailboxAppend, b as markDispatchRunning, c as getDispatchConversationId, d as getDispatchRecord, f as getDispatchTurnId, g as markDispatchAwaitingResume, j as readAutomationRuns, k as readAutomationExecutionSummaries, l as getDispatchIdForConversation, m as isTerminalDispatchStatus, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, t as processPluginTask, u as getDispatchInputMessageId, v as markDispatchCompleted, w as readAutomationExecutionByConversationId, y as markDispatchFailed } from "./task-runner-D3qJh4fK.js";
27
- import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, f as joinMailboxText, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-BBbKA61B.js";
28
- import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-C9JFst7-.js";
29
- import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-DRcsJ3hV.js";
30
- import { a as persistThreadState, c as configValueSchema, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-W3f6kAtz.js";
31
- import { c as deleteWebAuthorization, d as getPausedTurnRequest, m as getTurnAuthorization, p as wakePausedTurn, s as createWebAuthorization, u as createPausedTurns } from "./connections-ag_1JOhB.js";
32
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-CUxtfpr7.js";
33
- import { t as bindMessageAgent } from "./message-DyitL8no.js";
34
- import { t as bindSpawnAgent } from "./spawn-Dqfeo7XP.js";
35
- import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-CWx7aNIh.js";
36
- import { r as storeInputImages } from "./images-C2J_bj2g.js";
23
+ import { A as readAutomationExecutions, D as readAutomationExecutionStatusDays, E as readAutomationExecutionHours, O as readAutomationExecutionStatusHours, S as emptyAutomationRunWindows, T as readAutomationExecutionDays, _ as markDispatchBlocked, a as claimDispatchMailboxAppend, b as markDispatchRunning, c as getDispatchConversationId, d as getDispatchRecord, f as getDispatchTurnId, g as markDispatchAwaitingResume, j as readAutomationRuns, k as readAutomationExecutionSummaries, l as getDispatchIdForConversation, m as isTerminalDispatchStatus, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, t as processPluginTask, u as getDispatchInputMessageId, v as markDispatchCompleted, w as readAutomationExecutionByConversationId, y as markDispatchFailed } from "./task-runner-DGnd_B5X.js";
24
+ import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-DS7V4a3-.js";
25
+ import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-DYv8IV6w.js";
26
+ import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-D829Ue7k.js";
27
+ import { a as persistThreadState, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-CqkYowEz.js";
28
+ import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-CZ7HhEmN.js";
29
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-TaVhKmdz.js";
30
+ import { t as bindMessageAgent } from "./message-zaj5gBbS.js";
31
+ import { t as bindSpawnAgent } from "./spawn-BWqK6EwM.js";
32
+ import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-BkKmGqFt.js";
33
+ import { r as storeInputImages } from "./images-BBmDXQCB.js";
37
34
  import { z } from "zod";
38
35
  import { createHash } from "node:crypto";
39
36
  import { and, asc, count, desc, eq, exists, inArray, ne, or, sql } from "drizzle-orm";
@@ -3353,9 +3350,9 @@ function createSubscribedReplyPolicy(deps) {
3353
3350
  return async (args) => {
3354
3351
  const decision = await decideSubscribedThreadReply({
3355
3352
  botUserName: botConfig.userName,
3356
- modelId: botConfig.fastModelId,
3353
+ modelId: botConfig.decisionModelId,
3357
3354
  input: args,
3358
- completeObject: deps.completeObject,
3355
+ completeDecision: deps.completeDecision,
3359
3356
  logClassifierFailure: (error) => {
3360
3357
  logWarn("subscribed_message.classifier.failed", { "exception.message": error instanceof Error ? error.message : String(error) });
3361
3358
  }
@@ -3391,7 +3388,7 @@ function createJuniorRuntimeServices(overrides = {}) {
3391
3388
  conversationMemory,
3392
3389
  contextCompactor,
3393
3390
  executeTurn: async (run, saveResult) => await executeTurn(agentRunner, run, saveResult),
3394
- subscribedReplyPolicy: createSubscribedReplyPolicy({ completeObject: overrides.subscribedReplyPolicy?.completeObject ?? completeObject }),
3391
+ subscribedReplyPolicy: createSubscribedReplyPolicy({ completeDecision: overrides.subscribedReplyPolicy?.completeDecision ?? completeDecision }),
3395
3392
  visionContext
3396
3393
  };
3397
3394
  }
@@ -6596,6 +6593,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
6596
6593
  let startedAtMs = Date.now();
6597
6594
  let inputMessageIds = [];
6598
6595
  let event;
6596
+ let batchEvents = [];
6599
6597
  const storedConversation = await getConversationStore().get({ conversationId: context.conversationId });
6600
6598
  const mailboxDestination = resolved.kind === "mailbox" ? resolved.batch[0]?.message.destination : void 0;
6601
6599
  const destination = resolveConversationDestination({
@@ -6604,14 +6602,19 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
6604
6602
  });
6605
6603
  if (resolved.kind === "mailbox") {
6606
6604
  const first = resolved.batch[0];
6607
- text = joinMailboxText(resolved.batch.map((entry) => entry.message));
6605
+ const messages = resolved.batch.map((entry) => entry.message);
6606
+ const firstMetadata = first.message.input.metadata;
6607
+ if (isEventMailboxMetadata(firstMetadata)) {
6608
+ text = renderEventBatchText(messages);
6609
+ event = firstMetadata.event;
6610
+ batchEvents = eventBatchMessageEvents(messages);
6611
+ } else text = joinMailboxText(messages);
6608
6612
  attachments = resolved.batch.flatMap((entry) => readMessageAttachments(entry.message.input.attachments));
6609
6613
  startedAtMs = first.message.createdAtMs;
6610
6614
  userMessageId = first.message.inboundMessageId;
6611
6615
  turnId = buildDeterministicTurnId(userMessageId);
6612
6616
  inputMessageIds = resolved.batch.map((entry) => entry.message.inboundMessageId);
6613
6617
  turnInputFacts = first;
6614
- if (isEventMailboxMetadata(first.message.input.metadata)) event = first.message.input.metadata.event;
6615
6618
  } else turnId = resolved.turnId;
6616
6619
  const persisted = await getPersistedThreadState(context.conversationId);
6617
6620
  const conversation = coerceThreadConversationState(persisted);
@@ -6705,7 +6708,8 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
6705
6708
  ...event ? {
6706
6709
  eventType: event.eventType,
6707
6710
  eventObjectType: event.objectType,
6708
- ...event.trustedSummary ? { trustedSummary: event.trustedSummary } : void 0
6711
+ ...event.trustedSummary ? { trustedSummary: event.trustedSummary } : void 0,
6712
+ ...batchEvents.length > 1 ? { events: batchEvents } : void 0
6709
6713
  } : void 0
6710
6714
  }
6711
6715
  });
@@ -1,15 +1,14 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { $ as getAgentInvocation, G as recordSubagentStarted, H as stopChildAgentsOf, J as createAgentInvocation, Q as getActiveAgentInvocationForConversation, Rt as buildSteeringPiMessage, Ut as AuthorizationFlowDisabledError, W as recordSubagentEnded, Wt as readBlockedReport, at as getAgentInvocationTurnId, ct as isTerminalAgentInvocation, dt as markAgentInvocationMailboxAppended, gt as reportReplacedAgentInvocation, ht as markAgentInvocationSteered, m as PluginCredentialFailureError, mt as markAgentInvocationRunning, pt as markAgentInvocationPaused, q as completeAgentInvocation, rt as getAgentInvocationMessageId, st as getLatestAgentInvocationForConversation, zt as withoutSavedSteeringMessages } from "./agent-runner-DGsFQw72.js";
3
- import { n as botConfig } from "./config-_WO_AjCB.js";
4
- import { c as getConversationEventStore, u as getConversationStore } from "./viewer-CGvvRqKp.js";
2
+ import { At as saveTurnCheckpoint, Nt as failTurnRecord, Pt as getTurnRecord, Ut as isTurnExecutionLimitExceededError, _t as PluginCredentialFailureError, jt as abandonTurnRecord, qt as getTerminalAssistantMessages, xt as AuthorizationFlowDisabledError, z as openConversationProjection } from "./tasks-CjrS098O.js";
3
+ import { n as botConfig } from "./config-ULs6Zl9b.js";
4
+ import { c as getConversationEventStore, u as getConversationStore } from "./viewer-C-J0ewlH.js";
5
5
  import { m as sameActorIdentity, u as agentInstructionProvenance } from "./history-AY8rs-FR.js";
6
- import { J as abandonTurnRecord, Mt as openConversationProjection, X as failTurnRecord, Z as getTurnRecord, q as saveTurnCheckpoint, st as isTurnExecutionLimitExceededError, ut as getTerminalAssistantMessages } from "./tasks-CEXKTASS.js";
7
- import { c as isTurnInputCommitLostError, i as TurnInputCommitLostError, o as getConversationTurnBoundaryError } from "./oauth-authorization-djQn5Nhy.js";
8
- import { n as getAssistantReplyText } from "./assistant-reply-H1M-91oF.js";
9
- import { A as maybePostAutomatedTurnLimitNotice, M as resetAutomatedTurnLimit, j as recordFinishedTurnForAutomatedLimit } from "./session-stop-CIoFiwwe.js";
10
- import { r as appendAndEnqueueInboundMessage } from "./store-DJLwq4x8.js";
11
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-C9JFst7-.js";
12
- import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-W3f6kAtz.js";
6
+ import { At as getConversationTurnBoundaryError, G as createAgentInvocation, H as recordSubagentStarted, Mt as isTurnInputCommitLostError, Ot as TurnInputCommitLostError, Tt as readBlockedReport, V as recordSubagentEnded, W as completeAgentInvocation, X as getAgentInvocation, Y as getActiveAgentInvocationForConversation, at as isTerminalAgentInvocation, bt as buildSteeringPiMessage, ct as markAgentInvocationMailboxAppended, dt as markAgentInvocationRunning, et as getAgentInvocationMessageId, ft as markAgentInvocationSteered, it as getLatestAgentInvocationForConversation, nt as getAgentInvocationTurnId, pt as reportReplacedAgentInvocation, ut as markAgentInvocationPaused, xt as withoutSavedSteeringMessages, z as stopChildAgentsOf } from "./agent-runner-DvTUyGTY.js";
7
+ import { n as getAssistantReplyText } from "./assistant-reply-CEOMzsWy.js";
8
+ import { F as resetAutomatedTurnLimit, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit } from "./session-stop-HfKx-pky.js";
9
+ import { r as appendAndEnqueueInboundMessage } from "./store-DzRbd5VT.js";
10
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DYv8IV6w.js";
11
+ import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-CqkYowEz.js";
13
12
  import { isDeepStrictEqual } from "node:util";
14
13
  import { z } from "zod";
15
14
  // src/chat/runtime/turn-execution.ts
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { v as isProviderRetryError } from "./client-DbyHuMFU.js";
3
- import { f as logException, m as logWarn, p as logInfo, w as withLogContext } from "./logging-DsHONhVm.js";
4
- import { i as getChatConfig } from "./config-_WO_AjCB.js";
5
- import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-DVe37it2.js";
6
- import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-DJLwq4x8.js";
2
+ import { y as isProviderRetryError } from "./client-JeyzRwsT.js";
3
+ import { f as logException, m as logWarn, p as logInfo, w as withLogContext } from "./logging-DSMmkHXG.js";
4
+ import { i as getChatConfig } from "./config-ULs6Zl9b.js";
5
+ import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-CbdVyaCo.js";
6
+ import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-DzRbd5VT.js";
7
7
  // src/chat/task-execution/worker.ts
8
8
  var worker_exports = /* @__PURE__ */ __exportAll({
9
9
  CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
@@ -0,0 +1 @@
1
+ ALTER TABLE "junior_workspaces" ADD COLUMN "vcpus" integer;