@sentry/junior 0.285.0 → 0.286.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/{adapter-DN5AB4VU.js → adapter-JQZaJ-B_.js} +1 -1
  2. package/dist/{admin-DOITMKnn.js → admin-Dm2bimJ-.js} +1 -1
  3. package/dist/{agent-runner-BsWhHe4N.js → agent-runner-DGCwOEyL.js} +1567 -1048
  4. package/dist/api/schema.d.ts +1 -1
  5. package/dist/api/schema.js +5 -5
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +70 -92
  8. package/dist/{app-DyMs9330.d.ts → app-BKq0JzWx.d.ts} +2 -3
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +37 -40
  11. package/dist/{assistant-reply-9Jip5bsr.js → assistant-reply-CAPafcUY.js} +1 -1
  12. package/dist/{automation-Mk8aaHzy.js → automation-B-jJN_gM.js} +1 -1
  13. package/dist/{background-compaction-queue-DXkLsWoH.js → background-compaction-queue-Btu2oab_.js} +137 -3
  14. package/dist/{briefs-Cl8-nK9B.js → briefs-UMeYehUe.js} +4 -4
  15. package/dist/{catalog-runtime-Bte6jRB2.js → catalog-runtime-Bym8GVdh.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +5 -6
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{client-DDbBucBw.js → client-B0aAs7wC.js} +2 -2
  24. package/dist/{config-DqFnykQT.js → config-B9f9Lqo5.js} +1 -1
  25. package/dist/{connections-DA4LT9LL.js → connections-CQ7p0aNJ.js} +16 -50
  26. package/dist/{conversation-D8kVoCrP.js → conversation-BusI2uzj.js} +15 -6
  27. package/dist/{conversation-pending-messages-BvROq1bq.js → conversation-pending-messages-DwehU0Fd.js} +1 -1
  28. package/dist/{conversation-privacy-D0j_h70R.js → conversation-privacy-Cd_nZZBM.js} +1 -1
  29. package/dist/{credential-sync-hcsYatw-.js → credential-sync-DmiJi_At.js} +13 -13
  30. package/dist/{db-BhHZSuFw.d.ts → db-C5zi4ecs.d.ts} +4 -4
  31. package/dist/{executor-BLEMIgIZ.js → executor-Dipi2Ixl.js} +11 -17
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{logging-BfORLKoq.js → logging-CMFhLLj4.js} +1 -1
  34. package/dist/{media-Bu9C6lz0.js → media-B-BpXo41.js} +14 -2
  35. package/dist/{message-DqjuKzUx.js → message-D1xLljUF.js} +9 -9
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +2 -3
  38. package/dist/{oauth-callback-server-CFSRzu1n.js → oauth-callback-server-DCAFIUQr.js} +2 -2
  39. package/dist/{projection-DliWYrnT.js → projection-CoeMNxJ4.js} +286 -212
  40. package/dist/{prompt-BvIUzY4y.js → prompt-C9OQEfan.js} +1 -1
  41. package/dist/{registry-rC7MCxu8.js → registry-u-sFYtx_.js} +1 -1
  42. package/dist/{resolve-Biu8Qw3u.js → resolve-DYqgL3Eo.js} +3 -3
  43. package/dist/{result-DxJMCX47.js → result-CescSwAw.js} +8 -8
  44. package/dist/{runner-BQJSFLKg.js → runner-Cr67a8TB.js} +16 -12
  45. package/dist/{sandbox-egress-signals-6aMxJSDn.js → sandbox-egress-signals-DLOazy5W.js} +1 -1
  46. package/dist/{schema-BasXTvi2.js → schema-BUSi3sgv.js} +5 -5
  47. package/dist/{schema-BUviRAs8.d.ts → schema-Ih60j59-.d.ts} +44 -7
  48. package/dist/{service-account-BI5Wgx22.js → service-account-CGEqz9wG.js} +3 -3
  49. package/dist/{service-account-CAE-_1dR.js → service-account-CsKxktLk.js} +3 -3
  50. package/dist/{session-stop-CA-jOJ84.js → session-stop-CGz5DByb.js} +22 -20
  51. package/dist/{skills-B22duVJU.js → skills-COCqf61f.js} +2 -2
  52. package/dist/{spawn-BB2_4VYn.js → spawn-C8F_iXWO.js} +13 -2
  53. package/dist/{stop-DioIcEAu.js → stop-GyFZkHuQ.js} +242 -952
  54. package/dist/{store-Dn4W7qgH.js → store-D0-8plWp.js} +3 -3
  55. package/dist/{turn-session-routing-CGMKrYOj.js → task-runner-xPuQmEot.js} +1439 -993
  56. package/dist/{store-B26LV6UP.js → turn-failure-response-BOviBdT-.js} +331 -5
  57. package/dist/{validation-TzhfQABF.js → validation-DZDKorGz.js} +1 -1
  58. package/dist/{version-DSk8CFvA.js → version-BTIz7fGi.js} +1 -1
  59. package/dist/version.js +1 -1
  60. package/dist/{viewer-1Ea81s0b.js → viewer-CH-ASQzh.js} +39 -36
  61. package/dist/{work-ybG4_q5C.js → work-C75_IM5e.js} +92 -87
  62. package/dist/{worker-ccSyZRNz.js → worker-Dl47I729.js} +6 -6
  63. package/migrations/0086_shared_archive.sql +31 -0
  64. package/migrations/0087_child_location.sql +64 -0
  65. package/migrations/meta/0086_snapshot.json +4366 -0
  66. package/migrations/meta/0087_snapshot.json +4366 -0
  67. package/migrations/meta/_journal.json +14 -0
  68. package/package.json +5 -4
  69. package/dist/task-queue-Bt0IoR2i.js +0 -139
  70. package/dist/task-runner-D8lddjzp.js +0 -290
  71. package/dist/thread-state-CrFk3K_7.js +0 -173
  72. package/dist/turn-failure-response-DaJ04qVj.js +0 -224
  73. package/dist/turn-lifecycle-C2mXS7AZ.js +0 -58
@@ -1,224 +0,0 @@
1
- import { Eo as listConversationAnnotations, N as markConversationMessage, bn as buildDeterministicTurnId, q as clearPendingAuth, v as hydrateConversationMessages } from "./projection-DliWYrnT.js";
2
- import { b as getProviderErrorUserMessage, g as ProviderError, v as findProviderError, y as getProviderErrorAttributes } from "./client-DDbBucBw.js";
3
- import { W as isRecord, t as buildTurnFailureResponse } from "./logging-BfORLKoq.js";
4
- import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
5
- import { S as getDb, y as getConversationEventStore } from "./viewer-1Ea81s0b.js";
6
- import { F as removedCardSchema, I as resolveMessageCards, P as readMessageCardRefs } from "./conversation-D8kVoCrP.js";
7
- import { F as getAgentInvocationTurnId, J as markTurnClosed, Y as markTurnCompleted, a as getAgentInvocation, z as parseAgentInvocationResultMessageId } from "./store-B26LV6UP.js";
8
- import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-CrFk3K_7.js";
9
- // src/chat/conversations/pending-cards.ts
10
- /**
11
- * Add the cards that tool results selected since the last visible assistant
12
- * Message or Turn start, scanning back from `beforeSeq`. Returns the input
13
- * message ids of the Turn start that ended the scan.
14
- */
15
- async function selectTurnCards(conversationId, selection, beforeSeq) {
16
- while (true) {
17
- const page = await getConversationEventStore().query(conversationId, {
18
- beforeSeq,
19
- limit: 100,
20
- types: [
21
- "tool_result",
22
- "message",
23
- "turn_started"
24
- ]
25
- });
26
- for (const event of [...page.events].reverse()) {
27
- const data = event.data;
28
- if (data.type === "turn_started") return data.inputMessageIds;
29
- if (data.type === "message" && data.role === "assistant") return [];
30
- if (data.type !== "tool_result" || data.isError || typeof data.toolName !== "string" || !isRecord(data.details)) continue;
31
- if (data.details.timed_out === true) continue;
32
- if (Array.isArray(data.details.removedCards)) for (const ref of removedCardSchema.array().parse(data.details.removedCards)) selection.deleted.add(JSON.stringify([ref.plugin, ref.key]));
33
- for (const card of readMessageCardRefs(data.details)) {
34
- const key = JSON.stringify([card.plugin, card.key]);
35
- if (!selection.deleted.has(key) && !selection.cards.has(key)) selection.cards.set(key, card);
36
- }
37
- }
38
- if (!page.hasOlder || page.events.length === 0) return [];
39
- beforeSeq = page.events[0].seq;
40
- }
41
- }
42
- /**
43
- * Add the cards of child agents whose results started this Turn. A child
44
- * cannot reply to people, so its parent's reply delivers its cards.
45
- */
46
- async function selectChildResultCards(inputMessageIds, selection) {
47
- const events = getConversationEventStore();
48
- for (const messageId of [...inputMessageIds].reverse()) {
49
- const invocationId = parseAgentInvocationResultMessageId(messageId);
50
- const invocation = invocationId ? await getAgentInvocation(invocationId) : void 0;
51
- if (!invocation) continue;
52
- const turnId = getAgentInvocationTurnId(invocation.invocationId);
53
- const terminal = await events.loadByIdempotencyKey(invocation.childConversationId, `turn:${turnId}:terminal`);
54
- if (!terminal) continue;
55
- await selectTurnCards(invocation.childConversationId, selection, terminal.seq);
56
- }
57
- }
58
- /** Select undelivered cards and load their latest saved facts. */
59
- async function loadPendingMessageCards(conversationId) {
60
- const selection = {
61
- cards: /* @__PURE__ */ new Map(),
62
- deleted: /* @__PURE__ */ new Set()
63
- };
64
- await selectChildResultCards(await selectTurnCards(conversationId, selection), selection);
65
- if (selection.cards.size === 0) return [];
66
- return resolveMessageCards([...selection.cards.values()].reverse(), await listConversationAnnotations(getDb(), conversationId));
67
- }
68
- // src/chat/runtime/delivered-turn-state.ts
69
- /** Build state after destination delivery or intentional no-reply completion. */
70
- function buildDeliveredTurnStatePatch(args) {
71
- const conversation = structuredClone(args.conversation);
72
- clearPendingAuth(conversation, args.sessionId);
73
- markConversationMessage(conversation, args.userMessageId, {
74
- replied: true,
75
- skippedReason: void 0
76
- });
77
- markTurnCompleted({
78
- conversation,
79
- nowMs: Date.now(),
80
- sessionId: args.sessionId
81
- });
82
- return {
83
- conversation,
84
- sandboxRef: args.reply.sandboxRef
85
- };
86
- }
87
- // src/chat/runtime/turn-user-message.ts
88
- /** Return the user message for a persisted turn/session, if one exists. */
89
- function getTurnUserMessage(conversation, sessionId) {
90
- for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
91
- const message = conversation.messages[index];
92
- if (message?.role !== "user") continue;
93
- if (buildDeterministicTurnId(message.id) === sessionId) return message;
94
- }
95
- }
96
- /** Return the persisted user-message id for a turn/session, if one exists. */
97
- function getTurnUserMessageId(conversation, sessionId) {
98
- return getTurnUserMessage(conversation, sessionId)?.id;
99
- }
100
- /** Return the Slack timestamp for the user message that a resumed turn acts on. */
101
- function getTurnUserSlackMessageTs(message) {
102
- return parseSlackMessageTs(message?.meta?.slackTs);
103
- }
104
- /** Rebuild attachment context for a resumed turn from the persisted user message. */
105
- function getTurnUserReplyAttachmentContext(message) {
106
- const inboundAttachmentCount = message?.meta?.attachmentCount ?? 0;
107
- const imageAttachmentCount = message?.meta?.imageAttachmentCount ?? 0;
108
- const imagesHydrated = message?.meta?.imagesHydrated === true;
109
- return {
110
- ...inboundAttachmentCount > 0 ? { inboundAttachmentCount } : void 0,
111
- ...!imagesHydrated && imageAttachmentCount > 0 ? { omittedImageAttachmentCount: imageAttachmentCount } : void 0
112
- };
113
- }
114
- // src/chat/runtime/auth-pause-state.ts
115
- /** Mark an auth-paused turn complete after private authorization link delivery. */
116
- function completeAuthPauseTurn(args) {
117
- markConversationMessage(args.conversation, getTurnUserMessageId(args.conversation, args.sessionId), {
118
- replied: true,
119
- skippedReason: void 0
120
- });
121
- markTurnClosed({
122
- conversation: args.conversation,
123
- nowMs: Date.now(),
124
- sessionId: args.sessionId
125
- });
126
- }
127
- /** Reload thread state, mark the auth pause as parked, and persist it. */
128
- async function persistAuthPauseTurnState(args) {
129
- const currentState = await getPersistedThreadState(args.threadStateId);
130
- const conversation = coerceThreadConversationState(currentState);
131
- await hydrateConversationMessages({
132
- conversation,
133
- conversationId: args.threadStateId
134
- });
135
- completeAuthPauseTurn({
136
- conversation,
137
- sessionId: args.sessionId
138
- });
139
- await persistThreadStateById(args.threadStateId, { conversation });
140
- }
141
- // src/chat/interruption-marker.ts
142
- const INTERRUPTED_MARKER = "\n\n[Response interrupted before completion]";
143
- /** Return the marker added when a visible reply ended mid-execution. */
144
- function getInterruptionMarker() {
145
- return INTERRUPTED_MARKER;
146
- }
147
- // src/chat/services/turn-failure-response.ts
148
- /** Require captured turn failures to carry a real Sentry event reference. */
149
- function requireTurnFailureEventId(eventId, eventName) {
150
- if (!eventId) throw new Error(`Sentry did not return an event ID for ${eventName}`);
151
- return eventId;
152
- }
153
- function getExecutionFailureReason(reply) {
154
- const errorMessage = reply.diagnostics.errorMessage?.trim();
155
- if (errorMessage) return errorMessage;
156
- if (reply.diagnostics.toolErrorCount > 0) return `${reply.diagnostics.toolErrorCount} tool result error(s)`;
157
- if (reply.diagnostics.assistantMessageCount > 0) return "assistant returned no text";
158
- return "empty assistant turn";
159
- }
160
- /** Return a fixed reason label for a failed model turn. */
161
- function getTurnFailureReason(reply) {
162
- if (reply.diagnostics.outcome === "success") return;
163
- if (reply.diagnostics.outcome === "provider_error") return findProviderError(reply.diagnostics.providerError)?.kind ?? "unknown";
164
- if (reply.diagnostics.toolErrorCount > 0) return "tool_errors";
165
- if (reply.diagnostics.usedPrimaryText && reply.diagnostics.assistantMessageCount > 0) return "suppressed_output";
166
- return "empty_output";
167
- }
168
- function getFailureCapture(reply) {
169
- if (reply.diagnostics.outcome === "provider_error") {
170
- const providerError = findProviderError(reply.diagnostics.providerError);
171
- return {
172
- eventName: "agent.turn.provider_error",
173
- error: reply.diagnostics.providerError ?? new Error(reply.diagnostics.errorMessage ?? "Provider error without explicit message"),
174
- attributes: providerError ? getProviderErrorAttributes(providerError) : {},
175
- body: "Agent turn failed with provider error"
176
- };
177
- }
178
- const failureReason = getExecutionFailureReason(reply);
179
- return {
180
- eventName: "agent.turn.execution.failed",
181
- error: /* @__PURE__ */ new Error(`Agent turn execution failure: ${failureReason}`),
182
- attributes: { "app.ai.execution_failure_reason": failureReason },
183
- body: "Agent turn completed with execution failure"
184
- };
185
- }
186
- /** Keep failed-turn Sentry captures and completion spans on the same keys. */
187
- function getAgentTurnDiagnosticsAttributes(reply) {
188
- return {
189
- "app.ai.outcome": reply.diagnostics.outcome,
190
- "app.ai.assistant_messages": reply.diagnostics.assistantMessageCount,
191
- "app.ai.tool_results": reply.diagnostics.toolResultCount,
192
- "app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
193
- "app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
194
- "app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
195
- ...reply.automation ? { "app.automation.result": reply.automation.result } : void 0,
196
- ...reply.diagnostics.reasoningLevel ? { "gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel } : void 0,
197
- ...reply.diagnostics.stopReason ? { "gen_ai.response.finish_reasons": [reply.diagnostics.stopReason] } : void 0,
198
- ...reply.diagnostics.errorMessage && reply.diagnostics.outcome !== "provider_error" ? { "exception.message": reply.diagnostics.errorMessage } : void 0
199
- };
200
- }
201
- /** Enforce one captured failure response and return its structured correlation. */
202
- function finalizeFailedTurnReplyWithEvent(args) {
203
- if (args.reply.diagnostics.outcome === "success") return { reply: args.reply };
204
- const failureReason = getTurnFailureReason(args.reply);
205
- const capture = getFailureCapture(args.reply);
206
- const eventId = requireTurnFailureEventId(args.logException(capture.error, capture.eventName, {
207
- ...getAgentTurnDiagnosticsAttributes(args.reply),
208
- ...args.attributes,
209
- ...capture.attributes,
210
- ...failureReason ? { "app.ai.failure_reason": failureReason } : void 0
211
- }), capture.eventName);
212
- const providerPartialText = args.reply.diagnostics.outcome === "provider_error" && args.reply.diagnostics.assistantMessageCount > 0 ? args.reply.text.trim() : "";
213
- const providerUserMessage = args.reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorUserMessage(args.reply.diagnostics.providerError) : "";
214
- const failureText = providerUserMessage ? `${providerUserMessage} Reference: \`event_id=${eventId}\`.` : buildTurnFailureResponse(eventId);
215
- return {
216
- eventId,
217
- ...failureReason ? { failureReason } : void 0,
218
- reply: {
219
- ...args.reply,
220
- text: providerPartialText ? `${providerPartialText}${getInterruptionMarker()}` : failureText
221
- }
222
- };
223
- }
224
- export { persistAuthPauseTurnState as a, getTurnUserSlackMessageTs as c, completeAuthPauseTurn as i, buildDeliveredTurnStatePatch as l, getAgentTurnDiagnosticsAttributes as n, getTurnUserMessage as o, requireTurnFailureEventId as r, getTurnUserReplyAttachmentContext as s, finalizeFailedTurnReplyWithEvent as t, loadPendingMessageCards as u };
@@ -1,58 +0,0 @@
1
- import { y as getConversationEventStore } from "./viewer-1Ea81s0b.js";
2
- // src/chat/conversations/turn-lifecycle.ts
3
- /** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
4
- var ConversationTurnLifecycleService = class {
5
- events;
6
- constructor(events) {
7
- this.events = events;
8
- }
9
- /** Record the turn start once after every input message is durable. */
10
- async start(input) {
11
- await this.events.append(input.conversationId, [{
12
- idempotencyKey: `turn:${input.turnId}:started`,
13
- createdAtMs: input.createdAtMs,
14
- data: {
15
- type: "turn_started",
16
- turnId: input.turnId,
17
- inputMessageIds: input.inputMessageIds,
18
- surface: input.surface
19
- }
20
- }]);
21
- }
22
- /** Return the input message ids that started a Turn, when it started. */
23
- async loadInputMessageIds(conversationId, turnId) {
24
- const event = await this.events.loadByIdempotencyKey(conversationId, `turn:${turnId}:started`);
25
- return event?.data.type === "turn_started" ? event.data.inputMessageIds : void 0;
26
- }
27
- /** Record a completion that is not a failure once. */
28
- async complete(input) {
29
- await this.events.append(input.conversationId, [{
30
- idempotencyKey: `turn:${input.turnId}:terminal`,
31
- createdAtMs: input.createdAtMs,
32
- data: {
33
- type: "turn_completed",
34
- turnId: input.turnId,
35
- outcome: input.outcome
36
- }
37
- }]);
38
- }
39
- /** Record a classified failure once. Do not store raw error text. */
40
- async fail(input) {
41
- await this.events.append(input.conversationId, [{
42
- idempotencyKey: `turn:${input.turnId}:terminal`,
43
- createdAtMs: input.createdAtMs,
44
- data: {
45
- type: "turn_failed",
46
- turnId: input.turnId,
47
- failureCode: input.failureCode,
48
- ...input.failureReason ? { failureReason: input.failureReason } : void 0,
49
- ...input.eventId ? { eventId: input.eventId } : void 0
50
- }
51
- }]);
52
- }
53
- };
54
- /** Return the Turn lifecycle that records Conversation events. */
55
- function getTurnLifecycle() {
56
- return new ConversationTurnLifecycleService(getConversationEventStore());
57
- }
58
- export { getTurnLifecycle as n, ConversationTurnLifecycleService as t };