@wowok/agent-mcp 2.4.1 → 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/index.d.ts +2 -2
- package/dist/index.js +11 -1624
- package/dist/knowledge/guard-ledger.js +14 -0
- package/dist/knowledge/guard-lint.d.ts +1 -0
- package/dist/knowledge/guard-lint.js +83 -3
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -0
- package/dist/knowledge/guard-risk.d.ts +2 -0
- package/dist/knowledge/guard-risk.js +827 -57
- package/dist/knowledge/guard-templates.d.ts +1 -0
- package/dist/knowledge/guard-templates.js +278 -2
- 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 +3 -3
- package/dist/schema/call/machine.d.ts +38 -38
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +7 -7
- package/dist/schema/operations.d.ts +48 -48
- package/dist/schema/query/index.d.ts +146 -146
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schemas/bridge_operation.output.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.output.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2 -2
- 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 +6 -12
- 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,30 @@
|
|
|
1
|
+
export declare const handleAccountOperation: (args: any) => Promise<{
|
|
2
|
+
content: {
|
|
3
|
+
type: "text";
|
|
4
|
+
text: string;
|
|
5
|
+
}[];
|
|
6
|
+
structuredContent: {
|
|
7
|
+
result: any;
|
|
8
|
+
semantic: any;
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export declare const handleMarkOperation: (args: any) => Promise<{
|
|
12
|
+
content: {
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
}[];
|
|
16
|
+
structuredContent: {
|
|
17
|
+
result: any;
|
|
18
|
+
semantic: any;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare const handleInfoOperation: (args: any) => Promise<{
|
|
22
|
+
content: {
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}[];
|
|
26
|
+
structuredContent: {
|
|
27
|
+
result: any;
|
|
28
|
+
semantic: any;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { wrapLocalHandler } from "../shared.js";
|
|
2
|
+
import { AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, } from "../../schema/index.js";
|
|
3
|
+
import { account_operation, local_mark_operation, local_info_operation, } from "@wowok/wowok";
|
|
4
|
+
export const handleAccountOperation = wrapLocalHandler({
|
|
5
|
+
schema: AccountOperationSchema,
|
|
6
|
+
operationFn: account_operation,
|
|
7
|
+
parseLabel: "account_operation input",
|
|
8
|
+
buildContext: (validated) => ({
|
|
9
|
+
operation_type: "account_" + validated.operation_type,
|
|
10
|
+
data: validated,
|
|
11
|
+
}),
|
|
12
|
+
});
|
|
13
|
+
export const handleMarkOperation = wrapLocalHandler({
|
|
14
|
+
schema: LocalMarkOperationSchema,
|
|
15
|
+
operationFn: local_mark_operation,
|
|
16
|
+
parseLabel: "local_mark_operation input",
|
|
17
|
+
buildContext: (validated) => ({
|
|
18
|
+
operation_type: "mark_" + validated.operation_type,
|
|
19
|
+
data: validated,
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
export const handleInfoOperation = wrapLocalHandler({
|
|
23
|
+
schema: LocalInfoOperationSchema,
|
|
24
|
+
operationFn: local_info_operation,
|
|
25
|
+
parseLabel: "local_info_operation input",
|
|
26
|
+
buildContext: (validated) => ({ operation_type: "local_info", data: validated }),
|
|
27
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolDispatchResult } from "../types.js";
|
|
2
|
+
export declare function normalizeAccountOrMark(input: string | {
|
|
3
|
+
name_or_address?: string;
|
|
4
|
+
local_mark_first?: boolean;
|
|
5
|
+
}): {
|
|
6
|
+
name_or_address?: string;
|
|
7
|
+
local_mark_first?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function normalizeManyAccountOrMark(input: string[] | {
|
|
10
|
+
entities: any[];
|
|
11
|
+
check_all_founded?: boolean;
|
|
12
|
+
}): {
|
|
13
|
+
entities: any[];
|
|
14
|
+
check_all_founded?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function handleMessengerOperation(args: any): Promise<ToolDispatchResult>;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { strictParse, MessengerOperationInputSchema, } from "../../schema/index.js";
|
|
2
|
+
import { watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, pull_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, mark_messages_as_viewed, mark_conversation_as_viewed, blacklist, friendslist, guardlist, settings, } from "@wowok/wowok";
|
|
3
|
+
import { classifyError, buildDataSemantic, } from "../../schema/call/semantic.js";
|
|
4
|
+
export function normalizeAccountOrMark(input) {
|
|
5
|
+
if (typeof input === 'string') {
|
|
6
|
+
return { name_or_address: input, local_mark_first: true };
|
|
7
|
+
}
|
|
8
|
+
return input;
|
|
9
|
+
}
|
|
10
|
+
export function normalizeManyAccountOrMark(input) {
|
|
11
|
+
if (Array.isArray(input)) {
|
|
12
|
+
return {
|
|
13
|
+
entities: input.map(item => typeof item === 'string' ? { name_or_address: item, local_mark_first: true } : item),
|
|
14
|
+
check_all_founded: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return input;
|
|
18
|
+
}
|
|
19
|
+
export async function handleMessengerOperation(args) {
|
|
20
|
+
let validated;
|
|
21
|
+
try {
|
|
22
|
+
validated = strictParse(MessengerOperationInputSchema, args, "messenger_operation input");
|
|
23
|
+
let result;
|
|
24
|
+
switch (validated.operation) {
|
|
25
|
+
case "watch_conversations": {
|
|
26
|
+
const conversations = await watch_conversations(validated.filter);
|
|
27
|
+
result = { operation: "watch_conversations", result: conversations };
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case "send_message": {
|
|
31
|
+
const sendResult = await send_message(validated.from, normalizeAccountOrMark(validated.to), validated.content, validated.options);
|
|
32
|
+
const filteredResult = {
|
|
33
|
+
...sendResult,
|
|
34
|
+
merkleData: sendResult.merkleData ? {
|
|
35
|
+
leafIndex: sendResult.merkleData.leafIndex,
|
|
36
|
+
prevRoot: sendResult.merkleData.prevRoot,
|
|
37
|
+
newRoot: sendResult.merkleData.newRoot,
|
|
38
|
+
serverSignature: sendResult.merkleData.serverSignature,
|
|
39
|
+
serverTimestamp: sendResult.merkleData.serverTimestamp,
|
|
40
|
+
serverPublicKey: sendResult.merkleData.serverPublicKey,
|
|
41
|
+
} : undefined,
|
|
42
|
+
};
|
|
43
|
+
result = { operation: "send_message", result: filteredResult };
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "send_file": {
|
|
47
|
+
const sendResult = await send_file(validated.from, normalizeAccountOrMark(validated.to), validated.filePath, validated.options);
|
|
48
|
+
const filteredResult = {
|
|
49
|
+
...sendResult,
|
|
50
|
+
merkleData: sendResult.merkleData ? {
|
|
51
|
+
leafIndex: sendResult.merkleData.leafIndex,
|
|
52
|
+
prevRoot: sendResult.merkleData.prevRoot,
|
|
53
|
+
newRoot: sendResult.merkleData.newRoot,
|
|
54
|
+
serverSignature: sendResult.merkleData.serverSignature,
|
|
55
|
+
serverTimestamp: sendResult.merkleData.serverTimestamp,
|
|
56
|
+
serverPublicKey: sendResult.merkleData.serverPublicKey,
|
|
57
|
+
} : undefined,
|
|
58
|
+
};
|
|
59
|
+
result = { operation: "send_file", result: filteredResult };
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case "watch_messages": {
|
|
63
|
+
const filter = validated.filter ? {
|
|
64
|
+
...validated.filter,
|
|
65
|
+
peerAddress: validated.filter.peerAddress ? normalizeAccountOrMark(validated.filter.peerAddress) : undefined,
|
|
66
|
+
} : undefined;
|
|
67
|
+
const messages = await watch_messages(filter);
|
|
68
|
+
result = { operation: "watch_messages", result: messages };
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "extract_zip_messages": {
|
|
72
|
+
const extractedPaths = await extract_zip_messages(validated.account, validated.messages, validated.outputDir);
|
|
73
|
+
result = { operation: "extract_zip_messages", result: extractedPaths };
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "generate_wts": {
|
|
77
|
+
const params = validated.params ? {
|
|
78
|
+
...validated.params,
|
|
79
|
+
peerAccount: normalizeAccountOrMark(validated.params.peerAccount),
|
|
80
|
+
} : undefined;
|
|
81
|
+
const wtsResult = await generate_wts(params);
|
|
82
|
+
result = { operation: "generate_wts", result: wtsResult };
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case "verify_wts": {
|
|
86
|
+
const verifyResult = await verify_wts(validated.wtsFilePath);
|
|
87
|
+
result = { operation: "verify_wts", result: verifyResult };
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "sign_wts": {
|
|
91
|
+
const signedPath = await sign_wts(validated.wtsFilePath, validated.account, validated.outputPath);
|
|
92
|
+
result = { operation: "sign_wts", result: signedPath };
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case "wts2html": {
|
|
96
|
+
const htmlResult = await wts2html(validated.wtsPath, validated.options);
|
|
97
|
+
result = { operation: "wts2html", result: htmlResult };
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "proof_message": {
|
|
101
|
+
const proofResult = await proof_message(validated.account, validated.messageId, validated.network);
|
|
102
|
+
result = { operation: "proof_message", result: proofResult };
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "blacklist": {
|
|
106
|
+
const blacklistParams = {
|
|
107
|
+
account: validated.account,
|
|
108
|
+
op: validated.blacklist.op,
|
|
109
|
+
};
|
|
110
|
+
if ('users' in validated.blacklist) {
|
|
111
|
+
blacklistParams.users = normalizeManyAccountOrMark(validated.blacklist.users);
|
|
112
|
+
}
|
|
113
|
+
const blacklistResult = await blacklist(blacklistParams);
|
|
114
|
+
result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case "friendslist": {
|
|
118
|
+
const friendslistParams = {
|
|
119
|
+
account: validated.account,
|
|
120
|
+
op: validated.friendslist.op,
|
|
121
|
+
};
|
|
122
|
+
if ('users' in validated.friendslist) {
|
|
123
|
+
friendslistParams.users = normalizeManyAccountOrMark(validated.friendslist.users);
|
|
124
|
+
}
|
|
125
|
+
const friendslistResult = await friendslist(friendslistParams);
|
|
126
|
+
result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case "guardlist": {
|
|
130
|
+
const guardlistResult = await guardlist({
|
|
131
|
+
account: validated.account,
|
|
132
|
+
...validated.guardlist,
|
|
133
|
+
});
|
|
134
|
+
result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "settings": {
|
|
138
|
+
const settingsResult = await settings({
|
|
139
|
+
account: validated.account,
|
|
140
|
+
...validated.settings,
|
|
141
|
+
});
|
|
142
|
+
result = { operation: "settings", op: validated.settings.op, result: settingsResult.result };
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "mark_messages_as_viewed": {
|
|
146
|
+
const markedCount = await mark_messages_as_viewed(validated.messageIds, validated.account);
|
|
147
|
+
result = { operation: "mark_messages_as_viewed", result: markedCount };
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case "mark_conversation_as_viewed": {
|
|
151
|
+
const markedCount = await mark_conversation_as_viewed(normalizeAccountOrMark(validated.peerAddress), validated.account);
|
|
152
|
+
result = { operation: "mark_conversation_as_viewed", result: markedCount };
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case "pull_messages": {
|
|
156
|
+
const messages = await pull_messages(validated.account, validated.limit);
|
|
157
|
+
result = { operation: "pull_messages", result: messages };
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
default:
|
|
161
|
+
throw new Error(`Unknown messenger operation: ${validated.operation}`);
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
165
|
+
structuredContent: { result },
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
170
|
+
const ctx = validated ? { operation_type: "messenger_" + validated.operation, data: validated } : undefined;
|
|
171
|
+
const classified = classifyError(errorMessage);
|
|
172
|
+
const errorResult = { operation: "error", error: errorMessage };
|
|
173
|
+
if (classified.error_code !== undefined)
|
|
174
|
+
errorResult.error_code = classified.error_code;
|
|
175
|
+
if (classified.retryable !== undefined)
|
|
176
|
+
errorResult.retryable = classified.retryable;
|
|
177
|
+
if (classified.recovery_hint !== undefined)
|
|
178
|
+
errorResult.recovery_hint = classified.recovery_hint;
|
|
179
|
+
return {
|
|
180
|
+
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
181
|
+
structuredContent: {
|
|
182
|
+
result: errorResult,
|
|
183
|
+
semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -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>;
|