@wowok/agent-mcp 2.4.3 → 2.5.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/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1412 -6
- package/dist/schema/project/index.js +441 -3
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1809 -336
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +578 -579
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +0 -514
- package/dist/schemas/onchain_operations_permission.schema.json +0 -514
- package/dist/schemas/onchain_operations_personal.schema.json +0 -514
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +918 -0
- package/dist/schemas/project_operation.schema.json +474 -3
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +262 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +96 -25
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ProjectObjectType, IndustryMode } from "./namespace.js";
|
|
2
|
+
export interface BusinessPuzzleInput {
|
|
3
|
+
user_intent: string;
|
|
4
|
+
project_name?: string;
|
|
5
|
+
target_objects?: string[];
|
|
6
|
+
industry?: IndustryMode | string;
|
|
7
|
+
}
|
|
8
|
+
export interface DetectedScene {
|
|
9
|
+
object: ProjectObjectType;
|
|
10
|
+
scene_id: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IntentParsed {
|
|
13
|
+
primary_object: ProjectObjectType;
|
|
14
|
+
secondary_objects: ProjectObjectType[];
|
|
15
|
+
detected_scenes: DetectedScene[];
|
|
16
|
+
industry: IndustryMode;
|
|
17
|
+
keyword_matches: KeywordMatch[];
|
|
18
|
+
}
|
|
19
|
+
export interface ObjectPuzzleEntry {
|
|
20
|
+
puzzle: unknown;
|
|
21
|
+
completeness: unknown;
|
|
22
|
+
missing_dimensions: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface BusinessPuzzleResult {
|
|
25
|
+
intent_parsed: IntentParsed;
|
|
26
|
+
puzzles: Record<string, ObjectPuzzleEntry>;
|
|
27
|
+
overall_completeness: "complete" | "partial" | "empty";
|
|
28
|
+
next_step: string;
|
|
29
|
+
warnings: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface KeywordMatch {
|
|
32
|
+
keyword: string;
|
|
33
|
+
category: string;
|
|
34
|
+
matched_objects: ProjectObjectType[];
|
|
35
|
+
required_level: "R" | "C" | "OPTIONAL";
|
|
36
|
+
match_count: number;
|
|
37
|
+
}
|
|
38
|
+
export declare function extractKeywords(business_intent: string): KeywordMatch[];
|
|
39
|
+
export declare function resolveIndustry(intent: string, hint?: string): IndustryMode;
|
|
40
|
+
export declare function identifyObjects(intent: string, matches: KeywordMatch[]): {
|
|
41
|
+
primary: ProjectObjectType;
|
|
42
|
+
secondary: ProjectObjectType[];
|
|
43
|
+
scenes: DetectedScene[];
|
|
44
|
+
};
|
|
45
|
+
export declare function analyzeBusinessIntent(input: BusinessPuzzleInput): BusinessPuzzleResult;
|
|
46
|
+
export declare function aggregatePuzzleCompleteness(puzzles: Record<string, ObjectPuzzleEntry>): "complete" | "partial" | "empty";
|
|
47
|
+
export declare function suggestNextPuzzleStep(currentResult: BusinessPuzzleResult): string;
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { initServicePuzzleFromIntent, initMachinePuzzleFromIntent, initAllocationPuzzleFromIntent, initTreasuryPuzzleFromIntent, initArbitrationPuzzleFromIntent, initRewardPuzzleFromIntent, initProgressPuzzleFromIntent, initOrderPuzzleFromIntent, initPuzzleFromIntent as initGuardPuzzleFromIntent, checkServicePuzzleCompleteness, checkMachinePuzzleCompleteness, checkAllocationPuzzleCompleteness, checkTreasuryPuzzleCompleteness, checkArbitrationPuzzleCompleteness, checkRewardPuzzleCompleteness, checkProgressPuzzleCompleteness, checkOrderPuzzleCompleteness, checkPuzzleCompleteness as checkGuardPuzzleCompleteness, } from "../knowledge/index.js";
|
|
2
|
+
import { initPuzzleFromIntent as initPermissionPuzzleFromIntent, checkPuzzleCompleteness as checkPermissionPuzzleCompleteness, } from "../knowledge/permission-puzzle.js";
|
|
3
|
+
const KEYWORD_TABLE = [
|
|
4
|
+
{
|
|
5
|
+
category: "Product/Service",
|
|
6
|
+
keywords_zh: ["product", "selling", "sell", "sales", "store", "open shop"],
|
|
7
|
+
keywords_en: ["sell", "product", "sale", "shop", "store"],
|
|
8
|
+
objects: ["service", "order", "progress"],
|
|
9
|
+
required_level: "R",
|
|
10
|
+
scene_id: "retail",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
category: "Subscription",
|
|
14
|
+
keywords_zh: ["subscription", "cycle", "renewal"],
|
|
15
|
+
keywords_en: ["subscribe", "recurring", "subscription"],
|
|
16
|
+
objects: ["service", "machine", "reward"],
|
|
17
|
+
required_level: "C",
|
|
18
|
+
scene_id: "subscription",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
category: "Rental",
|
|
22
|
+
keywords_zh: ["rent", "lease", "return"],
|
|
23
|
+
keywords_en: ["rent", "lease", "return"],
|
|
24
|
+
objects: ["service", "machine", "arb"],
|
|
25
|
+
required_level: "C",
|
|
26
|
+
scene_id: "rental_return",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
category: "Trust",
|
|
30
|
+
keywords_zh: ["deposit", "pledge", "verify", "trust"],
|
|
31
|
+
keywords_en: ["deposit", "trust", "verify"],
|
|
32
|
+
objects: ["guard", "permission", "treasury"],
|
|
33
|
+
required_level: "R",
|
|
34
|
+
scene_id: "trust_deposit",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
category: "Funds",
|
|
38
|
+
keywords_zh: ["split", "collect", "share profit", "income", "incentive"],
|
|
39
|
+
keywords_en: ["split", "revenue", "reward"],
|
|
40
|
+
objects: ["allocation", "treasury", "reward"],
|
|
41
|
+
required_level: "R",
|
|
42
|
+
scene_id: "revenue_split",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
category: "Workflow",
|
|
46
|
+
keywords_zh: ["node", "stage", "process", "workflow"],
|
|
47
|
+
keywords_en: ["workflow", "stage", "node"],
|
|
48
|
+
objects: ["machine", "progress"],
|
|
49
|
+
required_level: "R",
|
|
50
|
+
scene_id: "workflow",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
category: "Dispute",
|
|
54
|
+
keywords_zh: ["arbitration", "refund", "conflict", "rights protection"],
|
|
55
|
+
keywords_en: ["arbitration", "refund", "dispute"],
|
|
56
|
+
objects: ["arb", "proof"],
|
|
57
|
+
required_level: "C",
|
|
58
|
+
scene_id: "arbitration_dispute",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
category: "Contact",
|
|
62
|
+
keywords_zh: ["customer service", "contact", "communication"],
|
|
63
|
+
keywords_en: ["contact", "support", "im"],
|
|
64
|
+
objects: ["contact"],
|
|
65
|
+
required_level: "C",
|
|
66
|
+
scene_id: "contact_im",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
category: "Data",
|
|
70
|
+
keywords_zh: ["evidence", "record", "data"],
|
|
71
|
+
keywords_en: ["evidence", "record", "data"],
|
|
72
|
+
objects: ["repository", "proof"],
|
|
73
|
+
required_level: "C",
|
|
74
|
+
scene_id: "evidence_record",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
category: "User Profile",
|
|
78
|
+
keywords_zh: ["personal info", "preference", "privacy"],
|
|
79
|
+
keywords_en: ["personal", "profile", "privacy"],
|
|
80
|
+
objects: ["personal", "contact"],
|
|
81
|
+
required_level: "OPTIONAL",
|
|
82
|
+
scene_id: "user_profile",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
category: "Demand Submission",
|
|
86
|
+
keywords_zh: ["demand", "publish", "inquiry"],
|
|
87
|
+
keywords_en: ["demand", "request", "inquiry"],
|
|
88
|
+
objects: ["demand"],
|
|
89
|
+
required_level: "OPTIONAL",
|
|
90
|
+
scene_id: "demand_inquiry",
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
const INDUSTRY_KEYWORDS = [
|
|
94
|
+
{ industry: "freelance", words: ["freelance", "outsourcing", "freelance", "gig"] },
|
|
95
|
+
{ industry: "rental", words: ["rental", "lease", "rental", "rent"] },
|
|
96
|
+
{ industry: "education", words: ["education", "course", "training", "education", "course"] },
|
|
97
|
+
{ industry: "travel", words: ["travel", "tour", "itinerary", "travel", "trip"] },
|
|
98
|
+
{ industry: "subscription", words: ["subscription", "cycle", "subscription", "recurring"] },
|
|
99
|
+
];
|
|
100
|
+
function buildPuzzleDispatch() {
|
|
101
|
+
const safeInit = (fn, input) => {
|
|
102
|
+
try {
|
|
103
|
+
return fn(input);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const safeCheck = (puzzle, fn) => {
|
|
110
|
+
if (!puzzle)
|
|
111
|
+
return { missing: [], complete: false, next_step: "init failed" };
|
|
112
|
+
try {
|
|
113
|
+
return fn(puzzle);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return { missing: [], complete: false, next_step: "check failed" };
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
service: {
|
|
121
|
+
init: (intent) => safeInit(initServicePuzzleFromIntent, { primary_goal: intent }),
|
|
122
|
+
check: (p) => safeCheck(p, checkServicePuzzleCompleteness),
|
|
123
|
+
},
|
|
124
|
+
machine: {
|
|
125
|
+
init: (intent) => safeInit(initMachinePuzzleFromIntent, intent),
|
|
126
|
+
check: (p) => safeCheck(p, checkMachinePuzzleCompleteness),
|
|
127
|
+
},
|
|
128
|
+
allocation: {
|
|
129
|
+
init: (intent) => safeInit(initAllocationPuzzleFromIntent, { primary_goal: intent }),
|
|
130
|
+
check: (p) => safeCheck(p, checkAllocationPuzzleCompleteness),
|
|
131
|
+
},
|
|
132
|
+
treasury: {
|
|
133
|
+
init: (intent) => safeInit(initTreasuryPuzzleFromIntent, { primary_goal: intent }),
|
|
134
|
+
check: (p) => safeCheck(p, checkTreasuryPuzzleCompleteness),
|
|
135
|
+
},
|
|
136
|
+
arb: {
|
|
137
|
+
init: (intent) => safeInit(initArbitrationPuzzleFromIntent, { primary_goal: intent }),
|
|
138
|
+
check: (p) => safeCheck(p, checkArbitrationPuzzleCompleteness),
|
|
139
|
+
},
|
|
140
|
+
reward: {
|
|
141
|
+
init: (intent) => safeInit(initRewardPuzzleFromIntent, { primary_goal: intent }),
|
|
142
|
+
check: (p) => safeCheck(p, checkRewardPuzzleCompleteness),
|
|
143
|
+
},
|
|
144
|
+
progress: {
|
|
145
|
+
init: (intent) => safeInit(initProgressPuzzleFromIntent, { primary_goal: intent }),
|
|
146
|
+
check: (p) => safeCheck(p, checkProgressPuzzleCompleteness),
|
|
147
|
+
},
|
|
148
|
+
order: {
|
|
149
|
+
init: (intent) => safeInit(initOrderPuzzleFromIntent, { primary_goal: intent }),
|
|
150
|
+
check: (p) => safeCheck(p, checkOrderPuzzleCompleteness),
|
|
151
|
+
},
|
|
152
|
+
permission: {
|
|
153
|
+
init: (intent) => safeInit(initPermissionPuzzleFromIntent, { primary_goal: intent }),
|
|
154
|
+
check: (p) => safeCheck(p, checkPermissionPuzzleCompleteness),
|
|
155
|
+
},
|
|
156
|
+
guard: {
|
|
157
|
+
init: (intent) => safeInit(initGuardPuzzleFromIntent, { primary_goal: intent }),
|
|
158
|
+
check: (p) => safeCheck(p, checkGuardPuzzleCompleteness),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
export function extractKeywords(business_intent) {
|
|
163
|
+
if (!business_intent || typeof business_intent !== "string")
|
|
164
|
+
return [];
|
|
165
|
+
const matches = [];
|
|
166
|
+
for (const entry of KEYWORD_TABLE) {
|
|
167
|
+
const allKeywords = [...entry.keywords_zh, ...entry.keywords_en];
|
|
168
|
+
for (const keyword of allKeywords) {
|
|
169
|
+
try {
|
|
170
|
+
const regex = new RegExp(escapeRegex(keyword), "gi");
|
|
171
|
+
const count = (business_intent.match(regex) || []).length;
|
|
172
|
+
if (count > 0) {
|
|
173
|
+
matches.push({
|
|
174
|
+
keyword,
|
|
175
|
+
category: entry.category,
|
|
176
|
+
matched_objects: [...entry.objects],
|
|
177
|
+
required_level: entry.required_level,
|
|
178
|
+
match_count: count,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
matches.sort((a, b) => b.match_count - a.match_count);
|
|
187
|
+
return matches;
|
|
188
|
+
}
|
|
189
|
+
function escapeRegex(s) {
|
|
190
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
191
|
+
}
|
|
192
|
+
export function resolveIndustry(intent, hint) {
|
|
193
|
+
const text = `${intent ?? ""} ${hint ?? ""}`.toLowerCase();
|
|
194
|
+
for (const entry of INDUSTRY_KEYWORDS) {
|
|
195
|
+
for (const w of entry.words) {
|
|
196
|
+
if (text.includes(w.toLowerCase()))
|
|
197
|
+
return entry.industry;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return "general";
|
|
201
|
+
}
|
|
202
|
+
export function identifyObjects(intent, matches) {
|
|
203
|
+
if (matches.length === 0) {
|
|
204
|
+
return {
|
|
205
|
+
primary: "service",
|
|
206
|
+
secondary: ["permission", "machine", "progress"],
|
|
207
|
+
scenes: [{ object: "service", scene_id: "general" }],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const firstR = matches.find((m) => m.required_level === "R");
|
|
211
|
+
const primary = (firstR ?? matches[0]).matched_objects[0];
|
|
212
|
+
const seen = new Set([primary]);
|
|
213
|
+
const secondary = [];
|
|
214
|
+
for (const m of matches) {
|
|
215
|
+
for (const obj of m.matched_objects) {
|
|
216
|
+
if (!seen.has(obj)) {
|
|
217
|
+
seen.add(obj);
|
|
218
|
+
secondary.push(obj);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const scenes = [];
|
|
223
|
+
const sceneSeen = new Set();
|
|
224
|
+
for (const entry of KEYWORD_TABLE) {
|
|
225
|
+
const matched = matches.find((m) => m.category === entry.category);
|
|
226
|
+
if (!matched)
|
|
227
|
+
continue;
|
|
228
|
+
if (sceneSeen.has(entry.scene_id))
|
|
229
|
+
continue;
|
|
230
|
+
sceneSeen.add(entry.scene_id);
|
|
231
|
+
scenes.push({ object: entry.objects[0], scene_id: entry.scene_id });
|
|
232
|
+
}
|
|
233
|
+
return { primary, secondary, scenes };
|
|
234
|
+
}
|
|
235
|
+
export function analyzeBusinessIntent(input) {
|
|
236
|
+
const warnings = [];
|
|
237
|
+
if (!input || !input.user_intent || typeof input.user_intent !== "string") {
|
|
238
|
+
return {
|
|
239
|
+
intent_parsed: {
|
|
240
|
+
primary_object: "service",
|
|
241
|
+
secondary_objects: [],
|
|
242
|
+
detected_scenes: [],
|
|
243
|
+
industry: "general",
|
|
244
|
+
keyword_matches: [],
|
|
245
|
+
},
|
|
246
|
+
puzzles: {},
|
|
247
|
+
overall_completeness: "empty",
|
|
248
|
+
next_step: "Please provide a non-empty business intent.",
|
|
249
|
+
warnings: ["input.user_intent is empty"],
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const intent = input.user_intent;
|
|
253
|
+
const matches = extractKeywords(intent);
|
|
254
|
+
const industry = resolveIndustry(intent, input.industry);
|
|
255
|
+
const { primary, secondary, scenes } = identifyObjects(intent, matches);
|
|
256
|
+
let targetObjects = [primary, ...secondary];
|
|
257
|
+
if (input.target_objects && input.target_objects.length > 0) {
|
|
258
|
+
const explicit = input.target_objects.filter((t) => [
|
|
259
|
+
"service", "machine", "guard", "permission", "reward", "arb",
|
|
260
|
+
"progress", "treasury", "demand", "repository", "contact", "order",
|
|
261
|
+
"allocation", "personal", "payment", "proof",
|
|
262
|
+
].includes(t));
|
|
263
|
+
if (explicit.length > 0)
|
|
264
|
+
targetObjects = explicit;
|
|
265
|
+
}
|
|
266
|
+
const dispatch = buildPuzzleDispatch();
|
|
267
|
+
const puzzles = {};
|
|
268
|
+
for (const objType of targetObjects) {
|
|
269
|
+
const d = dispatch[objType];
|
|
270
|
+
if (!d) {
|
|
271
|
+
warnings.push(`No puzzle module for '${objType}' — skipped (L3 object)`);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const puzzle = d.init(intent);
|
|
275
|
+
const completeness = puzzle ? d.check(puzzle) : undefined;
|
|
276
|
+
const missingDimensions = extractMissingDimensions(completeness);
|
|
277
|
+
puzzles[objType] = {
|
|
278
|
+
puzzle,
|
|
279
|
+
completeness,
|
|
280
|
+
missing_dimensions: missingDimensions,
|
|
281
|
+
};
|
|
282
|
+
if (!puzzle) {
|
|
283
|
+
warnings.push(`Puzzle init failed for '${objType}'`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const overall = aggregatePuzzleCompleteness(puzzles);
|
|
287
|
+
const nextStep = suggestNextPuzzleStep({
|
|
288
|
+
intent_parsed: {
|
|
289
|
+
primary_object: primary,
|
|
290
|
+
secondary_objects: secondary,
|
|
291
|
+
detected_scenes: scenes,
|
|
292
|
+
industry,
|
|
293
|
+
keyword_matches: matches,
|
|
294
|
+
},
|
|
295
|
+
puzzles,
|
|
296
|
+
overall_completeness: overall,
|
|
297
|
+
next_step: "",
|
|
298
|
+
warnings,
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
intent_parsed: {
|
|
302
|
+
primary_object: primary,
|
|
303
|
+
secondary_objects: secondary,
|
|
304
|
+
detected_scenes: scenes,
|
|
305
|
+
industry,
|
|
306
|
+
keyword_matches: matches,
|
|
307
|
+
},
|
|
308
|
+
puzzles,
|
|
309
|
+
overall_completeness: overall,
|
|
310
|
+
next_step: nextStep,
|
|
311
|
+
warnings,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function extractMissingDimensions(completeness) {
|
|
315
|
+
if (!completeness || typeof completeness !== "object")
|
|
316
|
+
return [];
|
|
317
|
+
const c = completeness;
|
|
318
|
+
const missing = c.missing;
|
|
319
|
+
if (Array.isArray(missing)) {
|
|
320
|
+
return missing.map((m) => String(m));
|
|
321
|
+
}
|
|
322
|
+
const missingDetails = c.missing_details;
|
|
323
|
+
if (Array.isArray(missingDetails)) {
|
|
324
|
+
return missingDetails.map((m) => String(m?.dimension ?? m));
|
|
325
|
+
}
|
|
326
|
+
return [];
|
|
327
|
+
}
|
|
328
|
+
export function aggregatePuzzleCompleteness(puzzles) {
|
|
329
|
+
const entries = Object.values(puzzles ?? {});
|
|
330
|
+
if (entries.length === 0)
|
|
331
|
+
return "empty";
|
|
332
|
+
const emptyCount = entries.filter((e) => !e.puzzle).length;
|
|
333
|
+
if (emptyCount === entries.length)
|
|
334
|
+
return "empty";
|
|
335
|
+
const missingCount = entries.reduce((sum, e) => sum + (e.missing_dimensions?.length ?? 0), 0);
|
|
336
|
+
if (missingCount === 0)
|
|
337
|
+
return "complete";
|
|
338
|
+
return "partial";
|
|
339
|
+
}
|
|
340
|
+
export function suggestNextPuzzleStep(currentResult) {
|
|
341
|
+
if (!currentResult)
|
|
342
|
+
return "No result to suggest from.";
|
|
343
|
+
if (currentResult.overall_completeness === "complete") {
|
|
344
|
+
return "All puzzle dimensions are complete — ready for risk calibration (stage 3).";
|
|
345
|
+
}
|
|
346
|
+
if (currentResult.overall_completeness === "empty") {
|
|
347
|
+
return "No puzzle has been initialized. Provide more concrete business intent so the primary object can be identified.";
|
|
348
|
+
}
|
|
349
|
+
const order = [
|
|
350
|
+
"permission", "treasury", "allocation", "guard", "machine",
|
|
351
|
+
"service", "order", "progress", "arb", "reward",
|
|
352
|
+
"proof", "repository", "demand", "contact",
|
|
353
|
+
"personal", "payment",
|
|
354
|
+
];
|
|
355
|
+
const puzzles = currentResult.puzzles ?? {};
|
|
356
|
+
const ordered = order.filter((o) => puzzles[o]);
|
|
357
|
+
for (const objType of ordered) {
|
|
358
|
+
const entry = puzzles[objType];
|
|
359
|
+
if (!entry)
|
|
360
|
+
continue;
|
|
361
|
+
const missing = entry.missing_dimensions ?? [];
|
|
362
|
+
if (missing.length === 0)
|
|
363
|
+
continue;
|
|
364
|
+
const c = entry.completeness;
|
|
365
|
+
const innerNext = c && typeof c === "object" ? c.next_step : undefined;
|
|
366
|
+
if (typeof innerNext === "string" && innerNext.trim()) {
|
|
367
|
+
return `[${objType}] ${innerNext}`;
|
|
368
|
+
}
|
|
369
|
+
return `[${objType}] Complete dimension${missing.length > 1 ? "s" : ""} ${missing.join(", ")} to advance the puzzle.`;
|
|
370
|
+
}
|
|
371
|
+
return "Continue dialog to fill remaining pending fields.";
|
|
372
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ProjectObjectType, IndustryMode } from "./namespace.js";
|
|
2
|
+
import type { EdgeKind } from "./graph.js";
|
|
3
|
+
export interface DeploymentObject {
|
|
4
|
+
entry_id: string;
|
|
5
|
+
object_type: ProjectObjectType;
|
|
6
|
+
name: string;
|
|
7
|
+
reused_from?: string;
|
|
8
|
+
publish_required: boolean;
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DeploymentDagEdge {
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
edge_kind: EdgeKind | string;
|
|
15
|
+
field_path: string;
|
|
16
|
+
required_at_publish: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface DeploymentScenario {
|
|
19
|
+
scenario_id: string;
|
|
20
|
+
description: string;
|
|
21
|
+
primary_object: string;
|
|
22
|
+
supporting_objects: string[];
|
|
23
|
+
test_step_refs?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface DeploymentStep {
|
|
26
|
+
step: number;
|
|
27
|
+
object_type: ProjectObjectType;
|
|
28
|
+
operation: string;
|
|
29
|
+
substep_count: number;
|
|
30
|
+
depends_on: number[];
|
|
31
|
+
entry_id: string;
|
|
32
|
+
network_phase: "testnet" | "mainnet" | "both";
|
|
33
|
+
}
|
|
34
|
+
export interface DeploymentDocInput {
|
|
35
|
+
project_prefix: string;
|
|
36
|
+
business_intent: string;
|
|
37
|
+
industry: IndustryMode | string;
|
|
38
|
+
version: string;
|
|
39
|
+
author?: string;
|
|
40
|
+
scenario_mode?: string;
|
|
41
|
+
objects: DeploymentObject[];
|
|
42
|
+
edges: DeploymentDagEdge[];
|
|
43
|
+
steps: DeploymentStep[];
|
|
44
|
+
scenarios?: DeploymentScenario[];
|
|
45
|
+
risk_status?: "RISK_PASSED" | "RISK_BLOCKED" | "RISK_PENDING_CONFIRM" | "RISK_CANCELLED";
|
|
46
|
+
risk_critical_count?: number;
|
|
47
|
+
risk_high_count?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface DeploymentDocValidationResult {
|
|
50
|
+
valid: boolean;
|
|
51
|
+
checks: Array<{
|
|
52
|
+
check_id: string;
|
|
53
|
+
description: string;
|
|
54
|
+
status: "PASS" | "FAIL" | "WARN";
|
|
55
|
+
notes?: string;
|
|
56
|
+
}>;
|
|
57
|
+
errors: string[];
|
|
58
|
+
}
|
|
59
|
+
export declare function generateDeploymentDoc(input: DeploymentDocInput): string;
|
|
60
|
+
export declare function validateDeploymentDoc(input: DeploymentDocInput): DeploymentDocValidationResult;
|
|
61
|
+
export declare function getStandardTopoOrder(): ProjectObjectType[];
|