@indexnetwork/protocol 6.11.1-rc.402.1 → 6.12.0-rc.403.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/dist/negotiation/negotiation.agent.d.ts +10 -0
- package/dist/negotiation/negotiation.agent.d.ts.map +1 -1
- package/dist/negotiation/negotiation.agent.js +26 -8
- package/dist/negotiation/negotiation.agent.js.map +1 -1
- package/dist/negotiation/negotiation.attribution.d.ts +92 -0
- package/dist/negotiation/negotiation.attribution.d.ts.map +1 -0
- package/dist/negotiation/negotiation.attribution.js +110 -0
- package/dist/negotiation/negotiation.attribution.js.map +1 -0
- package/dist/negotiation/negotiation.graph.d.ts +19 -0
- package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
- package/dist/negotiation/negotiation.graph.js +128 -6
- package/dist/negotiation/negotiation.graph.js.map +1 -1
- package/dist/negotiation/negotiation.screen.d.ts +24 -0
- package/dist/negotiation/negotiation.screen.d.ts.map +1 -1
- package/dist/negotiation/negotiation.screen.js +20 -1
- package/dist/negotiation/negotiation.screen.js.map +1 -1
- package/dist/negotiation/negotiation.state.d.ts +33 -0
- package/dist/negotiation/negotiation.state.d.ts.map +1 -1
- package/dist/negotiation/negotiation.state.js +33 -0
- package/dist/negotiation/negotiation.state.js.map +1 -1
- package/dist/opportunity/opportunity.evidence.d.ts.map +1 -1
- package/dist/opportunity/opportunity.evidence.js +8 -1
- package/dist/opportunity/opportunity.evidence.js.map +1 -1
- package/dist/opportunity/opportunity.graph.d.ts.map +1 -1
- package/dist/opportunity/opportunity.graph.js +91 -4
- package/dist/opportunity/opportunity.graph.js.map +1 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.d.ts +8 -0
- package/dist/shared/interfaces/agent-dispatcher.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.js.map +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +27 -2
- package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/database.interface.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import { createStructuredModel } from "../shared/agent/model.config.js";
|
|
3
3
|
import type { UserNegotiationContext, SeedAssessment } from "../shared/schemas/negotiation-state.schema.js";
|
|
4
4
|
import { type NegotiatorMemoryEntry } from "./negotiation.memory.js";
|
|
5
|
+
import type { NegotiationTurn } from "./negotiation.state.js";
|
|
6
|
+
import { type AttributedPriorDialogue } from "./negotiation.attribution.js";
|
|
5
7
|
/**
|
|
6
8
|
* Screen-gate modes (P2.1 — client-advocate protocol).
|
|
7
9
|
*
|
|
@@ -106,6 +108,28 @@ export interface NegotiationScreenerInput {
|
|
|
106
108
|
* → the prompt is byte-identical to before.
|
|
107
109
|
*/
|
|
108
110
|
memory?: NegotiatorMemoryEntry[];
|
|
111
|
+
/**
|
|
112
|
+
* Whether this screen is for a continuation — a match against a counterparty
|
|
113
|
+
* this client already has prior dialogue with (IND-563). When set with
|
|
114
|
+
* `priorDialogue`, the gate evaluates the NEW signal on its own merits with
|
|
115
|
+
* that dialogue as context. Absent → the prompt is byte-identical to before.
|
|
116
|
+
*/
|
|
117
|
+
isContinuation?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Prior negotiation turns with this counterparty (continuations only).
|
|
120
|
+
* Rendered as read-only context so the gate can tell a materially-new signal
|
|
121
|
+
* from a rehash of an already-settled one. Never treated as this task's own
|
|
122
|
+
* outreach.
|
|
123
|
+
*/
|
|
124
|
+
priorDialogue?: NegotiationTurn[];
|
|
125
|
+
/**
|
|
126
|
+
* Attributed form of the prior dialogue (IND-569). When present it supersedes
|
|
127
|
+
* the flat `priorDialogue` list: earlier concluded opportunities and legacy
|
|
128
|
+
* unattributed turns render as labeled, separated blocks so the gate can see
|
|
129
|
+
* which prior turns belonged to OTHER opportunities. Absent → the flat
|
|
130
|
+
* `priorDialogue` rendering is used (byte-identical to before).
|
|
131
|
+
*/
|
|
132
|
+
priorDialogueAttributed?: AttributedPriorDialogue;
|
|
109
133
|
}
|
|
110
134
|
export interface NegotiationScreenerConfig {
|
|
111
135
|
/** Hard ceiling on the screen LLM round-trip, in ms (default 15000). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negotiation.screen.d.ts","sourceRoot":"/","sources":["negotiation/negotiation.screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAE5G,OAAO,EAAiC,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"negotiation.screen.d.ts","sourceRoot":"/","sources":["negotiation/negotiation.screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAE5G,OAAO,EAAiC,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAA4D,KAAK,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAItI;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,uCAAwC,CAAC;AAE9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,qBAAqB,CAI5D;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;IAG/B,8EAA8E;;;QAG5E,0EAA0E;;QAE1E,uEAAuE;;QAEvE,uHA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M,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC;IAqEtE;;;OAGG;cACa,SAAS,CACvB,KAAK,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC/C,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GACrD,OAAO,CAAC,OAAO,CAAC;CAGpB"}
|
|
@@ -3,6 +3,7 @@ import { createStructuredModel } from "../shared/agent/model.config.js";
|
|
|
3
3
|
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
4
4
|
import { protocolLogger } from "../shared/observability/protocol.logger.js";
|
|
5
5
|
import { renderNegotiatorMemorySection } from "./negotiation.memory.js";
|
|
6
|
+
import { attributedDialogueIsEmpty, renderAttributedPriorDialogue } from "./negotiation.attribution.js";
|
|
6
7
|
const screenLog = protocolLogger("NegotiationScreener");
|
|
7
8
|
/**
|
|
8
9
|
* Screen-gate modes (P2.1 — client-advocate protocol).
|
|
@@ -97,6 +98,24 @@ export class NegotiationScreener {
|
|
|
97
98
|
.replace("{queryRule}", queryRule)
|
|
98
99
|
.replace("{negotiatorMemory}", renderNegotiatorMemorySection(input.memory ?? [], { memoryHintsInstruction: true }));
|
|
99
100
|
const formatIntents = (intents) => intents.length > 0 ? intents.map((i) => `- ${i.title}: ${i.description}`).join("\n") : "- (none)";
|
|
101
|
+
const formatScreenTurn = (t, i) => {
|
|
102
|
+
const msgPart = t.message ? ` — ${t.message}` : "";
|
|
103
|
+
return `Turn ${i + 1}: ${t.action} — ${t.assessment.reasoning}${msgPart}`;
|
|
104
|
+
};
|
|
105
|
+
// IND-569: prefer the attributed rendering (labeled per-opportunity blocks)
|
|
106
|
+
// when the graph supplies it; otherwise fall back to the flat prior-turn list.
|
|
107
|
+
const hasAttributed = input.isContinuation
|
|
108
|
+
&& input.priorDialogueAttributed != null
|
|
109
|
+
&& !attributedDialogueIsEmpty(input.priorDialogueAttributed);
|
|
110
|
+
const flatPriorDialogue = input.isContinuation && input.priorDialogue && input.priorDialogue.length > 0
|
|
111
|
+
? input.priorDialogue
|
|
112
|
+
: [];
|
|
113
|
+
const priorDialogueBody = hasAttributed
|
|
114
|
+
? renderAttributedPriorDialogue(input.priorDialogueAttributed, formatScreenTurn)
|
|
115
|
+
: (flatPriorDialogue.length > 0 ? flatPriorDialogue.map(formatScreenTurn).join("\n") : "");
|
|
116
|
+
const priorDialogueContext = priorDialogueBody
|
|
117
|
+
? `\n\n--- Prior dialogue with ${counterpartyName} (already spoken) ---\n${priorDialogueBody}\n\nThis is a NEW signal against a counterparty ${clientName} has prior dialogue with. Some turns above may belong to OTHER, already-concluded opportunities (each block is labeled); they are background only. Judge the new signal on its own merits: if it is materially the same as what was already discussed, pass unless something concrete changed; if materially different, judge it fresh. Do NOT reach out again on generic overlap just because they spoke before.`
|
|
118
|
+
: "";
|
|
100
119
|
const userMessage = `YOUR CLIENT (${clientName}):
|
|
101
120
|
Bio: ${input.clientUser.profile.bio ?? "N/A"}
|
|
102
121
|
${input.discoveryQuery ? `Search query: "${input.discoveryQuery}"\nBackground intents (secondary to the query):` : "Active intents:"}
|
|
@@ -107,7 +126,7 @@ Bio: ${input.counterpartyUser.profile.bio ?? "N/A"}
|
|
|
107
126
|
${input.counterpartyContext ? `Context: ${input.counterpartyContext}\n` : ""}Active intents:
|
|
108
127
|
${formatIntents(input.counterpartyUser.intents)}
|
|
109
128
|
|
|
110
|
-
Why this match was suggested: ${input.seedAssessment.reasoning}
|
|
129
|
+
Why this match was suggested: ${input.seedAssessment.reasoning}${priorDialogueContext}
|
|
111
130
|
|
|
112
131
|
Decide whether reaching out serves ${clientName}.`;
|
|
113
132
|
const chatMessages = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negotiation.screen.js","sourceRoot":"/","sources":["negotiation/negotiation.screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,SAAS,CAAC,IAAI,CAAC,wCAAwC,EAAE;gBACvD,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;aAC9D,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CAAC,sCAAsC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;QACxG,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,SAAS,CACvB,KAA+C,EAC/C,YAAsD;QAEtD,OAAO,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["import { z } from \"zod\";\n\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\nimport type { UserNegotiationContext, SeedAssessment } from \"../shared/schemas/negotiation-state.schema.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { renderNegotiatorMemorySection, type NegotiatorMemoryEntry } from \"./negotiation.memory.js\";\n\nconst screenLog = protocolLogger(\"NegotiationScreener\");\n\n/**\n * Screen-gate modes (P2.1 — client-advocate protocol).\n *\n * - `off` — the screen node is skipped entirely; no LLM call, no telemetry.\n * - `shadow` — the screen decision is made and recorded (task metadata +\n * trace event + log line) but NEVER blocks: every fresh negotiation still\n * proceeds to the first turn. Used to measure pass rates against observed\n * reject rates before enforcement.\n * - `enforce` — (P2.2) a `pass` decision blocks the negotiation before the\n * first turn: the graph routes straight to finalize with outcome\n * `reason: \"screened_out\"` — zero turns, zero counterparty involvement,\n * zero notifications; the opportunity is quietly `rejected`. A failed\n * screen still fails OPEN (never blocks), and `reach_out` proceeds normally.\n */\nexport const NEGOTIATION_SCREEN_MODES = [\"off\", \"shadow\", \"enforce\"] as const;\n\nexport type NegotiationScreenMode = (typeof NEGOTIATION_SCREEN_MODES)[number];\n\n/**\n * Resolve the screen mode from `NEGOTIATION_SCREEN_MODE`.\n *\n * Defaults to `off` when unset or unrecognized — the screen gate is an\n * explicit opt-in flip (same operational pattern as\n * `NEGOTIATION_PROTOCOL_VERSION` / `NEGOTIATOR_CHAT_ENABLED`): code ships\n * inert, the environment turns it on.\n */\nexport function configuredScreenMode(): NegotiationScreenMode {\n const raw = process.env.NEGOTIATION_SCREEN_MODE;\n if (raw === \"shadow\" || raw === \"enforce\" || raw === \"off\") return raw;\n return \"off\";\n}\n\n/**\n * Structured screen decision — the outreach gate's verdict on whether this\n * match is worth the client's name before any turn is exchanged.\n */\nexport const ScreenDecisionSchema = z.object({\n decision: z.enum([\"reach_out\", \"pass\"]),\n reasoning: z.string(),\n /** Suggested opening angle for the outreach turn (only when reaching out). */\n outreachAngle: z.string().nullable().optional(),\n evidence: z.object({\n /** How well the counterparty's context/premises fit the client's need. */\n counterpartyPremiseFit: z.string(),\n /** How the client's intents align with what the counterparty seeks. */\n intentAlignment: z.string(),\n /** Prior-negotiation memory signals (P5.3). Filled only when negotiator memory was injected into the screen prompt. */\n memoryHints: z.string().nullable().optional(),\n }),\n});\n\nexport type ScreenDecision = z.infer<typeof ScreenDecisionSchema>;\n\n/**\n * The record persisted to `tasks.metadata.screenDecision` and returned into\n * graph state. Extends the LLM decision with operational context so pass-rate\n * queries can group by mode and exclude failed-open rows.\n */\nexport interface ScreenDecisionRecord extends ScreenDecision {\n mode: NegotiationScreenMode;\n /** True when the screen LLM call failed and the gate defaulted open. */\n failedOpen?: boolean;\n /** Error message when `failedOpen` is set. */\n error?: string;\n screenedAt: string;\n durationMs: number;\n}\n\nexport interface NegotiationScreenerInput {\n /** The client — the user whose negotiator is deciding whether to reach out. */\n clientUser: UserNegotiationContext;\n /** The counterparty the client's negotiator would be reaching out to. */\n counterpartyUser: UserNegotiationContext;\n /** The counterparty's `user_contexts` paragraph (empty string when absent). */\n counterpartyContext?: string;\n /** The explicit search query that triggered discovery (if any). */\n discoveryQuery?: string;\n seedAssessment: Omit<SeedAssessment, \"actors\">;\n indexContext: { networkId: string; prompt?: string };\n /**\n * Retrieved negotiator memories for the client (P5.3 read path). Rendered\n * as a private prompt section with a memoryHints instruction. Absent/empty\n * → the prompt is byte-identical to before.\n */\n memory?: NegotiatorMemoryEntry[];\n}\n\nconst SYSTEM_PROMPT = `You are the outreach gate for {clientName}'s negotiator agent on a discovery network. Before any negotiation turn is exchanged, you decide whether this match is worth reaching out to on {clientName}'s behalf — their name and attention are spent with every outreach.\n\nNetwork context: {networkContext}\n\nDecide:\n- \"reach_out\" when the counterparty plausibly serves {clientName}'s stated needs and a concrete, honest opening case can be made. When reaching out, set outreachAngle to the strongest specific angle for the opening message.\n- \"pass\" when the match is generic, one-sided, or rests on vague overlap that would waste both parties' attention.\n\nRules:\n{queryRule}\n- Judge concrete intent alignment, not topical adjacency.\n- Fill evidence.counterpartyPremiseFit with what (if anything) in the counterparty's context actually fits, and evidence.intentAlignment with how the intents line up. Be specific; cite the strongest signal either way.\n- Do NOT reference internal system details like scores, pre-screens, or evaluator outputs in reasoning that could be shown to users.{negotiatorMemory}`;\n\nconst QUERY_RULE = `- {clientName} explicitly searched for \"{discoveryQuery}\". This query is the PRIMARY criterion: if the counterparty does not satisfy it, pass — background intents cannot rescue a query mismatch.`;\nconst NO_QUERY_RULE = `- No explicit search query: judge against {clientName}'s active intents.`;\n\nconst DEFAULT_SCREEN_TIMEOUT_MS = 15_000;\n\nexport interface NegotiationScreenerConfig {\n /** Hard ceiling on the screen LLM round-trip, in ms (default 15000). */\n timeoutMs?: number;\n}\n\n/**\n * The outreach gate (P2.1). One structured LLM call deciding\n * `reach_out | pass` for a fresh negotiation, from the reaching client's\n * perspective. Throws on LLM/validation failure — the screen graph node owns\n * the fail-open policy (a failed screen never blocks the negotiation).\n */\nexport class NegotiationScreener {\n private readonly timeoutMs: number;\n\n constructor(config?: NegotiationScreenerConfig) {\n this.timeoutMs = config?.timeoutMs && Number.isFinite(config.timeoutMs) && config.timeoutMs > 0\n ? config.timeoutMs\n : DEFAULT_SCREEN_TIMEOUT_MS;\n }\n\n /**\n * Produce a screen decision for a fresh match.\n * @throws When the LLM call times out or returns schema-invalid output.\n */\n async invoke(input: NegotiationScreenerInput): Promise<ScreenDecision> {\n const model = createStructuredModel(\"negotiationScreener\", ScreenDecisionSchema, { name: \"negotiation_screener\" });\n\n const clientName = input.clientUser.profile.name ?? \"your client\";\n const counterpartyName = input.counterpartyUser.profile.name ?? \"the counterparty\";\n const networkContext = input.indexContext.prompt || \"General discovery\";\n const queryRule = (input.discoveryQuery ? QUERY_RULE : NO_QUERY_RULE)\n .replace(/{clientName}/g, clientName)\n .replace(/{discoveryQuery}/g, input.discoveryQuery ?? \"\");\n\n const systemPrompt = SYSTEM_PROMPT\n .replace(/{clientName}/g, clientName)\n .replace(\"{networkContext}\", networkContext)\n .replace(\"{queryRule}\", queryRule)\n .replace(\"{negotiatorMemory}\", renderNegotiatorMemorySection(input.memory ?? [], { memoryHintsInstruction: true }));\n\n const formatIntents = (intents: UserNegotiationContext[\"intents\"]): string =>\n intents.length > 0 ? intents.map((i) => `- ${i.title}: ${i.description}`).join(\"\\n\") : \"- (none)\";\n\n const userMessage = `YOUR CLIENT (${clientName}):\nBio: ${input.clientUser.profile.bio ?? \"N/A\"}\n${input.discoveryQuery ? `Search query: \"${input.discoveryQuery}\"\\nBackground intents (secondary to the query):` : \"Active intents:\"}\n${formatIntents(input.clientUser.intents)}\n\nCOUNTERPARTY (${counterpartyName}):\nBio: ${input.counterpartyUser.profile.bio ?? \"N/A\"}\n${input.counterpartyContext ? `Context: ${input.counterpartyContext}\\n` : \"\"}Active intents:\n${formatIntents(input.counterpartyUser.intents)}\n\nWhy this match was suggested: ${input.seedAssessment.reasoning}\n\nDecide whether reaching out serves ${clientName}.`;\n\n const chatMessages = [\n { role: \"system\", content: systemPrompt },\n { role: \"user\", content: userMessage },\n ];\n\n const result = await this.callModel(model, chatMessages);\n const parsed = ScreenDecisionSchema.safeParse(result);\n if (!parsed.success) {\n screenLog.warn(\"Screen output failed schema validation\", {\n issues: parsed.error.issues.map((i) => i.message).slice(0, 3),\n });\n throw new Error(`Screen decision failed validation: ${parsed.error.issues[0]?.message ?? \"unknown\"}`);\n }\n return parsed.data;\n }\n\n /**\n * Raw structured-model round trip. Split out as a seam so tests can drive\n * the schema-validation and fail-open paths without a live provider.\n */\n protected async callModel(\n model: ReturnType<typeof createStructuredModel>,\n chatMessages: Array<{ role: string; content: string }>,\n ): Promise<unknown> {\n return invokeWithAbortSignal(model, chatMessages, AbortSignal.timeout(this.timeoutMs));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"negotiation.screen.js","sourceRoot":"/","sources":["negotiation/negotiation.screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAA8B,MAAM,yBAAyB,CAAC;AAEpG,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAgC,MAAM,8BAA8B,CAAC;AAEtI,MAAM,SAAS,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;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,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,SAAS,CACvB,KAA+C,EAC/C,YAAsD;QAEtD,OAAO,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["import { z } from \"zod\";\n\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\nimport type { UserNegotiationContext, SeedAssessment } from \"../shared/schemas/negotiation-state.schema.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { renderNegotiatorMemorySection, type NegotiatorMemoryEntry } from \"./negotiation.memory.js\";\nimport type { NegotiationTurn } from \"./negotiation.state.js\";\nimport { attributedDialogueIsEmpty, renderAttributedPriorDialogue, type AttributedPriorDialogue } from \"./negotiation.attribution.js\";\n\nconst screenLog = protocolLogger(\"NegotiationScreener\");\n\n/**\n * Screen-gate modes (P2.1 — client-advocate protocol).\n *\n * - `off` — the screen node is skipped entirely; no LLM call, no telemetry.\n * - `shadow` — the screen decision is made and recorded (task metadata +\n * trace event + log line) but NEVER blocks: every fresh negotiation still\n * proceeds to the first turn. Used to measure pass rates against observed\n * reject rates before enforcement.\n * - `enforce` — (P2.2) a `pass` decision blocks the negotiation before the\n * first turn: the graph routes straight to finalize with outcome\n * `reason: \"screened_out\"` — zero turns, zero counterparty involvement,\n * zero notifications; the opportunity is quietly `rejected`. A failed\n * screen still fails OPEN (never blocks), and `reach_out` proceeds normally.\n */\nexport const NEGOTIATION_SCREEN_MODES = [\"off\", \"shadow\", \"enforce\"] as const;\n\nexport type NegotiationScreenMode = (typeof NEGOTIATION_SCREEN_MODES)[number];\n\n/**\n * Resolve the screen mode from `NEGOTIATION_SCREEN_MODE`.\n *\n * Defaults to `off` when unset or unrecognized — the screen gate is an\n * explicit opt-in flip (same operational pattern as\n * `NEGOTIATION_PROTOCOL_VERSION` / `NEGOTIATOR_CHAT_ENABLED`): code ships\n * inert, the environment turns it on.\n */\nexport function configuredScreenMode(): NegotiationScreenMode {\n const raw = process.env.NEGOTIATION_SCREEN_MODE;\n if (raw === \"shadow\" || raw === \"enforce\" || raw === \"off\") return raw;\n return \"off\";\n}\n\n/**\n * Structured screen decision — the outreach gate's verdict on whether this\n * match is worth the client's name before any turn is exchanged.\n */\nexport const ScreenDecisionSchema = z.object({\n decision: z.enum([\"reach_out\", \"pass\"]),\n reasoning: z.string(),\n /** Suggested opening angle for the outreach turn (only when reaching out). */\n outreachAngle: z.string().nullable().optional(),\n evidence: z.object({\n /** How well the counterparty's context/premises fit the client's need. */\n counterpartyPremiseFit: z.string(),\n /** How the client's intents align with what the counterparty seeks. */\n intentAlignment: z.string(),\n /** Prior-negotiation memory signals (P5.3). Filled only when negotiator memory was injected into the screen prompt. */\n memoryHints: z.string().nullable().optional(),\n }),\n});\n\nexport type ScreenDecision = z.infer<typeof ScreenDecisionSchema>;\n\n/**\n * The record persisted to `tasks.metadata.screenDecision` and returned into\n * graph state. Extends the LLM decision with operational context so pass-rate\n * queries can group by mode and exclude failed-open rows.\n */\nexport interface ScreenDecisionRecord extends ScreenDecision {\n mode: NegotiationScreenMode;\n /** True when the screen LLM call failed and the gate defaulted open. */\n failedOpen?: boolean;\n /** Error message when `failedOpen` is set. */\n error?: string;\n screenedAt: string;\n durationMs: number;\n}\n\nexport interface NegotiationScreenerInput {\n /** The client — the user whose negotiator is deciding whether to reach out. */\n clientUser: UserNegotiationContext;\n /** The counterparty the client's negotiator would be reaching out to. */\n counterpartyUser: UserNegotiationContext;\n /** The counterparty's `user_contexts` paragraph (empty string when absent). */\n counterpartyContext?: string;\n /** The explicit search query that triggered discovery (if any). */\n discoveryQuery?: string;\n seedAssessment: Omit<SeedAssessment, \"actors\">;\n indexContext: { networkId: string; prompt?: string };\n /**\n * Retrieved negotiator memories for the client (P5.3 read path). Rendered\n * as a private prompt section with a memoryHints instruction. Absent/empty\n * → the prompt is byte-identical to before.\n */\n memory?: NegotiatorMemoryEntry[];\n /**\n * Whether this screen is for a continuation — a match against a counterparty\n * this client already has prior dialogue with (IND-563). When set with\n * `priorDialogue`, the gate evaluates the NEW signal on its own merits with\n * that dialogue as context. Absent → the prompt is byte-identical to before.\n */\n isContinuation?: boolean;\n /**\n * Prior negotiation turns with this counterparty (continuations only).\n * Rendered as read-only context so the gate can tell a materially-new signal\n * from a rehash of an already-settled one. Never treated as this task's own\n * outreach.\n */\n priorDialogue?: NegotiationTurn[];\n /**\n * Attributed form of the prior dialogue (IND-569). When present it supersedes\n * the flat `priorDialogue` list: earlier concluded opportunities and legacy\n * unattributed turns render as labeled, separated blocks so the gate can see\n * which prior turns belonged to OTHER opportunities. Absent → the flat\n * `priorDialogue` rendering is used (byte-identical to before).\n */\n priorDialogueAttributed?: AttributedPriorDialogue;\n}\n\nconst SYSTEM_PROMPT = `You are the outreach gate for {clientName}'s negotiator agent on a discovery network. Before any negotiation turn is exchanged, you decide whether this match is worth reaching out to on {clientName}'s behalf — their name and attention are spent with every outreach.\n\nNetwork context: {networkContext}\n\nDecide:\n- \"reach_out\" when the counterparty plausibly serves {clientName}'s stated needs and a concrete, honest opening case can be made. When reaching out, set outreachAngle to the strongest specific angle for the opening message.\n- \"pass\" when the match is generic, one-sided, or rests on vague overlap that would waste both parties' attention.\n\nRules:\n{queryRule}\n- Judge concrete intent alignment, not topical adjacency.\n- Fill evidence.counterpartyPremiseFit with what (if anything) in the counterparty's context actually fits, and evidence.intentAlignment with how the intents line up. Be specific; cite the strongest signal either way.\n- Do NOT reference internal system details like scores, pre-screens, or evaluator outputs in reasoning that could be shown to users.{negotiatorMemory}`;\n\nconst QUERY_RULE = `- {clientName} explicitly searched for \"{discoveryQuery}\". This query is the PRIMARY criterion: if the counterparty does not satisfy it, pass — background intents cannot rescue a query mismatch.`;\nconst NO_QUERY_RULE = `- No explicit search query: judge against {clientName}'s active intents.`;\n\nconst DEFAULT_SCREEN_TIMEOUT_MS = 15_000;\n\nexport interface NegotiationScreenerConfig {\n /** Hard ceiling on the screen LLM round-trip, in ms (default 15000). */\n timeoutMs?: number;\n}\n\n/**\n * The outreach gate (P2.1). One structured LLM call deciding\n * `reach_out | pass` for a fresh negotiation, from the reaching client's\n * perspective. Throws on LLM/validation failure — the screen graph node owns\n * the fail-open policy (a failed screen never blocks the negotiation).\n */\nexport class NegotiationScreener {\n private readonly timeoutMs: number;\n\n constructor(config?: NegotiationScreenerConfig) {\n this.timeoutMs = config?.timeoutMs && Number.isFinite(config.timeoutMs) && config.timeoutMs > 0\n ? config.timeoutMs\n : DEFAULT_SCREEN_TIMEOUT_MS;\n }\n\n /**\n * Produce a screen decision for a fresh match.\n * @throws When the LLM call times out or returns schema-invalid output.\n */\n async invoke(input: NegotiationScreenerInput): Promise<ScreenDecision> {\n const model = createStructuredModel(\"negotiationScreener\", ScreenDecisionSchema, { name: \"negotiation_screener\" });\n\n const clientName = input.clientUser.profile.name ?? \"your client\";\n const counterpartyName = input.counterpartyUser.profile.name ?? \"the counterparty\";\n const networkContext = input.indexContext.prompt || \"General discovery\";\n const queryRule = (input.discoveryQuery ? QUERY_RULE : NO_QUERY_RULE)\n .replace(/{clientName}/g, clientName)\n .replace(/{discoveryQuery}/g, input.discoveryQuery ?? \"\");\n\n const systemPrompt = SYSTEM_PROMPT\n .replace(/{clientName}/g, clientName)\n .replace(\"{networkContext}\", networkContext)\n .replace(\"{queryRule}\", queryRule)\n .replace(\"{negotiatorMemory}\", renderNegotiatorMemorySection(input.memory ?? [], { memoryHintsInstruction: true }));\n\n const formatIntents = (intents: UserNegotiationContext[\"intents\"]): string =>\n intents.length > 0 ? intents.map((i) => `- ${i.title}: ${i.description}`).join(\"\\n\") : \"- (none)\";\n\n const formatScreenTurn = (t: NegotiationTurn, i: number) => {\n const msgPart = t.message ? ` — ${t.message}` : \"\";\n return `Turn ${i + 1}: ${t.action} — ${t.assessment.reasoning}${msgPart}`;\n };\n\n // IND-569: prefer the attributed rendering (labeled per-opportunity blocks)\n // when the graph supplies it; otherwise fall back to the flat prior-turn list.\n const hasAttributed = input.isContinuation\n && input.priorDialogueAttributed != null\n && !attributedDialogueIsEmpty(input.priorDialogueAttributed);\n const flatPriorDialogue = input.isContinuation && input.priorDialogue && input.priorDialogue.length > 0\n ? input.priorDialogue\n : [];\n const priorDialogueBody = hasAttributed\n ? renderAttributedPriorDialogue(input.priorDialogueAttributed!, formatScreenTurn)\n : (flatPriorDialogue.length > 0 ? flatPriorDialogue.map(formatScreenTurn).join(\"\\n\") : \"\");\n const priorDialogueContext = priorDialogueBody\n ? `\\n\\n--- Prior dialogue with ${counterpartyName} (already spoken) ---\\n${priorDialogueBody}\\n\\nThis is a NEW signal against a counterparty ${clientName} has prior dialogue with. Some turns above may belong to OTHER, already-concluded opportunities (each block is labeled); they are background only. Judge the new signal on its own merits: if it is materially the same as what was already discussed, pass unless something concrete changed; if materially different, judge it fresh. Do NOT reach out again on generic overlap just because they spoke before.`\n : \"\";\n\n const userMessage = `YOUR CLIENT (${clientName}):\nBio: ${input.clientUser.profile.bio ?? \"N/A\"}\n${input.discoveryQuery ? `Search query: \"${input.discoveryQuery}\"\\nBackground intents (secondary to the query):` : \"Active intents:\"}\n${formatIntents(input.clientUser.intents)}\n\nCOUNTERPARTY (${counterpartyName}):\nBio: ${input.counterpartyUser.profile.bio ?? \"N/A\"}\n${input.counterpartyContext ? `Context: ${input.counterpartyContext}\\n` : \"\"}Active intents:\n${formatIntents(input.counterpartyUser.intents)}\n\nWhy this match was suggested: ${input.seedAssessment.reasoning}${priorDialogueContext}\n\nDecide whether reaching out serves ${clientName}.`;\n\n const chatMessages = [\n { role: \"system\", content: systemPrompt },\n { role: \"user\", content: userMessage },\n ];\n\n const result = await this.callModel(model, chatMessages);\n const parsed = ScreenDecisionSchema.safeParse(result);\n if (!parsed.success) {\n screenLog.warn(\"Screen output failed schema validation\", {\n issues: parsed.error.issues.map((i) => i.message).slice(0, 3),\n });\n throw new Error(`Screen decision failed validation: ${parsed.error.issues[0]?.message ?? \"unknown\"}`);\n }\n return parsed.data;\n }\n\n /**\n * Raw structured-model round trip. Split out as a seam so tests can drive\n * the schema-validation and fail-open paths without a live provider.\n */\n protected async callModel(\n model: ReturnType<typeof createStructuredModel>,\n chatMessages: Array<{ role: string; content: string }>,\n ): Promise<unknown> {\n return invokeWithAbortSignal(model, chatMessages, AbortSignal.timeout(this.timeoutMs));\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import type { NegotiationContinuationExecution, NegotiationContinuationReceipt,
|
|
|
3
3
|
import type { ScreenDecisionRecord } from "./negotiation.screen.js";
|
|
4
4
|
import type { DeadlockShiftRecord } from "./negotiation.deadlock.js";
|
|
5
5
|
import type { NegotiatorMemoryEntry } from "./negotiation.memory.js";
|
|
6
|
+
import type { SeededAttribution } from "./negotiation.attribution.js";
|
|
6
7
|
import { type NegotiationProtocolVersion } from "../shared/schemas/negotiation-state.schema.js";
|
|
7
8
|
import type { NegotiationConsultationReason } from "./negotiation.consultation-policy.js";
|
|
8
9
|
/**
|
|
@@ -291,6 +292,14 @@ export interface NegotiationMessage {
|
|
|
291
292
|
role: "agent";
|
|
292
293
|
parts: unknown[];
|
|
293
294
|
createdAt: Date;
|
|
295
|
+
/**
|
|
296
|
+
* Originating negotiation task (IND-569). Seeded prior messages carry their
|
|
297
|
+
* source task's id; turns persisted this session carry the current task id.
|
|
298
|
+
* Optional/undefined for legacy hosts whose `getMessagesForConversation`
|
|
299
|
+
* does not project task attribution — such turns degrade to the unattributed
|
|
300
|
+
* prior-dialogue block, never into the current opportunity's turns.
|
|
301
|
+
*/
|
|
302
|
+
taskId?: string | null;
|
|
294
303
|
}
|
|
295
304
|
/** LangGraph state annotation for the negotiation graph. */
|
|
296
305
|
export declare const NegotiationGraphState: import("@langchain/langgraph").AnnotationRoot<{
|
|
@@ -346,8 +355,32 @@ export declare const NegotiationGraphState: import("@langchain/langgraph").Annot
|
|
|
346
355
|
* retrieved and empty (flag off / no rows / retrieval failed).
|
|
347
356
|
*/
|
|
348
357
|
memoryBySide: import("@langchain/langgraph").BaseChannel<Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>, Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>> | import("@langchain/langgraph").OverwriteValue<Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>>, unknown>;
|
|
358
|
+
/**
|
|
359
|
+
* Immutable attributed prior dialogue derived once in the init node from the
|
|
360
|
+
* seeded prior messages (IND-569). Groups earlier-opportunity turns and
|
|
361
|
+
* legacy unattributed turns so the screen node and every turn prompt can
|
|
362
|
+
* label prior context per opportunity. Null on fresh runs / when there is no
|
|
363
|
+
* seeded prior dialogue.
|
|
364
|
+
*/
|
|
365
|
+
priorAttribution: import("@langchain/langgraph").BaseChannel<SeededAttribution | null, SeededAttribution | import("@langchain/langgraph").OverwriteValue<SeededAttribution | null> | null, unknown>;
|
|
349
366
|
/** Whether this run is continuing a prior conversation with the same pair. */
|
|
350
367
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
368
|
+
/**
|
|
369
|
+
* Whether the initiator has actually opened `outreach` within THIS task
|
|
370
|
+
* (IND-564). Set by the turn node the first time an `outreach` turn is
|
|
371
|
+
* persisted in the current session; seeded prior-task turns never flip it.
|
|
372
|
+
* `withdraw` is only legal after an in-task outreach — a withdraw before one
|
|
373
|
+
* would retract an outreach never made here and drop a spurious message into
|
|
374
|
+
* the shared thread, so the turn node maps it to a quiet screen-out instead.
|
|
375
|
+
*/
|
|
376
|
+
outreachOpened: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
377
|
+
/**
|
|
378
|
+
* Set by the turn node when an opening-move `withdraw` (no in-task outreach)
|
|
379
|
+
* was blocked (IND-564). Signals finalize to record the quiet screen-out
|
|
380
|
+
* outcome (`reason: "screened_out"`, opportunity `rejected`) without ever
|
|
381
|
+
* persisting the withdraw message into the shared `dm_pair` conversation.
|
|
382
|
+
*/
|
|
383
|
+
firstTurnScreenedOut: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
351
384
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
352
385
|
/** Exact persisted lifecycle state claimed by this negotiation attempt. */
|
|
353
386
|
opportunityStatus: import("@langchain/langgraph").BaseChannel<OpportunityStatus | undefined, OpportunityStatus | import("@langchain/langgraph").OverwriteValue<OpportunityStatus | undefined> | undefined, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negotiation.state.d.ts","sourceRoot":"/","sources":["negotiation/negotiation.state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC7M,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAA6C,KAAK,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3I,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAE1F;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUhC,oDAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEpD,CAAC;AAEH,2EAA2E;AAC3E,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IAKxF,gFAAgF;;;;;IAoBhF,gFAAgF;;;;;;;IAyBhF;;;;;;OAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAeH;;;;;;;OAOG;;IAMH,+EAA+E;;IAM/E,6EAA6E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc7E,CAAC"}
|
|
@@ -135,11 +135,44 @@ export const NegotiationGraphState = Annotation.Root({
|
|
|
135
135
|
reducer: (curr, next) => ({ ...curr, ...next }),
|
|
136
136
|
default: () => ({}),
|
|
137
137
|
}),
|
|
138
|
+
/**
|
|
139
|
+
* Immutable attributed prior dialogue derived once in the init node from the
|
|
140
|
+
* seeded prior messages (IND-569). Groups earlier-opportunity turns and
|
|
141
|
+
* legacy unattributed turns so the screen node and every turn prompt can
|
|
142
|
+
* label prior context per opportunity. Null on fresh runs / when there is no
|
|
143
|
+
* seeded prior dialogue.
|
|
144
|
+
*/
|
|
145
|
+
priorAttribution: Annotation({
|
|
146
|
+
reducer: (curr, next) => next ?? curr,
|
|
147
|
+
default: () => null,
|
|
148
|
+
}),
|
|
138
149
|
/** Whether this run is continuing a prior conversation with the same pair. */
|
|
139
150
|
isContinuation: Annotation({
|
|
140
151
|
reducer: (curr, next) => next ?? curr,
|
|
141
152
|
default: () => false,
|
|
142
153
|
}),
|
|
154
|
+
/**
|
|
155
|
+
* Whether the initiator has actually opened `outreach` within THIS task
|
|
156
|
+
* (IND-564). Set by the turn node the first time an `outreach` turn is
|
|
157
|
+
* persisted in the current session; seeded prior-task turns never flip it.
|
|
158
|
+
* `withdraw` is only legal after an in-task outreach — a withdraw before one
|
|
159
|
+
* would retract an outreach never made here and drop a spurious message into
|
|
160
|
+
* the shared thread, so the turn node maps it to a quiet screen-out instead.
|
|
161
|
+
*/
|
|
162
|
+
outreachOpened: Annotation({
|
|
163
|
+
reducer: (curr, next) => next ?? curr,
|
|
164
|
+
default: () => false,
|
|
165
|
+
}),
|
|
166
|
+
/**
|
|
167
|
+
* Set by the turn node when an opening-move `withdraw` (no in-task outreach)
|
|
168
|
+
* was blocked (IND-564). Signals finalize to record the quiet screen-out
|
|
169
|
+
* outcome (`reason: "screened_out"`, opportunity `rejected`) without ever
|
|
170
|
+
* persisting the withdraw message into the shared `dm_pair` conversation.
|
|
171
|
+
*/
|
|
172
|
+
firstTurnScreenedOut: Annotation({
|
|
173
|
+
reducer: (curr, next) => next ?? curr,
|
|
174
|
+
default: () => false,
|
|
175
|
+
}),
|
|
143
176
|
opportunityId: Annotation({
|
|
144
177
|
reducer: (curr, next) => next ?? curr,
|
|
145
178
|
default: () => "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negotiation.state.js","sourceRoot":"/","sources":["negotiation/negotiation.state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAmC,MAAM,+CAA+C,CAAC;AAG3I;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAC7C,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;SAChD,CAAC;KACH,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,oDAAoD;IACpD,OAAO,EAAE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E,CAAC,IAAI;KACpB,CAAC;IAEF;;;;;;;OAOG;IACH,MAAM,EAAE,UAAU,CAAkE;QAClF,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAiB;KACjC,CAAC;IAEF,+EAA+E;IAC/E,cAAc,EAAE,UAAU,CAAS;QACjC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;KACjB,CAAC;IAEF,6EAA6E;IAC7E,WAAW,EAAE,UAAU,CAA0B;QAC/C,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;IAEF,OAAO,EAAE,UAAU,CAA4B;QAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;KACpB,CAAC;IACF,KAAK,EAAE,UAAU,CAAgB;QAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;KACpB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { Annotation } from \"@langchain/langgraph\";\nimport { z } from \"zod\";\nimport type { NegotiationContinuationExecution, NegotiationContinuationReceipt, NegotiationPrivateConsultation, NegotiationUserAnswer, OpportunityStatus } from \"../shared/interfaces/database.interface.js\";\nimport type { ScreenDecisionRecord } from \"./negotiation.screen.js\";\nimport type { DeadlockShiftRecord } from \"./negotiation.deadlock.js\";\nimport type { NegotiatorMemoryEntry } from \"./negotiation.memory.js\";\nimport { AskUserPayloadSchema, NEGOTIATION_ACTIONS, type NegotiationProtocolVersion } from \"../shared/schemas/negotiation-state.schema.js\";\nimport type { NegotiationConsultationReason } from \"./negotiation.consultation-policy.js\";\n\n/**\n * Zod schema for a single negotiation turn (DataPart payload in A2A message).\n * Accepts the full v1+v2 action union — which subset is valid for a given turn\n * is enforced by the seat-scoped schemas in `negotiation.protocol.ts`.\n */\nexport const NegotiationTurnSchema = z.object({\n action: z.enum(NEGOTIATION_ACTIONS),\n assessment: z.object({\n reasoning: z.string(),\n suggestedRoles: z.object({\n ownUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n otherUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n }),\n }),\n message: z.string().nullable().optional(),\n /** Present when action is `ask_user` (v2, P3.2). */\n askUser: AskUserPayloadSchema.nullable().optional(),\n});\n\n/** Restricted v1 turn schema for the system agent (no question action). */\nexport const SystemNegotiationTurnSchema = z.object({\n action: z.enum([\"propose\", \"accept\", \"reject\", \"counter\"]),\n assessment: z.object({\n reasoning: z.string(),\n suggestedRoles: z.object({\n ownUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n otherUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n }),\n }),\n message: z.string().nullable().optional(),\n});\n\n/** v1 turn schema for system agent's final allowed turn (must decide). */\nexport const FinalNegotiationTurnSchema = z.object({\n action: z.enum([\"accept\", \"reject\"]),\n assessment: z.object({\n reasoning: z.string(),\n suggestedRoles: z.object({\n ownUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n otherUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n }),\n }),\n message: z.string().nullable().optional(),\n});\n\nexport type NegotiationTurn = z.infer<typeof NegotiationTurnSchema>;\n\n/** Zod schema for the negotiation outcome (Artifact payload on COMPLETED task). */\nexport const NegotiationOutcomeSchema = z.object({\n hasOpportunity: z.boolean(),\n agreedRoles: z.array(z.object({\n userId: z.string(),\n role: z.enum([\"agent\", \"patient\", \"peer\"]),\n })),\n reasoning: z.string(),\n turnCount: z.number(),\n reason: z.enum([\"turn_cap\", \"timeout\", \"screened_out\"]).optional(),\n});\n\nexport type NegotiationOutcome = z.infer<typeof NegotiationOutcomeSchema>;\n\n/** Context each agent receives about its user. */\nexport interface UserNegotiationContext {\n id: string;\n intents: Array<{ id: string; title: string; description: string; confidence: number }>;\n profile: { name?: string; bio?: string; location?: string; interests?: string[]; skills?: string[] };\n}\n\n/** Seed assessment from the evaluator pre-filter. */\nexport interface SeedAssessment {\n reasoning: string;\n valencyRole: string;\n actors?: Array<{ userId: string; role: string }>;\n}\n\n/** Typed interface for a negotiation graph's invoke signature. */\nexport interface NegotiationGraphLike {\n invoke(input: {\n sourceUser: UserNegotiationContext;\n candidateUser: UserNegotiationContext;\n /** Exact opportunity-actor intent bindings; never inferred from intent array order. */\n sourceIntentId?: string;\n candidateIntentId?: string;\n indexContext: { networkId: string; prompt: string };\n seedAssessment: Omit<SeedAssessment, \"actors\">;\n discoveryQuery?: string;\n opportunityId?: string;\n /** Exact persisted lifecycle state claimed by this negotiation attempt. */\n opportunityStatus?: OpportunityStatus;\n opportunityUpdatedAt?: Date;\n maxTurns?: number;\n timeoutMs?: number;\n /**\n * The user who holds the initiating seat for this match (v2 client-advocate\n * protocol). Stamped into task metadata by the init node. When omitted, the\n * init node resolves it: inherit from the prior task for the same\n * opportunity → conversation-scoped tie-break → fall back to sourceUser.id.\n */\n initiatorUserId?: string;\n /** Exact settled task for a durable ask_user continuation. */\n resumeFromTaskId?: string;\n /** Deterministic durable settlement/outbox identifier. */\n continuationSettlementId?: string;\n /** Current durable lease/fence for the exact successor execution. */\n continuationExecution?: NegotiationContinuationExecution;\n }): Promise<{\n outcome: NegotiationOutcome | null;\n messages?: NegotiationMessage[];\n conversationId?: string;\n isContinuation?: boolean;\n priorTurnCount?: number;\n error?: string | null;\n continuationReceipt?: NegotiationContinuationReceipt;\n }>;\n}\n\n/** A2A message record shape (matches messages table). */\nexport interface NegotiationMessage {\n id: string;\n senderId: string;\n role: \"agent\";\n parts: unknown[];\n createdAt: Date;\n}\n\n/** LangGraph state annotation for the negotiation graph. */\nexport const NegotiationGraphState = Annotation.Root({\n sourceUser: Annotation<UserNegotiationContext>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ id: \"\", intents: [], profile: {} }),\n }),\n candidateUser: Annotation<UserNegotiationContext>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ id: \"\", intents: [], profile: {} }),\n }),\n sourceIntentId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n candidateIntentId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n indexContext: Annotation<{ networkId: string; prompt: string }>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ networkId: \"\", prompt: \"\" }),\n }),\n seedAssessment: Annotation<SeedAssessment>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ reasoning: \"\", valencyRole: \"\" }),\n }),\n\n /**\n * Explicit initiator seat for this match (purely additive metadata — no seat\n * rules attach to it yet). Resolution when unset happens in the init node;\n * the resolved value is written back to state and into task metadata.\n */\n initiatorUserId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** The explicit search query that triggered discovery (if any). */\n discoveryQuery: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /**\n * Negotiation protocol version for this session's task. Resolved by the\n * init node: inherited from the prior task on the conversation when one\n * exists (never re-stamped — a v1 conversation stays v1 mid-flight), else\n * stamped from `NEGOTIATION_PROTOCOL_VERSION` for genuinely fresh runs.\n */\n protocolVersion: Annotation<NegotiationProtocolVersion>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"v1\" as const,\n }),\n\n /**\n * Screen-gate decision for this fresh run (P2.1 shadow mode). Written by the\n * screen node; null when the gate is off, on continuations, or before the\n * node runs. Mirrors `tasks.metadata.screenDecision`.\n */\n screenDecision: Annotation<ScreenDecisionRecord | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /**\n * First applied deadlock→bargaining shift in this session (IND-428).\n * Written by the turn node when the system agent first drafts in the\n * bargaining stance; used to record the shift exactly once per session.\n * Internal analytics only — mirrored to `tasks.metadata.deadlockShift`,\n * never into any turn payload or public projection.\n */\n deadlockShift: Annotation<DeadlockShiftRecord | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /**\n * Per-side negotiator-memory cache (P5.3 read path). Populated lazily the\n * first time each side's memory is retrieved (screen node for the client,\n * turn node for the speaker) so a multi-turn session pays for retrieval at\n * most once per side. `undefined` per side = not yet retrieved; `[]` =\n * retrieved and empty (flag off / no rows / retrieval failed).\n */\n memoryBySide: Annotation<Partial<Record<\"source\" | \"candidate\", NegotiatorMemoryEntry[]>>>({\n reducer: (curr, next) => ({ ...curr, ...next }),\n default: () => ({}),\n }),\n\n /** Whether this run is continuing a prior conversation with the same pair. */\n isContinuation: Annotation<boolean>({\n reducer: (curr, next) => next ?? curr,\n default: () => false,\n }),\n opportunityId: Annotation<string>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"\",\n }),\n /** Exact persisted lifecycle state claimed by this negotiation attempt. */\n opportunityStatus: Annotation<OpportunityStatus | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n opportunityUpdatedAt: Annotation<Date | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /** Exact prior task selected by a durable continuation; bypasses latest-task lookup. */\n resumeFromTaskId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /** Deterministic settlement key used to idempotently reuse a successor task. */\n continuationSettlementId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n continuationExecution: Annotation<NegotiationContinuationExecution | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n continuationReceipt: Annotation<NegotiationContinuationReceipt | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n privateConsultation: Annotation<NegotiationPrivateConsultation | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /** Server-only IND-508 category recovered from the exact prior task binding. */\n consultationPolicyReason: Annotation<NegotiationConsultationReason | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n conversationId: Annotation<string>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"\",\n }),\n taskId: Annotation<string>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"\",\n }),\n messages: Annotation<NegotiationMessage[]>({\n reducer: (curr, next) => [...curr, ...(next || [])],\n default: () => [],\n }),\n turnCount: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 0,\n }),\n maxTurns: Annotation<number | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /**\n * Park-window budget in milliseconds. Ambient callers pass `AMBIENT_PARK_WINDOW_MS`\n * (5 minutes); orchestrator callers pass a shorter window. This annotation default\n * is a safety net for any caller that omits the field — keep it aligned with\n * `AMBIENT_PARK_WINDOW_MS` in packages/protocol/src/negotiation/negotiation.tools.ts.\n * Inlined rather than imported to avoid a state↔tools cycle.\n */\n timeoutMs: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 5 * 60 * 1000,\n }),\n\n currentSpeaker: Annotation<\"source\" | \"candidate\">({\n reducer: (curr, next) => next ?? curr,\n default: () => \"source\" as const,\n }),\n lastTurn: Annotation<NegotiationTurn | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /**\n * Graph status.\n * - `active` — agents are exchanging turns (default)\n * - `waiting_for_agent` — graph suspended; awaiting external agent response or timeout\n * - `input_required` — graph suspended on an `ask_user` pause; awaiting the\n * negotiator's own client (answer or 24 h window expiry resumes it)\n * - `completed` — negotiation finalized (accept/reject/turn-cap/timeout)\n */\n status: Annotation<'active' | 'waiting_for_agent' | 'input_required' | 'completed'>({\n reducer: (curr, next) => next ?? curr,\n default: () => 'active' as const,\n }),\n\n /** Number of turns present in the conversation before this session started. */\n priorTurnCount: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 0,\n }),\n\n /** User answers collected by the questioner between negotiation sessions. */\n userAnswers: Annotation<NegotiationUserAnswer[]>({\n reducer: (curr, next) => next ?? curr,\n default: () => [],\n }),\n\n outcome: Annotation<NegotiationOutcome | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n error: Annotation<string | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"negotiation.state.js","sourceRoot":"/","sources":["negotiation/negotiation.state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAmC,MAAM,+CAA+C,CAAC;AAG3I;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAC7C,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;SAChD,CAAC;KACH,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,oDAAoD;IACpD,OAAO,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACpD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K,EAAE,UAAU,CAAgB;QAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;KACpB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { Annotation } from \"@langchain/langgraph\";\nimport { z } from \"zod\";\nimport type { NegotiationContinuationExecution, NegotiationContinuationReceipt, NegotiationPrivateConsultation, NegotiationUserAnswer, OpportunityStatus } from \"../shared/interfaces/database.interface.js\";\nimport type { ScreenDecisionRecord } from \"./negotiation.screen.js\";\nimport type { DeadlockShiftRecord } from \"./negotiation.deadlock.js\";\nimport type { NegotiatorMemoryEntry } from \"./negotiation.memory.js\";\nimport type { SeededAttribution } from \"./negotiation.attribution.js\";\nimport { AskUserPayloadSchema, NEGOTIATION_ACTIONS, type NegotiationProtocolVersion } from \"../shared/schemas/negotiation-state.schema.js\";\nimport type { NegotiationConsultationReason } from \"./negotiation.consultation-policy.js\";\n\n/**\n * Zod schema for a single negotiation turn (DataPart payload in A2A message).\n * Accepts the full v1+v2 action union — which subset is valid for a given turn\n * is enforced by the seat-scoped schemas in `negotiation.protocol.ts`.\n */\nexport const NegotiationTurnSchema = z.object({\n action: z.enum(NEGOTIATION_ACTIONS),\n assessment: z.object({\n reasoning: z.string(),\n suggestedRoles: z.object({\n ownUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n otherUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n }),\n }),\n message: z.string().nullable().optional(),\n /** Present when action is `ask_user` (v2, P3.2). */\n askUser: AskUserPayloadSchema.nullable().optional(),\n});\n\n/** Restricted v1 turn schema for the system agent (no question action). */\nexport const SystemNegotiationTurnSchema = z.object({\n action: z.enum([\"propose\", \"accept\", \"reject\", \"counter\"]),\n assessment: z.object({\n reasoning: z.string(),\n suggestedRoles: z.object({\n ownUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n otherUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n }),\n }),\n message: z.string().nullable().optional(),\n});\n\n/** v1 turn schema for system agent's final allowed turn (must decide). */\nexport const FinalNegotiationTurnSchema = z.object({\n action: z.enum([\"accept\", \"reject\"]),\n assessment: z.object({\n reasoning: z.string(),\n suggestedRoles: z.object({\n ownUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n otherUser: z.enum([\"agent\", \"patient\", \"peer\"]),\n }),\n }),\n message: z.string().nullable().optional(),\n});\n\nexport type NegotiationTurn = z.infer<typeof NegotiationTurnSchema>;\n\n/** Zod schema for the negotiation outcome (Artifact payload on COMPLETED task). */\nexport const NegotiationOutcomeSchema = z.object({\n hasOpportunity: z.boolean(),\n agreedRoles: z.array(z.object({\n userId: z.string(),\n role: z.enum([\"agent\", \"patient\", \"peer\"]),\n })),\n reasoning: z.string(),\n turnCount: z.number(),\n reason: z.enum([\"turn_cap\", \"timeout\", \"screened_out\"]).optional(),\n});\n\nexport type NegotiationOutcome = z.infer<typeof NegotiationOutcomeSchema>;\n\n/** Context each agent receives about its user. */\nexport interface UserNegotiationContext {\n id: string;\n intents: Array<{ id: string; title: string; description: string; confidence: number }>;\n profile: { name?: string; bio?: string; location?: string; interests?: string[]; skills?: string[] };\n}\n\n/** Seed assessment from the evaluator pre-filter. */\nexport interface SeedAssessment {\n reasoning: string;\n valencyRole: string;\n actors?: Array<{ userId: string; role: string }>;\n}\n\n/** Typed interface for a negotiation graph's invoke signature. */\nexport interface NegotiationGraphLike {\n invoke(input: {\n sourceUser: UserNegotiationContext;\n candidateUser: UserNegotiationContext;\n /** Exact opportunity-actor intent bindings; never inferred from intent array order. */\n sourceIntentId?: string;\n candidateIntentId?: string;\n indexContext: { networkId: string; prompt: string };\n seedAssessment: Omit<SeedAssessment, \"actors\">;\n discoveryQuery?: string;\n opportunityId?: string;\n /** Exact persisted lifecycle state claimed by this negotiation attempt. */\n opportunityStatus?: OpportunityStatus;\n opportunityUpdatedAt?: Date;\n maxTurns?: number;\n timeoutMs?: number;\n /**\n * The user who holds the initiating seat for this match (v2 client-advocate\n * protocol). Stamped into task metadata by the init node. When omitted, the\n * init node resolves it: inherit from the prior task for the same\n * opportunity → conversation-scoped tie-break → fall back to sourceUser.id.\n */\n initiatorUserId?: string;\n /** Exact settled task for a durable ask_user continuation. */\n resumeFromTaskId?: string;\n /** Deterministic durable settlement/outbox identifier. */\n continuationSettlementId?: string;\n /** Current durable lease/fence for the exact successor execution. */\n continuationExecution?: NegotiationContinuationExecution;\n }): Promise<{\n outcome: NegotiationOutcome | null;\n messages?: NegotiationMessage[];\n conversationId?: string;\n isContinuation?: boolean;\n priorTurnCount?: number;\n error?: string | null;\n continuationReceipt?: NegotiationContinuationReceipt;\n }>;\n}\n\n/** A2A message record shape (matches messages table). */\nexport interface NegotiationMessage {\n id: string;\n senderId: string;\n role: \"agent\";\n parts: unknown[];\n createdAt: Date;\n /**\n * Originating negotiation task (IND-569). Seeded prior messages carry their\n * source task's id; turns persisted this session carry the current task id.\n * Optional/undefined for legacy hosts whose `getMessagesForConversation`\n * does not project task attribution — such turns degrade to the unattributed\n * prior-dialogue block, never into the current opportunity's turns.\n */\n taskId?: string | null;\n}\n\n/** LangGraph state annotation for the negotiation graph. */\nexport const NegotiationGraphState = Annotation.Root({\n sourceUser: Annotation<UserNegotiationContext>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ id: \"\", intents: [], profile: {} }),\n }),\n candidateUser: Annotation<UserNegotiationContext>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ id: \"\", intents: [], profile: {} }),\n }),\n sourceIntentId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n candidateIntentId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n indexContext: Annotation<{ networkId: string; prompt: string }>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ networkId: \"\", prompt: \"\" }),\n }),\n seedAssessment: Annotation<SeedAssessment>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({ reasoning: \"\", valencyRole: \"\" }),\n }),\n\n /**\n * Explicit initiator seat for this match (purely additive metadata — no seat\n * rules attach to it yet). Resolution when unset happens in the init node;\n * the resolved value is written back to state and into task metadata.\n */\n initiatorUserId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** The explicit search query that triggered discovery (if any). */\n discoveryQuery: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /**\n * Negotiation protocol version for this session's task. Resolved by the\n * init node: inherited from the prior task on the conversation when one\n * exists (never re-stamped — a v1 conversation stays v1 mid-flight), else\n * stamped from `NEGOTIATION_PROTOCOL_VERSION` for genuinely fresh runs.\n */\n protocolVersion: Annotation<NegotiationProtocolVersion>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"v1\" as const,\n }),\n\n /**\n * Screen-gate decision for this fresh run (P2.1 shadow mode). Written by the\n * screen node; null when the gate is off, on continuations, or before the\n * node runs. Mirrors `tasks.metadata.screenDecision`.\n */\n screenDecision: Annotation<ScreenDecisionRecord | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /**\n * First applied deadlock→bargaining shift in this session (IND-428).\n * Written by the turn node when the system agent first drafts in the\n * bargaining stance; used to record the shift exactly once per session.\n * Internal analytics only — mirrored to `tasks.metadata.deadlockShift`,\n * never into any turn payload or public projection.\n */\n deadlockShift: Annotation<DeadlockShiftRecord | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /**\n * Per-side negotiator-memory cache (P5.3 read path). Populated lazily the\n * first time each side's memory is retrieved (screen node for the client,\n * turn node for the speaker) so a multi-turn session pays for retrieval at\n * most once per side. `undefined` per side = not yet retrieved; `[]` =\n * retrieved and empty (flag off / no rows / retrieval failed).\n */\n memoryBySide: Annotation<Partial<Record<\"source\" | \"candidate\", NegotiatorMemoryEntry[]>>>({\n reducer: (curr, next) => ({ ...curr, ...next }),\n default: () => ({}),\n }),\n\n /**\n * Immutable attributed prior dialogue derived once in the init node from the\n * seeded prior messages (IND-569). Groups earlier-opportunity turns and\n * legacy unattributed turns so the screen node and every turn prompt can\n * label prior context per opportunity. Null on fresh runs / when there is no\n * seeded prior dialogue.\n */\n priorAttribution: Annotation<SeededAttribution | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /** Whether this run is continuing a prior conversation with the same pair. */\n isContinuation: Annotation<boolean>({\n reducer: (curr, next) => next ?? curr,\n default: () => false,\n }),\n\n /**\n * Whether the initiator has actually opened `outreach` within THIS task\n * (IND-564). Set by the turn node the first time an `outreach` turn is\n * persisted in the current session; seeded prior-task turns never flip it.\n * `withdraw` is only legal after an in-task outreach — a withdraw before one\n * would retract an outreach never made here and drop a spurious message into\n * the shared thread, so the turn node maps it to a quiet screen-out instead.\n */\n outreachOpened: Annotation<boolean>({\n reducer: (curr, next) => next ?? curr,\n default: () => false,\n }),\n\n /**\n * Set by the turn node when an opening-move `withdraw` (no in-task outreach)\n * was blocked (IND-564). Signals finalize to record the quiet screen-out\n * outcome (`reason: \"screened_out\"`, opportunity `rejected`) without ever\n * persisting the withdraw message into the shared `dm_pair` conversation.\n */\n firstTurnScreenedOut: Annotation<boolean>({\n reducer: (curr, next) => next ?? curr,\n default: () => false,\n }),\n opportunityId: Annotation<string>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"\",\n }),\n /** Exact persisted lifecycle state claimed by this negotiation attempt. */\n opportunityStatus: Annotation<OpportunityStatus | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n opportunityUpdatedAt: Annotation<Date | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /** Exact prior task selected by a durable continuation; bypasses latest-task lookup. */\n resumeFromTaskId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /** Deterministic settlement key used to idempotently reuse a successor task. */\n continuationSettlementId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n continuationExecution: Annotation<NegotiationContinuationExecution | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n continuationReceipt: Annotation<NegotiationContinuationReceipt | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n privateConsultation: Annotation<NegotiationPrivateConsultation | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /** Server-only IND-508 category recovered from the exact prior task binding. */\n consultationPolicyReason: Annotation<NegotiationConsultationReason | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n conversationId: Annotation<string>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"\",\n }),\n taskId: Annotation<string>({\n reducer: (curr, next) => next ?? curr,\n default: () => \"\",\n }),\n messages: Annotation<NegotiationMessage[]>({\n reducer: (curr, next) => [...curr, ...(next || [])],\n default: () => [],\n }),\n turnCount: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 0,\n }),\n maxTurns: Annotation<number | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n /**\n * Park-window budget in milliseconds. Ambient callers pass `AMBIENT_PARK_WINDOW_MS`\n * (5 minutes); orchestrator callers pass a shorter window. This annotation default\n * is a safety net for any caller that omits the field — keep it aligned with\n * `AMBIENT_PARK_WINDOW_MS` in packages/protocol/src/negotiation/negotiation.tools.ts.\n * Inlined rather than imported to avoid a state↔tools cycle.\n */\n timeoutMs: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 5 * 60 * 1000,\n }),\n\n currentSpeaker: Annotation<\"source\" | \"candidate\">({\n reducer: (curr, next) => next ?? curr,\n default: () => \"source\" as const,\n }),\n lastTurn: Annotation<NegotiationTurn | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n\n /**\n * Graph status.\n * - `active` — agents are exchanging turns (default)\n * - `waiting_for_agent` — graph suspended; awaiting external agent response or timeout\n * - `input_required` — graph suspended on an `ask_user` pause; awaiting the\n * negotiator's own client (answer or 24 h window expiry resumes it)\n * - `completed` — negotiation finalized (accept/reject/turn-cap/timeout)\n */\n status: Annotation<'active' | 'waiting_for_agent' | 'input_required' | 'completed'>({\n reducer: (curr, next) => next ?? curr,\n default: () => 'active' as const,\n }),\n\n /** Number of turns present in the conversation before this session started. */\n priorTurnCount: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 0,\n }),\n\n /** User answers collected by the questioner between negotiation sessions. */\n userAnswers: Annotation<NegotiationUserAnswer[]>({\n reducer: (curr, next) => next ?? curr,\n default: () => [],\n }),\n\n outcome: Annotation<NegotiationOutcome | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n error: Annotation<string | null>({\n reducer: (curr, next) => next ?? curr,\n default: () => null,\n }),\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opportunity.evidence.d.ts","sourceRoot":"/","sources":["opportunity/opportunity.evidence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;IACvE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,sBAAsB,GAAG,mBAAmB,CAiB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AAQ,EAAE,mBAAmB,EAAE,CAAA;CAAE,CAE7H;AAED,wBAAgB,wBAAwB,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,mBAAmB,EAAE,GAAG,SAAS,CAAC,GAAG,mBAAmB,EAAE,CAgBnH;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAKlH;AAED,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAqB1F"}
|
|
@@ -55,7 +55,14 @@ export function renderOpportunityEvidenceForPrompt(evidence) {
|
|
|
55
55
|
item.matchedStrategies?.length ? `strategies=${item.matchedStrategies.join(',')}` : undefined,
|
|
56
56
|
].filter(Boolean).join(', ');
|
|
57
57
|
const text = item.summary ?? item.payload ?? item.assertionText ?? '';
|
|
58
|
-
|
|
58
|
+
// IND-567 Fix B: when a query_premise entry has no text, warn the evaluator
|
|
59
|
+
// so it does not treat a high RAG score as domain confirmation.
|
|
60
|
+
// (text should be populated by Fix A; this fallback fires if the DB fetch
|
|
61
|
+
// failed or the adapter omitted getPremise).
|
|
62
|
+
const domainCaution = item.kind === 'query_premise' && !text
|
|
63
|
+
? ' [premise text unavailable — do NOT infer domain match from RAG score alone; verify domain alignment from profile]'
|
|
64
|
+
: '';
|
|
65
|
+
return ` - ${item.kind} on ${item.networkId} via ${item.lens ?? 'unknown'} score=${item.score?.toFixed(3) ?? '—'}${refs ? ` (${refs})` : ''}${text ? `: ${text}` : ''}${domainCaution}`;
|
|
59
66
|
}).join('\n');
|
|
60
67
|
}
|
|
61
68
|
function resolveEvidenceKind(candidate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opportunity.evidence.js","sourceRoot":"/","sources":["opportunity/opportunity.evidence.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,sBAAsB,CAAC,SAAiC;IACtE,MAAM,IAAI,GAAG,mBA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AI,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC;QACtE,4EAA4E;QAC5E,gEAAgE;QAChE,0EAA0E;QAC1E,8CAA8C;QAC9C,MAAM,aAAa,GACjB,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,IAAI;YACpC,CAAC,CAAC,oHAAoH;YACtH,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,SAAS,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,SAAS,QAAQ,IAAI,CAAC,IAAI,IAAI,SAAS,UAAU,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,CAAC;IAC7L,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAiC;IAC5D,IAAI,SAAS,CAAC,eAAe,KAAK,oBAAoB;QAAE,OAAO,oBAAoB,CAAC;IACpF,IAAI,SAAS,CAAC,eAAe,KAAK,mBAAmB;QAAE,OAAO,mBAAmB,CAAC;IAClF,IAAI,SAAS,CAAC,kBAAkB;QAAE,OAAO,eAAe,CAAC;IACzD,IAAI,SAAS,CAAC,iBAAiB;QAAE,OAAO,cAAc,CAAC;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { OpportunityEvidence } from '../shared/schemas/network-assignment.schema.js';\n\nexport interface EvidenceCandidateInput {\n networkId: string;\n similarity: number;\n lens: string;\n discoverySource?: 'query' | 'premise-similarity' | 'context-to-intent';\n matchedStrategies?: string[];\n sourcePremiseId?: string;\n candidatePremiseId?: string;\n candidateIntentId?: string;\n sourceContextId?: string;\n candidatePayload?: string;\n candidateSummary?: string;\n}\n\nexport function buildCandidateEvidence(candidate: EvidenceCandidateInput): OpportunityEvidence {\n const kind = resolveEvidenceKind(candidate);\n return {\n kind,\n networkId: candidate.networkId,\n score: candidate.similarity,\n lens: candidate.lens,\n discoverySource: candidate.discoverySource,\n matchedStrategies: candidate.matchedStrategies,\n sourcePremiseId: candidate.sourcePremiseId,\n candidatePremiseId: candidate.candidatePremiseId,\n candidateIntentId: candidate.candidateIntentId,\n sourceContextId: candidate.sourceContextId,\n payload: candidate.candidatePayload,\n summary: candidate.candidateSummary,\n assertionText: candidate.candidatePremiseId ? candidate.candidatePayload : undefined,\n };\n}\n\nexport function withCandidateEvidence<T extends EvidenceCandidateInput>(candidate: T): T & { evidence: OpportunityEvidence[] } {\n return { ...candidate, evidence: [buildCandidateEvidence(candidate)] };\n}\n\nexport function mergeOpportunityEvidence(...groups: Array<OpportunityEvidence[] | undefined>): OpportunityEvidence[] {\n const byKey = new Map<string, OpportunityEvidence>();\n for (const evidence of groups.flatMap((group) => group ?? [])) {\n const key = [\n evidence.kind,\n evidence.networkId,\n evidence.sourcePremiseId ?? '',\n evidence.candidatePremiseId ?? '',\n evidence.candidateIntentId ?? '',\n evidence.sourceContextId ?? '',\n evidence.lens ?? '',\n ].join('|');\n const existing = byKey.get(key);\n if (!existing || (evidence.score ?? 0) > (existing.score ?? 0)) byKey.set(key, evidence);\n }\n return Array.from(byKey.values());\n}\n\nexport function withMatchedStrategies(evidence: OpportunityEvidence[], strategies: string[]): OpportunityEvidence[] {\n return evidence.map((item) => ({\n ...item,\n matchedStrategies: Array.from(new Set([...(item.matchedStrategies ?? []), ...strategies])),\n }));\n}\n\nexport function renderOpportunityEvidenceForPrompt(evidence: OpportunityEvidence[]): string {\n if (evidence.length === 0) return ' —';\n return evidence.map((item) => {\n const refs = [\n item.sourcePremiseId ? `sourcePremise=${item.sourcePremiseId}` : undefined,\n item.candidatePremiseId ? `candidatePremise=${item.candidatePremiseId}` : undefined,\n item.candidateIntentId ? `candidateIntent=${item.candidateIntentId}` : undefined,\n item.sourceContextId ? `sourceContext=${item.sourceContextId}` : undefined,\n item.matchedStrategies?.length ? `strategies=${item.matchedStrategies.join(',')}` : undefined,\n ].filter(Boolean).join(', ');\n const text = item.summary ?? item.payload ?? item.assertionText ?? '';\n // IND-567 Fix B: when a query_premise entry has no text, warn the evaluator\n // so it does not treat a high RAG score as domain confirmation.\n // (text should be populated by Fix A; this fallback fires if the DB fetch\n // failed or the adapter omitted getPremise).\n const domainCaution =\n item.kind === 'query_premise' && !text\n ? ' [premise text unavailable — do NOT infer domain match from RAG score alone; verify domain alignment from profile]'\n : '';\n return ` - ${item.kind} on ${item.networkId} via ${item.lens ?? 'unknown'} score=${item.score?.toFixed(3) ?? '—'}${refs ? ` (${refs})` : ''}${text ? `: ${text}` : ''}${domainCaution}`;\n }).join('\\n');\n}\n\nfunction resolveEvidenceKind(candidate: EvidenceCandidateInput): OpportunityEvidence['kind'] {\n if (candidate.discoverySource === 'premise-similarity') return 'premise_similarity';\n if (candidate.discoverySource === 'context-to-intent') return 'context_to_intent';\n if (candidate.candidatePremiseId) return 'query_premise';\n if (candidate.candidateIntentId) return 'query_intent';\n return 'profile';\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opportunity.graph.d.ts","sourceRoot":"/","sources":["opportunity/opportunity.graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAyB,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExO,OAAO,EAAwB,KAAK,gBA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