@wowok/agent-mcp 2.5.5 → 2.6.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.
Files changed (146) hide show
  1. package/README.md +5 -3
  2. package/dist/config/runtime.js +3 -6
  3. package/dist/extensions/capability-manifest.d.ts +125 -0
  4. package/dist/extensions/capability-manifest.js +594 -0
  5. package/dist/extensions/constraint-registry.d.ts +24 -0
  6. package/dist/extensions/constraint-registry.js +196 -0
  7. package/dist/extensions/index.d.ts +12 -0
  8. package/dist/extensions/index.js +6 -0
  9. package/dist/extensions/metric-registry.d.ts +26 -0
  10. package/dist/extensions/metric-registry.js +257 -0
  11. package/dist/extensions/mode-evaluator.d.ts +15 -0
  12. package/dist/extensions/mode-evaluator.js +170 -0
  13. package/dist/extensions/modes.d.ts +2 -0
  14. package/dist/extensions/modes.js +407 -0
  15. package/dist/extensions/registry.d.ts +48 -0
  16. package/dist/extensions/registry.js +629 -0
  17. package/dist/extensions/types.d.ts +218 -0
  18. package/dist/extensions/types.js +1 -0
  19. package/dist/harness/checkpoint.js +2 -2
  20. package/dist/knowledge/deployment-scanner.d.ts +3 -0
  21. package/dist/knowledge/deployment-scanner.js +64 -3
  22. package/dist/knowledge/flywheel-loop.js +2 -5
  23. package/dist/knowledge/guard-risk.d.ts +13 -0
  24. package/dist/knowledge/guard-risk.js +57 -0
  25. package/dist/knowledge/guard-templates.js +278 -0
  26. package/dist/knowledge/machine-templates.js +20 -1
  27. package/dist/knowledge/overrides-loader.js +2 -4
  28. package/dist/knowledge/progress-ledger.js +3 -0
  29. package/dist/knowledge/progress-translation.js +5 -1
  30. package/dist/knowledge/service-confirm.d.ts +14 -5
  31. package/dist/knowledge/service-confirm.js +116 -8
  32. package/dist/knowledge/tool-constraints.js +6 -2
  33. package/dist/loop-engineering/improve.js +2 -4
  34. package/dist/project/deployment-bridge.d.ts +5 -0
  35. package/dist/project/deployment-bridge.js +119 -0
  36. package/dist/project/deployment-doc.d.ts +3 -0
  37. package/dist/project/deployment-doc.js +72 -10
  38. package/dist/project/evaluation.d.ts +2 -0
  39. package/dist/project/evaluation.js +578 -86
  40. package/dist/project/graph-builder.d.ts +4 -1
  41. package/dist/project/graph-builder.js +141 -63
  42. package/dist/project/graph.d.ts +1 -0
  43. package/dist/project/handlers.d.ts +221 -5
  44. package/dist/project/handlers.js +933 -14
  45. package/dist/project/index.js +2 -6
  46. package/dist/project/project-store.js +2 -5
  47. package/dist/project/stage-gate.d.ts +4 -0
  48. package/dist/project/stage-gate.js +64 -5
  49. package/dist/project/task-tracker.d.ts +26 -0
  50. package/dist/project/task-tracker.js +78 -0
  51. package/dist/safety/preview.js +16 -0
  52. package/dist/schema/call/allocation.d.ts +16 -16
  53. package/dist/schema/call/base.d.ts +21 -13
  54. package/dist/schema/call/base.js +27 -6
  55. package/dist/schema/call/bridge.d.ts +5 -5
  56. package/dist/schema/call/bridge.js +3 -1
  57. package/dist/schema/call/demand.d.ts +23 -31
  58. package/dist/schema/call/guard.js +1 -1
  59. package/dist/schema/call/machine.d.ts +402 -376
  60. package/dist/schema/call/order.d.ts +149 -228
  61. package/dist/schema/call/order.js +7 -3
  62. package/dist/schema/call/payment.d.ts +183 -3
  63. package/dist/schema/call/payment.js +21 -3
  64. package/dist/schema/call/personal.d.ts +241 -52
  65. package/dist/schema/call/progress.d.ts +53 -61
  66. package/dist/schema/call/progress.js +18 -4
  67. package/dist/schema/call/repository.d.ts +23 -31
  68. package/dist/schema/call/semantic.d.ts +1 -1
  69. package/dist/schema/call/semantic.js +30 -1
  70. package/dist/schema/call/service.d.ts +95 -119
  71. package/dist/schema/call/service.js +22 -1
  72. package/dist/schema/common/index.d.ts +11 -2
  73. package/dist/schema/common/index.js +43 -14
  74. package/dist/schema/config/index.d.ts +12 -12
  75. package/dist/schema/local/index.d.ts +140 -143
  76. package/dist/schema/local/index.js +44 -23
  77. package/dist/schema/messenger/index.d.ts +290 -62
  78. package/dist/schema/messenger/index.js +2 -2
  79. package/dist/schema/operations.d.ts +680 -545
  80. package/dist/schema/operations.js +22 -0
  81. package/dist/schema/project/index.d.ts +2064 -84
  82. package/dist/schema/project/index.js +354 -12
  83. package/dist/schema/query/index.d.ts +715 -354
  84. package/dist/schema/query/index.js +164 -31
  85. package/dist/schema/schema-query/index.d.ts +15 -3
  86. package/dist/schema/schema-query/index.js +23 -5
  87. package/dist/schema/trust/index.d.ts +8 -8
  88. package/dist/schema/utils/node-parser.js +7 -4
  89. package/dist/schema-query/index.d.ts +7 -1
  90. package/dist/schema-query/index.js +204 -4
  91. package/dist/schemas/account_operation.output.json +14 -22
  92. package/dist/schemas/account_operation.schema.json +11 -25
  93. package/dist/schemas/bridge_operation.output.json +6 -0
  94. package/dist/schemas/bridge_operation.schema.json +1 -1
  95. package/dist/schemas/guard-templates.json +379 -0
  96. package/dist/schemas/guard2file.schema.json +1 -1
  97. package/dist/schemas/index.json +1 -1
  98. package/dist/schemas/local_info_operation.output.json +6 -0
  99. package/dist/schemas/local_mark_operation.output.json +7 -1
  100. package/dist/schemas/local_mark_operation.schema.json +1 -1
  101. package/dist/schemas/machineNode2file.schema.json +1 -1
  102. package/dist/schemas/messenger_operation.schema.json +10 -10
  103. package/dist/schemas/onchain_events.output.json +1 -1
  104. package/dist/schemas/onchain_operations.schema.json +348 -296
  105. package/dist/schemas/onchain_operations_allocation.schema.json +34 -25
  106. package/dist/schemas/onchain_operations_arbitration.schema.json +8 -8
  107. package/dist/schemas/onchain_operations_contact.schema.json +8 -8
  108. package/dist/schemas/onchain_operations_demand.schema.json +8 -8
  109. package/dist/schemas/onchain_operations_gen_passport.schema.json +14 -14
  110. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
  111. package/dist/schemas/onchain_operations_guard.schema.json +1 -1
  112. package/dist/schemas/onchain_operations_machine.schema.json +41 -33
  113. package/dist/schemas/onchain_operations_order.schema.json +71 -77
  114. package/dist/schemas/onchain_operations_payment.schema.json +141 -111
  115. package/dist/schemas/onchain_operations_permission.schema.json +2 -2
  116. package/dist/schemas/onchain_operations_personal.schema.json +7 -7
  117. package/dist/schemas/onchain_operations_progress.schema.json +8 -8
  118. package/dist/schemas/onchain_operations_proof.schema.json +7 -7
  119. package/dist/schemas/onchain_operations_repository.schema.json +8 -8
  120. package/dist/schemas/onchain_operations_reward.schema.json +10 -10
  121. package/dist/schemas/onchain_operations_service.schema.json +46 -35
  122. package/dist/schemas/onchain_operations_treasury.schema.json +8 -8
  123. package/dist/schemas/onchain_table_data.output.json +33 -25
  124. package/dist/schemas/onchain_table_data.schema.json +12 -12
  125. package/dist/schemas/project_operation.output.json +1352 -20
  126. package/dist/schemas/project_operation.schema.json +53 -4
  127. package/dist/schemas/query_toolkit.output.json +111 -82
  128. package/dist/schemas/query_toolkit.schema.json +9 -13
  129. package/dist/schemas/schema_query.output.json +7 -3
  130. package/dist/schemas/schema_query.schema.json +17 -3
  131. package/dist/telemetry/storage.js +2 -2
  132. package/dist/tools/handlers/local.js +20 -5
  133. package/dist/tools/handlers/onchain.js +36 -0
  134. package/dist/tools/handlers/project.js +72 -1
  135. package/dist/tools/handlers/query.js +27 -0
  136. package/dist/tools/handlers/schema-query.js +19 -0
  137. package/dist/tools/handlers/task-status.d.ts +170 -0
  138. package/dist/tools/handlers/task-status.js +55 -0
  139. package/dist/tools/handlers/wip.js +47 -1
  140. package/dist/tools/index.js +212 -8
  141. package/dist/tools/retry.d.ts +8 -0
  142. package/dist/tools/retry.js +85 -0
  143. package/dist/tools/wip-deploy-assist.d.ts +28 -0
  144. package/dist/tools/wip-deploy-assist.js +278 -0
  145. package/package.json +2 -2
  146. package/dist/schemas/guard-node-examples.md +0 -199
@@ -0,0 +1,2 @@
1
+ import type { IndustryMode } from "./types.js";
2
+ export declare const BUILTIN_MODES: IndustryMode[];
@@ -0,0 +1,407 @@
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 SUPPORTED_INDUSTRY_SET = new Set([
68
+ "freelance", "rental", "education", "travel", "subscription", "retail",
69
+ ]);
70
+ function fetchTemplate(name) {
71
+ const traits = getIndustryTraits(name) ?? GENERAL_TRAITS;
72
+ const isSupported = SUPPORTED_INDUSTRY_SET.has(name);
73
+ const risk_checks = isSupported
74
+ ? getIndustryRiskChecks(name)
75
+ : [];
76
+ const needs = isSupported
77
+ ? getIndustryNeeds(name)
78
+ : [];
79
+ const flywheel = getFlywheelForIndustry(name) ?? GENERAL_FLYWHEEL;
80
+ let machine_shape;
81
+ let guards;
82
+ let allocator;
83
+ let key_risk;
84
+ let build_notes;
85
+ if (name === "retail") {
86
+ machine_shape = RETAIL_MACHINE_SHAPE;
87
+ guards = RETAIL_GUARDS;
88
+ allocator = RETAIL_ALLOCATOR;
89
+ key_risk = RETAIL_KEY_RISK;
90
+ build_notes = RETAIL_BUILD_NOTES;
91
+ }
92
+ else if (name === "general") {
93
+ const sm = getScenarioMode("general");
94
+ machine_shape = GENERAL_MACHINE_SHAPE;
95
+ guards = [];
96
+ allocator = GENERAL_ALLOCATOR;
97
+ key_risk = sm?.key_risk ?? "No safety net — user must design all trust mechanisms manually";
98
+ build_notes = sm?.build_notes;
99
+ }
100
+ else {
101
+ const sm = getScenarioMode(name);
102
+ if (!sm) {
103
+ throw new Error(`[modes.ts] No scenario mode found for industry: ${name}`);
104
+ }
105
+ machine_shape = sm.machine_shape;
106
+ guards = sm.guards;
107
+ allocator = sm.allocator;
108
+ key_risk = sm.key_risk;
109
+ build_notes = sm.build_notes;
110
+ }
111
+ return { traits, risk_checks, needs, flywheel, machine_shape, guards, allocator, key_risk, build_notes };
112
+ }
113
+ export const BUILTIN_MODES = [
114
+ {
115
+ name: "freelance",
116
+ display_name: "Freelance 自由职业",
117
+ version: "v1",
118
+ source: "builtin",
119
+ ...fetchTemplate("freelance"),
120
+ capabilities_used: [
121
+ "permission.index_create", "permission.role_assign",
122
+ "guard.validate_buy", "guard.validate_wip_hash",
123
+ "machine.node_topology",
124
+ "treasury.owner_receive",
125
+ "allocation.distribute", "allocation.distribute_milestone",
126
+ "service.publish", "progress.advance",
127
+ "arb.vote_weighted", "contact.im_create",
128
+ ],
129
+ config_overrides: {
130
+ service: { setting_locked_time: "30d", engagement_type: "milestone" },
131
+ machine: { wip_required: true, wip_hash_algorithm: "sha256", acceptance_gate: true },
132
+ },
133
+ expected_benefits: [
134
+ { metric: "纠纷率降低", expected_value: "40%", evidence: "WIP 哈希 + 里程碑分账强制交付证据" },
135
+ { metric: "交付确认效率", expected_value: "提升 50%", evidence: "acceptance gate 自动化验收" },
136
+ { metric: "提供方回款保障", expected_value: "100%", evidence: "accepted 节点后资金自动释放给提供方" },
137
+ ],
138
+ risk_appetite: "balanced",
139
+ risk_constraints: {
140
+ require_arbitration: true,
141
+ require_compensation_fund: false,
142
+ require_wip_evidence: true,
143
+ other_constraints: ["setting_locked_time ≥ 7d 以锁定合作期规则"],
144
+ },
145
+ applicable_conditions: {
146
+ business_scale: "small",
147
+ min_daily_orders: 1,
148
+ other_conditions: ["适合中长期项目交付", "需里程碑分阶段验收"],
149
+ },
150
+ similar_industries: ["rental", "education"],
151
+ novel_capabilities: ["allocation.distribute_milestone"],
152
+ },
153
+ {
154
+ name: "rental",
155
+ display_name: "Rental 租赁",
156
+ version: "v1",
157
+ source: "builtin",
158
+ ...fetchTemplate("rental"),
159
+ capabilities_used: [
160
+ "permission.index_create", "permission.role_assign",
161
+ "guard.validate_buy", "guard.validate_wip_hash",
162
+ "machine.node_topology",
163
+ "treasury.owner_receive",
164
+ "allocation.distribute",
165
+ "service.publish", "progress.advance",
166
+ "arb.vote_weighted", "contact.im_create",
167
+ ],
168
+ config_overrides: {
169
+ treasury: { deposit_escrow: true, deposit_deductible: true },
170
+ machine: { wip_required: true, wip_stages: ["handover_out", "returned"], inspection_gate: true },
171
+ },
172
+ expected_benefits: [
173
+ { metric: "押金纠纷率", expected_value: "降低 60%", evidence: "pre-rental WIP 强制记录物品原始状态" },
174
+ { metric: "损坏定责准确率", expected_value: "提升 70%", evidence: "前后 WIP 哈希对比,杜绝无据扣款" },
175
+ { metric: "信任评分", expected_value: "提升 25%", evidence: "compensation_fund 覆盖损坏风险" },
176
+ ],
177
+ risk_appetite: "conservative",
178
+ risk_constraints: {
179
+ require_arbitration: true,
180
+ require_compensation_fund: true,
181
+ require_wip_evidence: true,
182
+ max_single_transaction: 10000,
183
+ other_constraints: ["押金必须 escrow 托管(不可直转)", "lock_duration ≥ 7d 防止商家随意提取"],
184
+ },
185
+ applicable_conditions: {
186
+ business_scale: "small",
187
+ min_daily_orders: 1,
188
+ other_conditions: ["需物理物品交接", "有物流或线下交付环节"],
189
+ },
190
+ similar_industries: ["retail", "travel"],
191
+ novel_capabilities: [],
192
+ },
193
+ {
194
+ name: "education",
195
+ display_name: "Education 教育",
196
+ version: "v1",
197
+ source: "builtin",
198
+ ...fetchTemplate("education"),
199
+ capabilities_used: [
200
+ "permission.index_create", "permission.role_assign",
201
+ "guard.validate_buy", "guard.validate_wip_hash",
202
+ "machine.node_topology",
203
+ "treasury.owner_receive",
204
+ "allocation.distribute", "allocation.distribute_milestone",
205
+ "service.publish", "progress.advance",
206
+ "arb.vote_weighted", "contact.im_create",
207
+ ],
208
+ config_overrides: {
209
+ allocation: {
210
+ strategy: {
211
+ recipient: "entity",
212
+ count: 1,
213
+ mode: "amount",
214
+ description: "1/N of tuition released per session attendance",
215
+ },
216
+ session_threshold: true,
217
+ },
218
+ service: { setting_locked_time: "120d", anti_runaway: true },
219
+ },
220
+ expected_benefits: [
221
+ { metric: "退费纠纷率", expected_value: "降低 50%", evidence: "per-session release 按课时释放学费" },
222
+ { metric: "机构跑路风险", expected_value: "消除", evidence: "资金按课时释放,未交付部分可退" },
223
+ { metric: "出勤可追溯", expected_value: "100%", evidence: "attendance_guard 每课时签名" },
224
+ ],
225
+ risk_appetite: "conservative",
226
+ risk_constraints: {
227
+ require_arbitration: true,
228
+ require_compensation_fund: true,
229
+ require_wip_evidence: false,
230
+ other_constraints: ["setting_locked_time 覆盖整个学期(≥90d)", "长周期需关注 >90d 进度"],
231
+ },
232
+ applicable_conditions: {
233
+ business_scale: "medium",
234
+ min_daily_orders: 1,
235
+ other_conditions: ["长周期交付", "需分课时验收", "监管强度 medium"],
236
+ },
237
+ similar_industries: ["freelance", "subscription"],
238
+ novel_capabilities: ["allocation.distribute_milestone"],
239
+ },
240
+ {
241
+ name: "travel",
242
+ display_name: "Travel 旅游",
243
+ version: "v1",
244
+ source: "builtin",
245
+ ...fetchTemplate("travel"),
246
+ capabilities_used: [
247
+ "permission.index_create", "permission.role_assign",
248
+ "guard.validate_buy", "guard.validate_wip_hash",
249
+ "machine.node_topology",
250
+ "treasury.owner_receive",
251
+ "allocation.distribute",
252
+ "service.publish", "progress.advance",
253
+ "arb.vote_weighted", "contact.im_create",
254
+ ],
255
+ config_overrides: {
256
+ allocation: {
257
+ strategy: {
258
+ recipient: "entity",
259
+ count: 3,
260
+ mode: "amount",
261
+ description: "Deposit 20% to agency, final 80% to agency, then agency-side Allocation splits to hotel/guide/driver per segment",
262
+ },
263
+ multi_tier_waterfall: true,
264
+ guard_chaining: true,
265
+ },
266
+ service: { supply_chain_suborders: true, segment_guard_required: true },
267
+ },
268
+ expected_benefits: [
269
+ { metric: "资金透明度", expected_value: "100%", evidence: "multi-tier allocation 按段分账至酒店/导游/司机" },
270
+ { metric: "行程变更纠纷", expected_value: "降低 45%", evidence: "segment WIP 每段验收" },
271
+ { metric: "违约赔付保障", expected_value: "提升 60%", evidence: "compensation_fund 覆盖行程违约" },
272
+ ],
273
+ risk_appetite: "balanced",
274
+ risk_constraints: {
275
+ require_arbitration: true,
276
+ require_compensation_fund: true,
277
+ require_wip_evidence: true,
278
+ other_constraints: ["多级分账需 guard chaining 校验", "deposit 20% + final 80% 两段付款"],
279
+ },
280
+ applicable_conditions: {
281
+ business_scale: "medium",
282
+ min_daily_orders: 1,
283
+ other_conditions: ["多段行程组合", "需酒店/导游/司机多方分账"],
284
+ },
285
+ similar_industries: ["rental", "education"],
286
+ novel_capabilities: [],
287
+ },
288
+ {
289
+ name: "subscription",
290
+ display_name: "Subscription 订阅",
291
+ version: "v1",
292
+ source: "builtin",
293
+ ...fetchTemplate("subscription"),
294
+ capabilities_used: [
295
+ "permission.index_create", "permission.role_assign",
296
+ "guard.validate_buy",
297
+ "machine.node_topology",
298
+ "treasury.owner_receive",
299
+ "allocation.distribute",
300
+ "service.publish", "progress.advance",
301
+ "arb.vote_weighted", "reward.claim_guard", "contact.im_create",
302
+ ],
303
+ config_overrides: {
304
+ machine: {
305
+ no_auto_renew_trap: true,
306
+ user_confirmed_charge: true,
307
+ cancel_anytime: true,
308
+ next_period_effective: true,
309
+ },
310
+ service: { creator_data_subscription: true, periodic_billing: true },
311
+ },
312
+ expected_benefits: [
313
+ { metric: "续费率", expected_value: "提升 25%", evidence: "loyalty reward + 透明订阅机制" },
314
+ { metric: "退订纠纷", expected_value: "消除", evidence: "cancel anytime + no auto-renew trap" },
315
+ { metric: "创作者留存", expected_value: "提升 30%", evidence: "deliver_guard_wip 防止内容断更" },
316
+ ],
317
+ risk_appetite: "aggressive",
318
+ risk_constraints: {
319
+ require_arbitration: false,
320
+ require_compensation_fund: false,
321
+ require_wip_evidence: false,
322
+ other_constraints: ["禁止 dead-end 节点(防止锁定)", "charge_guard 每期需用户确认"],
323
+ },
324
+ applicable_conditions: {
325
+ business_scale: "small",
326
+ min_daily_orders: 5,
327
+ other_conditions: ["纯数字交付", "周期性内容或 SaaS 服务"],
328
+ },
329
+ similar_industries: ["freelance", "education"],
330
+ novel_capabilities: [],
331
+ },
332
+ {
333
+ name: "retail",
334
+ display_name: "Retail 零售",
335
+ version: "v1",
336
+ source: "builtin",
337
+ ...fetchTemplate("retail"),
338
+ capabilities_used: [
339
+ "permission.index_create", "permission.role_assign",
340
+ "guard.validate_buy", "guard.validate_wip_hash",
341
+ "machine.node_topology",
342
+ "treasury.owner_receive",
343
+ "allocation.distribute",
344
+ "service.publish", "progress.advance",
345
+ "arb.vote_weighted", "reward.claim_guard", "contact.im_create",
346
+ ],
347
+ config_overrides: {
348
+ machine: {
349
+ wip_required: true,
350
+ wip_field: "tracking_number",
351
+ confirm_gate: true,
352
+ refund_requires_approval: true,
353
+ },
354
+ service: { logistics_mode: "standard", first_order_discount: true },
355
+ },
356
+ expected_benefits: [
357
+ { metric: "退货纠纷率", expected_value: "降低 35%", evidence: "logistics WIP + refund path 保障" },
358
+ { metric: "复购率", expected_value: "提升 20%", evidence: "spend cashback reward" },
359
+ { metric: "商品真实性可追溯", expected_value: "100%", evidence: "WIP 验证商品/物流信息" },
360
+ ],
361
+ risk_appetite: "conservative",
362
+ risk_constraints: {
363
+ require_arbitration: true,
364
+ require_compensation_fund: true,
365
+ require_wip_evidence: false,
366
+ other_constraints: ["refund_window ≥ 7d", "confirm_gate 仅买家可确认收货"],
367
+ },
368
+ applicable_conditions: {
369
+ business_scale: "medium",
370
+ min_daily_orders: 10,
371
+ other_conditions: ["有物流发货环节", "高频小额交易"],
372
+ },
373
+ similar_industries: ["rental", "subscription"],
374
+ novel_capabilities: [],
375
+ },
376
+ {
377
+ name: "general",
378
+ display_name: "General 通用",
379
+ version: "v1",
380
+ source: "builtin",
381
+ ...fetchTemplate("general"),
382
+ capabilities_used: [
383
+ "permission.index_create",
384
+ "machine.node_topology",
385
+ "treasury.owner_receive",
386
+ "allocation.distribute",
387
+ "service.publish",
388
+ "progress.advance",
389
+ ],
390
+ expected_benefits: [
391
+ { metric: "灵活性", expected_value: "100%", evidence: "用户自定义所有信任机制参数" },
392
+ { metric: "降级安全", expected_value: "可用", evidence: "任意时刻可切换至 general 兜底" },
393
+ ],
394
+ risk_appetite: "balanced",
395
+ risk_constraints: {
396
+ require_arbitration: false,
397
+ require_compensation_fund: false,
398
+ require_wip_evidence: false,
399
+ },
400
+ applicable_conditions: {
401
+ business_scale: "small",
402
+ other_conditions: ["降级兜底模式", "未被其他行业覆盖的混合场景"],
403
+ },
404
+ similar_industries: [],
405
+ novel_capabilities: [],
406
+ },
407
+ ];
@@ -0,0 +1,48 @@
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 makeObject;
45
+ private registerBuiltinModes;
46
+ }
47
+ export declare function getIndustryModeRegistry(): IndustryModeRegistry;
48
+ export declare const INDUSTRY_MODE_REGISTRY_VERSION = 2.1;