@wowok/agent-mcp 2.6.1 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/customer/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 +9 -2
- package/dist/customer/info-puzzle.js +34 -7
- 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 +30 -7
- package/dist/customer/types.d.ts +7 -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 +59 -0
- package/dist/examples/guard-template-time-lock.json +60 -0
- 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 +119 -0
- package/dist/examples/payment-scenario-bound.json +45 -0
- package/dist/examples/rental-ziroom-machine-create.json +149 -0
- package/dist/examples/rental-ziroom-permission-create.json +42 -0
- package/dist/examples/rental-ziroom-service-create.json +89 -0
- 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/retail-myshop-service-create.json +88 -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 +216 -29
- package/dist/extensions/constraint-registry.js +21 -19
- package/dist/extensions/metric-registry.js +14 -14
- package/dist/extensions/mode-evaluator.js +16 -16
- package/dist/extensions/modes.js +141 -49
- package/dist/extensions/registry.d.ts +16 -9
- package/dist/extensions/registry.js +132 -44
- package/dist/extensions/types.d.ts +2 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +138 -0
- package/dist/knowledge/fund-layer.js +969 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/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-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-risk.js +4 -1
- package/dist/knowledge/machine-templates.js +4 -4
- 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/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- package/dist/knowledge/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/service-confirm.d.ts +1 -1
- package/dist/knowledge/service-confirm.js +3 -3
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- package/dist/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/deployment-bridge.js +6 -5
- package/dist/project/deployment-doc.js +5 -5
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1342 -0
- package/dist/project/evaluation.d.ts +36 -0
- package/dist/project/evaluation.js +734 -68
- package/dist/project/game-theory.d.ts +43 -0
- package/dist/project/game-theory.js +177 -0
- package/dist/project/graph-builder.js +7 -1
- package/dist/project/handlers.d.ts +137 -2
- package/dist/project/handlers.js +423 -51
- 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/project/stage-gate.js +4 -4
- package/dist/schema/call/allocation.d.ts +11 -11
- package/dist/schema/call/allocation.js +13 -3
- package/dist/schema/call/arbitration.d.ts +21 -21
- package/dist/schema/call/arbitration.js +30 -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/contact.js +2 -2
- package/dist/schema/call/demand.d.ts +3 -3
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/guard.js +2 -2
- package/dist/schema/call/machine.d.ts +2072 -679
- package/dist/schema/call/machine.js +51 -5
- package/dist/schema/call/order.d.ts +7 -7
- package/dist/schema/call/order.js +3 -6
- package/dist/schema/call/payment.d.ts +3 -3
- package/dist/schema/call/permission.d.ts +3 -3
- package/dist/schema/call/permission.js +2 -2
- 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/repository.js +2 -2
- package/dist/schema/call/reward.d.ts +57 -57
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.js +48 -2
- package/dist/schema/call/service.d.ts +285 -113
- package/dist/schema/call/service.js +92 -28
- package/dist/schema/call/treasury.d.ts +57 -57
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +2 -0
- package/dist/schema/common/index.js +46 -10
- package/dist/schema/local/index.js +5 -1
- package/dist/schema/messenger/index.js +4 -1
- package/dist/schema/operations.d.ts +1318 -317
- package/dist/schema/operations.js +76 -7
- package/dist/schema/project/index.d.ts +5662 -164
- package/dist/schema/project/index.js +1136 -5
- package/dist/schema/query/index.d.ts +580 -19
- package/dist/schema/query/index.js +88 -36
- package/dist/schema/schema-query/index.d.ts +59 -3
- package/dist/schema/schema-query/index.js +45 -6
- package/dist/schema/trust/index.d.ts +1012 -6
- package/dist/schema/trust/index.js +212 -11
- package/dist/schema/utils/node-parser.js +13 -0
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +77 -0
- package/dist/schema-query/index.d.ts +17 -1
- package/dist/schema-query/index.js +359 -3
- package/dist/schemas/account_operation.schema.json +1 -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_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +255 -65
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
- package/dist/schemas/onchain_operations_contact.schema.json +4 -3
- package/dist/schemas/onchain_operations_demand.schema.json +4 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
- package/dist/schemas/onchain_operations_guard.schema.json +579 -1
- package/dist/schemas/onchain_operations_machine.schema.json +5 -4
- package/dist/schemas/onchain_operations_order.schema.json +7 -6
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +3 -2
- package/dist/schemas/onchain_operations_personal.schema.json +37 -0
- package/dist/schemas/onchain_operations_progress.schema.json +91 -4
- package/dist/schemas/onchain_operations_proof.schema.json +2 -1
- package/dist/schemas/onchain_operations_repository.schema.json +4 -3
- package/dist/schemas/onchain_operations_reward.schema.json +7 -6
- package/dist/schemas/onchain_operations_service.schema.json +80 -19
- package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
- package/dist/schemas/onchain_table_data.output.json +1 -1
- package/dist/schemas/onchain_table_data.schema.json +10 -9
- package/dist/schemas/project_operation.output.json +3318 -57
- package/dist/schemas/project_operation.schema.json +728 -4
- package/dist/schemas/query_toolkit.output.json +16 -16
- package/dist/schemas/query_toolkit.schema.json +40 -3
- package/dist/schemas/schema_query.output.json +65 -2
- package/dist/schemas/schema_query.schema.json +31 -5
- package/dist/schemas/trust_score.output.json +392 -1
- package/dist/schemas/trust_score.schema.json +275 -1
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/onchain.js +636 -6
- package/dist/tools/handlers/project.js +71 -2
- package/dist/tools/handlers/query.js +117 -2
- package/dist/tools/handlers/schema-query.js +65 -1
- package/dist/tools/handlers/trust.js +192 -6
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +229 -15
- package/dist/tools/wrap.js +194 -15
- package/package.json +2 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IndustryTraits } from "../knowledge/industry-registry.js";
|
|
2
|
+
export type BusinessIntentType = "sell_service" | "sell_product" | "sell_subscription" | "rent_asset" | "crowdfund" | "escrow";
|
|
3
|
+
export interface RoleDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
obligations: string[];
|
|
7
|
+
rights: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface DeliverableDefinition {
|
|
10
|
+
name: string;
|
|
11
|
+
type: "digital" | "physical" | "service_session" | "access_right";
|
|
12
|
+
acceptanceCriteria: string;
|
|
13
|
+
proofOfDelivery: "manual_confirm" | "wip_hash" | "third_party_attestation" | "auto_verify";
|
|
14
|
+
}
|
|
15
|
+
export interface PaymentTrigger {
|
|
16
|
+
event: string;
|
|
17
|
+
guardDescription: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PaymentAllocation {
|
|
20
|
+
recipient: string;
|
|
21
|
+
percentage: number;
|
|
22
|
+
}
|
|
23
|
+
export interface PaymentIntent {
|
|
24
|
+
model: "milestone" | "upfront" | "subscription" | "per_use" | "escrow";
|
|
25
|
+
currency: string;
|
|
26
|
+
triggers: PaymentTrigger[];
|
|
27
|
+
allocation?: PaymentAllocation[];
|
|
28
|
+
}
|
|
29
|
+
export interface TrustIntent {
|
|
30
|
+
refundPolicy: "no_refund" | "partial" | "full" | "milestone_prorated";
|
|
31
|
+
arbitration: "none" | "merchant_pick" | "mutual_pick" | "third_party";
|
|
32
|
+
escrow: boolean;
|
|
33
|
+
transparency: "minimal" | "standard" | "full";
|
|
34
|
+
}
|
|
35
|
+
export interface TimelineMilestone {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
duration: string;
|
|
39
|
+
}
|
|
40
|
+
export interface TimelineIntent {
|
|
41
|
+
totalDuration?: string;
|
|
42
|
+
milestones?: TimelineMilestone[];
|
|
43
|
+
}
|
|
44
|
+
export interface BusinessIntent {
|
|
45
|
+
intent: BusinessIntentType;
|
|
46
|
+
industry?: string;
|
|
47
|
+
description: string;
|
|
48
|
+
roles: {
|
|
49
|
+
merchant: RoleDefinition;
|
|
50
|
+
customer: RoleDefinition;
|
|
51
|
+
suppliers?: RoleDefinition[];
|
|
52
|
+
arbitrators?: RoleDefinition;
|
|
53
|
+
};
|
|
54
|
+
deliverables: DeliverableDefinition[];
|
|
55
|
+
payment: PaymentIntent;
|
|
56
|
+
trust: TrustIntent;
|
|
57
|
+
timeline?: TimelineIntent;
|
|
58
|
+
}
|
|
59
|
+
export interface IntentAnalysisResult {
|
|
60
|
+
intent: BusinessIntent;
|
|
61
|
+
inferredIndustry: string;
|
|
62
|
+
industryConfidence: number;
|
|
63
|
+
similarIndustries: string[];
|
|
64
|
+
inferredTraits: IndustryTraits;
|
|
65
|
+
recommendedModules: string[];
|
|
66
|
+
warnings: string[];
|
|
67
|
+
}
|
|
68
|
+
export declare function analyzeIntent(description: string, options?: {
|
|
69
|
+
preferredIndustry?: string;
|
|
70
|
+
currency?: string;
|
|
71
|
+
}): Promise<IntentAnalysisResult>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { findSimilarIndustries, inferTraitsFromDescription } from "../knowledge/industry-generalizer.js";
|
|
2
|
+
const INTENT_KEYWORDS = {
|
|
3
|
+
sell_service: ["design", "develop", "consult", "freelance", "service", "build", "create", "write", "translate"],
|
|
4
|
+
sell_product: ["sell", "product", "item", "goods", "merchandise", "store", "shop"],
|
|
5
|
+
sell_subscription: ["subscribe", "subscription", "membership", "monthly", "recurring", "creator", "patron"],
|
|
6
|
+
rent_asset: ["rent", "rental", "lease", "borrow", "car", "house", "apartment", "equipment"],
|
|
7
|
+
crowdfund: ["crowdfund", "fund", "raise", "campaign", "donation", "backer"],
|
|
8
|
+
escrow: ["escrow", "hold", "mediate", "intermediary", "safe", "secure transaction"],
|
|
9
|
+
};
|
|
10
|
+
function classifyIntentType(description) {
|
|
11
|
+
const lower = description.toLowerCase();
|
|
12
|
+
let bestType = "sell_service";
|
|
13
|
+
let bestScore = 0;
|
|
14
|
+
for (const [type, keywords] of Object.entries(INTENT_KEYWORDS)) {
|
|
15
|
+
const score = keywords.filter((k) => lower.includes(k)).length;
|
|
16
|
+
if (score > bestScore) {
|
|
17
|
+
bestScore = score;
|
|
18
|
+
bestType = type;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return bestType;
|
|
22
|
+
}
|
|
23
|
+
function inferPaymentModel(description) {
|
|
24
|
+
const lower = description.toLowerCase();
|
|
25
|
+
if (lower.includes("milestone") || lower.includes("phase") || lower.includes("stage"))
|
|
26
|
+
return "milestone";
|
|
27
|
+
if (lower.includes("subscription") || lower.includes("monthly") || lower.includes("recurring"))
|
|
28
|
+
return "subscription";
|
|
29
|
+
if (lower.includes("per use") || lower.includes("hourly") || lower.includes("per session"))
|
|
30
|
+
return "per_use";
|
|
31
|
+
if (lower.includes("escrow") || lower.includes("hold"))
|
|
32
|
+
return "escrow";
|
|
33
|
+
return "upfront";
|
|
34
|
+
}
|
|
35
|
+
function inferRefundPolicy(description) {
|
|
36
|
+
const lower = description.toLowerCase();
|
|
37
|
+
if (lower.includes("no refund") || lower.includes("non-refundable"))
|
|
38
|
+
return "no_refund";
|
|
39
|
+
if (lower.includes("milestone") && lower.includes("refund"))
|
|
40
|
+
return "milestone_prorated";
|
|
41
|
+
if (lower.includes("full refund"))
|
|
42
|
+
return "full";
|
|
43
|
+
return "partial";
|
|
44
|
+
}
|
|
45
|
+
function inferArbitration(description) {
|
|
46
|
+
const lower = description.toLowerCase();
|
|
47
|
+
if (lower.includes("no arbitration") || lower.includes("no dispute"))
|
|
48
|
+
return "none";
|
|
49
|
+
if (lower.includes("third party") || lower.includes("independent"))
|
|
50
|
+
return "third_party";
|
|
51
|
+
if (lower.includes("mutual"))
|
|
52
|
+
return "mutual_pick";
|
|
53
|
+
return "merchant_pick";
|
|
54
|
+
}
|
|
55
|
+
export async function analyzeIntent(description, options) {
|
|
56
|
+
const warnings = [];
|
|
57
|
+
const intentType = classifyIntentType(description);
|
|
58
|
+
const traitInference = inferTraitsFromDescription(description);
|
|
59
|
+
const similarMatches = findSimilarIndustries(traitInference.traits, 3);
|
|
60
|
+
const similarIndustries = similarMatches.map((m) => m.industry);
|
|
61
|
+
const inferredIndustry = options?.preferredIndustry ?? similarIndustries[0] ?? "general";
|
|
62
|
+
const industryConfidence = similarIndustries.includes(inferredIndustry) ? 0.85 : 0.5;
|
|
63
|
+
const inferredTraits = traitInference.traits;
|
|
64
|
+
const intent = {
|
|
65
|
+
intent: intentType,
|
|
66
|
+
industry: inferredIndustry,
|
|
67
|
+
description,
|
|
68
|
+
roles: {
|
|
69
|
+
merchant: {
|
|
70
|
+
name: "merchant",
|
|
71
|
+
description: "Service provider or seller",
|
|
72
|
+
obligations: ["Deliver as described", "Maintain compensation_fund if required", "Accept arbitration verdicts"],
|
|
73
|
+
rights: ["Receive payment upon verified delivery", "Set service terms before publish"],
|
|
74
|
+
},
|
|
75
|
+
customer: {
|
|
76
|
+
name: "customer",
|
|
77
|
+
description: "Buyer or service recipient",
|
|
78
|
+
obligations: ["Pay according to agreed schedule", "Provide acceptance/rejection within timeout"],
|
|
79
|
+
rights: ["Receive deliverables as described", "Request refund if delivery fails", "Initiate arbitration for disputes"],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
deliverables: [
|
|
83
|
+
{
|
|
84
|
+
name: "main_deliverable",
|
|
85
|
+
type: inferDeliverableType(description),
|
|
86
|
+
acceptanceCriteria: "To be defined by merchant during configuration",
|
|
87
|
+
proofOfDelivery: "wip_hash",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
payment: {
|
|
91
|
+
model: inferPaymentModel(description),
|
|
92
|
+
currency: options?.currency ?? "WOW",
|
|
93
|
+
triggers: [
|
|
94
|
+
{
|
|
95
|
+
event: inferPaymentModel(description) === "milestone" ? "milestone completion" : "service confirmation",
|
|
96
|
+
guardDescription: "Guard verifies deliverable meets acceptance criteria",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
allocation: [
|
|
100
|
+
{ recipient: "merchant", percentage: 90 },
|
|
101
|
+
{ recipient: "platform", percentage: 0 },
|
|
102
|
+
{ recipient: "arbitration_reserve", percentage: 10 },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
trust: {
|
|
106
|
+
refundPolicy: inferRefundPolicy(description),
|
|
107
|
+
arbitration: inferArbitration(description),
|
|
108
|
+
escrow: true,
|
|
109
|
+
transparency: "full",
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
if (intent.payment.model === "milestone" && !description.toLowerCase().includes("milestone")) {
|
|
113
|
+
warnings.push("Payment model inferred as 'milestone' but not explicitly mentioned. Please verify.");
|
|
114
|
+
}
|
|
115
|
+
if (intent.trust.arbitration === "none") {
|
|
116
|
+
warnings.push("No arbitration configured. This increases risk for both parties. Consider adding independent_arbitration module.");
|
|
117
|
+
}
|
|
118
|
+
if (intent.payment.allocation && intent.payment.allocation.some((a) => a.recipient === "platform" && a.percentage > 0)) {
|
|
119
|
+
warnings.push("Platform fee > 0 detected. WOW philosophy recommends 0% platform fee for peer-to-peer transactions.");
|
|
120
|
+
}
|
|
121
|
+
let recommendedModules = [];
|
|
122
|
+
try {
|
|
123
|
+
const { recommendModules } = await import("../extensions/business-modules.js");
|
|
124
|
+
const modules = recommendModules(inferredIndustry, description, { maxModules: 5 });
|
|
125
|
+
recommendedModules = modules.map((m) => m.id);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
recommendedModules = ["milestone_escrow", "independent_arbitration", "wip_provenance"];
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
intent,
|
|
132
|
+
inferredIndustry,
|
|
133
|
+
industryConfidence,
|
|
134
|
+
similarIndustries,
|
|
135
|
+
inferredTraits,
|
|
136
|
+
recommendedModules,
|
|
137
|
+
warnings,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function inferDeliverableType(description) {
|
|
141
|
+
const lower = description.toLowerCase();
|
|
142
|
+
if (lower.includes("design") || lower.includes("code") || lower.includes("write") || lower.includes("digital"))
|
|
143
|
+
return "digital";
|
|
144
|
+
if (lower.includes("class") || lower.includes("lesson") || lower.includes("session"))
|
|
145
|
+
return "service_session";
|
|
146
|
+
if (lower.includes("rent") || lower.includes("access"))
|
|
147
|
+
return "access_right";
|
|
148
|
+
return "physical";
|
|
149
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { query_objects, query_table } from "@wowok/wowok";
|
|
2
|
+
const BATCH = 50;
|
|
3
|
+
export async function fetchMachineNodes(machineAddress, network) {
|
|
4
|
+
const allFieldObjectIds = [];
|
|
5
|
+
let cursor = undefined;
|
|
6
|
+
for (;;) {
|
|
7
|
+
const tableResult = await query_table({
|
|
8
|
+
parent: machineAddress,
|
|
9
|
+
cursor: cursor ?? undefined,
|
|
10
|
+
network,
|
|
11
|
+
});
|
|
12
|
+
if (!tableResult?.items || tableResult.items.length === 0)
|
|
13
|
+
break;
|
|
14
|
+
for (const item of tableResult.items) {
|
|
15
|
+
if (item.object)
|
|
16
|
+
allFieldObjectIds.push(item.object);
|
|
17
|
+
}
|
|
18
|
+
if (!tableResult.hasNextPage || !tableResult.nextCursor)
|
|
19
|
+
break;
|
|
20
|
+
cursor = tableResult.nextCursor;
|
|
21
|
+
}
|
|
22
|
+
const rawNodes = [];
|
|
23
|
+
for (let i = 0; i < allFieldObjectIds.length; i += BATCH) {
|
|
24
|
+
const batch = allFieldObjectIds.slice(i, i + BATCH);
|
|
25
|
+
const nodeQueryResult = await query_objects({
|
|
26
|
+
objects: batch,
|
|
27
|
+
network,
|
|
28
|
+
});
|
|
29
|
+
for (const obj of nodeQueryResult?.objects ?? []) {
|
|
30
|
+
if (obj.type === "TableItem_MachineNode") {
|
|
31
|
+
rawNodes.push(obj);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return rawNodes;
|
|
36
|
+
}
|
|
@@ -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
|
+
}
|