@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
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const SchemaQueryInputSchema: z.ZodObject<{
|
|
3
|
-
action: z.ZodEnum<["list", "get", "get_output", "search", "list_operations", "get_guard_templates", "get_field"]>;
|
|
3
|
+
action: z.ZodEnum<["list", "get", "get_output", "search", "list_operations", "get_guard_templates", "get_field", "search_examples"]>;
|
|
4
4
|
name: z.ZodOptional<z.ZodString>;
|
|
5
5
|
query: z.ZodOptional<z.ZodString>;
|
|
6
6
|
field_path: z.ZodOptional<z.ZodString>;
|
|
7
7
|
template: z.ZodOptional<z.ZodString>;
|
|
8
8
|
output_file: z.ZodOptional<z.ZodString>;
|
|
9
9
|
}, "strict", z.ZodTypeAny, {
|
|
10
|
-
action: "get" | "search" | "list" | "get_output" | "list_operations" | "get_guard_templates" | "get_field";
|
|
10
|
+
action: "get" | "search" | "list" | "get_output" | "list_operations" | "get_guard_templates" | "get_field" | "search_examples";
|
|
11
11
|
name?: string | undefined;
|
|
12
12
|
query?: string | undefined;
|
|
13
13
|
field_path?: string | undefined;
|
|
14
14
|
template?: string | undefined;
|
|
15
15
|
output_file?: string | undefined;
|
|
16
16
|
}, {
|
|
17
|
-
action: "get" | "search" | "list" | "get_output" | "list_operations" | "get_guard_templates" | "get_field";
|
|
17
|
+
action: "get" | "search" | "list" | "get_output" | "list_operations" | "get_guard_templates" | "get_field" | "search_examples";
|
|
18
18
|
name?: string | undefined;
|
|
19
19
|
query?: string | undefined;
|
|
20
20
|
field_path?: string | undefined;
|
|
@@ -36,6 +36,36 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
36
36
|
name: string;
|
|
37
37
|
description?: string | undefined;
|
|
38
38
|
title?: string | undefined;
|
|
39
|
+
}>, "many">, z.ZodArray<z.ZodObject<{
|
|
40
|
+
file: z.ZodString;
|
|
41
|
+
title: z.ZodString;
|
|
42
|
+
description: z.ZodString;
|
|
43
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
44
|
+
industry: z.ZodString;
|
|
45
|
+
operation_type: z.ZodString;
|
|
46
|
+
verified: z.ZodBoolean;
|
|
47
|
+
score: z.ZodNumber;
|
|
48
|
+
matched_fields: z.ZodArray<z.ZodString, "many">;
|
|
49
|
+
}, "strict", z.ZodTypeAny, {
|
|
50
|
+
description: string;
|
|
51
|
+
title: string;
|
|
52
|
+
score: number;
|
|
53
|
+
tags: string[];
|
|
54
|
+
file: string;
|
|
55
|
+
industry: string;
|
|
56
|
+
operation_type: string;
|
|
57
|
+
verified: boolean;
|
|
58
|
+
matched_fields: string[];
|
|
59
|
+
}, {
|
|
60
|
+
description: string;
|
|
61
|
+
title: string;
|
|
62
|
+
score: number;
|
|
63
|
+
tags: string[];
|
|
64
|
+
file: string;
|
|
65
|
+
industry: string;
|
|
66
|
+
operation_type: string;
|
|
67
|
+
verified: boolean;
|
|
68
|
+
matched_fields: string[];
|
|
39
69
|
}>, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodNull]>;
|
|
40
70
|
message: z.ZodString;
|
|
41
71
|
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -46,6 +76,16 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
46
76
|
name: string;
|
|
47
77
|
description?: string | undefined;
|
|
48
78
|
title?: string | undefined;
|
|
79
|
+
}[] | {
|
|
80
|
+
description: string;
|
|
81
|
+
title: string;
|
|
82
|
+
score: number;
|
|
83
|
+
tags: string[];
|
|
84
|
+
file: string;
|
|
85
|
+
industry: string;
|
|
86
|
+
operation_type: string;
|
|
87
|
+
verified: boolean;
|
|
88
|
+
matched_fields: string[];
|
|
49
89
|
}[] | null;
|
|
50
90
|
success: boolean;
|
|
51
91
|
action: string;
|
|
@@ -57,6 +97,16 @@ export declare const SchemaQueryOutputSchema: z.ZodObject<{
|
|
|
57
97
|
name: string;
|
|
58
98
|
description?: string | undefined;
|
|
59
99
|
title?: string | undefined;
|
|
100
|
+
}[] | {
|
|
101
|
+
description: string;
|
|
102
|
+
title: string;
|
|
103
|
+
score: number;
|
|
104
|
+
tags: string[];
|
|
105
|
+
file: string;
|
|
106
|
+
industry: string;
|
|
107
|
+
operation_type: string;
|
|
108
|
+
verified: boolean;
|
|
109
|
+
matched_fields: string[];
|
|
60
110
|
}[] | null;
|
|
61
111
|
success: boolean;
|
|
62
112
|
action: string;
|
|
@@ -10,8 +10,9 @@ export const SchemaQueryInputSchema = z
|
|
|
10
10
|
"list_operations",
|
|
11
11
|
"get_guard_templates",
|
|
12
12
|
"get_field",
|
|
13
|
+
"search_examples",
|
|
13
14
|
])
|
|
14
|
-
.describe("Action to perform: 'list' (all schemas), 'get' (specific input schema), 'get_output' (tool output schema), 'get_field' (field-path query e.g. field_path='data.node'), 'search' (by keyword), 'list_operations' (on-chain operations), 'get_guard_templates' (Guard creation templates + best practices)."),
|
|
15
|
+
.describe("Action to perform: 'list' (all schemas), 'get' (specific input schema), 'get_output' (tool output schema), 'get_field' (field-path query e.g. field_path='data.node'), 'search' (by keyword), 'list_operations' (on-chain operations), 'get_guard_templates' (Guard creation templates + best practices), 'search_examples' (search verified example files by keyword — matches title, description, tags, operation_type, industry)."),
|
|
15
16
|
name: z
|
|
16
17
|
.string()
|
|
17
18
|
.optional()
|
|
@@ -41,6 +42,19 @@ const SchemaListItemSchema = z
|
|
|
41
42
|
description: z.string().optional().describe("Short description, if known."),
|
|
42
43
|
})
|
|
43
44
|
.strict();
|
|
45
|
+
const ExampleSearchResultSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
file: z.string().describe("Example file name (e.g. 'rental-ziroom-service-create.json')."),
|
|
48
|
+
title: z.string().describe("Human-readable title from the example metadata."),
|
|
49
|
+
description: z.string().describe("Longer description from the example metadata."),
|
|
50
|
+
tags: z.array(z.string()).describe("Tags from the example metadata."),
|
|
51
|
+
industry: z.string().describe("Industry category (e.g. 'rental', 'retail', 'general')."),
|
|
52
|
+
operation_type: z.string().describe("Operation type (e.g. 'service', 'machine', 'guard', 'permission')."),
|
|
53
|
+
verified: z.boolean().describe("Whether the example is marked as verified."),
|
|
54
|
+
score: z.number().describe("Relevance score — number of fields that matched the query (0-5)."),
|
|
55
|
+
matched_fields: z.array(z.string()).describe("List of fields that matched the query."),
|
|
56
|
+
})
|
|
57
|
+
.strict();
|
|
44
58
|
export const SchemaQueryOutputSchema = z
|
|
45
59
|
.object({
|
|
46
60
|
success: z.boolean().describe("Whether the request was successful"),
|
|
@@ -48,10 +62,11 @@ export const SchemaQueryOutputSchema = z
|
|
|
48
62
|
data: z
|
|
49
63
|
.union([
|
|
50
64
|
z.array(SchemaListItemSchema).describe("List of schema summaries (list/search/list_operations)."),
|
|
65
|
+
z.array(ExampleSearchResultSchema).describe("List of matching examples (search_examples)."),
|
|
51
66
|
z.record(z.unknown()).describe("JSON Schema object (get/get_output/get_field) or Guard template data."),
|
|
52
67
|
z.null().describe("No data — lookup failed or returned nothing, or data was written to output_file."),
|
|
53
68
|
])
|
|
54
|
-
.describe("Response data — array of schema summaries for list-like actions, JSON Schema object for get/get_output/get_field, Guard template data for get_guard_templates, null on failure or when output_file is used."),
|
|
69
|
+
.describe("Response data — array of schema summaries for list-like actions, array of example results for search_examples, JSON Schema object for get/get_output/get_field, Guard template data for get_guard_templates, null on failure or when output_file is used."),
|
|
55
70
|
message: z.string().describe("Human-readable message describing the result"),
|
|
56
71
|
suggestions: z
|
|
57
72
|
.array(z.string())
|
|
@@ -249,6 +249,19 @@ export function parseMachineNodesFromText(text) {
|
|
|
249
249
|
if (errors.length > 0) {
|
|
250
250
|
return { success: false, errors };
|
|
251
251
|
}
|
|
252
|
+
const hasEntryForward = nodes.some(node => node.pairs.some(pair => pair.prev_node === ""));
|
|
253
|
+
if (!hasEntryForward) {
|
|
254
|
+
return {
|
|
255
|
+
success: false,
|
|
256
|
+
errors: [{
|
|
257
|
+
message: 'Machine has no entry forward. At least one node must have a pair with prev_node="" (empty string), ' +
|
|
258
|
+
'which defines how Progress advances from the initial state (current="") to the first node. ' +
|
|
259
|
+
'Without an entry forward, the workflow will be permanently stuck. ' +
|
|
260
|
+
'Example: {name: "Subscribed", pairs: [{prev_node: "", forwards: [{name: "Subscribe", weight: 1}]}]}',
|
|
261
|
+
path: '/',
|
|
262
|
+
}]
|
|
263
|
+
};
|
|
264
|
+
}
|
|
252
265
|
return { success: true, data: nodes, errors: [] };
|
|
253
266
|
}
|
|
254
267
|
export function formatNodeErrors(errors) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function shortTypeName(objectType: string | null | undefined): string;
|
|
2
|
+
export declare function normalizeObjectType(objectType: string | null | undefined): string;
|
|
3
|
+
export declare function isObjectOfType(objectType: string | null | undefined, expectedShortName: string): boolean;
|
|
4
|
+
export declare function groupObjectsByType<T extends {
|
|
5
|
+
objectType: string | null;
|
|
6
|
+
}>(objects: T[]): Map<string, T[]>;
|
|
7
|
+
export declare function findObjectByType<T extends {
|
|
8
|
+
objectType: string | null;
|
|
9
|
+
}>(objects: T[], expectedShortName: string): T | undefined;
|
|
10
|
+
export declare function countObjectsByType<T extends {
|
|
11
|
+
objectType: string | null;
|
|
12
|
+
}>(objects: T[], expectedShortName: string): number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function shortTypeName(objectType) {
|
|
2
|
+
if (!objectType)
|
|
3
|
+
return "unknown";
|
|
4
|
+
const base = objectType.replace(/<.*>/, "").trim();
|
|
5
|
+
const segments = base.split("::");
|
|
6
|
+
const shortName = segments[segments.length - 1] || "unknown";
|
|
7
|
+
if (shortName.length > 0 && shortName === shortName.toLowerCase()) {
|
|
8
|
+
return shortName.charAt(0).toUpperCase() + shortName.slice(1);
|
|
9
|
+
}
|
|
10
|
+
return shortName;
|
|
11
|
+
}
|
|
12
|
+
export function normalizeObjectType(objectType) {
|
|
13
|
+
return shortTypeName(objectType).toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
export function isObjectOfType(objectType, expectedShortName) {
|
|
16
|
+
const normalized = normalizeObjectType(objectType);
|
|
17
|
+
const expected = expectedShortName.toLowerCase();
|
|
18
|
+
return normalized === expected;
|
|
19
|
+
}
|
|
20
|
+
export function groupObjectsByType(objects) {
|
|
21
|
+
const byType = new Map();
|
|
22
|
+
for (const obj of objects) {
|
|
23
|
+
const t = shortTypeName(obj.objectType);
|
|
24
|
+
if (!byType.has(t))
|
|
25
|
+
byType.set(t, []);
|
|
26
|
+
byType.get(t).push(obj);
|
|
27
|
+
}
|
|
28
|
+
return byType;
|
|
29
|
+
}
|
|
30
|
+
export function findObjectByType(objects, expectedShortName) {
|
|
31
|
+
return objects.find(o => isObjectOfType(o.objectType, expectedShortName));
|
|
32
|
+
}
|
|
33
|
+
export function countObjectsByType(objects, expectedShortName) {
|
|
34
|
+
return objects.filter(o => isObjectOfType(o.objectType, expectedShortName)).length;
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface ForwardPermissionRef {
|
|
2
|
+
nodeName: string;
|
|
3
|
+
prevNode: string;
|
|
4
|
+
forwardName: string;
|
|
5
|
+
permissionIndex: number | null;
|
|
6
|
+
namedOperator: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface PermissionRefCollection {
|
|
9
|
+
indexRefs: ForwardPermissionRef[];
|
|
10
|
+
namedRefs: ForwardPermissionRef[];
|
|
11
|
+
missingRefs: ForwardPermissionRef[];
|
|
12
|
+
requiredIndexes: number[];
|
|
13
|
+
}
|
|
14
|
+
export interface IndexAuthorizationStatus {
|
|
15
|
+
index: number;
|
|
16
|
+
authorized: boolean;
|
|
17
|
+
entityCount: number;
|
|
18
|
+
}
|
|
19
|
+
export interface PermissionAuthorizationReport {
|
|
20
|
+
statuses: IndexAuthorizationStatus[];
|
|
21
|
+
missingIndexes: number[];
|
|
22
|
+
authorizedIndexes: number[];
|
|
23
|
+
allAuthorized: boolean;
|
|
24
|
+
summary: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function collectPermissionIndexes(nodes: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
pairs?: Array<{
|
|
29
|
+
prev_node: string;
|
|
30
|
+
forwards?: Array<{
|
|
31
|
+
name: string;
|
|
32
|
+
permissionIndex?: number | null;
|
|
33
|
+
namedOperator?: string | null;
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
36
|
+
}>): PermissionRefCollection;
|
|
37
|
+
export interface PermissionObjectData {
|
|
38
|
+
address?: string;
|
|
39
|
+
entity_count?: number;
|
|
40
|
+
perm_remark?: Array<{
|
|
41
|
+
index: number;
|
|
42
|
+
remark: string;
|
|
43
|
+
}>;
|
|
44
|
+
entityPermissions?: Map<string, number[]>;
|
|
45
|
+
owner?: string;
|
|
46
|
+
admin?: string[];
|
|
47
|
+
}
|
|
48
|
+
export declare function checkPermissionAuthorization(requiredIndexes: number[], permission: PermissionObjectData | null | undefined): PermissionAuthorizationReport;
|
|
49
|
+
export declare function formatPermissionWarning(report: PermissionAuthorizationReport): string;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export function collectPermissionIndexes(nodes) {
|
|
2
|
+
const indexRefs = [];
|
|
3
|
+
const namedRefs = [];
|
|
4
|
+
const missingRefs = [];
|
|
5
|
+
const requiredIndexSet = new Set();
|
|
6
|
+
for (const node of nodes) {
|
|
7
|
+
if (!node.pairs)
|
|
8
|
+
continue;
|
|
9
|
+
for (const pair of node.pairs) {
|
|
10
|
+
if (!pair.forwards)
|
|
11
|
+
continue;
|
|
12
|
+
for (const forward of pair.forwards) {
|
|
13
|
+
const ref = {
|
|
14
|
+
nodeName: node.name,
|
|
15
|
+
prevNode: pair.prev_node,
|
|
16
|
+
forwardName: forward.name,
|
|
17
|
+
permissionIndex: forward.permissionIndex ?? null,
|
|
18
|
+
namedOperator: forward.namedOperator ?? null,
|
|
19
|
+
};
|
|
20
|
+
if (ref.permissionIndex != null) {
|
|
21
|
+
indexRefs.push(ref);
|
|
22
|
+
requiredIndexSet.add(ref.permissionIndex);
|
|
23
|
+
}
|
|
24
|
+
else if (ref.namedOperator != null && ref.namedOperator !== "") {
|
|
25
|
+
namedRefs.push(ref);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
missingRefs.push(ref);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
indexRefs,
|
|
35
|
+
namedRefs,
|
|
36
|
+
missingRefs,
|
|
37
|
+
requiredIndexes: Array.from(requiredIndexSet).sort((a, b) => a - b),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function checkPermissionAuthorization(requiredIndexes, permission) {
|
|
41
|
+
const BUILTIN_THRESHOLD = 1000;
|
|
42
|
+
const statuses = [];
|
|
43
|
+
const missingIndexes = [];
|
|
44
|
+
const authorizedIndexes = [];
|
|
45
|
+
for (const index of requiredIndexes) {
|
|
46
|
+
if (index < BUILTIN_THRESHOLD) {
|
|
47
|
+
statuses.push({ index, authorized: true, entityCount: -1 });
|
|
48
|
+
authorizedIndexes.push(index);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
let authorized = false;
|
|
52
|
+
let entityCount = 0;
|
|
53
|
+
if (permission?.entityPermissions) {
|
|
54
|
+
for (const perms of permission.entityPermissions.values()) {
|
|
55
|
+
if (perms.includes(index)) {
|
|
56
|
+
entityCount++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
authorized = entityCount > 0;
|
|
60
|
+
}
|
|
61
|
+
else if (permission?.perm_remark && permission.perm_remark.length > 0) {
|
|
62
|
+
authorized = permission.perm_remark.some(r => r.index === index);
|
|
63
|
+
entityCount = authorized ? -1 : 0;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
authorized = true;
|
|
67
|
+
entityCount = -1;
|
|
68
|
+
}
|
|
69
|
+
statuses.push({ index, authorized, entityCount });
|
|
70
|
+
if (authorized) {
|
|
71
|
+
authorizedIndexes.push(index);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
missingIndexes.push(index);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const allAuthorized = missingIndexes.length === 0;
|
|
78
|
+
const summary = allAuthorized
|
|
79
|
+
? `All ${requiredIndexes.length} required permission index(es) are authorized.`
|
|
80
|
+
: `${missingIndexes.length}/${requiredIndexes.length} required permission index(es) are NOT authorized: [${missingIndexes.join(", ")}]. ` +
|
|
81
|
+
`Forwards using these indexes will be un-executable — Progress will be stuck. ` +
|
|
82
|
+
`Grant entities for these indexes via permission.op="add perm by index" before publishing the Machine.`;
|
|
83
|
+
return {
|
|
84
|
+
statuses,
|
|
85
|
+
missingIndexes,
|
|
86
|
+
authorizedIndexes,
|
|
87
|
+
allAuthorized,
|
|
88
|
+
summary,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function formatPermissionWarning(report) {
|
|
92
|
+
if (report.allAuthorized) {
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
const lines = [
|
|
96
|
+
"CRITICAL PRE-PUBLISH: Machine forwards reference permission indexes that are NOT authorized in the Permission object.",
|
|
97
|
+
"",
|
|
98
|
+
`Missing indexes (no entities granted): ${report.missingIndexes.join(", ")}`,
|
|
99
|
+
"",
|
|
100
|
+
"Impact: Forwards using these indexes can NEVER be executed — Progress will be permanently stuck at the source node.",
|
|
101
|
+
"Buyer funds may be trapped if the workflow cannot advance past the stuck node.",
|
|
102
|
+
"",
|
|
103
|
+
"To fix BEFORE publishing:",
|
|
104
|
+
' 1. Call onchain_operations with op="permission"',
|
|
105
|
+
' 2. Set object=<your_permission_name_or_address>',
|
|
106
|
+
' 3. Set permission.op="add perm by index"',
|
|
107
|
+
" 4. Set index=<missing_index> for each missing index",
|
|
108
|
+
' 5. Set entity=["<entity_address>"] — the address that should be authorized',
|
|
109
|
+
" 6. After granting all missing indexes, re-attempt the Machine publish.",
|
|
110
|
+
"",
|
|
111
|
+
"Required permission indexes for this Machine:",
|
|
112
|
+
];
|
|
113
|
+
for (const status of report.statuses) {
|
|
114
|
+
const state = status.authorized ? "AUTHORIZED" : "MISSING";
|
|
115
|
+
const count = status.entityCount === -1
|
|
116
|
+
? "(built-in or heuristic)"
|
|
117
|
+
: `(${status.entityCount} entity/entities)`;
|
|
118
|
+
lines.push(` - Index ${status.index}: ${state} ${count}`);
|
|
119
|
+
}
|
|
120
|
+
return lines.join("\n");
|
|
121
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const SKILLS_BY_OPERATION_TYPE = {
|
|
2
|
+
service: ["wowok-provider", "wowok-safety"],
|
|
3
|
+
machine: ["wowok-machine"],
|
|
4
|
+
guard: ["wowok-guard"],
|
|
5
|
+
arbitration: ["wowok-arbitrator"],
|
|
6
|
+
allocation: ["wowok-provider"],
|
|
7
|
+
permission: ["wowok-safety"],
|
|
8
|
+
treasury: ["wowok-provider", "wowok-safety"],
|
|
9
|
+
reward: ["wowok-provider"],
|
|
10
|
+
repository: ["wowok-provider"],
|
|
11
|
+
demand: ["wowok-provider"],
|
|
12
|
+
contact: ["wowok-messenger"],
|
|
13
|
+
order: ["wowok-order"],
|
|
14
|
+
progress: [],
|
|
15
|
+
personal: [],
|
|
16
|
+
payment: [],
|
|
17
|
+
proof: [],
|
|
18
|
+
};
|
|
19
|
+
const SKILLS_BY_PROJECT_ACTION = {
|
|
20
|
+
create_project: ["wowok-onboard", "wowok-planner"],
|
|
21
|
+
create_project_from_onchain: ["wowok-onboard"],
|
|
22
|
+
evaluate_project: ["wowok-auditor"],
|
|
23
|
+
pre_evaluate_check: ["wowok-auditor"],
|
|
24
|
+
verify_deployment: ["wowok-auditor"],
|
|
25
|
+
generate_deployment_doc: ["wowok-planner"],
|
|
26
|
+
migrate_to_mainnet: ["wowok-onboard", "wowok-safety"],
|
|
27
|
+
migrate_network: ["wowok-onboard"],
|
|
28
|
+
clone_project_to_network: ["wowok-onboard"],
|
|
29
|
+
build_graph: ["wowok-planner"],
|
|
30
|
+
list_projects: [],
|
|
31
|
+
get_project_detail: [],
|
|
32
|
+
update_project: [],
|
|
33
|
+
add_object: [],
|
|
34
|
+
remove_object: [],
|
|
35
|
+
update_object: [],
|
|
36
|
+
create_version: [],
|
|
37
|
+
get_graph: [],
|
|
38
|
+
save_evaluation: [],
|
|
39
|
+
compare_projects: [],
|
|
40
|
+
refresh_objects: [],
|
|
41
|
+
get_object_diff: [],
|
|
42
|
+
delete_project: [],
|
|
43
|
+
assemble_context: [],
|
|
44
|
+
get_machine_graph: ["wowok-machine"],
|
|
45
|
+
get_guard_graph: ["wowok-guard"],
|
|
46
|
+
plan_object_edit: ["wowok-machine", "wowok-guard", "wowok-auditor"],
|
|
47
|
+
apply_object_edit: ["wowok-safety"],
|
|
48
|
+
patch_machine_nodes: ["wowok-machine"],
|
|
49
|
+
patch_guard_tree: ["wowok-guard"],
|
|
50
|
+
};
|
|
51
|
+
export function getSkillsHintForOnchain(operationType, data) {
|
|
52
|
+
const skills = SKILLS_BY_OPERATION_TYPE[operationType];
|
|
53
|
+
if (!skills || skills.length === 0)
|
|
54
|
+
return undefined;
|
|
55
|
+
const isPublish = data?.publish === true;
|
|
56
|
+
const hasOrderAllocators = !!data?.order_allocators;
|
|
57
|
+
const isComplex = isPublish || hasOrderAllocators;
|
|
58
|
+
const prefix = isComplex
|
|
59
|
+
? "SKILLS RECOMMENDED (complex operation — skills provide business-semantic guidance):"
|
|
60
|
+
: "SKILLS RECOMMENDED (optional — skills provide deeper guidance):";
|
|
61
|
+
return `${prefix} ${skills.join(", ")}. ` +
|
|
62
|
+
`skills focus on business intent → object parameter translation; ` +
|
|
63
|
+
`MCP handles object structure and on-chain execution. ` +
|
|
64
|
+
`If skills are installed, consult them BEFORE this call for design rationale. ` +
|
|
65
|
+
`If not installed, MCP executes independently — this hint is informational only.`;
|
|
66
|
+
}
|
|
67
|
+
export function getSkillsHintForProject(action) {
|
|
68
|
+
const skills = SKILLS_BY_PROJECT_ACTION[action];
|
|
69
|
+
if (!skills || skills.length === 0)
|
|
70
|
+
return undefined;
|
|
71
|
+
return `SKILLS RECOMMENDED (optional — skills provide deeper guidance): ${skills.join(", ")}. ` +
|
|
72
|
+
`skills focus on business intent → object parameter translation; ` +
|
|
73
|
+
`MCP handles project structure and evaluation. ` +
|
|
74
|
+
`If skills are installed, consult them for design/planning rationale. ` +
|
|
75
|
+
`If not installed, MCP executes independently — this hint is informational only.`;
|
|
76
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const EXAMPLES_DIR: string;
|
|
1
2
|
export interface SchemaInfo {
|
|
2
3
|
name: string;
|
|
3
4
|
title: string;
|
|
@@ -6,13 +7,24 @@ export interface SchemaInfo {
|
|
|
6
7
|
outputPath?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface SchemaQueryRequest {
|
|
9
|
-
action: "list" | "get" | "search" | "list_operations" | "get_output" | "get_guard_templates" | "get_field";
|
|
10
|
+
action: "list" | "get" | "search" | "list_operations" | "get_output" | "get_guard_templates" | "get_field" | "search_examples";
|
|
10
11
|
name?: string;
|
|
11
12
|
query?: string;
|
|
12
13
|
field_path?: string;
|
|
13
14
|
template?: string;
|
|
14
15
|
output_file?: string;
|
|
15
16
|
}
|
|
17
|
+
export interface ExampleSearchResult {
|
|
18
|
+
file: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
tags: string[];
|
|
22
|
+
industry: string;
|
|
23
|
+
operation_type: string;
|
|
24
|
+
verified: boolean;
|
|
25
|
+
score: number;
|
|
26
|
+
matched_fields: string[];
|
|
27
|
+
}
|
|
16
28
|
export interface SchemaQueryResponse {
|
|
17
29
|
[key: string]: unknown;
|
|
18
30
|
success: boolean;
|
|
@@ -31,6 +43,7 @@ export declare function listSchemas(): SchemaInfo[];
|
|
|
31
43
|
export declare function getSchema(name: string): any | null;
|
|
32
44
|
export declare function getOutputSchema(name: string): any | null;
|
|
33
45
|
export declare function getGuardTemplates(templateName?: string): any | null;
|
|
46
|
+
export declare function searchExamples(query: string): ExampleSearchResult[];
|
|
34
47
|
export declare function getSchemaField(name: string, fieldPath: string): any | null;
|
|
35
48
|
export declare function searchSchemas(query: string): SchemaInfo[];
|
|
36
49
|
export declare function listOperations(): SchemaInfo[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
1
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync, readdirSync } from "fs";
|
|
2
2
|
import { resolve, join, dirname } from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -9,6 +9,11 @@ const GUARD_TEMPLATES_PATH_DIST = resolve(__dirname, "../../dist/schemas/guard-t
|
|
|
9
9
|
const GUARD_TEMPLATES_PATH = existsSync(GUARD_TEMPLATES_PATH_SCRIPTS)
|
|
10
10
|
? GUARD_TEMPLATES_PATH_SCRIPTS
|
|
11
11
|
: GUARD_TEMPLATES_PATH_DIST;
|
|
12
|
+
const EXAMPLES_DIR_SCRIPTS = resolve(__dirname, "../../scripts/examples");
|
|
13
|
+
const EXAMPLES_DIR_DIST = resolve(__dirname, "../examples");
|
|
14
|
+
export const EXAMPLES_DIR = existsSync(EXAMPLES_DIR_SCRIPTS)
|
|
15
|
+
? EXAMPLES_DIR_SCRIPTS
|
|
16
|
+
: EXAMPLES_DIR_DIST;
|
|
12
17
|
const WORKSPACE_TMP_DIR = resolve(process.cwd(), ".trae", "tmp");
|
|
13
18
|
export function areSchemasAvailable() {
|
|
14
19
|
return existsSync(SCHEMAS_DIR) && existsSync(join(SCHEMAS_DIR, "index.json"));
|
|
@@ -96,6 +101,75 @@ export function getGuardTemplates(templateName) {
|
|
|
96
101
|
return null;
|
|
97
102
|
}
|
|
98
103
|
}
|
|
104
|
+
export function searchExamples(query) {
|
|
105
|
+
if (!existsSync(EXAMPLES_DIR)) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
let files;
|
|
109
|
+
try {
|
|
110
|
+
files = readdirSync(EXAMPLES_DIR);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
116
|
+
if (!lowerQuery) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
const results = [];
|
|
120
|
+
for (const file of files) {
|
|
121
|
+
if (!file.endsWith(".json"))
|
|
122
|
+
continue;
|
|
123
|
+
const filePath = join(EXAMPLES_DIR, file);
|
|
124
|
+
try {
|
|
125
|
+
const content = readFileSync(filePath, "utf-8");
|
|
126
|
+
const example = JSON.parse(content);
|
|
127
|
+
const title = String(example.title ?? "");
|
|
128
|
+
const description = String(example.description ?? "");
|
|
129
|
+
const tags = Array.isArray(example.tags) ? example.tags.map((t) => String(t)) : [];
|
|
130
|
+
const operationType = String(example.operation_type ?? "");
|
|
131
|
+
const industry = String(example.industry ?? "");
|
|
132
|
+
const matchedFields = [];
|
|
133
|
+
if (title.toLowerCase().includes(lowerQuery)) {
|
|
134
|
+
matchedFields.push("title");
|
|
135
|
+
}
|
|
136
|
+
if (description.toLowerCase().includes(lowerQuery)) {
|
|
137
|
+
matchedFields.push("description");
|
|
138
|
+
}
|
|
139
|
+
if (tags.some((t) => t.toLowerCase() === lowerQuery)) {
|
|
140
|
+
matchedFields.push("tags");
|
|
141
|
+
}
|
|
142
|
+
if (operationType && operationType.toLowerCase() === lowerQuery) {
|
|
143
|
+
matchedFields.push("operation_type");
|
|
144
|
+
}
|
|
145
|
+
if (industry && industry.toLowerCase() === lowerQuery) {
|
|
146
|
+
matchedFields.push("industry");
|
|
147
|
+
}
|
|
148
|
+
if (matchedFields.length > 0) {
|
|
149
|
+
results.push({
|
|
150
|
+
file,
|
|
151
|
+
title,
|
|
152
|
+
description,
|
|
153
|
+
tags,
|
|
154
|
+
industry,
|
|
155
|
+
operation_type: operationType,
|
|
156
|
+
verified: example.verified === true,
|
|
157
|
+
score: matchedFields.length,
|
|
158
|
+
matched_fields: matchedFields,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
results.sort((a, b) => {
|
|
167
|
+
if (b.score !== a.score)
|
|
168
|
+
return b.score - a.score;
|
|
169
|
+
return a.file.localeCompare(b.file);
|
|
170
|
+
});
|
|
171
|
+
return results;
|
|
172
|
+
}
|
|
99
173
|
export function getSchemaField(name, fieldPath) {
|
|
100
174
|
const schema = getSchema(name);
|
|
101
175
|
if (!schema)
|
|
@@ -267,6 +341,34 @@ export function processSchemaQuery(request) {
|
|
|
267
341
|
: `Retrieved ${Array.isArray(templates.templates) ? templates.templates.length : 0} Guard templates`,
|
|
268
342
|
};
|
|
269
343
|
}
|
|
344
|
+
if (action === "search_examples") {
|
|
345
|
+
if (!query) {
|
|
346
|
+
return {
|
|
347
|
+
success: false,
|
|
348
|
+
action,
|
|
349
|
+
data: null,
|
|
350
|
+
message: "Search query is required for 'search_examples' action",
|
|
351
|
+
suggestions: [
|
|
352
|
+
"Provide a 'query' string (e.g. 'rental', 'guard', 'service', 'machine')",
|
|
353
|
+
"Searchable fields: title, description, tags, operation_type, industry",
|
|
354
|
+
],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const results = searchExamples(query);
|
|
358
|
+
return {
|
|
359
|
+
success: true,
|
|
360
|
+
action,
|
|
361
|
+
data: results,
|
|
362
|
+
message: `Found ${results.length} example(s) matching '${query}'`,
|
|
363
|
+
suggestions: results.length === 0
|
|
364
|
+
? [
|
|
365
|
+
"Try broader terms like 'service', 'machine', 'guard', 'permission'",
|
|
366
|
+
"Try an industry name: 'rental', 'retail', 'general'",
|
|
367
|
+
"Use 'get' action with a schema name to see the full JSON Schema",
|
|
368
|
+
]
|
|
369
|
+
: undefined,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
270
372
|
if (!areSchemasAvailable()) {
|
|
271
373
|
return {
|
|
272
374
|
success: false,
|
|
@@ -448,7 +550,7 @@ export function processSchemaQuery(request) {
|
|
|
448
550
|
action,
|
|
449
551
|
data: null,
|
|
450
552
|
message: `Unknown action: ${action}`,
|
|
451
|
-
suggestions: ["Use 'list', 'get', 'get_field', 'get_output', 'search', 'list_operations', or '
|
|
553
|
+
suggestions: ["Use 'list', 'get', 'get_field', 'get_output', 'search', 'list_operations', 'get_guard_templates', or 'search_examples'"],
|
|
452
554
|
};
|
|
453
555
|
}
|
|
454
556
|
}
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
"additionalProperties": false,
|
|
239
|
-
"description": "Account operations. Parameters MUST be wrapped in the operation type property (e.g. {transfer: {...}}, NOT {amount: ...}). Unwrapped parameters are rejected."
|
|
239
|
+
"description": "Account operations (mutations only: gen/faucet/suspend/resume/rename/swap_name/transfer/get/signData/messenger). Parameters MUST be wrapped in the operation type property (e.g. {transfer: {...}}, NOT {amount: ...}). Unwrapped parameters are rejected. TO LIST ALL ACCOUNTS: use the query_toolkit tool with query_type='account_list' (returns name, address, suspended status, messenger status for all local accounts). This separation follows CQRS: account_operation = mutations, query_toolkit = queries. Common workflow after MCP restart: (1) query_toolkit query_type='account_list' to see all accounts, (2) account_operation with the appropriate mutation."
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
}
|
package/dist/schemas/index.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"title": "WoWok MCP Schema Index",
|
|
4
4
|
"description": "Index of all available JSON schemas for WoWok MCP tools",
|
|
5
|
-
"generatedAt": "2026-07-
|
|
5
|
+
"generatedAt": "2026-07-29T00:14:19.691Z",
|
|
6
6
|
"tools": [
|
|
7
7
|
{
|
|
8
8
|
"name": "onchain_operations",
|