diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index f58063eda..5acd46cb5 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -22340,6 +22340,9 @@ importers: '@coze-project-ide/framework': specifier: workspace:* version: link:../../project-ide/framework + '@coze-studio/api-schema': + specifier: workspace:* + version: link:../../arch/api-schema '@coze-studio/bot-detail-store': specifier: workspace:* version: link:../../studio/stores/bot-detail diff --git a/frontend/packages/arch/api-schema/api.config.js b/frontend/packages/arch/api-schema/api.config.js index 2e1a5116b..d4c8219a8 100644 --- a/frontend/packages/arch/api-schema/api.config.js +++ b/frontend/packages/arch/api-schema/api.config.js @@ -24,6 +24,7 @@ const config = [ entries: { passport: './idl/passport/passport.thrift', // Entry service name and path explore: './idl/marketplace/public_api.thrift', + upload: './idl/upload/upload.thrift', }, commonCodePath: path.resolve(__dirname, './src/api/config.ts'), // custom profile output: './src', // Product location diff --git a/frontend/packages/arch/api-schema/package.json b/frontend/packages/arch/api-schema/package.json index 90c80b03b..0aa69d6a1 100644 --- a/frontend/packages/arch/api-schema/package.json +++ b/frontend/packages/arch/api-schema/package.json @@ -8,7 +8,8 @@ "exports": { ".": "./src/index.ts", "./passport": "./src/idl/passport/passport.ts", - "./marketplace": "./src/idl/marketplace/public_api.ts" + "./marketplace": "./src/idl/marketplace/public_api.ts", + "./upload": "./src/idl/upload/upload.ts" }, "main": "src/index.ts", "typesVersions": { @@ -18,6 +19,9 @@ ], "marketplace": [ "./src/idl/marketplace/public_api.ts" + ], + "upload": [ + "./src/idl/upload/upload.ts" ] } }, diff --git a/frontend/packages/arch/api-schema/src/idl/app/bot_common.ts b/frontend/packages/arch/api-schema/src/idl/app/bot_common.ts new file mode 100644 index 000000000..2d553a347 --- /dev/null +++ b/frontend/packages/arch/api-schema/src/idl/app/bot_common.ts @@ -0,0 +1,1156 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface AuthToken { + service_id: string, + access_key_id: string, + secret_access_key: string, + session_token: string, + expired_time: string, + current_time: string, + upload_host: string, + host_scheme: string, +} +export interface PromptInfo { + /** Text prompt */ + prompt?: string +} +export interface ModelInfo { + /** Model ID */ + model_id?: string, + /** Temperature, model output randomness, the larger the value, the more random, the smaller the more conservative (0-1] */ + temperature?: number, + /** Maximum Token Reply */ + max_tokens?: number, + /** Another model's output randomness, the larger the value, the more random [0, 1] */ + top_p?: number, + /** Frequency penalty, adjust the frequency of words in the generated content, the fewer positive words are [-1.0, 1.0] */ + frequency_penalty?: number, + /** There is a penalty, adjust the frequency of new words in the generated content, avoid repeating words with positive values, and use new words [-1.0, 1.0] */ + presence_penalty?: number, + /** contextual policy */ + short_memory_policy?: ShortMemoryPolicy, + /** When generating, sample the size of the candidate set */ + top_k?: number, + /** model reply content format */ + response_format?: ModelResponseFormat, + /** User-selected model style */ + model_style?: ModelStyle, +} +export enum ModelStyle { + Custom = 0, + Creative = 1, + Balance = 2, + Precise = 3, +} +export enum ModelResponseFormat { + Text = 0, + Markdown = 1, + JSON = 2, +} +/** The type of transmission allowed by the context */ +export enum ContextMode { + Chat = 0, + FunctionCall_1 = 1, + FunctionCall_2 = 2, + FunctionCall_3 = 3, +} +export enum ModelFuncConfigType { + Plugin = 1, + Workflow = 2, + ImageFlow = 3, + Trigger = 4, + KnowledgeText = 5, + KnowledgeTable = 6, + KnowledgeAutoCall = 7, + KnowledgeOnDemandCall = 8, + Variable = 9, + Database = 10, + LongTermMemory = 11, + FileBox = 12, + Onboarding = 13, + Suggestion = 14, + ShortcutCommand = 15, + BackGroundImage = 16, + TTS = 17, + MultiAgentRecognize = 18, + KnowledgePhoto = 19, + HookInfo = 20, +} +export enum ModelFuncConfigStatus { + FullSupport = 0, + PoorSupport = 1, + NotSupport = 2, +} +export interface ShortMemoryPolicy { + /** The type of transmission allowed by the context */ + context_mode?: ContextMode, + /** Number of rounds of context band */ + history_round?: number, +} +export interface PluginInfo { + /** Plugin ID */ + plugin_id?: string, + /** api Id */ + api_id?: string, + /** API name O project */ + api_name?: string, + /** api version */ + api_version_ms?: string, +} +export interface WorkflowInfo { + /** WorkflowId */ + workflow_id?: string, + /** Plugin ID */ + plugin_id?: string, + /** api Id */ + api_id?: string, + /** Workflow or imageflow, default to workflow */ + flow_mode?: WorkflowMode, + /** workflow name */ + workflow_name?: string, + desc?: string, + parameters?: PluginParameter[], + plugin_icon?: string, +} +export interface PluginParameter { + name?: string, + desc?: string, + required?: boolean, + type?: string, + sub_parameters?: PluginParameter[], + /** If Type is an array, there is a subtype */ + sub_type?: string, +} +export enum WorkflowMode { + Workflow = 0, + Imageflow = 1, + SceneFlow = 2, + ChatFlow = 3, + All = 100, +} +/** onboarding content generation mode */ +export enum OnboardingMode { + /** No. */ + NO_NEED = 1, + /** Manually specify content (multi-language support is covered by LLM) */ + USE_MANUAL = 2, + /** Generated by LLM */ + USE_LLM = 3, +} +export interface OnboardingInfo { + /** + * Coze Opening Dialog + * opening statement + */ + prologue?: string, + /** suggestion question */ + suggested_questions?: string[], + /** Opener model */ + onboarding_mode?: OnboardingMode, + /** LLM Generation, User-defined Prompt */ + customized_onboarding_prompt?: string, + /** The opening statement presets the problem display method, and the default is 0 random display. */ + suggested_questions_show_mode?: SuggestedQuestionsShowMode, +} +export enum SuggestedQuestionsShowMode { + Random = 0, + All = 1, +} +export enum SuggestReplyMode { + System = 0, + Custom = 1, + Disable = 2, + /** Agent specific, multiplexed source Bot configuration */ + OriBot = 3, +} +/** suggest */ +export interface SuggestReplyInfo { + /** + * Coze Auto-Suggestion + * suggestion problem model + */ + suggest_reply_mode?: SuggestReplyMode, + /** user-defined suggestion questions */ + customized_suggest_prompt?: string, + /** The name of the ChainTask that runs the Prompt */ + chain_task_name?: string, +} +/** tts Voices */ +export interface VoicesInfo { + /** + * Coze Voices + * Whether to turn on sound true: disable false: turn on + */ + muted?: boolean, + /** Multi-voice voice configuration */ + i18n_lang_voice?: { + [key: string | number]: number + }, + /** Multi-voice tone configuration, string type */ + i18n_lang_voice_str?: { + [key: string | number]: string + }, + /** Whether to play automatically */ + autoplay?: boolean, + /** autoplay timbre */ + autoplay_voice?: { + [key: string | number]: number + }, + /** Whether to turn off voice calls, true: turn off false: turn on, default is false */ + voice_call?: boolean, + /** Default user input type */ + default_user_input_type?: DefaultUserInputType, +} +export enum DefaultUserInputType { + /** Not set */ + NotSet = 0, + /** Text */ + Text = 1, + /** Hold down the voice */ + Voice = 2, + /** voice call */ + Call = 3, +} +/** AnswerActions */ +export enum AnswerActionsMode { + Default = 1, + Customize = 2, +} +export enum AnswerActionTriggerType { + /** Platform preset Trigger action */ + Direct = 1, + /** Click Action to display the custom H5 page */ + WebView = 2, + /** Click Action to send a custom user message */ + SendMessage = 3, +} +export interface AnswerActionTriggerRule { + type: AnswerActionTriggerType, + need_preloading: boolean, + /** According to AnswerActionTriggerType */ + trigger_data: { + [key: string | number]: string + }, +} +export interface ActionIcon { + /** Customized button type does not need to be passed */ + type: string, + /** default state */ + default_url: string, + /** The state of pressing the button */ + active_url: string, + /** default state */ + default_uri: string, + /** The state of pressing the button */ + active_uri: string, +} +export interface AnswerActionConfig { + /** The prefabricated one only needs to pass the key. */ + key: string, + /** default */ + name: string, + /** Send uri. */ + icon: ActionIcon, + /** Store the name of user i18 */ + name_i18n: { + [key: string | number]: string + }, + /** Direct has no value; WebView contains webview_url and webview_callback_psm keys; SendMessage contains send_message_prompt */ + trigger_rule: AnswerActionTriggerRule, + /** location */ + position: number, +} +export interface AnswerActions { + answer_actions_mode: AnswerActionsMode, + answer_action_configs: AnswerActionConfig[], +} +/** bot ext */ +export interface BotExtInfo { + answer_actions?: AnswerActions, + card_ids?: number[], + prompt_id?: number, + bot_template_name?: string, + use_ugc_voice?: boolean, + app_id?: number, + /** Whether to bind the Mini Program logo */ + binding_mp?: boolean, +} +export interface KnowledgeInfo { + /** Knowledge ID */ + id?: string, + /** Knowledge base name */ + name?: string, +} +export enum SearchStrategy { + /** semantic search */ + SemanticSearch = 0, + /** Hybrid Search */ + HybirdSearch = 1, + /** Full Text Search */ + FullTextSearch = 20, +} +export interface Knowledge { + /** Knowledge Base Information */ + knowledge_info?: KnowledgeInfo[], + /** recall maximum data volume */ + top_k?: number, + /** minimum match */ + min_score?: number, + /** automatic recall */ + auto?: boolean, + /** search strategy */ + search_strategy?: SearchStrategy, + /** Whether to show the source */ + show_source?: boolean, + /** No recall reply mode, default 0 */ + no_recall_reply_mode?: KnowledgeNoRecallReplyMode, + /** Custom prompt for no recall reply, effective when NoRecallReplyMode = 1 */ + no_recall_reply_customize_prompt?: string, + /** Source display method, default value 0 card list method */ + show_source_mode?: KnowledgeShowSourceMode, + /** Recall policy, default value is true */ + recall_strategy?: RecallStrategy, +} +export interface RecallStrategy { + use_rerank?: boolean, + use_rewrite?: boolean, + use_nl2sql?: boolean, +} +export enum KnowledgeShowSourceMode { + ReplyBottom = 0, + CardList = 1, +} +export enum KnowledgeNoRecallReplyMode { + Default = 0, + CustomizePrompt = 1, +} +export enum SocietyVisibility { + /** Visible to all */ + Public = 1, + /** Visible to host only */ + Anonymous = 2, + /** custom */ + Custom = 3, +} +export interface SocietyVisibiltyConfig { + /** Visibility in Social Scene: Public = 1, Anonymous = 2 */ + visibility_type?: SocietyVisibility, + /** list of visible characters */ + visibility_roles?: string[], +} +export interface Variable { + /** key, Field */ + key?: string, + /** describe */ + description?: string, + /** default value */ + default_value?: string, + /** Whether the system value is the system value */ + is_system?: boolean, + /** Whether to support calling in Prompt, the default is supported */ + prompt_disabled?: boolean, + /** Visibility in Social Scene: Public = 1, Anonymous = 2 */ + society_visibility_config?: SocietyVisibiltyConfig, + /** Whether to disable, the default is false to enable */ + is_disabled?: boolean, +} +export interface TaskInfo { + /** + * Scheduled Tasks on Coze + * User starts task + */ + user_task_allowed?: boolean, + /** Allow preset tasks */ + enable_preset_task?: number, +} +export enum FieldItemType { + /** Text String */ + Text = 1, + /** Digital Integer */ + Number = 2, + /** Time Time */ + Date = 3, + /** float Number */ + Float = 4, + /** bool Boolean */ + Boolean = 5, +} +export interface FieldItem { + /** field name */ + name?: string, + /** Field description */ + desc?: string, + /** field type */ + type?: FieldItemType, + /** Is it required? */ + must_required?: boolean, + /** The field Id is added as 0. */ + id?: string, + /** Field type str */ + type_str?: string, + /** Field type str */ + alterId?: number, +} +export interface Database { + /** table id */ + table_id?: string, + /** Table name */ + table_name?: string, + /** Table Introduction */ + table_desc?: string, + /** Table field information */ + field_list?: FieldItem[], + /** Whether to support calling in Prompt, the default is supported */ + prompt_disabled?: boolean, + rw_mode?: BotTableRWMode, +} +export enum BotTableRWMode { + LimitedReadWrite = 1, + ReadOnly = 2, + UnlimitedReadWrite = 3, + RWModeMax = 4, +} +export enum AgentType { + Start_Agent = 0, + LLM_Agent = 1, + Task_Agent = 2, + Global_Agent = 3, + Bot_Agent = 4, +} +/** Version Compatibility: 0 - Old Version 1 - Rollback New Version 2 - Non-Rollback New Version 3 - Rollback New Version (no longer prompted) */ +export enum AgentVersionCompat { + OldVersion = 0, + MiddleVersion = 1, + NewVersion = 2, + MiddleVersionNotPrompt = 3, +} +export interface Agent { + agent_id: string, + agent_name: string, + /** Prompt message */ + prompt_info: PromptInfo, + /** List of plugins */ + plugin_info_list: PluginInfo[], + /** dataset */ + knowledge: Knowledge, + /** Workflow List */ + workflow_info_list: WorkflowInfo[], + /** model configuration */ + model_info: ModelInfo, + /** intent information */ + intents: Intent[], + agent_type: AgentType, + /** Is it a rootagent? */ + root_agent: boolean, + reference_id: string, + first_version: string, + last_version: string, + agent_position: AgentPosition, + icon_uri: string, + jump_config: JumpConfig, + suggest_reply_info: SuggestReplyInfo, + description: string, + /** multi_agent version compatibility field */ + version_compat: AgentVersionCompat, + hook_info?: HookInfo, + /** The current version of the subbot */ + current_version?: string, + /** 1: Available update 2: Removed */ + reference_info_status?: ReferenceInfoStatus, + /** Subbot update type */ + update_type?: ReferenceUpdateType, +} +export interface AgentPosition { + x: number, + y: number, +} +export enum MultiAgentSessionType { + Flow = 1, + Host = 2, +} +export enum MultiAgentConnectorType { + Curve = 0, + Straight = 1, +} +export interface Intent { + intent_id: string, + prompt: string, + next_agent_id: string, + session_type: MultiAgentSessionType, +} +export enum BotMode { + SingleMode = 0, + MultiMode = 1, + WorkflowMode = 2, +} +export enum BotSpecies { + /** + * Bot type + * Create from flow + */ + Default = 0, + /** Created from coze */ + Function = 1, +} +export enum TimeCapsuleMode { + /** close */ + Off = 0, + /** open */ + On = 1, +} +export enum DisablePromptCalling { + Off = 0, + On = 1, +} +/** Time Capsule Information */ +export interface TimeCapsuleInfo { + time_capsule_mode?: TimeCapsuleMode, + disable_prompt_calling?: DisablePromptCalling, +} +export interface BotTagInfo { + /** Time capsule information tag key: time_capsule */ + time_capsule_info?: TimeCapsuleInfo +} +export interface FileboxInfo { + Mode?: FileboxInfoMode +} +export enum FileboxInfoMode { + Off = 0, + On = 1, +} +export enum BotStatus { + Deleted = 0, + Using = 1, + Banned = 2, +} +export enum BusinessType { + Default = 0, + DouyinAvatar = 1, +} +/** bot information */ +export interface BotInfo { + /** bot id */ + bot_id: string, + /** bot name */ + name: string, + /** Bot description */ + description: string, + /** Bot icon uri */ + icon_uri: string, + /** Bot icon url */ + icon_url: string, + /** creator id */ + creator_id: string, + /** create_time */ + create_time: string, + /** update time */ + update_time: string, + /** line of business */ + connector_id: string, + /** Version, ms */ + version: string, + /** model configuration */ + model_info: ModelInfo, + /** Prompt message */ + prompt_info: PromptInfo, + /** List of plugins */ + plugin_info_list: PluginInfo[], + /** Workflow List */ + workflow_info_list: WorkflowInfo[], + /** opening statement */ + onboarding_info: OnboardingInfo, + /** dataset */ + knowledge: Knowledge, + /** KV storage */ + variable_list: Variable[], + /** Task management/preset tasks */ + task_info: TaskInfo, + /** data table */ + database_list: Database[], + /** referral question */ + suggest_reply_info: SuggestReplyInfo, + /** Timbre Configuration */ + voices_info: VoicesInfo, + /** Additional information, extended fields */ + bot_ext_info: BotExtInfo, + /** Bot type, single agent or multi agent */ + bot_mode: BotMode, + /** Multi agent mode agent information */ + agents: Agent[], + /** Bot type */ + bot_species: BotSpecies, + /** Bot tag information, user new field */ + bot_tag_info: BotTagInfo, + /** FileBox Information */ + filebox_info: FileboxInfo, + /** multi_agent structure */ + multi_agent_info: MultiAgentInfo, + /** Background cover list structure */ + background_image_info_list: BackgroundImageInfo[], + shortcut_sort: string[], + /** bot state */ + status: BotStatus, + /** Hook information */ + hook_info?: HookInfo, + /** User query collection configuration */ + user_query_collect_conf: UserQueryCollectConf, + /** Orchestration information for workflow patterns */ + layout_info: LayoutInfo, + business_type: BusinessType, +} +export interface CommonKnowledge { + /** Knowledge Base Information */ + knowledge_infos: KnowledgeInfo[] +} +export interface ShortcutCommandComponent { + /** + * Panel parameters + * parameter name + */ + name: string, + /** parameter description */ + description: string, + /** Input type text, select, file */ + type: string, + /** When requesting a tool, the key of the parameter corresponds to the parameter name of the tool. If not, it will not be returned. */ + tool_parameter?: string, + /** Options list when type is select or what types are supported when type is file image, doc, table, audio, video, zip, code, txt, ppt */ + options?: string[], + /** Default value, not returned when not configured */ + default_value?: string, + /** Whether to hide or not to show, the shortcut command of the online bot tool type does not return the component with hide = true */ + is_hide: boolean, +} +export interface ShortcutCommandToolInfo { + /** */ + name: string, + /** Tool type workflow plugin */ + type: string, +} +export interface ShortcutCommandInfo { + /** Quick Command ID */ + id: string, + /** Shortcut button name */ + name: string, + /** Quick Instruction */ + command: string, + /** shortcut description */ + description: string, + /** Command query template */ + query_template: string, + /** Quick command icon */ + icon_url: string, + /** Component list (parameter list) */ + components?: ShortcutCommandComponent[], + /** Tool information */ + tool?: ShortcutCommandToolInfo, + /** When the multi instruction is executed by which node, it will not be returned without configuration */ + agent_id?: string, +} +export interface OpenAPIBotInfo { + /** bot id */ + bot_id: string, + /** bot name */ + name: string, + /** Bot description */ + description: string, + /** Bot image url */ + icon_url: string, + /** create_time */ + create_time: number, + /** update time */ + update_time: number, + /** version */ + version: string, + /** Prompt message */ + prompt_info: PromptInfo, + /** opening statement */ + onboarding_info: OnboardingInfo, + /** Bot type, single agent or multi agent */ + bot_mode: BotMode, + /** + * 11: optional list < VoiceData > voice_data_list,//selected voice message + * model information + */ + model_info?: ModelInfo, + /** Plugin information list */ + plugin_info_list: PluginInfo[], + /** Knowledge Base Information */ + knowledge?: CommonKnowledge, + /** Workflow information list */ + workflow_info_list: WorkflowInfo[], + /** Quick Command Information List */ + shortcut_commands: ShortcutCommandInfo[], + /** + * 17: list < Voice > voice_info_list,//Tone Configuration + * Default user input type + */ + default_user_input_type: string, + /** User Question Suggestions */ + suggest_reply_info: SuggestReplyInfo, + /** background image */ + background_image_info: BackgroundImageInfo, + /** Variable list */ + variables: Variable[], +} +export interface LayoutInfo { + /** workflowId */ + workflow_id: string, + /** PluginId */ + plugin_id: string, +} +export interface UserQueryCollectConf { + /** Whether to turn on the collection switch */ + is_collected: boolean, + /** Privacy Policy Link */ + private_policy: string, +} +export interface MultiAgentInfo { + /** multi_agent session takeover */ + session_type: MultiAgentSessionType, + /** multi_agent version compatibility field, front-end use */ + version_compat_info: AgentVersionCompatInfo, + /** multi_agent connection type, front end */ + connector_type: MultiAgentConnectorType, +} +export interface AgentVersionCompatInfo { + version_compat: AgentVersionCompat, + version: string, +} +export interface BackgroundImageInfo { + /** Web background cover */ + web_background_image?: BackgroundImageDetail, + /** Mobile end background cover */ + mobile_background_image?: BackgroundImageDetail, +} +export interface BackgroundImageDetail { + /** original image */ + origin_image_uri?: string, + origin_image_url?: string, + /** Actual use of pictures */ + image_uri?: string, + image_url?: string, + theme_color?: string, + /** Gradual change of position */ + gradient_position?: GradientPosition, + /** Crop canvas position */ + canvas_position?: CanvasPosition, +} +export interface GradientPosition { + left?: number, + right?: number, +} +export interface CanvasPosition { + width?: number, + height?: number, + left?: number, + top?: number, +} +/** Update for bot information */ +export interface BotInfoForUpdate { + /** bot id */ + bot_id?: string, + /** bot name */ + name?: string, + /** Bot description */ + description?: string, + /** Bot icon uri */ + icon_uri?: string, + /** Bot icon url */ + icon_url?: string, + /** creator id */ + creator_id?: string, + /** create_time */ + create_time?: string, + /** update time */ + update_time?: string, + /** line of business */ + connector_id?: string, + /** Version, ms */ + version?: string, + /** model configuration */ + model_info?: ModelInfo, + /** Prompt message */ + prompt_info?: PromptInfo, + /** List of plugins */ + plugin_info_list?: PluginInfo[], + /** Workflow List */ + workflow_info_list?: WorkflowInfo[], + /** opening statement */ + onboarding_info?: OnboardingInfo, + /** dataset */ + knowledge?: Knowledge, + /** KV storage */ + variable_list?: Variable[], + /** Task management/preset tasks */ + task_info?: TaskInfo, + /** data table */ + database_list?: Database[], + /** referral question */ + suggest_reply_info?: SuggestReplyInfo, + /** Timbre Configuration */ + voices_info?: VoicesInfo, + /** Additional information, extended fields */ + bot_ext_info?: BotExtInfo, + /** Bot type, single agent or multi agent */ + bot_mode?: BotMode, + /** Multi agent mode agent information */ + agents?: AgentForUpdate[], + /** Bot type */ + bot_species: BotSpecies, + /** Bot tag information, user new field */ + bot_tag_info?: BotTagInfo, + /** FileBox Information */ + filebox_info?: FileboxInfo, + /** multi_agent structure */ + multi_agent_info?: MultiAgentInfo, + /** Background cover list structure */ + background_image_info_list?: BackgroundImageInfo[], + shortcut_sort?: string[], + hook_info?: HookInfo, + /** User query collection configuration */ + user_query_collect_conf?: UserQueryCollectConf, + /** Orchestration information for workflow patterns */ + layout_info?: LayoutInfo, +} +export interface AgentForUpdate { + /** The agw field names are specially mapped, note that */ + id?: string, + /** The agw field names are specially mapped, note that */ + name?: string, + /** Prompt message */ + prompt_info?: PromptInfo, + /** List of plugins */ + plugin_info_list?: PluginInfo[], + /** dataset */ + knowledge?: Knowledge, + /** Workflow List */ + workflow_info_list?: WorkflowInfo[], + /** model configuration */ + model_info?: ModelInfo, + /** intent information */ + intents?: Intent[], + agent_type?: AgentType, + /** Is it a rootagent? */ + root_agent?: boolean, + reference_id?: string, + first_version?: string, + last_version?: string, + agent_position?: AgentPosition, + icon_uri?: string, + jump_config?: JumpConfig, + suggest_reply_info?: SuggestReplyInfo, + description?: string, + /** multi_agent version compatibility field */ + version_compat?: AgentVersionCompat, + hook_info?: HookInfo, +} +export interface TableDetail { + /** table id */ + TableId?: string, + /** Table name */ + TableName?: string, + /** Table Introduction */ + TableDesc?: string, + /** Table field information */ + FieldList?: FieldItem[], + /** Whether to support calling in Prompt, the default is supported */ + prompt_disabled?: boolean, +} +export interface TaskPluginInputField { + Name?: string, + /** "Input", "Reference" */ + Type?: string, + Value?: string, +} +export interface TaskPluginInput { + Params?: TaskPluginInputField[] +} +export interface TaskWebhookField { + Name?: string, + Type?: string, + Description?: string, + Children?: TaskWebhookField[], +} +export interface TaskWebhookOutput { + Params?: TaskWebhookField[] +} +export interface TaskInfoDetail { + /** + * Tasks Detail + * task unique identifier + */ + TaskId?: string, + /** The query executed when the timer fires, for example: Remind me to drink water. Phase 2: TriggerType == "Time" */ + UserQuestion?: string, + /** Timed task create_time */ + CreateTime?: string, + /** The time when the scheduled task will next execute */ + NextTime?: string, + /** Task Status: Valid/Invalid */ + Status?: number, + /** 1-Draft, 2-Online */ + PresetType?: number, + /** crontab expression for timed tasks */ + CronExpr?: string, + /** Treated UserQuestions, such as Drinking Water */ + TaskContent?: string, + /** Time Zone */ + TimeZone?: string, + /** task name */ + TaskName?: string, + /** "Time", "Event" */ + TriggerType?: string, + /** "Bot query", "Plugin", "Workflow" */ + Action?: string, + /** Action == "Bot query" */ + BotQuery?: string, + /** Both plugins and workflows use this field */ + PluginName?: string, + /** Both plugins and workflows use this field */ + PluginInput?: TaskPluginInput, + /** TriggerType == "Event" */ + WebhookUrl?: string, + /** TriggerType == "Event" */ + WebhookBearerToken?: string, + /** TriggerType == "Event" */ + WebhookOutput?: TaskWebhookOutput, + /** Traceability ID. Generated when created, updated/released unchanged */ + OriginId?: string, +} +export interface DraftBotInfoV2 { + BotInfo: BotInfo, + CanvasData?: string, + BaseCommitVersion?: number, + CommitVersion?: number, + /** TableInfo */ + TableInfo?: { + [key: string | number]: TableDetail + }, + /** taskInfo */ + TaskInfo?: { + [key: string | number]: TaskInfoDetail + }, +} +export enum BacktrackMode { + Current = 1, + Previous = 2, + Start = 3, + MostSuitable = 4, +} +export enum RecognitionMode { + FunctionCall = 1, + Independent = 2, +} +export interface JumpConfig { + backtrack: BacktrackMode, + recognition: RecognitionMode, + independent_conf?: IndependentModeConfig, +} +export enum IndependentTiming { + /** Determine user input (front) */ + Pre = 1, + /** Determine node output (postfix) */ + Post = 2, + /** Front mode and rear mode support simultaneous selection */ + PreAndPost = 3, +} +export enum IndependentRecognitionModelType { + /** Small model */ + SLM = 0, + /** Large model */ + LLM = 1, +} +export interface IndependentModeConfig { + /** judge timing */ + judge_timing: IndependentTiming, + history_round: number, + model_type: IndependentRecognitionModelType, + model_id?: string, + prompt?: string, +} +export interface MessageFeedback { + /** feedback type */ + feedback_type: MessageFeedbackType, + /** segmentation type */ + detail_types: MessageFeedbackDetailType[], + /** Negative feedback custom content, corresponding to user selection Others */ + detail_content: string, +} +export enum MessageFeedbackType { + Default = 0, + Like = 1, + Unlike = 2, +} +export enum MessageFeedbackDetailType { + UnlikeDefault = 0, + /** Harmful information */ + UnlikeHarmful = 1, + /** incorrect information */ + UnlikeIncorrect = 2, + /** Did not follow instructions */ + UnlikeNotFollowInstructions = 3, + /** other */ + UnlikeOthers = 4, +} +export enum Scene { + Default = 0, + Explore = 1, + BotStore = 2, + CozeHome = 3, + Playground = 4, + /** evaluation platform */ + Evaluation = 5, + AgentAPP = 6, + /** Prompt optimization */ + PromptOptimize = 7, + /** Createbot's nl2bot features */ + GenerateAgentInfo = 8, +} +export interface UserLabel { + label_id: string, + label_name: string, + icon_uri: string, + icon_url: string, + jump_link: string, +} +export interface ChatV3ChatDetail { + id: string, + conversation_id: string, + bot_id: string, + created_at?: number, + completed_at?: number, + failed_at?: number, + meta_data?: { + [key: string | number]: string + }, + last_error?: LastError, + status: string, + usage?: Usage, + required_action?: RequiredAction, + section_id?: string, +} +export interface LastError { + code: number, + msg: string, +} +export interface Usage { + token_count?: number, + output_count?: number, + input_count?: number, +} +export interface RequiredAction { + type: string, + submit_tool_outputs: SubmitToolOutputs, +} +export interface SubmitToolOutputs { + tool_calls: InterruptPlugin[] +} +export interface InterruptPlugin { + id: string, + type: string, + function: InterruptFunction, + require_info: InterruptRequireInfo, +} +export interface InterruptFunction { + name: string, + arguments: string, +} +export interface InterruptRequireInfo { + infos: string[] +} +export interface ChatV3MessageDetail { + id: string, + conversation_id: string, + bot_id: string, + role: string, + type: string, + content: string, + content_type: string, + meta_data?: { + [key: string | number]: string + }, + chat_id: string, + section_id?: string, + created_at?: number, + updated_at?: number, + reasoning_content?: string, +} +export interface HookInfo { + /** Pre agent jump hook */ + pre_agent_jump_hook?: HookItem[], + /** Post agent jump hook */ + post_agent_jump_hook?: HookItem[], + /** Process hook */ + flow_hook?: HookItem[], + /** Atomic power hook */ + atomic_hook?: HookItem[], + /** Model call hook */ + llm_call_hook?: HookItem[], + /** Conversation result hook */ + res_parsing_hook?: HookItem[], + /** suggesion hook */ + suggestion_hook?: HookItem[], +} +export interface HookItem { + uri?: string, + filter_rules?: string[], + strong_dep?: boolean, + timeout_ms?: number, +} +/** + * struct ContentAttachment { + * 1: required string FileID (api.body = "file_id") + * } + * struct MetaContent{ + * 1: required string Type (api.body="type"), + * 2: optional string Text ( api.body="text"), + * 3: optional string FileID (api.body="file_id"), + * 4: optional string FileURL (api.body="file_url"), + * 5: optional string Card (api.body="card"), + * } + * struct EnterMessage { + * 1: required string Role (api.body = "role") + * 2: string Content (api.body = "content")//content + * 3: map MetaData(api.body = "meta_data") + * 4: string ContentType(api.body = "content_type")//text/card/object_string + * 5: string Type(api.body = "type") + * } + * struct OpenMessageApi { + * 1: string Id (api.body = "id")//primary key ID + * 2: string BotId (api.body = "bot_id")//bot id//TODO All i64 plus annotation str, imported parameters and exported parameters are required + * 3: string Role(api.body = "role") + * 4: string Content (api.body = "content")//content + * 5: string ConversationId(api.body = "conversation_id") // conversation id + * 6: map MetaData(api.body = "meta_data") + * 7: string CreatedAt (api.body = "created_at")//create_time + * 8: string UpdatedAt (api.body = "updated_at")//Update time//Change TODO time to int + * 9: string ChatId(api.body = "chat_id") + * 10: string ContentType(api.body = "content_type") + * 11: string Type(api.body = "type") + * } +*/ +export enum ReferenceUpdateType { + ManualUpdate = 1, + AutoUpdate = 2, +} +export enum ReferenceInfoStatus { + /** 1: Updates are available */ + HasUpdates = 1, + /** 2: Deleted */ + IsDelete = 2, +} \ No newline at end of file diff --git a/frontend/packages/arch/api-schema/src/idl/upload/upload.ts b/frontend/packages/arch/api-schema/src/idl/upload/upload.ts new file mode 100644 index 000000000..3d9e5d7b8 --- /dev/null +++ b/frontend/packages/arch/api-schema/src/idl/upload/upload.ts @@ -0,0 +1,157 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as bot_common from './../app/bot_common'; +export { bot_common }; +import * as base from './../base'; +export { base }; +import { createAPI } from './../../api/config'; +export interface CommonUploadRequest { + ByteData?: Blob, + uploadID?: string, + partNumber?: string, +} +export interface Error { + code: number, + error: string, + error_code: number, + message: string, +} +export interface Payload { + hash: string, + key: string, + uploadID: string, +} +export interface CommonUploadResponse { + Version: string, + success: number, + error: Error, + payload: Payload, +} +export interface ApplyUploadActionRequest { + Action?: string, + Version?: string, + ServiceId?: string, + FileExtension?: string, + FileSize?: string, + s?: string, + ByteData?: Blob, +} +export interface ResponseMetadata { + RequestId: string, + Action: string, + Version: string, + Service: string, + Region: string, +} +export interface StoreInfo { + StoreUri: string, + Auth: string, + UploadID: string, +} +export interface UploadAddress { + StoreInfos: StoreInfo[], + UploadHosts: string[], + UploadHeader?: { + [key: string | number]: string + }, + SessionKey: string, + Cloud: string, +} +export interface UploadNode { + StoreInfos: StoreInfo[], + UploadHost: string, + UploadHeader?: { + [key: string | number]: string + }, + SessionKey: string, +} +export interface InnerUploadAddress { + UploadNodes: UploadNode[] +} +export interface UploadResult { + Uri: string, + UriStatus: number, +} +export interface PluginResult { + FileName: string, + SourceUri: string, + ImageUri: string, + ImageWidth: number, + ImageHeight: number, + ImageMd5: string, + ImageFormat: string, + ImageSize: number, + FrameCnt: number, +} +export interface ApplyUploadActionResult { + UploadAddress?: UploadAddress, + FallbackUploadAddress?: UploadAddress, + InnerUploadAddress?: InnerUploadAddress, + RequestId?: string, + SDKParam?: string, + Results?: UploadResult[], + PluginResult?: PluginResult[], +} +export interface ApplyUploadActionResponse { + ResponseMetadata: ResponseMetadata, + Result: ApplyUploadActionResult, +} +export interface RecordFileInfoRequest { + FileURI: string, + FileName: string, + FileSize?: string, + FileExtension?: string, +} +export interface RecordFileInfoResponse {} +export const CommonUpload = /*#__PURE__*/createAPI({ + "url": "/api/common/upload/*tos_uri", + "method": "POST", + "name": "CommonUpload", + "reqType": "CommonUploadRequest", + "reqMapping": { + "raw_body": [], + "query": ["uploadID", "partNumber"] + }, + "resType": "CommonUploadResponse", + "schemaRoot": "api://schemas/idl_upload_upload", + "service": "upload" +}); +export const ApplyUploadAction = /*#__PURE__*/createAPI({ + "url": "/api/common/upload/apply_upload_action", + "method": "POST", + "name": "ApplyUploadAction", + "reqType": "ApplyUploadActionRequest", + "reqMapping": { + "query": ["Action", "Version", "ServiceId", "FileExtension", "FileSize", "s"], + "raw_body": [] + }, + "resType": "ApplyUploadActionResponse", + "schemaRoot": "api://schemas/idl_upload_upload", + "service": "upload" +}); +export const RecordFileInfo = /*#__PURE__*/createAPI({ + "url": "/api/common/record_file_info", + "method": "POST", + "name": "RecordFileInfo", + "reqType": "RecordFileInfoRequest", + "reqMapping": { + "body": ["FileURI", "FileName", "FileSize", "FileExtension"] + }, + "resType": "RecordFileInfoResponse", + "schemaRoot": "api://schemas/idl_upload_upload", + "service": "upload" +}); \ No newline at end of file diff --git a/frontend/packages/arch/api-schema/src/index.ts b/frontend/packages/arch/api-schema/src/index.ts index 5870c4a28..decf79d56 100644 --- a/frontend/packages/arch/api-schema/src/index.ts +++ b/frontend/packages/arch/api-schema/src/index.ts @@ -16,3 +16,4 @@ export * as passport from './idl/passport/passport'; export * as explore from './idl/marketplace/public_api'; +export * as upload from './idl/upload/upload'; diff --git a/frontend/packages/workflow/playground/package.json b/frontend/packages/workflow/playground/package.json index 04295a329..b79c96e61 100644 --- a/frontend/packages/workflow/playground/package.json +++ b/frontend/packages/workflow/playground/package.json @@ -92,6 +92,7 @@ "@coze-foundation/layout": "workspace:*", "@coze-foundation/local-storage": "workspace:*", "@coze-project-ide/framework": "workspace:*", + "@coze-studio/api-schema": "workspace:*", "@coze-studio/bot-detail-store": "workspace:*", "@coze-studio/components": "workspace:*", "@coze-studio/open-chat": "workspace:*", diff --git a/frontend/packages/workflow/playground/src/hooks/use-upload/use-upload.ts b/frontend/packages/workflow/playground/src/hooks/use-upload/use-upload.ts index 0f53b9085..27d2147be 100644 --- a/frontend/packages/workflow/playground/src/hooks/use-upload/use-upload.ts +++ b/frontend/packages/workflow/playground/src/hooks/use-upload/use-upload.ts @@ -20,10 +20,11 @@ import { useState } from 'react'; import { nanoid } from 'nanoid'; import { workflowApi } from '@coze-workflow/base/api'; import { type ViewVariableType } from '@coze-workflow/base'; +import { upload as uploadAPI } from '@coze-studio/api-schema'; import { I18n } from '@coze-arch/i18n'; +import { Toast } from '@coze-arch/coze-design'; import { upLoadFile } from '@coze-arch/bot-utils'; import { CustomError } from '@coze-arch/bot-error'; -import { Toast } from '@coze-arch/coze-design'; import { validate } from './validate'; import { FileItemStatus, type FileItem } from './types'; @@ -101,7 +102,10 @@ export const useUpload = (props?: UploadConfig) => { // Upload complete, clear timeout timer clearTimeout(progressTimer); - + await uploadAPI.RecordFileInfo({ + FileURI: uri, + FileName: file.name, + }); // Add uri and get the url. const { url } = await workflowApi.SignImageURL( { @@ -134,7 +138,8 @@ export const useUpload = (props?: UploadConfig) => { const validateFile = async (file: FileItem): Promise => { const validateMsg = await validate(file, { customValidate, - maxSize: maxSize ?? fileType === 'image' ? MAX_IMAGE_SIZE : MAX_FILE_SIZE, + maxSize: + (maxSize ?? fileType === 'image') ? MAX_IMAGE_SIZE : MAX_FILE_SIZE, accept, }); if (validateMsg) { diff --git a/frontend/packages/workflow/playground/tsconfig.build.json b/frontend/packages/workflow/playground/tsconfig.build.json index b7f33ca96..ed879f7bd 100644 --- a/frontend/packages/workflow/playground/tsconfig.build.json +++ b/frontend/packages/workflow/playground/tsconfig.build.json @@ -53,6 +53,9 @@ { "path": "../../agent-ide/space-bot/tsconfig.build.json" }, + { + "path": "../../arch/api-schema/tsconfig.build.json" + }, { "path": "../../arch/bot-api/tsconfig.build.json" },