wowok_agent
Version:
Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
59 lines (58 loc) • 5.38 kB
JavaScript
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 computational tree root node. MUST return a Bool value (pass/fail)."),
}).strict(),
z.object({
type: z.literal("file"),
file_path: z.string().describe("Path to JSON or Markdown file containing Guard definition. File can define: namedNew, description, table, root, rely."),
format: z.enum(["json", "markdown"]).optional().default("json")
.describe("File format: 'json' or 'markdown'. Default is 'json'."),
}).strict(),
]).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.");
export const CallGuard_DataSchema = z.object({
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."),
description: DescriptionSchema.optional().describe("Guard description. When using root.type='file', this field OVERRIDES description in the file."),
table: z.array(GuardTableItemBaseSchema).optional().describe("Data table of the Guard object. When using root.type='file', this field OVERRIDES table in the file."),
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."),
rely: z.object({
guards: z.array(NameOrAddressSchema).describe("List of dependent Guard object IDs or names."),
logic_or: z.boolean().optional().describe("Whether to use logical OR operator."),
}).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."),
}).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.");
export const CallGuard_InputSchema = z.object({
data: CallGuard_DataSchema.describe("Guard data definition."),
env: CallEnvSchema.optional(),
}).strict().describe("On-chain Guard creation input wrapper. Contains the Guard data definition and optional environment settings.");
export const CallGenPassport_InputSchema = z.object({
guard: z.union([NameOrAddressSchema, z.array(NameOrAddressSchema)]).describe("Guard object ID(s) to verify and generate passport from. Can be a single guard (string) or multiple guards (array of strings). Supports guard names or addresses."),
info: SubmissionCallSchema.optional().describe("Optional submission data. If not provided, will attempt to get existing submissions from the guard."),
env: CallEnvSchema.optional(),
}).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. Supports verifying multiple guards at once.");
export const Guard2File_InputSchema = z.object({
guard: NameOrAddressSchema.describe("Guard object ID or name to export"),
file_path: z.string().describe("Output file path (absolute or relative)"),
format: z.enum(["json", "markdown"]).optional().describe("Output format: 'json' (default) or 'markdown'"),
env: CallEnvSchema.optional(),
}).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.");
export const Guard2File_OutputSchema = z.discriminatedUnion("status", [
z.object({
status: z.literal("success"),
data: z.object({
file_path: z.string().describe("Absolute path of the exported file"),
format: z.enum(["json", "markdown"]).describe("Export format"),
guard_object: z.string().describe("Guard object ID"),
}).strict().describe("Success result data"),
}).strict(),
z.object({
status: z.literal("error"),
error: z.string().describe("Error message"),
}).strict(),
]).describe("Guard2File operation output schema with discriminator");
export const Guard2File_OutputWrappedSchema = z.object({
result: Guard2File_OutputSchema,
}).strict().describe("Guard2File operation output wrapped schema");