@sentry/junior 0.71.3 → 0.73.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 (103) hide show
  1. package/bin/junior.mjs +22 -10
  2. package/dist/api-reference.d.ts +2 -0
  3. package/dist/app.d.ts +12 -3
  4. package/dist/app.js +2522 -15560
  5. package/dist/chat/agent-dispatch/heartbeat.d.ts +0 -6
  6. package/dist/chat/agent-dispatch/runner.d.ts +2 -0
  7. package/dist/chat/agent-dispatch/store.d.ts +2 -2
  8. package/dist/chat/agent-dispatch/types.d.ts +6 -3
  9. package/dist/chat/agent-dispatch/validation.d.ts +2 -3
  10. package/dist/chat/app/production.d.ts +8 -1
  11. package/dist/chat/app/services.d.ts +7 -0
  12. package/dist/chat/destination.d.ts +3 -1
  13. package/dist/chat/logging.d.ts +3 -0
  14. package/dist/chat/mcp/errors.d.ts +3 -0
  15. package/dist/chat/mcp/tool-manager.d.ts +5 -1
  16. package/dist/chat/oauth-flow.d.ts +1 -1
  17. package/dist/chat/plugins/agent-hooks.d.ts +3 -2
  18. package/dist/chat/plugins/registry.d.ts +2 -0
  19. package/dist/chat/plugins/types.d.ts +2 -0
  20. package/dist/chat/prompt.d.ts +4 -1
  21. package/dist/chat/requester.d.ts +67 -0
  22. package/dist/chat/respond.d.ts +8 -8
  23. package/dist/chat/runtime/agent-continue-runner.d.ts +25 -0
  24. package/dist/chat/runtime/reply-executor.d.ts +7 -5
  25. package/dist/chat/runtime/slack-resume.d.ts +3 -3
  26. package/dist/chat/runtime/slack-runtime.d.ts +13 -3
  27. package/dist/chat/runtime/turn.d.ts +17 -3
  28. package/dist/chat/sandbox/egress-credentials.d.ts +5 -2
  29. package/dist/chat/sandbox/egress-policy.d.ts +5 -1
  30. package/dist/chat/sandbox/egress-proxy.d.ts +2 -0
  31. package/dist/chat/sandbox/egress-schemas.d.ts +4 -0
  32. package/dist/chat/sandbox/egress-session.d.ts +3 -1
  33. package/dist/chat/sandbox/egress-tracing.d.ts +7 -0
  34. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  35. package/dist/chat/sandbox/session.d.ts +3 -2
  36. package/dist/chat/services/agent-continue.d.ts +27 -0
  37. package/dist/chat/services/auth-pause-response.d.ts +1 -1
  38. package/dist/chat/services/auth-pause.d.ts +2 -1
  39. package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
  40. package/dist/chat/services/message-actor-identity.d.ts +12 -4
  41. package/dist/chat/services/plugin-auth-orchestration.d.ts +9 -8
  42. package/dist/chat/services/turn-result.d.ts +3 -0
  43. package/dist/chat/services/turn-session-record.d.ts +10 -7
  44. package/dist/chat/slack/user.d.ts +4 -4
  45. package/dist/chat/state/adapter.d.ts +2 -0
  46. package/dist/chat/state/conversation-details.d.ts +4 -3
  47. package/dist/chat/state/session-log.d.ts +43 -0
  48. package/dist/chat/state/turn-session.d.ts +7 -10
  49. package/dist/chat/task-execution/slack-work.d.ts +5 -5
  50. package/dist/chat/task-execution/store.d.ts +83 -48
  51. package/dist/chat/task-execution/worker.d.ts +3 -3
  52. package/dist/chat/tools/definition.d.ts +3 -0
  53. package/dist/chat/tools/execution/tool-error-handler.d.ts +2 -1
  54. package/dist/chat/tools/slack/canvas-tools.d.ts +3 -2
  55. package/dist/chat/tools/slack/channel-list-messages.d.ts +2 -2
  56. package/dist/chat/tools/slack/channel-post-message.d.ts +3 -2
  57. package/dist/chat/tools/slack/context.d.ts +15 -2
  58. package/dist/chat/tools/slack/message-add-reaction.d.ts +3 -2
  59. package/dist/chat/tools/slack/thread-read.d.ts +2 -2
  60. package/dist/chat/tools/types.d.ts +20 -23
  61. package/dist/{chunk-BBXYXOJW.js → chunk-3BYAPS6B.js} +48 -529
  62. package/dist/{chunk-UXG6TU2U.js → chunk-7Q5YOUUT.js} +16 -93
  63. package/dist/chunk-AL5T52ZD.js +1119 -0
  64. package/dist/chunk-CYUI7JU5.js +195 -0
  65. package/dist/{chunk-R62YWUNO.js → chunk-DIMX5F3T.js} +10 -28
  66. package/dist/chunk-G3E7SCME.js +28 -0
  67. package/dist/chunk-KVZL5NZS.js +519 -0
  68. package/dist/chunk-M4FLLXXD.js +212 -0
  69. package/dist/chunk-OQSYYOLM.js +12787 -0
  70. package/dist/{chunk-GT67ZWZQ.js → chunk-OR6NQJ5E.js} +5 -3
  71. package/dist/{chunk-B5HKWWQB.js → chunk-RY6AL5C7.js} +8 -6
  72. package/dist/chunk-SJHUF3DP.js +43 -0
  73. package/dist/{chunk-XE2VFQQN.js → chunk-UOTZ3EEQ.js} +1 -1
  74. package/dist/{chunk-HOGQL2H6.js → chunk-UZVHXZ7V.js} +1357 -1486
  75. package/dist/{chunk-76YMBKW7.js → chunk-V4VYUY4A.js} +27 -14
  76. package/dist/{chunk-JS4HURDT.js → chunk-WS2EG3GW.js} +224 -224
  77. package/dist/chunk-ZDA2HYX5.js +275 -0
  78. package/dist/cli/chat.js +205 -0
  79. package/dist/cli/check.js +6 -5
  80. package/dist/cli/run.js +18 -2
  81. package/dist/cli/snapshot-warmup.js +11 -8
  82. package/dist/cli/upgrade.js +599 -0
  83. package/dist/deployment.d.ts +4 -0
  84. package/dist/handlers/agent-dispatch.d.ts +6 -1
  85. package/dist/handlers/mcp-oauth-callback.d.ts +6 -1
  86. package/dist/handlers/oauth-callback.d.ts +6 -1
  87. package/dist/handlers/sandbox-egress-proxy.d.ts +2 -0
  88. package/dist/handlers/webhooks.d.ts +4 -2
  89. package/dist/instrumentation.js +17 -2
  90. package/dist/nitro.d.ts +1 -1
  91. package/dist/nitro.js +10 -10
  92. package/dist/plugins.d.ts +1 -1
  93. package/dist/reporting/conversations.d.ts +116 -0
  94. package/dist/reporting.d.ts +24 -129
  95. package/dist/reporting.js +320 -166
  96. package/dist/runner-LMAM4OGD.js +259 -0
  97. package/package.json +3 -3
  98. package/dist/chat/runtime/timeout-resume-runner.d.ts +0 -19
  99. package/dist/chat/services/requester-identity.d.ts +0 -19
  100. package/dist/chat/services/timeout-resume.d.ts +0 -23
  101. package/dist/chunk-6YY4Q3D4.js +0 -12
  102. package/dist/chunk-Z3YD6NHK.js +0 -12
  103. package/dist/handlers/turn-resume.d.ts +0 -4
@@ -0,0 +1,212 @@
1
+ import {
2
+ isRecord,
3
+ toOptionalNumber,
4
+ toOptionalString
5
+ } from "./chunk-3BYAPS6B.js";
6
+
7
+ // src/chat/state/conversation.ts
8
+ function coerceRole(value) {
9
+ return value === "assistant" || value === "system" || value === "user" ? value : "user";
10
+ }
11
+ function coerceAuthor(value) {
12
+ if (!isRecord(value)) return void 0;
13
+ const author = {
14
+ fullName: toOptionalString(value.fullName),
15
+ userId: toOptionalString(value.userId),
16
+ userName: toOptionalString(value.userName)
17
+ };
18
+ if (typeof value.isBot === "boolean") {
19
+ author.isBot = value.isBot;
20
+ }
21
+ if (!author.fullName && !author.userId && !author.userName && author.isBot === void 0) {
22
+ return void 0;
23
+ }
24
+ return author;
25
+ }
26
+ function coerceMessageMeta(value) {
27
+ if (!isRecord(value)) return void 0;
28
+ const meta = {};
29
+ const attachmentCount = toOptionalNumber(value.attachmentCount);
30
+ if (typeof attachmentCount === "number" && attachmentCount > 0) {
31
+ meta.attachmentCount = attachmentCount;
32
+ }
33
+ if (typeof value.explicitMention === "boolean") {
34
+ meta.explicitMention = value.explicitMention;
35
+ }
36
+ const imageAttachmentCount = toOptionalNumber(value.imageAttachmentCount);
37
+ if (typeof imageAttachmentCount === "number" && imageAttachmentCount > 0) {
38
+ meta.imageAttachmentCount = imageAttachmentCount;
39
+ }
40
+ if (typeof value.replied === "boolean") {
41
+ meta.replied = value.replied;
42
+ }
43
+ if (typeof value.skippedReason === "string" && value.skippedReason.trim().length > 0) {
44
+ meta.skippedReason = value.skippedReason;
45
+ }
46
+ if (typeof value.slackTs === "string" && value.slackTs.trim().length > 0) {
47
+ meta.slackTs = value.slackTs;
48
+ }
49
+ if (Array.isArray(value.imageFileIds)) {
50
+ const imageFileIds = value.imageFileIds.filter(
51
+ (entry) => typeof entry === "string" && entry.trim().length > 0
52
+ );
53
+ if (imageFileIds.length > 0) {
54
+ meta.imageFileIds = imageFileIds;
55
+ }
56
+ }
57
+ if (typeof value.imagesHydrated === "boolean") {
58
+ meta.imagesHydrated = value.imagesHydrated;
59
+ }
60
+ if (meta.attachmentCount === void 0 && meta.explicitMention === void 0 && meta.imageAttachmentCount === void 0 && meta.replied === void 0 && meta.skippedReason === void 0 && meta.slackTs === void 0 && meta.imageFileIds === void 0 && meta.imagesHydrated === void 0) {
61
+ return void 0;
62
+ }
63
+ return meta;
64
+ }
65
+ function defaultConversationState() {
66
+ const nowMs = Date.now();
67
+ return {
68
+ schemaVersion: 1,
69
+ messages: [],
70
+ piMessages: [],
71
+ compactions: [],
72
+ backfill: {},
73
+ processing: {},
74
+ stats: {
75
+ estimatedContextTokens: 0,
76
+ totalMessageCount: 0,
77
+ compactedMessageCount: 0,
78
+ updatedAtMs: nowMs
79
+ },
80
+ vision: {
81
+ byFileId: {}
82
+ }
83
+ };
84
+ }
85
+ function coercePendingAuthState(value) {
86
+ if (!isRecord(value)) {
87
+ return void 0;
88
+ }
89
+ const kind = value.kind;
90
+ const provider = toOptionalString(value.provider);
91
+ const requesterId = toOptionalString(value.requesterId);
92
+ const scope = toOptionalString(value.scope);
93
+ const sessionId = toOptionalString(value.sessionId);
94
+ const linkSentAtMs = toOptionalNumber(value.linkSentAtMs);
95
+ if (kind !== "mcp" && kind !== "plugin" || !provider || !requesterId || !sessionId || typeof linkSentAtMs !== "number") {
96
+ return void 0;
97
+ }
98
+ return {
99
+ kind,
100
+ provider,
101
+ requesterId,
102
+ ...scope ? { scope } : {},
103
+ sessionId,
104
+ linkSentAtMs
105
+ };
106
+ }
107
+ function coerceThreadConversationState(value) {
108
+ if (!isRecord(value)) {
109
+ return defaultConversationState();
110
+ }
111
+ const root = value;
112
+ const rawConversation = isRecord(root.conversation) ? root.conversation : {};
113
+ const base = defaultConversationState();
114
+ const rawMessages = Array.isArray(rawConversation.messages) ? rawConversation.messages : [];
115
+ const messages = [];
116
+ for (const item of rawMessages) {
117
+ if (!isRecord(item)) continue;
118
+ const id = toOptionalString(item.id);
119
+ const text = toOptionalString(item.text);
120
+ const createdAtMs = toOptionalNumber(item.createdAtMs);
121
+ if (!id || !text || !createdAtMs) continue;
122
+ messages.push({
123
+ id,
124
+ role: coerceRole(item.role),
125
+ text,
126
+ createdAtMs,
127
+ author: coerceAuthor(item.author),
128
+ meta: coerceMessageMeta(item.meta)
129
+ });
130
+ }
131
+ const rawCompactions = Array.isArray(rawConversation.compactions) ? rawConversation.compactions : [];
132
+ const compactions = [];
133
+ for (const item of rawCompactions) {
134
+ if (!isRecord(item)) continue;
135
+ const id = toOptionalString(item.id);
136
+ const summary = toOptionalString(item.summary);
137
+ const createdAtMs = toOptionalNumber(item.createdAtMs);
138
+ if (!id || !summary || !createdAtMs) continue;
139
+ const coveredMessageIds = Array.isArray(item.coveredMessageIds) ? item.coveredMessageIds.filter(
140
+ (entry) => typeof entry === "string" && entry.length > 0
141
+ ) : [];
142
+ compactions.push({
143
+ id,
144
+ summary,
145
+ createdAtMs,
146
+ coveredMessageIds
147
+ });
148
+ }
149
+ const rawBackfill = isRecord(rawConversation.backfill) ? rawConversation.backfill : {};
150
+ const backfill = {
151
+ completedAtMs: toOptionalNumber(rawBackfill.completedAtMs),
152
+ source: rawBackfill.source === "recent_messages" || rawBackfill.source === "thread_fetch" ? rawBackfill.source : void 0
153
+ };
154
+ const rawProcessing = isRecord(rawConversation.processing) ? rawConversation.processing : {};
155
+ const processing = {
156
+ activeTurnId: toOptionalString(rawProcessing.activeTurnId),
157
+ lastCompletedAtMs: toOptionalNumber(rawProcessing.lastCompletedAtMs),
158
+ pendingAuth: coercePendingAuthState(rawProcessing.pendingAuth)
159
+ };
160
+ const rawStats = isRecord(rawConversation.stats) ? rawConversation.stats : {};
161
+ const stats = {
162
+ estimatedContextTokens: toOptionalNumber(rawStats.estimatedContextTokens) ?? base.stats.estimatedContextTokens,
163
+ totalMessageCount: toOptionalNumber(rawStats.totalMessageCount) ?? messages.length,
164
+ compactedMessageCount: toOptionalNumber(rawStats.compactedMessageCount) ?? 0,
165
+ updatedAtMs: toOptionalNumber(rawStats.updatedAtMs) ?? base.stats.updatedAtMs
166
+ };
167
+ const rawVision = isRecord(rawConversation.vision) ? rawConversation.vision : {};
168
+ const rawVisionByFileId = isRecord(rawVision.byFileId) ? rawVision.byFileId : {};
169
+ const byFileId = {};
170
+ for (const [fileId, value2] of Object.entries(rawVisionByFileId)) {
171
+ if (typeof fileId !== "string" || fileId.trim().length === 0) continue;
172
+ if (!isRecord(value2)) continue;
173
+ const summary = toOptionalString(value2.summary);
174
+ const analyzedAtMs = toOptionalNumber(value2.analyzedAtMs);
175
+ if (!summary || !analyzedAtMs) continue;
176
+ byFileId[fileId] = {
177
+ summary,
178
+ analyzedAtMs
179
+ };
180
+ }
181
+ return {
182
+ schemaVersion: 1,
183
+ messages,
184
+ piMessages: Array.isArray(rawConversation.piMessages) ? rawConversation.piMessages : [],
185
+ compactions,
186
+ backfill,
187
+ processing,
188
+ stats,
189
+ vision: {
190
+ backfillCompletedAtMs: toOptionalNumber(rawVision.backfillCompletedAtMs),
191
+ byFileId
192
+ }
193
+ };
194
+ }
195
+ function buildConversationStatePatch(conversation) {
196
+ return {
197
+ conversation: {
198
+ ...conversation,
199
+ schemaVersion: 1,
200
+ stats: {
201
+ ...conversation.stats,
202
+ totalMessageCount: conversation.messages.length,
203
+ updatedAtMs: Date.now()
204
+ }
205
+ }
206
+ };
207
+ }
208
+
209
+ export {
210
+ coerceThreadConversationState,
211
+ buildConversationStatePatch
212
+ };