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"
}
}
}
}
}`
+377
View File
@@ -192,6 +192,188 @@
}
}
},
"/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": [
@@ -1418,6 +1600,135 @@
}
}
}
},
"/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": {
@@ -1655,6 +1966,50 @@
}
}
},
"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": {
@@ -2105,6 +2460,28 @@
"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"
}
}
}
}
}
+248
View File
@@ -151,6 +151,35 @@ definitions:
username:
type: string
type: object
history.CreateRequest:
properties:
messages:
items:
additionalProperties: true
type: object
type: array
type: object
history.ListResponse:
properties:
items:
items:
$ref: '#/definitions/history.Record'
type: array
type: object
history.Record:
properties:
id:
type: string
messages:
items:
additionalProperties: true
type: object
type: array
timestamp:
type: string
user_id:
type: string
type: object
memory.AddRequest:
properties:
agent_id:
@@ -454,6 +483,20 @@ definitions:
name:
type: string
type: object
settings.Settings:
properties:
language:
type: string
max_context_load_time:
type: integer
type: object
settings.UpsertRequest:
properties:
language:
type: string
max_context_load_time:
type: integer
type: object
info:
contact: {}
paths:
@@ -582,6 +625,126 @@ paths:
summary: Create embeddings
tags:
- embeddings
/history:
delete:
description: Delete all history records for current user
responses:
"204":
description: No Content
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Delete all history records
tags:
- history
get:
description: List history records for current user
parameters:
- description: Limit
in: query
name: limit
type: integer
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'
summary: List history records
tags:
- history
post:
description: Create a history record for current user
parameters:
- description: History payload
in: body
name: payload
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'
summary: Create history record
tags:
- history
/history/{id}:
delete:
description: Delete a history record by ID (must belong to current user)
parameters:
- description: History ID
in: path
name: id
required: true
type: string
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'
summary: Delete history record
tags:
- history
get:
description: Get a history record by ID (must belong to current user)
parameters:
- description: History ID
in: path
name: id
required: true
type: string
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'
summary: Get history record
tags:
- history
/mcp/containers:
post:
parameters:
@@ -1394,4 +1557,89 @@ paths:
summary: Get provider by name
tags:
- providers
/settings:
delete:
description: Remove agent settings for current user
responses:
"204":
description: No Content
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Delete user settings
tags:
- settings
get:
description: Get agent settings for current user
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'
summary: Get user settings
tags:
- settings
post:
description: Update or create agent settings for current user
parameters:
- description: Settings payload
in: body
name: payload
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'
summary: Update user settings
tags:
- settings
put:
description: Update or create agent settings for current user
parameters:
- description: Settings payload
in: body
name: payload
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'
summary: Update user settings
tags:
- settings
swagger: "2.0"