wowok_agent 2.1.38 → 2.1.40
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 +45 -2
- package/dist/index.js +1 -1319
- package/dist/schema/call/allocation.js +1 -27
- package/dist/schema/call/arbitration.js +1 -106
- package/dist/schema/call/base.js +1 -152
- package/dist/schema/call/contact.js +1 -41
- package/dist/schema/call/demand.js +1 -51
- package/dist/schema/call/guard.d.ts +6 -6
- package/dist/schema/call/guard.js +1 -67
- package/dist/schema/call/handler.d.ts +0 -45
- package/dist/schema/call/handler.js +1 -230
- package/dist/schema/call/index.js +1 -19
- package/dist/schema/call/machine.js +1 -164
- package/dist/schema/call/order.js +1 -39
- package/dist/schema/call/payment.js +1 -20
- package/dist/schema/call/permission.js +1 -118
- package/dist/schema/call/personal.js +1 -81
- package/dist/schema/call/progress.js +1 -28
- package/dist/schema/call/proof.js +1 -27
- package/dist/schema/call/repository.js +1 -85
- package/dist/schema/call/reward.d.ts +12 -0
- package/dist/schema/call/reward.js +1 -46
- package/dist/schema/call/service.js +1 -88
- package/dist/schema/call/treasury.d.ts +84 -0
- package/dist/schema/call/treasury.js +1 -76
- package/dist/schema/common/index.js +1 -395
- package/dist/schema/index.js +1 -8
- package/dist/schema/local/index.js +1 -913
- package/dist/schema/local/wip.js +1 -230
- package/dist/schema/messenger/index.d.ts +4 -6
- package/dist/schema/messenger/index.js +1 -479
- package/dist/schema/query/index.d.ts +155 -0
- package/dist/schema/query/index.js +1 -1256
- package/dist/schema/utils/guard-parser.js +1 -410
- package/dist/schema/utils/guard-query-utils.js +1 -22
- package/dist/schema/utils/node-parser.d.ts +0 -14
- package/dist/schema/utils/node-parser.js +1 -382
- package/dist/schema/utils/permission-index-utils.js +1 -10
- package/package.json +6 -3
|
@@ -1,67 +1 @@
|
|
|
1
|
-
import { z }
|
|
2
|
-
import { CallEnvSchema, NamedObjectSchema, SubmissionCallSchema } from './base.js';
|
|
3
|
-
import { GuardNodeSchema } from '../query/index.js';
|
|
4
|
-
import { DescriptionSchema, GuardTableItemBaseSchema, NameOrAddressSchema } from '../common/index.js';
|
|
5
|
-
// CallGuard_RootSchema - Root 可以是直接节点或文件引用
|
|
6
|
-
export const CallGuard_RootSchema = z.discriminatedUnion("type", [
|
|
7
|
-
// type: node - 直接提供 GuardNode 计算树
|
|
8
|
-
z.object({
|
|
9
|
-
type: z.literal("node"),
|
|
10
|
-
node: GuardNodeSchema.describe("Guard computational tree root node. MUST return a Bool value (pass/fail)."),
|
|
11
|
-
}),
|
|
12
|
-
// type: file - 从 JSON/Markdown 文件加载
|
|
13
|
-
z.object({
|
|
14
|
-
type: z.literal("file"),
|
|
15
|
-
file_path: z.string().describe("Path to JSON or Markdown file containing Guard definition. File can define: namedNew, description, table, root, rely."),
|
|
16
|
-
format: z.enum(["json", "markdown"]).optional().default("json")
|
|
17
|
-
.describe("File format: 'json' or 'markdown'. Default is 'json'."),
|
|
18
|
-
}),
|
|
19
|
-
]).describe("Guard root definition. Either provide a direct node tree or reference a file to load. When using file type, fields defined in the schema (namedNew, description, table, rely) will OVERRIDE the corresponding fields in the file.");
|
|
20
|
-
// CallGuard_DataSchema - Guard 数据定义
|
|
21
|
-
export const CallGuard_DataSchema = z.object({
|
|
22
|
-
namedNew: NamedObjectSchema.optional().describe("Name and optional tags for the new Guard object. Set 'onChain: true' to create a public on-chain identity. When using root.type='file', this field OVERRIDES namedNew in the file."),
|
|
23
|
-
description: DescriptionSchema.optional().describe("Guard description. When using root.type='file', this field OVERRIDES description in the file."),
|
|
24
|
-
table: z.array(GuardTableItemBaseSchema).optional().describe("Data table of the Guard object. When using root.type='file', this field OVERRIDES table in the file."),
|
|
25
|
-
root: CallGuard_RootSchema.describe("Root definition: either a direct node tree (type='node') or a file reference (type='file'). When type='file', the file can define all Guard fields (namedNew, description, table, root, rely), and schema fields override file content."),
|
|
26
|
-
rely: z.object({
|
|
27
|
-
guards: z.array(NameOrAddressSchema).describe("List of dependent Guard object IDs or names."),
|
|
28
|
-
logic_or: z.boolean().optional().describe("Whether to use logical OR operator."),
|
|
29
|
-
}).optional().describe("All Guard objects that the new Guard object depends on. If logic_or is true, the execution result of the new Guard object is the logical OR of the execution results of all dependent Guard objects; otherwise, it is logical AND. When using root.type='file', this field OVERRIDES rely in the file."),
|
|
30
|
-
}).strict().describe("On-chain Guard creation. IMPORTANT: All defined data (include all submitted data) must be defined in the 'table' field. USAGE: Set 'namedNew' field with {name, tags?, onChain?} to name the new Guard. The Guard is immutable once created. Define the validation logic in 'root' field. When root.type='file', the file can contain all Guard fields, and any fields defined in the schema will OVERRIDE the file content.");
|
|
31
|
-
// CallGuard_InputSchema - Guard 创建 Schema
|
|
32
|
-
export const CallGuard_InputSchema = z.object({
|
|
33
|
-
data: CallGuard_DataSchema.describe("Guard data definition."),
|
|
34
|
-
env: CallEnvSchema.optional(),
|
|
35
|
-
}).strict().describe("On-chain Guard creation input wrapper. Contains the Guard data definition and optional environment settings.");
|
|
36
|
-
// CallGenPassport_InputSchema - 用于 gen_passport 函数
|
|
37
|
-
export const CallGenPassport_InputSchema = z.object({
|
|
38
|
-
guard: NameOrAddressSchema.describe("Guard object ID to verify and generate passport from"),
|
|
39
|
-
info: SubmissionCallSchema.optional().describe("Optional submission data. If not provided, will attempt to get existing submissions from the guard."),
|
|
40
|
-
env: CallEnvSchema.optional(),
|
|
41
|
-
}).strict().describe("Generate a new Passport object after Guard verification succeeds. The Passport is an immutable on-chain object that can be used for offline friend verification, transaction condition verification, etc.");
|
|
42
|
-
// Guard2File_InputSchema - 用于 guard2file 函数
|
|
43
|
-
export const Guard2File_InputSchema = z.object({
|
|
44
|
-
guard: NameOrAddressSchema.describe("Guard object ID or name to export"),
|
|
45
|
-
file_path: z.string().describe("Output file path (absolute or relative)"),
|
|
46
|
-
format: z.enum(["json", "markdown"]).optional().describe("Output format: 'json' (default) or 'markdown'"),
|
|
47
|
-
env: CallEnvSchema.optional(),
|
|
48
|
-
}).strict().describe("Query a Guard object from the blockchain and export its definition to a JSON or Markdown file. The exported file can be edited and used to create new Guard objects.");
|
|
49
|
-
// Guard2File_OutputSchema - guard2file 输出 schema
|
|
50
|
-
export const Guard2File_OutputSchema = z.discriminatedUnion("status", [
|
|
51
|
-
z.object({
|
|
52
|
-
status: z.literal("success"),
|
|
53
|
-
data: z.object({
|
|
54
|
-
file_path: z.string().describe("Absolute path of the exported file"),
|
|
55
|
-
format: z.enum(["json", "markdown"]).describe("Export format"),
|
|
56
|
-
guard_object: z.string().describe("Guard object ID"),
|
|
57
|
-
}).strict().describe("Success result data"),
|
|
58
|
-
}).strict(),
|
|
59
|
-
z.object({
|
|
60
|
-
status: z.literal("error"),
|
|
61
|
-
error: z.string().describe("Error message"),
|
|
62
|
-
}).strict(),
|
|
63
|
-
]).describe("Guard2File operation output schema with discriminator");
|
|
64
|
-
// Guard2File_OutputWrappedSchema - 包装后的输出 schema
|
|
65
|
-
export const Guard2File_OutputWrappedSchema = z.object({
|
|
66
|
-
result: Guard2File_OutputSchema,
|
|
67
|
-
}).strict().describe("Guard2File operation output wrapped schema");
|
|
1
|
+
import{z}from'zod';import{CallEnvSchema,NamedObjectSchema,SubmissionCallSchema}from'./base.js';import{GuardNodeSchema}from'../query/index.js';import{DescriptionSchema,GuardTableItemBaseSchema,NameOrAddressSchema}from'../common/index.js';export const CallGuard_RootSchema=z['discriminatedUnion']('type',[z['object']({'type':z['literal']('node'),'node':GuardNodeSchema['describe']('Guard\x20computational\x20tree\x20root\x20node.\x20MUST\x20return\x20a\x20Bool\x20value\x20(pass/fail).')})['strict'](),z['object']({'type':z['literal']('file'),'file_path':z['string']()['describe']('Path\x20to\x20JSON\x20or\x20Markdown\x20file\x20containing\x20Guard\x20definition.\x20File\x20can\x20define:\x20namedNew,\x20description,\x20table,\x20root,\x20rely.'),'format':z['enum'](['json','markdown'])['optional']()['default']('json')['describe']('File\x20format:\x20\x27json\x27\x20or\x20\x27markdown\x27.\x20Default\x20is\x20\x27json\x27.')})['strict']()])['describe']('Guard\x20root\x20definition.\x20Either\x20provide\x20a\x20direct\x20node\x20tree\x20or\x20reference\x20a\x20file\x20to\x20load.\x20When\x20using\x20file\x20type,\x20fields\x20defined\x20in\x20the\x20schema\x20(namedNew,\x20description,\x20table,\x20rely)\x20will\x20OVERRIDE\x20the\x20corresponding\x20fields\x20in\x20the\x20file.');export const CallGuard_DataSchema=z['object']({'namedNew':NamedObjectSchema['optional']()['describe']('Name\x20and\x20optional\x20tags\x20for\x20the\x20new\x20Guard\x20object.\x20Set\x20\x27onChain:\x20true\x27\x20to\x20create\x20a\x20public\x20on-chain\x20identity.\x20When\x20using\x20root.type=\x27file\x27,\x20this\x20field\x20OVERRIDES\x20namedNew\x20in\x20the\x20file.'),'description':DescriptionSchema['optional']()['describe']('Guard\x20description.\x20When\x20using\x20root.type=\x27file\x27,\x20this\x20field\x20OVERRIDES\x20description\x20in\x20the\x20file.'),'table':z['array'](GuardTableItemBaseSchema)['optional']()['describe']('Data\x20table\x20of\x20the\x20Guard\x20object.\x20When\x20using\x20root.type=\x27file\x27,\x20this\x20field\x20OVERRIDES\x20table\x20in\x20the\x20file.'),'root':CallGuard_RootSchema['describe']('Root\x20definition:\x20either\x20a\x20direct\x20node\x20tree\x20(type=\x27node\x27)\x20or\x20a\x20file\x20reference\x20(type=\x27file\x27).\x20When\x20type=\x27file\x27,\x20the\x20file\x20can\x20define\x20all\x20Guard\x20fields\x20(namedNew,\x20description,\x20table,\x20root,\x20rely),\x20and\x20schema\x20fields\x20override\x20file\x20content.'),'rely':z['object']({'guards':z['array'](NameOrAddressSchema)['describe']('List\x20of\x20dependent\x20Guard\x20object\x20IDs\x20or\x20names.'),'logic_or':z['boolean']()['optional']()['describe']('Whether\x20to\x20use\x20logical\x20OR\x20operator.')})['optional']()['describe']('All\x20Guard\x20objects\x20that\x20the\x20new\x20Guard\x20object\x20depends\x20on.\x20If\x20logic_or\x20is\x20true,\x20the\x20execution\x20result\x20of\x20the\x20new\x20Guard\x20object\x20is\x20the\x20logical\x20OR\x20of\x20the\x20execution\x20results\x20of\x20all\x20dependent\x20Guard\x20objects;\x20otherwise,\x20it\x20is\x20logical\x20AND.\x20When\x20using\x20root.type=\x27file\x27,\x20this\x20field\x20OVERRIDES\x20rely\x20in\x20the\x20file.')})['strict']()['describe']('On-chain\x20Guard\x20creation.\x20IMPORTANT:\x20All\x20defined\x20data\x20(include\x20all\x20submitted\x20data)\x20must\x20be\x20defined\x20in\x20the\x20\x27table\x27\x20field.\x20USAGE:\x20Set\x20\x27namedNew\x27\x20field\x20with\x20{name,\x20tags?,\x20onChain?}\x20to\x20name\x20the\x20new\x20Guard.\x20The\x20Guard\x20is\x20immutable\x20once\x20created.\x20Define\x20the\x20validation\x20logic\x20in\x20\x27root\x27\x20field.\x20When\x20root.type=\x27file\x27,\x20the\x20file\x20can\x20contain\x20all\x20Guard\x20fields,\x20and\x20any\x20fields\x20defined\x20in\x20the\x20schema\x20will\x20OVERRIDE\x20the\x20file\x20content.');export const CallGuard_InputSchema=z['object']({'data':CallGuard_DataSchema['describe']('Guard\x20data\x20definition.'),'env':CallEnvSchema['optional']()})['strict']()['describe']('On-chain\x20Guard\x20creation\x20input\x20wrapper.\x20Contains\x20the\x20Guard\x20data\x20definition\x20and\x20optional\x20environment\x20settings.');export const CallGenPassport_InputSchema=z['object']({'guard':NameOrAddressSchema['describe']('Guard\x20object\x20ID\x20to\x20verify\x20and\x20generate\x20passport\x20from'),'info':SubmissionCallSchema['optional']()['describe']('Optional\x20submission\x20data.\x20If\x20not\x20provided,\x20will\x20attempt\x20to\x20get\x20existing\x20submissions\x20from\x20the\x20guard.'),'env':CallEnvSchema['optional']()})['strict']()['describe']('Generate\x20a\x20new\x20Passport\x20object\x20after\x20Guard\x20verification\x20succeeds.\x20The\x20Passport\x20is\x20an\x20immutable\x20on-chain\x20object\x20that\x20can\x20be\x20used\x20for\x20offline\x20friend\x20verification,\x20transaction\x20condition\x20verification,\x20etc.');export const Guard2File_InputSchema=z['object']({'guard':NameOrAddressSchema['describe']('Guard\x20object\x20ID\x20or\x20name\x20to\x20export'),'file_path':z['string']()['describe']('Output\x20file\x20path\x20(absolute\x20or\x20relative)'),'format':z['enum'](['json','markdown'])['optional']()['describe']('Output\x20format:\x20\x27json\x27\x20(default)\x20or\x20\x27markdown\x27'),'env':CallEnvSchema['optional']()})['strict']()['describe']('Query\x20a\x20Guard\x20object\x20from\x20the\x20blockchain\x20and\x20export\x20its\x20definition\x20to\x20a\x20JSON\x20or\x20Markdown\x20file.\x20The\x20exported\x20file\x20can\x20be\x20edited\x20and\x20used\x20to\x20create\x20new\x20Guard\x20objects.');export const Guard2File_OutputSchema=z['discriminatedUnion']('status',[z['object']({'status':z['literal']('success'),'data':z['object']({'file_path':z['string']()['describe']('Absolute\x20path\x20of\x20the\x20exported\x20file'),'format':z['enum'](['json','markdown'])['describe']('Export\x20format'),'guard_object':z['string']()['describe']('Guard\x20object\x20ID')})['strict']()['describe']('Success\x20result\x20data')})['strict'](),z['object']({'status':z['literal']('error'),'error':z['string']()['describe']('Error\x20message')})['strict']()])['describe']('Guard2File\x20operation\x20output\x20schema\x20with\x20discriminator');export const Guard2File_OutputWrappedSchema=z['object']({'result':Guard2File_OutputSchema})['strict']()['describe']('Guard2File\x20operation\x20output\x20wrapped\x20schema');
|
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
import type { CallEnv } from "wowok";
|
|
2
2
|
import type { CallOutput } from "./base.js";
|
|
3
|
-
/**
|
|
4
|
-
* Process Call result and return unified MCP output format
|
|
5
|
-
* @param result Call operation result
|
|
6
|
-
* @returns Unified MCP output format
|
|
7
|
-
*/
|
|
8
3
|
export declare function handleCallResult(result: any): {
|
|
9
4
|
content: any[];
|
|
10
5
|
structuredContent: CallOutput;
|
|
11
6
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Create standard MCP Server configuration
|
|
14
|
-
* @param packageJson package.json content
|
|
15
|
-
* @param description server description (overrides packageJson.description)
|
|
16
|
-
* @returns MCP Server configuration
|
|
17
|
-
*/
|
|
18
7
|
export declare function createServerConfig(packageJson: any, description?: string): {
|
|
19
8
|
name: any;
|
|
20
9
|
version: any;
|
|
21
10
|
description: any;
|
|
22
11
|
};
|
|
23
|
-
/**
|
|
24
|
-
* Create MCP Server capabilities configuration
|
|
25
|
-
* @returns Capabilities configuration
|
|
26
|
-
*/
|
|
27
12
|
export declare function createCapabilitiesConfig(): {
|
|
28
13
|
capabilities: {
|
|
29
14
|
prompts: {};
|
|
@@ -34,12 +19,6 @@ export declare function createCapabilitiesConfig(): {
|
|
|
34
19
|
logging: {};
|
|
35
20
|
};
|
|
36
21
|
};
|
|
37
|
-
/**
|
|
38
|
-
* Create standard tool metadata
|
|
39
|
-
* @param category Tool category
|
|
40
|
-
* @param tags Tool tags
|
|
41
|
-
* @returns Tool metadata
|
|
42
|
-
*/
|
|
43
22
|
export declare function createToolMeta(category: string, tags: string[]): {
|
|
44
23
|
author: string;
|
|
45
24
|
createdAt: string;
|
|
@@ -48,36 +27,12 @@ export declare function createToolMeta(category: string, tags: string[]): {
|
|
|
48
27
|
tags: string[];
|
|
49
28
|
requiresAuth: boolean;
|
|
50
29
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Create standard tool annotations
|
|
53
|
-
* @param readOnlyHint Whether read-only
|
|
54
|
-
* @param destructiveHint Whether destructive
|
|
55
|
-
* @returns Tool annotations
|
|
56
|
-
*/
|
|
57
30
|
export declare function createToolAnnotations(readOnlyHint?: boolean, destructiveHint?: boolean): {
|
|
58
31
|
readOnlyHint: boolean;
|
|
59
32
|
destructiveHint: boolean;
|
|
60
33
|
idempotentHint: boolean;
|
|
61
34
|
openWorldHint: boolean;
|
|
62
35
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Process submission parameter transformation
|
|
65
|
-
* Resolves Guard names to addresses using LocalMark
|
|
66
|
-
* Throws error if name cannot be resolved to address
|
|
67
|
-
* @param submission submission parameter
|
|
68
|
-
* @returns Transformed submission parameter
|
|
69
|
-
*/
|
|
70
36
|
export declare function transformSubmission(submission: any): Promise<any>;
|
|
71
|
-
/**
|
|
72
|
-
* Validate input data
|
|
73
|
-
* @param data Input data
|
|
74
|
-
* @param schema Zod schema
|
|
75
|
-
* @returns Validated data
|
|
76
|
-
*/
|
|
77
37
|
export declare function validateInput<T>(data: any, schema: any): T;
|
|
78
|
-
/**
|
|
79
|
-
* Get environment configuration
|
|
80
|
-
* @param env Environment parameters
|
|
81
|
-
* @returns Environment configuration
|
|
82
|
-
*/
|
|
83
38
|
export declare function getEnvConfig(env?: any): CallEnv;
|
|
@@ -1,230 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { ResponseData, LocalMark } from "wowok";
|
|
4
|
-
/**
|
|
5
|
-
* Process Call result and return unified MCP output format
|
|
6
|
-
* @param result Call operation result
|
|
7
|
-
* @returns Unified MCP output format
|
|
8
|
-
*/
|
|
9
|
-
export function handleCallResult(result) {
|
|
10
|
-
// Handle error result
|
|
11
|
-
if (result && "error" in result) {
|
|
12
|
-
const output = {
|
|
13
|
-
message: `Error: ${result.error}`,
|
|
14
|
-
result: { type: "error", error: result.error },
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
content: [{ type: "text", text: output.message }],
|
|
18
|
-
structuredContent: output,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
// Handle transaction result (contains digest field)
|
|
22
|
-
if (result && "digest" in result) {
|
|
23
|
-
const r = ResponseData(result);
|
|
24
|
-
const txStatus = result?.effects?.status?.status;
|
|
25
|
-
const txError = result?.effects?.status?.error;
|
|
26
|
-
const isSuccess = txStatus === "success";
|
|
27
|
-
if (!isSuccess) {
|
|
28
|
-
const output = {
|
|
29
|
-
message: `Transaction failed: ${txError || txStatus || "unknown error"}`,
|
|
30
|
-
result: { type: "error", error: txError || txStatus || "transaction failed" },
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
content: [
|
|
34
|
-
{ type: "text", text: output.message },
|
|
35
|
-
{ type: "text", text: JSON.stringify(r) },
|
|
36
|
-
],
|
|
37
|
-
structuredContent: output,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const output = {
|
|
41
|
-
message: "Transaction completed successfully",
|
|
42
|
-
result: { type: "transaction", ...result },
|
|
43
|
-
};
|
|
44
|
-
return {
|
|
45
|
-
content: [
|
|
46
|
-
{ type: "text", text: output.message },
|
|
47
|
-
{ type: "text", text: JSON.stringify(r) },
|
|
48
|
-
],
|
|
49
|
-
structuredContent: output,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
// Handle submission result (contains guard and submission fields)
|
|
53
|
-
if (result && "guard" in result && "submission" in result) {
|
|
54
|
-
const output = {
|
|
55
|
-
message: "Submission required for Guard verification",
|
|
56
|
-
result: { type: "submission", ...result },
|
|
57
|
-
};
|
|
58
|
-
return {
|
|
59
|
-
content: [
|
|
60
|
-
{ type: "text", text: output.message },
|
|
61
|
-
{ type: "text", text: JSON.stringify(result) },
|
|
62
|
-
],
|
|
63
|
-
structuredContent: output,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
// Handle array result
|
|
67
|
-
if (Array.isArray(result)) {
|
|
68
|
-
const output = {
|
|
69
|
-
message: "Operation completed",
|
|
70
|
-
result: { type: "data", data: result },
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
content: [
|
|
74
|
-
{ type: "text", text: output.message },
|
|
75
|
-
{ type: "text", text: JSON.stringify(result) },
|
|
76
|
-
],
|
|
77
|
-
structuredContent: output,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
// Handle empty or null result
|
|
81
|
-
if (result === undefined || result === null) {
|
|
82
|
-
const output = {
|
|
83
|
-
message: "Operation completed",
|
|
84
|
-
result: { type: "null" },
|
|
85
|
-
};
|
|
86
|
-
return {
|
|
87
|
-
content: [{ type: "text", text: output.message }],
|
|
88
|
-
structuredContent: output,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
// Default handling for other result types - treat as transaction
|
|
92
|
-
const output = {
|
|
93
|
-
message: "Operation completed",
|
|
94
|
-
result: { type: "transaction", ...result },
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
content: [{ type: "text", text: output.message }],
|
|
98
|
-
structuredContent: output,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Create standard MCP Server configuration
|
|
103
|
-
* @param packageJson package.json content
|
|
104
|
-
* @param description server description (overrides packageJson.description)
|
|
105
|
-
* @returns MCP Server configuration
|
|
106
|
-
*/
|
|
107
|
-
export function createServerConfig(packageJson, description) {
|
|
108
|
-
return {
|
|
109
|
-
name: packageJson.name,
|
|
110
|
-
version: packageJson.version,
|
|
111
|
-
description: description || packageJson.description,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Create MCP Server capabilities configuration
|
|
116
|
-
* @returns Capabilities configuration
|
|
117
|
-
*/
|
|
118
|
-
export function createCapabilitiesConfig() {
|
|
119
|
-
return {
|
|
120
|
-
capabilities: {
|
|
121
|
-
prompts: {},
|
|
122
|
-
resources: {},
|
|
123
|
-
tools: { listChanged: true },
|
|
124
|
-
logging: {},
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Create standard tool metadata
|
|
130
|
-
* @param category Tool category
|
|
131
|
-
* @param tags Tool tags
|
|
132
|
-
* @returns Tool metadata
|
|
133
|
-
*/
|
|
134
|
-
export function createToolMeta(category, tags) {
|
|
135
|
-
return {
|
|
136
|
-
author: "WOWOK Team",
|
|
137
|
-
createdAt: "2026-02-01",
|
|
138
|
-
lastUpdated: "2026-02-01",
|
|
139
|
-
category,
|
|
140
|
-
tags,
|
|
141
|
-
requiresAuth: false,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Create standard tool annotations
|
|
146
|
-
* @param readOnlyHint Whether read-only
|
|
147
|
-
* @param destructiveHint Whether destructive
|
|
148
|
-
* @returns Tool annotations
|
|
149
|
-
*/
|
|
150
|
-
export function createToolAnnotations(readOnlyHint = false, destructiveHint = false) {
|
|
151
|
-
return {
|
|
152
|
-
readOnlyHint,
|
|
153
|
-
destructiveHint,
|
|
154
|
-
idempotentHint: true,
|
|
155
|
-
openWorldHint: false,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Process submission parameter transformation
|
|
160
|
-
* Resolves Guard names to addresses using LocalMark
|
|
161
|
-
* Throws error if name cannot be resolved to address
|
|
162
|
-
* @param submission submission parameter
|
|
163
|
-
* @returns Transformed submission parameter
|
|
164
|
-
*/
|
|
165
|
-
export async function transformSubmission(submission) {
|
|
166
|
-
if (!submission)
|
|
167
|
-
return undefined;
|
|
168
|
-
// Collect all guard names/addresses that need resolution
|
|
169
|
-
const guardNames = (submission.guard || []).map((g) => g.object).filter(Boolean);
|
|
170
|
-
const submissionGuardNames = (submission.submission || []).map((s) => s.guard).filter(Boolean);
|
|
171
|
-
const allNames = [...new Set([...guardNames, ...submissionGuardNames])];
|
|
172
|
-
// Batch resolve names to addresses
|
|
173
|
-
const resolvedAddresses = allNames.length > 0
|
|
174
|
-
? await LocalMark.Instance().get_many_address(allNames)
|
|
175
|
-
: [];
|
|
176
|
-
// Create name to address mapping
|
|
177
|
-
const nameToAddress = new Map();
|
|
178
|
-
allNames.forEach((name, index) => {
|
|
179
|
-
const addr = resolvedAddresses[index];
|
|
180
|
-
if (addr) {
|
|
181
|
-
nameToAddress.set(name, addr);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
// Helper function: get address or throw error if not found
|
|
185
|
-
const getAddress = (name) => {
|
|
186
|
-
// If it's already a valid address, return it
|
|
187
|
-
if (nameToAddress.has(name)) {
|
|
188
|
-
return nameToAddress.get(name);
|
|
189
|
-
}
|
|
190
|
-
// If it was resolved from a name, return the address
|
|
191
|
-
for (const [n, addr] of nameToAddress.entries()) {
|
|
192
|
-
if (n === name)
|
|
193
|
-
return addr;
|
|
194
|
-
}
|
|
195
|
-
// If name looks like an address (starts with 0x), return it directly
|
|
196
|
-
if (name.startsWith("0x") && name.length === 66) {
|
|
197
|
-
return name;
|
|
198
|
-
}
|
|
199
|
-
// Otherwise, throw error
|
|
200
|
-
throw new Error(`Guard name or address not found: ${name}`);
|
|
201
|
-
};
|
|
202
|
-
return {
|
|
203
|
-
type: "submission",
|
|
204
|
-
guard: (submission.guard || []).map((g) => ({
|
|
205
|
-
object: getAddress(g.object),
|
|
206
|
-
impack: g.impack || false,
|
|
207
|
-
})),
|
|
208
|
-
submission: (submission.submission || []).map((s) => ({
|
|
209
|
-
guard: getAddress(s.guard),
|
|
210
|
-
submission: s.submission || [],
|
|
211
|
-
})),
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Validate input data
|
|
216
|
-
* @param data Input data
|
|
217
|
-
* @param schema Zod schema
|
|
218
|
-
* @returns Validated data
|
|
219
|
-
*/
|
|
220
|
-
export function validateInput(data, schema) {
|
|
221
|
-
return schema.parse(data);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Get environment configuration
|
|
225
|
-
* @param env Environment parameters
|
|
226
|
-
* @returns Environment configuration
|
|
227
|
-
*/
|
|
228
|
-
export function getEnvConfig(env) {
|
|
229
|
-
return env || {};
|
|
230
|
-
}
|
|
1
|
+
import{ResponseData,LocalMark,enrichMoveError}from'wowok';export function handleCallResult(a){if(a&&'error'in a){const c=enrichMoveError(a['error']),d={'message':'Error:\x20'+c,'result':{'type':'error','error':c}};return{'content':[{'type':'text','text':d['message']}],'structuredContent':d};}if(a&&'digest'in a){const e=ResponseData(a),f=a?.['effects']?.['status']?.['status'],g=a?.['effects']?.['status']?.['error'],h=f==='success';if(!h){const j=enrichMoveError(g||f||'unknown\x20error'),k={'message':'Transaction\x20failed:\x20'+j,'result':{'type':'error','error':j}};return{'content':[{'type':'text','text':k['message']},{'type':'text','text':JSON['stringify'](e)}],'structuredContent':k};}const i={'message':'Transaction\x20completed\x20successfully','result':{'type':'transaction',...a}};return{'content':[{'type':'text','text':i['message']},{'type':'text','text':JSON['stringify'](e)}],'structuredContent':i};}if(a&&'guard'in a&&'submission'in a){const l={'message':'Submission\x20required\x20for\x20Guard\x20verification','result':{'type':'submission',...a}};return{'content':[{'type':'text','text':l['message']},{'type':'text','text':JSON['stringify'](a)}],'structuredContent':l};}if(Array['isArray'](a)){const m={'message':'Operation\x20completed','result':{'type':'data','data':a}};return{'content':[{'type':'text','text':m['message']},{'type':'text','text':JSON['stringify'](a)}],'structuredContent':m};}if(a===undefined||a===null){const n={'message':'Operation\x20completed','result':{'type':'null'}};return{'content':[{'type':'text','text':n['message']}],'structuredContent':n};}const b={'message':'Operation\x20completed','result':{'type':'transaction',...a}};return{'content':[{'type':'text','text':b['message']}],'structuredContent':b};}export function createServerConfig(a,b){return{'name':a['name'],'version':a['version'],'description':b||a['description']};}export function createCapabilitiesConfig(){return{'capabilities':{'prompts':{},'resources':{},'tools':{'listChanged':!![]},'logging':{}}};}export function createToolMeta(a,b){return{'author':'WOWOK\x20Team','createdAt':'2026-02-01','lastUpdated':'2026-02-01','category':a,'tags':b,'requiresAuth':![]};}export function createToolAnnotations(a=![],b=![]){return{'readOnlyHint':a,'destructiveHint':b,'idempotentHint':!![],'openWorldHint':![]};}export async function transformSubmission(a){if(!a)return undefined;const b=(a['guard']||[])['map'](h=>h['object'])['filter'](Boolean),c=(a['submission']||[])['map'](h=>h['guard'])['filter'](Boolean),d=[...new Set([...b,...c])],e=d['length']>0x0?await LocalMark['Instance']()['get_many_address'](d):[],f=new Map();d['forEach']((h,i)=>{const j=e[i];j&&f['set'](h,j);});const g=h=>{if(f['has'](h))return f['get'](h);for(const [i,j]of f['entries']()){if(i===h)return j;}if(h['startsWith']('0x')&&h['length']===0x42)return h;throw new Error('Guard\x20name\x20or\x20address\x20not\x20found:\x20'+h);};return{'type':'submission','guard':(a['guard']||[])['map'](h=>({'object':g(h['object']),'impack':h['impack']||![]})),'submission':(a['submission']||[])['map'](h=>({'guard':g(h['guard']),'submission':h['submission']||[]}))};}export function validateInput(a,b){return b['parse'](a);}export function getEnvConfig(a){return a||{};}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './base.js';
|
|
3
|
-
export * from './handler.js';
|
|
4
|
-
export * from './contact.js';
|
|
5
|
-
export * from './demand.js';
|
|
6
|
-
export * from './guard.js';
|
|
7
|
-
export * from './machine.js';
|
|
8
|
-
export * from './arbitration.js';
|
|
9
|
-
export * from './allocation.js';
|
|
10
|
-
export * from './order.js';
|
|
11
|
-
export * from './payment.js';
|
|
12
|
-
export * from './permission.js';
|
|
13
|
-
export * from './personal.js';
|
|
14
|
-
export * from './proof.js';
|
|
15
|
-
export * from './progress.js';
|
|
16
|
-
export * from './repository.js';
|
|
17
|
-
export * from './reward.js';
|
|
18
|
-
export * from './service.js';
|
|
19
|
-
export * from './treasury.js';
|
|
1
|
+
export*from'./base.js';export*from'./handler.js';export*from'./contact.js';export*from'./demand.js';export*from'./guard.js';export*from'./machine.js';export*from'./arbitration.js';export*from'./allocation.js';export*from'./order.js';export*from'./payment.js';export*from'./permission.js';export*from'./personal.js';export*from'./proof.js';export*from'./progress.js';export*from'./repository.js';export*from'./reward.js';export*from'./service.js';export*from'./treasury.js';
|
|
@@ -1,164 +1 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { WithPermissionObjectSchema, NamedObjectSchema, ObjectsSchema, CallEnvSchema, SubmissionCallSchema, } from './base.js';
|
|
3
|
-
import { MachineNodeSchema, PermissionIndexTypeSchema } from '../query/index.js';
|
|
4
|
-
import { ManyAccountOrMark_AddressSchema, NameOrAddressSchema, NameSchema, NotEmptyNameSchema, ReceivedObjectsOrRecentlySchema } from '../common/index.js';
|
|
5
|
-
// progress_new的progress_namedOperator字段类型
|
|
6
|
-
export const ProgressNamedOperatorSchema = z.object({
|
|
7
|
-
op: z.union([z.literal('add'), z.literal('set'), z.literal('remove')]),
|
|
8
|
-
name: NotEmptyNameSchema,
|
|
9
|
-
operators: ManyAccountOrMark_AddressSchema,
|
|
10
|
-
}).strict();
|
|
11
|
-
// progress_new字段类型
|
|
12
|
-
export const ProgressNewSchema = z.object({
|
|
13
|
-
task: z.union([NameOrAddressSchema, z.null()]).optional().describe('Task bound to the Progress object. It is an object ID or name'),
|
|
14
|
-
repository: ObjectsSchema.optional().describe('Set repository list for the Progress object. Used for consensus data management.'),
|
|
15
|
-
progress_namedOperator: ProgressNamedOperatorSchema.optional().describe('Add, set, and remove operators for the permission namespace of the Progress object.'),
|
|
16
|
-
namedNew: NamedObjectSchema.optional(),
|
|
17
|
-
}).strict();
|
|
18
|
-
// node字段的add forward类型
|
|
19
|
-
export const NodeAddForwardDataSchema = z.object({
|
|
20
|
-
prior_node_name: NameSchema.describe('Name of the previous node.'),
|
|
21
|
-
node_name: NameSchema.describe('Name of the next node.'),
|
|
22
|
-
forward: z.array(z.object({
|
|
23
|
-
name: NameSchema.describe('Name of the operation'),
|
|
24
|
-
namedOperator: z.union([NotEmptyNameSchema, z.null()]).optional().describe('One of the operation permissions: use operators within the permission space name in the Machine object. Each Progress object can manage operators independently. Use empty string "" to indicate the order permission (order owner and agents can operate). When using Order object to operate progress, empty string namedOperator allows order owner/agents to execute the forward without needing other permissions.'),
|
|
25
|
-
permissionIndex: z.union([PermissionIndexTypeSchema, z.null()]).optional().describe('Second operation permission: use operators specified by the permission index of the Permission object in the Machine object. All Progress objects share the same operators.'),
|
|
26
|
-
weight: z.number().min(0).max(65535).int().describe('Weight of the operation'),
|
|
27
|
-
}).strict()).describe('List of operations between the previous and next nodes.'),
|
|
28
|
-
threshold: z.union([z.number().int().min(0), z.null()]).optional().describe('Threshold of operations that need to be completed to migrate from the previous node to the next node.'),
|
|
29
|
-
}).strict();
|
|
30
|
-
// node字段的remove forward类型
|
|
31
|
-
export const NodeRemoveForwardDataSchema = z.object({
|
|
32
|
-
prior_node_name: NameSchema.describe('Name of the previous node.'),
|
|
33
|
-
node_name: NameSchema.describe('Name of the next node.'),
|
|
34
|
-
forward_name: z.array(NameSchema).describe('List of operation names to delete.'),
|
|
35
|
-
}).strict();
|
|
36
|
-
// node字段的remove prior node类型
|
|
37
|
-
export const NodeRemovePriorNodeDataSchema = z.object({
|
|
38
|
-
prior_node_name: z.array(NameSchema).describe('List of previous node names to delete.'),
|
|
39
|
-
node_name: NameSchema.describe('Name of the next node.'),
|
|
40
|
-
}).strict();
|
|
41
|
-
// node字段类型
|
|
42
|
-
export const NodeSchema = z.discriminatedUnion('op', [
|
|
43
|
-
z.object({
|
|
44
|
-
op: z.literal('add'),
|
|
45
|
-
nodes: z.array(MachineNodeSchema).describe('List of nodes to add or set.'),
|
|
46
|
-
bReplace: z.boolean().optional().describe('Whether to replace existing nodes. If true, existing nodes will be replaced; if false, nodes will be added by merging.'),
|
|
47
|
-
}).strict().describe('Add nodes.'),
|
|
48
|
-
z.object({
|
|
49
|
-
op: z.literal('set'),
|
|
50
|
-
nodes: z.array(MachineNodeSchema).describe('List of nodes to add or set.'),
|
|
51
|
-
bReplace: z.boolean().optional().describe('Whether to replace existing nodes. If true, existing nodes will be replaced; if false, nodes will be added by merging.'),
|
|
52
|
-
}).strict().describe('Set nodes.'),
|
|
53
|
-
z.object({
|
|
54
|
-
op: z.literal('remove'),
|
|
55
|
-
nodes: z.array(NameSchema).describe('List of node names to delete.'),
|
|
56
|
-
}).strict().describe('Delete nodes.'),
|
|
57
|
-
z.object({
|
|
58
|
-
op: z.literal('clear'),
|
|
59
|
-
}).strict().describe('Clear all nodes.'),
|
|
60
|
-
z.object({
|
|
61
|
-
op: z.literal('exchange'),
|
|
62
|
-
node_one: NameSchema.describe('Name of the first node.'),
|
|
63
|
-
node_other: NameSchema.describe('Name of the second node.'),
|
|
64
|
-
}).strict().describe('Exchange the positions of two nodes.'),
|
|
65
|
-
z.object({
|
|
66
|
-
op: z.literal('rename'),
|
|
67
|
-
node_name_old: NameSchema.describe('Name of thenode.'),
|
|
68
|
-
node_name_new: NameSchema.describe('New name of the node.'),
|
|
69
|
-
}).strict().describe('Rename node.'),
|
|
70
|
-
z.object({
|
|
71
|
-
op: z.literal('remove prior node'),
|
|
72
|
-
pairs: z.array(NodeRemovePriorNodeDataSchema).describe('List of previous-next node pairs to delete.'),
|
|
73
|
-
}).strict().describe('Delete previous-next node pairs.'),
|
|
74
|
-
z.object({
|
|
75
|
-
op: z.literal('add forward'),
|
|
76
|
-
data: z.array(NodeAddForwardDataSchema).describe('List of operations to add.'),
|
|
77
|
-
}).strict().describe('Add operations.'),
|
|
78
|
-
z.object({
|
|
79
|
-
op: z.literal('remove forward'),
|
|
80
|
-
data: z.array(NodeRemoveForwardDataSchema).describe('List of operations to delete.'),
|
|
81
|
-
}).strict().describe('Delete operations.'),
|
|
82
|
-
]);
|
|
83
|
-
// json_or_markdown_file 模式:从文件读取并完全替换节点定义
|
|
84
|
-
export const NodeJsonOrMarkdownFileSchema = z.object({
|
|
85
|
-
json_or_markdown_file: z.string().describe(`Path to a JSON or Markdown file containing node array for COMPLETE REPLACEMENT of all nodes.
|
|
86
|
-
|
|
87
|
-
**File Format Requirements:**
|
|
88
|
-
- Must contain a JSON ARRAY of node objects: [{"name": "...", "pairs": [...]}, {...}]
|
|
89
|
-
- NOT an operation object with "op" field (use NodeSchema for operations)
|
|
90
|
-
- Supports JSON or Markdown (with \`\`\`json code blocks)
|
|
91
|
-
|
|
92
|
-
**Node Structure:**
|
|
93
|
-
Each node is a directed graph element representing workflow states and transitions:
|
|
94
|
-
- name: Node identifier
|
|
95
|
-
- pairs: Array of {prior_node, forwards, threshold} defining connections
|
|
96
|
-
- forwards: Operations available from this node
|
|
97
|
-
- threshold: Required weight to advance
|
|
98
|
-
|
|
99
|
-
**Behavior:**
|
|
100
|
-
- COMPLETELY REPLACES all existing nodes (equivalent to "set" with bReplace=true)
|
|
101
|
-
- Auto-detects format based on file content
|
|
102
|
-
- If parsing fails, error includes line number and column information`),
|
|
103
|
-
}).strict();
|
|
104
|
-
// node 字段支持两种模式
|
|
105
|
-
export const NodeFieldSchema = z.union([
|
|
106
|
-
NodeSchema,
|
|
107
|
-
NodeJsonOrMarkdownFileSchema,
|
|
108
|
-
]);
|
|
109
|
-
// CallMachine_Data类型
|
|
110
|
-
export const CallMachine_DataSchema = z.object({
|
|
111
|
-
object: WithPermissionObjectSchema,
|
|
112
|
-
progress_new: ProgressNewSchema.optional().describe('Generate new Progress object.'),
|
|
113
|
-
description: z.string().optional().describe('Description of the object.'),
|
|
114
|
-
repository: ObjectsSchema.optional().describe('Set repository list for the object. Used for consensus data management.'),
|
|
115
|
-
node: NodeFieldSchema.optional().describe(`CRITICAL: Choose ONE of two mutually exclusive modes:
|
|
116
|
-
|
|
117
|
-
**Mode 1: NodeSchema (incremental operations)**
|
|
118
|
-
Use for partial modifications: add, set, remove, clear, exchange, rename, remove prior node, add forward, remove forward.
|
|
119
|
-
Format: { "op": "add", "nodes": [...], "bReplace": false }
|
|
120
|
-
This mode modifies existing nodes incrementally.
|
|
121
|
-
|
|
122
|
-
**Mode 2: NodeJsonOrMarkdownFileSchema (complete replacement)**
|
|
123
|
-
Use for complete node redefinition from file.
|
|
124
|
-
Format: { "json_or_markdown_file": "/path/to/nodes.json" }
|
|
125
|
-
IMPORTANT: This COMPLETELY REPLACES all existing nodes. File must contain node array [{...}, {...}], NOT an operation object with "op" field.
|
|
126
|
-
Supported formats: JSON array or Markdown with code blocks.
|
|
127
|
-
If parsing fails, error includes line number and column information.`),
|
|
128
|
-
pause: z.boolean().optional().describe('Whether to pause generating new Progress objects.'),
|
|
129
|
-
publish: z.boolean().optional().describe('Whether to publish the object. After the object is published, new Progress objects can be generated; and node settings will no longer be changeable.'),
|
|
130
|
-
owner_receive: ReceivedObjectsOrRecentlySchema.optional().describe('Unwrap CoinWrapper objects and other objects received by this object and send them to the owner of its Permission object.'),
|
|
131
|
-
um: z.union([z.string(), z.null()]).optional().describe('Contact object.'),
|
|
132
|
-
}).strict().describe("On-chain Machine operations. USAGE: (1) CREATE NEW: Set 'object' field with OBJECT format {name, permission, ...} to create a Machine. NOTE: 'name' goes INSIDE 'object', NOT at the data root level. 'permission' can be a new Permission object or reference an existing one - check 'object' field description for details. (2) OPERATE EXISTING: Set 'object' field with STRING format (object ID or name). The 'object' field is CRITICAL and REQUIRED in both cases. STRING for existing, OBJECT for new creation.");
|
|
133
|
-
export const CallMachine_InputSchema = z.object({
|
|
134
|
-
data: CallMachine_DataSchema,
|
|
135
|
-
env: CallEnvSchema.optional(),
|
|
136
|
-
submission: SubmissionCallSchema.optional(),
|
|
137
|
-
}).strict();
|
|
138
|
-
// MachineNode2File_InputSchema - 用于 machineNode2file 函数
|
|
139
|
-
export const MachineNode2File_InputSchema = z.object({
|
|
140
|
-
machine: NameOrAddressSchema.describe("Machine object ID or name to export"),
|
|
141
|
-
file_path: z.string().describe("Output file path (absolute or relative)"),
|
|
142
|
-
format: z.enum(["json", "markdown"]).optional().describe("Output format: 'json' (default) or 'markdown'"),
|
|
143
|
-
env: CallEnvSchema.optional(),
|
|
144
|
-
}).strict().describe("Query a Machine object from the blockchain and export its node definition to a JSON or Markdown file. The exported file can be edited and used to create new Machine objects.");
|
|
145
|
-
// MachineNode2File_OutputSchema - machineNode2file 输出 schema
|
|
146
|
-
export const MachineNode2File_OutputSchema = z.discriminatedUnion("status", [
|
|
147
|
-
z.object({
|
|
148
|
-
status: z.literal("success"),
|
|
149
|
-
data: z.object({
|
|
150
|
-
file_path: z.string().describe("Absolute path of the exported file"),
|
|
151
|
-
format: z.enum(["json", "markdown"]).describe("Export format"),
|
|
152
|
-
machine_object: NameOrAddressSchema.describe("Machine object ID"),
|
|
153
|
-
node_count: z.number().describe("Number of nodes exported"),
|
|
154
|
-
}).strict().describe("Success result data"),
|
|
155
|
-
}).strict(),
|
|
156
|
-
z.object({
|
|
157
|
-
status: z.literal("error"),
|
|
158
|
-
error: z.string().describe("Error message"),
|
|
159
|
-
}).strict(),
|
|
160
|
-
]).describe("MachineNode2File operation output");
|
|
161
|
-
// MachineNode2File_OutputWrappedSchema - 包装后的输出 schema
|
|
162
|
-
export const MachineNode2File_OutputWrappedSchema = z.object({
|
|
163
|
-
result: MachineNode2File_OutputSchema,
|
|
164
|
-
}).strict().describe("MachineNode2File operation output wrapped schema");
|
|
1
|
+
import{z}from'zod';import{WithPermissionObjectSchema,NamedObjectSchema,ObjectsSchema,CallEnvSchema,SubmissionCallSchema}from'./base.js';import{MachineNodeSchema,PermissionIndexTypeSchema}from'../query/index.js';import{ManyAccountOrMark_AddressSchema,NameOrAddressSchema,NameSchema,NotEmptyNameSchema,ReceivedObjectsOrRecentlySchema}from'../common/index.js';export const ProgressNamedOperatorSchema=z['object']({'op':z['union']([z['literal']('add'),z['literal']('set'),z['literal']('remove')]),'name':NotEmptyNameSchema,'operators':ManyAccountOrMark_AddressSchema})['strict']();export const ProgressNewSchema=z['object']({'task':z['union']([NameOrAddressSchema,z['null']()])['optional']()['describe']('Task\x20bound\x20to\x20the\x20Progress\x20object.\x20It\x20is\x20an\x20object\x20ID\x20or\x20name'),'repository':ObjectsSchema['optional']()['describe']('Set\x20repository\x20list\x20for\x20the\x20Progress\x20object.\x20Used\x20for\x20consensus\x20data\x20management.'),'progress_namedOperator':ProgressNamedOperatorSchema['optional']()['describe']('Add,\x20set,\x20and\x20remove\x20operators\x20for\x20the\x20permission\x20namespace\x20of\x20the\x20Progress\x20object.'),'namedNew':NamedObjectSchema['optional']()})['strict']();export const NodeAddForwardDataSchema=z['object']({'prior_node_name':NameSchema['describe']('Name\x20of\x20the\x20previous\x20node.'),'node_name':NameSchema['describe']('Name\x20of\x20the\x20next\x20node.'),'forward':z['array'](z['object']({'name':NameSchema['describe']('Name\x20of\x20the\x20operation'),'namedOperator':z['union']([NotEmptyNameSchema,z['null']()])['optional']()['describe']('One\x20of\x20the\x20operation\x20permissions:\x20use\x20operators\x20within\x20the\x20permission\x20space\x20name\x20in\x20the\x20Machine\x20object.\x20Each\x20Progress\x20object\x20can\x20manage\x20operators\x20independently.\x20Use\x20empty\x20string\x20\x22\x22\x20to\x20indicate\x20the\x20order\x20permission\x20(order\x20owner\x20and\x20agents\x20can\x20operate).\x20When\x20using\x20Order\x20object\x20to\x20operate\x20progress,\x20empty\x20string\x20namedOperator\x20allows\x20order\x20owner/agents\x20to\x20execute\x20the\x20forward\x20without\x20needing\x20other\x20permissions.'),'permissionIndex':z['union']([PermissionIndexTypeSchema,z['null']()])['optional']()['describe']('Second\x20operation\x20permission:\x20use\x20operators\x20specified\x20by\x20the\x20permission\x20index\x20of\x20the\x20Permission\x20object\x20in\x20the\x20Machine\x20object.\x20All\x20Progress\x20objects\x20share\x20the\x20same\x20operators.'),'weight':z['number']()['min'](0x0)['max'](0xffff)['int']()['describe']('Weight\x20of\x20the\x20operation')})['strict']())['describe']('List\x20of\x20operations\x20between\x20the\x20previous\x20and\x20next\x20nodes.'),'threshold':z['union']([z['number']()['int']()['min'](0x0),z['null']()])['optional']()['describe']('Threshold\x20of\x20operations\x20that\x20need\x20to\x20be\x20completed\x20to\x20migrate\x20from\x20the\x20previous\x20node\x20to\x20the\x20next\x20node.')})['strict']();export const NodeRemoveForwardDataSchema=z['object']({'prior_node_name':NameSchema['describe']('Name\x20of\x20the\x20previous\x20node.'),'node_name':NameSchema['describe']('Name\x20of\x20the\x20next\x20node.'),'forward_name':z['array'](NameSchema)['describe']('List\x20of\x20operation\x20names\x20to\x20delete.')})['strict']();export const NodeRemovePriorNodeDataSchema=z['object']({'prior_node_name':z['array'](NameSchema)['describe']('List\x20of\x20previous\x20node\x20names\x20to\x20delete.'),'node_name':NameSchema['describe']('Name\x20of\x20the\x20next\x20node.')})['strict']();export const NodeSchema=z['discriminatedUnion']('op',[z['object']({'op':z['literal']('add'),'nodes':z['array'](MachineNodeSchema)['describe']('List\x20of\x20nodes\x20to\x20add\x20or\x20set.'),'bReplace':z['boolean']()['optional']()['describe']('Whether\x20to\x20replace\x20existing\x20nodes.\x20If\x20true,\x20existing\x20nodes\x20will\x20be\x20replaced;\x20if\x20false,\x20nodes\x20will\x20be\x20added\x20by\x20merging.')})['strict']()['describe']('Add\x20nodes.'),z['object']({'op':z['literal']('set'),'nodes':z['array'](MachineNodeSchema)['describe']('List\x20of\x20nodes\x20to\x20add\x20or\x20set.'),'bReplace':z['boolean']()['optional']()['describe']('Whether\x20to\x20replace\x20existing\x20nodes.\x20If\x20true,\x20existing\x20nodes\x20will\x20be\x20replaced;\x20if\x20false,\x20nodes\x20will\x20be\x20added\x20by\x20merging.')})['strict']()['describe']('Set\x20nodes.'),z['object']({'op':z['literal']('remove'),'nodes':z['array'](NameSchema)['describe']('List\x20of\x20node\x20names\x20to\x20delete.')})['strict']()['describe']('Delete\x20nodes.'),z['object']({'op':z['literal']('clear')})['strict']()['describe']('Clear\x20all\x20nodes.'),z['object']({'op':z['literal']('exchange'),'node_one':NameSchema['describe']('Name\x20of\x20the\x20first\x20node.'),'node_other':NameSchema['describe']('Name\x20of\x20the\x20second\x20node.')})['strict']()['describe']('Exchange\x20the\x20positions\x20of\x20two\x20nodes.'),z['object']({'op':z['literal']('rename'),'node_name_old':NameSchema['describe']('Name\x20of\x20thenode.'),'node_name_new':NameSchema['describe']('New\x20name\x20of\x20the\x20node.')})['strict']()['describe']('Rename\x20node.'),z['object']({'op':z['literal']('remove\x20prior\x20node'),'pairs':z['array'](NodeRemovePriorNodeDataSchema)['describe']('List\x20of\x20previous-next\x20node\x20pairs\x20to\x20delete.')})['strict']()['describe']('Delete\x20previous-next\x20node\x20pairs.'),z['object']({'op':z['literal']('add\x20forward'),'data':z['array'](NodeAddForwardDataSchema)['describe']('List\x20of\x20operations\x20to\x20add.')})['strict']()['describe']('Add\x20operations.'),z['object']({'op':z['literal']('remove\x20forward'),'data':z['array'](NodeRemoveForwardDataSchema)['describe']('List\x20of\x20operations\x20to\x20delete.')})['strict']()['describe']('Delete\x20operations.')]);export const NodeJsonOrMarkdownFileSchema=z['object']({'json_or_markdown_file':z['string']()['describe']('Path\x20to\x20a\x20JSON\x20or\x20Markdown\x20file\x20containing\x20node\x20array\x20for\x20COMPLETE\x20REPLACEMENT\x20of\x20all\x20nodes.\x0a\x0a**File\x20Format\x20Requirements:**\x0a-\x20Must\x20contain\x20a\x20JSON\x20ARRAY\x20of\x20node\x20objects:\x20[{\x22name\x22:\x20\x22...\x22,\x20\x22pairs\x22:\x20[...]},\x20{...}]\x0a-\x20NOT\x20an\x20operation\x20object\x20with\x20\x22op\x22\x20field\x20(use\x20NodeSchema\x20for\x20operations)\x0a-\x20Supports\x20JSON\x20or\x20Markdown\x20(with\x20```json\x20code\x20blocks)\x0a\x0a**Node\x20Structure:**\x0aEach\x20node\x20is\x20a\x20directed\x20graph\x20element\x20representing\x20workflow\x20states\x20and\x20transitions:\x0a-\x20name:\x20Node\x20identifier\x0a-\x20pairs:\x20Array\x20of\x20{prior_node,\x20forwards,\x20threshold}\x20defining\x20connections\x0a-\x20forwards:\x20Operations\x20available\x20from\x20this\x20node\x0a-\x20threshold:\x20Required\x20weight\x20to\x20advance\x0a\x0a**Behavior:**\x0a-\x20COMPLETELY\x20REPLACES\x20all\x20existing\x20nodes\x20(equivalent\x20to\x20\x22set\x22\x20with\x20bReplace=true)\x0a-\x20Auto-detects\x20format\x20based\x20on\x20file\x20content\x0a-\x20If\x20parsing\x20fails,\x20error\x20includes\x20line\x20number\x20and\x20column\x20information')})['strict']();export const NodeFieldSchema=z['union']([NodeSchema,NodeJsonOrMarkdownFileSchema]);export const CallMachine_DataSchema=z['object']({'object':WithPermissionObjectSchema,'progress_new':ProgressNewSchema['optional']()['describe']('Generate\x20new\x20Progress\x20object.'),'description':z['string']()['optional']()['describe']('Description\x20of\x20the\x20object.'),'repository':ObjectsSchema['optional']()['describe']('Set\x20repository\x20list\x20for\x20the\x20object.\x20Used\x20for\x20consensus\x20data\x20management.'),'node':NodeFieldSchema['optional']()['describe']('CRITICAL:\x20Choose\x20ONE\x20of\x20two\x20mutually\x20exclusive\x20modes:\x0a\x0a**Mode\x201:\x20NodeSchema\x20(incremental\x20operations)**\x0aUse\x20for\x20partial\x20modifications:\x20add,\x20set,\x20remove,\x20clear,\x20exchange,\x20rename,\x20remove\x20prior\x20node,\x20add\x20forward,\x20remove\x20forward.\x0aFormat:\x20{\x20\x22op\x22:\x20\x22add\x22,\x20\x22nodes\x22:\x20[...],\x20\x22bReplace\x22:\x20false\x20}\x0aThis\x20mode\x20modifies\x20existing\x20nodes\x20incrementally.\x0a\x0a**Mode\x202:\x20NodeJsonOrMarkdownFileSchema\x20(complete\x20replacement)**\x0aUse\x20for\x20complete\x20node\x20redefinition\x20from\x20file.\x0aFormat:\x20{\x20\x22json_or_markdown_file\x22:\x20\x22/path/to/nodes.json\x22\x20}\x0aIMPORTANT:\x20This\x20COMPLETELY\x20REPLACES\x20all\x20existing\x20nodes.\x20File\x20must\x20contain\x20node\x20array\x20[{...},\x20{...}],\x20NOT\x20an\x20operation\x20object\x20with\x20\x22op\x22\x20field.\x0aSupported\x20formats:\x20JSON\x20array\x20or\x20Markdown\x20with\x20code\x20blocks.\x0aIf\x20parsing\x20fails,\x20error\x20includes\x20line\x20number\x20and\x20column\x20information.'),'pause':z['boolean']()['optional']()['describe']('Whether\x20to\x20pause\x20generating\x20new\x20Progress\x20objects.'),'publish':z['boolean']()['optional']()['describe']('Whether\x20to\x20publish\x20the\x20object.\x20After\x20the\x20object\x20is\x20published,\x20new\x20Progress\x20objects\x20can\x20be\x20generated;\x20and\x20node\x20settings\x20will\x20no\x20longer\x20be\x20changeable.'),'owner_receive':ReceivedObjectsOrRecentlySchema['optional']()['describe']('Unwrap\x20CoinWrapper\x20objects\x20and\x20other\x20objects\x20received\x20by\x20this\x20object\x20and\x20send\x20them\x20to\x20the\x20owner\x20of\x20its\x20Permission\x20object.'),'um':z['union']([z['string'](),z['null']()])['optional']()['describe']('Contact\x20object.')})['strict']()['describe']('On-chain\x20Machine\x20operations.\x20USAGE:\x20(1)\x20CREATE\x20NEW:\x20Set\x20\x27object\x27\x20field\x20with\x20OBJECT\x20format\x20{name,\x20permission,\x20...}\x20to\x20create\x20a\x20Machine.\x20NOTE:\x20\x27name\x27\x20goes\x20INSIDE\x20\x27object\x27,\x20NOT\x20at\x20the\x20data\x20root\x20level.\x20\x27permission\x27\x20can\x20be\x20a\x20new\x20Permission\x20object\x20or\x20reference\x20an\x20existing\x20one\x20-\x20check\x20\x27object\x27\x20field\x20description\x20for\x20details.\x20(2)\x20OPERATE\x20EXISTING:\x20Set\x20\x27object\x27\x20field\x20with\x20STRING\x20format\x20(object\x20ID\x20or\x20name).\x20The\x20\x27object\x27\x20field\x20is\x20CRITICAL\x20and\x20REQUIRED\x20in\x20both\x20cases.\x20STRING\x20for\x20existing,\x20OBJECT\x20for\x20new\x20creation.');export const CallMachine_InputSchema=z['object']({'data':CallMachine_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['strict']();export const MachineNode2File_InputSchema=z['object']({'machine':NameOrAddressSchema['describe']('Machine\x20object\x20ID\x20or\x20name\x20to\x20export'),'file_path':z['string']()['describe']('Output\x20file\x20path\x20(absolute\x20or\x20relative)'),'format':z['enum'](['json','markdown'])['optional']()['describe']('Output\x20format:\x20\x27json\x27\x20(default)\x20or\x20\x27markdown\x27'),'env':CallEnvSchema['optional']()})['strict']()['describe']('Query\x20a\x20Machine\x20object\x20from\x20the\x20blockchain\x20and\x20export\x20its\x20node\x20definition\x20to\x20a\x20JSON\x20or\x20Markdown\x20file.\x20The\x20exported\x20file\x20can\x20be\x20edited\x20and\x20used\x20to\x20create\x20new\x20Machine\x20objects.');export const MachineNode2File_OutputSchema=z['discriminatedUnion']('status',[z['object']({'status':z['literal']('success'),'data':z['object']({'file_path':z['string']()['describe']('Absolute\x20path\x20of\x20the\x20exported\x20file'),'format':z['enum'](['json','markdown'])['describe']('Export\x20format'),'machine_object':NameOrAddressSchema['describe']('Machine\x20object\x20ID'),'node_count':z['number']()['describe']('Number\x20of\x20nodes\x20exported')})['strict']()['describe']('Success\x20result\x20data')})['strict'](),z['object']({'status':z['literal']('error'),'error':z['string']()['describe']('Error\x20message')})['strict']()])['describe']('MachineNode2File\x20operation\x20output');export const MachineNode2File_OutputWrappedSchema=z['object']({'result':MachineNode2File_OutputSchema})['strict']()['describe']('MachineNode2File\x20operation\x20output\x20wrapped\x20schema');
|