@indexnetwork/protocol 4.11.0-rc.351.1 → 4.12.0-rc.352.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 +3 -0
- package/dist/intent/intent.graph.d.ts +12 -5
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +19 -6
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/opportunity/discriminator/discriminator.question.d.ts +2 -0
- package/dist/opportunity/discriminator/discriminator.question.d.ts.map +1 -1
- package/dist/opportunity/discriminator/discriminator.question.js +3 -0
- package/dist/opportunity/discriminator/discriminator.question.js.map +1 -1
- package/dist/opportunity/discriminator/discriminator.shadow.d.ts +8 -0
- package/dist/opportunity/discriminator/discriminator.shadow.d.ts.map +1 -1
- package/dist/opportunity/discriminator/discriminator.shadow.js +41 -7
- package/dist/opportunity/discriminator/discriminator.shadow.js.map +1 -1
- package/dist/opportunity/discriminator/discriminator.types.d.ts +4 -0
- package/dist/opportunity/discriminator/discriminator.types.d.ts.map +1 -1
- package/dist/opportunity/discriminator/discriminator.types.js.map +1 -1
- package/dist/questioner/questioner.types.d.ts +3 -1
- package/dist/questioner/questioner.types.d.ts.map +1 -1
- package/dist/questioner/questioner.types.js.map +1 -1
- package/dist/shared/schemas/question.schema.d.ts +74 -0
- package/dist/shared/schemas/question.schema.d.ts.map +1 -1
- package/dist/shared/schemas/question.schema.js +6 -0
- package/dist/shared/schemas/question.schema.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,14 @@ export interface DiscriminatorShadowInput {
|
|
|
12
12
|
* sentences. An axis semantically equal to any reference scores ~0.
|
|
13
13
|
*/
|
|
14
14
|
referenceTexts: string[];
|
|
15
|
+
/** Legacy/model-mismatched resolved axes re-embedded with an independent budget. */
|
|
16
|
+
priorReferenceTexts?: string[];
|
|
17
|
+
/** Fresh resolved-axis vectors generated by the current embedding model. */
|
|
18
|
+
priorReferenceEmbeddings?: number[][];
|
|
19
|
+
/** Model used for current axis embeddings and persisted metadata. */
|
|
20
|
+
embeddingModel?: string;
|
|
21
|
+
/** Retain generated axis vectors on results for durable question snapshots. */
|
|
22
|
+
retainEmbeddings?: boolean;
|
|
15
23
|
miner: Pick<PoolDiscriminatorMiner, "mine">;
|
|
16
24
|
embedder: EmbeddingGenerator;
|
|
17
25
|
signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.shadow.d.ts","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.shadow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,KAAK,EAAsB,aAAa,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"discriminator.shadow.d.ts","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.shadow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,KAAK,EAAsB,aAAa,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAS7G,gDAAgD;AAChD,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B;;;OAGG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,oFAAoF;IACpF,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,4EAA4E;IAC5E,wBAAwB,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACtC,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAC5C,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAOD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAoEpH"}
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
import { protocolLogger } from "../../shared/observability/protocol.logger.js";
|
|
7
7
|
import { computeNovelty, scoreDiscriminator } from "./discriminator.scorer.js";
|
|
8
8
|
const logger = protocolLogger("PoolDiscriminatorShadow");
|
|
9
|
-
/** Max
|
|
9
|
+
/** Max text/vector references compared for novelty. */
|
|
10
10
|
const MAX_REFERENCE_TEXTS = 24;
|
|
11
|
+
const MAX_PRIOR_REFERENCE_TEXTS = 24;
|
|
12
|
+
const MAX_REFERENCE_EMBEDDINGS = 24;
|
|
11
13
|
/** Text embedded per discriminator for the novelty comparison. */
|
|
12
14
|
function discriminatorEmbeddingText(d) {
|
|
13
15
|
return `${d.label} — ${d.questionSeed}`;
|
|
@@ -27,14 +29,36 @@ export async function runPoolDiscriminatorShadow(input) {
|
|
|
27
29
|
.map((t) => t.trim())
|
|
28
30
|
.filter((t) => t.length > 0)
|
|
29
31
|
.slice(0, MAX_REFERENCE_TEXTS);
|
|
32
|
+
const priorReferenceTexts = (input.priorReferenceTexts ?? [])
|
|
33
|
+
.map((text) => text.trim())
|
|
34
|
+
.filter((text) => text.length > 0)
|
|
35
|
+
.slice(0, MAX_PRIOR_REFERENCE_TEXTS);
|
|
36
|
+
const priorReferenceEmbeddings = (input.priorReferenceEmbeddings ?? [])
|
|
37
|
+
.filter((embedding) => embedding.length > 0)
|
|
38
|
+
.slice(0, MAX_REFERENCE_EMBEDDINGS);
|
|
30
39
|
let novelties = mined.map(() => 1);
|
|
31
|
-
|
|
40
|
+
let discriminatorEmbeddings = null;
|
|
41
|
+
const shouldEmbed = input.retainEmbeddings
|
|
42
|
+
|| references.length > 0
|
|
43
|
+
|| priorReferenceTexts.length > 0
|
|
44
|
+
|| priorReferenceEmbeddings.length > 0;
|
|
45
|
+
if (shouldEmbed) {
|
|
32
46
|
try {
|
|
33
|
-
const texts = [
|
|
47
|
+
const texts = [
|
|
48
|
+
...mined.map(discriminatorEmbeddingText),
|
|
49
|
+
...references,
|
|
50
|
+
...priorReferenceTexts,
|
|
51
|
+
];
|
|
34
52
|
const embeddings = (await input.embedder.generate(texts));
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
if (embeddings.length !== texts.length || embeddings.some((embedding) => !Array.isArray(embedding) || embedding.length === 0)) {
|
|
54
|
+
throw new Error("Embedding provider returned an invalid batch");
|
|
55
|
+
}
|
|
56
|
+
discriminatorEmbeddings = embeddings.slice(0, mined.length);
|
|
57
|
+
const referenceEmbeddings = [
|
|
58
|
+
...priorReferenceEmbeddings,
|
|
59
|
+
...embeddings.slice(mined.length),
|
|
60
|
+
];
|
|
61
|
+
novelties = discriminatorEmbeddings.map((embedding) => computeNovelty(embedding, referenceEmbeddings));
|
|
38
62
|
}
|
|
39
63
|
catch (err) {
|
|
40
64
|
logger.warn("Novelty embedding failed; defaulting novelty to 1", {
|
|
@@ -43,7 +67,17 @@ export async function runPoolDiscriminatorShadow(input) {
|
|
|
43
67
|
}
|
|
44
68
|
}
|
|
45
69
|
const discriminators = mined
|
|
46
|
-
.map((d, i) =>
|
|
70
|
+
.map((d, i) => {
|
|
71
|
+
const scored = scoreDiscriminator(d, candidates, novelties[i]);
|
|
72
|
+
const embedding = input.retainEmbeddings ? discriminatorEmbeddings?.[i] : undefined;
|
|
73
|
+
return embedding
|
|
74
|
+
? {
|
|
75
|
+
...scored,
|
|
76
|
+
embedding,
|
|
77
|
+
...(input.embeddingModel ? { embeddingModel: input.embeddingModel } : {}),
|
|
78
|
+
}
|
|
79
|
+
: scored;
|
|
80
|
+
})
|
|
47
81
|
.sort((a, b) => b.voi - a.voi);
|
|
48
82
|
return { poolSize: candidates.length, discriminators };
|
|
49
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.shadow.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.shadow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAG/E,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/E,MAAM,MAAM,GAAG,cAAc,CAAC,yBAAyB,CAAC,CAAC;AAEzD,
|
|
1
|
+
{"version":3,"file":"discriminator.shadow.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.shadow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAG/E,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/E,MAAM,MAAM,GAAG,cAAc,CAAC,yBAAyB,CAAC,CAAC;AAEzD,uDAAuD;AACvD,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AA0BpC,kEAAkE;AAClE,SAAS,0BAA0B,CAAC,CAAqB;IACvD,OAAO,GAAG,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,YAAY,EAAE,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,KAA+B;IAC9E,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAClC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,EAC5C,KAAK,CAAC,MAA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AC,CAAC,EAAE,CAAC,EAAE,EAAE;QACZ,MAAM,MAAM,GAAG,kBAAkB,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpF,OAAO,SAAS;YACd,CAAC,CAAC;gBACE,GAAG,MAAM;gBACT,SAAS;gBACT,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1E;YACH,CAAC,CAAC,MAAM,CAAC;IACb,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;AACzD,CAAC","sourcesContent":["/**\n * Shadow orchestrator: mine discriminators for a pool, embed them, score VoI, and\n * return the log payload (IND-417). No persistence, no questions, no UI —\n * P1 output is consumed only by structured logs for human review.\n */\nimport { protocolLogger } from \"../../shared/observability/protocol.logger.js\";\nimport type { EmbeddingGenerator } from \"../../shared/interfaces/embedder.interface.js\";\nimport type { PoolDiscriminatorMiner } from \"./discriminator.miner.js\";\nimport { computeNovelty, scoreDiscriminator } from \"./discriminator.scorer.js\";\nimport type { MinedDiscriminator, PoolCandidate, DiscriminatorShadowResult } from \"./discriminator.types.js\";\n\nconst logger = protocolLogger(\"PoolDiscriminatorShadow\");\n\n/** Max text/vector references compared for novelty. */\nconst MAX_REFERENCE_TEXTS = 24;\nconst MAX_PRIOR_REFERENCE_TEXTS = 24;\nconst MAX_REFERENCE_EMBEDDINGS = 24;\n\n/** Input for one shadow mining+scoring pass. */\nexport interface DiscriminatorShadowInput {\n /** Intent payload (+ summary) or search query that produced the pool. */\n intentText: string;\n /** The pool (already filtered/capped by the caller). */\n candidates: PoolCandidate[];\n /**\n * Novelty references: the intent owner's active premise texts and intent\n * sentences. An axis semantically equal to any reference scores ~0.\n */\n referenceTexts: string[];\n /** Legacy/model-mismatched resolved axes re-embedded with an independent budget. */\n priorReferenceTexts?: string[];\n /** Fresh resolved-axis vectors generated by the current embedding model. */\n priorReferenceEmbeddings?: number[][];\n /** Model used for current axis embeddings and persisted metadata. */\n embeddingModel?: string;\n /** Retain generated axis vectors on results for durable question snapshots. */\n retainEmbeddings?: boolean;\n miner: Pick<PoolDiscriminatorMiner, \"mine\">;\n embedder: EmbeddingGenerator;\n signal?: AbortSignal;\n}\n\n/** Text embedded per discriminator for the novelty comparison. */\nfunction discriminatorEmbeddingText(d: MinedDiscriminator): string {\n return `${d.label} — ${d.questionSeed}`;\n}\n\n/**\n * Runs miner → embeddings → scorer. Throws only when *mining* fails (callers\n * are fire-and-forget); embedding failures degrade to novelty = 1 for all\n * discriminators rather than dropping the pass.\n */\nexport async function runPoolDiscriminatorShadow(input: DiscriminatorShadowInput): Promise<DiscriminatorShadowResult> {\n const { candidates } = input;\n const mined = await input.miner.mine(\n { intentText: input.intentText, candidates },\n input.signal ? { signal: input.signal } : undefined,\n );\n if (mined.length === 0) {\n return { poolSize: candidates.length, discriminators: [] };\n }\n\n const references = input.referenceTexts\n .map((t) => t.trim())\n .filter((t) => t.length > 0)\n .slice(0, MAX_REFERENCE_TEXTS);\n\n const priorReferenceTexts = (input.priorReferenceTexts ?? [])\n .map((text) => text.trim())\n .filter((text) => text.length > 0)\n .slice(0, MAX_PRIOR_REFERENCE_TEXTS);\n const priorReferenceEmbeddings = (input.priorReferenceEmbeddings ?? [])\n .filter((embedding) => embedding.length > 0)\n .slice(0, MAX_REFERENCE_EMBEDDINGS);\n\n let novelties: number[] = mined.map(() => 1);\n let discriminatorEmbeddings: number[][] | null = null;\n const shouldEmbed = input.retainEmbeddings\n || references.length > 0\n || priorReferenceTexts.length > 0\n || priorReferenceEmbeddings.length > 0;\n if (shouldEmbed) {\n try {\n const texts = [\n ...mined.map(discriminatorEmbeddingText),\n ...references,\n ...priorReferenceTexts,\n ];\n const embeddings = (await input.embedder.generate(texts)) as number[][];\n if (embeddings.length !== texts.length || embeddings.some((embedding) => !Array.isArray(embedding) || embedding.length === 0)) {\n throw new Error(\"Embedding provider returned an invalid batch\");\n }\n discriminatorEmbeddings = embeddings.slice(0, mined.length);\n const referenceEmbeddings = [\n ...priorReferenceEmbeddings,\n ...embeddings.slice(mined.length),\n ];\n novelties = discriminatorEmbeddings.map((embedding) => computeNovelty(embedding, referenceEmbeddings));\n } catch (err) {\n logger.warn(\"Novelty embedding failed; defaulting novelty to 1\", {\n error: err instanceof Error ? err.message : String(err),\n });\n }\n }\n\n const discriminators = mined\n .map((d, i) => {\n const scored = scoreDiscriminator(d, candidates, novelties[i]);\n const embedding = input.retainEmbeddings ? discriminatorEmbeddings?.[i] : undefined;\n return embedding\n ? {\n ...scored,\n embedding,\n ...(input.embeddingModel ? { embeddingModel: input.embeddingModel } : {}),\n }\n : scored;\n })\n .sort((a, b) => b.voi - a.voi);\n\n return { poolSize: candidates.length, discriminators };\n}\n"]}
|
|
@@ -70,6 +70,10 @@ export interface MinedDiscriminator {
|
|
|
70
70
|
}
|
|
71
71
|
/** A mined discriminator with its deterministic VoI score components. */
|
|
72
72
|
export interface ScoredDiscriminator extends MinedDiscriminator {
|
|
73
|
+
/** Current discriminator embedding retained for durable semantic dedup. */
|
|
74
|
+
embedding?: number[];
|
|
75
|
+
/** Model that generated {@link embedding}. */
|
|
76
|
+
embeddingModel?: string;
|
|
73
77
|
/** Normalized score-weighted entropy over sides, in [0,1]. */
|
|
74
78
|
entropy: number;
|
|
75
79
|
/** Assigned score mass / total pool score mass, in [0,1]. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.types.d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E,MAAM,CAAC;IACjB,uDAAuD;IACvD,cAAc,EAAE,mBAAmB,EAAE,CAAC;CACvC"}
|
|
1
|
+
{"version":3,"file":"discriminator.types.d.ts","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0CAA0C;AAC1C,MAAM,WAAW,wBAAwB;IACvC,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,iFAAiF;IACjF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,4CAA4C;IAC5C,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,yEAAyE;AACzE,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wEAAwE;AACxE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,cAAc,EAAE,mBAAmB,EAAE,CAAC;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.types.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG","sourcesContent":["/**\n * Pool discriminator mining — shared types (IND-416 / IND-417).\n *\n * A \"pool discriminator\" is a preference dimension that splits a discovery-run\n * candidate pool into meaningfully different groups (e.g. \"hands-on builders\n * vs advisors\"). Discriminators are mined by one structured LLM pass, then\n * scored deterministically (VoI = entropy × coverage^1.5 × novelty) so the\n * highest value question can eventually be asked to the intent owner.\n *\n * Vocabulary note: the LLM wire format (prompt + response schema in the miner)\n * speaks of \"axes\" with mutually exclusive \"sides\" — the clearest way to\n * explain the concept to the model. Everything the rest of the codebase\n * touches (types, exports, logs) uses \"discriminator\".\n *\n * P1 (shadow) uses these types for log-only output; later phases reuse them\n * for question synthesis and answer application.\n */\n\n/** One candidate in the pool as supplied to the miner LLM. */\nexport interface PoolCandidate {\n /** Opportunity id (stable key for later answer application). */\n id: string;\n /**\n * The exact public-context string shown to the LLM for this candidate\n * (name + bio + matchReason + headline + premise snippets, ≤400 chars).\n * Evidence spans are substring-verified against this exact string.\n */\n publicContext: string;\n /** Candidate confidence/score — the mass used for score-weighted entropy. */\n score: number;\n}\n\n/** Input envelope for one mining pass. */\nexport interface DiscriminatorMiningInput {\n /** Intent payload (+ summary) or ad-hoc search query that produced the pool. */\n intentText: string;\n candidates: PoolCandidate[];\n}\n\n/**\n * One candidate assignment on a discriminator, after code-side evidence verification.\n * `side === null` means unknown (LLM abstained, evidence failed verification,\n * or the candidate was missing from the LLM output).\n */\nexport interface VerifiedAssignment {\n /** Candidate (opportunity) id. */\n id: string;\n /** Verified side label (one of the discriminator's sides), or null = unknown. */\n side: string | null;\n /** The evidence span quoted by the LLM (kept for logging/audit), if any. */\n evidence: string | null;\n /**\n * True when the LLM proposed a side AND its evidence span substring-matched\n * the candidate's publicContext. False for demoted-to-unknown proposals.\n */\n verified: boolean;\n}\n\n/** One mined discriminator after evidence verification (pre-scoring). */\nexport interface MinedDiscriminator {\n /** Short discriminator label, e.g. \"Hands-on builders vs strategic advisors\". */\n label: string;\n /** A question the intent owner could be asked to resolve the discriminator. */\n questionSeed: string;\n /** 2–3 mutually exclusive side labels. */\n sides: string[];\n /** Exactly one entry per pool candidate. */\n assignments: VerifiedAssignment[];\n /**\n * verified-proposals / total side proposals from the LLM for this discriminator\n * (0 when the LLM proposed no sides at all). The hallucination health metric.\n */\n evidenceRate: number;\n}\n\n/** A mined discriminator with its deterministic VoI score components. */\nexport interface ScoredDiscriminator extends MinedDiscriminator {\n /** Normalized score-weighted entropy over sides, in [0,1]. */\n entropy: number;\n /** Assigned score mass / total pool score mass, in [0,1]. */\n coverage: number;\n /** 1 − max cosine similarity vs reference texts (premises/intent), in [0,1]. */\n novelty: number;\n /** entropy × coverage^1.5 × novelty. */\n voi: number;\n}\n\n/** Result of one shadow mining+scoring pass (the log payload shape). */\nexport interface DiscriminatorShadowResult {\n poolSize: number;\n /** Scored discriminators, sorted by VoI descending. */\n discriminators: ScoredDiscriminator[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"discriminator.types.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG","sourcesContent":["/**\n * Pool discriminator mining — shared types (IND-416 / IND-417).\n *\n * A \"pool discriminator\" is a preference dimension that splits a discovery-run\n * candidate pool into meaningfully different groups (e.g. \"hands-on builders\n * vs advisors\"). Discriminators are mined by one structured LLM pass, then\n * scored deterministically (VoI = entropy × coverage^1.5 × novelty) so the\n * highest value question can eventually be asked to the intent owner.\n *\n * Vocabulary note: the LLM wire format (prompt + response schema in the miner)\n * speaks of \"axes\" with mutually exclusive \"sides\" — the clearest way to\n * explain the concept to the model. Everything the rest of the codebase\n * touches (types, exports, logs) uses \"discriminator\".\n *\n * P1 (shadow) uses these types for log-only output; later phases reuse them\n * for question synthesis and answer application.\n */\n\n/** One candidate in the pool as supplied to the miner LLM. */\nexport interface PoolCandidate {\n /** Opportunity id (stable key for later answer application). */\n id: string;\n /**\n * The exact public-context string shown to the LLM for this candidate\n * (name + bio + matchReason + headline + premise snippets, ≤400 chars).\n * Evidence spans are substring-verified against this exact string.\n */\n publicContext: string;\n /** Candidate confidence/score — the mass used for score-weighted entropy. */\n score: number;\n}\n\n/** Input envelope for one mining pass. */\nexport interface DiscriminatorMiningInput {\n /** Intent payload (+ summary) or ad-hoc search query that produced the pool. */\n intentText: string;\n candidates: PoolCandidate[];\n}\n\n/**\n * One candidate assignment on a discriminator, after code-side evidence verification.\n * `side === null` means unknown (LLM abstained, evidence failed verification,\n * or the candidate was missing from the LLM output).\n */\nexport interface VerifiedAssignment {\n /** Candidate (opportunity) id. */\n id: string;\n /** Verified side label (one of the discriminator's sides), or null = unknown. */\n side: string | null;\n /** The evidence span quoted by the LLM (kept for logging/audit), if any. */\n evidence: string | null;\n /**\n * True when the LLM proposed a side AND its evidence span substring-matched\n * the candidate's publicContext. False for demoted-to-unknown proposals.\n */\n verified: boolean;\n}\n\n/** One mined discriminator after evidence verification (pre-scoring). */\nexport interface MinedDiscriminator {\n /** Short discriminator label, e.g. \"Hands-on builders vs strategic advisors\". */\n label: string;\n /** A question the intent owner could be asked to resolve the discriminator. */\n questionSeed: string;\n /** 2–3 mutually exclusive side labels. */\n sides: string[];\n /** Exactly one entry per pool candidate. */\n assignments: VerifiedAssignment[];\n /**\n * verified-proposals / total side proposals from the LLM for this discriminator\n * (0 when the LLM proposed no sides at all). The hallucination health metric.\n */\n evidenceRate: number;\n}\n\n/** A mined discriminator with its deterministic VoI score components. */\nexport interface ScoredDiscriminator extends MinedDiscriminator {\n /** Current discriminator embedding retained for durable semantic dedup. */\n embedding?: number[];\n /** Model that generated {@link embedding}. */\n embeddingModel?: string;\n /** Normalized score-weighted entropy over sides, in [0,1]. */\n entropy: number;\n /** Assigned score mass / total pool score mass, in [0,1]. */\n coverage: number;\n /** 1 − max cosine similarity vs reference texts (premises/intent), in [0,1]. */\n novelty: number;\n /** entropy × coverage^1.5 × novelty. */\n voi: number;\n}\n\n/** Result of one shadow mining+scoring pass (the log payload shape). */\nexport interface DiscriminatorShadowResult {\n poolSize: number;\n /** Scored discriminators, sorted by VoI descending. */\n discriminators: ScoredDiscriminator[];\n}\n"]}
|
|
@@ -87,8 +87,10 @@ export interface ChatContext {
|
|
|
87
87
|
*/
|
|
88
88
|
export interface PoolDiscoveryContext {
|
|
89
89
|
intentId: string;
|
|
90
|
-
/**
|
|
90
|
+
/** Truncated intent payload (+ summary) display snippet. */
|
|
91
91
|
intentText: string;
|
|
92
|
+
/** Stable hash of the full normalized payload + summary used for freshness. */
|
|
93
|
+
intentFingerprint?: string;
|
|
92
94
|
poolSize: number;
|
|
93
95
|
/** Discovery run that produced the pool. */
|
|
94
96
|
runId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.types.d.ts","sourceRoot":"/","sources":["questioner/questioner.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAIpG;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEtD,0EAA0E;AAC1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MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAErF,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,IAAI,EAAE,YAAY,CAAC;IACnB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,OAAO,EAAE,iBAAiB,CAAC;IAC3B,kFAAkF;IAClF,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oIAAoI;IACpI,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wIAAwI;IACxI,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.types.js","sourceRoot":"/","sources":["questioner/questioner.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * QuestionerAgent input types. The `QuestionerInput` envelope carries a `mode`\n * field that selects a preset, plus a polymorphic `context` that varies per mode.\n *\n * Slice 1 defines all four context shapes but only `DiscoveryContext` has a\n * working preset implementation. The others are type stubs for future slices.\n */\nimport type { DiscoveryQuestionInput } from \"../opportunity/question.prompt.js\";\nimport type { ToolScopeType } from \"../shared/agent/tool.scope.js\";\nimport type { QuestionMode, QuestionPoolDiscriminator } from \"../shared/schemas/question.schema.js\";\n\n// ─── Per-mode context types ─────────────────────────────────────────────────\n\n/**\n * Discovery context — wraps the existing DiscoveryQuestionInput wholesale.\n * The discovery preset's buildPrompt delegates to the migrated builder.\n */\nexport type DiscoveryContext = DiscoveryQuestionInput;\n\n/** Intent context — data needed to generate questions about an intent. */\nexport interface IntentContext {\n intentId: string;\n payload: string;\n summary?: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/** Profile context — data needed to generate questions to fill profile gaps. */\nexport interface ProfileContext {\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n gaps: string[];\n /** Existing premise texts the user has already stated (e.g. \"I live in Berlin\"). */\n existingPremises?: string[];\n}\n\n/** Negotiation context — data from a stalled or capped negotiation. */\nexport interface NegotiationContext {\n negotiationId: string;\n counterpartyHint: string;\n indexContext: string;\n outcomeReason: \"turn_cap\" | \"timeout\" | \"stalled\";\n keyTake: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/**\n * Negotiation-inflight context — a negotiator mid-negotiation wants to ask its\n * OWN client a question before continuing (the `ask_user` action, P3.2). The\n * negotiator states the disclosure subject and optionally drafts the question;\n * the QuestionerAgent refines it into polished disclosure-gating questions.\n * Distinct from {@link NegotiationContext}, which covers post-stall questions.\n */\nexport interface NegotiationInflightContext {\n negotiationId: string;\n /** Anonymized counterparty description (attributes, never identity). */\n counterpartyHint: string;\n /** What the negotiator wants permission to share or needs to know (e.g. \"budget range\", \"availability in Q3\"). */\n disclosureSubject: string;\n /** Draft question authored by the negotiator. The agent refines it. */\n draftQuestion?: string;\n /** Community / index context the negotiation runs in. */\n indexContext: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/**\n * Chat context — data for orchestrator-initiated mid-conversation questions\n * (the `ask_user_question` tool). The orchestrator states what it needs to\n * learn; the QuestionerAgent turns that into polished structured questions,\n * grounded in the recent conversation and the user's identity context.\n */\nexport interface ChatContext {\n /** What the orchestrator needs to learn and why (authored by the chat model). */\n purpose: string;\n /** Draft questions proposed by the orchestrator. The agent refines these. */\n draftQuestions?: Array<{\n prompt: string;\n options?: string[];\n multiSelect?: boolean;\n }>;\n /** Recent conversation excerpt for grounding (most recent messages last). */\n conversationExcerpt?: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/**\n * Pool-discovery context — mined discriminators from a discovery-run pool\n * (IND-418). No generator LLM runs for this mode: the QuestionerQueue\n * synthesizes the question deterministically from the top discriminator and\n * stashes the rest as interview-mode alternates.\n */\nexport interface PoolDiscoveryContext {\n intentId: string;\n /**
|
|
1
|
+
{"version":3,"file":"questioner.types.js","sourceRoot":"/","sources":["questioner/questioner.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * QuestionerAgent input types. The `QuestionerInput` envelope carries a `mode`\n * field that selects a preset, plus a polymorphic `context` that varies per mode.\n *\n * Slice 1 defines all four context shapes but only `DiscoveryContext` has a\n * working preset implementation. The others are type stubs for future slices.\n */\nimport type { DiscoveryQuestionInput } from \"../opportunity/question.prompt.js\";\nimport type { ToolScopeType } from \"../shared/agent/tool.scope.js\";\nimport type { QuestionMode, QuestionPoolDiscriminator } from \"../shared/schemas/question.schema.js\";\n\n// ─── Per-mode context types ─────────────────────────────────────────────────\n\n/**\n * Discovery context — wraps the existing DiscoveryQuestionInput wholesale.\n * The discovery preset's buildPrompt delegates to the migrated builder.\n */\nexport type DiscoveryContext = DiscoveryQuestionInput;\n\n/** Intent context — data needed to generate questions about an intent. */\nexport interface IntentContext {\n intentId: string;\n payload: string;\n summary?: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/** Profile context — data needed to generate questions to fill profile gaps. */\nexport interface ProfileContext {\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n gaps: string[];\n /** Existing premise texts the user has already stated (e.g. \"I live in Berlin\"). */\n existingPremises?: string[];\n}\n\n/** Negotiation context — data from a stalled or capped negotiation. */\nexport interface NegotiationContext {\n negotiationId: string;\n counterpartyHint: string;\n indexContext: string;\n outcomeReason: \"turn_cap\" | \"timeout\" | \"stalled\";\n keyTake: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/**\n * Negotiation-inflight context — a negotiator mid-negotiation wants to ask its\n * OWN client a question before continuing (the `ask_user` action, P3.2). The\n * negotiator states the disclosure subject and optionally drafts the question;\n * the QuestionerAgent refines it into polished disclosure-gating questions.\n * Distinct from {@link NegotiationContext}, which covers post-stall questions.\n */\nexport interface NegotiationInflightContext {\n negotiationId: string;\n /** Anonymized counterparty description (attributes, never identity). */\n counterpartyHint: string;\n /** What the negotiator wants permission to share or needs to know (e.g. \"budget range\", \"availability in Q3\"). */\n disclosureSubject: string;\n /** Draft question authored by the negotiator. The agent refines it. */\n draftQuestion?: string;\n /** Community / index context the negotiation runs in. */\n indexContext: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/**\n * Chat context — data for orchestrator-initiated mid-conversation questions\n * (the `ask_user_question` tool). The orchestrator states what it needs to\n * learn; the QuestionerAgent turns that into polished structured questions,\n * grounded in the recent conversation and the user's identity context.\n */\nexport interface ChatContext {\n /** What the orchestrator needs to learn and why (authored by the chat model). */\n purpose: string;\n /** Draft questions proposed by the orchestrator. The agent refines these. */\n draftQuestions?: Array<{\n prompt: string;\n options?: string[];\n multiSelect?: boolean;\n }>;\n /** Recent conversation excerpt for grounding (most recent messages last). */\n conversationExcerpt?: string;\n /** The user's global user_context paragraph (profile-replacing identity text). */\n userContext?: string;\n}\n\n/**\n * Pool-discovery context — mined discriminators from a discovery-run pool\n * (IND-418). No generator LLM runs for this mode: the QuestionerQueue\n * synthesizes the question deterministically from the top discriminator and\n * stashes the rest as interview-mode alternates.\n */\nexport interface PoolDiscoveryContext {\n intentId: string;\n /** Truncated intent payload (+ summary) display snippet. */\n intentText: string;\n /** Stable hash of the full normalized payload + summary used for freshness. */\n intentFingerprint?: string;\n poolSize: number;\n /** Discovery run that produced the pool. */\n runId?: string;\n /** Eligible discriminators, VoI-descending (asked + chain alternates). */\n discriminators: QuestionPoolDiscriminator[];\n /** ISO-8601 timestamp of the mining pass. */\n minedAt: string;\n}\n\n/** Discriminated union: mode selects the context shape. */\nexport type QuestionerContext =\n | DiscoveryContext\n | IntentContext\n | ProfileContext\n | NegotiationContext\n | NegotiationInflightContext\n | ChatContext\n | PoolDiscoveryContext;\n\n/**\n * Payload shape accepted by the questionerEnqueue callback. Covers all\n * question modes — the composition root bridges this to the concrete\n * QuestionerQueue.\n */\nexport type QuestionerEnqueuePayload = QuestionerInput;\n\n/** Callback signature for async question generation enqueue. */\nexport type QuestionerEnqueueFn = (input: QuestionerEnqueuePayload) => Promise<void>;\n\n/** Top-level input envelope for QuestionerAgent.invoke(). */\nexport interface QuestionerInput {\n /** Selects the preset (system prompt + builder). */\n mode: QuestionMode;\n /** User the questions are generated for. */\n userId: string;\n /** Entity type that triggered this (e.g. \"opportunity\", \"intent\", \"profile\"). */\n sourceType: string;\n /** ID of the triggering entity. */\n sourceId: string;\n /** Mode-specific context. Must align with the selected mode. */\n context: QuestionerContext;\n /** Scoped question context. Network scopes persist as QuestionActor.networkId. */\n scopeType?: ToolScopeType;\n /** Scoped question id. When scopeType is `network`, this is the actor networkId. */\n scopeId?: string;\n /**\n * Intent that triggered the run that generated these questions. Persisted as\n * `detection.triggeredBy` so intent-scoped surfaces (e.g. the intent page)\n * can find them. Independent of `scopeType`/`scopeId`, which may carry a\n * network scope at the same time.\n */\n triggeredByIntentId?: string;\n /** Conversation ID — set when the question originates from a chat session. Persisted on the question row for frontend filtering. */\n conversationId?: string;\n /** Assistant message ID — set when we know which message triggered the question. Stored in detection.messageId for inline anchoring. */\n messageId?: string;\n}\n"]}
|
|
@@ -245,6 +245,10 @@ export declare const QuestionPoolDiscriminatorSchema: z.ZodObject<{
|
|
|
245
245
|
sideCounts: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
246
246
|
voi: z.ZodNumber;
|
|
247
247
|
evidenceRate: z.ZodNumber;
|
|
248
|
+
/** Discriminator embedding retained for durable semantic novelty checks. */
|
|
249
|
+
embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
250
|
+
/** Model that generated `embedding`; mismatches must fall back to text. */
|
|
251
|
+
embeddingModel: z.ZodOptional<z.ZodString>;
|
|
248
252
|
/** Verified assignments only — the P3 re-rank input. */
|
|
249
253
|
assignments: z.ZodArray<z.ZodObject<{
|
|
250
254
|
opportunityId: z.ZodString;
|
|
@@ -267,6 +271,8 @@ export declare const QuestionPoolDiscriminatorSchema: z.ZodObject<{
|
|
|
267
271
|
opportunityId: string;
|
|
268
272
|
side: string;
|
|
269
273
|
}[];
|
|
274
|
+
embedding?: number[] | undefined;
|
|
275
|
+
embeddingModel?: string | undefined;
|
|
270
276
|
}, {
|
|
271
277
|
label: string;
|
|
272
278
|
questionSeed: string;
|
|
@@ -278,6 +284,8 @@ export declare const QuestionPoolDiscriminatorSchema: z.ZodObject<{
|
|
|
278
284
|
opportunityId: string;
|
|
279
285
|
side: string;
|
|
280
286
|
}[];
|
|
287
|
+
embedding?: number[] | undefined;
|
|
288
|
+
embeddingModel?: string | undefined;
|
|
281
289
|
}>;
|
|
282
290
|
/** Pool snapshot stored on pool_discovery questions (server-side only). */
|
|
283
291
|
export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
@@ -288,6 +296,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
288
296
|
runId: z.ZodOptional<z.ZodString>;
|
|
289
297
|
/** Intent payload snippet (≤160 chars) — reused by chained questions' evidence chips. */
|
|
290
298
|
intentText: z.ZodOptional<z.ZodString>;
|
|
299
|
+
/** Stable hash of the full normalized payload + summary used for freshness. */
|
|
300
|
+
intentFingerprint: z.ZodOptional<z.ZodString>;
|
|
291
301
|
/** The discriminator this question asks about. */
|
|
292
302
|
discriminator: z.ZodObject<{
|
|
293
303
|
label: z.ZodString;
|
|
@@ -297,6 +307,10 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
297
307
|
sideCounts: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
298
308
|
voi: z.ZodNumber;
|
|
299
309
|
evidenceRate: z.ZodNumber;
|
|
310
|
+
/** Discriminator embedding retained for durable semantic novelty checks. */
|
|
311
|
+
embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
312
|
+
/** Model that generated `embedding`; mismatches must fall back to text. */
|
|
313
|
+
embeddingModel: z.ZodOptional<z.ZodString>;
|
|
300
314
|
/** Verified assignments only — the P3 re-rank input. */
|
|
301
315
|
assignments: z.ZodArray<z.ZodObject<{
|
|
302
316
|
opportunityId: z.ZodString;
|
|
@@ -319,6 +333,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
319
333
|
opportunityId: string;
|
|
320
334
|
side: string;
|
|
321
335
|
}[];
|
|
336
|
+
embedding?: number[] | undefined;
|
|
337
|
+
embeddingModel?: string | undefined;
|
|
322
338
|
}, {
|
|
323
339
|
label: string;
|
|
324
340
|
questionSeed: string;
|
|
@@ -330,6 +346,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
330
346
|
opportunityId: string;
|
|
331
347
|
side: string;
|
|
332
348
|
}[];
|
|
349
|
+
embedding?: number[] | undefined;
|
|
350
|
+
embeddingModel?: string | undefined;
|
|
333
351
|
}>;
|
|
334
352
|
/** Remaining ranked discriminators for interview-mode chaining. */
|
|
335
353
|
alternates: z.ZodArray<z.ZodObject<{
|
|
@@ -340,6 +358,10 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
340
358
|
sideCounts: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
341
359
|
voi: z.ZodNumber;
|
|
342
360
|
evidenceRate: z.ZodNumber;
|
|
361
|
+
/** Discriminator embedding retained for durable semantic novelty checks. */
|
|
362
|
+
embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
363
|
+
/** Model that generated `embedding`; mismatches must fall back to text. */
|
|
364
|
+
embeddingModel: z.ZodOptional<z.ZodString>;
|
|
343
365
|
/** Verified assignments only — the P3 re-rank input. */
|
|
344
366
|
assignments: z.ZodArray<z.ZodObject<{
|
|
345
367
|
opportunityId: z.ZodString;
|
|
@@ -362,6 +384,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
362
384
|
opportunityId: string;
|
|
363
385
|
side: string;
|
|
364
386
|
}[];
|
|
387
|
+
embedding?: number[] | undefined;
|
|
388
|
+
embeddingModel?: string | undefined;
|
|
365
389
|
}, {
|
|
366
390
|
label: string;
|
|
367
391
|
questionSeed: string;
|
|
@@ -373,6 +397,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
373
397
|
opportunityId: string;
|
|
374
398
|
side: string;
|
|
375
399
|
}[];
|
|
400
|
+
embedding?: number[] | undefined;
|
|
401
|
+
embeddingModel?: string | undefined;
|
|
376
402
|
}>, "many">;
|
|
377
403
|
}, "strip", z.ZodTypeAny, {
|
|
378
404
|
poolSize: number;
|
|
@@ -388,6 +414,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
388
414
|
opportunityId: string;
|
|
389
415
|
side: string;
|
|
390
416
|
}[];
|
|
417
|
+
embedding?: number[] | undefined;
|
|
418
|
+
embeddingModel?: string | undefined;
|
|
391
419
|
};
|
|
392
420
|
alternates: {
|
|
393
421
|
label: string;
|
|
@@ -400,9 +428,12 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
400
428
|
opportunityId: string;
|
|
401
429
|
side: string;
|
|
402
430
|
}[];
|
|
431
|
+
embedding?: number[] | undefined;
|
|
432
|
+
embeddingModel?: string | undefined;
|
|
403
433
|
}[];
|
|
404
434
|
runId?: string | undefined;
|
|
405
435
|
intentText?: string | undefined;
|
|
436
|
+
intentFingerprint?: string | undefined;
|
|
406
437
|
}, {
|
|
407
438
|
poolSize: number;
|
|
408
439
|
minedAt: string;
|
|
@@ -417,6 +448,8 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
417
448
|
opportunityId: string;
|
|
418
449
|
side: string;
|
|
419
450
|
}[];
|
|
451
|
+
embedding?: number[] | undefined;
|
|
452
|
+
embeddingModel?: string | undefined;
|
|
420
453
|
};
|
|
421
454
|
alternates: {
|
|
422
455
|
label: string;
|
|
@@ -429,9 +462,12 @@ export declare const QuestionPoolSnapshotSchema: z.ZodObject<{
|
|
|
429
462
|
opportunityId: string;
|
|
430
463
|
side: string;
|
|
431
464
|
}[];
|
|
465
|
+
embedding?: number[] | undefined;
|
|
466
|
+
embeddingModel?: string | undefined;
|
|
432
467
|
}[];
|
|
433
468
|
runId?: string | undefined;
|
|
434
469
|
intentText?: string | undefined;
|
|
470
|
+
intentFingerprint?: string | undefined;
|
|
435
471
|
}>;
|
|
436
472
|
export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
437
473
|
/** Which preset mode generated this question. */
|
|
@@ -462,6 +498,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
462
498
|
runId: z.ZodOptional<z.ZodString>;
|
|
463
499
|
/** Intent payload snippet (≤160 chars) — reused by chained questions' evidence chips. */
|
|
464
500
|
intentText: z.ZodOptional<z.ZodString>;
|
|
501
|
+
/** Stable hash of the full normalized payload + summary used for freshness. */
|
|
502
|
+
intentFingerprint: z.ZodOptional<z.ZodString>;
|
|
465
503
|
/** The discriminator this question asks about. */
|
|
466
504
|
discriminator: z.ZodObject<{
|
|
467
505
|
label: z.ZodString;
|
|
@@ -471,6 +509,10 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
471
509
|
sideCounts: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
472
510
|
voi: z.ZodNumber;
|
|
473
511
|
evidenceRate: z.ZodNumber;
|
|
512
|
+
/** Discriminator embedding retained for durable semantic novelty checks. */
|
|
513
|
+
embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
514
|
+
/** Model that generated `embedding`; mismatches must fall back to text. */
|
|
515
|
+
embeddingModel: z.ZodOptional<z.ZodString>;
|
|
474
516
|
/** Verified assignments only — the P3 re-rank input. */
|
|
475
517
|
assignments: z.ZodArray<z.ZodObject<{
|
|
476
518
|
opportunityId: z.ZodString;
|
|
@@ -493,6 +535,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
493
535
|
opportunityId: string;
|
|
494
536
|
side: string;
|
|
495
537
|
}[];
|
|
538
|
+
embedding?: number[] | undefined;
|
|
539
|
+
embeddingModel?: string | undefined;
|
|
496
540
|
}, {
|
|
497
541
|
label: string;
|
|
498
542
|
questionSeed: string;
|
|
@@ -504,6 +548,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
504
548
|
opportunityId: string;
|
|
505
549
|
side: string;
|
|
506
550
|
}[];
|
|
551
|
+
embedding?: number[] | undefined;
|
|
552
|
+
embeddingModel?: string | undefined;
|
|
507
553
|
}>;
|
|
508
554
|
/** Remaining ranked discriminators for interview-mode chaining. */
|
|
509
555
|
alternates: z.ZodArray<z.ZodObject<{
|
|
@@ -514,6 +560,10 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
514
560
|
sideCounts: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
515
561
|
voi: z.ZodNumber;
|
|
516
562
|
evidenceRate: z.ZodNumber;
|
|
563
|
+
/** Discriminator embedding retained for durable semantic novelty checks. */
|
|
564
|
+
embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
565
|
+
/** Model that generated `embedding`; mismatches must fall back to text. */
|
|
566
|
+
embeddingModel: z.ZodOptional<z.ZodString>;
|
|
517
567
|
/** Verified assignments only — the P3 re-rank input. */
|
|
518
568
|
assignments: z.ZodArray<z.ZodObject<{
|
|
519
569
|
opportunityId: z.ZodString;
|
|
@@ -536,6 +586,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
536
586
|
opportunityId: string;
|
|
537
587
|
side: string;
|
|
538
588
|
}[];
|
|
589
|
+
embedding?: number[] | undefined;
|
|
590
|
+
embeddingModel?: string | undefined;
|
|
539
591
|
}, {
|
|
540
592
|
label: string;
|
|
541
593
|
questionSeed: string;
|
|
@@ -547,6 +599,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
547
599
|
opportunityId: string;
|
|
548
600
|
side: string;
|
|
549
601
|
}[];
|
|
602
|
+
embedding?: number[] | undefined;
|
|
603
|
+
embeddingModel?: string | undefined;
|
|
550
604
|
}>, "many">;
|
|
551
605
|
}, "strip", z.ZodTypeAny, {
|
|
552
606
|
poolSize: number;
|
|
@@ -562,6 +616,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
562
616
|
opportunityId: string;
|
|
563
617
|
side: string;
|
|
564
618
|
}[];
|
|
619
|
+
embedding?: number[] | undefined;
|
|
620
|
+
embeddingModel?: string | undefined;
|
|
565
621
|
};
|
|
566
622
|
alternates: {
|
|
567
623
|
label: string;
|
|
@@ -574,9 +630,12 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
574
630
|
opportunityId: string;
|
|
575
631
|
side: string;
|
|
576
632
|
}[];
|
|
633
|
+
embedding?: number[] | undefined;
|
|
634
|
+
embeddingModel?: string | undefined;
|
|
577
635
|
}[];
|
|
578
636
|
runId?: string | undefined;
|
|
579
637
|
intentText?: string | undefined;
|
|
638
|
+
intentFingerprint?: string | undefined;
|
|
580
639
|
}, {
|
|
581
640
|
poolSize: number;
|
|
582
641
|
minedAt: string;
|
|
@@ -591,6 +650,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
591
650
|
opportunityId: string;
|
|
592
651
|
side: string;
|
|
593
652
|
}[];
|
|
653
|
+
embedding?: number[] | undefined;
|
|
654
|
+
embeddingModel?: string | undefined;
|
|
594
655
|
};
|
|
595
656
|
alternates: {
|
|
596
657
|
label: string;
|
|
@@ -603,9 +664,12 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
603
664
|
opportunityId: string;
|
|
604
665
|
side: string;
|
|
605
666
|
}[];
|
|
667
|
+
embedding?: number[] | undefined;
|
|
668
|
+
embeddingModel?: string | undefined;
|
|
606
669
|
}[];
|
|
607
670
|
runId?: string | undefined;
|
|
608
671
|
intentText?: string | undefined;
|
|
672
|
+
intentFingerprint?: string | undefined;
|
|
609
673
|
}>>;
|
|
610
674
|
}, "strip", z.ZodTypeAny, {
|
|
611
675
|
mode: "intent" | "chat" | "enrichment" | "discovery" | "negotiation" | "negotiation_inflight" | "pool_discovery";
|
|
@@ -630,6 +694,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
630
694
|
opportunityId: string;
|
|
631
695
|
side: string;
|
|
632
696
|
}[];
|
|
697
|
+
embedding?: number[] | undefined;
|
|
698
|
+
embeddingModel?: string | undefined;
|
|
633
699
|
};
|
|
634
700
|
alternates: {
|
|
635
701
|
label: string;
|
|
@@ -642,9 +708,12 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
642
708
|
opportunityId: string;
|
|
643
709
|
side: string;
|
|
644
710
|
}[];
|
|
711
|
+
embedding?: number[] | undefined;
|
|
712
|
+
embeddingModel?: string | undefined;
|
|
645
713
|
}[];
|
|
646
714
|
runId?: string | undefined;
|
|
647
715
|
intentText?: string | undefined;
|
|
716
|
+
intentFingerprint?: string | undefined;
|
|
648
717
|
} | undefined;
|
|
649
718
|
}, {
|
|
650
719
|
mode: "intent" | "chat" | "enrichment" | "discovery" | "negotiation" | "negotiation_inflight" | "pool_discovery";
|
|
@@ -669,6 +738,8 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
669
738
|
opportunityId: string;
|
|
670
739
|
side: string;
|
|
671
740
|
}[];
|
|
741
|
+
embedding?: number[] | undefined;
|
|
742
|
+
embeddingModel?: string | undefined;
|
|
672
743
|
};
|
|
673
744
|
alternates: {
|
|
674
745
|
label: string;
|
|
@@ -681,9 +752,12 @@ export declare const QuestionDetectionSchema: z.ZodObject<{
|
|
|
681
752
|
opportunityId: string;
|
|
682
753
|
side: string;
|
|
683
754
|
}[];
|
|
755
|
+
embedding?: number[] | undefined;
|
|
756
|
+
embeddingModel?: string | undefined;
|
|
684
757
|
}[];
|
|
685
758
|
runId?: string | undefined;
|
|
686
759
|
intentText?: string | undefined;
|
|
760
|
+
intentFingerprint?: string | undefined;
|
|
687
761
|
} | undefined;
|
|
688
762
|
}>;
|
|
689
763
|
export declare const QuestionActorSchema: z.ZodObject<{
|
|
@@ -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;;IAE1E;;;;OAIG;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,kFAIvC,CAAC;AAEH,eAAO,MAAM,sBAAsB,oIAMjC,CAAC;AAEH,eAAO,MAAM,0BAA0B;IA/BrC,+EAA+E;;IAE/E,yDAAyD;;IAEzD,6EAA6E;;QAX7E,+EAA+E;;QAE/E,iFAAiF;;;;;;;;;IAWjF,0EAA0E;;IAE1E;;;;OAIG;;;;IAqBH,0FAA0F;;;;;;;;;;;;;;;;;;;;;;;;EAE1F,CAAC;AAEH,eAAO,MAAM,+BAA+B;;QArC1C,+EAA+E;;QAE/E,yDAAyD;;QAEzD,6EAA6E;;YAX7E,+EAA+E;;YAE/E,iFAAiF;;;;;;;;;QAWjF,0EAA0E;;QAE1E;;;;WAIG;;;;QAqBH,0FAA0F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM1F,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CxD,CAAC;AAEH,eAAO,MAAM,mBAAmB;IAC9B,qCAAqC;;IAErC,gCAAgC;;IAEhC,iEAAiE;;;;;;;;;;EAEjE,CAAC;AAEH,eAAO,MAAM,oBAAoB;IAC/B,uCAAuC;;IAEvC,iEAAiE;;IAEjE,+BAA+B;;IAE/B,2DAA2D;;;;;;;;;;;;EAE3D,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,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"}
|
|
@@ -86,6 +86,10 @@ export const QuestionPoolDiscriminatorSchema = z.object({
|
|
|
86
86
|
sideCounts: z.record(z.string(), z.number()),
|
|
87
87
|
voi: z.number(),
|
|
88
88
|
evidenceRate: z.number(),
|
|
89
|
+
/** Discriminator embedding retained for durable semantic novelty checks. */
|
|
90
|
+
embedding: z.array(z.number().finite()).min(1).max(4096).optional(),
|
|
91
|
+
/** Model that generated `embedding`; mismatches must fall back to text. */
|
|
92
|
+
embeddingModel: z.string().min(1).optional(),
|
|
89
93
|
/** Verified assignments only — the P3 re-rank input. */
|
|
90
94
|
assignments: z.array(QuestionPoolAssignmentSchema),
|
|
91
95
|
});
|
|
@@ -98,6 +102,8 @@ export const QuestionPoolSnapshotSchema = z.object({
|
|
|
98
102
|
runId: z.string().optional(),
|
|
99
103
|
/** Intent payload snippet (≤160 chars) — reused by chained questions' evidence chips. */
|
|
100
104
|
intentText: z.string().optional(),
|
|
105
|
+
/** Stable hash of the full normalized payload + summary used for freshness. */
|
|
106
|
+
intentFingerprint: z.string().min(1).optional(),
|
|
101
107
|
/** The discriminator this question asks about. */
|
|
102
108
|
discriminator: QuestionPoolDiscriminatorSchema,
|
|
103
109
|
/** Remaining ranked discriminators for interview-mode chaining. */
|
|
@@ -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;I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zB,gCAAgC;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,iEAAiE;IACjE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,uCAAuC;IACvC,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,iEAAiE;IACjE,QAAQ,EAAE,CAAC,CAAC,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\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 /** 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 /** The discriminator this question asks about. */\n discriminator: QuestionPoolDiscriminatorSchema,\n /** Remaining ranked discriminators for interview-mode chaining. */\n alternates: z.array(QuestionPoolDiscriminatorSchema),\n});\n\nexport const QuestionDetectionSchema = z.object({\n /** Which preset mode generated this question. */\n mode: QuestionModeSchema,\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});\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 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>;\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,EA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M,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\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 /** The discriminator this question asks about. */\n discriminator: QuestionPoolDiscriminatorSchema,\n /** Remaining ranked discriminators for interview-mode chaining. */\n alternates: z.array(QuestionPoolDiscriminatorSchema),\n});\n\nexport const QuestionDetectionSchema = z.object({\n /** Which preset mode generated this question. */\n mode: QuestionModeSchema,\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});\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 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>;\n"]}
|