@sentry/junior 0.131.0 → 0.132.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-M5V454P5.js → agent-hooks-ONXOJDR6.js} +8 -8
- package/dist/api/conversations/list.d.ts +13 -2
- package/dist/api/schema/task.d.ts +0 -3
- package/dist/api/schema.js +1 -1
- package/dist/api.js +23 -22
- package/dist/app.js +21 -21
- package/dist/{catalog-runtime-PI2IFWZ5.js → catalog-runtime-BATAY4R7.js} +5 -5
- package/dist/chat/conversations/location.d.ts +10 -0
- package/dist/chat/conversations/sql/location.d.ts +9 -0
- package/dist/chat/conversations/store.d.ts +2 -0
- package/dist/chat/scheduled-tasks/tool-support.d.ts +2 -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 +3 -3
- package/dist/chat/scheduled-tasks/types.d.ts +1 -1
- package/dist/{chunk-SVX4JDOR.js → chunk-2425Q4OR.js} +1 -1
- package/dist/{chunk-MLIJGLW5.js → chunk-ALDPUN3Z.js} +4 -4
- package/dist/{chunk-XXGCQCFJ.js → chunk-AW5Z3T7V.js} +4 -4
- package/dist/{chunk-APUL3Y63.js → chunk-B7IY6SVJ.js} +1 -1
- package/dist/{chunk-J4I2GVGH.js → chunk-BKE47OOW.js} +2 -2
- package/dist/{chunk-JKHK3LM2.js → chunk-G3WYA2RS.js} +1 -1
- package/dist/{chunk-HSPYTFMD.js → chunk-GOEZU33G.js} +1 -1
- package/dist/{chunk-HZ5EVSPV.js → chunk-GPXVDJML.js} +4 -4
- package/dist/{chunk-VMPL77IK.js → chunk-GTKNPQNN.js} +12 -12
- package/dist/{chunk-KWYCUXJX.js → chunk-ISNRPCPG.js} +1 -1
- package/dist/{chunk-UYYSD255.js → chunk-JYQAE2ZU.js} +1 -1
- package/dist/{chunk-ZMIO64MA.js → chunk-NNHUGGO4.js} +2 -2
- package/dist/{chunk-D6ZMP3FC.js → chunk-O2UXPUVQ.js} +6 -6
- package/dist/{chunk-XMDY52DJ.js → chunk-ODIP5CEM.js} +1 -1
- package/dist/{chunk-BVKP37NE.js → chunk-QVEXYYFM.js} +1 -1
- package/dist/{chunk-DRFI6CW3.js → chunk-SKWIIUS7.js} +7 -7
- package/dist/{chunk-NGJEC4MF.js → chunk-U76PS7AT.js} +2 -2
- package/dist/{chunk-7Y2OKB5K.js → chunk-V44FFBO3.js} +1 -1
- package/dist/{chunk-TD2A27ET.js → chunk-WEJIS7OC.js} +1 -1
- package/dist/{chunk-5ONXE2GF.js → chunk-WYQP7QSB.js} +206 -176
- package/dist/{chunk-7X62XOC4.js → chunk-XN656LB4.js} +53 -18
- package/dist/{chunk-TRKWWIB3.js → chunk-ZMV2YBT6.js} +21 -21
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +11 -11
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +6 -6
- package/dist/{db-5P6K3ZCM.js → db-QFFZACXF.js} +6 -6
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-RIMCKQZX.js → oauth-callback-server-5WXLD533.js} +16 -16
- package/dist/{runner-CAD3BVML.js → runner-Y3LTUNAA.js} +10 -10
- package/dist/{skills-WVPCTBUT.js → skills-7M5C24GM.js} +6 -6
- package/dist/{validation-GLEXIFFI.js → validation-MRILMYDI.js} +6 -6
- package/dist/version.js +1 -1
- package/migrations/0017_drop_paused_scheduled_tasks.sql +19 -0
- package/migrations/meta/0017_snapshot.json +1666 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +4 -4
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
TURN_REASONING_LEVELS,
|
|
10
10
|
getChatConfig,
|
|
11
11
|
modelProfileSchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NNHUGGO4.js";
|
|
13
13
|
import {
|
|
14
14
|
juniorDestinations
|
|
15
15
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./chunk-F3B2YJ76.js";
|
|
20
20
|
import {
|
|
21
21
|
normalizeIdentityEmail
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GOEZU33G.js";
|
|
23
23
|
|
|
24
24
|
// src/chat/conversations/sql/store.ts
|
|
25
25
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -197,6 +197,39 @@ function parseSessionSource(value) {
|
|
|
197
197
|
return parsed.success ? normalizeSessionSource(parsed.data) : void 0;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
// src/chat/conversations/location.ts
|
|
201
|
+
import { nonBlankStringSchema } from "@sentry/junior-plugin-api";
|
|
202
|
+
import { z } from "zod";
|
|
203
|
+
var locationSchema = z.object({
|
|
204
|
+
/** Junior-owned stable identity for this location. */
|
|
205
|
+
id: nonBlankStringSchema,
|
|
206
|
+
/** Provider namespace that owns the provider and tenant identifiers. */
|
|
207
|
+
provider: nonBlankStringSchema,
|
|
208
|
+
/** Optional provider-native workspace, account, or tenant scope. */
|
|
209
|
+
tenantId: nonBlankStringSchema.optional(),
|
|
210
|
+
/** Provider-native identifier for the container within its tenant scope. */
|
|
211
|
+
providerId: nonBlankStringSchema
|
|
212
|
+
}).strict();
|
|
213
|
+
|
|
214
|
+
// src/chat/conversations/sql/location.ts
|
|
215
|
+
function locationFromRow(row) {
|
|
216
|
+
if (!row || row.provider === "local") {
|
|
217
|
+
return void 0;
|
|
218
|
+
}
|
|
219
|
+
return locationSchema.parse({
|
|
220
|
+
id: row.id,
|
|
221
|
+
provider: row.provider,
|
|
222
|
+
...row.providerTenantId ? { tenantId: row.providerTenantId } : {},
|
|
223
|
+
providerId: row.providerDestinationId
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function privacyFromLocationRow(row) {
|
|
227
|
+
if (!row) {
|
|
228
|
+
return void 0;
|
|
229
|
+
}
|
|
230
|
+
return row.visibility === "public" ? "public" : "private";
|
|
231
|
+
}
|
|
232
|
+
|
|
200
233
|
// src/chat/conversations/sql/store.ts
|
|
201
234
|
var CONVERSATION_MUTATION_LOCK_PREFIX = "junior_conversation";
|
|
202
235
|
function now() {
|
|
@@ -315,12 +348,6 @@ function executionStatusFromValue(value) {
|
|
|
315
348
|
}
|
|
316
349
|
throw new Error("Conversation record execution status is invalid");
|
|
317
350
|
}
|
|
318
|
-
function privacyFromRow(row) {
|
|
319
|
-
if (row.destination === null) {
|
|
320
|
-
return void 0;
|
|
321
|
-
}
|
|
322
|
-
return row.destination.visibility === "public" ? "public" : "private";
|
|
323
|
-
}
|
|
324
351
|
function actorFromIdentityRow(identity, userDisplayName) {
|
|
325
352
|
if (!identity) {
|
|
326
353
|
return void 0;
|
|
@@ -351,7 +378,7 @@ function destinationFromRow(destination) {
|
|
|
351
378
|
}
|
|
352
379
|
function conversationFromRow(readRow) {
|
|
353
380
|
const row = readRow.conversation;
|
|
354
|
-
const visibility =
|
|
381
|
+
const visibility = privacyFromLocationRow(readRow.destination);
|
|
355
382
|
if (row.schemaVersion !== 1) {
|
|
356
383
|
throw new Error("Conversation record schema version is invalid");
|
|
357
384
|
}
|
|
@@ -384,6 +411,7 @@ function conversationFromRow(readRow) {
|
|
|
384
411
|
...row.runId ? { runId: row.runId } : {},
|
|
385
412
|
updatedAtMs: msFromDate(row.executionUpdatedAt) ?? requiredMsFromDate(row.updatedAt)
|
|
386
413
|
};
|
|
414
|
+
const location = locationFromRow(readRow.destination);
|
|
387
415
|
return {
|
|
388
416
|
schemaVersion: 1,
|
|
389
417
|
conversationId: row.conversationId,
|
|
@@ -397,6 +425,7 @@ function conversationFromRow(readRow) {
|
|
|
397
425
|
}
|
|
398
426
|
} : {},
|
|
399
427
|
...destination ? { destination } : {},
|
|
428
|
+
...location ? { location } : {},
|
|
400
429
|
...actor ? { actor } : {},
|
|
401
430
|
...msFromDate(row.archivedAt) !== void 0 ? { archivedAtMs: msFromDate(row.archivedAt) } : {},
|
|
402
431
|
...row.channelName ? { channelName: row.channelName } : {},
|
|
@@ -793,16 +822,16 @@ import {
|
|
|
793
822
|
} from "drizzle-orm";
|
|
794
823
|
|
|
795
824
|
// src/chat/conversations/history.ts
|
|
796
|
-
import { z as
|
|
825
|
+
import { z as z3 } from "zod";
|
|
797
826
|
|
|
798
827
|
// src/chat/conversations/provenance.ts
|
|
799
828
|
import { actorSchema } from "@sentry/junior-plugin-api";
|
|
800
|
-
import { z } from "zod";
|
|
801
|
-
var conversationMessageAuthoritySchema =
|
|
802
|
-
|
|
803
|
-
|
|
829
|
+
import { z as z2 } from "zod";
|
|
830
|
+
var conversationMessageAuthoritySchema = z2.union([
|
|
831
|
+
z2.literal("instruction"),
|
|
832
|
+
z2.literal("context")
|
|
804
833
|
]);
|
|
805
|
-
var conversationMessageProvenanceSchema =
|
|
834
|
+
var conversationMessageProvenanceSchema = z2.object({
|
|
806
835
|
authority: conversationMessageAuthoritySchema,
|
|
807
836
|
actor: actorSchema.optional()
|
|
808
837
|
}).strict();
|
|
@@ -845,214 +874,214 @@ var handoffModelProfileSchema = modelProfileSchema.refine(
|
|
|
845
874
|
(profile) => profile !== "standard",
|
|
846
875
|
"handoff profile must not be standard"
|
|
847
876
|
);
|
|
848
|
-
var userMessageEventDataSchema =
|
|
849
|
-
type:
|
|
850
|
-
role:
|
|
877
|
+
var userMessageEventDataSchema = z3.object({
|
|
878
|
+
type: z3.literal("user_message"),
|
|
879
|
+
role: z3.never().optional(),
|
|
851
880
|
provenance: conversationMessageProvenanceSchema
|
|
852
881
|
}).passthrough();
|
|
853
|
-
var assistantMessageEventDataSchema =
|
|
854
|
-
type:
|
|
855
|
-
role:
|
|
882
|
+
var assistantMessageEventDataSchema = z3.object({
|
|
883
|
+
type: z3.literal("assistant_message"),
|
|
884
|
+
role: z3.never().optional()
|
|
856
885
|
}).passthrough();
|
|
857
|
-
var toolResultEventDataSchema =
|
|
858
|
-
type:
|
|
859
|
-
role:
|
|
886
|
+
var toolResultEventDataSchema = z3.object({
|
|
887
|
+
type: z3.literal("tool_result"),
|
|
888
|
+
role: z3.never().optional()
|
|
860
889
|
}).passthrough();
|
|
861
|
-
var agentHistoryItemSchema =
|
|
890
|
+
var agentHistoryItemSchema = z3.discriminatedUnion("type", [
|
|
862
891
|
userMessageEventDataSchema,
|
|
863
892
|
assistantMessageEventDataSchema,
|
|
864
893
|
toolResultEventDataSchema
|
|
865
894
|
]);
|
|
866
|
-
var nativeReplacementHistoryItemSchema =
|
|
895
|
+
var nativeReplacementHistoryItemSchema = z3.object({
|
|
867
896
|
item: agentHistoryItemSchema,
|
|
868
897
|
// Preserve the copied item's position when a turn resumes. Synthetic
|
|
869
898
|
// summary and handoff items have no source event.
|
|
870
|
-
sourceEventSeq:
|
|
899
|
+
sourceEventSeq: z3.number().int().nonnegative().optional()
|
|
871
900
|
}).strict();
|
|
872
|
-
var replacementHistorySchema =
|
|
873
|
-
var compactionDetailsSchema =
|
|
874
|
-
reason:
|
|
875
|
-
estimatedInputTokens:
|
|
876
|
-
replacementInputTokens:
|
|
877
|
-
triggerTokens:
|
|
878
|
-
inputLimitTokens:
|
|
879
|
-
inputMessageCount:
|
|
880
|
-
retainedMessageCount:
|
|
881
|
-
summaryChars:
|
|
901
|
+
var replacementHistorySchema = z3.array(nativeReplacementHistoryItemSchema);
|
|
902
|
+
var compactionDetailsSchema = z3.object({
|
|
903
|
+
reason: z3.literal("capacity"),
|
|
904
|
+
estimatedInputTokens: z3.number().int().nonnegative(),
|
|
905
|
+
replacementInputTokens: z3.number().int().nonnegative().optional(),
|
|
906
|
+
triggerTokens: z3.number().int().nonnegative(),
|
|
907
|
+
inputLimitTokens: z3.number().int().positive(),
|
|
908
|
+
inputMessageCount: z3.number().int().nonnegative(),
|
|
909
|
+
retainedMessageCount: z3.number().int().nonnegative(),
|
|
910
|
+
summaryChars: z3.number().int().nonnegative()
|
|
882
911
|
}).strict();
|
|
883
|
-
var historyReplacementEventDataSchema =
|
|
884
|
-
|
|
885
|
-
type:
|
|
912
|
+
var historyReplacementEventDataSchema = z3.discriminatedUnion("type", [
|
|
913
|
+
z3.object({
|
|
914
|
+
type: z3.literal("handoff"),
|
|
886
915
|
modelProfile: handoffModelProfileSchema,
|
|
887
|
-
modelId:
|
|
888
|
-
reasoningLevel:
|
|
889
|
-
triggeringToolCallId:
|
|
890
|
-
summary:
|
|
916
|
+
modelId: z3.string().min(1),
|
|
917
|
+
reasoningLevel: z3.string().min(1).optional(),
|
|
918
|
+
triggeringToolCallId: z3.string().min(1).optional(),
|
|
919
|
+
summary: z3.string().min(1).optional(),
|
|
891
920
|
replacementHistory: replacementHistorySchema
|
|
892
921
|
}).strict(),
|
|
893
|
-
|
|
894
|
-
type:
|
|
922
|
+
z3.object({
|
|
923
|
+
type: z3.literal("compaction"),
|
|
895
924
|
modelProfile: modelProfileSchema,
|
|
896
|
-
modelId:
|
|
925
|
+
modelId: z3.string().min(1),
|
|
897
926
|
details: compactionDetailsSchema.optional(),
|
|
898
|
-
summary:
|
|
927
|
+
summary: z3.string().min(1).optional(),
|
|
899
928
|
replacementHistory: replacementHistorySchema
|
|
900
929
|
}).strict()
|
|
901
930
|
]);
|
|
902
|
-
var historyReplacementSchema =
|
|
931
|
+
var historyReplacementSchema = z3.object({
|
|
903
932
|
data: historyReplacementEventDataSchema,
|
|
904
|
-
createdAtMs:
|
|
933
|
+
createdAtMs: z3.number().finite()
|
|
905
934
|
}).strict();
|
|
906
|
-
var mcpProviderConnectedEventDataSchema =
|
|
907
|
-
type:
|
|
908
|
-
provider:
|
|
935
|
+
var mcpProviderConnectedEventDataSchema = z3.object({
|
|
936
|
+
type: z3.literal("mcp_provider_connected"),
|
|
937
|
+
provider: z3.string().min(1)
|
|
909
938
|
}).strict();
|
|
910
|
-
var authorizationKindSchema =
|
|
911
|
-
|
|
912
|
-
|
|
939
|
+
var authorizationKindSchema = z3.union([
|
|
940
|
+
z3.literal("plugin"),
|
|
941
|
+
z3.literal("mcp")
|
|
913
942
|
]);
|
|
914
|
-
var authorizationRequestedEventDataSchema =
|
|
915
|
-
type:
|
|
943
|
+
var authorizationRequestedEventDataSchema = z3.object({
|
|
944
|
+
type: z3.literal("authorization_requested"),
|
|
916
945
|
kind: authorizationKindSchema,
|
|
917
|
-
provider:
|
|
918
|
-
actorId:
|
|
919
|
-
authorizationId:
|
|
920
|
-
delivery:
|
|
921
|
-
|
|
922
|
-
|
|
946
|
+
provider: z3.string().min(1),
|
|
947
|
+
actorId: z3.string().min(1),
|
|
948
|
+
authorizationId: z3.string().min(1),
|
|
949
|
+
delivery: z3.union([
|
|
950
|
+
z3.literal("private_link_sent"),
|
|
951
|
+
z3.literal("private_link_reused")
|
|
923
952
|
])
|
|
924
953
|
}).strict();
|
|
925
|
-
var authorizationCompletedEventDataSchema =
|
|
926
|
-
type:
|
|
954
|
+
var authorizationCompletedEventDataSchema = z3.object({
|
|
955
|
+
type: z3.literal("authorization_completed"),
|
|
927
956
|
kind: authorizationKindSchema,
|
|
928
|
-
provider:
|
|
929
|
-
actorId:
|
|
930
|
-
authorizationId:
|
|
957
|
+
provider: z3.string().min(1),
|
|
958
|
+
actorId: z3.string().min(1),
|
|
959
|
+
authorizationId: z3.string().min(1)
|
|
931
960
|
}).strict();
|
|
932
|
-
var toolExecutionStartedEventDataSchema =
|
|
933
|
-
type:
|
|
934
|
-
toolCallId:
|
|
935
|
-
toolName:
|
|
961
|
+
var toolExecutionStartedEventDataSchema = z3.object({
|
|
962
|
+
type: z3.literal("tool_execution_started"),
|
|
963
|
+
toolCallId: z3.string().min(1),
|
|
964
|
+
toolName: z3.string().min(1)
|
|
936
965
|
}).strict();
|
|
937
|
-
var guardianActionReviewedEventDataSchema =
|
|
938
|
-
type:
|
|
939
|
-
turnId:
|
|
940
|
-
toolCallId:
|
|
941
|
-
toolName:
|
|
942
|
-
costUsd:
|
|
943
|
-
decision:
|
|
944
|
-
riskLevel:
|
|
945
|
-
userAuthorization:
|
|
966
|
+
var guardianActionReviewedEventDataSchema = z3.object({
|
|
967
|
+
type: z3.literal("guardian_action_reviewed"),
|
|
968
|
+
turnId: z3.string().min(1),
|
|
969
|
+
toolCallId: z3.string().min(1),
|
|
970
|
+
toolName: z3.string().min(1),
|
|
971
|
+
costUsd: z3.number().finite().nonnegative().optional(),
|
|
972
|
+
decision: z3.enum(["allow", "ask", "deny"]),
|
|
973
|
+
riskLevel: z3.enum(["low", "medium", "high", "critical"]),
|
|
974
|
+
userAuthorization: z3.enum(["high", "medium", "low", "unknown"])
|
|
946
975
|
}).strict();
|
|
947
|
-
var conversationMessageRoleSchema =
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
976
|
+
var conversationMessageRoleSchema = z3.union([
|
|
977
|
+
z3.literal("user"),
|
|
978
|
+
z3.literal("assistant"),
|
|
979
|
+
z3.literal("system")
|
|
951
980
|
]);
|
|
952
|
-
var messageEventDataSchema =
|
|
953
|
-
type:
|
|
954
|
-
messageId:
|
|
981
|
+
var messageEventDataSchema = z3.object({
|
|
982
|
+
type: z3.literal("message"),
|
|
983
|
+
messageId: z3.string().min(1),
|
|
955
984
|
role: conversationMessageRoleSchema,
|
|
956
|
-
text:
|
|
957
|
-
authorIdentityId:
|
|
958
|
-
meta:
|
|
985
|
+
text: z3.string(),
|
|
986
|
+
authorIdentityId: z3.string().min(1).optional(),
|
|
987
|
+
meta: z3.record(z3.string(), z3.unknown()).optional()
|
|
959
988
|
}).strict();
|
|
960
989
|
var messageUpdatedEventDataSchema = messageEventDataSchema.extend({
|
|
961
|
-
type:
|
|
990
|
+
type: z3.literal("message_updated")
|
|
962
991
|
});
|
|
963
|
-
var messageHandledEventDataSchema =
|
|
964
|
-
type:
|
|
965
|
-
messageId:
|
|
992
|
+
var messageHandledEventDataSchema = z3.object({
|
|
993
|
+
type: z3.literal("message_handled"),
|
|
994
|
+
messageId: z3.string().min(1)
|
|
966
995
|
}).strict();
|
|
967
|
-
var messagesSummarizedEventDataSchema =
|
|
968
|
-
type:
|
|
969
|
-
historyFromSeq:
|
|
970
|
-
compactions:
|
|
971
|
-
|
|
972
|
-
coveredMessageCount:
|
|
973
|
-
createdAtMs:
|
|
974
|
-
id:
|
|
975
|
-
summary:
|
|
996
|
+
var messagesSummarizedEventDataSchema = z3.object({
|
|
997
|
+
type: z3.literal("messages_summarized"),
|
|
998
|
+
historyFromSeq: z3.number().int().nonnegative(),
|
|
999
|
+
compactions: z3.array(
|
|
1000
|
+
z3.object({
|
|
1001
|
+
coveredMessageCount: z3.number().int().nonnegative(),
|
|
1002
|
+
createdAtMs: z3.number(),
|
|
1003
|
+
id: z3.string().min(1),
|
|
1004
|
+
summary: z3.string()
|
|
976
1005
|
}).strict()
|
|
977
1006
|
)
|
|
978
1007
|
}).strict();
|
|
979
|
-
var conversationTurnSurfaceSchema =
|
|
1008
|
+
var conversationTurnSurfaceSchema = z3.enum([
|
|
980
1009
|
"slack",
|
|
981
1010
|
"api",
|
|
982
1011
|
"scheduler",
|
|
983
1012
|
"internal"
|
|
984
1013
|
]);
|
|
985
|
-
var conversationTurnFailureCodeSchema =
|
|
1014
|
+
var conversationTurnFailureCodeSchema = z3.enum([
|
|
986
1015
|
"agent_run_failed",
|
|
987
1016
|
"delivery_failed",
|
|
988
1017
|
"model_execution_failed",
|
|
989
1018
|
"persistence_failed"
|
|
990
1019
|
]);
|
|
991
|
-
var turnStartedEventDataSchema =
|
|
992
|
-
type:
|
|
993
|
-
turnId:
|
|
994
|
-
inputMessageIds:
|
|
1020
|
+
var turnStartedEventDataSchema = z3.object({
|
|
1021
|
+
type: z3.literal("turn_started"),
|
|
1022
|
+
turnId: z3.string().min(1),
|
|
1023
|
+
inputMessageIds: z3.array(z3.string().min(1)).min(1),
|
|
995
1024
|
surface: conversationTurnSurfaceSchema
|
|
996
1025
|
}).strict().refine(
|
|
997
1026
|
(data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length,
|
|
998
1027
|
"turn input message ids must be unique"
|
|
999
1028
|
);
|
|
1000
|
-
var turnRoutedEventDataSchema =
|
|
1001
|
-
type:
|
|
1002
|
-
turnId:
|
|
1029
|
+
var turnRoutedEventDataSchema = z3.object({
|
|
1030
|
+
type: z3.literal("turn_routed"),
|
|
1031
|
+
turnId: z3.string().min(1),
|
|
1003
1032
|
modelProfile: modelProfileSchema,
|
|
1004
|
-
modelId:
|
|
1005
|
-
reasoningLevel:
|
|
1006
|
-
confidence:
|
|
1007
|
-
source:
|
|
1033
|
+
modelId: z3.string().min(1),
|
|
1034
|
+
reasoningLevel: z3.enum(TURN_REASONING_LEVELS),
|
|
1035
|
+
confidence: z3.number().min(0).max(1).optional(),
|
|
1036
|
+
source: z3.enum(["configured", "inherited", "router"])
|
|
1008
1037
|
}).strict();
|
|
1009
|
-
var turnContextEventDataSchema =
|
|
1010
|
-
type:
|
|
1011
|
-
turnId:
|
|
1012
|
-
pluginName:
|
|
1013
|
-
kind:
|
|
1014
|
-
version:
|
|
1015
|
-
content:
|
|
1038
|
+
var turnContextEventDataSchema = z3.object({
|
|
1039
|
+
type: z3.literal("turn_context"),
|
|
1040
|
+
turnId: z3.string().min(1),
|
|
1041
|
+
pluginName: z3.string().min(1),
|
|
1042
|
+
kind: z3.string().min(1).max(64),
|
|
1043
|
+
version: z3.number().int().positive(),
|
|
1044
|
+
content: z3.record(z3.string(), z3.unknown())
|
|
1016
1045
|
}).strict();
|
|
1017
|
-
var structuredConversationEventDataSchema =
|
|
1018
|
-
type:
|
|
1019
|
-
namespace:
|
|
1020
|
-
name:
|
|
1021
|
-
version:
|
|
1022
|
-
turnId:
|
|
1023
|
-
content:
|
|
1046
|
+
var structuredConversationEventDataSchema = z3.object({
|
|
1047
|
+
type: z3.literal("structured_event"),
|
|
1048
|
+
namespace: z3.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
1049
|
+
name: z3.string().regex(/^[a-z][a-z0-9_]*$/),
|
|
1050
|
+
version: z3.number().int().positive(),
|
|
1051
|
+
turnId: z3.string().min(1).optional(),
|
|
1052
|
+
content: z3.record(z3.string(), z3.unknown())
|
|
1024
1053
|
}).strict();
|
|
1025
|
-
var turnCompletedEventDataSchema =
|
|
1026
|
-
type:
|
|
1027
|
-
turnId:
|
|
1028
|
-
outcome:
|
|
1054
|
+
var turnCompletedEventDataSchema = z3.object({
|
|
1055
|
+
type: z3.literal("turn_completed"),
|
|
1056
|
+
turnId: z3.string().min(1),
|
|
1057
|
+
outcome: z3.enum(["success", "no_reply"])
|
|
1029
1058
|
}).strict();
|
|
1030
|
-
var turnFailedEventDataSchema =
|
|
1031
|
-
type:
|
|
1032
|
-
turnId:
|
|
1059
|
+
var turnFailedEventDataSchema = z3.object({
|
|
1060
|
+
type: z3.literal("turn_failed"),
|
|
1061
|
+
turnId: z3.string().min(1),
|
|
1033
1062
|
failureCode: conversationTurnFailureCodeSchema,
|
|
1034
|
-
eventId:
|
|
1063
|
+
eventId: z3.string().regex(/^[a-f0-9]{32}$/i).optional()
|
|
1035
1064
|
}).strict();
|
|
1036
|
-
var subagentStartedEventDataSchema =
|
|
1037
|
-
type:
|
|
1038
|
-
subagentInvocationId:
|
|
1039
|
-
subagentKind:
|
|
1040
|
-
modelId:
|
|
1041
|
-
parentToolCallId:
|
|
1042
|
-
reasoningLevel:
|
|
1043
|
-
childConversationId:
|
|
1065
|
+
var subagentStartedEventDataSchema = z3.object({
|
|
1066
|
+
type: z3.literal("subagent_started"),
|
|
1067
|
+
subagentInvocationId: z3.string().min(1),
|
|
1068
|
+
subagentKind: z3.string().min(1),
|
|
1069
|
+
modelId: z3.string().min(1).optional(),
|
|
1070
|
+
parentToolCallId: z3.string().min(1).optional(),
|
|
1071
|
+
reasoningLevel: z3.string().min(1).optional(),
|
|
1072
|
+
childConversationId: z3.string().min(1)
|
|
1044
1073
|
}).strict();
|
|
1045
|
-
var subagentEndedEventDataSchema =
|
|
1046
|
-
type:
|
|
1047
|
-
subagentInvocationId:
|
|
1048
|
-
outcome:
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1074
|
+
var subagentEndedEventDataSchema = z3.object({
|
|
1075
|
+
type: z3.literal("subagent_ended"),
|
|
1076
|
+
subagentInvocationId: z3.string().min(1),
|
|
1077
|
+
outcome: z3.union([
|
|
1078
|
+
z3.literal("success"),
|
|
1079
|
+
z3.literal("error"),
|
|
1080
|
+
z3.literal("aborted")
|
|
1052
1081
|
]),
|
|
1053
|
-
errorCode:
|
|
1082
|
+
errorCode: z3.string().min(1).optional()
|
|
1054
1083
|
}).strict();
|
|
1055
|
-
var appendableConversationEventDataSchema =
|
|
1084
|
+
var appendableConversationEventDataSchema = z3.union([
|
|
1056
1085
|
messageEventDataSchema,
|
|
1057
1086
|
messageUpdatedEventDataSchema,
|
|
1058
1087
|
agentHistoryItemSchema,
|
|
@@ -1072,7 +1101,7 @@ var appendableConversationEventDataSchema = z2.union([
|
|
|
1072
1101
|
subagentStartedEventDataSchema,
|
|
1073
1102
|
subagentEndedEventDataSchema
|
|
1074
1103
|
]);
|
|
1075
|
-
var conversationEventDataSchema =
|
|
1104
|
+
var conversationEventDataSchema = z3.union([
|
|
1076
1105
|
appendableConversationEventDataSchema,
|
|
1077
1106
|
historyReplacementEventDataSchema
|
|
1078
1107
|
]);
|
|
@@ -1100,22 +1129,22 @@ var KNOWN_CONVERSATION_EVENT_TYPES = [
|
|
|
1100
1129
|
"handoff",
|
|
1101
1130
|
"compaction"
|
|
1102
1131
|
];
|
|
1103
|
-
var knownConversationEventTypeSchema =
|
|
1104
|
-
var unknownConversationEventDataSchema =
|
|
1105
|
-
type:
|
|
1106
|
-
originalType:
|
|
1107
|
-
payload:
|
|
1132
|
+
var knownConversationEventTypeSchema = z3.enum(KNOWN_CONVERSATION_EVENT_TYPES);
|
|
1133
|
+
var unknownConversationEventDataSchema = z3.object({
|
|
1134
|
+
type: z3.literal("unknown"),
|
|
1135
|
+
originalType: z3.string().min(1),
|
|
1136
|
+
payload: z3.unknown()
|
|
1108
1137
|
}).strict();
|
|
1109
|
-
var conversationEventEnvelopeSchema =
|
|
1110
|
-
schemaVersion:
|
|
1111
|
-
seq:
|
|
1112
|
-
historyVersion:
|
|
1113
|
-
idempotencyKey:
|
|
1114
|
-
createdAtMs:
|
|
1138
|
+
var conversationEventEnvelopeSchema = z3.object({
|
|
1139
|
+
schemaVersion: z3.number().int().nonnegative(),
|
|
1140
|
+
seq: z3.number().int().nonnegative(),
|
|
1141
|
+
historyVersion: z3.number().int().nonnegative(),
|
|
1142
|
+
idempotencyKey: z3.string().min(1).optional(),
|
|
1143
|
+
createdAtMs: z3.number().finite()
|
|
1115
1144
|
}).strict();
|
|
1116
|
-
var conversationEventSchema =
|
|
1145
|
+
var conversationEventSchema = z3.union([
|
|
1117
1146
|
conversationEventEnvelopeSchema.extend({
|
|
1118
|
-
schemaVersion:
|
|
1147
|
+
schemaVersion: z3.literal(1),
|
|
1119
1148
|
data: conversationEventDataSchema
|
|
1120
1149
|
}),
|
|
1121
1150
|
conversationEventEnvelopeSchema.extend({
|
|
@@ -1123,8 +1152,8 @@ var conversationEventSchema = z2.union([
|
|
|
1123
1152
|
})
|
|
1124
1153
|
]);
|
|
1125
1154
|
var storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
|
|
1126
|
-
type:
|
|
1127
|
-
payload:
|
|
1155
|
+
type: z3.string().min(1),
|
|
1156
|
+
payload: z3.unknown()
|
|
1128
1157
|
});
|
|
1129
1158
|
function decodeStoredConversationEvent(value) {
|
|
1130
1159
|
const stored = storedConversationEventSchema.parse(value);
|
|
@@ -1139,10 +1168,10 @@ function decodeStoredConversationEvent(value) {
|
|
|
1139
1168
|
data: { type: "unknown", originalType: type, payload }
|
|
1140
1169
|
});
|
|
1141
1170
|
}
|
|
1142
|
-
var newConversationEventSchema =
|
|
1171
|
+
var newConversationEventSchema = z3.object({
|
|
1143
1172
|
data: appendableConversationEventDataSchema,
|
|
1144
|
-
idempotencyKey:
|
|
1145
|
-
createdAtMs:
|
|
1173
|
+
idempotencyKey: z3.string().min(1).optional(),
|
|
1174
|
+
createdAtMs: z3.number().finite()
|
|
1146
1175
|
}).strict();
|
|
1147
1176
|
|
|
1148
1177
|
// src/chat/conversations/sql/conversation-row.ts
|
|
@@ -1599,6 +1628,7 @@ export {
|
|
|
1599
1628
|
requireSlackDestination,
|
|
1600
1629
|
sameDestination,
|
|
1601
1630
|
parseSessionSource,
|
|
1631
|
+
locationFromRow,
|
|
1602
1632
|
instructionProvenanceFor,
|
|
1603
1633
|
contextProvenance,
|
|
1604
1634
|
sameActorIdentity,
|