@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.
- package/README.md +5 -3
- package/dist/config/runtime.js +3 -6
- 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 +407 -0
- package/dist/extensions/registry.d.ts +48 -0
- package/dist/extensions/registry.js +629 -0
- package/dist/extensions/types.d.ts +218 -0
- package/dist/extensions/types.js +1 -0
- package/dist/harness/checkpoint.js +2 -2
- package/dist/knowledge/deployment-scanner.d.ts +3 -0
- package/dist/knowledge/deployment-scanner.js +64 -3
- package/dist/knowledge/flywheel-loop.js +2 -5
- package/dist/knowledge/guard-risk.d.ts +13 -0
- package/dist/knowledge/guard-risk.js +57 -0
- package/dist/knowledge/guard-templates.js +278 -0
- package/dist/knowledge/machine-templates.js +20 -1
- package/dist/knowledge/overrides-loader.js +2 -4
- package/dist/knowledge/progress-ledger.js +3 -0
- package/dist/knowledge/progress-translation.js +5 -1
- package/dist/knowledge/service-confirm.d.ts +14 -5
- package/dist/knowledge/service-confirm.js +116 -8
- package/dist/knowledge/tool-constraints.js +6 -2
- package/dist/loop-engineering/improve.js +2 -4
- package/dist/project/deployment-bridge.d.ts +5 -0
- package/dist/project/deployment-bridge.js +119 -0
- package/dist/project/deployment-doc.d.ts +3 -0
- package/dist/project/deployment-doc.js +72 -10
- package/dist/project/evaluation.d.ts +2 -0
- package/dist/project/evaluation.js +578 -86
- package/dist/project/graph-builder.d.ts +4 -1
- package/dist/project/graph-builder.js +141 -63
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/handlers.d.ts +221 -5
- package/dist/project/handlers.js +933 -14
- package/dist/project/index.js +2 -6
- package/dist/project/project-store.js +2 -5
- 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/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/demand.d.ts +23 -31
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +402 -376
- package/dist/schema/call/order.d.ts +149 -228
- package/dist/schema/call/order.js +7 -3
- package/dist/schema/call/payment.d.ts +183 -3
- package/dist/schema/call/payment.js +21 -3
- 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/semantic.d.ts +1 -1
- package/dist/schema/call/semantic.js +30 -1
- package/dist/schema/call/service.d.ts +95 -119
- package/dist/schema/call/service.js +22 -1
- package/dist/schema/common/index.d.ts +11 -2
- package/dist/schema/common/index.js +43 -14
- package/dist/schema/config/index.d.ts +12 -12
- package/dist/schema/local/index.d.ts +140 -143
- package/dist/schema/local/index.js +44 -23
- package/dist/schema/messenger/index.d.ts +290 -62
- package/dist/schema/messenger/index.js +2 -2
- package/dist/schema/operations.d.ts +680 -545
- package/dist/schema/operations.js +22 -0
- package/dist/schema/project/index.d.ts +2064 -84
- package/dist/schema/project/index.js +354 -12
- package/dist/schema/query/index.d.ts +715 -354
- package/dist/schema/query/index.js +164 -31
- package/dist/schema/schema-query/index.d.ts +15 -3
- package/dist/schema/schema-query/index.js +23 -5
- package/dist/schema/trust/index.d.ts +8 -8
- package/dist/schema/utils/node-parser.js +7 -4
- package/dist/schema-query/index.d.ts +7 -1
- package/dist/schema-query/index.js +204 -4
- package/dist/schemas/account_operation.output.json +14 -22
- package/dist/schemas/account_operation.schema.json +11 -25
- 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 +10 -10
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +348 -296
- package/dist/schemas/onchain_operations_allocation.schema.json +34 -25
- package/dist/schemas/onchain_operations_arbitration.schema.json +8 -8
- package/dist/schemas/onchain_operations_contact.schema.json +8 -8
- package/dist/schemas/onchain_operations_demand.schema.json +8 -8
- package/dist/schemas/onchain_operations_gen_passport.schema.json +14 -14
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +41 -33
- package/dist/schemas/onchain_operations_order.schema.json +71 -77
- package/dist/schemas/onchain_operations_payment.schema.json +141 -111
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_personal.schema.json +7 -7
- package/dist/schemas/onchain_operations_progress.schema.json +8 -8
- package/dist/schemas/onchain_operations_proof.schema.json +7 -7
- package/dist/schemas/onchain_operations_repository.schema.json +8 -8
- package/dist/schemas/onchain_operations_reward.schema.json +10 -10
- package/dist/schemas/onchain_operations_service.schema.json +46 -35
- package/dist/schemas/onchain_operations_treasury.schema.json +8 -8
- package/dist/schemas/onchain_table_data.output.json +33 -25
- package/dist/schemas/onchain_table_data.schema.json +12 -12
- package/dist/schemas/project_operation.output.json +1352 -20
- package/dist/schemas/project_operation.schema.json +53 -4
- package/dist/schemas/query_toolkit.output.json +111 -82
- package/dist/schemas/query_toolkit.schema.json +9 -13
- package/dist/schemas/schema_query.output.json +7 -3
- package/dist/schemas/schema_query.schema.json +17 -3
- package/dist/telemetry/storage.js +2 -2
- package/dist/tools/handlers/local.js +20 -5
- package/dist/tools/handlers/onchain.js +36 -0
- package/dist/tools/handlers/project.js +72 -1
- package/dist/tools/handlers/query.js +27 -0
- package/dist/tools/handlers/schema-query.js +19 -0
- 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.js +212 -8
- 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,594 @@
|
|
|
1
|
+
export class CapabilityRegistry {
|
|
2
|
+
static instance;
|
|
3
|
+
cards = new Map();
|
|
4
|
+
edges = [];
|
|
5
|
+
initialized = false;
|
|
6
|
+
static Instance() {
|
|
7
|
+
if (!CapabilityRegistry.instance) {
|
|
8
|
+
CapabilityRegistry.instance = new CapabilityRegistry();
|
|
9
|
+
}
|
|
10
|
+
return CapabilityRegistry.instance;
|
|
11
|
+
}
|
|
12
|
+
constructor() {
|
|
13
|
+
this.registerBuiltins();
|
|
14
|
+
this.registerBuiltinEdges();
|
|
15
|
+
this.initialized = true;
|
|
16
|
+
}
|
|
17
|
+
registerCard(card) {
|
|
18
|
+
if (!card.capability_id || !card.object_type || !card.module)
|
|
19
|
+
return false;
|
|
20
|
+
this.cards.set(card.capability_id, card);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
getCard(capabilityId) {
|
|
24
|
+
return this.cards.get(capabilityId);
|
|
25
|
+
}
|
|
26
|
+
listCards(filter) {
|
|
27
|
+
let all = Array.from(this.cards.values());
|
|
28
|
+
if (!filter)
|
|
29
|
+
return all;
|
|
30
|
+
if (filter.objectType)
|
|
31
|
+
all = all.filter(c => c.object_type === filter.objectType);
|
|
32
|
+
if (filter.module)
|
|
33
|
+
all = all.filter(c => c.module === filter.module);
|
|
34
|
+
if (filter.industryAgnostic)
|
|
35
|
+
all = all.filter(c => c.industry_agnostic === filter.industryAgnostic);
|
|
36
|
+
if (filter.industry)
|
|
37
|
+
all = all.filter(c => c.observed_in_industries[filter.industry] !== undefined ||
|
|
38
|
+
c.industry_overrides?.[filter.industry] !== undefined);
|
|
39
|
+
return all;
|
|
40
|
+
}
|
|
41
|
+
registerEdge(edge) {
|
|
42
|
+
this.edges.push(edge);
|
|
43
|
+
}
|
|
44
|
+
getGraph() {
|
|
45
|
+
return {
|
|
46
|
+
nodes: new Map(this.cards),
|
|
47
|
+
edges: [...this.edges],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
getDependencies(capabilityId) {
|
|
51
|
+
const visited = new Set();
|
|
52
|
+
const result = [];
|
|
53
|
+
const traverse = (id) => {
|
|
54
|
+
if (visited.has(id))
|
|
55
|
+
return;
|
|
56
|
+
visited.add(id);
|
|
57
|
+
for (const edge of this.edges) {
|
|
58
|
+
if (edge.from === id && edge.edge_kind === "requires") {
|
|
59
|
+
const dep = this.cards.get(edge.to);
|
|
60
|
+
if (dep && !visited.has(dep.capability_id)) {
|
|
61
|
+
result.push(dep);
|
|
62
|
+
traverse(edge.to);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
traverse(capabilityId);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
getDependents(capabilityId) {
|
|
71
|
+
const result = [];
|
|
72
|
+
for (const edge of this.edges) {
|
|
73
|
+
if (edge.to === capabilityId && edge.edge_kind === "requires") {
|
|
74
|
+
const dep = this.cards.get(edge.from);
|
|
75
|
+
if (dep)
|
|
76
|
+
result.push(dep);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
getCapabilitiesByIndustry(industry) {
|
|
82
|
+
return this.listCards({ industry });
|
|
83
|
+
}
|
|
84
|
+
getCapabilitiesByObject(objectType) {
|
|
85
|
+
return this.listCards({ objectType });
|
|
86
|
+
}
|
|
87
|
+
evaluateMigration(source, target) {
|
|
88
|
+
const sourceCaps = this.getCapabilitiesByIndustry(source);
|
|
89
|
+
const targetCaps = this.getCapabilitiesByIndustry(target);
|
|
90
|
+
const sourceIds = new Set(sourceCaps.map(c => c.capability_id));
|
|
91
|
+
const targetIds = new Set(targetCaps.map(c => c.capability_id));
|
|
92
|
+
const covered = [];
|
|
93
|
+
const missing = [];
|
|
94
|
+
const conflicting = [];
|
|
95
|
+
for (const id of sourceIds) {
|
|
96
|
+
if (targetIds.has(id)) {
|
|
97
|
+
covered.push(id);
|
|
98
|
+
const sourceCard = sourceCaps.find(c => c.capability_id === id);
|
|
99
|
+
const targetCard = targetCaps.find(c => c.capability_id === id);
|
|
100
|
+
const diff = this.computeConfigDiff(sourceCard.industry_overrides?.[source] ?? sourceCard.config_template, targetCard.industry_overrides?.[target] ?? targetCard.config_template);
|
|
101
|
+
if (diff.diff_ratio > 0.5) {
|
|
102
|
+
conflicting.push({
|
|
103
|
+
capability_id: id,
|
|
104
|
+
source_config: sourceCard.industry_overrides?.[source] ?? sourceCard.config_template,
|
|
105
|
+
target_config: targetCard.industry_overrides?.[target] ?? targetCard.config_template,
|
|
106
|
+
diff_summary: diff.summary,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (const id of targetIds) {
|
|
112
|
+
if (!sourceIds.has(id))
|
|
113
|
+
missing.push(id);
|
|
114
|
+
}
|
|
115
|
+
const feasibility_score = covered.length === 0 && missing.length === 0
|
|
116
|
+
? 0
|
|
117
|
+
: Math.round(((covered.length - conflicting.length) / (covered.length + missing.length)) * 100);
|
|
118
|
+
const recommendations = [];
|
|
119
|
+
if (missing.length > 0) {
|
|
120
|
+
recommendations.push(`缺失 ${missing.length} 个能力,需要新增:${missing.slice(0, 5).join(", ")}${missing.length > 5 ? "..." : ""}`);
|
|
121
|
+
}
|
|
122
|
+
if (conflicting.length > 0) {
|
|
123
|
+
recommendations.push(`检测到 ${conflicting.length} 个能力参数差异过大,需要重写配置`);
|
|
124
|
+
}
|
|
125
|
+
if (feasibility_score >= 80) {
|
|
126
|
+
recommendations.push("迁移可行性高,可直接复用大部分能力");
|
|
127
|
+
}
|
|
128
|
+
else if (feasibility_score >= 50) {
|
|
129
|
+
recommendations.push("迁移可行性中等,需要补充或重写部分能力");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
recommendations.push("迁移可行性低,建议基于 target 行业模板重新生成方案");
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
feasibility_score,
|
|
136
|
+
covered_capabilities: covered,
|
|
137
|
+
missing_capabilities: missing,
|
|
138
|
+
conflicting_capabilities: conflicting,
|
|
139
|
+
recommendations,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
findPurityViolations() {
|
|
143
|
+
return Array.from(this.cards.values()).filter(c => {
|
|
144
|
+
if (c.industry_agnostic !== "high")
|
|
145
|
+
return false;
|
|
146
|
+
const overrideCount = c.industry_overrides ? Object.keys(c.industry_overrides).length : 0;
|
|
147
|
+
return overrideCount >= 3;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
recordUsage(capabilityId, industry) {
|
|
151
|
+
const card = this.cards.get(capabilityId);
|
|
152
|
+
if (!card)
|
|
153
|
+
return;
|
|
154
|
+
if (!card.observed_in_industries[industry]) {
|
|
155
|
+
card.observed_in_industries[industry] = 0;
|
|
156
|
+
}
|
|
157
|
+
card.observed_in_industries[industry]++;
|
|
158
|
+
}
|
|
159
|
+
recordSuccess(capabilityId) {
|
|
160
|
+
const card = this.cards.get(capabilityId);
|
|
161
|
+
if (card)
|
|
162
|
+
card.success_count++;
|
|
163
|
+
}
|
|
164
|
+
recordFailure(capabilityId, reason) {
|
|
165
|
+
const card = this.cards.get(capabilityId);
|
|
166
|
+
if (!card)
|
|
167
|
+
return;
|
|
168
|
+
card.failure_count++;
|
|
169
|
+
if (reason && !card.known_failure_modes.includes(reason)) {
|
|
170
|
+
card.known_failure_modes.push(reason);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
recordVerificationReport(report) {
|
|
174
|
+
for (const capId of report.capabilities_used) {
|
|
175
|
+
this.recordUsage(capId, report.industry);
|
|
176
|
+
if (report.result === "success") {
|
|
177
|
+
this.recordSuccess(capId);
|
|
178
|
+
}
|
|
179
|
+
else if (report.result === "failure") {
|
|
180
|
+
const reason = report.failure_reasons?.[0] ?? "unknown failure";
|
|
181
|
+
this.recordFailure(capId, reason);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
getCapabilitiesForExtension(capabilitiesUsed) {
|
|
186
|
+
return capabilitiesUsed
|
|
187
|
+
.map(id => this.cards.get(id))
|
|
188
|
+
.filter((c) => c !== undefined);
|
|
189
|
+
}
|
|
190
|
+
evaluateExtensionCoverage(industry, capabilitiesUsed) {
|
|
191
|
+
const declared = capabilitiesUsed.length;
|
|
192
|
+
const industryCaps = this.getCapabilitiesByIndustry(industry);
|
|
193
|
+
const expected = industryCaps.length || declared;
|
|
194
|
+
const missing = industryCaps
|
|
195
|
+
.filter(c => !capabilitiesUsed.includes(c.capability_id))
|
|
196
|
+
.map(c => c.capability_id);
|
|
197
|
+
const coverage = expected === 0 ? 100 : Math.round((declared / expected) * 100);
|
|
198
|
+
return {
|
|
199
|
+
industry,
|
|
200
|
+
declared_count: declared,
|
|
201
|
+
expected_count: expected,
|
|
202
|
+
coverage_percentage: Math.min(coverage, 100),
|
|
203
|
+
missing_capabilities: missing,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
registerBuiltins() {
|
|
207
|
+
this.registerCard({
|
|
208
|
+
capability_id: "permission.index_create",
|
|
209
|
+
display_name: "Permission Index Create",
|
|
210
|
+
description: "创建角色权限索引,支持 merchant/customer/arbiter 等多角色权限分配",
|
|
211
|
+
object_type: "permission", module: "handler", category: "trust",
|
|
212
|
+
industry_agnostic: "high",
|
|
213
|
+
config_template: {
|
|
214
|
+
permission_indexes: [
|
|
215
|
+
{ name: "merchant", description: "Service owner" },
|
|
216
|
+
{ name: "customer", description: "Service buyer" },
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
industry_overrides: {
|
|
220
|
+
education: { permission_indexes: [
|
|
221
|
+
{ name: "teacher", description: "Course provider" },
|
|
222
|
+
{ name: "student", description: "Course consumer" },
|
|
223
|
+
{ name: "parent", description: "Guardian (minor)" },
|
|
224
|
+
] },
|
|
225
|
+
travel: { permission_indexes: [
|
|
226
|
+
{ name: "guide", description: "Tour guide" },
|
|
227
|
+
{ name: "tourist", description: "Tour participant" },
|
|
228
|
+
] },
|
|
229
|
+
},
|
|
230
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
231
|
+
depends_on_capabilities: [], version: "v1",
|
|
232
|
+
});
|
|
233
|
+
this.registerCard({
|
|
234
|
+
capability_id: "permission.role_assign",
|
|
235
|
+
display_name: "Permission Role Assign",
|
|
236
|
+
description: "为对象(Machine/Service/Allocation)分配角色权限索引",
|
|
237
|
+
object_type: "permission", module: "handler", category: "trust",
|
|
238
|
+
industry_agnostic: "high",
|
|
239
|
+
config_template: { target_object: "<obj>", role: "<role_name>" },
|
|
240
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
241
|
+
depends_on_capabilities: ["permission.index_create"], version: "v1",
|
|
242
|
+
});
|
|
243
|
+
this.registerCard({
|
|
244
|
+
capability_id: "guard.validate_buy",
|
|
245
|
+
display_name: "Guard Validate Buy",
|
|
246
|
+
description: "下单验证:检查买家资格、订单参数、库存等条件",
|
|
247
|
+
object_type: "guard", module: "handler", category: "validation",
|
|
248
|
+
industry_agnostic: "medium",
|
|
249
|
+
config_template: { host: "service", templates: [] },
|
|
250
|
+
industry_overrides: {
|
|
251
|
+
retail: { templates: ["tpl_check_inventory", "tpl_check_buyer_address"] },
|
|
252
|
+
freelance: { templates: ["tpl_check_buyer_budget", "tpl_check_freelancer_available"] },
|
|
253
|
+
rental: { templates: ["tpl_check_deposit", "tpl_check_item_available"] },
|
|
254
|
+
},
|
|
255
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
256
|
+
depends_on_capabilities: ["permission.index_create"], version: "v1",
|
|
257
|
+
});
|
|
258
|
+
this.registerCard({
|
|
259
|
+
capability_id: "guard.validate_wip_hash",
|
|
260
|
+
display_name: "Guard Validate WIP Hash",
|
|
261
|
+
description: "验证 WIP(Work-In-Progress)哈希,用于数字交付物的里程碑验证",
|
|
262
|
+
object_type: "guard", module: "handler", category: "evidence",
|
|
263
|
+
industry_agnostic: "low",
|
|
264
|
+
config_template: { host: "machine", templates: ["tpl_validate_wip_hash"] },
|
|
265
|
+
industry_overrides: {
|
|
266
|
+
freelance: { templates: ["tpl_validate_wip_hash", "tpl_validate_deliverable_format"] },
|
|
267
|
+
},
|
|
268
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0,
|
|
269
|
+
known_failure_modes: ["milestone mode requires WIP hash evidence — without WIP, allocation cannot advance"],
|
|
270
|
+
depends_on_capabilities: ["guard.validate_buy"], version: "v1",
|
|
271
|
+
});
|
|
272
|
+
this.registerCard({
|
|
273
|
+
capability_id: "machine.node_topology",
|
|
274
|
+
display_name: "Machine Node Topology",
|
|
275
|
+
description: "工作流节点拓扑:定义订单从创建到完成的状态机",
|
|
276
|
+
object_type: "machine", module: "templates", category: "workflow",
|
|
277
|
+
industry_agnostic: "low",
|
|
278
|
+
config_template: {
|
|
279
|
+
nodes: [
|
|
280
|
+
{ name: "paid", role: "Entry: order created and paid" },
|
|
281
|
+
{ name: "delivering", role: "Service delivery in progress" },
|
|
282
|
+
{ name: "completed", role: "Service completed, funds released" },
|
|
283
|
+
{ name: "refunded", role: "Customer refund path" },
|
|
284
|
+
{ name: "cancelled", role: "Pre-delivery cancellation" },
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
industry_overrides: {
|
|
288
|
+
retail: { nodes: [
|
|
289
|
+
{ name: "paid", role: "Order paid" },
|
|
290
|
+
{ name: "shipped", role: "Goods shipped" },
|
|
291
|
+
{ name: "delivered", role: "Goods delivered" },
|
|
292
|
+
{ name: "confirmed", role: "Buyer confirms receipt" },
|
|
293
|
+
{ name: "completed", role: "Funds released" },
|
|
294
|
+
{ name: "refunded", role: "Return & refund" },
|
|
295
|
+
{ name: "cancelled", role: "Pre-ship cancellation" },
|
|
296
|
+
] },
|
|
297
|
+
freelance: { nodes: [
|
|
298
|
+
{ name: "paid", role: "Order paid (escrow)" },
|
|
299
|
+
{ name: "in_progress", role: "Freelancer working" },
|
|
300
|
+
{ name: "submitted", role: "Work submitted for review" },
|
|
301
|
+
{ name: "accepted", role: "Buyer accepts deliverable" },
|
|
302
|
+
{ name: "completed", role: "Funds released" },
|
|
303
|
+
{ name: "revision", role: "Revision requested" },
|
|
304
|
+
{ name: "refunded", role: "Refund path" },
|
|
305
|
+
{ name: "cancelled", role: "Pre-start cancellation" },
|
|
306
|
+
] },
|
|
307
|
+
},
|
|
308
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
309
|
+
depends_on_capabilities: ["permission.index_create"], version: "v1",
|
|
310
|
+
});
|
|
311
|
+
this.registerCard({
|
|
312
|
+
capability_id: "treasury.owner_receive",
|
|
313
|
+
display_name: "Treasury Owner Receive",
|
|
314
|
+
description: "资金托管:支持 owner_receive 模式,资金直接进入对象 owner 钱包",
|
|
315
|
+
object_type: "treasury", module: "handler", category: "fund_flow",
|
|
316
|
+
industry_agnostic: "high",
|
|
317
|
+
config_template: { owner_receive: true },
|
|
318
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
319
|
+
depends_on_capabilities: [], version: "v1",
|
|
320
|
+
});
|
|
321
|
+
this.registerCard({
|
|
322
|
+
capability_id: "allocation.distribute",
|
|
323
|
+
display_name: "Multi-tier Allocation Distribution",
|
|
324
|
+
description: "多级分账:支持按比例 / 按顺序 / 按条件分配资金给多个接收者",
|
|
325
|
+
object_type: "allocation", module: "handler", category: "fund_flow",
|
|
326
|
+
industry_agnostic: "medium",
|
|
327
|
+
config_template: {
|
|
328
|
+
strategy: { recipient: "entity", count: 1, mode: "surplus", description: "Default: all to service owner" },
|
|
329
|
+
},
|
|
330
|
+
industry_overrides: {
|
|
331
|
+
retail: { strategy: { recipient: "entity", count: 2, mode: "rate", description: "Platform 10% + Merchant 90%" } },
|
|
332
|
+
freelance: { strategy: { recipient: "entity", count: 2, mode: "milestone", description: "50% upfront + 50% on delivery" } },
|
|
333
|
+
travel: { strategy: { recipient: "entity", count: 3, mode: "rate", description: "Guide 60% + Platform 30% + Insurance 10%" } },
|
|
334
|
+
},
|
|
335
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0,
|
|
336
|
+
known_failure_modes: ["milestone mode requires WIP hash evidence — without WIP, allocation cannot advance"],
|
|
337
|
+
depends_on_capabilities: ["treasury.owner_receive", "guard.validate_buy"], version: "v1",
|
|
338
|
+
});
|
|
339
|
+
this.registerCard({
|
|
340
|
+
capability_id: "allocation.distribute_milestone",
|
|
341
|
+
display_name: "Milestone-based Allocation",
|
|
342
|
+
description: "里程碑分账:按交付里程碑释放资金,每里程碑需 WIP 哈希验证",
|
|
343
|
+
object_type: "allocation", module: "handler", category: "fund_flow",
|
|
344
|
+
industry_agnostic: "low",
|
|
345
|
+
config_template: {
|
|
346
|
+
strategy: { recipient: "entity", count: 2, mode: "milestone", description: "Milestone-based release" },
|
|
347
|
+
},
|
|
348
|
+
industry_overrides: {
|
|
349
|
+
freelance: { strategy: { recipient: "entity", count: 2, mode: "milestone", description: "50% upfront + 50% on delivery" } },
|
|
350
|
+
education: { strategy: { recipient: "entity", count: 2, mode: "milestone", description: "Per session release" } },
|
|
351
|
+
},
|
|
352
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
353
|
+
depends_on_capabilities: ["allocation.distribute", "guard.validate_wip_hash"], version: "v1",
|
|
354
|
+
});
|
|
355
|
+
this.registerCard({
|
|
356
|
+
capability_id: "service.publish",
|
|
357
|
+
display_name: "Service Publish",
|
|
358
|
+
description: "发布 Service 对象到链上,绑定 Machine/Guard/Permission/Allocation 等依赖",
|
|
359
|
+
object_type: "service", module: "handler", category: "lifecycle",
|
|
360
|
+
industry_agnostic: "high",
|
|
361
|
+
config_template: {
|
|
362
|
+
machine: "<machine_name>",
|
|
363
|
+
buy_guard: "<guard_name>",
|
|
364
|
+
permission: "<permission_name>",
|
|
365
|
+
order_allocators: ["<allocation_name>"],
|
|
366
|
+
compensation_fund_balance: 0,
|
|
367
|
+
compensation_fund_add_hint: "Post-publish: call service.compensation_fund_add with Coin<T>. Recommend 5× max single-order amount.",
|
|
368
|
+
},
|
|
369
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
370
|
+
depends_on_capabilities: [
|
|
371
|
+
"machine.node_topology", "guard.validate_buy", "permission.index_create",
|
|
372
|
+
"allocation.distribute", "treasury.owner_receive",
|
|
373
|
+
],
|
|
374
|
+
version: "v1",
|
|
375
|
+
});
|
|
376
|
+
this.registerCard({
|
|
377
|
+
capability_id: "progress.advance",
|
|
378
|
+
display_name: "Progress Advance",
|
|
379
|
+
description: "订单履约进度推进:基于 Machine 节点拓扑前进到下一状态",
|
|
380
|
+
object_type: "progress", module: "handler", category: "workflow",
|
|
381
|
+
industry_agnostic: "medium",
|
|
382
|
+
config_template: { parent: "<machine_name>" },
|
|
383
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
384
|
+
depends_on_capabilities: ["machine.node_topology"], version: "v1",
|
|
385
|
+
});
|
|
386
|
+
this.registerCard({
|
|
387
|
+
capability_id: "arb.vote_weighted",
|
|
388
|
+
display_name: "Arbitration Vote Weighted",
|
|
389
|
+
description: "guard-based 加权投票仲裁:按 Guard 权重投票决定仲裁结果",
|
|
390
|
+
object_type: "arb", module: "handler", category: "trust",
|
|
391
|
+
industry_agnostic: "medium",
|
|
392
|
+
config_template: { guard: "<guard_name>", voting_rule: "guard_weighted" },
|
|
393
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
394
|
+
depends_on_capabilities: ["guard.validate_buy"], version: "v1",
|
|
395
|
+
});
|
|
396
|
+
this.registerCard({
|
|
397
|
+
capability_id: "reward.claim_guard",
|
|
398
|
+
display_name: "Reward Claim Guard",
|
|
399
|
+
description: "奖励申领:通过 Guard 验证申领条件(如好评、复购)后释放奖励",
|
|
400
|
+
object_type: "reward", module: "handler", category: "fund_flow",
|
|
401
|
+
industry_agnostic: "medium",
|
|
402
|
+
config_template: { claim_guard: "<guard_name>", max_guard_count: 1 },
|
|
403
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
404
|
+
depends_on_capabilities: ["guard.validate_buy"], version: "v1",
|
|
405
|
+
});
|
|
406
|
+
this.registerCard({
|
|
407
|
+
capability_id: "contact.im_create",
|
|
408
|
+
display_name: "Contact IM Create",
|
|
409
|
+
description: "创建 IM 联系对象:买卖双方通过 Messenger 通信",
|
|
410
|
+
object_type: "contact", module: "handler", category: "communication",
|
|
411
|
+
industry_agnostic: "high",
|
|
412
|
+
config_template: {},
|
|
413
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
414
|
+
depends_on_capabilities: [], version: "v1",
|
|
415
|
+
});
|
|
416
|
+
this.registerCard({
|
|
417
|
+
capability_id: "demand.matching",
|
|
418
|
+
display_name: "Demand Matching",
|
|
419
|
+
description: "需求匹配:根据用户需求匹配对应 Service",
|
|
420
|
+
object_type: "demand", module: "handler", category: "query",
|
|
421
|
+
industry_agnostic: "high",
|
|
422
|
+
config_template: {},
|
|
423
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
424
|
+
depends_on_capabilities: ["service.publish"], version: "v1",
|
|
425
|
+
});
|
|
426
|
+
this.registerCard({
|
|
427
|
+
capability_id: "repository.write_validate",
|
|
428
|
+
display_name: "Repository Write Validate",
|
|
429
|
+
description: "知识库写入验证:通过 Guard 验证写入权限和数据格式",
|
|
430
|
+
object_type: "repository", module: "handler", category: "validation",
|
|
431
|
+
industry_agnostic: "high",
|
|
432
|
+
config_template: {},
|
|
433
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
434
|
+
depends_on_capabilities: ["guard.validate_buy"], version: "v1",
|
|
435
|
+
});
|
|
436
|
+
this.registerCard({
|
|
437
|
+
capability_id: "proof.evidence_anchor",
|
|
438
|
+
display_name: "Proof Evidence Anchor",
|
|
439
|
+
description: "凭证上链:将交付凭证(哈希)锚定到链上 Progress 节点",
|
|
440
|
+
object_type: "proof", module: "handler", category: "evidence",
|
|
441
|
+
industry_agnostic: "medium",
|
|
442
|
+
config_template: {},
|
|
443
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
444
|
+
depends_on_capabilities: ["progress.advance"], version: "v1",
|
|
445
|
+
});
|
|
446
|
+
this.registerCard({
|
|
447
|
+
capability_id: "personal.profile_manage",
|
|
448
|
+
display_name: "Personal Profile Manage",
|
|
449
|
+
description: "个人档案管理:用户身份/偏好/历史记录管理",
|
|
450
|
+
object_type: "personal", module: "handler", category: "data_model",
|
|
451
|
+
industry_agnostic: "high",
|
|
452
|
+
config_template: {},
|
|
453
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
454
|
+
depends_on_capabilities: [], version: "v1",
|
|
455
|
+
});
|
|
456
|
+
this.registerCard({
|
|
457
|
+
capability_id: "payment.settle",
|
|
458
|
+
display_name: "Payment Settle",
|
|
459
|
+
description: "支付结算:与 Allocation 协作完成资金结算",
|
|
460
|
+
object_type: "payment", module: "handler", category: "fund_flow",
|
|
461
|
+
industry_agnostic: "high",
|
|
462
|
+
config_template: {},
|
|
463
|
+
observed_in_industries: {}, success_count: 0, failure_count: 0, known_failure_modes: [],
|
|
464
|
+
depends_on_capabilities: ["allocation.distribute", "treasury.owner_receive"], version: "v1",
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
registerBuiltinEdges() {
|
|
468
|
+
const serviceDeps = [
|
|
469
|
+
"machine.node_topology", "guard.validate_buy", "permission.index_create",
|
|
470
|
+
"allocation.distribute", "treasury.owner_receive",
|
|
471
|
+
];
|
|
472
|
+
for (const dep of serviceDeps) {
|
|
473
|
+
this.registerEdge({
|
|
474
|
+
from: "service.publish", to: dep,
|
|
475
|
+
edge_kind: "requires", phase: "publish",
|
|
476
|
+
description: "Service publish requires this capability",
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
this.registerEdge({
|
|
480
|
+
from: "service.publish", to: "arb.vote_weighted",
|
|
481
|
+
edge_kind: "optional", phase: "publish",
|
|
482
|
+
description: "Optional: arbitration for dispute resolution",
|
|
483
|
+
});
|
|
484
|
+
this.registerEdge({
|
|
485
|
+
from: "service.publish", to: "reward.claim_guard",
|
|
486
|
+
edge_kind: "optional", phase: "publish",
|
|
487
|
+
description: "Optional: reward for positive behavior",
|
|
488
|
+
});
|
|
489
|
+
this.registerEdge({
|
|
490
|
+
from: "service.publish", to: "contact.im_create",
|
|
491
|
+
edge_kind: "optional", phase: "publish",
|
|
492
|
+
description: "Optional: IM contact between buyer and seller",
|
|
493
|
+
});
|
|
494
|
+
this.registerEdge({
|
|
495
|
+
from: "permission.role_assign", to: "permission.index_create",
|
|
496
|
+
edge_kind: "requires", phase: "create",
|
|
497
|
+
description: "Role assignment requires permission index",
|
|
498
|
+
});
|
|
499
|
+
this.registerEdge({
|
|
500
|
+
from: "machine.node_topology", to: "permission.index_create",
|
|
501
|
+
edge_kind: "requires", phase: "create",
|
|
502
|
+
description: "Machine requires permission for role-based node access",
|
|
503
|
+
});
|
|
504
|
+
this.registerEdge({
|
|
505
|
+
from: "allocation.distribute", to: "treasury.owner_receive",
|
|
506
|
+
edge_kind: "requires", phase: "runtime",
|
|
507
|
+
description: "Allocation distributes via treasury",
|
|
508
|
+
});
|
|
509
|
+
this.registerEdge({
|
|
510
|
+
from: "allocation.distribute", to: "guard.validate_buy",
|
|
511
|
+
edge_kind: "requires", phase: "runtime",
|
|
512
|
+
description: "Allocation requires guard validation",
|
|
513
|
+
});
|
|
514
|
+
this.registerEdge({
|
|
515
|
+
from: "allocation.distribute_milestone", to: "allocation.distribute",
|
|
516
|
+
edge_kind: "requires", phase: "create",
|
|
517
|
+
description: "Milestone allocation extends base allocation",
|
|
518
|
+
});
|
|
519
|
+
this.registerEdge({
|
|
520
|
+
from: "allocation.distribute_milestone", to: "guard.validate_wip_hash",
|
|
521
|
+
edge_kind: "requires", phase: "runtime",
|
|
522
|
+
description: "Milestone allocation requires WIP hash validation",
|
|
523
|
+
});
|
|
524
|
+
this.registerEdge({
|
|
525
|
+
from: "progress.advance", to: "machine.node_topology",
|
|
526
|
+
edge_kind: "requires", phase: "runtime",
|
|
527
|
+
description: "Progress advances based on machine topology",
|
|
528
|
+
});
|
|
529
|
+
this.registerEdge({
|
|
530
|
+
from: "arb.vote_weighted", to: "guard.validate_buy",
|
|
531
|
+
edge_kind: "requires", phase: "runtime",
|
|
532
|
+
description: "Arbitration voting requires guard for weight validation",
|
|
533
|
+
});
|
|
534
|
+
this.registerEdge({
|
|
535
|
+
from: "reward.claim_guard", to: "guard.validate_buy",
|
|
536
|
+
edge_kind: "requires", phase: "runtime",
|
|
537
|
+
description: "Reward claim requires guard validation",
|
|
538
|
+
});
|
|
539
|
+
this.registerEdge({
|
|
540
|
+
from: "proof.evidence_anchor", to: "progress.advance",
|
|
541
|
+
edge_kind: "requires", phase: "runtime",
|
|
542
|
+
description: "Proof anchors to progress node",
|
|
543
|
+
});
|
|
544
|
+
this.registerEdge({
|
|
545
|
+
from: "payment.settle", to: "allocation.distribute",
|
|
546
|
+
edge_kind: "requires", phase: "runtime",
|
|
547
|
+
description: "Payment settles via allocation",
|
|
548
|
+
});
|
|
549
|
+
this.registerEdge({
|
|
550
|
+
from: "demand.matching", to: "service.publish",
|
|
551
|
+
edge_kind: "requires", phase: "runtime",
|
|
552
|
+
description: "Demand matching requires published services",
|
|
553
|
+
});
|
|
554
|
+
this.registerEdge({
|
|
555
|
+
from: "repository.write_validate", to: "guard.validate_buy",
|
|
556
|
+
edge_kind: "requires", phase: "runtime",
|
|
557
|
+
description: "Repository write requires guard validation",
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
computeConfigDiff(source, target) {
|
|
561
|
+
if (typeof source !== "object" || typeof target !== "object" || source === null || target === null) {
|
|
562
|
+
return source === target ? { diff_ratio: 0, summary: "identical" } : { diff_ratio: 1, summary: "type mismatch" };
|
|
563
|
+
}
|
|
564
|
+
const s = source;
|
|
565
|
+
const t = target;
|
|
566
|
+
const sKeys = new Set(Object.keys(s));
|
|
567
|
+
const tKeys = new Set(Object.keys(t));
|
|
568
|
+
const allKeys = new Set([...sKeys, ...tKeys]);
|
|
569
|
+
if (allKeys.size === 0)
|
|
570
|
+
return { diff_ratio: 0, summary: "empty configs" };
|
|
571
|
+
let diffCount = 0;
|
|
572
|
+
const diffs = [];
|
|
573
|
+
for (const k of allKeys) {
|
|
574
|
+
const sv = s[k], tv = t[k];
|
|
575
|
+
if (JSON.stringify(sv) !== JSON.stringify(tv)) {
|
|
576
|
+
diffCount++;
|
|
577
|
+
diffs.push(k);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const diff_ratio = diffCount / allKeys.size;
|
|
581
|
+
const summary = `${diffCount}/${allKeys.size} fields differ: ${diffs.slice(0, 3).join(", ")}${diffs.length > 3 ? "..." : ""}`;
|
|
582
|
+
return { diff_ratio, summary };
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
export function getCapabilityRegistry() {
|
|
586
|
+
return CapabilityRegistry.Instance();
|
|
587
|
+
}
|
|
588
|
+
export const CAPABILITY_MANIFEST_VERSION = 1;
|
|
589
|
+
export function recordCapabilitiesUsed(industry, capabilitiesUsed) {
|
|
590
|
+
const registry = CapabilityRegistry.Instance();
|
|
591
|
+
for (const capId of capabilitiesUsed) {
|
|
592
|
+
registry.recordUsage(capId, industry);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ModeConstraint, ConstraintRule, ConstraintViolation, ConstraintSeverity, ConstraintViolationAction, IndustryMode } from "./types.js";
|
|
2
|
+
import type { CapabilityRegistry } from "./capability-manifest.js";
|
|
3
|
+
export declare class ConstraintRegistry {
|
|
4
|
+
private static instance;
|
|
5
|
+
private constraints;
|
|
6
|
+
private initialized;
|
|
7
|
+
static Instance(): ConstraintRegistry;
|
|
8
|
+
private constructor();
|
|
9
|
+
registerConstraint(constraint: ModeConstraint): boolean;
|
|
10
|
+
registerCustomConstraint(constraint_id: string, display_name: string, description: string, rule: ConstraintRule, owner: string, severity?: ConstraintSeverity, on_violation?: ConstraintViolationAction): boolean;
|
|
11
|
+
getConstraint(constraint_id: string): ModeConstraint | undefined;
|
|
12
|
+
listConstraints(filter?: {
|
|
13
|
+
scope?: "builtin" | "custom";
|
|
14
|
+
owner?: string;
|
|
15
|
+
severity?: ConstraintSeverity;
|
|
16
|
+
}): ModeConstraint[];
|
|
17
|
+
unregisterConstraint(constraint_id: string, owner: string): boolean;
|
|
18
|
+
checkConstraints(mode: IndustryMode, _capabilityRegistry: CapabilityRegistry, extraConstraints?: ModeConstraint[]): ConstraintViolation[];
|
|
19
|
+
private checkConstraint;
|
|
20
|
+
private getNumericField;
|
|
21
|
+
private registerBuiltinConstraints;
|
|
22
|
+
}
|
|
23
|
+
export declare function getConstraintRegistry(): ConstraintRegistry;
|
|
24
|
+
export declare const BUILTIN_CONSTRAINTS_COUNT: number;
|