Session manager (#4648)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Douwe Osinga
2025-09-26 14:56:45 -04:00
committed by GitHub
parent d0aa14a1ea
commit dc292883b7
61 changed files with 2895 additions and 5572 deletions
+238 -143
View File
@@ -107,7 +107,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StartAgentResponse"
"$ref": "#/components/schemas/Session"
}
}
}
@@ -185,7 +185,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StartAgentResponse"
"$ref": "#/components/schemas/Session"
}
}
}
@@ -1500,12 +1500,43 @@
]
}
},
"/sessions/insights": {
"get": {
"tags": [
"Session Management"
],
"operationId": "get_session_insights",
"responses": {
"200": {
"description": "Session insights retrieved successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SessionInsights"
}
}
}
},
"401": {
"description": "Unauthorized - Invalid or missing API key"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"api_key": []
}
]
}
},
"/sessions/{session_id}": {
"get": {
"tags": [
"Session Management"
],
"operationId": "get_session_history",
"operationId": "get_session",
"parameters": [
{
"name": "session_id",
@@ -1523,7 +1554,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SessionHistoryResponse"
"$ref": "#/components/schemas/Session"
}
}
}
@@ -1543,6 +1574,93 @@
"api_key": []
}
]
},
"delete": {
"tags": [
"Session Management"
],
"operationId": "delete_session",
"parameters": [
{
"name": "session_id",
"in": "path",
"description": "Unique identifier for the session",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Session deleted successfully"
},
"401": {
"description": "Unauthorized - Invalid or missing API key"
},
"404": {
"description": "Session not found"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"api_key": []
}
]
}
},
"/sessions/{session_id}/description": {
"put": {
"tags": [
"Session Management"
],
"operationId": "update_session_description",
"parameters": [
{
"name": "session_id",
"in": "path",
"description": "Unique identifier for the session",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateSessionDescriptionRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Session description updated successfully"
},
"400": {
"description": "Bad request - Description too long (max 200 characters)"
},
"401": {
"description": "Unauthorized - Invalid or missing API key"
},
"404": {
"description": "Session not found"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"api_key": []
}
]
}
},
"/status": {
@@ -1815,6 +1933,12 @@
}
}
},
"Conversation": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Message"
}
},
"CreateCustomProviderRequest": {
"type": "object",
"required": [
@@ -3426,6 +3550,92 @@
}
}
},
"Session": {
"type": "object",
"required": [
"id",
"working_dir",
"description",
"created_at",
"updated_at",
"extension_data",
"message_count"
],
"properties": {
"accumulated_input_tokens": {
"type": "integer",
"format": "int32",
"nullable": true
},
"accumulated_output_tokens": {
"type": "integer",
"format": "int32",
"nullable": true
},
"accumulated_total_tokens": {
"type": "integer",
"format": "int32",
"nullable": true
},
"conversation": {
"allOf": [
{
"$ref": "#/components/schemas/Conversation"
}
],
"nullable": true
},
"created_at": {
"type": "string"
},
"description": {
"type": "string"
},
"extension_data": {
"$ref": "#/components/schemas/ExtensionData"
},
"id": {
"type": "string"
},
"input_tokens": {
"type": "integer",
"format": "int32",
"nullable": true
},
"message_count": {
"type": "integer",
"minimum": 0
},
"output_tokens": {
"type": "integer",
"format": "int32",
"nullable": true
},
"recipe": {
"allOf": [
{
"$ref": "#/components/schemas/Recipe"
}
],
"nullable": true
},
"schedule_id": {
"type": "string",
"nullable": true
},
"total_tokens": {
"type": "integer",
"format": "int32",
"nullable": true
},
"updated_at": {
"type": "string"
},
"working_dir": {
"type": "string"
}
}
},
"SessionConfigRequest": {
"type": "object",
"required": [
@@ -3507,50 +3717,22 @@
}
}
},
"SessionHistoryResponse": {
"SessionInsights": {
"type": "object",
"required": [
"sessionId",
"metadata",
"messages"
"totalSessions",
"totalTokens"
],
"properties": {
"messages": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Message"
},
"description": "List of messages in the session conversation"
"totalSessions": {
"type": "integer",
"description": "Total number of sessions",
"minimum": 0
},
"metadata": {
"$ref": "#/components/schemas/SessionMetadata"
},
"sessionId": {
"type": "string",
"description": "Unique identifier for the session"
}
}
},
"SessionInfo": {
"type": "object",
"required": [
"id",
"path",
"modified",
"metadata"
],
"properties": {
"id": {
"type": "string"
},
"metadata": {
"$ref": "#/components/schemas/SessionMetadata"
},
"modified": {
"type": "string"
},
"path": {
"type": "string"
"totalTokens": {
"type": "integer",
"format": "int64",
"description": "Total tokens used across all sessions"
}
}
},
@@ -3563,89 +3745,12 @@
"sessions": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SessionInfo"
"$ref": "#/components/schemas/Session"
},
"description": "List of available session information objects"
}
}
},
"SessionMetadata": {
"type": "object",
"description": "Metadata for a session, stored as the first line in the session file",
"required": [
"working_dir",
"description",
"message_count"
],
"properties": {
"accumulated_input_tokens": {
"type": "integer",
"format": "int32",
"description": "The number of input tokens used in the session. Accumulated across all messages.",
"nullable": true
},
"accumulated_output_tokens": {
"type": "integer",
"format": "int32",
"description": "The number of output tokens used in the session. Accumulated across all messages.",
"nullable": true
},
"accumulated_total_tokens": {
"type": "integer",
"format": "int32",
"description": "The total number of tokens used in the session. Accumulated across all messages (useful for tracking cost over an entire session).",
"nullable": true
},
"description": {
"type": "string",
"description": "A short description of the session, typically 3 words or less"
},
"extension_data": {
"$ref": "#/components/schemas/ExtensionData"
},
"input_tokens": {
"type": "integer",
"format": "int32",
"description": "The number of input tokens used in the session. Retrieved from the provider's last usage.",
"nullable": true
},
"message_count": {
"type": "integer",
"description": "Number of messages in the session",
"minimum": 0
},
"output_tokens": {
"type": "integer",
"format": "int32",
"description": "The number of output tokens used in the session. Retrieved from the provider's last usage.",
"nullable": true
},
"recipe": {
"allOf": [
{
"$ref": "#/components/schemas/Recipe"
}
],
"nullable": true
},
"schedule_id": {
"type": "string",
"description": "ID of the schedule that triggered this session, if any",
"nullable": true
},
"total_tokens": {
"type": "integer",
"format": "int32",
"description": "The total number of tokens used in the session. Retrieved from the provider's last usage.",
"nullable": true
},
"working_dir": {
"type": "string",
"description": "Working directory for the session",
"example": "/home/user/sessions/session1"
}
}
},
"SessionsQuery": {
"type": "object",
"properties": {
@@ -3708,28 +3813,6 @@
}
}
},
"StartAgentResponse": {
"type": "object",
"required": [
"session_id",
"metadata",
"messages"
],
"properties": {
"messages": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Message"
}
},
"metadata": {
"$ref": "#/components/schemas/SessionMetadata"
},
"session_id": {
"type": "string"
}
}
},
"SubRecipe": {
"type": "object",
"required": [
@@ -4029,6 +4112,18 @@
}
}
},
"UpdateSessionDescriptionRequest": {
"type": "object",
"required": [
"description"
],
"properties": {
"description": {
"type": "string",
"description": "Updated description (name) for the session (max 200 characters)"
}
}
},
"UpsertConfigQuery": {
"type": "object",
"required": [