@wowok/agent-mcp 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/customer/info-puzzle.d.ts +1 -1
- package/dist/customer/info-puzzle.js +4 -2
- package/dist/customer/risk-assessment.js +26 -4
- package/dist/customer/types.d.ts +2 -0
- package/dist/examples/guard-template-balance-check.json +38 -0
- package/dist/examples/guard-template-time-lock.json +39 -0
- package/dist/examples/machine-template-7node-rental.json +114 -0
- package/dist/examples/rental-ziroom-machine-create.json +137 -0
- package/dist/examples/rental-ziroom-permission-create.json +35 -0
- package/dist/examples/rental-ziroom-service-create.json +80 -0
- package/dist/examples/retail-myshop-service-create.json +88 -0
- package/dist/extensions/capability-manifest.js +24 -24
- package/dist/extensions/constraint-registry.js +18 -18
- package/dist/extensions/metric-registry.js +14 -14
- package/dist/extensions/mode-evaluator.js +16 -16
- package/dist/extensions/modes.js +131 -45
- package/dist/extensions/registry.d.ts +2 -0
- package/dist/extensions/registry.js +63 -30
- package/dist/extensions/types.d.ts +1 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +72 -0
- package/dist/knowledge/fund-layer.js +420 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-templates.js +4 -4
- package/dist/knowledge/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- package/dist/knowledge/service-confirm.d.ts +1 -1
- package/dist/knowledge/service-confirm.js +3 -3
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- package/dist/project/deployment-bridge.js +6 -5
- package/dist/project/deployment-doc.js +5 -5
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1371 -0
- package/dist/project/evaluation.js +314 -14
- package/dist/project/graph-builder.js +6 -1
- package/dist/project/handlers.d.ts +99 -2
- package/dist/project/handlers.js +358 -16
- package/dist/project/stage-gate.js +4 -4
- package/dist/schema/call/allocation.js +2 -2
- package/dist/schema/call/arbitration.js +19 -6
- package/dist/schema/call/contact.js +2 -2
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.js +1 -1
- package/dist/schema/call/machine.d.ts +1975 -777
- package/dist/schema/call/machine.js +50 -4
- package/dist/schema/call/order.js +3 -6
- package/dist/schema/call/permission.js +2 -2
- package/dist/schema/call/repository.js +2 -2
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.js +7 -1
- package/dist/schema/call/service.d.ts +180 -8
- package/dist/schema/call/service.js +82 -27
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +2 -0
- package/dist/schema/common/index.js +46 -10
- package/dist/schema/local/index.js +5 -1
- package/dist/schema/operations.d.ts +755 -176
- package/dist/schema/operations.js +43 -7
- package/dist/schema/project/index.d.ts +969 -6
- package/dist/schema/project/index.js +268 -4
- package/dist/schema/query/index.d.ts +217 -0
- package/dist/schema/query/index.js +63 -33
- package/dist/schema/schema-query/index.d.ts +53 -3
- package/dist/schema/schema-query/index.js +17 -2
- package/dist/schema/utils/node-parser.js +13 -0
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +76 -0
- package/dist/schema-query/index.d.ts +14 -1
- package/dist/schema-query/index.js +104 -2
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +115 -53
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +9 -7
- package/dist/schemas/onchain_operations_contact.schema.json +3 -3
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -2
- package/dist/schemas/onchain_operations_guard.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +4 -4
- package/dist/schemas/onchain_operations_order.schema.json +3 -3
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -2
- package/dist/schemas/onchain_operations_progress.schema.json +1 -1
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +3 -3
- package/dist/schemas/onchain_operations_reward.schema.json +6 -6
- package/dist/schemas/onchain_operations_service.schema.json +77 -17
- package/dist/schemas/onchain_operations_treasury.schema.json +4 -4
- package/dist/schemas/onchain_table_data.output.json +1 -1
- package/dist/schemas/onchain_table_data.schema.json +10 -9
- package/dist/schemas/project_operation.output.json +1026 -7
- package/dist/schemas/project_operation.schema.json +46 -4
- package/dist/schemas/query_toolkit.output.json +15 -15
- package/dist/schemas/query_toolkit.schema.json +3 -3
- package/dist/schemas/schema_query.output.json +64 -1
- package/dist/schemas/schema_query.schema.json +3 -2
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/onchain.js +571 -6
- package/dist/tools/handlers/project.js +25 -2
- package/dist/tools/handlers/schema-query.js +24 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +177 -6
- package/package.json +2 -2
|
@@ -3,10 +3,12 @@ import { generateDeploymentDocFromProject } from "../../project/deployment-bridg
|
|
|
3
3
|
import { LocalProject } from "@wowok/wowok";
|
|
4
4
|
import { validateStageGate } from "../../project/stage-gate.js";
|
|
5
5
|
import { scanDeployment } from "../../knowledge/deployment-scanner.js";
|
|
6
|
-
import { handleListProjects, handleCreateProject, handleCreateProjectFromOnchain, handleUpdateProject, handleGetProjectDetail, handleAddObject, handleRemoveObject, handleUpdateObject, handleCreateVersion, handleBuildGraph, handleGetGraph, handleEvaluateProject, handleSaveEvaluation, handleCompareProjects, handleRefreshObjects, handleGetObjectDiff, handleDeleteProject, handleGetMachineGraph, handlePreEvaluateCheck, handleVerifyDeployment, handleCloneProjectToNetwork, } from "../../project/handlers.js";
|
|
6
|
+
import { handleListProjects, handleCreateProject, handleCreateProjectFromOnchain, handleUpdateProject, handleGetProjectDetail, handleAddObject, handleRemoveObject, handleUpdateObject, handleCreateVersion, handleBuildGraph, handleGetGraph, handleEvaluateProject, handleSaveEvaluation, handleCompareProjects, handleRefreshObjects, handleGetObjectDiff, handleDeleteProject, handleGetMachineGraph, handleGetGuardGraph, handlePreEvaluateCheck, handleVerifyDeployment, handleCloneProjectToNetwork, handleMigrateToMainnet, } from "../../project/handlers.js";
|
|
7
|
+
import { handlePlanObjectEdit, handleApplyObjectEdit, handlePatchMachineNodes, handlePatchGuardTree, } from "../../project/edit-planner.js";
|
|
7
8
|
import { strictParse } from "../../schema/index.js";
|
|
8
9
|
import { ProjectOperationInputSchema } from "../../schema/project/index.js";
|
|
9
10
|
import { getStageCache } from "../../project/index.js";
|
|
11
|
+
import { getSkillsHintForProject } from "../../schema/utils/skills-recommendation.js";
|
|
10
12
|
export async function handleProjectOperation(args) {
|
|
11
13
|
const validated = strictParse(ProjectOperationInputSchema, args, "project_operation input");
|
|
12
14
|
const { action } = validated;
|
|
@@ -66,6 +68,9 @@ export async function handleProjectOperation(args) {
|
|
|
66
68
|
case "get_machine_graph":
|
|
67
69
|
result = await handleGetMachineGraph(validated);
|
|
68
70
|
break;
|
|
71
|
+
case "get_guard_graph":
|
|
72
|
+
result = await handleGetGuardGraph(validated);
|
|
73
|
+
break;
|
|
69
74
|
case "assemble_context":
|
|
70
75
|
result = await assembleContext(validated);
|
|
71
76
|
break;
|
|
@@ -132,11 +137,29 @@ export async function handleProjectOperation(args) {
|
|
|
132
137
|
case "migrate_network":
|
|
133
138
|
result = await handleCloneProjectToNetwork(validated);
|
|
134
139
|
break;
|
|
140
|
+
case "migrate_to_mainnet":
|
|
141
|
+
result = await handleMigrateToMainnet(validated);
|
|
142
|
+
break;
|
|
143
|
+
case "plan_object_edit":
|
|
144
|
+
result = await handlePlanObjectEdit(validated);
|
|
145
|
+
break;
|
|
146
|
+
case "apply_object_edit":
|
|
147
|
+
result = await handleApplyObjectEdit(validated);
|
|
148
|
+
break;
|
|
149
|
+
case "patch_machine_nodes":
|
|
150
|
+
result = await handlePatchMachineNodes(validated);
|
|
151
|
+
break;
|
|
152
|
+
case "patch_guard_tree":
|
|
153
|
+
result = await handlePatchGuardTree(validated);
|
|
154
|
+
break;
|
|
135
155
|
default:
|
|
136
156
|
throw new Error(`Unknown project_operation action: ${String(action)}`);
|
|
137
157
|
}
|
|
158
|
+
const skillsHint = getSkillsHintForProject(action);
|
|
138
159
|
return {
|
|
139
160
|
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
140
|
-
structuredContent:
|
|
161
|
+
structuredContent: skillsHint
|
|
162
|
+
? { result, skills_recommended: skillsHint }
|
|
163
|
+
: { result },
|
|
141
164
|
};
|
|
142
165
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { processSchemaQuery, } from "../../schema-query/index.js";
|
|
1
|
+
import { processSchemaQuery, EXAMPLES_DIR, } from "../../schema-query/index.js";
|
|
2
2
|
import { strictParse } from "../../schema/index.js";
|
|
3
3
|
import { SchemaQueryInputSchema } from "../../schema/schema-query/index.js";
|
|
4
4
|
export async function handleSchemaQuery(args) {
|
|
@@ -92,6 +92,29 @@ export async function handleSchemaQuery(args) {
|
|
|
92
92
|
textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
|
|
93
93
|
}
|
|
94
94
|
break;
|
|
95
|
+
case "search_examples": {
|
|
96
|
+
const items = (Array.isArray(data) ? data : []);
|
|
97
|
+
if (items.length > 0) {
|
|
98
|
+
textContent += `\n\nFound ${items.length} example(s) matching '${request.query ?? ""}':\n`;
|
|
99
|
+
for (const item of items) {
|
|
100
|
+
textContent += `\n • [score: ${item.score}] ${item.file}`;
|
|
101
|
+
textContent += `\n Title: ${item.title}`;
|
|
102
|
+
textContent += `\n Industry: ${item.industry} | Operation: ${item.operation_type} | Verified: ${item.verified ? "yes" : "no"}`;
|
|
103
|
+
textContent += `\n Tags: ${item.tags.join(", ")}`;
|
|
104
|
+
textContent += `\n Matched fields: ${item.matched_fields.join(", ")}`;
|
|
105
|
+
const descPreview = item.description.length > 120
|
|
106
|
+
? `${item.description.slice(0, 120)}...`
|
|
107
|
+
: item.description;
|
|
108
|
+
textContent += `\n Description: ${descPreview}`;
|
|
109
|
+
textContent += "\n";
|
|
110
|
+
}
|
|
111
|
+
textContent += `\n To view the full example JSON, read files from: ${EXAMPLES_DIR}`;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
textContent += "\n\nNo examples found. Try broader terms like 'service', 'machine', 'guard', 'permission', or an industry name like 'rental' or 'retail'.";
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
95
118
|
default:
|
|
96
119
|
throw new Error(`Unknown schema_query action: ${String(request.action)}`);
|
|
97
120
|
}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ 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 interface StructuredSchemaError {
|
|
6
|
+
path: string;
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
expected?: string;
|
|
10
|
+
received_value?: unknown;
|
|
11
|
+
suggestion: string;
|
|
12
|
+
}
|
|
5
13
|
export declare function dispatchToolCall(name: string, args: unknown, options?: DispatchOptions): Promise<ToolDispatchResult>;
|
|
6
14
|
export interface ToolListEntry {
|
|
7
15
|
name: string;
|
package/dist/tools/index.js
CHANGED
|
@@ -462,10 +462,10 @@ const WOWOK_TOOL_DESCRIPTION = [
|
|
|
462
462
|
"Projects are the core organizing unit for all WoWok workflows. The policy is context-aware:",
|
|
463
463
|
"",
|
|
464
464
|
"CASE 1 — COMPLEX REQUIREMENT (user wants to build/deploy a full service):",
|
|
465
|
-
" Examples: '
|
|
465
|
+
" Examples: 'build a travel guide service', 'open a toy store', 'create a rental service'",
|
|
466
466
|
" → You MUST auto-create a project FIRST, then create objects.",
|
|
467
467
|
" → Check for similar existing projects first: project_operation action='list_projects'",
|
|
468
|
-
" If similar projects exist (same industry), remind the user: '
|
|
468
|
+
" If similar projects exist (same industry), remind the user: 'Found similar project X. Reuse or create new?'",
|
|
469
469
|
" → Workflow:",
|
|
470
470
|
" 1. project_operation action='create_project' (perspective='producer', project_industry=<best match>)",
|
|
471
471
|
" 2. Create on-chain objects via onchain_operations with env.project='<prefix>' (auto-tags + auto-associates to SQLite project)",
|
|
@@ -475,11 +475,11 @@ const WOWOK_TOOL_DESCRIPTION = [
|
|
|
475
475
|
" 6. Report results, fix critical findings, then publish Service",
|
|
476
476
|
"",
|
|
477
477
|
"CASE 2 — SINGLE OBJECT CREATION (user wants one specific object):",
|
|
478
|
-
" Examples: '
|
|
478
|
+
" Examples: 'create a Permission', 'add a Contact', 'build a Guard'",
|
|
479
479
|
" → Do NOT auto-create a project. If the user has an existing project, create with env.project='<prefix>' to auto-associate.",
|
|
480
480
|
" → If no existing project, after creation, REMIND the user:",
|
|
481
|
-
" '
|
|
482
|
-
"
|
|
481
|
+
" 'This object has been created. Consider adding it to a project for management: project_operation action=\"add_object\"",
|
|
482
|
+
" If no project exists yet, use action=\"create_project\" to create one. Existing projects: [list projects if any]'",
|
|
483
483
|
" → If the user then says 'yes, create a project' or 'add to project X', proceed accordingly.",
|
|
484
484
|
"",
|
|
485
485
|
"CASE 3 — CONSUMER FLOW (user wants to buy/evaluate a service):",
|
|
@@ -545,6 +545,150 @@ function formatZodErrors(error, input) {
|
|
|
545
545
|
return `${path} [${code}]: ${message}${extras}`;
|
|
546
546
|
});
|
|
547
547
|
}
|
|
548
|
+
function generateSuggestion(code, issue, receivedValue) {
|
|
549
|
+
const issueAny = issue;
|
|
550
|
+
switch (code) {
|
|
551
|
+
case "invalid_type": {
|
|
552
|
+
const expected = issueAny.expected;
|
|
553
|
+
const received = issueAny.received;
|
|
554
|
+
if (expected === "number" && typeof receivedValue === "string") {
|
|
555
|
+
return `Convert to number: ${Number(receivedValue)}`;
|
|
556
|
+
}
|
|
557
|
+
if (expected === "string") {
|
|
558
|
+
return `Wrap in quotes or call String(...)`;
|
|
559
|
+
}
|
|
560
|
+
if (expected === "array") {
|
|
561
|
+
return `Wrap in array: [${JSON.stringify(receivedValue)}]`;
|
|
562
|
+
}
|
|
563
|
+
if (expected === "object") {
|
|
564
|
+
return `Provide an object, not a primitive`;
|
|
565
|
+
}
|
|
566
|
+
return `Convert value to ${expected ?? "the expected type"}`;
|
|
567
|
+
}
|
|
568
|
+
case "invalid_enum_value": {
|
|
569
|
+
const options = issueAny.options;
|
|
570
|
+
const optionsStr = Array.isArray(options)
|
|
571
|
+
? options.map((v) => JSON.stringify(v)).join(" | ")
|
|
572
|
+
: String(options);
|
|
573
|
+
return `Use one of: ${optionsStr}`;
|
|
574
|
+
}
|
|
575
|
+
case "invalid_literal": {
|
|
576
|
+
const expected = issueAny.expected;
|
|
577
|
+
return `Use the exact value: ${JSON.stringify(expected)}`;
|
|
578
|
+
}
|
|
579
|
+
case "too_small": {
|
|
580
|
+
const minimum = issueAny.minimum;
|
|
581
|
+
const type = issueAny.type;
|
|
582
|
+
if (type === "array") {
|
|
583
|
+
return `Add at least ${minimum} element(s) to the array`;
|
|
584
|
+
}
|
|
585
|
+
if (type === "string") {
|
|
586
|
+
return `String must be at least ${minimum} character(s) long`;
|
|
587
|
+
}
|
|
588
|
+
if (type === "number") {
|
|
589
|
+
return `Use a value >= ${minimum}`;
|
|
590
|
+
}
|
|
591
|
+
return `Value must be >= ${minimum}`;
|
|
592
|
+
}
|
|
593
|
+
case "too_big": {
|
|
594
|
+
const maximum = issueAny.maximum;
|
|
595
|
+
const type = issueAny.type;
|
|
596
|
+
if (type === "array") {
|
|
597
|
+
return `Reduce array to at most ${maximum} element(s)`;
|
|
598
|
+
}
|
|
599
|
+
if (type === "string") {
|
|
600
|
+
return `Shorten string to at most ${maximum} character(s)`;
|
|
601
|
+
}
|
|
602
|
+
if (type === "number") {
|
|
603
|
+
return `Use a value <= ${maximum}`;
|
|
604
|
+
}
|
|
605
|
+
return `Value must be <= ${maximum}`;
|
|
606
|
+
}
|
|
607
|
+
case "unrecognized_keys": {
|
|
608
|
+
const keys = issueAny.keys;
|
|
609
|
+
return `Remove unknown field(s): ${(keys ?? []).join(", ")}. Check the schema for valid field names.`;
|
|
610
|
+
}
|
|
611
|
+
case "invalid_union": {
|
|
612
|
+
return `Value does not match any of the union variants. Check the schema for valid shapes.`;
|
|
613
|
+
}
|
|
614
|
+
case "invalid_string": {
|
|
615
|
+
const validation = issueAny.validation;
|
|
616
|
+
if (validation === "url")
|
|
617
|
+
return `Provide a valid URL string`;
|
|
618
|
+
if (validation === "email")
|
|
619
|
+
return `Provide a valid email string`;
|
|
620
|
+
if (validation === "uuid")
|
|
621
|
+
return `Provide a valid UUID string`;
|
|
622
|
+
if (validation === "regex")
|
|
623
|
+
return `String does not match the required pattern`;
|
|
624
|
+
return `Provide a valid string matching the validation: ${validation ?? "unknown"}`;
|
|
625
|
+
}
|
|
626
|
+
case "invalid_date": {
|
|
627
|
+
return `Provide a valid Date object or ISO date string`;
|
|
628
|
+
}
|
|
629
|
+
case "not_finite": {
|
|
630
|
+
return `Use a finite number (not Infinity or NaN)`;
|
|
631
|
+
}
|
|
632
|
+
case "invalid_arguments": {
|
|
633
|
+
return `Arguments do not match the expected schema`;
|
|
634
|
+
}
|
|
635
|
+
case "invalid_return_type": {
|
|
636
|
+
return `Return type does not match the expected schema`;
|
|
637
|
+
}
|
|
638
|
+
case "custom": {
|
|
639
|
+
return `Custom validation failed — see the field's description in the schema`;
|
|
640
|
+
}
|
|
641
|
+
default: {
|
|
642
|
+
return `Fix the value at '${issue.path.join(".")}' based on the schema`;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
function formatZodErrorsStructured(error, input) {
|
|
647
|
+
return error.issues.map(issue => {
|
|
648
|
+
const path = issue.path.length > 0
|
|
649
|
+
? issue.path.map(p => typeof p === "number" ? `[${p}]` : p).join(".").replace(".[", "[")
|
|
650
|
+
: "(root)";
|
|
651
|
+
const code = issue.code;
|
|
652
|
+
const message = issue.message;
|
|
653
|
+
const issueAny = issue;
|
|
654
|
+
let expected;
|
|
655
|
+
if (code === "invalid_type") {
|
|
656
|
+
const exp = issueAny.expected;
|
|
657
|
+
const rec = issueAny.received;
|
|
658
|
+
if (typeof exp === "string" && typeof rec === "string") {
|
|
659
|
+
expected = exp;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
else if (code === "invalid_literal") {
|
|
663
|
+
const exp = issueAny.expected;
|
|
664
|
+
if (exp !== undefined) {
|
|
665
|
+
expected = typeof exp === "string" ? exp : JSON.stringify(exp);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
else if (code === "invalid_enum_value") {
|
|
669
|
+
const options = issueAny.options;
|
|
670
|
+
if (Array.isArray(options)) {
|
|
671
|
+
expected = options.map((v) => JSON.stringify(v)).join(" | ");
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
else if (code === "too_big" || code === "too_small") {
|
|
675
|
+
const threshold = issueAny.maximum ?? issueAny.minimum;
|
|
676
|
+
if (threshold !== undefined) {
|
|
677
|
+
expected = String(threshold);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
const receivedVal = extractValueAtPath(input, issue.path);
|
|
681
|
+
const suggestion = generateSuggestion(code, issue, receivedVal);
|
|
682
|
+
return {
|
|
683
|
+
path,
|
|
684
|
+
code,
|
|
685
|
+
message,
|
|
686
|
+
expected,
|
|
687
|
+
received_value: receivedVal,
|
|
688
|
+
suggestion,
|
|
689
|
+
};
|
|
690
|
+
});
|
|
691
|
+
}
|
|
548
692
|
function extractValueAtPath(input, path) {
|
|
549
693
|
if (input === undefined || input === null || path.length === 0) {
|
|
550
694
|
return undefined;
|
|
@@ -837,18 +981,36 @@ async function handleWowok(args) {
|
|
|
837
981
|
if (unknownFields.length > 0) {
|
|
838
982
|
allErrors.push(`Unknown field(s): ${unknownFields.join(", ")}`);
|
|
839
983
|
}
|
|
984
|
+
const structuredErrors = [];
|
|
985
|
+
if (!validationResult.success) {
|
|
986
|
+
structuredErrors.push(...formatZodErrorsStructured(validationResult.error, normalizedData));
|
|
987
|
+
}
|
|
988
|
+
if (unknownFields.length > 0) {
|
|
989
|
+
for (const f of unknownFields) {
|
|
990
|
+
structuredErrors.push({
|
|
991
|
+
path: f,
|
|
992
|
+
code: "unrecognized_keys",
|
|
993
|
+
message: `Unknown field '${f}' is not allowed`,
|
|
994
|
+
suggestion: `Remove field '${f}' or check the schema for valid field names`,
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}
|
|
840
998
|
const fullSchema = loadPreGeneratedSchema(normalizedToolName) ?? zodToJsonSchemaSafe(entry.config.inputSchema, normalizedToolName);
|
|
841
999
|
const relevantSchema = extractRelevantSchema(fullSchema, normalizedToolName, normalizedData);
|
|
1000
|
+
const firstSuggestion = structuredErrors[0]?.suggestion
|
|
1001
|
+
? ` FIRST ERROR SUGGESTION: ${structuredErrors[0].suggestion}`
|
|
1002
|
+
: '';
|
|
842
1003
|
const errorPreview = allErrors.slice(0, 5).map((e, i) => ` ${i + 1}. ${e}`).join("\n");
|
|
843
1004
|
const schemaPreview = buildSchemaPreview(relevantSchema, normalizedToolName, normalizedData);
|
|
844
1005
|
const textContent = [
|
|
845
|
-
`Schema mismatch for ${normalizedToolName}. ${allErrors.length} error(s)
|
|
1006
|
+
`Schema mismatch for ${normalizedToolName}. ${allErrors.length} error(s).${firstSuggestion}`,
|
|
846
1007
|
errorPreview,
|
|
847
1008
|
"",
|
|
848
1009
|
schemaPreview,
|
|
849
1010
|
"",
|
|
850
1011
|
"Fix the parameters based on the errors above and the schema summary, then retry.",
|
|
851
1012
|
`Full JSON Schema is in the structuredContent.schema.input field (cache it for future ${normalizedToolName} calls).`,
|
|
1013
|
+
`Structured errors with fix suggestions are in structuredContent.result.structured_errors (ARCH-02).`,
|
|
852
1014
|
].filter(Boolean).join("\n");
|
|
853
1015
|
return {
|
|
854
1016
|
content: [{
|
|
@@ -859,6 +1021,7 @@ async function handleWowok(args) {
|
|
|
859
1021
|
result: {
|
|
860
1022
|
status: "schema_mismatch",
|
|
861
1023
|
errors: allErrors,
|
|
1024
|
+
structured_errors: structuredErrors,
|
|
862
1025
|
hint: `Fix your parameters based on the schema below and retry. CACHE THIS SCHEMA for future ${normalizedToolName} calls — you don't need to query it again.`,
|
|
863
1026
|
},
|
|
864
1027
|
schema: {
|
|
@@ -903,12 +1066,19 @@ async function handleWowok(args) {
|
|
|
903
1066
|
const fullSchema = loadPreGeneratedSchema(normalizedToolName) ?? zodToJsonSchemaSafe(entry.config.inputSchema, normalizedToolName);
|
|
904
1067
|
const relevantSchema = extractRelevantSchema(fullSchema, normalizedToolName, normalizedData);
|
|
905
1068
|
const schemaPreview = buildSchemaPreview(relevantSchema, normalizedToolName, normalizedData);
|
|
1069
|
+
const structuredErrors = [{
|
|
1070
|
+
path: "(runtime)",
|
|
1071
|
+
code: "schema_validation_error",
|
|
1072
|
+
message: errorMessage,
|
|
1073
|
+
suggestion: "Check the error message and the schema below for the correct field format",
|
|
1074
|
+
}];
|
|
906
1075
|
const textContent = [
|
|
907
1076
|
`Schema mismatch for ${normalizedToolName}: ${errorMessage}`,
|
|
908
1077
|
"",
|
|
909
1078
|
schemaPreview,
|
|
910
1079
|
"",
|
|
911
1080
|
"Fix the parameters and retry. Full JSON Schema is in structuredContent.schema.input.",
|
|
1081
|
+
"Structured errors with fix suggestions are in structuredContent.result.structured_errors (ARCH-02).",
|
|
912
1082
|
].join("\n");
|
|
913
1083
|
return {
|
|
914
1084
|
content: [{
|
|
@@ -919,6 +1089,7 @@ async function handleWowok(args) {
|
|
|
919
1089
|
result: {
|
|
920
1090
|
status: "schema_mismatch",
|
|
921
1091
|
errors: [errorMessage],
|
|
1092
|
+
structured_errors: structuredErrors,
|
|
922
1093
|
hint: `Fix your parameters based on the schema below and retry. CACHE THIS SCHEMA for future ${normalizedToolName} calls.`,
|
|
923
1094
|
},
|
|
924
1095
|
schema: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wowok/agent-mcp",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"license": "Apache-2.0",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
53
|
-
"@wowok/wowok": "2.6.
|
|
53
|
+
"@wowok/wowok": "2.6.3",
|
|
54
54
|
"lodash": "^4.18.1",
|
|
55
55
|
"zod": "^3.25.76",
|
|
56
56
|
"zod-to-json-schema": "^3.25.2"
|