@wowok/agent-mcp 2.6.3 → 2.6.6
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 +13 -9
- package/dist/customer/customer-advice.d.ts +31 -0
- package/dist/customer/customer-advice.js +129 -0
- package/dist/customer/index.d.ts +2 -0
- package/dist/customer/index.js +2 -0
- package/dist/customer/info-puzzle.d.ts +8 -1
- package/dist/customer/info-puzzle.js +30 -5
- package/dist/customer/order-monitor.d.ts +2 -0
- package/dist/customer/order-monitor.js +3 -2
- package/dist/customer/post-purchase.d.ts +2 -0
- package/dist/customer/post-purchase.js +6 -5
- package/dist/customer/preorder-compare.d.ts +24 -0
- package/dist/customer/preorder-compare.js +34 -0
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +2 -1
- package/dist/customer/risk-assessment.js +4 -3
- package/dist/customer/types.d.ts +5 -0
- package/dist/examples/arbitration-dispute-create.json +41 -0
- package/dist/examples/arbitration-vote-weighted.json +35 -0
- package/dist/examples/arbitration-voting-guard-add.json +38 -0
- package/dist/examples/demand-present-service.json +33 -0
- package/dist/examples/gen-passport-verify-guard.json +48 -0
- package/dist/examples/guard-template-balance-check.json +36 -15
- package/dist/examples/guard-template-time-lock.json +33 -12
- package/dist/examples/insurance-guard-claim-timelock.json +75 -0
- package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
- package/dist/examples/insurance-machine-create-publish.json +75 -0
- package/dist/examples/insurance-service-allocators-publish.json +56 -0
- package/dist/examples/machine-multisig-threshold.json +86 -0
- package/dist/examples/machine-template-7node-rental.json +99 -94
- package/dist/examples/payment-scenario-bound.json +45 -0
- package/dist/examples/rental-ziroom-machine-create.json +126 -114
- package/dist/examples/rental-ziroom-permission-create.json +10 -3
- package/dist/examples/rental-ziroom-service-create.json +27 -18
- package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
- package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
- package/dist/examples/retail-adv-reward-guard-add.json +51 -0
- package/dist/examples/retail-myshop-allocation-activate.json +55 -0
- package/dist/examples/retail-myshop-arbitration-create.json +40 -0
- package/dist/examples/retail-myshop-contact-create.json +43 -0
- package/dist/examples/retail-myshop-order-create.json +56 -0
- package/dist/examples/retail-myshop-progress-operate.json +38 -0
- package/dist/examples/retail-myshop-reward-create.json +35 -0
- package/dist/examples/service-discount-issue.json +46 -0
- package/dist/examples/threebody-guard-create.json +56 -0
- package/dist/examples/threebody-machine-create.json +72 -0
- package/dist/examples/threebody-permission-create.json +38 -0
- package/dist/examples/threebody-service-allocators.json +49 -0
- package/dist/examples/travel-guard-time-lock.json +69 -0
- package/dist/examples/travel-guard-weather-oracle.json +70 -0
- package/dist/examples/travel-machine-create.json +136 -0
- package/dist/examples/travel-repository-create.json +47 -0
- package/dist/examples/travel-service-create.json +102 -0
- package/dist/examples/travel-treasury-create.json +34 -0
- package/dist/examples/treasury-deposit.json +37 -0
- package/dist/examples/treasury-withdraw.json +38 -0
- package/dist/extensions/business-modules.d.ts +49 -0
- package/dist/extensions/business-modules.js +287 -0
- package/dist/extensions/capability-manifest.js +192 -5
- package/dist/extensions/constraint-registry.js +3 -1
- package/dist/extensions/modes.js +10 -4
- package/dist/extensions/registry.d.ts +14 -9
- package/dist/extensions/registry.js +69 -14
- package/dist/extensions/types.d.ts +1 -0
- package/dist/knowledge/fund-layer.d.ts +67 -1
- package/dist/knowledge/fund-layer.js +561 -12
- package/dist/knowledge/guard-templates.d.ts +10 -0
- package/dist/knowledge/guard-templates.js +50 -0
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +2 -2
- package/dist/knowledge/machine-risk.js +4 -1
- package/dist/knowledge/progress-context.js +1 -1
- package/dist/knowledge/progress-ledger.js +3 -3
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/safety-rules.d.ts +83 -1
- package/dist/knowledge/safety-rules.js +166 -2
- package/dist/knowledge/scenario-modes.d.ts +1 -1
- package/dist/knowledge/scenario-modes.js +13 -11
- package/dist/knowledge/template-registry.d.ts +48 -0
- package/dist/knowledge/template-registry.js +341 -0
- package/dist/knowledge/tool-constraints.js +6 -6
- package/dist/knowledge/tools-reference.js +11 -8
- package/dist/participation/merchant-interest.d.ts +32 -0
- package/dist/participation/merchant-interest.js +100 -0
- package/dist/participation/radar-core.d.ts +104 -0
- package/dist/participation/radar-core.js +269 -0
- package/dist/project/context-assembly.js +8 -0
- package/dist/project/edit-planner.js +27 -56
- package/dist/project/evaluation.d.ts +36 -0
- package/dist/project/evaluation.js +422 -56
- package/dist/project/game-theory.d.ts +43 -0
- package/dist/project/game-theory.js +177 -0
- package/dist/project/graph-builder.js +1 -0
- package/dist/project/handlers.d.ts +38 -0
- package/dist/project/handlers.js +65 -35
- package/dist/project/intent-analyzer.d.ts +71 -0
- package/dist/project/intent-analyzer.js +149 -0
- package/dist/project/machine-nodes.d.ts +2 -0
- package/dist/project/machine-nodes.js +36 -0
- package/dist/project/merchant-guide.d.ts +165 -0
- package/dist/project/merchant-guide.js +264 -0
- package/dist/project/mode-actions.d.ts +199 -0
- package/dist/project/mode-actions.js +309 -0
- package/dist/project/participation-radar.d.ts +18 -0
- package/dist/project/participation-radar.js +428 -0
- package/dist/project/pipeline-actions.d.ts +101 -0
- package/dist/project/pipeline-actions.js +109 -0
- package/dist/project/semantic-graph.d.ts +95 -0
- package/dist/project/semantic-graph.js +245 -0
- package/dist/schema/call/allocation.d.ts +11 -11
- package/dist/schema/call/allocation.js +11 -1
- package/dist/schema/call/arbitration.d.ts +21 -21
- package/dist/schema/call/arbitration.js +17 -9
- package/dist/schema/call/base.d.ts +2 -2
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +127 -127
- package/dist/schema/call/bridge.js +12 -12
- package/dist/schema/call/contact.d.ts +3 -3
- package/dist/schema/call/demand.d.ts +3 -3
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +216 -21
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +7 -7
- package/dist/schema/call/payment.d.ts +3 -3
- package/dist/schema/call/permission.d.ts +3 -3
- package/dist/schema/call/personal.d.ts +337 -3
- package/dist/schema/call/personal.js +10 -0
- package/dist/schema/call/progress.d.ts +177 -9
- package/dist/schema/call/progress.js +7 -3
- package/dist/schema/call/proof.d.ts +6 -6
- package/dist/schema/call/repository.d.ts +3 -3
- package/dist/schema/call/reward.d.ts +57 -57
- package/dist/schema/call/semantic.js +41 -1
- package/dist/schema/call/service.d.ts +114 -114
- package/dist/schema/call/service.js +11 -2
- package/dist/schema/call/treasury.d.ts +57 -57
- package/dist/schema/messenger/index.js +4 -1
- package/dist/schema/operations.d.ts +713 -291
- package/dist/schema/operations.js +33 -0
- package/dist/schema/project/index.d.ts +4635 -100
- package/dist/schema/project/index.js +868 -1
- package/dist/schema/query/index.d.ts +363 -19
- package/dist/schema/query/index.js +25 -3
- package/dist/schema/schema-query/index.d.ts +13 -7
- package/dist/schema/schema-query/index.js +29 -5
- package/dist/schema/trust/index.d.ts +1012 -6
- package/dist/schema/trust/index.js +212 -11
- package/dist/schema/utils/skills-recommendation.js +1 -0
- package/dist/schema-query/index.d.ts +4 -1
- package/dist/schema-query/index.js +255 -1
- package/dist/schemas/bridge_operation.schema.json +14 -7
- package/dist/schemas/guard2file.schema.json +2 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +2 -0
- package/dist/schemas/messenger_operation.schema.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +143 -15
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +7 -5
- package/dist/schemas/onchain_operations_contact.schema.json +1 -0
- package/dist/schemas/onchain_operations_demand.schema.json +1 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -0
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
- package/dist/schemas/onchain_operations_guard.schema.json +578 -0
- package/dist/schemas/onchain_operations_machine.schema.json +1 -0
- package/dist/schemas/onchain_operations_order.schema.json +4 -3
- package/dist/schemas/onchain_operations_payment.schema.json +1 -0
- package/dist/schemas/onchain_operations_permission.schema.json +1 -0
- package/dist/schemas/onchain_operations_personal.schema.json +37 -0
- package/dist/schemas/onchain_operations_progress.schema.json +90 -3
- package/dist/schemas/onchain_operations_proof.schema.json +1 -0
- package/dist/schemas/onchain_operations_repository.schema.json +1 -0
- package/dist/schemas/onchain_operations_reward.schema.json +1 -0
- package/dist/schemas/onchain_operations_service.schema.json +4 -3
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -0
- package/dist/schemas/project_operation.output.json +2243 -1
- package/dist/schemas/project_operation.schema.json +683 -1
- package/dist/schemas/query_toolkit.output.json +1 -1
- package/dist/schemas/query_toolkit.schema.json +37 -0
- package/dist/schemas/schema_query.output.json +1 -1
- package/dist/schemas/schema_query.schema.json +30 -5
- package/dist/schemas/trust_score.output.json +392 -1
- package/dist/schemas/trust_score.schema.json +275 -1
- package/dist/tools/handlers/onchain.js +73 -8
- package/dist/tools/handlers/project.js +46 -0
- package/dist/tools/handlers/query.js +117 -2
- package/dist/tools/handlers/schema-query.js +41 -0
- package/dist/tools/handlers/trust.js +192 -6
- package/dist/tools/index.js +52 -9
- package/dist/tools/wrap.js +194 -15
- package/package.json +2 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { type BusinessIntent, type DeliverableDefinition, type PaymentIntent, type TrustIntent } from "./intent-analyzer.js";
|
|
2
|
+
import { type BusinessModuleId } from "../extensions/business-modules.js";
|
|
3
|
+
export interface GuideState {
|
|
4
|
+
intent_text: string;
|
|
5
|
+
confirmed_industry?: string;
|
|
6
|
+
currency?: string;
|
|
7
|
+
deliverables?: DeliverableDefinition[];
|
|
8
|
+
payment_override?: Partial<PaymentIntent>;
|
|
9
|
+
trust_override?: Partial<TrustIntent>;
|
|
10
|
+
adopted_module_ids?: BusinessModuleId[];
|
|
11
|
+
}
|
|
12
|
+
export interface MerchantGuideInput {
|
|
13
|
+
intent?: string;
|
|
14
|
+
guide_state?: {
|
|
15
|
+
intent_text: string;
|
|
16
|
+
confirmed_industry?: string;
|
|
17
|
+
currency?: string;
|
|
18
|
+
deliverables?: unknown[];
|
|
19
|
+
payment_override?: Record<string, unknown>;
|
|
20
|
+
trust_override?: Record<string, unknown>;
|
|
21
|
+
adopted_module_ids?: string[];
|
|
22
|
+
};
|
|
23
|
+
guide_confirm?: {
|
|
24
|
+
industry?: string;
|
|
25
|
+
currency?: string;
|
|
26
|
+
deliverables?: unknown[];
|
|
27
|
+
payment?: Record<string, unknown>;
|
|
28
|
+
trust?: Record<string, unknown>;
|
|
29
|
+
adopted_module_ids?: string[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface CreationPlanEntry {
|
|
33
|
+
order: number;
|
|
34
|
+
node_id: string;
|
|
35
|
+
object_type: string;
|
|
36
|
+
suggested_name: string;
|
|
37
|
+
depends_on: string[];
|
|
38
|
+
operation_hint: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function handleMerchantGuide(v: MerchantGuideInput): Promise<{
|
|
41
|
+
action: "merchant_guide";
|
|
42
|
+
current_step: number;
|
|
43
|
+
step_name: string;
|
|
44
|
+
guide_state: GuideState;
|
|
45
|
+
intent_draft: BusinessIntent;
|
|
46
|
+
industry_options: {
|
|
47
|
+
inferred: string;
|
|
48
|
+
confidence: number;
|
|
49
|
+
similar: string[];
|
|
50
|
+
};
|
|
51
|
+
warnings: string[];
|
|
52
|
+
next_action: string;
|
|
53
|
+
intent?: undefined;
|
|
54
|
+
adopted_modules?: undefined;
|
|
55
|
+
blueprint?: undefined;
|
|
56
|
+
evaluation_preview?: undefined;
|
|
57
|
+
graph_validation?: undefined;
|
|
58
|
+
harness_check?: undefined;
|
|
59
|
+
game_theory?: undefined;
|
|
60
|
+
creation_plan?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
action: "merchant_guide";
|
|
63
|
+
current_step: number;
|
|
64
|
+
step_name: string;
|
|
65
|
+
guide_state: {
|
|
66
|
+
adopted_module_ids: BusinessModuleId[];
|
|
67
|
+
intent_text: string;
|
|
68
|
+
confirmed_industry?: string;
|
|
69
|
+
currency?: string;
|
|
70
|
+
deliverables?: DeliverableDefinition[];
|
|
71
|
+
payment_override?: Partial<PaymentIntent>;
|
|
72
|
+
trust_override?: Partial<TrustIntent>;
|
|
73
|
+
};
|
|
74
|
+
intent: {
|
|
75
|
+
intent_type: import("./intent-analyzer.js").BusinessIntentType;
|
|
76
|
+
industry: string | undefined;
|
|
77
|
+
roles: {
|
|
78
|
+
merchant: import("./intent-analyzer.js").RoleDefinition;
|
|
79
|
+
customer: import("./intent-analyzer.js").RoleDefinition;
|
|
80
|
+
suppliers?: import("./intent-analyzer.js").RoleDefinition[];
|
|
81
|
+
arbitrators?: import("./intent-analyzer.js").RoleDefinition;
|
|
82
|
+
};
|
|
83
|
+
deliverables: DeliverableDefinition[];
|
|
84
|
+
payment: PaymentIntent;
|
|
85
|
+
trust: TrustIntent;
|
|
86
|
+
};
|
|
87
|
+
adopted_modules: {
|
|
88
|
+
id: BusinessModuleId;
|
|
89
|
+
name: string;
|
|
90
|
+
description: string;
|
|
91
|
+
requires_keeper: boolean;
|
|
92
|
+
keeper_hint: string | undefined;
|
|
93
|
+
user_protections: string[];
|
|
94
|
+
merchant_obligations: string[];
|
|
95
|
+
}[];
|
|
96
|
+
blueprint: {
|
|
97
|
+
nodes: {
|
|
98
|
+
id: string;
|
|
99
|
+
type: import("./namespace.js").ProjectObjectType;
|
|
100
|
+
purpose: string;
|
|
101
|
+
}[];
|
|
102
|
+
edges: {
|
|
103
|
+
from: string;
|
|
104
|
+
to: string;
|
|
105
|
+
relation: string;
|
|
106
|
+
required: boolean;
|
|
107
|
+
}[];
|
|
108
|
+
};
|
|
109
|
+
evaluation_preview: import("./semantic-graph.js").EvaluationPreview | undefined;
|
|
110
|
+
graph_validation: {
|
|
111
|
+
valid: boolean;
|
|
112
|
+
hard_violations: {
|
|
113
|
+
id: string;
|
|
114
|
+
description: string;
|
|
115
|
+
fix: string;
|
|
116
|
+
}[];
|
|
117
|
+
soft_notes: {
|
|
118
|
+
id: string;
|
|
119
|
+
description: string;
|
|
120
|
+
}[];
|
|
121
|
+
};
|
|
122
|
+
harness_check: {
|
|
123
|
+
module_constraints: {
|
|
124
|
+
module: BusinessModuleId;
|
|
125
|
+
plan_satisfied: boolean;
|
|
126
|
+
missing: string[] | undefined;
|
|
127
|
+
reason: string | undefined;
|
|
128
|
+
estimated_score_boost: number;
|
|
129
|
+
}[];
|
|
130
|
+
blocking_issues: {
|
|
131
|
+
module: BusinessModuleId;
|
|
132
|
+
missing_constraints: string[] | undefined;
|
|
133
|
+
fix: string | undefined;
|
|
134
|
+
}[];
|
|
135
|
+
deploy_time_checks: string[];
|
|
136
|
+
};
|
|
137
|
+
game_theory: {
|
|
138
|
+
summary: string;
|
|
139
|
+
coverage: string;
|
|
140
|
+
exposed_scenarios: import("./game-theory.js").GameScenario[];
|
|
141
|
+
wow_alignments: string[];
|
|
142
|
+
scenarios: {
|
|
143
|
+
scenario: import("./game-theory.js").GameScenario;
|
|
144
|
+
covered: boolean;
|
|
145
|
+
conflict: string;
|
|
146
|
+
user_protection: string;
|
|
147
|
+
evaluation_metric: string;
|
|
148
|
+
recommendation: string | undefined;
|
|
149
|
+
}[];
|
|
150
|
+
};
|
|
151
|
+
creation_plan: CreationPlanEntry[];
|
|
152
|
+
warnings: string[];
|
|
153
|
+
next_action: string;
|
|
154
|
+
intent_draft?: undefined;
|
|
155
|
+
industry_options?: undefined;
|
|
156
|
+
}>;
|
|
157
|
+
export declare function listBusinessModules(): {
|
|
158
|
+
id: BusinessModuleId;
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
industry_fit: Record<string, number>;
|
|
162
|
+
addresses_pain_points: string[];
|
|
163
|
+
requires_keeper: boolean;
|
|
164
|
+
}[];
|
|
165
|
+
export {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { analyzeIntent } from "./intent-analyzer.js";
|
|
2
|
+
import { buildSemanticGraph, validateGraph } from "./semantic-graph.js";
|
|
3
|
+
import { checkGameTheoryConstraints } from "./game-theory.js";
|
|
4
|
+
import { CORE_BUSINESS_MODULES, getBusinessModule, recommendModules, checkModuleConstraints, } from "../extensions/business-modules.js";
|
|
5
|
+
function derivePlanSatisfiedConstraints(graph, intent) {
|
|
6
|
+
const satisfied = new Set();
|
|
7
|
+
const hasEdge = (rel) => graph.edges.some((e) => e.relation === rel);
|
|
8
|
+
const hasNode = (id) => graph.nodes.some((n) => n.id === id);
|
|
9
|
+
const hasNodeType = (t) => graph.nodes.some((n) => n.type === t);
|
|
10
|
+
const moduleAdopted = (id) => graph.adoptedModules.includes(id);
|
|
11
|
+
if (hasEdge("has_order_allocators"))
|
|
12
|
+
satisfied.add("order_allocators_bound");
|
|
13
|
+
if (hasEdge("uses_machine"))
|
|
14
|
+
satisfied.add("machine_bound_before_publish");
|
|
15
|
+
if (hasEdge("has_arbitration"))
|
|
16
|
+
satisfied.add("arbitration_bound_to_service");
|
|
17
|
+
if (hasNode("main_machine"))
|
|
18
|
+
satisfied.add("machine_published");
|
|
19
|
+
if (hasNode("main_repository"))
|
|
20
|
+
satisfied.add("repository_published");
|
|
21
|
+
if (hasNode("main_service"))
|
|
22
|
+
satisfied.add("service_published");
|
|
23
|
+
if (hasNode("arb_permission") && hasNode("main_permission")) {
|
|
24
|
+
satisfied.add("arbitration_permission_independent");
|
|
25
|
+
}
|
|
26
|
+
if (moduleAdopted("independent_arbitration") && hasNode("guard_independent_arbitration")) {
|
|
27
|
+
satisfied.add("voting_guard_configured");
|
|
28
|
+
}
|
|
29
|
+
if (moduleAdopted("accept_timeout_protection")) {
|
|
30
|
+
satisfied.add("time_guard_configured");
|
|
31
|
+
satisfied.add("adminUnhold_permission");
|
|
32
|
+
}
|
|
33
|
+
if (moduleAdopted("milestone_escrow") && hasNodeType("guard")) {
|
|
34
|
+
satisfied.add("milestone_forward_guarded");
|
|
35
|
+
}
|
|
36
|
+
if (hasNode("main_allocation") && intent.payment.allocation && intent.payment.allocation.length > 0) {
|
|
37
|
+
satisfied.add("allocators_configured");
|
|
38
|
+
const sum = intent.payment.allocation.reduce((a, p) => a + p.percentage, 0);
|
|
39
|
+
if (Math.abs(sum - 100) < 0.001)
|
|
40
|
+
satisfied.add("sharing_sum_100");
|
|
41
|
+
const platform = intent.payment.allocation.find((p) => p.recipient === "platform");
|
|
42
|
+
if (platform && platform.percentage === 0)
|
|
43
|
+
satisfied.add("platform_fee_zero");
|
|
44
|
+
if (moduleAdopted("supplier_collaboration")) {
|
|
45
|
+
satisfied.add("allocation_sharing_configured");
|
|
46
|
+
satisfied.add("demand_configured");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (moduleAdopted("wip_provenance") && hasNode("main_repository")) {
|
|
50
|
+
satisfied.add("wip_hash_before_delivery");
|
|
51
|
+
}
|
|
52
|
+
if (moduleAdopted("subscription_with_proof") && hasNode("main_repository")) {
|
|
53
|
+
satisfied.add("delivery_guard_per_cycle");
|
|
54
|
+
satisfied.add("repository_updated");
|
|
55
|
+
}
|
|
56
|
+
if (moduleAdopted("damage_attestation")) {
|
|
57
|
+
satisfied.add("pre_rental_hash");
|
|
58
|
+
satisfied.add("post_rental_hash");
|
|
59
|
+
}
|
|
60
|
+
if (moduleAdopted("refund_guarantee")) {
|
|
61
|
+
satisfied.add("compensation_fund_positive");
|
|
62
|
+
satisfied.add("refund_guard_configured");
|
|
63
|
+
}
|
|
64
|
+
return satisfied;
|
|
65
|
+
}
|
|
66
|
+
function deriveDeployTimeChecks(graph) {
|
|
67
|
+
const checks = [];
|
|
68
|
+
if (graph.nodes.some((n) => n.id === "main_machine")) {
|
|
69
|
+
checks.push("Machine published AND bound to Service BEFORE Service.publish (machine is immutable after publish)");
|
|
70
|
+
}
|
|
71
|
+
if (graph.edges.some((e) => e.relation === "has_order_allocators")) {
|
|
72
|
+
checks.push("Service.order_allocators bound (verify via query_objects after publish — order_allocators is FROZEN at publish)");
|
|
73
|
+
}
|
|
74
|
+
if (graph.nodes.some((n) => n.id === "main_arbitration")) {
|
|
75
|
+
checks.push("Arbitration.permission != Service.permission on-chain (E_ARBITRATION_PERMISSION_CONFLICT=33)");
|
|
76
|
+
}
|
|
77
|
+
if (graph.nodes.some((n) => n.id === "main_repository")) {
|
|
78
|
+
checks.push("Repository published and Guard write validation configured");
|
|
79
|
+
}
|
|
80
|
+
checks.push("Run project_operation action='verify_deployment' after materialization to confirm on-chain state matches this plan");
|
|
81
|
+
return checks;
|
|
82
|
+
}
|
|
83
|
+
function buildCreationPlan(graph) {
|
|
84
|
+
const entries = [];
|
|
85
|
+
const nodeById = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
86
|
+
const deps = new Map();
|
|
87
|
+
for (const n of graph.nodes)
|
|
88
|
+
deps.set(n.id, new Set());
|
|
89
|
+
for (const e of graph.edges) {
|
|
90
|
+
if (e.required && deps.has(e.from) && nodeById.has(e.to)) {
|
|
91
|
+
deps.get(e.from).add(e.to);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const ordered = [];
|
|
95
|
+
const remaining = new Map(deps);
|
|
96
|
+
while (remaining.size > 0) {
|
|
97
|
+
const ready = [...remaining.entries()].filter(([, d]) => d.size === 0).map(([id]) => id);
|
|
98
|
+
if (ready.length === 0) {
|
|
99
|
+
ordered.push(...remaining.keys());
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
ready.sort();
|
|
103
|
+
for (const id of ready) {
|
|
104
|
+
ordered.push(id);
|
|
105
|
+
remaining.delete(id);
|
|
106
|
+
for (const d of remaining.values())
|
|
107
|
+
d.delete(id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
ordered.forEach((id, i) => {
|
|
111
|
+
const node = nodeById.get(id);
|
|
112
|
+
const nameCfg = node.config["name"];
|
|
113
|
+
entries.push({
|
|
114
|
+
order: i + 1,
|
|
115
|
+
node_id: id,
|
|
116
|
+
object_type: node.type,
|
|
117
|
+
suggested_name: nameCfg?.type === "string" ? nameCfg.value : id,
|
|
118
|
+
depends_on: [...(deps.get(id) ?? [])],
|
|
119
|
+
operation_hint: `Create ${node.type} via onchain_operations, then configure. Purpose: ${node.purpose}`,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return entries;
|
|
123
|
+
}
|
|
124
|
+
export async function handleMerchantGuide(v) {
|
|
125
|
+
const prior = v.guide_state ?? { intent_text: "" };
|
|
126
|
+
const confirm = v.guide_confirm ?? {};
|
|
127
|
+
const state = {
|
|
128
|
+
intent_text: (v.intent ?? prior.intent_text ?? "").trim(),
|
|
129
|
+
confirmed_industry: confirm.industry ?? prior.confirmed_industry,
|
|
130
|
+
currency: confirm.currency ?? prior.currency,
|
|
131
|
+
deliverables: (confirm.deliverables ?? prior.deliverables),
|
|
132
|
+
payment_override: (confirm.payment ?? prior.payment_override),
|
|
133
|
+
trust_override: (confirm.trust ?? prior.trust_override),
|
|
134
|
+
adopted_module_ids: (confirm.adopted_module_ids ?? prior.adopted_module_ids),
|
|
135
|
+
};
|
|
136
|
+
for (const k of Object.keys(state)) {
|
|
137
|
+
if (state[k] === undefined)
|
|
138
|
+
delete state[k];
|
|
139
|
+
}
|
|
140
|
+
if (!state.intent_text) {
|
|
141
|
+
throw new Error("merchant_guide requires 'intent' (business description) for Step 1. " +
|
|
142
|
+
"Example: intent='I want to offer online design service with milestone payments'. " +
|
|
143
|
+
"Pass the returned guide_state back UNCHANGED on subsequent calls, plus guide_confirm for merchant decisions.");
|
|
144
|
+
}
|
|
145
|
+
const analysis = await analyzeIntent(state.intent_text, {
|
|
146
|
+
preferredIndustry: state.confirmed_industry,
|
|
147
|
+
currency: state.currency,
|
|
148
|
+
});
|
|
149
|
+
if (!state.confirmed_industry) {
|
|
150
|
+
return {
|
|
151
|
+
action: "merchant_guide",
|
|
152
|
+
current_step: 2,
|
|
153
|
+
step_name: "Industry Matching",
|
|
154
|
+
guide_state: state,
|
|
155
|
+
intent_draft: analysis.intent,
|
|
156
|
+
industry_options: {
|
|
157
|
+
inferred: analysis.inferredIndustry,
|
|
158
|
+
confidence: analysis.industryConfidence,
|
|
159
|
+
similar: analysis.similarIndustries,
|
|
160
|
+
},
|
|
161
|
+
warnings: analysis.warnings,
|
|
162
|
+
next_action: "Confirm the industry by calling merchant_guide again with guide_state (UNCHANGED) " +
|
|
163
|
+
`plus guide_confirm={ industry: '<one of: ${analysis.similarIndustries.join(", ")} — or any other industry id>' }`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const intent = {
|
|
167
|
+
...analysis.intent,
|
|
168
|
+
industry: state.confirmed_industry,
|
|
169
|
+
deliverables: state.deliverables ?? analysis.intent.deliverables,
|
|
170
|
+
payment: { ...analysis.intent.payment, ...(state.payment_override ?? {}) },
|
|
171
|
+
trust: { ...analysis.intent.trust, ...(state.trust_override ?? {}) },
|
|
172
|
+
};
|
|
173
|
+
const adoptedModules = state.adopted_module_ids
|
|
174
|
+
? state.adopted_module_ids.map((id) => getBusinessModule(id)).filter((m) => !!m)
|
|
175
|
+
: recommendModules(state.confirmed_industry, state.intent_text, { maxModules: 5 });
|
|
176
|
+
const graph = buildSemanticGraph(intent, adoptedModules);
|
|
177
|
+
const validation = validateGraph(graph);
|
|
178
|
+
const satisfied = derivePlanSatisfiedConstraints(graph, intent);
|
|
179
|
+
const moduleChecks = adoptedModules.map((m) => checkModuleConstraints(m, satisfied));
|
|
180
|
+
const deployTimeChecks = deriveDeployTimeChecks(graph);
|
|
181
|
+
const blockingMissing = moduleChecks.filter((c) => !c.adopted);
|
|
182
|
+
const gameTheory = checkGameTheoryConstraints(graph, intent);
|
|
183
|
+
const creationPlan = buildCreationPlan(graph);
|
|
184
|
+
return {
|
|
185
|
+
action: "merchant_guide",
|
|
186
|
+
current_step: blockingMissing.length > 0 ? 9 : 10,
|
|
187
|
+
step_name: blockingMissing.length > 0 ? "Harness Check (issues found)" : "Submission Plan Ready",
|
|
188
|
+
guide_state: { ...state, adopted_module_ids: adoptedModules.map((m) => m.id) },
|
|
189
|
+
intent: {
|
|
190
|
+
intent_type: intent.intent,
|
|
191
|
+
industry: intent.industry,
|
|
192
|
+
roles: intent.roles,
|
|
193
|
+
deliverables: intent.deliverables,
|
|
194
|
+
payment: intent.payment,
|
|
195
|
+
trust: intent.trust,
|
|
196
|
+
},
|
|
197
|
+
adopted_modules: adoptedModules.map((m) => ({
|
|
198
|
+
id: m.id,
|
|
199
|
+
name: m.name,
|
|
200
|
+
description: m.description,
|
|
201
|
+
requires_keeper: m.requiresKeeper,
|
|
202
|
+
keeper_hint: m.keeperHint,
|
|
203
|
+
user_protections: m.userProtections,
|
|
204
|
+
merchant_obligations: m.merchantObligations,
|
|
205
|
+
})),
|
|
206
|
+
blueprint: {
|
|
207
|
+
nodes: graph.nodes.map((n) => ({ id: n.id, type: n.type, purpose: n.purpose })),
|
|
208
|
+
edges: graph.edges.map((e) => ({ from: e.from, to: e.to, relation: e.relation, required: e.required })),
|
|
209
|
+
},
|
|
210
|
+
evaluation_preview: graph.evaluationPreview,
|
|
211
|
+
graph_validation: {
|
|
212
|
+
valid: validation.valid,
|
|
213
|
+
hard_violations: validation.hardViolations.map((c) => ({ id: c.id, description: c.description, fix: c.fixSuggestion })),
|
|
214
|
+
soft_notes: validation.softViolations.map((c) => ({ id: c.id, description: c.description })),
|
|
215
|
+
},
|
|
216
|
+
harness_check: {
|
|
217
|
+
module_constraints: moduleChecks.map((c) => ({
|
|
218
|
+
module: c.module,
|
|
219
|
+
plan_satisfied: c.adopted,
|
|
220
|
+
missing: c.missingConstraints,
|
|
221
|
+
reason: c.reason,
|
|
222
|
+
estimated_score_boost: c.estimatedScoreBoost,
|
|
223
|
+
})),
|
|
224
|
+
blocking_issues: blockingMissing.map((c) => ({
|
|
225
|
+
module: c.module,
|
|
226
|
+
missing_constraints: c.missingConstraints,
|
|
227
|
+
fix: c.reason,
|
|
228
|
+
})),
|
|
229
|
+
deploy_time_checks: deployTimeChecks,
|
|
230
|
+
},
|
|
231
|
+
game_theory: {
|
|
232
|
+
summary: gameTheory.summary,
|
|
233
|
+
coverage: `${gameTheory.coveredCount}/${gameTheory.totalCount}`,
|
|
234
|
+
exposed_scenarios: gameTheory.exposedScenarios,
|
|
235
|
+
wow_alignments: gameTheory.wowAlignments,
|
|
236
|
+
scenarios: gameTheory.results.map((r) => ({
|
|
237
|
+
scenario: r.scenario,
|
|
238
|
+
covered: r.covered,
|
|
239
|
+
conflict: r.conflict,
|
|
240
|
+
user_protection: r.userProtection,
|
|
241
|
+
evaluation_metric: r.evaluationMetric,
|
|
242
|
+
recommendation: r.recommendation,
|
|
243
|
+
})),
|
|
244
|
+
},
|
|
245
|
+
creation_plan: creationPlan,
|
|
246
|
+
warnings: analysis.warnings,
|
|
247
|
+
next_action: blockingMissing.length > 0
|
|
248
|
+
? "Resolve the blocking_issues above (adjust guide_confirm payment/trust/modules, or accept and drop the affected module via guide_confirm.adopted_module_ids), then call merchant_guide again."
|
|
249
|
+
: "Plan ready. Materialize: 1) create_project with project_industry='" + state.confirmed_industry + "' " +
|
|
250
|
+
"2) create objects in creation_plan order via onchain_operations " +
|
|
251
|
+
"3) add_object each on-chain address into the project " +
|
|
252
|
+
"4) build_graph + evaluate_project 5) verify_deployment.",
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export function listBusinessModules() {
|
|
256
|
+
return CORE_BUSINESS_MODULES.map((m) => ({
|
|
257
|
+
id: m.id,
|
|
258
|
+
name: m.name,
|
|
259
|
+
description: m.description,
|
|
260
|
+
industry_fit: m.industryFit,
|
|
261
|
+
addresses_pain_points: m.addressesPainPoints,
|
|
262
|
+
requires_keeper: m.requiresKeeper,
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { type MetricType, type MetricScale, type ConstraintRule, type ConstraintSeverity, type ConstraintViolationAction } from "../extensions/index.js";
|
|
2
|
+
export interface RecommendIndustryInput {
|
|
3
|
+
intent?: string;
|
|
4
|
+
project_description?: string;
|
|
5
|
+
project_name?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function handleRecommendIndustry(v: RecommendIndustryInput): {
|
|
8
|
+
action: "recommend_industry";
|
|
9
|
+
intent: string;
|
|
10
|
+
inferred_traits: import("../knowledge/industry-registry.js").IndustryTraits;
|
|
11
|
+
inference_confidence: number;
|
|
12
|
+
matched_keywords: string[];
|
|
13
|
+
recommendations: {
|
|
14
|
+
industry: string;
|
|
15
|
+
similarity: number;
|
|
16
|
+
matched_traits: string[];
|
|
17
|
+
reference_examples: {
|
|
18
|
+
file: string;
|
|
19
|
+
title: string;
|
|
20
|
+
operation_type: string;
|
|
21
|
+
verified: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
}[];
|
|
24
|
+
hint: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function handleListModes(): Promise<{
|
|
27
|
+
action: "list_modes";
|
|
28
|
+
builtin_modes: {
|
|
29
|
+
name: string;
|
|
30
|
+
display_name: string;
|
|
31
|
+
version: string;
|
|
32
|
+
key_risk: string;
|
|
33
|
+
machine_nodes: string[];
|
|
34
|
+
similar_industries: string[];
|
|
35
|
+
}[];
|
|
36
|
+
user_modes: {
|
|
37
|
+
name: string;
|
|
38
|
+
display_name: string;
|
|
39
|
+
version: string;
|
|
40
|
+
derived_from: string | null;
|
|
41
|
+
key_risk: string;
|
|
42
|
+
machine_nodes: string[];
|
|
43
|
+
evolution_history: {
|
|
44
|
+
version: string;
|
|
45
|
+
changed_at: number;
|
|
46
|
+
changes: string[];
|
|
47
|
+
}[];
|
|
48
|
+
}[];
|
|
49
|
+
owner: string;
|
|
50
|
+
hint: string;
|
|
51
|
+
}>;
|
|
52
|
+
export interface DeriveUserModeInput {
|
|
53
|
+
mode_source?: string;
|
|
54
|
+
mode_name?: string;
|
|
55
|
+
mode_display_name?: string;
|
|
56
|
+
mode_changes?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
export declare function handleDeriveUserMode(v: DeriveUserModeInput): Promise<{
|
|
59
|
+
action: "derive_user_mode";
|
|
60
|
+
mode: {
|
|
61
|
+
name: string;
|
|
62
|
+
display_name: string;
|
|
63
|
+
version: string;
|
|
64
|
+
derived_from: string | null;
|
|
65
|
+
owner: string;
|
|
66
|
+
key_risk: string;
|
|
67
|
+
machine_nodes: string[];
|
|
68
|
+
evolution_history: {
|
|
69
|
+
version: string;
|
|
70
|
+
changed_at: number;
|
|
71
|
+
changes: string[];
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
74
|
+
hint: string;
|
|
75
|
+
}>;
|
|
76
|
+
export interface EvolveUserModeInput {
|
|
77
|
+
mode_name?: string;
|
|
78
|
+
mode_changes?: Record<string, unknown>;
|
|
79
|
+
mode_change_description?: string;
|
|
80
|
+
mode_bump_version?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export declare function handleEvolveUserMode(v: EvolveUserModeInput): Promise<{
|
|
83
|
+
action: "evolve_user_mode";
|
|
84
|
+
mode: {
|
|
85
|
+
name: string;
|
|
86
|
+
display_name: string;
|
|
87
|
+
version: string;
|
|
88
|
+
derived_from: string | null;
|
|
89
|
+
owner: string;
|
|
90
|
+
key_risk: string;
|
|
91
|
+
machine_nodes: string[];
|
|
92
|
+
evolution_history: {
|
|
93
|
+
version: string;
|
|
94
|
+
changed_at: number;
|
|
95
|
+
changes: string[];
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
hint: string;
|
|
99
|
+
}>;
|
|
100
|
+
export interface RegisterUserModeInput {
|
|
101
|
+
mode_name?: string;
|
|
102
|
+
mode_display_name?: string;
|
|
103
|
+
mode_changes?: Record<string, unknown>;
|
|
104
|
+
}
|
|
105
|
+
export declare function handleRegisterUserMode(v: RegisterUserModeInput): Promise<{
|
|
106
|
+
action: "register_user_mode";
|
|
107
|
+
mode: {
|
|
108
|
+
name: string;
|
|
109
|
+
display_name: string;
|
|
110
|
+
version: string;
|
|
111
|
+
derived_from: string | null;
|
|
112
|
+
owner: string;
|
|
113
|
+
key_risk: string;
|
|
114
|
+
machine_nodes: string[];
|
|
115
|
+
evolution_history: {
|
|
116
|
+
version: string;
|
|
117
|
+
changed_at: number;
|
|
118
|
+
changes: string[];
|
|
119
|
+
}[];
|
|
120
|
+
};
|
|
121
|
+
hint: string;
|
|
122
|
+
}>;
|
|
123
|
+
export declare function handleUnregisterUserMode(v: {
|
|
124
|
+
mode_name?: string;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
action: "unregister_user_mode";
|
|
127
|
+
removed: true;
|
|
128
|
+
mode_name: string;
|
|
129
|
+
}>;
|
|
130
|
+
export interface RegisterCustomMetricInput {
|
|
131
|
+
metric_id?: string;
|
|
132
|
+
metric_display_name?: string;
|
|
133
|
+
metric_description?: string;
|
|
134
|
+
metric_type?: MetricType;
|
|
135
|
+
metric_scale?: MetricScale;
|
|
136
|
+
metric_weight?: number;
|
|
137
|
+
}
|
|
138
|
+
export declare function handleRegisterCustomMetric(v: RegisterCustomMetricInput): {
|
|
139
|
+
action: "register_custom_metric";
|
|
140
|
+
metric: {
|
|
141
|
+
metric_id: string;
|
|
142
|
+
display_name: string;
|
|
143
|
+
description: string;
|
|
144
|
+
type: "risk" | "benefit";
|
|
145
|
+
scale: "level" | "numeric" | "percentage";
|
|
146
|
+
weight: number;
|
|
147
|
+
scope: string;
|
|
148
|
+
owner: string;
|
|
149
|
+
};
|
|
150
|
+
hint: string;
|
|
151
|
+
};
|
|
152
|
+
export interface RegisterCustomConstraintInput {
|
|
153
|
+
constraint_id?: string;
|
|
154
|
+
constraint_display_name?: string;
|
|
155
|
+
constraint_description?: string;
|
|
156
|
+
constraint_rule?: ConstraintRule;
|
|
157
|
+
constraint_severity?: ConstraintSeverity;
|
|
158
|
+
constraint_on_violation?: ConstraintViolationAction;
|
|
159
|
+
}
|
|
160
|
+
export declare function handleRegisterCustomConstraint(v: RegisterCustomConstraintInput): {
|
|
161
|
+
action: "register_custom_constraint";
|
|
162
|
+
constraint: {
|
|
163
|
+
constraint_id: string;
|
|
164
|
+
display_name: string;
|
|
165
|
+
description: string;
|
|
166
|
+
rule: ConstraintRule;
|
|
167
|
+
severity: ConstraintSeverity;
|
|
168
|
+
on_violation: ConstraintViolationAction;
|
|
169
|
+
scope: string;
|
|
170
|
+
owner: string;
|
|
171
|
+
};
|
|
172
|
+
hint: string;
|
|
173
|
+
};
|
|
174
|
+
export interface ListMetricsConstraintsInput {
|
|
175
|
+
metric_type_filter?: MetricType;
|
|
176
|
+
scope_filter?: "builtin" | "custom";
|
|
177
|
+
}
|
|
178
|
+
export declare function handleListMetricsConstraints(v: ListMetricsConstraintsInput): {
|
|
179
|
+
action: "list_metrics_constraints";
|
|
180
|
+
metrics: {
|
|
181
|
+
metric_id: string;
|
|
182
|
+
display_name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
type: MetricType;
|
|
185
|
+
scale: MetricScale;
|
|
186
|
+
weight: number | undefined;
|
|
187
|
+
scope: "custom" | "builtin";
|
|
188
|
+
}[];
|
|
189
|
+
constraints: {
|
|
190
|
+
constraint_id: string;
|
|
191
|
+
display_name: string;
|
|
192
|
+
description: string;
|
|
193
|
+
rule: ConstraintRule;
|
|
194
|
+
severity: ConstraintSeverity;
|
|
195
|
+
on_violation: ConstraintViolationAction;
|
|
196
|
+
scope: "custom" | "builtin";
|
|
197
|
+
}[];
|
|
198
|
+
hint: string;
|
|
199
|
+
};
|