@wowok/agent-mcp 2.6.0 → 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/README.md +5 -3
- 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.d.ts +125 -0
- package/dist/extensions/capability-manifest.js +594 -0
- package/dist/extensions/constraint-registry.d.ts +24 -0
- package/dist/extensions/constraint-registry.js +196 -0
- package/dist/extensions/index.d.ts +12 -0
- package/dist/extensions/index.js +6 -0
- package/dist/extensions/metric-registry.d.ts +26 -0
- package/dist/extensions/metric-registry.js +257 -0
- package/dist/extensions/mode-evaluator.d.ts +15 -0
- package/dist/extensions/mode-evaluator.js +170 -0
- package/dist/extensions/modes.d.ts +2 -0
- package/dist/extensions/modes.js +493 -0
- package/dist/extensions/registry.d.ts +50 -0
- package/dist/extensions/registry.js +662 -0
- package/dist/extensions/types.d.ts +219 -0
- package/dist/extensions/types.js +1 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.d.ts +3 -0
- package/dist/knowledge/deployment-scanner.js +64 -3
- 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-risk.d.ts +13 -0
- package/dist/knowledge/guard-risk.js +57 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/guard-templates.js +278 -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 +24 -5
- 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 +15 -6
- package/dist/knowledge/service-confirm.js +119 -11
- 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/knowledge/tool-constraints.js +6 -2
- package/dist/project/deployment-bridge.d.ts +1 -1
- package/dist/project/deployment-bridge.js +31 -7
- package/dist/project/deployment-doc.d.ts +3 -0
- package/dist/project/deployment-doc.js +76 -14
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1371 -0
- package/dist/project/evaluation.d.ts +2 -0
- package/dist/project/evaluation.js +873 -88
- package/dist/project/graph-builder.d.ts +4 -1
- package/dist/project/graph-builder.js +132 -62
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/handlers.d.ts +317 -6
- package/dist/project/handlers.js +1171 -19
- package/dist/project/stage-gate.d.ts +4 -0
- package/dist/project/stage-gate.js +64 -5
- package/dist/project/task-tracker.d.ts +26 -0
- package/dist/project/task-tracker.js +78 -0
- package/dist/safety/preview.js +16 -0
- package/dist/schema/call/allocation.d.ts +16 -16
- package/dist/schema/call/allocation.js +2 -2
- package/dist/schema/call/arbitration.js +19 -6
- package/dist/schema/call/base.d.ts +21 -13
- package/dist/schema/call/base.js +27 -6
- package/dist/schema/call/bridge.d.ts +5 -5
- package/dist/schema/call/bridge.js +3 -1
- package/dist/schema/call/contact.js +2 -2
- package/dist/schema/call/demand.d.ts +23 -31
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.js +2 -2
- package/dist/schema/call/machine.d.ts +1976 -752
- package/dist/schema/call/machine.js +50 -4
- package/dist/schema/call/order.d.ts +149 -228
- package/dist/schema/call/order.js +4 -3
- package/dist/schema/call/payment.d.ts +183 -3
- package/dist/schema/call/payment.js +21 -3
- package/dist/schema/call/permission.js +2 -2
- package/dist/schema/call/personal.d.ts +241 -52
- package/dist/schema/call/progress.d.ts +53 -61
- package/dist/schema/call/progress.js +18 -4
- package/dist/schema/call/repository.d.ts +23 -31
- package/dist/schema/call/repository.js +2 -2
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.d.ts +1 -1
- package/dist/schema/call/semantic.js +37 -2
- package/dist/schema/call/service.d.ts +275 -127
- package/dist/schema/call/service.js +89 -13
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +13 -2
- package/dist/schema/common/index.js +80 -15
- package/dist/schema/local/index.d.ts +32 -35
- package/dist/schema/local/index.js +28 -6
- package/dist/schema/messenger/index.d.ts +274 -46
- package/dist/schema/operations.d.ts +1264 -544
- package/dist/schema/operations.js +65 -7
- package/dist/schema/project/index.d.ts +2846 -167
- package/dist/schema/project/index.js +570 -16
- package/dist/schema/query/index.d.ts +922 -349
- package/dist/schema/query/index.js +205 -42
- package/dist/schema/schema-query/index.d.ts +65 -3
- package/dist/schema/schema-query/index.js +38 -5
- package/dist/schema/utils/node-parser.js +20 -4
- 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 +20 -1
- package/dist/schema-query/index.js +306 -4
- package/dist/schemas/account_operation.output.json +7 -1
- package/dist/schemas/account_operation.schema.json +3 -3
- package/dist/schemas/bridge_operation.output.json +6 -0
- package/dist/schemas/bridge_operation.schema.json +1 -1
- package/dist/schemas/guard-templates.json +379 -0
- package/dist/schemas/guard2file.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +6 -0
- package/dist/schemas/local_mark_operation.output.json +7 -1
- package/dist/schemas/local_mark_operation.schema.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +1 -1
- package/dist/schemas/messenger_operation.schema.json +4 -4
- 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 +444 -330
- package/dist/schemas/onchain_operations_allocation.schema.json +37 -28
- package/dist/schemas/onchain_operations_arbitration.schema.json +16 -14
- package/dist/schemas/onchain_operations_contact.schema.json +10 -10
- package/dist/schemas/onchain_operations_demand.schema.json +10 -10
- package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -16
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +2 -2
- package/dist/schemas/onchain_operations_machine.schema.json +43 -35
- package/dist/schemas/onchain_operations_order.schema.json +72 -78
- package/dist/schemas/onchain_operations_payment.schema.json +141 -111
- package/dist/schemas/onchain_operations_permission.schema.json +3 -3
- package/dist/schemas/onchain_operations_personal.schema.json +7 -7
- package/dist/schemas/onchain_operations_progress.schema.json +9 -9
- package/dist/schemas/onchain_operations_proof.schema.json +8 -8
- package/dist/schemas/onchain_operations_repository.schema.json +10 -10
- package/dist/schemas/onchain_operations_reward.schema.json +14 -14
- package/dist/schemas/onchain_operations_service.schema.json +119 -48
- package/dist/schemas/onchain_operations_treasury.schema.json +11 -11
- package/dist/schemas/onchain_table_data.output.json +33 -25
- package/dist/schemas/onchain_table_data.schema.json +22 -21
- package/dist/schemas/project_operation.output.json +2194 -23
- package/dist/schemas/project_operation.schema.json +84 -6
- package/dist/schemas/query_toolkit.output.json +108 -80
- package/dist/schemas/query_toolkit.schema.json +12 -12
- package/dist/schemas/schema_query.output.json +70 -3
- package/dist/schemas/schema_query.schema.json +18 -3
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/local.js +20 -5
- package/dist/tools/handlers/onchain.js +594 -6
- package/dist/tools/handlers/project.js +76 -4
- package/dist/tools/handlers/query.js +27 -0
- package/dist/tools/handlers/schema-query.js +43 -1
- package/dist/tools/handlers/task-status.d.ts +170 -0
- package/dist/tools/handlers/task-status.js +55 -0
- package/dist/tools/handlers/wip.js +47 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +387 -12
- package/dist/tools/retry.d.ts +8 -0
- package/dist/tools/retry.js +85 -0
- package/dist/tools/wip-deploy-assist.d.ts +28 -0
- package/dist/tools/wip-deploy-assist.js +278 -0
- package/package.json +2 -2
- package/dist/schemas/guard-node-examples.md +0 -199
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { getScenarioMode } from "../knowledge/scenario-modes.js";
|
|
2
|
+
import { getIndustryTraits } from "../knowledge/industry-registry.js";
|
|
3
|
+
import { getIndustryRiskChecks, getIndustryNeeds } from "../customer/index.js";
|
|
4
|
+
import { getFlywheelForIndustry } from "../knowledge/acquisition-flywheel.js";
|
|
5
|
+
const GENERAL_TRAITS = {
|
|
6
|
+
has_logistics: false,
|
|
7
|
+
communication_heavy: false,
|
|
8
|
+
pure_digital: false,
|
|
9
|
+
long_cycle: false,
|
|
10
|
+
deposit_required: false,
|
|
11
|
+
multi_tier_allocation: false,
|
|
12
|
+
regulatory_intensity: "low",
|
|
13
|
+
trust_sensitivity: "medium",
|
|
14
|
+
consumption_frequency: "occasional",
|
|
15
|
+
avg_ticket_size: "medium",
|
|
16
|
+
};
|
|
17
|
+
const GENERAL_FLYWHEEL = {
|
|
18
|
+
industry: "general",
|
|
19
|
+
trustSellingPoints: [],
|
|
20
|
+
keyActions: [],
|
|
21
|
+
rewardStrategy: "User-defined",
|
|
22
|
+
discountStrategy: "User-defined",
|
|
23
|
+
trustDescription: "User-defined trust mechanism",
|
|
24
|
+
};
|
|
25
|
+
const GENERAL_MACHINE_SHAPE = [
|
|
26
|
+
{ name: "paid", role: "Entry: order created and paid" },
|
|
27
|
+
{ name: "delivering", role: "Service delivery in progress" },
|
|
28
|
+
{ name: "completed", role: "Service completed, funds released" },
|
|
29
|
+
{ name: "refunded", role: "Customer refund path" },
|
|
30
|
+
{ name: "cancelled", role: "Pre-delivery cancellation" },
|
|
31
|
+
];
|
|
32
|
+
const GENERAL_ALLOCATOR = {
|
|
33
|
+
recipient: "signer",
|
|
34
|
+
count: 1,
|
|
35
|
+
mode: "surplus",
|
|
36
|
+
description: "Default: surplus to service owner (general fallback)",
|
|
37
|
+
};
|
|
38
|
+
const RETAIL_MACHINE_SHAPE = [
|
|
39
|
+
{ name: "paid", role: "Entry: order paid via Service.buy(); Machine starts here" },
|
|
40
|
+
{ name: "shipped", role: "Merchant ships goods, records shipping WIP (tracking number)" },
|
|
41
|
+
{ name: "delivered", role: "Goods delivered to buyer" },
|
|
42
|
+
{ name: "confirmed", role: "Buyer confirms receipt" },
|
|
43
|
+
{ name: "completed", role: "Funds released to merchant" },
|
|
44
|
+
{ name: "refunded", role: "Return & refund path" },
|
|
45
|
+
{ name: "cancelled", role: "Pre-ship cancellation" },
|
|
46
|
+
];
|
|
47
|
+
const RETAIL_GUARDS = [
|
|
48
|
+
{ template_id: "buy_guard_inventory", host: "service", purpose: "Verify inventory and buyer address on purchase" },
|
|
49
|
+
{ template_id: "ship_guard_wip", host: "machine", purpose: "Shipping evidence WIP (logistics tracking number)" },
|
|
50
|
+
{ template_id: "confirm_guard_signer", host: "machine", purpose: "Only buyer can confirm receipt" },
|
|
51
|
+
{ template_id: "refund_guard_permission", host: "machine", purpose: "Return & refund requires merchant permission OR arbiter" },
|
|
52
|
+
{ template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Logistics delay exception compensation (§2.13)" },
|
|
53
|
+
];
|
|
54
|
+
const RETAIL_ALLOCATOR = {
|
|
55
|
+
recipient: "entity",
|
|
56
|
+
count: 2,
|
|
57
|
+
mode: "rate",
|
|
58
|
+
description: "Platform 10% + Merchant 90% (rate-based split)",
|
|
59
|
+
};
|
|
60
|
+
const RETAIL_KEY_RISK = "Products don't match description — no refund path for returns";
|
|
61
|
+
const RETAIL_BUILD_NOTES = [
|
|
62
|
+
"Logistics WIP (tracking number) is essential — shipping evidence protects both parties in return disputes",
|
|
63
|
+
"confirm_gate prevents merchant from self-confirming receipt",
|
|
64
|
+
"Refund path must support return-and-exchange flow",
|
|
65
|
+
"Compensation fund covers return/exchange disputes",
|
|
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
|
+
];
|
|
93
|
+
const SUPPORTED_INDUSTRY_SET = new Set([
|
|
94
|
+
"freelance", "rental", "education", "travel", "subscription", "retail", "retail_d2c",
|
|
95
|
+
]);
|
|
96
|
+
function fetchTemplate(name) {
|
|
97
|
+
const traitsLookupName = name === "retail_d2c" ? "retail" : name;
|
|
98
|
+
const traits = getIndustryTraits(traitsLookupName) ?? GENERAL_TRAITS;
|
|
99
|
+
const isSupported = SUPPORTED_INDUSTRY_SET.has(name);
|
|
100
|
+
const industryLookupName = name === "retail_d2c" ? "retail" : name;
|
|
101
|
+
const risk_checks = isSupported
|
|
102
|
+
? getIndustryRiskChecks(industryLookupName)
|
|
103
|
+
: [];
|
|
104
|
+
const needs = isSupported
|
|
105
|
+
? getIndustryNeeds(industryLookupName)
|
|
106
|
+
: [];
|
|
107
|
+
const flywheel = getFlywheelForIndustry(traitsLookupName) ?? GENERAL_FLYWHEEL;
|
|
108
|
+
let machine_shape;
|
|
109
|
+
let guards;
|
|
110
|
+
let allocator;
|
|
111
|
+
let key_risk;
|
|
112
|
+
let build_notes;
|
|
113
|
+
if (name === "retail") {
|
|
114
|
+
machine_shape = RETAIL_MACHINE_SHAPE;
|
|
115
|
+
guards = RETAIL_GUARDS;
|
|
116
|
+
allocator = RETAIL_ALLOCATOR;
|
|
117
|
+
key_risk = RETAIL_KEY_RISK;
|
|
118
|
+
build_notes = RETAIL_BUILD_NOTES;
|
|
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
|
+
}
|
|
127
|
+
else if (name === "general") {
|
|
128
|
+
const sm = getScenarioMode("general");
|
|
129
|
+
machine_shape = GENERAL_MACHINE_SHAPE;
|
|
130
|
+
guards = [];
|
|
131
|
+
allocator = GENERAL_ALLOCATOR;
|
|
132
|
+
key_risk = sm?.key_risk ?? "No safety net — user must design all trust mechanisms manually";
|
|
133
|
+
build_notes = sm?.build_notes;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const sm = getScenarioMode(name);
|
|
137
|
+
if (!sm) {
|
|
138
|
+
throw new Error(`[modes.ts] No scenario mode found for industry: ${name}`);
|
|
139
|
+
}
|
|
140
|
+
machine_shape = sm.machine_shape;
|
|
141
|
+
guards = sm.guards;
|
|
142
|
+
allocator = sm.allocator;
|
|
143
|
+
key_risk = sm.key_risk;
|
|
144
|
+
build_notes = sm.build_notes;
|
|
145
|
+
}
|
|
146
|
+
return { traits, risk_checks, needs, flywheel, machine_shape, guards, allocator, key_risk, build_notes };
|
|
147
|
+
}
|
|
148
|
+
export const BUILTIN_MODES = [
|
|
149
|
+
{
|
|
150
|
+
name: "freelance",
|
|
151
|
+
display_name: "Freelance",
|
|
152
|
+
version: "v1",
|
|
153
|
+
source: "builtin",
|
|
154
|
+
...fetchTemplate("freelance"),
|
|
155
|
+
capabilities_used: [
|
|
156
|
+
"permission.index_create", "permission.role_assign",
|
|
157
|
+
"guard.validate_buy", "guard.validate_wip_hash",
|
|
158
|
+
"machine.node_topology",
|
|
159
|
+
"treasury.owner_receive",
|
|
160
|
+
"allocation.distribute", "allocation.distribute_milestone",
|
|
161
|
+
"service.publish", "progress.advance",
|
|
162
|
+
"arb.vote_weighted", "contact.im_create",
|
|
163
|
+
],
|
|
164
|
+
config_overrides: {
|
|
165
|
+
service: { setting_locked_time: "30d", engagement_type: "milestone" },
|
|
166
|
+
machine: { wip_required: true, wip_hash_algorithm: "sha256", acceptance_gate: true },
|
|
167
|
+
},
|
|
168
|
+
expected_benefits: [
|
|
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" },
|
|
172
|
+
],
|
|
173
|
+
risk_appetite: "balanced",
|
|
174
|
+
risk_constraints: {
|
|
175
|
+
require_arbitration: true,
|
|
176
|
+
require_compensation_fund: false,
|
|
177
|
+
require_wip_evidence: true,
|
|
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
|
+
],
|
|
182
|
+
},
|
|
183
|
+
applicable_conditions: {
|
|
184
|
+
business_scale: "small",
|
|
185
|
+
min_daily_orders: 1,
|
|
186
|
+
other_conditions: ["Suitable for mid-to-long-term project delivery", "Requires milestone-based phased acceptance"],
|
|
187
|
+
},
|
|
188
|
+
similar_industries: ["rental", "education"],
|
|
189
|
+
novel_capabilities: ["allocation.distribute_milestone"],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "rental",
|
|
193
|
+
display_name: "Rental",
|
|
194
|
+
version: "v1",
|
|
195
|
+
source: "builtin",
|
|
196
|
+
...fetchTemplate("rental"),
|
|
197
|
+
capabilities_used: [
|
|
198
|
+
"permission.index_create", "permission.role_assign",
|
|
199
|
+
"guard.validate_buy", "guard.validate_wip_hash",
|
|
200
|
+
"machine.node_topology",
|
|
201
|
+
"treasury.owner_receive",
|
|
202
|
+
"allocation.distribute",
|
|
203
|
+
"service.publish", "progress.advance",
|
|
204
|
+
"arb.vote_weighted", "contact.im_create",
|
|
205
|
+
],
|
|
206
|
+
config_overrides: {
|
|
207
|
+
treasury: { deposit_escrow: true, deposit_deductible: true },
|
|
208
|
+
machine: { wip_required: true, wip_stages: ["handover_out", "returned"], inspection_gate: true },
|
|
209
|
+
},
|
|
210
|
+
expected_benefits: [
|
|
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" },
|
|
214
|
+
],
|
|
215
|
+
risk_appetite: "conservative",
|
|
216
|
+
risk_constraints: {
|
|
217
|
+
require_arbitration: true,
|
|
218
|
+
require_compensation_fund: true,
|
|
219
|
+
require_wip_evidence: true,
|
|
220
|
+
max_single_transaction: 10000,
|
|
221
|
+
compensation_fund_coverage_ratio: 10,
|
|
222
|
+
other_constraints: ["Deposit must be escrowed (no direct transfer)", "lock_duration >= 7d to prevent arbitrary merchant withdrawal"],
|
|
223
|
+
},
|
|
224
|
+
applicable_conditions: {
|
|
225
|
+
business_scale: "small",
|
|
226
|
+
min_daily_orders: 1,
|
|
227
|
+
other_conditions: ["Requires physical item handover", "Has logistics or offline delivery leg"],
|
|
228
|
+
},
|
|
229
|
+
similar_industries: ["retail", "travel"],
|
|
230
|
+
novel_capabilities: [],
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "education",
|
|
234
|
+
display_name: "Education",
|
|
235
|
+
version: "v1",
|
|
236
|
+
source: "builtin",
|
|
237
|
+
...fetchTemplate("education"),
|
|
238
|
+
capabilities_used: [
|
|
239
|
+
"permission.index_create", "permission.role_assign",
|
|
240
|
+
"guard.validate_buy", "guard.validate_wip_hash",
|
|
241
|
+
"machine.node_topology",
|
|
242
|
+
"treasury.owner_receive",
|
|
243
|
+
"allocation.distribute", "allocation.distribute_milestone",
|
|
244
|
+
"service.publish", "progress.advance",
|
|
245
|
+
"arb.vote_weighted", "contact.im_create",
|
|
246
|
+
],
|
|
247
|
+
config_overrides: {
|
|
248
|
+
allocation: {
|
|
249
|
+
strategy: {
|
|
250
|
+
recipient: "entity",
|
|
251
|
+
count: 1,
|
|
252
|
+
mode: "amount",
|
|
253
|
+
description: "1/N of tuition released per session attendance",
|
|
254
|
+
},
|
|
255
|
+
session_threshold: true,
|
|
256
|
+
},
|
|
257
|
+
service: { setting_locked_time: "120d", anti_runaway: true },
|
|
258
|
+
},
|
|
259
|
+
expected_benefits: [
|
|
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" },
|
|
263
|
+
],
|
|
264
|
+
risk_appetite: "conservative",
|
|
265
|
+
risk_constraints: {
|
|
266
|
+
require_arbitration: true,
|
|
267
|
+
require_compensation_fund: true,
|
|
268
|
+
require_wip_evidence: false,
|
|
269
|
+
other_constraints: ["setting_locked_time covers the entire term (>=90d)", "Long-cycle projects must monitor >90d progress"],
|
|
270
|
+
},
|
|
271
|
+
applicable_conditions: {
|
|
272
|
+
business_scale: "medium",
|
|
273
|
+
min_daily_orders: 1,
|
|
274
|
+
other_conditions: ["Long-cycle delivery", "Requires per-session acceptance", "Regulatory intensity: medium"],
|
|
275
|
+
},
|
|
276
|
+
similar_industries: ["freelance", "subscription"],
|
|
277
|
+
novel_capabilities: ["allocation.distribute_milestone"],
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: "travel",
|
|
281
|
+
display_name: "Travel",
|
|
282
|
+
version: "v1",
|
|
283
|
+
source: "builtin",
|
|
284
|
+
...fetchTemplate("travel"),
|
|
285
|
+
capabilities_used: [
|
|
286
|
+
"permission.index_create", "permission.role_assign",
|
|
287
|
+
"guard.validate_buy", "guard.validate_wip_hash",
|
|
288
|
+
"machine.node_topology",
|
|
289
|
+
"treasury.owner_receive",
|
|
290
|
+
"allocation.distribute",
|
|
291
|
+
"service.publish", "progress.advance",
|
|
292
|
+
"arb.vote_weighted", "contact.im_create",
|
|
293
|
+
],
|
|
294
|
+
config_overrides: {
|
|
295
|
+
allocation: {
|
|
296
|
+
strategy: {
|
|
297
|
+
recipient: "entity",
|
|
298
|
+
count: 3,
|
|
299
|
+
mode: "amount",
|
|
300
|
+
description: "Deposit 20% to agency, final 80% to agency, then agency-side Allocation splits to hotel/guide/driver per segment",
|
|
301
|
+
},
|
|
302
|
+
multi_tier_waterfall: true,
|
|
303
|
+
guard_chaining: true,
|
|
304
|
+
},
|
|
305
|
+
service: { supply_chain_suborders: true, segment_guard_required: true },
|
|
306
|
+
},
|
|
307
|
+
expected_benefits: [
|
|
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" },
|
|
311
|
+
],
|
|
312
|
+
risk_appetite: "balanced",
|
|
313
|
+
risk_constraints: {
|
|
314
|
+
require_arbitration: true,
|
|
315
|
+
require_compensation_fund: true,
|
|
316
|
+
require_wip_evidence: true,
|
|
317
|
+
other_constraints: ["Multi-tier allocation requires guard chaining validation", "deposit 20% + final 80% two-stage payment"],
|
|
318
|
+
},
|
|
319
|
+
applicable_conditions: {
|
|
320
|
+
business_scale: "medium",
|
|
321
|
+
min_daily_orders: 1,
|
|
322
|
+
other_conditions: ["Multi-segment itinerary combination", "Requires hotel/guide/driver multi-party allocation"],
|
|
323
|
+
},
|
|
324
|
+
similar_industries: ["rental", "education"],
|
|
325
|
+
novel_capabilities: [],
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "subscription",
|
|
329
|
+
display_name: "Subscription",
|
|
330
|
+
version: "v1",
|
|
331
|
+
source: "builtin",
|
|
332
|
+
...fetchTemplate("subscription"),
|
|
333
|
+
capabilities_used: [
|
|
334
|
+
"permission.index_create", "permission.role_assign",
|
|
335
|
+
"guard.validate_buy",
|
|
336
|
+
"machine.node_topology",
|
|
337
|
+
"treasury.owner_receive",
|
|
338
|
+
"allocation.distribute",
|
|
339
|
+
"service.publish", "progress.advance",
|
|
340
|
+
"arb.vote_weighted", "reward.claim_guard", "contact.im_create",
|
|
341
|
+
],
|
|
342
|
+
config_overrides: {
|
|
343
|
+
machine: {
|
|
344
|
+
no_auto_renew_trap: true,
|
|
345
|
+
user_confirmed_charge: true,
|
|
346
|
+
cancel_anytime: true,
|
|
347
|
+
next_period_effective: true,
|
|
348
|
+
},
|
|
349
|
+
service: { creator_data_subscription: true, periodic_billing: true },
|
|
350
|
+
},
|
|
351
|
+
expected_benefits: [
|
|
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" },
|
|
355
|
+
],
|
|
356
|
+
risk_appetite: "aggressive",
|
|
357
|
+
risk_constraints: {
|
|
358
|
+
require_arbitration: false,
|
|
359
|
+
require_compensation_fund: false,
|
|
360
|
+
require_wip_evidence: false,
|
|
361
|
+
compensation_fund_coverage_ratio: 3,
|
|
362
|
+
other_constraints: ["Forbid dead-end nodes (prevent lock-in)", "charge_guard requires user confirmation each period"],
|
|
363
|
+
},
|
|
364
|
+
applicable_conditions: {
|
|
365
|
+
business_scale: "small",
|
|
366
|
+
min_daily_orders: 5,
|
|
367
|
+
other_conditions: ["Pure-digital delivery", "Periodic content or SaaS service"],
|
|
368
|
+
},
|
|
369
|
+
similar_industries: ["freelance", "education"],
|
|
370
|
+
novel_capabilities: [],
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "retail",
|
|
374
|
+
display_name: "Retail",
|
|
375
|
+
version: "v1",
|
|
376
|
+
source: "builtin",
|
|
377
|
+
...fetchTemplate("retail"),
|
|
378
|
+
capabilities_used: [
|
|
379
|
+
"permission.index_create", "permission.role_assign",
|
|
380
|
+
"guard.validate_buy", "guard.validate_wip_hash",
|
|
381
|
+
"machine.node_topology",
|
|
382
|
+
"treasury.owner_receive",
|
|
383
|
+
"allocation.distribute",
|
|
384
|
+
"service.publish", "progress.advance",
|
|
385
|
+
"arb.vote_weighted", "reward.claim_guard", "contact.im_create",
|
|
386
|
+
],
|
|
387
|
+
config_overrides: {
|
|
388
|
+
machine: {
|
|
389
|
+
wip_required: true,
|
|
390
|
+
wip_field: "tracking_number",
|
|
391
|
+
confirm_gate: true,
|
|
392
|
+
refund_requires_approval: true,
|
|
393
|
+
},
|
|
394
|
+
service: { logistics_mode: "standard", first_order_discount: true },
|
|
395
|
+
},
|
|
396
|
+
expected_benefits: [
|
|
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" },
|
|
400
|
+
],
|
|
401
|
+
risk_appetite: "conservative",
|
|
402
|
+
risk_constraints: {
|
|
403
|
+
require_arbitration: true,
|
|
404
|
+
require_compensation_fund: true,
|
|
405
|
+
require_wip_evidence: false,
|
|
406
|
+
compensation_fund_coverage_ratio: 5,
|
|
407
|
+
other_constraints: ["refund_window >= 7d", "confirm_gate: only buyer can confirm receipt"],
|
|
408
|
+
},
|
|
409
|
+
applicable_conditions: {
|
|
410
|
+
business_scale: "medium",
|
|
411
|
+
min_daily_orders: 10,
|
|
412
|
+
other_conditions: ["Has logistics shipping leg", "High-frequency small-ticket transactions"],
|
|
413
|
+
},
|
|
414
|
+
similar_industries: ["rental", "subscription"],
|
|
415
|
+
novel_capabilities: [],
|
|
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
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "general",
|
|
464
|
+
display_name: "General",
|
|
465
|
+
version: "v1",
|
|
466
|
+
source: "builtin",
|
|
467
|
+
...fetchTemplate("general"),
|
|
468
|
+
capabilities_used: [
|
|
469
|
+
"permission.index_create",
|
|
470
|
+
"machine.node_topology",
|
|
471
|
+
"treasury.owner_receive",
|
|
472
|
+
"allocation.distribute",
|
|
473
|
+
"service.publish",
|
|
474
|
+
"progress.advance",
|
|
475
|
+
],
|
|
476
|
+
expected_benefits: [
|
|
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" },
|
|
479
|
+
],
|
|
480
|
+
risk_appetite: "balanced",
|
|
481
|
+
risk_constraints: {
|
|
482
|
+
require_arbitration: false,
|
|
483
|
+
require_compensation_fund: false,
|
|
484
|
+
require_wip_evidence: false,
|
|
485
|
+
},
|
|
486
|
+
applicable_conditions: {
|
|
487
|
+
business_scale: "small",
|
|
488
|
+
other_conditions: ["Fallback degraded mode", "Hybrid scenarios not covered by other industries"],
|
|
489
|
+
},
|
|
490
|
+
similar_industries: [],
|
|
491
|
+
novel_capabilities: [],
|
|
492
|
+
},
|
|
493
|
+
];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IndustryMode, UserDefinedMode, Blueprint, BlueprintObject, BlueprintEdge, ProjectContext, ModeEvaluation, ModeMigrationEvaluation } from "./types.js";
|
|
2
|
+
export declare class IndustryModeRegistry {
|
|
3
|
+
private static instance;
|
|
4
|
+
private registrations;
|
|
5
|
+
private userModes;
|
|
6
|
+
private aliases;
|
|
7
|
+
private evaluator;
|
|
8
|
+
private initialized;
|
|
9
|
+
static Instance(): IndustryModeRegistry;
|
|
10
|
+
private constructor();
|
|
11
|
+
registerMode(mode: IndustryMode, aliases?: string[]): boolean;
|
|
12
|
+
getMode(name: string): IndustryMode | undefined;
|
|
13
|
+
listModes(): IndustryMode[];
|
|
14
|
+
resolveAlias(name: string): string;
|
|
15
|
+
hasMode(name: string): boolean;
|
|
16
|
+
evaluateMode(name: string, intent: string, context: ProjectContext): ModeEvaluation;
|
|
17
|
+
evaluateMigration(sourceName: string, targetName: string): ModeMigrationEvaluation;
|
|
18
|
+
registerUserMode(mode: UserDefinedMode, userId: string): boolean;
|
|
19
|
+
deriveMode(sourceMode: string, modifications: Partial<UserDefinedMode>, userId: string, newName: string, newDisplayName?: string): UserDefinedMode | undefined;
|
|
20
|
+
evolveMode(modeName: string, updates: Partial<UserDefinedMode>, userId: string, changeDescription: string, bumpVersion?: boolean): UserDefinedMode | undefined;
|
|
21
|
+
listUserModes(userId: string): UserDefinedMode[];
|
|
22
|
+
getUserMode(modeName: string, userId: string): UserDefinedMode | undefined;
|
|
23
|
+
unregisterUserMode(modeName: string, userId: string): boolean;
|
|
24
|
+
private userModeKey;
|
|
25
|
+
private bumpPatchVersion;
|
|
26
|
+
applyTemplate(name: string, intent: string, context: ProjectContext): Blueprint;
|
|
27
|
+
applyUserMode(modeName: string, userId: string, intent: string, context: ProjectContext): Blueprint;
|
|
28
|
+
private doApplyTemplate;
|
|
29
|
+
validateBlueprint(objects: BlueprintObject[], edges: BlueprintEdge[], mode: IndustryMode): {
|
|
30
|
+
errors: string[];
|
|
31
|
+
warnings: string[];
|
|
32
|
+
};
|
|
33
|
+
private buildObjects;
|
|
34
|
+
private buildPermissionIndexes;
|
|
35
|
+
private applyConfigOverrides;
|
|
36
|
+
private applyConfigOverrideRules;
|
|
37
|
+
private evaluateCondition;
|
|
38
|
+
private setNestedField;
|
|
39
|
+
private buildEdges;
|
|
40
|
+
private makeEdge;
|
|
41
|
+
private buildSteps;
|
|
42
|
+
private defaultScenarios;
|
|
43
|
+
private recordCapabilitiesUsed;
|
|
44
|
+
private deriveGuardShortName;
|
|
45
|
+
private getFirstServiceGuardName;
|
|
46
|
+
private makeObject;
|
|
47
|
+
private registerBuiltinModes;
|
|
48
|
+
}
|
|
49
|
+
export declare function getIndustryModeRegistry(): IndustryModeRegistry;
|
|
50
|
+
export declare const INDUSTRY_MODE_REGISTRY_VERSION = 2.1;
|