diff --git a/frontend/app/src/components/bots/AutoBotBuilder.svelte b/frontend/app/src/components/bots/AutoBotBuilder.svelte index 69ab28b304..2508fbcd6d 100644 --- a/frontend/app/src/components/bots/AutoBotBuilder.svelte +++ b/frontend/app/src/components/bots/AutoBotBuilder.svelte @@ -177,7 +177,7 @@ (value: unknown, validator: T): Static { - try { - return Value.Parse(validator, value); - } catch (err) { - throw new Error("Validation failed: " + JSON.stringify(err)); - } + return Value.Parse(validator, value); } private static prepareMsgpackArgs( @@ -267,7 +263,11 @@ export abstract class CandidService { const validated = CandidService.validate(response, validator); return mapper(validated); } catch (err) { - console.error("Validation failed for response: ", response); + console.error( + "Validation failed for response: ", + response, + err instanceof AssertError ? err.error : undefined, + ); throw err; } } diff --git a/frontend/openchat-agent/src/services/common/chatMappersV2.ts b/frontend/openchat-agent/src/services/common/chatMappersV2.ts index b35b925306..7ca9cae0be 100644 --- a/frontend/openchat-agent/src/services/common/chatMappersV2.ts +++ b/frontend/openchat-agent/src/services/common/chatMappersV2.ts @@ -3415,8 +3415,8 @@ export function customParamFields(paramType: ApiSlashCommandParamType): SlashCom } else if ("NumberParam" in paramType) { return { kind: "number", - minValue: paramType.NumberParam.min_length, - maxValue: paramType.NumberParam.max_length, + minValue: paramType.NumberParam.min_value, + maxValue: paramType.NumberParam.max_value, choices: paramType.NumberParam.choices, }; } diff --git a/frontend/openchat-agent/src/services/localUserIndex/mappers.ts b/frontend/openchat-agent/src/services/localUserIndex/mappers.ts index 9d9114cae1..86005ea5d5 100644 --- a/frontend/openchat-agent/src/services/localUserIndex/mappers.ts +++ b/frontend/openchat-agent/src/services/localUserIndex/mappers.ts @@ -70,8 +70,7 @@ export function apiAccessTokenType(domain: AccessTokenType): TAccessTokenType { ), message_id: domain.messageId, command_name: domain.commandName, - parameters: domain.parameters, - version: domain.version, + command_args: domain.parameters, command_text: domain.commandText, }, }; diff --git a/frontend/openchat-agent/src/services/userIndex/mappers.ts b/frontend/openchat-agent/src/services/userIndex/mappers.ts index 57344dd999..fd29c7df27 100644 --- a/frontend/openchat-agent/src/services/userIndex/mappers.ts +++ b/frontend/openchat-agent/src/services/userIndex/mappers.ts @@ -608,8 +608,8 @@ export function apiCustomParamFields(param: SlashCommandParam): ApiSlashCommandP case "number": return { NumberParam: { - min_length: param.minValue, - max_length: param.maxValue, + min_value: param.minValue, + max_value: param.maxValue, choices: param.choices, }, }; diff --git a/frontend/openchat-agent/src/typebox.ts b/frontend/openchat-agent/src/typebox.ts index e18dfc49d6..1c5738ea0d 100644 --- a/frontend/openchat-agent/src/typebox.ts +++ b/frontend/openchat-agent/src/typebox.ts @@ -1019,12 +1019,6 @@ export const ChatMetrics = Type.Object({ last_active: Type.BigInt(), }); -export type SlashCommandOptionChoiceU16 = Static; -export const SlashCommandOptionChoiceU16 = Type.Object({ - name: Type.String(), - value: Type.Number(), -}); - export type VideoCallType = Static; export const VideoCallType = Type.Union([Type.Literal("Broadcast"), Type.Literal("Default")]); @@ -1109,13 +1103,6 @@ export const Rules = Type.Object({ enabled: Type.Boolean(), }); -export type NumberParam = Static; -export const NumberParam = Type.Object({ - min_length: Type.Number(), - max_length: Type.Number(), - choices: Type.Array(SlashCommandOptionChoiceU16), -}); - export type SubscriptionInfo = Static; export const SubscriptionInfo = Type.Object({ endpoint: Type.String(), @@ -1525,6 +1512,12 @@ export const TextContent = Type.Object({ export type MessageId = Static; export const MessageId = Type.BigInt(); +export type SlashCommandOptionChoiceF64 = Static; +export const SlashCommandOptionChoiceF64 = Type.Object({ + name: Type.String(), + value: Type.Number(), +}); + export type CustomPermission = Static; export const CustomPermission = Type.Object({ subtype: Type.String(), @@ -4029,18 +4022,6 @@ export const PaymentGate = Type.Object({ fee: Type.BigInt(), }); -export type SlashCommandParamType = Static; -export const SlashCommandParamType = Type.Union([ - Type.Literal("UserParam"), - Type.Literal("BooleanParam"), - Type.Object({ - StringParam: StringParam, - }), - Type.Object({ - NumberParam: NumberParam, - }), -]); - export type VersionedRules = Static; export const VersionedRules = Type.Object({ text: Type.String(), @@ -4373,6 +4354,13 @@ export const OptionUpdateOptionalMessagePermissions = Type.Union( { default: "NoChange" }, ); +export type NumberParam = Static; +export const NumberParam = Type.Object({ + min_value: Type.Number(), + max_value: Type.Number(), + choices: Type.Array(SlashCommandOptionChoiceF64), +}); + export type PendingCryptoTransactionICRC2 = Static; export const PendingCryptoTransactionICRC2 = Type.Object({ ledger: TSBytes, @@ -4402,23 +4390,6 @@ export const ImageContent = Type.Object({ blob_reference: Type.Optional(Type.Union([BlobReference, Type.Undefined()])), }); -export type SlashCommandParam = Static; -export const SlashCommandParam = Type.Object({ - name: Type.String(), - description: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), - placeholder: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), - required: Type.Boolean(), - param_type: SlashCommandParamType, -}); - -export type SlashCommandSchema = Static; -export const SlashCommandSchema = Type.Object({ - name: Type.String(), - description: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), - params: Type.Array(SlashCommandParam), - permissions: SlashCommandPermissions, -}); - export type UserId = Static; export const UserId = TSBytes; @@ -4937,18 +4908,6 @@ export const UserIndexUserArgs = Type.Object({ username: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), }); -export type UserIndexBotUpdatesBotSchema = Static; -export const UserIndexBotUpdatesBotSchema = Type.Object({ - id: UserId, - owner: UserId, - name: Type.String(), - avatar_id: Type.Optional(Type.Union([Type.BigInt(), Type.Undefined()])), - endpoint: Type.String(), - description: Type.String(), - commands: Type.Array(SlashCommandSchema), - last_updated: Type.BigInt(), -}); - export type UserIndexReferralMetricsResponse = Static; export const UserIndexReferralMetricsResponse = Type.Object({ Success: UserIndexReferralMetricsReferralMetrics, @@ -4996,17 +4955,6 @@ export const UserIndexSetDiamondMembershipFeesArgs = Type.Object({ fees: DiamondMembershipFees, }); -export type UserIndexRegisterBotArgs = Static; -export const UserIndexRegisterBotArgs = Type.Object({ - principal: TSBytes, - owner: UserId, - name: Type.String(), - avatar: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), - endpoint: Type.String(), - description: Type.String(), - commands: Type.Array(SlashCommandSchema), -}); - export type UserIndexPlatformModeratorsGroupResponse = Static< typeof UserIndexPlatformModeratorsGroupResponse >; @@ -5994,6 +5942,18 @@ export const GroupPermissions = Type.Object({ thread_permissions: Type.Optional(Type.Union([MessagePermissions, Type.Undefined()])), }); +export type SlashCommandParamType = Static; +export const SlashCommandParamType = Type.Union([ + Type.Literal("UserParam"), + Type.Literal("BooleanParam"), + Type.Object({ + StringParam: StringParam, + }), + Type.Object({ + NumberParam: NumberParam, + }), +]); + export type GroupSubtype = Static; export const GroupSubtype = Type.Object({ GovernanceProposals: GovernanceProposalsSubtype, @@ -6401,17 +6361,6 @@ export const FrozenGroupInfo = Type.Object({ reason: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), }); -export type BotMatch = Static; -export const BotMatch = Type.Object({ - id: UserId, - score: Type.Number(), - name: Type.String(), - description: Type.String(), - owner: UserId, - avatar_id: Type.Optional(Type.Union([Type.BigInt(), Type.Undefined()])), - commands: Type.Array(SlashCommandSchema), -}); - export type GroupUnfrozen = Static; export const GroupUnfrozen = Type.Object({ unfrozen_by: UserId, @@ -6429,6 +6378,23 @@ export const MemberJoined = Type.Object({ invited_by: Type.Optional(Type.Union([UserId, Type.Undefined()])), }); +export type SlashCommandParam = Static; +export const SlashCommandParam = Type.Object({ + name: Type.String(), + description: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), + placeholder: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), + required: Type.Boolean(), + param_type: SlashCommandParamType, +}); + +export type SlashCommandSchema = Static; +export const SlashCommandSchema = Type.Object({ + name: Type.String(), + description: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), + params: Type.Array(SlashCommandParam), + permissions: SlashCommandPermissions, +}); + export type RoleChanged = Static; export const RoleChanged = Type.Object({ user_ids: Type.Array(UserId), @@ -6535,8 +6501,7 @@ export const BotCommandArgs = Type.Object({ thread_root_message_index: Type.Optional(Type.Union([MessageIndex, Type.Undefined()])), message_id: MessageId, command_name: Type.String(), - parameters: Type.String(), - version: Type.Number(), + command_args: Type.String(), command_text: Type.String(), }); @@ -6590,21 +6555,18 @@ export const UserIndexUserResponse = Type.Union([ Type.Literal("UserNotFound"), ]); -export type UserIndexBotUpdatesSuccessResult = Static; -export const UserIndexBotUpdatesSuccessResult = Type.Object({ - added_or_updated: Type.Array(UserIndexBotUpdatesBotSchema), - deleted: Type.Array(UserId), - timestamp: Type.BigInt(), +export type UserIndexBotUpdatesBotSchema = Static; +export const UserIndexBotUpdatesBotSchema = Type.Object({ + id: UserId, + owner: UserId, + name: Type.String(), + avatar_id: Type.Optional(Type.Union([Type.BigInt(), Type.Undefined()])), + endpoint: Type.String(), + description: Type.String(), + commands: Type.Array(SlashCommandSchema), + last_updated: Type.BigInt(), }); -export type UserIndexBotUpdatesResponse = Static; -export const UserIndexBotUpdatesResponse = Type.Union([ - Type.Object({ - Success: UserIndexBotUpdatesSuccessResult, - }), - Type.Literal("SuccessNoUpdates"), -]); - export type UserIndexSearchResult = Static; export const UserIndexSearchResult = Type.Object({ users: Type.Array(UserSummary), @@ -6616,26 +6578,6 @@ export const UserIndexSearchResponse = Type.Object({ Success: UserIndexSearchResult, }); -export type UserIndexExploreBotsSuccessResult = Static; -export const UserIndexExploreBotsSuccessResult = Type.Object({ - matches: Type.Array(BotMatch), - total: Type.Number(), -}); - -export type UserIndexExploreBotsResponse = Static; -export const UserIndexExploreBotsResponse = Type.Union([ - Type.Object({ - Success: UserIndexExploreBotsSuccessResult, - }), - Type.Object({ - TermTooShort: Type.Number(), - }), - Type.Object({ - TermTooLong: Type.Number(), - }), - Type.Literal("InvalidTerm"), -]); - export type UserIndexChitLeaderboardSuccessResult = Static< typeof UserIndexChitLeaderboardSuccessResult >; @@ -6650,6 +6592,17 @@ export const UserIndexChitLeaderboardResponse = Type.Object({ SuccessV2: UserIndexChitLeaderboardSuccessResult, }); +export type UserIndexRegisterBotArgs = Static; +export const UserIndexRegisterBotArgs = Type.Object({ + principal: TSBytes, + owner: UserId, + name: Type.String(), + avatar: Type.Optional(Type.Union([Type.String(), Type.Undefined()])), + endpoint: Type.String(), + description: Type.String(), + commands: Type.Array(SlashCommandSchema), +}); + export type UserIndexCurrentUserSuccessResult = Static; export const UserIndexCurrentUserSuccessResult = Type.Object({ user_id: UserId, @@ -7401,6 +7354,17 @@ export const SwapStatusError = Type.Union([ }), ]); +export type BotMatch = Static; +export const BotMatch = Type.Object({ + id: UserId, + score: Type.Number(), + name: Type.String(), + description: Type.String(), + owner: UserId, + avatar_id: Type.Optional(Type.Union([Type.BigInt(), Type.Undefined()])), + commands: Type.Array(SlashCommandSchema), +}); + export type P2PSwapContent = Static; export const P2PSwapContent = Type.Object({ swap_id: Type.Number(), @@ -7497,6 +7461,21 @@ export const GroupIndexUnfreezeGroupResponse = Type.Union([ }), ]); +export type UserIndexBotUpdatesSuccessResult = Static; +export const UserIndexBotUpdatesSuccessResult = Type.Object({ + added_or_updated: Type.Array(UserIndexBotUpdatesBotSchema), + deleted: Type.Array(UserId), + timestamp: Type.BigInt(), +}); + +export type UserIndexBotUpdatesResponse = Static; +export const UserIndexBotUpdatesResponse = Type.Union([ + Type.Object({ + Success: UserIndexBotUpdatesSuccessResult, + }), + Type.Literal("SuccessNoUpdates"), +]); + export type UserIndexUsersResult = Static; export const UserIndexUsersResult = Type.Object({ users: Type.Array(UserSummaryV2), @@ -7510,6 +7489,26 @@ export const UserIndexUsersResponse = Type.Object({ Success: UserIndexUsersResult, }); +export type UserIndexExploreBotsSuccessResult = Static; +export const UserIndexExploreBotsSuccessResult = Type.Object({ + matches: Type.Array(BotMatch), + total: Type.Number(), +}); + +export type UserIndexExploreBotsResponse = Static; +export const UserIndexExploreBotsResponse = Type.Union([ + Type.Object({ + Success: UserIndexExploreBotsSuccessResult, + }), + Type.Object({ + TermTooShort: Type.Number(), + }), + Type.Object({ + TermTooLong: Type.Number(), + }), + Type.Literal("InvalidTerm"), +]); + export type LocalUserIndexAccessTokenArgs = Static; export const LocalUserIndexAccessTokenArgs = Type.Object({ token_type: AccessTokenType, diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index b111216363..46d5ce6ce9 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -946,17 +946,15 @@ export class OpenChat extends EventTarget { } #startBotsPoller() { - this.#botsPoller?.stop(); - this.#botsPoller = new Poller( - () => this.#loadBots(), - BOT_UPDATE_INTERVAL, - BOT_UPDATE_IDLE_INTERVAL, - true, - ); - - // we need to load chats at least once if we are completely offline - if (this.#liveState.offlineStore) { - this.#loadChats(); + const enabled = localStorage.getItem("openchat_bots_enabled") === "true"; + if (enabled) { + this.#botsPoller?.stop(); + this.#botsPoller = new Poller( + () => this.#loadBots(), + BOT_UPDATE_INTERVAL, + BOT_UPDATE_IDLE_INTERVAL, + true, + ); } } @@ -7854,7 +7852,6 @@ export class OpenChat extends EventTarget { messageId: random64(), commandName: bot.command.name, parameters: JSON.stringify(bot.command.params), - version: 0, commandText: `@${this.getDisplayName( this.#liveState.user, )} executed the command /${bot.command.name}`, diff --git a/frontend/openchat-shared/src/domain/permission.ts b/frontend/openchat-shared/src/domain/permission.ts index 761caf0394..a0335ced00 100644 --- a/frontend/openchat-shared/src/domain/permission.ts +++ b/frontend/openchat-shared/src/domain/permission.ts @@ -176,7 +176,6 @@ export type ExecuteBotCommand = { messageId: bigint; commandName: string; parameters: string; - version: number; commandText: string; botId: string; userId: string; diff --git a/tsBindings/shared/BotCommandArgs.ts b/tsBindings/shared/BotCommandArgs.ts index dce2ccda70..6ad6f4982a 100644 --- a/tsBindings/shared/BotCommandArgs.ts +++ b/tsBindings/shared/BotCommandArgs.ts @@ -4,4 +4,4 @@ import type { MessageId } from "./MessageId"; import type { MessageIndex } from "./MessageIndex"; import type { UserId } from "./UserId"; -export type BotCommandArgs = { user_id: UserId, bot: UserId, chat: Chat, thread_root_message_index?: MessageIndex | undefined, message_id: MessageId, command_name: string, parameters: string, version: number, command_text: string, }; +export type BotCommandArgs = { user_id: UserId, bot: UserId, chat: Chat, thread_root_message_index?: MessageIndex | undefined, message_id: MessageId, command_name: string, command_args: string, command_text: string, }; diff --git a/tsBindings/shared/NumberParam.ts b/tsBindings/shared/NumberParam.ts index 76f1ecc1c1..16eff6aa09 100644 --- a/tsBindings/shared/NumberParam.ts +++ b/tsBindings/shared/NumberParam.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { SlashCommandOptionChoiceU16 } from "./SlashCommandOptionChoiceU16"; +import type { SlashCommandOptionChoiceF64 } from "./SlashCommandOptionChoiceF64"; -export type NumberParam = { min_length: number, max_length: number, choices: Array, }; +export type NumberParam = { min_value: number, max_value: number, choices: Array, }; diff --git a/tsBindings/shared/SlashCommandOptionChoiceU16.ts b/tsBindings/shared/SlashCommandOptionChoiceF64.ts similarity index 65% rename from tsBindings/shared/SlashCommandOptionChoiceU16.ts rename to tsBindings/shared/SlashCommandOptionChoiceF64.ts index 5797a1d68f..cfc677244f 100644 --- a/tsBindings/shared/SlashCommandOptionChoiceU16.ts +++ b/tsBindings/shared/SlashCommandOptionChoiceF64.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type SlashCommandOptionChoiceU16 = { name: string, value: number, }; +export type SlashCommandOptionChoiceF64 = { name: string, value: number, }; diff --git a/tsBindings/types.d.ts b/tsBindings/types.d.ts index a34d74f717..79b69fba27 100644 --- a/tsBindings/types.d.ts +++ b/tsBindings/types.d.ts @@ -113,7 +113,6 @@ export type PinNumberSettings = { length: number, attempts_blocked_until?: bigin export type ApproveError = { "BadFee": { expected_fee: bigint, } } | { "InsufficientFunds": { balance: bigint, } } | { "AllowanceChanged": { current_allowance: bigint, } } | { "Expired": { ledger_time: bigint, } } | "TooOld" | { "CreatedInFuture": { ledger_time: bigint, } } | { "Duplicate": { duplicate_of: bigint, } } | "TemporarilyUnavailable" | { "GenericError": { error_code: bigint, message: string, } }; export type VideoCallPresence = "Default" | "Owner" | "Hidden"; export type ChatMetrics = { text_messages: bigint, image_messages: bigint, video_messages: bigint, audio_messages: bigint, file_messages: bigint, polls: bigint, poll_votes: bigint, crypto_messages: bigint, icp_messages: bigint, sns1_messages: bigint, ckbtc_messages: bigint, chat_messages: bigint, kinic_messages: bigint, deleted_messages: bigint, giphy_messages: bigint, prize_messages: bigint, prize_winner_messages: bigint, replies: bigint, edits: bigint, reactions: bigint, proposals: bigint, reported_messages: bigint, message_reminders: bigint, custom_type_messages: bigint, last_active: bigint, }; -export type SlashCommandOptionChoiceU16 = { name: string, value: number, }; export type VideoCallType = "Broadcast" | "Default"; export type MessagePermission = "Text" | "Image" | "Video" | "Audio" | "File" | "Poll" | "Crypto" | "Giphy" | "Prize" | "P2pSwap" | "VideoCall"; export type VideoCall = { message_index: MessageIndex, call_type: VideoCallType, }; @@ -128,7 +127,6 @@ export type OptionUpdateU64 = "NoChange" | "SetToNone" | { "SetToSome": bigint } export type GroupCanisterThreadDetails = { root_message_index: MessageIndex, latest_event: EventIndex, latest_message: MessageIndex, last_updated: bigint, }; export type Tokens = { e8s: bigint, }; export type Rules = { text: string, enabled: boolean, }; -export type NumberParam = { min_length: number, max_length: number, choices: Array, }; export type SubscriptionInfo = { endpoint: string, keys: SubscriptionKeys, }; /** * @default NoChange @@ -179,6 +177,7 @@ export type VideoCallAccessTokenArgs = { call_type: VideoCallType, }; export type P2PSwapCancelled = { token0_txn_out?: bigint | undefined, }; export type TextContent = { text: string, }; export type MessageId = bigint; +export type SlashCommandOptionChoiceF64 = { name: string, value: number, }; export type CustomPermission = { subtype: string, role: GroupPermissionRole, }; export type TSBytes = Uint8Array; export type UpdatedRules = { text: string, enabled: boolean, new_version: boolean, }; @@ -434,7 +433,6 @@ export type UserMarkReadChannelMessagesRead = { channel_id: ChannelId, read_up_t export type UserLocalUserIndexResponse = { "Success": TSBytes }; export type UserConfigureWalletArgs = { config: UserWalletConfig, }; export type PaymentGate = { ledger_canister_id: TSBytes, amount: bigint, fee: bigint, }; -export type SlashCommandParamType = "UserParam" | "BooleanParam" | { "StringParam": StringParam } | { "NumberParam": NumberParam }; export type VersionedRules = { text: string, version: Version, enabled: boolean, }; export type AccountICRC1 = { owner: TSBytes, subaccount?: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number] | undefined, }; export type CommunityMembershipUpdates = { role?: CommunityRole | undefined, rules_accepted?: boolean | undefined, display_name: OptionUpdateString, lapsed?: boolean | undefined, }; @@ -465,11 +463,10 @@ export type CompletedCryptoTransactionNNS = { ledger: TSBytes, token: Cryptocurr * @default NoChange */ export type OptionUpdateOptionalMessagePermissions = "NoChange" | "SetToNone" | { "SetToSome": OptionalMessagePermissions }; +export type NumberParam = { min_value: number, max_value: number, choices: Array, }; export type PendingCryptoTransactionICRC2 = { ledger: TSBytes, token: Cryptocurrency, amount: bigint, from: AccountICRC1, to: AccountICRC1, fee: bigint, memo?: TSBytes | undefined, created: bigint, }; export type AudioContent = { caption?: string | undefined, mime_type: string, blob_reference?: BlobReference | undefined, }; export type ImageContent = { width: number, height: number, thumbnail_data: ThumbnailData, caption?: string | undefined, mime_type: string, blob_reference?: BlobReference | undefined, }; -export type SlashCommandParam = { name: string, description?: string | undefined, placeholder?: string | undefined, required: boolean, param_type: SlashCommandParamType, }; -export type SlashCommandSchema = { name: string, description?: string | undefined, params: Array, permissions: SlashCommandPermissions, }; export type UserId = TSBytes; export type CommunityId = TSBytes; export type CompletedCryptoTransactionICRC1 = { ledger: TSBytes, token: Cryptocurrency, amount: bigint, from: CryptoAccountICRC1, to: CryptoAccountICRC1, fee: bigint, memo?: TSBytes | undefined, created: bigint, block_index: bigint, }; @@ -524,7 +521,6 @@ export type UserIndexSuspectedBotsArgs = { after?: UserId | undefined, count: nu export type UserIndexExternalAchievementsSuccessResult = { last_updated: bigint, added_or_updated: Array, }; export type UserIndexExternalAchievementsResponse = { "Success": UserIndexExternalAchievementsSuccessResult } | "SuccessNoUpdates"; export type UserIndexUserArgs = { user_id?: UserId | undefined, username?: string | undefined, }; -export type UserIndexBotUpdatesBotSchema = { id: UserId, owner: UserId, name: string, avatar_id?: bigint | undefined, endpoint: string, description: string, commands: Array, last_updated: bigint, }; export type UserIndexReferralMetricsResponse = { "Success": UserIndexReferralMetricsReferralMetrics }; export type UserIndexUnsuspendUserArgs = { user_id: UserId, }; export type UserIndexUsersUserGroup = { users: Array, updated_since: bigint, }; @@ -532,7 +528,6 @@ export type UserIndexUsersArgs = { user_groups: Array, export type UserIndexChitLeaderboardChitUserBalance = { user_id: UserId, username: string, balance: number, }; export type UserIndexUpdateBotArgs = { bot_id: UserId, owner?: UserId | undefined, name?: string | undefined, avatar: OptionUpdateString, endpoint?: string | undefined, }; export type UserIndexSetDiamondMembershipFeesArgs = { fees: DiamondMembershipFees, }; -export type UserIndexRegisterBotArgs = { principal: TSBytes, owner: UserId, name: string, avatar?: string | undefined, endpoint: string, description: string, commands: Array, }; export type UserIndexPlatformModeratorsGroupResponse = { "Success": ChatId }; export type UserIndexReportedMessagesArgs = { user_id?: UserId | undefined, }; export type LocalUserIndexInviteUsersToCommunityArgs = { community_id: CommunityId, user_ids: Array, caller_username: string, }; @@ -639,6 +634,7 @@ export type UserChitEventsSuccessResult = { events: Array, total: nu export type UserReportMessageArgs = { them: UserId, thread_root_message_index?: MessageIndex | undefined, message_id: MessageId, delete: boolean, }; export type VideoContent = { width: number, height: number, thumbnail_data: ThumbnailData, caption?: string | undefined, mime_type: string, image_blob_reference?: BlobReference | undefined, video_blob_reference?: BlobReference | undefined, }; export type GroupPermissions = { change_roles: GroupPermissionRole, update_group: GroupPermissionRole, add_members: GroupPermissionRole, invite_users: GroupPermissionRole, remove_members: GroupPermissionRole, delete_messages: GroupPermissionRole, pin_messages: GroupPermissionRole, react_to_messages: GroupPermissionRole, mention_all_members: GroupPermissionRole, start_video_call: GroupPermissionRole, message_permissions: MessagePermissions, thread_permissions?: MessagePermissions | undefined, }; +export type SlashCommandParamType = "UserParam" | "BooleanParam" | { "StringParam": StringParam } | { "NumberParam": NumberParam }; export type GroupSubtype = { "GovernanceProposals": GovernanceProposalsSubtype }; export type SignedDelegation = { delegation: Delegation, signature: TSBytes, }; export type P2PSwapReserved = { reserved_by: UserId, }; @@ -688,10 +684,11 @@ export type SwapStatusErrorCompleted = { accepted_by: UserId, token1_txn_in: big export type AirdropConfig = { community_id: CommunityId, channel_id: ChannelId, community_name: string, channel_name: string, }; export type MembersAdded = { user_ids: Array, added_by: UserId, unblocked: Array, }; export type FrozenGroupInfo = { timestamp: bigint, frozen_by: UserId, reason?: string | undefined, }; -export type BotMatch = { id: UserId, score: number, name: string, description: string, owner: UserId, avatar_id?: bigint | undefined, commands: Array, }; export type GroupUnfrozen = { unfrozen_by: UserId, }; export type EventsTimeToLiveUpdated = { updated_by: UserId, new_ttl?: bigint | undefined, }; export type MemberJoined = { user_id: UserId, invited_by?: UserId | undefined, }; +export type SlashCommandParam = { name: string, description?: string | undefined, placeholder?: string | undefined, required: boolean, param_type: SlashCommandParamType, }; +export type SlashCommandSchema = { name: string, description?: string | undefined, params: Array, permissions: SlashCommandPermissions, }; export type RoleChanged = { user_ids: Array, changed_by: UserId, old_role: GroupRole, new_role: GroupRole, }; export type GroupVisibilityChanged = { public?: boolean | undefined, messages_visible_to_non_members?: boolean | undefined, changed_by: UserId, }; export type SelectedGroupUpdates = { timestamp: bigint, last_updated: bigint, latest_event_index: EventIndex, members_added_or_updated: Array, members_removed: Array, bots_added_or_updated: Array, bots_removed: Array, blocked_users_added: Array, blocked_users_removed: Array, invited_users?: Array | undefined, pinned_messages_added: Array, pinned_messages_removed: Array, chat_rules?: VersionedRules | undefined, }; @@ -711,21 +708,19 @@ export type DiamondMembershipStatusFull = "Inactive" | { "Active": DiamondMember * @default NoChange */ export type OptionUpdateGroupSubtype = "NoChange" | "SetToNone" | { "SetToSome": GroupSubtype }; -export type BotCommandArgs = { user_id: UserId, bot: UserId, chat: Chat, thread_root_message_index?: MessageIndex | undefined, message_id: MessageId, command_name: string, parameters: string, version: number, command_text: string, }; +export type BotCommandArgs = { user_id: UserId, bot: UserId, chat: Chat, thread_root_message_index?: MessageIndex | undefined, message_id: MessageId, command_name: string, command_args: string, command_text: string, }; export type GroupIndexActiveGroupsSuccessResult = { timestamp: bigint, active_groups: Array, active_communities: Array, deleted_groups: Array, deleted_communities: Array, }; export type RegistryUpdatesSuccessResult = { last_updated: bigint, token_details?: Array | undefined, nervous_system_details: Array, message_filters_added: Array, message_filters_removed: Array, swap_providers?: Array | undefined, airdrop_config: OptionUpdateAirdropConfig, }; export type RegistryUpdatesResponse = { "Success": RegistryUpdatesSuccessResult } | "SuccessNoUpdates"; export type UserIndexPlatformModeratorsResponse = { "Success": UserIndexPlatformModeratorsSuccessResult }; export type UserIndexSuspectedBotsResponse = { "Success": UserIndexSuspectedBotsSuccessResult }; export type UserIndexUserResponse = { "Success": UserSummary } | "UserNotFound"; -export type UserIndexBotUpdatesSuccessResult = { added_or_updated: Array, deleted: Array, timestamp: bigint, }; -export type UserIndexBotUpdatesResponse = { "Success": UserIndexBotUpdatesSuccessResult } | "SuccessNoUpdates"; +export type UserIndexBotUpdatesBotSchema = { id: UserId, owner: UserId, name: string, avatar_id?: bigint | undefined, endpoint: string, description: string, commands: Array, last_updated: bigint, }; export type UserIndexSearchResult = { users: Array, timestamp: bigint, }; export type UserIndexSearchResponse = { "Success": UserIndexSearchResult }; -export type UserIndexExploreBotsSuccessResult = { matches: Array, total: number, }; -export type UserIndexExploreBotsResponse = { "Success": UserIndexExploreBotsSuccessResult } | { "TermTooShort": number } | { "TermTooLong": number } | "InvalidTerm"; export type UserIndexChitLeaderboardSuccessResult = { all_time: Array, this_month: Array, last_month: Array, }; export type UserIndexChitLeaderboardResponse = { "SuccessV2": UserIndexChitLeaderboardSuccessResult }; +export type UserIndexRegisterBotArgs = { principal: TSBytes, owner: UserId, name: string, avatar?: string | undefined, endpoint: string, description: string, commands: Array, }; export type UserIndexCurrentUserSuccessResult = { user_id: UserId, username: string, date_created: bigint, display_name?: string | undefined, avatar_id?: bigint | undefined, canister_upgrade_status: CanisterUpgradeStatus, wasm_version: BuildVersion, icp_account: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number], referrals: Array, is_platform_moderator: boolean, is_platform_operator: boolean, suspension_details?: SuspensionDetails | undefined, is_suspected_bot: boolean, diamond_membership_details?: DiamondMembershipDetails | undefined, diamond_membership_status: DiamondMembershipStatusFull, moderation_flags_enabled: number, is_unique_person: boolean, }; export type UserIndexCurrentUserResponse = { "Success": UserIndexCurrentUserSuccessResult } | "UserNotFound"; export type LocalUserIndexRegisterUserResponse = { "Success": LocalUserIndexRegisterUserSuccessResult } | "RegistrationInProgress" | "AlreadyRegistered" | "UserLimitReached" | "UsernameInvalid" | { "UsernameTooShort": number } | { "UsernameTooLong": number } | "CyclesBalanceTooLow" | { "InternalError": string } | { "PublicKeyInvalid": string } | "ReferralCodeInvalid" | "ReferralCodeAlreadyClaimed" | "ReferralCodeExpired"; @@ -785,6 +780,7 @@ export type PollVotes = { total: TotalVotes, user: Array, }; export type CurrentUserSummary = { user_id: UserId, username: string, display_name?: string | undefined, avatar_id?: bigint | undefined, is_bot: boolean, is_platform_moderator: boolean, is_platform_operator: boolean, suspension_details?: SuspensionDetails | undefined, is_suspected_bot: boolean, diamond_membership_details?: DiamondMembershipDetails | undefined, diamond_membership_status: DiamondMembershipStatusFull, moderation_flags_enabled: number, is_unique_person: boolean, }; export type AccessTokenType = { "StartVideoCallV2": VideoCallAccessTokenArgs } | "JoinVideoCall" | "MarkVideoCallAsEnded" | { "BotCommand": BotCommandArgs }; export type SwapStatusError = { "Reserved": SwapStatusErrorReserved } | { "Accepted": SwapStatusErrorAccepted } | { "Completed": SwapStatusErrorCompleted } | { "Expired": SwapStatusErrorExpired } | { "Cancelled": SwapStatusErrorCancelled }; +export type BotMatch = { id: UserId, score: number, name: string, description: string, owner: UserId, avatar_id?: bigint | undefined, commands: Array, }; export type P2PSwapContent = { swap_id: number, token0: TokenInfo, token0_amount: bigint, token1: TokenInfo, token1_amount: bigint, expires_at: bigint, caption?: string | undefined, token0_txn_in: bigint, status: P2PSwapStatus, }; export type AccessGate = "DiamondMember" | "LifetimeDiamondMember" | "UniquePerson" | { "VerifiedCredential": VerifiedCredentialGate } | { "SnsNeuron": SnsNeuronGate } | { "Payment": PaymentGate } | { "TokenBalance": TokenBalanceGate } | { "Composite": CompositeGate } | "Locked" | "ReferredByMember"; export type GroupIndexFreezeGroupResponse = { "Success": EventWrapperGroupFrozen } | "ChatAlreadyFrozen" | "ChatNotFound" | "NotAuthorized" | { "InternalError": string }; @@ -792,8 +788,12 @@ export type GroupIndexUnfreezeCommunityResponse = { "Success": EventWrapperGroup export type GroupIndexFreezeCommunityResponse = { "Success": EventWrapperGroupFrozen } | "CommunityAlreadyFrozen" | "CommunityNotFound" | "NotAuthorized" | { "InternalError": string }; export type GroupIndexActiveGroupsResponse = { "Success": GroupIndexActiveGroupsSuccessResult }; export type GroupIndexUnfreezeGroupResponse = { "Success": EventWrapperGroupUnfrozen } | "ChatNotFrozen" | "ChatNotFound" | "NotAuthorized" | { "InternalError": string }; +export type UserIndexBotUpdatesSuccessResult = { added_or_updated: Array, deleted: Array, timestamp: bigint, }; +export type UserIndexBotUpdatesResponse = { "Success": UserIndexBotUpdatesSuccessResult } | "SuccessNoUpdates"; export type UserIndexUsersResult = { users: Array, current_user?: CurrentUserSummary | undefined, deleted: Array, timestamp: bigint, }; export type UserIndexUsersResponse = { "Success": UserIndexUsersResult }; +export type UserIndexExploreBotsSuccessResult = { matches: Array, total: number, }; +export type UserIndexExploreBotsResponse = { "Success": UserIndexExploreBotsSuccessResult } | { "TermTooShort": number } | { "TermTooLong": number } | "InvalidTerm"; export type LocalUserIndexAccessTokenArgs = { token_type: AccessTokenType, chat: Chat, }; export type LocalUserIndexChatEventsArgs = { requests: Array, }; export type CommunityClaimPrizeResponse = "Success" | "MessageNotFound" | "UserNotInCommunity" | "UserNotInChannel" | "UserSuspended" | "CommunityFrozen" | "ChannelNotFound" | "AlreadyClaimed" | "PrizeFullyClaimed" | "PrizeEnded" | "LedgerError" | { "TransferFailed": [string, FailedCryptoTransaction] } | { "FailedAfterTransfer": [string, CompletedCryptoTransaction] } | { "InternalError": string } | "UserLapsed";