UNPKG

wowok_agent

Version:

Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.

77 lines (76 loc) 5.35 kB
import { z } from "zod"; import { WithPermissionObjectSchema, ObjectsSchema, CallEnvSchema, SubmissionCallSchema, } from "./base.js"; import { AccountOrMark_AddressSchema, DescriptionSchema, NameOrAddressSchema, NameSchema, ReceivedObjectsOrRecentlySchema } from "../common/index.js"; import { PolicyRuleSchema } from "../query/index.js"; import { SupportedValueSchema } from "../common/index.js"; export const RepositoryIdSchema = z.union([ AccountOrMark_AddressSchema, z.number().int(), ]).describe("Data item ID. If a number (such as time) is specified, it will be automatically converted to an address or ID type."); export const KeyDataSchema = z.object({ id: RepositoryIdSchema, data: SupportedValueSchema, }).strict().describe("Data ID and value."); export const RepDataItemSchema = z.object({ data: z.array(KeyDataSchema).describe("Data item list."), write_guard: NameOrAddressSchema.optional().describe("Guard ID or name. Used to specify the policy write permissions and rules corresponding to this Guard."), }).strict().describe("List of data items to write."); export const SignerOrClockBaseSchema = z.object({ name: NameSchema.describe("Data item name."), write_guard: NameOrAddressSchema.optional().describe("Guard ID or name. Used to specify the policy write permissions and rules corresponding to this Guard."), }).strict().describe("Specify data items by name and ID. ID is the on-chain timestamp or signer ID (depending on how write_guard specifies the ID source)."); export const SignerOrClockSchema = z.object({ name: NameSchema.describe("Data item name."), write_guard: NameOrAddressSchema.optional().describe("Guard ID or name. Used to specify the policy write permissions and rules corresponding to this Guard."), data: SupportedValueSchema, }).strict().describe("Specify data items by name and data. ID is the on-chain timestamp or signer ID (depending on how write_guard specifies the ID source)."); export const DataRemoveItemSchema = z.object({ id: z.array(RepositoryIdSchema).describe("Data item ID list."), write_guard: NameOrAddressSchema.optional().describe("Guard ID or name. Used to verify permission to delete data."), }).strict().describe("Delete data items by name and ID list."); export const PoliciesAddSetSchema = z.object({ op: z.enum(["add", "set"]), policy: z.array(PolicyRuleSchema).describe("Policy rule list."), }).strict().describe("Add or set policy rules."); export const PoliciesRemoveSchema = z.object({ op: z.literal("remove"), policy: z.array(NameSchema).describe("Policy rule name list."), }).strict().describe("Remove policy rules."); export const PoliciesClearSchema = z.object({ op: z.literal("clear"), }).strict().describe("Clear policy rules."); export const PoliciesSchema = z.discriminatedUnion("op", [ PoliciesAddSetSchema, PoliciesRemoveSchema, PoliciesClearSchema, ]); export const DataAddWithItemsSchema = z.object({ name: NameSchema.describe("Data item name. Must match the name in PolicyRule."), items: z.array(RepDataItemSchema).describe("List of data items to add. Each data item contains name, ID, and data parts, where name and ID together form the unique key for the data."), }).strict().describe("Add data by name and data item list. Each data item contains name, ID, and data parts, where name and ID together form the unique key for the data."); export const DataAddSchema = z.union([ SignerOrClockSchema, DataAddWithItemsSchema, ]); export const DataRemoveSchema = z.union([ SignerOrClockBaseSchema, z.object({ name: NameSchema.describe("Data item name. Must match the name in PolicyRule."), items: z.array(DataRemoveItemSchema).describe("List of data items to delete."), }).strict(), ]); export const CallRepository_DataSchema = z.object({ object: WithPermissionObjectSchema, description: DescriptionSchema.optional(), policies: PoliciesSchema.optional().describe("Policy list. Used to define data item write permissions and rules, as well as data item read permissions."), data_add: DataAddSchema.optional().describe("Add data items"), data_remove: DataRemoveSchema.optional().describe("Delete data items"), rewards: ObjectsSchema.optional().describe("Reward object list. Used for data contribution incentives."), 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 Repository operations. USAGE: (1) CREATE NEW: Set 'object' field with OBJECT format {name, permission, ...} to create a Repository. 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 CallRepository_InputSchema = z.object({ data: CallRepository_DataSchema, env: CallEnvSchema.optional(), submission: SubmissionCallSchema.optional(), }).strict();