@sentry/junior 0.184.0 → 0.185.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 (111) hide show
  1. package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-NGZQLL5O.js} +13 -11
  2. package/dist/api/acp/schema.d.ts +20 -2
  3. package/dist/api/code/overview.d.ts +39 -0
  4. package/dist/api/locations/detail.d.ts +1 -1
  5. package/dist/api/people/code.d.ts +22 -0
  6. package/dist/api/schema/code.d.ts +46 -0
  7. package/dist/api/schema/conversation.d.ts +100 -20
  8. package/dist/api/schema/location.d.ts +1 -1
  9. package/dist/api/schema/person.d.ts +1 -1
  10. package/dist/api/schema.d.ts +4 -4
  11. package/dist/api/schema.js +12 -1
  12. package/dist/api.js +358 -76
  13. package/dist/app.js +406 -377
  14. package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AAEAO2RL.js} +4 -4
  15. package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
  16. package/dist/chat/api-turns/cancellation.d.ts +3 -5
  17. package/dist/chat/api-turns/work.d.ts +4 -9
  18. package/dist/chat/app/conversation-work.d.ts +1 -1
  19. package/dist/chat/app/factory.d.ts +4 -0
  20. package/dist/chat/app/services.d.ts +4 -3
  21. package/dist/chat/conversations/history.d.ts +83 -9
  22. package/dist/chat/conversations/turn-lifecycle.d.ts +4 -3
  23. package/dist/chat/providers/slack/input.d.ts +32 -0
  24. package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
  25. package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
  26. package/dist/chat/providers/slack/runtime.d.ts +1 -10
  27. package/dist/chat/providers/slack/turn.d.ts +11 -24
  28. package/dist/chat/resource-events/store.d.ts +1 -1
  29. package/dist/chat/resource-events/tool-support.d.ts +0 -5
  30. package/dist/chat/runtime/turn-execution.d.ts +7 -2
  31. package/dist/chat/sandbox/egress/credentials.d.ts +3 -3
  32. package/dist/chat/sandbox/egress/session.d.ts +5 -6
  33. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  34. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  35. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  36. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  37. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  38. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  39. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  40. package/dist/chat/services/provider-retry.d.ts +2 -0
  41. package/dist/chat/services/turn-failure-response.d.ts +4 -0
  42. package/dist/chat/task-execution/paused-turn.d.ts +0 -2
  43. package/dist/chat/task-execution/state.d.ts +2 -2
  44. package/dist/chat/task-execution/store.d.ts +1 -1
  45. package/dist/chat/task-execution/turn-wake.d.ts +12 -0
  46. package/dist/chat/tool-support/action-review.d.ts +1 -1
  47. package/dist/chat/tools/resource-events.d.ts +1 -1
  48. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  49. package/dist/chat/tools/types.d.ts +1 -1
  50. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  51. package/dist/{chunk-FKEZZMXS.js → chunk-4HA36IWS.js} +9 -94
  52. package/dist/{chunk-WVIA7V3M.js → chunk-4K25ODAO.js} +27 -1
  53. package/dist/{chunk-UF6BUA5W.js → chunk-4S47VHJR.js} +3 -3
  54. package/dist/{chunk-JNO2GUDS.js → chunk-6DOAUXLD.js} +231 -198
  55. package/dist/{chunk-M3QYTBQ6.js → chunk-6Q7YZLCL.js} +2 -1
  56. package/dist/{chunk-6VOYP4M6.js → chunk-7GAP2XG4.js} +1 -1
  57. package/dist/{chunk-LHXIZLFF.js → chunk-7MHNIGHP.js} +1 -1
  58. package/dist/{chunk-IZDYYYGP.js → chunk-ABAX75GG.js} +10 -384
  59. package/dist/{chunk-WQFEWULF.js → chunk-ATUWN6Z3.js} +2 -2
  60. package/dist/{chunk-4RONS3WR.js → chunk-C6TS47CQ.js} +4 -4
  61. package/dist/chunk-D4YV5TDV.js +45 -0
  62. package/dist/{chunk-Z3QAXJR7.js → chunk-D63IUQQE.js} +4 -4
  63. package/dist/{chunk-M5YWNMTE.js → chunk-DAPC2HTM.js} +24 -6
  64. package/dist/{chunk-BHYRYYLY.js → chunk-EIJCPJOY.js} +1 -1
  65. package/dist/{chunk-SHJK75Z2.js → chunk-EJYP3NQ4.js} +4 -4
  66. package/dist/{chunk-K7VDC2QW.js → chunk-EWEH2PJW.js} +6 -6
  67. package/dist/{chunk-6WGC3SO4.js → chunk-FFHXG2FX.js} +13 -11
  68. package/dist/{chunk-MLSQX2EX.js → chunk-FTVMXDNN.js} +1 -1
  69. package/dist/chunk-GFBR4S3Q.js +406 -0
  70. package/dist/{chunk-PJPRXO2T.js → chunk-GJTIZQGJ.js} +1 -1
  71. package/dist/{chunk-BT53RIGJ.js → chunk-HJPC32TQ.js} +12 -50
  72. package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
  73. package/dist/{chunk-6UDPINOX.js → chunk-LRI5IRGY.js} +19 -44
  74. package/dist/{chunk-BCHYQS4B.js → chunk-LVK4WJKM.js} +1 -1
  75. package/dist/{chunk-UBOIHNTH.js → chunk-MWOH6CIK.js} +178 -148
  76. package/dist/{chunk-3S7ULUWW.js → chunk-OMQ2J6F6.js} +1 -1
  77. package/dist/{chunk-DUKIDPF6.js → chunk-PNYJOEVV.js} +1 -1
  78. package/dist/{chunk-MAPJFUMV.js → chunk-QCT4226Q.js} +3 -3
  79. package/dist/{chunk-HIPUIPJM.js → chunk-QZKHHG3B.js} +34 -8
  80. package/dist/{chunk-QABCY33S.js → chunk-TVVAMOLS.js} +2 -2
  81. package/dist/{chunk-JA43DV4Y.js → chunk-U4CTAVWN.js} +1 -1
  82. package/dist/{chunk-LCP4EDKR.js → chunk-UUULGCKK.js} +1 -1
  83. package/dist/{chunk-4CNDGK25.js → chunk-VH4IU3UC.js} +928 -984
  84. package/dist/chunk-W7GCLNIV.js +58 -0
  85. package/dist/{chunk-2ZQPVX7C.js → chunk-WLKWN4CD.js} +22 -12
  86. package/dist/{chunk-ACPDVEJO.js → chunk-X2SS6BF7.js} +198 -209
  87. package/dist/{chunk-YKX6MTLU.js → chunk-X7NCJQAA.js} +1 -1
  88. package/dist/{chunk-E57WPXWY.js → chunk-Y5G23T2D.js} +5 -5
  89. package/dist/{chunk-HUXFMDBZ.js → chunk-ZIF2S464.js} +1 -1
  90. package/dist/{chunk-JM2COLGC.js → chunk-ZKKGFUWM.js} +6 -6
  91. package/dist/cli/chat.js +35 -33
  92. package/dist/cli/check.js +5 -5
  93. package/dist/cli/plugins.js +14 -12
  94. package/dist/cli/snapshot-create.js +10 -9
  95. package/dist/cli/upgrade.js +7 -6
  96. package/dist/{db-MA52H62H.js → db-TRJ77FAU.js} +8 -6
  97. package/dist/instrumentation.js +3 -3
  98. package/dist/nitro.js +7 -6
  99. package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-XD5SV3MS.js} +30 -27
  100. package/dist/{runner-4IXUAQNK.js → runner-KFX7NG6D.js} +24 -19
  101. package/dist/{skills-X3DY7AXO.js → skills-J2AH26CW.js} +5 -5
  102. package/dist/spawn-VU3CSRI6.js +41 -0
  103. package/dist/task-runner-5JG3VIIY.js +34 -0
  104. package/dist/{validation-Z6JXSTJS.js → validation-O5J4VOPF.js} +5 -5
  105. package/dist/version.js +1 -1
  106. package/dist/{work-OKWRFBDW.js → work-ECPQTG3U.js} +24 -19
  107. package/dist/worker-RS3DXUDO.js +24 -0
  108. package/package.json +4 -4
  109. package/dist/spawn-43WGS6CH.js +0 -37
  110. package/dist/task-runner-VDRKITPV.js +0 -32
  111. package/dist/worker-B236AE72.js +0 -22
@@ -33,7 +33,7 @@ var ConversationTurnLifecycleService = class {
33
33
  }
34
34
  ]);
35
35
  }
36
- /** Record a classified failure once without accepting raw error details. */
36
+ /** Record a classified failure once. Do not store raw error text. */
37
37
  async fail(input) {
38
38
  await this.events.append(input.conversationId, [
39
39
  {
@@ -43,6 +43,7 @@ var ConversationTurnLifecycleService = class {
43
43
  type: "turn_failed",
44
44
  turnId: input.turnId,
45
45
  failureCode: input.failureCode,
46
+ ...input.failureReason ? { failureReason: input.failureReason } : void 0,
46
47
  ...input.eventId ? { eventId: input.eventId } : void 0
47
48
  }
48
49
  }
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.184.0",
4
+ version: "0.185.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"
@@ -12,7 +12,7 @@ import {
12
12
  logInfo,
13
13
  logWarn,
14
14
  setSpanAttributes
15
- } from "./chunk-3S7ULUWW.js";
15
+ } from "./chunk-OMQ2J6F6.js";
16
16
 
17
17
  // src/chat/plugins/manifest.ts
18
18
  import { z } from "zod";
@@ -8,15 +8,19 @@ import {
8
8
  juniorConversations,
9
9
  juniorIdentities,
10
10
  juniorUsers
11
- } from "./chunk-BCHYQS4B.js";
11
+ } from "./chunk-LVK4WJKM.js";
12
+ import {
13
+ conversationEventDataSchema,
14
+ decodeStoredConversationEvent,
15
+ historyReplacementSchema,
16
+ newConversationEventSchema
17
+ } from "./chunk-GFBR4S3Q.js";
12
18
  import {
13
19
  juniorDestinations
14
20
  } from "./chunk-VFUK3X5B.js";
15
21
  import {
16
- TURN_REASONING_LEVELS,
17
- getChatConfig,
18
- modelProfileSchema
19
- } from "./chunk-6UDPINOX.js";
22
+ getChatConfig
23
+ } from "./chunk-LRI5IRGY.js";
20
24
  import {
21
25
  parseActorUserId,
22
26
  parseSlackChannelReferenceId,
@@ -24,7 +28,7 @@ import {
24
28
  } from "./chunk-N7TMSOZH.js";
25
29
  import {
26
30
  normalizeIdentityEmail
27
- } from "./chunk-3S7ULUWW.js";
31
+ } from "./chunk-OMQ2J6F6.js";
28
32
 
29
33
  // src/chat/conversations/sql/store.ts
30
34
  import { randomUUID as randomUUID2 } from "crypto";
@@ -1059,377 +1063,6 @@ import {
1059
1063
  sql as sql6
1060
1064
  } from "drizzle-orm";
1061
1065
 
1062
- // src/chat/conversations/history.ts
1063
- import { z as z3 } from "zod";
1064
-
1065
- // src/chat/conversations/provenance.ts
1066
- import { actorSchema } from "@sentry/junior-plugin-api";
1067
- import { z as z2 } from "zod";
1068
- var conversationMessageAuthoritySchema = z2.union([
1069
- z2.literal("instruction"),
1070
- z2.literal("context")
1071
- ]);
1072
- var conversationMessageProvenanceSchema = z2.object({
1073
- authority: conversationMessageAuthoritySchema,
1074
- actor: actorSchema.optional()
1075
- }).strict();
1076
- function instructionProvenanceFor(actor) {
1077
- return actor ? { authority: "instruction", actor } : { authority: "instruction" };
1078
- }
1079
- var contextProvenance = {
1080
- authority: "context"
1081
- };
1082
- function actorIdentityKey(actor) {
1083
- if (actor.platform === "system") {
1084
- return `system ${actor.name}`;
1085
- }
1086
- return actor.platform === "slack" ? `slack\0${actor.teamId}\0${actor.userId}` : `${actor.platform}\0${actor.userId}`;
1087
- }
1088
- function sameActorIdentity(left, right) {
1089
- return Boolean(
1090
- left && right && actorIdentityKey(left) === actorIdentityKey(right)
1091
- );
1092
- }
1093
- function instructionActors(provenance) {
1094
- const seen = /* @__PURE__ */ new Set();
1095
- const actors = [];
1096
- for (const entry of provenance) {
1097
- if (entry.authority !== "instruction" || !entry.actor) {
1098
- continue;
1099
- }
1100
- const identity = actorIdentityKey(entry.actor);
1101
- if (seen.has(identity)) {
1102
- continue;
1103
- }
1104
- seen.add(identity);
1105
- actors.push(entry.actor);
1106
- }
1107
- return actors;
1108
- }
1109
-
1110
- // src/chat/conversations/history.ts
1111
- var userMessageEventDataSchema = z3.object({
1112
- type: z3.literal("user_message"),
1113
- role: z3.never().optional(),
1114
- provenance: conversationMessageProvenanceSchema
1115
- }).passthrough();
1116
- var assistantMessageEventDataSchema = z3.object({
1117
- type: z3.literal("assistant_message"),
1118
- role: z3.never().optional()
1119
- }).passthrough();
1120
- var toolResultEventDataSchema = z3.object({
1121
- type: z3.literal("tool_result"),
1122
- role: z3.never().optional()
1123
- }).passthrough();
1124
- var agentHistoryItemSchema = z3.discriminatedUnion("type", [
1125
- userMessageEventDataSchema,
1126
- assistantMessageEventDataSchema,
1127
- toolResultEventDataSchema
1128
- ]);
1129
- var nativeReplacementHistoryItemSchema = z3.object({
1130
- item: agentHistoryItemSchema,
1131
- // Preserve the copied item's position when a turn resumes. Synthetic
1132
- // summary and handoff items have no source event.
1133
- sourceEventSeq: z3.number().int().nonnegative().optional()
1134
- }).strict();
1135
- var replacementHistorySchema = z3.array(nativeReplacementHistoryItemSchema);
1136
- var compactionDetailsSchema = z3.object({
1137
- reason: z3.literal("capacity"),
1138
- estimatedInputTokens: z3.number().int().nonnegative(),
1139
- replacementInputTokens: z3.number().int().nonnegative().optional(),
1140
- triggerTokens: z3.number().int().nonnegative(),
1141
- inputLimitTokens: z3.number().int().positive(),
1142
- inputMessageCount: z3.number().int().nonnegative(),
1143
- retainedMessageCount: z3.number().int().nonnegative(),
1144
- summaryChars: z3.number().int().nonnegative()
1145
- }).strict();
1146
- var historyReplacementEventDataSchema = z3.discriminatedUnion("type", [
1147
- z3.object({
1148
- type: z3.literal("handoff"),
1149
- modelProfile: modelProfileSchema,
1150
- modelId: z3.string().min(1),
1151
- reasoningLevel: z3.string().min(1).optional(),
1152
- triggeringToolCallId: z3.string().min(1).optional(),
1153
- summary: z3.string().min(1).optional(),
1154
- replacementHistory: replacementHistorySchema
1155
- }).strict(),
1156
- z3.object({
1157
- type: z3.literal("compaction"),
1158
- modelProfile: modelProfileSchema,
1159
- modelId: z3.string().min(1),
1160
- details: compactionDetailsSchema.optional(),
1161
- summary: z3.string().min(1).optional(),
1162
- replacementHistory: replacementHistorySchema
1163
- }).strict()
1164
- ]);
1165
- var historyReplacementSchema = z3.object({
1166
- data: historyReplacementEventDataSchema,
1167
- createdAtMs: z3.number().finite()
1168
- }).strict();
1169
- var mcpProviderConnectedEventDataSchema = z3.object({
1170
- type: z3.literal("mcp_provider_connected"),
1171
- provider: z3.string().min(1),
1172
- credentialSubjectId: z3.string().min(1)
1173
- }).strict();
1174
- var unownedMcpProviderConnectedEventDataSchema = z3.object({
1175
- type: z3.literal("mcp_provider_connected_unowned"),
1176
- provider: z3.string().min(1)
1177
- }).strict();
1178
- var authorizationKindSchema = z3.union([
1179
- z3.literal("plugin"),
1180
- z3.literal("mcp")
1181
- ]);
1182
- var authorizationRequestedEventDataSchema = z3.object({
1183
- type: z3.literal("authorization_requested"),
1184
- kind: authorizationKindSchema,
1185
- provider: z3.string().min(1),
1186
- actorId: z3.string().min(1),
1187
- authorizationId: z3.string().min(1),
1188
- delivery: z3.union([
1189
- z3.literal("private_link_sent"),
1190
- z3.literal("private_link_reused")
1191
- ])
1192
- }).strict();
1193
- var authorizationCompletedEventDataSchema = z3.object({
1194
- type: z3.literal("authorization_completed"),
1195
- kind: authorizationKindSchema,
1196
- provider: z3.string().min(1),
1197
- actorId: z3.string().min(1),
1198
- authorizationId: z3.string().min(1)
1199
- }).strict();
1200
- var toolExecutionStartedEventDataSchema = z3.object({
1201
- type: z3.literal("tool_execution_started"),
1202
- toolCallId: z3.string().min(1),
1203
- toolName: z3.string().min(1)
1204
- }).strict();
1205
- var guardianActionReviewedEventDataSchema = z3.object({
1206
- type: z3.literal("guardian_action_reviewed"),
1207
- turnId: z3.string().min(1),
1208
- toolCallId: z3.string().min(1),
1209
- toolName: z3.string().min(1),
1210
- costUsd: z3.number().finite().nonnegative().optional(),
1211
- decision: z3.enum(["allow", "ask", "deny"]),
1212
- riskLevel: z3.enum(["low", "medium", "high", "critical"]),
1213
- userAuthorization: z3.enum(["high", "medium", "low", "unknown"])
1214
- }).strict();
1215
- var conversationMessageRoleSchema = z3.union([
1216
- z3.literal("user"),
1217
- z3.literal("assistant"),
1218
- z3.literal("system")
1219
- ]);
1220
- var messageEventDataSchema = z3.object({
1221
- type: z3.literal("message"),
1222
- messageId: z3.string().min(1),
1223
- role: conversationMessageRoleSchema,
1224
- text: z3.string(),
1225
- authorIdentityId: z3.string().min(1).optional(),
1226
- meta: z3.record(z3.string(), z3.unknown()).optional()
1227
- }).strict();
1228
- var messageUpdatedEventDataSchema = messageEventDataSchema.extend({
1229
- type: z3.literal("message_updated")
1230
- });
1231
- var messageHandledEventDataSchema = z3.object({
1232
- type: z3.literal("message_handled"),
1233
- messageId: z3.string().min(1)
1234
- }).strict();
1235
- var messagesSummarizedEventDataSchema = z3.object({
1236
- type: z3.literal("messages_summarized"),
1237
- historyFromSeq: z3.number().int().nonnegative(),
1238
- compactions: z3.array(
1239
- z3.object({
1240
- coveredMessageCount: z3.number().int().nonnegative(),
1241
- createdAtMs: z3.number(),
1242
- id: z3.string().min(1),
1243
- summary: z3.string()
1244
- }).strict()
1245
- )
1246
- }).strict();
1247
- var conversationTurnSurfaceSchema = z3.enum([
1248
- "slack",
1249
- "api",
1250
- "scheduler",
1251
- "internal"
1252
- ]);
1253
- var conversationTurnFailureCodeSchema = z3.enum([
1254
- "agent_run_failed",
1255
- "delivery_failed",
1256
- "model_execution_failed",
1257
- "persistence_failed"
1258
- ]);
1259
- var turnStartedEventDataSchema = z3.object({
1260
- type: z3.literal("turn_started"),
1261
- turnId: z3.string().min(1),
1262
- inputMessageIds: z3.array(z3.string().min(1)).min(1),
1263
- surface: conversationTurnSurfaceSchema
1264
- }).strict().refine(
1265
- (data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length,
1266
- "turn input message ids must be unique"
1267
- );
1268
- var turnRoutedEventDataSchema = z3.object({
1269
- type: z3.literal("turn_routed"),
1270
- turnId: z3.string().min(1),
1271
- modelProfile: modelProfileSchema,
1272
- modelId: z3.string().min(1),
1273
- costUsd: z3.number().finite().nonnegative().optional(),
1274
- reasoningLevel: z3.enum(TURN_REASONING_LEVELS),
1275
- confidence: z3.number().min(0).max(1).optional(),
1276
- source: z3.enum(["configured", "inherited", "router"])
1277
- }).strict();
1278
- var turnContextEventDataSchema = z3.object({
1279
- type: z3.literal("turn_context"),
1280
- turnId: z3.string().min(1),
1281
- pluginName: z3.string().min(1),
1282
- kind: z3.string().min(1).max(64),
1283
- version: z3.number().int().positive(),
1284
- content: z3.record(z3.string(), z3.unknown())
1285
- }).strict();
1286
- var structuredConversationEventDataSchema = z3.object({
1287
- type: z3.literal("structured_event"),
1288
- namespace: z3.string().regex(/^[a-z][a-z0-9-]*$/),
1289
- name: z3.string().regex(/^[a-z][a-z0-9_]*$/),
1290
- version: z3.number().int().positive(),
1291
- turnId: z3.string().min(1).optional(),
1292
- content: z3.record(z3.string(), z3.unknown())
1293
- }).strict();
1294
- var deliveredAttachmentSchema = z3.object({
1295
- id: z3.string().min(1),
1296
- filename: z3.string().min(1),
1297
- contentType: z3.string().min(1),
1298
- bytes: z3.number().int().nonnegative()
1299
- }).strict();
1300
- var attachmentsDeliveredEventDataSchema = z3.object({
1301
- type: z3.literal("attachments_delivered"),
1302
- attachments: z3.array(deliveredAttachmentSchema).min(1),
1303
- toolCallId: z3.string().min(1).optional(),
1304
- turnId: z3.string().min(1).optional()
1305
- }).strict();
1306
- var turnCompletedEventDataSchema = z3.object({
1307
- type: z3.literal("turn_completed"),
1308
- turnId: z3.string().min(1),
1309
- outcome: z3.enum(["success", "no_reply", "cancelled"])
1310
- }).strict();
1311
- var turnFailedEventDataSchema = z3.object({
1312
- type: z3.literal("turn_failed"),
1313
- turnId: z3.string().min(1),
1314
- failureCode: conversationTurnFailureCodeSchema,
1315
- eventId: z3.string().regex(/^[a-f0-9]{32}$/i).optional()
1316
- }).strict();
1317
- var subagentStartedEventDataSchema = z3.object({
1318
- type: z3.literal("subagent_started"),
1319
- subagentInvocationId: z3.string().min(1),
1320
- subagentKind: z3.string().min(1),
1321
- modelId: z3.string().min(1).optional(),
1322
- parentToolCallId: z3.string().min(1).optional(),
1323
- reasoningLevel: z3.string().min(1).optional(),
1324
- childConversationId: z3.string().min(1)
1325
- }).strict();
1326
- var subagentEndedEventDataSchema = z3.object({
1327
- type: z3.literal("subagent_ended"),
1328
- subagentInvocationId: z3.string().min(1),
1329
- outcome: z3.union([
1330
- z3.literal("success"),
1331
- z3.literal("error"),
1332
- z3.literal("aborted")
1333
- ]),
1334
- errorCode: z3.string().min(1).optional()
1335
- }).strict();
1336
- var appendableConversationEventDataSchema = z3.union([
1337
- messageEventDataSchema,
1338
- messageUpdatedEventDataSchema,
1339
- agentHistoryItemSchema,
1340
- mcpProviderConnectedEventDataSchema,
1341
- authorizationRequestedEventDataSchema,
1342
- authorizationCompletedEventDataSchema,
1343
- toolExecutionStartedEventDataSchema,
1344
- guardianActionReviewedEventDataSchema,
1345
- messageHandledEventDataSchema,
1346
- messagesSummarizedEventDataSchema,
1347
- turnStartedEventDataSchema,
1348
- turnContextEventDataSchema,
1349
- structuredConversationEventDataSchema,
1350
- attachmentsDeliveredEventDataSchema,
1351
- turnRoutedEventDataSchema,
1352
- turnCompletedEventDataSchema,
1353
- turnFailedEventDataSchema,
1354
- subagentStartedEventDataSchema,
1355
- subagentEndedEventDataSchema
1356
- ]);
1357
- var conversationEventDataSchema = z3.union([
1358
- appendableConversationEventDataSchema,
1359
- historyReplacementEventDataSchema,
1360
- unownedMcpProviderConnectedEventDataSchema
1361
- ]);
1362
- var KNOWN_CONVERSATION_EVENT_TYPES = [
1363
- "message",
1364
- "message_updated",
1365
- "user_message",
1366
- "assistant_message",
1367
- "tool_result",
1368
- "mcp_provider_connected",
1369
- "mcp_provider_connected_unowned",
1370
- "authorization_requested",
1371
- "authorization_completed",
1372
- "tool_execution_started",
1373
- "guardian_action_reviewed",
1374
- "message_handled",
1375
- "messages_summarized",
1376
- "turn_started",
1377
- "turn_context",
1378
- "structured_event",
1379
- "attachments_delivered",
1380
- "turn_routed",
1381
- "turn_completed",
1382
- "turn_failed",
1383
- "subagent_started",
1384
- "subagent_ended",
1385
- "handoff",
1386
- "compaction"
1387
- ];
1388
- var knownConversationEventTypeSchema = z3.enum(KNOWN_CONVERSATION_EVENT_TYPES);
1389
- var unknownConversationEventDataSchema = z3.object({
1390
- type: z3.literal("unknown"),
1391
- originalType: z3.string().min(1),
1392
- payload: z3.unknown()
1393
- }).strict();
1394
- var conversationEventEnvelopeSchema = z3.object({
1395
- schemaVersion: z3.number().int().nonnegative(),
1396
- seq: z3.number().int().nonnegative(),
1397
- historyVersion: z3.number().int().nonnegative(),
1398
- idempotencyKey: z3.string().min(1).optional(),
1399
- createdAtMs: z3.number().finite()
1400
- }).strict();
1401
- var conversationEventSchema = z3.union([
1402
- conversationEventEnvelopeSchema.extend({
1403
- schemaVersion: z3.literal(1),
1404
- data: conversationEventDataSchema
1405
- }),
1406
- conversationEventEnvelopeSchema.extend({
1407
- data: unknownConversationEventDataSchema
1408
- })
1409
- ]);
1410
- var storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
1411
- type: z3.string().min(1),
1412
- payload: z3.unknown()
1413
- });
1414
- function decodeStoredConversationEvent(value) {
1415
- const stored = storedConversationEventSchema.parse(value);
1416
- const { type, payload, ...envelope } = stored;
1417
- const knownType = knownConversationEventTypeSchema.safeParse(type).success;
1418
- if (stored.schemaVersion === 1 && knownType) {
1419
- const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) ? { ...payload, type } : { type };
1420
- return conversationEventSchema.parse({ ...envelope, data });
1421
- }
1422
- return conversationEventSchema.parse({
1423
- ...envelope,
1424
- data: { type: "unknown", originalType: type, payload }
1425
- });
1426
- }
1427
- var newConversationEventSchema = z3.object({
1428
- data: appendableConversationEventDataSchema,
1429
- idempotencyKey: z3.string().min(1).optional(),
1430
- createdAtMs: z3.number().finite()
1431
- }).strict();
1432
-
1433
1066
  // src/chat/conversations/sql/conversation-row.ts
1434
1067
  import { sql as sql4 } from "drizzle-orm";
1435
1068
  async function ensureConversationRow(executor, conversationId, atMs, options = {}) {
@@ -2150,13 +1783,6 @@ export {
2150
1783
  bindProviderConversation,
2151
1784
  locationFromRow,
2152
1785
  withConversationMutationLock,
2153
- instructionProvenanceFor,
2154
- contextProvenance,
2155
- sameActorIdentity,
2156
- instructionActors,
2157
- agentHistoryItemSchema,
2158
- KNOWN_CONVERSATION_EVENT_TYPES,
2159
- decodeStoredConversationEvent,
2160
1786
  sanitizePostgresJson,
2161
1787
  withConversationEventLock,
2162
1788
  createSqlConversationEventStore,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-PJPRXO2T.js";
3
+ } from "./chunk-GJTIZQGJ.js";
4
4
  import {
5
5
  skillRoots
6
6
  } from "./chunk-TXKUKMVO.js";
7
7
  import {
8
8
  logWarn
9
- } from "./chunk-3S7ULUWW.js";
9
+ } from "./chunk-OMQ2J6F6.js";
10
10
 
11
11
  // src/chat/skills.ts
12
12
  import fs from "fs/promises";
@@ -19,23 +19,23 @@ import {
19
19
  releaseConversationWork,
20
20
  requestAnotherSlice,
21
21
  startConversationWork
22
- } from "./chunk-Z3QAXJR7.js";
22
+ } from "./chunk-D63IUQQE.js";
23
23
  import {
24
24
  ConversationQueueMessageRejectedError
25
25
  } from "./chunk-JAL3CH4G.js";
26
26
  import {
27
27
  getTurnRequestDeadline
28
- } from "./chunk-MLSQX2EX.js";
28
+ } from "./chunk-FTVMXDNN.js";
29
29
  import {
30
30
  getChatConfig,
31
31
  isProviderRetryError
32
- } from "./chunk-6UDPINOX.js";
32
+ } from "./chunk-LRI5IRGY.js";
33
33
  import {
34
34
  logException,
35
35
  logInfo,
36
36
  logWarn,
37
37
  withLogContext
38
- } from "./chunk-3S7ULUWW.js";
38
+ } from "./chunk-OMQ2J6F6.js";
39
39
 
40
40
  // src/chat/task-execution/worker.ts
41
41
  var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
@@ -0,0 +1,45 @@
1
+ // src/chat/reasoning-level.ts
2
+ import { z } from "zod";
3
+ var TURN_REASONING_LEVELS = [
4
+ "none",
5
+ "low",
6
+ "medium",
7
+ "high",
8
+ "xhigh"
9
+ ];
10
+ function parseTurnReasoningLevel(value) {
11
+ return z.enum(TURN_REASONING_LEVELS).parse(value);
12
+ }
13
+
14
+ // src/chat/model-profile.ts
15
+ import { z as z2 } from "zod";
16
+ var modelProfileSchema = z2.string().regex(/^[a-z][a-z0-9_-]*$/);
17
+ var ModelProfileNotConfiguredError = class extends Error {
18
+ constructor(profile) {
19
+ super(`Model profile "${profile}" is not configured`);
20
+ this.name = "ModelProfileNotConfiguredError";
21
+ }
22
+ };
23
+ function modelIdForProfile(config, profile) {
24
+ return profileConfig(config, profile).modelId;
25
+ }
26
+ function defaultModelId(config) {
27
+ return modelIdForProfile(config, config.defaultProfile);
28
+ }
29
+ function profileConfig(config, profile) {
30
+ const profileConfig2 = Object.hasOwn(config.profiles, profile) ? config.profiles[profile] : void 0;
31
+ if (!profileConfig2) {
32
+ throw new ModelProfileNotConfiguredError(profile);
33
+ }
34
+ return profileConfig2;
35
+ }
36
+
37
+ export {
38
+ TURN_REASONING_LEVELS,
39
+ parseTurnReasoningLevel,
40
+ modelProfileSchema,
41
+ ModelProfileNotConfiguredError,
42
+ modelIdForProfile,
43
+ defaultModelId,
44
+ profileConfig
45
+ };
@@ -8,14 +8,14 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-IZDYYYGP.js";
11
+ } from "./chunk-ABAX75GG.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-DUKIDPF6.js";
15
+ } from "./chunk-PNYJOEVV.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-6UDPINOX.js";
18
+ } from "./chunk-LRI5IRGY.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
21
  } from "./chunk-N7TMSOZH.js";
@@ -23,7 +23,7 @@ import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-3S7ULUWW.js";
26
+ } from "./chunk-OMQ2J6F6.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -2,29 +2,29 @@ import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState,
4
4
  persistThreadStateById
5
- } from "./chunk-E57WPXWY.js";
5
+ } from "./chunk-Y5G23T2D.js";
6
6
  import {
7
7
  buildDeterministicTurnId,
8
8
  clearPendingAuth,
9
9
  markTurnClosed,
10
10
  markTurnCompleted
11
- } from "./chunk-JA43DV4Y.js";
11
+ } from "./chunk-U4CTAVWN.js";
12
12
  import {
13
13
  hydrateConversationMessages,
14
14
  markConversationMessage
15
- } from "./chunk-2ZQPVX7C.js";
15
+ } from "./chunk-WLKWN4CD.js";
16
16
  import {
17
17
  ProviderError,
18
18
  findProviderError,
19
19
  getProviderErrorAttributes,
20
20
  getProviderErrorUserMessage
21
- } from "./chunk-6UDPINOX.js";
21
+ } from "./chunk-LRI5IRGY.js";
22
22
  import {
23
23
  parseSlackMessageTs
24
24
  } from "./chunk-N7TMSOZH.js";
25
25
  import {
26
26
  buildTurnFailureResponse
27
- } from "./chunk-3S7ULUWW.js";
27
+ } from "./chunk-OMQ2J6F6.js";
28
28
 
29
29
  // src/chat/runtime/delivered-turn-state.ts
30
30
  function buildDeliveredTurnStatePatch(args) {
@@ -71,6 +71,21 @@ function getExecutionFailureReason(reply) {
71
71
  }
72
72
  return "empty assistant turn";
73
73
  }
74
+ function getTurnFailureReason(reply) {
75
+ if (reply.diagnostics.outcome === "success") {
76
+ return void 0;
77
+ }
78
+ if (reply.diagnostics.outcome === "provider_error") {
79
+ return findProviderError(reply.diagnostics.providerError)?.kind ?? "unknown";
80
+ }
81
+ if (reply.diagnostics.toolErrorCount > 0) {
82
+ return "tool_errors";
83
+ }
84
+ if (reply.diagnostics.usedPrimaryText && reply.diagnostics.assistantMessageCount > 0) {
85
+ return "suppressed_output";
86
+ }
87
+ return "empty_output";
88
+ }
74
89
  function getFailureCapture(reply) {
75
90
  if (reply.diagnostics.outcome === "provider_error") {
76
91
  const providerError = findProviderError(reply.diagnostics.providerError);
@@ -114,12 +129,14 @@ function finalizeFailedTurnReplyWithEvent(args) {
114
129
  if (args.reply.diagnostics.outcome === "success") {
115
130
  return { reply: args.reply };
116
131
  }
132
+ const failureReason = getTurnFailureReason(args.reply);
117
133
  const capture = getFailureCapture(args.reply);
118
134
  const eventId = requireTurnFailureEventId(
119
135
  args.logException(capture.error, capture.eventName, {
120
136
  ...getAgentTurnDiagnosticsAttributes(args.reply),
121
137
  ...args.attributes,
122
- ...capture.attributes
138
+ ...capture.attributes,
139
+ ...failureReason ? { "app.ai.failure_reason": failureReason } : void 0
123
140
  }),
124
141
  capture.eventName
125
142
  );
@@ -128,6 +145,7 @@ function finalizeFailedTurnReplyWithEvent(args) {
128
145
  const failureText = providerUserMessage ? `${providerUserMessage} Reference: \`event_id=${eventId}\`.` : buildTurnFailureResponse(eventId);
129
146
  return {
130
147
  eventId,
148
+ ...failureReason ? { failureReason } : void 0,
131
149
  reply: {
132
150
  ...args.reply,
133
151
  text: providerPartialText ? `${providerPartialText}${getInterruptionMarker()}` : failureText
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logWarn
3
- } from "./chunk-3S7ULUWW.js";
3
+ } from "./chunk-OMQ2J6F6.js";
4
4
 
5
5
  // src/chat/conversation-privacy.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  toOptionalTrimmed
3
- } from "./chunk-6UDPINOX.js";
3
+ } from "./chunk-LRI5IRGY.js";
4
4
  import {
5
5
  pluginCatalogRuntime
6
- } from "./chunk-PJPRXO2T.js";
6
+ } from "./chunk-GJTIZQGJ.js";
7
7
  import {
8
8
  setSpanAttributes,
9
9
  setSpanStatus
10
- } from "./chunk-3S7ULUWW.js";
10
+ } from "./chunk-OMQ2J6F6.js";
11
11
 
12
12
  // src/chat/sandbox/paths.ts
13
13
  function normalizeWorkspaceRoot(input) {
@@ -591,7 +591,7 @@ function isAbortError(error) {
591
591
  if (!(candidate instanceof Error)) return false;
592
592
  if (candidate.name === "AbortError") return true;
593
593
  const message = candidate.message.toLowerCase();
594
- return message === "api turn cancelled" || message === "api turn canceled" || message.startsWith("executeagentrun timed out after");
594
+ return message.startsWith("executeagentrun timed out after");
595
595
  });
596
596
  }
597
597
  function isSandboxApiTransientError(error) {