feat(web): use generate sdk

This commit is contained in:
Acbox
2026-02-11 15:23:47 +08:00
parent ca86a8d1c3
commit 1f30e666e0
48 changed files with 1670 additions and 722 deletions
+360
View File
@@ -162,6 +162,13 @@ const docTemplate = `{
], ],
"summary": "Chat with AI", "summary": "Chat with AI",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Chat request", "description": "Chat request",
"name": "request", "name": "request",
@@ -208,6 +215,13 @@ const docTemplate = `{
], ],
"summary": "Stream chat with AI", "summary": "Stream chat with AI",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Chat request", "description": "Chat request",
"name": "request", "name": "request",
@@ -1136,6 +1150,13 @@ const docTemplate = `{
], ],
"summary": "List history records", "summary": "List history records",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Limit", "description": "Limit",
@@ -1171,6 +1192,13 @@ const docTemplate = `{
], ],
"summary": "Create history record", "summary": "Create history record",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "History payload", "description": "History payload",
"name": "payload", "name": "payload",
@@ -1208,6 +1236,15 @@ const docTemplate = `{
"history" "history"
], ],
"summary": "Delete all history records", "summary": "Delete all history records",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"204": { "204": {
"description": "No Content" "description": "No Content"
@@ -1235,6 +1272,13 @@ const docTemplate = `{
], ],
"summary": "Get history record", "summary": "Get history record",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "History ID", "description": "History ID",
@@ -1277,6 +1321,13 @@ const docTemplate = `{
], ],
"summary": "Delete history record", "summary": "Delete history record",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "History ID", "description": "History ID",
@@ -1317,6 +1368,15 @@ const docTemplate = `{
"mcp" "mcp"
], ],
"summary": "List MCP connections", "summary": "List MCP connections",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -1357,6 +1417,13 @@ const docTemplate = `{
], ],
"summary": "Create MCP connection", "summary": "Create MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "MCP payload", "description": "MCP payload",
"name": "payload", "name": "payload",
@@ -1522,6 +1589,13 @@ const docTemplate = `{
], ],
"summary": "Get MCP connection", "summary": "Get MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "MCP ID", "description": "MCP ID",
@@ -1570,6 +1644,13 @@ const docTemplate = `{
], ],
"summary": "Update MCP connection", "summary": "Update MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "MCP ID", "description": "MCP ID",
@@ -1627,6 +1708,13 @@ const docTemplate = `{
], ],
"summary": "Delete MCP connection", "summary": "Delete MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "MCP ID", "description": "MCP ID",
@@ -1674,6 +1762,13 @@ const docTemplate = `{
], ],
"summary": "Add memory", "summary": "Add memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Add request", "description": "Add request",
"name": "payload", "name": "payload",
@@ -1714,6 +1809,13 @@ const docTemplate = `{
], ],
"summary": "Embed and upsert memory", "summary": "Embed and upsert memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Embed upsert request", "description": "Embed upsert request",
"name": "payload", "name": "payload",
@@ -1754,6 +1856,13 @@ const docTemplate = `{
], ],
"summary": "List memories", "summary": "List memories",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Run ID", "description": "Run ID",
@@ -1795,6 +1904,13 @@ const docTemplate = `{
], ],
"summary": "Delete memories", "summary": "Delete memories",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Delete all request", "description": "Delete all request",
"name": "payload", "name": "payload",
@@ -1835,6 +1951,13 @@ const docTemplate = `{
], ],
"summary": "Get memory", "summary": "Get memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Memory ID", "description": "Memory ID",
@@ -1871,6 +1994,13 @@ const docTemplate = `{
], ],
"summary": "Delete memory", "summary": "Delete memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Memory ID", "description": "Memory ID",
@@ -1909,6 +2039,13 @@ const docTemplate = `{
], ],
"summary": "Search memories", "summary": "Search memories",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Search request", "description": "Search request",
"name": "payload", "name": "payload",
@@ -1949,6 +2086,13 @@ const docTemplate = `{
], ],
"summary": "Update memory", "summary": "Update memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Update request", "description": "Update request",
"name": "payload", "name": "payload",
@@ -1988,6 +2132,15 @@ const docTemplate = `{
"schedule" "schedule"
], ],
"summary": "List schedules", "summary": "List schedules",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -2016,6 +2169,13 @@ const docTemplate = `{
], ],
"summary": "Create schedule", "summary": "Create schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Schedule payload", "description": "Schedule payload",
"name": "payload", "name": "payload",
@@ -2056,6 +2216,13 @@ const docTemplate = `{
], ],
"summary": "Get schedule", "summary": "Get schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Schedule ID", "description": "Schedule ID",
@@ -2098,6 +2265,13 @@ const docTemplate = `{
], ],
"summary": "Update schedule", "summary": "Update schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Schedule ID", "description": "Schedule ID",
@@ -2143,6 +2317,13 @@ const docTemplate = `{
], ],
"summary": "Delete schedule", "summary": "Delete schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Schedule ID", "description": "Schedule ID",
@@ -2177,6 +2358,15 @@ const docTemplate = `{
"settings" "settings"
], ],
"summary": "Get user settings", "summary": "Get user settings",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -2205,6 +2395,13 @@ const docTemplate = `{
], ],
"summary": "Update user settings", "summary": "Update user settings",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Settings payload", "description": "Settings payload",
"name": "payload", "name": "payload",
@@ -2243,6 +2440,13 @@ const docTemplate = `{
], ],
"summary": "Update user settings", "summary": "Update user settings",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Settings payload", "description": "Settings payload",
"name": "payload", "name": "payload",
@@ -2280,6 +2484,15 @@ const docTemplate = `{
"settings" "settings"
], ],
"summary": "Delete user settings", "summary": "Delete user settings",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"204": { "204": {
"description": "No Content" "description": "No Content"
@@ -2306,6 +2519,15 @@ const docTemplate = `{
"subagent" "subagent"
], ],
"summary": "List subagents", "summary": "List subagents",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -2334,6 +2556,13 @@ const docTemplate = `{
], ],
"summary": "Create subagent", "summary": "Create subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Subagent payload", "description": "Subagent payload",
"name": "payload", "name": "payload",
@@ -2374,6 +2603,13 @@ const docTemplate = `{
], ],
"summary": "Get subagent", "summary": "Get subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2416,6 +2652,13 @@ const docTemplate = `{
], ],
"summary": "Update subagent", "summary": "Update subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2467,6 +2710,13 @@ const docTemplate = `{
], ],
"summary": "Delete subagent", "summary": "Delete subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2508,6 +2758,13 @@ const docTemplate = `{
], ],
"summary": "Get subagent context", "summary": "Get subagent context",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2550,6 +2807,13 @@ const docTemplate = `{
], ],
"summary": "Update subagent context", "summary": "Update subagent context",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2603,6 +2867,13 @@ const docTemplate = `{
], ],
"summary": "Get subagent skills", "summary": "Get subagent skills",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2645,6 +2916,13 @@ const docTemplate = `{
], ],
"summary": "Update subagent skills", "summary": "Update subagent skills",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2696,6 +2974,13 @@ const docTemplate = `{
], ],
"summary": "Add subagent skills", "summary": "Add subagent skills",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -4744,6 +5029,15 @@ const docTemplate = `{
"definitions": { "definitions": {
"bots.Bot": { "bots.Bot": {
"type": "object", "type": "object",
"required": [
"created_at",
"display_name",
"id",
"is_active",
"owner_user_id",
"type",
"updated_at"
],
"properties": { "properties": {
"avatar_url": { "avatar_url": {
"type": "string" "type": "string"
@@ -4815,6 +5109,9 @@ const docTemplate = `{
}, },
"bots.ListBotsResponse": { "bots.ListBotsResponse": {
"type": "object", "type": "object",
"required": [
"items"
],
"properties": { "properties": {
"items": { "items": {
"type": "array", "type": "array",
@@ -5459,6 +5756,16 @@ const docTemplate = `{
}, },
"github_com_memohai_memoh_internal_mcp.Connection": { "github_com_memohai_memoh_internal_mcp.Connection": {
"type": "object", "type": "object",
"required": [
"active",
"bot_id",
"config",
"created_at",
"id",
"name",
"type",
"updated_at"
],
"properties": { "properties": {
"active": { "active": {
"type": "boolean" "type": "boolean"
@@ -5489,6 +5796,12 @@ const docTemplate = `{
}, },
"handlers.ChannelMeta": { "handlers.ChannelMeta": {
"type": "object", "type": "object",
"required": [
"capabilities",
"config_schema",
"display_name",
"type"
],
"properties": { "properties": {
"capabilities": { "capabilities": {
"$ref": "#/definitions/channel.ChannelCapabilities" "$ref": "#/definitions/channel.ChannelCapabilities"
@@ -5839,6 +6152,10 @@ const docTemplate = `{
}, },
"handlers.LoginRequest": { "handlers.LoginRequest": {
"type": "object", "type": "object",
"required": [
"password",
"username"
],
"properties": { "properties": {
"password": { "password": {
"type": "string" "type": "string"
@@ -5850,6 +6167,15 @@ const docTemplate = `{
}, },
"handlers.LoginResponse": { "handlers.LoginResponse": {
"type": "object", "type": "object",
"required": [
"access_token",
"display_name",
"expires_at",
"role",
"token_type",
"user_id",
"username"
],
"properties": { "properties": {
"access_token": { "access_token": {
"type": "string" "type": "string"
@@ -6318,6 +6644,12 @@ const docTemplate = `{
}, },
"models.AddRequest": { "models.AddRequest": {
"type": "object", "type": "object",
"required": [
"llm_provider_id",
"model_id",
"name",
"type"
],
"properties": { "properties": {
"dimensions": { "dimensions": {
"type": "integer" "type": "integer"
@@ -6366,6 +6698,12 @@ const docTemplate = `{
}, },
"models.GetResponse": { "models.GetResponse": {
"type": "object", "type": "object",
"required": [
"llm_provider_id",
"model_id",
"name",
"type"
],
"properties": { "properties": {
"dimensions": { "dimensions": {
"type": "integer" "type": "integer"
@@ -6406,6 +6744,12 @@ const docTemplate = `{
}, },
"models.UpdateRequest": { "models.UpdateRequest": {
"type": "object", "type": "object",
"required": [
"llm_provider_id",
"model_id",
"name",
"type"
],
"properties": { "properties": {
"dimensions": { "dimensions": {
"type": "integer" "type": "integer"
@@ -6486,6 +6830,14 @@ const docTemplate = `{
}, },
"providers.GetResponse": { "providers.GetResponse": {
"type": "object", "type": "object",
"required": [
"base_url",
"client_type",
"created_at",
"id",
"name",
"updated_at"
],
"properties": { "properties": {
"api_key": { "api_key": {
"description": "masked in response", "description": "masked in response",
@@ -6644,6 +6996,14 @@ const docTemplate = `{
}, },
"settings.Settings": { "settings.Settings": {
"type": "object", "type": "object",
"required": [
"allow_guest",
"chat_model_id",
"embedding_model_id",
"language",
"max_context_load_time",
"memory_model_id"
],
"properties": { "properties": {
"allow_guest": { "allow_guest": {
"type": "boolean" "type": "boolean"
+360
View File
@@ -153,6 +153,13 @@
], ],
"summary": "Chat with AI", "summary": "Chat with AI",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Chat request", "description": "Chat request",
"name": "request", "name": "request",
@@ -199,6 +206,13 @@
], ],
"summary": "Stream chat with AI", "summary": "Stream chat with AI",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Chat request", "description": "Chat request",
"name": "request", "name": "request",
@@ -1127,6 +1141,13 @@
], ],
"summary": "List history records", "summary": "List history records",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Limit", "description": "Limit",
@@ -1162,6 +1183,13 @@
], ],
"summary": "Create history record", "summary": "Create history record",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "History payload", "description": "History payload",
"name": "payload", "name": "payload",
@@ -1199,6 +1227,15 @@
"history" "history"
], ],
"summary": "Delete all history records", "summary": "Delete all history records",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"204": { "204": {
"description": "No Content" "description": "No Content"
@@ -1226,6 +1263,13 @@
], ],
"summary": "Get history record", "summary": "Get history record",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "History ID", "description": "History ID",
@@ -1268,6 +1312,13 @@
], ],
"summary": "Delete history record", "summary": "Delete history record",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "History ID", "description": "History ID",
@@ -1308,6 +1359,15 @@
"mcp" "mcp"
], ],
"summary": "List MCP connections", "summary": "List MCP connections",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -1348,6 +1408,13 @@
], ],
"summary": "Create MCP connection", "summary": "Create MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "MCP payload", "description": "MCP payload",
"name": "payload", "name": "payload",
@@ -1513,6 +1580,13 @@
], ],
"summary": "Get MCP connection", "summary": "Get MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "MCP ID", "description": "MCP ID",
@@ -1561,6 +1635,13 @@
], ],
"summary": "Update MCP connection", "summary": "Update MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "MCP ID", "description": "MCP ID",
@@ -1618,6 +1699,13 @@
], ],
"summary": "Delete MCP connection", "summary": "Delete MCP connection",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "MCP ID", "description": "MCP ID",
@@ -1665,6 +1753,13 @@
], ],
"summary": "Add memory", "summary": "Add memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Add request", "description": "Add request",
"name": "payload", "name": "payload",
@@ -1705,6 +1800,13 @@
], ],
"summary": "Embed and upsert memory", "summary": "Embed and upsert memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Embed upsert request", "description": "Embed upsert request",
"name": "payload", "name": "payload",
@@ -1745,6 +1847,13 @@
], ],
"summary": "List memories", "summary": "List memories",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Run ID", "description": "Run ID",
@@ -1786,6 +1895,13 @@
], ],
"summary": "Delete memories", "summary": "Delete memories",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Delete all request", "description": "Delete all request",
"name": "payload", "name": "payload",
@@ -1826,6 +1942,13 @@
], ],
"summary": "Get memory", "summary": "Get memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Memory ID", "description": "Memory ID",
@@ -1862,6 +1985,13 @@
], ],
"summary": "Delete memory", "summary": "Delete memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Memory ID", "description": "Memory ID",
@@ -1900,6 +2030,13 @@
], ],
"summary": "Search memories", "summary": "Search memories",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Search request", "description": "Search request",
"name": "payload", "name": "payload",
@@ -1940,6 +2077,13 @@
], ],
"summary": "Update memory", "summary": "Update memory",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Update request", "description": "Update request",
"name": "payload", "name": "payload",
@@ -1979,6 +2123,15 @@
"schedule" "schedule"
], ],
"summary": "List schedules", "summary": "List schedules",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -2007,6 +2160,13 @@
], ],
"summary": "Create schedule", "summary": "Create schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Schedule payload", "description": "Schedule payload",
"name": "payload", "name": "payload",
@@ -2047,6 +2207,13 @@
], ],
"summary": "Get schedule", "summary": "Get schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Schedule ID", "description": "Schedule ID",
@@ -2089,6 +2256,13 @@
], ],
"summary": "Update schedule", "summary": "Update schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Schedule ID", "description": "Schedule ID",
@@ -2134,6 +2308,13 @@
], ],
"summary": "Delete schedule", "summary": "Delete schedule",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Schedule ID", "description": "Schedule ID",
@@ -2168,6 +2349,15 @@
"settings" "settings"
], ],
"summary": "Get user settings", "summary": "Get user settings",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -2196,6 +2386,13 @@
], ],
"summary": "Update user settings", "summary": "Update user settings",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Settings payload", "description": "Settings payload",
"name": "payload", "name": "payload",
@@ -2234,6 +2431,13 @@
], ],
"summary": "Update user settings", "summary": "Update user settings",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Settings payload", "description": "Settings payload",
"name": "payload", "name": "payload",
@@ -2271,6 +2475,15 @@
"settings" "settings"
], ],
"summary": "Delete user settings", "summary": "Delete user settings",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"204": { "204": {
"description": "No Content" "description": "No Content"
@@ -2297,6 +2510,15 @@
"subagent" "subagent"
], ],
"summary": "List subagents", "summary": "List subagents",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@@ -2325,6 +2547,13 @@
], ],
"summary": "Create subagent", "summary": "Create subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"description": "Subagent payload", "description": "Subagent payload",
"name": "payload", "name": "payload",
@@ -2365,6 +2594,13 @@
], ],
"summary": "Get subagent", "summary": "Get subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2407,6 +2643,13 @@
], ],
"summary": "Update subagent", "summary": "Update subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2458,6 +2701,13 @@
], ],
"summary": "Delete subagent", "summary": "Delete subagent",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2499,6 +2749,13 @@
], ],
"summary": "Get subagent context", "summary": "Get subagent context",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2541,6 +2798,13 @@
], ],
"summary": "Update subagent context", "summary": "Update subagent context",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2594,6 +2858,13 @@
], ],
"summary": "Get subagent skills", "summary": "Get subagent skills",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2636,6 +2907,13 @@
], ],
"summary": "Update subagent skills", "summary": "Update subagent skills",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -2687,6 +2965,13 @@
], ],
"summary": "Add subagent skills", "summary": "Add subagent skills",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Subagent ID", "description": "Subagent ID",
@@ -4735,6 +5020,15 @@
"definitions": { "definitions": {
"bots.Bot": { "bots.Bot": {
"type": "object", "type": "object",
"required": [
"created_at",
"display_name",
"id",
"is_active",
"owner_user_id",
"type",
"updated_at"
],
"properties": { "properties": {
"avatar_url": { "avatar_url": {
"type": "string" "type": "string"
@@ -4806,6 +5100,9 @@
}, },
"bots.ListBotsResponse": { "bots.ListBotsResponse": {
"type": "object", "type": "object",
"required": [
"items"
],
"properties": { "properties": {
"items": { "items": {
"type": "array", "type": "array",
@@ -5450,6 +5747,16 @@
}, },
"github_com_memohai_memoh_internal_mcp.Connection": { "github_com_memohai_memoh_internal_mcp.Connection": {
"type": "object", "type": "object",
"required": [
"active",
"bot_id",
"config",
"created_at",
"id",
"name",
"type",
"updated_at"
],
"properties": { "properties": {
"active": { "active": {
"type": "boolean" "type": "boolean"
@@ -5480,6 +5787,12 @@
}, },
"handlers.ChannelMeta": { "handlers.ChannelMeta": {
"type": "object", "type": "object",
"required": [
"capabilities",
"config_schema",
"display_name",
"type"
],
"properties": { "properties": {
"capabilities": { "capabilities": {
"$ref": "#/definitions/channel.ChannelCapabilities" "$ref": "#/definitions/channel.ChannelCapabilities"
@@ -5830,6 +6143,10 @@
}, },
"handlers.LoginRequest": { "handlers.LoginRequest": {
"type": "object", "type": "object",
"required": [
"password",
"username"
],
"properties": { "properties": {
"password": { "password": {
"type": "string" "type": "string"
@@ -5841,6 +6158,15 @@
}, },
"handlers.LoginResponse": { "handlers.LoginResponse": {
"type": "object", "type": "object",
"required": [
"access_token",
"display_name",
"expires_at",
"role",
"token_type",
"user_id",
"username"
],
"properties": { "properties": {
"access_token": { "access_token": {
"type": "string" "type": "string"
@@ -6309,6 +6635,12 @@
}, },
"models.AddRequest": { "models.AddRequest": {
"type": "object", "type": "object",
"required": [
"llm_provider_id",
"model_id",
"name",
"type"
],
"properties": { "properties": {
"dimensions": { "dimensions": {
"type": "integer" "type": "integer"
@@ -6357,6 +6689,12 @@
}, },
"models.GetResponse": { "models.GetResponse": {
"type": "object", "type": "object",
"required": [
"llm_provider_id",
"model_id",
"name",
"type"
],
"properties": { "properties": {
"dimensions": { "dimensions": {
"type": "integer" "type": "integer"
@@ -6397,6 +6735,12 @@
}, },
"models.UpdateRequest": { "models.UpdateRequest": {
"type": "object", "type": "object",
"required": [
"llm_provider_id",
"model_id",
"name",
"type"
],
"properties": { "properties": {
"dimensions": { "dimensions": {
"type": "integer" "type": "integer"
@@ -6477,6 +6821,14 @@
}, },
"providers.GetResponse": { "providers.GetResponse": {
"type": "object", "type": "object",
"required": [
"base_url",
"client_type",
"created_at",
"id",
"name",
"updated_at"
],
"properties": { "properties": {
"api_key": { "api_key": {
"description": "masked in response", "description": "masked in response",
@@ -6635,6 +6987,14 @@
}, },
"settings.Settings": { "settings.Settings": {
"type": "object", "type": "object",
"required": [
"allow_guest",
"chat_model_id",
"embedding_model_id",
"language",
"max_context_load_time",
"memory_model_id"
],
"properties": { "properties": {
"allow_guest": { "allow_guest": {
"type": "boolean" "type": "boolean"
+265
View File
@@ -20,6 +20,14 @@ definitions:
type: string type: string
updated_at: updated_at:
type: string type: string
required:
- created_at
- display_name
- id
- is_active
- owner_user_id
- type
- updated_at
type: object type: object
bots.BotMember: bots.BotMember:
properties: properties:
@@ -52,6 +60,8 @@ definitions:
items: items:
$ref: '#/definitions/bots.Bot' $ref: '#/definitions/bots.Bot'
type: array type: array
required:
- items
type: object type: object
bots.ListMembersResponse: bots.ListMembersResponse:
properties: properties:
@@ -502,6 +512,15 @@ definitions:
type: string type: string
updated_at: updated_at:
type: string type: string
required:
- active
- bot_id
- config
- created_at
- id
- name
- type
- updated_at
type: object type: object
handlers.ChannelMeta: handlers.ChannelMeta:
properties: properties:
@@ -519,6 +538,11 @@ definitions:
type: string type: string
user_config_schema: user_config_schema:
$ref: '#/definitions/channel.ConfigSchema' $ref: '#/definitions/channel.ConfigSchema'
required:
- capabilities
- config_schema
- display_name
- type
type: object type: object
handlers.CreateContainerRequest: handlers.CreateContainerRequest:
properties: properties:
@@ -735,6 +759,9 @@ definitions:
type: string type: string
username: username:
type: string type: string
required:
- password
- username
type: object type: object
handlers.LoginResponse: handlers.LoginResponse:
properties: properties:
@@ -752,6 +779,14 @@ definitions:
type: string type: string
username: username:
type: string type: string
required:
- access_token
- display_name
- expires_at
- role
- token_type
- user_id
- username
type: object type: object
handlers.MCPStdioRequest: handlers.MCPStdioRequest:
properties: properties:
@@ -1062,6 +1097,11 @@ definitions:
type: string type: string
type: type:
$ref: '#/definitions/models.ModelType' $ref: '#/definitions/models.ModelType'
required:
- llm_provider_id
- model_id
- name
- type
type: object type: object
models.AddResponse: models.AddResponse:
properties: properties:
@@ -1093,6 +1133,11 @@ definitions:
type: string type: string
type: type:
$ref: '#/definitions/models.ModelType' $ref: '#/definitions/models.ModelType'
required:
- llm_provider_id
- model_id
- name
- type
type: object type: object
models.ModelType: models.ModelType:
enum: enum:
@@ -1120,6 +1165,11 @@ definitions:
type: string type: string
type: type:
$ref: '#/definitions/models.ModelType' $ref: '#/definitions/models.ModelType'
required:
- llm_provider_id
- model_id
- name
- type
type: object type: object
providers.ClientType: providers.ClientType:
enum: enum:
@@ -1178,6 +1228,13 @@ definitions:
type: string type: string
updated_at: updated_at:
type: string type: string
required:
- base_url
- client_type
- created_at
- id
- name
- updated_at
type: object type: object
providers.UpdateRequest: providers.UpdateRequest:
properties: properties:
@@ -1276,6 +1333,13 @@ definitions:
type: integer type: integer
memory_model_id: memory_model_id:
type: string type: string
required:
- allow_guest
- chat_model_id
- embedding_model_id
- language
- max_context_load_time
- memory_model_id
type: object type: object
settings.UpsertRequest: settings.UpsertRequest:
properties: properties:
@@ -1572,6 +1636,11 @@ paths:
description: Send a chat message and get a response. The system will automatically description: Send a chat message and get a response. The system will automatically
select an appropriate chat model from the database. select an appropriate chat model from the database.
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Chat request - description: Chat request
in: body in: body
name: request name: request
@@ -1603,6 +1672,11 @@ paths:
description: Send a chat message and get a streaming response. The system will description: Send a chat message and get a streaming response. The system will
automatically select an appropriate chat model from the database. automatically select an appropriate chat model from the database.
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Chat request - description: Chat request
in: body in: body
name: request name: request
@@ -2227,6 +2301,12 @@ paths:
/bots/{bot_id}/history: /bots/{bot_id}/history:
delete: delete:
description: Delete all history records for current user description: Delete all history records for current user
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses: responses:
"204": "204":
description: No Content description: No Content
@@ -2244,6 +2324,11 @@ paths:
get: get:
description: List history records for current user description: List history records for current user
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Limit - description: Limit
in: query in: query
name: limit name: limit
@@ -2267,6 +2352,11 @@ paths:
post: post:
description: Create a history record for current user description: Create a history record for current user
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: History payload - description: History payload
in: body in: body
name: payload name: payload
@@ -2293,6 +2383,11 @@ paths:
delete: delete:
description: Delete a history record by ID (must belong to current user) description: Delete a history record by ID (must belong to current user)
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: History ID - description: History ID
in: path in: path
name: id name: id
@@ -2319,6 +2414,11 @@ paths:
get: get:
description: Get a history record by ID (must belong to current user) description: Get a history record by ID (must belong to current user)
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: History ID - description: History ID
in: path in: path
name: id name: id
@@ -2347,6 +2447,12 @@ paths:
/bots/{bot_id}/mcp: /bots/{bot_id}/mcp:
get: get:
description: List MCP connections for a bot description: List MCP connections for a bot
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses: responses:
"200": "200":
description: OK description: OK
@@ -2374,6 +2480,11 @@ paths:
post: post:
description: Create a MCP connection for a bot description: Create a MCP connection for a bot
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: MCP payload - description: MCP payload
in: body in: body
name: payload name: payload
@@ -2484,6 +2595,11 @@ paths:
delete: delete:
description: Delete a MCP connection by ID description: Delete a MCP connection by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: MCP ID - description: MCP ID
in: path in: path
name: id name: id
@@ -2514,6 +2630,11 @@ paths:
get: get:
description: Get a MCP connection by ID description: Get a MCP connection by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: MCP ID - description: MCP ID
in: path in: path
name: id name: id
@@ -2546,6 +2667,11 @@ paths:
put: put:
description: Update a MCP connection by ID description: Update a MCP connection by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: MCP ID - description: MCP ID
in: path in: path
name: id name: id
@@ -2586,6 +2712,11 @@ paths:
description: 'Add memory for a user via memory. Auth: Bearer JWT determines description: 'Add memory for a user via memory. Auth: Bearer JWT determines
user_id (sub or user_id).' user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Add request - description: Add request
in: body in: body
name: payload name: payload
@@ -2613,6 +2744,11 @@ paths:
description: 'Embed text or multimodal input and upsert into memory store. Auth: description: 'Embed text or multimodal input and upsert into memory store. Auth:
Bearer JWT determines user_id (sub or user_id).' Bearer JWT determines user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Embed upsert request - description: Embed upsert request
in: body in: body
name: payload name: payload
@@ -2640,6 +2776,11 @@ paths:
description: 'Delete all memories for a user via memory. Auth: Bearer JWT determines description: 'Delete all memories for a user via memory. Auth: Bearer JWT determines
user_id (sub or user_id).' user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Delete all request - description: Delete all request
in: body in: body
name: payload name: payload
@@ -2666,6 +2807,11 @@ paths:
description: 'List memories for a user via memory. Auth: Bearer JWT determines description: 'List memories for a user via memory. Auth: Bearer JWT determines
user_id (sub or user_id).' user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Run ID - description: Run ID
in: query in: query
name: run_id name: run_id
@@ -2695,6 +2841,11 @@ paths:
description: 'Delete a memory by ID via memory. Auth: Bearer JWT determines description: 'Delete a memory by ID via memory. Auth: Bearer JWT determines
user_id (sub or user_id).' user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Memory ID - description: Memory ID
in: path in: path
name: memoryId name: memoryId
@@ -2720,6 +2871,11 @@ paths:
description: 'Get a memory by ID via memory. Auth: Bearer JWT determines user_id description: 'Get a memory by ID via memory. Auth: Bearer JWT determines user_id
(sub or user_id).' (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Memory ID - description: Memory ID
in: path in: path
name: memoryId name: memoryId
@@ -2746,6 +2902,11 @@ paths:
description: 'Search memories for a user via memory. Auth: Bearer JWT determines description: 'Search memories for a user via memory. Auth: Bearer JWT determines
user_id (sub or user_id).' user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Search request - description: Search request
in: body in: body
name: payload name: payload
@@ -2773,6 +2934,11 @@ paths:
description: 'Update a memory by ID via memory. Auth: Bearer JWT determines description: 'Update a memory by ID via memory. Auth: Bearer JWT determines
user_id (sub or user_id).' user_id (sub or user_id).'
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Update request - description: Update request
in: body in: body
name: payload name: payload
@@ -2798,6 +2964,12 @@ paths:
/bots/{bot_id}/schedule: /bots/{bot_id}/schedule:
get: get:
description: List schedules for current user description: List schedules for current user
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses: responses:
"200": "200":
description: OK description: OK
@@ -2817,6 +2989,11 @@ paths:
post: post:
description: Create a schedule for current user description: Create a schedule for current user
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Schedule payload - description: Schedule payload
in: body in: body
name: payload name: payload
@@ -2843,6 +3020,11 @@ paths:
delete: delete:
description: Delete a schedule by ID description: Delete a schedule by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Schedule ID - description: Schedule ID
in: path in: path
name: id name: id
@@ -2865,6 +3047,11 @@ paths:
get: get:
description: Get a schedule by ID description: Get a schedule by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Schedule ID - description: Schedule ID
in: path in: path
name: id name: id
@@ -2893,6 +3080,11 @@ paths:
put: put:
description: Update a schedule by ID description: Update a schedule by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Schedule ID - description: Schedule ID
in: path in: path
name: id name: id
@@ -2923,6 +3115,12 @@ paths:
/bots/{bot_id}/settings: /bots/{bot_id}/settings:
delete: delete:
description: Remove agent settings for current user description: Remove agent settings for current user
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses: responses:
"204": "204":
description: No Content description: No Content
@@ -2939,6 +3137,12 @@ paths:
- settings - settings
get: get:
description: Get agent settings for current user description: Get agent settings for current user
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses: responses:
"200": "200":
description: OK description: OK
@@ -2958,6 +3162,11 @@ paths:
post: post:
description: Update or create agent settings for current user description: Update or create agent settings for current user
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Settings payload - description: Settings payload
in: body in: body
name: payload name: payload
@@ -2983,6 +3192,11 @@ paths:
put: put:
description: Update or create agent settings for current user description: Update or create agent settings for current user
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Settings payload - description: Settings payload
in: body in: body
name: payload name: payload
@@ -3008,6 +3222,12 @@ paths:
/bots/{bot_id}/subagents: /bots/{bot_id}/subagents:
get: get:
description: List subagents for current user description: List subagents for current user
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses: responses:
"200": "200":
description: OK description: OK
@@ -3027,6 +3247,11 @@ paths:
post: post:
description: Create a subagent for current user description: Create a subagent for current user
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent payload - description: Subagent payload
in: body in: body
name: payload name: payload
@@ -3053,6 +3278,11 @@ paths:
delete: delete:
description: Delete a subagent by ID description: Delete a subagent by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3079,6 +3309,11 @@ paths:
get: get:
description: Get a subagent by ID description: Get a subagent by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3107,6 +3342,11 @@ paths:
put: put:
description: Update a subagent by ID description: Update a subagent by ID
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3142,6 +3382,11 @@ paths:
get: get:
description: Get a subagent's message context description: Get a subagent's message context
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3170,6 +3415,11 @@ paths:
put: put:
description: Update a subagent's message context description: Update a subagent's message context
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3205,6 +3455,11 @@ paths:
get: get:
description: Get a subagent's skills description: Get a subagent's skills
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3233,6 +3488,11 @@ paths:
post: post:
description: Add skills to a subagent description: Add skills to a subagent
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
@@ -3267,6 +3527,11 @@ paths:
put: put:
description: Replace a subagent's skills description: Replace a subagent's skills
parameters: parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Subagent ID - description: Subagent ID
in: path in: path
name: id name: id
+8 -8
View File
@@ -6,15 +6,15 @@ import (
) )
type Bot struct { type Bot struct {
ID string `json:"id"` ID string `json:"id" validate:"required"`
OwnerUserID string `json:"owner_user_id"` OwnerUserID string `json:"owner_user_id" validate:"required"`
Type string `json:"type"` Type string `json:"type" validate:"required"`
DisplayName string `json:"display_name"` DisplayName string `json:"display_name" validate:"required"`
AvatarURL string `json:"avatar_url,omitempty"` AvatarURL string `json:"avatar_url,omitempty"`
IsActive bool `json:"is_active"` IsActive bool `json:"is_active" validate:"required"`
Metadata map[string]any `json:"metadata,omitempty"` Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at" validate:"required"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at" validate:"required"`
} }
type BotMember struct { type BotMember struct {
@@ -49,7 +49,7 @@ type UpsertMemberRequest struct {
} }
type ListBotsResponse struct { type ListBotsResponse struct {
Items []Bot `json:"items"` Items []Bot `json:"items" validate:"required"`
} }
type ListMembersResponse struct { type ListMembersResponse struct {
+9 -9
View File
@@ -21,18 +21,18 @@ type AuthHandler struct {
} }
type LoginRequest struct { type LoginRequest struct {
Username string `json:"username"` Username string `json:"username" validate:"required"`
Password string `json:"password"` Password string `json:"password" validate:"required"`
} }
type LoginResponse struct { type LoginResponse struct {
AccessToken string `json:"access_token"` AccessToken string `json:"access_token" validate:"required"`
TokenType string `json:"token_type"` TokenType string `json:"token_type" validate:"required"`
ExpiresAt string `json:"expires_at"` ExpiresAt string `json:"expires_at" validate:"required"`
UserID string `json:"user_id"` UserID string `json:"user_id" validate:"required"`
Role string `json:"role"` Role string `json:"role" validate:"required"`
DisplayName string `json:"display_name"` DisplayName string `json:"display_name" validate:"required"`
Username string `json:"username"` Username string `json:"username" validate:"required"`
} }
func NewAuthHandler(log *slog.Logger, userService *users.Service, jwtSecret string, expiresIn time.Duration) *AuthHandler { func NewAuthHandler(log *slog.Logger, userService *users.Service, jwtSecret string, expiresIn time.Duration) *AuthHandler {
+4 -4
View File
@@ -94,11 +94,11 @@ func (h *ChannelHandler) UpsertUserConfig(c echo.Context) error {
} }
type ChannelMeta struct { type ChannelMeta struct {
Type string `json:"type"` Type string `json:"type" validate:"required"`
DisplayName string `json:"display_name"` DisplayName string `json:"display_name" validate:"required"`
Configless bool `json:"configless"` Configless bool `json:"configless"`
Capabilities channel.ChannelCapabilities `json:"capabilities"` Capabilities channel.ChannelCapabilities `json:"capabilities" validate:"required"`
ConfigSchema channel.ConfigSchema `json:"config_schema"` ConfigSchema channel.ConfigSchema `json:"config_schema" validate:"required"`
UserConfigSchema channel.ConfigSchema `json:"user_config_schema"` UserConfigSchema channel.ConfigSchema `json:"user_config_schema"`
TargetSpec channel.TargetSpec `json:"target_spec"` TargetSpec channel.TargetSpec `json:"target_spec"`
} }
+2
View File
@@ -47,6 +47,7 @@ func (h *ChatHandler) Register(e *echo.Echo) {
// @Tags chat // @Tags chat
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param bot_id path string true "Bot ID"
// @Param request body chat.ChatRequest true "Chat request" // @Param request body chat.ChatRequest true "Chat request"
// @Success 200 {object} chat.ChatResponse // @Success 200 {object} chat.ChatResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -102,6 +103,7 @@ func (h *ChatHandler) Chat(c echo.Context) error {
// @Tags chat // @Tags chat
// @Accept json // @Accept json
// @Produce text/event-stream // @Produce text/event-stream
// @Param bot_id path string true "Bot ID"
// @Param request body chat.ChatRequest true "Chat request" // @Param request body chat.ChatRequest true "Chat request"
// @Success 200 {string} string // @Success 200 {string} string
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
+5
View File
@@ -46,6 +46,7 @@ func (h *HistoryHandler) Register(e *echo.Echo) {
// @Summary Create history record // @Summary Create history record
// @Description Create a history record for current user // @Description Create a history record for current user
// @Tags history // @Tags history
// @Param bot_id path string true "Bot ID"
// @Param payload body history.CreateRequest true "History payload" // @Param payload body history.CreateRequest true "History payload"
// @Success 201 {object} history.Record // @Success 201 {object} history.Record
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -82,6 +83,7 @@ func (h *HistoryHandler) Create(c echo.Context) error {
// @Summary Get history record // @Summary Get history record
// @Description Get a history record by ID (must belong to current user) // @Description Get a history record by ID (must belong to current user)
// @Tags history // @Tags history
// @Param bot_id path string true "Bot ID"
// @Param id path string true "History ID" // @Param id path string true "History ID"
// @Success 200 {object} history.Record // @Success 200 {object} history.Record
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -118,6 +120,7 @@ func (h *HistoryHandler) Get(c echo.Context) error {
// @Summary List history records // @Summary List history records
// @Description List history records for current user // @Description List history records for current user
// @Tags history // @Tags history
// @Param bot_id path string true "Bot ID"
// @Param limit query int false "Limit" // @Param limit query int false "Limit"
// @Success 200 {object} history.ListResponse // @Success 200 {object} history.ListResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -156,6 +159,7 @@ func (h *HistoryHandler) List(c echo.Context) error {
// @Summary Delete history record // @Summary Delete history record
// @Description Delete a history record by ID (must belong to current user) // @Description Delete a history record by ID (must belong to current user)
// @Tags history // @Tags history
// @Param bot_id path string true "Bot ID"
// @Param id path string true "History ID" // @Param id path string true "History ID"
// @Success 204 "No Content" // @Success 204 "No Content"
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -195,6 +199,7 @@ func (h *HistoryHandler) Delete(c echo.Context) error {
// @Summary Delete all history records // @Summary Delete all history records
// @Description Delete all history records for current user // @Description Delete all history records for current user
// @Tags history // @Tags history
// @Param bot_id path string true "Bot ID"
// @Success 204 "No Content" // @Success 204 "No Content"
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse // @Failure 500 {object} ErrorResponse
+5
View File
@@ -46,6 +46,7 @@ func (h *MCPHandler) Register(e *echo.Echo) {
// @Summary List MCP connections // @Summary List MCP connections
// @Description List MCP connections for a bot // @Description List MCP connections for a bot
// @Tags mcp // @Tags mcp
// @Param bot_id path string true "Bot ID"
// @Success 200 {object} mcp.ListResponse // @Success 200 {object} mcp.ListResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse // @Failure 403 {object} ErrorResponse
@@ -75,6 +76,7 @@ func (h *MCPHandler) List(c echo.Context) error {
// @Summary Create MCP connection // @Summary Create MCP connection
// @Description Create a MCP connection for a bot // @Description Create a MCP connection for a bot
// @Tags mcp // @Tags mcp
// @Param bot_id path string true "Bot ID"
// @Param payload body mcp.UpsertRequest true "MCP payload" // @Param payload body mcp.UpsertRequest true "MCP payload"
// @Success 201 {object} mcp.Connection // @Success 201 {object} mcp.Connection
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -109,6 +111,7 @@ func (h *MCPHandler) Create(c echo.Context) error {
// @Summary Get MCP connection // @Summary Get MCP connection
// @Description Get a MCP connection by ID // @Description Get a MCP connection by ID
// @Tags mcp // @Tags mcp
// @Param bot_id path string true "Bot ID"
// @Param id path string true "MCP ID" // @Param id path string true "MCP ID"
// @Success 200 {object} mcp.Connection // @Success 200 {object} mcp.Connection
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -146,6 +149,7 @@ func (h *MCPHandler) Get(c echo.Context) error {
// @Summary Update MCP connection // @Summary Update MCP connection
// @Description Update a MCP connection by ID // @Description Update a MCP connection by ID
// @Tags mcp // @Tags mcp
// @Param bot_id path string true "Bot ID"
// @Param id path string true "MCP ID" // @Param id path string true "MCP ID"
// @Param payload body mcp.UpsertRequest true "MCP payload" // @Param payload body mcp.UpsertRequest true "MCP payload"
// @Success 200 {object} mcp.Connection // @Success 200 {object} mcp.Connection
@@ -188,6 +192,7 @@ func (h *MCPHandler) Update(c echo.Context) error {
// @Summary Delete MCP connection // @Summary Delete MCP connection
// @Description Delete a MCP connection by ID // @Description Delete a MCP connection by ID
// @Tags mcp // @Tags mcp
// @Param bot_id path string true "Bot ID"
// @Param id path string true "MCP ID" // @Param id path string true "MCP ID"
// @Success 204 "No Content" // @Success 204 "No Content"
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
+8
View File
@@ -90,6 +90,7 @@ func (h *MemoryHandler) checkService() error {
// @Summary Embed and upsert memory // @Summary Embed and upsert memory
// @Description Embed text or multimodal input and upsert into memory store. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Embed text or multimodal input and upsert into memory store. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param payload body memoryEmbedUpsertPayload true "Embed upsert request" // @Param payload body memoryEmbedUpsertPayload true "Embed upsert request"
// @Success 200 {object} memory.EmbedUpsertResponse // @Success 200 {object} memory.EmbedUpsertResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -144,6 +145,7 @@ func (h *MemoryHandler) EmbedUpsert(c echo.Context) error {
// @Summary Add memory // @Summary Add memory
// @Description Add memory for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Add memory for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param payload body memoryAddPayload true "Add request" // @Param payload body memoryAddPayload true "Add request"
// @Success 200 {object} memory.SearchResponse // @Success 200 {object} memory.SearchResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -197,6 +199,7 @@ func (h *MemoryHandler) Add(c echo.Context) error {
// @Summary Search memories // @Summary Search memories
// @Description Search memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Search memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param payload body memorySearchPayload true "Search request" // @Param payload body memorySearchPayload true "Search request"
// @Success 200 {object} memory.SearchResponse // @Success 200 {object} memory.SearchResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -249,6 +252,7 @@ func (h *MemoryHandler) Search(c echo.Context) error {
// @Summary Update memory // @Summary Update memory
// @Description Update a memory by ID via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Update a memory by ID via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param payload body memory.UpdateRequest true "Update request" // @Param payload body memory.UpdateRequest true "Update request"
// @Success 200 {object} memory.MemoryItem // @Success 200 {object} memory.MemoryItem
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -296,6 +300,7 @@ func (h *MemoryHandler) Update(c echo.Context) error {
// @Summary Get memory // @Summary Get memory
// @Description Get a memory by ID via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Get a memory by ID via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param memoryId path string true "Memory ID" // @Param memoryId path string true "Memory ID"
// @Success 200 {object} memory.MemoryItem // @Success 200 {object} memory.MemoryItem
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -337,6 +342,7 @@ func (h *MemoryHandler) Get(c echo.Context) error {
// @Summary List memories // @Summary List memories
// @Description List memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description List memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param run_id query string false "Run ID" // @Param run_id query string false "Run ID"
// @Param limit query int false "Limit" // @Param limit query int false "Limit"
// @Success 200 {object} memory.SearchResponse // @Success 200 {object} memory.SearchResponse
@@ -388,6 +394,7 @@ func (h *MemoryHandler) GetAll(c echo.Context) error {
// @Summary Delete memory // @Summary Delete memory
// @Description Delete a memory by ID via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Delete a memory by ID via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param memoryId path string true "Memory ID" // @Param memoryId path string true "Memory ID"
// @Success 200 {object} memory.DeleteResponse // @Success 200 {object} memory.DeleteResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -434,6 +441,7 @@ func (h *MemoryHandler) Delete(c echo.Context) error {
// @Summary Delete memories // @Summary Delete memories
// @Description Delete all memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id). // @Description Delete all memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id).
// @Tags memory // @Tags memory
// @Param bot_id path string true "Bot ID"
// @Param payload body memoryDeleteAllPayload true "Delete all request" // @Param payload body memoryDeleteAllPayload true "Delete all request"
// @Success 200 {object} memory.DeleteResponse // @Success 200 {object} memory.DeleteResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
+5
View File
@@ -45,6 +45,7 @@ func (h *ScheduleHandler) Register(e *echo.Echo) {
// @Summary Create schedule // @Summary Create schedule
// @Description Create a schedule for current user // @Description Create a schedule for current user
// @Tags schedule // @Tags schedule
// @Param bot_id path string true "Bot ID"
// @Param payload body schedule.CreateRequest true "Schedule payload" // @Param payload body schedule.CreateRequest true "Schedule payload"
// @Success 201 {object} schedule.Schedule // @Success 201 {object} schedule.Schedule
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -77,6 +78,7 @@ func (h *ScheduleHandler) Create(c echo.Context) error {
// @Summary List schedules // @Summary List schedules
// @Description List schedules for current user // @Description List schedules for current user
// @Tags schedule // @Tags schedule
// @Param bot_id path string true "Bot ID"
// @Success 200 {object} schedule.ListResponse // @Success 200 {object} schedule.ListResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse // @Failure 500 {object} ErrorResponse
@@ -104,6 +106,7 @@ func (h *ScheduleHandler) List(c echo.Context) error {
// @Summary Get schedule // @Summary Get schedule
// @Description Get a schedule by ID // @Description Get a schedule by ID
// @Tags schedule // @Tags schedule
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Schedule ID" // @Param id path string true "Schedule ID"
// @Success 200 {object} schedule.Schedule // @Success 200 {object} schedule.Schedule
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -140,6 +143,7 @@ func (h *ScheduleHandler) Get(c echo.Context) error {
// @Summary Update schedule // @Summary Update schedule
// @Description Update a schedule by ID // @Description Update a schedule by ID
// @Tags schedule // @Tags schedule
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Schedule ID" // @Param id path string true "Schedule ID"
// @Param payload body schedule.UpdateRequest true "Schedule payload" // @Param payload body schedule.UpdateRequest true "Schedule payload"
// @Success 200 {object} schedule.Schedule // @Success 200 {object} schedule.Schedule
@@ -184,6 +188,7 @@ func (h *ScheduleHandler) Update(c echo.Context) error {
// @Summary Delete schedule // @Summary Delete schedule
// @Description Delete a schedule by ID // @Description Delete a schedule by ID
// @Tags schedule // @Tags schedule
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Schedule ID" // @Param id path string true "Schedule ID"
// @Success 204 "No Content" // @Success 204 "No Content"
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
+3
View File
@@ -44,6 +44,7 @@ func (h *SettingsHandler) Register(e *echo.Echo) {
// @Summary Get user settings // @Summary Get user settings
// @Description Get agent settings for current user // @Description Get agent settings for current user
// @Tags settings // @Tags settings
// @Param bot_id path string true "Bot ID"
// @Success 200 {object} settings.Settings // @Success 200 {object} settings.Settings
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse // @Failure 500 {object} ErrorResponse
@@ -71,6 +72,7 @@ func (h *SettingsHandler) Get(c echo.Context) error {
// @Summary Update user settings // @Summary Update user settings
// @Description Update or create agent settings for current user // @Description Update or create agent settings for current user
// @Tags settings // @Tags settings
// @Param bot_id path string true "Bot ID"
// @Param payload body settings.UpsertRequest true "Settings payload" // @Param payload body settings.UpsertRequest true "Settings payload"
// @Success 200 {object} settings.Settings // @Success 200 {object} settings.Settings
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -104,6 +106,7 @@ func (h *SettingsHandler) Upsert(c echo.Context) error {
// @Summary Delete user settings // @Summary Delete user settings
// @Description Remove agent settings for current user // @Description Remove agent settings for current user
// @Tags settings // @Tags settings
// @Param bot_id path string true "Bot ID"
// @Success 204 "No Content" // @Success 204 "No Content"
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse // @Failure 500 {object} ErrorResponse
+10
View File
@@ -50,6 +50,7 @@ func (h *SubagentHandler) Register(e *echo.Echo) {
// @Summary Create subagent // @Summary Create subagent
// @Description Create a subagent for current user // @Description Create a subagent for current user
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param payload body subagent.CreateRequest true "Subagent payload" // @Param payload body subagent.CreateRequest true "Subagent payload"
// @Success 201 {object} subagent.Subagent // @Success 201 {object} subagent.Subagent
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -82,6 +83,7 @@ func (h *SubagentHandler) Create(c echo.Context) error {
// @Summary List subagents // @Summary List subagents
// @Description List subagents for current user // @Description List subagents for current user
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Success 200 {object} subagent.ListResponse // @Success 200 {object} subagent.ListResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse // @Failure 500 {object} ErrorResponse
@@ -109,6 +111,7 @@ func (h *SubagentHandler) List(c echo.Context) error {
// @Summary Get subagent // @Summary Get subagent
// @Description Get a subagent by ID // @Description Get a subagent by ID
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Success 200 {object} subagent.Subagent // @Success 200 {object} subagent.Subagent
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -145,6 +148,7 @@ func (h *SubagentHandler) Get(c echo.Context) error {
// @Summary Update subagent // @Summary Update subagent
// @Description Update a subagent by ID // @Description Update a subagent by ID
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Param payload body subagent.UpdateRequest true "Subagent payload" // @Param payload body subagent.UpdateRequest true "Subagent payload"
// @Success 200 {object} subagent.Subagent // @Success 200 {object} subagent.Subagent
@@ -190,6 +194,7 @@ func (h *SubagentHandler) Update(c echo.Context) error {
// @Summary Delete subagent // @Summary Delete subagent
// @Description Delete a subagent by ID // @Description Delete a subagent by ID
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Success 204 "No Content" // @Success 204 "No Content"
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -229,6 +234,7 @@ func (h *SubagentHandler) Delete(c echo.Context) error {
// @Summary Get subagent context // @Summary Get subagent context
// @Description Get a subagent's message context // @Description Get a subagent's message context
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Success 200 {object} subagent.ContextResponse // @Success 200 {object} subagent.ContextResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -265,6 +271,7 @@ func (h *SubagentHandler) GetContext(c echo.Context) error {
// @Summary Update subagent context // @Summary Update subagent context
// @Description Update a subagent's message context // @Description Update a subagent's message context
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Param payload body subagent.UpdateContextRequest true "Context payload" // @Param payload body subagent.UpdateContextRequest true "Context payload"
// @Success 200 {object} subagent.ContextResponse // @Success 200 {object} subagent.ContextResponse
@@ -310,6 +317,7 @@ func (h *SubagentHandler) UpdateContext(c echo.Context) error {
// @Summary Get subagent skills // @Summary Get subagent skills
// @Description Get a subagent's skills // @Description Get a subagent's skills
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Success 200 {object} subagent.SkillsResponse // @Success 200 {object} subagent.SkillsResponse
// @Failure 400 {object} ErrorResponse // @Failure 400 {object} ErrorResponse
@@ -346,6 +354,7 @@ func (h *SubagentHandler) GetSkills(c echo.Context) error {
// @Summary Update subagent skills // @Summary Update subagent skills
// @Description Replace a subagent's skills // @Description Replace a subagent's skills
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Param payload body subagent.UpdateSkillsRequest true "Skills payload" // @Param payload body subagent.UpdateSkillsRequest true "Skills payload"
// @Success 200 {object} subagent.SkillsResponse // @Success 200 {object} subagent.SkillsResponse
@@ -391,6 +400,7 @@ func (h *SubagentHandler) UpdateSkills(c echo.Context) error {
// @Summary Add subagent skills // @Summary Add subagent skills
// @Description Add skills to a subagent // @Description Add skills to a subagent
// @Tags subagent // @Tags subagent
// @Param bot_id path string true "Bot ID"
// @Param id path string true "Subagent ID" // @Param id path string true "Subagent ID"
// @Param payload body subagent.AddSkillsRequest true "Skills payload" // @Param payload body subagent.AddSkillsRequest true "Skills payload"
// @Success 200 {object} subagent.SkillsResponse // @Success 200 {object} subagent.SkillsResponse
+8 -8
View File
@@ -14,14 +14,14 @@ import (
// Connection represents a stored MCP connection for a bot. // Connection represents a stored MCP connection for a bot.
type Connection struct { type Connection struct {
ID string `json:"id"` ID string `json:"id" validate:"required"`
BotID string `json:"bot_id"` BotID string `json:"bot_id" validate:"required"`
Name string `json:"name"` Name string `json:"name" validate:"required"`
Type string `json:"type"` Type string `json:"type" validate:"required"`
Config map[string]any `json:"config"` Config map[string]any `json:"config" validate:"required"`
Active bool `json:"active"` Active bool `json:"active" validate:"required"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at" validate:"required"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at" validate:"required"`
} }
// UpsertRequest is the payload for creating or updating MCP connections. // UpsertRequest is the payload for creating or updating MCP connections.
+4 -4
View File
@@ -32,12 +32,12 @@ const (
) )
type Model struct { type Model struct {
ModelID string `json:"model_id"` ModelID string `json:"model_id" validate:"required"`
Name string `json:"name"` Name string `json:"name" validate:"required"`
LlmProviderID string `json:"llm_provider_id"` LlmProviderID string `json:"llm_provider_id" validate:"required"`
IsMultimodal bool `json:"is_multimodal"` IsMultimodal bool `json:"is_multimodal"`
Input []string `json:"input"` Input []string `json:"input"`
Type ModelType `json:"type"` Type ModelType `json:"type" validate:"required"`
Dimensions int `json:"dimensions"` Dimensions int `json:"dimensions"`
} }
+6 -6
View File
@@ -33,14 +33,14 @@ type UpdateRequest struct {
// GetResponse represents the response for getting a provider // GetResponse represents the response for getting a provider
type GetResponse struct { type GetResponse struct {
ID string `json:"id"` ID string `json:"id" validate:"required"`
Name string `json:"name"` Name string `json:"name" validate:"required"`
ClientType string `json:"client_type"` ClientType string `json:"client_type" validate:"required"`
BaseURL string `json:"base_url"` BaseURL string `json:"base_url" validate:"required"`
APIKey string `json:"api_key,omitempty"` // masked in response APIKey string `json:"api_key,omitempty"` // masked in response
Metadata map[string]any `json:"metadata,omitempty"` Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at" validate:"required"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at" validate:"required"`
} }
// ListResponse represents the response for listing providers // ListResponse represents the response for listing providers
+6 -6
View File
@@ -6,12 +6,12 @@ const (
) )
type Settings struct { type Settings struct {
ChatModelID string `json:"chat_model_id"` ChatModelID string `json:"chat_model_id" validate:"required"`
MemoryModelID string `json:"memory_model_id"` MemoryModelID string `json:"memory_model_id" validate:"required"`
EmbeddingModelID string `json:"embedding_model_id"` EmbeddingModelID string `json:"embedding_model_id" validate:"required"`
MaxContextLoadTime int `json:"max_context_load_time"` MaxContextLoadTime int `json:"max_context_load_time" validate:"required"`
Language string `json:"language"` Language string `json:"language" validate:"required"`
AllowGuest bool `json:"allow_guest"` AllowGuest bool `json:"allow_guest" validate:"required"`
} }
type UpsertRequest struct { type UpsertRequest struct {
+12 -2
View File
@@ -3,11 +3,21 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts",
"./client": "./src/client.gen.ts",
"./colada": "./src/@pinia/colada.gen.ts"
}, },
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
}, },
"packageManager": "pnpm@10.27.0" "packageManager": "pnpm@10.27.0",
"peerDependencies": {
"@pinia/colada": ">=0.21.0"
},
"peerDependenciesMeta": {
"@pinia/colada": {
"optional": true
}
}
} }
+12 -12
View File
@@ -444,14 +444,14 @@ export const deleteBotsByBotIdHistoryMutation = (options?: Partial<Options<Delet
} }
}); });
export const getBotsByBotIdHistoryQueryKey = (options?: Options<GetBotsByBotIdHistoryData>) => createQueryKey('getBotsByBotIdHistory', options); export const getBotsByBotIdHistoryQueryKey = (options: Options<GetBotsByBotIdHistoryData>) => createQueryKey('getBotsByBotIdHistory', options);
/** /**
* List history records * List history records
* *
* List history records for current user * List history records for current user
*/ */
export const getBotsByBotIdHistoryQuery = defineQueryOptions((options?: Options<GetBotsByBotIdHistoryData>) => ({ export const getBotsByBotIdHistoryQuery = defineQueryOptions((options: Options<GetBotsByBotIdHistoryData>) => ({
key: getBotsByBotIdHistoryQueryKey(options), key: getBotsByBotIdHistoryQueryKey(options),
query: async (context) => { query: async (context) => {
const { data } = await getBotsByBotIdHistory({ const { data } = await getBotsByBotIdHistory({
@@ -514,14 +514,14 @@ export const getBotsByBotIdHistoryByIdQuery = defineQueryOptions((options: Optio
} }
})); }));
export const getBotsByBotIdMcpQueryKey = (options?: Options<GetBotsByBotIdMcpData>) => createQueryKey('getBotsByBotIdMcp', options); export const getBotsByBotIdMcpQueryKey = (options: Options<GetBotsByBotIdMcpData>) => createQueryKey('getBotsByBotIdMcp', options);
/** /**
* List MCP connections * List MCP connections
* *
* List MCP connections for a bot * List MCP connections for a bot
*/ */
export const getBotsByBotIdMcpQuery = defineQueryOptions((options?: Options<GetBotsByBotIdMcpData>) => ({ export const getBotsByBotIdMcpQuery = defineQueryOptions((options: Options<GetBotsByBotIdMcpData>) => ({
key: getBotsByBotIdMcpQueryKey(options), key: getBotsByBotIdMcpQueryKey(options),
query: async (context) => { query: async (context) => {
const { data } = await getBotsByBotIdMcp({ const { data } = await getBotsByBotIdMcp({
@@ -680,14 +680,14 @@ export const deleteBotsByBotIdMemoryMemoriesMutation = (options?: Partial<Option
} }
}); });
export const getBotsByBotIdMemoryMemoriesQueryKey = (options?: Options<GetBotsByBotIdMemoryMemoriesData>) => createQueryKey('getBotsByBotIdMemoryMemories', options); export const getBotsByBotIdMemoryMemoriesQueryKey = (options: Options<GetBotsByBotIdMemoryMemoriesData>) => createQueryKey('getBotsByBotIdMemoryMemories', options);
/** /**
* List memories * List memories
* *
* List memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id). * List memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id).
*/ */
export const getBotsByBotIdMemoryMemoriesQuery = defineQueryOptions((options?: Options<GetBotsByBotIdMemoryMemoriesData>) => ({ export const getBotsByBotIdMemoryMemoriesQuery = defineQueryOptions((options: Options<GetBotsByBotIdMemoryMemoriesData>) => ({
key: getBotsByBotIdMemoryMemoriesQueryKey(options), key: getBotsByBotIdMemoryMemoriesQueryKey(options),
query: async (context) => { query: async (context) => {
const { data } = await getBotsByBotIdMemoryMemories({ const { data } = await getBotsByBotIdMemoryMemories({
@@ -766,14 +766,14 @@ export const postBotsByBotIdMemoryUpdateMutation = (options?: Partial<Options<Po
} }
}); });
export const getBotsByBotIdScheduleQueryKey = (options?: Options<GetBotsByBotIdScheduleData>) => createQueryKey('getBotsByBotIdSchedule', options); export const getBotsByBotIdScheduleQueryKey = (options: Options<GetBotsByBotIdScheduleData>) => createQueryKey('getBotsByBotIdSchedule', options);
/** /**
* List schedules * List schedules
* *
* List schedules for current user * List schedules for current user
*/ */
export const getBotsByBotIdScheduleQuery = defineQueryOptions((options?: Options<GetBotsByBotIdScheduleData>) => ({ export const getBotsByBotIdScheduleQuery = defineQueryOptions((options: Options<GetBotsByBotIdScheduleData>) => ({
key: getBotsByBotIdScheduleQueryKey(options), key: getBotsByBotIdScheduleQueryKey(options),
query: async (context) => { query: async (context) => {
const { data } = await getBotsByBotIdSchedule({ const { data } = await getBotsByBotIdSchedule({
@@ -868,14 +868,14 @@ export const deleteBotsByBotIdSettingsMutation = (options?: Partial<Options<Dele
} }
}); });
export const getBotsByBotIdSettingsQueryKey = (options?: Options<GetBotsByBotIdSettingsData>) => createQueryKey('getBotsByBotIdSettings', options); export const getBotsByBotIdSettingsQueryKey = (options: Options<GetBotsByBotIdSettingsData>) => createQueryKey('getBotsByBotIdSettings', options);
/** /**
* Get user settings * Get user settings
* *
* Get agent settings for current user * Get agent settings for current user
*/ */
export const getBotsByBotIdSettingsQuery = defineQueryOptions((options?: Options<GetBotsByBotIdSettingsData>) => ({ export const getBotsByBotIdSettingsQuery = defineQueryOptions((options: Options<GetBotsByBotIdSettingsData>) => ({
key: getBotsByBotIdSettingsQueryKey(options), key: getBotsByBotIdSettingsQueryKey(options),
query: async (context) => { query: async (context) => {
const { data } = await getBotsByBotIdSettings({ const { data } = await getBotsByBotIdSettings({
@@ -919,14 +919,14 @@ export const putBotsByBotIdSettingsMutation = (options?: Partial<Options<PutBots
} }
}); });
export const getBotsByBotIdSubagentsQueryKey = (options?: Options<GetBotsByBotIdSubagentsData>) => createQueryKey('getBotsByBotIdSubagents', options); export const getBotsByBotIdSubagentsQueryKey = (options: Options<GetBotsByBotIdSubagentsData>) => createQueryKey('getBotsByBotIdSubagents', options);
/** /**
* List subagents * List subagents
* *
* List subagents for current user * List subagents for current user
*/ */
export const getBotsByBotIdSubagentsQuery = defineQueryOptions((options?: Options<GetBotsByBotIdSubagentsData>) => ({ export const getBotsByBotIdSubagentsQuery = defineQueryOptions((options: Options<GetBotsByBotIdSubagentsData>) => ({
key: getBotsByBotIdSubagentsQueryKey(options), key: getBotsByBotIdSubagentsQueryKey(options),
query: async (context) => { query: async (context) => {
const { data } = await getBotsByBotIdSubagents({ const { data } = await getBotsByBotIdSubagents({
+8 -8
View File
@@ -246,14 +246,14 @@ export const postBotsByBotIdContainerStop = <ThrowOnError extends boolean = fals
* *
* Delete all history records for current user * Delete all history records for current user
*/ */
export const deleteBotsByBotIdHistory = <ThrowOnError extends boolean = false>(options?: Options<DeleteBotsByBotIdHistoryData, ThrowOnError>) => (options?.client ?? client).delete<DeleteBotsByBotIdHistoryResponses, DeleteBotsByBotIdHistoryErrors, ThrowOnError>({ url: '/bots/{bot_id}/history', ...options }); export const deleteBotsByBotIdHistory = <ThrowOnError extends boolean = false>(options: Options<DeleteBotsByBotIdHistoryData, ThrowOnError>) => (options.client ?? client).delete<DeleteBotsByBotIdHistoryResponses, DeleteBotsByBotIdHistoryErrors, ThrowOnError>({ url: '/bots/{bot_id}/history', ...options });
/** /**
* List history records * List history records
* *
* List history records for current user * List history records for current user
*/ */
export const getBotsByBotIdHistory = <ThrowOnError extends boolean = false>(options?: Options<GetBotsByBotIdHistoryData, ThrowOnError>) => (options?.client ?? client).get<GetBotsByBotIdHistoryResponses, GetBotsByBotIdHistoryErrors, ThrowOnError>({ url: '/bots/{bot_id}/history', ...options }); export const getBotsByBotIdHistory = <ThrowOnError extends boolean = false>(options: Options<GetBotsByBotIdHistoryData, ThrowOnError>) => (options.client ?? client).get<GetBotsByBotIdHistoryResponses, GetBotsByBotIdHistoryErrors, ThrowOnError>({ url: '/bots/{bot_id}/history', ...options });
/** /**
* Create history record * Create history record
@@ -288,7 +288,7 @@ export const getBotsByBotIdHistoryById = <ThrowOnError extends boolean = false>(
* *
* List MCP connections for a bot * List MCP connections for a bot
*/ */
export const getBotsByBotIdMcp = <ThrowOnError extends boolean = false>(options?: Options<GetBotsByBotIdMcpData, ThrowOnError>) => (options?.client ?? client).get<GetBotsByBotIdMcpResponses, GetBotsByBotIdMcpErrors, ThrowOnError>({ url: '/bots/{bot_id}/mcp', ...options }); export const getBotsByBotIdMcp = <ThrowOnError extends boolean = false>(options: Options<GetBotsByBotIdMcpData, ThrowOnError>) => (options.client ?? client).get<GetBotsByBotIdMcpResponses, GetBotsByBotIdMcpErrors, ThrowOnError>({ url: '/bots/{bot_id}/mcp', ...options });
/** /**
* Create MCP connection * Create MCP connection
@@ -407,7 +407,7 @@ export const deleteBotsByBotIdMemoryMemories = <ThrowOnError extends boolean = f
* *
* List memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id). * List memories for a user via memory. Auth: Bearer JWT determines user_id (sub or user_id).
*/ */
export const getBotsByBotIdMemoryMemories = <ThrowOnError extends boolean = false>(options?: Options<GetBotsByBotIdMemoryMemoriesData, ThrowOnError>) => (options?.client ?? client).get<GetBotsByBotIdMemoryMemoriesResponses, GetBotsByBotIdMemoryMemoriesErrors, ThrowOnError>({ url: '/bots/{bot_id}/memory/memories', ...options }); export const getBotsByBotIdMemoryMemories = <ThrowOnError extends boolean = false>(options: Options<GetBotsByBotIdMemoryMemoriesData, ThrowOnError>) => (options.client ?? client).get<GetBotsByBotIdMemoryMemoriesResponses, GetBotsByBotIdMemoryMemoriesErrors, ThrowOnError>({ url: '/bots/{bot_id}/memory/memories', ...options });
/** /**
* Delete memory * Delete memory
@@ -456,7 +456,7 @@ export const postBotsByBotIdMemoryUpdate = <ThrowOnError extends boolean = false
* *
* List schedules for current user * List schedules for current user
*/ */
export const getBotsByBotIdSchedule = <ThrowOnError extends boolean = false>(options?: Options<GetBotsByBotIdScheduleData, ThrowOnError>) => (options?.client ?? client).get<GetBotsByBotIdScheduleResponses, GetBotsByBotIdScheduleErrors, ThrowOnError>({ url: '/bots/{bot_id}/schedule', ...options }); export const getBotsByBotIdSchedule = <ThrowOnError extends boolean = false>(options: Options<GetBotsByBotIdScheduleData, ThrowOnError>) => (options.client ?? client).get<GetBotsByBotIdScheduleResponses, GetBotsByBotIdScheduleErrors, ThrowOnError>({ url: '/bots/{bot_id}/schedule', ...options });
/** /**
* Create schedule * Create schedule
@@ -505,14 +505,14 @@ export const putBotsByBotIdScheduleById = <ThrowOnError extends boolean = false>
* *
* Remove agent settings for current user * Remove agent settings for current user
*/ */
export const deleteBotsByBotIdSettings = <ThrowOnError extends boolean = false>(options?: Options<DeleteBotsByBotIdSettingsData, ThrowOnError>) => (options?.client ?? client).delete<DeleteBotsByBotIdSettingsResponses, DeleteBotsByBotIdSettingsErrors, ThrowOnError>({ url: '/bots/{bot_id}/settings', ...options }); export const deleteBotsByBotIdSettings = <ThrowOnError extends boolean = false>(options: Options<DeleteBotsByBotIdSettingsData, ThrowOnError>) => (options.client ?? client).delete<DeleteBotsByBotIdSettingsResponses, DeleteBotsByBotIdSettingsErrors, ThrowOnError>({ url: '/bots/{bot_id}/settings', ...options });
/** /**
* Get user settings * Get user settings
* *
* Get agent settings for current user * Get agent settings for current user
*/ */
export const getBotsByBotIdSettings = <ThrowOnError extends boolean = false>(options?: Options<GetBotsByBotIdSettingsData, ThrowOnError>) => (options?.client ?? client).get<GetBotsByBotIdSettingsResponses, GetBotsByBotIdSettingsErrors, ThrowOnError>({ url: '/bots/{bot_id}/settings', ...options }); export const getBotsByBotIdSettings = <ThrowOnError extends boolean = false>(options: Options<GetBotsByBotIdSettingsData, ThrowOnError>) => (options.client ?? client).get<GetBotsByBotIdSettingsResponses, GetBotsByBotIdSettingsErrors, ThrowOnError>({ url: '/bots/{bot_id}/settings', ...options });
/** /**
* Update user settings * Update user settings
@@ -547,7 +547,7 @@ export const putBotsByBotIdSettings = <ThrowOnError extends boolean = false>(opt
* *
* List subagents for current user * List subagents for current user
*/ */
export const getBotsByBotIdSubagents = <ThrowOnError extends boolean = false>(options?: Options<GetBotsByBotIdSubagentsData, ThrowOnError>) => (options?.client ?? client).get<GetBotsByBotIdSubagentsResponses, GetBotsByBotIdSubagentsErrors, ThrowOnError>({ url: '/bots/{bot_id}/subagents', ...options }); export const getBotsByBotIdSubagents = <ThrowOnError extends boolean = false>(options: Options<GetBotsByBotIdSubagentsData, ThrowOnError>) => (options.client ?? client).get<GetBotsByBotIdSubagentsResponses, GetBotsByBotIdSubagentsErrors, ThrowOnError>({ url: '/bots/{bot_id}/subagents', ...options });
/** /**
* Create subagent * Create subagent
+251 -74
View File
@@ -6,16 +6,16 @@ export type ClientOptions = {
export type BotsBot = { export type BotsBot = {
avatar_url?: string; avatar_url?: string;
created_at?: string; created_at: string;
display_name?: string; display_name: string;
id?: string; id: string;
is_active?: boolean; is_active: boolean;
metadata?: { metadata?: {
[key: string]: unknown; [key: string]: unknown;
}; };
owner_user_id?: string; owner_user_id: string;
type?: string; type: string;
updated_at?: string; updated_at: string;
}; };
export type BotsBotMember = { export type BotsBotMember = {
@@ -36,7 +36,7 @@ export type BotsCreateBotRequest = {
}; };
export type BotsListBotsResponse = { export type BotsListBotsResponse = {
items?: Array<BotsBot>; items: Array<BotsBot>;
}; };
export type BotsListMembersResponse = { export type BotsListMembersResponse = {
@@ -273,25 +273,25 @@ export type ChatToolCallFunction = {
}; };
export type GithubComMemohaiMemohInternalMcpConnection = { export type GithubComMemohaiMemohInternalMcpConnection = {
active?: boolean; active: boolean;
bot_id?: string; bot_id: string;
config?: { config: {
[key: string]: unknown; [key: string]: unknown;
}; };
created_at?: string; created_at: string;
id?: string; id: string;
name?: string; name: string;
type?: string; type: string;
updated_at?: string; updated_at: string;
}; };
export type HandlersChannelMeta = { export type HandlersChannelMeta = {
capabilities?: ChannelChannelCapabilities; capabilities: ChannelChannelCapabilities;
config_schema?: ChannelConfigSchema; config_schema: ChannelConfigSchema;
configless?: boolean; configless?: boolean;
display_name?: string; display_name: string;
target_spec?: ChannelTargetSpec; target_spec?: ChannelTargetSpec;
type?: string; type: string;
user_config_schema?: ChannelConfigSchema; user_config_schema?: ChannelConfigSchema;
}; };
@@ -429,18 +429,18 @@ export type HandlersListSnapshotsResponse = {
}; };
export type HandlersLoginRequest = { export type HandlersLoginRequest = {
password?: string; password: string;
username?: string; username: string;
}; };
export type HandlersLoginResponse = { export type HandlersLoginResponse = {
access_token?: string; access_token: string;
display_name?: string; display_name: string;
expires_at?: string; expires_at: string;
role?: string; role: string;
token_type?: string; token_type: string;
user_id?: string; user_id: string;
username?: string; username: string;
}; };
export type HandlersMcpStdioRequest = { export type HandlersMcpStdioRequest = {
@@ -634,10 +634,10 @@ export type ModelsAddRequest = {
dimensions?: number; dimensions?: number;
input?: Array<string>; input?: Array<string>;
is_multimodal?: boolean; is_multimodal?: boolean;
llm_provider_id?: string; llm_provider_id: string;
model_id?: string; model_id: string;
name?: string; name: string;
type?: ModelsModelType; type: ModelsModelType;
}; };
export type ModelsAddResponse = { export type ModelsAddResponse = {
@@ -653,10 +653,10 @@ export type ModelsGetResponse = {
dimensions?: number; dimensions?: number;
input?: Array<string>; input?: Array<string>;
is_multimodal?: boolean; is_multimodal?: boolean;
llm_provider_id?: string; llm_provider_id: string;
model_id?: string; model_id: string;
name?: string; name: string;
type?: ModelsModelType; type: ModelsModelType;
}; };
export type ModelsModelType = 'chat' | 'embedding'; export type ModelsModelType = 'chat' | 'embedding';
@@ -665,10 +665,10 @@ export type ModelsUpdateRequest = {
dimensions?: number; dimensions?: number;
input?: Array<string>; input?: Array<string>;
is_multimodal?: boolean; is_multimodal?: boolean;
llm_provider_id?: string; llm_provider_id: string;
model_id?: string; model_id: string;
name?: string; name: string;
type?: ModelsModelType; type: ModelsModelType;
}; };
export type ProvidersClientType = 'openai' | 'openai-compat' | 'anthropic' | 'google' | 'ollama'; export type ProvidersClientType = 'openai' | 'openai-compat' | 'anthropic' | 'google' | 'ollama';
@@ -692,15 +692,15 @@ export type ProvidersGetResponse = {
* masked in response * masked in response
*/ */
api_key?: string; api_key?: string;
base_url?: string; base_url: string;
client_type?: string; client_type: string;
created_at?: string; created_at: string;
id?: string; id: string;
metadata?: { metadata?: {
[key: string]: unknown; [key: string]: unknown;
}; };
name?: string; name: string;
updated_at?: string; updated_at: string;
}; };
export type ProvidersUpdateRequest = { export type ProvidersUpdateRequest = {
@@ -755,12 +755,12 @@ export type ScheduleUpdateRequest = {
}; };
export type SettingsSettings = { export type SettingsSettings = {
allow_guest?: boolean; allow_guest: boolean;
chat_model_id?: string; chat_model_id: string;
embedding_model_id?: string; embedding_model_id: string;
language?: string; language: string;
max_context_load_time?: number; max_context_load_time: number;
memory_model_id?: string; memory_model_id: string;
}; };
export type SettingsUpsertRequest = { export type SettingsUpsertRequest = {
@@ -1001,7 +1001,12 @@ export type PostBotsByBotIdChatData = {
* Chat request * Chat request
*/ */
body: ChatChatRequest; body: ChatChatRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/chat'; url: '/bots/{bot_id}/chat';
}; };
@@ -1033,7 +1038,12 @@ export type PostBotsByBotIdChatStreamData = {
* Chat request * Chat request
*/ */
body: ChatChatRequest; body: ChatChatRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/chat/stream'; url: '/bots/{bot_id}/chat/stream';
}; };
@@ -1823,7 +1833,12 @@ export type PostBotsByBotIdContainerStopResponse = PostBotsByBotIdContainerStopR
export type DeleteBotsByBotIdHistoryData = { export type DeleteBotsByBotIdHistoryData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/history'; url: '/bots/{bot_id}/history';
}; };
@@ -1850,7 +1865,12 @@ export type DeleteBotsByBotIdHistoryResponses = {
export type GetBotsByBotIdHistoryData = { export type GetBotsByBotIdHistoryData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: { query?: {
/** /**
* Limit * Limit
@@ -1887,7 +1907,12 @@ export type PostBotsByBotIdHistoryData = {
* History payload * History payload
*/ */
body: HistoryCreateRequest; body: HistoryCreateRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/history'; url: '/bots/{bot_id}/history';
}; };
@@ -1917,6 +1942,10 @@ export type PostBotsByBotIdHistoryResponse = PostBotsByBotIdHistoryResponses[key
export type DeleteBotsByBotIdHistoryByIdData = { export type DeleteBotsByBotIdHistoryByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* History ID * History ID
*/ */
@@ -1953,6 +1982,10 @@ export type DeleteBotsByBotIdHistoryByIdResponses = {
export type GetBotsByBotIdHistoryByIdData = { export type GetBotsByBotIdHistoryByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* History ID * History ID
*/ */
@@ -1990,7 +2023,12 @@ export type GetBotsByBotIdHistoryByIdResponse = GetBotsByBotIdHistoryByIdRespons
export type GetBotsByBotIdMcpData = { export type GetBotsByBotIdMcpData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/mcp'; url: '/bots/{bot_id}/mcp';
}; };
@@ -2030,7 +2068,12 @@ export type PostBotsByBotIdMcpData = {
* MCP payload * MCP payload
*/ */
body: McpUpsertRequest; body: McpUpsertRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/mcp'; url: '/bots/{bot_id}/mcp';
}; };
@@ -2158,6 +2201,10 @@ export type PostBotsByBotIdMcpStdioBySessionIdResponse = PostBotsByBotIdMcpStdio
export type DeleteBotsByBotIdMcpByIdData = { export type DeleteBotsByBotIdMcpByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* MCP ID * MCP ID
*/ */
@@ -2198,6 +2245,10 @@ export type DeleteBotsByBotIdMcpByIdResponses = {
export type GetBotsByBotIdMcpByIdData = { export type GetBotsByBotIdMcpByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* MCP ID * MCP ID
*/ */
@@ -2243,6 +2294,10 @@ export type PutBotsByBotIdMcpByIdData = {
*/ */
body: McpUpsertRequest; body: McpUpsertRequest;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* MCP ID * MCP ID
*/ */
@@ -2287,7 +2342,12 @@ export type PostBotsByBotIdMemoryAddData = {
* Add request * Add request
*/ */
body: HandlersMemoryAddPayload; body: HandlersMemoryAddPayload;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/memory/add'; url: '/bots/{bot_id}/memory/add';
}; };
@@ -2319,7 +2379,12 @@ export type PostBotsByBotIdMemoryEmbedData = {
* Embed upsert request * Embed upsert request
*/ */
body: HandlersMemoryEmbedUpsertPayload; body: HandlersMemoryEmbedUpsertPayload;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/memory/embed'; url: '/bots/{bot_id}/memory/embed';
}; };
@@ -2351,7 +2416,12 @@ export type DeleteBotsByBotIdMemoryMemoriesData = {
* Delete all request * Delete all request
*/ */
body: HandlersMemoryDeleteAllPayload; body: HandlersMemoryDeleteAllPayload;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/memory/memories'; url: '/bots/{bot_id}/memory/memories';
}; };
@@ -2380,7 +2450,12 @@ export type DeleteBotsByBotIdMemoryMemoriesResponse = DeleteBotsByBotIdMemoryMem
export type GetBotsByBotIdMemoryMemoriesData = { export type GetBotsByBotIdMemoryMemoriesData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: { query?: {
/** /**
* Run ID * Run ID
@@ -2419,6 +2494,10 @@ export type GetBotsByBotIdMemoryMemoriesResponse = GetBotsByBotIdMemoryMemoriesR
export type DeleteBotsByBotIdMemoryMemoriesByMemoryIdData = { export type DeleteBotsByBotIdMemoryMemoriesByMemoryIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Memory ID * Memory ID
*/ */
@@ -2453,6 +2532,10 @@ export type DeleteBotsByBotIdMemoryMemoriesByMemoryIdResponse = DeleteBotsByBotI
export type GetBotsByBotIdMemoryMemoriesByMemoryIdData = { export type GetBotsByBotIdMemoryMemoriesByMemoryIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Memory ID * Memory ID
*/ */
@@ -2489,7 +2572,12 @@ export type PostBotsByBotIdMemorySearchData = {
* Search request * Search request
*/ */
body: HandlersMemorySearchPayload; body: HandlersMemorySearchPayload;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/memory/search'; url: '/bots/{bot_id}/memory/search';
}; };
@@ -2521,7 +2609,12 @@ export type PostBotsByBotIdMemoryUpdateData = {
* Update request * Update request
*/ */
body: MemoryUpdateRequest; body: MemoryUpdateRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/memory/update'; url: '/bots/{bot_id}/memory/update';
}; };
@@ -2550,7 +2643,12 @@ export type PostBotsByBotIdMemoryUpdateResponse = PostBotsByBotIdMemoryUpdateRes
export type GetBotsByBotIdScheduleData = { export type GetBotsByBotIdScheduleData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/schedule'; url: '/bots/{bot_id}/schedule';
}; };
@@ -2582,7 +2680,12 @@ export type PostBotsByBotIdScheduleData = {
* Schedule payload * Schedule payload
*/ */
body: ScheduleCreateRequest; body: ScheduleCreateRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/schedule'; url: '/bots/{bot_id}/schedule';
}; };
@@ -2612,6 +2715,10 @@ export type PostBotsByBotIdScheduleResponse = PostBotsByBotIdScheduleResponses[k
export type DeleteBotsByBotIdScheduleByIdData = { export type DeleteBotsByBotIdScheduleByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Schedule ID * Schedule ID
*/ */
@@ -2644,6 +2751,10 @@ export type DeleteBotsByBotIdScheduleByIdResponses = {
export type GetBotsByBotIdScheduleByIdData = { export type GetBotsByBotIdScheduleByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Schedule ID * Schedule ID
*/ */
@@ -2685,6 +2796,10 @@ export type PutBotsByBotIdScheduleByIdData = {
*/ */
body: ScheduleUpdateRequest; body: ScheduleUpdateRequest;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Schedule ID * Schedule ID
*/ */
@@ -2718,7 +2833,12 @@ export type PutBotsByBotIdScheduleByIdResponse = PutBotsByBotIdScheduleByIdRespo
export type DeleteBotsByBotIdSettingsData = { export type DeleteBotsByBotIdSettingsData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/settings'; url: '/bots/{bot_id}/settings';
}; };
@@ -2745,7 +2865,12 @@ export type DeleteBotsByBotIdSettingsResponses = {
export type GetBotsByBotIdSettingsData = { export type GetBotsByBotIdSettingsData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/settings'; url: '/bots/{bot_id}/settings';
}; };
@@ -2777,7 +2902,12 @@ export type PostBotsByBotIdSettingsData = {
* Settings payload * Settings payload
*/ */
body: SettingsUpsertRequest; body: SettingsUpsertRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/settings'; url: '/bots/{bot_id}/settings';
}; };
@@ -2809,7 +2939,12 @@ export type PutBotsByBotIdSettingsData = {
* Settings payload * Settings payload
*/ */
body: SettingsUpsertRequest; body: SettingsUpsertRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/settings'; url: '/bots/{bot_id}/settings';
}; };
@@ -2838,7 +2973,12 @@ export type PutBotsByBotIdSettingsResponse = PutBotsByBotIdSettingsResponses[key
export type GetBotsByBotIdSubagentsData = { export type GetBotsByBotIdSubagentsData = {
body?: never; body?: never;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/subagents'; url: '/bots/{bot_id}/subagents';
}; };
@@ -2870,7 +3010,12 @@ export type PostBotsByBotIdSubagentsData = {
* Subagent payload * Subagent payload
*/ */
body: SubagentCreateRequest; body: SubagentCreateRequest;
path?: never; path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never; query?: never;
url: '/bots/{bot_id}/subagents'; url: '/bots/{bot_id}/subagents';
}; };
@@ -2900,6 +3045,10 @@ export type PostBotsByBotIdSubagentsResponse = PostBotsByBotIdSubagentsResponses
export type DeleteBotsByBotIdSubagentsByIdData = { export type DeleteBotsByBotIdSubagentsByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -2936,6 +3085,10 @@ export type DeleteBotsByBotIdSubagentsByIdResponses = {
export type GetBotsByBotIdSubagentsByIdData = { export type GetBotsByBotIdSubagentsByIdData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -2977,6 +3130,10 @@ export type PutBotsByBotIdSubagentsByIdData = {
*/ */
body: SubagentUpdateRequest; body: SubagentUpdateRequest;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -3015,6 +3172,10 @@ export type PutBotsByBotIdSubagentsByIdResponse = PutBotsByBotIdSubagentsByIdRes
export type GetBotsByBotIdSubagentsByIdContextData = { export type GetBotsByBotIdSubagentsByIdContextData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -3056,6 +3217,10 @@ export type PutBotsByBotIdSubagentsByIdContextData = {
*/ */
body: SubagentUpdateContextRequest; body: SubagentUpdateContextRequest;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -3094,6 +3259,10 @@ export type PutBotsByBotIdSubagentsByIdContextResponse = PutBotsByBotIdSubagents
export type GetBotsByBotIdSubagentsByIdSkillsData = { export type GetBotsByBotIdSubagentsByIdSkillsData = {
body?: never; body?: never;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -3135,6 +3304,10 @@ export type PostBotsByBotIdSubagentsByIdSkillsData = {
*/ */
body: SubagentAddSkillsRequest; body: SubagentAddSkillsRequest;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -3176,6 +3349,10 @@ export type PutBotsByBotIdSubagentsByIdSkillsData = {
*/ */
body: SubagentUpdateSkillsRequest; body: SubagentUpdateSkillsRequest;
path: { path: {
/**
* Bot ID
*/
bot_id: string;
/** /**
* Subagent ID * Subagent ID
*/ */
@@ -152,12 +152,22 @@ import {
import { toTypedSchema } from '@vee-validate/zod' import { toTypedSchema } from '@vee-validate/zod'
import z from 'zod' import z from 'zod'
import { useForm } from 'vee-validate' import { useForm } from 'vee-validate'
import { CLIENT_TYPES } from '@/composables/api/useProviders' import { useMutation, useQueryCache } from '@pinia/colada'
import { useCreateProvider } from '@/composables/api/useProviders' import { postProviders } from '@memoh/sdk'
import type { ProvidersClientType } from '@memoh/sdk'
const CLIENT_TYPES: ProvidersClientType[] = ['openai', 'openai-compat', 'anthropic', 'google', 'ollama']
const open = defineModel<boolean>('open') const open = defineModel<boolean>('open')
const { mutate: providerFetch, isLoading } = useCreateProvider() const queryCache = useQueryCache()
const { mutate: providerFetch, isLoading } = useMutation({
mutation: async (data: Record<string, unknown>) => {
const { data: result } = await postProviders({ body: data as any, throwOnError: true })
return result
},
onSettled: () => queryCache.invalidateQueries({ key: ['providers'] }),
})
const providerSchema = toTypedSchema(z.object({ const providerSchema = toTypedSchema(z.object({
api_key: z.string().min(1), api_key: z.string().min(1),
@@ -172,8 +172,9 @@ import { useForm } from 'vee-validate'
import { inject, computed, watch, nextTick, type Ref, ref } from 'vue' import { inject, computed, watch, nextTick, type Ref, ref } from 'vue'
import { toTypedSchema } from '@vee-validate/zod' import { toTypedSchema } from '@vee-validate/zod'
import z from 'zod' import z from 'zod'
import { type ModelInfo } from '@/composables/api/useModels' import { useMutation, useQueryCache } from '@pinia/colada'
import { useCreateModel, useUpdateModel } from '@/composables/api/useModels' import { postModels, putModelsModelByModelId } from '@memoh/sdk'
import type { ModelsGetResponse } from '@memoh/sdk'
const formSchema = toTypedSchema(z.object({ const formSchema = toTypedSchema(z.object({
type: z.string().min(1), type: z.string().min(1),
@@ -191,7 +192,7 @@ const selectedType = computed(() => form.values.type || editInfo?.value?.type)
const open = inject<Ref<boolean>>('openModel', ref(false)) const open = inject<Ref<boolean>>('openModel', ref(false))
const title = inject<Ref<'edit' | 'title'>>('openModelTitle', ref('title')) const title = inject<Ref<'edit' | 'title'>>('openModelTitle', ref('title'))
const editInfo = inject<Ref<ModelInfo | null>>('openModelState', ref(null)) const editInfo = inject<Ref<ModelsGetResponse | null>>('openModelState', ref(null))
// handleSubmit // handleSubmit
// //
@@ -229,8 +230,25 @@ function onNameInput(e: Event) {
const { id } = defineProps<{ id: string }>() const { id } = defineProps<{ id: string }>()
const { mutateAsync: createModel, isLoading: createLoading } = useCreateModel() const queryCache = useQueryCache()
const { mutateAsync: updateModel, isLoading: updateLoading } = useUpdateModel() const { mutateAsync: createModel, isLoading: createLoading } = useMutation({
mutation: async (data: Record<string, unknown>) => {
const { data: result } = await postModels({ body: data as any, throwOnError: true })
return result
},
onSettled: () => queryCache.invalidateQueries({ key: ['provider-models'] }),
})
const { mutateAsync: updateModel, isLoading: updateLoading } = useMutation({
mutation: async ({ modelId, data }: { modelId: string; data: Record<string, unknown> }) => {
const { data: result } = await putModelsModelByModelId({
path: { modelId },
body: data as any,
throwOnError: true,
})
return result
},
onSettled: () => queryCache.invalidateQueries({ key: ['provider-models'] }),
})
const isLoading = computed(() => createLoading.value || updateLoading.value) const isLoading = computed(() => createLoading.value || updateLoading.value)
async function addModel(e: Event) { async function addModel(e: Event) {
@@ -1,20 +0,0 @@
import { fetchApi } from '@/utils/request'
export interface LoginRequest {
username: string
password: string
}
export interface LoginResponse {
access_token: string
user_id: string
username: string
}
export async function login(data: LoginRequest): Promise<LoginResponse> {
return fetchApi<LoginResponse>('/auth/login', {
method: 'POST',
body: data,
noAuth: true,
})
}
@@ -1,46 +0,0 @@
import { fetchApi } from '@/utils/request'
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import type { Ref } from 'vue'
// ---- Types ----
export interface BotSettings {
chat_model_id: string
memory_model_id: string
embedding_model_id: string
max_context_load_time: number
language: string
allow_guest: boolean
}
export interface UpsertBotSettingsRequest {
chat_model_id?: string
memory_model_id?: string
embedding_model_id?: string
max_context_load_time?: number
language?: string
allow_guest?: boolean
}
// ---- Query ----
export function useBotSettings(botId: Ref<string>) {
return useQuery({
key: () => ['bot-settings', botId.value],
query: () => fetchApi<BotSettings>(`/bots/${botId.value}/settings`),
enabled: () => !!botId.value,
})
}
// ---- Mutation ----
export function useUpdateBotSettings(botId: Ref<string>) {
const queryCache = useQueryCache()
return useMutation({
mutation: (data: UpsertBotSettingsRequest) => fetchApi<BotSettings>(
`/bots/${botId.value}/settings`,
{ method: 'PUT', body: data },
),
onSettled: () => queryCache.invalidateQueries({ key: ['bot-settings', botId.value] }),
})
}
@@ -1,99 +0,0 @@
import { fetchApi } from '@/utils/request'
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import type { Ref } from 'vue'
// ---- Types ----
export interface BotInfo {
id: string
display_name: string
avatar_url: string
type: string
is_active: boolean
owner_user_id: string
metadata: Record<string, unknown>
created_at: string
updated_at: string
}
export interface ListBotsResponse {
items: BotInfo[]
}
export interface CreateBotRequest {
display_name: string
avatar_url?: string
type?: string
is_active?: boolean
metadata?: Record<string, unknown>
}
export interface UpdateBotRequest {
display_name?: string
avatar_url?: string
is_active?: boolean
metadata?: Record<string, unknown>
}
// ---- Query: 获取 Bot 列表 ----
export function useBotList() {
const queryCache = useQueryCache()
const query = useQuery({
key: ['bots'],
query: async (): Promise<BotInfo[]> => {
const res = await fetchApi<ListBotsResponse>('/bots')
return res.items ?? []
},
})
return {
...query,
invalidate: () => queryCache.invalidateQueries({ key: ['bots'] }),
}
}
// ---- Query: 获取单个 Bot 详情 ----
export function useBotDetail(botId: Ref<string>) {
return useQuery({
key: () => ['bot', botId.value],
query: () => fetchApi<BotInfo>(`/bots/${botId.value}`),
enabled: () => !!botId.value,
})
}
// ---- Mutations ----
export function useCreateBot() {
const queryCache = useQueryCache()
return useMutation({
mutation: (data: CreateBotRequest) => fetchApi<BotInfo>('/bots', {
method: 'POST',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['bots'] }),
})
}
export function useDeleteBot() {
const queryCache = useQueryCache()
return useMutation({
mutation: (botId: string) => fetchApi(`/bots/${botId}`, {
method: 'DELETE',
}),
onSettled: () => queryCache.invalidateQueries({ key: ['bots'] }),
})
}
export function useUpdateBot() {
const queryCache = useQueryCache()
return useMutation({
mutation: ({ id, ...data }: UpdateBotRequest & { id: string }) => fetchApi<BotInfo>(`/bots/${id}`, {
method: 'PUT',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['bots'] }),
})
}
@@ -1,143 +0,0 @@
import { fetchApi, ApiError } from '@/utils/request'
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import type { Ref } from 'vue'
// ---- Types ----
export interface FieldSchema {
title: string
description?: string
type: 'string' | 'secret' | 'bool' | 'number' | 'enum'
required?: boolean
enum?: string[]
example?: unknown
}
export interface ConfigSchema {
version: number
fields: Record<string, FieldSchema>
}
export interface ChannelCapabilities {
text: boolean
markdown: boolean
rich_text: boolean
attachments: boolean
media: boolean
reactions: boolean
buttons: boolean
reply: boolean
threads: boolean
streaming: boolean
polls: boolean
edit: boolean
unsend: boolean
native_commands: boolean
block_streaming: boolean
chat_types?: string[]
}
export interface ChannelMeta {
type: string
display_name: string
configless: boolean
capabilities: ChannelCapabilities
config_schema: ConfigSchema
user_config_schema: ConfigSchema
target_spec: { format: string; description: string }
}
export interface ChannelConfig {
id: string
botID: string
channelType: string
credentials: Record<string, unknown>
externalIdentity: string
selfIdentity: Record<string, unknown>
routing: Record<string, unknown>
status: string
verifiedAt: string
createdAt: string
updatedAt: string
}
export interface UpsertConfigRequest {
credentials: Record<string, unknown>
external_identity?: string
self_identity?: Record<string, unknown>
routing?: Record<string, unknown>
status?: string
}
export interface BotChannelItem {
meta: ChannelMeta
config: ChannelConfig | null
configured: boolean
}
// ---- Query: 获取可用渠道类型元信息 ----
export function useChannelMetas() {
return useQuery({
key: ['channel-metas'],
query: () => fetchApi<ChannelMeta[]>('/channels'),
})
}
// ---- Query: 获取某 Bot 的所有渠道配置(组合查询) ----
export function useBotChannels(botId: Ref<string>) {
const queryCache = useQueryCache()
const query = useQuery({
key: () => ['bot-channels', botId.value],
query: async (): Promise<BotChannelItem[]> => {
// 1. 获取所有渠道元信息
const metas = await fetchApi<ChannelMeta[]>('/channels')
// 2. 过滤掉 configless 的类型(cli / web 等本地渠道)
const configurableTypes = metas.filter((m) => !m.configless)
// 3. 并行获取每种类型的 bot 配置
const results = await Promise.all(
configurableTypes.map(async (meta) => {
try {
const config = await fetchApi<ChannelConfig>(
`/bots/${botId.value}/channel/${meta.type}`,
)
return { meta, config, configured: true } as BotChannelItem
} catch (err) {
// 404 = 尚未配置,其他错误也视为未配置
if (err instanceof ApiError && err.status === 404) {
return { meta, config: null, configured: false } as BotChannelItem
}
return { meta, config: null, configured: false } as BotChannelItem
}
}),
)
return results
},
enabled: () => !!botId.value,
})
return {
...query,
invalidate: () => queryCache.invalidateQueries({ key: ['bot-channels', botId.value] }),
}
}
// ---- Mutation: 创建/更新 Bot 渠道配置 ----
export function useUpsertBotChannel(botId: Ref<string>) {
const queryCache = useQueryCache()
return useMutation({
mutation: ({ platform, data }: { platform: string; data: UpsertConfigRequest }) =>
fetchApi<ChannelConfig>(`/bots/${botId.value}/channel/${platform}`, {
method: 'PUT',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['bot-channels', botId.value] }),
})
}
@@ -1,88 +0,0 @@
import { fetchApi } from '@/utils/request'
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import type { Ref } from 'vue'
// ---- Types ----
export interface ModelInfo {
dimensions: number
is_multimodal: boolean
input?: string[]
llm_provider_id: string
model_id: string
name: string
type: string
enable_as?: string
}
export interface CreateModelRequest {
model_id: string
type: string
llm_provider_id: string
name?: string
dimensions?: number
is_multimodal?: boolean
}
// ---- Query: 获取 Provider 下的模型列表 ----
export function useModelList(providerId: Ref<string | undefined>) {
const queryCache = useQueryCache()
const query = useQuery({
key: ['model'],
query: () => fetchApi<ModelInfo[]>(
`/providers/${providerId.value}/models`,
),
})
return {
...query,
/** 当 providerId 变化时手动刷新 */
invalidate: () => queryCache.invalidateQueries({ key: ['model'] }),
}
}
// ---- Query: 获取所有模型(跨 Provider ----
export function useAllModels() {
return useQuery({
key: ['all-models'],
query: () => fetchApi<ModelInfo[]>('/models'),
})
}
// ---- Mutations ----
export function useCreateModel() {
const queryCache = useQueryCache()
return useMutation({
mutation: (data: CreateModelRequest) => fetchApi('/models', {
method: 'POST',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['model'], exact: true }),
})
}
export function useUpdateModel() {
const queryCache = useQueryCache()
return useMutation({
mutation: ({ modelId, data }: { modelId: string; data: Partial<CreateModelRequest> }) =>
fetchApi(`/models/model/${modelId}`, {
method: 'PUT',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['model'] }),
})
}
export function useDeleteModel() {
const queryCache = useQueryCache()
return useMutation({
mutation: (modelName: string) => fetchApi(`/models/model/${modelName}`, {
method: 'DELETE',
}),
onSettled: () => queryCache.invalidateQueries({ key: ['model'] }),
})
}
@@ -1,80 +0,0 @@
import { fetchApi } from '@/utils/request'
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import type { Ref } from 'vue'
// ---- Types ----
export interface ProviderInfo {
api_key: string
base_url: string
client_type: string
metadata: Record<'additionalProp1', object>
name: string
}
export const CLIENT_TYPES = ['openai', 'anthropic', 'google', 'ollama'] as const
export type ProviderWithId = ProviderInfo & { id: string }
export interface CreateProviderRequest {
name: string
api_key: string
base_url: string
client_type: string
metadata?: Record<string, unknown>
}
export type UpdateProviderRequest = Partial<CreateProviderRequest>
// ---- Query: 获取 Provider 列表 ----
export function useProviderList(clientType: Ref<string>) {
return useQuery({
key: ['provider'],
query: () => fetchApi<ProviderWithId[]>(
`/providers?client_type=${clientType.value}`,
),
})
}
/** 获取所有 Provider(无过滤) */
export function useAllProviders() {
return useQuery({
key: ['all-providers'],
query: () => fetchApi<ProviderWithId[]>('/providers'),
})
}
// ---- Mutations ----
export function useCreateProvider() {
const queryCache = useQueryCache()
return useMutation({
mutation: (data: CreateProviderRequest) => fetchApi('/providers', {
method: 'POST',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['provider'] }),
})
}
export function useUpdateProvider(providerId: Ref<string | undefined>) {
const queryCache = useQueryCache()
return useMutation({
mutation: (data: UpdateProviderRequest) => fetchApi(`/providers/${providerId.value}`, {
method: 'PUT',
body: data,
}),
onSettled: () => queryCache.invalidateQueries({ key: ['provider'] }),
})
}
export function useDeleteProvider(providerId: Ref<string | undefined>) {
const queryCache = useQueryCache()
return useMutation({
mutation: () => fetchApi(`/providers/${providerId.value}`, {
method: 'DELETE',
}),
onSettled: () => queryCache.invalidateQueries({ key: ['provider'] }),
})
}
+29
View File
@@ -0,0 +1,29 @@
import { client } from '@memoh/sdk/client'
import router from '@/router'
/**
* Configure the SDK client with base URL, auth interceptor, and 401 handling.
* Call this once at app startup (main.ts).
*/
export function setupApiClient() {
// Set base URL to match the Vite proxy
client.setConfig({ baseUrl: '/api' })
// Add auth token to every request
client.interceptors.request.use((request) => {
const token = localStorage.getItem('token')
if (token) {
request.headers.set('Authorization', `Bearer ${token}`)
}
return request
})
// Handle 401 responses globally
client.interceptors.response.use((response) => {
if (response.status === 401) {
localStorage.removeItem('token')
router.replace({ name: 'Login' })
}
return response
})
}
+4
View File
@@ -2,6 +2,10 @@ import { createApp } from 'vue'
import './style.css' import './style.css'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
import { setupApiClient } from './lib/api-client'
// Configure SDK client before anything else
setupApiClient()
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import i18n from './i18n' import i18n from './i18n'
import { PiniaColada } from '@pinia/colada' import { PiniaColada } from '@pinia/colada'
@@ -80,17 +80,17 @@ import {
import ConfirmPopover from '@/components/confirm-popover/index.vue' import ConfirmPopover from '@/components/confirm-popover/index.vue'
import { computed } from 'vue' import { computed } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import type { BotInfo } from '@/composables/api/useBots' import type { BotsBot } from '@memoh/sdk'
const router = useRouter() const router = useRouter()
const props = defineProps<{ const props = defineProps<{
bot: BotInfo bot: BotsBot
deleteLoading: boolean deleteLoading: boolean
}>() }>()
defineEmits<{ defineEmits<{
edit: [bot: BotInfo] edit: [bot: BotsBot]
delete: [id: string] delete: [id: string]
}>() }>()
@@ -142,15 +142,48 @@ import {
PopoverTrigger, PopoverTrigger,
PopoverContent, PopoverContent,
} from '@memoh/ui' } from '@memoh/ui'
import { useBotChannels, type BotChannelItem } from '@/composables/api/useChannels' import { useQuery, useQueryCache } from '@pinia/colada'
import { getChannels, getBotsByIdChannelByPlatform } from '@memoh/sdk'
import type { HandlersChannelMeta, ChannelChannelConfig } from '@memoh/sdk'
import ChannelSettingsPanel from './channel-settings-panel.vue' import ChannelSettingsPanel from './channel-settings-panel.vue'
export interface BotChannelItem {
meta: HandlersChannelMeta
config: ChannelChannelConfig | null
configured: boolean
}
const props = defineProps<{ const props = defineProps<{
botId: string botId: string
}>() }>()
const botIdRef = computed(() => props.botId) const botIdRef = computed(() => props.botId)
const { data: channels, isLoading, refetch } = useBotChannels(botIdRef)
const { data: channels, isLoading, refetch } = useQuery({
key: () => ['bot-channels', botIdRef.value],
query: async (): Promise<BotChannelItem[]> => {
const { data: metas } = await getChannels({ throwOnError: true })
if (!metas) return []
const configurableTypes = metas.filter((m) => !m.configless)
const results = await Promise.all(
configurableTypes.map(async (meta) => {
try {
const { data: config } = await getBotsByIdChannelByPlatform({
path: { id: botIdRef.value, platform: meta.type },
throwOnError: true,
})
return { meta, config: config ?? null, configured: true } as BotChannelItem
} catch {
return { meta, config: null, configured: false } as BotChannelItem
}
}),
)
return results
},
enabled: () => !!botIdRef.value,
})
const selectedType = ref<string | null>(null) const selectedType = ref<string | null>(null)
const addPopoverOpen = ref(false) const addPopoverOpen = ref(false)
@@ -94,9 +94,9 @@ import { reactive, computed, watch } from 'vue'
import { toast } from 'vue-sonner' import { toast } from 'vue-sonner'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import ModelSelect from './model-select.vue' import ModelSelect from './model-select.vue'
import { useBotSettings, useUpdateBotSettings, type BotSettings } from '@/composables/api/useBotSettings' import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import { useAllModels } from '@/composables/api/useModels' import { getBotsByBotIdSettings, putBotsByBotIdSettings, getModels, getProviders } from '@memoh/sdk'
import { useAllProviders } from '@/composables/api/useProviders' import type { SettingsSettings } from '@memoh/sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
const props = defineProps<{ const props = defineProps<{
@@ -108,16 +108,50 @@ const { t } = useI18n()
const botIdRef = computed(() => props.botId) as Ref<string> const botIdRef = computed(() => props.botId) as Ref<string>
// ---- Data ---- // ---- Data ----
const { data: settings } = useBotSettings(botIdRef) const queryCache = useQueryCache()
const { data: modelData } = useAllModels()
const { data: providerData } = useAllProviders() const { data: settings } = useQuery({
const { mutateAsync: updateSettings, isLoading } = useUpdateBotSettings(botIdRef) key: () => ['bot-settings', botIdRef.value],
query: async () => {
const { data } = await getBotsByBotIdSettings({ path: { bot_id: botIdRef.value }, throwOnError: true })
return data
},
enabled: () => !!botIdRef.value,
})
const { data: modelData } = useQuery({
key: ['all-models'],
query: async () => {
const { data } = await getModels({ throwOnError: true })
return data
},
})
const { data: providerData } = useQuery({
key: ['all-providers'],
query: async () => {
const { data } = await getProviders({ throwOnError: true })
return data
},
})
const { mutateAsync: updateSettings, isLoading } = useMutation({
mutation: async (body: Partial<SettingsSettings>) => {
const { data } = await putBotsByBotIdSettings({
path: { bot_id: botIdRef.value },
body,
throwOnError: true,
})
return data
},
onSettled: () => queryCache.invalidateQueries({ key: ['bot-settings', botIdRef.value] }),
})
const models = computed(() => modelData.value ?? []) const models = computed(() => modelData.value ?? [])
const providers = computed(() => providerData.value ?? []) const providers = computed(() => providerData.value ?? [])
// ---- Form ---- // ---- Form ----
const form = reactive<BotSettings>({ const form = reactive<SettingsSettings>({
chat_model_id: '', chat_model_id: '',
memory_model_id: '', memory_model_id: '',
embedding_model_id: '', embedding_model_id: '',
@@ -151,14 +151,17 @@ import {
import { reactive, watch, computed } from 'vue' import { reactive, watch, computed } from 'vue'
import { toast } from 'vue-sonner' import { toast } from 'vue-sonner'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { import { useMutation, useQueryCache } from '@pinia/colada'
useUpsertBotChannel, import { putBotsByIdChannelByPlatform } from '@memoh/sdk'
type BotChannelItem, import type { HandlersChannelMeta, ChannelChannelConfig, ChannelFieldSchema } from '@memoh/sdk'
type FieldSchema,
} from '@/composables/api/useChannels'
import { ApiError } from '@/utils/request'
import type { Ref } from 'vue' import type { Ref } from 'vue'
interface BotChannelItem {
meta: HandlersChannelMeta
config: ChannelChannelConfig | null
configured: boolean
}
const props = defineProps<{ const props = defineProps<{
botId: string botId: string
channelItem: BotChannelItem channelItem: BotChannelItem
@@ -170,7 +173,18 @@ const emit = defineEmits<{
const { t } = useI18n() const { t } = useI18n()
const botIdRef = computed(() => props.botId) as Ref<string> const botIdRef = computed(() => props.botId) as Ref<string>
const { mutateAsync: upsertChannel, isLoading } = useUpsertBotChannel(botIdRef) const queryCache = useQueryCache()
const { mutateAsync: upsertChannel, isLoading } = useMutation({
mutation: async ({ platform, data }: { platform: string; data: Record<string, unknown> }) => {
const { data: result } = await putBotsByIdChannelByPlatform({
path: { id: botIdRef.value, platform },
body: data as any,
throwOnError: true,
})
return result
},
onSettled: () => queryCache.invalidateQueries({ key: ['bot-channels', botIdRef.value] }),
})
// ---- Form state ---- // ---- Form state ----
@@ -193,7 +207,7 @@ const orderedFields = computed(() => {
if (!a.required && b.required) return 1 if (!a.required && b.required) return 1
return 0 return 0
}) })
return Object.fromEntries(entries) as Record<string, FieldSchema> return Object.fromEntries(entries) as Record<string, ChannelFieldSchema>
}) })
// //
@@ -252,10 +266,7 @@ async function handleSave() {
emit('saved') emit('saved')
} catch (err) { } catch (err) {
let detail = '' let detail = ''
if (err instanceof ApiError && err.body) { if (err instanceof Error) {
const body = err.body as Record<string, unknown>
detail = String(body.message || body.error || '')
} else if (err instanceof Error) {
detail = err.message detail = err.message
} }
toast.error(detail ? `${t('bots.channels.saveFailed')}: ${detail}` : t('bots.channels.saveFailed')) toast.error(detail ? `${t('bots.channels.saveFailed')}: ${detail}` : t('bots.channels.saveFailed'))
@@ -153,10 +153,12 @@ import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod' import { toTypedSchema } from '@vee-validate/zod'
import z from 'zod' import z from 'zod'
import { computed, watch } from 'vue' import { computed, watch } from 'vue'
import { useCreateBot, useUpdateBot, type BotInfo } from '@/composables/api/useBots' import { useMutation, useQueryCache } from '@pinia/colada'
import { postBotsMutation, putBotsByIdMutation, getBotsQueryKey } from '@memoh/sdk/colada'
import type { BotsBot } from '@memoh/sdk'
const open = defineModel<boolean>('open', { default: false }) const open = defineModel<boolean>('open', { default: false })
const editBot = defineModel<BotInfo | null>('editBot', { default: null }) const editBot = defineModel<BotsBot | null>('editBot', { default: null })
const isEdit = computed(() => !!editBot.value) const isEdit = computed(() => !!editBot.value)
@@ -174,8 +176,15 @@ const form = useForm({
}, },
}) })
const { mutate: createBot, isLoading: createLoading } = useCreateBot() const queryCache = useQueryCache()
const { mutate: updateBot, isLoading: updateLoading } = useUpdateBot() const { mutate: createBot, isLoading: createLoading } = useMutation({
...postBotsMutation(),
onSettled: () => queryCache.invalidateQueries({ key: getBotsQueryKey() }),
})
const { mutate: updateBot, isLoading: updateLoading } = useMutation({
...putBotsByIdMutation(),
onSettled: () => queryCache.invalidateQueries({ key: getBotsQueryKey() }),
})
const submitLoading = computed(() => createLoading.value || updateLoading.value) const submitLoading = computed(() => createLoading.value || updateLoading.value)
@@ -199,17 +208,21 @@ const handleSubmit = form.handleSubmit(async (values) => {
try { try {
if (isEdit.value && editBot.value) { if (isEdit.value && editBot.value) {
await updateBot({ await updateBot({
id: editBot.value.id, path: { id: editBot.value.id },
body: {
display_name: values.display_name, display_name: values.display_name,
avatar_url: values.avatar_url || undefined, avatar_url: values.avatar_url || undefined,
is_active: values.is_active, is_active: values.is_active,
},
}) })
} else { } else {
await createBot({ await createBot({
body: {
display_name: values.display_name, display_name: values.display_name,
avatar_url: values.avatar_url || undefined, avatar_url: values.avatar_url || undefined,
type: values.type || undefined, type: values.type || undefined,
is_active: true, is_active: true,
},
}) })
} }
open.value = false open.value = false
@@ -89,12 +89,11 @@ import {
ScrollArea, ScrollArea,
} from '@memoh/ui' } from '@memoh/ui'
import { computed, ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
import type { ModelInfo } from '@/composables/api/useModels' import type { ModelsGetResponse, ProvidersGetResponse } from '@memoh/sdk'
import type { ProviderWithId } from '@/composables/api/useProviders'
const props = defineProps<{ const props = defineProps<{
models: ModelInfo[] models: ModelsGetResponse[]
providers: ProviderWithId[] providers: ProvidersGetResponse[]
modelType: 'chat' | 'embedding' modelType: 'chat' | 'embedding'
placeholder?: string placeholder?: string
}>() }>()
@@ -131,7 +130,7 @@ const filteredGroups = computed(() => {
) )
: typeFilteredModels.value : typeFilteredModels.value
const groups = new Map<string, { providerName: string; models: ModelInfo[] }>() const groups = new Map<string, { providerName: string; models: ModelsGetResponse[] }>()
for (const model of models) { for (const model of models) {
const pid = model.llm_provider_id const pid = model.llm_provider_id
const providerName = providerMap.value.get(pid) ?? pid const providerName = providerMap.value.get(pid) ?? pid
+10 -2
View File
@@ -117,14 +117,22 @@ import {
} from '@memoh/ui' } from '@memoh/ui'
import { computed, ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { useBotDetail } from '@/composables/api/useBots' import { useQuery } from '@pinia/colada'
import { getBotsById } from '@memoh/sdk'
import BotSettings from './components/bot-settings.vue' import BotSettings from './components/bot-settings.vue'
import BotChannels from './components/bot-channels.vue' import BotChannels from './components/bot-channels.vue'
const route = useRoute() const route = useRoute()
const botId = computed(() => route.params.botId as string) const botId = computed(() => route.params.botId as string)
const { data: bot } = useBotDetail(botId) const { data: bot } = useQuery({
key: () => ['bot', botId.value],
query: async () => {
const { data } = await getBotsById({ path: { id: botId.value }, throwOnError: true })
return data
},
enabled: () => !!botId.value,
})
// bot breadcrumb botId // bot breadcrumb botId
watch(bot, (val) => { watch(bot, (val) => {
+13 -7
View File
@@ -69,19 +69,25 @@ import {
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import BotCard from './components/bot-card.vue' import BotCard from './components/bot-card.vue'
import CreateBot from './components/create-bot.vue' import CreateBot from './components/create-bot.vue'
import { useBotList, useDeleteBot, type BotInfo } from '@/composables/api/useBots' import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import { getBotsQuery, getBotsQueryKey, deleteBotsByIdMutation } from '@memoh/sdk/colada'
import type { BotsBot } from '@memoh/sdk'
const searchText = ref('') const searchText = ref('')
const dialogOpen = ref(false) const dialogOpen = ref(false)
const editingBot = ref<BotInfo | null>(null) const editingBot = ref<BotsBot | null>(null)
const { data: botData, status } = useBotList() const queryCache = useQueryCache()
const { mutate: deleteBot, isLoading: deleteLoading } = useDeleteBot() const { data: botData, status } = useQuery(getBotsQuery())
const { mutate: deleteBot, isLoading: deleteLoading } = useMutation({
...deleteBotsByIdMutation(),
onSettled: () => queryCache.invalidateQueries({ key: getBotsQueryKey() }),
})
const isLoading = computed(() => status.value === 'loading') const isLoading = computed(() => status.value === 'loading')
const filteredBots = computed(() => { const filteredBots = computed(() => {
const list = botData.value ?? [] const list = botData.value?.items ?? []
const keyword = searchText.value.trim().toLowerCase() const keyword = searchText.value.trim().toLowerCase()
if (!keyword) return list if (!keyword) return list
return list.filter((bot) => return list.filter((bot) =>
@@ -91,14 +97,14 @@ const filteredBots = computed(() => {
) )
}) })
function handleEdit(bot: BotInfo) { function handleEdit(bot: BotsBot) {
editingBot.value = bot editingBot.value = bot
dialogOpen.value = true dialogOpen.value = true
} }
async function handleDelete(id: string) { async function handleDelete(id: string) {
try { try {
await deleteBot(id) await deleteBot({ path: { id } })
} catch { } catch {
return return
} }
@@ -65,17 +65,19 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { Avatar, AvatarImage, AvatarFallback, ScrollArea } from '@memoh/ui' import { Avatar, AvatarImage, AvatarFallback, ScrollArea } from '@memoh/ui'
import { useBotList, type BotInfo } from '@/composables/api/useBots' import { useQuery } from '@pinia/colada'
import { getBotsQuery } from '@memoh/sdk/colada'
import type { BotsBot } from '@memoh/sdk'
import { useChatStore } from '@/store/chat-list' import { useChatStore } from '@/store/chat-list'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
const chatStore = useChatStore() const chatStore = useChatStore()
const { currentBotId } = storeToRefs(chatStore) const { currentBotId } = storeToRefs(chatStore)
const { data: botData, isLoading } = useBotList() const { data: botData, isLoading } = useQuery(getBotsQuery())
const bots = computed<BotInfo[]>(() => botData.value ?? []) const bots = computed<BotsBot[]>(() => botData.value?.items ?? [])
function handleSelect(bot: BotInfo) { function handleSelect(bot: BotsBot) {
chatStore.selectBot(bot.id) chatStore.selectBot(bot.id)
} }
</script> </script>
+5 -5
View File
@@ -107,11 +107,11 @@ import { useRouter } from 'vue-router'
import { toTypedSchema } from '@vee-validate/zod' import { toTypedSchema } from '@vee-validate/zod'
import { useForm } from 'vee-validate' import { useForm } from 'vee-validate'
import * as z from 'zod' import * as z from 'zod'
import { useUserStore } from '@/store/User' import { useUserStore } from '@/store/user'
import { ref } from 'vue' import { ref } from 'vue'
import { toast } from 'vue-sonner' import { toast } from 'vue-sonner'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { login as loginApi } from '@/composables/api/useAuth' import { postAuthLogin } from '@memoh/sdk'
const router = useRouter() const router = useRouter()
const { t } = useI18n() const { t } = useI18n()
@@ -130,13 +130,13 @@ const loading = ref(false)
const login = form.handleSubmit(async (values) => { const login = form.handleSubmit(async (values) => {
try { try {
loading.value = true loading.value = true
const data = await loginApi(values) const { data } = await postAuthLogin({ body: values })
if (data?.access_token && data?.user_id) { if (data?.access_token && data?.user_id) {
loginHandle({ loginHandle({
id: data.user_id, id: data.user_id,
username: data.username, username: data.username,
displayName: '', displayName: data.display_name ?? '',
role: '', role: data.role ?? '',
}, data.access_token) }, data.access_token)
} else { } else {
throw new Error(t('auth.loginFailed')) throw new Error(t('auth.loginFailed'))
@@ -43,15 +43,15 @@ import {
Button, Button,
} from '@memoh/ui' } from '@memoh/ui'
import ConfirmPopover from '@/components/confirm-popover/index.vue' import ConfirmPopover from '@/components/confirm-popover/index.vue'
import { type ModelInfo } from '@/composables/api/useModels' import type { ModelsGetResponse } from '@memoh/sdk'
defineProps<{ defineProps<{
model: ModelInfo model: ModelsGetResponse
deleteLoading: boolean deleteLoading: boolean
}>() }>()
defineEmits<{ defineEmits<{
edit: [model: ModelInfo] edit: [model: ModelsGetResponse]
delete: [name: string] delete: [name: string]
}>() }>()
</script> </script>
@@ -51,16 +51,16 @@ import {
} from '@memoh/ui' } from '@memoh/ui'
import CreateModel from '@/components/create-model/index.vue' import CreateModel from '@/components/create-model/index.vue'
import ModelItem from './model-item.vue' import ModelItem from './model-item.vue'
import { type ModelInfo } from '@/composables/api/useModels' import type { ModelsGetResponse } from '@memoh/sdk'
defineProps<{ defineProps<{
providerId: string | undefined providerId: string | undefined
models: ModelInfo[] | undefined models: ModelsGetResponse[] | undefined
deleteModelLoading: boolean deleteModelLoading: boolean
}>() }>()
defineEmits<{ defineEmits<{
edit: [model: ModelInfo] edit: [model: ModelsGetResponse]
delete: [name: string] delete: [name: string]
}>() }>()
</script> </script>
@@ -100,10 +100,10 @@ import { computed, watch } from 'vue'
import { toTypedSchema } from '@vee-validate/zod' import { toTypedSchema } from '@vee-validate/zod'
import z from 'zod' import z from 'zod'
import { useForm } from 'vee-validate' import { useForm } from 'vee-validate'
import { type ProviderInfo } from '@/composables/api/useProviders' import type { ProvidersGetResponse } from '@memoh/sdk'
const props = defineProps<{ const props = defineProps<{
provider: Partial<ProviderInfo & { id: string }> | undefined provider: Partial<ProvidersGetResponse> | undefined
editLoading: boolean editLoading: boolean
deleteLoading: boolean deleteLoading: boolean
}>() }>()
+18 -6
View File
@@ -28,20 +28,32 @@ import {
EmptyMedia, EmptyMedia,
EmptyTitle, EmptyTitle,
} from '@memoh/ui' } from '@memoh/ui'
import { type ProviderInfo, CLIENT_TYPES } from '@/composables/api/useProviders' import { getProviders } from '@memoh/sdk'
import type { ProvidersGetResponse, ProvidersClientType } from '@memoh/sdk'
import AddProvider from '@/components/add-provider/index.vue' import AddProvider from '@/components/add-provider/index.vue'
import { useProviderList } from '@/composables/api/useProviders' import { useQuery } from '@pinia/colada'
const CLIENT_TYPES: ProvidersClientType[] = ['openai', 'openai-compat', 'anthropic', 'google', 'ollama']
const filterProvider = ref('') const filterProvider = ref('')
const { data: providerData } = useProviderList(filterProvider) const { data: providerData } = useQuery({
key: () => ['providers', filterProvider.value],
query: async () => {
const { data } = await getProviders({
query: filterProvider.value ? { client_type: filterProvider.value } : undefined,
throwOnError: true,
})
return data
},
})
const queryCache = useQueryCache() const queryCache = useQueryCache()
watch(filterProvider, () => { watch(filterProvider, () => {
queryCache.invalidateQueries({ key: ['provider'] }) queryCache.invalidateQueries({ key: ['providers'] })
}, { immediate: true }) }, { immediate: true })
const curProvider = ref<Partial<ProviderInfo> & { id: string }>() const curProvider = ref<ProvidersGetResponse>()
provide('curProvider', curProvider) provide('curProvider', curProvider)
const selectProvider = (value: string) => computed(() => { const selectProvider = (value: string) => computed(() => {
@@ -58,7 +70,7 @@ const curFilterProvider = computed(() => {
return [] return []
} }
const searchReg = new RegExp([...searchProviderTxt.value].map(v => `\\u{${v.codePointAt(0)?.toString(16)}}`).join(''), 'u') const searchReg = new RegExp([...searchProviderTxt.value].map(v => `\\u{${v.codePointAt(0)?.toString(16)}}`).join(''), 'u')
return providerData.value.filter((provider: Partial<ProviderInfo> & { id: string }) => { return providerData.value.filter((provider: ProvidersGetResponse) => {
return searchReg.test(provider.name as string) return searchReg.test(provider.name as string)
}) })
}) })
+49 -18
View File
@@ -32,22 +32,15 @@ import { Separator } from '@memoh/ui'
import ProviderForm from './components/provider-form.vue' import ProviderForm from './components/provider-form.vue'
import ModelList from './components/model-list.vue' import ModelList from './components/model-list.vue'
import { computed, inject, provide, reactive, ref, toRef, watch } from 'vue' import { computed, inject, provide, reactive, ref, toRef, watch } from 'vue'
import { type ModelInfo } from '@/composables/api/useModels' import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
import { type ProviderInfo } from '@/composables/api/useProviders' import { putProvidersById, deleteProvidersById, getProvidersByIdModels, deleteModelsModelByModelId } from '@memoh/sdk'
import { import type { ModelsGetResponse, ProvidersGetResponse } from '@memoh/sdk'
useUpdateProvider,
useDeleteProvider,
} from '@/composables/api/useProviders'
import {
useModelList,
useDeleteModel,
} from '@/composables/api/useModels'
// ---- Model provide CreateModel ---- // ---- Model provide CreateModel ----
const openModel = reactive<{ const openModel = reactive<{
state: boolean state: boolean
title: 'title' | 'edit' title: 'title' | 'edit'
curState: ModelInfo | null curState: ModelsGetResponse | null
}>({ }>({
state: false, state: false,
title: 'title', title: 'title',
@@ -58,23 +51,61 @@ provide('openModel', toRef(openModel, 'state'))
provide('openModelTitle', toRef(openModel, 'title')) provide('openModelTitle', toRef(openModel, 'title'))
provide('openModelState', toRef(openModel, 'curState')) provide('openModelState', toRef(openModel, 'curState'))
function handleEditModel(model: ModelInfo) { function handleEditModel(model: ModelsGetResponse) {
openModel.state = true openModel.state = true
openModel.title = 'edit' openModel.title = 'edit'
openModel.curState = { ...model } openModel.curState = { ...model }
} }
// ---- Provider ---- // ---- Provider ----
const curProvider = inject('curProvider', ref<Partial<ProviderInfo & { id: string }>>()) const curProvider = inject('curProvider', ref<ProvidersGetResponse>())
const curProviderId = computed(() => curProvider.value?.id) const curProviderId = computed(() => curProvider.value?.id)
// ---- API Hooks ---- // ---- API Hooks ----
const { mutate: deleteProvider, isLoading: deleteLoading } = useDeleteProvider(curProviderId) const queryCache = useQueryCache()
const { mutate: changeProvider, isLoading: editLoading } = useUpdateProvider(curProviderId)
const { mutate: deleteModel, isLoading: deleteModelLoading } = useDeleteModel() const { mutate: deleteProvider, isLoading: deleteLoading } = useMutation({
const { data: modelDataList, invalidate: invalidateModels } = useModelList(curProviderId) mutation: async () => {
if (!curProviderId.value) return
await deleteProvidersById({ path: { id: curProviderId.value }, throwOnError: true })
},
onSettled: () => queryCache.invalidateQueries({ key: ['providers'] }),
})
const { mutate: changeProvider, isLoading: editLoading } = useMutation({
mutation: async (data: Record<string, unknown>) => {
if (!curProviderId.value) return
const { data: result } = await putProvidersById({
path: { id: curProviderId.value },
body: data as any,
throwOnError: true,
})
return result
},
onSettled: () => queryCache.invalidateQueries({ key: ['providers'] }),
})
const { mutate: deleteModel, isLoading: deleteModelLoading } = useMutation({
mutation: async (modelName: string) => {
await deleteModelsModelByModelId({ path: { modelId: modelName }, throwOnError: true })
},
onSettled: () => queryCache.invalidateQueries({ key: ['provider-models'] }),
})
const { data: modelDataList } = useQuery({
key: () => ['provider-models', curProviderId.value ?? ''],
query: async () => {
if (!curProviderId.value) return []
const { data } = await getProvidersByIdModels({
path: { id: curProviderId.value },
throwOnError: true,
})
return data
},
enabled: () => !!curProviderId.value,
})
watch(curProvider, () => { watch(curProvider, () => {
invalidateModels() queryCache.invalidateQueries({ key: ['provider-models'] })
}, { immediate: true }) }, { immediate: true })
</script> </script>
+1 -1
View File
@@ -104,7 +104,7 @@ import {
} from '@memoh/ui' } from '@memoh/ui'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useUserStore } from '../../store/User' import { useUserStore } from '@/store/user'
import { useSettingsStore } from '@/store/settings' import { useSettingsStore } from '@/store/settings'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n'
+5 -1
View File
@@ -144,7 +144,11 @@ importers:
specifier: latest specifier: latest
version: 1.3.8 version: 1.3.8
packages/sdk: {} packages/sdk:
dependencies:
'@pinia/colada':
specifier: '>=0.21.0'
version: 0.21.2(pinia@3.0.4(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3)))(vue@3.5.26(typescript@5.9.3))
packages/ui: packages/ui:
dependencies: dependencies: