wowok_agent
Version:
Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
83 lines (82 loc) • 6.91 kB
JavaScript
import { z } from "zod";
import { TypedPermissionObjectSchema, CoinParamSchema, NamedObjectSchema, ObjectsSchema, CallEnvSchema, SubmissionCallSchema } from "./base.js";
import { AllocatorsSchema, DiscountTypeSchema, ServiceSaleSchema } from "../query/index.js";
import { AccountOrMark_AddressSchema, DescriptionSchema, LongNameSchema, ManyAccountOrMark_AddressSchema, NameOrAddressSchema, NotEmptyNameSchema, ReceivedBalanceOrRecentlySchema, ReceivedObjectsOrRecentlySchema } from "../common/index.js";
import { BalanceTypeSchema } from "../common/index.js";
export const ServiceBuyItemSchema = z.object({
name: LongNameSchema.describe("Name of the product or service to purchase"),
stock: BalanceTypeSchema.describe("Quantity of the product or service to purchase"),
wip_hash: z.string().describe("WIP file hash of the item"),
}).strict();
export const BuySchema = z.object({
items: z.array(ServiceBuyItemSchema).describe("List of products or services to purchase"),
total_pay: CoinParamSchema.describe("Actual payment amount"),
discount: z.string().optional().describe("Discount object ID or name"),
payment_remark: z.string().optional().describe("Payment remark"),
payment_index: z.number().optional().describe("Payment index"),
}).strict();
export const DiscountSchema = z.object({
name: z.string().describe("Discount name"),
discount_type: DiscountTypeSchema.describe("Discount type"),
discount_value: BalanceTypeSchema.describe("Discount value"),
benchmark: z.union([z.number(), z.string()]).optional().describe("Discount benchmark value. Discount is only applied if the amount exceeds this value"),
time_ms_start: z.number().optional().describe("Discount start time (milliseconds)"),
time_ms_end: z.number().optional().describe("Discount end time (milliseconds)"),
count: z.number().optional().describe("Discount usage count"),
recipient: ManyAccountOrMark_AddressSchema.describe("Discount recipient"),
transferable: z.boolean().optional().describe("Whether the discount object recipient can transfer the discount object"),
}).strict();
export const OrderNewSchema = z.object({
buy: BuySchema,
agents: ManyAccountOrMark_AddressSchema.optional().describe("Order agents. Agents can operate the order, such as canceling the order, modifying the order status, etc.; but cannot receive the funds received by the order."),
order_required_info: z.string().optional().describe("Contact object ID or WTS Proof object"),
transfer: AccountOrMark_AddressSchema.optional().describe("Set the new owner of the order. Requires order owner permission to set."),
namedNewOrder: NamedObjectSchema.optional().describe("Set the local name of the order object."),
namedNewAllocation: NamedObjectSchema.optional().describe("Set the local name of the order's Allocation object."),
namedNewProgress: NamedObjectSchema.optional().describe("Set the local name of the order's Progress object."),
}).strict();
export const SalesSchema = z.discriminatedUnion("op", [
z.object({
op: z.literal("add"),
sales: z.array(ServiceSaleSchema),
}).strict().describe("Add new sales products or services."),
z.object({
op: z.literal("set"),
sales: z.array(ServiceSaleSchema),
}).strict().describe("Set sales products or services."),
z.object({
op: z.literal("remove"),
sales_name: z.array(LongNameSchema.describe("Sales name")),
}).strict().describe("Remove existing sales products or services."),
z.object({
op: z.literal("clear"),
}).strict().describe("Clear all sales products or services."),
]);
export const CallService_DataSchema = z.object({
object: TypedPermissionObjectSchema,
order_new: OrderNewSchema.optional().describe("Create new order."),
description: DescriptionSchema.optional(),
location: LongNameSchema.optional().describe("Location of the Service"),
sales: SalesSchema.optional().describe("Service sales products or services list."),
repositories: ObjectsSchema.optional().describe("Service Repository object list."),
rewards: ObjectsSchema.optional().describe("Service Reward object list."),
arbitrations: ObjectsSchema.optional().describe("Service Arbitration object list."),
machine: z.union([NameOrAddressSchema, z.null()]).optional().describe("Service Machine object ID or name. The Machine object must be in published state."),
discount: DiscountSchema.optional().describe("Issue discount."),
discount_destroy: z.array(NameOrAddressSchema).optional().describe("Destroy existing discount object ID list."),
customer_required: z.array(NotEmptyNameSchema).optional().describe("Customer required information. Such as phone, email, etc."),
order_allocators: z.union([AllocatorsSchema, z.null()]).optional().describe("Order fund allocator."),
buy_guard: z.union([NameOrAddressSchema, z.null()]).optional().describe("Buy guard object ID or name."),
compensation_fund_add: CoinParamSchema.optional().describe("Compensation fund. Used to claim compensation based on the arbitration result of the Arb object when resolving order disputes."),
setting_locked_time_add: z.number().optional().describe("Additional lock duration (milliseconds) to extend the 'setting_lock_duration'. Initial value is 30 days, can only be increased, not decreased. Affects: rewards, arbitrations, and compensation_fund_receive."),
compensation_fund_receive: ReceivedBalanceOrRecentlySchema.optional().describe("Receive order compensation funds."),
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 ID or name."),
pause: z.boolean().optional().describe("Whether to pause accepting new orders."),
publish: z.boolean().optional().describe("Whether to publish the Service. After publishing, customers can place orders; at the same time, service commitments such as machine, order_allocators, arbitrations, etc. will be immutable."),
}).strict().describe("On-chain Service operations. USAGE: (1) CREATE NEW: Set 'object' field with OBJECT format {name, type_parameter, permission, ...} to create a Service. 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 CallService_InputSchema = z.object({
data: CallService_DataSchema,
env: CallEnvSchema.optional(),
submission: SubmissionCallSchema.optional(),
}).strict();