@wowok/agent-mcp 2.3.18 → 2.4.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/industry-risks.js +31 -31
- package/dist/customer/order-monitor.js +57 -57
- package/dist/customer/order-strategy.js +89 -89
- package/dist/customer/post-purchase.js +97 -97
- package/dist/customer/reminder-system.js +26 -26
- package/dist/customer/risk-assessment.js +46 -46
- package/dist/customer/types.d.ts +4 -4
- package/dist/customer/types.js +4 -4
- package/dist/customer/user-preferences.js +50 -50
- package/dist/experience/intent-distill.js +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -1624
- package/dist/knowledge/acquisition-flywheel.js +64 -64
- package/dist/knowledge/arbitration-trust.js +10 -10
- package/dist/knowledge/demand-matching.js +8 -8
- package/dist/knowledge/dynamic-pricing.js +18 -18
- package/dist/knowledge/flywheel-loop.js +11 -11
- package/dist/knowledge/glossary.js +22 -22
- package/dist/knowledge/guard-ledger.d.ts +1 -1
- package/dist/knowledge/guard-ledger.js +145 -104
- package/dist/knowledge/guard-lint.d.ts +77 -0
- package/dist/knowledge/guard-lint.js +670 -0
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -0
- package/dist/knowledge/guard-puzzle.d.ts +109 -14
- package/dist/knowledge/guard-puzzle.js +627 -101
- package/dist/knowledge/guard-risk.d.ts +10 -1
- package/dist/knowledge/guard-risk.js +1634 -292
- package/dist/knowledge/guard-templates.d.ts +38 -0
- package/dist/knowledge/guard-templates.js +605 -0
- package/dist/knowledge/guard-translation.d.ts +14 -2
- package/dist/knowledge/guard-translation.js +825 -194
- package/dist/knowledge/index.d.ts +8 -4
- package/dist/knowledge/index.js +9 -5
- package/dist/knowledge/industry-evolution.js +29 -29
- package/dist/knowledge/industry-generalizer.js +52 -52
- package/dist/knowledge/industry-registry.js +20 -33
- package/dist/knowledge/intent-metrics.js +67 -67
- package/dist/knowledge/process-model.js +80 -80
- package/dist/knowledge/reputation-rules.js +9 -9
- package/dist/knowledge/reward-templates.js +51 -51
- package/dist/knowledge/safety-rules.js +3 -3
- package/dist/knowledge/tool-constraints.js +20 -4
- package/dist/knowledge/trust-metrics.js +26 -26
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/graph.js +27 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +39 -2
- package/dist/project/namespace.d.ts +11 -1
- package/dist/project/namespace.js +27 -2
- package/dist/project/query.d.ts +2 -0
- package/dist/project/query.js +56 -15
- package/dist/rules.d.ts +12 -0
- package/dist/rules.js +9 -0
- package/dist/schema/call/allocation.d.ts +10 -10
- package/dist/schema/call/base.js +19 -19
- package/dist/schema/call/bridge.d.ts +32 -32
- package/dist/schema/call/demand.d.ts +84 -84
- package/dist/schema/call/guard.d.ts +153 -0
- package/dist/schema/call/guard.js +50 -0
- package/dist/schema/call/machine.d.ts +38 -38
- package/dist/schema/call/permission.d.ts +78 -78
- package/dist/schema/call/repository.d.ts +22 -22
- package/dist/schema/call/semantic.js +229 -25
- package/dist/schema/call/service.d.ts +7 -7
- package/dist/schema/local/wip.d.ts +39 -19
- package/dist/schema/local/wip.js +5 -5
- package/dist/schema/messenger/index.d.ts +26 -26
- package/dist/schema/messenger/index.js +2 -2
- package/dist/schema/operations.d.ts +270 -192
- package/dist/schema/query/index.d.ts +184 -184
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/trust/index.d.ts +4 -4
- package/dist/schema/utils/guard-parser.js +4 -4
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schema/utils/node-parser.js +14 -14
- package/dist/schemas/bridge_operation.output.json +15 -15
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.output.json +18 -16
- package/dist/schemas/onchain_events.output.json +15 -15
- package/dist/schemas/onchain_operations.output.json +16 -16
- package/dist/schemas/onchain_operations.schema.json +11 -20
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
- package/dist/schemas/onchain_operations_machine.schema.json +2 -5
- package/dist/schemas/onchain_operations_service.schema.json +2 -5
- package/dist/schemas/onchain_table_data.output.json +20 -26
- package/dist/schemas/wip_file.output.json +24 -1
- package/dist/tools/handlers/bridge.d.ts +1 -0
- package/dist/tools/handlers/bridge.js +1 -0
- package/dist/tools/handlers/config.d.ts +2 -0
- package/dist/tools/handlers/config.js +71 -0
- package/dist/tools/handlers/file-export.d.ts +3 -0
- package/dist/tools/handlers/file-export.js +90 -0
- package/dist/tools/handlers/local.d.ts +30 -0
- package/dist/tools/handlers/local.js +27 -0
- package/dist/tools/handlers/messenger.d.ts +16 -0
- package/dist/tools/handlers/messenger.js +187 -0
- package/dist/tools/handlers/onchain.d.ts +2 -0
- package/dist/tools/handlers/onchain.js +246 -0
- package/dist/tools/handlers/project.d.ts +2 -0
- package/dist/tools/handlers/project.js +53 -0
- package/dist/tools/handlers/query.d.ts +5 -0
- package/dist/tools/handlers/query.js +256 -0
- package/dist/tools/handlers/schema-query.d.ts +2 -0
- package/dist/tools/handlers/schema-query.js +92 -0
- package/dist/tools/handlers/trust.d.ts +2 -0
- package/dist/tools/handlers/trust.js +194 -0
- package/dist/tools/handlers/wip.d.ts +2 -0
- package/dist/tools/handlers/wip.js +44 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +479 -0
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +22 -0
- package/dist/tools/shared.d.ts +29 -0
- package/dist/tools/shared.js +130 -0
- package/dist/tools/types.d.ts +35 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/wrap.d.ts +6 -0
- package/dist/tools/wrap.js +55 -0
- package/package.json +19 -5
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, CallProof, gen_proof, parseGuardFile, formatGuardParseErrors, transformRewardInput, transformPersonalInput, } from "@wowok/wowok";
|
|
4
|
+
import { OnchainOperationsSchema, strictParse, getEnvConfig, handleCallResult, checkClientSchemaCompatibility, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, transformSubmission, } from "../../schema/index.js";
|
|
5
|
+
import { isProjectServiceEnabled, normalize as projectNormalize, } from "../../project/index.js";
|
|
6
|
+
import { withHarness } from "../shared.js";
|
|
7
|
+
export async function handleOnchainOperations(args) {
|
|
8
|
+
let validated;
|
|
9
|
+
let constraintWarnings = [];
|
|
10
|
+
let projectWarnings = [];
|
|
11
|
+
try {
|
|
12
|
+
if (typeof args === 'object' && args !== null && args.description && !args.operation_type) {
|
|
13
|
+
const hasWrappedParams = typeof args.description === 'string' &&
|
|
14
|
+
(args.description.includes('operation_type') || args.description.includes('data'));
|
|
15
|
+
if (hasWrappedParams) {
|
|
16
|
+
throw new Error("Invalid parameter structure. Parameters should NOT be wrapped in 'description' field.\n" +
|
|
17
|
+
"Correct format: { operation_type: '...', data: {...} }\n" +
|
|
18
|
+
"Incorrect format: { description: '{ operation_type: ... }' }");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
|
|
22
|
+
const env = getEnvConfig(validated.env);
|
|
23
|
+
const clientSchemaVersion = env?.client_schema_version;
|
|
24
|
+
const schemaStrictMode = env?.schema_strict_mode;
|
|
25
|
+
const schemaCheck = clientSchemaVersion
|
|
26
|
+
? checkClientSchemaCompatibility(clientSchemaVersion, { mode: schemaStrictMode ? "strict" : "warn" })
|
|
27
|
+
: undefined;
|
|
28
|
+
const buildCtx = (data) => ({
|
|
29
|
+
operation_type: validated.operation_type,
|
|
30
|
+
data,
|
|
31
|
+
pre_warnings: [...constraintWarnings, ...projectWarnings].length
|
|
32
|
+
? [...constraintWarnings, ...projectWarnings]
|
|
33
|
+
: undefined,
|
|
34
|
+
schema_check: schemaCheck,
|
|
35
|
+
});
|
|
36
|
+
const projectEnvPrefix = env?.project;
|
|
37
|
+
if (isProjectServiceEnabled()) {
|
|
38
|
+
const pn = projectNormalize({
|
|
39
|
+
operation_type: validated.operation_type,
|
|
40
|
+
data: validated.data,
|
|
41
|
+
projectPrefix: projectEnvPrefix,
|
|
42
|
+
});
|
|
43
|
+
validated.data = pn.data;
|
|
44
|
+
projectWarnings = pn.warnings ?? [];
|
|
45
|
+
}
|
|
46
|
+
if (env && typeof env === "object") {
|
|
47
|
+
delete env.confirmed;
|
|
48
|
+
delete env.user_intent_phrases;
|
|
49
|
+
delete env.project;
|
|
50
|
+
delete env.client_schema_version;
|
|
51
|
+
delete env.schema_strict_mode;
|
|
52
|
+
}
|
|
53
|
+
switch (validated.operation_type) {
|
|
54
|
+
case "service": {
|
|
55
|
+
const callService = new CallService(validated.data);
|
|
56
|
+
const result = validated.submission
|
|
57
|
+
? await callService.call_with_submission(env, await transformSubmission(validated.submission))
|
|
58
|
+
: await callService.call(env);
|
|
59
|
+
const data = validated.data;
|
|
60
|
+
const intent = data?.publish ? "publish service" : data?.bPublished !== undefined ? "modify service" : "create service";
|
|
61
|
+
return handleCallResult(result, withHarness(buildCtx(data), "service", intent));
|
|
62
|
+
}
|
|
63
|
+
case "machine": {
|
|
64
|
+
if (validated.data.node && typeof validated.data.node === 'object' && 'json_or_markdown_file' in validated.data.node) {
|
|
65
|
+
const filePathStr = validated.data.node.json_or_markdown_file;
|
|
66
|
+
let fileContent;
|
|
67
|
+
try {
|
|
68
|
+
const filePath = resolve(filePathStr);
|
|
69
|
+
fileContent = readFileSync(filePath, 'utf-8');
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
throw new Error(`Failed to read file '${filePathStr}': ${e.message}`);
|
|
73
|
+
}
|
|
74
|
+
const parseResult = parseMachineNodesFromText(fileContent);
|
|
75
|
+
if (!parseResult.success) {
|
|
76
|
+
const errorMessages = formatMachineNodeErrors(parseResult.errors);
|
|
77
|
+
throw new Error(`Machine node validation failed for file '${filePathStr}':\n\n${errorMessages}`);
|
|
78
|
+
}
|
|
79
|
+
if (!parseResult.data) {
|
|
80
|
+
throw new Error(`No nodes found in file '${filePathStr}'`);
|
|
81
|
+
}
|
|
82
|
+
validated.data.node = {
|
|
83
|
+
op: "set",
|
|
84
|
+
nodes: parseResult.data,
|
|
85
|
+
bReplace: true
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const callMachine = new CallMachine(validated.data);
|
|
89
|
+
const result = validated.submission
|
|
90
|
+
? await callMachine.call_with_submission(env, await transformSubmission(validated.submission))
|
|
91
|
+
: await callMachine.call(env);
|
|
92
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
93
|
+
}
|
|
94
|
+
case "progress": {
|
|
95
|
+
const callProgress = new CallProgress(validated.data);
|
|
96
|
+
const result = validated.submission
|
|
97
|
+
? await callProgress.call_with_submission(env, await transformSubmission(validated.submission))
|
|
98
|
+
: await callProgress.call(env);
|
|
99
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
100
|
+
}
|
|
101
|
+
case "repository": {
|
|
102
|
+
const callRepository = new CallRepository(validated.data);
|
|
103
|
+
const result = validated.submission
|
|
104
|
+
? await callRepository.call_with_submission(env, await transformSubmission(validated.submission))
|
|
105
|
+
: await callRepository.call(env);
|
|
106
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
107
|
+
}
|
|
108
|
+
case "arbitration": {
|
|
109
|
+
const callArbitration = new CallArbitration(validated.data);
|
|
110
|
+
const result = validated.submission
|
|
111
|
+
? await callArbitration.call_with_submission(env, await transformSubmission(validated.submission))
|
|
112
|
+
: await callArbitration.call(env);
|
|
113
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
114
|
+
}
|
|
115
|
+
case "contact": {
|
|
116
|
+
const callContact = new CallContact(validated.data);
|
|
117
|
+
const result = validated.submission
|
|
118
|
+
? await callContact.call_with_submission(env, await transformSubmission(validated.submission))
|
|
119
|
+
: await callContact.call(env);
|
|
120
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
121
|
+
}
|
|
122
|
+
case "treasury": {
|
|
123
|
+
const callTreasury = new CallTreasury(validated.data);
|
|
124
|
+
const result = validated.submission
|
|
125
|
+
? await callTreasury.call_with_submission(env, await transformSubmission(validated.submission))
|
|
126
|
+
: await callTreasury.call(env);
|
|
127
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
128
|
+
}
|
|
129
|
+
case "reward": {
|
|
130
|
+
const transformedData = transformRewardInput(validated.data);
|
|
131
|
+
const callReward = new CallReward(transformedData);
|
|
132
|
+
const result = validated.submission
|
|
133
|
+
? await callReward.call_with_submission(env, await transformSubmission(validated.submission))
|
|
134
|
+
: await callReward.call(env);
|
|
135
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
136
|
+
}
|
|
137
|
+
case "allocation": {
|
|
138
|
+
const callAllocation = new CallAllocation(validated.data);
|
|
139
|
+
const result = validated.submission
|
|
140
|
+
? await callAllocation.call_with_submission(env, await transformSubmission(validated.submission))
|
|
141
|
+
: await callAllocation.call(env);
|
|
142
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
143
|
+
}
|
|
144
|
+
case "permission": {
|
|
145
|
+
const callPermission = new CallPermission(validated.data);
|
|
146
|
+
const result = await callPermission.call(env);
|
|
147
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
148
|
+
}
|
|
149
|
+
case "guard": {
|
|
150
|
+
const validatedData = validated.data;
|
|
151
|
+
if (validatedData.root?.type === "file") {
|
|
152
|
+
const filePath = resolve(validatedData.root.file_path);
|
|
153
|
+
let fileContent;
|
|
154
|
+
try {
|
|
155
|
+
fileContent = readFileSync(filePath, 'utf-8');
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
throw new Error(`Failed to read Guard definition file '${validatedData.root.file_path}': ${e.message}`);
|
|
159
|
+
}
|
|
160
|
+
const parseResult = parseGuardFile(fileContent, validatedData.root.format);
|
|
161
|
+
if (!parseResult.success) {
|
|
162
|
+
const errorMessages = formatGuardParseErrors(parseResult.errors);
|
|
163
|
+
throw new Error(`Guard validation failed for file '${validatedData.root.file_path}':\n\n${errorMessages}`);
|
|
164
|
+
}
|
|
165
|
+
const fileData = parseResult.data;
|
|
166
|
+
validatedData.root = { type: "node", node: fileData.root };
|
|
167
|
+
if (fileData.table !== undefined && validatedData.table === undefined) {
|
|
168
|
+
validatedData.table = fileData.table;
|
|
169
|
+
}
|
|
170
|
+
if (fileData.description !== undefined && validatedData.description === undefined) {
|
|
171
|
+
validatedData.description = fileData.description;
|
|
172
|
+
}
|
|
173
|
+
if (fileData.rely !== undefined && validatedData.rely === undefined) {
|
|
174
|
+
validatedData.rely = fileData.rely;
|
|
175
|
+
}
|
|
176
|
+
if (fileData.namedNew !== undefined && validatedData.namedNew === undefined) {
|
|
177
|
+
validatedData.namedNew = fileData.namedNew;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (validatedData.root && typeof validatedData.root === 'object') {
|
|
181
|
+
const rootObj = validatedData.root;
|
|
182
|
+
if (rootObj.type === 'node' && rootObj.node) {
|
|
183
|
+
validatedData.root = rootObj.node;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (!validatedData.table || validatedData.table.length === 0) {
|
|
187
|
+
throw new Error("Guard 'table' field is required and cannot be empty");
|
|
188
|
+
}
|
|
189
|
+
if (!validatedData.root) {
|
|
190
|
+
throw new Error("Guard 'root' field is required");
|
|
191
|
+
}
|
|
192
|
+
const callGuard = new CallGuard(validatedData);
|
|
193
|
+
const result = await callGuard.call(env);
|
|
194
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
195
|
+
}
|
|
196
|
+
case "personal": {
|
|
197
|
+
const transformedData = transformPersonalInput(validated.data);
|
|
198
|
+
const callPersonal = new CallPersonal(transformedData);
|
|
199
|
+
const result = await callPersonal.call(env);
|
|
200
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
201
|
+
}
|
|
202
|
+
case "payment": {
|
|
203
|
+
const callPayment = new CallPayment(validated.data);
|
|
204
|
+
const result = await callPayment.call(env);
|
|
205
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
206
|
+
}
|
|
207
|
+
case "demand": {
|
|
208
|
+
const callDemand = new CallDemand(validated.data);
|
|
209
|
+
const result = validated.submission
|
|
210
|
+
? await callDemand.call_with_submission(env, await transformSubmission(validated.submission))
|
|
211
|
+
: await callDemand.call(env);
|
|
212
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
213
|
+
}
|
|
214
|
+
case "order": {
|
|
215
|
+
const callOrder = new CallOrder(validated.data);
|
|
216
|
+
const result = validated.submission
|
|
217
|
+
? await callOrder.call_with_submission(env, await transformSubmission(validated.submission))
|
|
218
|
+
: await callOrder.call(env);
|
|
219
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
220
|
+
}
|
|
221
|
+
case "gen_passport": {
|
|
222
|
+
const result = await gen_passport(env, validated.guard, validated.info);
|
|
223
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
224
|
+
}
|
|
225
|
+
case "proof": {
|
|
226
|
+
const callProof = new CallProof(validated.data);
|
|
227
|
+
const result = validated.submission
|
|
228
|
+
? await callProof.call_with_submission(env, await transformSubmission(validated.submission))
|
|
229
|
+
: await callProof.call(env);
|
|
230
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
231
|
+
}
|
|
232
|
+
case "gen_proof": {
|
|
233
|
+
const result = await gen_proof(env, validated.proof, validated.server_pubkey, validated.server_signature, validated.proof_type, validated.description, validated.item_count, validated.about_address);
|
|
234
|
+
return handleCallResult(result, buildCtx(validated.data));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
throw new Error(`Unknown on-chain operation type: ${validated.operation_type}`);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
241
|
+
return handleCallResult({ error: errorMessage }, validated ? {
|
|
242
|
+
operation_type: validated.operation_type,
|
|
243
|
+
data: validated.data,
|
|
244
|
+
} : undefined);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { queryProjects, queryProjectObjects, queryShareableObjects, queryDependencies, queryReferencedBy, queryPrePublishCheck, queryCrossProjectReferences, queryGraphStats, saveGraph, loadGraph, } from "../../project/index.js";
|
|
2
|
+
export async function handleProjectOperation(args) {
|
|
3
|
+
const action = args.action;
|
|
4
|
+
const project = args.project;
|
|
5
|
+
const object = args.object;
|
|
6
|
+
let result;
|
|
7
|
+
switch (action) {
|
|
8
|
+
case "list_projects":
|
|
9
|
+
result = await queryProjects();
|
|
10
|
+
break;
|
|
11
|
+
case "list_objects":
|
|
12
|
+
if (!project)
|
|
13
|
+
throw new Error("'project' param is required for list_objects");
|
|
14
|
+
result = await queryProjectObjects(project);
|
|
15
|
+
break;
|
|
16
|
+
case "shareable":
|
|
17
|
+
result = await queryShareableObjects();
|
|
18
|
+
break;
|
|
19
|
+
case "dependencies":
|
|
20
|
+
if (!object)
|
|
21
|
+
throw new Error("'object' param is required for dependencies");
|
|
22
|
+
result = queryDependencies(object);
|
|
23
|
+
break;
|
|
24
|
+
case "referenced_by":
|
|
25
|
+
if (!object)
|
|
26
|
+
throw new Error("'object' param is required for referenced_by");
|
|
27
|
+
result = queryReferencedBy(object);
|
|
28
|
+
break;
|
|
29
|
+
case "pre_publish_check":
|
|
30
|
+
if (!object)
|
|
31
|
+
throw new Error("'object' param is required for pre_publish_check");
|
|
32
|
+
result = { warnings: queryPrePublishCheck(object) };
|
|
33
|
+
break;
|
|
34
|
+
case "cross_project_refs":
|
|
35
|
+
result = queryCrossProjectReferences();
|
|
36
|
+
break;
|
|
37
|
+
case "graph_stats":
|
|
38
|
+
result = queryGraphStats();
|
|
39
|
+
break;
|
|
40
|
+
case "save_graph":
|
|
41
|
+
result = { saved: true, path: saveGraph() };
|
|
42
|
+
break;
|
|
43
|
+
case "load_graph":
|
|
44
|
+
result = { loaded: loadGraph() };
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(`Unknown project_operation action: ${action}`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
51
|
+
structuredContent: { result },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ToolDispatchResult } from "../types.js";
|
|
2
|
+
export declare function handleWatchQueryOperations(args: any): Promise<ToolDispatchResult>;
|
|
3
|
+
export declare function handleOnchainTableData(args: any): Promise<ToolDispatchResult>;
|
|
4
|
+
export declare function handleOnchainEvents(args: any): Promise<ToolDispatchResult>;
|
|
5
|
+
export declare function handleWowokInfo(args: any): Promise<ToolDispatchResult>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { strictParse, WatchQueryOperationsSchema, OnchainTableDataSchema, OnchainEventsInputSchema, ProtocolInfoQuerySchema, } from "../../schema/index.js";
|
|
2
|
+
import { query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, GetLocalNamesByAddresses, query_personal, query_objects, query_table, query_tableItem, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_received, queryProtocolInfo, query_events, generateNodeComments, } from "@wowok/wowok";
|
|
3
|
+
import { buildDataSemantic, } from "../../schema/call/semantic.js";
|
|
4
|
+
import { normalizeAccountOrMark } from "./messenger.js";
|
|
5
|
+
export async function handleWatchQueryOperations(args) {
|
|
6
|
+
const validated = strictParse(WatchQueryOperationsSchema, args, "watch_and_query input");
|
|
7
|
+
let result;
|
|
8
|
+
switch (validated.query_type) {
|
|
9
|
+
case "local_mark_list": {
|
|
10
|
+
const queryResult = await query_local_mark_list(validated.filter || {});
|
|
11
|
+
result = { query_type: "local_mark_list", result: queryResult };
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
case "account_list": {
|
|
15
|
+
const queryResult = await query_account_list(validated.filter);
|
|
16
|
+
result = { query_type: "account_list", result: queryResult };
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
case "local_info_list": {
|
|
20
|
+
const queryResult = await query_local_info_list(validated.filter);
|
|
21
|
+
result = { query_type: "local_info_list", result: queryResult };
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case "token_list": {
|
|
25
|
+
const queryResult = await query_local_token_list(validated.filter || {});
|
|
26
|
+
result = { query_type: "token_list", result: queryResult };
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case "account_balance": {
|
|
30
|
+
const queryResult = await query_account({
|
|
31
|
+
name_or_address: validated.name_or_address,
|
|
32
|
+
token_type: validated.token_type,
|
|
33
|
+
balance: validated.balance,
|
|
34
|
+
coin: validated.coin,
|
|
35
|
+
network: validated.network,
|
|
36
|
+
});
|
|
37
|
+
result = { query_type: "account_balance", result: queryResult };
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case "local_names": {
|
|
41
|
+
const queryResult = await GetLocalNamesByAddresses(validated.addresses);
|
|
42
|
+
result = { query_type: "local_names", result: queryResult };
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case "onchain_personal_profile": {
|
|
46
|
+
const queryResult = await query_personal({
|
|
47
|
+
account: validated.account,
|
|
48
|
+
no_cache: validated.no_cache,
|
|
49
|
+
network: validated.network,
|
|
50
|
+
});
|
|
51
|
+
result = { query_type: "onchain_personal_profile", result: queryResult };
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case "onchain_objects": {
|
|
55
|
+
const queryResult = await query_objects({
|
|
56
|
+
objects: validated.objects,
|
|
57
|
+
no_cache: validated.no_cache,
|
|
58
|
+
network: validated.network,
|
|
59
|
+
});
|
|
60
|
+
if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
|
|
61
|
+
queryResult.objects = queryResult.objects.map((obj) => {
|
|
62
|
+
if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
|
|
63
|
+
try {
|
|
64
|
+
const nodeComments = generateNodeComments(obj.data.root);
|
|
65
|
+
return {
|
|
66
|
+
...obj,
|
|
67
|
+
_guard_node_comments: nodeComments,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return obj;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
result = { query_type: "onchain_objects", result: queryResult };
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "onchain_received": {
|
|
81
|
+
const queryResult = await query_received({
|
|
82
|
+
name_or_address: normalizeAccountOrMark(validated.name_or_address),
|
|
83
|
+
type: validated.type,
|
|
84
|
+
cursor: validated.cursor,
|
|
85
|
+
limit: validated.limit,
|
|
86
|
+
no_cache: validated.no_cache,
|
|
87
|
+
network: validated.network,
|
|
88
|
+
});
|
|
89
|
+
result = { query_type: "onchain_received", result: queryResult };
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
default:
|
|
93
|
+
throw new Error(`Unknown query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "local_names", "onchain_personal_profile", "onchain_objects", "onchain_received". For table queries, use the "onchain_table_data" tool.`);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
97
|
+
structuredContent: {
|
|
98
|
+
result,
|
|
99
|
+
semantic: buildDataSemantic(result, {
|
|
100
|
+
operation_type: "query_toolkit",
|
|
101
|
+
data: validated,
|
|
102
|
+
}),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export async function handleOnchainTableData(args) {
|
|
107
|
+
const validated = strictParse(OnchainTableDataSchema, args, "onchain_table_data input");
|
|
108
|
+
let result;
|
|
109
|
+
switch (validated.query_type) {
|
|
110
|
+
case "onchain_table": {
|
|
111
|
+
const queryResult = await query_table({
|
|
112
|
+
parent: validated.parent,
|
|
113
|
+
cursor: validated.cursor,
|
|
114
|
+
limit: validated.limit,
|
|
115
|
+
no_cache: validated.no_cache,
|
|
116
|
+
network: validated.network,
|
|
117
|
+
});
|
|
118
|
+
result = { query_type: "onchain_table", result: queryResult };
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "onchain_table_item_repository_data": {
|
|
122
|
+
const queryResult = await queryTableItem_RepositoryData({
|
|
123
|
+
parent: validated.parent, name: validated.name, entity: validated.entity,
|
|
124
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
125
|
+
});
|
|
126
|
+
result = { query_type: "onchain_table_item_repository_data", result: queryResult };
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case "onchain_table_item_permission_perm": {
|
|
130
|
+
const queryResult = await queryTableItem_PermissionPerm({
|
|
131
|
+
parent: validated.parent, address: validated.address,
|
|
132
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
133
|
+
});
|
|
134
|
+
result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "onchain_table_item_reward_record": {
|
|
138
|
+
const queryResult = await queryTableItem_RewardRecord({
|
|
139
|
+
parent: validated.parent, address: validated.address,
|
|
140
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
141
|
+
});
|
|
142
|
+
result = { query_type: "onchain_table_item_reward_record", result: queryResult };
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "onchain_table_item_demand_presenter": {
|
|
146
|
+
const queryResult = await queryTableItem_DemandPresenter({
|
|
147
|
+
parent: validated.parent, address: validated.address,
|
|
148
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
149
|
+
});
|
|
150
|
+
result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case "onchain_table_item_treasury_history": {
|
|
154
|
+
const queryResult = await queryTableItem_TreasuryHistory({
|
|
155
|
+
parent: validated.parent, address: validated.address,
|
|
156
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
157
|
+
});
|
|
158
|
+
result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case "onchain_table_item_machine_node": {
|
|
162
|
+
const queryResult = await queryTableItem_MachineNode({
|
|
163
|
+
parent: validated.parent, key: validated.key,
|
|
164
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
165
|
+
});
|
|
166
|
+
result = { query_type: "onchain_table_item_machine_node", result: queryResult };
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case "onchain_table_item_progress_history": {
|
|
170
|
+
const queryResult = await queryTableItem_ProgressHistory({
|
|
171
|
+
parent: validated.parent, u64: validated.u64,
|
|
172
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
173
|
+
});
|
|
174
|
+
result = { query_type: "onchain_table_item_progress_history", result: queryResult };
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case "onchain_table_item_address_mark": {
|
|
178
|
+
const queryResult = await queryTableItem_AddressMark({
|
|
179
|
+
parent: validated.parent, address: validated.address,
|
|
180
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
181
|
+
});
|
|
182
|
+
result = { query_type: "onchain_table_item_address_mark", result: queryResult };
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case "onchain_table_item_entity_registrar": {
|
|
186
|
+
const queryResult = await queryTableItem_EntityRegistrar({
|
|
187
|
+
address: validated.address,
|
|
188
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
189
|
+
});
|
|
190
|
+
result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case "onchain_table_item_entity_linker": {
|
|
194
|
+
const queryResult = await queryTableItem_EntityLinker({
|
|
195
|
+
address: validated.address,
|
|
196
|
+
no_cache: validated.no_cache, network: validated.network,
|
|
197
|
+
});
|
|
198
|
+
result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "onchain_table_item_generic": {
|
|
202
|
+
const queryResult = await query_tableItem({
|
|
203
|
+
parent: validated.parent,
|
|
204
|
+
key: { type: validated.key_type, value: validated.key_value },
|
|
205
|
+
no_cache: validated.no_cache,
|
|
206
|
+
network: validated.network,
|
|
207
|
+
});
|
|
208
|
+
result = { query_type: "onchain_table_item_generic", result: queryResult };
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
default:
|
|
212
|
+
throw new Error(`Unknown table query type. Valid query_types are: "onchain_table", "onchain_table_item_repository_data", "onchain_table_item_permission_perm", "onchain_table_item_reward_record", "onchain_table_item_demand_presenter", "onchain_table_item_treasury_history", "onchain_table_item_machine_node", "onchain_table_item_progress_history", "onchain_table_item_address_mark", "onchain_table_item_entity_registrar", "onchain_table_item_entity_linker", "onchain_table_item_generic"`);
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
216
|
+
structuredContent: {
|
|
217
|
+
result,
|
|
218
|
+
semantic: buildDataSemantic(result, {
|
|
219
|
+
operation_type: "onchain_table_data",
|
|
220
|
+
data: validated,
|
|
221
|
+
}),
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export async function handleOnchainEvents(args) {
|
|
226
|
+
const validated = strictParse(OnchainEventsInputSchema, args, "onchain_events input");
|
|
227
|
+
const queryResult = await query_events({
|
|
228
|
+
type: validated.type,
|
|
229
|
+
cursor: validated.cursor ? {
|
|
230
|
+
eventSeq: String(validated.cursor.eventSeq),
|
|
231
|
+
txDigest: validated.cursor.txDigest,
|
|
232
|
+
} : null,
|
|
233
|
+
limit: validated.limit ?? null,
|
|
234
|
+
order: validated.order ?? null,
|
|
235
|
+
no_cache: validated.no_cache,
|
|
236
|
+
network: validated.network,
|
|
237
|
+
});
|
|
238
|
+
return {
|
|
239
|
+
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
240
|
+
structuredContent: {
|
|
241
|
+
result: queryResult,
|
|
242
|
+
semantic: buildDataSemantic(queryResult, {
|
|
243
|
+
operation_type: "onchain_events",
|
|
244
|
+
data: validated,
|
|
245
|
+
}),
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
export async function handleWowokInfo(args) {
|
|
250
|
+
const validated = strictParse(ProtocolInfoQuerySchema, args, "wowok_buildin_info input");
|
|
251
|
+
const queryResult = await queryProtocolInfo(validated);
|
|
252
|
+
return {
|
|
253
|
+
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
254
|
+
structuredContent: { result: queryResult },
|
|
255
|
+
};
|
|
256
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { processSchemaQuery, } from "../../schema-query/index.js";
|
|
2
|
+
export async function handleSchemaQuery(args) {
|
|
3
|
+
const request = {
|
|
4
|
+
action: args.action,
|
|
5
|
+
name: args.name,
|
|
6
|
+
query: args.query,
|
|
7
|
+
};
|
|
8
|
+
const response = processSchemaQuery(request);
|
|
9
|
+
let textContent = response.message;
|
|
10
|
+
const data = response.data;
|
|
11
|
+
if (response.success && data) {
|
|
12
|
+
switch (args.action) {
|
|
13
|
+
case "list":
|
|
14
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
15
|
+
textContent += "\n\nAll available schemas:\n";
|
|
16
|
+
for (const item of data) {
|
|
17
|
+
textContent += `\n • ${item.name}`;
|
|
18
|
+
if (item.title) {
|
|
19
|
+
textContent += ` - ${item.title}`;
|
|
20
|
+
}
|
|
21
|
+
if (item.description) {
|
|
22
|
+
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
23
|
+
}
|
|
24
|
+
textContent += "\n";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "list_operations":
|
|
29
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
30
|
+
textContent += "\n\nOn-chain operation schemas:\n";
|
|
31
|
+
for (const item of data) {
|
|
32
|
+
textContent += `\n • ${item.name}`;
|
|
33
|
+
if (item.title) {
|
|
34
|
+
textContent += ` - ${item.title}`;
|
|
35
|
+
}
|
|
36
|
+
if (item.description) {
|
|
37
|
+
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
38
|
+
}
|
|
39
|
+
textContent += "\n";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case "get":
|
|
44
|
+
if (data) {
|
|
45
|
+
textContent += "\n\n## JSON Schema\n\n";
|
|
46
|
+
textContent += "```json\n";
|
|
47
|
+
textContent += JSON.stringify(data, null, 2);
|
|
48
|
+
textContent += "\n```\n";
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case "get_output":
|
|
52
|
+
if (data) {
|
|
53
|
+
textContent += "\n\n## Output JSON Schema\n\n";
|
|
54
|
+
textContent += "```json\n";
|
|
55
|
+
textContent += JSON.stringify(data, null, 2);
|
|
56
|
+
textContent += "\n```\n";
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case "search":
|
|
60
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
61
|
+
textContent += `\n\nFound ${data.length} schemas matching '${args.query}':\n`;
|
|
62
|
+
for (const item of data) {
|
|
63
|
+
textContent += `\n • ${item.name}`;
|
|
64
|
+
if (item.title) {
|
|
65
|
+
textContent += ` - ${item.title}`;
|
|
66
|
+
}
|
|
67
|
+
if (item.description) {
|
|
68
|
+
textContent += `\n ${item.description.slice(0, 100)}...`;
|
|
69
|
+
}
|
|
70
|
+
textContent += "\n";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (response.suggestions && response.suggestions.length > 0) {
|
|
80
|
+
textContent += "\n\n💡 Suggestions:\n";
|
|
81
|
+
for (const suggestion of response.suggestions) {
|
|
82
|
+
textContent += ` • ${suggestion}\n`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
content: [{
|
|
87
|
+
type: "text",
|
|
88
|
+
text: textContent,
|
|
89
|
+
}],
|
|
90
|
+
structuredContent: response,
|
|
91
|
+
};
|
|
92
|
+
}
|