@sentry/junior 0.187.0 → 0.189.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/{agent-hooks-XVAE2554.js → agent-hooks-6QRYH6PX.js} +11 -11
  2. package/dist/api/acp/conversations.d.ts +2 -2
  3. package/dist/api/conversations/list.d.ts +7 -0
  4. package/dist/api/people/shared.d.ts +54 -0
  5. package/dist/api.js +41 -52
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1001 -338
  8. package/dist/{catalog-runtime-DWFAC562.js → catalog-runtime-IETJLJFG.js} +4 -4
  9. package/dist/chat/agent/resume.d.ts +0 -2
  10. package/dist/chat/agent/types.d.ts +9 -14
  11. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  12. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  13. package/dist/chat/agent-invocations/types.d.ts +296 -24
  14. package/dist/chat/app/conversation-work.d.ts +16 -8
  15. package/dist/chat/conversation-privacy.d.ts +7 -7
  16. package/dist/chat/conversations/destination.d.ts +12 -0
  17. package/dist/chat/conversations/location.d.ts +3 -8
  18. package/dist/chat/conversations/projection.d.ts +2 -2
  19. package/dist/chat/conversations/sql/location.d.ts +13 -4
  20. package/dist/chat/{api-turns → conversations}/stop.d.ts +2 -2
  21. package/dist/chat/conversations/store.d.ts +8 -11
  22. package/dist/chat/conversations/structured-events.d.ts +1 -1
  23. package/dist/chat/{api-turns/authorization.d.ts → conversations/web-authorization.d.ts} +1 -0
  24. package/dist/chat/conversations/web-input.d.ts +98 -0
  25. package/dist/chat/conversations/web-mailbox.d.ts +12 -0
  26. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  27. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  28. package/dist/chat/resource-events/actor.d.ts +13 -12
  29. package/dist/chat/resource-events/notification.d.ts +1 -1
  30. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  31. package/dist/chat/services/turn-session-routing.d.ts +5 -5
  32. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  33. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  34. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  35. package/dist/chat/task-execution/mailbox-turn.d.ts +42 -0
  36. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  37. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  38. package/dist/{chunk-WL3R2KTS.js → chunk-4RHJ3CXR.js} +90 -289
  39. package/dist/{chunk-U6ZQHRIP.js → chunk-5CXCGDIL.js} +1 -1
  40. package/dist/{chunk-HXR3FHTE.js → chunk-5VWAY27R.js} +7 -3
  41. package/dist/{chunk-D3GDGREI.js → chunk-6AUR6PWR.js} +3 -3
  42. package/dist/{chunk-EIWYZXSM.js → chunk-7R5JRPCY.js} +8 -6
  43. package/dist/{chunk-WRDW3A3D.js → chunk-AC7MDOJW.js} +5 -7
  44. package/dist/{chunk-URZ7UD4P.js → chunk-BYBSI5TI.js} +2 -2
  45. package/dist/{chunk-MUPPP7A7.js → chunk-CMWIMFM6.js} +4 -182
  46. package/dist/{chunk-WKIS4VRK.js → chunk-CUYFCI4G.js} +70 -39
  47. package/dist/chunk-DA2KGZZI.js +13 -0
  48. package/dist/{chunk-Q6OCUQ7W.js → chunk-DYXVAO2E.js} +1 -1
  49. package/dist/{chunk-QH3I7ZOK.js → chunk-E3PDZPGV.js} +1 -1
  50. package/dist/{chunk-NU775DLU.js → chunk-GP32KD2J.js} +4 -12
  51. package/dist/{chunk-STF4GSK4.js → chunk-KN32OWL2.js} +5 -5
  52. package/dist/chunk-LHKZKAZ4.js +285 -0
  53. package/dist/{chunk-D5BWM37G.js → chunk-MFSET7Q7.js} +51 -341
  54. package/dist/{chunk-DUE4EUNL.js → chunk-MI6ZBDTS.js} +6 -6
  55. package/dist/{chunk-27T5HZHO.js → chunk-MRXMFB4L.js} +6 -87
  56. package/dist/{chunk-4A2R3AQB.js → chunk-MVPLEPSI.js} +1 -1
  57. package/dist/{chunk-7LRRVMPH.js → chunk-NY2F7BZA.js} +1 -1
  58. package/dist/chunk-O35GZCKL.js +311 -0
  59. package/dist/{chunk-U3KMII5Y.js → chunk-OEIITG5F.js} +1 -1
  60. package/dist/{chunk-6FKNNUSN.js → chunk-PCPSX4ES.js} +209 -7
  61. package/dist/{chunk-6YCIYOVA.js → chunk-PY3EIEAF.js} +1 -1
  62. package/dist/{chunk-U5POFCKM.js → chunk-QNIOBNOY.js} +284 -123
  63. package/dist/{chunk-JCRXXEMC.js → chunk-S3SGZUOI.js} +1 -1
  64. package/dist/chunk-SR6OMO5C.js +703 -0
  65. package/dist/{chunk-TQHCZXN7.js → chunk-UCWO5MKP.js} +7 -7
  66. package/dist/{chunk-ITLYUKGZ.js → chunk-VKQWU4PO.js} +2 -2
  67. package/dist/{chunk-JZPDYKRG.js → chunk-WDHPN2GH.js} +3 -3
  68. package/dist/{chunk-P2VU5JNH.js → chunk-WMUAKAIF.js} +42 -42
  69. package/dist/{chunk-NIKLTFBP.js → chunk-WN6VLHOU.js} +12 -5
  70. package/dist/{chunk-VC343WHM.js → chunk-WWYUYKKV.js} +1 -1
  71. package/dist/{chunk-OM4SFFJK.js → chunk-WYDF6PGK.js} +3 -3
  72. package/dist/{chunk-KRYJ5VOD.js → chunk-YNZPOFF3.js} +16 -21
  73. package/dist/{chunk-Z6OHCDXP.js → chunk-YYSEH2WC.js} +2 -2
  74. package/dist/{chunk-BITZUBPJ.js → chunk-YYZNESC3.js} +8 -8
  75. package/dist/{chunk-2VUDJGB6.js → chunk-ZUPDSJUE.js} +2 -5
  76. package/dist/{chunk-X5SXFVZT.js → chunk-ZV6PFUA4.js} +1 -1
  77. package/dist/cli/chat.js +34 -33
  78. package/dist/cli/check.js +5 -5
  79. package/dist/cli/plugins.js +12 -12
  80. package/dist/cli/snapshot-create.js +9 -9
  81. package/dist/cli/upgrade.js +6 -6
  82. package/dist/db/schema/conversations.d.ts +62 -0
  83. package/dist/db/schema.d.ts +31 -0
  84. package/dist/{db-FBHAWVXU.js → db-LPJKR2EO.js} +6 -6
  85. package/dist/instrumentation.js +3 -3
  86. package/dist/nitro.js +6 -6
  87. package/dist/{oauth-callback-server-5HS5ULC6.js → oauth-callback-server-DMXF4TTQ.js} +30 -28
  88. package/dist/{runner-46W6NV6B.js → runner-L5DPVYCN.js} +24 -20
  89. package/dist/{skills-TG3QC4B6.js → skills-NXG3LBCK.js} +5 -5
  90. package/dist/spawn-VRUIGKWW.js +42 -0
  91. package/dist/task-runner-7YTBSPXW.js +36 -0
  92. package/dist/{validation-GMRIDBC5.js → validation-CH36LTOS.js} +5 -5
  93. package/dist/version.js +1 -1
  94. package/dist/{work-W4ULBJTU.js → work-HBC5Y5VZ.js} +22 -21
  95. package/dist/{worker-M6NVACS2.js → worker-5RDZHLXH.js} +10 -10
  96. package/migrations/0037_conversation_location.sql +23 -0
  97. package/migrations/meta/0037_snapshot.json +3192 -0
  98. package/migrations/meta/_journal.json +7 -0
  99. package/package.json +4 -4
  100. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  101. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  102. package/dist/chat/api-turns/routing.d.ts +0 -51
  103. package/dist/chat/api-turns/work.d.ts +0 -99
  104. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -47
  105. package/dist/chunk-4YD3DET6.js +0 -1503
  106. package/dist/chunk-6FGN7ZEG.js +0 -221
  107. package/dist/spawn-Y6YWBIJS.js +0 -41
  108. package/dist/task-runner-YSGBPN4U.js +0 -34
@@ -1,3 +1,6 @@
1
+ import {
2
+ isExperimentalFeatureEnabled
3
+ } from "./chunk-2LYHWMR4.js";
1
4
  import {
2
5
  SlackActionError,
3
6
  applyPluginFormatMarkdown,
@@ -5,19 +8,19 @@ import {
5
8
  isDmChannel,
6
9
  normalizeSlackConversationId,
7
10
  withSlackRetries
8
- } from "./chunk-DUE4EUNL.js";
11
+ } from "./chunk-MI6ZBDTS.js";
9
12
  import {
10
13
  parseDestination
11
- } from "./chunk-WKIS4VRK.js";
14
+ } from "./chunk-CUYFCI4G.js";
12
15
  import {
13
16
  getStateAdapter
14
- } from "./chunk-U6ZQHRIP.js";
17
+ } from "./chunk-5CXCGDIL.js";
15
18
  import {
16
19
  normalizeSlackEmojiName
17
- } from "./chunk-URZ7UD4P.js";
20
+ } from "./chunk-BYBSI5TI.js";
18
21
  import {
19
22
  pluginCatalogRuntime
20
- } from "./chunk-QH3I7ZOK.js";
23
+ } from "./chunk-E3PDZPGV.js";
21
24
  import {
22
25
  parseSlackMessageTs,
23
26
  parseSlackUserId
@@ -26,7 +29,198 @@ import {
26
29
  isRecord,
27
30
  logInfo,
28
31
  logWarn
29
- } from "./chunk-6YCIYOVA.js";
32
+ } from "./chunk-PY3EIEAF.js";
33
+
34
+ // src/chat/agent/types.ts
35
+ var RetryableDeliveryError = class extends Error {
36
+ constructor(cause) {
37
+ super("Assistant delivery was transient or ambiguous", { cause });
38
+ this.name = "RetryableDeliveryError";
39
+ }
40
+ };
41
+ function isAgentRunFeatureDisabled(disabledFeatures, feature) {
42
+ return disabledFeatures?.includes(feature) ?? false;
43
+ }
44
+ function actorFromRun(run) {
45
+ if (run.dispatch?.actor) {
46
+ return run.dispatch.actor;
47
+ }
48
+ if (run.actor) {
49
+ return run.actor;
50
+ }
51
+ if (run.credentialContext && !("type" in run.credentialContext.actor)) {
52
+ return run.credentialContext.actor;
53
+ }
54
+ return void 0;
55
+ }
56
+ function assertRunConsistency(run) {
57
+ const { destination, source } = run;
58
+ switch (source.platform) {
59
+ case "slack": {
60
+ if (destination.platform !== "slack") {
61
+ throw new TypeError(
62
+ "Run source and destination platforms do not match"
63
+ );
64
+ }
65
+ if (source.teamId !== destination.teamId) {
66
+ throw new TypeError("Slack source and destination teams do not match");
67
+ }
68
+ break;
69
+ }
70
+ case "local": {
71
+ if (destination.platform !== "local") {
72
+ throw new TypeError(
73
+ "Run source and destination platforms do not match"
74
+ );
75
+ }
76
+ if (source.conversationId !== destination.conversationId) {
77
+ throw new TypeError(
78
+ "Source and destination conversation IDs do not match"
79
+ );
80
+ }
81
+ if (run.surface !== "internal" && destination.conversationId !== run.conversationId) {
82
+ throw new TypeError(
83
+ "Source, destination, and run conversation IDs do not match"
84
+ );
85
+ }
86
+ break;
87
+ }
88
+ case "web": {
89
+ if (run.surface !== "internal" && source.conversationId !== run.conversationId) {
90
+ throw new TypeError("Web source and run conversation IDs do not match");
91
+ }
92
+ switch (destination.platform) {
93
+ case "local": {
94
+ if (source.conversationId !== destination.conversationId) {
95
+ throw new TypeError(
96
+ "Source and destination conversation IDs do not match"
97
+ );
98
+ }
99
+ if (run.surface !== "internal" && destination.conversationId !== run.conversationId) {
100
+ throw new TypeError(
101
+ "Source, destination, and run conversation IDs do not match"
102
+ );
103
+ }
104
+ break;
105
+ }
106
+ case "slack":
107
+ break;
108
+ }
109
+ break;
110
+ }
111
+ }
112
+ const actor = run.dispatch?.actor ?? run.actor;
113
+ if (!actor || actor.platform === "system") {
114
+ return;
115
+ }
116
+ if (actor.platform !== source.platform) {
117
+ throw new TypeError(
118
+ `Actor platform "${actor.platform}" does not match Source platform "${source.platform}"`
119
+ );
120
+ }
121
+ if (actor.platform === "slack" && source.platform === "slack" && actor.teamId !== source.teamId) {
122
+ throw new TypeError("Slack Actor team does not match Source team");
123
+ }
124
+ }
125
+ function toolInvocationDestination(run) {
126
+ if (run.destination.platform !== "slack" || !run.toolChannelId) {
127
+ return run.destination;
128
+ }
129
+ return {
130
+ platform: "slack",
131
+ teamId: run.destination.teamId,
132
+ channelId: run.toolChannelId
133
+ };
134
+ }
135
+ function surfaceFromRun(run) {
136
+ if (run.surface) {
137
+ return run.surface;
138
+ }
139
+ if (run.source.platform === "slack") {
140
+ return "slack";
141
+ }
142
+ if (run.source.platform === "web") {
143
+ return "api";
144
+ }
145
+ return "internal";
146
+ }
147
+
148
+ // src/chat/runtime/agent-runner.ts
149
+ var AGENT_ABORT_SETTLE_GRACE_MS = 5e3;
150
+ function createAgentRunner(execute, options) {
151
+ const attachmentStorage = options?.attachmentStorage;
152
+ const streamFn = options?.streamFn;
153
+ const tracePropagation = options?.tracePropagation;
154
+ const bindSpawnAgent = options?.bindSpawnAgent;
155
+ const canBindSpawn = Boolean(bindSpawnAgent) && isExperimentalFeatureEnabled("subagents");
156
+ return {
157
+ run: async (run) => {
158
+ const spawnAgent = bindSpawnAgent && canBindSpawn && !isAgentRunFeatureDisabled(run.disabledFeatures, "subagents") ? bindSpawnAgent(run) : void 0;
159
+ const nextRun = {
160
+ ...run,
161
+ environment: {
162
+ ...run.environment,
163
+ attachmentStorage: run.environment?.attachmentStorage ?? attachmentStorage,
164
+ sandboxTracePropagation: run.environment?.sandboxTracePropagation ?? tracePropagation
165
+ },
166
+ ...spawnAgent ? {
167
+ durability: {
168
+ ...run.durability,
169
+ spawnAgent
170
+ }
171
+ } : void 0
172
+ };
173
+ return await execute(nextRun, streamFn);
174
+ }
175
+ };
176
+ }
177
+ async function waitForAgentSettlement(runPromise) {
178
+ let timeoutId;
179
+ const settleGrace = new Promise((resolve) => {
180
+ timeoutId = setTimeout(resolve, AGENT_ABORT_SETTLE_GRACE_MS);
181
+ timeoutId.unref?.();
182
+ });
183
+ await Promise.race([
184
+ runPromise.then(
185
+ () => void 0,
186
+ () => void 0
187
+ ),
188
+ settleGrace
189
+ ]);
190
+ if (timeoutId) {
191
+ clearTimeout(timeoutId);
192
+ }
193
+ }
194
+ async function runAgentWithTimeout(agentRunner, run, timeoutMs) {
195
+ if (typeof timeoutMs !== "number") {
196
+ return await agentRunner.run(run);
197
+ }
198
+ const timeoutError = new Error(
199
+ `executeAgentRun timed out after ${timeoutMs}ms`
200
+ );
201
+ const abortController = new AbortController();
202
+ const signal = run.signal ? AbortSignal.any([run.signal, abortController.signal]) : abortController.signal;
203
+ const runPromise = agentRunner.run({ ...run, signal });
204
+ let timeoutId;
205
+ const timeoutPromise = new Promise((_, reject) => {
206
+ timeoutId = setTimeout(() => {
207
+ abortController.abort(timeoutError);
208
+ reject(timeoutError);
209
+ }, timeoutMs);
210
+ });
211
+ try {
212
+ return await Promise.race([runPromise, timeoutPromise]);
213
+ } catch (error) {
214
+ if (abortController.signal.aborted) {
215
+ await waitForAgentSettlement(runPromise);
216
+ }
217
+ throw error;
218
+ } finally {
219
+ if (timeoutId) {
220
+ clearTimeout(timeoutId);
221
+ }
222
+ }
223
+ }
30
224
 
31
225
  // src/chat/slack/outbound.ts
32
226
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -705,6 +899,12 @@ async function startOAuthFlow(provider, input) {
705
899
  }
706
900
 
707
901
  export {
902
+ RetryableDeliveryError,
903
+ isAgentRunFeatureDisabled,
904
+ actorFromRun,
905
+ assertRunConsistency,
906
+ toolInvocationDestination,
907
+ surfaceFromRun,
708
908
  getSlackMessagePermalink,
709
909
  postSlackMessage,
710
910
  uploadFilesToConversation,
@@ -719,5 +919,7 @@ export {
719
919
  formatProviderLabel,
720
920
  resolveBaseUrl,
721
921
  deliverOAuthAuthorization,
722
- startOAuthFlow
922
+ startOAuthFlow,
923
+ createAgentRunner,
924
+ runAgentWithTimeout
723
925
  };
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-PEQXYSSE.js";
13
13
  import {
14
14
  JUNIOR_VERSION
15
- } from "./chunk-7LRRVMPH.js";
15
+ } from "./chunk-NY2F7BZA.js";
16
16
 
17
17
  // src/deployment.ts
18
18
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";