@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
|
@@ -1,50 +1,294 @@
|
|
|
1
1
|
import { queryProjects, queryProjectObjects, queryShareableObjects, queryDependencies, queryReferencedBy, queryPrePublishCheck, queryCrossProjectReferences, queryGraphStats, saveGraph, loadGraph, } from "../../project/index.js";
|
|
2
|
+
import { analyzeBusinessIntent } from "../../project/business-puzzle.js";
|
|
3
|
+
import { aggregateProjectRisks } from "../../project/risk-aggregator.js";
|
|
4
|
+
import { generateDeploymentDoc, validateDeploymentDoc, } from "../../project/deployment-doc.js";
|
|
5
|
+
import { traceSubsteps } from "../../project/substep-trace.js";
|
|
6
|
+
import { strictParse } from "../../schema/index.js";
|
|
7
|
+
import { ProjectOperationInputSchema } from "../../schema/project/index.js";
|
|
8
|
+
import { injectEvolutionContext } from "../../knowledge/flywheel-loop.js";
|
|
9
|
+
import { getExperienceFeedback } from "../../experience/index.js";
|
|
10
|
+
function requireProject(v) {
|
|
11
|
+
if (!v.project) {
|
|
12
|
+
throw new Error("'project' (prefix) is required for this action");
|
|
13
|
+
}
|
|
14
|
+
if (!v.version) {
|
|
15
|
+
throw new Error("'version' is required for this action (e.g. 'v1')");
|
|
16
|
+
}
|
|
17
|
+
return { prefix: v.project, version: v.version };
|
|
18
|
+
}
|
|
19
|
+
function requireUserIntent(v) {
|
|
20
|
+
if (!v.user_intent) {
|
|
21
|
+
throw new Error("'user_intent' is required for analyze_intent");
|
|
22
|
+
}
|
|
23
|
+
return v.user_intent;
|
|
24
|
+
}
|
|
25
|
+
function requirePuzzles(v) {
|
|
26
|
+
if (!v.puzzles || Object.keys(v.puzzles).length === 0) {
|
|
27
|
+
throw new Error("'puzzles' is required for this action (obtain from analyze_intent)");
|
|
28
|
+
}
|
|
29
|
+
return v.puzzles;
|
|
30
|
+
}
|
|
31
|
+
function requireDeploymentInputs(v) {
|
|
32
|
+
if (!v.business_intent) {
|
|
33
|
+
throw new Error("'business_intent' is required for generate_deployment_doc");
|
|
34
|
+
}
|
|
35
|
+
if (!v.objects || v.objects.length === 0) {
|
|
36
|
+
throw new Error("'objects' is required for generate_deployment_doc");
|
|
37
|
+
}
|
|
38
|
+
if (!v.edges) {
|
|
39
|
+
throw new Error("'edges' is required for generate_deployment_doc");
|
|
40
|
+
}
|
|
41
|
+
if (!v.steps) {
|
|
42
|
+
throw new Error("'steps' is required for generate_deployment_doc");
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
business_intent: v.business_intent,
|
|
46
|
+
objects: v.objects,
|
|
47
|
+
edges: v.edges,
|
|
48
|
+
steps: v.steps,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function requireSubsteps(v) {
|
|
52
|
+
if (!v.network) {
|
|
53
|
+
throw new Error("'network' is required for trace_substeps");
|
|
54
|
+
}
|
|
55
|
+
if (v.network !== "testnet" && v.network !== "mainnet") {
|
|
56
|
+
throw new Error("'network' must be 'testnet' or 'mainnet'");
|
|
57
|
+
}
|
|
58
|
+
if (!v.substeps || v.substeps.length === 0) {
|
|
59
|
+
throw new Error("'substeps' is required for trace_substeps");
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
network: v.network,
|
|
63
|
+
substeps: v.substeps,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function handleAnalyzeIntent(validated) {
|
|
67
|
+
const { prefix, version } = requireProject(validated);
|
|
68
|
+
const userIntent = requireUserIntent(validated);
|
|
69
|
+
const result = analyzeBusinessIntent({
|
|
70
|
+
user_intent: userIntent,
|
|
71
|
+
project_name: `${prefix}_${version}`,
|
|
72
|
+
industry: validated.industry,
|
|
73
|
+
target_objects: validated.target_objects,
|
|
74
|
+
});
|
|
75
|
+
const industry = validated.industry ?? "general";
|
|
76
|
+
let evolutionContext;
|
|
77
|
+
let experienceFeedback;
|
|
78
|
+
try {
|
|
79
|
+
evolutionContext = injectEvolutionContext(undefined, industry);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
evolutionContext = undefined;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
experienceFeedback = getExperienceFeedback("analyze_intent", { user_intent: userIntent, industry, target_objects: validated.target_objects }, `project:analyze_intent`);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
experienceFeedback = undefined;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
action: "analyze_intent",
|
|
92
|
+
intent_parsed: result.intent_parsed,
|
|
93
|
+
puzzles: result.puzzles,
|
|
94
|
+
overall_completeness: result.overall_completeness,
|
|
95
|
+
next_step: result.next_step,
|
|
96
|
+
next_action: result.overall_completeness === "complete" ? "aggregate_risks" : "none",
|
|
97
|
+
warnings: result.warnings,
|
|
98
|
+
evolution_context: evolutionContext,
|
|
99
|
+
experience_feedback: experienceFeedback,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async function handleAggregateRisks(validated) {
|
|
103
|
+
const { prefix, version } = requireProject(validated);
|
|
104
|
+
const puzzles = requirePuzzles(validated);
|
|
105
|
+
const result = aggregateProjectRisks({
|
|
106
|
+
project_prefix: prefix,
|
|
107
|
+
version: version,
|
|
108
|
+
industry: validated.industry,
|
|
109
|
+
puzzles,
|
|
110
|
+
severity_threshold: validated.severity_threshold,
|
|
111
|
+
user_confirmed_high_risks: validated.user_confirmed_high_risks,
|
|
112
|
+
});
|
|
113
|
+
const hasCritical = result.severity_summary.CRITICAL > 0;
|
|
114
|
+
const unconfirmedHigh = result.findings.filter((r) => r.severity === "HIGH").length;
|
|
115
|
+
return {
|
|
116
|
+
action: "aggregate_risks",
|
|
117
|
+
namespace: result.namespace,
|
|
118
|
+
findings: result.findings,
|
|
119
|
+
severity_summary: result.severity_summary,
|
|
120
|
+
status: result.status,
|
|
121
|
+
pending_confirmations: result.pending_confirmations,
|
|
122
|
+
calibrated_at: result.calibrated_at,
|
|
123
|
+
warnings: result.warnings,
|
|
124
|
+
can_proceed: !hasCritical,
|
|
125
|
+
next_action: hasCritical ? "fix_risks" : "generate_deployment_doc",
|
|
126
|
+
user_action_required: hasCritical
|
|
127
|
+
? `Fix ${result.severity_summary.CRITICAL} CRITICAL risk(s) before proceeding`
|
|
128
|
+
: unconfirmedHigh > 0
|
|
129
|
+
? `Review ${unconfirmedHigh} HIGH risk(s). You may proceed at your own risk.`
|
|
130
|
+
: "All risks reviewed. You may proceed.",
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async function handleGenerateDeploymentDoc(validated) {
|
|
134
|
+
const { prefix, version } = requireProject(validated);
|
|
135
|
+
const required = requireDeploymentInputs(validated);
|
|
136
|
+
const docInput = {
|
|
137
|
+
project_prefix: prefix,
|
|
138
|
+
version: version,
|
|
139
|
+
business_intent: required.business_intent,
|
|
140
|
+
industry: validated.industry ?? "general",
|
|
141
|
+
author: validated.author,
|
|
142
|
+
objects: required.objects,
|
|
143
|
+
edges: required.edges,
|
|
144
|
+
steps: required.steps,
|
|
145
|
+
scenarios: validated.scenarios,
|
|
146
|
+
risk_status: validated.risk_status,
|
|
147
|
+
risk_critical_count: validated.risk_critical_count,
|
|
148
|
+
risk_high_count: validated.risk_high_count,
|
|
149
|
+
};
|
|
150
|
+
const markdown = generateDeploymentDoc(docInput);
|
|
151
|
+
const generatedAt = new Date().toISOString();
|
|
152
|
+
const shouldRunScanner = validated.run_scanner !== false;
|
|
153
|
+
let validationResult;
|
|
154
|
+
if (shouldRunScanner) {
|
|
155
|
+
const validation = validateDeploymentDoc(docInput);
|
|
156
|
+
validationResult = {
|
|
157
|
+
valid: validation.valid,
|
|
158
|
+
checks: validation.checks,
|
|
159
|
+
errors: validation.errors,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const errorCount = validationResult
|
|
163
|
+
? validationResult.checks.filter((c) => c.status === "FAIL").length
|
|
164
|
+
: 0;
|
|
165
|
+
const warningCount = validationResult
|
|
166
|
+
? validationResult.checks.filter((c) => c.status === "WARN").length
|
|
167
|
+
: 0;
|
|
168
|
+
return {
|
|
169
|
+
action: "generate_deployment_doc",
|
|
170
|
+
markdown,
|
|
171
|
+
meta: {
|
|
172
|
+
project_prefix: prefix,
|
|
173
|
+
version: version,
|
|
174
|
+
generated_at: generatedAt,
|
|
175
|
+
object_count: required.objects.length,
|
|
176
|
+
step_count: required.steps.length,
|
|
177
|
+
},
|
|
178
|
+
validation: validationResult,
|
|
179
|
+
can_proceed: errorCount === 0,
|
|
180
|
+
next_action: errorCount === 0 ? "trace_substeps" : "fix_doc_errors",
|
|
181
|
+
user_action_required: errorCount > 0
|
|
182
|
+
? `Fix ${errorCount} D-error(s) before deploying`
|
|
183
|
+
: warningCount > 0
|
|
184
|
+
? `${warningCount} D-warning(s) found. You may proceed at your own risk.`
|
|
185
|
+
: "Deployment document ready. You may proceed to stage 5.",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async function handleTraceSubsteps(validated) {
|
|
189
|
+
const { prefix, version } = requireProject(validated);
|
|
190
|
+
const { network, substeps } = requireSubsteps(validated);
|
|
191
|
+
const result = traceSubsteps({
|
|
192
|
+
project_prefix: prefix,
|
|
193
|
+
version: version,
|
|
194
|
+
network: network,
|
|
195
|
+
substeps,
|
|
196
|
+
});
|
|
197
|
+
const hasFailedSubstep = substeps.some((s) => s.status === "FAILED");
|
|
198
|
+
const canProceed = result.coherent && !hasFailedSubstep;
|
|
199
|
+
const issueParts = [];
|
|
200
|
+
if (result.dangling_inputs.length > 0) {
|
|
201
|
+
issueParts.push(`${result.dangling_inputs.length} dangling inputs`);
|
|
202
|
+
}
|
|
203
|
+
if (result.circular_refs.length > 0) {
|
|
204
|
+
issueParts.push(`${result.circular_refs.length} circular refs`);
|
|
205
|
+
}
|
|
206
|
+
if (result.missing_outputs.length > 0) {
|
|
207
|
+
issueParts.push(`${result.missing_outputs.length} missing outputs`);
|
|
208
|
+
}
|
|
209
|
+
if (result.cross_step_breaks.length > 0) {
|
|
210
|
+
issueParts.push(`${result.cross_step_breaks.length} cross-step breaks`);
|
|
211
|
+
}
|
|
212
|
+
if (hasFailedSubstep) {
|
|
213
|
+
const failedCount = substeps.filter((s) => s.status === "FAILED").length;
|
|
214
|
+
issueParts.push(`${failedCount} failed substep(s)`);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
action: "trace_substeps",
|
|
218
|
+
namespace: result.namespace,
|
|
219
|
+
network: result.network,
|
|
220
|
+
coherent: result.coherent,
|
|
221
|
+
dangling_inputs: result.dangling_inputs,
|
|
222
|
+
circular_refs: result.circular_refs,
|
|
223
|
+
missing_outputs: result.missing_outputs,
|
|
224
|
+
cross_step_breaks: result.cross_step_breaks,
|
|
225
|
+
step_details: result.step_details,
|
|
226
|
+
topological_order: result.topological_order,
|
|
227
|
+
d10_check: result.d10_check,
|
|
228
|
+
can_proceed: canProceed,
|
|
229
|
+
next_action: canProceed ? "deploy" : "fix_substeps",
|
|
230
|
+
user_action_required: issueParts.length > 0
|
|
231
|
+
? `Fix: ${issueParts.join(", ")}`
|
|
232
|
+
: "All substeps passed. Deployment complete.",
|
|
233
|
+
};
|
|
234
|
+
}
|
|
2
235
|
export async function handleProjectOperation(args) {
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const object = args.object;
|
|
236
|
+
const validated = strictParse(ProjectOperationInputSchema, args, "project_operation input");
|
|
237
|
+
const { action } = validated;
|
|
6
238
|
let result;
|
|
7
239
|
switch (action) {
|
|
8
240
|
case "list_projects":
|
|
9
|
-
result = await queryProjects();
|
|
241
|
+
result = { action: "list_projects", items: await queryProjects() };
|
|
10
242
|
break;
|
|
11
243
|
case "list_objects":
|
|
12
|
-
if (!project)
|
|
244
|
+
if (!validated.project)
|
|
13
245
|
throw new Error("'project' param is required for list_objects");
|
|
14
|
-
result = await queryProjectObjects(project);
|
|
246
|
+
result = { action: "list_objects", items: await queryProjectObjects(validated.project) };
|
|
15
247
|
break;
|
|
16
248
|
case "shareable":
|
|
17
|
-
result = await queryShareableObjects();
|
|
249
|
+
result = { action: "shareable", items: await queryShareableObjects() };
|
|
18
250
|
break;
|
|
19
251
|
case "dependencies":
|
|
20
|
-
if (!object)
|
|
252
|
+
if (!validated.object)
|
|
21
253
|
throw new Error("'object' param is required for dependencies");
|
|
22
|
-
result = queryDependencies(object);
|
|
254
|
+
result = { action: "dependencies", items: queryDependencies(validated.object) };
|
|
23
255
|
break;
|
|
24
256
|
case "referenced_by":
|
|
25
|
-
if (!object)
|
|
257
|
+
if (!validated.object)
|
|
26
258
|
throw new Error("'object' param is required for referenced_by");
|
|
27
|
-
result = queryReferencedBy(object);
|
|
259
|
+
result = { action: "referenced_by", items: queryReferencedBy(validated.object) };
|
|
28
260
|
break;
|
|
29
261
|
case "pre_publish_check":
|
|
30
|
-
if (!object)
|
|
262
|
+
if (!validated.object)
|
|
31
263
|
throw new Error("'object' param is required for pre_publish_check");
|
|
32
|
-
result = { warnings: queryPrePublishCheck(object) };
|
|
264
|
+
result = { action: "pre_publish_check", warnings: queryPrePublishCheck(validated.object) };
|
|
33
265
|
break;
|
|
34
266
|
case "cross_project_refs":
|
|
35
|
-
result = queryCrossProjectReferences();
|
|
267
|
+
result = { action: "cross_project_refs", items: queryCrossProjectReferences() };
|
|
36
268
|
break;
|
|
37
269
|
case "graph_stats":
|
|
38
|
-
result = queryGraphStats();
|
|
270
|
+
result = { action: "graph_stats", stats: queryGraphStats() };
|
|
39
271
|
break;
|
|
40
272
|
case "save_graph":
|
|
41
|
-
result = { saved: true, path: saveGraph() };
|
|
273
|
+
result = { action: "save_graph", saved: true, path: saveGraph() };
|
|
42
274
|
break;
|
|
43
275
|
case "load_graph":
|
|
44
|
-
result = { loaded: loadGraph() };
|
|
276
|
+
result = { action: "load_graph", loaded: loadGraph() };
|
|
277
|
+
break;
|
|
278
|
+
case "analyze_intent":
|
|
279
|
+
result = await handleAnalyzeIntent(validated);
|
|
280
|
+
break;
|
|
281
|
+
case "aggregate_risks":
|
|
282
|
+
result = await handleAggregateRisks(validated);
|
|
283
|
+
break;
|
|
284
|
+
case "generate_deployment_doc":
|
|
285
|
+
result = await handleGenerateDeploymentDoc(validated);
|
|
286
|
+
break;
|
|
287
|
+
case "trace_substeps":
|
|
288
|
+
result = await handleTraceSubsteps(validated);
|
|
45
289
|
break;
|
|
46
290
|
default:
|
|
47
|
-
throw new Error(`Unknown project_operation action: ${action}`);
|
|
291
|
+
throw new Error(`Unknown project_operation action: ${String(action)}`);
|
|
48
292
|
}
|
|
49
293
|
return {
|
|
50
294
|
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolDispatchResult } from "../types.js";
|
|
2
|
-
export declare function handleWatchQueryOperations(args:
|
|
3
|
-
export declare function handleOnchainTableData(args:
|
|
4
|
-
export declare function handleOnchainEvents(args:
|
|
5
|
-
export declare function handleWowokInfo(args:
|
|
2
|
+
export declare function handleWatchQueryOperations(args: unknown): Promise<ToolDispatchResult>;
|
|
3
|
+
export declare function handleOnchainTableData(args: unknown): Promise<ToolDispatchResult>;
|
|
4
|
+
export declare function handleOnchainEvents(args: unknown): Promise<ToolDispatchResult>;
|
|
5
|
+
export declare function handleWowokInfo(args: unknown): Promise<ToolDispatchResult>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ToolDispatchResult } from "../types.js";
|
|
2
|
-
export declare function handleSchemaQuery(args:
|
|
2
|
+
export declare function handleSchemaQuery(args: unknown): Promise<ToolDispatchResult>;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { processSchemaQuery, } from "../../schema-query/index.js";
|
|
2
|
+
import { strictParse } from "../../schema/index.js";
|
|
3
|
+
import { SchemaQueryInputSchema } from "../../schema/schema-query/index.js";
|
|
2
4
|
export async function handleSchemaQuery(args) {
|
|
5
|
+
const validated = strictParse(SchemaQueryInputSchema, args, "schema_query input");
|
|
3
6
|
const request = {
|
|
4
|
-
action:
|
|
5
|
-
name:
|
|
6
|
-
query:
|
|
7
|
+
action: validated.action,
|
|
8
|
+
name: validated.name,
|
|
9
|
+
query: validated.query,
|
|
7
10
|
};
|
|
8
11
|
const response = processSchemaQuery(request);
|
|
9
12
|
let textContent = response.message;
|
|
10
13
|
const data = response.data;
|
|
11
14
|
if (response.success && data) {
|
|
12
|
-
switch (
|
|
15
|
+
switch (request.action) {
|
|
13
16
|
case "list":
|
|
14
17
|
if (Array.isArray(data) && data.length > 0) {
|
|
15
18
|
textContent += "\n\nAll available schemas:\n";
|
|
16
19
|
for (const item of data) {
|
|
17
|
-
textContent += `\n • ${item.name}`;
|
|
20
|
+
textContent += `\n • ${item.name ?? ""}`;
|
|
18
21
|
if (item.title) {
|
|
19
22
|
textContent += ` - ${item.title}`;
|
|
20
23
|
}
|
|
@@ -29,7 +32,7 @@ export async function handleSchemaQuery(args) {
|
|
|
29
32
|
if (Array.isArray(data) && data.length > 0) {
|
|
30
33
|
textContent += "\n\nOn-chain operation schemas:\n";
|
|
31
34
|
for (const item of data) {
|
|
32
|
-
textContent += `\n • ${item.name}`;
|
|
35
|
+
textContent += `\n • ${item.name ?? ""}`;
|
|
33
36
|
if (item.title) {
|
|
34
37
|
textContent += ` - ${item.title}`;
|
|
35
38
|
}
|
|
@@ -41,26 +44,22 @@ export async function handleSchemaQuery(args) {
|
|
|
41
44
|
}
|
|
42
45
|
break;
|
|
43
46
|
case "get":
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
textContent += "\n```\n";
|
|
49
|
-
}
|
|
47
|
+
textContent += "\n\n## JSON Schema\n\n";
|
|
48
|
+
textContent += "```json\n";
|
|
49
|
+
textContent += JSON.stringify(data, null, 2);
|
|
50
|
+
textContent += "\n```\n";
|
|
50
51
|
break;
|
|
51
52
|
case "get_output":
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
textContent += "\n```\n";
|
|
57
|
-
}
|
|
53
|
+
textContent += "\n\n## Output JSON Schema\n\n";
|
|
54
|
+
textContent += "```json\n";
|
|
55
|
+
textContent += JSON.stringify(data, null, 2);
|
|
56
|
+
textContent += "\n```\n";
|
|
58
57
|
break;
|
|
59
58
|
case "search":
|
|
60
59
|
if (Array.isArray(data) && data.length > 0) {
|
|
61
|
-
textContent += `\n\nFound ${data.length} schemas matching '${
|
|
60
|
+
textContent += `\n\nFound ${data.length} schemas matching '${request.query ?? ""}':\n`;
|
|
62
61
|
for (const item of data) {
|
|
63
|
-
textContent += `\n • ${item.name}`;
|
|
62
|
+
textContent += `\n • ${item.name ?? ""}`;
|
|
64
63
|
if (item.title) {
|
|
65
64
|
textContent += ` - ${item.title}`;
|
|
66
65
|
}
|
|
@@ -74,6 +73,8 @@ export async function handleSchemaQuery(args) {
|
|
|
74
73
|
textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
|
|
75
74
|
}
|
|
76
75
|
break;
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(`Unknown schema_query action: ${String(request.action)}`);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
if (response.suggestions && response.suggestions.length > 0) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ToolDispatchResult } from "../types.js";
|
|
2
|
-
export declare function handleTrustScore(args:
|
|
2
|
+
export declare function handleTrustScore(args: unknown): Promise<ToolDispatchResult>;
|
|
@@ -140,8 +140,8 @@ export async function handleTrustScore(args) {
|
|
|
140
140
|
const orderAmount = validated.order_amount != null
|
|
141
141
|
? BigInt(validated.order_amount)
|
|
142
142
|
: salePriceRaw;
|
|
143
|
-
let riskScore
|
|
144
|
-
let infoPuzzle
|
|
143
|
+
let riskScore;
|
|
144
|
+
let infoPuzzle;
|
|
145
145
|
if (depth === "evaluate" || depth === "preorder") {
|
|
146
146
|
const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
|
|
147
147
|
infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ToolDispatchResult } from "../types.js";
|
|
2
|
-
export declare function handleWipOperations(args:
|
|
2
|
+
export declare function handleWipOperations(args: unknown): Promise<ToolDispatchResult>;
|
|
@@ -21,7 +21,7 @@ export async function handleWipOperations(args) {
|
|
|
21
21
|
}
|
|
22
22
|
case "wip2html": {
|
|
23
23
|
const result = await wip2html(validated.wipPath, validated.options);
|
|
24
|
-
|
|
24
|
+
const output = { type: "wip2html" };
|
|
25
25
|
if (typeof result === "string") {
|
|
26
26
|
output.html = result;
|
|
27
27
|
}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import type { ToolEntry, ToolDispatchResult, DispatchOptions } from "./types.js";
|
|
3
3
|
export declare const TOOL_REGISTRY: ToolEntry[];
|
|
4
4
|
export declare const TOOL_REGISTRY_MAP: Map<string, ToolEntry>;
|
|
5
|
-
export declare function dispatchToolCall(name: string, args:
|
|
5
|
+
export declare function dispatchToolCall(name: string, args: unknown, options?: DispatchOptions): Promise<ToolDispatchResult>;
|
|
6
6
|
export interface ToolListEntry {
|
|
7
7
|
name: string;
|
|
8
8
|
title: string;
|
package/dist/tools/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { zodToJsonSchema } from "zod-to-json-schema";
|
|
|
3
3
|
import { readFileSync } from "fs";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { dirname, join } from "path";
|
|
6
|
+
import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
8
9
|
const SCHEMA_DIR_CANDIDATES = [
|
|
@@ -10,7 +11,7 @@ const SCHEMA_DIR_CANDIDATES = [
|
|
|
10
11
|
join(__dirname, "..", "..", "dist", "schemas"),
|
|
11
12
|
];
|
|
12
13
|
const preGeneratedSchemaCache = new Map();
|
|
13
|
-
import { wrapHandlerWithErrorShape, statusErrorShape, operationErrorShape, strictStatusErrorShape, } from "./wrap.js";
|
|
14
|
+
import { wrapHandlerWithErrorShape, statusErrorShape, operationErrorShape, strictStatusErrorShape, dispatchWithHarness, } from "./wrap.js";
|
|
14
15
|
import { withTelemetry } from "../telemetry/index.js";
|
|
15
16
|
import { handleOnchainOperations } from "./handlers/onchain.js";
|
|
16
17
|
import { handleAccountOperation, handleMarkOperation, handleInfoOperation } from "./handlers/local.js";
|
|
@@ -24,7 +25,7 @@ import { handleProjectOperation } from "./handlers/project.js";
|
|
|
24
25
|
import { handleConfigOperation } from "./handlers/config.js";
|
|
25
26
|
import { handleTrustScore } from "./handlers/trust.js";
|
|
26
27
|
import { applyOnchainRules } from "./rules-hook.js";
|
|
27
|
-
import { createToolMeta, OnchainOperationsSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, WipOperationsSchema, MessengerOperationInputSchema, Guard2File_InputSchema, MachineNode2File_InputSchema, WatchQueryOperationsSchema, OnchainTableDataSchema, OnchainEventsInputSchema, ProtocolInfoQuerySchema, SchemaQueryInputSchema, BridgeOperationsSchema, ProjectOperationInputSchema, ConfigOperationInputSchema, TrustScoreInputSchema, CallOutputSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, Guard2File_OutputWrappedSchema, MachineNode2File_OutputWrappedSchema, OnchainTableDataResultSchema, OnchainEventsResultSchema, ProtocolInfoResultSchema, SchemaQueryOutputSchema, BridgeCallOutputSchema, ProjectOperationOutputSchema, ConfigOperationOutputSchema, TrustScoreOutputSchema, } from "../schema/index.js";
|
|
28
|
+
import { createToolMeta, OnchainOperationsSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, WipOperationsSchema, MessengerOperationInputSchema, Guard2File_InputSchema, MachineNode2File_InputSchema, WatchQueryOperationsSchema, WatchQueryOperationsResultSchema, OnchainTableDataSchema, OnchainEventsInputSchema, ProtocolInfoQuerySchema, SchemaQueryInputSchema, BridgeOperationsSchema, ProjectOperationInputSchema, ConfigOperationInputSchema, TrustScoreInputSchema, CallOutputSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, Guard2File_OutputWrappedSchema, MachineNode2File_OutputWrappedSchema, OnchainTableDataResultSchema, OnchainEventsResultSchema, ProtocolInfoResultSchema, SchemaQueryOutputSchema, BridgeCallOutputSchema, ProjectOperationOutputSchema, ConfigOperationOutputSchema, TrustScoreOutputSchema, } from "../schema/index.js";
|
|
28
29
|
export const TOOL_REGISTRY = [
|
|
29
30
|
{
|
|
30
31
|
name: "onchain_operations",
|
|
@@ -152,10 +153,7 @@ export const TOOL_REGISTRY = [
|
|
|
152
153
|
+ "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.\n\n"
|
|
153
154
|
+ "💡 Schema hint: Use schema_query with action='get' and name='query_toolkit' to retrieve the exact parameter schema with all query types and field definitions.",
|
|
154
155
|
inputSchema: WatchQueryOperationsSchema,
|
|
155
|
-
outputSchema:
|
|
156
|
-
result: z.unknown().describe("Query result — type depends on query_type. Local queries return arrays (MarkData[], AccountData[], InfoData[], TokenTypeInfo[]). account_balance returns { address, balance? | coin? }. Onchain queries return typed objects or undefined. onchain_received returns ReceivedBalance | ReceivedNormal[]."),
|
|
157
|
-
semantic: z.unknown().optional().describe("Business semantic summary for the query operation"),
|
|
158
|
-
}),
|
|
156
|
+
outputSchema: WatchQueryOperationsResultSchema,
|
|
159
157
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
160
158
|
_meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tokens", "balance", "profile"]),
|
|
161
159
|
},
|
|
@@ -261,29 +259,53 @@ export const TOOL_REGISTRY = [
|
|
|
261
259
|
name: "project_operation",
|
|
262
260
|
handler: handleProjectOperation,
|
|
263
261
|
config: {
|
|
264
|
-
title: "🗂️ Project -
|
|
265
|
-
description: "
|
|
266
|
-
"
|
|
262
|
+
title: "🗂️ Project - 5-Stage Deployment & Object Graph",
|
|
263
|
+
description: "Project-based deployment service — manage the local object dependency graph (DAG) AND guide users " +
|
|
264
|
+
"through the 5-stage project deployment workflow. All data comes from local marks tagged " +
|
|
267
265
|
"`project:<prefix>` (auto-injected by the ProjectService when enabled, default ON).\n\n" +
|
|
268
|
-
"
|
|
269
|
-
"
|
|
266
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
267
|
+
" PROJECT-BASED DEPLOYMENT — 5-STAGE WORKFLOW (C1-C4)\n" +
|
|
268
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
269
|
+
"When a user wants to build/deploy a service, follow these 5 stages IN ORDER. " +
|
|
270
|
+
"Each stage's output tells you the next action to call:\n\n" +
|
|
271
|
+
" Stage 1: Project Naming\n" +
|
|
272
|
+
" → Use `project` + `version` params to name the project (e.g. myshop_v1).\n" +
|
|
273
|
+
" Stage 2: Business Puzzle (action='analyze_intent')\n" +
|
|
274
|
+
" → Input: user_intent (natural language), industry hint.\n" +
|
|
275
|
+
" → Output: ODG (object dependency graph), puzzles, missing fields, next_step.\n" +
|
|
276
|
+
" → Guide user to fill missing fields, then proceed to Stage 3.\n" +
|
|
277
|
+
" Stage 3: Risk Calibration (action='aggregate_risks')\n" +
|
|
278
|
+
" → Input: puzzles from Stage 2.\n" +
|
|
279
|
+
" → Output: risk findings, can_proceed flag.\n" +
|
|
280
|
+
" → CRITICAL risks block; HIGH/MEDIUM/LOW only warn. Fix CRITICAL before proceeding.\n" +
|
|
281
|
+
" Stage 4: Deployment Doc (action='generate_deployment_doc')\n" +
|
|
282
|
+
" → Input: objects, edges, steps (topological plan from Stage 2-3).\n" +
|
|
283
|
+
" → Output: markdown deployment doc, D-01..D-18 scanner checks, can_proceed.\n" +
|
|
284
|
+
" → 0 D-errors required before Stage 5.\n" +
|
|
285
|
+
" Stage 5: Substep Trace (action='trace_substeps')\n" +
|
|
286
|
+
" → Input: substeps (from deployment doc), network (testnet/mainnet).\n" +
|
|
287
|
+
" → Output: coherence check, D-10 substep linkage, can_proceed.\n" +
|
|
288
|
+
" → Execute each substep via onchain_operations, record outcomes.\n\n" +
|
|
289
|
+
"Correct object creation order (topological): Permission → Allocation → Guard → Machine → Service.\n" +
|
|
290
|
+
"All objects created as draft (publish=false) first; publish Machine before Service (last).\n\n" +
|
|
291
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
292
|
+
" GRAPH QUERY ACTIONS (10)\n" +
|
|
293
|
+
"═══════════════════════════════════════════════════════════════\n" +
|
|
294
|
+
" • list_projects — List all discovered projects with object counts.\n" +
|
|
270
295
|
" • list_objects — List objects in a project (requires `project` param).\n" +
|
|
271
|
-
" • shareable — List
|
|
272
|
-
" • dependencies — Trace forward dependencies of an object (BFS
|
|
296
|
+
" • shareable — List cross-project reusable objects (common Permission, 3rd-party Arb).\n" +
|
|
297
|
+
" • dependencies — Trace forward dependencies of an object (BFS + dangling refs).\n" +
|
|
273
298
|
" • referenced_by — Reverse query: who references this object?\n" +
|
|
274
|
-
" • pre_publish_check — Pre-publish sanity check
|
|
275
|
-
" • cross_project_refs — Find edges
|
|
299
|
+
" • pre_publish_check — Pre-publish sanity check (dangling deps + cycles).\n" +
|
|
300
|
+
" • cross_project_refs — Find edges crossing project boundaries.\n" +
|
|
276
301
|
" • graph_stats — Graph statistics (node/edge counts, cycles, dangling deps).\n" +
|
|
277
|
-
" • save_graph — Save
|
|
278
|
-
" • load_graph — Load
|
|
279
|
-
"
|
|
280
|
-
"(or toggle graph_persist via config_operation for auto-save). " +
|
|
281
|
-
"list_projects/shareable always query local_mark (persistent).\n\n" +
|
|
282
|
-
"💡 Schema hint: Use schema_query with action='get' and name='project_operation' to retrieve the exact parameter schema with all actions and field definitions.",
|
|
302
|
+
" • save_graph — Save graph to ~/.wowok/project-graph.json.\n" +
|
|
303
|
+
" • load_graph — Load graph from file (restore after restart).\n\n" +
|
|
304
|
+
"💡 Schema hint: Use schema_query with action='get' and name='project_operation' for exact field definitions.",
|
|
283
305
|
inputSchema: ProjectOperationInputSchema,
|
|
284
306
|
outputSchema: ProjectOperationOutputSchema,
|
|
285
|
-
annotations: { readOnlyHint:
|
|
286
|
-
_meta: createToolMeta("project", ["project", "namespace", "graph", "dag", "dependency", "reference", "organization"]),
|
|
307
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
308
|
+
_meta: createToolMeta("project", ["project", "namespace", "graph", "dag", "dependency", "reference", "organization", "deployment", "5-stage", "analyze_intent", "aggregate_risks", "deployment_doc", "trace_substeps", "puzzle", "risk", "odg"]),
|
|
287
309
|
},
|
|
288
310
|
},
|
|
289
311
|
{
|
|
@@ -360,8 +382,9 @@ export async function dispatchToolCall(name, args, options) {
|
|
|
360
382
|
if (ruleResult)
|
|
361
383
|
return ruleResult;
|
|
362
384
|
}
|
|
385
|
+
const harnessWrapped = dispatchWithHarness(entry.handler, name);
|
|
363
386
|
const timeoutMs = entry.timeoutMs ?? 60000;
|
|
364
|
-
const wrapped = wrapHandlerWithErrorShape(
|
|
387
|
+
const wrapped = wrapHandlerWithErrorShape(harnessWrapped, timeoutMs, name, entry.errorShapeBuilder);
|
|
365
388
|
return wrapped(args);
|
|
366
389
|
}
|
|
367
390
|
function zodToJsonSchemaSafe(schema, name) {
|
|
@@ -390,7 +413,7 @@ function resolveSchemaRefs(schema) {
|
|
|
390
413
|
const parts = path.slice(2).split("/");
|
|
391
414
|
let target = schema;
|
|
392
415
|
for (const part of parts) {
|
|
393
|
-
if (target == null || typeof target !== "object"
|
|
416
|
+
if (target == null || typeof target !== "object") {
|
|
394
417
|
return null;
|
|
395
418
|
}
|
|
396
419
|
target = target[part];
|
|
@@ -455,6 +478,25 @@ function loadPreGeneratedSchema(toolName) {
|
|
|
455
478
|
}
|
|
456
479
|
return null;
|
|
457
480
|
}
|
|
481
|
+
const preGeneratedOutputSchemaCache = new Map();
|
|
482
|
+
function loadPreGeneratedOutputSchema(toolName) {
|
|
483
|
+
const cached = preGeneratedOutputSchemaCache.get(toolName);
|
|
484
|
+
if (cached)
|
|
485
|
+
return cached;
|
|
486
|
+
for (const dir of SCHEMA_DIR_CANDIDATES) {
|
|
487
|
+
try {
|
|
488
|
+
const schemaPath = join(dir, `${toolName}.output.json`);
|
|
489
|
+
const raw = readFileSync(schemaPath, "utf-8");
|
|
490
|
+
const schema = JSON.parse(raw);
|
|
491
|
+
const resolved = resolveSchemaRefs(schema);
|
|
492
|
+
preGeneratedOutputSchemaCache.set(toolName, resolved);
|
|
493
|
+
return resolved;
|
|
494
|
+
}
|
|
495
|
+
catch {
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
458
500
|
export function listTools() {
|
|
459
501
|
return TOOL_REGISTRY.map(entry => {
|
|
460
502
|
const preGenerated = loadPreGeneratedSchema(entry.name);
|
|
@@ -476,4 +518,33 @@ export function registerAllTools(server) {
|
|
|
476
518
|
const wrapped = wrapHandlerWithErrorShape(handlerWithRules, timeoutMs, entry.name, entry.errorShapeBuilder);
|
|
477
519
|
server.registerTool(entry.name, entry.config, withTelemetry(entry.name, wrapped));
|
|
478
520
|
}
|
|
521
|
+
overrideToolsListHandler(server);
|
|
522
|
+
}
|
|
523
|
+
function overrideToolsListHandler(server) {
|
|
524
|
+
server.server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
525
|
+
tools: TOOL_REGISTRY.map(entry => {
|
|
526
|
+
const rawSchema = loadPreGeneratedSchema(entry.name) ??
|
|
527
|
+
zodToJsonSchemaSafe(entry.config.inputSchema, entry.name);
|
|
528
|
+
const inputSchema = ensureObjectType(rawSchema);
|
|
529
|
+
const toolDef = {
|
|
530
|
+
name: entry.name,
|
|
531
|
+
title: entry.config.title,
|
|
532
|
+
description: entry.config.description,
|
|
533
|
+
inputSchema,
|
|
534
|
+
annotations: entry.config.annotations,
|
|
535
|
+
_meta: entry.config._meta,
|
|
536
|
+
};
|
|
537
|
+
if (entry.config.outputSchema) {
|
|
538
|
+
const outputSchema = loadPreGeneratedOutputSchema(entry.name) ??
|
|
539
|
+
zodToJsonSchemaSafe(entry.config.outputSchema, `${entry.name}_output`);
|
|
540
|
+
toolDef.outputSchema = outputSchema;
|
|
541
|
+
}
|
|
542
|
+
return toolDef;
|
|
543
|
+
}),
|
|
544
|
+
}));
|
|
545
|
+
}
|
|
546
|
+
function ensureObjectType(schema) {
|
|
547
|
+
if (schema.type === "object")
|
|
548
|
+
return schema;
|
|
549
|
+
return { ...schema, type: "object" };
|
|
479
550
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ToolDispatchResult } from "./types.js";
|
|
2
|
-
export declare function applyOnchainRules(args:
|
|
2
|
+
export declare function applyOnchainRules(args: unknown): ToolDispatchResult | null;
|