Skip to content

Commit a4e32cb

Browse files
authored
feat: support bot marketplace (#1374)
1 parent 53ee75f commit a4e32cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5176
-265
lines changed

aperag/api/components/schemas/auth.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ user:
103103
registration_source:
104104
type: string
105105
description: The registration source of the user (local, google, github, etc.)
106+
department_id:
107+
type: string
108+
description: The department ID the user belongs to
109+
nullable: true
106110

107111
userList:
108112
type: object
@@ -127,3 +131,49 @@ changePassword:
127131
new_password:
128132
type: string
129133
description: The new password of the user
134+
135+
department:
136+
type: object
137+
properties:
138+
id:
139+
type: string
140+
description: The ID of the department
141+
parent_id:
142+
type: string
143+
description: The parent department ID, -1 for root department
144+
name:
145+
type: string
146+
description: The name of the department
147+
status:
148+
type: integer
149+
description: The status of the department (0=inactive, 1=active)
150+
enum: [0, 1]
151+
group_path:
152+
type: string
153+
description: The hierarchical path of the department
154+
tenant_id:
155+
type: string
156+
description: The tenant ID this department belongs to
157+
created_at:
158+
type: string
159+
description: The date and time the department was created
160+
updated_at:
161+
type: string
162+
description: The date and time the department was last updated
163+
children:
164+
type: array
165+
items:
166+
$ref: '#/department'
167+
description: Child departments (only present in hierarchical mode)
168+
nullable: true
169+
170+
departmentList:
171+
type: object
172+
description: A list of departments
173+
properties:
174+
items:
175+
type: array
176+
items:
177+
$ref: '#/department'
178+
pageResult:
179+
$ref: './common.yaml#/pageResult'

aperag/api/components/schemas/bot.yaml

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1+
agentConfig:
2+
type: object
3+
properties:
4+
completion:
5+
$ref: './model.yaml#/modelSpec'
6+
system_prompt_template:
7+
type: string
8+
query_prompt_template:
9+
type: string
10+
collections:
11+
type: array
12+
items:
13+
$ref: './collection.yaml#/collection'
14+
115
botConfig:
216
type: object
317
properties:
418
agent:
5-
type: object
6-
properties:
7-
completion:
8-
$ref: './model.yaml#/modelSpec'
9-
system_prompt_template:
10-
type: string
11-
query_prompt_template:
12-
type: string
13-
collections:
14-
type: array
15-
items:
16-
$ref: './collection.yaml#/collection'
19+
$ref: '#/agentConfig'
1720
flow:
1821
$ref: './flow.yaml#/components/schemas/WorkflowDefinition'
1922

@@ -92,3 +95,60 @@ debugFlowRequest:
9295
type: string
9396
required:
9497
- query
98+
99+
botPublishRequest:
100+
type: object
101+
properties:
102+
group_ids:
103+
type: array
104+
items:
105+
type: string
106+
description: List of department IDs to publish to, or ["*"] for global publishing
107+
example: ["*", "dp_1", "dp_2"]
108+
required:
109+
- group_ids
110+
111+
botMarketplace:
112+
type: object
113+
properties:
114+
id:
115+
type: string
116+
description: Marketplace entry ID
117+
bot_id:
118+
type: string
119+
description: Bot ID
120+
group_id:
121+
type: string
122+
description: Department ID or "*" for global
123+
status:
124+
type: string
125+
enum: [DRAFT, PUBLISHED]
126+
description: Publishing status
127+
published_at:
128+
type: string
129+
format: date-time
130+
description: When the bot was published
131+
132+
marketplaceBotList:
133+
type: object
134+
description: List of marketplace bots accessible to user
135+
properties:
136+
items:
137+
type: array
138+
items:
139+
allOf:
140+
- $ref: '#/bot'
141+
- type: object
142+
properties:
143+
group_id:
144+
type: string
145+
description: The department this bot is published to
146+
published_at:
147+
type: string
148+
format: date-time
149+
description: When the bot was published
150+
owner_username:
151+
type: string
152+
description: Username of the bot owner
153+
pageResult:
154+
$ref: './common.yaml#/pageResult'

aperag/api/components/schemas/marketplace.yaml

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,118 @@ SharingStatusResponse:
114114
nullable: true
115115
description: Publication time, null when not published
116116
required:
117-
- is_published
117+
- is_published
118+
119+
BotMarketplaceStatusEnum:
120+
type: string
121+
enum:
122+
- DRAFT
123+
- PUBLISHED
124+
description: Bot marketplace sharing status
125+
126+
127+
BotSharingStatusResponse:
128+
type: object
129+
description: Simple sharing status response
130+
properties:
131+
is_published:
132+
type: boolean
133+
description: Whether published to marketplace
134+
group_ids:
135+
type: array
136+
items:
137+
type: string
138+
description: List of department IDs where the bot is published
139+
is_global:
140+
type: boolean
141+
description: Whether the bot is published globally
142+
required:
143+
- is_published
144+
145+
SharedBotConfig:
146+
type: object
147+
description: Configuration settings for shared bot (read-only version)
148+
properties:
149+
agent:
150+
$ref: './bot.yaml#/agentConfig'
151+
flow:
152+
$ref: './flow.yaml#/components/schemas/WorkflowDefinition'
153+
154+
SharedBot:
155+
type: object
156+
description: Shared bot information for marketplace users
157+
properties:
158+
id:
159+
type: string
160+
description: Bot ID
161+
title:
162+
type: string
163+
description: Bot title
164+
description:
165+
type: string
166+
nullable: true
167+
description: Bot description
168+
type:
169+
type: string
170+
enum:
171+
- knowledge
172+
- common
173+
- agent
174+
description: Bot type
175+
owner_user_id:
176+
type: string
177+
description: Original owner user ID
178+
owner_username:
179+
type: string
180+
nullable: true
181+
description: Original owner username
182+
subscription_id:
183+
type: string
184+
nullable: true
185+
description: Subscription record ID (has value if subscribed, null if not subscribed)
186+
gmt_subscribed:
187+
type: string
188+
format: date-time
189+
nullable: true
190+
description: Subscription time (only has value when subscribed)
191+
config:
192+
$ref: '#/SharedBotConfig'
193+
description: Bot configuration settings (read-only)
194+
is_subscribed:
195+
type: boolean
196+
description: Whether current user has subscribed to this bot
197+
is_owner:
198+
type: boolean
199+
description: Whether current user is the owner of this bot
200+
required:
201+
- id
202+
- title
203+
- type
204+
- owner_user_id
205+
- config
206+
- is_subscribed
207+
- is_owner
208+
209+
SharedBotList:
210+
type: object
211+
description: Shared bot list response
212+
properties:
213+
items:
214+
type: array
215+
items:
216+
$ref: '#/SharedBot'
217+
description: List of shared bots
218+
total:
219+
type: integer
220+
description: Total count (for pagination)
221+
page:
222+
type: integer
223+
description: Current page number
224+
page_size:
225+
type: integer
226+
description: Page size
227+
required:
228+
- items
229+
- total
230+
- page
231+
- page_size

aperag/api/openapi.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ paths:
2929
$ref: './paths/flow.yaml#/flow'
3030
/bots/{bot_id}/flow/debug:
3131
$ref: './paths/bots.yaml#/debugFlow'
32+
/bots/{bot_id}/sharing:
33+
$ref: './paths/bots.yaml#/botSharing'
3234

3335
# chats
3436
/bots/{bot_id}/chats:
@@ -116,6 +118,12 @@ paths:
116118
/marketplace/collections/{collection_id}/graph:
117119
$ref: './paths/marketplace.yaml#/marketplaceCollectionGraph'
118120

121+
# Bot marketplace
122+
/marketplace/bots:
123+
$ref: './paths/marketplace.yaml#/marketplaceBots'
124+
/marketplace/bots/{bot_id}:
125+
$ref: './paths/marketplace.yaml#/marketplaceBot'
126+
119127
# object storage sync
120128
/collections/{collection_id}/sync:
121129
$ref: './paths/collections.yaml#/sync_object_storage'
@@ -183,6 +191,8 @@ paths:
183191
$ref: './paths/auth.yaml#/changePassword'
184192
/users/{user_id}:
185193
$ref: './paths/auth.yaml#/deleteUser'
194+
/departments:
195+
$ref: './paths/auth.yaml#/departments'
186196

187197
# quotas
188198
/quotas:

aperag/api/paths/auth.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,35 @@ user:
160160
application/json:
161161
schema:
162162
$ref: '../components/schemas/common.yaml#/failResponse'
163+
164+
departments:
165+
get:
166+
summary: Get department organization structure
167+
description: Get department organization structure information
168+
parameters:
169+
- name: tenant_id
170+
in: query
171+
required: false
172+
schema:
173+
type: string
174+
description: Optional tenant ID to filter departments
175+
- name: hierarchical
176+
in: query
177+
required: false
178+
schema:
179+
type: boolean
180+
default: true
181+
description: If true, returns departments in hierarchical structure with children
182+
responses:
183+
'200':
184+
description: Departments fetched successfully
185+
content:
186+
application/json:
187+
schema:
188+
$ref: '../components/schemas/auth.yaml#/departmentList'
189+
'401':
190+
description: Unauthorized
191+
content:
192+
application/json:
193+
schema:
194+
$ref: '../components/schemas/common.yaml#/failResponse'

0 commit comments

Comments
 (0)