@indexnetwork/protocol 4.5.0-rc.337.1 → 4.5.0-rc.338.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/chat/negotiator.prompt.d.ts +8 -0
- package/dist/chat/negotiator.prompt.d.ts.map +1 -1
- package/dist/chat/negotiator.prompt.js +3 -1
- package/dist/chat/negotiator.prompt.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/negotiation/negotiation.agent.d.ts +7 -0
- package/dist/negotiation/negotiation.agent.d.ts.map +1 -1
- package/dist/negotiation/negotiation.agent.js +4 -2
- package/dist/negotiation/negotiation.agent.js.map +1 -1
- package/dist/negotiation/negotiation.graph.d.ts +21 -3
- package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
- package/dist/negotiation/negotiation.graph.js +51 -3
- package/dist/negotiation/negotiation.graph.js.map +1 -1
- package/dist/negotiation/negotiation.memory.d.ts +58 -0
- package/dist/negotiation/negotiation.memory.d.ts.map +1 -0
- package/dist/negotiation/negotiation.memory.js +71 -0
- package/dist/negotiation/negotiation.memory.js.map +1 -0
- package/dist/negotiation/negotiation.screen.d.ts +8 -1
- package/dist/negotiation/negotiation.screen.d.ts.map +1 -1
- package/dist/negotiation/negotiation.screen.js +5 -3
- package/dist/negotiation/negotiation.screen.js.map +1 -1
- package/dist/negotiation/negotiation.state.d.ts +9 -0
- package/dist/negotiation/negotiation.state.d.ts.map +1 -1
- package/dist/negotiation/negotiation.state.js +11 -0
- package/dist/negotiation/negotiation.state.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/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { type ScreenDecisionRecord } from "./negotiation.screen.js";
|
|
|
7
7
|
import type { NegotiationProtocolVersion } from "../shared/schemas/negotiation-state.schema.js";
|
|
8
8
|
import type { QuestionerEnqueueFn } from "../questioner/questioner.types.js";
|
|
9
9
|
import type { ReflectEnqueueFn } from "./negotiation.reflect.js";
|
|
10
|
+
import type { NegotiatorMemoryEntry, NegotiatorMemoryRetrieveFn } from "./negotiation.memory.js";
|
|
10
11
|
/**
|
|
11
12
|
* Factory for the bilateral negotiation LangGraph state machine.
|
|
12
13
|
* @remarks Accepts an AgentDispatcher for per-turn agent resolution.
|
|
@@ -17,7 +18,8 @@ export declare class NegotiationGraphFactory {
|
|
|
17
18
|
private timeoutQueue?;
|
|
18
19
|
private questionerEnqueue?;
|
|
19
20
|
private reflectEnqueue?;
|
|
20
|
-
|
|
21
|
+
private memoryRetrieve?;
|
|
22
|
+
constructor(database: NegotiationGraphDatabase, dispatcher: AgentDispatcher, timeoutQueue?: NegotiationTimeoutQueue | undefined, questionerEnqueue?: QuestionerEnqueueFn | undefined, reflectEnqueue?: ReflectEnqueueFn | undefined, memoryRetrieve?: NegotiatorMemoryRetrieveFn | undefined);
|
|
21
23
|
createGraph(): import("@langchain/langgraph").CompiledStateGraph<{
|
|
22
24
|
sourceUser: UserNegotiationContext;
|
|
23
25
|
candidateUser: UserNegotiationContext;
|
|
@@ -30,6 +32,7 @@ export declare class NegotiationGraphFactory {
|
|
|
30
32
|
discoveryQuery: string | undefined;
|
|
31
33
|
protocolVersion: NegotiationProtocolVersion;
|
|
32
34
|
screenDecision: ScreenDecisionRecord | null;
|
|
35
|
+
memoryBySide: Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>;
|
|
33
36
|
isContinuation: boolean;
|
|
34
37
|
opportunityId: string;
|
|
35
38
|
conversationId: string;
|
|
@@ -83,6 +86,7 @@ export declare class NegotiationGraphFactory {
|
|
|
83
86
|
discoveryQuery?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
|
|
84
87
|
protocolVersion?: NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion> | undefined;
|
|
85
88
|
screenDecision?: ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null | undefined;
|
|
89
|
+
memoryBySide?: Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>> | import("@langchain/langgraph").OverwriteValue<Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>> | undefined;
|
|
86
90
|
isContinuation?: boolean | import("@langchain/langgraph").OverwriteValue<boolean> | undefined;
|
|
87
91
|
opportunityId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
88
92
|
conversationId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
@@ -144,7 +148,7 @@ export declare class NegotiationGraphFactory {
|
|
|
144
148
|
reason?: "timeout" | "turn_cap" | undefined;
|
|
145
149
|
} | null> | null | undefined;
|
|
146
150
|
error?: string | import("@langchain/langgraph").OverwriteValue<string | null> | null | undefined;
|
|
147
|
-
}, "__start__" | "
|
|
151
|
+
}, "__start__" | "screen" | "turn" | "init" | "finalize", {
|
|
148
152
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
149
153
|
candidateUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
150
154
|
indexContext: import("@langchain/langgraph").BaseChannel<{
|
|
@@ -162,6 +166,7 @@ export declare class NegotiationGraphFactory {
|
|
|
162
166
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
163
167
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
164
168
|
screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
|
|
169
|
+
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>;
|
|
165
170
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
166
171
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
167
172
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -264,6 +269,7 @@ export declare class NegotiationGraphFactory {
|
|
|
264
269
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
265
270
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
266
271
|
screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
|
|
272
|
+
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>;
|
|
267
273
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
268
274
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
269
275
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -373,6 +379,9 @@ export declare class NegotiationGraphFactory {
|
|
|
373
379
|
};
|
|
374
380
|
screen: {
|
|
375
381
|
screenDecision: ScreenDecisionRecord;
|
|
382
|
+
memoryBySide: {
|
|
383
|
+
[x: string]: NegotiatorMemoryEntry[];
|
|
384
|
+
};
|
|
376
385
|
};
|
|
377
386
|
turn: import("@langchain/langgraph").UpdateType<{
|
|
378
387
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
@@ -392,6 +401,7 @@ export declare class NegotiationGraphFactory {
|
|
|
392
401
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
393
402
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
394
403
|
screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
|
|
404
|
+
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>;
|
|
395
405
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
396
406
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
397
407
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -575,6 +585,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
575
585
|
discoveryQuery: string | undefined;
|
|
576
586
|
protocolVersion: NegotiationProtocolVersion;
|
|
577
587
|
screenDecision: ScreenDecisionRecord | null;
|
|
588
|
+
memoryBySide: Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>;
|
|
578
589
|
isContinuation: boolean;
|
|
579
590
|
opportunityId: string;
|
|
580
591
|
conversationId: string;
|
|
@@ -628,6 +639,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
628
639
|
discoveryQuery?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
|
|
629
640
|
protocolVersion?: NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion> | undefined;
|
|
630
641
|
screenDecision?: ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null | undefined;
|
|
642
|
+
memoryBySide?: Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>> | import("@langchain/langgraph").OverwriteValue<Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>> | undefined;
|
|
631
643
|
isContinuation?: boolean | import("@langchain/langgraph").OverwriteValue<boolean> | undefined;
|
|
632
644
|
opportunityId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
633
645
|
conversationId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
@@ -689,7 +701,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
689
701
|
reason?: "timeout" | "turn_cap" | undefined;
|
|
690
702
|
} | null> | null | undefined;
|
|
691
703
|
error?: string | import("@langchain/langgraph").OverwriteValue<string | null> | null | undefined;
|
|
692
|
-
}, "__start__" | "
|
|
704
|
+
}, "__start__" | "screen" | "turn" | "init" | "finalize", {
|
|
693
705
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
694
706
|
candidateUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
695
707
|
indexContext: import("@langchain/langgraph").BaseChannel<{
|
|
@@ -707,6 +719,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
707
719
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
708
720
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
709
721
|
screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
|
|
722
|
+
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>;
|
|
710
723
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
711
724
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
712
725
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -809,6 +822,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
809
822
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
810
823
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
811
824
|
screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
|
|
825
|
+
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>;
|
|
812
826
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
813
827
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
814
828
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -918,6 +932,9 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
918
932
|
};
|
|
919
933
|
screen: {
|
|
920
934
|
screenDecision: ScreenDecisionRecord;
|
|
935
|
+
memoryBySide: {
|
|
936
|
+
[x: string]: NegotiatorMemoryEntry[];
|
|
937
|
+
};
|
|
921
938
|
};
|
|
922
939
|
turn: import("@langchain/langgraph").UpdateType<{
|
|
923
940
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
@@ -937,6 +954,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
937
954
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
938
955
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
939
956
|
screenDecision: import("@langchain/langgraph").BaseChannel<ScreenDecisionRecord | null, ScreenDecisionRecord | import("@langchain/langgraph").OverwriteValue<ScreenDecisionRecord | null> | null, unknown>;
|
|
957
|
+
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>;
|
|
940
958
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
941
959
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
942
960
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negotiation.graph.d.ts","sourceRoot":"/","sources":["negotiation/negotiation.graph.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AACpG,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,oDAAoD,CAAC;AAClH,OAAO,EAAyB,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAGA"}
|
|
@@ -41,17 +41,46 @@ function hasPriorAskUser(messages, userId) {
|
|
|
41
41
|
* @remarks Accepts an AgentDispatcher for per-turn agent resolution.
|
|
42
42
|
*/
|
|
43
43
|
export class NegotiationGraphFactory {
|
|
44
|
-
constructor(database, dispatcher, timeoutQueue, questionerEnqueue, reflectEnqueue) {
|
|
44
|
+
constructor(database, dispatcher, timeoutQueue, questionerEnqueue, reflectEnqueue, memoryRetrieve) {
|
|
45
45
|
this.database = database;
|
|
46
46
|
this.dispatcher = dispatcher;
|
|
47
47
|
this.timeoutQueue = timeoutQueue;
|
|
48
48
|
this.questionerEnqueue = questionerEnqueue;
|
|
49
49
|
this.reflectEnqueue = reflectEnqueue;
|
|
50
|
+
this.memoryRetrieve = memoryRetrieve;
|
|
50
51
|
}
|
|
51
52
|
createGraph() {
|
|
52
|
-
const { database, dispatcher, timeoutQueue, questionerEnqueue, reflectEnqueue } = this;
|
|
53
|
+
const { database, dispatcher, timeoutQueue, questionerEnqueue, reflectEnqueue, memoryRetrieve } = this;
|
|
53
54
|
const systemAgent = new IndexNegotiator();
|
|
54
55
|
const screener = new NegotiationScreener();
|
|
56
|
+
/**
|
|
57
|
+
* P5.3 memory retrieval — never throws, never blocks a negotiation. The
|
|
58
|
+
* injected fn already resolves [] when NEGOTIATOR_MEMORY_INJECT is off;
|
|
59
|
+
* this wrapper adds the graph-side failure guard.
|
|
60
|
+
*/
|
|
61
|
+
const retrieveMemory = async (userId, counterpartyUserId, queryText, scope) => {
|
|
62
|
+
if (!memoryRetrieve)
|
|
63
|
+
return [];
|
|
64
|
+
try {
|
|
65
|
+
return await memoryRetrieve({ userId, counterpartyUserId, queryText, scope });
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
logger.warn("Negotiator memory retrieval failed; proceeding without memory", {
|
|
69
|
+
userId,
|
|
70
|
+
scope,
|
|
71
|
+
error: err instanceof Error ? err.message : String(err),
|
|
72
|
+
});
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/** Similarity query text: seed reasoning + counterparty context. */
|
|
77
|
+
const memoryQueryText = (state, counterparty) => [
|
|
78
|
+
state.discoveryQuery ? `Search: ${state.discoveryQuery}` : "",
|
|
79
|
+
state.seedAssessment?.reasoning ?? "",
|
|
80
|
+
counterparty?.profile?.name ?? "",
|
|
81
|
+
counterparty?.profile?.bio ?? "",
|
|
82
|
+
(counterparty?.intents ?? []).slice(0, 5).map((i) => `${i.title}: ${i.description}`).join("\n"),
|
|
83
|
+
].filter(Boolean).join("\n");
|
|
55
84
|
const initNode = async (state) => {
|
|
56
85
|
try {
|
|
57
86
|
// Find-or-create the DM conversation for this agent pair (same as user DMs)
|
|
@@ -244,6 +273,13 @@ export class NegotiationGraphFactory {
|
|
|
244
273
|
const clientIsSource = initiatorId !== state.candidateUser.id;
|
|
245
274
|
const clientUser = clientIsSource ? state.sourceUser : state.candidateUser;
|
|
246
275
|
const counterpartyUser = clientIsSource ? state.candidateUser : state.sourceUser;
|
|
276
|
+
// P5.3: the client's own negotiator memory informs the outreach gate.
|
|
277
|
+
// Cached into state so the client's first turn reuses it.
|
|
278
|
+
const clientSide = clientIsSource ? "source" : "candidate";
|
|
279
|
+
const clientMemory = state.memoryBySide?.[clientSide]
|
|
280
|
+
?? (memoryRetrieve
|
|
281
|
+
? await retrieveMemory(clientUser.id, counterpartyUser.id, memoryQueryText(state, counterpartyUser), "screen")
|
|
282
|
+
: []);
|
|
247
283
|
let decision;
|
|
248
284
|
let failedOpen = false;
|
|
249
285
|
let screenError;
|
|
@@ -253,6 +289,7 @@ export class NegotiationGraphFactory {
|
|
|
253
289
|
clientUser,
|
|
254
290
|
counterpartyUser,
|
|
255
291
|
...(counterpartyContext && { counterpartyContext }),
|
|
292
|
+
...(clientMemory.length > 0 && { memory: clientMemory }),
|
|
256
293
|
// discoveryQuery belongs to the discovery session's source user; only
|
|
257
294
|
// meaningful for the client when the client holds the source side.
|
|
258
295
|
...(clientIsSource && state.discoveryQuery && { discoveryQuery: state.discoveryQuery }),
|
|
@@ -307,7 +344,7 @@ export class NegotiationGraphFactory {
|
|
|
307
344
|
});
|
|
308
345
|
}
|
|
309
346
|
// Shadow (and pre-P2.2 enforce): always proceed to the first turn.
|
|
310
|
-
return { screenDecision: record };
|
|
347
|
+
return { screenDecision: record, memoryBySide: { [clientSide]: clientMemory } };
|
|
311
348
|
};
|
|
312
349
|
const turnNode = async (state) => {
|
|
313
350
|
const traceEmitter = requestContext.getStore()?.traceEmitter;
|
|
@@ -348,6 +385,14 @@ export class NegotiationGraphFactory {
|
|
|
348
385
|
&& !!state.opportunityId
|
|
349
386
|
&& !(state.turnCount === 0 && !state.isContinuation)
|
|
350
387
|
&& !hasPriorAskUser(state.messages, ownUser.id);
|
|
388
|
+
// P5.3: the speaker's own negotiator memory (cached per side across
|
|
389
|
+
// turns). Injected into both the dispatch payload (the user's own
|
|
390
|
+
// agent — scope-correct) and the system-agent prompt.
|
|
391
|
+
const ownSide = isSource ? "source" : "candidate";
|
|
392
|
+
const ownMemory = state.memoryBySide?.[ownSide]
|
|
393
|
+
?? (memoryRetrieve
|
|
394
|
+
? await retrieveMemory(ownUser.id, otherUser.id, memoryQueryText(state, otherUser), "turn")
|
|
395
|
+
: []);
|
|
351
396
|
const payload = {
|
|
352
397
|
negotiationId: state.taskId,
|
|
353
398
|
ownUser,
|
|
@@ -361,6 +406,7 @@ export class NegotiationGraphFactory {
|
|
|
361
406
|
protocolVersion: version,
|
|
362
407
|
allowedActions: [...allowedActionsFor(version, seat, isFinalTurn, { askUser: askUserAvailable })],
|
|
363
408
|
...(state.discoveryQuery && isSource && { discoveryQuery: state.discoveryQuery }),
|
|
409
|
+
...(ownMemory.length > 0 && { negotiatorMemory: ownMemory }),
|
|
364
410
|
};
|
|
365
411
|
const scope = { action: 'manage:negotiations', scopeType: 'network', scopeId: state.indexContext.networkId };
|
|
366
412
|
const dispatchResult = await dispatcher.dispatch(ownUser.id, scope, payload, { timeoutMs: state.timeoutMs });
|
|
@@ -414,6 +460,7 @@ export class NegotiationGraphFactory {
|
|
|
414
460
|
isContinuation: state.isContinuation,
|
|
415
461
|
...(state.userAnswers.length > 0 && { userAnswers: state.userAnswers }),
|
|
416
462
|
...(askUserAvailable && { canAskUser: true }),
|
|
463
|
+
...(ownMemory.length > 0 && { memory: ownMemory }),
|
|
417
464
|
});
|
|
418
465
|
}
|
|
419
466
|
traceEmitter?.({ type: "agent_end", name: agentName, durationMs: Date.now() - agentStart, summary: `${turn.action}` });
|
|
@@ -554,6 +601,7 @@ export class NegotiationGraphFactory {
|
|
|
554
601
|
turnCount: state.turnCount + 1,
|
|
555
602
|
currentSpeaker: (isSource ? "candidate" : "source"),
|
|
556
603
|
lastTurn: turn,
|
|
604
|
+
memoryBySide: { [ownSide]: ownMemory },
|
|
557
605
|
};
|
|
558
606
|
}
|
|
559
607
|
catch (err) {
|