mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
* fix(apiServer): use 127.0.0.1 instead of localhost for better compatibility - Change default host from localhost to 127.0.0.1 in config and settings - Add buildApiServerUrl helper to properly construct API server URLs - Update OpenAPI documentation server URL - Update test files to use 127.0.0.1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(migration): migrate existing localhost config to 127.0.0.1 - Add migration 180 to automatically update localhost to 127.0.0.1 - Handle both plain host and hosts with http/https protocol - Increment store version to 180 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor(apiServer): simplify buildApiServerUrl implementation - Remove complex URL parsing and protocol handling - Use simple string concatenation for URL building - Assume http protocol since API server is local 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: remove buildApiServerUrl helper and simplify migration - Remove buildApiServerUrl helper function - Use 127.0.0.1 directly in URL construction - Simplify migration 180 to unconditionally set host to 127.0.0.1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor(apiServer): fix critical bugs and improve code structure 🔴 Critical Fixes: - Fix config.ts to use stored host value instead of ignoring it - Fix hardcoded 127.0.0.1 URLs to use apiServerConfig.host 🟡 Improvements: - Extract API_SERVER_DEFAULTS to shared constants in packages/shared/config/constant.ts - Apply consistent fallback pattern using API_SERVER_DEFAULTS.HOST and API_SERVER_DEFAULTS.PORT - Update all imports to use shared constants across main and renderer processes Files changed: - packages/shared/config/constant.ts: Add API_SERVER_DEFAULTS constants - src/main/apiServer/config.ts: Use stored host with fallback - src/main/apiServer/middleware/openapi.ts: Use constants - src/renderer/src/pages/settings/ToolSettings/ApiServerSettings/ApiServerSettings.tsx: Use config host and constants - src/renderer/src/store/settings.ts: Use constants in initial state - src/renderer/src/store/migrate.ts: Use constants in migration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * update * fix(apiServer): use relative URL in OpenAPI spec for better compatibility - Change server URL from hardcoded defaults to relative path '/' - This ensures Swagger UI "Try it out" works correctly regardless of configured host/port - Remove unused API_SERVER_DEFAULTS import 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
73 lines
1.8 KiB
HTTP
73 lines
1.8 KiB
HTTP
|
|
@host=http://127.0.0.1:23333
|
|
@token=cs-sk-af798ed4-7cf5-4fd7-ae4b-df203b164194
|
|
@agent_id=agent_1758092281575_tn9dxio9k
|
|
@session_id=session_1758278828236_mqj91e7c0
|
|
|
|
### List Sessions
|
|
GET {{host}}/v1/agents/{{agent_id}}/sessions
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
|
|
### Create Session
|
|
POST {{host}}/v1/agents/{{agent_id}}/sessions
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"name": "Story Writing Session 2",
|
|
"instructions": "You are a creative writing assistant. Help me brainstorm and write engaging stories.",
|
|
"model": "anthropic:claude-sonnet-4",
|
|
"accessible_paths": [
|
|
"/tmp/Documents/stories"
|
|
]
|
|
}
|
|
|
|
### Get Session Details
|
|
GET {{host}}/v1/agents/{{agent_id}}/sessions/{{session_id}}
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
### Delete Session
|
|
DELETE {{host}}/v1/agents/{{agent_id}}/sessions/{{session_id}}
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
### Full Update Session
|
|
PUT {{host}}/v1/agents/{{agent_id}}/sessions/{{session_id}}
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"name": "Story Writing Session 2",
|
|
"instructions": "You are a creative writing assistant. Help me brainstorm and write engaging stories.",
|
|
"model": "anthropic:claude-sonnet-4",
|
|
"accessible_paths": [
|
|
"/tmp/Documents/stories"
|
|
]
|
|
}
|
|
|
|
|
|
### Partial Update Session
|
|
PATCH {{host}}/v1/agents/{{agent_id}}/sessions/{{session_id}}
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"model": "anthropic:claude-sonnet-4-20250514",
|
|
"accessible_paths": [
|
|
"/tmp/Documents/stories2"
|
|
]
|
|
}
|
|
|
|
|
|
### Create Session Message
|
|
POST {{host}}/v1/agents/{{agent_id}}/sessions/{{session_id}}/messages
|
|
Authorization: Bearer {{token}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"content": "Write a short story about a robot learning to love."
|
|
}
|