@wowok/agent-mcp 2.3.18 → 2.4.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/customer/industry-risks.js +31 -31
- package/dist/customer/order-monitor.js +57 -57
- package/dist/customer/order-strategy.js +89 -89
- package/dist/customer/post-purchase.js +97 -97
- package/dist/customer/reminder-system.js +26 -26
- package/dist/customer/risk-assessment.js +46 -46
- package/dist/customer/types.d.ts +4 -4
- package/dist/customer/types.js +4 -4
- package/dist/customer/user-preferences.js +50 -50
- package/dist/experience/intent-distill.js +6 -6
- package/dist/knowledge/acquisition-flywheel.js +64 -64
- package/dist/knowledge/arbitration-trust.js +10 -10
- package/dist/knowledge/demand-matching.js +8 -8
- package/dist/knowledge/dynamic-pricing.js +18 -18
- package/dist/knowledge/flywheel-loop.js +11 -11
- package/dist/knowledge/glossary.js +22 -22
- package/dist/knowledge/guard-ledger.d.ts +1 -1
- package/dist/knowledge/guard-ledger.js +131 -104
- package/dist/knowledge/guard-lint.d.ts +76 -0
- package/dist/knowledge/guard-lint.js +590 -0
- package/dist/knowledge/guard-puzzle.d.ts +109 -14
- package/dist/knowledge/guard-puzzle.js +627 -101
- package/dist/knowledge/guard-risk.d.ts +8 -1
- package/dist/knowledge/guard-risk.js +868 -296
- package/dist/knowledge/guard-templates.d.ts +37 -0
- package/dist/knowledge/guard-templates.js +329 -0
- package/dist/knowledge/guard-translation.d.ts +14 -2
- package/dist/knowledge/guard-translation.js +825 -194
- package/dist/knowledge/index.d.ts +8 -4
- package/dist/knowledge/index.js +9 -5
- package/dist/knowledge/industry-evolution.js +29 -29
- package/dist/knowledge/industry-generalizer.js +52 -52
- package/dist/knowledge/industry-registry.js +20 -33
- package/dist/knowledge/intent-metrics.js +67 -67
- package/dist/knowledge/process-model.js +80 -80
- package/dist/knowledge/reputation-rules.js +9 -9
- package/dist/knowledge/reward-templates.js +51 -51
- package/dist/knowledge/safety-rules.js +3 -3
- package/dist/knowledge/tool-constraints.js +20 -4
- package/dist/knowledge/trust-metrics.js +26 -26
- package/dist/schema/call/base.js +16 -16
- package/dist/schema/call/bridge.d.ts +32 -32
- package/dist/schema/call/demand.d.ts +84 -84
- package/dist/schema/call/guard.d.ts +153 -0
- package/dist/schema/call/guard.js +50 -0
- package/dist/schema/call/permission.d.ts +78 -78
- package/dist/schema/call/repository.d.ts +22 -22
- package/dist/schema/call/semantic.js +228 -24
- package/dist/schema/local/wip.d.ts +39 -19
- package/dist/schema/local/wip.js +5 -5
- package/dist/schema/messenger/index.d.ts +26 -26
- package/dist/schema/messenger/index.js +2 -2
- package/dist/schema/operations.d.ts +222 -144
- package/dist/schema/query/index.d.ts +38 -38
- package/dist/schema/trust/index.d.ts +4 -4
- package/dist/schema/utils/guard-parser.js +4 -4
- package/dist/schema/utils/node-parser.js +14 -14
- package/dist/schemas/bridge_operation.output.json +14 -14
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.output.json +17 -15
- package/dist/schemas/onchain_events.output.json +14 -14
- package/dist/schemas/onchain_operations.output.json +14 -14
- package/dist/schemas/onchain_table_data.output.json +14 -14
- package/dist/schemas/wip_file.output.json +24 -1
- package/package.json +2 -2
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
export const REWARD_TEMPLATES = [
|
|
2
2
|
{
|
|
3
3
|
type: "first_order",
|
|
4
|
-
name: "
|
|
5
|
-
description: "
|
|
6
|
-
guardCondition: "Guard
|
|
4
|
+
name: "First-order reward",
|
|
5
|
+
description: "New customers receive a reward after their first order, lowering the trial barrier and boosting conversion.",
|
|
6
|
+
guardCondition: "Guard verifies: order_address.holder == current claimer, and order.service == this Service, and order is the first order for this holder (via Repository history query)",
|
|
7
7
|
amountRange: { min: "0.1WOW", max: "5WOW" },
|
|
8
8
|
allocationStrategy: "fixed",
|
|
9
9
|
parameters: [
|
|
10
|
-
{ name: "amount", type: "string", description: "
|
|
11
|
-
{ name: "budget", type: "string", description: "
|
|
10
|
+
{ name: "amount", type: "string", description: "Reward amount (e.g., '1WOW')", required: true },
|
|
11
|
+
{ name: "budget", type: "string", description: "Total budget (e.g., '100WOW')", required: true },
|
|
12
12
|
],
|
|
13
|
-
example: "
|
|
13
|
+
example: "A new customer orders a photography service and receives 1 WOW cashback on the first order, lowering the first trial cost.",
|
|
14
14
|
relevantGuardOps: ["query", "repository_read"],
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
type: "referral",
|
|
18
|
-
name: "
|
|
19
|
-
description: "
|
|
20
|
-
guardCondition: "Guard
|
|
18
|
+
name: "Referral viral reward",
|
|
19
|
+
description: "Existing customers refer new customers to place an order; both parties receive a reward, creating a word-of-mouth flywheel.",
|
|
20
|
+
guardCondition: "Guard verifies: referrer address is marked as 'referred_by' in the Repository review table, and the referee's order is completed (Progress reached terminal state)",
|
|
21
21
|
amountRange: { min: "0.5WOW", max: "10WOW" },
|
|
22
22
|
allocationStrategy: "proportional",
|
|
23
23
|
parameters: [
|
|
24
|
-
{ name: "referrer_reward", type: "string", description: "
|
|
25
|
-
{ name: "referee_reward", type: "string", description: "
|
|
26
|
-
{ name: "max_referrals", type: "number", description: "
|
|
24
|
+
{ name: "referrer_reward", type: "string", description: "Referrer reward (e.g., '2WOW')", required: true },
|
|
25
|
+
{ name: "referee_reward", type: "string", description: "Referee reward (e.g., '1WOW')", required: true },
|
|
26
|
+
{ name: "max_referrals", type: "number", description: "Max referrals per person (e.g., 10)", required: false },
|
|
27
27
|
],
|
|
28
|
-
example: "Alice
|
|
28
|
+
example: "Alice refers Bob to purchase a service; after Bob completes the first order, Alice gets 2 WOW and Bob gets 1 WOW.",
|
|
29
29
|
relevantGuardOps: ["query", "repository_read", "repository_write"],
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
type: "loyalty",
|
|
33
|
-
name: "
|
|
34
|
-
description: "
|
|
35
|
-
guardCondition: "Guard
|
|
33
|
+
name: "Loyalty tiered reward",
|
|
34
|
+
description: "Customers unlock higher rewards after reaching cumulative spending tiers, improving repeat rate and average order value.",
|
|
35
|
+
guardCondition: "Guard verifies: via Repository query, the address's historical order count >= N, where N is the current tier threshold",
|
|
36
36
|
amountRange: { min: "1WOW", max: "50WOW" },
|
|
37
37
|
allocationStrategy: "tiered",
|
|
38
38
|
parameters: [
|
|
39
|
-
{ name: "tier1_orders", type: "number", description: "
|
|
40
|
-
{ name: "tier1_reward", type: "string", description: "
|
|
41
|
-
{ name: "tier2_orders", type: "number", description: "
|
|
42
|
-
{ name: "tier2_reward", type: "string", description: "
|
|
43
|
-
{ name: "tier3_orders", type: "number", description: "
|
|
44
|
-
{ name: "tier3_reward", type: "string", description: "
|
|
39
|
+
{ name: "tier1_orders", type: "number", description: "Tier 1 order count (e.g., 3)", required: true },
|
|
40
|
+
{ name: "tier1_reward", type: "string", description: "Tier 1 reward (e.g., '1WOW')", required: true },
|
|
41
|
+
{ name: "tier2_orders", type: "number", description: "Tier 2 order count (e.g., 10)", required: true },
|
|
42
|
+
{ name: "tier2_reward", type: "string", description: "Tier 2 reward (e.g., '5WOW')", required: true },
|
|
43
|
+
{ name: "tier3_orders", type: "number", description: "Tier 3 order count (e.g., 30)", required: false },
|
|
44
|
+
{ name: "tier3_reward", type: "string", description: "Tier 3 reward (e.g., '20WOW')", required: false },
|
|
45
45
|
],
|
|
46
|
-
example: "
|
|
46
|
+
example: "A customer with 3 cumulative orders gets 1 WOW, 10 orders gets 5 WOW, 30 orders gets 20 WOW, incentivizing continued spending.",
|
|
47
47
|
relevantGuardOps: ["query", "repository_read"],
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
type: "flash_sale",
|
|
51
|
-
name: "
|
|
52
|
-
description: "
|
|
53
|
-
guardCondition: "Guard
|
|
51
|
+
name: "Limited-time flash sale",
|
|
52
|
+
description: "Provides discounts or extra rewards within a limited time window, creating urgency to drive instant conversion.",
|
|
53
|
+
guardCondition: "Guard verifies: current block time is within [start_time, end_time] range (Guard time condition)",
|
|
54
54
|
amountRange: { min: "0.1WOW", max: "20WOW" },
|
|
55
55
|
allocationStrategy: "fixed",
|
|
56
56
|
parameters: [
|
|
57
|
-
{ name: "start_time", type: "string", description: "
|
|
58
|
-
{ name: "end_time", type: "string", description: "
|
|
59
|
-
{ name: "amount", type: "string", description: "
|
|
60
|
-
{ name: "max_claims", type: "number", description: "
|
|
57
|
+
{ name: "start_time", type: "string", description: "Start time (Unix timestamp)", required: true },
|
|
58
|
+
{ name: "end_time", type: "string", description: "End time (Unix timestamp)", required: true },
|
|
59
|
+
{ name: "amount", type: "string", description: "Flash sale reward amount", required: true },
|
|
60
|
+
{ name: "max_claims", type: "number", description: "Max claims (e.g., 100)", required: true },
|
|
61
61
|
],
|
|
62
|
-
example: "
|
|
62
|
+
example: "Weekend 48-hour flash sale: ordering customers get an extra 2 WOW cashback, valid for the first 100.",
|
|
63
63
|
relevantGuardOps: ["query", "time_condition"],
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
type: "cashback",
|
|
67
|
-
name: "
|
|
68
|
-
description: "
|
|
69
|
-
guardCondition: "Guard
|
|
67
|
+
name: "Spending cashback",
|
|
68
|
+
description: "Customers receive cashback proportional to spending after completing an order, improving repeat purchase willingness.",
|
|
69
|
+
guardCondition: "Guard verifies: order has reached terminal state (Progress completed), and order.service == this Service",
|
|
70
70
|
amountRange: { min: "0.1WOW", max: "100WOW" },
|
|
71
71
|
allocationStrategy: "proportional",
|
|
72
72
|
parameters: [
|
|
73
|
-
{ name: "cashback_rate", type: "string", description: "
|
|
74
|
-
{ name: "max_cashback", type: "string", description: "
|
|
75
|
-
{ name: "budget", type: "string", description: "
|
|
73
|
+
{ name: "cashback_rate", type: "string", description: "Cashback rate (e.g., '0.1' = 10%)", required: true },
|
|
74
|
+
{ name: "max_cashback", type: "string", description: "Max cashback per order (e.g., '10WOW')", required: true },
|
|
75
|
+
{ name: "budget", type: "string", description: "Total budget (e.g., '500WOW')", required: true },
|
|
76
76
|
],
|
|
77
|
-
example: "
|
|
77
|
+
example: "A customer spends 10 WOW, gets 10% cashback = 1 WOW, which can be deducted on the next purchase.",
|
|
78
78
|
relevantGuardOps: ["query"],
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
type: "milestone",
|
|
82
|
-
name: "
|
|
83
|
-
description: "Service
|
|
84
|
-
guardCondition: "Guard
|
|
82
|
+
name: "Milestone reward",
|
|
83
|
+
description: "When a Service reaches a specific milestone (e.g., 100 orders, 1000 customers), early supporters receive extra rewards.",
|
|
84
|
+
guardCondition: "Guard verifies: Repository query shows Service cumulative order count >= milestone_threshold, and claimer is an early customer (order_index < milestone)",
|
|
85
85
|
amountRange: { min: "1WOW", max: "100WOW" },
|
|
86
86
|
allocationStrategy: "fixed",
|
|
87
87
|
parameters: [
|
|
88
|
-
{ name: "milestone", type: "number", description: "
|
|
89
|
-
{ name: "reward_per_user", type: "string", description: "
|
|
90
|
-
{ name: "max_recipients", type: "number", description: "
|
|
88
|
+
{ name: "milestone", type: "number", description: "Milestone value (e.g., 100)", required: true },
|
|
89
|
+
{ name: "reward_per_user", type: "string", description: "Reward per person (e.g., '5WOW')", required: true },
|
|
90
|
+
{ name: "max_recipients", type: "number", description: "Max beneficiaries (e.g., 50)", required: true },
|
|
91
91
|
],
|
|
92
|
-
example: "Service
|
|
92
|
+
example: "Service reaches the 100-order milestone; the first 50 customers each receive 5 WOW extra reward.",
|
|
93
93
|
relevantGuardOps: ["query", "repository_read"],
|
|
94
94
|
},
|
|
95
95
|
];
|
|
@@ -102,22 +102,22 @@ export function listRewardTemplates() {
|
|
|
102
102
|
}
|
|
103
103
|
export function suggestRewardTemplate(intent) {
|
|
104
104
|
const lower = intent.toLowerCase();
|
|
105
|
-
if (lower.includes("
|
|
105
|
+
if (lower.includes("first order") || lower.includes("new") || lower.includes("first")) {
|
|
106
106
|
return getRewardTemplate("first_order");
|
|
107
107
|
}
|
|
108
|
-
if (lower.includes("
|
|
108
|
+
if (lower.includes("referral") || lower.includes("viral") || lower.includes("referral")) {
|
|
109
109
|
return getRewardTemplate("referral");
|
|
110
110
|
}
|
|
111
|
-
if (lower.includes("
|
|
111
|
+
if (lower.includes("repeat") || lower.includes("loyalty") || lower.includes("loyalty")) {
|
|
112
112
|
return getRewardTemplate("loyalty");
|
|
113
113
|
}
|
|
114
|
-
if (lower.includes("
|
|
114
|
+
if (lower.includes("limited-time") || lower.includes("flash") || lower.includes("flash")) {
|
|
115
115
|
return getRewardTemplate("flash_sale");
|
|
116
116
|
}
|
|
117
|
-
if (lower.includes("
|
|
117
|
+
if (lower.includes("cashback") || lower.includes("cashback")) {
|
|
118
118
|
return getRewardTemplate("cashback");
|
|
119
119
|
}
|
|
120
|
-
if (lower.includes("
|
|
120
|
+
if (lower.includes("milestone") || lower.includes("milestone")) {
|
|
121
121
|
return getRewardTemplate("milestone");
|
|
122
122
|
}
|
|
123
123
|
return undefined;
|
|
@@ -146,8 +146,8 @@ export const CONFIRMATION_RULES = [
|
|
|
146
146
|
bypass_on_explicit_intent: [
|
|
147
147
|
"use default account",
|
|
148
148
|
"default account is fine",
|
|
149
|
-
"
|
|
150
|
-
"
|
|
149
|
+
"use the default account",
|
|
150
|
+
"default account works fine",
|
|
151
151
|
],
|
|
152
152
|
},
|
|
153
153
|
{
|
|
@@ -209,7 +209,7 @@ export const CONFIRMATION_RULES = [
|
|
|
209
209
|
"gen_passport will consume gas for static testing",
|
|
210
210
|
],
|
|
211
211
|
}),
|
|
212
|
-
bypass_on_explicit_intent: ["test guard", "
|
|
212
|
+
bypass_on_explicit_intent: ["test guard", "testing guard", "gen passport", "generate passport"],
|
|
213
213
|
},
|
|
214
214
|
];
|
|
215
215
|
function extractAmount(data) {
|
|
@@ -26,8 +26,8 @@ export const TOOL_CONSTRAINTS = [
|
|
|
26
26
|
constraints: [
|
|
27
27
|
{
|
|
28
28
|
field: "node.nodes",
|
|
29
|
-
description: "Machine
|
|
30
|
-
severity: "
|
|
29
|
+
description: "Machine must have at least one node when published",
|
|
30
|
+
severity: "error",
|
|
31
31
|
check: (d) => {
|
|
32
32
|
if (typeof d?.object === "string")
|
|
33
33
|
return true;
|
|
@@ -61,7 +61,15 @@ export const TOOL_CONSTRAINTS = [
|
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
operation_type: "order",
|
|
64
|
-
constraints: [
|
|
64
|
+
constraints: [
|
|
65
|
+
{
|
|
66
|
+
field: "object",
|
|
67
|
+
description: "Order requires an existing Order object reference",
|
|
68
|
+
severity: "error",
|
|
69
|
+
check: (d) => !!d?.object,
|
|
70
|
+
message: () => "Order requires 'object' field (Order object ID or name).",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
65
73
|
},
|
|
66
74
|
{
|
|
67
75
|
operation_type: "reward",
|
|
@@ -118,7 +126,15 @@ export const TOOL_CONSTRAINTS = [
|
|
|
118
126
|
},
|
|
119
127
|
{
|
|
120
128
|
operation_type: "progress",
|
|
121
|
-
constraints: [
|
|
129
|
+
constraints: [
|
|
130
|
+
{
|
|
131
|
+
field: "object",
|
|
132
|
+
description: "Progress requires an existing Progress object reference",
|
|
133
|
+
severity: "error",
|
|
134
|
+
check: (d) => !!d?.object,
|
|
135
|
+
message: () => "Progress requires 'object' field (Progress object ID or name).",
|
|
136
|
+
},
|
|
137
|
+
],
|
|
122
138
|
},
|
|
123
139
|
];
|
|
124
140
|
const CONSTRAINT_INDEX = new Map(TOOL_CONSTRAINTS.map((c) => [c.operation_type, c]));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const TRUST_METRICS_VERSION = 1;
|
|
2
2
|
const TRUST_LEVELS = [
|
|
3
|
-
{ min: 75, level: "trusted", label: "
|
|
4
|
-
{ min: 50, level: "moderate", label: "
|
|
5
|
-
{ min: 25, level: "caution", label: "
|
|
6
|
-
{ min: 0, level: "high_risk", label: "
|
|
3
|
+
{ min: 75, level: "trusted", label: "High trust" },
|
|
4
|
+
{ min: 50, level: "moderate", label: "Moderate trust" },
|
|
5
|
+
{ min: 25, level: "caution", label: "Needs attention" },
|
|
6
|
+
{ min: 0, level: "high_risk", label: "High risk" },
|
|
7
7
|
];
|
|
8
8
|
export function computeServiceTrustScore(metrics) {
|
|
9
9
|
const breakdown = [];
|
|
@@ -11,49 +11,49 @@ export function computeServiceTrustScore(metrics) {
|
|
|
11
11
|
const arbScore = computeArbitrationDimension(metrics);
|
|
12
12
|
breakdown.push(arbScore);
|
|
13
13
|
if (arbScore.score < arbScore.maxScore * 0.3) {
|
|
14
|
-
warnings.push("
|
|
14
|
+
warnings.push("Arbitration trust score is low; recommend checking arbitration records");
|
|
15
15
|
}
|
|
16
16
|
const reviewScore = computeReviewDimension(metrics);
|
|
17
17
|
breakdown.push(reviewScore);
|
|
18
18
|
if (reviewScore.score < reviewScore.maxScore * 0.3 && metrics.reviewStats) {
|
|
19
|
-
warnings.push(
|
|
19
|
+
warnings.push(`Low like rate (${metrics.reviewStats.likes}/${metrics.reviewStats.totalReviews})`);
|
|
20
20
|
}
|
|
21
21
|
const fulfillmentScore = computeFulfillmentDimension(metrics);
|
|
22
22
|
breakdown.push(fulfillmentScore);
|
|
23
23
|
if (metrics.completedRate !== undefined && metrics.completedRate < 0.7) {
|
|
24
|
-
warnings.push(
|
|
24
|
+
warnings.push(`Completion rate only ${Math.round(metrics.completedRate * 100)}%`);
|
|
25
25
|
}
|
|
26
26
|
const fundScore = computeFundDimension(metrics);
|
|
27
27
|
breakdown.push(fundScore);
|
|
28
28
|
if (metrics.compensationFundBalance === undefined || metrics.compensationFundBalance === 0n) {
|
|
29
|
-
warnings.push("
|
|
29
|
+
warnings.push("No compensation fund; insufficient protection of customer rights");
|
|
30
30
|
}
|
|
31
31
|
const transparencyScore = computeTransparencyDimension(metrics);
|
|
32
32
|
breakdown.push(transparencyScore);
|
|
33
33
|
const totalScore = breakdown.reduce((sum, d) => sum + d.score, 0);
|
|
34
34
|
const level = TRUST_LEVELS.find((l) => totalScore >= l.min)?.level ?? "high_risk";
|
|
35
|
-
const label = TRUST_LEVELS.find((l) => totalScore >= l.min)?.label ?? "
|
|
35
|
+
const label = TRUST_LEVELS.find((l) => totalScore >= l.min)?.label ?? "High risk";
|
|
36
36
|
const summary = buildSummary(totalScore, label, metrics, breakdown);
|
|
37
37
|
return { score: totalScore, level, breakdown, summary, warnings };
|
|
38
38
|
}
|
|
39
39
|
function computeArbitrationDimension(metrics) {
|
|
40
40
|
const maxScore = 30;
|
|
41
41
|
if (metrics.arbitrationScore === undefined) {
|
|
42
|
-
return { name: "arbitration", score: maxScore * 0.5, maxScore, description: "
|
|
42
|
+
return { name: "arbitration", score: maxScore * 0.5, maxScore, description: "Arbitration trust score (no data, default moderate)", humanReadable: "Arbitration record: no data" };
|
|
43
43
|
}
|
|
44
44
|
const score = Math.round((metrics.arbitrationScore / 100) * maxScore);
|
|
45
45
|
return {
|
|
46
46
|
name: "arbitration",
|
|
47
47
|
score,
|
|
48
48
|
maxScore,
|
|
49
|
-
description:
|
|
50
|
-
humanReadable:
|
|
49
|
+
description: `Arbitration trust score ${metrics.arbitrationScore}/100`,
|
|
50
|
+
humanReadable: `Arbitration trust: ${metrics.arbitrationScore}/100${metrics.arbitrationCases !== undefined ? ` (${metrics.arbitrationCases} cases)` : ""}`,
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
function computeReviewDimension(metrics) {
|
|
54
54
|
const maxScore = 25;
|
|
55
55
|
if (!metrics.reviewStats || metrics.reviewStats.totalReviews === 0) {
|
|
56
|
-
return { name: "reviews", score: maxScore * 0.5, maxScore, description: "
|
|
56
|
+
return { name: "reviews", score: maxScore * 0.5, maxScore, description: "Review reputation (no review data)", humanReadable: "Reviews: no data" };
|
|
57
57
|
}
|
|
58
58
|
const { likes, dislikes, verifiedReviews, totalReviews } = metrics.reviewStats;
|
|
59
59
|
const likeRate = likes / Math.max(1, totalReviews);
|
|
@@ -63,14 +63,14 @@ function computeReviewDimension(metrics) {
|
|
|
63
63
|
name: "reviews",
|
|
64
64
|
score: Math.min(maxScore, score),
|
|
65
65
|
maxScore,
|
|
66
|
-
description:
|
|
67
|
-
humanReadable:
|
|
66
|
+
description: `Like rate ${Math.round(likeRate * 100)}% (${totalReviews} reviews, ${verifiedReviews} verified)`,
|
|
67
|
+
humanReadable: `Like rate ${Math.round(likeRate * 100)}% (${totalReviews} reviews)`,
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
function computeFulfillmentDimension(metrics) {
|
|
71
71
|
const maxScore = 20;
|
|
72
72
|
if (metrics.orderCount === undefined) {
|
|
73
|
-
return { name: "fulfillment", score: maxScore * 0.5, maxScore, description: "
|
|
73
|
+
return { name: "fulfillment", score: maxScore * 0.5, maxScore, description: "Fulfillment record (no order data)", humanReadable: "Fulfillment: no data" };
|
|
74
74
|
}
|
|
75
75
|
let score = 0;
|
|
76
76
|
const orderScore = Math.min(10, Math.floor(metrics.orderCount / 5));
|
|
@@ -85,14 +85,14 @@ function computeFulfillmentDimension(metrics) {
|
|
|
85
85
|
name: "fulfillment",
|
|
86
86
|
score: Math.min(maxScore, score),
|
|
87
87
|
maxScore,
|
|
88
|
-
description:
|
|
89
|
-
humanReadable:
|
|
88
|
+
description: `Completed ${metrics.orderCount} orders, completion rate ${metrics.completedRate !== undefined ? Math.round(metrics.completedRate * 100) + "%" : "unknown"}`,
|
|
89
|
+
humanReadable: `Fulfillment: ${metrics.orderCount} orders${metrics.avgCompletionTime !== undefined ? `, avg ${metrics.avgCompletionTime}h` : ""}`,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
function computeFundDimension(metrics) {
|
|
93
93
|
const maxScore = 15;
|
|
94
94
|
if (metrics.compensationFundBalance === undefined || metrics.compensationFundBalance === 0n) {
|
|
95
|
-
return { name: "fund_safety", score: 0, maxScore, description: "
|
|
95
|
+
return { name: "fund_safety", score: 0, maxScore, description: "No compensation fund", humanReadable: "Compensation fund: none" };
|
|
96
96
|
}
|
|
97
97
|
const threshold = 1000000000000n;
|
|
98
98
|
const ratio = Number(metrics.compensationFundBalance * 100n / threshold) / 100;
|
|
@@ -101,8 +101,8 @@ function computeFundDimension(metrics) {
|
|
|
101
101
|
name: "fund_safety",
|
|
102
102
|
score,
|
|
103
103
|
maxScore,
|
|
104
|
-
description:
|
|
105
|
-
humanReadable:
|
|
104
|
+
description: `Compensation fund ${metrics.compensationFundBalance} smallest unit`,
|
|
105
|
+
humanReadable: `Compensation fund: sufficient`,
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
function computeTransparencyDimension(metrics) {
|
|
@@ -118,12 +118,12 @@ function computeTransparencyDimension(metrics) {
|
|
|
118
118
|
name: "transparency",
|
|
119
119
|
score: Math.min(maxScore, score),
|
|
120
120
|
maxScore,
|
|
121
|
-
description:
|
|
122
|
-
humanReadable:
|
|
121
|
+
description: `On-chain events ${metrics.hasPublishedEvents ? "✓" : "✗"}, Machine ${metrics.hasMachineBound ? "✓" : "✗"}, Guard ${metrics.hasBuyGuard ? "✓" : "✗"}`,
|
|
122
|
+
humanReadable: `Transparency: ${["Events", "Machine", "Guard"].filter((_, i) => [metrics.hasPublishedEvents, metrics.hasMachineBound, metrics.hasBuyGuard][i]).join("+") || "none"}`,
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
function buildSummary(score, label, metrics, breakdown) {
|
|
126
|
-
const parts = [
|
|
126
|
+
const parts = [`Trust score ${score}/100 (${label})`];
|
|
127
127
|
for (const d of breakdown) {
|
|
128
128
|
parts.push(`${d.humanReadable}`);
|
|
129
129
|
}
|
|
@@ -132,7 +132,7 @@ function buildSummary(score, label, metrics, breakdown) {
|
|
|
132
132
|
export function quickTrustCheck(metrics) {
|
|
133
133
|
const result = computeServiceTrustScore(metrics);
|
|
134
134
|
if (result.score < 25) {
|
|
135
|
-
return { pass: false, reason:
|
|
135
|
+
return { pass: false, reason: `Trust score ${result.score}/100, high risk: ${result.warnings.join("; ")}` };
|
|
136
136
|
}
|
|
137
|
-
return { pass: true, reason:
|
|
137
|
+
return { pass: true, reason: `Trust score ${result.score}/100 (${result.level})` };
|
|
138
138
|
}
|
package/dist/schema/call/base.js
CHANGED
|
@@ -122,7 +122,7 @@ export const ExperienceSchema = z.object({
|
|
|
122
122
|
avoid: z.array(z.string()).optional().describe("Pitfalls to avoid based on history. Example: ['Guard rejection on delivery_proof']"),
|
|
123
123
|
relevance: z.number().min(0).max(1).optional().describe("Relevance score 0-1 of the matched experience. Example: 0.85"),
|
|
124
124
|
matched_scenario: z.string().optional().describe("Matched historical scenario. Example: 'publish_service_freelance'"),
|
|
125
|
-
}).strict().describe("Experience layer feedback from past operations (Phase 2
|
|
125
|
+
}).strict().describe("Experience layer feedback from past operations (Phase 2 Topic 2). Provides advice and pitfalls based on historical patterns.");
|
|
126
126
|
export const ServiceStatusSchema = z.object({
|
|
127
127
|
active: z.array(z.string()).describe("Phase 2 services currently active (enabled). Example: ['confirm_gate','project_service','experience_layer']"),
|
|
128
128
|
inactive: z.array(z.string()).optional().describe("Phase 2 services currently inactive (can be toggled via config_operation). Example: ['harness','graph_persist']"),
|
|
@@ -131,29 +131,29 @@ export const CustomerReminderSchema = z.object({
|
|
|
131
131
|
id: z.string().describe("Reminder rule id. Example: 'high_risk_score'"),
|
|
132
132
|
stage: z.enum(["browse", "evaluate", "preorder", "in_progress", "complete", "after_sale"]).describe("Order lifecycle stage when this reminder fires. Example: 'evaluate'"),
|
|
133
133
|
priority: z.enum(["required", "recommended", "info", "reminder"]).describe("Priority. 'required' = blocks purchase; 'recommended' = strong caution. Example: 'required'"),
|
|
134
|
-
message: z.string().describe("Human-readable reminder message. Example: '
|
|
134
|
+
message: z.string().describe("Human-readable reminder message. Example: 'Composite risk score 25/100, strongly discourage purchase'"),
|
|
135
135
|
action: z.string().optional().describe("Suggested next action. Example: 'require merchant to bind Arbitration before ordering'"),
|
|
136
136
|
}).strict().describe("A buyer-side reminder triggered at a specific order lifecycle stage (Phase 3 C-3).");
|
|
137
137
|
export const PreferenceMatchSchema = z.object({
|
|
138
138
|
score: z.number().min(0).max(100).describe("Match score 0-100 (higher = better fit). Example: 75"),
|
|
139
|
-
matches: z.array(z.string()).describe("Aspects that match user preferences. Example: ['
|
|
140
|
-
mismatches: z.array(z.string()).describe("Aspects that mismatch user preferences. Example: ['
|
|
139
|
+
matches: z.array(z.string()).describe("Aspects that match user preferences. Example: ['Price 10% below average','Has arbitration']"),
|
|
140
|
+
mismatches: z.array(z.string()).describe("Aspects that mismatch user preferences. Example: ['Delivery cycle exceeds expectation']"),
|
|
141
141
|
}).strict().describe("Service-to-preference match result (Phase 3 C-2). 7-dimension scoring: price/time/region/brand/bargain/emotion/risk.");
|
|
142
142
|
export const CustomerAdviceSchema = z.object({
|
|
143
143
|
risk_score: z.number().min(0).max(100).optional().describe("Composite risk score 0-100 (higher = safer). Relation: from risk-assessment.ts 4-dimension scoring. Example: 75"),
|
|
144
144
|
risk_level: z.enum(["low", "medium_low", "medium_high", "high"]).optional().describe("Risk level bucket. 'high' = strongly discourage purchase. Example: 'medium_high'"),
|
|
145
|
-
recommendations: z.array(z.string()).describe("Actionable recommendations for the buyer. Example: ['
|
|
146
|
-
reminders: z.array(CustomerReminderSchema).describe("Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'
|
|
145
|
+
recommendations: z.array(z.string()).describe("Actionable recommendations for the buyer. Example: ['Require merchant to configure arbitration','Negotiate refund terms via Messenger']"),
|
|
146
|
+
reminders: z.array(CustomerReminderSchema).describe("Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'Ambiguous Guard must be human-reviewed'}]"),
|
|
147
147
|
preference_match: PreferenceMatchSchema.optional().describe("Service-to-preference match (populated when user preferences exist). Example: {score:75, matches:[...], mismatches:[...]}"),
|
|
148
148
|
}).strict().describe("Buyer-side advice (Phase 3 C-3.3). Populated in semantic.customer_advice for order/query operations when customer_intelligence service is enabled.");
|
|
149
149
|
export const EvolutionContextSchema = z.object({
|
|
150
|
-
industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: '
|
|
151
|
-
evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: '
|
|
150
|
+
industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: 'Industry health 82/100 (healthy); 25 cumulative industry signals'"),
|
|
151
|
+
evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: 'Recommend mandatory arbitration + compensation fund + delivery Guard'"),
|
|
152
152
|
confidence: z.number().min(0).max(1).describe("Confidence of the evolution context 0-1. <0.5 means no data yet. Example: 0.75"),
|
|
153
153
|
health_score: z.number().min(0).max(100).optional().describe("Industry health score 0-100 if available. Example: 82"),
|
|
154
154
|
pending_suggestions: z.number().int().min(0).optional().describe("Count of pending industry update suggestions (filtered by role if role is set). Example: 3"),
|
|
155
155
|
intent: z.enum(["default", "growth", "retention", "compliance", "efficiency", "trust_building", "custom"]).optional().describe("Phase 4 P4-6.C: Current business intent driving the scoring model. Absent = 'default'. Example: 'growth'"),
|
|
156
|
-
role_advice: z.array(z.string()).optional().describe("Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['
|
|
156
|
+
role_advice: z.array(z.string()).optional().describe("Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['Strengthen loyalty flywheel','Optimize first-order conversion']"),
|
|
157
157
|
role: z.enum(["user", "merchant", "arbitrator"]).optional().describe("Phase 4 P4-6.C: Role used for advice routing. Example: 'merchant'"),
|
|
158
158
|
}).strict().describe("Phase 4 industry evolution context (populated when industry_evolution service is enabled). Provides AI with industry-level health signals, evolution advice, and role-targeted recommendations.");
|
|
159
159
|
export const GuardPuzzleStatusSchema = z.object({
|
|
@@ -179,17 +179,17 @@ export const GuardAdviceSchema = z.object({
|
|
|
179
179
|
matched_scene: z.string().optional()
|
|
180
180
|
.describe("Matched Guard scene id from the 8 binding scenarios ledger. Example: 'machine_forward_guard'"),
|
|
181
181
|
scene_description: z.string().optional()
|
|
182
|
-
.describe("Human-readable scene description. Example: '
|
|
182
|
+
.describe("Human-readable scene description. Example: 'Workflow node forward validation (Forward.guard)'"),
|
|
183
183
|
scene_constraints: z.array(z.string()).optional()
|
|
184
|
-
.describe("Special constraints for the matched scene. Example: ['
|
|
184
|
+
.describe("Special constraints for the matched scene. Example: ['Forward.guard cannot be modified after Machine is published']"),
|
|
185
185
|
suggested_patterns: z.array(z.string()).optional()
|
|
186
|
-
.describe("Suggested Guard patterns based on user intent. Example: ['
|
|
186
|
+
.describe("Suggested Guard patterns based on user intent. Example: ['time lock','progress status check']"),
|
|
187
187
|
available_queries: z.array(GuardAvailableQuerySchema).optional()
|
|
188
188
|
.describe("Available query instructions for the current context (subset of 375 GUARDQUERY entries)"),
|
|
189
189
|
risk_warnings: z.array(z.string()).optional()
|
|
190
|
-
.describe("Risk warnings for the current Guard design. Example: ['Guard
|
|
190
|
+
.describe("Risk warnings for the current Guard design. Example: ['Guard cannot be modified after creation','Time lock test uses 1000ms']"),
|
|
191
191
|
pending_questions: z.array(z.string()).optional()
|
|
192
|
-
.describe("Questions for the user to complete the puzzle. Example: ['
|
|
192
|
+
.describe("Questions for the user to complete the puzzle. Example: ['Which Host Object will the Guard bind to?']"),
|
|
193
193
|
confirmation_text: z.string().optional()
|
|
194
194
|
.describe("Structured semantic confirmation text for user review (generated when puzzle is complete). User must explicitly confirm before CREATE."),
|
|
195
195
|
test_result: z.object({
|
|
@@ -217,7 +217,7 @@ export const SemanticSummarySchema = z.object({
|
|
|
217
217
|
events: z.array(EventSemanticSchema).optional().describe("On-chain events annotated with business semantics (S-8)"),
|
|
218
218
|
next_actions: z.array(NextActionSchema).optional().describe("Recommended next actions to drive the workflow forward"),
|
|
219
219
|
warnings: z.array(z.string()).optional().describe("Business-level warnings. Example: 'order_allocators not configured; order funds cannot be distributed'"),
|
|
220
|
-
experience: ExperienceSchema.optional().describe("Experience layer feedback from past operations (Phase 2
|
|
220
|
+
experience: ExperienceSchema.optional().describe("Experience layer feedback from past operations (Phase 2 Topic 2)"),
|
|
221
221
|
service_status: ServiceStatusSchema.optional().describe("Phase 2 runtime service status (populated when semantic_rich is enabled). Lets AI see active services in each response."),
|
|
222
222
|
customer_advice: CustomerAdviceSchema.optional().describe("Buyer-side advice (Phase 3 C-3.3). Populated when customer_intelligence service is enabled AND operation is order/query on a Service. Contains risk_score, recommendations, reminders, and preference_match."),
|
|
223
223
|
evolution_context: EvolutionContextSchema.optional().describe("Phase 4 industry evolution context (populated when industry_evolution service is enabled). Provides AI with industry health signals and evolution advice."),
|
|
@@ -246,7 +246,7 @@ export const OperationPreviewSchema = z.object({
|
|
|
246
246
|
immutable_after: z.array(z.string()).optional().describe("Fields that become immutable after this op (for publish). Example: ['machine','order_allocators']"),
|
|
247
247
|
warnings: z.array(z.string()).optional().describe("Default-value warnings. Example: ['Using default account (env.account=\"\")']"),
|
|
248
248
|
irreversible: z.boolean().optional().describe("True when the operation cannot be reverted. Example: true"),
|
|
249
|
-
}).strict().describe("Preview of an operation awaiting user confirmation (Phase 2
|
|
249
|
+
}).strict().describe("Preview of an operation awaiting user confirmation (Phase 2 Topic 4 ConfirmGate).");
|
|
250
250
|
export const CallPendingConfirmationSchema = z.object({
|
|
251
251
|
type: z.literal("pending_confirmation").describe("Discriminator. The operation was NOT executed; it is blocked pending user confirmation. Re-call with env.confirmed=true to proceed, or modify/cancel."),
|
|
252
252
|
preview: OperationPreviewSchema.describe("Preview of the operation awaiting confirmation."),
|