@higher.archi/boe 1.0.27 → 1.0.29
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/engines/decay/compiler.d.ts +11 -0
- package/dist/engines/decay/compiler.d.ts.map +1 -0
- package/dist/engines/decay/compiler.js +216 -0
- package/dist/engines/decay/compiler.js.map +1 -0
- package/dist/engines/decay/engine.d.ts +79 -0
- package/dist/engines/decay/engine.d.ts.map +1 -0
- package/dist/engines/decay/engine.js +159 -0
- package/dist/engines/decay/engine.js.map +1 -0
- package/dist/engines/decay/index.d.ts +9 -0
- package/dist/engines/decay/index.d.ts.map +1 -0
- package/dist/engines/decay/index.js +21 -0
- package/dist/engines/decay/index.js.map +1 -0
- package/dist/engines/decay/strategy.d.ts +21 -0
- package/dist/engines/decay/strategy.d.ts.map +1 -0
- package/dist/engines/decay/strategy.js +308 -0
- package/dist/engines/decay/strategy.js.map +1 -0
- package/dist/engines/decay/types.d.ts +157 -0
- package/dist/engines/decay/types.d.ts.map +1 -0
- package/dist/engines/decay/types.js +39 -0
- package/dist/engines/decay/types.js.map +1 -0
- package/dist/engines/negotiation/compiler.d.ts +11 -0
- package/dist/engines/negotiation/compiler.d.ts.map +1 -0
- package/dist/engines/negotiation/compiler.js +177 -0
- package/dist/engines/negotiation/compiler.js.map +1 -0
- package/dist/engines/negotiation/engine.d.ts +46 -0
- package/dist/engines/negotiation/engine.d.ts.map +1 -0
- package/dist/engines/negotiation/engine.js +88 -0
- package/dist/engines/negotiation/engine.js.map +1 -0
- package/dist/engines/negotiation/index.d.ts +8 -0
- package/dist/engines/negotiation/index.d.ts.map +1 -0
- package/dist/engines/negotiation/index.js +17 -0
- package/dist/engines/negotiation/index.js.map +1 -0
- package/dist/engines/negotiation/strategy.d.ts +18 -0
- package/dist/engines/negotiation/strategy.d.ts.map +1 -0
- package/dist/engines/negotiation/strategy.js +439 -0
- package/dist/engines/negotiation/strategy.js.map +1 -0
- package/dist/engines/negotiation/types.d.ts +179 -0
- package/dist/engines/negotiation/types.d.ts.map +1 -0
- package/dist/engines/negotiation/types.js +10 -0
- package/dist/engines/negotiation/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/engines/decay/compiler.ts +276 -0
- package/src/engines/decay/engine.ts +211 -0
- package/src/engines/decay/index.ts +43 -0
- package/src/engines/decay/strategy.ts +433 -0
- package/src/engines/decay/types.ts +231 -0
- package/src/engines/negotiation/compiler.ts +229 -0
- package/src/engines/negotiation/engine.ts +117 -0
- package/src/engines/negotiation/index.ts +42 -0
- package/src/engines/negotiation/strategy.ts +587 -0
- package/src/engines/negotiation/types.ts +244 -0
- package/src/index.ts +69 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negotiation Engine Types
|
|
3
|
+
*
|
|
4
|
+
* Two-party negotiation engine that analyzes zones of possible agreement,
|
|
5
|
+
* plans concession strategies, and optimizes deal packages across
|
|
6
|
+
* multiple dimensions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { SemanticPriority } from '../utility/types';
|
|
10
|
+
|
|
11
|
+
// ========================================
|
|
12
|
+
// Semantic Types
|
|
13
|
+
// ========================================
|
|
14
|
+
|
|
15
|
+
/** Negotiation algorithm to use */
|
|
16
|
+
export type NegotiationStrategy = 'zopa-analysis' | 'concession-planning' | 'package-optimization';
|
|
17
|
+
|
|
18
|
+
/** Concession aggressiveness style */
|
|
19
|
+
export type ConcessionStyle = 'aggressive' | 'moderate' | 'collaborative';
|
|
20
|
+
|
|
21
|
+
/** Outcome of a negotiation analysis */
|
|
22
|
+
export type DealOutcome = 'agreed' | 'no-zopa' | 'batna-preferred';
|
|
23
|
+
|
|
24
|
+
/** Whether higher or lower values are preferred for a dimension */
|
|
25
|
+
export type DimensionDirection = 'higher-is-better' | 'lower-is-better';
|
|
26
|
+
|
|
27
|
+
// ========================================
|
|
28
|
+
// Dimension & Party Types
|
|
29
|
+
// ========================================
|
|
30
|
+
|
|
31
|
+
/** A single negotiable dimension (e.g. price, delivery time) */
|
|
32
|
+
export type NegotiationDimension = {
|
|
33
|
+
id: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
unit?: string;
|
|
36
|
+
direction: DimensionDirection;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A party's position on a single dimension */
|
|
40
|
+
export type PartyPosition = {
|
|
41
|
+
dimensionId: string;
|
|
42
|
+
ideal: number;
|
|
43
|
+
acceptable: number;
|
|
44
|
+
walkaway: number;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** A negotiating party with positions across all dimensions */
|
|
48
|
+
export type PartyProfile = {
|
|
49
|
+
id: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
positions: PartyPosition[];
|
|
52
|
+
batna?: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Weight function mapping a dimension to its importance for a party */
|
|
56
|
+
export type ValueFunction = {
|
|
57
|
+
dimensionId: string;
|
|
58
|
+
weight: number | SemanticPriority;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// ========================================
|
|
62
|
+
// Compiled Dimension & Party Types
|
|
63
|
+
// ========================================
|
|
64
|
+
|
|
65
|
+
/** Compiled value function with resolved numeric weight */
|
|
66
|
+
export type CompiledValueFunction = {
|
|
67
|
+
dimensionId: string;
|
|
68
|
+
weight: number; // normalized to sum to 1.0 per party
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Compiled party profile with resolved weights */
|
|
72
|
+
export type CompiledPartyProfile = {
|
|
73
|
+
id: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
positions: PartyPosition[];
|
|
76
|
+
batna?: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ========================================
|
|
80
|
+
// Strategy-Specific Config Types
|
|
81
|
+
// ========================================
|
|
82
|
+
|
|
83
|
+
export type ZopaAnalysisConfig = {
|
|
84
|
+
resolution?: number; // default: 100
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type ConcessionPlanningConfig = {
|
|
88
|
+
style?: ConcessionStyle; // default: 'moderate'
|
|
89
|
+
rounds?: number; // default: 5
|
|
90
|
+
startingPosition?: 'ideal' | 'midpoint'; // default: 'ideal'
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type PackageOptimizationConfig = {
|
|
94
|
+
sampleSize?: number; // default: 1000
|
|
95
|
+
objectiveWeights?: {
|
|
96
|
+
closeProb: number;
|
|
97
|
+
margin: number;
|
|
98
|
+
}; // default: { closeProb: 0.6, margin: 0.4 }
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// ========================================
|
|
102
|
+
// Source RuleSet Types (Discriminated Union)
|
|
103
|
+
// ========================================
|
|
104
|
+
|
|
105
|
+
type NegotiationRuleSetBase = {
|
|
106
|
+
id: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
mode: 'negotiation';
|
|
109
|
+
dimensions: NegotiationDimension[];
|
|
110
|
+
parties: [PartyProfile, PartyProfile];
|
|
111
|
+
valueWeights: Record<string, ValueFunction[]>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** ZOPA analysis: compute zones of possible agreement per dimension */
|
|
115
|
+
export type ZopaAnalysisRuleSet = NegotiationRuleSetBase & {
|
|
116
|
+
strategy: 'zopa-analysis';
|
|
117
|
+
config?: ZopaAnalysisConfig;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** Concession planning: simulate round-by-round concession trajectories */
|
|
121
|
+
export type ConcessionPlanningRuleSet = NegotiationRuleSetBase & {
|
|
122
|
+
strategy: 'concession-planning';
|
|
123
|
+
config?: ConcessionPlanningConfig;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** Package optimization: find optimal deal packages within the ZOPA */
|
|
127
|
+
export type PackageOptimizationRuleSet = NegotiationRuleSetBase & {
|
|
128
|
+
strategy: 'package-optimization';
|
|
129
|
+
config?: PackageOptimizationConfig;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type NegotiationRuleSet =
|
|
133
|
+
| ZopaAnalysisRuleSet
|
|
134
|
+
| ConcessionPlanningRuleSet
|
|
135
|
+
| PackageOptimizationRuleSet;
|
|
136
|
+
|
|
137
|
+
// ========================================
|
|
138
|
+
// Compiled RuleSet Types
|
|
139
|
+
// ========================================
|
|
140
|
+
|
|
141
|
+
type CompiledNegotiationRuleSetBase = {
|
|
142
|
+
id: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
mode: 'negotiation';
|
|
145
|
+
dimensions: NegotiationDimension[];
|
|
146
|
+
parties: [CompiledPartyProfile, CompiledPartyProfile];
|
|
147
|
+
valueWeights: Record<string, CompiledValueFunction[]>;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type CompiledZopaAnalysisRuleSet = CompiledNegotiationRuleSetBase & {
|
|
151
|
+
strategy: 'zopa-analysis';
|
|
152
|
+
config: {
|
|
153
|
+
resolution: number;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type CompiledConcessionPlanningRuleSet = CompiledNegotiationRuleSetBase & {
|
|
158
|
+
strategy: 'concession-planning';
|
|
159
|
+
config: {
|
|
160
|
+
style: ConcessionStyle;
|
|
161
|
+
rounds: number;
|
|
162
|
+
startingPosition: 'ideal' | 'midpoint';
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type CompiledPackageOptimizationRuleSet = CompiledNegotiationRuleSetBase & {
|
|
167
|
+
strategy: 'package-optimization';
|
|
168
|
+
config: {
|
|
169
|
+
sampleSize: number;
|
|
170
|
+
objectiveWeights: {
|
|
171
|
+
closeProb: number;
|
|
172
|
+
margin: number;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export type CompiledNegotiationRuleSet =
|
|
178
|
+
| CompiledZopaAnalysisRuleSet
|
|
179
|
+
| CompiledConcessionPlanningRuleSet
|
|
180
|
+
| CompiledPackageOptimizationRuleSet;
|
|
181
|
+
|
|
182
|
+
// ========================================
|
|
183
|
+
// Result Types
|
|
184
|
+
// ========================================
|
|
185
|
+
|
|
186
|
+
/** Range of agreement for a single dimension */
|
|
187
|
+
export type ZopaRange = {
|
|
188
|
+
dimensionId: string;
|
|
189
|
+
lower: number;
|
|
190
|
+
upper: number;
|
|
191
|
+
size: number;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/** A single round's concession step for one party */
|
|
195
|
+
export type ConcessionStep = {
|
|
196
|
+
round: number;
|
|
197
|
+
partyId: string;
|
|
198
|
+
offers: Record<string, number>;
|
|
199
|
+
totalValue: number;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/** A candidate deal package */
|
|
203
|
+
export type PackageCandidate = {
|
|
204
|
+
dimensions: Record<string, number>;
|
|
205
|
+
partyAValue: number;
|
|
206
|
+
partyBValue: number;
|
|
207
|
+
closeProbability: number;
|
|
208
|
+
marginScore: number;
|
|
209
|
+
compositeScore: number;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/** Full negotiation result */
|
|
213
|
+
export type NegotiationResult = {
|
|
214
|
+
outcome: DealOutcome;
|
|
215
|
+
zopa?: {
|
|
216
|
+
ranges: ZopaRange[];
|
|
217
|
+
hasAgreement: boolean;
|
|
218
|
+
zopaVolume: number;
|
|
219
|
+
};
|
|
220
|
+
concessionPlan?: {
|
|
221
|
+
steps: ConcessionStep[];
|
|
222
|
+
convergenceRound?: number;
|
|
223
|
+
finalDeal?: Record<string, number>;
|
|
224
|
+
};
|
|
225
|
+
recommendedPackage?: PackageCandidate;
|
|
226
|
+
allPackages?: PackageCandidate[];
|
|
227
|
+
batnaComparison: Record<string, {
|
|
228
|
+
dealValue: number;
|
|
229
|
+
batnaValue: number;
|
|
230
|
+
surplus: number;
|
|
231
|
+
}>;
|
|
232
|
+
strategy: NegotiationStrategy;
|
|
233
|
+
executionTimeMs: number;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// ========================================
|
|
237
|
+
// Runtime Types
|
|
238
|
+
// ========================================
|
|
239
|
+
|
|
240
|
+
/** Runtime options for negotiation execution */
|
|
241
|
+
export type NegotiationOptions = {
|
|
242
|
+
onStep?: (step: ConcessionStep) => void;
|
|
243
|
+
onPackage?: (candidate: PackageCandidate) => void;
|
|
244
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,8 @@ export { UtilityEngine } from './engines/utility';
|
|
|
32
32
|
export { PricingEngine } from './engines/pricing';
|
|
33
33
|
export { EnsembleEngine } from './engines/ensemble';
|
|
34
34
|
export { SentimentEngine } from './engines/sentiment';
|
|
35
|
+
export { NegotiationEngine } from './engines/negotiation';
|
|
36
|
+
export { DecayEngine } from './engines/decay';
|
|
35
37
|
|
|
36
38
|
// ========================================
|
|
37
39
|
// Core Types & Utilities
|
|
@@ -516,6 +518,73 @@ export type {
|
|
|
516
518
|
IngestResult
|
|
517
519
|
} from './engines/sentiment';
|
|
518
520
|
|
|
521
|
+
// Negotiation
|
|
522
|
+
export {
|
|
523
|
+
NegotiationExecutor,
|
|
524
|
+
compileNegotiationRuleSet,
|
|
525
|
+
negotiationStrategy
|
|
526
|
+
} from './engines/negotiation';
|
|
527
|
+
export type {
|
|
528
|
+
NegotiationStrategy,
|
|
529
|
+
ConcessionStyle,
|
|
530
|
+
DealOutcome,
|
|
531
|
+
DimensionDirection,
|
|
532
|
+
NegotiationDimension,
|
|
533
|
+
PartyPosition,
|
|
534
|
+
PartyProfile,
|
|
535
|
+
ValueFunction,
|
|
536
|
+
CompiledValueFunction,
|
|
537
|
+
CompiledPartyProfile,
|
|
538
|
+
ZopaAnalysisConfig,
|
|
539
|
+
ConcessionPlanningConfig,
|
|
540
|
+
PackageOptimizationConfig,
|
|
541
|
+
ZopaAnalysisRuleSet,
|
|
542
|
+
ConcessionPlanningRuleSet,
|
|
543
|
+
PackageOptimizationRuleSet,
|
|
544
|
+
NegotiationRuleSet,
|
|
545
|
+
CompiledZopaAnalysisRuleSet,
|
|
546
|
+
CompiledConcessionPlanningRuleSet,
|
|
547
|
+
CompiledPackageOptimizationRuleSet,
|
|
548
|
+
CompiledNegotiationRuleSet,
|
|
549
|
+
ZopaRange,
|
|
550
|
+
ConcessionStep,
|
|
551
|
+
PackageCandidate,
|
|
552
|
+
NegotiationResult,
|
|
553
|
+
NegotiationOptions
|
|
554
|
+
} from './engines/negotiation';
|
|
555
|
+
|
|
556
|
+
// Decay
|
|
557
|
+
export {
|
|
558
|
+
DecayExecutor,
|
|
559
|
+
compileDecayRuleSet,
|
|
560
|
+
decayStrategy,
|
|
561
|
+
URGENCY_THRESHOLDS,
|
|
562
|
+
resolveUrgencyTier
|
|
563
|
+
} from './engines/decay';
|
|
564
|
+
export type {
|
|
565
|
+
DecayStrategy,
|
|
566
|
+
UrgencyTier,
|
|
567
|
+
ReEngagementEffect,
|
|
568
|
+
DecayAggregation,
|
|
569
|
+
DecayDimension,
|
|
570
|
+
CompiledDecayDimension,
|
|
571
|
+
ReEngagementRule,
|
|
572
|
+
SingleDimensionDecayRuleSet,
|
|
573
|
+
MultiDimensionDecayRuleSet,
|
|
574
|
+
EventDrivenDecayRuleSet,
|
|
575
|
+
DecayRuleSet,
|
|
576
|
+
CompiledSingleDimensionDecayRuleSet,
|
|
577
|
+
CompiledMultiDimensionDecayRuleSet,
|
|
578
|
+
CompiledEventDrivenDecayRuleSet,
|
|
579
|
+
CompiledDecayRuleSet,
|
|
580
|
+
DimensionDecayResult,
|
|
581
|
+
ReEngagementEvent,
|
|
582
|
+
EntityDecayResult,
|
|
583
|
+
DecayResult,
|
|
584
|
+
DecayOptions,
|
|
585
|
+
DecayIngestResult
|
|
586
|
+
} from './engines/decay';
|
|
587
|
+
|
|
519
588
|
// ========================================
|
|
520
589
|
// Utility Functions (from old modules, re-exported for convenience)
|
|
521
590
|
// ========================================
|