@sentry/junior 0.184.0 → 0.186.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-XTZVALGQ.js → agent-hooks-4B3Z4WRK.js} +13 -11
- package/dist/api/acp/schema.d.ts +20 -2
- 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 +108 -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 +368 -78
- package/dist/app.js +1412 -538
- package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AFJCAOHC.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/mailbox-input.d.ts +7 -0
- package/dist/chat/api-turns/routing.d.ts +18 -3
- 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 +6 -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 -12
- package/dist/chat/providers/slack/turn.d.ts +10 -25
- package/dist/chat/resource-events/actor.d.ts +7 -2
- package/dist/chat/resource-events/app-publisher.d.ts +18 -0
- package/dist/chat/resource-events/catalog.d.ts +19 -0
- package/dist/chat/resource-events/ingest.d.ts +0 -1
- package/dist/chat/resource-events/notification.d.ts +28 -3
- package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
- package/dist/chat/resource-events/store.d.ts +2 -14
- package/dist/chat/resource-events/tool-support.d.ts +0 -5
- package/dist/chat/resource-events/workspace.d.ts +7 -3
- package/dist/chat/runtime/turn-execution.d.ts +7 -2
- package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
- package/dist/chat/sandbox/egress/session.d.ts +10 -11
- package/dist/chat/sandbox/errors.d.ts +1 -1
- package/dist/chat/sandbox/ref.d.ts +1 -1
- package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
- package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
- 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/sentry-links.d.ts +2 -0
- package/dist/chat/services/provider-retry.d.ts +2 -0
- package/dist/chat/services/turn-failure-response.d.ts +4 -0
- package/dist/chat/services/turn-session-routing.d.ts +20 -5
- package/dist/chat/task-execution/paused-turn.d.ts +0 -2
- package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
- package/dist/chat/task-execution/slack-work.d.ts +0 -21
- 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/event-tasks.d.ts +1 -1
- package/dist/chat/tools/resource-events.d.ts +2 -2
- 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-Z3QAXJR7.js → chunk-2IBDVE62.js} +12 -9
- package/dist/{chunk-4RONS3WR.js → chunk-2U7EPTRZ.js} +11 -5
- package/dist/{chunk-3S7ULUWW.js → chunk-3CVEE6LA.js} +1 -1
- package/dist/{chunk-IZDYYYGP.js → chunk-43LODHJM.js} +24 -384
- package/dist/{chunk-LHXIZLFF.js → chunk-64WF2GQ3.js} +1 -1
- package/dist/{chunk-YKX6MTLU.js → chunk-7EOWT62G.js} +1 -1
- package/dist/{chunk-UBOIHNTH.js → chunk-7EU4YSZ4.js} +362 -188
- package/dist/{chunk-UF6BUA5W.js → chunk-ACGWTJ74.js} +3 -3
- package/dist/{chunk-6UDPINOX.js → chunk-AD64YMEC.js} +19 -44
- package/dist/{chunk-MLSQX2EX.js → chunk-BRKB5R7P.js} +1 -1
- package/dist/{chunk-E57WPXWY.js → chunk-CM6RTYSO.js} +5 -5
- package/dist/{chunk-MAPJFUMV.js → chunk-CV5CPRVG.js} +3 -3
- package/dist/chunk-D4YV5TDV.js +45 -0
- package/dist/{chunk-HIPUIPJM.js → chunk-DHYZ4VKG.js} +383 -254
- package/dist/{chunk-DUKIDPF6.js → chunk-DOP3FIQC.js} +1 -1
- package/dist/{chunk-BT53RIGJ.js → chunk-EWRPUXE3.js} +12 -50
- package/dist/{chunk-BHYRYYLY.js → chunk-FFYDRLXW.js} +1 -1
- package/dist/chunk-GFBR4S3Q.js +406 -0
- package/dist/chunk-GQMQCY7H.js +58 -0
- package/dist/{chunk-JNO2GUDS.js → chunk-GSB3NTNS.js} +926 -1856
- package/dist/{chunk-2ZQPVX7C.js → chunk-H7X2G2KS.js} +25 -12
- package/dist/{chunk-WQFEWULF.js → chunk-HKFLRIBD.js} +2 -2
- package/dist/{chunk-SHJK75Z2.js → chunk-HWXP6RHG.js} +38 -4
- package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
- package/dist/{chunk-4CNDGK25.js → chunk-JFPY6XFF.js} +911 -993
- package/dist/{chunk-6WGC3SO4.js → chunk-MCLWOBPN.js} +80 -18
- package/dist/{chunk-PJPRXO2T.js → chunk-NRMAOGRS.js} +1 -1
- package/dist/{chunk-ACPDVEJO.js → chunk-O6GQO7VP.js} +201 -218
- package/dist/{chunk-M5YWNMTE.js → chunk-OZG7E22Y.js} +24 -6
- package/dist/{chunk-WVIA7V3M.js → chunk-PFAZSRGR.js} +29 -1
- package/dist/{chunk-LCP4EDKR.js → chunk-PZZOGHVR.js} +14 -4
- package/dist/{chunk-QABCY33S.js → chunk-QBL2AVFF.js} +2 -2
- package/dist/{chunk-FKEZZMXS.js → chunk-QU3URVWG.js} +9 -94
- package/dist/{chunk-M3QYTBQ6.js → chunk-STOCCPWH.js} +11 -2
- package/dist/{chunk-K7VDC2QW.js → chunk-TXLBLGNQ.js} +6 -6
- package/dist/{chunk-JA43DV4Y.js → chunk-VOGOTEW7.js} +1 -1
- package/dist/{chunk-HUXFMDBZ.js → chunk-VQIWBJOP.js} +1 -1
- package/dist/{chunk-JM2COLGC.js → chunk-VQZYIVYN.js} +6 -6
- package/dist/{chunk-BCHYQS4B.js → chunk-VXL2LBPK.js} +1 -1
- package/dist/{chunk-6VOYP4M6.js → chunk-YXSBZRP7.js} +1 -1
- 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-MA52H62H.js → db-7XL4UPAE.js} +8 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +7 -6
- package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-RAOYHWDI.js} +30 -27
- package/dist/{runner-4IXUAQNK.js → runner-KMPBWRPM.js} +24 -19
- package/dist/{skills-X3DY7AXO.js → skills-IPCALGLQ.js} +5 -5
- package/dist/spawn-OSOWTMBG.js +41 -0
- package/dist/task-runner-IQNBA3RY.js +34 -0
- package/dist/{validation-Z6JXSTJS.js → validation-BSRCCX6N.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-OKWRFBDW.js → work-T6UFTOJY.js} +24 -19
- package/dist/worker-L35OG7VA.js +24 -0
- package/package.json +5 -5
- package/dist/spawn-43WGS6CH.js +0 -37
- package/dist/task-runner-VDRKITPV.js +0 -32
- package/dist/worker-B236AE72.js +0 -22
|
@@ -8,15 +8,19 @@ import {
|
|
|
8
8
|
juniorConversations,
|
|
9
9
|
juniorIdentities,
|
|
10
10
|
juniorUsers
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VXL2LBPK.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-6UDPINOX.js";
|
|
22
|
+
getChatConfig
|
|
23
|
+
} from "./chunk-AD64YMEC.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-3CVEE6LA.js";
|
|
28
32
|
|
|
29
33
|
// src/chat/conversations/sql/store.ts
|
|
30
34
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -773,6 +777,9 @@ var SqlStore = class {
|
|
|
773
777
|
await this.withConversationMutation(args.conversationId, async () => {
|
|
774
778
|
const existingRow = await this.readConversationRow(args.conversationId);
|
|
775
779
|
const existing = existingRow ? conversationFromRow(existingRow) : void 0;
|
|
780
|
+
if (!existing && !args.destination) {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
776
783
|
const incomingExecutionAt = args.execution.updatedAtMs ?? args.updatedAtMs;
|
|
777
784
|
const existingExecutionAt = existing?.execution.updatedAtMs ?? existing?.updatedAtMs ?? 0;
|
|
778
785
|
const incomingIsFresh = incomingExecutionAt >= existingExecutionAt;
|
|
@@ -786,6 +793,7 @@ var SqlStore = class {
|
|
|
786
793
|
createdAtMs: args.createdAtMs,
|
|
787
794
|
lastActivityAtMs: args.lastActivityAtMs,
|
|
788
795
|
updatedAtMs: args.updatedAtMs,
|
|
796
|
+
...existing?.lineage ? { lineage: existing.lineage } : void 0,
|
|
789
797
|
...args.channelName ? { channelName: args.channelName } : void 0,
|
|
790
798
|
...args.destination ? { destination: args.destination } : void 0,
|
|
791
799
|
...args.actor ? { actor: args.actor } : void 0,
|
|
@@ -913,6 +921,16 @@ var SqlStore = class {
|
|
|
913
921
|
/** Upsert the conversation row while preserving previously discovered nullable metadata fields. */
|
|
914
922
|
async upsertConversation(args) {
|
|
915
923
|
const { conversation } = args;
|
|
924
|
+
if (!conversation.lineage && !conversation.destination) {
|
|
925
|
+
const existing = await this.get({
|
|
926
|
+
conversationId: conversation.conversationId
|
|
927
|
+
});
|
|
928
|
+
if (!existing) {
|
|
929
|
+
throw new Error(
|
|
930
|
+
`Conversation ${conversation.conversationId} requires a destination at create`
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
916
934
|
const incomingExecutionVersion = sql3`coalesce(excluded.execution_updated_at, excluded.updated_at)`;
|
|
917
935
|
const currentExecutionVersion = sql3`coalesce(${juniorConversations.executionUpdatedAt}, ${juniorConversations.updatedAt})`;
|
|
918
936
|
const incomingExecutionIsFresh = sql3`${incomingExecutionVersion} >= ${currentExecutionVersion}`;
|
|
@@ -1059,377 +1077,6 @@ import {
|
|
|
1059
1077
|
sql as sql6
|
|
1060
1078
|
} from "drizzle-orm";
|
|
1061
1079
|
|
|
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
1080
|
// src/chat/conversations/sql/conversation-row.ts
|
|
1434
1081
|
import { sql as sql4 } from "drizzle-orm";
|
|
1435
1082
|
async function ensureConversationRow(executor, conversationId, atMs, options = {}) {
|
|
@@ -2150,13 +1797,6 @@ export {
|
|
|
2150
1797
|
bindProviderConversation,
|
|
2151
1798
|
locationFromRow,
|
|
2152
1799
|
withConversationMutationLock,
|
|
2153
|
-
instructionProvenanceFor,
|
|
2154
|
-
contextProvenance,
|
|
2155
|
-
sameActorIdentity,
|
|
2156
|
-
instructionActors,
|
|
2157
|
-
agentHistoryItemSchema,
|
|
2158
|
-
KNOWN_CONVERSATION_EVENT_TYPES,
|
|
2159
|
-
decodeStoredConversationEvent,
|
|
2160
1800
|
sanitizePostgresJson,
|
|
2161
1801
|
withConversationEventLock,
|
|
2162
1802
|
createSqlConversationEventStore,
|