@indexnetwork/protocol 6.7.1 → 6.8.0-rc.395.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/intent/intent.graph.d.ts +5 -0
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +4 -0
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/intent/intent.state.d.ts +5 -0
- package/dist/intent/intent.state.d.ts.map +1 -1
- package/dist/intent/intent.state.js +8 -0
- package/dist/intent/intent.state.js.map +1 -1
- package/dist/questioner/questioner.agent.js +1 -1
- package/dist/questioner/questioner.agent.js.map +1 -1
- package/dist/questioner/questioner.presets.d.ts +2 -2
- package/dist/questioner/questioner.presets.d.ts.map +1 -1
- package/dist/questioner/questioner.presets.js +52 -1
- package/dist/questioner/questioner.presets.js.map +1 -1
- package/dist/questioner/questioner.types.d.ts +17 -3
- package/dist/questioner/questioner.types.d.ts.map +1 -1
- package/dist/questioner/questioner.types.js.map +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +8 -0
- package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/database.interface.js.map +1 -1
- package/dist/shared/schemas/question.schema.d.ts +86 -13
- package/dist/shared/schemas/question.schema.d.ts.map +1 -1
- package/dist/shared/schemas/question.schema.js +35 -3
- package/dist/shared/schemas/question.schema.js.map +1 -1
- package/package.json +1 -1
|
@@ -220,7 +220,7 @@ export interface QuestionGenerationResult {
|
|
|
220
220
|
underspecificationTypes: Array<UnderspecificationType | null>;
|
|
221
221
|
}
|
|
222
222
|
/** Internal reason a question was generated, orthogonal to mode and QUD metadata. */
|
|
223
|
-
export declare const QuestionPurposeSchema: z.ZodEnum<["uptake"]>;
|
|
223
|
+
export declare const QuestionPurposeSchema: z.ZodEnum<["uptake", "recovery"]>;
|
|
224
224
|
export declare const QuestionModeSchema: z.ZodEnum<["discovery", "intent", "enrichment", "negotiation", "negotiation_inflight", "chat", "pool_discovery"]>;
|
|
225
225
|
/** One server-side candidate→side assignment (never serialized to clients). */
|
|
226
226
|
export declare const QuestionPoolAssignmentSchema: z.ZodObject<{
|
|
@@ -521,15 +521,37 @@ export declare const QuestionPoolPushSchema: z.ZodObject<{
|
|
|
521
521
|
}>;
|
|
522
522
|
/** Durable request state for proactive pool-question delivery. */
|
|
523
523
|
export declare const QuestionPoolPushRequestStatusSchema: z.ZodEnum<["requested", "suppressed"]>;
|
|
524
|
-
/**
|
|
525
|
-
export declare const
|
|
524
|
+
/** Private snapshot for a post-discovery recovery refinement question. */
|
|
525
|
+
export declare const QuestionRecoverySnapshotSchema: z.ZodObject<{
|
|
526
|
+
version: z.ZodLiteral<1>;
|
|
527
|
+
intentFingerprint: z.ZodString;
|
|
528
|
+
completionSource: z.ZodEnum<["from_intent", "discovery_run"]>;
|
|
529
|
+
/** Privacy-safe aggregate only; raw negotiation evidence is never persisted. */
|
|
530
|
+
rejectedNegotiationCount: z.ZodOptional<z.ZodNumber>;
|
|
531
|
+
/** Bounded internal correlation id for an asynchronous discovery run. */
|
|
532
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
533
|
+
}, "strip", z.ZodTypeAny, {
|
|
534
|
+
intentFingerprint: string;
|
|
535
|
+
version: 1;
|
|
536
|
+
completionSource: "from_intent" | "discovery_run";
|
|
537
|
+
runId?: string | undefined;
|
|
538
|
+
rejectedNegotiationCount?: number | undefined;
|
|
539
|
+
}, {
|
|
540
|
+
intentFingerprint: string;
|
|
541
|
+
version: 1;
|
|
542
|
+
completionSource: "from_intent" | "discovery_run";
|
|
543
|
+
runId?: string | undefined;
|
|
544
|
+
rejectedNegotiationCount?: number | undefined;
|
|
545
|
+
}>;
|
|
546
|
+
/** Internal reason a pending question was voided. */
|
|
547
|
+
export declare const QuestionVoidedReasonSchema: z.ZodEnum<["pool_drift", "intent_edit", "recovery_drift"]>;
|
|
526
548
|
/** Permanent reasons that terminalize an unclaimed proactive push request. */
|
|
527
549
|
export declare const QuestionPoolPushRequestReasonSchema: z.ZodEnum<["question_lifecycle", "intent_lifecycle", "malformed_source", "malformed_actor", "malformed_pool", "malformed_cycle", "visited", "pool_size", "voi", "cycle_budget"]>;
|
|
528
550
|
export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
529
551
|
/** Which preset mode generated this question. */
|
|
530
552
|
mode: z.ZodEnum<["discovery", "intent", "enrichment", "negotiation", "negotiation_inflight", "chat", "pool_discovery"]>;
|
|
531
553
|
/** Internal reason for generation; independent of mode and QUD repair metadata. */
|
|
532
|
-
purpose: z.ZodOptional<z.ZodEnum<["uptake"]>>;
|
|
554
|
+
purpose: z.ZodOptional<z.ZodEnum<["uptake", "recovery"]>>;
|
|
533
555
|
/** Entity type that triggered generation (e.g. "opportunity", "intent", "profile"). */
|
|
534
556
|
sourceType: z.ZodString;
|
|
535
557
|
/** ID of the triggering entity. */
|
|
@@ -733,6 +755,28 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
733
755
|
intentFingerprint?: string | undefined;
|
|
734
756
|
opportunityIds?: string[] | undefined;
|
|
735
757
|
}>>;
|
|
758
|
+
/** Post-discovery intent recovery snapshot. Internal only. */
|
|
759
|
+
recovery: z.ZodOptional<z.ZodObject<{
|
|
760
|
+
version: z.ZodLiteral<1>;
|
|
761
|
+
intentFingerprint: z.ZodString;
|
|
762
|
+
completionSource: z.ZodEnum<["from_intent", "discovery_run"]>;
|
|
763
|
+
/** Privacy-safe aggregate only; raw negotiation evidence is never persisted. */
|
|
764
|
+
rejectedNegotiationCount: z.ZodOptional<z.ZodNumber>;
|
|
765
|
+
/** Bounded internal correlation id for an asynchronous discovery run. */
|
|
766
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
767
|
+
}, "strip", z.ZodTypeAny, {
|
|
768
|
+
intentFingerprint: string;
|
|
769
|
+
version: 1;
|
|
770
|
+
completionSource: "from_intent" | "discovery_run";
|
|
771
|
+
runId?: string | undefined;
|
|
772
|
+
rejectedNegotiationCount?: number | undefined;
|
|
773
|
+
}, {
|
|
774
|
+
intentFingerprint: string;
|
|
775
|
+
version: 1;
|
|
776
|
+
completionSource: "from_intent" | "discovery_run";
|
|
777
|
+
runId?: string | undefined;
|
|
778
|
+
rejectedNegotiationCount?: number | undefined;
|
|
779
|
+
}>>;
|
|
736
780
|
/** Durable request marker written before enqueueing proactive delivery. Internal only. */
|
|
737
781
|
pushRequestedAt: z.ZodOptional<z.ZodString>;
|
|
738
782
|
/** Last bounded recovery sweep that selected this request. Internal only. */
|
|
@@ -788,7 +832,7 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
788
832
|
failure?: string | undefined;
|
|
789
833
|
}>>;
|
|
790
834
|
/** Internal reason this question was voided after pool or intent drift. */
|
|
791
|
-
voidedReason: z.ZodOptional<z.ZodEnum<["pool_drift", "intent_edit"]>>;
|
|
835
|
+
voidedReason: z.ZodOptional<z.ZodEnum<["pool_drift", "intent_edit", "recovery_drift"]>>;
|
|
792
836
|
/** Authoritative successful-delivery ledger timestamp. Internal only. */
|
|
793
837
|
pushedAt: z.ZodOptional<z.ZodString>;
|
|
794
838
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -813,8 +857,15 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
813
857
|
} | undefined;
|
|
814
858
|
strategy?: "refine_intent" | "surface_missing_detail" | "open_adjacent_thread" | "reflective_summary" | "surface_emergent_knowledge" | undefined;
|
|
815
859
|
underspecificationType?: "missing_constituent" | "missing_constraint" | "open_alternative_set" | null | undefined;
|
|
860
|
+
recovery?: {
|
|
861
|
+
intentFingerprint: string;
|
|
862
|
+
version: 1;
|
|
863
|
+
completionSource: "from_intent" | "discovery_run";
|
|
864
|
+
runId?: string | undefined;
|
|
865
|
+
rejectedNegotiationCount?: number | undefined;
|
|
866
|
+
} | undefined;
|
|
816
867
|
messageId?: string | undefined;
|
|
817
|
-
purpose?: "uptake" | undefined;
|
|
868
|
+
purpose?: "uptake" | "recovery" | undefined;
|
|
818
869
|
triggeredBy?: string | undefined;
|
|
819
870
|
pool?: {
|
|
820
871
|
poolSize: number;
|
|
@@ -857,7 +908,7 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
857
908
|
pushRequestStatus?: "suppressed" | "requested" | undefined;
|
|
858
909
|
pushRequestReason?: "voi" | "question_lifecycle" | "intent_lifecycle" | "malformed_source" | "malformed_actor" | "malformed_pool" | "malformed_cycle" | "visited" | "pool_size" | "cycle_budget" | undefined;
|
|
859
910
|
pushRequestSuppressedAt?: string | undefined;
|
|
860
|
-
voidedReason?: "pool_drift" | "intent_edit" | undefined;
|
|
911
|
+
voidedReason?: "pool_drift" | "intent_edit" | "recovery_drift" | undefined;
|
|
861
912
|
pushedAt?: string | undefined;
|
|
862
913
|
}, {
|
|
863
914
|
mode: "chat" | "intent" | "enrichment" | "discovery" | "negotiation" | "negotiation_inflight" | "pool_discovery";
|
|
@@ -881,8 +932,15 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
881
932
|
} | undefined;
|
|
882
933
|
strategy?: "refine_intent" | "surface_missing_detail" | "open_adjacent_thread" | "reflective_summary" | "surface_emergent_knowledge" | undefined;
|
|
883
934
|
underspecificationType?: "missing_constituent" | "missing_constraint" | "open_alternative_set" | null | undefined;
|
|
935
|
+
recovery?: {
|
|
936
|
+
intentFingerprint: string;
|
|
937
|
+
version: 1;
|
|
938
|
+
completionSource: "from_intent" | "discovery_run";
|
|
939
|
+
runId?: string | undefined;
|
|
940
|
+
rejectedNegotiationCount?: number | undefined;
|
|
941
|
+
} | undefined;
|
|
884
942
|
messageId?: string | undefined;
|
|
885
|
-
purpose?: "uptake" | undefined;
|
|
943
|
+
purpose?: "uptake" | "recovery" | undefined;
|
|
886
944
|
triggeredBy?: string | undefined;
|
|
887
945
|
pool?: {
|
|
888
946
|
poolSize: number;
|
|
@@ -925,7 +983,7 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
925
983
|
pushRequestStatus?: "suppressed" | "requested" | undefined;
|
|
926
984
|
pushRequestReason?: "voi" | "question_lifecycle" | "intent_lifecycle" | "malformed_source" | "malformed_actor" | "malformed_pool" | "malformed_cycle" | "visited" | "pool_size" | "cycle_budget" | undefined;
|
|
927
985
|
pushRequestSuppressedAt?: string | undefined;
|
|
928
|
-
voidedReason?: "pool_drift" | "intent_edit" | undefined;
|
|
986
|
+
voidedReason?: "pool_drift" | "intent_edit" | "recovery_drift" | undefined;
|
|
929
987
|
pushedAt?: string | undefined;
|
|
930
988
|
}>, {
|
|
931
989
|
mode: "chat" | "intent" | "enrichment" | "discovery" | "negotiation" | "negotiation_inflight" | "pool_discovery";
|
|
@@ -949,8 +1007,15 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
949
1007
|
} | undefined;
|
|
950
1008
|
strategy?: "refine_intent" | "surface_missing_detail" | "open_adjacent_thread" | "reflective_summary" | "surface_emergent_knowledge" | undefined;
|
|
951
1009
|
underspecificationType?: "missing_constituent" | "missing_constraint" | "open_alternative_set" | null | undefined;
|
|
1010
|
+
recovery?: {
|
|
1011
|
+
intentFingerprint: string;
|
|
1012
|
+
version: 1;
|
|
1013
|
+
completionSource: "from_intent" | "discovery_run";
|
|
1014
|
+
runId?: string | undefined;
|
|
1015
|
+
rejectedNegotiationCount?: number | undefined;
|
|
1016
|
+
} | undefined;
|
|
952
1017
|
messageId?: string | undefined;
|
|
953
|
-
purpose?: "uptake" | undefined;
|
|
1018
|
+
purpose?: "uptake" | "recovery" | undefined;
|
|
954
1019
|
triggeredBy?: string | undefined;
|
|
955
1020
|
pool?: {
|
|
956
1021
|
poolSize: number;
|
|
@@ -993,7 +1058,7 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
993
1058
|
pushRequestStatus?: "suppressed" | "requested" | undefined;
|
|
994
1059
|
pushRequestReason?: "voi" | "question_lifecycle" | "intent_lifecycle" | "malformed_source" | "malformed_actor" | "malformed_pool" | "malformed_cycle" | "visited" | "pool_size" | "cycle_budget" | undefined;
|
|
995
1060
|
pushRequestSuppressedAt?: string | undefined;
|
|
996
|
-
voidedReason?: "pool_drift" | "intent_edit" | undefined;
|
|
1061
|
+
voidedReason?: "pool_drift" | "intent_edit" | "recovery_drift" | undefined;
|
|
997
1062
|
pushedAt?: string | undefined;
|
|
998
1063
|
}, {
|
|
999
1064
|
mode: "chat" | "intent" | "enrichment" | "discovery" | "negotiation" | "negotiation_inflight" | "pool_discovery";
|
|
@@ -1017,8 +1082,15 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1017
1082
|
} | undefined;
|
|
1018
1083
|
strategy?: "refine_intent" | "surface_missing_detail" | "open_adjacent_thread" | "reflective_summary" | "surface_emergent_knowledge" | undefined;
|
|
1019
1084
|
underspecificationType?: "missing_constituent" | "missing_constraint" | "open_alternative_set" | null | undefined;
|
|
1085
|
+
recovery?: {
|
|
1086
|
+
intentFingerprint: string;
|
|
1087
|
+
version: 1;
|
|
1088
|
+
completionSource: "from_intent" | "discovery_run";
|
|
1089
|
+
runId?: string | undefined;
|
|
1090
|
+
rejectedNegotiationCount?: number | undefined;
|
|
1091
|
+
} | undefined;
|
|
1020
1092
|
messageId?: string | undefined;
|
|
1021
|
-
purpose?: "uptake" | undefined;
|
|
1093
|
+
purpose?: "uptake" | "recovery" | undefined;
|
|
1022
1094
|
triggeredBy?: string | undefined;
|
|
1023
1095
|
pool?: {
|
|
1024
1096
|
poolSize: number;
|
|
@@ -1061,7 +1133,7 @@ export declare const QuestionDetectionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1061
1133
|
pushRequestStatus?: "suppressed" | "requested" | undefined;
|
|
1062
1134
|
pushRequestReason?: "voi" | "question_lifecycle" | "intent_lifecycle" | "malformed_source" | "malformed_actor" | "malformed_pool" | "malformed_cycle" | "visited" | "pool_size" | "cycle_budget" | undefined;
|
|
1063
1135
|
pushRequestSuppressedAt?: string | undefined;
|
|
1064
|
-
voidedReason?: "pool_drift" | "intent_edit" | undefined;
|
|
1136
|
+
voidedReason?: "pool_drift" | "intent_edit" | "recovery_drift" | undefined;
|
|
1065
1137
|
pushedAt?: string | undefined;
|
|
1066
1138
|
}>;
|
|
1067
1139
|
export declare const QuestionActorSchema: z.ZodObject<{
|
|
@@ -1108,6 +1180,7 @@ export type QuestionAnswer = z.infer<typeof QuestionAnswerSchema>;
|
|
|
1108
1180
|
export type QuestionPoolAssignment = z.infer<typeof QuestionPoolAssignmentSchema>;
|
|
1109
1181
|
export type QuestionPoolDiscriminator = z.infer<typeof QuestionPoolDiscriminatorSchema>;
|
|
1110
1182
|
export type QuestionPoolSnapshot = z.infer<typeof QuestionPoolSnapshotSchema>;
|
|
1183
|
+
export type QuestionRecoverySnapshot = z.infer<typeof QuestionRecoverySnapshotSchema>;
|
|
1111
1184
|
export type QuestionPoolPush = z.infer<typeof QuestionPoolPushSchema>;
|
|
1112
1185
|
export type QuestionVoidedReason = z.infer<typeof QuestionVoidedReasonSchema>;
|
|
1113
1186
|
export type QuestionPoolPushRequestStatus = z.infer<typeof QuestionPoolPushRequestStatusSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.schema.d.ts","sourceRoot":"/","sources":["shared/schemas/question.schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;IAC/B,+EAA+E;;IAE/E,iFAAiF;;;;;;;;EAEjF,CAAC;AAEH,eAAO,MAAM,cAAc;IACzB,+EAA+E;;IAE/E,yDAAyD;;IAEzD,6EAA6E;;QAX7E,+EAA+E;;QAE/E,iFAAiF;;;;;;;;;IAWjF,0EAA0E;;IA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AAC,CAAC;AAClF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACxF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAChG,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC"}
|
|
@@ -54,7 +54,7 @@ export const QuestionGeneratorResponseSchema = z.object({
|
|
|
54
54
|
});
|
|
55
55
|
// ─── Persistence types (opportunity-style composable jsonb) ──────────────────
|
|
56
56
|
/** Internal reason a question was generated, orthogonal to mode and QUD metadata. */
|
|
57
|
-
export const QuestionPurposeSchema = z.enum(["uptake"]);
|
|
57
|
+
export const QuestionPurposeSchema = z.enum(["uptake", "recovery"]);
|
|
58
58
|
export const QuestionModeSchema = z.enum([
|
|
59
59
|
"discovery",
|
|
60
60
|
"intent",
|
|
@@ -134,8 +134,18 @@ export const QuestionPoolPushSchema = z.object({
|
|
|
134
134
|
});
|
|
135
135
|
/** Durable request state for proactive pool-question delivery. */
|
|
136
136
|
export const QuestionPoolPushRequestStatusSchema = z.enum(["requested", "suppressed"]);
|
|
137
|
-
/**
|
|
138
|
-
export const
|
|
137
|
+
/** Private snapshot for a post-discovery recovery refinement question. */
|
|
138
|
+
export const QuestionRecoverySnapshotSchema = z.object({
|
|
139
|
+
version: z.literal(1),
|
|
140
|
+
intentFingerprint: z.string().regex(/^[a-f0-9]{64}$/),
|
|
141
|
+
completionSource: z.enum(["from_intent", "discovery_run"]),
|
|
142
|
+
/** Privacy-safe aggregate only; raw negotiation evidence is never persisted. */
|
|
143
|
+
rejectedNegotiationCount: z.number().int().min(1).max(50).optional(),
|
|
144
|
+
/** Bounded internal correlation id for an asynchronous discovery run. */
|
|
145
|
+
runId: z.string().min(1).max(128).optional(),
|
|
146
|
+
});
|
|
147
|
+
/** Internal reason a pending question was voided. */
|
|
148
|
+
export const QuestionVoidedReasonSchema = z.enum(["pool_drift", "intent_edit", "recovery_drift"]);
|
|
139
149
|
/** Permanent reasons that terminalize an unclaimed proactive push request. */
|
|
140
150
|
export const QuestionPoolPushRequestReasonSchema = z.enum([
|
|
141
151
|
"question_lifecycle",
|
|
@@ -173,6 +183,8 @@ export const QuestionDetectionSchema = z.object({
|
|
|
173
183
|
* INTERNAL — stripped from every client-facing read (web + MCP).
|
|
174
184
|
*/
|
|
175
185
|
pool: QuestionPoolSnapshotSchema.optional(),
|
|
186
|
+
/** Post-discovery intent recovery snapshot. Internal only. */
|
|
187
|
+
recovery: QuestionRecoverySnapshotSchema.optional(),
|
|
176
188
|
/** Durable request marker written before enqueueing proactive delivery. Internal only. */
|
|
177
189
|
pushRequestedAt: z.string().min(1).optional(),
|
|
178
190
|
/** Last bounded recovery sweep that selected this request. Internal only. */
|
|
@@ -198,6 +210,26 @@ export const QuestionDetectionSchema = z.object({
|
|
|
198
210
|
message: "pool_discovery triggeredBy must be non-empty and equal sourceId",
|
|
199
211
|
});
|
|
200
212
|
}
|
|
213
|
+
if (detection.purpose === "recovery") {
|
|
214
|
+
if (detection.mode !== "intent"
|
|
215
|
+
|| detection.sourceType !== "intent"
|
|
216
|
+
|| !detection.triggeredBy?.trim()
|
|
217
|
+
|| detection.triggeredBy !== detection.sourceId
|
|
218
|
+
|| !detection.recovery) {
|
|
219
|
+
ctx.addIssue({
|
|
220
|
+
code: z.ZodIssueCode.custom,
|
|
221
|
+
path: ["recovery"],
|
|
222
|
+
message: "recovery purpose requires intent mode/source, equal trigger provenance, and a recovery snapshot",
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if (detection.recovery) {
|
|
227
|
+
ctx.addIssue({
|
|
228
|
+
code: z.ZodIssueCode.custom,
|
|
229
|
+
path: ["purpose"],
|
|
230
|
+
message: "recovery snapshot requires recovery purpose",
|
|
231
|
+
});
|
|
232
|
+
}
|
|
201
233
|
if (detection.pushRequestStatus && !detection.pushRequestedAt) {
|
|
202
234
|
ctx.addIssue({
|
|
203
235
|
code: z.ZodIssueCode.custom,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.schema.js","sourceRoot":"/","sources":["shared/schemas/question.schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,+EAA+E;IAC/E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACjC,iFAAiF;IACjF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,+EAA+E;IAC/E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAChC,yDAAyD;IACzD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAClC,6EAA6E;IAC7E,OAAO,EAAE,CAAC,CAAC,K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CAAC","sourcesContent":["/**\n * Question — public structured shape consumed by frontend renderers and MCP\n * elicitation dispatch. Mirrors the brainstorming AskUserQuestion skill so a\n * Question can be rendered identically across surfaces.\n *\n * `QuestionWithStrategy` extends the public shape with internal `strategy`\n * and QUD underspecification tags used by generator guardrails and persisted\n * metadata. Both tags are stripped before the public payload leaves the\n * generator — users never see them.\n */\nimport { z } from \"zod\";\n\nexport const QuestionOptionSchema = z.object({\n /** Display text. Suffix \" (Recommended)\" on the safest path; list it first. */\n label: z.string().min(1).max(120),\n /** Explains the consequence of choosing this option, not just its definition. */\n description: z.string().min(1).max(280),\n});\n\nexport const QuestionSchema = z.object({\n /** ≤12 chars. Noun of the decision domain — e.g. \"Stage\", \"Timing\", \"Role\". */\n title: z.string().min(1).max(12),\n /** ≤2 sentences, ≤400 chars. Ends in a question mark. */\n prompt: z.string().min(1).max(400),\n /** 2–4 options. No explicit \"Other\" — clients provide that automatically. */\n options: z.array(QuestionOptionSchema).min(2).max(4),\n /** True when options are not mutually exclusive (priorities, bundles). */\n multiSelect: z.boolean(),\n /**\n * Optional provenance line rendered as a muted chip above the prompt\n * (e.g. \"based on 18 people matching this intent\"). Aggregate counts only —\n * never individual identities (pool_discovery k-anonymity invariant).\n */\n evidence: z.string().min(1).max(160).optional(),\n});\n\n/** Canonical QUD repair categories for underspecified intents/questions. */\nexport const UnderspecificationTypeSchema = z.enum([\n \"missing_constituent\",\n \"missing_constraint\",\n \"open_alternative_set\",\n]);\n\nexport const QuestionStrategySchema = z.enum([\n \"refine_intent\",\n \"surface_missing_detail\",\n \"open_adjacent_thread\",\n \"reflective_summary\",\n \"surface_emergent_knowledge\",\n]);\n\nexport const QuestionWithStrategySchema = QuestionSchema.extend({\n strategy: QuestionStrategySchema,\n /** QUD repair category, or null when the question is not an underspecification repair. */\n underspecificationType: UnderspecificationTypeSchema.nullable(),\n});\n\nexport const QuestionGeneratorResponseSchema = z.object({\n questions: z.array(QuestionWithStrategySchema).max(3),\n});\n\nexport type QuestionOption = z.infer<typeof QuestionOptionSchema>;\nexport type Question = z.infer<typeof QuestionSchema>;\nexport type UnderspecificationType = z.infer<typeof UnderspecificationTypeSchema>;\nexport type QuestionStrategy = z.infer<typeof QuestionStrategySchema>;\nexport type QuestionWithStrategy = z.infer<typeof QuestionWithStrategySchema>;\nexport type QuestionGeneratorResponse = z.infer<typeof QuestionGeneratorResponseSchema>;\n\n/**\n * Internal generator output: public questions plus parallel strategy and QUD\n * taxonomy arrays for metadata-only consumption. The generator emits this;\n * callers forward only `questions` to renderers.\n */\nexport interface QuestionGenerationResult {\n questions: Question[];\n strategies: QuestionStrategy[];\n underspecificationTypes: Array<UnderspecificationType | null>;\n}\n\n// ─── Persistence types (opportunity-style composable jsonb) ──────────────────\n\n/** Internal reason a question was generated, orthogonal to mode and QUD metadata. */\nexport const QuestionPurposeSchema = z.enum([\"uptake\"]);\n\nexport const QuestionModeSchema = z.enum([\n \"discovery\",\n \"intent\",\n \"enrichment\",\n \"negotiation\",\n // Negotiator-initiated mid-negotiation client questions (ask_user action, P3).\n // Distinct from \"negotiation\", which covers post-stall questions only.\n \"negotiation_inflight\",\n // Orchestrator-initiated mid-conversation questions (ask_user_question tool).\n \"chat\",\n // Pool-discriminator questions mined from the intent's candidate pool\n // (IND-418). Synthesized deterministically — no generator LLM call.\n \"pool_discovery\",\n]);\n\n/** One server-side candidate→side assignment (never serialized to clients). */\nexport const QuestionPoolAssignmentSchema = z.object({\n opportunityId: z.string().min(1),\n side: z.string().min(1),\n});\n\n/**\n * One mined discriminator carried inside a pool_discovery question's\n * detection (the asked one plus ranked alternates for interview-mode\n * chaining). INTERNAL — the read path strips `detection.pool` before any\n * payload leaves the server.\n */\nexport const QuestionPoolDiscriminatorSchema = z.object({\n label: z.string().min(1),\n questionSeed: z.string().min(1),\n sides: z.array(z.string().min(1)).min(2).max(3),\n /** Verified-assignment count per side label. */\n sideCounts: z.record(z.string(), z.number()),\n voi: z.number(),\n evidenceRate: z.number(),\n /** Discriminator embedding retained for durable semantic novelty checks. */\n embedding: z.array(z.number().finite()).min(1).max(4096).optional(),\n /** Model that generated `embedding`; mismatches must fall back to text. */\n embeddingModel: z.string().min(1).optional(),\n /** Verified assignments only — the P3 re-rank input. */\n assignments: z.array(QuestionPoolAssignmentSchema),\n});\n\n/** Pool snapshot stored on pool_discovery questions (server-side only). */\nexport const QuestionPoolSnapshotSchema = z.object({\n poolSize: z.number().int().min(0),\n /** ISO-8601 timestamp of the mining pass. */\n minedAt: z.string().min(1),\n /** Discovery run that produced the pool, when known. */\n runId: z.string().optional(),\n /** Intent payload snippet (≤160 chars) — reused by chained questions' evidence chips. */\n intentText: z.string().optional(),\n /** Stable hash of the full normalized payload + summary used for freshness. */\n intentFingerprint: z.string().min(1).optional(),\n /** Exact bounded candidate pool. Optional for legacy rows/jobs created before IND-422. */\n opportunityIds: z.array(z.string().uuid()).optional(),\n /** The discriminator this question asks about. */\n discriminator: QuestionPoolDiscriminatorSchema,\n /** Remaining ranked discriminators for interview-mode chaining. */\n alternates: z.array(QuestionPoolDiscriminatorSchema),\n});\n\n/** Internal delivery ledger for proactive pool-question pushes (IND-421). */\nexport const QuestionPoolPushSchema = z.object({\n version: z.literal(1),\n source: z.literal(\"pool_discovery\"),\n recipientId: z.string().min(1),\n intentId: z.string().min(1),\n cycleKey: z.string().min(1),\n messageId: z.string().min(1),\n surfaces: z.tuple([\n z.literal(\"personal_agent_badge\"),\n z.literal(\"negotiator_dm\"),\n ]),\n claimedAt: z.string().min(1),\n deliveryStatus: z.enum([\"claimed\", \"delivered\", \"suppressed\", \"failed\"]),\n conversationId: z.string().min(1).optional(),\n deliveredAt: z.string().min(1).optional(),\n suppressedAt: z.string().min(1).optional(),\n failure: z.string().min(1).max(500).optional(),\n});\n\n/** Durable request state for proactive pool-question delivery. */\nexport const QuestionPoolPushRequestStatusSchema = z.enum([\"requested\", \"suppressed\"]);\n\n/** Internal reason a pending pool question was voided. */\nexport const QuestionVoidedReasonSchema = z.enum([\"pool_drift\", \"intent_edit\"]);\n\n/** Permanent reasons that terminalize an unclaimed proactive push request. */\nexport const QuestionPoolPushRequestReasonSchema = z.enum([\n \"question_lifecycle\",\n \"intent_lifecycle\",\n \"malformed_source\",\n \"malformed_actor\",\n \"malformed_pool\",\n \"malformed_cycle\",\n \"visited\",\n \"pool_size\",\n \"voi\",\n \"cycle_budget\",\n]);\n\nexport const QuestionDetectionSchema = z.object({\n /** Which preset mode generated this question. */\n mode: QuestionModeSchema,\n /** Internal reason for generation; independent of mode and QUD repair metadata. */\n purpose: QuestionPurposeSchema.optional(),\n /** Entity type that triggered generation (e.g. \"opportunity\", \"intent\", \"profile\"). */\n sourceType: z.string().min(1),\n /** ID of the triggering entity. */\n sourceId: z.string().min(1),\n /** Optional intent ID that was the root cause. */\n triggeredBy: z.string().optional(),\n /** ISO-8601 timestamp of generation. */\n timestamp: z.string().min(1),\n /** Generation strategy persisted as internal metadata. */\n strategy: QuestionStrategySchema.optional(),\n /** QUD repair category persisted as internal metadata. */\n underspecificationType: UnderspecificationTypeSchema.nullable().optional(),\n /** ID of the assistant message that triggered this question. Used by the frontend to anchor the question card inline. */\n messageId: z.string().optional(),\n /**\n * pool_discovery only: the mined pool snapshot (assignments + alternates).\n * INTERNAL — stripped from every client-facing read (web + MCP).\n */\n pool: QuestionPoolSnapshotSchema.optional(),\n /** Durable request marker written before enqueueing proactive delivery. Internal only. */\n pushRequestedAt: z.string().min(1).optional(),\n /** Last bounded recovery sweep that selected this request. Internal only. */\n pushRecoveryAttemptedAt: z.string().min(1).optional(),\n /** Durable request outcome. Internal only. */\n pushRequestStatus: QuestionPoolPushRequestStatusSchema.optional(),\n /** Permanent suppression reason for an unclaimed request. Internal only. */\n pushRequestReason: QuestionPoolPushRequestReasonSchema.optional(),\n /** ISO-8601 timestamp at which an unclaimed request was suppressed. Internal only. */\n pushRequestSuppressedAt: z.string().min(1).optional(),\n /** Internal proactive delivery state. Never serialize to public clients. */\n push: QuestionPoolPushSchema.optional(),\n /** Internal reason this question was voided after pool or intent drift. */\n voidedReason: QuestionVoidedReasonSchema.optional(),\n /** Authoritative successful-delivery ledger timestamp. Internal only. */\n pushedAt: z.string().min(1).optional(),\n}).superRefine((detection, ctx) => {\n if (\n detection.mode === \"pool_discovery\"\n && (!detection.triggeredBy?.trim() || detection.triggeredBy !== detection.sourceId)\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"triggeredBy\"],\n message: \"pool_discovery triggeredBy must be non-empty and equal sourceId\",\n });\n }\n if (detection.pushRequestStatus && !detection.pushRequestedAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestedAt\"],\n message: \"push request state requires a request timestamp\",\n });\n }\n if (detection.pushRecoveryAttemptedAt && !detection.pushRequestedAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestedAt\"],\n message: \"push recovery attempts require a request timestamp\",\n });\n }\n if (detection.pushRequestStatus === \"suppressed\") {\n if (!detection.pushRequestReason) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestReason\"],\n message: \"suppressed push requests require a reason\",\n });\n }\n if (!detection.pushRequestSuppressedAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestSuppressedAt\"],\n message: \"suppressed push requests require a timestamp\",\n });\n }\n }\n});\n\nexport const QuestionActorSchema = z.object({\n /** The user this question is for. */\n userId: z.string().min(1),\n /** Optional network context. */\n networkId: z.string().optional(),\n /** Actor's role in the question — currently always \"subject\". */\n role: z.literal(\"subject\"),\n});\n\nexport const QuestionAnswerSchema = z.object({\n /** Option labels the user selected. */\n selectedOptions: z.array(z.string()),\n /** Free-text input when the user chose \"Other\" or elaborated. */\n freeText: z.string().optional(),\n /** User ID of the answerer. */\n answeredBy: z.string().min(1),\n /** ISO-8601 timestamp of when the answer was submitted. */\n answeredAt: z.string().min(1),\n});\n\nexport type QuestionPurpose = z.infer<typeof QuestionPurposeSchema>;\nexport type QuestionMode = z.infer<typeof QuestionModeSchema>;\nexport type QuestionDetection = z.infer<typeof QuestionDetectionSchema>;\nexport type QuestionActor = z.infer<typeof QuestionActorSchema>;\nexport type QuestionAnswer = z.infer<typeof QuestionAnswerSchema>;\nexport type QuestionPoolAssignment = z.infer<typeof QuestionPoolAssignmentSchema>;\nexport type QuestionPoolDiscriminator = z.infer<typeof QuestionPoolDiscriminatorSchema>;\nexport type QuestionPoolSnapshot = z.infer<typeof QuestionPoolSnapshotSchema>;\nexport type QuestionPoolPush = z.infer<typeof QuestionPoolPushSchema>;\nexport type QuestionVoidedReason = z.infer<typeof QuestionVoidedReasonSchema>;\nexport type QuestionPoolPushRequestStatus = z.infer<typeof QuestionPoolPushRequestStatusSchema>;\nexport type QuestionPoolPushRequestReason = z.infer<typeof QuestionPoolPushRequestReasonSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"question.schema.js","sourceRoot":"/","sources":["shared/schemas/question.schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,+EAA+E;IAC/E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACjC,iFAAiF;IACjF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,+EAA+E;IAC/E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAChC,yDAAyD;IACzD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC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C,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,+BAA+B;IAC/B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,2DAA2D;IAC3D,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9B,CAAC,CAAC","sourcesContent":["/**\n * Question — public structured shape consumed by frontend renderers and MCP\n * elicitation dispatch. Mirrors the brainstorming AskUserQuestion skill so a\n * Question can be rendered identically across surfaces.\n *\n * `QuestionWithStrategy` extends the public shape with internal `strategy`\n * and QUD underspecification tags used by generator guardrails and persisted\n * metadata. Both tags are stripped before the public payload leaves the\n * generator — users never see them.\n */\nimport { z } from \"zod\";\n\nexport const QuestionOptionSchema = z.object({\n /** Display text. Suffix \" (Recommended)\" on the safest path; list it first. */\n label: z.string().min(1).max(120),\n /** Explains the consequence of choosing this option, not just its definition. */\n description: z.string().min(1).max(280),\n});\n\nexport const QuestionSchema = z.object({\n /** ≤12 chars. Noun of the decision domain — e.g. \"Stage\", \"Timing\", \"Role\". */\n title: z.string().min(1).max(12),\n /** ≤2 sentences, ≤400 chars. Ends in a question mark. */\n prompt: z.string().min(1).max(400),\n /** 2–4 options. No explicit \"Other\" — clients provide that automatically. */\n options: z.array(QuestionOptionSchema).min(2).max(4),\n /** True when options are not mutually exclusive (priorities, bundles). */\n multiSelect: z.boolean(),\n /**\n * Optional provenance line rendered as a muted chip above the prompt\n * (e.g. \"based on 18 people matching this intent\"). Aggregate counts only —\n * never individual identities (pool_discovery k-anonymity invariant).\n */\n evidence: z.string().min(1).max(160).optional(),\n});\n\n/** Canonical QUD repair categories for underspecified intents/questions. */\nexport const UnderspecificationTypeSchema = z.enum([\n \"missing_constituent\",\n \"missing_constraint\",\n \"open_alternative_set\",\n]);\n\nexport const QuestionStrategySchema = z.enum([\n \"refine_intent\",\n \"surface_missing_detail\",\n \"open_adjacent_thread\",\n \"reflective_summary\",\n \"surface_emergent_knowledge\",\n]);\n\nexport const QuestionWithStrategySchema = QuestionSchema.extend({\n strategy: QuestionStrategySchema,\n /** QUD repair category, or null when the question is not an underspecification repair. */\n underspecificationType: UnderspecificationTypeSchema.nullable(),\n});\n\nexport const QuestionGeneratorResponseSchema = z.object({\n questions: z.array(QuestionWithStrategySchema).max(3),\n});\n\nexport type QuestionOption = z.infer<typeof QuestionOptionSchema>;\nexport type Question = z.infer<typeof QuestionSchema>;\nexport type UnderspecificationType = z.infer<typeof UnderspecificationTypeSchema>;\nexport type QuestionStrategy = z.infer<typeof QuestionStrategySchema>;\nexport type QuestionWithStrategy = z.infer<typeof QuestionWithStrategySchema>;\nexport type QuestionGeneratorResponse = z.infer<typeof QuestionGeneratorResponseSchema>;\n\n/**\n * Internal generator output: public questions plus parallel strategy and QUD\n * taxonomy arrays for metadata-only consumption. The generator emits this;\n * callers forward only `questions` to renderers.\n */\nexport interface QuestionGenerationResult {\n questions: Question[];\n strategies: QuestionStrategy[];\n underspecificationTypes: Array<UnderspecificationType | null>;\n}\n\n// ─── Persistence types (opportunity-style composable jsonb) ──────────────────\n\n/** Internal reason a question was generated, orthogonal to mode and QUD metadata. */\nexport const QuestionPurposeSchema = z.enum([\"uptake\", \"recovery\"]);\n\nexport const QuestionModeSchema = z.enum([\n \"discovery\",\n \"intent\",\n \"enrichment\",\n \"negotiation\",\n // Negotiator-initiated mid-negotiation client questions (ask_user action, P3).\n // Distinct from \"negotiation\", which covers post-stall questions only.\n \"negotiation_inflight\",\n // Orchestrator-initiated mid-conversation questions (ask_user_question tool).\n \"chat\",\n // Pool-discriminator questions mined from the intent's candidate pool\n // (IND-418). Synthesized deterministically — no generator LLM call.\n \"pool_discovery\",\n]);\n\n/** One server-side candidate→side assignment (never serialized to clients). */\nexport const QuestionPoolAssignmentSchema = z.object({\n opportunityId: z.string().min(1),\n side: z.string().min(1),\n});\n\n/**\n * One mined discriminator carried inside a pool_discovery question's\n * detection (the asked one plus ranked alternates for interview-mode\n * chaining). INTERNAL — the read path strips `detection.pool` before any\n * payload leaves the server.\n */\nexport const QuestionPoolDiscriminatorSchema = z.object({\n label: z.string().min(1),\n questionSeed: z.string().min(1),\n sides: z.array(z.string().min(1)).min(2).max(3),\n /** Verified-assignment count per side label. */\n sideCounts: z.record(z.string(), z.number()),\n voi: z.number(),\n evidenceRate: z.number(),\n /** Discriminator embedding retained for durable semantic novelty checks. */\n embedding: z.array(z.number().finite()).min(1).max(4096).optional(),\n /** Model that generated `embedding`; mismatches must fall back to text. */\n embeddingModel: z.string().min(1).optional(),\n /** Verified assignments only — the P3 re-rank input. */\n assignments: z.array(QuestionPoolAssignmentSchema),\n});\n\n/** Pool snapshot stored on pool_discovery questions (server-side only). */\nexport const QuestionPoolSnapshotSchema = z.object({\n poolSize: z.number().int().min(0),\n /** ISO-8601 timestamp of the mining pass. */\n minedAt: z.string().min(1),\n /** Discovery run that produced the pool, when known. */\n runId: z.string().optional(),\n /** Intent payload snippet (≤160 chars) — reused by chained questions' evidence chips. */\n intentText: z.string().optional(),\n /** Stable hash of the full normalized payload + summary used for freshness. */\n intentFingerprint: z.string().min(1).optional(),\n /** Exact bounded candidate pool. Optional for legacy rows/jobs created before IND-422. */\n opportunityIds: z.array(z.string().uuid()).optional(),\n /** The discriminator this question asks about. */\n discriminator: QuestionPoolDiscriminatorSchema,\n /** Remaining ranked discriminators for interview-mode chaining. */\n alternates: z.array(QuestionPoolDiscriminatorSchema),\n});\n\n/** Internal delivery ledger for proactive pool-question pushes (IND-421). */\nexport const QuestionPoolPushSchema = z.object({\n version: z.literal(1),\n source: z.literal(\"pool_discovery\"),\n recipientId: z.string().min(1),\n intentId: z.string().min(1),\n cycleKey: z.string().min(1),\n messageId: z.string().min(1),\n surfaces: z.tuple([\n z.literal(\"personal_agent_badge\"),\n z.literal(\"negotiator_dm\"),\n ]),\n claimedAt: z.string().min(1),\n deliveryStatus: z.enum([\"claimed\", \"delivered\", \"suppressed\", \"failed\"]),\n conversationId: z.string().min(1).optional(),\n deliveredAt: z.string().min(1).optional(),\n suppressedAt: z.string().min(1).optional(),\n failure: z.string().min(1).max(500).optional(),\n});\n\n/** Durable request state for proactive pool-question delivery. */\nexport const QuestionPoolPushRequestStatusSchema = z.enum([\"requested\", \"suppressed\"]);\n\n/** Private snapshot for a post-discovery recovery refinement question. */\nexport const QuestionRecoverySnapshotSchema = z.object({\n version: z.literal(1),\n intentFingerprint: z.string().regex(/^[a-f0-9]{64}$/),\n completionSource: z.enum([\"from_intent\", \"discovery_run\"]),\n /** Privacy-safe aggregate only; raw negotiation evidence is never persisted. */\n rejectedNegotiationCount: z.number().int().min(1).max(50).optional(),\n /** Bounded internal correlation id for an asynchronous discovery run. */\n runId: z.string().min(1).max(128).optional(),\n});\n\n/** Internal reason a pending question was voided. */\nexport const QuestionVoidedReasonSchema = z.enum([\"pool_drift\", \"intent_edit\", \"recovery_drift\"]);\n\n/** Permanent reasons that terminalize an unclaimed proactive push request. */\nexport const QuestionPoolPushRequestReasonSchema = z.enum([\n \"question_lifecycle\",\n \"intent_lifecycle\",\n \"malformed_source\",\n \"malformed_actor\",\n \"malformed_pool\",\n \"malformed_cycle\",\n \"visited\",\n \"pool_size\",\n \"voi\",\n \"cycle_budget\",\n]);\n\nexport const QuestionDetectionSchema = z.object({\n /** Which preset mode generated this question. */\n mode: QuestionModeSchema,\n /** Internal reason for generation; independent of mode and QUD repair metadata. */\n purpose: QuestionPurposeSchema.optional(),\n /** Entity type that triggered generation (e.g. \"opportunity\", \"intent\", \"profile\"). */\n sourceType: z.string().min(1),\n /** ID of the triggering entity. */\n sourceId: z.string().min(1),\n /** Optional intent ID that was the root cause. */\n triggeredBy: z.string().optional(),\n /** ISO-8601 timestamp of generation. */\n timestamp: z.string().min(1),\n /** Generation strategy persisted as internal metadata. */\n strategy: QuestionStrategySchema.optional(),\n /** QUD repair category persisted as internal metadata. */\n underspecificationType: UnderspecificationTypeSchema.nullable().optional(),\n /** ID of the assistant message that triggered this question. Used by the frontend to anchor the question card inline. */\n messageId: z.string().optional(),\n /**\n * pool_discovery only: the mined pool snapshot (assignments + alternates).\n * INTERNAL — stripped from every client-facing read (web + MCP).\n */\n pool: QuestionPoolSnapshotSchema.optional(),\n /** Post-discovery intent recovery snapshot. Internal only. */\n recovery: QuestionRecoverySnapshotSchema.optional(),\n /** Durable request marker written before enqueueing proactive delivery. Internal only. */\n pushRequestedAt: z.string().min(1).optional(),\n /** Last bounded recovery sweep that selected this request. Internal only. */\n pushRecoveryAttemptedAt: z.string().min(1).optional(),\n /** Durable request outcome. Internal only. */\n pushRequestStatus: QuestionPoolPushRequestStatusSchema.optional(),\n /** Permanent suppression reason for an unclaimed request. Internal only. */\n pushRequestReason: QuestionPoolPushRequestReasonSchema.optional(),\n /** ISO-8601 timestamp at which an unclaimed request was suppressed. Internal only. */\n pushRequestSuppressedAt: z.string().min(1).optional(),\n /** Internal proactive delivery state. Never serialize to public clients. */\n push: QuestionPoolPushSchema.optional(),\n /** Internal reason this question was voided after pool or intent drift. */\n voidedReason: QuestionVoidedReasonSchema.optional(),\n /** Authoritative successful-delivery ledger timestamp. Internal only. */\n pushedAt: z.string().min(1).optional(),\n}).superRefine((detection, ctx) => {\n if (\n detection.mode === \"pool_discovery\"\n && (!detection.triggeredBy?.trim() || detection.triggeredBy !== detection.sourceId)\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"triggeredBy\"],\n message: \"pool_discovery triggeredBy must be non-empty and equal sourceId\",\n });\n }\n if (detection.purpose === \"recovery\") {\n if (\n detection.mode !== \"intent\"\n || detection.sourceType !== \"intent\"\n || !detection.triggeredBy?.trim()\n || detection.triggeredBy !== detection.sourceId\n || !detection.recovery\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"recovery\"],\n message: \"recovery purpose requires intent mode/source, equal trigger provenance, and a recovery snapshot\",\n });\n }\n } else if (detection.recovery) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"purpose\"],\n message: \"recovery snapshot requires recovery purpose\",\n });\n }\n if (detection.pushRequestStatus && !detection.pushRequestedAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestedAt\"],\n message: \"push request state requires a request timestamp\",\n });\n }\n if (detection.pushRecoveryAttemptedAt && !detection.pushRequestedAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestedAt\"],\n message: \"push recovery attempts require a request timestamp\",\n });\n }\n if (detection.pushRequestStatus === \"suppressed\") {\n if (!detection.pushRequestReason) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestReason\"],\n message: \"suppressed push requests require a reason\",\n });\n }\n if (!detection.pushRequestSuppressedAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"pushRequestSuppressedAt\"],\n message: \"suppressed push requests require a timestamp\",\n });\n }\n }\n});\n\nexport const QuestionActorSchema = z.object({\n /** The user this question is for. */\n userId: z.string().min(1),\n /** Optional network context. */\n networkId: z.string().optional(),\n /** Actor's role in the question — currently always \"subject\". */\n role: z.literal(\"subject\"),\n});\n\nexport const QuestionAnswerSchema = z.object({\n /** Option labels the user selected. */\n selectedOptions: z.array(z.string()),\n /** Free-text input when the user chose \"Other\" or elaborated. */\n freeText: z.string().optional(),\n /** User ID of the answerer. */\n answeredBy: z.string().min(1),\n /** ISO-8601 timestamp of when the answer was submitted. */\n answeredAt: z.string().min(1),\n});\n\nexport type QuestionPurpose = z.infer<typeof QuestionPurposeSchema>;\nexport type QuestionMode = z.infer<typeof QuestionModeSchema>;\nexport type QuestionDetection = z.infer<typeof QuestionDetectionSchema>;\nexport type QuestionActor = z.infer<typeof QuestionActorSchema>;\nexport type QuestionAnswer = z.infer<typeof QuestionAnswerSchema>;\nexport type QuestionPoolAssignment = z.infer<typeof QuestionPoolAssignmentSchema>;\nexport type QuestionPoolDiscriminator = z.infer<typeof QuestionPoolDiscriminatorSchema>;\nexport type QuestionPoolSnapshot = z.infer<typeof QuestionPoolSnapshotSchema>;\nexport type QuestionRecoverySnapshot = z.infer<typeof QuestionRecoverySnapshotSchema>;\nexport type QuestionPoolPush = z.infer<typeof QuestionPoolPushSchema>;\nexport type QuestionVoidedReason = z.infer<typeof QuestionVoidedReasonSchema>;\nexport type QuestionPoolPushRequestStatus = z.infer<typeof QuestionPoolPushRequestStatusSchema>;\nexport type QuestionPoolPushRequestReason = z.infer<typeof QuestionPoolPushRequestReasonSchema>;\n"]}
|