@wowok/agent-mcp 2.4.3 → 2.5.0
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 +1392 -6
- package/dist/schema/project/index.js +426 -2
- 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 +1802 -313
- 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 +584 -70
- 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 +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- 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 +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- 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 +258 -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 +55 -8
- 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,290 @@
|
|
|
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
|
+
warnings: result.warnings,
|
|
97
|
+
evolution_context: evolutionContext,
|
|
98
|
+
experience_feedback: experienceFeedback,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function handleAggregateRisks(validated) {
|
|
102
|
+
const { prefix, version } = requireProject(validated);
|
|
103
|
+
const puzzles = requirePuzzles(validated);
|
|
104
|
+
const result = aggregateProjectRisks({
|
|
105
|
+
project_prefix: prefix,
|
|
106
|
+
version: version,
|
|
107
|
+
industry: validated.industry,
|
|
108
|
+
puzzles,
|
|
109
|
+
severity_threshold: validated.severity_threshold,
|
|
110
|
+
user_confirmed_high_risks: validated.user_confirmed_high_risks,
|
|
111
|
+
});
|
|
112
|
+
const hasCritical = result.severity_summary.CRITICAL > 0;
|
|
113
|
+
const unconfirmedHigh = result.findings.filter((r) => r.severity === "HIGH").length;
|
|
114
|
+
return {
|
|
115
|
+
action: "aggregate_risks",
|
|
116
|
+
namespace: result.namespace,
|
|
117
|
+
findings: result.findings,
|
|
118
|
+
severity_summary: result.severity_summary,
|
|
119
|
+
status: result.status,
|
|
120
|
+
pending_confirmations: result.pending_confirmations,
|
|
121
|
+
calibrated_at: result.calibrated_at,
|
|
122
|
+
warnings: result.warnings,
|
|
123
|
+
can_proceed: !hasCritical,
|
|
124
|
+
user_action_required: hasCritical
|
|
125
|
+
? `Fix ${result.severity_summary.CRITICAL} CRITICAL risk(s) before proceeding`
|
|
126
|
+
: unconfirmedHigh > 0
|
|
127
|
+
? `Review ${unconfirmedHigh} HIGH risk(s). You may proceed at your own risk.`
|
|
128
|
+
: "All risks reviewed. You may proceed.",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async function handleGenerateDeploymentDoc(validated) {
|
|
132
|
+
const { prefix, version } = requireProject(validated);
|
|
133
|
+
const required = requireDeploymentInputs(validated);
|
|
134
|
+
const docInput = {
|
|
135
|
+
project_prefix: prefix,
|
|
136
|
+
version: version,
|
|
137
|
+
business_intent: required.business_intent,
|
|
138
|
+
industry: validated.industry ?? "general",
|
|
139
|
+
author: validated.author,
|
|
140
|
+
objects: required.objects,
|
|
141
|
+
edges: required.edges,
|
|
142
|
+
steps: required.steps,
|
|
143
|
+
scenarios: validated.scenarios,
|
|
144
|
+
risk_status: validated.risk_status,
|
|
145
|
+
risk_critical_count: validated.risk_critical_count,
|
|
146
|
+
risk_high_count: validated.risk_high_count,
|
|
147
|
+
};
|
|
148
|
+
const markdown = generateDeploymentDoc(docInput);
|
|
149
|
+
const generatedAt = new Date().toISOString();
|
|
150
|
+
const shouldRunScanner = validated.run_scanner !== false;
|
|
151
|
+
let validationResult;
|
|
152
|
+
if (shouldRunScanner) {
|
|
153
|
+
const validation = validateDeploymentDoc(docInput);
|
|
154
|
+
validationResult = {
|
|
155
|
+
valid: validation.valid,
|
|
156
|
+
checks: validation.checks,
|
|
157
|
+
errors: validation.errors,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const errorCount = validationResult
|
|
161
|
+
? validationResult.checks.filter((c) => c.status === "FAIL").length
|
|
162
|
+
: 0;
|
|
163
|
+
const warningCount = validationResult
|
|
164
|
+
? validationResult.checks.filter((c) => c.status === "WARN").length
|
|
165
|
+
: 0;
|
|
166
|
+
return {
|
|
167
|
+
action: "generate_deployment_doc",
|
|
168
|
+
markdown,
|
|
169
|
+
meta: {
|
|
170
|
+
project_prefix: prefix,
|
|
171
|
+
version: version,
|
|
172
|
+
generated_at: generatedAt,
|
|
173
|
+
object_count: required.objects.length,
|
|
174
|
+
step_count: required.steps.length,
|
|
175
|
+
},
|
|
176
|
+
validation: validationResult,
|
|
177
|
+
can_proceed: errorCount === 0,
|
|
178
|
+
user_action_required: errorCount > 0
|
|
179
|
+
? `Fix ${errorCount} D-error(s) before deploying`
|
|
180
|
+
: warningCount > 0
|
|
181
|
+
? `${warningCount} D-warning(s) found. You may proceed at your own risk.`
|
|
182
|
+
: "Deployment document ready. You may proceed to stage 5.",
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async function handleTraceSubsteps(validated) {
|
|
186
|
+
const { prefix, version } = requireProject(validated);
|
|
187
|
+
const { network, substeps } = requireSubsteps(validated);
|
|
188
|
+
const result = traceSubsteps({
|
|
189
|
+
project_prefix: prefix,
|
|
190
|
+
version: version,
|
|
191
|
+
network: network,
|
|
192
|
+
substeps,
|
|
193
|
+
});
|
|
194
|
+
const hasFailedSubstep = substeps.some((s) => s.status === "FAILED");
|
|
195
|
+
const canProceed = result.coherent && !hasFailedSubstep;
|
|
196
|
+
const issueParts = [];
|
|
197
|
+
if (result.dangling_inputs.length > 0) {
|
|
198
|
+
issueParts.push(`${result.dangling_inputs.length} dangling inputs`);
|
|
199
|
+
}
|
|
200
|
+
if (result.circular_refs.length > 0) {
|
|
201
|
+
issueParts.push(`${result.circular_refs.length} circular refs`);
|
|
202
|
+
}
|
|
203
|
+
if (result.missing_outputs.length > 0) {
|
|
204
|
+
issueParts.push(`${result.missing_outputs.length} missing outputs`);
|
|
205
|
+
}
|
|
206
|
+
if (result.cross_step_breaks.length > 0) {
|
|
207
|
+
issueParts.push(`${result.cross_step_breaks.length} cross-step breaks`);
|
|
208
|
+
}
|
|
209
|
+
if (hasFailedSubstep) {
|
|
210
|
+
const failedCount = substeps.filter((s) => s.status === "FAILED").length;
|
|
211
|
+
issueParts.push(`${failedCount} failed substep(s)`);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
action: "trace_substeps",
|
|
215
|
+
namespace: result.namespace,
|
|
216
|
+
network: result.network,
|
|
217
|
+
coherent: result.coherent,
|
|
218
|
+
dangling_inputs: result.dangling_inputs,
|
|
219
|
+
circular_refs: result.circular_refs,
|
|
220
|
+
missing_outputs: result.missing_outputs,
|
|
221
|
+
cross_step_breaks: result.cross_step_breaks,
|
|
222
|
+
step_details: result.step_details,
|
|
223
|
+
topological_order: result.topological_order,
|
|
224
|
+
d10_check: result.d10_check,
|
|
225
|
+
can_proceed: canProceed,
|
|
226
|
+
user_action_required: issueParts.length > 0
|
|
227
|
+
? `Fix: ${issueParts.join(", ")}`
|
|
228
|
+
: "All substeps passed. Deployment complete.",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
2
231
|
export async function handleProjectOperation(args) {
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const object = args.object;
|
|
232
|
+
const validated = strictParse(ProjectOperationInputSchema, args, "project_operation input");
|
|
233
|
+
const { action } = validated;
|
|
6
234
|
let result;
|
|
7
235
|
switch (action) {
|
|
8
236
|
case "list_projects":
|
|
9
|
-
result = await queryProjects();
|
|
237
|
+
result = { action: "list_projects", items: await queryProjects() };
|
|
10
238
|
break;
|
|
11
239
|
case "list_objects":
|
|
12
|
-
if (!project)
|
|
240
|
+
if (!validated.project)
|
|
13
241
|
throw new Error("'project' param is required for list_objects");
|
|
14
|
-
result = await queryProjectObjects(project);
|
|
242
|
+
result = { action: "list_objects", items: await queryProjectObjects(validated.project) };
|
|
15
243
|
break;
|
|
16
244
|
case "shareable":
|
|
17
|
-
result = await queryShareableObjects();
|
|
245
|
+
result = { action: "shareable", items: await queryShareableObjects() };
|
|
18
246
|
break;
|
|
19
247
|
case "dependencies":
|
|
20
|
-
if (!object)
|
|
248
|
+
if (!validated.object)
|
|
21
249
|
throw new Error("'object' param is required for dependencies");
|
|
22
|
-
result = queryDependencies(object);
|
|
250
|
+
result = { action: "dependencies", items: queryDependencies(validated.object) };
|
|
23
251
|
break;
|
|
24
252
|
case "referenced_by":
|
|
25
|
-
if (!object)
|
|
253
|
+
if (!validated.object)
|
|
26
254
|
throw new Error("'object' param is required for referenced_by");
|
|
27
|
-
result = queryReferencedBy(object);
|
|
255
|
+
result = { action: "referenced_by", items: queryReferencedBy(validated.object) };
|
|
28
256
|
break;
|
|
29
257
|
case "pre_publish_check":
|
|
30
|
-
if (!object)
|
|
258
|
+
if (!validated.object)
|
|
31
259
|
throw new Error("'object' param is required for pre_publish_check");
|
|
32
|
-
result = { warnings: queryPrePublishCheck(object) };
|
|
260
|
+
result = { action: "pre_publish_check", warnings: queryPrePublishCheck(validated.object) };
|
|
33
261
|
break;
|
|
34
262
|
case "cross_project_refs":
|
|
35
|
-
result = queryCrossProjectReferences();
|
|
263
|
+
result = { action: "cross_project_refs", items: queryCrossProjectReferences() };
|
|
36
264
|
break;
|
|
37
265
|
case "graph_stats":
|
|
38
|
-
result = queryGraphStats();
|
|
266
|
+
result = { action: "graph_stats", stats: queryGraphStats() };
|
|
39
267
|
break;
|
|
40
268
|
case "save_graph":
|
|
41
|
-
result = { saved: true, path: saveGraph() };
|
|
269
|
+
result = { action: "save_graph", saved: true, path: saveGraph() };
|
|
42
270
|
break;
|
|
43
271
|
case "load_graph":
|
|
44
|
-
result = { loaded: loadGraph() };
|
|
272
|
+
result = { action: "load_graph", loaded: loadGraph() };
|
|
273
|
+
break;
|
|
274
|
+
case "analyze_intent":
|
|
275
|
+
result = await handleAnalyzeIntent(validated);
|
|
276
|
+
break;
|
|
277
|
+
case "aggregate_risks":
|
|
278
|
+
result = await handleAggregateRisks(validated);
|
|
279
|
+
break;
|
|
280
|
+
case "generate_deployment_doc":
|
|
281
|
+
result = await handleGenerateDeploymentDoc(validated);
|
|
282
|
+
break;
|
|
283
|
+
case "trace_substeps":
|
|
284
|
+
result = await handleTraceSubsteps(validated);
|
|
45
285
|
break;
|
|
46
286
|
default:
|
|
47
|
-
throw new Error(`Unknown project_operation action: ${action}`);
|
|
287
|
+
throw new Error(`Unknown project_operation action: ${String(action)}`);
|
|
48
288
|
}
|
|
49
289
|
return {
|
|
50
290
|
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
|
},
|
|
@@ -360,8 +358,9 @@ export async function dispatchToolCall(name, args, options) {
|
|
|
360
358
|
if (ruleResult)
|
|
361
359
|
return ruleResult;
|
|
362
360
|
}
|
|
361
|
+
const harnessWrapped = dispatchWithHarness(entry.handler, name);
|
|
363
362
|
const timeoutMs = entry.timeoutMs ?? 60000;
|
|
364
|
-
const wrapped = wrapHandlerWithErrorShape(
|
|
363
|
+
const wrapped = wrapHandlerWithErrorShape(harnessWrapped, timeoutMs, name, entry.errorShapeBuilder);
|
|
365
364
|
return wrapped(args);
|
|
366
365
|
}
|
|
367
366
|
function zodToJsonSchemaSafe(schema, name) {
|
|
@@ -390,7 +389,7 @@ function resolveSchemaRefs(schema) {
|
|
|
390
389
|
const parts = path.slice(2).split("/");
|
|
391
390
|
let target = schema;
|
|
392
391
|
for (const part of parts) {
|
|
393
|
-
if (target == null || typeof target !== "object"
|
|
392
|
+
if (target == null || typeof target !== "object") {
|
|
394
393
|
return null;
|
|
395
394
|
}
|
|
396
395
|
target = target[part];
|
|
@@ -455,6 +454,25 @@ function loadPreGeneratedSchema(toolName) {
|
|
|
455
454
|
}
|
|
456
455
|
return null;
|
|
457
456
|
}
|
|
457
|
+
const preGeneratedOutputSchemaCache = new Map();
|
|
458
|
+
function loadPreGeneratedOutputSchema(toolName) {
|
|
459
|
+
const cached = preGeneratedOutputSchemaCache.get(toolName);
|
|
460
|
+
if (cached)
|
|
461
|
+
return cached;
|
|
462
|
+
for (const dir of SCHEMA_DIR_CANDIDATES) {
|
|
463
|
+
try {
|
|
464
|
+
const schemaPath = join(dir, `${toolName}.output.json`);
|
|
465
|
+
const raw = readFileSync(schemaPath, "utf-8");
|
|
466
|
+
const schema = JSON.parse(raw);
|
|
467
|
+
const resolved = resolveSchemaRefs(schema);
|
|
468
|
+
preGeneratedOutputSchemaCache.set(toolName, resolved);
|
|
469
|
+
return resolved;
|
|
470
|
+
}
|
|
471
|
+
catch {
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
458
476
|
export function listTools() {
|
|
459
477
|
return TOOL_REGISTRY.map(entry => {
|
|
460
478
|
const preGenerated = loadPreGeneratedSchema(entry.name);
|
|
@@ -476,4 +494,33 @@ export function registerAllTools(server) {
|
|
|
476
494
|
const wrapped = wrapHandlerWithErrorShape(handlerWithRules, timeoutMs, entry.name, entry.errorShapeBuilder);
|
|
477
495
|
server.registerTool(entry.name, entry.config, withTelemetry(entry.name, wrapped));
|
|
478
496
|
}
|
|
497
|
+
overrideToolsListHandler(server);
|
|
498
|
+
}
|
|
499
|
+
function overrideToolsListHandler(server) {
|
|
500
|
+
server.server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
501
|
+
tools: TOOL_REGISTRY.map(entry => {
|
|
502
|
+
const rawSchema = loadPreGeneratedSchema(entry.name) ??
|
|
503
|
+
zodToJsonSchemaSafe(entry.config.inputSchema, entry.name);
|
|
504
|
+
const inputSchema = ensureObjectType(rawSchema);
|
|
505
|
+
const toolDef = {
|
|
506
|
+
name: entry.name,
|
|
507
|
+
title: entry.config.title,
|
|
508
|
+
description: entry.config.description,
|
|
509
|
+
inputSchema,
|
|
510
|
+
annotations: entry.config.annotations,
|
|
511
|
+
_meta: entry.config._meta,
|
|
512
|
+
};
|
|
513
|
+
if (entry.config.outputSchema) {
|
|
514
|
+
const outputSchema = loadPreGeneratedOutputSchema(entry.name) ??
|
|
515
|
+
zodToJsonSchemaSafe(entry.config.outputSchema, `${entry.name}_output`);
|
|
516
|
+
toolDef.outputSchema = outputSchema;
|
|
517
|
+
}
|
|
518
|
+
return toolDef;
|
|
519
|
+
}),
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
522
|
+
function ensureObjectType(schema) {
|
|
523
|
+
if (schema.type === "object")
|
|
524
|
+
return schema;
|
|
525
|
+
return { ...schema, type: "object" };
|
|
479
526
|
}
|
|
@@ -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;
|
package/dist/tools/rules-hook.js
CHANGED
|
@@ -10,11 +10,12 @@ export function applyOnchainRules(args) {
|
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
const env = getEnvConfig(validated.env);
|
|
13
|
-
const
|
|
13
|
+
const data = 'data' in validated ? validated.data : undefined;
|
|
14
|
+
const gateResult = buildPendingConfirmation(validated.operation_type, data, env);
|
|
14
15
|
if (gateResult.structuredContent) {
|
|
15
16
|
return gateResult;
|
|
16
17
|
}
|
|
17
|
-
const constraintViolations = validateOperation(validated.operation_type,
|
|
18
|
+
const constraintViolations = validateOperation(validated.operation_type, data);
|
|
18
19
|
if (hasBlockingViolations(constraintViolations)) {
|
|
19
20
|
return buildConstraintError(validated.operation_type, constraintViolations);
|
|
20
21
|
}
|
package/dist/tools/shared.d.ts
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
import { validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintViolation } from "../knowledge/index.js";
|
|
2
2
|
import { classifyError, type SemanticContext } from "../schema/call/semantic.js";
|
|
3
|
+
import type { ToolDispatchResult } from "./types.js";
|
|
3
4
|
export declare function withHarness(base: SemanticContext, operation: string, intent: string): SemanticContext;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type { z } from "zod";
|
|
6
|
+
import type { CallEnv } from "../schema/call/base.js";
|
|
7
|
+
export interface LocalHandlerConfig<S extends z.ZodTypeAny> {
|
|
8
|
+
schema: S;
|
|
9
|
+
operationFn: (input: z.infer<S>) => Promise<unknown>;
|
|
7
10
|
parseLabel: string;
|
|
8
|
-
buildContext: (validated:
|
|
11
|
+
buildContext: (validated: z.infer<S>) => SemanticContext;
|
|
9
12
|
}
|
|
10
|
-
export declare function wrapLocalHandler(config: LocalHandlerConfig): (args:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}[];
|
|
15
|
-
structuredContent: {
|
|
16
|
-
result: any;
|
|
17
|
-
semantic: any;
|
|
18
|
-
};
|
|
19
|
-
}>;
|
|
20
|
-
export declare function buildPendingConfirmation(operation_type: string, data: any, env: any): {
|
|
21
|
-
content: any[];
|
|
22
|
-
structuredContent: any;
|
|
13
|
+
export declare function wrapLocalHandler<S extends z.ZodTypeAny>(config: LocalHandlerConfig<S>): (args: unknown) => Promise<ToolDispatchResult>;
|
|
14
|
+
export declare function buildPendingConfirmation(operation_type: string, data: unknown, env: CallEnv | undefined): ToolDispatchResult | {
|
|
15
|
+
content: never[];
|
|
16
|
+
structuredContent: null;
|
|
23
17
|
};
|
|
24
|
-
export declare function buildConstraintError(operation_type: string, violations: ConstraintViolation[]):
|
|
25
|
-
|
|
26
|
-
structuredContent: any;
|
|
27
|
-
};
|
|
28
|
-
export declare function buildClassifiedErrorResult(base: Record<string, any>, error: string, classified: ReturnType<typeof classifyError>): Record<string, any>;
|
|
18
|
+
export declare function buildConstraintError(operation_type: string, violations: ConstraintViolation[]): ToolDispatchResult;
|
|
19
|
+
export declare function buildClassifiedErrorResult(base: Record<string, unknown>, error: string, classified: ReturnType<typeof classifyError>): Record<string, unknown>;
|
|
29
20
|
export { validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintViolation, };
|