@sentry/junior 0.131.0 → 0.133.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 (73) hide show
  1. package/dist/{agent-hooks-M5V454P5.js → agent-hooks-5BUIXVIX.js} +9 -9
  2. package/dist/api/conversations/list.d.ts +13 -2
  3. package/dist/api/schema/task.d.ts +0 -3
  4. package/dist/api/schema.js +1 -1
  5. package/dist/api.js +24 -23
  6. package/dist/app.js +84 -37
  7. package/dist/{catalog-runtime-PI2IFWZ5.js → catalog-runtime-VGB3DWXZ.js} +5 -5
  8. package/dist/chat/config.d.ts +2 -0
  9. package/dist/chat/conversations/location.d.ts +10 -0
  10. package/dist/chat/conversations/projection.d.ts +3 -1
  11. package/dist/chat/conversations/sql/bindings.d.ts +13 -0
  12. package/dist/chat/conversations/sql/location.d.ts +9 -0
  13. package/dist/chat/conversations/sql/store.d.ts +3 -0
  14. package/dist/chat/conversations/store.d.ts +17 -0
  15. package/dist/chat/runtime/reply-executor.d.ts +1 -0
  16. package/dist/chat/runtime/slack-runtime.d.ts +2 -0
  17. package/dist/chat/scheduled-tasks/tool-support.d.ts +2 -5
  18. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  19. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  20. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  21. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  22. package/dist/chat/scheduled-tasks/tools/update.d.ts +3 -3
  23. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  24. package/dist/chat/slack/dispatch-turn.d.ts +1 -0
  25. package/dist/chat/slack/reply.d.ts +1 -1
  26. package/dist/{chunk-UYYSD255.js → chunk-5ZAZHLIW.js} +1 -1
  27. package/dist/{chunk-JKHK3LM2.js → chunk-AH5HTUYX.js} +1 -1
  28. package/dist/{chunk-HZ5EVSPV.js → chunk-ECUILEUX.js} +24 -15
  29. package/dist/{chunk-HSPYTFMD.js → chunk-EJRJWBKG.js} +1 -1
  30. package/dist/{chunk-TD2A27ET.js → chunk-FX6BLEDP.js} +1 -1
  31. package/dist/{chunk-7Y2OKB5K.js → chunk-HJ4KDO4N.js} +1 -1
  32. package/dist/{chunk-DRFI6CW3.js → chunk-HTGXUNEC.js} +7 -7
  33. package/dist/{chunk-SVX4JDOR.js → chunk-IKO5LFIU.js} +1 -1
  34. package/dist/{chunk-J4I2GVGH.js → chunk-IVTHTAVK.js} +2 -2
  35. package/dist/{chunk-APUL3Y63.js → chunk-JLN4XSPR.js} +1 -1
  36. package/dist/{chunk-ZMIO64MA.js → chunk-LDRO4OQ4.js} +19 -3
  37. package/dist/{chunk-5ONXE2GF.js → chunk-LNYNTR27.js} +305 -235
  38. package/dist/{chunk-BVKP37NE.js → chunk-QVEXYYFM.js} +1 -1
  39. package/dist/{chunk-KB2M27DL.js → chunk-QWGZ273D.js} +78 -36
  40. package/dist/{chunk-TRKWWIB3.js → chunk-T5FPIBU2.js} +21 -21
  41. package/dist/{chunk-XXGCQCFJ.js → chunk-TBVS7GBE.js} +4 -4
  42. package/dist/{chunk-XMDY52DJ.js → chunk-TLN54TOQ.js} +1 -1
  43. package/dist/{chunk-VMPL77IK.js → chunk-TU7P77FI.js} +36 -24
  44. package/dist/{chunk-NGJEC4MF.js → chunk-V365UVCU.js} +2 -2
  45. package/dist/{chunk-KWYCUXJX.js → chunk-VL7OYSHD.js} +1 -1
  46. package/dist/{chunk-D6ZMP3FC.js → chunk-VQA25AL4.js} +6 -6
  47. package/dist/{chunk-MLIJGLW5.js → chunk-WHEMUEXT.js} +5 -5
  48. package/dist/{chunk-7X62XOC4.js → chunk-XTQGVNM3.js} +54 -19
  49. package/dist/cli/chat.js +24 -24
  50. package/dist/cli/check.js +6 -6
  51. package/dist/cli/init.js +1 -0
  52. package/dist/cli/plugins.js +12 -12
  53. package/dist/cli/snapshot-create.js +9 -9
  54. package/dist/cli/upgrade.js +9 -8
  55. package/dist/db/executor.d.ts +2 -1
  56. package/dist/db/neon.d.ts +1 -0
  57. package/dist/db/postgres.d.ts +1 -0
  58. package/dist/db/schema/conversation-bindings.d.ts +110 -0
  59. package/dist/db/schema.d.ts +111 -1
  60. package/dist/{db-5P6K3ZCM.js → db-RICMPUFT.js} +7 -7
  61. package/dist/instrumentation.js +4 -4
  62. package/dist/nitro.js +2 -2
  63. package/dist/{oauth-callback-server-RIMCKQZX.js → oauth-callback-server-YFVS4SAX.js} +17 -17
  64. package/dist/{runner-CAD3BVML.js → runner-A3LVGZR6.js} +11 -11
  65. package/dist/{skills-WVPCTBUT.js → skills-P7Q6Z6PN.js} +6 -6
  66. package/dist/{validation-GLEXIFFI.js → validation-RYHOWBET.js} +6 -6
  67. package/dist/version.js +1 -1
  68. package/migrations/0017_drop_paused_scheduled_tasks.sql +19 -0
  69. package/migrations/0018_curvy_excalibur.sql +12 -0
  70. package/migrations/meta/0017_snapshot.json +1666 -0
  71. package/migrations/meta/0018_snapshot.json +1756 -0
  72. package/migrations/meta/_journal.json +15 -1
  73. package/package.json +5 -5
@@ -11,19 +11,19 @@ import {
11
11
  getPlugins,
12
12
  setPlugins,
13
13
  validatePlugins
14
- } from "./chunk-MLIJGLW5.js";
15
- import "./chunk-5ONXE2GF.js";
16
- import "./chunk-KB2M27DL.js";
17
- import "./chunk-XMDY52DJ.js";
18
- import "./chunk-ZMIO64MA.js";
14
+ } from "./chunk-WHEMUEXT.js";
15
+ import "./chunk-LNYNTR27.js";
16
+ import "./chunk-QWGZ273D.js";
17
+ import "./chunk-TLN54TOQ.js";
18
+ import "./chunk-LDRO4OQ4.js";
19
19
  import "./chunk-VFUK3X5B.js";
20
- import "./chunk-KWYCUXJX.js";
20
+ import "./chunk-VL7OYSHD.js";
21
21
  import "./chunk-HZF5P5UN.js";
22
22
  import "./chunk-F3B2YJ76.js";
23
- import "./chunk-HSPYTFMD.js";
23
+ import "./chunk-EJRJWBKG.js";
24
24
  import "./chunk-6GWA276C.js";
25
- import "./chunk-TD2A27ET.js";
26
- import "./chunk-SVX4JDOR.js";
25
+ import "./chunk-FX6BLEDP.js";
26
+ import "./chunk-IKO5LFIU.js";
27
27
  import "./chunk-MLKGABMK.js";
28
28
  export {
29
29
  PluginHookDeniedError,
@@ -78,8 +78,19 @@ declare function conversationRows(db: JuniorDatabase, limit: number, actorEmail?
78
78
  metricRunId: string | null;
79
79
  archivedAt: Date | null;
80
80
  };
81
- destinationId: string | null;
82
- destinationVisibility: import("../../db/schema/destinations").JuniorDestinationVisibility | null;
81
+ destination: {
82
+ id: string;
83
+ provider: string;
84
+ providerTenantId: string;
85
+ providerDestinationId: string;
86
+ kind: "channel" | "dm" | "group" | "local_conversation" | "thread" | "web_session";
87
+ parentDestinationId: string | null;
88
+ displayName: string | null;
89
+ visibility: import("../../db/schema/destinations").JuniorDestinationVisibility;
90
+ metadata: unknown;
91
+ createdAt: Date;
92
+ updatedAt: Date;
93
+ } | null;
83
94
  identityDisplayName: string | null;
84
95
  identityEmail: string | null;
85
96
  identityHandle: string | null;
@@ -21,7 +21,6 @@ export declare const scheduledTaskSummarySchema: z.ZodObject<{
21
21
  status: z.ZodEnum<{
22
22
  blocked: "blocked";
23
23
  active: "active";
24
- paused: "paused";
25
24
  }>;
26
25
  }, z.core.$strict>;
27
26
  export declare const eventTaskSummarySchema: z.ZodObject<{
@@ -68,7 +67,6 @@ export declare const taskSummarySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
68
67
  status: z.ZodEnum<{
69
68
  blocked: "blocked";
70
69
  active: "active";
71
- paused: "paused";
72
70
  }>;
73
71
  }, z.core.$strict>, z.ZodObject<{
74
72
  createdAt: z.ZodString;
@@ -115,7 +113,6 @@ export declare const taskListSchema: z.ZodObject<{
115
113
  status: z.ZodEnum<{
116
114
  blocked: "blocked";
117
115
  active: "active";
118
- paused: "paused";
119
116
  }>;
120
117
  }, z.core.$strict>, z.ZodObject<{
121
118
  createdAt: z.ZodString;
@@ -37,7 +37,7 @@ import {
37
37
  taskListSchema,
38
38
  taskParamsSchema,
39
39
  taskSummarySchema
40
- } from "../chunk-BVKP37NE.js";
40
+ } from "../chunk-QVEXYYFM.js";
41
41
  import {
42
42
  healthReportSchema,
43
43
  pluginOperationalReportFeedSchema,
package/dist/api.js CHANGED
@@ -27,12 +27,12 @@ import {
27
27
  statsReportSchema,
28
28
  taskListSchema,
29
29
  taskParamsSchema
30
- } from "./chunk-BVKP37NE.js";
30
+ } from "./chunk-QVEXYYFM.js";
31
31
  import {
32
32
  formatSlackConversationRedactedLabel,
33
33
  readHealthReport,
34
34
  resolveSlackConversationContextFromThreadId
35
- } from "./chunk-NGJEC4MF.js";
35
+ } from "./chunk-V365UVCU.js";
36
36
  import {
37
37
  buildSentryConversationUrl
38
38
  } from "./chunk-4CODA7P5.js";
@@ -54,10 +54,10 @@ import {
54
54
  listPublicEventTasksForTeams,
55
55
  listPublicScheduledTasksForTeams,
56
56
  readStats
57
- } from "./chunk-7X62XOC4.js";
57
+ } from "./chunk-XTQGVNM3.js";
58
58
  import {
59
59
  parseSlackThreadId
60
- } from "./chunk-JKHK3LM2.js";
60
+ } from "./chunk-AH5HTUYX.js";
61
61
  import {
62
62
  agentTurnUsageSchema,
63
63
  hasAgentTurnUsage,
@@ -70,37 +70,38 @@ import {
70
70
  listConversationAnnotations,
71
71
  renderPluginConversationEvent,
72
72
  resolveViewerUser
73
- } from "./chunk-MLIJGLW5.js";
73
+ } from "./chunk-WHEMUEXT.js";
74
74
  import {
75
75
  decodeStoredConversationEvent,
76
76
  getDb,
77
77
  getSqlExecutor,
78
+ locationFromRow,
78
79
  parseSessionSource
79
- } from "./chunk-5ONXE2GF.js";
80
+ } from "./chunk-LNYNTR27.js";
80
81
  import {
81
82
  juniorApiTokens,
82
83
  juniorConversationEvents,
83
84
  juniorConversations,
84
85
  juniorIdentities,
85
86
  juniorUsers
86
- } from "./chunk-KB2M27DL.js";
87
- import "./chunk-XMDY52DJ.js";
88
- import "./chunk-ZMIO64MA.js";
87
+ } from "./chunk-QWGZ273D.js";
88
+ import "./chunk-TLN54TOQ.js";
89
+ import "./chunk-LDRO4OQ4.js";
89
90
  import {
90
91
  juniorDestinations
91
92
  } from "./chunk-VFUK3X5B.js";
92
93
  import {
93
94
  canExposeConversationPayload
94
- } from "./chunk-KWYCUXJX.js";
95
+ } from "./chunk-VL7OYSHD.js";
95
96
  import "./chunk-HZF5P5UN.js";
96
97
  import {
97
98
  parseSlackChannelId,
98
99
  parseSlackTeamId
99
100
  } from "./chunk-F3B2YJ76.js";
100
- import "./chunk-HSPYTFMD.js";
101
+ import "./chunk-EJRJWBKG.js";
101
102
  import "./chunk-6GWA276C.js";
102
- import "./chunk-TD2A27ET.js";
103
- import "./chunk-SVX4JDOR.js";
103
+ import "./chunk-FX6BLEDP.js";
104
+ import "./chunk-IKO5LFIU.js";
104
105
  import "./chunk-MLKGABMK.js";
105
106
 
106
107
  // src/api.ts
@@ -1316,8 +1317,7 @@ var CONVERSATION_FEED_LIMIT = 50;
1316
1317
  async function conversationRows(db, limit, actorEmail) {
1317
1318
  return db.select({
1318
1319
  conversation: juniorConversations,
1319
- destinationId: juniorDestinations.id,
1320
- destinationVisibility: juniorDestinations.visibility,
1320
+ destination: juniorDestinations,
1321
1321
  identityDisplayName: juniorIdentities.displayName,
1322
1322
  identityEmail: juniorIdentities.email,
1323
1323
  identityHandle: juniorIdentities.handle,
@@ -1360,6 +1360,7 @@ function conversationFromRow(row) {
1360
1360
  ...row.identityHandle ? { slackUserName: row.identityHandle } : {},
1361
1361
  ...row.identityTenantId ? { teamId: row.identityTenantId } : {}
1362
1362
  } : void 0;
1363
+ const location = locationFromRow(row.destination);
1363
1364
  return {
1364
1365
  schemaVersion: 1,
1365
1366
  conversationId: value.conversationId,
@@ -1372,6 +1373,7 @@ function conversationFromRow(row) {
1372
1373
  ...value.executionUpdatedAt ? { updatedAtMs: value.executionUpdatedAt.getTime() } : {}
1373
1374
  },
1374
1375
  ...actor ? { actor } : {},
1376
+ ...location ? { location } : {},
1375
1377
  ...value.archivedAt ? { archivedAtMs: value.archivedAt.getTime() } : {},
1376
1378
  ...value.channelName ? { channelName: value.channelName } : {},
1377
1379
  ...value.source ? { source: value.source } : {},
@@ -1384,8 +1386,7 @@ async function readConversationRecordFromSql(conversationId) {
1384
1386
  const db = getDb();
1385
1387
  const rows = await db.select({
1386
1388
  conversation: juniorConversations,
1387
- destinationId: juniorDestinations.id,
1388
- destinationVisibility: juniorDestinations.visibility,
1389
+ destination: juniorDestinations,
1389
1390
  identityDisplayName: juniorIdentities.displayName,
1390
1391
  identityEmail: juniorIdentities.email,
1391
1392
  identityHandle: juniorIdentities.handle,
@@ -1404,7 +1405,7 @@ async function readConversationRecordFromSql(conversationId) {
1404
1405
  return row ? {
1405
1406
  conversation: conversationFromRow(row),
1406
1407
  durationMs: row.conversation.durationMs,
1407
- ...row.destinationVisibility === "public" && row.destinationId ? { locationId: row.destinationId } : {},
1408
+ ...row.destination?.visibility === "public" ? { locationId: row.destination.id } : {},
1408
1409
  usage: row.conversation.usage,
1409
1410
  rootConversationId: row.conversation.rootConversationId
1410
1411
  } : void 0;
@@ -1439,7 +1440,7 @@ async function readConversationFeedFromSql(options = {}) {
1439
1440
  row.conversation.conversationId
1440
1441
  ),
1441
1442
  durationMs: metrics?.durationMs ?? row.conversation.durationMs,
1442
- ...row.destinationVisibility === "public" && row.destinationId ? { locationId: row.destinationId } : {},
1443
+ ...row.destination?.visibility === "public" ? { locationId: row.destination.id } : {},
1443
1444
  usage: metrics?.usage ?? row.conversation.usage ?? void 0
1444
1445
  });
1445
1446
  }),
@@ -2026,7 +2027,7 @@ function readDescriptionText(home) {
2026
2027
  }
2027
2028
  }
2028
2029
  async function readSkillReports() {
2029
- const { discoverSkills } = await import("./skills-WVPCTBUT.js");
2030
+ const { discoverSkills } = await import("./skills-P7Q6Z6PN.js");
2030
2031
  const skills = await discoverSkills();
2031
2032
  return skillReportsSchema.parse(
2032
2033
  skills.map((skill) => ({
@@ -2036,7 +2037,7 @@ async function readSkillReports() {
2036
2037
  );
2037
2038
  }
2038
2039
  async function readPlugins() {
2039
- const { pluginCatalogRuntime } = await import("./catalog-runtime-PI2IFWZ5.js");
2040
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-VGB3DWXZ.js");
2040
2041
  return pluginsSchema.parse(
2041
2042
  pluginCatalogRuntime.getProviders().map((plugin) => ({
2042
2043
  configKeys: plugin.manifest.configKeys ?? [],
@@ -2049,7 +2050,7 @@ async function readPlugins() {
2049
2050
  async function readRuntimeInfoReport() {
2050
2051
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
2051
2052
  import("./discovery-GUFTFBTL.js"),
2052
- import("./catalog-runtime-PI2IFWZ5.js"),
2053
+ import("./catalog-runtime-VGB3DWXZ.js"),
2053
2054
  readPlugins(),
2054
2055
  readSkillReports()
2055
2056
  ]);
@@ -2065,7 +2066,7 @@ async function readRuntimeInfoReport() {
2065
2066
  }
2066
2067
  async function readPluginOperationalReportFeed() {
2067
2068
  const nowMs = Date.now();
2068
- const { getPluginOperationalReports } = await import("./agent-hooks-M5V454P5.js");
2069
+ const { getPluginOperationalReports } = await import("./agent-hooks-5BUIXVIX.js");
2069
2070
  return pluginOperationalReportFeedSchema.parse({
2070
2071
  source: "plugins",
2071
2072
  generatedAt: new Date(nowMs).toISOString(),
package/dist/app.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  startConversationWork,
51
51
  startSlackProcessingReaction,
52
52
  stripLeadingBotMention
53
- } from "./chunk-VMPL77IK.js";
53
+ } from "./chunk-TU7P77FI.js";
54
54
  import "./chunk-FA6POGLH.js";
55
55
  import {
56
56
  ConversationTurnLifecycleService,
@@ -65,13 +65,13 @@ import {
65
65
  processPluginTask,
66
66
  requireTurnFailureEventId,
67
67
  scheduleSessionCompletedPluginTasks
68
- } from "./chunk-D6ZMP3FC.js";
68
+ } from "./chunk-VQA25AL4.js";
69
69
  import {
70
70
  GET,
71
71
  conversationVisibilityFromSlackChannelType,
72
72
  resolveSlackChannelTypeFromMessage,
73
73
  resolveSlackConversationContext
74
- } from "./chunk-NGJEC4MF.js";
74
+ } from "./chunk-V365UVCU.js";
75
75
  import "./chunk-4CODA7P5.js";
76
76
  import "./chunk-UTL3MHPC.js";
77
77
  import {
@@ -90,7 +90,7 @@ import {
90
90
  import {
91
91
  validatePluginEgressCredentialHooks,
92
92
  validatePluginRegistrations
93
- } from "./chunk-UYYSD255.js";
93
+ } from "./chunk-5ZAZHLIW.js";
94
94
  import {
95
95
  defineJuniorPlugins,
96
96
  pluginCatalogConfigFromEnv,
@@ -125,7 +125,7 @@ import {
125
125
  setConfigDefaults,
126
126
  shouldEmitDevAgentTrace,
127
127
  shouldPropagateSandboxEgressTrace
128
- } from "./chunk-TRKWWIB3.js";
128
+ } from "./chunk-T5FPIBU2.js";
129
129
  import "./chunk-DIB4GX3G.js";
130
130
  import {
131
131
  RetryableDeliveryError,
@@ -136,7 +136,7 @@ import {
136
136
  formatProviderLabel,
137
137
  postSlackMessage,
138
138
  startOAuthFlow
139
- } from "./chunk-DRFI6CW3.js";
139
+ } from "./chunk-HTGXUNEC.js";
140
140
  import {
141
141
  ConversationTurnBoundaryError,
142
142
  CooperativeTurnYieldError,
@@ -192,19 +192,19 @@ import {
192
192
  trimTrailingAssistantMessages,
193
193
  updateConversationStats,
194
194
  upsertConversationMessage
195
- } from "./chunk-HZ5EVSPV.js";
195
+ } from "./chunk-ECUILEUX.js";
196
196
  import "./chunk-EPBBYMNE.js";
197
197
  import {
198
198
  getSandboxResourceConfig,
199
199
  setSandboxResourceConfig
200
- } from "./chunk-XXGCQCFJ.js";
200
+ } from "./chunk-TBVS7GBE.js";
201
201
  import {
202
202
  createSchedulerSqlStore,
203
203
  findMatchingEventTasks
204
- } from "./chunk-7X62XOC4.js";
204
+ } from "./chunk-XTQGVNM3.js";
205
205
  import {
206
206
  parseSlackThreadId
207
- } from "./chunk-JKHK3LM2.js";
207
+ } from "./chunk-AH5HTUYX.js";
208
208
  import "./chunk-HX236W2U.js";
209
209
  import "./chunk-PDO5BLNM.js";
210
210
  import "./chunk-UIE3R5XU.js";
@@ -232,7 +232,7 @@ import {
232
232
  verifyEventTaskCredentialSubject,
233
233
  verifyScheduledTaskCredentialSubject,
234
234
  verifySlackDirectCredentialSubject
235
- } from "./chunk-MLIJGLW5.js";
235
+ } from "./chunk-WHEMUEXT.js";
236
236
  import {
237
237
  contextProvenance,
238
238
  createSlackDestination,
@@ -243,16 +243,16 @@ import {
243
243
  instructionProvenanceFor,
244
244
  requireSlackDestination,
245
245
  withConversationEventLock
246
- } from "./chunk-5ONXE2GF.js";
246
+ } from "./chunk-LNYNTR27.js";
247
247
  import {
248
248
  juniorConversationEvents,
249
249
  juniorConversations
250
- } from "./chunk-KB2M27DL.js";
250
+ } from "./chunk-QWGZ273D.js";
251
251
  import {
252
252
  acquireActiveLock,
253
253
  getStateAdapter,
254
254
  sleep
255
- } from "./chunk-XMDY52DJ.js";
255
+ } from "./chunk-TLN54TOQ.js";
256
256
  import {
257
257
  STANDARD_MODEL_PROFILE,
258
258
  botConfig,
@@ -270,16 +270,16 @@ import {
270
270
  modelIdForProfile,
271
271
  setSlackReactionConfig,
272
272
  standardModelId
273
- } from "./chunk-ZMIO64MA.js";
273
+ } from "./chunk-LDRO4OQ4.js";
274
274
  import {
275
275
  juniorDestinations
276
276
  } from "./chunk-VFUK3X5B.js";
277
- import "./chunk-KWYCUXJX.js";
278
- import "./chunk-J4I2GVGH.js";
277
+ import "./chunk-VL7OYSHD.js";
278
+ import "./chunk-IVTHTAVK.js";
279
279
  import {
280
280
  pluginCatalogRuntime
281
- } from "./chunk-APUL3Y63.js";
282
- import "./chunk-7Y2OKB5K.js";
281
+ } from "./chunk-JLN4XSPR.js";
282
+ import "./chunk-HJ4KDO4N.js";
283
283
  import {
284
284
  credentialSubjectSchema
285
285
  } from "./chunk-77VDLF3Z.js";
@@ -311,7 +311,7 @@ import {
311
311
  withContext,
312
312
  withLogContext,
313
313
  withSpan
314
- } from "./chunk-HSPYTFMD.js";
314
+ } from "./chunk-EJRJWBKG.js";
315
315
  import {
316
316
  continueTrace
317
317
  } from "./chunk-6GWA276C.js";
@@ -319,10 +319,10 @@ import "./chunk-OOUNJNMR.js";
319
319
  import "./chunk-H4HBKISO.js";
320
320
  import {
321
321
  JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE
322
- } from "./chunk-TD2A27ET.js";
322
+ } from "./chunk-FX6BLEDP.js";
323
323
  import {
324
324
  JUNIOR_VERSION
325
- } from "./chunk-SVX4JDOR.js";
325
+ } from "./chunk-IKO5LFIU.js";
326
326
  import "./chunk-MLKGABMK.js";
327
327
 
328
328
  // src/app.ts
@@ -2804,8 +2804,9 @@ async function lookupSlackUser(teamId, userId) {
2804
2804
  }
2805
2805
 
2806
2806
  // src/chat/slack/message-control.ts
2807
+ var LEADING_MENTION_BEFORE_STEERING_RE = /^(\s*(?:<@[^>]+>|@[A-Za-z0-9._-]+\b)[\s,:-]*)!!\s*/;
2807
2808
  function stripLeadingSteeringOverride(text) {
2808
- return text.replace(/^\s*!!\s*/, "");
2809
+ return text.replace(LEADING_MENTION_BEFORE_STEERING_RE, "$1").replace(/^\s*!!\s*/, "");
2809
2810
  }
2810
2811
 
2811
2812
  // src/chat/task-execution/slack-work.ts
@@ -3326,6 +3327,7 @@ function createSlackConversationWorker(options) {
3326
3327
  try {
3327
3328
  if (route === "mention") {
3328
3329
  await options.runtime.handleNewMention(thread, latestMessage, {
3330
+ conversationId: context.conversationId,
3329
3331
  destination: context.destination,
3330
3332
  messageContext,
3331
3333
  drainSteeringMessages,
@@ -3338,6 +3340,7 @@ function createSlackConversationWorker(options) {
3338
3340
  thread,
3339
3341
  latestMessage,
3340
3342
  {
3343
+ conversationId: context.conversationId,
3341
3344
  destination: context.destination,
3342
3345
  messageContext,
3343
3346
  drainSteeringMessages,
@@ -3720,10 +3723,32 @@ function shouldIgnoreMessage(message) {
3720
3723
  function shouldPersistBeforeAck(body) {
3721
3724
  return body.event?.type === "app_mention" || body.event?.type === "message";
3722
3725
  }
3726
+ async function resolveSlackConversationId(args) {
3727
+ const providerThread = parseSlackThreadId(args.canonicalThreadId);
3728
+ const conversationStore = args.conversationStore ?? getConversationStore();
3729
+ if (!providerThread) {
3730
+ return args.canonicalThreadId;
3731
+ }
3732
+ return await conversationStore.getConversationIdByProviderConversation({
3733
+ provider: "slack",
3734
+ providerDestinationId: providerThread.channelId,
3735
+ providerTenantId: args.installation.teamId ?? "",
3736
+ providerConversationId: providerThread.threadTs
3737
+ }) ?? args.canonicalThreadId;
3738
+ }
3723
3739
  async function persistSlackMessage(args) {
3740
+ const canonicalThreadId = normalizeIncomingSlackThreadId(
3741
+ args.message.threadId,
3742
+ args.message
3743
+ );
3744
+ const conversationId = args.conversationId ?? await resolveSlackConversationId({
3745
+ canonicalThreadId,
3746
+ conversationStore: args.conversationStore,
3747
+ installation: args.installation
3748
+ });
3724
3749
  const thread = await buildThread(args);
3725
3750
  const inbound = buildSlackInboundMessage({
3726
- conversationId: thread.id,
3751
+ conversationId,
3727
3752
  installation: args.installation,
3728
3753
  message: args.message,
3729
3754
  receivedAtMs: args.receivedAtMs,
@@ -3743,12 +3768,17 @@ async function routeParsedMessage(args) {
3743
3768
  if (shouldIgnoreMessage(args.message)) {
3744
3769
  return;
3745
3770
  }
3746
- const threadId = normalizeMessageThreadId(args.message);
3771
+ const canonicalThreadId = normalizeMessageThreadId(args.message);
3772
+ const conversationId = await resolveSlackConversationId({
3773
+ canonicalThreadId,
3774
+ conversationStore: args.conversationStore,
3775
+ installation: args.installation
3776
+ });
3747
3777
  const isMention = args.event.type === "app_mention" || textMentionsBot2(args.event, args.adapter.botUserId);
3748
3778
  if (isMention) {
3749
3779
  args.message.isMention = true;
3750
3780
  }
3751
- const route = isDmEvent(args.event) || isMention ? "mention" : await args.state.isSubscribed(threadId) ? "subscribed" : void 0;
3781
+ const route = isDmEvent(args.event) || isMention ? "mention" : await args.state.isSubscribed(canonicalThreadId) ? "subscribed" : void 0;
3752
3782
  if (!route) {
3753
3783
  return;
3754
3784
  }
@@ -3756,6 +3786,7 @@ async function routeParsedMessage(args) {
3756
3786
  adapter: args.adapter,
3757
3787
  installation: args.installation,
3758
3788
  message: args.message,
3789
+ conversationId,
3759
3790
  conversationStore: args.conversationStore,
3760
3791
  queue: args.queue,
3761
3792
  receivedAtMs: args.receivedAtMs,
@@ -5639,6 +5670,7 @@ function createSlackTurnRuntime(deps) {
5639
5670
  await deps.replyToThread(thread, message, {
5640
5671
  explicitMention: true,
5641
5672
  beforeFirstResponsePost: hooks.beforeFirstResponsePost,
5673
+ conversationId: hooks.conversationId,
5642
5674
  destination: hooks.destination,
5643
5675
  queuedMessages,
5644
5676
  ack,
@@ -5903,6 +5935,7 @@ function createSlackTurnRuntime(deps) {
5903
5935
  );
5904
5936
  await deps.replyToThread(thread, message, {
5905
5937
  explicitMention: Boolean(message.isMention),
5938
+ conversationId: hooks.conversationId,
5906
5939
  destination: hooks.destination,
5907
5940
  preparedState,
5908
5941
  beforeFirstResponsePost: hooks.beforeFirstResponsePost,
@@ -6824,8 +6857,8 @@ function createReplyToThread(deps) {
6824
6857
  destination,
6825
6858
  visibility: options.execution?.destinationVisibility ?? conversationVisibilityFromSlackChannelType(slackChannelType)
6826
6859
  });
6827
- const threadTs = getThreadTs(threadId);
6828
6860
  const assistantThreadContext = getAssistantThreadContext(message);
6861
+ const threadTs = getThreadTs(threadId) ?? assistantThreadContext?.threadTs;
6829
6862
  const messageTs = getMessageTs(message);
6830
6863
  const teamId = destination.teamId;
6831
6864
  const source = options.execution?.source ?? createSlackSource2({
@@ -6837,7 +6870,7 @@ function createReplyToThread(deps) {
6837
6870
  });
6838
6871
  const slackActionToken = readSlackActionToken(message);
6839
6872
  const runId = options.execution?.dispatch?.id ?? getRunId(thread, message);
6840
- const conversationId = threadId ?? runId;
6873
+ const conversationId = options.conversationId ?? threadId ?? runId;
6841
6874
  if (!conversationId) {
6842
6875
  throw new Error("Slack reply execution requires a conversation id");
6843
6876
  }
@@ -7289,11 +7322,11 @@ function createReplyToThread(deps) {
7289
7322
  return;
7290
7323
  }
7291
7324
  boundaryFailureCode = "delivery_failed";
7292
- let slackTs;
7325
+ let slackMessageTs2 = [];
7293
7326
  await beforeFirstResponsePost();
7294
7327
  try {
7295
7328
  if (channelId && thread.adapter.name === "slack") {
7296
- slackTs = await sendSlackReply({
7329
+ slackMessageTs2 = await sendSlackReply({
7297
7330
  channelId,
7298
7331
  conversationId,
7299
7332
  replyAttribution: options.execution?.dispatch?.replyAttribution,
@@ -7302,7 +7335,10 @@ function createReplyToThread(deps) {
7302
7335
  });
7303
7336
  } else {
7304
7337
  for (const part of splitSlackReplyText(text)) {
7305
- slackTs = (await thread.post(buildSlackOutputMessage(part))).id;
7338
+ const postedMessageTs = (await thread.post(buildSlackOutputMessage(part))).id;
7339
+ if (postedMessageTs) {
7340
+ slackMessageTs2.push(postedMessageTs);
7341
+ }
7306
7342
  }
7307
7343
  }
7308
7344
  } catch (error) {
@@ -7320,6 +7356,7 @@ function createReplyToThread(deps) {
7320
7356
  failureCode: "delivery_failed"
7321
7357
  });
7322
7358
  }
7359
+ const slackTs = slackMessageTs2.at(-1);
7323
7360
  assistantMessageDelivered = true;
7324
7361
  acceptedDeliveryId = slackTs;
7325
7362
  options.onTurnDeliveryAccepted?.(slackTs);
@@ -7337,17 +7374,26 @@ function createReplyToThread(deps) {
7337
7374
  );
7338
7375
  }
7339
7376
  try {
7377
+ const providerConversationIds = threadTs ? [threadTs] : slackMessageTs2;
7340
7378
  await persistWithRetry(
7341
- () => agentMessage && conversationId ? commitAcceptedReply({
7342
- agentMessage,
7379
+ () => commitAcceptedReply({
7380
+ ...agentMessage ? { agentMessage } : {},
7343
7381
  conversation: preparedState.conversation,
7344
7382
  conversationMessageId: recordedMessageId,
7345
- conversationId
7346
- }) : persistConversationMessages({
7347
- conversation: preparedState.conversation,
7348
- conversationId
7383
+ conversationId,
7384
+ ...options.execution?.dispatch && providerConversationIds.length > 0 ? {
7385
+ providerConversationBindings: providerConversationIds.map(
7386
+ (providerConversationId) => ({
7387
+ provider: "slack",
7388
+ providerDestinationId: destination.channelId,
7389
+ providerTenantId: destination.teamId,
7390
+ providerConversationId
7391
+ })
7392
+ )
7393
+ } : {}
7349
7394
  })
7350
7395
  );
7396
+ await options.onTurnStatePersisted?.();
7351
7397
  } catch (error) {
7352
7398
  logException(
7353
7399
  new Error("Accepted assistant message persistence failed"),
@@ -8254,6 +8300,7 @@ function createSlackDispatchTurnRunner(options) {
8254
8300
  const routing = buildDispatchRoutingContext(dispatch2);
8255
8301
  await options.replyToThread(thread, message, {
8256
8302
  ack: hooks.ack,
8303
+ conversationId,
8257
8304
  destination: dispatch2.destination,
8258
8305
  execution: {
8259
8306
  authorizationFlowMode: "disabled",
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-APUL3Y63.js";
4
- import "./chunk-7Y2OKB5K.js";
3
+ } from "./chunk-JLN4XSPR.js";
4
+ import "./chunk-HJ4KDO4N.js";
5
5
  import "./chunk-77VDLF3Z.js";
6
6
  import "./chunk-HZF5P5UN.js";
7
7
  import "./chunk-F3B2YJ76.js";
8
- import "./chunk-HSPYTFMD.js";
8
+ import "./chunk-EJRJWBKG.js";
9
9
  import "./chunk-6GWA276C.js";
10
10
  import "./chunk-OOUNJNMR.js";
11
11
  import "./chunk-H4HBKISO.js";
12
- import "./chunk-TD2A27ET.js";
13
- import "./chunk-SVX4JDOR.js";
12
+ import "./chunk-FX6BLEDP.js";
13
+ import "./chunk-IKO5LFIU.js";
14
14
  import "./chunk-MLKGABMK.js";
15
15
  export {
16
16
  pluginCatalogRuntime
@@ -1,5 +1,6 @@
1
1
  import { type TurnReasoningLevel } from "@/chat/reasoning-level";
2
2
  import { type ExecutionProfileConfig } from "@/chat/model-profile";
3
+ export declare const DEFAULT_SQL_STATEMENT_TIMEOUT_MS = 30000;
3
4
  /**
4
5
  * Buffer between the Vercel function timeout and the agent turn timeout so
5
6
  * Junior can abort, persist, and schedule continuation before host teardown.
@@ -32,6 +33,7 @@ export interface ChatConfig {
32
33
  sql: {
33
34
  databaseUrl: string;
34
35
  driver: SqlDriver;
36
+ statementTimeoutMs: number | false;
35
37
  };
36
38
  slack: {
37
39
  botToken?: string;
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ /** Provider-neutral container associated with a conversation. */
3
+ export declare const locationSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ provider: z.ZodString;
6
+ tenantId: z.ZodOptional<z.ZodString>;
7
+ providerId: z.ZodString;
8
+ }, z.core.$strict>;
9
+ /** Validated provider location associated with a conversation. */
10
+ export type Location = z.output<typeof locationSchema>;
@@ -2,6 +2,7 @@ import { type PiMessage } from "@/chat/pi/messages";
2
2
  import { type ConversationMessageProvenance } from "@/chat/conversations/provenance";
3
3
  import type { AuthorizationKind, ConversationEvent } from "@/chat/conversations/history";
4
4
  import type { JuniorSqlDatabase } from "@/db/db";
5
+ import { type ProviderConversationBinding } from "@/chat/conversations/sql/bindings";
5
6
  import { type PiConversationEventProjection, type PiConversationProjection } from "@/chat/pi/conversation-events";
6
7
  import type { ModelProfile } from "@/chat/model-profile";
7
8
  import type { TurnReasoningLevel } from "@/chat/reasoning-level";
@@ -73,10 +74,11 @@ export declare function commitMessages(args: {
73
74
  * produced it.
74
75
  */
75
76
  export declare function commitAcceptedReply(args: {
76
- agentMessage: AssistantMessage;
77
+ agentMessage?: AssistantMessage;
77
78
  conversation: ThreadConversationState;
78
79
  conversationMessageId: string;
79
80
  conversationId: string;
81
+ providerConversationBindings?: Array<Omit<ProviderConversationBinding, "conversationId">>;
80
82
  repliedAtMs?: number;
81
83
  }): Promise<void>;
82
84
  /** Record a successful MCP provider connection without duplicating the fact. */
@@ -0,0 +1,13 @@
1
+ import type { JuniorSqlDatabase } from "@/db/db";
2
+ export interface ProviderConversationBinding {
3
+ conversationId: string;
4
+ provider: string;
5
+ providerDestinationId: string;
6
+ providerTenantId: string;
7
+ providerConversationId: string;
8
+ }
9
+ export type ProviderConversationReference = Omit<ProviderConversationBinding, "conversationId">;
10
+ /** Resolve the durable conversation bound to provider-owned coordinates. */
11
+ export declare function getConversationIdByProviderConversation(executor: JuniorSqlDatabase, args: ProviderConversationReference): Promise<string | undefined>;
12
+ /** Bind provider coordinates to a durable conversation in the caller's SQL scope. */
13
+ export declare function bindProviderConversation(executor: JuniorSqlDatabase, args: ProviderConversationBinding): Promise<void>;