@sentry/junior 0.146.0 → 0.148.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 (227) hide show
  1. package/dist/{agent-hooks-SLJADYE5.js → agent-hooks-VAUYT6PD.js} +10 -10
  2. package/dist/api/conversations/access.d.ts +2 -1
  3. package/dist/api/conversations/archive.d.ts +3 -5
  4. package/dist/api/conversations/create.d.ts +6 -0
  5. package/dist/api/conversations/detail.d.ts +2 -295
  6. package/dist/api/conversations/event-list.d.ts +2 -192
  7. package/dist/api/conversations/list.d.ts +4 -66
  8. package/dist/api/conversations/routes.d.ts +1 -1
  9. package/dist/api/conversations/stats.d.ts +0 -54
  10. package/dist/api/http.d.ts +2 -6
  11. package/dist/api/locations/detail.d.ts +3 -111
  12. package/dist/api/locations/list.d.ts +0 -45
  13. package/dist/api/locations/query.d.ts +2 -1
  14. package/dist/api/locations/routes.d.ts +1 -1
  15. package/dist/api/people/list.d.ts +0 -29
  16. package/dist/api/people/profile.d.ts +2 -106
  17. package/dist/api/people/profile.query.d.ts +2 -1
  18. package/dist/api/people/routes.d.ts +1 -1
  19. package/dist/api/people/shared.d.ts +1 -1
  20. package/dist/api/people/spend.d.ts +3 -4
  21. package/dist/api/personal-tokens/routes.d.ts +2 -2
  22. package/dist/api/route.d.ts +8 -14
  23. package/dist/api/schema/conversation.d.ts +64 -29
  24. package/dist/api/schema/location.d.ts +4 -0
  25. package/dist/api/schema/person.d.ts +7 -3
  26. package/dist/api/schema.d.ts +2 -2
  27. package/dist/api/schema.js +7 -1
  28. package/dist/api/stats.d.ts +0 -13
  29. package/dist/api/validation.d.ts +7 -0
  30. package/dist/api/viewer.d.ts +3 -0
  31. package/dist/api.d.ts +2 -1
  32. package/dist/api.js +630 -564
  33. package/dist/app.js +369 -309
  34. package/dist/{catalog-runtime-RQIMSDPR.js → catalog-runtime-WADOZVTB.js} +5 -5
  35. package/dist/chat/actor.d.ts +4 -1
  36. package/dist/chat/agent/prompt.d.ts +0 -2
  37. package/dist/chat/agent/request.d.ts +4 -5
  38. package/dist/chat/agent/resume.d.ts +1 -0
  39. package/dist/chat/agent/sandbox.d.ts +2 -2
  40. package/dist/chat/agent/tools.d.ts +0 -2
  41. package/dist/chat/agent-dispatch/context.d.ts +2 -2
  42. package/dist/chat/agent-dispatch/types.d.ts +2 -2
  43. package/dist/chat/agent-invocations/types.d.ts +52 -0
  44. package/dist/chat/api-turns/work.d.ts +103 -0
  45. package/dist/chat/capabilities/jr-rpc-command.d.ts +2 -2
  46. package/dist/chat/configuration/service.d.ts +5 -2
  47. package/dist/chat/configuration/sql.d.ts +9 -0
  48. package/dist/chat/configuration/types.d.ts +17 -13
  49. package/dist/chat/conversations/history.d.ts +63 -0
  50. package/dist/chat/conversations/projection.d.ts +10 -0
  51. package/dist/chat/conversations/provenance.d.ts +6 -0
  52. package/dist/chat/conversations/sql/actor-identity.d.ts +19 -0
  53. package/dist/chat/conversations/store.d.ts +1 -1
  54. package/dist/chat/credentials/unlink-provider.d.ts +2 -1
  55. package/dist/chat/credentials/user-token-store.d.ts +2 -0
  56. package/dist/chat/event-tasks/tool-support.d.ts +2 -0
  57. package/dist/chat/identities/sql.d.ts +8 -0
  58. package/dist/chat/logging.d.ts +2 -0
  59. package/dist/chat/mcp/auth-store.d.ts +0 -2
  60. package/dist/chat/mcp/oauth.d.ts +0 -2
  61. package/dist/chat/oauth-flow.d.ts +3 -1
  62. package/dist/chat/pi/client.d.ts +2 -0
  63. package/dist/chat/plugins/credential-hooks.d.ts +2 -0
  64. package/dist/chat/prompt.d.ts +0 -2
  65. package/dist/chat/resource-events/notification.d.ts +2 -1
  66. package/dist/chat/resource-events/store.d.ts +1 -1
  67. package/dist/chat/runtime/delivered-turn-state.d.ts +1 -4
  68. package/dist/chat/runtime/reply-executor.d.ts +1 -1
  69. package/dist/chat/runtime/slack-runtime.d.ts +2 -1
  70. package/dist/chat/runtime/thread-state.d.ts +8 -11
  71. package/dist/chat/runtime/turn-input.d.ts +4 -2
  72. package/dist/chat/runtime/turn-preparation.d.ts +11 -4
  73. package/dist/chat/sandbox/command-result.d.ts +2 -0
  74. package/dist/chat/sandbox/egress/schemas.d.ts +6 -0
  75. package/dist/chat/scheduled-tasks/tool-support.d.ts +7 -5
  76. package/dist/chat/scheduled-tasks/tools/create.d.ts +4 -2
  77. package/dist/chat/scheduled-tasks/tools/delete.d.ts +4 -2
  78. package/dist/chat/scheduled-tasks/tools/list.d.ts +4 -2
  79. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +4 -2
  80. package/dist/chat/scheduled-tasks/tools/update.d.ts +4 -2
  81. package/dist/chat/services/mcp-auth-orchestration.d.ts +0 -3
  82. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
  83. package/dist/chat/services/provider-default-config.d.ts +2 -2
  84. package/dist/chat/services/subscribed-decision.d.ts +3 -0
  85. package/dist/chat/services/subscribed-reply-policy.d.ts +1 -0
  86. package/dist/chat/services/turn-result.d.ts +0 -3
  87. package/dist/chat/services/turn-router.d.ts +3 -0
  88. package/dist/chat/slack/assistant-thread/lifecycle.d.ts +0 -1
  89. package/dist/chat/slack/assistant-thread/title.d.ts +0 -3
  90. package/dist/chat/slack/channel.d.ts +26 -0
  91. package/dist/chat/slack/dispatch-turn.d.ts +2 -1
  92. package/dist/chat/slack/timestamp-param.d.ts +0 -2
  93. package/dist/chat/slack/{tools → tool-support}/canvas/api.d.ts +1 -1
  94. package/dist/chat/slack/tool-support/canvas/context.d.ts +11 -0
  95. package/dist/chat/slack/tool-support/channel-access.d.ts +42 -0
  96. package/dist/chat/slack/tool-support/channel-target.d.ts +27 -0
  97. package/dist/chat/slack/{tools → tool-support}/list/api.d.ts +8 -1
  98. package/dist/chat/slack/tool-support/list/params.d.ts +5 -0
  99. package/dist/chat/slack/tools/canvas/create.d.ts +3 -1
  100. package/dist/chat/slack/tools/canvas/edit.d.ts +2 -0
  101. package/dist/chat/slack/tools/canvas/read.d.ts +2 -0
  102. package/dist/chat/slack/tools/canvas/write.d.ts +2 -0
  103. package/dist/chat/slack/tools/{user-lookup.d.ts → channel-join.d.ts} +6 -5
  104. package/dist/chat/slack/tools/channel-list-messages.d.ts +5 -2
  105. package/dist/chat/slack/tools/conversation-message-search.d.ts +4 -8
  106. package/dist/chat/slack/tools/list/add-items.d.ts +4 -1
  107. package/dist/chat/slack/tools/list/create.d.ts +2 -0
  108. package/dist/chat/slack/tools/list/get-items.d.ts +5 -3
  109. package/dist/chat/slack/tools/list/update-item.d.ts +5 -1
  110. package/dist/chat/slack/tools/message-add-reaction.d.ts +3 -1
  111. package/dist/chat/slack/tools/public-search.d.ts +65 -2
  112. package/dist/chat/slack/tools/send-files.d.ts +3 -1
  113. package/dist/chat/slack/tools/thread-read.d.ts +4 -5
  114. package/dist/chat/slack/vision-cache.d.ts +5 -0
  115. package/dist/chat/source.d.ts +2 -0
  116. package/dist/chat/state/conversation.d.ts +4 -5
  117. package/dist/chat/task-execution/checkpoint.d.ts +1 -0
  118. package/dist/chat/task-execution/state.d.ts +9 -4
  119. package/dist/chat/task-execution/store.d.ts +3 -2
  120. package/dist/chat/task-execution/turn-cursor.d.ts +2 -0
  121. package/dist/chat/task-execution/worker.d.ts +2 -0
  122. package/dist/chat/tasks/read.d.ts +1 -1
  123. package/dist/chat/tool-support/structured-result.d.ts +1 -0
  124. package/dist/chat/tool-support/timed-out-tool-result.d.ts +11 -0
  125. package/dist/chat/tools/create-event-task.d.ts +2 -0
  126. package/dist/chat/tools/delete-event-task.d.ts +2 -0
  127. package/dist/chat/tools/handoff/tool.d.ts +2 -0
  128. package/dist/chat/tools/list-event-tasks.d.ts +2 -0
  129. package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
  130. package/dist/chat/tools/runtime/report-progress.d.ts +2 -0
  131. package/dist/chat/tools/runtime/spawn-agent.d.ts +2 -0
  132. package/dist/chat/tools/search-conversation-events.d.ts +3 -1
  133. package/dist/chat/tools/search-resource-event-types.d.ts +2 -0
  134. package/dist/chat/tools/search-tools.d.ts +2 -0
  135. package/dist/chat/tools/skill/load-skill.d.ts +2 -0
  136. package/dist/chat/tools/skill/search-mcp-tools.d.ts +2 -0
  137. package/dist/chat/tools/stop-watching-resources.d.ts +2 -0
  138. package/dist/chat/tools/system-time.d.ts +2 -0
  139. package/dist/chat/tools/types.d.ts +11 -10
  140. package/dist/chat/tools/update-event-task.d.ts +2 -0
  141. package/dist/chat/tools/user-lookup.d.ts +29 -0
  142. package/dist/chat/tools/watch-resource-events.d.ts +4 -2
  143. package/dist/chat/tools/web/fetch-tool.d.ts +2 -0
  144. package/dist/chat/tools/web/image-generate.d.ts +2 -0
  145. package/dist/chat/tools/web/search.d.ts +2 -0
  146. package/dist/{chunk-GYEKOX7N.js → chunk-2B3PT3V2.js} +1 -1
  147. package/dist/{chunk-JLMVCNXL.js → chunk-45LOR4PU.js} +22 -4
  148. package/dist/{chunk-FGHADGIC.js → chunk-4AQZYNHM.js} +2 -2
  149. package/dist/{chunk-W65V465O.js → chunk-4EA2SFK2.js} +66 -4
  150. package/dist/{chunk-MKRIZ4VG.js → chunk-4GXJUYJV.js} +4 -2
  151. package/dist/{chunk-F7REGDKO.js → chunk-55F4QU2V.js} +2 -1
  152. package/dist/{chunk-M6ZWP4RI.js → chunk-7OEIXFC3.js} +2 -2
  153. package/dist/{chunk-MCFIXAV5.js → chunk-D3WPMGEX.js} +55 -37
  154. package/dist/{chunk-AISNSNDV.js → chunk-D6YX4NNN.js} +22 -10
  155. package/dist/chunk-DUY5CDAM.js +36 -0
  156. package/dist/{chunk-B63BF443.js → chunk-EAI67NTM.js} +9 -1
  157. package/dist/{chunk-FEKQHPVA.js → chunk-EINWQFXI.js} +9 -8
  158. package/dist/chunk-GDFF3BQG.js +136 -0
  159. package/dist/{chunk-X22KCSCO.js → chunk-GXYDVZKM.js} +7 -5
  160. package/dist/{chunk-X2WMBTS3.js → chunk-HLPLT3NY.js} +8 -5
  161. package/dist/{chunk-PB222GIA.js → chunk-HWQGBIH7.js} +1 -1
  162. package/dist/chunk-IL4EDBMV.js +566 -0
  163. package/dist/{chunk-HQE6EJS5.js → chunk-LAZGHEYU.js} +1 -1
  164. package/dist/{chunk-QG7OOKIN.js → chunk-LE5H7LMT.js} +1 -1
  165. package/dist/chunk-LNVEIJ2L.js +48 -0
  166. package/dist/{chunk-JUA6VU2Z.js → chunk-OJCP3C3J.js} +12 -23
  167. package/dist/{chunk-37JJDS4H.js → chunk-POSZWRGL.js} +1 -1
  168. package/dist/{chunk-TCEJ7XXM.js → chunk-QOWHHM3F.js} +1 -1
  169. package/dist/{chunk-H6U2U3EP.js → chunk-RRJV5UR5.js} +304 -65
  170. package/dist/{chunk-OFPYOC3M.js → chunk-ULAU5ZGU.js} +127 -120
  171. package/dist/{chunk-V6SRLKUB.js → chunk-V2FXMOEA.js} +2 -2
  172. package/dist/{chunk-GDQEU4I7.js → chunk-VCYSOXON.js} +296 -526
  173. package/dist/{chunk-BLETMLRX.js → chunk-VMNRXKAH.js} +1374 -989
  174. package/dist/{chunk-37EVZP66.js → chunk-VRHTNBA6.js} +167 -92
  175. package/dist/{chunk-FXDDDSPL.js → chunk-VY6W3T43.js} +4 -4
  176. package/dist/{chunk-ZDGHGY74.js → chunk-WCN4YSH7.js} +13 -6
  177. package/dist/{chunk-PH4Q3A6W.js → chunk-WOONT5ZP.js} +1 -1
  178. package/dist/{chunk-47OSH2ZO.js → chunk-XJ42NBP5.js} +395 -206
  179. package/dist/{chunk-SCGVWUZX.js → chunk-ZCHIC2GM.js} +92 -75
  180. package/dist/chunk-ZPL2RR7F.js +798 -0
  181. package/dist/cli/chat.js +33 -35
  182. package/dist/cli/check.js +6 -6
  183. package/dist/cli/plugins.js +13 -13
  184. package/dist/cli/snapshot-create.js +9 -9
  185. package/dist/cli/upgrade.js +7 -7
  186. package/dist/db/schema/agent-invocations.d.ts +20 -0
  187. package/dist/db/schema/conversation-annotations.d.ts +2 -2
  188. package/dist/db/schema/location-configurations.d.ts +127 -0
  189. package/dist/db/schema.d.ts +150 -3
  190. package/dist/{db-WWOMXWTT.js → db-XUKZRFFK.js} +7 -7
  191. package/dist/instrumentation.js +4 -4
  192. package/dist/nitro.js +2 -2
  193. package/dist/{oauth-callback-server-A6ZZX74U.js → oauth-callback-server-LPZMMGFI.js} +25 -26
  194. package/dist/{runner-KSGB2UAV.js → runner-DGKUTMPX.js} +22 -41
  195. package/dist/{skills-26QPWKVS.js → skills-P7YUFSXM.js} +6 -6
  196. package/dist/spawn-DSK3ZEVD.js +38 -0
  197. package/dist/{validation-OPSRGFGH.js → validation-S7U5M5NR.js} +6 -6
  198. package/dist/version.js +1 -1
  199. package/dist/{work-VMSW7STJ.js → work-GAA7TVAD.js} +18 -19
  200. package/dist/{worker-2JNFB7C7.js → worker-JXPJH3QB.js} +11 -10
  201. package/migrations/0024_misty_typhoid_mary.sql +12 -0
  202. package/migrations/meta/0024_snapshot.json +2275 -0
  203. package/migrations/meta/_journal.json +7 -0
  204. package/package.json +6 -5
  205. package/dist/api/health.d.ts +0 -7
  206. package/dist/api/personal-tokens/create.d.ts +0 -11
  207. package/dist/api/personal-tokens/list.d.ts +0 -12
  208. package/dist/api/personal-tokens/revoke.d.ts +0 -5
  209. package/dist/api/plugin-reports.d.ts +0 -63
  210. package/dist/api/plugins.d.ts +0 -8
  211. package/dist/api/runtime.d.ts +0 -24
  212. package/dist/api/skills.d.ts +0 -6
  213. package/dist/chat/slack/tools/canvas/context.d.ts +0 -18
  214. package/dist/chat/slack/tools/channel-access.d.ts +0 -30
  215. package/dist/chat/state/artifacts.d.ts +0 -30
  216. package/dist/chat/tool-support/turn-deadline-result.d.ts +0 -3
  217. package/dist/chunk-HLXXQI5Q.js +0 -238
  218. package/dist/chunk-LVW7BLLT.js +0 -115
  219. package/dist/chunk-Q6QZTTLS.js +0 -55
  220. package/dist/chunk-QSXZ42KX.js +0 -285
  221. package/dist/chunk-R776HKPK.js +0 -81
  222. package/dist/chunk-T5GXFFLA.js +0 -67
  223. package/dist/spawn-5LAJXZ2P.js +0 -39
  224. /package/dist/chat/slack/{tools → tool-support}/canvas/markdown.d.ts +0 -0
  225. /package/dist/chat/slack/{tools → tool-support}/channel-capabilities.d.ts +0 -0
  226. /package/dist/chat/slack/{tools → tool-support}/context.d.ts +0 -0
  227. /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  appendAndEnqueueInboundMessage
3
- } from "./chunk-X2WMBTS3.js";
3
+ } from "./chunk-HLPLT3NY.js";
4
4
  import {
5
- ConversationTurnLifecycleService
6
- } from "./chunk-Q6QZTTLS.js";
5
+ ConversationTurnLifecycleService,
6
+ getPersistedSandboxState,
7
+ getPersistedThreadState,
8
+ persistThreadStateById
9
+ } from "./chunk-IL4EDBMV.js";
7
10
  import {
8
11
  AgentInvocationBusyError,
9
12
  AgentInvocationLimitError,
@@ -12,31 +15,27 @@ import {
12
15
  agentBindingSchema,
13
16
  agentInvocationSchema,
14
17
  createAgentInvocationSchema
15
- } from "./chunk-FEKQHPVA.js";
18
+ } from "./chunk-EINWQFXI.js";
16
19
  import {
17
20
  TurnInputCommitLostError,
18
- coerceThreadArtifactsState,
19
21
  failTurnRecord,
20
22
  getAssistantReplyText,
21
23
  getConversationTurnBoundaryError,
22
- getPersistedSandboxState,
23
- getPersistedThreadState,
24
24
  getTerminalAssistantMessages,
25
25
  getTurnRecord,
26
26
  isTurnInputCommitLostError,
27
27
  openConversationProjection,
28
- persistThreadStateById,
29
28
  saveTurnCheckpoint
30
- } from "./chunk-GDQEU4I7.js";
29
+ } from "./chunk-VCYSOXON.js";
31
30
  import {
32
31
  getConversationEventStore,
33
32
  getConversationStore,
34
33
  getSqlExecutor
35
- } from "./chunk-37EVZP66.js";
34
+ } from "./chunk-VRHTNBA6.js";
36
35
  import {
37
36
  juniorAgentBindings,
38
37
  juniorAgentInvocations
39
- } from "./chunk-MCFIXAV5.js";
38
+ } from "./chunk-D3WPMGEX.js";
40
39
 
41
40
  // src/chat/agent-invocations/work.ts
42
41
  import { z } from "zod";
@@ -309,6 +308,7 @@ function buildAgentInvocationInboundMessage(invocation, nowMs = Date.now()) {
309
308
  }
310
309
  },
311
310
  receivedAtMs: nowMs,
311
+ publishExternally: false,
312
312
  source: "internal"
313
313
  };
314
314
  }
@@ -461,7 +461,6 @@ function createAgentInvocationWorker(options) {
461
461
  const lifecycle = new ConversationTurnLifecycleService(
462
462
  getConversationEventStore()
463
463
  );
464
- let artifacts;
465
464
  let sandboxRef;
466
465
  let history;
467
466
  try {
@@ -500,7 +499,6 @@ function createAgentInvocationWorker(options) {
500
499
  conversationId: invocation.childConversationId
501
500
  })
502
501
  ]);
503
- artifacts = coerceThreadArtifactsState(persisted);
504
502
  sandboxRef = getPersistedSandboxState(persisted);
505
503
  history = projection.messages;
506
504
  } catch (error) {
@@ -536,6 +534,7 @@ function createAgentInvocationWorker(options) {
536
534
  credentialContext: invocation.credentialContext,
537
535
  destination: invocation.destination,
538
536
  destinationVisibility: invocation.destinationVisibility,
537
+ publishExternally: context.publishExternally,
539
538
  source: invocation.source,
540
539
  surface: "internal"
541
540
  },
@@ -548,23 +547,14 @@ function createAgentInvocationWorker(options) {
548
547
  reasoningLevel: invocation.reasoningLevel
549
548
  },
550
549
  state: {
551
- artifactState: artifacts,
552
550
  sandboxRef
553
551
  },
554
552
  durability: {
555
553
  onInputCommitted: acknowledge,
556
554
  shouldYield: context.shouldYield,
557
- onArtifactStateUpdated: async (nextArtifacts) => {
558
- artifacts = nextArtifacts;
559
- await persistThreadStateById(invocation.childConversationId, {
560
- artifacts,
561
- sandboxRef
562
- });
563
- },
564
555
  onSandboxRefChanged: async (nextSandboxRef) => {
565
556
  sandboxRef = nextSandboxRef;
566
557
  await persistThreadStateById(invocation.childConversationId, {
567
- artifacts,
568
558
  sandboxRef
569
559
  });
570
560
  }
@@ -620,7 +610,6 @@ function createAgentInvocationWorker(options) {
620
610
  const result = outcome.result;
621
611
  const failed = result.diagnostics.outcome !== "success";
622
612
  await persistThreadStateById(invocation.childConversationId, {
623
- artifacts: result.artifactStatePatch ? { ...artifacts, ...result.artifactStatePatch } : artifacts,
624
613
  sandboxRef: result.sandboxRef ?? sandboxRef
625
614
  });
626
615
  if (result.piMessages?.length) {
@@ -5,7 +5,7 @@ import {
5
5
  logInfo,
6
6
  logWarn,
7
7
  setSpanAttributes
8
- } from "./chunk-B63BF443.js";
8
+ } from "./chunk-EAI67NTM.js";
9
9
  import {
10
10
  discoverInstalledPluginPackageContent,
11
11
  normalizePluginPackageNames
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-PB222GIA.js";
3
+ } from "./chunk-HWQGBIH7.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -1,6 +1,7 @@
1
1
  import {
2
- recordTaskExecution
3
- } from "./chunk-QSXZ42KX.js";
2
+ coerceThreadConversationState,
3
+ getPersistedThreadState
4
+ } from "./chunk-IL4EDBMV.js";
4
5
  import {
5
6
  pluginTaskId,
6
7
  pluginTaskParamsSchema,
@@ -9,33 +10,26 @@ import {
9
10
  import {
10
11
  calculateContextCompactionTargetTokens,
11
12
  estimateTextTokens,
13
+ fallbackShortTitle,
14
+ generateShortTitle,
12
15
  getConversationContextCompactionTriggerTokens
13
- } from "./chunk-T5GXFFLA.js";
16
+ } from "./chunk-4EA2SFK2.js";
14
17
  import {
15
18
  buildDeterministicTurnId,
16
19
  clearPendingAuth,
17
- coerceThreadConversationState,
18
- getPersistedThreadState,
19
20
  getPiMessageRole,
20
21
  getTurnRecord,
21
22
  hydrateConversationMessages,
22
23
  instructionTextForProjection,
23
24
  isToolResultError,
24
25
  isToolResultMessage,
25
- markTurnClosed,
26
26
  markTurnCompleted,
27
- mergeArtifactsState,
28
27
  normalizeToolNameFromResult,
29
- persistThreadStateById,
30
28
  stripRuntimeTurnContext
31
- } from "./chunk-GDQEU4I7.js";
29
+ } from "./chunk-VCYSOXON.js";
32
30
  import {
33
31
  JUNIOR_THREAD_STATE_TTL_MS
34
32
  } from "./chunk-3Y47VMHV.js";
35
- import {
36
- fallbackShortTitle,
37
- generateShortTitle
38
- } from "./chunk-W65V465O.js";
39
33
  import {
40
34
  createPluginConversationEvents,
41
35
  createPluginEmbedder,
@@ -43,15 +37,19 @@ import {
43
37
  createPluginModel,
44
38
  createPluginState,
45
39
  getPlugins
46
- } from "./chunk-SCGVWUZX.js";
40
+ } from "./chunk-ZCHIC2GM.js";
47
41
  import {
48
42
  getConversationStore,
49
43
  getDb,
50
44
  sameActorIdentity
51
- } from "./chunk-37EVZP66.js";
45
+ } from "./chunk-VRHTNBA6.js";
46
+ import {
47
+ juniorConversations,
48
+ juniorTaskExecutions
49
+ } from "./chunk-D3WPMGEX.js";
52
50
  import {
53
51
  getStateAdapter
54
- } from "./chunk-GYEKOX7N.js";
52
+ } from "./chunk-2B3PT3V2.js";
55
53
  import {
56
54
  ProviderError,
57
55
  botConfig,
@@ -59,7 +57,7 @@ import {
59
57
  findProviderError,
60
58
  getProviderErrorAttributes,
61
59
  getProviderErrorUserMessage
62
- } from "./chunk-MKRIZ4VG.js";
60
+ } from "./chunk-4GXJUYJV.js";
63
61
  import {
64
62
  credentialSubjectSchema
65
63
  } from "./chunk-RUIXF3YQ.js";
@@ -70,7 +68,7 @@ import {
70
68
  buildTurnFailureResponse,
71
69
  logWarn,
72
70
  setSpanAttributes
73
- } from "./chunk-B63BF443.js";
71
+ } from "./chunk-EAI67NTM.js";
74
72
 
75
73
  // src/chat/services/conversation-memory.ts
76
74
  var CONTEXT_MIN_LIVE_MESSAGES = 12;
@@ -238,7 +236,7 @@ function pruneCompactions(compactions) {
238
236
  const merged = compactions.slice(0, overflowCount);
239
237
  const mergedSummary = merged.map((entry) => entry.summary).join("\n").slice(0, 3500);
240
238
  const coveredMessageCount = merged.reduce(
241
- (count, entry) => count + entry.coveredMessageCount,
239
+ (count2, entry) => count2 + entry.coveredMessageCount,
242
240
  0
243
241
  );
244
242
  const compacted = {
@@ -255,6 +253,7 @@ async function summarizeConversationChunk(messages, conversation, context, deps)
255
253
  const result = await deps.completeText({
256
254
  modelId: botConfig.fastModelId,
257
255
  temperature: 0,
256
+ promptName: "junior.thread_compaction",
258
257
  messages: [
259
258
  {
260
259
  role: "user",
@@ -380,11 +379,6 @@ function getConversationMessageSlackTs(message) {
380
379
  // src/chat/runtime/delivered-turn-state.ts
381
380
  function buildDeliveredTurnStatePatch(args) {
382
381
  const conversation = structuredClone(args.conversation);
383
- const artifactStatePatch = {
384
- ...args.reply.artifactStatePatch ?? {},
385
- ...args.artifactStatePatch ?? {}
386
- };
387
- const artifacts = Object.keys(artifactStatePatch).length > 0 ? mergeArtifactsState(args.artifacts, artifactStatePatch) : void 0;
388
382
  clearPendingAuth(conversation, args.sessionId);
389
383
  markConversationMessage(conversation, args.userMessageId, {
390
384
  replied: true,
@@ -396,21 +390,17 @@ function buildDeliveredTurnStatePatch(args) {
396
390
  sessionId: args.sessionId
397
391
  });
398
392
  return {
399
- artifacts,
400
393
  conversation,
401
394
  sandboxRef: args.reply.sandboxRef
402
395
  };
403
396
  }
404
397
 
405
398
  // src/chat/plugins/task-runner.ts
406
- import {
407
- isPrivateSource,
408
- pluginRunContextSchema
409
- } from "@sentry/junior-plugin-api";
399
+ import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
410
400
 
411
401
  // src/chat/services/turn-session-routing.ts
412
402
  async function resolveTurnSessionRouting(args) {
413
- const conversationStore = args.conversationStore ?? (await import("./db-WWOMXWTT.js")).getConversationStore();
403
+ const conversationStore = args.conversationStore ?? (await import("./db-XUKZRFFK.js")).getConversationStore();
414
404
  const conversation = await conversationStore.get({
415
405
  conversationId: args.conversationId
416
406
  });
@@ -435,6 +425,273 @@ import {
435
425
  sourceSchema
436
426
  } from "@sentry/junior-plugin-api";
437
427
  import { z } from "zod";
428
+
429
+ // src/chat/tasks/execution-stats.ts
430
+ import {
431
+ and,
432
+ asc,
433
+ count,
434
+ desc,
435
+ eq,
436
+ gte,
437
+ inArray,
438
+ lte,
439
+ max,
440
+ or,
441
+ sql
442
+ } from "drizzle-orm";
443
+ var TASK_EXECUTION_TYPES = ["scheduled", "event"];
444
+ var TASK_EXECUTION_STATUSES = [
445
+ "blocked",
446
+ "completed",
447
+ "failed"
448
+ ];
449
+ function utcDate(nowMs) {
450
+ return new Date(nowMs).toISOString().slice(0, 10);
451
+ }
452
+ function emptyDay(date) {
453
+ return { date, event: 0, scheduled: 0 };
454
+ }
455
+ function emptyStatusDay(date) {
456
+ return { blocked: 0, completed: 0, date, failed: 0 };
457
+ }
458
+ async function recordTaskExecution(type, taskId, options) {
459
+ const namespace = options.namespace ?? "junior";
460
+ const nowMs = options.nowMs ?? Date.now();
461
+ const status = options.status ?? "completed";
462
+ try {
463
+ await getDb().insert(juniorTaskExecutions).values({
464
+ ...options.conversationId ? { conversationId: options.conversationId } : {},
465
+ executedAtMs: nowMs,
466
+ executionId: options.executionId,
467
+ kind: type,
468
+ namespace,
469
+ status,
470
+ taskId
471
+ }).onConflictDoNothing({
472
+ target: [
473
+ juniorTaskExecutions.kind,
474
+ juniorTaskExecutions.namespace,
475
+ juniorTaskExecutions.executionId
476
+ ]
477
+ });
478
+ } catch (error) {
479
+ logWarn("task.execution.stat_failed", {
480
+ error,
481
+ "app.task.execution.id": options.executionId,
482
+ "app.task.execution.namespace": namespace,
483
+ "app.task.execution.status": status,
484
+ "app.task.execution.task_id": taskId,
485
+ "app.task.execution.type": type
486
+ });
487
+ }
488
+ }
489
+ async function readTaskExecutionSummaries(type, namespace, options = {}) {
490
+ const sevenDaysAgoMs = (options.nowMs ?? Date.now()) - 7 * 24 * 60 * 60 * 1e3;
491
+ const db = getDb();
492
+ const latest = db.selectDistinctOn([juniorTaskExecutions.taskId], {
493
+ conversationId: juniorTaskExecutions.conversationId,
494
+ taskId: juniorTaskExecutions.taskId
495
+ }).from(juniorTaskExecutions).where(
496
+ and(
497
+ eq(juniorTaskExecutions.kind, type),
498
+ eq(juniorTaskExecutions.namespace, namespace)
499
+ )
500
+ ).orderBy(
501
+ juniorTaskExecutions.taskId,
502
+ desc(juniorTaskExecutions.executedAtMs),
503
+ desc(juniorTaskExecutions.executionId)
504
+ ).as("latest_task_execution");
505
+ const rows = await db.select({
506
+ lastConversationId: latest.conversationId,
507
+ lastExecutedAtMs: max(juniorTaskExecutions.executedAtMs),
508
+ runsLast7Days: sql`count(*) filter (where ${juniorTaskExecutions.executedAtMs} >= ${sevenDaysAgoMs})::int`,
509
+ taskId: juniorTaskExecutions.taskId,
510
+ totalRuns: sql`count(*)::int`
511
+ }).from(juniorTaskExecutions).innerJoin(latest, eq(latest.taskId, juniorTaskExecutions.taskId)).where(
512
+ and(
513
+ eq(juniorTaskExecutions.kind, type),
514
+ eq(juniorTaskExecutions.namespace, namespace)
515
+ )
516
+ ).groupBy(juniorTaskExecutions.taskId, latest.conversationId);
517
+ return new Map(
518
+ rows.map((row) => [
519
+ row.taskId,
520
+ {
521
+ ...row.lastConversationId ? { lastConversationId: row.lastConversationId } : {},
522
+ ...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } : {},
523
+ runsLast7Days: row.runsLast7Days,
524
+ totalRuns: row.totalRuns
525
+ }
526
+ ])
527
+ );
528
+ }
529
+ async function readTaskExecutionDays(dayCount = 90, options = {}) {
530
+ const nowMs = options.nowMs ?? Date.now();
531
+ const end = utcDate(nowMs);
532
+ const endMs = Date.parse(`${end}T23:59:59.999Z`);
533
+ const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
534
+ const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
535
+ const rows = await getDb().select({
536
+ count: count(),
537
+ date: executionDate,
538
+ kind: juniorTaskExecutions.kind
539
+ }).from(juniorTaskExecutions).where(
540
+ and(
541
+ gte(juniorTaskExecutions.executedAtMs, startMs),
542
+ lte(juniorTaskExecutions.executedAtMs, endMs),
543
+ eq(juniorTaskExecutions.status, "completed")
544
+ )
545
+ ).groupBy(executionDate, juniorTaskExecutions.kind).orderBy(asc(executionDate), asc(juniorTaskExecutions.kind));
546
+ const byDate = /* @__PURE__ */ new Map();
547
+ for (let offset = 0; offset < dayCount; offset += 1) {
548
+ const date = utcDate(startMs + offset * 864e5);
549
+ byDate.set(date, emptyDay(date));
550
+ }
551
+ for (const row of rows) {
552
+ const day = byDate.get(row.date);
553
+ if (!day) continue;
554
+ if (row.kind === "scheduled") day.scheduled = row.count;
555
+ else if (row.kind === "event") day.event = row.count;
556
+ }
557
+ return [...byDate.values()];
558
+ }
559
+ async function readTaskExecutionByConversationId(args) {
560
+ const namespace = args.namespace ?? "junior";
561
+ const rows = await getDb().select({
562
+ kind: juniorTaskExecutions.kind,
563
+ taskId: juniorTaskExecutions.taskId
564
+ }).from(juniorTaskExecutions).where(
565
+ and(
566
+ eq(juniorTaskExecutions.conversationId, args.conversationId),
567
+ eq(juniorTaskExecutions.namespace, namespace),
568
+ inArray(juniorTaskExecutions.kind, [...TASK_EXECUTION_TYPES])
569
+ )
570
+ ).orderBy(
571
+ desc(juniorTaskExecutions.executedAtMs),
572
+ desc(juniorTaskExecutions.executionId)
573
+ ).limit(1);
574
+ const row = rows[0];
575
+ if (!row) return void 0;
576
+ if (row.kind !== "scheduled" && row.kind !== "event") return void 0;
577
+ return { kind: row.kind, taskId: row.taskId };
578
+ }
579
+ async function readTaskExecutions(args) {
580
+ const namespace = args.namespace ?? "junior";
581
+ const rows = await getDb().select({
582
+ conversationId: juniorTaskExecutions.conversationId,
583
+ executedAtMs: juniorTaskExecutions.executedAtMs,
584
+ executionId: juniorTaskExecutions.executionId,
585
+ status: juniorTaskExecutions.status,
586
+ title: juniorConversations.title
587
+ }).from(juniorTaskExecutions).leftJoin(
588
+ juniorConversations,
589
+ eq(
590
+ juniorConversations.conversationId,
591
+ juniorTaskExecutions.conversationId
592
+ )
593
+ ).where(
594
+ and(
595
+ eq(juniorTaskExecutions.kind, args.kind),
596
+ eq(juniorTaskExecutions.namespace, namespace),
597
+ eq(juniorTaskExecutions.taskId, args.taskId)
598
+ )
599
+ ).orderBy(
600
+ desc(juniorTaskExecutions.executedAtMs),
601
+ desc(juniorTaskExecutions.executionId)
602
+ ).limit(args.limit);
603
+ return rows.map((row) => {
604
+ const title = row.title?.trim();
605
+ return {
606
+ ...row.conversationId ? { conversationId: row.conversationId } : {},
607
+ executedAt: new Date(row.executedAtMs).toISOString(),
608
+ executionId: row.executionId,
609
+ status: row.status,
610
+ ...title ? { title } : {}
611
+ };
612
+ });
613
+ }
614
+ async function readTaskRuns(args) {
615
+ if (args.tasks.length === 0) return [];
616
+ const namespace = args.namespace ?? "junior";
617
+ const selectors = args.tasks.map(
618
+ (task) => and(
619
+ eq(juniorTaskExecutions.kind, task.kind),
620
+ eq(juniorTaskExecutions.taskId, task.taskId)
621
+ )
622
+ );
623
+ const rows = await getDb().select({
624
+ conversationId: juniorTaskExecutions.conversationId,
625
+ executedAtMs: juniorTaskExecutions.executedAtMs,
626
+ executionId: juniorTaskExecutions.executionId,
627
+ kind: juniorTaskExecutions.kind,
628
+ status: juniorTaskExecutions.status,
629
+ taskId: juniorTaskExecutions.taskId,
630
+ title: juniorConversations.title
631
+ }).from(juniorTaskExecutions).leftJoin(
632
+ juniorConversations,
633
+ eq(
634
+ juniorConversations.conversationId,
635
+ juniorTaskExecutions.conversationId
636
+ )
637
+ ).where(and(eq(juniorTaskExecutions.namespace, namespace), or(...selectors))).orderBy(
638
+ desc(juniorTaskExecutions.executedAtMs),
639
+ desc(juniorTaskExecutions.executionId)
640
+ ).limit(args.limit);
641
+ return rows.flatMap((row) => {
642
+ if (row.kind !== "scheduled" && row.kind !== "event") return [];
643
+ const title = row.title?.trim();
644
+ return [
645
+ {
646
+ ...row.conversationId ? { conversationId: row.conversationId } : {},
647
+ executedAt: new Date(row.executedAtMs).toISOString(),
648
+ executionId: row.executionId,
649
+ kind: row.kind,
650
+ status: row.status,
651
+ taskId: row.taskId,
652
+ ...title ? { title } : {}
653
+ }
654
+ ];
655
+ });
656
+ }
657
+ async function readTaskExecutionStatusDays(args) {
658
+ const dayCount = args.dayCount ?? 90;
659
+ const namespace = args.namespace ?? "junior";
660
+ const nowMs = args.nowMs ?? Date.now();
661
+ const end = utcDate(nowMs);
662
+ const endMs = Date.parse(`${end}T23:59:59.999Z`);
663
+ const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
664
+ const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
665
+ const rows = await getDb().select({
666
+ count: count(),
667
+ date: executionDate,
668
+ status: juniorTaskExecutions.status
669
+ }).from(juniorTaskExecutions).where(
670
+ and(
671
+ eq(juniorTaskExecutions.kind, args.kind),
672
+ eq(juniorTaskExecutions.namespace, namespace),
673
+ eq(juniorTaskExecutions.taskId, args.taskId),
674
+ gte(juniorTaskExecutions.executedAtMs, startMs),
675
+ lte(juniorTaskExecutions.executedAtMs, endMs),
676
+ inArray(juniorTaskExecutions.status, [...TASK_EXECUTION_STATUSES])
677
+ )
678
+ ).groupBy(executionDate, juniorTaskExecutions.status).orderBy(asc(executionDate), asc(juniorTaskExecutions.status));
679
+ const byDate = /* @__PURE__ */ new Map();
680
+ for (let offset = 0; offset < dayCount; offset += 1) {
681
+ const date = utcDate(startMs + offset * 864e5);
682
+ byDate.set(date, emptyStatusDay(date));
683
+ }
684
+ for (const row of rows) {
685
+ const day = byDate.get(row.date);
686
+ if (!day) continue;
687
+ if (row.status === "completed") day.completed = row.count;
688
+ else if (row.status === "failed") day.failed = row.count;
689
+ else if (row.status === "blocked") day.blocked = row.count;
690
+ }
691
+ return [...byDate.values()];
692
+ }
693
+
694
+ // src/chat/agent-dispatch/store.ts
438
695
  var DISPATCH_PREFIX = "junior:agent_dispatch";
439
696
  var DISPATCH_LOCK_TTL_MS = 10 * 60 * 1e3;
440
697
  var DISPATCH_MAILBOX_APPEND_INDEX_LOCK_TTL_MS = 1e4;
@@ -946,8 +1203,15 @@ function messageExistedAtRunCompletion(message, completedAtMs) {
946
1203
  return messageTimestampMs !== void 0 && messageTimestampMs <= completedAtMs;
947
1204
  }
948
1205
  async function loadConversationContextTranscriptEntries(record, source, runActor) {
949
- if (source.platform !== "slack" || isPrivateSource(source)) {
950
- return [];
1206
+ switch (source.platform) {
1207
+ case "slack":
1208
+ if (source.visibility === "private") {
1209
+ return [];
1210
+ }
1211
+ break;
1212
+ case "web":
1213
+ case "local":
1214
+ return [];
951
1215
  }
952
1216
  const state = await getPersistedThreadState(record.conversationId);
953
1217
  const conversation = coerceThreadConversationState(state);
@@ -1234,37 +1498,14 @@ function getTurnUserReplyAttachmentContext(message) {
1234
1498
  };
1235
1499
  }
1236
1500
 
1237
- // src/chat/runtime/auth-pause-state.ts
1238
- function completeAuthPauseTurn(args) {
1239
- markConversationMessage(
1240
- args.conversation,
1241
- getTurnUserMessageId(args.conversation, args.sessionId),
1242
- {
1243
- replied: true,
1244
- skippedReason: void 0
1245
- }
1246
- );
1247
- markTurnClosed({
1248
- conversation: args.conversation,
1249
- nowMs: Date.now(),
1250
- sessionId: args.sessionId
1251
- });
1252
- }
1253
- async function persistAuthPauseTurnState(args) {
1254
- const currentState = await getPersistedThreadState(args.threadStateId);
1255
- const conversation = coerceThreadConversationState(currentState);
1256
- await hydrateConversationMessages({
1257
- conversation,
1258
- conversationId: args.threadStateId
1259
- });
1260
- completeAuthPauseTurn({
1261
- conversation,
1262
- sessionId: args.sessionId
1263
- });
1264
- await persistThreadStateById(args.threadStateId, { conversation });
1265
- }
1266
-
1267
1501
  export {
1502
+ recordTaskExecution,
1503
+ readTaskExecutionSummaries,
1504
+ readTaskExecutionDays,
1505
+ readTaskExecutionByConversationId,
1506
+ readTaskExecutions,
1507
+ readTaskRuns,
1508
+ readTaskExecutionStatusDays,
1268
1509
  getDispatchConversationId,
1269
1510
  getDispatchInputMessageId,
1270
1511
  getDispatchInputMessageIds,
@@ -1303,7 +1544,5 @@ export {
1303
1544
  getInterruptionMarker,
1304
1545
  requireTurnFailureEventId,
1305
1546
  getAgentTurnDiagnosticsAttributes,
1306
- finalizeFailedTurnReplyWithEvent,
1307
- completeAuthPauseTurn,
1308
- persistAuthPauseTurnState
1547
+ finalizeFailedTurnReplyWithEvent
1309
1548
  };