@sentry/junior 0.115.0 → 0.116.1
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.
- package/dist/{agent-hooks-4EUUXP2F.js → agent-hooks-GUAAS3XH.js} +9 -9
- package/dist/api/conversations/detail.d.ts +18 -0
- package/dist/api/conversations/event-page.d.ts +1 -1
- package/dist/api/conversations/events.d.ts +1 -1
- package/dist/api/people/profile.d.ts +2 -2
- package/dist/api/people/shared.d.ts +1 -1
- package/dist/api/personal-tokens/create.d.ts +11 -0
- package/dist/api/personal-tokens/list.d.ts +12 -0
- package/dist/api/personal-tokens/revoke.d.ts +5 -0
- package/dist/api/personal-tokens/routes.d.ts +4 -0
- package/dist/api/plugins.d.ts +0 -1
- package/dist/api/route.d.ts +1 -1
- package/dist/api/schema/conversation.d.ts +18 -0
- package/dist/api/schema/person.d.ts +3 -3
- package/dist/api/schema/personal-token.d.ts +38 -0
- package/dist/api/schema.d.ts +2 -0
- package/dist/api/schema.js +15 -3
- package/dist/api.d.ts +1 -0
- package/dist/api.js +179 -39
- package/dist/app.js +1035 -853
- package/dist/{catalog-runtime-Y32UEQLB.js → catalog-runtime-WMPC4J4U.js} +5 -5
- package/dist/chat/agent/request.d.ts +1 -0
- package/dist/chat/agent/resume.d.ts +1 -0
- package/dist/chat/agent/sandbox.d.ts +1 -0
- package/dist/chat/agent/tools.d.ts +1 -0
- package/dist/chat/agent-dispatch/context.d.ts +2 -0
- package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
- package/dist/chat/agent-dispatch/signing.d.ts +14 -5
- package/dist/chat/agent-dispatch/store.d.ts +36 -15
- package/dist/chat/agent-dispatch/types.d.ts +23 -10
- package/dist/chat/agent-dispatch/work.d.ts +58 -0
- package/dist/chat/app/factory.d.ts +12 -3
- package/dist/chat/conversations/history.d.ts +285 -290
- package/dist/chat/conversations/projection.d.ts +2 -2
- package/dist/chat/mcp/tool-manager.d.ts +2 -1
- package/dist/chat/pi/conversation-events.d.ts +6 -2
- package/dist/chat/plugins/annotations.d.ts +8 -0
- package/dist/chat/plugins/registry.d.ts +0 -3
- package/dist/chat/plugins/types.d.ts +0 -2
- package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
- package/dist/chat/runtime/reply-executor.d.ts +6 -1
- package/dist/chat/runtime/slack-resume.d.ts +5 -1
- package/dist/chat/runtime/turn-input.d.ts +3 -0
- package/dist/chat/sandbox/sandbox.d.ts +2 -1
- package/dist/chat/sandbox/session.d.ts +2 -11
- package/dist/chat/sandbox/workspace.d.ts +10 -2
- package/dist/chat/services/turn-session-record.d.ts +14 -1
- package/dist/chat/slack/dispatch-turn.d.ts +25 -0
- package/dist/chat/state/turn-session.d.ts +11 -0
- package/dist/chat/tool-support/text-range-result.d.ts +3 -0
- package/dist/chat/tool-support/zod-tool.d.ts +1 -0
- package/dist/chat/tools/definition.d.ts +3 -10
- package/dist/chat/tools/query-conversation-events.d.ts +68 -0
- package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
- package/dist/chat/tools/sandbox/grep.d.ts +2 -1
- package/dist/{chunk-6V762AB4.js → chunk-2YYPXQNQ.js} +1 -1
- package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
- package/dist/{chunk-67CVNDJ7.js → chunk-7CSVG54J.js} +1 -1
- package/dist/{chunk-HWCQRGLL.js → chunk-BFYVIOTS.js} +105 -37
- package/dist/{chunk-LYA2AB5G.js → chunk-CGXLCMWI.js} +8 -52
- package/dist/{chunk-SYJT7AKB.js → chunk-CY7NXM32.js} +1 -1
- package/dist/{chunk-2QG4MZQ7.js → chunk-DLLW5ITL.js} +2 -2
- package/dist/{chunk-NVUQSFWX.js → chunk-F3SWGSPG.js} +3 -15
- package/dist/{chunk-CWEZEPD4.js → chunk-FAEALXEH.js} +68 -2
- package/dist/{chunk-43RYMWJ2.js → chunk-GDAXWEIJ.js} +809 -213
- package/dist/{chunk-AGLQYELI.js → chunk-H35BDAUS.js} +170 -170
- package/dist/{chunk-YCLO7D7M.js → chunk-JPKGW6L6.js} +77 -26
- package/dist/{chunk-G5SX4UPR.js → chunk-KNCELO2M.js} +2 -2
- package/dist/{chunk-FHC4JUSF.js → chunk-N3C4XCRE.js} +1 -2
- package/dist/{chunk-6FKLPVF3.js → chunk-OY2PQQ4P.js} +1 -1
- package/dist/{chunk-6OPTF4BQ.js → chunk-PE44LDDQ.js} +0 -1
- package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
- package/dist/{chunk-CEYOL62C.js → chunk-RYFAVWP3.js} +120 -20
- package/dist/{chunk-G36V2YGB.js → chunk-TC4ZEM2D.js} +33 -1
- package/dist/{chunk-PVZHG2XZ.js → chunk-VBMMMVVQ.js} +112 -35
- package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
- package/dist/{chunk-TVE25LPW.js → chunk-WLT72MRP.js} +1 -1
- package/dist/{chunk-EW5MLKT5.js → chunk-XA3VLFPK.js} +1 -55
- package/dist/{chunk-RAVKCKXA.js → chunk-ZYHLNTC2.js} +20 -5
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-warmup.js +8 -8
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/api-tokens.d.ts +160 -0
- package/dist/db/schema/conversation-annotations.d.ts +142 -0
- package/dist/db/schema.d.ts +305 -1
- package/dist/{db-KBSJHAZU.js → db-FH4R5ZQ4.js} +6 -6
- package/dist/handlers/agent-dispatch.d.ts +7 -3
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +5 -5
- package/dist/{oauth-callback-server-EYRMJTCS.js → oauth-callback-server-C2SSJ3FQ.js} +18 -18
- package/dist/personal-tokens/store.d.ts +27 -0
- package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
- package/dist/reporting-schema.d.ts +0 -2
- package/dist/{runner-RQGZ5Z2S.js → runner-NAALFIXM.js} +12 -12
- package/dist/{skills-JJQIE3BT.js → skills-UN2JXYYF.js} +6 -6
- package/dist/{validation-MZ47PZP5.js → validation-EEF4ROHR.js} +6 -6
- package/dist/version.js +1 -1
- package/migrations/0008_sticky_rage.sql +14 -0
- package/migrations/0009_slippery_harrier.sql +12 -0
- package/migrations/0010_native_conversation_history.sql +142 -0
- package/migrations/meta/0008_snapshot.json +1076 -0
- package/migrations/meta/0009_snapshot.json +1146 -0
- package/migrations/meta/0010_snapshot.json +1190 -0
- package/migrations/meta/_journal.json +22 -1
- package/package.json +5 -6
- package/dist/chat/agent-dispatch/runner.d.ts +0 -13
- package/dist/chat/capabilities/catalog.d.ts +0 -16
- package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
pluginTaskId,
|
|
3
3
|
pluginTaskParamsSchema,
|
|
4
4
|
sendVercelPluginTask
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5I6ORJUY.js";
|
|
6
6
|
import {
|
|
7
7
|
buildDeterministicTurnId,
|
|
8
8
|
clearPendingAuth,
|
|
@@ -23,173 +23,58 @@ import {
|
|
|
23
23
|
persistThreadStateById,
|
|
24
24
|
stripRuntimeTurnContext,
|
|
25
25
|
updateConversationStats
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RYFAVWP3.js";
|
|
27
27
|
import {
|
|
28
28
|
createPluginEmbedder,
|
|
29
29
|
createPluginLogger,
|
|
30
30
|
createPluginModel,
|
|
31
31
|
createPluginState,
|
|
32
32
|
getPlugins
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ZYHLNTC2.js";
|
|
34
34
|
import {
|
|
35
35
|
getStateAdapter
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-7CSVG54J.js";
|
|
37
37
|
import {
|
|
38
38
|
getDb
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-BFYVIOTS.js";
|
|
40
40
|
import {
|
|
41
41
|
ProviderError,
|
|
42
42
|
getProviderErrorAttributes,
|
|
43
43
|
getProviderErrorUserMessage
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-CY7NXM32.js";
|
|
45
45
|
import {
|
|
46
46
|
buildTurnFailureResponse
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-F3SWGSPG.js";
|
|
48
48
|
import {
|
|
49
49
|
parseSlackMessageTs
|
|
50
50
|
} from "./chunk-F3B2YJ76.js";
|
|
51
51
|
|
|
52
|
-
// src/chat/
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function getExecutionFailureReason(reply) {
|
|
60
|
-
const errorMessage = reply.diagnostics.errorMessage?.trim();
|
|
61
|
-
if (errorMessage) {
|
|
62
|
-
return errorMessage;
|
|
63
|
-
}
|
|
64
|
-
if (reply.diagnostics.toolErrorCount > 0) {
|
|
65
|
-
return `${reply.diagnostics.toolErrorCount} tool result error(s)`;
|
|
66
|
-
}
|
|
67
|
-
if (reply.diagnostics.assistantMessageCount > 0) {
|
|
68
|
-
return "assistant returned no text";
|
|
69
|
-
}
|
|
70
|
-
return "empty assistant turn";
|
|
71
|
-
}
|
|
72
|
-
function getFailureCapture(reply) {
|
|
73
|
-
if (reply.diagnostics.outcome === "provider_error") {
|
|
74
|
-
return {
|
|
75
|
-
eventName: "agent_turn_provider_error",
|
|
76
|
-
error: reply.diagnostics.providerError ?? new Error(
|
|
77
|
-
reply.diagnostics.errorMessage ?? "Provider error without explicit message"
|
|
78
|
-
),
|
|
79
|
-
attributes: reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorAttributes(reply.diagnostics.providerError) : {},
|
|
80
|
-
body: "Agent turn failed with provider error"
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const failureReason = getExecutionFailureReason(reply);
|
|
84
|
-
return {
|
|
85
|
-
eventName: "agent_turn_execution_failure",
|
|
86
|
-
error: new Error(`Agent turn execution failure: ${failureReason}`),
|
|
87
|
-
attributes: {
|
|
88
|
-
"app.ai.execution_failure_reason": failureReason
|
|
89
|
-
},
|
|
90
|
-
body: "Agent turn completed with execution failure"
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function getAgentTurnDiagnosticsAttributes(reply) {
|
|
94
|
-
return {
|
|
95
|
-
"app.ai.outcome": reply.diagnostics.outcome,
|
|
96
|
-
"app.ai.assistant_messages": reply.diagnostics.assistantMessageCount,
|
|
97
|
-
"app.ai.tool_results": reply.diagnostics.toolResultCount,
|
|
98
|
-
"app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
|
|
99
|
-
"app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
|
|
100
|
-
"app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
|
|
101
|
-
...reply.diagnostics.reasoningLevel ? {
|
|
102
|
-
"gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel
|
|
103
|
-
} : {},
|
|
104
|
-
...reply.diagnostics.stopReason ? {
|
|
105
|
-
"gen_ai.response.finish_reasons": [reply.diagnostics.stopReason]
|
|
106
|
-
} : {},
|
|
107
|
-
...reply.diagnostics.errorMessage && reply.diagnostics.outcome !== "provider_error" ? { "exception.message": reply.diagnostics.errorMessage } : {}
|
|
52
|
+
// src/chat/runtime/delivered-turn-state.ts
|
|
53
|
+
function buildDeliveredTurnStatePatch(args) {
|
|
54
|
+
const conversation = structuredClone(args.conversation);
|
|
55
|
+
const artifactStatePatch = {
|
|
56
|
+
...args.reply.artifactStatePatch ?? {},
|
|
57
|
+
...args.artifactStatePatch ?? {}
|
|
108
58
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
...getAgentTurnDiagnosticsAttributes(args.reply),
|
|
122
|
-
...args.attributes,
|
|
123
|
-
...capture.attributes
|
|
124
|
-
},
|
|
125
|
-
capture.body
|
|
126
|
-
),
|
|
127
|
-
capture.eventName
|
|
128
|
-
);
|
|
129
|
-
const providerPartialText = args.reply.diagnostics.outcome === "provider_error" && args.reply.diagnostics.assistantMessageCount > 0 ? args.reply.text.trim() : "";
|
|
130
|
-
const providerUserMessage = args.reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorUserMessage(args.reply.diagnostics.providerError) : "";
|
|
131
|
-
const failureText = providerUserMessage ? `${providerUserMessage} Reference: \`event_id=${eventId}\`.` : buildTurnFailureResponse(eventId);
|
|
59
|
+
const artifacts = Object.keys(artifactStatePatch).length > 0 ? mergeArtifactsState(args.artifacts, artifactStatePatch) : void 0;
|
|
60
|
+
clearPendingAuth(conversation, args.sessionId);
|
|
61
|
+
markConversationMessage(conversation, args.userMessageId, {
|
|
62
|
+
replied: true,
|
|
63
|
+
skippedReason: void 0
|
|
64
|
+
});
|
|
65
|
+
markTurnCompleted({
|
|
66
|
+
conversation,
|
|
67
|
+
nowMs: Date.now(),
|
|
68
|
+
sessionId: args.sessionId,
|
|
69
|
+
updateConversationStats
|
|
70
|
+
});
|
|
132
71
|
return {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
text: providerPartialText ? `${providerPartialText}${getInterruptionMarker()}` : failureText
|
|
137
|
-
}
|
|
72
|
+
artifacts,
|
|
73
|
+
conversation,
|
|
74
|
+
sandboxRef: args.reply.sandboxRef
|
|
138
75
|
};
|
|
139
76
|
}
|
|
140
77
|
|
|
141
|
-
// src/chat/conversations/turn-lifecycle.ts
|
|
142
|
-
var ConversationTurnLifecycleService = class {
|
|
143
|
-
constructor(events) {
|
|
144
|
-
this.events = events;
|
|
145
|
-
}
|
|
146
|
-
events;
|
|
147
|
-
/** Record the turn start once after every input message is durable. */
|
|
148
|
-
async start(input) {
|
|
149
|
-
await this.events.append(input.conversationId, [
|
|
150
|
-
{
|
|
151
|
-
idempotencyKey: `turn:${input.turnId}:started`,
|
|
152
|
-
createdAtMs: input.createdAtMs,
|
|
153
|
-
data: {
|
|
154
|
-
type: "turn_started",
|
|
155
|
-
turnId: input.turnId,
|
|
156
|
-
inputMessageIds: input.inputMessageIds,
|
|
157
|
-
surface: input.surface
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
]);
|
|
161
|
-
}
|
|
162
|
-
/** Record successful or intentional-silence completion once. */
|
|
163
|
-
async complete(input) {
|
|
164
|
-
await this.events.append(input.conversationId, [
|
|
165
|
-
{
|
|
166
|
-
idempotencyKey: `turn:${input.turnId}:terminal`,
|
|
167
|
-
createdAtMs: input.createdAtMs,
|
|
168
|
-
data: {
|
|
169
|
-
type: "turn_completed",
|
|
170
|
-
turnId: input.turnId,
|
|
171
|
-
outcome: input.outcome
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
]);
|
|
175
|
-
}
|
|
176
|
-
/** Record a classified failure once without accepting raw error details. */
|
|
177
|
-
async fail(input) {
|
|
178
|
-
await this.events.append(input.conversationId, [
|
|
179
|
-
{
|
|
180
|
-
idempotencyKey: `turn:${input.turnId}:terminal`,
|
|
181
|
-
createdAtMs: input.createdAtMs,
|
|
182
|
-
data: {
|
|
183
|
-
type: "turn_failed",
|
|
184
|
-
turnId: input.turnId,
|
|
185
|
-
failureCode: input.failureCode,
|
|
186
|
-
...input.eventId ? { eventId: input.eventId } : {}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
]);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
78
|
// src/chat/plugins/task-runner.ts
|
|
194
79
|
import {
|
|
195
80
|
isPrivateSource,
|
|
@@ -500,32 +385,147 @@ async function processPluginTask(message, options = {}) {
|
|
|
500
385
|
});
|
|
501
386
|
}
|
|
502
387
|
|
|
503
|
-
// src/chat/
|
|
504
|
-
function
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
388
|
+
// src/chat/services/turn-failure-response.ts
|
|
389
|
+
function requireTurnFailureEventId(eventId, eventName) {
|
|
390
|
+
if (!eventId) {
|
|
391
|
+
throw new Error(`Sentry did not return an event ID for ${eventName}`);
|
|
392
|
+
}
|
|
393
|
+
return eventId;
|
|
394
|
+
}
|
|
395
|
+
function getExecutionFailureReason(reply) {
|
|
396
|
+
const errorMessage = reply.diagnostics.errorMessage?.trim();
|
|
397
|
+
if (errorMessage) {
|
|
398
|
+
return errorMessage;
|
|
399
|
+
}
|
|
400
|
+
if (reply.diagnostics.toolErrorCount > 0) {
|
|
401
|
+
return `${reply.diagnostics.toolErrorCount} tool result error(s)`;
|
|
402
|
+
}
|
|
403
|
+
if (reply.diagnostics.assistantMessageCount > 0) {
|
|
404
|
+
return "assistant returned no text";
|
|
405
|
+
}
|
|
406
|
+
return "empty assistant turn";
|
|
407
|
+
}
|
|
408
|
+
function getFailureCapture(reply) {
|
|
409
|
+
if (reply.diagnostics.outcome === "provider_error") {
|
|
410
|
+
return {
|
|
411
|
+
eventName: "agent_turn_provider_error",
|
|
412
|
+
error: reply.diagnostics.providerError ?? new Error(
|
|
413
|
+
reply.diagnostics.errorMessage ?? "Provider error without explicit message"
|
|
414
|
+
),
|
|
415
|
+
attributes: reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorAttributes(reply.diagnostics.providerError) : {},
|
|
416
|
+
body: "Agent turn failed with provider error"
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
const failureReason = getExecutionFailureReason(reply);
|
|
420
|
+
return {
|
|
421
|
+
eventName: "agent_turn_execution_failure",
|
|
422
|
+
error: new Error(`Agent turn execution failure: ${failureReason}`),
|
|
423
|
+
attributes: {
|
|
424
|
+
"app.ai.execution_failure_reason": failureReason
|
|
425
|
+
},
|
|
426
|
+
body: "Agent turn completed with execution failure"
|
|
509
427
|
};
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
markConversationMessage(conversation, args.userMessageId, {
|
|
513
|
-
replied: true,
|
|
514
|
-
skippedReason: void 0
|
|
515
|
-
});
|
|
516
|
-
markTurnCompleted({
|
|
517
|
-
conversation,
|
|
518
|
-
nowMs: Date.now(),
|
|
519
|
-
sessionId: args.sessionId,
|
|
520
|
-
updateConversationStats
|
|
521
|
-
});
|
|
428
|
+
}
|
|
429
|
+
function getAgentTurnDiagnosticsAttributes(reply) {
|
|
522
430
|
return {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
431
|
+
"app.ai.outcome": reply.diagnostics.outcome,
|
|
432
|
+
"app.ai.assistant_messages": reply.diagnostics.assistantMessageCount,
|
|
433
|
+
"app.ai.tool_results": reply.diagnostics.toolResultCount,
|
|
434
|
+
"app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
|
|
435
|
+
"app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
|
|
436
|
+
"app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
|
|
437
|
+
...reply.diagnostics.reasoningLevel ? {
|
|
438
|
+
"gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel
|
|
439
|
+
} : {},
|
|
440
|
+
...reply.diagnostics.stopReason ? {
|
|
441
|
+
"gen_ai.response.finish_reasons": [reply.diagnostics.stopReason]
|
|
442
|
+
} : {},
|
|
443
|
+
...reply.diagnostics.errorMessage && reply.diagnostics.outcome !== "provider_error" ? { "exception.message": reply.diagnostics.errorMessage } : {}
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function finalizeFailedTurnReplyWithEvent(args) {
|
|
447
|
+
if (args.reply.diagnostics.outcome === "success") {
|
|
448
|
+
return { reply: args.reply };
|
|
449
|
+
}
|
|
450
|
+
const capture = getFailureCapture(args.reply);
|
|
451
|
+
const eventId = requireTurnFailureEventId(
|
|
452
|
+
args.logException(
|
|
453
|
+
capture.error,
|
|
454
|
+
capture.eventName,
|
|
455
|
+
args.context,
|
|
456
|
+
{
|
|
457
|
+
...getAgentTurnDiagnosticsAttributes(args.reply),
|
|
458
|
+
...args.attributes,
|
|
459
|
+
...capture.attributes
|
|
460
|
+
},
|
|
461
|
+
capture.body
|
|
462
|
+
),
|
|
463
|
+
capture.eventName
|
|
464
|
+
);
|
|
465
|
+
const providerPartialText = args.reply.diagnostics.outcome === "provider_error" && args.reply.diagnostics.assistantMessageCount > 0 ? args.reply.text.trim() : "";
|
|
466
|
+
const providerUserMessage = args.reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorUserMessage(args.reply.diagnostics.providerError) : "";
|
|
467
|
+
const failureText = providerUserMessage ? `${providerUserMessage} Reference: \`event_id=${eventId}\`.` : buildTurnFailureResponse(eventId);
|
|
468
|
+
return {
|
|
469
|
+
eventId,
|
|
470
|
+
reply: {
|
|
471
|
+
...args.reply,
|
|
472
|
+
text: providerPartialText ? `${providerPartialText}${getInterruptionMarker()}` : failureText
|
|
473
|
+
}
|
|
526
474
|
};
|
|
527
475
|
}
|
|
528
476
|
|
|
477
|
+
// src/chat/conversations/turn-lifecycle.ts
|
|
478
|
+
var ConversationTurnLifecycleService = class {
|
|
479
|
+
constructor(events) {
|
|
480
|
+
this.events = events;
|
|
481
|
+
}
|
|
482
|
+
events;
|
|
483
|
+
/** Record the turn start once after every input message is durable. */
|
|
484
|
+
async start(input) {
|
|
485
|
+
await this.events.append(input.conversationId, [
|
|
486
|
+
{
|
|
487
|
+
idempotencyKey: `turn:${input.turnId}:started`,
|
|
488
|
+
createdAtMs: input.createdAtMs,
|
|
489
|
+
data: {
|
|
490
|
+
type: "turn_started",
|
|
491
|
+
turnId: input.turnId,
|
|
492
|
+
inputMessageIds: input.inputMessageIds,
|
|
493
|
+
surface: input.surface
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
]);
|
|
497
|
+
}
|
|
498
|
+
/** Record successful or intentional-silence completion once. */
|
|
499
|
+
async complete(input) {
|
|
500
|
+
await this.events.append(input.conversationId, [
|
|
501
|
+
{
|
|
502
|
+
idempotencyKey: `turn:${input.turnId}:terminal`,
|
|
503
|
+
createdAtMs: input.createdAtMs,
|
|
504
|
+
data: {
|
|
505
|
+
type: "turn_completed",
|
|
506
|
+
turnId: input.turnId,
|
|
507
|
+
outcome: input.outcome
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
]);
|
|
511
|
+
}
|
|
512
|
+
/** Record a classified failure once without accepting raw error details. */
|
|
513
|
+
async fail(input) {
|
|
514
|
+
await this.events.append(input.conversationId, [
|
|
515
|
+
{
|
|
516
|
+
idempotencyKey: `turn:${input.turnId}:terminal`,
|
|
517
|
+
createdAtMs: input.createdAtMs,
|
|
518
|
+
data: {
|
|
519
|
+
type: "turn_failed",
|
|
520
|
+
turnId: input.turnId,
|
|
521
|
+
failureCode: input.failureCode,
|
|
522
|
+
...input.eventId ? { eventId: input.eventId } : {}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
]);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
|
|
529
529
|
// src/chat/runtime/turn-user-message.ts
|
|
530
530
|
function getTurnUserMessage(conversation, sessionId) {
|
|
531
531
|
for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
|
|
@@ -587,17 +587,17 @@ async function persistAuthPauseTurnState(args) {
|
|
|
587
587
|
}
|
|
588
588
|
|
|
589
589
|
export {
|
|
590
|
-
requireTurnFailureEventId,
|
|
591
|
-
getAgentTurnDiagnosticsAttributes,
|
|
592
|
-
finalizeFailedTurnReplyWithEvent,
|
|
593
|
-
ConversationTurnLifecycleService,
|
|
594
|
-
scheduleSessionCompletedPluginTasks,
|
|
595
|
-
processPluginTask,
|
|
596
590
|
buildDeliveredTurnStatePatch,
|
|
597
591
|
getTurnUserMessage,
|
|
598
592
|
getTurnUserMessageId,
|
|
599
593
|
getTurnUserSlackMessageTs,
|
|
600
594
|
getTurnUserReplyAttachmentContext,
|
|
595
|
+
scheduleSessionCompletedPluginTasks,
|
|
596
|
+
processPluginTask,
|
|
597
|
+
requireTurnFailureEventId,
|
|
598
|
+
getAgentTurnDiagnosticsAttributes,
|
|
599
|
+
finalizeFailedTurnReplyWithEvent,
|
|
600
|
+
ConversationTurnLifecycleService,
|
|
601
601
|
completeAuthPauseTurn,
|
|
602
602
|
persistAuthPauseTurnState
|
|
603
603
|
};
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
persistAuthPauseTurnState,
|
|
13
13
|
requireTurnFailureEventId,
|
|
14
14
|
scheduleSessionCompletedPluginTasks
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-H35BDAUS.js";
|
|
16
16
|
import {
|
|
17
17
|
buildSentryConversationUrl
|
|
18
18
|
} from "./chunk-4CODA7P5.js";
|
|
19
19
|
import {
|
|
20
20
|
getVercelConversationWorkQueue
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-6ZK6FZIV.js";
|
|
22
22
|
import {
|
|
23
23
|
RetryableDeliveryError,
|
|
24
24
|
addReactionToMessage,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
resolvePluginOAuthAccount,
|
|
39
39
|
splitSlackReplyText,
|
|
40
40
|
truncateStatusText
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-CGXLCMWI.js";
|
|
42
42
|
import {
|
|
43
43
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
44
44
|
TurnSliceLimitExceededError,
|
|
@@ -63,34 +63,35 @@ import {
|
|
|
63
63
|
persistConversationMessages,
|
|
64
64
|
persistThreadStateById,
|
|
65
65
|
persistWithRetry,
|
|
66
|
+
recordAgentTurnSessionSummary,
|
|
66
67
|
recordAuthorizationCompleted,
|
|
67
68
|
recordDeliveredAssistantMessage,
|
|
68
69
|
turnHasReply,
|
|
69
70
|
updateConversationStats
|
|
70
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-RYFAVWP3.js";
|
|
71
72
|
import {
|
|
72
73
|
getDashboardConversationLink,
|
|
73
74
|
getPluginSlackConversationLink
|
|
74
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-ZYHLNTC2.js";
|
|
75
76
|
import {
|
|
76
77
|
acquireActiveLock,
|
|
77
78
|
getDefaultRedisStateAdapterFor,
|
|
78
79
|
getStateAdapter
|
|
79
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-7CSVG54J.js";
|
|
80
81
|
import {
|
|
81
82
|
SlackActionError,
|
|
82
83
|
getHeaderString,
|
|
83
84
|
getSlackClient,
|
|
84
85
|
isDmChannel,
|
|
85
86
|
normalizeSlackConversationId
|
|
86
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-FAEALXEH.js";
|
|
87
88
|
import {
|
|
88
89
|
getConversationEventStore,
|
|
89
90
|
getConversationStore,
|
|
90
91
|
parseDestination,
|
|
91
92
|
requireSlackDestination,
|
|
92
93
|
sameDestination
|
|
93
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-BFYVIOTS.js";
|
|
94
95
|
import {
|
|
95
96
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
96
97
|
botConfig,
|
|
@@ -99,7 +100,7 @@ import {
|
|
|
99
100
|
getRuntimeMetadata,
|
|
100
101
|
normalizeSlackEmojiName,
|
|
101
102
|
standardModelId
|
|
102
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-CY7NXM32.js";
|
|
103
104
|
import {
|
|
104
105
|
parseSlackThreadId,
|
|
105
106
|
readSlackRawMessageContext,
|
|
@@ -108,15 +109,15 @@ import {
|
|
|
108
109
|
} from "./chunk-FXOYURO4.js";
|
|
109
110
|
import {
|
|
110
111
|
discoverSkills
|
|
111
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-DLLW5ITL.js";
|
|
112
113
|
import {
|
|
113
114
|
pluginCatalogRuntime
|
|
114
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-OY2PQQ4P.js";
|
|
115
116
|
import {
|
|
116
117
|
buildOAuthTokenRequest,
|
|
117
118
|
hasRequiredOAuthScope,
|
|
118
119
|
parseOAuthTokenResponse
|
|
119
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-XA3VLFPK.js";
|
|
120
121
|
import {
|
|
121
122
|
createSlackResumeActor,
|
|
122
123
|
isUserActor,
|
|
@@ -127,7 +128,7 @@ import {
|
|
|
127
128
|
logException,
|
|
128
129
|
logInfo,
|
|
129
130
|
logWarn
|
|
130
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-F3SWGSPG.js";
|
|
131
132
|
import {
|
|
132
133
|
isRecord,
|
|
133
134
|
toOptionalNumber,
|
|
@@ -947,7 +948,7 @@ var ResumeTurnBusyError = class extends Error {
|
|
|
947
948
|
}
|
|
948
949
|
};
|
|
949
950
|
function getDefaultLockKey(channelId, threadTs) {
|
|
950
|
-
return `slack:${channelId}:${threadTs}`;
|
|
951
|
+
return threadTs ? `slack:${channelId}:${threadTs}` : `slack:${channelId}`;
|
|
951
952
|
}
|
|
952
953
|
function getResumeLogContext(args, lockKey) {
|
|
953
954
|
const routing = args.replyContext?.routing;
|
|
@@ -1063,9 +1064,6 @@ function createResumeReplyContext(args, statusSession, delivery) {
|
|
|
1063
1064
|
throw new TypeError("Slack resume requires a reply context source");
|
|
1064
1065
|
}
|
|
1065
1066
|
const source = replyContext.routing.source;
|
|
1066
|
-
if (source.platform !== "slack") {
|
|
1067
|
-
throw new TypeError("Slack resume requires a Slack source");
|
|
1068
|
-
}
|
|
1069
1067
|
if (replyContext.routing.destination.platform !== "slack") {
|
|
1070
1068
|
throw new TypeError("Slack resume requires a Slack destination");
|
|
1071
1069
|
}
|
|
@@ -1081,11 +1079,11 @@ function createResumeReplyContext(args, statusSession, delivery) {
|
|
|
1081
1079
|
},
|
|
1082
1080
|
routing: {
|
|
1083
1081
|
...replyContext.routing,
|
|
1084
|
-
source: {
|
|
1082
|
+
source: source.platform === "slack" ? {
|
|
1085
1083
|
...source,
|
|
1086
1084
|
channelId: args.channelId,
|
|
1087
|
-
threadTs: args.threadTs
|
|
1088
|
-
}
|
|
1085
|
+
...args.threadTs ? { threadTs: args.threadTs } : {}
|
|
1086
|
+
} : source
|
|
1089
1087
|
},
|
|
1090
1088
|
policy: {
|
|
1091
1089
|
...replyContext.policy,
|
|
@@ -1191,6 +1189,7 @@ async function resumeSlackTurn(args) {
|
|
|
1191
1189
|
const visibleConversationId = lockKey;
|
|
1192
1190
|
const sessionId = runArgs.turnId;
|
|
1193
1191
|
let deliveryConversation;
|
|
1192
|
+
let acceptedDeliveryId;
|
|
1194
1193
|
const getDeliveryConversation = async () => {
|
|
1195
1194
|
if (deliveryConversation) {
|
|
1196
1195
|
const userMessageId2 = getTurnUserMessage(
|
|
@@ -1240,6 +1239,7 @@ async function resumeSlackTurn(args) {
|
|
|
1240
1239
|
throw error;
|
|
1241
1240
|
}
|
|
1242
1241
|
assistantMessageDelivered = true;
|
|
1242
|
+
acceptedDeliveryId = messageTs;
|
|
1243
1243
|
const recordedMessageId = recordDeliveredAssistantMessage({
|
|
1244
1244
|
conversation: deliveryState2.conversation,
|
|
1245
1245
|
sessionId: deliveryState2.sessionId,
|
|
@@ -1267,6 +1267,34 @@ async function resumeSlackTurn(args) {
|
|
|
1267
1267
|
"Failed to persist an accepted resumed assistant message"
|
|
1268
1268
|
);
|
|
1269
1269
|
}
|
|
1270
|
+
const routing = runArgs.replyContext?.routing;
|
|
1271
|
+
const dispatchId = routing?.dispatch?.id;
|
|
1272
|
+
if (messageTs && dispatchId && routing) {
|
|
1273
|
+
try {
|
|
1274
|
+
await persistWithRetry(
|
|
1275
|
+
() => recordAgentTurnSessionSummary({
|
|
1276
|
+
conversationId: runArgs.conversationId,
|
|
1277
|
+
destination: routing.destination,
|
|
1278
|
+
destinationVisibility: routing.destinationVisibility,
|
|
1279
|
+
dispatchId,
|
|
1280
|
+
resultMessageId: messageTs,
|
|
1281
|
+
sessionId: runArgs.turnId,
|
|
1282
|
+
sliceId: runArgs.sliceId ?? 1,
|
|
1283
|
+
source: routing.source,
|
|
1284
|
+
state: "running",
|
|
1285
|
+
surface: routing.surface ?? "slack"
|
|
1286
|
+
})
|
|
1287
|
+
);
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
logException(
|
|
1290
|
+
error,
|
|
1291
|
+
"agent_turn_delivery_receipt_persist_failed",
|
|
1292
|
+
getResumeLogContext(runArgs, lockKey),
|
|
1293
|
+
{},
|
|
1294
|
+
"Failed to persist accepted resumed turn delivery receipt"
|
|
1295
|
+
);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1270
1298
|
failureCode = "agent_run_failed";
|
|
1271
1299
|
};
|
|
1272
1300
|
const deliveryState = await getDeliveryConversation();
|
|
@@ -1342,6 +1370,7 @@ async function resumeSlackTurn(args) {
|
|
|
1342
1370
|
context: getResumeLogContext(runArgs, lockKey)
|
|
1343
1371
|
});
|
|
1344
1372
|
const reply = finalized.reply;
|
|
1373
|
+
const dispatchErrorMessage = replyContext.routing.dispatch && reply.diagnostics.outcome !== "success" ? reply.diagnostics.errorMessage ?? `Agent turn ended with ${reply.diagnostics.outcome}.` : void 0;
|
|
1345
1374
|
if (reply.diagnostics.outcome !== "success") {
|
|
1346
1375
|
await deliverAssistantMessage({ text: reply.text });
|
|
1347
1376
|
}
|
|
@@ -1357,9 +1386,29 @@ async function resumeSlackTurn(args) {
|
|
|
1357
1386
|
currentDurationMs: reply.diagnostics.durationMs,
|
|
1358
1387
|
currentUsage: reply.diagnostics.usage,
|
|
1359
1388
|
destination: replyContext.routing.destination,
|
|
1389
|
+
destinationVisibility: replyContext.routing.destinationVisibility,
|
|
1390
|
+
dispatchId: replyContext.routing.dispatch?.id,
|
|
1391
|
+
dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
|
|
1392
|
+
...dispatchErrorMessage ? { errorMessage: dispatchErrorMessage } : {},
|
|
1393
|
+
...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : {},
|
|
1360
1394
|
source: replyContext.routing.source,
|
|
1361
1395
|
actor: resumeActor,
|
|
1362
|
-
surface: "slack"
|
|
1396
|
+
surface: replyContext.routing.surface ?? "slack",
|
|
1397
|
+
sliceId: runArgs.sliceId
|
|
1398
|
+
});
|
|
1399
|
+
} else if (replyContext.routing.dispatch?.id) {
|
|
1400
|
+
await recordAgentTurnSessionSummary({
|
|
1401
|
+
conversationId: runArgs.conversationId,
|
|
1402
|
+
destination: replyContext.routing.destination,
|
|
1403
|
+
destinationVisibility: replyContext.routing.destinationVisibility,
|
|
1404
|
+
dispatchId: replyContext.routing.dispatch?.id,
|
|
1405
|
+
dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
|
|
1406
|
+
...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : {},
|
|
1407
|
+
sessionId: runArgs.turnId,
|
|
1408
|
+
sliceId: runArgs.sliceId ?? 1,
|
|
1409
|
+
source: replyContext.routing.source,
|
|
1410
|
+
state: reply.diagnostics.outcome === "success" ? "completed" : "failed",
|
|
1411
|
+
surface: replyContext.routing.surface ?? "slack"
|
|
1363
1412
|
});
|
|
1364
1413
|
}
|
|
1365
1414
|
await runArgs.commitResult?.(reply);
|
|
@@ -3208,6 +3257,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
3208
3257
|
const lockedMessageTs = getTurnUserSlackMessageTs(lockedUserMessage);
|
|
3209
3258
|
return {
|
|
3210
3259
|
messageText: lockedUserMessage.text,
|
|
3260
|
+
sliceId: lockedSessionRecord.sliceId,
|
|
3211
3261
|
messageTs: lockedMessageTs,
|
|
3212
3262
|
inputMessageIds: [lockedUserMessage.id],
|
|
3213
3263
|
replyContext: {
|
|
@@ -3819,6 +3869,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
3819
3869
|
const lockedMessageTs = getTurnUserSlackMessageTs(lockedUserMessage);
|
|
3820
3870
|
return {
|
|
3821
3871
|
messageText: lockedUserMessage.text,
|
|
3872
|
+
sliceId: lockedSessionRecord.sliceId,
|
|
3822
3873
|
messageTs: lockedMessageTs,
|
|
3823
3874
|
inputMessageIds: [lockedUserMessage.id],
|
|
3824
3875
|
replyContext: {
|
|
@@ -4214,11 +4265,6 @@ async function receiveLocalOAuthCredential(request) {
|
|
|
4214
4265
|
}
|
|
4215
4266
|
|
|
4216
4267
|
export {
|
|
4217
|
-
sendSlackReply,
|
|
4218
|
-
getSlackApiErrorCode,
|
|
4219
|
-
getSlackErrorObservabilityAttributes,
|
|
4220
|
-
isRetryableSlackPostError,
|
|
4221
|
-
isSlackTitlePermissionError,
|
|
4222
4268
|
isInvalidConversationRecordError,
|
|
4223
4269
|
CONVERSATION_WORK_CHECK_IN_INTERVAL_MS,
|
|
4224
4270
|
CONVERSATION_WORK_STALE_ENQUEUE_MS,
|
|
@@ -4243,6 +4289,11 @@ export {
|
|
|
4243
4289
|
removeActiveConversation2 as removeActiveConversation,
|
|
4244
4290
|
listActiveConversationIds2 as listActiveConversationIds,
|
|
4245
4291
|
createSlackAdapterAssistantStatusSession,
|
|
4292
|
+
sendSlackReply,
|
|
4293
|
+
getSlackApiErrorCode,
|
|
4294
|
+
getSlackErrorObservabilityAttributes,
|
|
4295
|
+
isRetryableSlackPostError,
|
|
4296
|
+
isSlackTitlePermissionError,
|
|
4246
4297
|
stripLeadingBotMention,
|
|
4247
4298
|
getThreadId,
|
|
4248
4299
|
getRunId,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
healthReportSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PE44LDDQ.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeSlackConversationId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FAEALXEH.js";
|
|
7
7
|
import {
|
|
8
8
|
parseSlackThreadId
|
|
9
9
|
} from "./chunk-FXOYURO4.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@sentry/junior",
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.116.1",
|
|
5
5
|
private: false,
|
|
6
6
|
publishConfig: {
|
|
7
7
|
access: "public"
|
|
@@ -82,7 +82,6 @@ var package_default = {
|
|
|
82
82
|
"@vercel/queue": "^0.2.0",
|
|
83
83
|
"@vercel/sandbox": "2.8.0",
|
|
84
84
|
ai: "^6.0.190",
|
|
85
|
-
"bash-tool": "^1.3.16",
|
|
86
85
|
chat: "4.29.0",
|
|
87
86
|
commander: "^14.0.3",
|
|
88
87
|
"drizzle-orm": "catalog:",
|