@wowok/agent-mcp 2.6.1 → 2.6.3
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/info-puzzle.d.ts +1 -1
- package/dist/customer/info-puzzle.js +4 -2
- package/dist/customer/risk-assessment.js +26 -4
- package/dist/customer/types.d.ts +2 -0
- package/dist/examples/guard-template-balance-check.json +38 -0
- package/dist/examples/guard-template-time-lock.json +39 -0
- package/dist/examples/machine-template-7node-rental.json +114 -0
- package/dist/examples/rental-ziroom-machine-create.json +137 -0
- package/dist/examples/rental-ziroom-permission-create.json +35 -0
- package/dist/examples/rental-ziroom-service-create.json +80 -0
- package/dist/examples/retail-myshop-service-create.json +88 -0
- package/dist/extensions/capability-manifest.js +24 -24
- package/dist/extensions/constraint-registry.js +18 -18
- package/dist/extensions/metric-registry.js +14 -14
- package/dist/extensions/mode-evaluator.js +16 -16
- package/dist/extensions/modes.js +131 -45
- package/dist/extensions/registry.d.ts +2 -0
- package/dist/extensions/registry.js +63 -30
- package/dist/extensions/types.d.ts +1 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +72 -0
- package/dist/knowledge/fund-layer.js +420 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-templates.js +4 -4
- package/dist/knowledge/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- package/dist/knowledge/service-confirm.d.ts +1 -1
- package/dist/knowledge/service-confirm.js +3 -3
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- package/dist/project/deployment-bridge.js +6 -5
- package/dist/project/deployment-doc.js +5 -5
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1371 -0
- package/dist/project/evaluation.js +314 -14
- package/dist/project/graph-builder.js +6 -1
- package/dist/project/handlers.d.ts +99 -2
- package/dist/project/handlers.js +358 -16
- package/dist/project/stage-gate.js +4 -4
- package/dist/schema/call/allocation.js +2 -2
- package/dist/schema/call/arbitration.js +19 -6
- package/dist/schema/call/contact.js +2 -2
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +1975 -777
- package/dist/schema/call/machine.js +50 -4
- package/dist/schema/call/order.js +3 -6
- package/dist/schema/call/permission.js +2 -2
- package/dist/schema/call/repository.js +2 -2
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.js +7 -1
- package/dist/schema/call/service.d.ts +180 -8
- package/dist/schema/call/service.js +82 -27
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +2 -0
- package/dist/schema/common/index.js +46 -10
- package/dist/schema/local/index.js +5 -1
- package/dist/schema/operations.d.ts +755 -176
- package/dist/schema/operations.js +43 -7
- package/dist/schema/project/index.d.ts +969 -6
- package/dist/schema/project/index.js +268 -4
- package/dist/schema/query/index.d.ts +217 -0
- package/dist/schema/query/index.js +63 -33
- package/dist/schema/schema-query/index.d.ts +53 -3
- package/dist/schema/schema-query/index.js +17 -2
- package/dist/schema/utils/node-parser.js +13 -0
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +76 -0
- package/dist/schema-query/index.d.ts +14 -1
- package/dist/schema-query/index.js +104 -2
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +115 -53
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +9 -7
- package/dist/schemas/onchain_operations_contact.schema.json +3 -3
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +4 -4
- package/dist/schemas/onchain_operations_order.schema.json +3 -3
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +1 -1
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +3 -3
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +77 -17
- package/dist/schemas/onchain_operations_treasury.schema.json +4 -4
- package/dist/schemas/onchain_table_data.output.json +1 -1
- package/dist/schemas/onchain_table_data.schema.json +10 -9
- package/dist/schemas/project_operation.output.json +1026 -7
- package/dist/schemas/project_operation.schema.json +46 -4
- package/dist/schemas/query_toolkit.output.json +15 -15
- package/dist/schemas/query_toolkit.schema.json +3 -3
- package/dist/schemas/schema_query.output.json +64 -1
- package/dist/schemas/schema_query.schema.json +3 -2
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/onchain.js +571 -6
- package/dist/tools/handlers/project.js +25 -2
- package/dist/tools/handlers/schema-query.js +24 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +177 -6
- package/package.json +2 -2
package/dist/extensions/modes.js
CHANGED
|
@@ -64,19 +64,47 @@ const RETAIL_BUILD_NOTES = [
|
|
|
64
64
|
"Refund path must support return-and-exchange flow",
|
|
65
65
|
"Compensation fund covers return/exchange disputes",
|
|
66
66
|
];
|
|
67
|
+
const RETAIL_D2C_MACHINE_SHAPE = [
|
|
68
|
+
{ name: "ordered", role: "Entry: order created (funds escrowed in Allocation)" },
|
|
69
|
+
{ name: "shipped", role: "Merchant ships goods" },
|
|
70
|
+
{ name: "delivered", role: "Goods delivered to buyer" },
|
|
71
|
+
{ name: "completed", role: "Buyer confirms receipt — withdraw_guard releases funds" },
|
|
72
|
+
{ name: "cancelled", role: "Pre-ship cancellation — refund_guard refunds buyer" },
|
|
73
|
+
];
|
|
74
|
+
const RETAIL_D2C_GUARDS = [
|
|
75
|
+
{ template_id: "withdraw_guard_delivery", host: "service", purpose: "Release funds to merchant + processor on order completion (delivery confirmation)" },
|
|
76
|
+
{ template_id: "refund_guard_cancellation", host: "service", purpose: "Refund 100% to buyer on order cancellation" },
|
|
77
|
+
];
|
|
78
|
+
const RETAIL_D2C_ALLOCATOR = {
|
|
79
|
+
recipient: "entity",
|
|
80
|
+
count: 2,
|
|
81
|
+
mode: "rate",
|
|
82
|
+
description: "Merchant 97% + Processor 3% (rate-based split, no platform commission)",
|
|
83
|
+
};
|
|
84
|
+
const RETAIL_D2C_KEY_RISK = "No platform arbitration — disputes rely on optional Arbitration or off-chain chargeback";
|
|
85
|
+
const RETAIL_D2C_BUILD_NOTES = [
|
|
86
|
+
"Allocation escrow replaces platform custody — funds locked in contract until Guard releases",
|
|
87
|
+
"withdraw_guard enforces delivery gate — merchant must reach 'completed' state to receive payment",
|
|
88
|
+
"refund_guard ensures 100% refund on cancellation — no merchant approval needed",
|
|
89
|
+
"No buy_guard needed — D2C doesn't gate purchases (open storefront)",
|
|
90
|
+
"Arbitration is optional — add when dispute volume justifies the cost",
|
|
91
|
+
"Service ↔ Guard circular dependency: create Service (unpublished) → create Guards → update Service (publish)",
|
|
92
|
+
];
|
|
67
93
|
const SUPPORTED_INDUSTRY_SET = new Set([
|
|
68
|
-
"freelance", "rental", "education", "travel", "subscription", "retail",
|
|
94
|
+
"freelance", "rental", "education", "travel", "subscription", "retail", "retail_d2c",
|
|
69
95
|
]);
|
|
70
96
|
function fetchTemplate(name) {
|
|
71
|
-
const
|
|
97
|
+
const traitsLookupName = name === "retail_d2c" ? "retail" : name;
|
|
98
|
+
const traits = getIndustryTraits(traitsLookupName) ?? GENERAL_TRAITS;
|
|
72
99
|
const isSupported = SUPPORTED_INDUSTRY_SET.has(name);
|
|
100
|
+
const industryLookupName = name === "retail_d2c" ? "retail" : name;
|
|
73
101
|
const risk_checks = isSupported
|
|
74
|
-
? getIndustryRiskChecks(
|
|
102
|
+
? getIndustryRiskChecks(industryLookupName)
|
|
75
103
|
: [];
|
|
76
104
|
const needs = isSupported
|
|
77
|
-
? getIndustryNeeds(
|
|
105
|
+
? getIndustryNeeds(industryLookupName)
|
|
78
106
|
: [];
|
|
79
|
-
const flywheel = getFlywheelForIndustry(
|
|
107
|
+
const flywheel = getFlywheelForIndustry(traitsLookupName) ?? GENERAL_FLYWHEEL;
|
|
80
108
|
let machine_shape;
|
|
81
109
|
let guards;
|
|
82
110
|
let allocator;
|
|
@@ -89,6 +117,13 @@ function fetchTemplate(name) {
|
|
|
89
117
|
key_risk = RETAIL_KEY_RISK;
|
|
90
118
|
build_notes = RETAIL_BUILD_NOTES;
|
|
91
119
|
}
|
|
120
|
+
else if (name === "retail_d2c") {
|
|
121
|
+
machine_shape = RETAIL_D2C_MACHINE_SHAPE;
|
|
122
|
+
guards = RETAIL_D2C_GUARDS;
|
|
123
|
+
allocator = RETAIL_D2C_ALLOCATOR;
|
|
124
|
+
key_risk = RETAIL_D2C_KEY_RISK;
|
|
125
|
+
build_notes = RETAIL_D2C_BUILD_NOTES;
|
|
126
|
+
}
|
|
92
127
|
else if (name === "general") {
|
|
93
128
|
const sm = getScenarioMode("general");
|
|
94
129
|
machine_shape = GENERAL_MACHINE_SHAPE;
|
|
@@ -113,7 +148,7 @@ function fetchTemplate(name) {
|
|
|
113
148
|
export const BUILTIN_MODES = [
|
|
114
149
|
{
|
|
115
150
|
name: "freelance",
|
|
116
|
-
display_name: "Freelance
|
|
151
|
+
display_name: "Freelance",
|
|
117
152
|
version: "v1",
|
|
118
153
|
source: "builtin",
|
|
119
154
|
...fetchTemplate("freelance"),
|
|
@@ -131,28 +166,31 @@ export const BUILTIN_MODES = [
|
|
|
131
166
|
machine: { wip_required: true, wip_hash_algorithm: "sha256", acceptance_gate: true },
|
|
132
167
|
},
|
|
133
168
|
expected_benefits: [
|
|
134
|
-
{ metric: "
|
|
135
|
-
{ metric: "
|
|
136
|
-
{ metric: "
|
|
169
|
+
{ metric: "Dispute rate reduction", expected_value: "40%", evidence: "WIP hash + milestone allocation enforces delivery evidence" },
|
|
170
|
+
{ metric: "Delivery confirmation efficiency", expected_value: "+50%", evidence: "acceptance gate automates acceptance workflow" },
|
|
171
|
+
{ metric: "Provider payment assurance", expected_value: "100%", evidence: "Funds auto-release to provider after accepted node" },
|
|
137
172
|
],
|
|
138
173
|
risk_appetite: "balanced",
|
|
139
174
|
risk_constraints: {
|
|
140
175
|
require_arbitration: true,
|
|
141
176
|
require_compensation_fund: false,
|
|
142
177
|
require_wip_evidence: true,
|
|
143
|
-
other_constraints: [
|
|
178
|
+
other_constraints: [
|
|
179
|
+
"setting_locked_time >= 7d to lock engagement-period rules",
|
|
180
|
+
"ISSUE-P1-4: 48h auto-accept requires off-chain keeper (WoWok Guard does not support time-based triggers). Deploy a keeper service that polls Progress objects in 'delivered' state and calls adminUnhold (permission 224) after 48h timeout. See keeper template in docs.",
|
|
181
|
+
],
|
|
144
182
|
},
|
|
145
183
|
applicable_conditions: {
|
|
146
184
|
business_scale: "small",
|
|
147
185
|
min_daily_orders: 1,
|
|
148
|
-
other_conditions: ["
|
|
186
|
+
other_conditions: ["Suitable for mid-to-long-term project delivery", "Requires milestone-based phased acceptance"],
|
|
149
187
|
},
|
|
150
188
|
similar_industries: ["rental", "education"],
|
|
151
189
|
novel_capabilities: ["allocation.distribute_milestone"],
|
|
152
190
|
},
|
|
153
191
|
{
|
|
154
192
|
name: "rental",
|
|
155
|
-
display_name: "Rental
|
|
193
|
+
display_name: "Rental",
|
|
156
194
|
version: "v1",
|
|
157
195
|
source: "builtin",
|
|
158
196
|
...fetchTemplate("rental"),
|
|
@@ -170,9 +208,9 @@ export const BUILTIN_MODES = [
|
|
|
170
208
|
machine: { wip_required: true, wip_stages: ["handover_out", "returned"], inspection_gate: true },
|
|
171
209
|
},
|
|
172
210
|
expected_benefits: [
|
|
173
|
-
{ metric: "
|
|
174
|
-
{ metric: "
|
|
175
|
-
{ metric: "
|
|
211
|
+
{ metric: "Deposit dispute rate", expected_value: "-60%", evidence: "pre-rental WIP mandatorily records item's original state" },
|
|
212
|
+
{ metric: "Damage liability accuracy", expected_value: "+70%", evidence: "pre/post WIP hash comparison eliminates unfounded deductions" },
|
|
213
|
+
{ metric: "Trust score", expected_value: "+25%", evidence: "compensation_fund covers damage risk" },
|
|
176
214
|
],
|
|
177
215
|
risk_appetite: "conservative",
|
|
178
216
|
risk_constraints: {
|
|
@@ -180,19 +218,20 @@ export const BUILTIN_MODES = [
|
|
|
180
218
|
require_compensation_fund: true,
|
|
181
219
|
require_wip_evidence: true,
|
|
182
220
|
max_single_transaction: 10000,
|
|
183
|
-
|
|
221
|
+
compensation_fund_coverage_ratio: 10,
|
|
222
|
+
other_constraints: ["Deposit must be escrowed (no direct transfer)", "lock_duration >= 7d to prevent arbitrary merchant withdrawal"],
|
|
184
223
|
},
|
|
185
224
|
applicable_conditions: {
|
|
186
225
|
business_scale: "small",
|
|
187
226
|
min_daily_orders: 1,
|
|
188
|
-
other_conditions: ["
|
|
227
|
+
other_conditions: ["Requires physical item handover", "Has logistics or offline delivery leg"],
|
|
189
228
|
},
|
|
190
229
|
similar_industries: ["retail", "travel"],
|
|
191
230
|
novel_capabilities: [],
|
|
192
231
|
},
|
|
193
232
|
{
|
|
194
233
|
name: "education",
|
|
195
|
-
display_name: "Education
|
|
234
|
+
display_name: "Education",
|
|
196
235
|
version: "v1",
|
|
197
236
|
source: "builtin",
|
|
198
237
|
...fetchTemplate("education"),
|
|
@@ -218,28 +257,28 @@ export const BUILTIN_MODES = [
|
|
|
218
257
|
service: { setting_locked_time: "120d", anti_runaway: true },
|
|
219
258
|
},
|
|
220
259
|
expected_benefits: [
|
|
221
|
-
{ metric: "
|
|
222
|
-
{ metric: "
|
|
223
|
-
{ metric: "
|
|
260
|
+
{ metric: "Refund dispute rate", expected_value: "-50%", evidence: "per-session release distributes tuition by class" },
|
|
261
|
+
{ metric: "Institution runaway risk", expected_value: "eliminated", evidence: "Funds release per session; undelivered portion is refundable" },
|
|
262
|
+
{ metric: "Attendance traceability", expected_value: "100%", evidence: "attendance_guard signs each session" },
|
|
224
263
|
],
|
|
225
264
|
risk_appetite: "conservative",
|
|
226
265
|
risk_constraints: {
|
|
227
266
|
require_arbitration: true,
|
|
228
267
|
require_compensation_fund: true,
|
|
229
268
|
require_wip_evidence: false,
|
|
230
|
-
other_constraints: ["setting_locked_time
|
|
269
|
+
other_constraints: ["setting_locked_time covers the entire term (>=90d)", "Long-cycle projects must monitor >90d progress"],
|
|
231
270
|
},
|
|
232
271
|
applicable_conditions: {
|
|
233
272
|
business_scale: "medium",
|
|
234
273
|
min_daily_orders: 1,
|
|
235
|
-
other_conditions: ["
|
|
274
|
+
other_conditions: ["Long-cycle delivery", "Requires per-session acceptance", "Regulatory intensity: medium"],
|
|
236
275
|
},
|
|
237
276
|
similar_industries: ["freelance", "subscription"],
|
|
238
277
|
novel_capabilities: ["allocation.distribute_milestone"],
|
|
239
278
|
},
|
|
240
279
|
{
|
|
241
280
|
name: "travel",
|
|
242
|
-
display_name: "Travel
|
|
281
|
+
display_name: "Travel",
|
|
243
282
|
version: "v1",
|
|
244
283
|
source: "builtin",
|
|
245
284
|
...fetchTemplate("travel"),
|
|
@@ -266,28 +305,28 @@ export const BUILTIN_MODES = [
|
|
|
266
305
|
service: { supply_chain_suborders: true, segment_guard_required: true },
|
|
267
306
|
},
|
|
268
307
|
expected_benefits: [
|
|
269
|
-
{ metric: "
|
|
270
|
-
{ metric: "
|
|
271
|
-
{ metric: "
|
|
308
|
+
{ metric: "Fund transparency", expected_value: "100%", evidence: "multi-tier allocation splits per segment to hotel/guide/driver" },
|
|
309
|
+
{ metric: "Itinerary change disputes", expected_value: "-45%", evidence: "segment WIP accepts each leg" },
|
|
310
|
+
{ metric: "Breach compensation assurance", expected_value: "+60%", evidence: "compensation_fund covers itinerary breach" },
|
|
272
311
|
],
|
|
273
312
|
risk_appetite: "balanced",
|
|
274
313
|
risk_constraints: {
|
|
275
314
|
require_arbitration: true,
|
|
276
315
|
require_compensation_fund: true,
|
|
277
316
|
require_wip_evidence: true,
|
|
278
|
-
other_constraints: ["
|
|
317
|
+
other_constraints: ["Multi-tier allocation requires guard chaining validation", "deposit 20% + final 80% two-stage payment"],
|
|
279
318
|
},
|
|
280
319
|
applicable_conditions: {
|
|
281
320
|
business_scale: "medium",
|
|
282
321
|
min_daily_orders: 1,
|
|
283
|
-
other_conditions: ["
|
|
322
|
+
other_conditions: ["Multi-segment itinerary combination", "Requires hotel/guide/driver multi-party allocation"],
|
|
284
323
|
},
|
|
285
324
|
similar_industries: ["rental", "education"],
|
|
286
325
|
novel_capabilities: [],
|
|
287
326
|
},
|
|
288
327
|
{
|
|
289
328
|
name: "subscription",
|
|
290
|
-
display_name: "Subscription
|
|
329
|
+
display_name: "Subscription",
|
|
291
330
|
version: "v1",
|
|
292
331
|
source: "builtin",
|
|
293
332
|
...fetchTemplate("subscription"),
|
|
@@ -310,28 +349,29 @@ export const BUILTIN_MODES = [
|
|
|
310
349
|
service: { creator_data_subscription: true, periodic_billing: true },
|
|
311
350
|
},
|
|
312
351
|
expected_benefits: [
|
|
313
|
-
{ metric: "
|
|
314
|
-
{ metric: "
|
|
315
|
-
{ metric: "
|
|
352
|
+
{ metric: "Renewal rate", expected_value: "+25%", evidence: "loyalty reward + transparent subscription mechanism" },
|
|
353
|
+
{ metric: "Cancellation disputes", expected_value: "eliminated", evidence: "cancel anytime + no auto-renew trap" },
|
|
354
|
+
{ metric: "Creator retention", expected_value: "+30%", evidence: "deliver_guard_wip prevents content dropout" },
|
|
316
355
|
],
|
|
317
356
|
risk_appetite: "aggressive",
|
|
318
357
|
risk_constraints: {
|
|
319
358
|
require_arbitration: false,
|
|
320
359
|
require_compensation_fund: false,
|
|
321
360
|
require_wip_evidence: false,
|
|
322
|
-
|
|
361
|
+
compensation_fund_coverage_ratio: 3,
|
|
362
|
+
other_constraints: ["Forbid dead-end nodes (prevent lock-in)", "charge_guard requires user confirmation each period"],
|
|
323
363
|
},
|
|
324
364
|
applicable_conditions: {
|
|
325
365
|
business_scale: "small",
|
|
326
366
|
min_daily_orders: 5,
|
|
327
|
-
other_conditions: ["
|
|
367
|
+
other_conditions: ["Pure-digital delivery", "Periodic content or SaaS service"],
|
|
328
368
|
},
|
|
329
369
|
similar_industries: ["freelance", "education"],
|
|
330
370
|
novel_capabilities: [],
|
|
331
371
|
},
|
|
332
372
|
{
|
|
333
373
|
name: "retail",
|
|
334
|
-
display_name: "Retail
|
|
374
|
+
display_name: "Retail",
|
|
335
375
|
version: "v1",
|
|
336
376
|
source: "builtin",
|
|
337
377
|
...fetchTemplate("retail"),
|
|
@@ -354,28 +394,74 @@ export const BUILTIN_MODES = [
|
|
|
354
394
|
service: { logistics_mode: "standard", first_order_discount: true },
|
|
355
395
|
},
|
|
356
396
|
expected_benefits: [
|
|
357
|
-
{ metric: "
|
|
358
|
-
{ metric: "
|
|
359
|
-
{ metric: "
|
|
397
|
+
{ metric: "Return dispute rate", expected_value: "-35%", evidence: "logistics WIP + refund path assurance" },
|
|
398
|
+
{ metric: "Repurchase rate", expected_value: "+20%", evidence: "spend cashback reward" },
|
|
399
|
+
{ metric: "Product authenticity traceability", expected_value: "100%", evidence: "WIP verifies product/logistics info" },
|
|
360
400
|
],
|
|
361
401
|
risk_appetite: "conservative",
|
|
362
402
|
risk_constraints: {
|
|
363
403
|
require_arbitration: true,
|
|
364
404
|
require_compensation_fund: true,
|
|
365
405
|
require_wip_evidence: false,
|
|
366
|
-
|
|
406
|
+
compensation_fund_coverage_ratio: 5,
|
|
407
|
+
other_constraints: ["refund_window >= 7d", "confirm_gate: only buyer can confirm receipt"],
|
|
367
408
|
},
|
|
368
409
|
applicable_conditions: {
|
|
369
410
|
business_scale: "medium",
|
|
370
411
|
min_daily_orders: 10,
|
|
371
|
-
other_conditions: ["
|
|
412
|
+
other_conditions: ["Has logistics shipping leg", "High-frequency small-ticket transactions"],
|
|
372
413
|
},
|
|
373
414
|
similar_industries: ["rental", "subscription"],
|
|
374
415
|
novel_capabilities: [],
|
|
375
416
|
},
|
|
417
|
+
{
|
|
418
|
+
name: "retail_d2c",
|
|
419
|
+
display_name: "Retail D2C (Direct-to-Consumer)",
|
|
420
|
+
version: "v1",
|
|
421
|
+
source: "builtin",
|
|
422
|
+
...fetchTemplate("retail_d2c"),
|
|
423
|
+
capabilities_used: [
|
|
424
|
+
"permission.index_create", "permission.role_assign",
|
|
425
|
+
"guard.validate_withdraw", "guard.validate_refund",
|
|
426
|
+
"machine.node_topology",
|
|
427
|
+
"allocation.distribute",
|
|
428
|
+
"service.publish", "progress.advance",
|
|
429
|
+
"contact.im_create",
|
|
430
|
+
],
|
|
431
|
+
config_overrides: {
|
|
432
|
+
machine: {
|
|
433
|
+
wip_required: false,
|
|
434
|
+
confirm_gate: true,
|
|
435
|
+
refund_requires_approval: false,
|
|
436
|
+
},
|
|
437
|
+
service: { logistics_mode: "merchant_managed", multi_recipient_allocation: true },
|
|
438
|
+
},
|
|
439
|
+
expected_benefits: [
|
|
440
|
+
{ metric: "Merchant revenue share", expected_value: "97%", evidence: "No platform commission — only 3% processing fee" },
|
|
441
|
+
{ metric: "Fund safety", expected_value: "contract-grade", evidence: "Allocation escrow + Guard verification replaces platform custody" },
|
|
442
|
+
{ metric: "Delivery reliability", expected_value: "high", evidence: "withdraw_guard enforces delivery confirmation before payment" },
|
|
443
|
+
],
|
|
444
|
+
risk_appetite: "balanced",
|
|
445
|
+
risk_constraints: {
|
|
446
|
+
require_arbitration: false,
|
|
447
|
+
require_compensation_fund: false,
|
|
448
|
+
require_wip_evidence: false,
|
|
449
|
+
other_constraints: [
|
|
450
|
+
"Allocation escrow required (withdraw_guard + refund_guard)",
|
|
451
|
+
"Service ↔ Guard circular dependency requires 3-step creation pattern",
|
|
452
|
+
],
|
|
453
|
+
},
|
|
454
|
+
applicable_conditions: {
|
|
455
|
+
business_scale: "small",
|
|
456
|
+
min_daily_orders: 1,
|
|
457
|
+
other_conditions: ["Independent storefront (no marketplace)", "Merchant-managed logistics", "Allocation escrow model"],
|
|
458
|
+
},
|
|
459
|
+
similar_industries: ["retail", "subscription"],
|
|
460
|
+
novel_capabilities: ["Allocation escrow as platform-custody alternative", "Multi-recipient allocation (merchant + processor)"],
|
|
461
|
+
},
|
|
376
462
|
{
|
|
377
463
|
name: "general",
|
|
378
|
-
display_name: "General
|
|
464
|
+
display_name: "General",
|
|
379
465
|
version: "v1",
|
|
380
466
|
source: "builtin",
|
|
381
467
|
...fetchTemplate("general"),
|
|
@@ -388,8 +474,8 @@ export const BUILTIN_MODES = [
|
|
|
388
474
|
"progress.advance",
|
|
389
475
|
],
|
|
390
476
|
expected_benefits: [
|
|
391
|
-
{ metric: "
|
|
392
|
-
{ metric: "
|
|
477
|
+
{ metric: "Flexibility", expected_value: "100%", evidence: "User customizes all trust mechanism parameters" },
|
|
478
|
+
{ metric: "Degraded safety", expected_value: "usable", evidence: "Can fall back to general at any time" },
|
|
393
479
|
],
|
|
394
480
|
risk_appetite: "balanced",
|
|
395
481
|
risk_constraints: {
|
|
@@ -399,7 +485,7 @@ export const BUILTIN_MODES = [
|
|
|
399
485
|
},
|
|
400
486
|
applicable_conditions: {
|
|
401
487
|
business_scale: "small",
|
|
402
|
-
other_conditions: ["
|
|
488
|
+
other_conditions: ["Fallback degraded mode", "Hybrid scenarios not covered by other industries"],
|
|
403
489
|
},
|
|
404
490
|
similar_industries: [],
|
|
405
491
|
novel_capabilities: [],
|
|
@@ -41,6 +41,8 @@ export declare class IndustryModeRegistry {
|
|
|
41
41
|
private buildSteps;
|
|
42
42
|
private defaultScenarios;
|
|
43
43
|
private recordCapabilitiesUsed;
|
|
44
|
+
private deriveGuardShortName;
|
|
45
|
+
private getFirstServiceGuardName;
|
|
44
46
|
private makeObject;
|
|
45
47
|
private registerBuiltinModes;
|
|
46
48
|
}
|
|
@@ -116,7 +116,7 @@ export class IndustryModeRegistry {
|
|
|
116
116
|
mode.evolution_history = [{
|
|
117
117
|
version: mode.version || "v1",
|
|
118
118
|
changed_at: Date.now(),
|
|
119
|
-
changes: ["
|
|
119
|
+
changes: ["Initial registration (registerUserMode)"],
|
|
120
120
|
}];
|
|
121
121
|
}
|
|
122
122
|
this.userModes.set(userKey, mode);
|
|
@@ -161,7 +161,7 @@ export class IndustryModeRegistry {
|
|
|
161
161
|
evolution_history: [{
|
|
162
162
|
version: "v1",
|
|
163
163
|
changed_at: Date.now(),
|
|
164
|
-
changes: [
|
|
164
|
+
changes: [`Derived from builtin '${sourceMode}'`],
|
|
165
165
|
}],
|
|
166
166
|
};
|
|
167
167
|
this.userModes.set(userKey, derived);
|
|
@@ -333,22 +333,33 @@ export class IndustryModeRegistry {
|
|
|
333
333
|
const objects = [];
|
|
334
334
|
objects.push(this.makeObject("permission", `${prefix}_permission`, {
|
|
335
335
|
name: `${prefix}_permission`,
|
|
336
|
-
description: `Permission:
|
|
336
|
+
description: `Permission: role permission index (${mode.display_name})`,
|
|
337
337
|
permission_indexes: this.buildPermissionIndexes(mode),
|
|
338
338
|
tags: [`industry:${mode.name}`],
|
|
339
339
|
}));
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
340
|
+
const serviceGuardName = this.getFirstServiceGuardName(mode, prefix);
|
|
341
|
+
for (const guard of mode.guards) {
|
|
342
|
+
const shortName = this.deriveGuardShortName(guard.template_id);
|
|
343
|
+
const guardName = `${prefix}_guard_${shortName}`;
|
|
344
|
+
objects.push(this.makeObject("guard", guardName, {
|
|
345
|
+
name: guardName,
|
|
346
|
+
description: `Guard: ${guard.purpose} (${mode.display_name})`,
|
|
347
|
+
host: guard.host,
|
|
348
|
+
template_id: guard.template_id,
|
|
349
|
+
tags: [`industry:${mode.name}`, `host:${guard.host}`],
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
347
352
|
objects.push(this.makeObject("machine", `${prefix}_machine`, {
|
|
348
353
|
name: `${prefix}_machine`,
|
|
349
|
-
description: `Machine:
|
|
354
|
+
description: `Machine: workflow topology (${mode.display_name}) — ${mode.machine_shape.length} nodes`,
|
|
350
355
|
nodes: mode.machine_shape.map(n => ({ name: n.name, role: n.role })),
|
|
351
|
-
|
|
356
|
+
guard_objects: mode.guards
|
|
357
|
+
.filter(g => g.host === "machine")
|
|
358
|
+
.map(g => ({
|
|
359
|
+
template_id: g.template_id,
|
|
360
|
+
object_name: `${prefix}_guard_${this.deriveGuardShortName(g.template_id)}`,
|
|
361
|
+
purpose: g.purpose,
|
|
362
|
+
})),
|
|
352
363
|
permission: `${prefix}_permission`,
|
|
353
364
|
entry_node_forward_hint: {
|
|
354
365
|
entry_node_name: mode.machine_shape[0]?.name ?? "paid",
|
|
@@ -366,31 +377,32 @@ export class IndustryModeRegistry {
|
|
|
366
377
|
}, true));
|
|
367
378
|
objects.push(this.makeObject("treasury", `${prefix}_treasury`, {
|
|
368
379
|
name: `${prefix}_treasury`,
|
|
369
|
-
description: `Treasury:
|
|
380
|
+
description: `Treasury: fund escrow (${mode.display_name})`,
|
|
370
381
|
owner_receive: true,
|
|
371
382
|
tags: [`industry:${mode.name}`],
|
|
372
383
|
}));
|
|
373
384
|
objects.push(this.makeObject("allocation", `${prefix}_allocation`, {
|
|
374
385
|
name: `${prefix}_allocation`,
|
|
375
|
-
description: `Allocation:
|
|
386
|
+
description: `Allocation: allocation strategy (${mode.display_name}) — ${mode.allocator.description}`,
|
|
376
387
|
strategy: mode.allocator,
|
|
377
388
|
treasury: `${prefix}_treasury`,
|
|
378
|
-
guard:
|
|
389
|
+
guard: serviceGuardName,
|
|
379
390
|
tags: [`industry:${mode.name}`],
|
|
380
391
|
}));
|
|
381
392
|
objects.push(this.makeObject("service", `${prefix}_service`, {
|
|
382
393
|
name: `${prefix}_service`,
|
|
383
|
-
description: `Service:
|
|
394
|
+
description: `Service: business service (${mode.display_name}) — ${intent.slice(0, 100)}`,
|
|
384
395
|
machine: `${prefix}_machine`,
|
|
385
|
-
buy_guard:
|
|
396
|
+
buy_guard: serviceGuardName,
|
|
386
397
|
permission: `${prefix}_permission`,
|
|
387
398
|
order_allocators: [`${prefix}_allocation`],
|
|
388
399
|
compensation_fund_balance: 0,
|
|
389
400
|
compensation_fund_required: mode.risk_constraints?.require_compensation_fund ?? false,
|
|
401
|
+
compensation_fund_coverage_ratio: mode.risk_constraints?.compensation_fund_coverage_ratio ?? 5,
|
|
390
402
|
compensation_fund_add_hint: "Call service.compensation_fund_add with a Coin<T> to deposit. " +
|
|
391
403
|
"The compensation_fund is a Balance<T> (numeric), not a Treasury object reference. " +
|
|
392
404
|
"Without deposit, arbitration rulings that award refunds to buyers cannot be paid out. " +
|
|
393
|
-
|
|
405
|
+
`Recommend ${mode.risk_constraints?.compensation_fund_coverage_ratio ?? 5}× the max single-order amount (P1-1 evaluation rule, industry: ${mode.name}).`,
|
|
394
406
|
arbitrations: [`${prefix}_arb`],
|
|
395
407
|
rewards: [`${prefix}_reward`],
|
|
396
408
|
business_intent: intent,
|
|
@@ -399,25 +411,25 @@ export class IndustryModeRegistry {
|
|
|
399
411
|
}, true));
|
|
400
412
|
objects.push(this.makeObject("progress", `${prefix}_progress`, {
|
|
401
413
|
name: `${prefix}_progress`,
|
|
402
|
-
description: `Progress:
|
|
414
|
+
description: `Progress: order fulfillment progress (${mode.display_name})`,
|
|
403
415
|
parent: `${prefix}_machine`,
|
|
404
416
|
tags: [`industry:${mode.name}`],
|
|
405
417
|
}));
|
|
406
418
|
objects.push(this.makeObject("arb", `${prefix}_arb`, {
|
|
407
419
|
name: `${prefix}_arb`,
|
|
408
|
-
description: `Arbitration:
|
|
420
|
+
description: `Arbitration: arbitration rules (${mode.display_name}) — ${mode.key_risk}`,
|
|
409
421
|
guard: `${prefix}_guard_buy`,
|
|
410
422
|
tags: [`industry:${mode.name}`],
|
|
411
423
|
}));
|
|
412
424
|
objects.push(this.makeObject("reward", `${prefix}_reward`, {
|
|
413
425
|
name: `${prefix}_reward`,
|
|
414
|
-
description: `Reward:
|
|
426
|
+
description: `Reward: incentive rules (${mode.display_name})`,
|
|
415
427
|
claim_guard: `${prefix}_guard_buy`,
|
|
416
428
|
tags: [`industry:${mode.name}`],
|
|
417
429
|
}));
|
|
418
430
|
objects.push(this.makeObject("contact", `${prefix}_contact`, {
|
|
419
431
|
name: `${prefix}_contact`,
|
|
420
|
-
description: `Contact:
|
|
432
|
+
description: `Contact: customer service contact (${mode.display_name})`,
|
|
421
433
|
tags: [`industry:${mode.name}`],
|
|
422
434
|
}));
|
|
423
435
|
return objects;
|
|
@@ -501,21 +513,21 @@ export class IndustryModeRegistry {
|
|
|
501
513
|
?? "";
|
|
502
514
|
const service = find(`${prefix}_service`);
|
|
503
515
|
const machine = find(`${prefix}_machine`);
|
|
504
|
-
const guard = find(`${prefix}_guard_buy`);
|
|
505
516
|
const permission = find(`${prefix}_permission`);
|
|
506
517
|
const allocation = find(`${prefix}_allocation`);
|
|
507
518
|
const treasury = find(`${prefix}_treasury`);
|
|
508
519
|
const arb = find(`${prefix}_arb`);
|
|
509
520
|
const reward = find(`${prefix}_reward`);
|
|
510
521
|
const progress = find(`${prefix}_progress`);
|
|
511
|
-
|
|
522
|
+
const allGuards = objects.filter(o => o.object_type === "guard");
|
|
523
|
+
const serviceGuard = allGuards.find(g => g.config?.host === "service");
|
|
524
|
+
const machineGuards = allGuards.filter(g => g.config?.host === "machine");
|
|
525
|
+
if (!service || !machine || !permission) {
|
|
512
526
|
const missing = [];
|
|
513
527
|
if (!service)
|
|
514
528
|
missing.push("service");
|
|
515
529
|
if (!machine)
|
|
516
530
|
missing.push("machine");
|
|
517
|
-
if (!guard)
|
|
518
|
-
missing.push("guard");
|
|
519
531
|
if (!permission)
|
|
520
532
|
missing.push("permission");
|
|
521
533
|
console.warn(`[buildEdges] Missing core objects: ${missing.join(", ")}. ` +
|
|
@@ -524,7 +536,9 @@ export class IndustryModeRegistry {
|
|
|
524
536
|
return edges;
|
|
525
537
|
}
|
|
526
538
|
edges.push(this.makeEdge(service, machine, "machine", "service.machine", true));
|
|
527
|
-
|
|
539
|
+
if (serviceGuard) {
|
|
540
|
+
edges.push(this.makeEdge(service, serviceGuard, "buy_guard", "service.buy_guard", true));
|
|
541
|
+
}
|
|
528
542
|
edges.push(this.makeEdge(service, permission, "permission", "service.permission", true));
|
|
529
543
|
if (allocation)
|
|
530
544
|
edges.push(this.makeEdge(service, allocation, "order_allocators", "service.order_allocators", true));
|
|
@@ -533,12 +547,15 @@ export class IndustryModeRegistry {
|
|
|
533
547
|
if (reward)
|
|
534
548
|
edges.push(this.makeEdge(service, reward, "rewards", "service.rewards", false));
|
|
535
549
|
edges.push(this.makeEdge(machine, permission, "permission", "machine.permission", false));
|
|
550
|
+
for (const mg of machineGuards) {
|
|
551
|
+
edges.push(this.makeEdge(machine, mg, "guard", "machine.forwards.guard", false));
|
|
552
|
+
}
|
|
536
553
|
if (progress)
|
|
537
554
|
edges.push(this.makeEdge(progress, machine, "parent", "progress.parent", false));
|
|
538
555
|
if (allocation && treasury)
|
|
539
556
|
edges.push(this.makeEdge(allocation, treasury, "treasury", "allocation.treasury", false));
|
|
540
|
-
if (allocation &&
|
|
541
|
-
edges.push(this.makeEdge(allocation,
|
|
557
|
+
if (allocation && serviceGuard)
|
|
558
|
+
edges.push(this.makeEdge(allocation, serviceGuard, "buy_guard", "allocation.guard", false));
|
|
542
559
|
return edges;
|
|
543
560
|
}
|
|
544
561
|
makeEdge(from, to, edge_kind, field_path, required_at_publish) {
|
|
@@ -590,7 +607,7 @@ export class IndustryModeRegistry {
|
|
|
590
607
|
const service = objects.find(o => o.object_type === "service");
|
|
591
608
|
return [{
|
|
592
609
|
scenario_id: `${mode.name}_primary`,
|
|
593
|
-
description: `${mode.display_name}
|
|
610
|
+
description: `${mode.display_name} main flow: ${intent.slice(0, 80)}`,
|
|
594
611
|
primary_object: service?.entry_id ?? "",
|
|
595
612
|
supporting_objects: objects.filter(o => o.object_type !== "service").map(o => o.entry_id),
|
|
596
613
|
}];
|
|
@@ -607,6 +624,22 @@ export class IndustryModeRegistry {
|
|
|
607
624
|
catch {
|
|
608
625
|
}
|
|
609
626
|
}
|
|
627
|
+
deriveGuardShortName(templateId) {
|
|
628
|
+
if (templateId.startsWith("tpl_")) {
|
|
629
|
+
const parts = templateId.split("_");
|
|
630
|
+
return parts[parts.length - 1] || templateId;
|
|
631
|
+
}
|
|
632
|
+
const match = templateId.match(/^([a-z]+)_guard_/);
|
|
633
|
+
if (match)
|
|
634
|
+
return match[1];
|
|
635
|
+
return templateId.split("_")[0] || templateId;
|
|
636
|
+
}
|
|
637
|
+
getFirstServiceGuardName(mode, prefix) {
|
|
638
|
+
const serviceGuard = mode.guards.find(g => g.host === "service");
|
|
639
|
+
if (!serviceGuard)
|
|
640
|
+
return "";
|
|
641
|
+
return `${prefix}_guard_${this.deriveGuardShortName(serviceGuard.template_id)}`;
|
|
642
|
+
}
|
|
610
643
|
makeObject(type, name, config, publish_required = false) {
|
|
611
644
|
return {
|
|
612
645
|
entry_id: `${type}:${name}`,
|
|
@@ -68,6 +68,7 @@ export interface ModeRiskConstraints {
|
|
|
68
68
|
require_compensation_fund: boolean;
|
|
69
69
|
require_wip_evidence: boolean;
|
|
70
70
|
max_single_transaction?: number;
|
|
71
|
+
compensation_fund_coverage_ratio?: number;
|
|
71
72
|
other_constraints?: string[];
|
|
72
73
|
}
|
|
73
74
|
export interface ModeApplicableConditions {
|