@sentry/junior 0.183.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.
- package/dist/{agent-hooks-SNRBZYAU.js → agent-hooks-NGZQLL5O.js} +13 -11
- package/dist/api/acp/auth.d.ts +46 -0
- package/dist/api/acp/authorization-page.d.ts +11 -0
- package/dist/api/acp/conversations.d.ts +70 -0
- package/dist/api/acp/errors.d.ts +6 -0
- package/dist/api/acp/route.d.ts +16 -0
- package/dist/api/acp/schema.d.ts +115 -0
- package/dist/api/acp/sleep.d.ts +2 -0
- package/dist/api/acp/state.d.ts +22 -0
- package/dist/api/acp/transport.d.ts +113 -0
- package/dist/api/code/overview.d.ts +39 -0
- package/dist/api/locations/detail.d.ts +1 -1
- package/dist/api/people/code.d.ts +22 -0
- package/dist/api/schema/code.d.ts +46 -0
- package/dist/api/schema/conversation.d.ts +100 -20
- package/dist/api/schema/location.d.ts +1 -1
- package/dist/api/schema/person.d.ts +1 -1
- package/dist/api/schema.d.ts +4 -4
- package/dist/api/schema.js +12 -1
- package/dist/api.js +358 -76
- package/dist/app.d.ts +0 -4
- package/dist/app.js +2450 -493
- package/dist/{catalog-runtime-3I3JOIIH.js → catalog-runtime-AAEAO2RL.js} +4 -4
- package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
- package/dist/chat/api-turns/cancellation.d.ts +3 -5
- package/dist/chat/api-turns/work.d.ts +4 -9
- package/dist/chat/app/conversation-work.d.ts +1 -1
- package/dist/chat/app/factory.d.ts +4 -0
- package/dist/chat/app/services.d.ts +4 -3
- package/dist/chat/conversations/history.d.ts +83 -9
- package/dist/chat/conversations/turn-lifecycle.d.ts +4 -3
- package/dist/chat/providers/slack/input.d.ts +32 -0
- package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
- package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
- package/dist/chat/providers/slack/runtime.d.ts +1 -10
- package/dist/chat/providers/slack/turn.d.ts +11 -24
- package/dist/chat/resource-events/store.d.ts +1 -1
- package/dist/chat/resource-events/tool-support.d.ts +0 -5
- package/dist/chat/runtime/turn-execution.d.ts +7 -2
- package/dist/chat/sandbox/egress/credentials.d.ts +3 -3
- package/dist/chat/sandbox/egress/session.d.ts +5 -6
- package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
- package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
- package/dist/chat/scheduled-tasks/types.d.ts +1 -1
- package/dist/chat/services/provider-retry.d.ts +2 -0
- package/dist/chat/services/turn-failure-response.d.ts +4 -0
- package/dist/chat/task-execution/paused-turn.d.ts +0 -2
- package/dist/chat/task-execution/state.d.ts +2 -2
- package/dist/chat/task-execution/store.d.ts +1 -1
- package/dist/chat/task-execution/turn-wake.d.ts +12 -0
- package/dist/chat/tool-support/action-review.d.ts +1 -1
- package/dist/chat/tools/resource-events.d.ts +1 -1
- package/dist/chat/tools/search-conversation-events.d.ts +1 -1
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/chat/tools/watch-resource-events.d.ts +2 -2
- package/dist/{chunk-2EPYYVJC.js → chunk-4HA36IWS.js} +9 -94
- package/dist/{chunk-WVIA7V3M.js → chunk-4K25ODAO.js} +27 -1
- package/dist/{chunk-V64JCZUV.js → chunk-4S47VHJR.js} +3 -3
- package/dist/{chunk-QZV76CM4.js → chunk-6DOAUXLD.js} +231 -198
- package/dist/{chunk-M3QYTBQ6.js → chunk-6Q7YZLCL.js} +2 -1
- package/dist/{chunk-W46NIB5H.js → chunk-7GAP2XG4.js} +2 -3
- package/dist/{chunk-EENQGEIP.js → chunk-7MHNIGHP.js} +1 -1
- package/dist/{chunk-AX3UDIMA.js → chunk-ABAX75GG.js} +10 -384
- package/dist/{chunk-KTXOGLNE.js → chunk-ATUWN6Z3.js} +2 -2
- package/dist/{chunk-3HJ4F4L7.js → chunk-C6TS47CQ.js} +4 -4
- package/dist/chunk-D4YV5TDV.js +45 -0
- package/dist/{chunk-HUK5XIZL.js → chunk-D63IUQQE.js} +4 -4
- package/dist/{chunk-WOKJRLM2.js → chunk-DAPC2HTM.js} +24 -6
- package/dist/{chunk-2ADFGSUS.js → chunk-EIJCPJOY.js} +1 -1
- package/dist/{chunk-X52ESOBP.js → chunk-EJYP3NQ4.js} +4 -4
- package/dist/{chunk-35PM4YY5.js → chunk-EWEH2PJW.js} +6 -6
- package/dist/{chunk-W5JMPEBO.js → chunk-FFHXG2FX.js} +13 -11
- package/dist/{chunk-FJMTMGBC.js → chunk-FTVMXDNN.js} +1 -1
- package/dist/chunk-GFBR4S3Q.js +406 -0
- package/dist/{chunk-E3OBGRHN.js → chunk-GJTIZQGJ.js} +1 -1
- package/dist/{chunk-IO6KFXYE.js → chunk-HJPC32TQ.js} +12 -50
- package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
- package/dist/{chunk-LMNMMESF.js → chunk-LRI5IRGY.js} +19 -44
- package/dist/{chunk-6UXDTPEN.js → chunk-LVK4WJKM.js} +1 -1
- package/dist/{chunk-AYW7J6K4.js → chunk-MWOH6CIK.js} +178 -148
- package/dist/{chunk-LZBPGX5A.js → chunk-OMQ2J6F6.js} +1 -1
- package/dist/{chunk-G2B2XZQW.js → chunk-PNYJOEVV.js} +1 -1
- package/dist/{chunk-37IQ6DGU.js → chunk-QCT4226Q.js} +3 -3
- package/dist/{chunk-R767Y7QV.js → chunk-QZKHHG3B.js} +34 -8
- package/dist/{chunk-VOV3SCM3.js → chunk-TVVAMOLS.js} +2 -2
- package/dist/{chunk-56XONJPF.js → chunk-U4CTAVWN.js} +1 -1
- package/dist/{chunk-4WGFWHWP.js → chunk-UUULGCKK.js} +1 -1
- package/dist/{chunk-AHMWPFIW.js → chunk-VH4IU3UC.js} +928 -984
- package/dist/chunk-W7GCLNIV.js +58 -0
- package/dist/{chunk-24OJZ5OU.js → chunk-WLKWN4CD.js} +22 -12
- package/dist/{chunk-T5MTGX2E.js → chunk-X2SS6BF7.js} +201 -210
- package/dist/{chunk-SQHFVIMZ.js → chunk-X7NCJQAA.js} +1 -1
- package/dist/{chunk-PLZT45VC.js → chunk-Y5G23T2D.js} +5 -5
- package/dist/{chunk-3L7CWDQQ.js → chunk-ZIF2S464.js} +1 -1
- package/dist/{chunk-QI5JW5AG.js → chunk-ZKKGFUWM.js} +6 -6
- package/dist/cli/chat.js +35 -33
- package/dist/cli/check.js +5 -5
- package/dist/cli/plugins.js +14 -12
- package/dist/cli/snapshot-create.js +10 -9
- package/dist/cli/upgrade.js +7 -6
- package/dist/{db-K2VMNLHQ.js → db-TRJ77FAU.js} +8 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +7 -6
- package/dist/{oauth-callback-server-DZZMTKSS.js → oauth-callback-server-XD5SV3MS.js} +30 -27
- package/dist/{runner-IIAKWDXI.js → runner-KFX7NG6D.js} +24 -19
- package/dist/{skills-EXIQ7BP5.js → skills-J2AH26CW.js} +5 -5
- package/dist/spawn-VU3CSRI6.js +41 -0
- package/dist/task-runner-5JG3VIIY.js +34 -0
- package/dist/{validation-XUGIWBJF.js → validation-O5J4VOPF.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-G4RLJ634.js → work-ECPQTG3U.js} +24 -19
- package/dist/worker-RS3DXUDO.js +24 -0
- package/package.json +5 -6
- package/dist/app-adapter.d.ts +0 -85
- package/dist/chat/api-turns/adapter-conversations.d.ts +0 -15
- package/dist/spawn-ZR6OOEAN.js +0 -37
- package/dist/task-runner-C52HYCVD.js +0 -32
- package/dist/worker-R2JEHK67.js +0 -22
|
@@ -33,7 +33,7 @@ var ConversationTurnLifecycleService = class {
|
|
|
33
33
|
}
|
|
34
34
|
]);
|
|
35
35
|
}
|
|
36
|
-
/** Record a classified failure once
|
|
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.
|
|
4
|
+
version: "0.185.0",
|
|
5
5
|
private: false,
|
|
6
6
|
publishConfig: {
|
|
7
7
|
access: "public"
|
|
@@ -69,6 +69,7 @@ var package_default = {
|
|
|
69
69
|
"test:coverage": "vitest run --maxWorkers=4 --coverage --reporter=default --reporter=junit --outputFile.junit=coverage/results.junit.xml"
|
|
70
70
|
},
|
|
71
71
|
dependencies: {
|
|
72
|
+
"@agentclientprotocol/sdk": "1.3.0",
|
|
72
73
|
"@ai-sdk/gateway": "^3.0.119",
|
|
73
74
|
"@chat-adapter/slack": "4.29.0",
|
|
74
75
|
"@chat-adapter/state-memory": "4.29.0",
|
|
@@ -104,13 +105,11 @@ var package_default = {
|
|
|
104
105
|
zod: "catalog:"
|
|
105
106
|
},
|
|
106
107
|
devDependencies: {
|
|
107
|
-
"@agentclientprotocol/sdk": "1.3.0",
|
|
108
108
|
"@emnapi/core": "^1.10.0",
|
|
109
109
|
"@emnapi/runtime": "^1.10.0",
|
|
110
110
|
"@hono/node-server": "1.19.14",
|
|
111
111
|
"@oxlint/plugins": "1.79.0",
|
|
112
112
|
"@sentry/junior-github": "workspace:*",
|
|
113
|
-
"@sentry/junior-acp": "workspace:*",
|
|
114
113
|
"@sentry/junior-memory": "workspace:*",
|
|
115
114
|
"@sentry/junior-testing": "workspace:*",
|
|
116
115
|
"@types/node": "^25.9.1",
|
|
@@ -8,15 +8,19 @@ import {
|
|
|
8
8
|
juniorConversations,
|
|
9
9
|
juniorIdentities,
|
|
10
10
|
juniorUsers
|
|
11
|
-
} from "./chunk-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
modelProfileSchema
|
|
19
|
-
} from "./chunk-LMNMMESF.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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
28
|
+
} from "./chunk-FTVMXDNN.js";
|
|
29
29
|
import {
|
|
30
30
|
getChatConfig,
|
|
31
31
|
isProviderRetryError
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-LRI5IRGY.js";
|
|
33
33
|
import {
|
|
34
34
|
logException,
|
|
35
35
|
logInfo,
|
|
36
36
|
logWarn,
|
|
37
37
|
withLogContext
|
|
38
|
-
} from "./chunk-
|
|
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-
|
|
11
|
+
} from "./chunk-ABAX75GG.js";
|
|
12
12
|
import {
|
|
13
13
|
getDefaultRedisStateAdapterFor,
|
|
14
14
|
getStateAdapter
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-PNYJOEVV.js";
|
|
16
16
|
import {
|
|
17
17
|
getChatConfig
|
|
18
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
5
|
+
} from "./chunk-Y5G23T2D.js";
|
|
6
6
|
import {
|
|
7
7
|
buildDeterministicTurnId,
|
|
8
8
|
clearPendingAuth,
|
|
9
9
|
markTurnClosed,
|
|
10
10
|
markTurnCompleted
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-U4CTAVWN.js";
|
|
12
12
|
import {
|
|
13
13
|
hydrateConversationMessages,
|
|
14
14
|
markConversationMessage
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WLKWN4CD.js";
|
|
16
16
|
import {
|
|
17
17
|
ProviderError,
|
|
18
18
|
findProviderError,
|
|
19
19
|
getProviderErrorAttributes,
|
|
20
20
|
getProviderErrorUserMessage
|
|
21
|
-
} from "./chunk-
|
|
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-
|
|
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
|