@indexnetwork/protocol 4.5.0-rc.336.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 +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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 +23 -3
- package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
- package/dist/negotiation/negotiation.graph.js +78 -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.reflect.d.ts +199 -0
- package/dist/negotiation/negotiation.reflect.d.ts.map +1 -0
- package/dist/negotiation/negotiation.reflect.js +153 -0
- package/dist/negotiation/negotiation.reflect.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/agent/model.config.d.ts +5 -0
- package/dist/shared/agent/model.config.d.ts.map +1 -1
- package/dist/shared/agent/model.config.js +1 -0
- package/dist/shared/agent/model.config.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
|
@@ -6,6 +6,8 @@ import { type NegotiationTurn, type NegotiationOutcome, type UserNegotiationCont
|
|
|
6
6
|
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
|
+
import type { ReflectEnqueueFn } from "./negotiation.reflect.js";
|
|
10
|
+
import type { NegotiatorMemoryEntry, NegotiatorMemoryRetrieveFn } from "./negotiation.memory.js";
|
|
9
11
|
/**
|
|
10
12
|
* Factory for the bilateral negotiation LangGraph state machine.
|
|
11
13
|
* @remarks Accepts an AgentDispatcher for per-turn agent resolution.
|
|
@@ -15,7 +17,9 @@ export declare class NegotiationGraphFactory {
|
|
|
15
17
|
private dispatcher;
|
|
16
18
|
private timeoutQueue?;
|
|
17
19
|
private questionerEnqueue?;
|
|
18
|
-
|
|
20
|
+
private reflectEnqueue?;
|
|
21
|
+
private memoryRetrieve?;
|
|
22
|
+
constructor(database: NegotiationGraphDatabase, dispatcher: AgentDispatcher, timeoutQueue?: NegotiationTimeoutQueue | undefined, questionerEnqueue?: QuestionerEnqueueFn | undefined, reflectEnqueue?: ReflectEnqueueFn | undefined, memoryRetrieve?: NegotiatorMemoryRetrieveFn | undefined);
|
|
19
23
|
createGraph(): import("@langchain/langgraph").CompiledStateGraph<{
|
|
20
24
|
sourceUser: UserNegotiationContext;
|
|
21
25
|
candidateUser: UserNegotiationContext;
|
|
@@ -28,6 +32,7 @@ export declare class NegotiationGraphFactory {
|
|
|
28
32
|
discoveryQuery: string | undefined;
|
|
29
33
|
protocolVersion: NegotiationProtocolVersion;
|
|
30
34
|
screenDecision: ScreenDecisionRecord | null;
|
|
35
|
+
memoryBySide: Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>;
|
|
31
36
|
isContinuation: boolean;
|
|
32
37
|
opportunityId: string;
|
|
33
38
|
conversationId: string;
|
|
@@ -81,6 +86,7 @@ export declare class NegotiationGraphFactory {
|
|
|
81
86
|
discoveryQuery?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
|
|
82
87
|
protocolVersion?: NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion> | undefined;
|
|
83
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;
|
|
84
90
|
isContinuation?: boolean | import("@langchain/langgraph").OverwriteValue<boolean> | undefined;
|
|
85
91
|
opportunityId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
86
92
|
conversationId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
@@ -142,7 +148,7 @@ export declare class NegotiationGraphFactory {
|
|
|
142
148
|
reason?: "timeout" | "turn_cap" | undefined;
|
|
143
149
|
} | null> | null | undefined;
|
|
144
150
|
error?: string | import("@langchain/langgraph").OverwriteValue<string | null> | null | undefined;
|
|
145
|
-
}, "__start__" | "
|
|
151
|
+
}, "__start__" | "screen" | "turn" | "init" | "finalize", {
|
|
146
152
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
147
153
|
candidateUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
148
154
|
indexContext: import("@langchain/langgraph").BaseChannel<{
|
|
@@ -160,6 +166,7 @@ export declare class NegotiationGraphFactory {
|
|
|
160
166
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
161
167
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
162
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>;
|
|
163
170
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
164
171
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
165
172
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -262,6 +269,7 @@ export declare class NegotiationGraphFactory {
|
|
|
262
269
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
263
270
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
264
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>;
|
|
265
273
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
266
274
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
267
275
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -371,6 +379,9 @@ export declare class NegotiationGraphFactory {
|
|
|
371
379
|
};
|
|
372
380
|
screen: {
|
|
373
381
|
screenDecision: ScreenDecisionRecord;
|
|
382
|
+
memoryBySide: {
|
|
383
|
+
[x: string]: NegotiatorMemoryEntry[];
|
|
384
|
+
};
|
|
374
385
|
};
|
|
375
386
|
turn: import("@langchain/langgraph").UpdateType<{
|
|
376
387
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
@@ -390,6 +401,7 @@ export declare class NegotiationGraphFactory {
|
|
|
390
401
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
391
402
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
392
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>;
|
|
393
405
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
394
406
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
395
407
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -573,6 +585,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
573
585
|
discoveryQuery: string | undefined;
|
|
574
586
|
protocolVersion: NegotiationProtocolVersion;
|
|
575
587
|
screenDecision: ScreenDecisionRecord | null;
|
|
588
|
+
memoryBySide: Partial<Record<"source" | "candidate", NegotiatorMemoryEntry[]>>;
|
|
576
589
|
isContinuation: boolean;
|
|
577
590
|
opportunityId: string;
|
|
578
591
|
conversationId: string;
|
|
@@ -626,6 +639,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
626
639
|
discoveryQuery?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
|
|
627
640
|
protocolVersion?: NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion> | undefined;
|
|
628
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;
|
|
629
643
|
isContinuation?: boolean | import("@langchain/langgraph").OverwriteValue<boolean> | undefined;
|
|
630
644
|
opportunityId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
631
645
|
conversationId?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
@@ -687,7 +701,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
687
701
|
reason?: "timeout" | "turn_cap" | undefined;
|
|
688
702
|
} | null> | null | undefined;
|
|
689
703
|
error?: string | import("@langchain/langgraph").OverwriteValue<string | null> | null | undefined;
|
|
690
|
-
}, "__start__" | "
|
|
704
|
+
}, "__start__" | "screen" | "turn" | "init" | "finalize", {
|
|
691
705
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
692
706
|
candidateUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
693
707
|
indexContext: import("@langchain/langgraph").BaseChannel<{
|
|
@@ -705,6 +719,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
705
719
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
706
720
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
707
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>;
|
|
708
723
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
709
724
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
710
725
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -807,6 +822,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
807
822
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
808
823
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
809
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>;
|
|
810
826
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
811
827
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
812
828
|
conversationId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
@@ -916,6 +932,9 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
916
932
|
};
|
|
917
933
|
screen: {
|
|
918
934
|
screenDecision: ScreenDecisionRecord;
|
|
935
|
+
memoryBySide: {
|
|
936
|
+
[x: string]: NegotiatorMemoryEntry[];
|
|
937
|
+
};
|
|
919
938
|
};
|
|
920
939
|
turn: import("@langchain/langgraph").UpdateType<{
|
|
921
940
|
sourceUser: import("@langchain/langgraph").BaseChannel<UserNegotiationContext, UserNegotiationContext | import("@langchain/langgraph").OverwriteValue<UserNegotiationContext>, unknown>;
|
|
@@ -935,6 +954,7 @@ export declare function createDefaultNegotiationGraph(deps: {
|
|
|
935
954
|
discoveryQuery: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
936
955
|
protocolVersion: import("@langchain/langgraph").BaseChannel<NegotiationProtocolVersion, NegotiationProtocolVersion | import("@langchain/langgraph").OverwriteValue<NegotiationProtocolVersion>, unknown>;
|
|
937
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>;
|
|
938
958
|
isContinuation: import("@langchain/langgraph").BaseChannel<boolean, boolean | import("@langchain/langgraph").OverwriteValue<boolean>, unknown>;
|
|
939
959
|
opportunityId: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
940
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,YAA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6B,CAAC,IAAI,EAAE;IAClD,QAAQ,EAAE,wBAAwB,CAAC;IACnC,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAGA"}
|
|
@@ -41,16 +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) {
|
|
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
|
+
this.reflectEnqueue = reflectEnqueue;
|
|
50
|
+
this.memoryRetrieve = memoryRetrieve;
|
|
49
51
|
}
|
|
50
52
|
createGraph() {
|
|
51
|
-
const { database, dispatcher, timeoutQueue, questionerEnqueue } = this;
|
|
53
|
+
const { database, dispatcher, timeoutQueue, questionerEnqueue, reflectEnqueue, memoryRetrieve } = this;
|
|
52
54
|
const systemAgent = new IndexNegotiator();
|
|
53
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");
|
|
54
84
|
const initNode = async (state) => {
|
|
55
85
|
try {
|
|
56
86
|
// Find-or-create the DM conversation for this agent pair (same as user DMs)
|
|
@@ -243,6 +273,13 @@ export class NegotiationGraphFactory {
|
|
|
243
273
|
const clientIsSource = initiatorId !== state.candidateUser.id;
|
|
244
274
|
const clientUser = clientIsSource ? state.sourceUser : state.candidateUser;
|
|
245
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
|
+
: []);
|
|
246
283
|
let decision;
|
|
247
284
|
let failedOpen = false;
|
|
248
285
|
let screenError;
|
|
@@ -252,6 +289,7 @@ export class NegotiationGraphFactory {
|
|
|
252
289
|
clientUser,
|
|
253
290
|
counterpartyUser,
|
|
254
291
|
...(counterpartyContext && { counterpartyContext }),
|
|
292
|
+
...(clientMemory.length > 0 && { memory: clientMemory }),
|
|
255
293
|
// discoveryQuery belongs to the discovery session's source user; only
|
|
256
294
|
// meaningful for the client when the client holds the source side.
|
|
257
295
|
...(clientIsSource && state.discoveryQuery && { discoveryQuery: state.discoveryQuery }),
|
|
@@ -306,7 +344,7 @@ export class NegotiationGraphFactory {
|
|
|
306
344
|
});
|
|
307
345
|
}
|
|
308
346
|
// Shadow (and pre-P2.2 enforce): always proceed to the first turn.
|
|
309
|
-
return { screenDecision: record };
|
|
347
|
+
return { screenDecision: record, memoryBySide: { [clientSide]: clientMemory } };
|
|
310
348
|
};
|
|
311
349
|
const turnNode = async (state) => {
|
|
312
350
|
const traceEmitter = requestContext.getStore()?.traceEmitter;
|
|
@@ -347,6 +385,14 @@ export class NegotiationGraphFactory {
|
|
|
347
385
|
&& !!state.opportunityId
|
|
348
386
|
&& !(state.turnCount === 0 && !state.isContinuation)
|
|
349
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
|
+
: []);
|
|
350
396
|
const payload = {
|
|
351
397
|
negotiationId: state.taskId,
|
|
352
398
|
ownUser,
|
|
@@ -360,6 +406,7 @@ export class NegotiationGraphFactory {
|
|
|
360
406
|
protocolVersion: version,
|
|
361
407
|
allowedActions: [...allowedActionsFor(version, seat, isFinalTurn, { askUser: askUserAvailable })],
|
|
362
408
|
...(state.discoveryQuery && isSource && { discoveryQuery: state.discoveryQuery }),
|
|
409
|
+
...(ownMemory.length > 0 && { negotiatorMemory: ownMemory }),
|
|
363
410
|
};
|
|
364
411
|
const scope = { action: 'manage:negotiations', scopeType: 'network', scopeId: state.indexContext.networkId };
|
|
365
412
|
const dispatchResult = await dispatcher.dispatch(ownUser.id, scope, payload, { timeoutMs: state.timeoutMs });
|
|
@@ -413,6 +460,7 @@ export class NegotiationGraphFactory {
|
|
|
413
460
|
isContinuation: state.isContinuation,
|
|
414
461
|
...(state.userAnswers.length > 0 && { userAnswers: state.userAnswers }),
|
|
415
462
|
...(askUserAvailable && { canAskUser: true }),
|
|
463
|
+
...(ownMemory.length > 0 && { memory: ownMemory }),
|
|
416
464
|
});
|
|
417
465
|
}
|
|
418
466
|
traceEmitter?.({ type: "agent_end", name: agentName, durationMs: Date.now() - agentStart, summary: `${turn.action}` });
|
|
@@ -553,6 +601,7 @@ export class NegotiationGraphFactory {
|
|
|
553
601
|
turnCount: state.turnCount + 1,
|
|
554
602
|
currentSpeaker: (isSource ? "candidate" : "source"),
|
|
555
603
|
lastTurn: turn,
|
|
604
|
+
memoryBySide: { [ownSide]: ownMemory },
|
|
556
605
|
};
|
|
557
606
|
}
|
|
558
607
|
catch (err) {
|
|
@@ -698,6 +747,32 @@ export class NegotiationGraphFactory {
|
|
|
698
747
|
}),
|
|
699
748
|
});
|
|
700
749
|
}
|
|
750
|
+
// Enqueue post-negotiation reflection (P5.2 memory write path) — fire
|
|
751
|
+
// and forget: a reflection failure must never affect the outcome. Only
|
|
752
|
+
// sessions that actually exchanged turns teach anything; init/turn
|
|
753
|
+
// errors with turnCount 0 are skipped.
|
|
754
|
+
if (reflectEnqueue && state.turnCount > 0) {
|
|
755
|
+
reflectEnqueue({
|
|
756
|
+
negotiationId: state.taskId,
|
|
757
|
+
conversationId: state.conversationId,
|
|
758
|
+
...(state.opportunityId && { opportunityId: state.opportunityId }),
|
|
759
|
+
sourceUser: {
|
|
760
|
+
id: state.sourceUser.id,
|
|
761
|
+
...(state.sourceUser.profile.name && { name: state.sourceUser.profile.name }),
|
|
762
|
+
...(state.sourceUser.profile.bio && { bio: state.sourceUser.profile.bio }),
|
|
763
|
+
},
|
|
764
|
+
candidateUser: {
|
|
765
|
+
id: state.candidateUser.id,
|
|
766
|
+
...(state.candidateUser.profile.name && { name: state.candidateUser.profile.name }),
|
|
767
|
+
...(state.candidateUser.profile.bio && { bio: state.candidateUser.profile.bio }),
|
|
768
|
+
},
|
|
769
|
+
initiatorUserId: state.initiatorUserId ?? state.sourceUser.id,
|
|
770
|
+
outcome: { hasOpportunity, reasoning: outcome.reasoning, turnCount: state.turnCount },
|
|
771
|
+
}).catch((err) => finalizeLog.error('Failed to enqueue negotiation reflection', {
|
|
772
|
+
taskId: state.taskId,
|
|
773
|
+
error: err,
|
|
774
|
+
}));
|
|
775
|
+
}
|
|
701
776
|
// Enqueue question generation for stalled/capped negotiations (not accepted or explicitly rejected).
|
|
702
777
|
// Require turnCount > 0 so early init/turn errors don't enqueue with empty context.
|
|
703
778
|
if (!hasOpportunity && !isRejectLikeAction(lastTurn?.action) && state.turnCount > 0 && state.opportunityId && questionerEnqueue) {
|