From d332321138ea3a4ec7bf6046c8ca7cddb4a6ea9a Mon Sep 17 00:00:00 2001 From: doria <93405247+dr-frmr@users.noreply.github.com> Date: Tue, 24 Jun 2025 10:45:55 -0400 Subject: [PATCH] chore: update api routes to /v2 (#138) * chore: update api routes to /v2 * chore: undo erroneous uv.lock update * chore: update openapi.json --- CHANGELOG.md | 1 + CLAUDE.md | 2 +- docs/openapi.json | 5369 ++++++++++++--------------- src/main.py | 14 +- tests/routes/test_keys.py | 12 +- tests/routes/test_messages.py | 48 +- tests/routes/test_peers.py | 82 +- tests/routes/test_scoped_api.py | 40 +- tests/routes/test_sessions.py | 136 +- tests/routes/test_validation_api.py | 46 +- tests/routes/test_workspaces.py | 44 +- 11 files changed, 2598 insertions(+), 3196 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc115fe..c57cfcdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- API route is now /v2/ - New architecture centered around the concept of a "peer" replaces the former "app"/"user"/"session" paradigm - Workspaces replace "apps" as top-level namespace diff --git a/CLAUDE.md b/CLAUDE.md index 6bb26342..e3791a2c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -29,7 +29,7 @@ Honcho uses a peer-based model where both users and agents are represented as "p ## Architecture Overview ### API Structure -All API routes follow the pattern: `/v1/{resource}/{id}/{action}` +All API routes follow the pattern: `/v2/{resource}/{id}/{action}` - **Workspaces**: Create, list, update, search - **Peers**: Create, list, update, chat (dialectic), messages, representation - **Sessions**: Create, list, update, delete, clone, manage peers, get context diff --git a/docs/openapi.json b/docs/openapi.json index f925911b..68388796 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -9,46 +9,55 @@ "url": "https://honcho.dev/", "email": "hello@plasticlabs.ai" }, - "version": "1.1.0" + "license": { + "name": "GNU Affero General Public License v3.0", + "identifier": "AGPL-3.0-only", + "url": "https://github.com/plastic-labs/honcho/blob/main/LICENSE" + }, + "version": "2.0.0" }, "servers": [ { "url": "http://localhost:8000", "description": "Local Development Server" }, - { "url": "https://demo.honcho.dev", "description": "Demo Server" }, + { + "url": "https://demo.honcho.dev", + "description": "Demo Server" + }, { "url": "https://api.honcho.dev", "description": "Production SaaS Platform" } ], "paths": { - "/v1/apps": { - "get": { - "tags": ["apps"], - "summary": "Get App", - "description": "Get an App by ID.\n\nIf app_id is provided as a query parameter, it uses that (must match JWT app_id).\nOtherwise, it uses the app_id from the JWT token.", - "operationId": "get_app_v1_apps_get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "App ID to retrieve. If not provided, uses JWT token", - "title": "App Id" - }, - "description": "App ID to retrieve. If not provided, uses JWT token" - } + "/v2/workspaces": { + "post": { + "tags": [ + "workspaces" ], + "summary": "Get Or Create Workspace", + "description": "Get a Workspace by ID.\n\nIf workspace_id is provided as a query parameter, it uses that (must match JWT workspace_id).\nOtherwise, it uses the workspace_id from the JWT token.", + "operationId": "get_or_create_workspace_v2_workspaces_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkspaceCreate", + "description": "Workspace creation parameters" + } + } + }, + "required": true + }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/App" } + "schema": { + "$ref": "#/components/schemas/Workspace" + } } } }, @@ -56,35 +65,140 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } }, - "x-codeSamples": [ + "security": [ { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const app = await client.apps.get();\n\n console.log(app.id);\n}\n\nmain();" + "HTTPBearer": [] + }, + {} + ] + } + }, + "/v2/workspaces/list": { + "post": { + "tags": [ + "workspaces" + ], + "summary": "Get All Workspaces", + "description": "Get all Workspaces", + "operationId": "get_all_workspaces_v2_workspaces_list_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "description": "Page number", + "default": 1, + "title": "Page" + }, + "description": "Page number" }, { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\napp = client.apps.get()\nprint(app.id)" + "name": "size", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "description": "Page size", + "default": 50, + "title": "Size" + }, + "description": "Page size" } - ] - }, - "post": { - "tags": ["apps"], - "summary": "Create App", - "description": "Create a new App", - "operationId": "create_app_v1_apps_post", - "security": [{ "HTTPBearer": [] }, {}], + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/WorkspaceGet" + }, + { + "type": "null" + } + ], + "description": "Filtering and pagination options for the workspaces list", + "title": "Options" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_Workspace_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}": { + "put": { + "tags": [ + "workspaces" + ], + "summary": "Update Workspace", + "description": "Update a Workspace", + "operationId": "update_workspace_v2_workspaces__workspace_id__put", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace to update", + "title": "Workspace Id" + }, + "description": "ID of the workspace to update" + } + ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AppCreate", - "description": "App creation parameters" + "$ref": "#/components/schemas/WorkspaceUpdate", + "description": "Updated workspace parameters" } } } @@ -94,7 +208,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/App" } + "schema": { + "$ref": "#/components/schemas/Workspace" + } } } }, @@ -102,37 +218,643 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/search": { + "post": { + "tags": [ + "workspaces" + ], + "summary": "Search Workspace", + "description": "Search a Workspace", + "operationId": "search_workspace_v2_workspaces__workspace_id__search_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace to search", + "title": "Workspace Id" + }, + "description": "ID of the workspace to search" + }, + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "description": "Page number", + "default": 1, + "title": "Page" + }, + "description": "Page number" + }, + { + "name": "size", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "description": "Page size", + "default": 50, + "title": "Size" + }, + "description": "Page size" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "string", + "description": "Search query", + "title": "Query" } } } }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const app = await client.apps.create({ name: 'x' });\n\n console.log(app.id);\n}\n\nmain();" + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_Message_" + } + } + } }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\napp = client.apps.create(\n name=\"x\",\n)\nprint(app.id)" + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } } - ] + } } }, - "/v1/apps/list": { + "/v2/workspaces/{workspace_id}/peers/list": { "post": { - "tags": ["apps"], - "summary": "Get All Apps", - "description": "Get all Apps", - "operationId": "get_all_apps_v1_apps_list_post", - "security": [{ "HTTPBearer": [] }, {}], + "tags": [ + "peers" + ], + "summary": "Get Peers", + "description": "Get All Peers for a Workspace", + "operationId": "get_peers_v2_workspaces__workspace_id__peers_list_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "description": "Page number", + "default": 1, + "title": "Page" + }, + "description": "Page number" + }, + { + "name": "size", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "description": "Page size", + "default": 50, + "title": "Size" + }, + "description": "Page size" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/PeerGet" + }, + { + "type": "null" + } + ], + "description": "Filtering options for the peers list", + "title": "Options" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_Peer_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/peers": { + "post": { + "tags": [ + "peers" + ], + "summary": "Get Or Create Peer", + "description": "Get a Peer by ID\n\nIf peer_id is provided as a query parameter, it uses that (must match JWT workspace_id).\nOtherwise, it uses the peer_id from the JWT token.", + "operationId": "get_or_create_peer_v2_workspaces__workspace_id__peers_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PeerCreate", + "description": "Peer creation parameters" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Peer" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/peers/{peer_id}": { + "put": { + "tags": [ + "peers" + ], + "summary": "Update Peer", + "description": "Update a Peer's name and/or metadata", + "operationId": "update_peer_v2_workspaces__workspace_id__peers__peer_id__put", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer to update", + "title": "Peer Id" + }, + "description": "ID of the peer to update" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PeerUpdate", + "description": "Updated peer parameters" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Peer" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/peers/{peer_id}/sessions": { + "post": { + "tags": [ + "peers" + ], + "summary": "Get Sessions For Peer", + "description": "Get All Sessions for a Peer", + "operationId": "get_sessions_for_peer_v2_workspaces__workspace_id__peers__peer_id__sessions_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" + }, + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "description": "Page number", + "default": 1, + "title": "Page" + }, + "description": "Page number" + }, + { + "name": "size", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "description": "Page size", + "default": 50, + "title": "Size" + }, + "description": "Page size" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/SessionGet" + }, + { + "type": "null" + } + ], + "description": "Filtering options for the sessions list", + "title": "Options" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_Session_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/peers/{peer_id}/chat": { + "post": { + "tags": [ + "peers" + ], + "summary": "Chat", + "operationId": "chat_v2_workspaces__workspace_id__peers__peer_id__chat_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DialecticOptions", + "description": "Dialectic Endpoint Parameters" + } + } + } + }, + "responses": { + "200": { + "description": "Response to a question informed by Honcho's User Representation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DialecticResponse" + } + }, + "text/event-stream": {} + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/peers/{peer_id}/messages": { + "post": { + "tags": [ + "peers" + ], + "summary": "Create Messages For Peer", + "description": "Create messages for a peer", + "operationId": "create_messages_for_peer_v2_workspaces__workspace_id__peers__peer_id__messages_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MessageBatchCreate", + "description": "Batch of messages to create" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Message" + }, + "title": "Response Create Messages For Peer V2 Workspaces Workspace Id Peers Peer Id Messages Post" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/peers/{peer_id}/messages/list": { + "post": { + "tags": [ + "peers" + ], + "summary": "Get Messages For Peer", + "description": "Get all messages for a peer", + "operationId": "get_messages_for_peer_v2_workspaces__workspace_id__peers__peer_id__messages_list_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" + }, { "name": "reverse", "in": "query", "required": false, "schema": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], "description": "Whether to reverse the order of results", "default": false, "title": "Reverse" @@ -172,10 +894,14 @@ "application/json": { "schema": { "anyOf": [ - { "$ref": "#/components/schemas/AppGet" }, - { "type": "null" } + { + "$ref": "#/components/schemas/MessageGet" + }, + { + "type": "null" + } ], - "description": "Filtering and pagination options for the apps list", + "description": "Filtering options for the messages list", "title": "Options" } } @@ -186,7 +912,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Page_App_" } + "schema": { + "$ref": "#/components/schemas/Page_Message_" + } } } }, @@ -194,141 +922,51 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const app of client.apps.list()) {\n console.log(app.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.list()\npage = page.items[0]\nprint(page.id)" - } - ] + } } }, - "/v1/apps/name/{name}": { - "get": { - "tags": ["apps"], - "summary": "Get App By Name", - "description": "Get an App by Name", - "operationId": "get_app_by_name_v1_apps_name__name__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Name of the app to retrieve", - "title": "Name" - }, - "description": "Name of the app to retrieve" - } + "/v2/workspaces/{workspace_id}/peers/{peer_id}/representation": { + "post": { + "tags": [ + "peers" ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/App" } - } - } + "summary": "Get Working Representation", + "description": "Get a peer's working representation for a session.\n\nIf a session_id is provided in the body, we get the working representation of the peer in that session.\n\nIn the current implementation, we don't offer representations of `target` so that parameter is ignored.\nFuture releases will allow for this.", + "operationId": "get_working_representation_v2_workspaces__workspace_id__peers__peer_id__representation_post", + "security": [ + { + "HTTPBearer": [] }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const app = await client.apps.getByName('name');\n\n console.log(app.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\napp = client.apps.get_by_name(\n \"name\",\n)\nprint(app.id)" - } - ] - } - }, - "/v1/apps/get_or_create/{name}": { - "get": { - "tags": ["apps"], - "summary": "Get Or Create App", - "description": "Get or Create an App", - "operationId": "get_or_create_app_v1_apps_get_or_create__name__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Name of the app to get or create", - "title": "Name" - }, - "description": "Name of the app to get or create" - } + {} ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/App" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const app = await client.apps.getOrCreate('name');\n\n console.log(app.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\napp = client.apps.get_or_create(\n \"name\",\n)\nprint(app.id)" - } - ] - } - }, - "/v1/apps/{app_id}": { - "put": { - "tags": ["apps"], - "summary": "Update App", - "description": "Update an App", - "operationId": "update_app_v1_apps__app_id__put", - "security": [{ "HTTPBearer": [] }, {}], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app to update", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app to update" + "description": "ID of the workspace" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" } ], "requestBody": { @@ -336,8 +974,8 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AppUpdate", - "description": "Updated app parameters" + "$ref": "#/components/schemas/PeerRepresentationGet", + "description": "Options for getting the peer representation" } } } @@ -347,7 +985,11 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/App" } + "schema": { + "type": "object", + "additionalProperties": true, + "title": "Response Get Working Representation V2 Workspaces Workspace Id Peers Peer Id Representation Post" + } } } }, @@ -355,173 +997,51 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const app = await client.apps.update('app_id');\n\n console.log(app.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\napp = client.apps.update(\n app_id=\"app_id\",\n)\nprint(app.id)" - } - ] + } } }, - "/v1/apps/{app_id}/users": { + "/v2/workspaces/{workspace_id}/peers/{peer_id}/search": { "post": { - "tags": ["users"], - "summary": "Create User", - "description": "Create a new User", - "operationId": "create_user_v1_apps__app_id__users_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - } + "tags": [ + "peers" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserCreate", - "description": "User creation parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/User" } - } - } + "summary": "Search Peer", + "description": "Search a Peer", + "operationId": "search_peer_v2_workspaces__workspace_id__peers__peer_id__search_post", + "security": [ + { + "HTTPBearer": [] }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const user = await client.apps.users.create('app_id', { name: 'x' });\n\n console.log(user.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nuser = client.apps.users.create(\n app_id=\"app_id\",\n name=\"x\",\n)\nprint(user.id)" - } - ] - }, - "get": { - "tags": ["users"], - "summary": "Get User", - "description": "Get a User by ID\n\nIf user_id is provided as a query parameter, it uses that (must match JWT app_id).\nOtherwise, it uses the user_id from the JWT token.", - "operationId": "get_user_v1_apps__app_id__users_get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "User ID to retrieve. If not provided, users JWT token", - "title": "User Id" - }, - "description": "User ID to retrieve. If not provided, users JWT token" - } + {} ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/User" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const user = await client.apps.users.get('app_id');\n\n console.log(user.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nuser = client.apps.users.get(\n app_id=\"app_id\",\n)\nprint(user.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/list": { - "post": { - "tags": ["users"], - "summary": "Get Users", - "description": "Get All Users for an App", - "operationId": "get_users_v1_apps__app_id__users_list_post", - "security": [{ "HTTPBearer": [] }, {}], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" + "description": "ID of the workspace" }, { - "name": "reverse", - "in": "query", - "required": false, + "name": "peer_id", + "in": "path", + "required": true, "schema": { - "type": "boolean", - "description": "Whether to reverse the order of results", - "default": false, - "title": "Reverse" + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" }, - "description": "Whether to reverse the order of results" + "description": "ID of the peer" }, { "name": "page", @@ -551,210 +1071,14 @@ "description": "Page size" } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "anyOf": [ - { "$ref": "#/components/schemas/UserGet" }, - { "type": "null" } - ], - "description": "Filtering options for the users list", - "title": "Options" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Page_User_" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const user of client.apps.users.list('app_id')) {\n console.log(user.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.users.list(\n app_id=\"app_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/name/{name}": { - "get": { - "tags": ["users"], - "summary": "Get User By Name", - "description": "Get a User by name", - "operationId": "get_user_by_name_v1_apps__app_id__users_name__name__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Name of the user to retrieve", - "title": "Name" - }, - "description": "Name of the user to retrieve" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/User" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const user = await client.apps.users.getByName('app_id', 'name');\n\n console.log(user.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nuser = client.apps.users.get_by_name(\n name=\"name\",\n app_id=\"app_id\",\n)\nprint(user.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/get_or_create/{name}": { - "get": { - "tags": ["users"], - "summary": "Get Or Create User", - "description": "Get a User or create a new one by the input name", - "operationId": "get_or_create_user_v1_apps__app_id__users_get_or_create__name__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Name of the user to get or create", - "title": "Name" - }, - "description": "Name of the user to get or create" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/User" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const user = await client.apps.users.getOrCreate('app_id', 'name');\n\n console.log(user.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nuser = client.apps.users.get_or_create(\n name=\"name\",\n app_id=\"app_id\",\n)\nprint(user.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}": { - "put": { - "tags": ["users"], - "summary": "Update User", - "description": "Update a User's name and/or metadata", - "operationId": "update_user_v1_apps__app_id__users__user_id__put", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user to update", - "title": "User Id" - }, - "description": "ID of the user to update" - } - ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UserUpdate", - "description": "Updated user parameters" + "type": "string", + "description": "Search query", + "title": "Query" } } } @@ -764,7 +1088,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/User" } + "schema": { + "$ref": "#/components/schemas/Page_Message_" + } } } }, @@ -772,122 +1098,40 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const user = await client.apps.users.update('app_id', 'user_id');\n\n console.log(user.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nuser = client.apps.users.update(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\nprint(user.id)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions": { - "get": { - "tags": ["sessions"], - "summary": "Get Session", - "description": "Get a specific session for a user.\n\nIf session_id is provided as a query parameter, it uses that (must match JWT session_id).\nOtherwise, it uses the session_id from the JWT token.", - "operationId": "get_session_v1_apps__app_id__users__user_id__sessions_get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "session_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "Session ID to retrieve. If not provided, uses JWT token", - "title": "Session Id" - }, - "description": "Session ID to retrieve. If not provided, uses JWT token" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Session" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const session = await client.apps.users.sessions.get('app_id', 'user_id');\n\n console.log(session.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nsession = client.apps.users.sessions.get(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\nprint(session.id)" - } - ] - }, + "/v2/workspaces/{workspace_id}/sessions": { "post": { - "tags": ["sessions"], - "summary": "Create Session", - "description": "Create a Session for a User", - "operationId": "create_session_v1_apps__app_id__users__user_id__sessions_post", - "security": [{ "HTTPBearer": [] }, {}], + "tags": [ + "sessions" + ], + "summary": "Get Or Create Session", + "description": "Get a specific session in a workspace.\n\nIf session_id is provided as a query parameter, it verifies the session is in the workspace.\nOtherwise, it uses the session_id from the JWT token for verification.", + "operationId": "get_or_create_session_v2_workspaces__workspace_id__sessions_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" } ], "requestBody": { @@ -906,7 +1150,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Session" } + "schema": { + "$ref": "#/components/schemas/Session" + } } } }, @@ -914,64 +1160,40 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const session = await client.apps.users.sessions.create('app_id', 'user_id');\n\n console.log(session.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nsession = client.apps.users.sessions.create(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\nprint(session.id)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions/list": { + "/v2/workspaces/{workspace_id}/sessions/list": { "post": { - "tags": ["sessions"], + "tags": [ + "sessions" + ], "summary": "Get Sessions", - "description": "Get All Sessions for a User", - "operationId": "get_sessions_v1_apps__app_id__users__user_id__sessions_list_post", - "security": [{ "HTTPBearer": [] }, {}], + "description": "Get All Sessions in a Workspace", + "operationId": "get_sessions_v2_workspaces__workspace_id__sessions_list_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "reverse", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "description": "Whether to reverse the order of results", - "default": false, - "title": "Reverse" - }, - "description": "Whether to reverse the order of results" + "description": "ID of the workspace" }, { "name": "page", @@ -1006,8 +1228,12 @@ "application/json": { "schema": { "anyOf": [ - { "$ref": "#/components/schemas/SessionGet" }, - { "type": "null" } + { + "$ref": "#/components/schemas/SessionGet" + }, + { + "type": "null" + } ], "description": "Filtering and pagination options for the sessions list", "title": "Options" @@ -1020,7 +1246,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Page_Session_" } + "schema": { + "$ref": "#/components/schemas/Page_Session_" + } } } }, @@ -1028,52 +1256,40 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const session of client.apps.users.sessions.list('app_id', 'user_id')) {\n console.log(session.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.users.sessions.list(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}": { + "/v2/workspaces/{workspace_id}/sessions/{session_id}": { "put": { - "tags": ["sessions"], + "tags": [ + "sessions" + ], "summary": "Update Session", "description": "Update the metadata of a Session", - "operationId": "update_session_v1_apps__app_id__users__user_id__sessions__session_id__put", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "update_session_v2_workspaces__workspace_id__sessions__session_id__put", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1103,7 +1319,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Session" } + "schema": { + "$ref": "#/components/schemas/Session" + } } } }, @@ -1111,50 +1329,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const session = await client.apps.users.sessions.update('app_id', 'user_id', 'session_id', {\n metadata: { foo: 'bar' },\n });\n\n console.log(session.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nsession = client.apps.users.sessions.update(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n metadata={\n \"foo\": \"bar\"\n },\n)\nprint(session.id)" - } - ] + } }, "delete": { - "tags": ["sessions"], + "tags": [ + "sessions" + ], "summary": "Delete Session", "description": "Delete a session by marking it as inactive", - "operationId": "delete_session_v1_apps__app_id__users__user_id__sessions__session_id__delete", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "delete_session_v2_workspaces__workspace_id__sessions__session_id__delete", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1171,142 +1377,50 @@ "responses": { "200": { "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": {} } } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const session = await client.apps.users.sessions.delete('app_id', 'user_id', 'session_id');\n\n console.log(session);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nsession = client.apps.users.sessions.delete(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(session)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/chat": { - "post": { - "tags": ["sessions"], - "summary": "Chat", - "description": "Chat with the Dialectic API", - "operationId": "chat_v1_apps__app_id__users__user_id__sessions__session_id__chat_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the session", - "title": "Session Id" - }, - "description": "ID of the session" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DialecticOptions", - "description": "Dialectic Endpoint Parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Response to a question informed by Honcho's User Representation", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/DialecticResponse" } - }, - "text/event-stream": {} - } }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const dialecticResponse = await client.apps.users.sessions.chat('app_id', 'user_id', 'session_id', {\n queries: 'string',\n });\n\n console.log(dialecticResponse.content);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ndialectic_response = client.apps.users.sessions.chat(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n queries=\"string\",\n)\nprint(dialectic_response.content)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/clone": { + "/v2/workspaces/{workspace_id}/sessions/{session_id}/clone": { "get": { - "tags": ["sessions"], + "tags": [ + "sessions" + ], "summary": "Clone Session", "description": "Clone a session, optionally up to a specific message", - "operationId": "clone_session_v1_apps__app_id__users__user_id__sessions__session_id__clone_get", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "clone_session_v2_workspaces__workspace_id__sessions__session_id__clone_get", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1324,23 +1438,18 @@ "in": "query", "required": false, "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], "description": "Message ID to cut off the clone at", "title": "Message Id" }, "description": "Message ID to cut off the clone at" - }, - { - "name": "deep_copy", - "in": "query", - "required": false, - "schema": { - "type": "boolean", - "description": "Whether to deep copy metamessages", - "default": false, - "title": "Deep Copy" - }, - "description": "Whether to deep copy metamessages" } ], "responses": { @@ -1348,7 +1457,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Session" } + "schema": { + "$ref": "#/components/schemas/Session" + } } } }, @@ -1356,52 +1467,40 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const session = await client.apps.users.sessions.clone('app_id', 'user_id', 'session_id');\n\n console.log(session.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nsession = client.apps.users.sessions.clone(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(session.id)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages": { + "/v2/workspaces/{workspace_id}/sessions/{session_id}/peers": { "post": { - "tags": ["messages"], - "summary": "Create Message For Session", - "description": "Adds a message to a session", - "operationId": "create_message_for_session_v1_apps__app_id__users__user_id__sessions__session_id__messages_post", - "security": [{ "HTTPBearer": [] }, {}], + "tags": [ + "sessions" + ], + "summary": "Add Peers To Session", + "description": "Add peers to a session", + "operationId": "add_peers_to_session_v2_workspaces__workspace_id__sessions__session_id__peers_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1420,8 +1519,12 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MessageCreate", - "description": "Message creation parameters" + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/SessionPeerConfig" + }, + "description": "List of peer IDs to add to the session", + "title": "Peers" } } } @@ -1431,7 +1534,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Message" } + "schema": { + "$ref": "#/components/schemas/Session" + } } } }, @@ -1439,52 +1544,622 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "put": { + "tags": [ + "sessions" + ], + "summary": "Set Session Peers", + "description": "Set the peers in a session", + "operationId": "set_session_peers_v2_workspaces__workspace_id__sessions__session_id__peers_put", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the session", + "title": "Session Id" + }, + "description": "ID of the session" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/SessionPeerConfig" + }, + "description": "List of peer IDs to set for the session", + "title": "Peers" } } } }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const message = await client.apps.users.sessions.messages.create('app_id', 'user_id', 'session_id', {\n content: 'content',\n is_user: true,\n });\n\n console.log(message.id);\n}\n\nmain();" + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Session" + } + } + } }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmessage = client.apps.users.sessions.messages.create(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n content=\"content\",\n is_user=True,\n)\nprint(message.id)" + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch": { - "post": { - "tags": ["messages"], - "summary": "Create Batch Messages For Session", - "description": "Bulk create messages for a session while maintaining order. Maximum 100 messages per batch.", - "operationId": "create_batch_messages_for_session_v1_apps__app_id__users__user_id__sessions__session_id__messages_batch_post", - "security": [{ "HTTPBearer": [] }, {}], + } + }, + "delete": { + "tags": [ + "sessions" + ], + "summary": "Remove Peers From Session", + "description": "Remove peers from a session", + "operationId": "remove_peers_from_session_v2_workspaces__workspace_id__sessions__session_id__peers_delete", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" + "description": "ID of the workspace" }, { - "name": "user_id", + "name": "session_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the user", - "title": "User Id" + "description": "ID of the session", + "title": "Session Id" }, - "description": "ID of the user" + "description": "ID of the session" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of peer IDs to remove from the session", + "title": "Peers" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Session" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "get": { + "tags": [ + "sessions" + ], + "summary": "Get Session Peers", + "description": "Get peers from a session", + "operationId": "get_session_peers_v2_workspaces__workspace_id__sessions__session_id__peers_get", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the session", + "title": "Session Id" + }, + "description": "ID of the session" + }, + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "description": "Page number", + "default": 1, + "title": "Page" + }, + "description": "Page number" + }, + { + "name": "size", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "description": "Page size", + "default": 50, + "title": "Size" + }, + "description": "Page size" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_Peer_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/sessions/{session_id}/peers/{peer_id}/config": { + "get": { + "tags": [ + "sessions" + ], + "summary": "Get Peer Config", + "description": "Get the configuration for a peer in a session", + "operationId": "get_peer_config_v2_workspaces__workspace_id__sessions__session_id__peers__peer_id__config_get", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the session", + "title": "Session Id" + }, + "description": "ID of the session" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SessionPeerConfig" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "post": { + "tags": [ + "sessions" + ], + "summary": "Set Peer Config", + "description": "Set the configuration for a peer in a session", + "operationId": "set_peer_config_v2_workspaces__workspace_id__sessions__session_id__peers__peer_id__config_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the session", + "title": "Session Id" + }, + "description": "ID of the session" + }, + { + "name": "peer_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the peer", + "title": "Peer Id" + }, + "description": "ID of the peer" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SessionPeerConfig", + "description": "Peer configuration" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/sessions/{session_id}/context": { + "get": { + "tags": [ + "sessions" + ], + "summary": "Get Session Context", + "description": "Produce a context object from the session. The caller provides a token limit which the entire context must fit into.\nTo do this, we allocate 40% of the token limit to the summary, and 60% to recent messages -- as many as can fit.\nIf the caller does not want a summary, we allocate all the tokens to recent messages.\nThe default token limit if not provided is 2048. (TODO: make this configurable)", + "operationId": "get_session_context_v2_workspaces__workspace_id__sessions__session_id__context_get", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the session", + "title": "Session Id" + }, + "description": "ID of the session" + }, + { + "name": "tokens", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Number of tokens to use for the context. Includes summary if set to true", + "title": "Tokens" + }, + "description": "Number of tokens to use for the context. Includes summary if set to true" + }, + { + "name": "summary", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "description": "Whether to summarize the session history prior to the cutoff message", + "default": false, + "title": "Summary" + }, + "description": "Whether to summarize the session history prior to the cutoff message" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SessionContext" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/sessions/{session_id}/search": { + "post": { + "tags": [ + "sessions" + ], + "summary": "Search Session", + "description": "Search a Session", + "operationId": "search_session_v2_workspaces__workspace_id__sessions__session_id__search_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the session", + "title": "Session Id" + }, + "description": "ID of the session" + }, + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "description": "Page number", + "default": 1, + "title": "Page" + }, + "description": "Page number" + }, + { + "name": "size", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "description": "Page size", + "default": 50, + "title": "Size" + }, + "description": "Page size" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "string", + "description": "Search query", + "title": "Query" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_Message_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/": { + "post": { + "tags": [ + "messages" + ], + "summary": "Create Messages For Session", + "operationId": "create_messages_for_session_v2_workspaces__workspace_id__sessions__session_id__messages__post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], + "parameters": [ + { + "name": "workspace_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "ID of the workspace", + "title": "Workspace Id" + }, + "description": "ID of the workspace" }, { "name": "session_id", @@ -1516,8 +2191,10 @@ "application/json": { "schema": { "type": "array", - "items": { "$ref": "#/components/schemas/Message" }, - "title": "Response Create Batch Messages For Session V1 Apps App Id Users User Id Sessions Session Id Messages Batch Post" + "items": { + "$ref": "#/components/schemas/Message" + }, + "title": "Response Create Messages For Session V2 Workspaces Workspace Id Sessions Session Id Messages Post" } } } @@ -1526,52 +2203,40 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const messages = await client.apps.users.sessions.messages.batch('app_id', 'user_id', 'session_id', {\n messages: [{ content: 'content', is_user: true }],\n });\n\n console.log(messages);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmessages = client.apps.users.sessions.messages.batch(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n messages=[{\n \"content\": \"content\",\n \"is_user\": True,\n }],\n)\nprint(messages)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/list": { + "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/list": { "post": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Messages", "description": "Get all messages for a session", - "operationId": "get_messages_v1_apps__app_id__users__user_id__sessions__session_id__messages_list_post", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "get_messages_v2_workspaces__workspace_id__sessions__session_id__messages_list_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1589,7 +2254,14 @@ "in": "query", "required": false, "schema": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], "description": "Whether to reverse the order of results", "default": false, "title": "Reverse" @@ -1629,8 +2301,12 @@ "application/json": { "schema": { "anyOf": [ - { "$ref": "#/components/schemas/MessageGet" }, - { "type": "null" } + { + "$ref": "#/components/schemas/MessageGet" + }, + { + "type": "null" + } ], "description": "Filtering options for the messages list", "title": "Options" @@ -1643,7 +2319,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Page_Message_" } + "schema": { + "$ref": "#/components/schemas/Page_Message_" + } } } }, @@ -1651,52 +2329,40 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const message of client.apps.users.sessions.messages.list('app_id', 'user_id', 'session_id')) {\n console.log(message.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.users.sessions.messages.list(\n session_id=\"session_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}": { + "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/{message_id}": { "get": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Get Message", "description": "Get a Message by ID", - "operationId": "get_message_v1_apps__app_id__users__user_id__sessions__session_id__messages__message_id__get", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "get_message_v2_workspaces__workspace_id__sessions__session_id__messages__message_id__get", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1726,7 +2392,9 @@ "description": "Successful Response", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/Message" } + "schema": { + "$ref": "#/components/schemas/Message" + } } } }, @@ -1734,50 +2402,38 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const message = await client.apps.users.sessions.messages.get(\n 'app_id',\n 'user_id',\n 'session_id',\n 'message_id',\n );\n\n console.log(message.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmessage = client.apps.users.sessions.messages.get(\n message_id=\"message_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n session_id=\"session_id\",\n)\nprint(message.id)" - } - ] + } }, "put": { - "tags": ["messages"], + "tags": [ + "messages" + ], "summary": "Update Message", "description": "Update the metadata of a Message", - "operationId": "update_message_v1_apps__app_id__users__user_id__sessions__session_id__messages__message_id__put", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "update_message_v2_workspaces__workspace_id__sessions__session_id__messages__message_id__put", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "path", "required": true, "schema": { "type": "string", - "description": "ID of the app", - "title": "App Id" + "description": "ID of the workspace", + "title": "Workspace Id" }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" + "description": "ID of the workspace" }, { "name": "session_id", @@ -1813,1291 +2469,13 @@ } } }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Message" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const message = await client.apps.users.sessions.messages.update(\n 'app_id',\n 'user_id',\n 'session_id',\n 'message_id',\n { metadata: { foo: 'bar' } },\n );\n\n console.log(message.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmessage = client.apps.users.sessions.messages.update(\n message_id=\"message_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n session_id=\"session_id\",\n metadata={\n \"foo\": \"bar\"\n },\n)\nprint(message.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/metamessages": { - "post": { - "tags": ["metamessages"], - "summary": "Create Metamessage", - "description": "Create a new metamessage associated with a user.\nOptionally link to a session and message by providing those IDs in the request body.", - "operationId": "create_metamessage_v1_apps__app_id__users__user_id__metamessages_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MetamessageCreate", - "description": "Metamessage creation parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Metamessage" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const metamessage = await client.apps.users.metamessages.create('app_id', 'user_id', {\n content: 'content',\n metamessage_type: 'x',\n });\n\n console.log(metamessage.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmetamessage = client.apps.users.metamessages.create(\n user_id=\"user_id\",\n app_id=\"app_id\",\n content=\"content\",\n metamessage_type=\"x\",\n)\nprint(metamessage.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/metamessages/list": { - "post": { - "tags": ["metamessages"], - "summary": "Get Metamessages", - "description": "Get metamessages with flexible filtering.\n\n- Filter by user only: No additional parameters needed\n- Filter by session: Provide session_id\n- Filter by message: Provide message_id (and session_id)\n- Filter by type: Provide label\n- Filter by metadata: Provide filter object", - "operationId": "get_metamessages_v1_apps__app_id__users__user_id__metamessages_list_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "reverse", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "description": "Whether to reverse the order of results", - "default": false, - "title": "Reverse" - }, - "description": "Whether to reverse the order of results" - }, - { - "name": "page", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "minimum": 1, - "description": "Page number", - "default": 1, - "title": "Page" - }, - "description": "Page number" - }, - { - "name": "size", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "minimum": 1, - "description": "Page size", - "default": 50, - "title": "Size" - }, - "description": "Page size" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "anyOf": [ - { "$ref": "#/components/schemas/MetamessageGet" }, - { "type": "null" } - ], - "description": "Filtering options for the metamessages list", - "title": "Options" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Page_Metamessage_" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const metamessage of client.apps.users.metamessages.list('app_id', 'user_id')) {\n console.log(metamessage.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.users.metamessages.list(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/metamessages/{metamessage_id}": { - "get": { - "tags": ["metamessages"], - "summary": "Get Metamessage", - "description": "Get a specific Metamessage by ID", - "operationId": "get_metamessage_v1_apps__app_id__users__user_id__metamessages__metamessage_id__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "metamessage_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the metamessage to retrieve", - "title": "Metamessage Id" - }, - "description": "ID of the metamessage to retrieve" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Metamessage" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const metamessage = await client.apps.users.metamessages.get('app_id', 'user_id', 'metamessage_id');\n\n console.log(metamessage.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmetamessage = client.apps.users.metamessages.get(\n metamessage_id=\"metamessage_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(metamessage.id)" - } - ] - }, - "put": { - "tags": ["metamessages"], - "summary": "Update Metamessage", - "description": "Update a metamessage's metadata, type, or relationships", - "operationId": "update_metamessage_v1_apps__app_id__users__user_id__metamessages__metamessage_id__put", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "metamessage_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the metamessage to update", - "title": "Metamessage Id" - }, - "description": "ID of the metamessage to update" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MetamessageUpdate", - "description": "Updated metamessage parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Metamessage" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const metamessage = await client.apps.users.metamessages.update('app_id', 'user_id', 'metamessage_id');\n\n console.log(metamessage.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nmetamessage = client.apps.users.metamessages.update(\n metamessage_id=\"metamessage_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(metamessage.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections": { - "get": { - "tags": ["collections"], - "summary": "Get Collection", - "description": "Get a specific collection for a user.\n\nIf collection_id is provided as a query parameter, it uses that (must match JWT collection_id).\nOtherwise, it uses the collection_id from the JWT token.", - "operationId": "get_collection_v1_apps__app_id__users__user_id__collections_get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "Collection ID to retrieve. If not provided, uses JWT token", - "title": "Collection Id" - }, - "description": "Collection ID to retrieve. If not provided, uses JWT token" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Collection" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const collection = await client.apps.users.collections.get('app_id', 'user_id');\n\n console.log(collection.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ncollection = client.apps.users.collections.get(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\nprint(collection.id)" - } - ] - }, - "post": { - "tags": ["collections"], - "summary": "Create Collection", - "description": "Create a new Collection", - "operationId": "create_collection_v1_apps__app_id__users__user_id__collections_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CollectionCreate", - "description": "Collection creation parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Collection" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const collection = await client.apps.users.collections.create('app_id', 'user_id', { name: 'x' });\n\n console.log(collection.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ncollection = client.apps.users.collections.create(\n user_id=\"user_id\",\n app_id=\"app_id\",\n name=\"x\",\n)\nprint(collection.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections/list": { - "post": { - "tags": ["collections"], - "summary": "Get Collections", - "description": "Get All Collections for a User", - "operationId": "get_collections_v1_apps__app_id__users__user_id__collections_list_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "reverse", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "description": "Whether to reverse the order of results", - "default": false, - "title": "Reverse" - }, - "description": "Whether to reverse the order of results" - }, - { - "name": "page", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "minimum": 1, - "description": "Page number", - "default": 1, - "title": "Page" - }, - "description": "Page number" - }, - { - "name": "size", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "minimum": 1, - "description": "Page size", - "default": 50, - "title": "Size" - }, - "description": "Page size" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "anyOf": [ - { "$ref": "#/components/schemas/CollectionGet" }, - { "type": "null" } - ], - "description": "Filtering options for the collections list", - "title": "Options" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Page_Collection_" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const collection of client.apps.users.collections.list('app_id', 'user_id')) {\n console.log(collection.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.users.collections.list(\n user_id=\"user_id\",\n app_id=\"app_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections/name/{name}": { - "get": { - "tags": ["collections"], - "summary": "Get Collection By Name", - "description": "Get a Collection by Name", - "operationId": "get_collection_by_name_v1_apps__app_id__users__user_id__collections_name__name__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Name of the collection to retrieve", - "title": "Name" - }, - "description": "Name of the collection to retrieve" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Collection" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const collection = await client.apps.users.collections.getByName('app_id', 'user_id', 'name');\n\n console.log(collection.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ncollection = client.apps.users.collections.get_by_name(\n name=\"name\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(collection.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections/{collection_id}": { - "put": { - "tags": ["collections"], - "summary": "Update Collection", - "description": "Update a Collection's name or metadata", - "operationId": "update_collection_v1_apps__app_id__users__user_id__collections__collection_id__put", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection to update", - "title": "Collection Id" - }, - "description": "ID of the collection to update" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CollectionUpdate", - "description": "Updated collection parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Collection" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const collection = await client.apps.users.collections.update('app_id', 'user_id', 'collection_id');\n\n console.log(collection.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ncollection = client.apps.users.collections.update(\n collection_id=\"collection_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(collection.id)" - } - ] - }, - "delete": { - "tags": ["collections"], - "summary": "Delete Collection", - "description": "Delete a Collection and its documents", - "operationId": "delete_collection_v1_apps__app_id__users__user_id__collections__collection_id__delete", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection to delete", - "title": "Collection Id" - }, - "description": "ID of the collection to delete" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const collection = await client.apps.users.collections.delete('app_id', 'user_id', 'collection_id');\n\n console.log(collection);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ncollection = client.apps.users.collections.delete(\n collection_id=\"collection_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\nprint(collection)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/list": { - "post": { - "tags": ["documents"], - "summary": "Get Documents", - "description": "Get all of the Documents in a Collection", - "operationId": "get_documents_v1_apps__app_id__users__user_id__collections__collection_id__documents_list_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection", - "title": "Collection Id" - }, - "description": "ID of the collection" - }, - { - "name": "reverse", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "description": "Whether to reverse the order of results", - "default": false, - "title": "Reverse" - }, - "description": "Whether to reverse the order of results" - }, - { - "name": "page", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "minimum": 1, - "description": "Page number", - "default": 1, - "title": "Page" - }, - "description": "Page number" - }, - { - "name": "size", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "minimum": 1, - "description": "Page size", - "default": 50, - "title": "Size" - }, - "description": "Page size" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "anyOf": [ - { "$ref": "#/components/schemas/DocumentGet" }, - { "type": "null" } - ], - "description": "Filtering options for the documents list", - "title": "Options" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Page_Document_" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const document of client.apps.users.collections.documents.list(\n 'app_id',\n 'user_id',\n 'collection_id',\n )) {\n console.log(document.id);\n }\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\npage = client.apps.users.collections.documents.list(\n collection_id=\"collection_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/{document_id}": { - "get": { - "tags": ["documents"], - "summary": "Get Document", - "description": "Get a document by ID", - "operationId": "get_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__get", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection", - "title": "Collection Id" - }, - "description": "ID of the collection" - }, - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the document to retrieve", - "title": "Document Id" - }, - "description": "ID of the document to retrieve" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Document" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const document = await client.apps.users.collections.documents.get(\n 'app_id',\n 'user_id',\n 'collection_id',\n 'document_id',\n );\n\n console.log(document.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ndocument = client.apps.users.collections.documents.get(\n document_id=\"document_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n collection_id=\"collection_id\",\n)\nprint(document.id)" - } - ] - }, - "put": { - "tags": ["documents"], - "summary": "Update Document", - "description": "Update the content and/or the metadata of a Document", - "operationId": "update_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__put", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection", - "title": "Collection Id" - }, - "description": "ID of the collection" - }, - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the document to update", - "title": "Document Id" - }, - "description": "ID of the document to update" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DocumentUpdate", - "description": "Updated document parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Document" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const document = await client.apps.users.collections.documents.update(\n 'app_id',\n 'user_id',\n 'collection_id',\n 'document_id',\n );\n\n console.log(document.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ndocument = client.apps.users.collections.documents.update(\n document_id=\"document_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n collection_id=\"collection_id\",\n)\nprint(document.id)" - } - ] - }, - "delete": { - "tags": ["documents"], - "summary": "Delete Document", - "description": "Delete a Document by ID", - "operationId": "delete_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__delete", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection", - "title": "Collection Id" - }, - "description": "ID of the collection" - }, - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the document to delete", - "title": "Document Id" - }, - "description": "ID of the document to delete" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const document = await client.apps.users.collections.documents.delete(\n 'app_id',\n 'user_id',\n 'collection_id',\n 'document_id',\n );\n\n console.log(document);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ndocument = client.apps.users.collections.documents.delete(\n document_id=\"document_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n collection_id=\"collection_id\",\n)\nprint(document)" - } - ] - } - }, - "/v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/query": { - "post": { - "tags": ["documents"], - "summary": "Query Documents", - "description": "Cosine Similarity Search for Documents", - "operationId": "query_documents_v1_apps__app_id__users__user_id__collections__collection_id__documents_query_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection", - "title": "Collection Id" - }, - "description": "ID of the collection" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DocumentQuery", - "description": "Query parameters for document search" - } - } - } - }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "type": "array", - "items": { "$ref": "#/components/schemas/Document" }, - "title": "Response Query Documents V1 Apps App Id Users User Id Collections Collection Id Documents Query Post" + "$ref": "#/components/schemas/Message" } } } @@ -3106,166 +2484,97 @@ "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const documents = await client.apps.users.collections.documents.query(\n 'app_id',\n 'user_id',\n 'collection_id',\n { query: 'x' },\n );\n\n console.log(documents);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ndocuments = client.apps.users.collections.documents.query(\n collection_id=\"collection_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n query=\"x\",\n)\nprint(documents)" - } - ] + } } }, - "/v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents": { + "/v2/keys": { "post": { - "tags": ["documents"], - "summary": "Create Document", - "description": "Embed text as a vector and create a Document", - "operationId": "create_document_v1_apps__app_id__users__user_id__collections__collection_id__documents_post", - "security": [{ "HTTPBearer": [] }, {}], - "parameters": [ - { - "name": "app_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the app", - "title": "App Id" - }, - "description": "ID of the app" - }, - { - "name": "user_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the user", - "title": "User Id" - }, - "description": "ID of the user" - }, - { - "name": "collection_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the collection", - "title": "Collection Id" - }, - "description": "ID of the collection" - } + "tags": [ + "keys" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DocumentCreate", - "description": "Document creation parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Document" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const document = await client.apps.users.collections.documents.create(\n 'app_id',\n 'user_id',\n 'collection_id',\n { content: 'x' },\n );\n\n console.log(document.id);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\ndocument = client.apps.users.collections.documents.create(\n collection_id=\"collection_id\",\n app_id=\"app_id\",\n user_id=\"user_id\",\n content=\"x\",\n)\nprint(document.id)" - } - ] - } - }, - "/v1/keys": { - "post": { - "tags": ["keys"], "summary": "Create Key", "description": "Create a new Key", - "operationId": "create_key_v1_keys_post", - "security": [{ "HTTPBearer": [] }, {}], + "operationId": "create_key_v2_keys_post", + "security": [ + { + "HTTPBearer": [] + }, + {} + ], "parameters": [ { - "name": "app_id", + "name": "workspace_id", "in": "query", "required": false, "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "ID of the app to scope the key to", - "title": "App Id" + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "description": "ID of the workspace to scope the key to", + "title": "Workspace Id" }, - "description": "ID of the app to scope the key to" + "description": "ID of the workspace to scope the key to" }, { - "name": "user_id", + "name": "peer_id", "in": "query", "required": false, "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "ID of the user to scope the key to", - "title": "User Id" + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "description": "ID of the peer to scope the key to", + "title": "Peer Id" }, - "description": "ID of the user to scope the key to" + "description": "ID of the peer to scope the key to" }, { "name": "session_id", "in": "query", "required": false, "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], "description": "ID of the session to scope the key to", "title": "Session Id" }, "description": "ID of the session to scope the key to" }, - { - "name": "collection_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "description": "ID of the collection to scope the key to", - "title": "Collection Id" - }, - "description": "ID of the collection to scope the key to" - }, { "name": "expires_at", "in": "query", "required": false, "schema": { "anyOf": [ - { "type": "string", "format": "date-time" }, - { "type": "null" } + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } ], "title": "Expires At" } @@ -3274,310 +2583,99 @@ "responses": { "200": { "description": "Successful Response", - "content": { "application/json": { "schema": {} } } + "content": { + "application/json": { + "schema": {} + } + } }, "422": { "description": "Validation Error", "content": { "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } } } } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from 'honcho-ai';\n\nconst client = new Honcho({\n apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const key = await client.keys.create();\n\n console.log(key);\n}\n\nmain();" - }, - { - "lang": "Python", - "source": "import os\nfrom honcho import Honcho\n\nclient = Honcho(\n api_key=os.environ.get(\"HONCHO_API_KEY\"), # This is the default and can be omitted\n)\nkey = client.keys.create()\nprint(key)" - } - ] + } } } }, "components": { "schemas": { - "App": { - "properties": { - "id": { "type": "string", "title": "Id" }, - "name": { "type": "string", "title": "Name" }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - } - }, - "type": "object", - "required": ["id", "name", "created_at"], - "title": "App" - }, - "AppCreate": { - "properties": { - "name": { - "type": "string", - "maxLength": 100, - "minLength": 1, - "title": "Name" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} - } - }, - "type": "object", - "required": ["name"], - "title": "AppCreate" - }, - "AppGet": { - "properties": { - "filter": { - "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } - ], - "title": "Filter" - } - }, - "type": "object", - "title": "AppGet" - }, - "AppUpdate": { - "properties": { - "name": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Name" - }, - "metadata": { - "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } - ], - "title": "Metadata" - } - }, - "type": "object", - "title": "AppUpdate" - }, - "Collection": { - "properties": { - "id": { "type": "string", "title": "Id" }, - "name": { "type": "string", "title": "Name" }, - "user_id": { "type": "string", "title": "User Id" }, - "app_id": { "type": "string", "title": "App Id" }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - } - }, - "type": "object", - "required": ["id", "name", "user_id", "app_id", "created_at"], - "title": "Collection" - }, - "CollectionCreate": { - "properties": { - "name": { - "type": "string", - "maxLength": 100, - "minLength": 1, - "title": "Name" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} - } - }, - "type": "object", - "required": ["name"], - "title": "CollectionCreate" - }, - "CollectionGet": { - "properties": { - "filter": { - "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } - ], - "title": "Filter" - } - }, - "type": "object", - "title": "CollectionGet" - }, - "CollectionUpdate": { - "properties": { - "name": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Name" - }, - "metadata": { - "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } - ], - "title": "Metadata" - } - }, - "type": "object", - "title": "CollectionUpdate" - }, "DialecticOptions": { "properties": { + "session_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Session Id", + "description": "ID of the session to scope the representation to" + }, + "target": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Target", + "description": "Optional peer to get the representation for, from the perspective of this peer" + }, "queries": { "anyOf": [ - { "type": "string" }, - { "items": { "type": "string" }, "type": "array" } + { + "type": "string" + }, + { + "items": { + "type": "string" + }, + "type": "array" + } ], "title": "Queries" }, - "stream": { "type": "boolean", "title": "Stream", "default": false } - }, - "type": "object", - "required": ["queries"], - "title": "DialecticOptions" - }, - "DialecticResponse": { - "properties": { "content": { "type": "string", "title": "Content" } }, - "type": "object", - "required": ["content"], - "title": "DialecticResponse" - }, - "Document": { - "properties": { - "id": { "type": "string", "title": "Id" }, - "content": { "type": "string", "title": "Content" }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "collection_id": { "type": "string", "title": "Collection Id" }, - "app_id": { "type": "string", "title": "App Id" }, - "user_id": { "type": "string", "title": "User Id" } + "stream": { + "type": "boolean", + "title": "Stream", + "default": false + } }, "type": "object", "required": [ - "id", - "content", - "created_at", - "collection_id", - "app_id", - "user_id" + "queries" ], - "title": "Document" + "title": "DialecticOptions" }, - "DocumentCreate": { + "DialecticResponse": { "properties": { "content": { "type": "string", - "maxLength": 100000, - "minLength": 1, - "title": "Content" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} - } - }, - "type": "object", - "required": ["content"], - "title": "DocumentCreate" - }, - "DocumentGet": { - "properties": { - "filter": { - "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } - ], - "title": "Filter" - } - }, - "type": "object", - "title": "DocumentGet" - }, - "DocumentQuery": { - "properties": { - "query": { - "type": "string", - "maxLength": 1000, - "minLength": 1, - "title": "Query" - }, - "filter": { - "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } - ], - "title": "Filter" - }, - "top_k": { - "type": "integer", - "maximum": 50, - "minimum": 1, - "title": "Top K", - "default": 5 - } - }, - "type": "object", - "required": ["query"], - "title": "DocumentQuery" - }, - "DocumentUpdate": { - "properties": { - "metadata": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object", - "maxProperties": 10000 - }, - { "type": "null" } - ], - "title": "Metadata" - }, - "content": { - "anyOf": [ - { "type": "string", "maxLength": 100000, "minLength": 1 }, - { "type": "null" } - ], "title": "Content" } }, "type": "object", - "title": "DocumentUpdate" + "required": [ + "content" + ], + "title": "DialecticResponse" }, "HTTPValidationError": { "properties": { "detail": { - "items": { "$ref": "#/components/schemas/ValidationError" }, + "items": { + "$ref": "#/components/schemas/ValidationError" + }, "type": "array", "title": "Detail" } @@ -3587,47 +2685,76 @@ }, "Message": { "properties": { - "id": { "type": "string", "title": "Id" }, - "content": { "type": "string", "title": "Content" }, - "is_user": { "type": "boolean", "title": "Is User" }, - "session_id": { "type": "string", "title": "Session Id" }, + "id": { + "type": "string", + "title": "Id" + }, + "content": { + "type": "string", + "title": "Content" + }, + "peer_id": { + "type": "string", + "title": "Peer Id" + }, + "session_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Session Id" + }, "metadata": { "additionalProperties": true, "type": "object", - "title": "Metadata", - "default": {} + "title": "Metadata" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" }, - "app_id": { "type": "string", "title": "App Id" }, - "user_id": { "type": "string", "title": "User Id" } + "workspace_id": { + "type": "string", + "title": "Workspace Id" + }, + "token_count": { + "type": "integer", + "title": "Token Count" + } }, "type": "object", "required": [ "id", "content", - "is_user", + "peer_id", "session_id", "created_at", - "app_id", - "user_id" + "workspace_id", + "token_count" ], "title": "Message" }, "MessageBatchCreate": { "properties": { "messages": { - "items": { "$ref": "#/components/schemas/MessageCreate" }, + "items": { + "$ref": "#/components/schemas/MessageCreate" + }, "type": "array", "maxItems": 100, + "minItems": 1, "title": "Messages" } }, "type": "object", - "required": ["messages"], + "required": [ + "messages" + ], "title": "MessageBatchCreate", "description": "Schema for batch message creation with a max of 100 messages" }, @@ -3639,24 +2766,41 @@ "minLength": 0, "title": "Content" }, - "is_user": { "type": "boolean", "title": "Is User" }, + "peer_id": { + "type": "string", + "title": "Peer Id" + }, "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Metadata" } }, "type": "object", - "required": ["content", "is_user"], + "required": [ + "content", + "peer_id" + ], "title": "MessageCreate" }, "MessageGet": { "properties": { "filter": { "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } ], "title": "Filter" } @@ -3667,267 +2811,348 @@ "MessageUpdate": { "properties": { "metadata": { - "additionalProperties": true, - "type": "object", + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], "title": "Metadata" } }, "type": "object", - "required": ["metadata"], "title": "MessageUpdate" }, - "Metamessage": { + "Page_Message_": { "properties": { - "id": { "type": "string", "title": "Id" }, - "label": { "type": "string", "title": "Label" }, - "content": { "type": "string", "title": "Content" }, - "user_id": { "type": "string", "title": "User Id" }, - "app_id": { "type": "string", "title": "App Id" }, - "session_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Session Id" + "items": { + "items": { + "$ref": "#/components/schemas/Message" + }, + "type": "array", + "title": "Items" }, - "message_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Message Id" + "total": { + "type": "integer", + "minimum": 0.0, + "title": "Total" }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} + "page": { + "type": "integer", + "minimum": 1.0, + "title": "Page" + }, + "size": { + "type": "integer", + "minimum": 1.0, + "title": "Size" + }, + "pages": { + "type": "integer", + "minimum": 0.0, + "title": "Pages" + } + }, + "type": "object", + "required": [ + "items", + "total", + "page", + "size" + ], + "title": "Page[Message]" + }, + "Page_Peer_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/Peer" + }, + "type": "array", + "title": "Items" + }, + "total": { + "type": "integer", + "minimum": 0.0, + "title": "Total" + }, + "page": { + "type": "integer", + "minimum": 1.0, + "title": "Page" + }, + "size": { + "type": "integer", + "minimum": 1.0, + "title": "Size" + }, + "pages": { + "type": "integer", + "minimum": 0.0, + "title": "Pages" + } + }, + "type": "object", + "required": [ + "items", + "total", + "page", + "size" + ], + "title": "Page[Peer]" + }, + "Page_Session_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/Session" + }, + "type": "array", + "title": "Items" + }, + "total": { + "type": "integer", + "minimum": 0.0, + "title": "Total" + }, + "page": { + "type": "integer", + "minimum": 1.0, + "title": "Page" + }, + "size": { + "type": "integer", + "minimum": 1.0, + "title": "Size" + }, + "pages": { + "type": "integer", + "minimum": 0.0, + "title": "Pages" + } + }, + "type": "object", + "required": [ + "items", + "total", + "page", + "size" + ], + "title": "Page[Session]" + }, + "Page_Workspace_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/Workspace" + }, + "type": "array", + "title": "Items" + }, + "total": { + "type": "integer", + "minimum": 0.0, + "title": "Total" + }, + "page": { + "type": "integer", + "minimum": 1.0, + "title": "Page" + }, + "size": { + "type": "integer", + "minimum": 1.0, + "title": "Size" + }, + "pages": { + "type": "integer", + "minimum": 0.0, + "title": "Pages" + } + }, + "type": "object", + "required": [ + "items", + "total", + "page", + "size" + ], + "title": "Page[Workspace]" + }, + "Peer": { + "properties": { + "id": { + "type": "string", + "title": "Id" + }, + "workspace_id": { + "type": "string", + "title": "Workspace Id" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" }, - "metamessage_type": { - "type": "string", - "title": "Metamessage Type", - "readOnly": true + "metadata": { + "additionalProperties": true, + "type": "object", + "title": "Metadata" + }, + "configuration": { + "additionalProperties": true, + "type": "object", + "title": "Configuration" } }, "type": "object", "required": [ "id", - "label", - "content", - "user_id", - "app_id", - "session_id", - "message_id", - "created_at", - "metamessage_type" + "workspace_id", + "created_at" ], - "title": "Metamessage" + "title": "Peer" }, - "MetamessageCreate": { + "PeerCreate": { "properties": { - "metamessage_type": { + "id": { "type": "string", - "maxLength": 50, + "maxLength": 100, "minLength": 1, - "title": "Metamessage Type" - }, - "content": { - "type": "string", - "maxLength": 50000, - "minLength": 0, - "title": "Content" - }, - "session_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Session Id" - }, - "message_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Message Id" + "pattern": "^[a-zA-Z0-9_-]+$", + "title": "Id" }, "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Metadata" + }, + "configuration": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Configuration" } }, "type": "object", - "required": ["metamessage_type", "content"], - "title": "MetamessageCreate" + "required": [ + "id" + ], + "title": "PeerCreate" }, - "MetamessageGet": { + "PeerGet": { "properties": { - "metamessage_type": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Metamessage Type" - }, - "session_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Session Id" - }, - "message_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Message Id" - }, "filter": { "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } ], "title": "Filter" } }, "type": "object", - "title": "MetamessageGet" + "title": "PeerGet" }, - "MetamessageUpdate": { + "PeerRepresentationGet": { "properties": { "session_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Session Id" + "type": "string", + "title": "Session Id", + "description": "Get the working representation within this session" }, - "message_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Message Id" - }, - "metamessage_type": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Metamessage Type" - }, - "metadata": { + "target": { "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } + { + "type": "string" + }, + { + "type": "null" + } ], - "title": "Metadata" + "title": "Target", + "description": "Optional peer ID to get the representation for, from the perspective of this peer" } }, "type": "object", - "title": "MetamessageUpdate" + "required": [ + "session_id" + ], + "title": "PeerRepresentationGet" }, - "Page_App_": { + "PeerUpdate": { "properties": { - "items": { - "items": { "$ref": "#/components/schemas/App" }, - "type": "array", - "title": "Items" + "metadata": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Metadata" }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } + "configuration": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Configuration" + } }, "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[App]" - }, - "Page_Collection_": { - "properties": { - "items": { - "items": { "$ref": "#/components/schemas/Collection" }, - "type": "array", - "title": "Items" - }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } - }, - "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[Collection]" - }, - "Page_Document_": { - "properties": { - "items": { - "items": { "$ref": "#/components/schemas/Document" }, - "type": "array", - "title": "Items" - }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } - }, - "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[Document]" - }, - "Page_Message_": { - "properties": { - "items": { - "items": { "$ref": "#/components/schemas/Message" }, - "type": "array", - "title": "Items" - }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } - }, - "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[Message]" - }, - "Page_Metamessage_": { - "properties": { - "items": { - "items": { "$ref": "#/components/schemas/Metamessage" }, - "type": "array", - "title": "Items" - }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } - }, - "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[Metamessage]" - }, - "Page_Session_": { - "properties": { - "items": { - "items": { "$ref": "#/components/schemas/Session" }, - "type": "array", - "title": "Items" - }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } - }, - "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[Session]" - }, - "Page_User_": { - "properties": { - "items": { - "items": { "$ref": "#/components/schemas/User" }, - "type": "array", - "title": "Items" - }, - "total": { "type": "integer", "minimum": 0, "title": "Total" }, - "page": { "type": "integer", "minimum": 1, "title": "Page" }, - "size": { "type": "integer", "minimum": 1, "title": "Size" }, - "pages": { "type": "integer", "minimum": 0, "title": "Pages" } - }, - "type": "object", - "required": ["items", "total", "page", "size"], - "title": "Page[User]" + "title": "PeerUpdate" }, "Session": { "properties": { - "id": { "type": "string", "title": "Id" }, - "is_active": { "type": "boolean", "title": "Is Active" }, - "user_id": { "type": "string", "title": "User Id" }, - "app_id": { "type": "string", "title": "App Id" }, + "id": { + "type": "string", + "title": "Id" + }, + "is_active": { + "type": "boolean", + "title": "Is Active" + }, + "workspace_id": { + "type": "string", + "title": "Workspace Id" + }, "metadata": { "additionalProperties": true, "type": "object", - "title": "Metadata", - "default": {} + "title": "Metadata" + }, + "configuration": { + "additionalProperties": true, + "type": "object", + "title": "Configuration" }, "created_at": { "type": "string", @@ -3936,27 +3161,105 @@ } }, "type": "object", - "required": ["id", "is_active", "user_id", "app_id", "created_at"], + "required": [ + "id", + "is_active", + "workspace_id", + "created_at" + ], "title": "Session" }, - "SessionCreate": { + "SessionContext": { "properties": { - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} + "id": { + "type": "string", + "title": "Id" + }, + "messages": { + "items": { + "$ref": "#/components/schemas/Message" + }, + "type": "array", + "title": "Messages" + }, + "summary": { + "type": "string", + "title": "Summary" } }, "type": "object", + "required": [ + "id", + "messages", + "summary" + ], + "title": "SessionContext" + }, + "SessionCreate": { + "properties": { + "id": { + "type": "string", + "maxLength": 100, + "minLength": 1, + "pattern": "^[a-zA-Z0-9_-]+$", + "title": "Id" + }, + "metadata": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Metadata" + }, + "peers": { + "anyOf": [ + { + "additionalProperties": { + "$ref": "#/components/schemas/SessionPeerConfig" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Peers" + }, + "configuration": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Configuration" + } + }, + "type": "object", + "required": [ + "id" + ], "title": "SessionCreate" }, "SessionGet": { "properties": { "filter": { "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } ], "title": "Filter" }, @@ -3969,104 +3272,204 @@ "type": "object", "title": "SessionGet" }, + "SessionPeerConfig": { + "properties": { + "observe_others": { + "type": "boolean", + "title": "Observe Others", + "description": "Whether this peer should form a session-level theory-of-mind representation of other peers in the session", + "default": false + }, + "observe_me": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Observe Me", + "description": "Whether other peers in this session should try to form a session-level theory-of-mind representation of this peer" + } + }, + "type": "object", + "title": "SessionPeerConfig" + }, "SessionUpdate": { "properties": { + "metadata": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Metadata" + }, + "configuration": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Configuration" + } + }, + "type": "object", + "title": "SessionUpdate" + }, + "ValidationError": { + "properties": { + "loc": { + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + }, + "type": "array", + "title": "Location" + }, + "msg": { + "type": "string", + "title": "Message" + }, + "type": { + "type": "string", + "title": "Error Type" + } + }, + "type": "object", + "required": [ + "loc", + "msg", + "type" + ], + "title": "ValidationError" + }, + "Workspace": { + "properties": { + "id": { + "type": "string", + "title": "Id" + }, "metadata": { "additionalProperties": true, "type": "object", "title": "Metadata" - } - }, - "type": "object", - "required": ["metadata"], - "title": "SessionUpdate" - }, - "User": { - "properties": { - "id": { "type": "string", "title": "Id" }, - "name": { "type": "string", "title": "Name" }, - "app_id": { "type": "string", "title": "App Id" }, + }, + "configuration": { + "additionalProperties": true, + "type": "object", + "title": "Configuration" + }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata", - "default": {} } }, "type": "object", - "required": ["id", "name", "app_id", "created_at"], - "title": "User" + "required": [ + "id", + "created_at" + ], + "title": "Workspace" }, - "UserCreate": { + "WorkspaceCreate": { "properties": { - "name": { + "id": { "type": "string", "maxLength": 100, "minLength": 1, - "title": "Name" + "pattern": "^[a-zA-Z0-9_-]+$", + "title": "Id" }, "metadata": { "additionalProperties": true, "type": "object", "title": "Metadata", "default": {} + }, + "configuration": { + "additionalProperties": true, + "type": "object", + "title": "Configuration", + "default": {} } }, "type": "object", - "required": ["name"], - "title": "UserCreate" + "required": [ + "id" + ], + "title": "WorkspaceCreate" }, - "UserGet": { + "WorkspaceGet": { "properties": { "filter": { "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } ], "title": "Filter" } }, "type": "object", - "title": "UserGet" + "title": "WorkspaceGet" }, - "UserUpdate": { + "WorkspaceUpdate": { "properties": { - "name": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Name" - }, "metadata": { "anyOf": [ - { "additionalProperties": true, "type": "object" }, - { "type": "null" } + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } ], "title": "Metadata" + }, + "configuration": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Configuration" } }, "type": "object", - "title": "UserUpdate" - }, - "ValidationError": { - "properties": { - "loc": { - "items": { "anyOf": [{ "type": "string" }, { "type": "integer" }] }, - "type": "array", - "title": "Location" - }, - "msg": { "type": "string", "title": "Message" }, - "type": { "type": "string", "title": "Error Type" } - }, - "type": "object", - "required": ["loc", "msg", "type"], - "title": "ValidationError" + "title": "WorkspaceUpdate" } }, - "securitySchemes": { "HTTPBearer": { "type": "http", "scheme": "bearer" } } + "securitySchemes": { + "HTTPBearer": { + "type": "http", + "scheme": "bearer" + } + } } -} - +} \ No newline at end of file diff --git a/src/main.py b/src/main.py index 4a36b3b4..21e36466 100644 --- a/src/main.py +++ b/src/main.py @@ -5,7 +5,7 @@ import uuid from contextlib import asynccontextmanager import sentry_sdk -from fastapi import APIRouter, FastAPI, Request +from fastapi import FastAPI, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse from fastapi_pagination import add_pagination @@ -137,15 +137,13 @@ app.add_middleware( allow_headers=["*"], ) -router = APIRouter(prefix="/apps/{app_id}/users/{user_id}") - add_pagination(app) -app.include_router(workspaces.router, prefix="/v1") -app.include_router(peers.router, prefix="/v1") -app.include_router(sessions.router, prefix="/v1") -app.include_router(messages.router, prefix="/v1") -app.include_router(keys.router, prefix="/v1") +app.include_router(workspaces.router, prefix="/v2") +app.include_router(peers.router, prefix="/v2") +app.include_router(sessions.router, prefix="/v2") +app.include_router(messages.router, prefix="/v2") +app.include_router(keys.router, prefix="/v2") # Global exception handlers diff --git a/tests/routes/test_keys.py b/tests/routes/test_keys.py index 487b0bfb..7d864be8 100644 --- a/tests/routes/test_keys.py +++ b/tests/routes/test_keys.py @@ -1,6 +1,6 @@ def test_create_key_no_params(auth_client): """Test creating a key with no parameters""" - response = auth_client.post("/v1/keys") + response = auth_client.post("/v2/keys") # Only admin JWT should be allowed if auth_client.auth_type == "admin": @@ -19,14 +19,14 @@ def test_create_key_with_params(auth_client, sample_data): # Test with app_id response = auth_client.post( - "/v1/keys", params={"workspace_id": test_workspace.name} + "/v2/keys", params={"workspace_id": test_workspace.name} ) assert response.status_code == 200 assert "key" in response.json() # Test with app_id and user_id response = auth_client.post( - "/v1/keys", + "/v2/keys", params={"workspace_id": test_workspace.name, "peer_id": test_peer.name}, ) assert response.status_code == 200 @@ -34,7 +34,7 @@ def test_create_key_with_params(auth_client, sample_data): # Test with session_id and collection_id response = auth_client.post( - "/v1/keys", + "/v2/keys", params={ "workspace_id": test_workspace.name, "peer_id": test_peer.name, @@ -48,7 +48,7 @@ def test_create_key_with_params(auth_client, sample_data): def test_create_key_with_expires_at(auth_client, sample_data): """Test creating a key with an expiration date""" - response = auth_client.post("/v1/keys", params={"expires_at": "2025-01-01"}) + response = auth_client.post("/v2/keys", params={"expires_at": "2025-01-01"}) # Only admin JWT should be allowed if auth_client.auth_type == "admin": @@ -62,6 +62,6 @@ def test_create_key_with_expires_at(auth_client, sample_data): # assert that the key is expired response = auth_client.post( - "/v1/keys", params={"workspace_id": test_workspace.name} + "/v2/keys", params={"workspace_id": test_workspace.name} ) assert response.status_code == 401 diff --git a/tests/routes/test_messages.py b/tests/routes/test_messages.py index 72876884..6273ed4c 100644 --- a/tests/routes/test_messages.py +++ b/tests/routes/test_messages.py @@ -16,7 +16,7 @@ async def test_create_message(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", json={ "messages": [ { @@ -51,7 +51,7 @@ async def test_create_batch_messages_with_metadata(client, db_session, sample_da await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", json={ "messages": [ { @@ -93,7 +93,7 @@ async def test_create_batch_messages_without_metadata(client, db_session, sample await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", json={ "messages": [ { @@ -125,7 +125,7 @@ async def test_create_batch_messages_with_null_metadata( await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", json={ "messages": [ { @@ -164,7 +164,7 @@ async def test_get_messages(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", json={}, ) assert response.status_code == 200 @@ -208,7 +208,7 @@ async def test_get_messages_with_reverse(client, db_session, sample_data): # Test normal order response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", json={}, ) assert response.status_code == 200 @@ -216,7 +216,7 @@ async def test_get_messages_with_reverse(client, db_session, sample_data): # Test reversed order response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list?reverse=true", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list?reverse=true", json={}, ) assert response.status_code == 200 @@ -253,7 +253,7 @@ async def test_get_messages_with_empty_filter(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", json={"filter": {}}, ) assert response.status_code == 200 @@ -284,7 +284,7 @@ async def test_get_messages_with_null_filter(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", json={"filter": None}, ) assert response.status_code == 200 @@ -315,7 +315,7 @@ async def test_get_messages_no_body(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list" + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list" ) assert response.status_code == 200 data = response.json() @@ -353,7 +353,7 @@ async def test_get_filtered_messages(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", json={"filter": {"key": "value2"}}, ) assert response.status_code == 200 @@ -408,7 +408,7 @@ async def test_get_filtered_messages_with_complex_filter( # Filter by multiple criteria response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/list", json={"filter": {"priority": "high", "category": "technical"}}, ) assert response.status_code == 200 @@ -439,7 +439,7 @@ async def test_update_message(client, db_session, sample_data): await db_session.commit() response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", json={"metadata": {"new_key": "new_value"}}, ) assert response.status_code == 200 @@ -476,7 +476,7 @@ async def test_update_message_with_complex_metadata(client, db_session, sample_d } response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", json={"metadata": complex_metadata}, ) assert response.status_code == 200 @@ -509,14 +509,14 @@ async def test_update_message_empty_metadata(client, db_session, sample_data): await db_session.commit() response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", json={"metadata": None}, ) assert response.status_code == 200 # now ensure that the metadata is not changed response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}" + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}" ) assert response.status_code == 200 data = response.json() @@ -546,7 +546,7 @@ async def test_update_message_with_empty_dict_metadata(client, db_session, sampl await db_session.commit() response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}", json={"metadata": {}}, ) assert response.status_code == 200 @@ -575,7 +575,7 @@ async def test_get_single_message(client, db_session, sample_data): await db_session.commit() response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}" + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{test_message.public_id}" ) assert response.status_code == 200 data = response.json() @@ -600,7 +600,7 @@ async def test_get_nonexistent_message(client, db_session, sample_data): nonexistent_message_id = str(generate_nanoid()) response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{nonexistent_message_id}" + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{nonexistent_message_id}" ) assert response.status_code == 404 @@ -619,7 +619,7 @@ async def test_update_nonexistent_message(client, db_session, sample_data): nonexistent_message_id = str(generate_nanoid()) response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{nonexistent_message_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages/{nonexistent_message_id}", json={"metadata": {"key": "value"}}, ) assert response.status_code == 404 @@ -632,7 +632,7 @@ async def test_create_messages_for_nonexistent_session(client, sample_data): nonexistent_session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{nonexistent_session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{nonexistent_session_id}/messages", json={ "messages": [ { @@ -659,7 +659,7 @@ async def test_get_messages_for_nonexistent_session(client, sample_data): nonexistent_session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{nonexistent_session_id}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{nonexistent_session_id}/messages/list", json={}, ) # Should return 200 with empty results (session doesn't exist = no messages) @@ -682,7 +682,7 @@ async def test_create_empty_batch_messages(client, db_session, sample_data): await db_session.commit() response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", json={"messages": []}, ) # Should return 422 for validation error (empty list not allowed) @@ -708,7 +708,7 @@ async def test_create_batch_messages_max_limit(client, db_session, sample_data): ] response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{test_session.name}/messages", json={"messages": messages}, ) assert response.status_code == 200 diff --git a/tests/routes/test_peers.py b/tests/routes/test_peers.py index 95783583..84ee9243 100644 --- a/tests/routes/test_peers.py +++ b/tests/routes/test_peers.py @@ -5,7 +5,7 @@ def test_get_or_create_peer(client, sample_data): test_workspace, _ = sample_data name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": name, "metadata": {"peer_key": "peer_value"}}, ) assert response.status_code == 200 @@ -22,7 +22,7 @@ def test_get_or_create_peer_with_configuration(client, sample_data): configuration = {"experimental": True, "beta": False} response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": name, "configuration": configuration}, ) assert response.status_code == 200 @@ -39,7 +39,7 @@ def test_get_or_create_peer_with_all_optional_params(client, sample_data): configuration = {"feature1": True, "feature2": False} response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": name, "metadata": metadata, "configuration": configuration}, ) assert response.status_code == 200 @@ -55,7 +55,7 @@ def test_get_or_create_existing_peer(client, sample_data): # Create the peer response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": name, "metadata": {"peer_key": "peer_value"}}, ) assert response.status_code == 200 @@ -63,7 +63,7 @@ def test_get_or_create_existing_peer(client, sample_data): # Try to create the same peer again - should return existing peer response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": name, "metadata": {"peer_key": "peer_value"}}, ) assert response.status_code == 200 @@ -79,21 +79,21 @@ def test_get_peers(client, sample_data): # Create a few peers with metadata response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": str(generate_nanoid()), "metadata": {"peer_key": "peer_value"}}, ) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": str(generate_nanoid()), "metadata": {"peer_key": "peer_value"}}, ) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": str(generate_nanoid()), "metadata": {"peer_key": "peer_value2"}}, ) # Get all peers response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/list", + f"/v2/workspaces/{test_workspace.name}/peers/list", json={}, ) assert response.status_code == 200 @@ -103,7 +103,7 @@ def test_get_peers(client, sample_data): # Get peers with filter response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/list", + f"/v2/workspaces/{test_workspace.name}/peers/list", json={"filter": {"peer_key": "peer_value"}}, ) assert response.status_code == 200 @@ -118,7 +118,7 @@ def test_get_peers_with_empty_filter(client, sample_data): test_workspace, _ = sample_data response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/list", json={"filter": {}} + f"/v2/workspaces/{test_workspace.name}/peers/list", json={"filter": {}} ) assert response.status_code == 200 data = response.json() @@ -131,7 +131,7 @@ def test_get_peers_with_null_filter(client, sample_data): test_workspace, _ = sample_data response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/list", json={"filter": None} + f"/v2/workspaces/{test_workspace.name}/peers/list", json={"filter": None} ) assert response.status_code == 200 data = response.json() @@ -142,7 +142,7 @@ def test_get_peers_with_null_filter(client, sample_data): def test_update_peer(client, sample_data): test_workspace, test_peer = sample_data response = client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"metadata": {"new_key": "new_value"}}, ) assert response.status_code == 200 @@ -156,7 +156,7 @@ def test_update_peer_with_configuration(client, sample_data): configuration = {"new_feature": True, "legacy_feature": False} response = client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"configuration": configuration}, ) assert response.status_code == 200 @@ -171,7 +171,7 @@ def test_update_peer_with_all_optional_params(client, sample_data): configuration = {"experimental": True, "beta": True} response = client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"metadata": metadata, "configuration": configuration}, ) assert response.status_code == 200 @@ -186,13 +186,13 @@ def test_update_peer_with_null_metadata(client, sample_data): # First set some metadata client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"metadata": {"temp": "value"}}, ) # Then clear it with null response = client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"metadata": None}, ) assert response.status_code == 200 @@ -205,7 +205,7 @@ def test_update_peer_with_null_configuration(client, sample_data): test_workspace, test_peer = sample_data response = client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"configuration": None}, ) assert response.status_code == 200 @@ -218,7 +218,7 @@ def test_get_sessions_for_peer_no_sessions(client, sample_data): # Get sessions for the peer response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", json={}, ) assert response.status_code == 200 @@ -232,7 +232,7 @@ def test_get_sessions_for_peer(client, sample_data): # Create session for the peer session_name = str(generate_nanoid()) create_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_name, "peer_names": {test_peer.name: {}}}, ) assert create_response.status_code == 200 @@ -241,7 +241,7 @@ def test_get_sessions_for_peer(client, sample_data): # Now get sessions for the peer and validate the session is returned response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", ) assert response.status_code == 200 data = response.json() @@ -259,14 +259,14 @@ def test_get_sessions_for_peer_with_is_active_filter(client, sample_data): # Create and then delete a session to have inactive session session_name = str(generate_nanoid()) client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_name, "peer_names": {test_peer.name: {}}}, ) - client.delete(f"/v1/workspaces/{test_workspace.name}/sessions/{session_name}") + client.delete(f"/v2/workspaces/{test_workspace.name}/sessions/{session_name}") # Test getting inactive sessions response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", json={"is_active": False}, ) assert response.status_code == 200 @@ -282,7 +282,7 @@ def test_get_sessions_for_peer_with_empty_filter(client, sample_data): test_workspace, test_peer = sample_data response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/sessions", json={"filter": {}}, ) assert response.status_code == 200 @@ -296,7 +296,7 @@ def test_create_and_get_messages_for_peer(client, sample_data): # Create messages for the peer response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages", json={ "messages": [ { @@ -321,7 +321,7 @@ def test_create_and_get_messages_for_peer(client, sample_data): # Get messages for the peer response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", json={}, ) assert response.status_code == 200 @@ -340,7 +340,7 @@ def test_get_messages_for_peer_with_reverse(client, sample_data): # Create messages client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages", json={ "messages": [ {"content": "First message", "peer_id": test_peer.name}, @@ -351,7 +351,7 @@ def test_get_messages_for_peer_with_reverse(client, sample_data): # Test normal order response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", json={}, ) assert response.status_code == 200 @@ -359,7 +359,7 @@ def test_get_messages_for_peer_with_reverse(client, sample_data): # Test reversed order response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list?reverse=true", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list?reverse=true", json={}, ) assert response.status_code == 200 @@ -375,7 +375,7 @@ def test_get_messages_for_peer_with_empty_filter(client, sample_data): test_workspace, test_peer = sample_data response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", json={"filter": {}}, ) assert response.status_code == 200 @@ -389,7 +389,7 @@ def test_get_messages_for_peer_with_null_filter(client, sample_data): test_workspace, test_peer = sample_data response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages/list", json={"filter": None}, ) assert response.status_code == 200 @@ -404,7 +404,7 @@ def test_chat(client, sample_data): # Test chat endpoint response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", json={ "queries": "Hello, how are you?", "stream": False, @@ -424,13 +424,13 @@ def test_chat_with_optional_params(client, sample_data): # Create a session first client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) # Test chat without optional parameters response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", json={ "queries": "Hello, how are you?", "stream": False, @@ -449,13 +449,13 @@ def test_get_peer_representation_with_session(client, sample_data): # Create a session first client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) # Test representation scoped to session response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/representation", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/representation", json={ "session_id": session_id, "queries": "Hello, how are you?", @@ -470,7 +470,7 @@ def test_search_peer(client, sample_data): # Add some messages to search through client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/messages", json={ "messages": [ {"content": "Search this content", "peer_id": test_peer.name}, @@ -481,7 +481,7 @@ def test_search_peer(client, sample_data): # Search with a query response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/search", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/search", json="search query", ) assert response.status_code == 200 @@ -501,7 +501,7 @@ def test_search_peer_empty_query(client, sample_data): # Search with empty query response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/search", json="" + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/search", json="" ) assert response.status_code == 200 data = response.json() @@ -517,7 +517,7 @@ def test_search_peer_nonexistent(client, sample_data): nonexistent_peer_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{nonexistent_peer_id}/search", + f"/v2/workspaces/{test_workspace.name}/peers/{nonexistent_peer_id}/search", json="test query", ) # This should probably return 404 or handle gracefully diff --git a/tests/routes/test_scoped_api.py b/tests/routes/test_scoped_api.py index bc154fdb..fc1b669c 100644 --- a/tests/routes/test_scoped_api.py +++ b/tests/routes/test_scoped_api.py @@ -7,7 +7,7 @@ def test_create_workspace_with_auth(auth_client): name = str(generate_nanoid()) response = auth_client.post( - "/v1/workspaces", json={"name": name, "metadata": {"key": "value"}} + "/v2/workspaces", json={"name": name, "metadata": {"key": "value"}} ) # Check expected behavior based on auth type @@ -26,7 +26,7 @@ def test_auth_response_time(auth_client): start_time = time.time() response = auth_client.post( - "/v1/workspaces", json={"name": name, "metadata": {"key": "value"}} + "/v2/workspaces", json={"name": name, "metadata": {"key": "value"}} ) end_time = time.time() @@ -47,7 +47,7 @@ def test_get_or_create_workspace_with_auth(auth_client): name = str(generate_nanoid()) response = auth_client.post( - "/v1/workspaces", json={"name": name, "metadata": {"key": "value"}} + "/v2/workspaces", json={"name": name, "metadata": {"key": "value"}} ) if auth_client.auth_type != "admin": @@ -66,7 +66,7 @@ def test_get_workspace_with_auth(auth_client, sample_data): f"Bearer {create_jwt(JWTParams(w=test_workspace.name))}" ) - response = auth_client.post("/v1/workspaces", json={"name": test_workspace.name}) + response = auth_client.post("/v2/workspaces", json={"name": test_workspace.name}) # Admin JWT or JWT with matching workspace should be allowed if auth_client.auth_type in ["admin", "empty"]: @@ -86,7 +86,7 @@ def test_update_workspace_with_auth(auth_client, sample_data): new_name = str(generate_nanoid()) response = auth_client.put( - f"/v1/workspaces/{test_workspace.name}", + f"/v2/workspaces/{test_workspace.name}", json={"name": new_name, "metadata": {"new_key": "new_value"}}, ) @@ -110,7 +110,7 @@ def test_update_workspace_with_wrong_auth(auth_client, sample_data): new_name = str(generate_nanoid()) response = auth_client.put( - f"/v1/workspaces/{test_workspace.name}", + f"/v2/workspaces/{test_workspace.name}", json={"name": new_name, "metadata": {"new_key": "new_value"}}, ) @@ -133,7 +133,7 @@ def test_create_peer_with_auth(auth_client, sample_data): name = str(generate_nanoid()) response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": name, "metadata": {"peer_key": "peer_value"}}, ) @@ -155,7 +155,7 @@ def test_get_peer_by_name_with_auth(auth_client, sample_data): # Use POST /list endpoint to get peers response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/peers/list", + f"/v2/workspaces/{test_workspace.name}/peers/list", json={"filter": {"name": test_peer.name}}, ) @@ -173,7 +173,7 @@ def test_get_peer_by_name_with_auth(auth_client, sample_data): # Get specific peer using get_or_create endpoint response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/peers", json={"name": test_peer.name} + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": test_peer.name} ) assert response.status_code == 200 @@ -190,7 +190,7 @@ def test_update_peer_with_auth(auth_client, sample_data): new_name = str(generate_nanoid()) response = auth_client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={"name": new_name, "metadata": {"updated_key": "updated_value"}}, ) @@ -207,7 +207,7 @@ def test_update_peer_with_auth(auth_client, sample_data): ) response = auth_client.put( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}", json={ "name": str(generate_nanoid()), "metadata": {"peer_key": "peer_value"}, @@ -228,7 +228,7 @@ def test_create_session_with_auth(auth_client, sample_data): session_name = str(generate_nanoid()) response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name, "peer_names": {test_peer.name: {}}}, ) @@ -246,7 +246,7 @@ def test_create_session_with_auth(auth_client, sample_data): session_name2 = str(generate_nanoid()) response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name2, "peer_names": {test_peer.name: {}}}, ) @@ -264,7 +264,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): session_name = str(generate_nanoid()) create_response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name, "peer_names": {test_peer.name: {}}}, ) @@ -276,7 +276,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): # Test with workspace scoped JWT - get the same session response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", json={"name": session_name} + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name} ) assert response.status_code == 200 @@ -287,7 +287,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): ) response = auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name}, ) assert response.status_code == 200 @@ -295,7 +295,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): # Test with wrong session_name (should be 401 since we have a session-scoped JWT) assert ( auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": generate_nanoid()}, ).status_code == 401 @@ -308,7 +308,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): assert ( auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name}, ).status_code == 200 @@ -321,7 +321,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): assert ( auth_client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"name": session_name}, ).status_code == 200 @@ -331,7 +331,7 @@ def test_get_session_by_name_with_auth(auth_client, sample_data): wrong_session_name = generate_nanoid() assert ( auth_client.delete( - f"/v1/workspaces/{test_workspace.name}/sessions/{wrong_session_name}" + f"/v2/workspaces/{test_workspace.name}/sessions/{wrong_session_name}" ).status_code == 404 ) diff --git a/tests/routes/test_sessions.py b/tests/routes/test_sessions.py index 1478acfd..75d71973 100644 --- a/tests/routes/test_sessions.py +++ b/tests/routes/test_sessions.py @@ -7,7 +7,7 @@ def test_get_or_create_session(client, sample_data): # Test creating a new session with no parameters response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": str(generate_nanoid())}, ) assert response.status_code == 200 @@ -19,7 +19,7 @@ def test_get_or_create_session(client, sample_data): # Test creating a session with a specific id and peer_names (should get or create) session_id = str(generate_nanoid()) response2 = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) assert response2.status_code == 200 @@ -30,7 +30,7 @@ def test_get_or_create_session(client, sample_data): # Test getting the same session again (should return the same session) response3 = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) assert response3.status_code == 200 @@ -44,7 +44,7 @@ def test_create_session_with_metadata(client, sample_data): test_workspace, test_peer = sample_data session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -66,7 +66,7 @@ def test_create_session_with_configuration(client, sample_data): configuration = {"experimental_feature": True, "beta_mode": False} response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -88,7 +88,7 @@ def test_create_session_with_all_optional_params(client, sample_data): configuration = {"feature1": True, "feature2": False} response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -111,7 +111,7 @@ def test_create_session_with_too_many_peers(client, sample_data, caplog): for _ in range(10): peer_name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": peer_name, "metadata": {}}, ) assert response.status_code == 200 @@ -119,7 +119,7 @@ def test_create_session_with_too_many_peers(client, sample_data, caplog): # create session with 11 peers response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": str(generate_nanoid()), "peer_names": {peer_name: {} for peer_name in peer_names}, @@ -129,7 +129,7 @@ def test_create_session_with_too_many_peers(client, sample_data, caplog): assert "Failed to get or create session" in caplog.text session_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/list", + f"/v2/workspaces/{test_workspace.name}/sessions/list", json={"filter": {"name": "test_session"}}, ) assert session_response.status_code == 200 @@ -139,7 +139,7 @@ def test_create_session_with_too_many_peers(client, sample_data, caplog): peer_names.pop() # Attempt to create session with same name response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": "test_session", "peer_names": {peer_name: {} for peer_name in peer_names}, @@ -156,7 +156,7 @@ def test_get_sessions(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -169,7 +169,7 @@ def test_get_sessions(client, sample_data): assert "id" in data assert data["workspace_id"] == test_workspace.name response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/list", + f"/v2/workspaces/{test_workspace.name}/sessions/list", json={"filter": {"test_key": "test_value"}}, ) assert response.status_code == 200 @@ -187,14 +187,14 @@ def test_get_sessions_with_is_active_filter(client, sample_data): # Create and then delete a session to have inactive session session_id = str(generate_nanoid()) client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) - client.delete(f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}") + client.delete(f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}") # Test getting inactive sessions response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/list", json={"is_active": False} + f"/v2/workspaces/{test_workspace.name}/sessions/list", json={"is_active": False} ) assert response.status_code == 200 data = response.json() @@ -209,7 +209,7 @@ def test_get_sessions_with_empty_filter(client, sample_data): test_workspace, test_peer = sample_data response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/list", json={"filter": {}} + f"/v2/workspaces/{test_workspace.name}/sessions/list", json={"filter": {}} ) assert response.status_code == 200 data = response.json() @@ -222,7 +222,7 @@ def test_update_delete_metadata(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -232,7 +232,7 @@ def test_update_delete_metadata(client, sample_data): assert response.status_code == 200 response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={"metadata": {}}, ) assert response.status_code == 200 @@ -245,7 +245,7 @@ def test_update_session(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -254,7 +254,7 @@ def test_update_session(client, sample_data): assert response.status_code == 200 response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={"metadata": {"new_key": "new_value"}}, ) assert response.status_code == 200 @@ -269,14 +269,14 @@ def test_update_session_with_configuration(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) # Update with configuration configuration = {"new_feature": True, "legacy_feature": False} response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={"metadata": {}, "configuration": configuration}, ) assert response.status_code == 200 @@ -291,7 +291,7 @@ def test_update_session_with_all_optional_params(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) @@ -299,7 +299,7 @@ def test_update_session_with_all_optional_params(client, sample_data): metadata = {"updated_key": "updated_value"} configuration = {"experimental": True, "beta": True} response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={"metadata": metadata, "configuration": configuration}, ) assert response.status_code == 200 @@ -315,7 +315,7 @@ def test_update_session_with_null_configuration(client, sample_data): # Create session with configuration client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -325,7 +325,7 @@ def test_update_session_with_null_configuration(client, sample_data): # Update with null configuration response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={"metadata": {}, "configuration": None}, ) assert response.status_code == 200 @@ -338,7 +338,7 @@ def test_delete_session(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -347,13 +347,13 @@ def test_delete_session(client, sample_data): assert response.status_code == 200 response = client.delete( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}" + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}" ) assert response.status_code == 200 # Check that session is marked as inactive response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/list", + f"/v2/workspaces/{test_workspace.name}/sessions/list", json={"is_active": False}, ) data = response.json() @@ -368,7 +368,7 @@ def test_clone_session(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -379,7 +379,7 @@ def test_clone_session(client, sample_data): # Create some messages in the session response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={ "messages": [ { @@ -398,7 +398,7 @@ def test_clone_session(client, sample_data): assert response.status_code == 200 response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/clone", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/clone", ) assert response.status_code == 200 data = response.json() @@ -406,7 +406,7 @@ def test_clone_session(client, sample_data): # Check messages were cloned response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{data['id']}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{data['id']}/messages/list", json={}, ) @@ -429,13 +429,13 @@ def test_clone_session_with_cutoff(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) # Create messages response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={ "messages": [ {"content": "Message 1", "peer_id": test_peer.name}, @@ -450,7 +450,7 @@ def test_clone_session_with_cutoff(client, sample_data): # Clone with cutoff at first message response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/clone?message_id={first_message_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/clone?message_id={first_message_id}", ) assert response.status_code == 200 data = response.json() @@ -462,7 +462,7 @@ def test_add_peers_to_session(client, sample_data): # Create another peer peer2_name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": peer2_name, "metadata": {}}, ) assert response.status_code == 200 @@ -470,7 +470,7 @@ def test_add_peers_to_session(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -480,7 +480,7 @@ def test_add_peers_to_session(client, sample_data): # Add another peer to the session response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", json={peer2_name: {}}, ) assert response.status_code == 200 @@ -491,7 +491,7 @@ def test_get_session_peers(client, sample_data): # Create another peer peer2_name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": peer2_name, "metadata": {}}, ) assert response.status_code == 200 @@ -499,7 +499,7 @@ def test_get_session_peers(client, sample_data): # Create a test session with multiple peers session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}, peer2_name: {}}, @@ -509,7 +509,7 @@ def test_get_session_peers(client, sample_data): # Get peers from the session response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", ) assert response.status_code == 200 data = response.json() @@ -525,7 +525,7 @@ def test_set_session_peers(client, sample_data): # Create another peer peer2_name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": peer2_name, "metadata": {}}, ) assert response.status_code == 200 @@ -533,7 +533,7 @@ def test_set_session_peers(client, sample_data): # Create a test session session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -543,14 +543,14 @@ def test_set_session_peers(client, sample_data): # Set peers for the session (should replace existing peers) response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", json={peer2_name: {}}, ) assert response.status_code == 200 # Check that only the new peer is in the session response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", ) assert response.status_code == 200 data = response.json() @@ -565,7 +565,7 @@ def test_set_session_peers_with_limit(client, sample_data, caplog): # Create a test session with multiple peers session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, }, @@ -577,7 +577,7 @@ def test_set_session_peers_with_limit(client, sample_data, caplog): for _ in range(10): peer_name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": peer_name, "metadata": {}}, ) assert response.status_code == 200 @@ -586,7 +586,7 @@ def test_set_session_peers_with_limit(client, sample_data, caplog): # set peers with 11 peers (as a dict of peer_name: {}) peers_dict = {peer_name: {} for peer_name in peer_names} response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", json=peers_dict, ) assert response.status_code == 404 @@ -598,7 +598,7 @@ def test_remove_peers_from_session(client, sample_data): # Create another peer peer2_name = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": peer2_name, "metadata": {}}, ) assert response.status_code == 200 @@ -606,7 +606,7 @@ def test_remove_peers_from_session(client, sample_data): # Create a test session with multiple peers session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}, peer2_name: {}}, @@ -617,14 +617,14 @@ def test_remove_peers_from_session(client, sample_data): # Remove one peer from the session response = client.request( "DELETE", - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", json=[test_peer.name], ) assert response.status_code == 200 # Check that only the remaining peer is in the session response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/peers", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/peers", ) assert response.status_code == 200 data = response.json() @@ -640,13 +640,13 @@ def test_get_session_context(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peers": {test_peer.name: {}}}, ) # Add some messages to have context client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={ "messages": [ {"content": "Test message 1", "peer_id": test_peer.name}, @@ -657,7 +657,7 @@ def test_get_session_context(client, sample_data): # Get context response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/context", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/context", ) assert response.status_code == 200 data = response.json() @@ -677,13 +677,13 @@ def test_get_session_context_with_summary(client, sample_data): # Create session with messages client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peers": {test_peer.name: {}}}, ) # Get context with summary response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/context?summary=true", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/context?summary=true", ) assert response.status_code == 200 data = response.json() @@ -697,13 +697,13 @@ def test_get_session_context_with_tokens(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peers": {test_peer.name: {}}}, ) # Get context with token limit response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/context?tokens=100", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/context?tokens=100", ) assert response.status_code == 200 data = response.json() @@ -718,13 +718,13 @@ def test_get_session_context_with_all_params(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peers": {test_peer.name: {}}}, ) # Get context with all parameters response = client.get( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/context?tokens=100&summary=true", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/context?tokens=100&summary=true", ) assert response.status_code == 200 data = response.json() @@ -739,13 +739,13 @@ def test_search_session(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peers": {test_peer.name: {}}}, ) # Add messages to search through client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={ "messages": [ {"content": "Search this content", "peer_id": test_peer.name}, @@ -756,7 +756,7 @@ def test_search_session(client, sample_data): # Search with a query response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/search", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/search", json="search query", ) assert response.status_code == 200 @@ -777,13 +777,13 @@ def test_search_session_empty_query(client, sample_data): # Create session client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) # Search with empty query response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/search", json="" + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/search", json="" ) assert response.status_code == 200 data = response.json() @@ -799,7 +799,7 @@ def test_search_session_nonexistent(client, sample_data): nonexistent_session_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{nonexistent_session_id}/search", + f"/v2/workspaces/{test_workspace.name}/sessions/{nonexistent_session_id}/search", json="test query", ) # This should probably return 404 or handle gracefully diff --git a/tests/routes/test_validation_api.py b/tests/routes/test_validation_api.py index 038dca89..6725e1e7 100644 --- a/tests/routes/test_validation_api.py +++ b/tests/routes/test_validation_api.py @@ -3,7 +3,7 @@ from nanoid import generate as generate_nanoid def test_workspace_validations_api(client): # Test name too short - response = client.post("/v1/workspaces", json={"name": "", "metadata": {}}) + response = client.post("/v2/workspaces", json={"name": "", "metadata": {}}) assert response.status_code == 422 error = response.json()["detail"][0] assert error["loc"] == ["body", "name"] @@ -11,7 +11,7 @@ def test_workspace_validations_api(client): assert error["type"] == "string_too_short" # Test name too long - response = client.post("/v1/workspaces", json={"name": "a" * 101, "metadata": {}}) + response = client.post("/v2/workspaces", json={"name": "a" * 101, "metadata": {}}) assert response.status_code == 422 error = response.json()["detail"][0] assert error["loc"] == ["body", "name"] @@ -20,7 +20,7 @@ def test_workspace_validations_api(client): # Test invalid metadata type response = client.post( - "/v1/workspaces", json={"name": "test", "metadata": "not a dict"} + "/v2/workspaces", json={"name": "test", "metadata": "not a dict"} ) assert response.status_code == 422 error = response.json()["detail"][0] @@ -33,7 +33,7 @@ def test_peer_validations_api(client, sample_data): # Test name too short response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", json={"name": "", "metadata": {}} + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": "", "metadata": {}} ) assert response.status_code == 422 error = response.json()["detail"][0] @@ -43,7 +43,7 @@ def test_peer_validations_api(client, sample_data): # Test name too long response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers", + f"/v2/workspaces/{test_workspace.name}/peers", json={"name": "a" * 101, "metadata": {}}, ) assert response.status_code == 422 @@ -58,14 +58,14 @@ def test_message_validations_api(client, sample_data): # Create a test session first session_id = str(generate_nanoid()) session_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) assert session_response.status_code == 200 # Test content too long response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={ "messages": [ {"content": "a" * 50001, "peer_id": test_peer.name, "metadata": {}} @@ -84,7 +84,7 @@ def test_session_validations_api(client, sample_data): # Create a test session first session_id = str(generate_nanoid()) session_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, "peer_names": {test_peer.name: {}}, @@ -96,7 +96,7 @@ def test_session_validations_api(client, sample_data): # Test invalid metadata type response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={"metadata": "not a dict"}, ) assert response.status_code == 422 @@ -107,14 +107,14 @@ def test_session_validations_api(client, sample_data): # Test empty update # This should work but not change the session's metadata or configuration response = client.put( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}", json={}, ) assert response.status_code == 200 # Test that the session's metadata and configuration are not changed response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={ "id": session_id, }, @@ -130,14 +130,14 @@ def test_agent_query_validations_api(client, sample_data): # Create a session first since agent queries are session-based session_id = str(generate_nanoid()) session_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) assert session_response.status_code == 200 # Test valid string query (under 10000 chars) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", params={"session_id": session_id, "target": "test_target"}, json={"queries": "a" * 9999, "stream": False}, ) @@ -145,7 +145,7 @@ def test_agent_query_validations_api(client, sample_data): # Test string query too long (over 10000 chars) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", params={"session_id": session_id, "target": "test_target"}, json={"queries": "a" * 10001, "stream": False}, ) @@ -157,7 +157,7 @@ def test_agent_query_validations_api(client, sample_data): # Test valid list query (under 25 items, each under 10000 chars) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", params={"session_id": session_id, "target": "test_target"}, json={"queries": ["a" * 9999 for _ in range(25)], "stream": False}, ) @@ -165,7 +165,7 @@ def test_agent_query_validations_api(client, sample_data): # Test list too long (over 25 items) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", params={"session_id": session_id, "target": "test_target"}, json={"queries": ["test" for _ in range(26)], "stream": False}, ) @@ -176,7 +176,7 @@ def test_agent_query_validations_api(client, sample_data): # Test list item too long (item over 10000 chars) response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", params={"session_id": session_id, "target": "test_target"}, json={"queries": ["a" * 10001], "stream": False}, ) @@ -188,7 +188,7 @@ def test_agent_query_validations_api(client, sample_data): # Test that strings over 20 chars are allowed response = client.post( - f"/v1/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", + f"/v2/workspaces/{test_workspace.name}/peers/{test_peer.name}/chat", params={"session_id": session_id, "target": "test_target"}, json={"queries": "a" * 100, "stream": False}, # 100 chars should be fine ) @@ -199,14 +199,14 @@ def test_required_field_validations_api(client, sample_data): test_workspace, test_peer = sample_data session_id = str(generate_nanoid()) session_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) assert session_response.status_code == 200 # Test missing required content in message response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={"messages": [{"peer_id": test_peer.name, "metadata": {}}]}, ) assert response.status_code == 422 @@ -216,7 +216,7 @@ def test_required_field_validations_api(client, sample_data): # Test missing required peer_id in message response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages", json={"messages": [{"content": "test", "metadata": {}}]}, ) assert response.status_code == 422 @@ -230,14 +230,14 @@ def test_filter_validations_api(client, sample_data): # Create a session first session_id = str(generate_nanoid()) session_response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions", + f"/v2/workspaces/{test_workspace.name}/sessions", json={"id": session_id, "peer_names": {test_peer.name: {}}}, ) assert session_response.status_code == 200 # Test invalid filter type in message list (at session level) response = client.post( - f"/v1/workspaces/{test_workspace.name}/sessions/{session_id}/messages/list", + f"/v2/workspaces/{test_workspace.name}/sessions/{session_id}/messages/list", json={"filter": "not a dict"}, ) assert response.status_code == 422 diff --git a/tests/routes/test_workspaces.py b/tests/routes/test_workspaces.py index d77f4e42..158146c4 100644 --- a/tests/routes/test_workspaces.py +++ b/tests/routes/test_workspaces.py @@ -5,8 +5,8 @@ from nanoid import generate as generate_nanoid def test_get_or_create_workspace(client): name = str(generate_nanoid()) - # This should create the workspace using POST /v1/workspaces - response = client.post("/v1/workspaces", json={"name": name}) + # This should create the workspace using POST /v2/workspaces + response = client.post("/v2/workspaces", json={"name": name}) assert response.status_code == 200 data = response.json() assert data["id"] == name @@ -19,7 +19,7 @@ def test_get_or_create_workspace_with_configuration(client): configuration = {"feature1": True, "feature2": False} response = client.post( - "/v1/workspaces", json={"name": name, "configuration": configuration} + "/v2/workspaces", json={"name": name, "configuration": configuration} ) assert response.status_code == 200 data = response.json() @@ -34,7 +34,7 @@ def test_get_or_create_workspace_with_all_optional_params(client): configuration = {"experimental": True, "beta": False} response = client.post( - "/v1/workspaces", + "/v2/workspaces", json={"name": name, "metadata": metadata, "configuration": configuration}, ) assert response.status_code == 200 @@ -49,14 +49,14 @@ def test_get_or_create_existing_workspace(client): # Create the workspace response = client.post( - "/v1/workspaces", json={"name": name, "metadata": {"key": "value"}} + "/v2/workspaces", json={"name": name, "metadata": {"key": "value"}} ) assert response.status_code == 200 workspace1 = response.json() # Try to create the same workspace again - should return existing workspace response = client.post( - "/v1/workspaces", json={"name": name, "metadata": {"key": "value"}} + "/v2/workspaces", json={"name": name, "metadata": {"key": "value"}} ) assert response.status_code == 200 workspace2 = response.json() @@ -70,7 +70,7 @@ def test_get_or_create_existing_workspace(client): async def test_get_all_workspaces(client, db_session, sample_data): # create a test workspace with metadata response = client.post( - "/v1/workspaces", + "/v2/workspaces", json={ "name": "test_workspace", "metadata": {"test_key": "test_value"}, @@ -78,7 +78,7 @@ async def test_get_all_workspaces(client, db_session, sample_data): ) response = client.post( - "/v1/workspaces/list", + "/v2/workspaces/list", json={}, ) assert response.status_code == 200 @@ -87,7 +87,7 @@ async def test_get_all_workspaces(client, db_session, sample_data): assert len(data["items"]) > 0 response = client.post( - "/v1/workspaces/list", + "/v2/workspaces/list", json={"filter": {"test_key": "test_value"}}, ) assert response.status_code == 200 @@ -100,7 +100,7 @@ async def test_get_all_workspaces(client, db_session, sample_data): @pytest.mark.asyncio async def test_get_all_workspaces_with_empty_filter(client, db_session, sample_data): """Test workspace listing with empty filter object""" - response = client.post("/v1/workspaces/list", json={"filter": {}}) + response = client.post("/v2/workspaces/list", json={"filter": {}}) assert response.status_code == 200 data = response.json() assert "items" in data @@ -110,7 +110,7 @@ async def test_get_all_workspaces_with_empty_filter(client, db_session, sample_d @pytest.mark.asyncio async def test_get_all_workspaces_with_null_filter(client, db_session, sample_data): """Test workspace listing with null filter""" - response = client.post("/v1/workspaces/list", json={"filter": None}) + response = client.post("/v2/workspaces/list", json={"filter": None}) assert response.status_code == 200 data = response.json() assert "items" in data @@ -121,7 +121,7 @@ def test_update_workspace(client, sample_data): test_workspace, _ = sample_data _new_name = str(generate_nanoid()) response = client.put( - f"/v1/workspaces/{test_workspace.name}", + f"/v2/workspaces/{test_workspace.name}", json={"metadata": {"new_key": "new_value"}}, ) assert response.status_code == 200 @@ -135,7 +135,7 @@ def test_update_workspace_with_configuration(client, sample_data): configuration = {"new_feature": True, "legacy_feature": False} response = client.put( - f"/v1/workspaces/{test_workspace.name}", json={"configuration": configuration} + f"/v2/workspaces/{test_workspace.name}", json={"configuration": configuration} ) assert response.status_code == 200 data = response.json() @@ -149,7 +149,7 @@ def test_update_workspace_with_all_optional_params(client, sample_data): configuration = {"experimental": True, "beta": True} response = client.put( - f"/v1/workspaces/{test_workspace.name}", + f"/v2/workspaces/{test_workspace.name}", json={"metadata": metadata, "configuration": configuration}, ) assert response.status_code == 200 @@ -164,12 +164,12 @@ def test_update_workspace_with_null_metadata(client, sample_data): # First set some metadata client.put( - f"/v1/workspaces/{test_workspace.name}", json={"metadata": {"temp": "value"}} + f"/v2/workspaces/{test_workspace.name}", json={"metadata": {"temp": "value"}} ) # Then clear it with null response = client.put( - f"/v1/workspaces/{test_workspace.name}", json={"metadata": None} + f"/v2/workspaces/{test_workspace.name}", json={"metadata": None} ) assert response.status_code == 200 data = response.json() @@ -183,7 +183,7 @@ def test_update_workspace_with_null_configuration(client, sample_data): test_workspace, _ = sample_data response = client.put( - f"/v1/workspaces/{test_workspace.name}", json={"configuration": None} + f"/v2/workspaces/{test_workspace.name}", json={"configuration": None} ) assert response.status_code == 200 data = response.json() @@ -193,11 +193,11 @@ def test_update_workspace_with_null_configuration(client, sample_data): def test_create_duplicate_workspace_name(client): # Create an workspace name = str(generate_nanoid()) - response = client.post("/v1/workspaces", json={"name": name}) + response = client.post("/v2/workspaces", json={"name": name}) assert response.status_code == 200 # Try to create another workspace with the same name - should return existing workspace - response = client.post("/v1/workspaces", json={"name": name}) + response = client.post("/v2/workspaces", json={"name": name}) # Should return the existing workspace with 200 status (get_or_create behavior) assert response.status_code == 200 @@ -211,7 +211,7 @@ def test_search_workspace(client, sample_data): # Test search with a query response = client.post( - f"/v1/workspaces/{test_workspace.name}/search", json="test search query" + f"/v2/workspaces/{test_workspace.name}/search", json="test search query" ) assert response.status_code == 200 data = response.json() @@ -229,7 +229,7 @@ def test_search_workspace_empty_query(client, sample_data): test_workspace, _ = sample_data # Test search with empty query - response = client.post(f"/v1/workspaces/{test_workspace.name}/search", json="") + response = client.post(f"/v2/workspaces/{test_workspace.name}/search", json="") assert response.status_code == 200 data = response.json() @@ -243,6 +243,6 @@ def test_search_workspace_nonexistent(client): nonexistent_workspace_id = str(generate_nanoid()) response = client.post( - f"/v1/workspaces/{nonexistent_workspace_id}/search", json="test query" + f"/v2/workspaces/{nonexistent_workspace_id}/search", json="test query" ) assert response.status_code == 200