@wowok/agent-mcp 2.3.14 → 2.3.16
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/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/runtime.d.ts +26 -0
- package/dist/config/runtime.js +217 -0
- package/dist/customer/industry-risks.d.ts +36 -0
- package/dist/customer/industry-risks.js +424 -0
- package/dist/customer/info-puzzle.d.ts +102 -0
- package/dist/customer/info-puzzle.js +312 -0
- package/dist/customer/order-monitor.d.ts +75 -0
- package/dist/customer/order-monitor.js +327 -0
- package/dist/customer/order-strategy.d.ts +36 -0
- package/dist/customer/order-strategy.js +373 -0
- package/dist/customer/post-purchase.d.ts +42 -0
- package/dist/customer/post-purchase.js +350 -0
- package/dist/customer/reminder-system.d.ts +42 -0
- package/dist/customer/reminder-system.js +295 -0
- package/dist/customer/risk-assessment.d.ts +8 -0
- package/dist/customer/risk-assessment.js +337 -0
- package/dist/customer/types.d.ts +193 -0
- package/dist/customer/types.js +13 -0
- package/dist/customer/user-preferences.d.ts +67 -0
- package/dist/customer/user-preferences.js +451 -0
- package/dist/experience/experience-reuse.d.ts +10 -0
- package/dist/experience/experience-reuse.js +103 -0
- package/dist/experience/index.d.ts +6 -0
- package/dist/experience/index.js +5 -0
- package/dist/experience/intent-distill.d.ts +3 -0
- package/dist/experience/intent-distill.js +83 -0
- package/dist/experience/realtime-feedback.d.ts +5 -0
- package/dist/experience/realtime-feedback.js +77 -0
- package/dist/experience/types.d.ts +50 -0
- package/dist/experience/types.js +1 -0
- package/dist/experience/user-profile.d.ts +25 -0
- package/dist/experience/user-profile.js +171 -0
- package/dist/index.js +570 -186
- package/dist/knowledge/acquisition-flywheel.d.ts +50 -0
- package/dist/knowledge/acquisition-flywheel.js +183 -0
- package/dist/knowledge/arbitration-trust.d.ts +24 -0
- package/dist/knowledge/arbitration-trust.js +117 -0
- package/dist/knowledge/audit-rules.d.ts +28 -0
- package/dist/knowledge/audit-rules.js +141 -0
- package/dist/knowledge/demand-matching.d.ts +29 -0
- package/dist/knowledge/demand-matching.js +132 -0
- package/dist/knowledge/dynamic-pricing.d.ts +31 -0
- package/dist/knowledge/dynamic-pricing.js +87 -0
- package/dist/knowledge/flywheel-loop.d.ts +87 -0
- package/dist/knowledge/flywheel-loop.js +378 -0
- package/dist/knowledge/glossary.d.ts +18 -0
- package/dist/knowledge/glossary.js +209 -0
- package/dist/knowledge/index.d.ts +64 -0
- package/dist/knowledge/index.js +66 -0
- package/dist/knowledge/industry-evolution.d.ts +82 -0
- package/dist/knowledge/industry-evolution.js +323 -0
- package/dist/knowledge/industry-generalizer.d.ts +17 -0
- package/dist/knowledge/industry-generalizer.js +381 -0
- package/dist/knowledge/industry-registry.d.ts +49 -0
- package/dist/knowledge/industry-registry.js +167 -0
- package/dist/knowledge/intent-metrics.d.ts +42 -0
- package/dist/knowledge/intent-metrics.js +566 -0
- package/dist/knowledge/process-model.d.ts +24 -0
- package/dist/knowledge/process-model.js +160 -0
- package/dist/knowledge/reputation-rules.d.ts +42 -0
- package/dist/knowledge/reputation-rules.js +99 -0
- package/dist/knowledge/reward-templates.d.ts +25 -0
- package/dist/knowledge/reward-templates.js +125 -0
- package/dist/knowledge/safety-rules.d.ts +36 -0
- package/dist/knowledge/safety-rules.js +171 -0
- package/dist/knowledge/tool-constraints.d.ts +30 -0
- package/dist/knowledge/tool-constraints.js +185 -0
- package/dist/knowledge/trust-metrics.d.ts +37 -0
- package/dist/knowledge/trust-metrics.js +138 -0
- package/dist/loop-engineering/diagnose.d.ts +3 -2
- package/dist/loop-engineering/diagnose.js +94 -0
- package/dist/loop-engineering/improve.d.ts +1 -1
- package/dist/loop-engineering/improve.js +52 -1
- package/dist/project/graph.d.ts +71 -0
- package/dist/project/graph.js +314 -0
- package/dist/project/index.d.ts +62 -0
- package/dist/project/index.js +167 -0
- package/dist/project/namespace.d.ts +62 -0
- package/dist/project/namespace.js +181 -0
- package/dist/project/query.d.ts +40 -0
- package/dist/project/query.js +110 -0
- package/dist/safety/confirm-gate.d.ts +15 -0
- package/dist/safety/confirm-gate.js +44 -0
- package/dist/safety/index.d.ts +3 -0
- package/dist/safety/index.js +3 -0
- package/dist/safety/preview.d.ts +2 -0
- package/dist/safety/preview.js +36 -0
- package/dist/schema/call/allocation.d.ts +15 -0
- package/dist/schema/call/arbitration.d.ts +111 -96
- package/dist/schema/call/base.d.ts +1070 -44
- package/dist/schema/call/base.js +69 -1
- package/dist/schema/call/bridge.d.ts +709 -52
- package/dist/schema/call/bridge.js +13 -2
- package/dist/schema/call/contact.d.ts +15 -0
- package/dist/schema/call/demand.d.ts +69 -54
- package/dist/schema/call/guard.d.ts +125 -80
- package/dist/schema/call/handler.d.ts +3 -0
- package/dist/schema/call/handler.js +14 -0
- package/dist/schema/call/machine.d.ts +830 -800
- package/dist/schema/call/order.d.ts +15 -0
- package/dist/schema/call/payment.d.ts +15 -0
- package/dist/schema/call/permission.d.ts +15 -0
- package/dist/schema/call/personal.d.ts +15 -0
- package/dist/schema/call/progress.d.ts +15 -0
- package/dist/schema/call/proof.d.ts +42 -12
- package/dist/schema/call/proof.js +3 -3
- package/dist/schema/call/repository.d.ts +91 -76
- package/dist/schema/call/reward.d.ts +45 -30
- package/dist/schema/call/semantic.d.ts +1 -0
- package/dist/schema/call/semantic.js +217 -0
- package/dist/schema/call/service.d.ts +407 -392
- package/dist/schema/call/treasury.d.ts +15 -0
- package/dist/schema/common/index.js +3 -3
- package/dist/schema/local/index.d.ts +228 -72
- package/dist/schema/local/index.js +33 -6
- package/dist/schema/messenger/index.d.ts +668 -50
- package/dist/schema/messenger/index.js +9 -0
- package/dist/schema/operations.d.ts +1693 -1369
- package/dist/schema/operations.js +2 -2
- package/dist/schema/query/index.d.ts +1614 -1614
- package/dist/schema/query/index.js +30 -27
- package/dist/schemas/account_operation.output.json +25 -16
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.output.json +520 -0
- package/dist/schemas/bridge_operation.schema.json +15 -0
- package/dist/schemas/guard2file.schema.json +15 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +23 -0
- package/dist/schemas/local_info_operation.schema.json +1 -1
- package/dist/schemas/local_mark_operation.output.json +24 -1
- package/dist/schemas/local_mark_operation.schema.json +4 -4
- package/dist/schemas/machineNode2file.schema.json +15 -0
- package/dist/schemas/messenger_operation.output.json +528 -0
- package/dist/schemas/onchain_operations.output.json +350 -16
- package/dist/schemas/onchain_operations.schema.json +96 -23
- package/dist/schemas/onchain_operations_allocation.schema.json +15 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +15 -0
- package/dist/schemas/onchain_operations_contact.schema.json +15 -0
- package/dist/schemas/onchain_operations_demand.schema.json +15 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +30 -0
- package/dist/schemas/onchain_operations_guard.schema.json +15 -0
- package/dist/schemas/onchain_operations_machine.schema.json +81 -23
- package/dist/schemas/onchain_operations_order.schema.json +15 -0
- package/dist/schemas/onchain_operations_payment.schema.json +15 -0
- package/dist/schemas/onchain_operations_permission.schema.json +15 -0
- package/dist/schemas/onchain_operations_personal.schema.json +15 -0
- package/dist/schemas/onchain_operations_progress.schema.json +15 -0
- package/dist/schemas/onchain_operations_repository.schema.json +15 -0
- package/dist/schemas/onchain_operations_reward.schema.json +15 -0
- package/dist/schemas/onchain_operations_service.schema.json +15 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +15 -0
- package/dist/schemas/onchain_table_data.output.json +221 -69
- package/dist/schemas/onchain_table_data.schema.json +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export const DEMAND_MATCHING_VERSION = 1;
|
|
2
|
+
const WEIGHTS = {
|
|
3
|
+
tags: 30,
|
|
4
|
+
price: 20,
|
|
5
|
+
scenario: 15,
|
|
6
|
+
trust: 20,
|
|
7
|
+
location: 10,
|
|
8
|
+
keyword: 5,
|
|
9
|
+
};
|
|
10
|
+
export function matchDemand(demand, services, limit = 5) {
|
|
11
|
+
const matches = services
|
|
12
|
+
.filter((s) => s.published !== false)
|
|
13
|
+
.map((s) => computeMatchScore(demand, s))
|
|
14
|
+
.filter((m) => m.score >= 60)
|
|
15
|
+
.sort((a, b) => b.score - a.score)
|
|
16
|
+
.slice(0, limit);
|
|
17
|
+
return matches;
|
|
18
|
+
}
|
|
19
|
+
function computeMatchScore(demand, service) {
|
|
20
|
+
const reasons = [];
|
|
21
|
+
const warnings = [];
|
|
22
|
+
let score = 0;
|
|
23
|
+
const tagScore = computeTagScore(demand.tags, service.tags);
|
|
24
|
+
score += tagScore;
|
|
25
|
+
if (tagScore >= WEIGHTS.tags * 0.8) {
|
|
26
|
+
reasons.push(`tags 匹配度高 (${tagScore}/${WEIGHTS.tags})`);
|
|
27
|
+
}
|
|
28
|
+
const priceScore = computePriceScore(demand.maxPrice, service.price);
|
|
29
|
+
score += priceScore;
|
|
30
|
+
if (priceScore === WEIGHTS.price) {
|
|
31
|
+
reasons.push(`价格在预算范围内`);
|
|
32
|
+
}
|
|
33
|
+
else if (priceScore === 0 && demand.maxPrice && service.price) {
|
|
34
|
+
warnings.push(`价格超出预算 (${service.price} > ${demand.maxPrice})`);
|
|
35
|
+
}
|
|
36
|
+
const scenarioScore = computeScenarioScore(demand.scenario, service.scenario);
|
|
37
|
+
score += scenarioScore;
|
|
38
|
+
if (scenarioScore === WEIGHTS.scenario) {
|
|
39
|
+
reasons.push(`行业场景匹配 (${service.scenario})`);
|
|
40
|
+
}
|
|
41
|
+
const trustScore = computeTrustScore(service.trustScore, demand.minTrustScore);
|
|
42
|
+
score += trustScore;
|
|
43
|
+
if (service.trustScore !== undefined) {
|
|
44
|
+
if (service.trustScore >= 75) {
|
|
45
|
+
reasons.push(`信任分高 (${service.trustScore}/100)`);
|
|
46
|
+
}
|
|
47
|
+
else if (service.trustScore < 50) {
|
|
48
|
+
warnings.push(`信任分较低 (${service.trustScore}/100)`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const locationScore = computeLocationScore(demand.location, service.location);
|
|
52
|
+
score += locationScore;
|
|
53
|
+
if (locationScore === WEIGHTS.location && demand.location) {
|
|
54
|
+
reasons.push(`地理位置匹配 (${service.location})`);
|
|
55
|
+
}
|
|
56
|
+
const keywordScore = computeKeywordScore(demand.keywords, service.description);
|
|
57
|
+
score += keywordScore;
|
|
58
|
+
if (demand.minTrustScore !== undefined && service.trustScore !== undefined) {
|
|
59
|
+
if (service.trustScore < demand.minTrustScore) {
|
|
60
|
+
warnings.push(`信任分低于要求 (${service.trustScore} < ${demand.minTrustScore})`);
|
|
61
|
+
score -= 10;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
service,
|
|
66
|
+
score: Math.max(0, Math.min(100, score)),
|
|
67
|
+
reasons,
|
|
68
|
+
warnings,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function computeTagScore(demandTags, serviceTags) {
|
|
72
|
+
if (!demandTags || !serviceTags || demandTags.length === 0 || serviceTags.length === 0)
|
|
73
|
+
return 0;
|
|
74
|
+
const demandSet = new Set(demandTags.map((t) => t.toLowerCase()));
|
|
75
|
+
const serviceSet = new Set(serviceTags.map((t) => t.toLowerCase()));
|
|
76
|
+
const overlap = [...demandSet].filter((t) => serviceSet.has(t)).length;
|
|
77
|
+
return Math.round((overlap / demandSet.size) * WEIGHTS.tags);
|
|
78
|
+
}
|
|
79
|
+
function computePriceScore(maxPrice, servicePrice) {
|
|
80
|
+
if (!maxPrice || !servicePrice)
|
|
81
|
+
return WEIGHTS.price / 2;
|
|
82
|
+
try {
|
|
83
|
+
const max = BigInt(maxPrice);
|
|
84
|
+
const price = BigInt(servicePrice);
|
|
85
|
+
if (price <= max)
|
|
86
|
+
return WEIGHTS.price;
|
|
87
|
+
if (price <= max * 110n / 100n)
|
|
88
|
+
return WEIGHTS.price * 0.5;
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return WEIGHTS.price / 2;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function computeScenarioScore(demandScenario, serviceScenario) {
|
|
96
|
+
if (!demandScenario || !serviceScenario)
|
|
97
|
+
return 0;
|
|
98
|
+
return demandScenario.toLowerCase() === serviceScenario.toLowerCase() ? WEIGHTS.scenario : 0;
|
|
99
|
+
}
|
|
100
|
+
function computeTrustScore(serviceTrust, minTrust) {
|
|
101
|
+
if (serviceTrust === undefined)
|
|
102
|
+
return WEIGHTS.trust / 2;
|
|
103
|
+
if (serviceTrust >= 75)
|
|
104
|
+
return WEIGHTS.trust;
|
|
105
|
+
if (serviceTrust >= 50)
|
|
106
|
+
return WEIGHTS.trust * 0.6;
|
|
107
|
+
if (serviceTrust >= 25)
|
|
108
|
+
return WEIGHTS.trust * 0.3;
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
function computeLocationScore(demandLocation, serviceLocation) {
|
|
112
|
+
if (!demandLocation || !serviceLocation)
|
|
113
|
+
return 0;
|
|
114
|
+
return demandLocation.toLowerCase() === serviceLocation.toLowerCase() ? WEIGHTS.location : 0;
|
|
115
|
+
}
|
|
116
|
+
function computeKeywordScore(keywords, description) {
|
|
117
|
+
if (!keywords || !description || keywords.length === 0)
|
|
118
|
+
return 0;
|
|
119
|
+
const desc = description.toLowerCase();
|
|
120
|
+
const matches = keywords.filter((k) => desc.includes(k.toLowerCase()));
|
|
121
|
+
return Math.min(WEIGHTS.keyword, matches.length);
|
|
122
|
+
}
|
|
123
|
+
export function extractDemandInfo(demandData) {
|
|
124
|
+
return {
|
|
125
|
+
tags: demandData?.tags,
|
|
126
|
+
maxPrice: demandData?.max_price ?? demandData?.maxPrice,
|
|
127
|
+
scenario: demandData?.scenario,
|
|
128
|
+
location: demandData?.location,
|
|
129
|
+
minTrustScore: demandData?.min_trust_score ?? demandData?.minTrustScore,
|
|
130
|
+
keywords: demandData?.keywords,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface MarketSignals {
|
|
2
|
+
supplyCount: number;
|
|
3
|
+
demandCount: number;
|
|
4
|
+
avgPrice?: string;
|
|
5
|
+
myPrice?: string;
|
|
6
|
+
competitorPrices?: string[];
|
|
7
|
+
recentOrderCount?: number;
|
|
8
|
+
repeatCustomerRate?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PricingSuggestion {
|
|
11
|
+
action: "increase" | "decrease" | "maintain";
|
|
12
|
+
suggestedRange?: {
|
|
13
|
+
min: string;
|
|
14
|
+
max: string;
|
|
15
|
+
};
|
|
16
|
+
reason: string;
|
|
17
|
+
confidence: number;
|
|
18
|
+
adjustmentPercent?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface MutableFieldInfo {
|
|
21
|
+
field: string;
|
|
22
|
+
purpose: string;
|
|
23
|
+
mutableAfterPublish: boolean;
|
|
24
|
+
adjustmentMechanism: string;
|
|
25
|
+
metricToWatch: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const DYNAMIC_PRICING_VERSION = 1;
|
|
28
|
+
export declare const MUTABLE_FIELDS: MutableFieldInfo[];
|
|
29
|
+
export declare function suggestPricing(signals: MarketSignals): PricingSuggestion;
|
|
30
|
+
export declare function getMutableFields(published?: boolean): MutableFieldInfo[];
|
|
31
|
+
export declare function getMutableField(field: string): MutableFieldInfo | undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export const DYNAMIC_PRICING_VERSION = 1;
|
|
2
|
+
export const MUTABLE_FIELDS = [
|
|
3
|
+
{ field: "sales", purpose: "调整产品/价格", mutableAfterPublish: true, adjustmentMechanism: "Service.sales 可变", metricToWatch: "下单率" },
|
|
4
|
+
{ field: "discount", purpose: "营销促销", mutableAfterPublish: true, adjustmentMechanism: "add/set/destroy", metricToWatch: "转化率" },
|
|
5
|
+
{ field: "description", purpose: "信任说明", mutableAfterPublish: true, adjustmentMechanism: "可变", metricToWatch: "浏览时长" },
|
|
6
|
+
{ field: "rewards", purpose: "Reward 营销活动", mutableAfterPublish: true, adjustmentMechanism: "add/remove", metricToWatch: "复购率" },
|
|
7
|
+
{ field: "arbitrations", purpose: "仲裁升级", mutableAfterPublish: true, adjustmentMechanism: "可变", metricToWatch: "仲裁率" },
|
|
8
|
+
{ field: "compensation_fund", purpose: "增信", mutableAfterPublish: true, adjustmentMechanism: "add", metricToWatch: "信任分" },
|
|
9
|
+
{ field: "buy_guard", purpose: "购买门槛", mutableAfterPublish: true, adjustmentMechanism: "可变", metricToWatch: "下单率" },
|
|
10
|
+
{ field: "pause", purpose: "暂停/恢复", mutableAfterPublish: true, adjustmentMechanism: "可变", metricToWatch: "库存状态" },
|
|
11
|
+
{ field: "machine", purpose: "流程模板", mutableAfterPublish: false, adjustmentMechanism: "publish 后锁定,需新建 Service", metricToWatch: "流程速度" },
|
|
12
|
+
{ field: "order_allocators", purpose: "资金分配", mutableAfterPublish: false, adjustmentMechanism: "publish 后锁定,需新建 Service", metricToWatch: "分配公平性" },
|
|
13
|
+
{ field: "type_parameter", purpose: "支付代币", mutableAfterPublish: false, adjustmentMechanism: "不可变,可新建 Service + Reward 引导迁移", metricToWatch: "代币偏好" },
|
|
14
|
+
];
|
|
15
|
+
export function suggestPricing(signals) {
|
|
16
|
+
const { supplyCount, demandCount, avgPrice, myPrice, competitorPrices, recentOrderCount, repeatCustomerRate } = signals;
|
|
17
|
+
const supplyDemandRatio = demandCount / Math.max(1, supplyCount);
|
|
18
|
+
if (supplyDemandRatio > 2) {
|
|
19
|
+
const increasePercent = Math.min(30, Math.round((supplyDemandRatio - 1) * 10));
|
|
20
|
+
return {
|
|
21
|
+
action: "increase",
|
|
22
|
+
adjustmentPercent: increasePercent,
|
|
23
|
+
reason: `需求/供给比 ${supplyDemandRatio.toFixed(1)},市场供不应求,建议涨价 ${increasePercent}%`,
|
|
24
|
+
confidence: Math.min(0.9, 0.5 + supplyDemandRatio * 0.1),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (supplyDemandRatio < 0.5) {
|
|
28
|
+
const decreasePercent = Math.min(20, Math.round((1 - supplyDemandRatio) * 15));
|
|
29
|
+
return {
|
|
30
|
+
action: "decrease",
|
|
31
|
+
adjustmentPercent: decreasePercent,
|
|
32
|
+
reason: `需求/供给比 ${supplyDemandRatio.toFixed(1)},市场供过于求,建议降价 ${decreasePercent}% 以提升竞争力`,
|
|
33
|
+
confidence: Math.min(0.85, 0.5 + (1 - supplyDemandRatio) * 0.15),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (myPrice && competitorPrices && competitorPrices.length > 0) {
|
|
37
|
+
try {
|
|
38
|
+
const my = BigInt(myPrice);
|
|
39
|
+
const comps = competitorPrices.map((p) => BigInt(p));
|
|
40
|
+
const avgComp = comps.reduce((a, b) => a + b, 0n) / BigInt(comps.length);
|
|
41
|
+
if (my > avgComp * 120n / 100n) {
|
|
42
|
+
return {
|
|
43
|
+
action: "decrease",
|
|
44
|
+
adjustmentPercent: 10,
|
|
45
|
+
reason: `当前价格高于市场均价 20%+,建议降价以提升竞争力`,
|
|
46
|
+
confidence: 0.7,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (my < avgComp * 80n / 100n) {
|
|
50
|
+
return {
|
|
51
|
+
action: "increase",
|
|
52
|
+
adjustmentPercent: 10,
|
|
53
|
+
reason: `当前价格低于市场均价 20%+,有涨价空间`,
|
|
54
|
+
confidence: 0.65,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (repeatCustomerRate !== undefined && repeatCustomerRate > 0.4) {
|
|
62
|
+
return {
|
|
63
|
+
action: "maintain",
|
|
64
|
+
reason: `复购率 ${Math.round(repeatCustomerRate * 100)}%,定价策略有效,建议维持`,
|
|
65
|
+
confidence: 0.8,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (repeatCustomerRate !== undefined && repeatCustomerRate < 0.1 && (recentOrderCount ?? 0) > 10) {
|
|
69
|
+
return {
|
|
70
|
+
action: "decrease",
|
|
71
|
+
adjustmentPercent: 5,
|
|
72
|
+
reason: `复购率仅 ${Math.round(repeatCustomerRate * 100)}%,建议小幅降价或增加 Reward 吸引复购`,
|
|
73
|
+
confidence: 0.6,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
action: "maintain",
|
|
78
|
+
reason: "市场供需平衡,建议维持当前定价",
|
|
79
|
+
confidence: 0.5,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export function getMutableFields(published = true) {
|
|
83
|
+
return MUTABLE_FIELDS.filter((f) => published ? f.mutableAfterPublish : true);
|
|
84
|
+
}
|
|
85
|
+
export function getMutableField(field) {
|
|
86
|
+
return MUTABLE_FIELDS.find((f) => f.field === field);
|
|
87
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type IndustryHealthReport, type IndustryUpdateSuggestion, type OrderRawDataPoint } from "./industry-evolution.js";
|
|
2
|
+
import { type BusinessIntent, type AdviceRole } from "./intent-metrics.js";
|
|
3
|
+
export declare const FLYWHEEL_LOOP_VERSION = 2;
|
|
4
|
+
declare const MIN_SIGNALS_FOR_EVOLUTION = 10;
|
|
5
|
+
export type EvolutionScheduleMode = "realtime" | "semi_realtime" | "manual";
|
|
6
|
+
export interface EvolutionScheduleConfig {
|
|
7
|
+
mode: EvolutionScheduleMode;
|
|
8
|
+
signal_threshold?: number;
|
|
9
|
+
time_interval_ms?: number;
|
|
10
|
+
auto_apply?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface IndustrySignal {
|
|
13
|
+
industry: string;
|
|
14
|
+
operation_type: string;
|
|
15
|
+
success: boolean;
|
|
16
|
+
error_code?: string;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
decision_context_id?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function recordIndustrySignal(industry: string, operation: {
|
|
21
|
+
type: string;
|
|
22
|
+
data?: unknown;
|
|
23
|
+
}, outcome: {
|
|
24
|
+
success: boolean;
|
|
25
|
+
error_code?: string;
|
|
26
|
+
}): void;
|
|
27
|
+
export declare function setEvolutionSchedule(industry: string, config: EvolutionScheduleConfig): void;
|
|
28
|
+
export declare function getEvolutionSchedule(industry: string): EvolutionScheduleConfig;
|
|
29
|
+
export declare function setIndustryIntent(industry: string, intent: BusinessIntent): void;
|
|
30
|
+
export declare function getIndustryIntent(industry: string): BusinessIntent;
|
|
31
|
+
export declare function getIndustrySignalCount(industry: string): number;
|
|
32
|
+
export declare function getIndustrySignals(industry: string): IndustrySignal[];
|
|
33
|
+
export declare function listIndustriesWithSignals(): string[];
|
|
34
|
+
export declare function getPendingSuggestions(industry: string): IndustryUpdateSuggestion[];
|
|
35
|
+
export interface DecisionContext {
|
|
36
|
+
id: string;
|
|
37
|
+
node_id: string;
|
|
38
|
+
decided_at: number;
|
|
39
|
+
decider: "user" | "ai" | "system";
|
|
40
|
+
industry?: string;
|
|
41
|
+
intent?: string;
|
|
42
|
+
alternatives?: string[];
|
|
43
|
+
rationale?: string;
|
|
44
|
+
outcome?: "success" | "failed" | "pending";
|
|
45
|
+
}
|
|
46
|
+
export declare function recordDecisionContext(ctx: DecisionContext, graph?: {
|
|
47
|
+
attachDecisionContext: (nodeId: string, c: any) => unknown;
|
|
48
|
+
}): void;
|
|
49
|
+
export declare function queryDecisionsByIndustry(industry: string): DecisionContext[];
|
|
50
|
+
export declare function queryDecisionsByNode(nodeId: string): DecisionContext[];
|
|
51
|
+
export declare function backfillDecisionOutcome(decisionId: string, outcome: "success" | "failed" | "pending"): boolean;
|
|
52
|
+
export interface CognitionUpdateResult {
|
|
53
|
+
industry: string;
|
|
54
|
+
metrics_updated: boolean;
|
|
55
|
+
health_recomputed: boolean;
|
|
56
|
+
suggestions_generated: number;
|
|
57
|
+
evolution_ready: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare function updateIndustryCognition(industry: string, rawData?: OrderRawDataPoint[]): CognitionUpdateResult;
|
|
60
|
+
export interface EvolutionContext {
|
|
61
|
+
industry_signal?: string;
|
|
62
|
+
evolution_advice?: string;
|
|
63
|
+
confidence: number;
|
|
64
|
+
health_score?: number;
|
|
65
|
+
pending_suggestions?: number;
|
|
66
|
+
intent?: BusinessIntent;
|
|
67
|
+
role_advice?: string[];
|
|
68
|
+
role?: AdviceRole;
|
|
69
|
+
}
|
|
70
|
+
export declare function injectEvolutionContext(_semantic: unknown, industry?: string, role?: AdviceRole): EvolutionContext;
|
|
71
|
+
export interface IndustryEvolutionStatus {
|
|
72
|
+
industry: string;
|
|
73
|
+
version: string;
|
|
74
|
+
last_updated: number;
|
|
75
|
+
signal_count: number;
|
|
76
|
+
health?: IndustryHealthReport;
|
|
77
|
+
pending_suggestions: number;
|
|
78
|
+
evolution_ready: boolean;
|
|
79
|
+
}
|
|
80
|
+
export declare function getIndustryEvolutionStatus(industry: string): IndustryEvolutionStatus;
|
|
81
|
+
export declare const EVOLUTION_STATE_VERSION = 1;
|
|
82
|
+
export declare function saveEvolutionState(): string;
|
|
83
|
+
export declare function loadEvolutionState(): boolean;
|
|
84
|
+
export declare function hasPersistedEvolutionState(): boolean;
|
|
85
|
+
export declare function _resetFlywheelLoopForTest(): void;
|
|
86
|
+
export declare function _snapshotSignalBuffer(): Record<string, IndustrySignal[]>;
|
|
87
|
+
export { MIN_SIGNALS_FOR_EVOLUTION as FLYWHEEL_LOOP_MIN_SIGNALS };
|