wowok_agent
Version:
Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
48 lines (47 loc) • 3.43 kB
JavaScript
import { z } from 'zod';
import { WithPermissionObjectSchema, ObjectsSchema, CallEnvSchema, SubmissionCallSchema, } from './base.js';
import { ServiceGuardSchema } from '../query/index.js';
import { AccountOrMark_AddressSchema, DescriptionSchema, LongNameSchema, NameOrAddressSchema, ReceivedObjectsOrRecentlySchema } from '../common/index.js';
export const GuardsSchema = z.discriminatedUnion('op', [
z.object({
op: z.literal('add'),
guard: z.array(ServiceGuardSchema).describe('List of guard IDs or names to add'),
}).strict(),
z.object({
op: z.literal('set'),
guard: z.array(ServiceGuardSchema).describe('List of guard IDs or names to set'),
}).strict(),
z.object({
op: z.literal('remove'),
guard: z.array(NameOrAddressSchema).describe('List of guard IDs or names to remove'),
}).strict(),
z.object({
op: z.literal('clear'),
}).strict(),
]);
export const DemandPresentSchema = z.object({
recommend: DescriptionSchema.describe('Recommendation for the demand'),
by_guard: NameOrAddressSchema.optional().describe('Guard ID or name, used to select which Guard\'s verification to pass through'),
service: NameOrAddressSchema.optional().describe('Service ID or name to present'),
}).strict();
export const FeedbackInfoSchema = z.object({
who: AccountOrMark_AddressSchema.describe('Account address or mark name, used to identify providing feedback to this user'),
acceptance_score: z.number().int().min(0).max(255).optional().describe('Acceptance score, used to evaluate the reception level of the service recommended by the user'),
feedback: DescriptionSchema.optional().describe('Feedback content for the user'),
}).strict();
export const CallDemand_DataSchema = z.object({
object: WithPermissionObjectSchema,
present: DemandPresentSchema.optional().describe('Recommend Service to Demand object'),
description: DescriptionSchema.optional(),
location: LongNameSchema.optional().describe('Service location of the Demand object'),
rewards: ObjectsSchema.optional().describe('Reward information of the Demand object'),
feedback: z.array(FeedbackInfoSchema).optional().describe('User feedback information for the Demand object'),
guards: GuardsSchema.optional().describe('Validation Guard list for the Demand object. Used to verify whether the service recommended by the user meets the requirements'),
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.'),
um: z.union([NameOrAddressSchema, z.null()]).optional().describe('Contact object.'),
}).strict().describe("On-chain Demand operations. USAGE: (1) CREATE NEW: Set 'object' field with OBJECT format {name, permission, ...} to create a Demand. 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.");
export const CallDemand_InputSchema = z.object({
data: CallDemand_DataSchema,
env: CallEnvSchema.optional(),
submission: SubmissionCallSchema.optional(),
}).strict();