@indexnetwork/protocol 4.5.0-rc.332.1 → 4.5.0-rc.334.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.
Files changed (54) hide show
  1. package/dist/chat/chat-streaming.types.d.ts +1 -1
  2. package/dist/chat/chat-streaming.types.d.ts.map +1 -1
  3. package/dist/chat/chat-streaming.types.js.map +1 -1
  4. package/dist/chat/chat.agent.d.ts +1 -1
  5. package/dist/chat/chat.agent.d.ts.map +1 -1
  6. package/dist/chat/chat.agent.js.map +1 -1
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +4 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/negotiation/negotiation.agent.d.ts +21 -0
  12. package/dist/negotiation/negotiation.agent.d.ts.map +1 -1
  13. package/dist/negotiation/negotiation.agent.js +79 -11
  14. package/dist/negotiation/negotiation.agent.js.map +1 -1
  15. package/dist/negotiation/negotiation.graph.d.ts +56 -26
  16. package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
  17. package/dist/negotiation/negotiation.graph.js +174 -19
  18. package/dist/negotiation/negotiation.graph.js.map +1 -1
  19. package/dist/negotiation/negotiation.protocol.d.ts +287 -0
  20. package/dist/negotiation/negotiation.protocol.d.ts.map +1 -0
  21. package/dist/negotiation/negotiation.protocol.js +152 -0
  22. package/dist/negotiation/negotiation.protocol.js.map +1 -0
  23. package/dist/negotiation/negotiation.screen.d.ts +128 -0
  24. package/dist/negotiation/negotiation.screen.d.ts.map +1 -0
  25. package/dist/negotiation/negotiation.screen.js +131 -0
  26. package/dist/negotiation/negotiation.screen.js.map +1 -0
  27. package/dist/negotiation/negotiation.state.d.ts +28 -9
  28. package/dist/negotiation/negotiation.state.d.ts.map +1 -1
  29. package/dist/negotiation/negotiation.state.js +28 -4
  30. package/dist/negotiation/negotiation.state.js.map +1 -1
  31. package/dist/negotiation/negotiation.tools.d.ts.map +1 -1
  32. package/dist/negotiation/negotiation.tools.js +86 -31
  33. package/dist/negotiation/negotiation.tools.js.map +1 -1
  34. package/dist/opportunity/question.prompt.d.ts +1 -1
  35. package/dist/opportunity/question.prompt.d.ts.map +1 -1
  36. package/dist/opportunity/question.prompt.js.map +1 -1
  37. package/dist/shared/agent/model.config.d.ts +5 -0
  38. package/dist/shared/agent/model.config.d.ts.map +1 -1
  39. package/dist/shared/agent/model.config.js +1 -0
  40. package/dist/shared/agent/model.config.js.map +1 -1
  41. package/dist/shared/interfaces/agent-dispatcher.interface.d.ts +6 -0
  42. package/dist/shared/interfaces/agent-dispatcher.interface.d.ts.map +1 -1
  43. package/dist/shared/interfaces/agent-dispatcher.interface.js.map +1 -1
  44. package/dist/shared/interfaces/database.interface.d.ts +9 -0
  45. package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
  46. package/dist/shared/interfaces/database.interface.js.map +1 -1
  47. package/dist/shared/schemas/discovery-question.schema.d.ts +8 -8
  48. package/dist/shared/schemas/discovery-question.schema.js +1 -1
  49. package/dist/shared/schemas/discovery-question.schema.js.map +1 -1
  50. package/dist/shared/schemas/negotiation-state.schema.d.ts +19 -3
  51. package/dist/shared/schemas/negotiation-state.schema.d.ts.map +1 -1
  52. package/dist/shared/schemas/negotiation-state.schema.js +15 -1
  53. package/dist/shared/schemas/negotiation-state.schema.js.map +1 -1
  54. package/package.json +1 -1
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Seat-scoped negotiation protocol rules (v2 client-advocate protocol).
3
+ *
4
+ * v2 fixes exactly one initiating seat per match (`metadata.initiatorUserId`,
5
+ * stamped at discovery time — IND-396) and makes consent asymmetric:
6
+ * **accept can only come from the counterparty seat**, schema-enforced.
7
+ *
8
+ * Vocabulary per seat (v2):
9
+ * - initiator: `outreach | counter | question | withdraw` (no accept)
10
+ * - counterparty: `accept | decline | counter | question`
11
+ * - final turn: initiator `withdraw | counter`; counterparty `accept | decline`
12
+ *
13
+ * v1 tasks keep the legacy vocabulary (`propose | accept | reject | counter |
14
+ * question`) — the version is inherited per conversation, never re-stamped, so
15
+ * in-flight v1 negotiations are grandfathered untouched.
16
+ *
17
+ * Outcome mapping is version-independent: `accept` → opportunity `pending`,
18
+ * `reject`/`withdraw`/`decline` → `rejected`, turn-cap → `stalled`.
19
+ */
20
+ import { z } from "zod";
21
+ // ─── Shared assessment fragment ──────────────────────────────────────────────
22
+ const AssessmentSchema = z.object({
23
+ reasoning: z.string(),
24
+ suggestedRoles: z.object({
25
+ ownUser: z.enum(["agent", "patient", "peer"]),
26
+ otherUser: z.enum(["agent", "patient", "peer"]),
27
+ }),
28
+ });
29
+ function turnSchema(actions) {
30
+ return z.object({
31
+ action: z.enum(actions),
32
+ assessment: AssessmentSchema,
33
+ message: z.string().nullable().optional(),
34
+ });
35
+ }
36
+ // ─── v2 seat-scoped turn schemas ─────────────────────────────────────────────
37
+ /** Initiator seat, non-final turn: may reach out, push back, ask, or walk away — never accept. */
38
+ export const InitiatorTurnSchema = turnSchema(["outreach", "counter", "question", "withdraw"]);
39
+ /** Counterparty seat, non-final turn: the only seat that can accept. */
40
+ export const CounterpartyTurnSchema = turnSchema(["accept", "decline", "counter", "question"]);
41
+ /** Initiator seat, final allowed turn: commit to walking away or leave the door open. */
42
+ export const FinalInitiatorTurnSchema = turnSchema(["withdraw", "counter"]);
43
+ /** Counterparty seat, final allowed turn: must decide. */
44
+ export const FinalCounterpartyTurnSchema = turnSchema(["accept", "decline"]);
45
+ // ─── Action vocabulary per version + seat ────────────────────────────────────
46
+ const V1_ACTIONS = ["propose", "accept", "reject", "counter", "question"];
47
+ const V1_FINAL_ACTIONS = ["accept", "reject"];
48
+ const V2_INITIATOR_ACTIONS = ["outreach", "counter", "question", "withdraw"];
49
+ const V2_COUNTERPARTY_ACTIONS = ["accept", "decline", "counter", "question"];
50
+ const V2_FINAL_INITIATOR_ACTIONS = ["withdraw", "counter"];
51
+ const V2_FINAL_COUNTERPARTY_ACTIONS = ["accept", "decline"];
52
+ /**
53
+ * The set of actions a given seat may submit under a given protocol version.
54
+ *
55
+ * v1 ignores the seat entirely (legacy symmetric vocabulary) so pre-v2
56
+ * negotiations behave exactly as before.
57
+ */
58
+ export function allowedActionsFor(version, seat, isFinalTurn = false) {
59
+ if (version !== "v2")
60
+ return isFinalTurn ? V1_FINAL_ACTIONS : V1_ACTIONS;
61
+ if (seat === "initiator")
62
+ return isFinalTurn ? V2_FINAL_INITIATOR_ACTIONS : V2_INITIATOR_ACTIONS;
63
+ return isFinalTurn ? V2_FINAL_COUNTERPARTY_ACTIONS : V2_COUNTERPARTY_ACTIONS;
64
+ }
65
+ /**
66
+ * Zod turn schema for a system-agent turn, selected by version + seat +
67
+ * final-turn flag. v1 returns the legacy schemas (seat-agnostic); v2 returns
68
+ * the seat-scoped schemas above, making an initiator `accept` structurally
69
+ * impossible rather than prompt-discouraged.
70
+ *
71
+ * The v1 legacy schemas are passed in by the caller (they live in
72
+ * `negotiation.state.ts`) to keep this module free of a state-module import.
73
+ */
74
+ export function turnSchemaFor(version, seat, isFinalTurn, v1Schemas) {
75
+ if (version !== "v2")
76
+ return isFinalTurn ? v1Schemas.final : v1Schemas.system;
77
+ if (seat === "initiator")
78
+ return isFinalTurn ? FinalInitiatorTurnSchema : InitiatorTurnSchema;
79
+ return isFinalTurn ? FinalCounterpartyTurnSchema : CounterpartyTurnSchema;
80
+ }
81
+ // ─── Action semantics (version-independent) ──────────────────────────────────
82
+ /** Terminal actions end the negotiation immediately. */
83
+ export function isTerminalAction(action) {
84
+ return action === "accept" || action === "reject" || action === "withdraw" || action === "decline";
85
+ }
86
+ /** Reject-like actions map the opportunity to `rejected` (v1 reject, v2 withdraw/decline). */
87
+ export function isRejectLikeAction(action) {
88
+ return action === "reject" || action === "withdraw" || action === "decline";
89
+ }
90
+ /**
91
+ * Conservative action when an agent produced schema-invalid output (after the
92
+ * retry) or an internal error needs a seat-valid terminal placeholder.
93
+ *
94
+ * Non-final turns fall back to `counter` (keeps the dialogue open — the AC's
95
+ * "conservative counter"). Final turns must decide: v1 → `reject`, v2
96
+ * counterparty → `decline`, v2 initiator → `counter` is still legal on the
97
+ * final turn so it stays `counter` (finalizes as turn-cap/stalled).
98
+ */
99
+ export function fallbackActionFor(version, seat, isFinalTurn) {
100
+ if (!isFinalTurn)
101
+ return "counter";
102
+ if (version !== "v2")
103
+ return "reject";
104
+ return seat === "counterparty" ? "decline" : "counter";
105
+ }
106
+ /** Seat-appropriate reject-like action for error paths. */
107
+ export function rejectActionFor(version, seat) {
108
+ if (version !== "v2")
109
+ return "reject";
110
+ return seat === "initiator" ? "withdraw" : "decline";
111
+ }
112
+ // ─── Metadata readers ────────────────────────────────────────────────────────
113
+ /**
114
+ * Read the protocol version off task metadata. Returns null when the task
115
+ * predates version stamping (treat as v1 at the call site when the task is a
116
+ * genuine prior; fresh tasks stamp from {@link configuredProtocolVersion}).
117
+ */
118
+ export function readProtocolVersion(metadata) {
119
+ const v = metadata?.protocolVersion;
120
+ return v === "v2" ? "v2" : v === "v1" ? "v1" : null;
121
+ }
122
+ /**
123
+ * Protocol version for genuinely fresh negotiations, from the
124
+ * `NEGOTIATION_PROTOCOL_VERSION` env switch. Defaults to `v1` when unset —
125
+ * v2 is opt-in per environment, and rolling back is the same single switch.
126
+ */
127
+ export function configuredProtocolVersion() {
128
+ return process.env.NEGOTIATION_PROTOCOL_VERSION === "v2" ? "v2" : "v1";
129
+ }
130
+ /**
131
+ * Resolve the seat of `userId` on a negotiation task.
132
+ *
133
+ * Keys on `metadata.initiatorUserId` (the rigid v2 stamp), **never on turn
134
+ * parity** — continuations can start with either side speaking first, so
135
+ * parity misattributes seats across sessions. Pre-stamp tasks fall back to
136
+ * `sourceUserId` (the discovery-session opener), which is what the stamp
137
+ * defaults to anyway.
138
+ */
139
+ export function resolveSeat(userId, metadata) {
140
+ const initiator = typeof metadata?.initiatorUserId === "string" && metadata.initiatorUserId.length > 0
141
+ ? metadata.initiatorUserId
142
+ : typeof metadata?.sourceUserId === "string"
143
+ ? metadata.sourceUserId
144
+ : undefined;
145
+ return initiator === userId ? "initiator" : "counterparty";
146
+ }
147
+ /** Human-readable seat-violation message shared by respond surfaces. */
148
+ export function seatViolationMessage(action, seat, version) {
149
+ const allowed = allowedActionsFor(version, seat).join(", ");
150
+ return `Action "${action}" is not allowed for your seat (${seat}) under negotiation protocol ${version}. Allowed actions: ${allowed}.`;
151
+ }
152
+ //# sourceMappingURL=negotiation.protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negotiation.protocol.js","sourceRoot":"/","sources":["negotiation/negotiation.protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,gFAAgF;AAEhF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC;QACvB,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC7C,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;KAChD,CAAC;CACH,CAAC,CAAC;AAEH,SAAS,UAAU,CAAwD,OAAU;IACnF,OAAO,CAAC,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QACvB,UAAU,EAAE,gBAAgB;QAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;KAC1C,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAEhF,kGAAkG;AAClG,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAE/F,wEAAwE;AACxE,MAAM,CAA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one initiating seat per match (`metadata.initiatorUserId`,\n * stamped at discovery time — IND-396) and makes consent asymmetric:\n * **accept can only come from the counterparty seat**, schema-enforced.\n *\n * Vocabulary per seat (v2):\n * - initiator: `outreach | counter | question | withdraw` (no accept)\n * - counterparty: `accept | decline | counter | question`\n * - final turn: initiator `withdraw | counter`; counterparty `accept | decline`\n *\n * v1 tasks keep the legacy vocabulary (`propose | accept | reject | counter |\n * question`) — the version is inherited per conversation, never re-stamped, so\n * in-flight v1 negotiations are grandfathered untouched.\n *\n * Outcome mapping is version-independent: `accept` → opportunity `pending`,\n * `reject`/`withdraw`/`decline` → `rejected`, turn-cap → `stalled`.\n */\nimport { z } from \"zod\";\n\nimport type { NegotiationAction, NegotiationSeat, NegotiationProtocolVersion } from \"../shared/schemas/negotiation-state.schema.js\";\n\n// ─── Shared assessment fragment ──────────────────────────────────────────────\n\nconst AssessmentSchema = 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\nfunction turnSchema<T extends [NegotiationAction, ...NegotiationAction[]]>(actions: T) {\n return z.object({\n action: z.enum(actions),\n assessment: AssessmentSchema,\n message: z.string().nullable().optional(),\n });\n}\n\n// ─── v2 seat-scoped turn schemas ─────────────────────────────────────────────\n\n/** Initiator seat, non-final turn: may reach out, push back, ask, or walk away — never accept. */\nexport const InitiatorTurnSchema = turnSchema([\"outreach\", \"counter\", \"question\", \"withdraw\"]);\n\n/** Counterparty seat, non-final turn: the only seat that can accept. */\nexport const CounterpartyTurnSchema = turnSchema([\"accept\", \"decline\", \"counter\", \"question\"]);\n\n/** Initiator seat, final allowed turn: commit to walking away or leave the door open. */\nexport const FinalInitiatorTurnSchema = turnSchema([\"withdraw\", \"counter\"]);\n\n/** Counterparty seat, final allowed turn: must decide. */\nexport const FinalCounterpartyTurnSchema = turnSchema([\"accept\", \"decline\"]);\n\n// ─── Action vocabulary per version + seat ────────────────────────────────────\n\nconst V1_ACTIONS: readonly NegotiationAction[] = [\"propose\", \"accept\", \"reject\", \"counter\", \"question\"];\nconst V1_FINAL_ACTIONS: readonly NegotiationAction[] = [\"accept\", \"reject\"];\nconst V2_INITIATOR_ACTIONS: readonly NegotiationAction[] = [\"outreach\", \"counter\", \"question\", \"withdraw\"];\nconst V2_COUNTERPARTY_ACTIONS: readonly NegotiationAction[] = [\"accept\", \"decline\", \"counter\", \"question\"];\nconst V2_FINAL_INITIATOR_ACTIONS: readonly NegotiationAction[] = [\"withdraw\", \"counter\"];\nconst V2_FINAL_COUNTERPARTY_ACTIONS: readonly NegotiationAction[] = [\"accept\", \"decline\"];\n\n/**\n * The set of actions a given seat may submit under a given protocol version.\n *\n * v1 ignores the seat entirely (legacy symmetric vocabulary) so pre-v2\n * negotiations behave exactly as before.\n */\nexport function allowedActionsFor(\n version: NegotiationProtocolVersion,\n seat: NegotiationSeat,\n isFinalTurn = false,\n): readonly NegotiationAction[] {\n if (version !== \"v2\") return isFinalTurn ? V1_FINAL_ACTIONS : V1_ACTIONS;\n if (seat === \"initiator\") return isFinalTurn ? V2_FINAL_INITIATOR_ACTIONS : V2_INITIATOR_ACTIONS;\n return isFinalTurn ? V2_FINAL_COUNTERPARTY_ACTIONS : V2_COUNTERPARTY_ACTIONS;\n}\n\n/**\n * Zod turn schema for a system-agent turn, selected by version + seat +\n * final-turn flag. v1 returns the legacy schemas (seat-agnostic); v2 returns\n * the seat-scoped schemas above, making an initiator `accept` structurally\n * impossible rather than prompt-discouraged.\n *\n * The v1 legacy schemas are passed in by the caller (they live in\n * `negotiation.state.ts`) to keep this module free of a state-module import.\n */\nexport function turnSchemaFor(\n version: NegotiationProtocolVersion,\n seat: NegotiationSeat,\n isFinalTurn: boolean,\n v1Schemas: { system: z.ZodTypeAny; final: z.ZodTypeAny },\n): z.ZodTypeAny {\n if (version !== \"v2\") return isFinalTurn ? v1Schemas.final : v1Schemas.system;\n if (seat === \"initiator\") return isFinalTurn ? FinalInitiatorTurnSchema : InitiatorTurnSchema;\n return isFinalTurn ? FinalCounterpartyTurnSchema : CounterpartyTurnSchema;\n}\n\n// ─── Action semantics (version-independent) ──────────────────────────────────\n\n/** Terminal actions end the negotiation immediately. */\nexport function isTerminalAction(action: string | undefined | null): boolean {\n return action === \"accept\" || action === \"reject\" || action === \"withdraw\" || action === \"decline\";\n}\n\n/** Reject-like actions map the opportunity to `rejected` (v1 reject, v2 withdraw/decline). */\nexport function isRejectLikeAction(action: string | undefined | null): boolean {\n return action === \"reject\" || action === \"withdraw\" || action === \"decline\";\n}\n\n/**\n * Conservative action when an agent produced schema-invalid output (after the\n * retry) or an internal error needs a seat-valid terminal placeholder.\n *\n * Non-final turns fall back to `counter` (keeps the dialogue open — the AC's\n * \"conservative counter\"). Final turns must decide: v1 → `reject`, v2\n * counterparty → `decline`, v2 initiator → `counter` is still legal on the\n * final turn so it stays `counter` (finalizes as turn-cap/stalled).\n */\nexport function fallbackActionFor(\n version: NegotiationProtocolVersion,\n seat: NegotiationSeat,\n isFinalTurn: boolean,\n): NegotiationAction {\n if (!isFinalTurn) return \"counter\";\n if (version !== \"v2\") return \"reject\";\n return seat === \"counterparty\" ? \"decline\" : \"counter\";\n}\n\n/** Seat-appropriate reject-like action for error paths. */\nexport function rejectActionFor(\n version: NegotiationProtocolVersion,\n seat: NegotiationSeat,\n): NegotiationAction {\n if (version !== \"v2\") return \"reject\";\n return seat === \"initiator\" ? \"withdraw\" : \"decline\";\n}\n\n// ─── Metadata readers ────────────────────────────────────────────────────────\n\n/**\n * Read the protocol version off task metadata. Returns null when the task\n * predates version stamping (treat as v1 at the call site when the task is a\n * genuine prior; fresh tasks stamp from {@link configuredProtocolVersion}).\n */\nexport function readProtocolVersion(\n metadata: { protocolVersion?: unknown } | null | undefined,\n): NegotiationProtocolVersion | null {\n const v = metadata?.protocolVersion;\n return v === \"v2\" ? \"v2\" : v === \"v1\" ? \"v1\" : null;\n}\n\n/**\n * Protocol version for genuinely fresh negotiations, from the\n * `NEGOTIATION_PROTOCOL_VERSION` env switch. Defaults to `v1` when unset —\n * v2 is opt-in per environment, and rolling back is the same single switch.\n */\nexport function configuredProtocolVersion(): NegotiationProtocolVersion {\n return process.env.NEGOTIATION_PROTOCOL_VERSION === \"v2\" ? \"v2\" : \"v1\";\n}\n\n/**\n * Resolve the seat of `userId` on a negotiation task.\n *\n * Keys on `metadata.initiatorUserId` (the rigid v2 stamp), **never on turn\n * parity** — continuations can start with either side speaking first, so\n * parity misattributes seats across sessions. Pre-stamp tasks fall back to\n * `sourceUserId` (the discovery-session opener), which is what the stamp\n * defaults to anyway.\n */\nexport function resolveSeat(\n userId: string,\n metadata: { initiatorUserId?: unknown; sourceUserId?: unknown } | null | undefined,\n): NegotiationSeat {\n const initiator =\n typeof metadata?.initiatorUserId === \"string\" && metadata.initiatorUserId.length > 0\n ? metadata.initiatorUserId\n : typeof metadata?.sourceUserId === \"string\"\n ? metadata.sourceUserId\n : undefined;\n return initiator === userId ? \"initiator\" : \"counterparty\";\n}\n\n/** Human-readable seat-violation message shared by respond surfaces. */\nexport function seatViolationMessage(\n action: string,\n seat: NegotiationSeat,\n version: NegotiationProtocolVersion,\n): string {\n const allowed = allowedActionsFor(version, seat).join(\", \");\n return `Action \"${action}\" is not allowed for your seat (${seat}) under negotiation protocol ${version}. Allowed actions: ${allowed}.`;\n}\n"]}
@@ -0,0 +1,128 @@
1
+ import { z } from "zod";
2
+ import { createStructuredModel } from "../shared/agent/model.config.js";
3
+ import type { UserNegotiationContext, SeedAssessment } from "../shared/schemas/negotiation-state.schema.js";
4
+ /**
5
+ * Screen-gate modes (P2.1 — client-advocate protocol).
6
+ *
7
+ * - `off` — the screen node is skipped entirely; no LLM call, no telemetry.
8
+ * - `shadow` — the screen decision is made and recorded (task metadata +
9
+ * trace event + log line) but NEVER blocks: every fresh negotiation still
10
+ * proceeds to the first turn. Used to measure pass rates against observed
11
+ * reject rates before enforcement.
12
+ * - `enforce` — reserved for P2.2. Until enforcement lands, `enforce` runs
13
+ * identically to `shadow` (decision recorded, negotiation proceeds) and the
14
+ * screen node logs a warning that enforcement is not yet implemented.
15
+ */
16
+ export declare const NEGOTIATION_SCREEN_MODES: readonly ["off", "shadow", "enforce"];
17
+ export type NegotiationScreenMode = (typeof NEGOTIATION_SCREEN_MODES)[number];
18
+ /**
19
+ * Resolve the screen mode from `NEGOTIATION_SCREEN_MODE`.
20
+ *
21
+ * Defaults to `off` when unset or unrecognized — the screen gate is an
22
+ * explicit opt-in flip (same operational pattern as
23
+ * `NEGOTIATION_PROTOCOL_VERSION` / `NEGOTIATOR_CHAT_ENABLED`): code ships
24
+ * inert, the environment turns it on.
25
+ */
26
+ export declare function configuredScreenMode(): NegotiationScreenMode;
27
+ /**
28
+ * Structured screen decision — the outreach gate's verdict on whether this
29
+ * match is worth the client's name before any turn is exchanged.
30
+ */
31
+ export declare const ScreenDecisionSchema: z.ZodObject<{
32
+ decision: z.ZodEnum<["reach_out", "pass"]>;
33
+ reasoning: z.ZodString;
34
+ /** Suggested opening angle for the outreach turn (only when reaching out). */
35
+ outreachAngle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ evidence: z.ZodObject<{
37
+ /** How well the counterparty's context/premises fit the client's need. */
38
+ counterpartyPremiseFit: z.ZodString;
39
+ /** How the client's intents align with what the counterparty seeks. */
40
+ intentAlignment: z.ZodString;
41
+ /** Prior-negotiation memory signals. Wired in P5.3 — always absent today. */
42
+ memoryHints: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ counterpartyPremiseFit: string;
45
+ intentAlignment: string;
46
+ memoryHints?: string | null | undefined;
47
+ }, {
48
+ counterpartyPremiseFit: string;
49
+ intentAlignment: string;
50
+ memoryHints?: string | null | undefined;
51
+ }>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ reasoning: string;
54
+ decision: "reach_out" | "pass";
55
+ evidence: {
56
+ counterpartyPremiseFit: string;
57
+ intentAlignment: string;
58
+ memoryHints?: string | null | undefined;
59
+ };
60
+ outreachAngle?: string | null | undefined;
61
+ }, {
62
+ reasoning: string;
63
+ decision: "reach_out" | "pass";
64
+ evidence: {
65
+ counterpartyPremiseFit: string;
66
+ intentAlignment: string;
67
+ memoryHints?: string | null | undefined;
68
+ };
69
+ outreachAngle?: string | null | undefined;
70
+ }>;
71
+ export type ScreenDecision = z.infer<typeof ScreenDecisionSchema>;
72
+ /**
73
+ * The record persisted to `tasks.metadata.screenDecision` and returned into
74
+ * graph state. Extends the LLM decision with operational context so pass-rate
75
+ * queries can group by mode and exclude failed-open rows.
76
+ */
77
+ export interface ScreenDecisionRecord extends ScreenDecision {
78
+ mode: NegotiationScreenMode;
79
+ /** True when the screen LLM call failed and the gate defaulted open. */
80
+ failedOpen?: boolean;
81
+ /** Error message when `failedOpen` is set. */
82
+ error?: string;
83
+ screenedAt: string;
84
+ durationMs: number;
85
+ }
86
+ export interface NegotiationScreenerInput {
87
+ /** The client — the user whose negotiator is deciding whether to reach out. */
88
+ clientUser: UserNegotiationContext;
89
+ /** The counterparty the client's negotiator would be reaching out to. */
90
+ counterpartyUser: UserNegotiationContext;
91
+ /** The counterparty's `user_contexts` paragraph (empty string when absent). */
92
+ counterpartyContext?: string;
93
+ /** The explicit search query that triggered discovery (if any). */
94
+ discoveryQuery?: string;
95
+ seedAssessment: Omit<SeedAssessment, "actors">;
96
+ indexContext: {
97
+ networkId: string;
98
+ prompt?: string;
99
+ };
100
+ }
101
+ export interface NegotiationScreenerConfig {
102
+ /** Hard ceiling on the screen LLM round-trip, in ms (default 15000). */
103
+ timeoutMs?: number;
104
+ }
105
+ /**
106
+ * The outreach gate (P2.1). One structured LLM call deciding
107
+ * `reach_out | pass` for a fresh negotiation, from the reaching client's
108
+ * perspective. Throws on LLM/validation failure — the screen graph node owns
109
+ * the fail-open policy (a failed screen never blocks the negotiation).
110
+ */
111
+ export declare class NegotiationScreener {
112
+ private readonly timeoutMs;
113
+ constructor(config?: NegotiationScreenerConfig);
114
+ /**
115
+ * Produce a screen decision for a fresh match.
116
+ * @throws When the LLM call times out or returns schema-invalid output.
117
+ */
118
+ invoke(input: NegotiationScreenerInput): Promise<ScreenDecision>;
119
+ /**
120
+ * Raw structured-model round trip. Split out as a seam so tests can drive
121
+ * the schema-validation and fail-open paths without a live provider.
122
+ */
123
+ protected callModel(model: ReturnType<typeof createStructuredModel>, chatMessages: Array<{
124
+ role: string;
125
+ content: string;
126
+ }>): Promise<unknown>;
127
+ }
128
+ //# sourceMappingURL=negotiation.screen.d.ts.map
@@ -0,0 +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;AAK5G;;;;;;;;;;;GAWG;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,6EAA6E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG/E,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,IAAI,EAAE,qBAAqB,CAAC;IAC5B,wEAAwE;IACxE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,+EAA+E;IAC/E,UAAU,EAAE,sBAAsB,CAAC;IACnC,yEAAyE;IACzE,gBAAgB,EAAE,sBAAsB,CAAC;IACzC,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC/C,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD;AAqBD,MAAM,WAAW,yBAAyB;IACxC,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,MAAM,CAAC,EAAE,yBAAyB;IAM9C;;;OAGG;IACG,MAAM,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC;IAgDtE;;;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"}
@@ -0,0 +1,131 @@
1
+ import { z } from "zod";
2
+ import { createStructuredModel } from "../shared/agent/model.config.js";
3
+ import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
4
+ import { protocolLogger } from "../shared/observability/protocol.logger.js";
5
+ const screenLog = protocolLogger("NegotiationScreener");
6
+ /**
7
+ * Screen-gate modes (P2.1 — client-advocate protocol).
8
+ *
9
+ * - `off` — the screen node is skipped entirely; no LLM call, no telemetry.
10
+ * - `shadow` — the screen decision is made and recorded (task metadata +
11
+ * trace event + log line) but NEVER blocks: every fresh negotiation still
12
+ * proceeds to the first turn. Used to measure pass rates against observed
13
+ * reject rates before enforcement.
14
+ * - `enforce` — reserved for P2.2. Until enforcement lands, `enforce` runs
15
+ * identically to `shadow` (decision recorded, negotiation proceeds) and the
16
+ * screen node logs a warning that enforcement is not yet implemented.
17
+ */
18
+ export const NEGOTIATION_SCREEN_MODES = ["off", "shadow", "enforce"];
19
+ /**
20
+ * Resolve the screen mode from `NEGOTIATION_SCREEN_MODE`.
21
+ *
22
+ * Defaults to `off` when unset or unrecognized — the screen gate is an
23
+ * explicit opt-in flip (same operational pattern as
24
+ * `NEGOTIATION_PROTOCOL_VERSION` / `NEGOTIATOR_CHAT_ENABLED`): code ships
25
+ * inert, the environment turns it on.
26
+ */
27
+ export function configuredScreenMode() {
28
+ const raw = process.env.NEGOTIATION_SCREEN_MODE;
29
+ if (raw === "shadow" || raw === "enforce" || raw === "off")
30
+ return raw;
31
+ return "off";
32
+ }
33
+ /**
34
+ * Structured screen decision — the outreach gate's verdict on whether this
35
+ * match is worth the client's name before any turn is exchanged.
36
+ */
37
+ export const ScreenDecisionSchema = z.object({
38
+ decision: z.enum(["reach_out", "pass"]),
39
+ reasoning: z.string(),
40
+ /** Suggested opening angle for the outreach turn (only when reaching out). */
41
+ outreachAngle: z.string().nullable().optional(),
42
+ evidence: z.object({
43
+ /** How well the counterparty's context/premises fit the client's need. */
44
+ counterpartyPremiseFit: z.string(),
45
+ /** How the client's intents align with what the counterparty seeks. */
46
+ intentAlignment: z.string(),
47
+ /** Prior-negotiation memory signals. Wired in P5.3 — always absent today. */
48
+ memoryHints: z.string().nullable().optional(),
49
+ }),
50
+ });
51
+ const 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.
52
+
53
+ Network context: {networkContext}
54
+
55
+ Decide:
56
+ - "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.
57
+ - "pass" when the match is generic, one-sided, or rests on vague overlap that would waste both parties' attention.
58
+
59
+ Rules:
60
+ {queryRule}
61
+ - Judge concrete intent alignment, not topical adjacency.
62
+ - 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.
63
+ - Do NOT reference internal system details like scores, pre-screens, or evaluator outputs in reasoning that could be shown to users.`;
64
+ const 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.`;
65
+ const NO_QUERY_RULE = `- No explicit search query: judge against {clientName}'s active intents.`;
66
+ const DEFAULT_SCREEN_TIMEOUT_MS = 15000;
67
+ /**
68
+ * The outreach gate (P2.1). One structured LLM call deciding
69
+ * `reach_out | pass` for a fresh negotiation, from the reaching client's
70
+ * perspective. Throws on LLM/validation failure — the screen graph node owns
71
+ * the fail-open policy (a failed screen never blocks the negotiation).
72
+ */
73
+ export class NegotiationScreener {
74
+ constructor(config) {
75
+ this.timeoutMs = config?.timeoutMs && Number.isFinite(config.timeoutMs) && config.timeoutMs > 0
76
+ ? config.timeoutMs
77
+ : DEFAULT_SCREEN_TIMEOUT_MS;
78
+ }
79
+ /**
80
+ * Produce a screen decision for a fresh match.
81
+ * @throws When the LLM call times out or returns schema-invalid output.
82
+ */
83
+ async invoke(input) {
84
+ const model = createStructuredModel("negotiationScreener", ScreenDecisionSchema, { name: "negotiation_screener" });
85
+ const clientName = input.clientUser.profile.name ?? "your client";
86
+ const counterpartyName = input.counterpartyUser.profile.name ?? "the counterparty";
87
+ const networkContext = input.indexContext.prompt || "General discovery";
88
+ const queryRule = (input.discoveryQuery ? QUERY_RULE : NO_QUERY_RULE)
89
+ .replace(/{clientName}/g, clientName)
90
+ .replace(/{discoveryQuery}/g, input.discoveryQuery ?? "");
91
+ const systemPrompt = SYSTEM_PROMPT
92
+ .replace(/{clientName}/g, clientName)
93
+ .replace("{networkContext}", networkContext)
94
+ .replace("{queryRule}", queryRule);
95
+ const formatIntents = (intents) => intents.length > 0 ? intents.map((i) => `- ${i.title}: ${i.description}`).join("\n") : "- (none)";
96
+ const userMessage = `YOUR CLIENT (${clientName}):
97
+ Bio: ${input.clientUser.profile.bio ?? "N/A"}
98
+ ${input.discoveryQuery ? `Search query: "${input.discoveryQuery}"\nBackground intents (secondary to the query):` : "Active intents:"}
99
+ ${formatIntents(input.clientUser.intents)}
100
+
101
+ COUNTERPARTY (${counterpartyName}):
102
+ Bio: ${input.counterpartyUser.profile.bio ?? "N/A"}
103
+ ${input.counterpartyContext ? `Context: ${input.counterpartyContext}\n` : ""}Active intents:
104
+ ${formatIntents(input.counterpartyUser.intents)}
105
+
106
+ Why this match was suggested: ${input.seedAssessment.reasoning}
107
+
108
+ Decide whether reaching out serves ${clientName}.`;
109
+ const chatMessages = [
110
+ { role: "system", content: systemPrompt },
111
+ { role: "user", content: userMessage },
112
+ ];
113
+ const result = await this.callModel(model, chatMessages);
114
+ const parsed = ScreenDecisionSchema.safeParse(result);
115
+ if (!parsed.success) {
116
+ screenLog.warn("Screen output failed schema validation", {
117
+ issues: parsed.error.issues.map((i) => i.message).slice(0, 3),
118
+ });
119
+ throw new Error(`Screen decision failed validation: ${parsed.error.issues[0]?.message ?? "unknown"}`);
120
+ }
121
+ return parsed.data;
122
+ }
123
+ /**
124
+ * Raw structured-model round trip. Split out as a seam so tests can drive
125
+ * the schema-validation and fail-open paths without a live provider.
126
+ */
127
+ async callModel(model, chatMessages) {
128
+ return invokeWithAbortSignal(model, chatMessages, AbortSignal.timeout(this.timeoutMs));
129
+ }
130
+ }
131
+ //# sourceMappingURL=negotiation.screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neg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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\";\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` — reserved for P2.2. Until enforcement lands, `enforce` runs\n * identically to `shadow` (decision recorded, negotiation proceeds) and the\n * screen node logs a warning that enforcement is not yet implemented.\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. Wired in P5.3 — always absent today. */\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\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.`;\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\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,8 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import type { NegotiationUserAnswer } from "../shared/interfaces/database.interface.js";
3
- /** Zod schema for a single negotiation turn (DataPart payload in A2A message). */
3
+ import type { ScreenDecisionRecord } from "./negotiation.screen.js";
4
+ import { type NegotiationProtocolVersion } from "../shared/schemas/negotiation-state.schema.js";
5
+ /**
6
+ * Zod schema for a single negotiation turn (DataPart payload in A2A message).
7
+ * Accepts the full v1+v2 action union — which subset is valid for a given turn
8
+ * is enforced by the seat-scoped schemas in `negotiation.protocol.ts`.
9
+ */
4
10
  export declare const NegotiationTurnSchema: z.ZodObject<{
5
- action: z.ZodEnum<["propose", "accept", "reject", "counter", "question"]>;
11
+ action: z.ZodEnum<["propose", "accept", "reject", "counter", "question", "outreach", "withdraw", "decline"]>;
6
12
  assessment: z.ZodObject<{
7
13
  reasoning: z.ZodString;
8
14
  suggestedRoles: z.ZodObject<{
@@ -30,7 +36,7 @@ export declare const NegotiationTurnSchema: z.ZodObject<{
30
36
  }>;
31
37
  message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
38
  }, "strip", z.ZodTypeAny, {
33
- action: "propose" | "accept" | "reject" | "counter" | "question";
39
+ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline";
34
40
  assessment: {
35
41
  reasoning: string;
36
42
  suggestedRoles: {
@@ -40,7 +46,7 @@ export declare const NegotiationTurnSchema: z.ZodObject<{
40
46
  };
41
47
  message?: string | null | undefined;
42
48
  }, {
43
- action: "propose" | "accept" | "reject" | "counter" | "question";
49
+ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline";
44
50
  assessment: {
45
51
  reasoning: string;
46
52
  suggestedRoles: {
@@ -50,7 +56,7 @@ export declare const NegotiationTurnSchema: z.ZodObject<{
50
56
  };
51
57
  message?: string | null | undefined;
52
58
  }>;
53
- /** Restricted turn schema for the system agent (no question action). */
59
+ /** Restricted v1 turn schema for the system agent (no question action). */
54
60
  export declare const SystemNegotiationTurnSchema: z.ZodObject<{
55
61
  action: z.ZodEnum<["propose", "accept", "reject", "counter"]>;
56
62
  assessment: z.ZodObject<{
@@ -100,7 +106,7 @@ export declare const SystemNegotiationTurnSchema: z.ZodObject<{
100
106
  };
101
107
  message?: string | null | undefined;
102
108
  }>;
103
- /** Turn schema for system agent's final allowed turn (must decide). */
109
+ /** v1 turn schema for system agent's final allowed turn (must decide). */
104
110
  export declare const FinalNegotiationTurnSchema: z.ZodObject<{
105
111
  action: z.ZodEnum<["accept", "reject"]>;
106
112
  assessment: z.ZodObject<{
@@ -273,6 +279,19 @@ export declare const NegotiationGraphState: import("@langchain/langgraph").Annot
273
279
  initiatorUserId: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
274
280
  /** The explicit search query that triggered discovery (if any). */
275
281
  discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
282
+ /**
283
+ * Negotiation protocol version for this session's task. Resolved by the
284
+ * init node: inherited from the prior task on the conversation when one
285
+ * exists (never re-stamped — a v1 conversation stays v1 mid-flight), else
286
+ * stamped from `NEGOTIATION_PROTOCOL_VERSION` for genuinely fresh runs.
287
+ */
288
+ protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
289
+ /**
290
+ * Screen-gate decision for this fresh run (P2.1 shadow mode). Written by the
291
+ * screen node; null when the gate is off, on continuations, or before the
292
+ * node runs. Mirrors `tasks.metadata.screenDecision`.
293
+ */
294
+ screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
276
295
  /** Whether this run is continuing a prior conversation with the same pair. */
277
296
  isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
278
297
  opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
@@ -291,7 +310,7 @@ export declare const NegotiationGraphState: import("@langchain/langgraph").Annot
291
310
  timeoutMs: import("@langchain/langgraph").BaseChannel<number, number | import("@langchain/langgraph").OverwriteValue<number>, unknown>;
292
311
  currentSpeaker: import("@langchain/langgraph").BaseChannel<"source" | "candidate", "source" | "candidate" | import("@langchain/langgraph").OverwriteValue<"source" | "candidate">, unknown>;
293
312
  lastTurn: import("@langchain/langgraph").BaseChannel<{
294
- action: "propose" | "accept" | "reject" | "counter" | "question";
313
+ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline";
295
314
  assessment: {
296
315
  reasoning: string;
297
316
  suggestedRoles: {
@@ -301,7 +320,7 @@ export declare const NegotiationGraphState: import("@langchain/langgraph").Annot
301
320
  };
302
321
  message?: string | null | undefined;
303
322
  } | null, {
304
- action: "propose" | "accept" | "reject" | "counter" | "question";
323
+ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline";
305
324
  assessment: {
306
325
  reasoning: string;
307
326
  suggestedRoles: {
@@ -311,7 +330,7 @@ export declare const NegotiationGraphState: import("@langchain/langgraph").Annot
311
330
  };
312
331
  message?: string | null | undefined;
313
332
  } | import("@langchain/langgraph").OverwriteValue<{
314
- action: "propose" | "accept" | "reject" | "counter" | "question";
333
+ action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline";
315
334
  assessment: {
316
335
  reasoning: string;
317
336
  suggestedRoles: {
@@ -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,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAExF,kFAAkF;AAClF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUhC,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUtC,CAAC;AAEH,uEAAuE;AACvE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUrC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,mFAAmF;AACnF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,kDAAkD;AAClD,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvF,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,M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