feat: user settings & history

This commit is contained in:
Acbox
2026-01-28 15:57:39 +08:00
parent 39215309da
commit 11551b72ab
19 changed files with 1920 additions and 10 deletions
+377
View File
@@ -203,6 +203,188 @@ const docTemplate = `{
}
}
},
"/history": {
"get": {
"description": "List history records for current user",
"tags": [
"history"
],
"summary": "List history records",
"parameters": [
{
"type": "integer",
"description": "Limit",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history.ListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a history record for current user",
"tags": [
"history"
],
"summary": "Create history record",
"parameters": [
{
"description": "History payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history.CreateRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/history.Record"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"delete": {
"description": "Delete all history records for current user",
"tags": [
"history"
],
"summary": "Delete all history records",
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/history/{id}": {
"get": {
"description": "Get a history record by ID (must belong to current user)",
"tags": [
"history"
],
"summary": "Get history record",
"parameters": [
{
"type": "string",
"description": "History ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history.Record"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"delete": {
"description": "Delete a history record by ID (must belong to current user)",
"tags": [
"history"
],
"summary": "Delete history record",
"parameters": [
{
"type": "string",
"description": "History ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/mcp/containers": {
"post": {
"tags": [
@@ -1429,6 +1611,135 @@ const docTemplate = `{
}
}
}
},
"/settings": {
"get": {
"description": "Get agent settings for current user",
"tags": [
"settings"
],
"summary": "Get user settings",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/settings.Settings"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"put": {
"description": "Update or create agent settings for current user",
"tags": [
"settings"
],
"summary": "Update user settings",
"parameters": [
{
"description": "Settings payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/settings.UpsertRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/settings.Settings"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"post": {
"description": "Update or create agent settings for current user",
"tags": [
"settings"
],
"summary": "Update user settings",
"parameters": [
{
"description": "Settings payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/settings.UpsertRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/settings.Settings"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
},
"delete": {
"description": "Remove agent settings for current user",
"tags": [
"settings"
],
"summary": "Delete user settings",
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
}
},
"definitions": {
@@ -1666,6 +1977,50 @@ const docTemplate = `{
}
}
},
"history.CreateRequest": {
"type": "object",
"properties": {
"messages": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
}
},
"history.ListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/history.Record"
}
}
}
},
"history.Record": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"messages": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
},
"timestamp": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"memory.AddRequest": {
"type": "object",
"properties": {
@@ -2116,6 +2471,28 @@ const docTemplate = `{
"type": "string"
}
}
},
"settings.Settings": {
"type": "object",
"properties": {
"language": {
"type": "string"
},
"max_context_load_time": {
"type": "integer"
}
}
},
"settings.UpsertRequest": {
"type": "object",
"properties": {
"language": {
"type": "string"
},
"max_context_load_time": {
"type": "integer"
}
}
}
}
}`