diff --git a/CHANGELOG.md b/CHANGELOG.md index e1707ad9..5e194440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [2.4.0] - 2025-10-08 +## [2.4.0] - 2025-10-09 ### Added @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Prometheus Client for better Metrics - Performance metrics instrumentation - Error reporting to deriver +- Workspace Delete Method +- Multi-db option in test harness ### Changed @@ -26,6 +28,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Semantic across codebase to reference resources based on `observer` and `observed` - Prompts for Deriver & Dialectic to reference peer_id and add examples - `Get Context` route returns peer card and representation in addition to messages and summaries +- Refactoring logger.info calls to logger.debug where applicable + +### Fixed + +- Gemini client to use async methods ## [2.3.3] — 2025-10-01 diff --git a/docs/changelog/introduction.mdx b/docs/changelog/introduction.mdx index 7ec64c88..062ec647 100644 --- a/docs/changelog/introduction.mdx +++ b/docs/changelog/introduction.mdx @@ -38,6 +38,8 @@ Welcome to the Honcho changelog! This section documents all notable changes to t - Prometheus Client for better Metrics - Performance metrics instrumentation - Error reporting to deriver + - Workspace Delete Method + - Multi-db option in test harness ### Changed @@ -47,6 +49,12 @@ Welcome to the Honcho changelog! This section documents all notable changes to t - Semantic across codebase to reference resources based on `observer` and `observed` - Prompts for Deriver & Dialectic to reference peer_id and add examples - `Get Context` route returns peer card and representation in addition to messages and summaries + - Refactoring logger.info calls to logger.debug where applicable + + ### Fixed + + - Gemini client to use async methods + @@ -328,9 +336,14 @@ Welcome to the Honcho changelog! This section documents all notable changes to t [Python SDK](https://pypi.org/project/honcho-ai/) - ### Changed + ### Added - - message_id of `Summary` model is a string nanoid + - Delete workspace method + + ### Changed + + - message_id of `Summary` model is a string nanoid + - Get Context can return Peer Card & Peer Representation ### Added @@ -397,9 +410,14 @@ Welcome to the Honcho changelog! This section documents all notable changes to t [TypeScript SDK](https://www.npmjs.com/package/@honcho-ai/sdk) - ### Changed + ### Added - - message_id of `Summary` model is a string nanoid + - Delete workspace method + + ### Changed + + - message_id of `Summary` model is a string nanoid + - Get Context can return Peer Card & Peer Representation ### Added diff --git a/docs/docs.json b/docs/docs.json index 84120065..3b3e5f91 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -88,6 +88,7 @@ "v2/api-reference/endpoint/workspaces/get-or-create-workspace", "v2/api-reference/endpoint/workspaces/get-all-workspaces", "v2/api-reference/endpoint/workspaces/update-workspace", + "v2/api-reference/endpoint/workspaces/delete-workspace", "v2/api-reference/endpoint/workspaces/search-workspace", "v2/api-reference/endpoint/workspaces/get-deriver-status" ] diff --git a/docs/v2/api-reference/endpoint/workspaces/delete-workspace.mdx b/docs/v2/api-reference/endpoint/workspaces/delete-workspace.mdx new file mode 100644 index 00000000..f8eb6168 --- /dev/null +++ b/docs/v2/api-reference/endpoint/workspaces/delete-workspace.mdx @@ -0,0 +1,3 @@ +--- +openapi: delete /v2/workspaces/{workspace_id} +--- diff --git a/docs/v2/openapi.documented.json b/docs/v2/openapi.documented.json deleted file mode 100644 index 09daa5f7..00000000 --- a/docs/v2/openapi.documented.json +++ /dev/null @@ -1,4514 +0,0 @@ -{ - "openapi": "3.1.0", - "info": { - "title": "Honcho API", - "summary": "The Identity Layer for the Agentic World", - "description": "Honcho is a platform for giving agents user-centric memory and social cognition", - "contact": { - "name": "Plastic Labs", - "url": "https://honcho.dev/", - "email": "hello@plasticlabs.ai" - }, - "version": "2.4.0" - }, - "servers": [ - { - "url": "http://localhost:8000", - "description": "Local Development Server" - }, - { - "url": "https://demo.honcho.dev", - "description": "Demo Server" - }, - { - "url": "https://api.honcho.dev", - "description": "Production SaaS Platform" - } - ], - "paths": { - "/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.", - "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/Workspace" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst workspace = await client.workspaces.getOrCreate({ id: 'id' });\n\nconsole.log(workspace.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nworkspace = client.workspaces.get_or_create(\n id=\"id\",\n)\nprint(workspace.id)" - } - ] - } - }, - "/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" - }, - { - "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/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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const workspace of client.workspaces.list()) {\n console.log(workspace.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.list()\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/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/WorkspaceUpdate", - "description": "Updated workspace parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Workspace" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst workspace = await client.workspaces.update('workspace_id');\n\nconsole.log(workspace.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nworkspace = client.workspaces.update(\n workspace_id=\"workspace_id\",\n)\nprint(workspace.id)" - } - ] - } - }, - "/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" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MessageSearchOptions", - "description": "Message search parameters " - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Message" - }, - "title": "Response Search Workspace V2 Workspaces Workspace Id Search Post" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst messages = await client.workspaces.search('workspace_id', { query: 'query' });\n\nconsole.log(messages);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessages = client.workspaces.search(\n workspace_id=\"workspace_id\",\n query=\"query\",\n)\nprint(messages)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/deriver/status": { - "get": { - "tags": ["workspaces"], - "summary": "Get Deriver Status", - "description": "Get the deriver processing status, optionally scoped to an observer, sender, and/or session", - "operationId": "get_deriver_status_v2_workspaces__workspace_id__deriver_status_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": "observer_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "Optional observer ID to filter by", - "title": "Observer Id" - }, - "description": "Optional observer ID to filter by" - }, - { - "name": "sender_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "Optional sender ID to filter by", - "title": "Sender Id" - }, - "description": "Optional sender ID to filter by" - }, - { - "name": "session_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "Optional session ID to filter by", - "title": "Session Id" - }, - "description": "Optional session ID to filter by" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeriverStatus" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst deriverStatus = await client.workspaces.deriverStatus('workspace_id');\n\nconsole.log(deriverStatus.completed_work_units);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nderiver_status = client.workspaces.deriver_status(\n workspace_id=\"workspace_id\",\n)\nprint(deriver_status.completed_work_units)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/peers/list": { - "post": { - "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const peer of client.workspaces.peers.list('workspace_id')) {\n console.log(peer.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.peers.list(\n workspace_id=\"workspace_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/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.", - "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst peer = await client.workspaces.peers.getOrCreate('workspace_id', { id: 'id' });\n\nconsole.log(peer.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npeer = client.workspaces.peers.get_or_create(\n workspace_id=\"workspace_id\",\n id=\"id\",\n)\nprint(peer.id)" - } - ] - } - }, - "/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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst peer = await client.workspaces.peers.update('workspace_id', 'peer_id');\n\nconsole.log(peer.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npeer = client.workspaces.peers.update(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n)\nprint(peer.id)" - } - ] - } - }, - "/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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const session of client.workspaces.peers.sessions.list('workspace_id', 'peer_id')) {\n console.log(session.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.peers.sessions.list(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/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": { - "properties": { - "content": { - "title": "Content", - "type": "string" - } - }, - "required": ["content"], - "title": "DialecticResponse", - "type": "object" - } - }, - "text/event-stream": {} - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.peers.chat('workspace_id', 'peer_id', { query: 'x' });\n\nconsole.log(response.content);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.peers.chat(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n query=\"x\",\n)\nprint(response.content)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/peers/{peer_id}/representation": { - "post": { - "tags": ["peers"], - "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.\nIf a target is provided, we get the representation of the target from the perspective of the peer.\nIf no target is provided, we get the omniscient Honcho representation of the peer.", - "operationId": "get_working_representation_v2_workspaces__workspace_id__peers__peer_id__representation_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/PeerRepresentationGet", - "description": "Options for getting the peer representation" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": true, - "title": "Response Get Working Representation V2 Workspaces Workspace Id Peers Peer Id Representation Post" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.peers.workingRepresentation('workspace_id', 'peer_id');\n\nconsole.log(response);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.peers.working_representation(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n)\nprint(response)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/peers/{peer_id}/card": { - "get": { - "tags": ["peers"], - "summary": "Get Peer Card", - "description": "Get a peer card for a specific peer relationship.\n\nReturns the peer card that the observer peer has for the target peer if it exists.\nIf no target is specified, returns the observer's own peer card.", - "operationId": "get_peer_card_v2_workspaces__workspace_id__peers__peer_id__card_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": "peer_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the observer peer", - "title": "Peer Id" - }, - "description": "ID of the observer peer" - }, - { - "name": "target", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "The peer whose card to retrieve. If not provided, returns the observer's own card", - "title": "Target" - }, - "description": "The peer whose card to retrieve. If not provided, returns the observer's own card" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PeerCardResponse" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.peers.card('workspace_id', 'peer_id');\n\nconsole.log(response.peer_card);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.peers.card(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n)\nprint(response.peer_card)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/peers/{peer_id}/search": { - "post": { - "tags": ["peers"], - "summary": "Search Peer", - "description": "Search a Peer", - "operationId": "search_peer_v2_workspaces__workspace_id__peers__peer_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": "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/MessageSearchOptions", - "description": "Message search parameters " - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Message" - }, - "title": "Response Search Peer V2 Workspaces Workspace Id Peers Peer Id Search Post" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst messages = await client.workspaces.peers.search('workspace_id', 'peer_id', { query: 'query' });\n\nconsole.log(messages);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessages = client.workspaces.peers.search(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n query=\"query\",\n)\nprint(messages)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions": { - "post": { - "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 for verification.", - "operationId": "get_or_create_session_v2_workspaces__workspace_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" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SessionCreate", - "description": "Session creation parameters" - } - } - } - }, - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.getOrCreate('workspace_id', { id: 'id' });\n\nconsole.log(session.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.get_or_create(\n workspace_id=\"workspace_id\",\n id=\"id\",\n)\nprint(session.id)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/list": { - "post": { - "tags": ["sessions"], - "summary": "Get Sessions", - "description": "Get All Sessions in a Workspace", - "operationId": "get_sessions_v2_workspaces__workspace_id__sessions_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/SessionGet" - }, - { - "type": "null" - } - ], - "description": "Filtering and pagination 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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const session of client.workspaces.sessions.list('workspace_id')) {\n console.log(session.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.sessions.list(\n workspace_id=\"workspace_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}": { - "put": { - "tags": ["sessions"], - "summary": "Update Session", - "description": "Update the metadata of a Session", - "operationId": "update_session_v2_workspaces__workspace_id__sessions__session_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": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the session to update", - "title": "Session Id" - }, - "description": "ID of the session to update" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SessionUpdate", - "description": "Updated session parameters" - } - } - } - }, - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.update('workspace_id', 'session_id');\n\nconsole.log(session.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.update(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\nprint(session.id)" - } - ] - }, - "delete": { - "tags": ["sessions"], - "summary": "Delete Session", - "description": "Delete a session by marking it as inactive", - "operationId": "delete_session_v2_workspaces__workspace_id__sessions__session_id__delete", - "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 to delete", - "title": "Session Id" - }, - "description": "ID of the session 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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.delete('workspace_id', 'session_id');\n\nconsole.log(session);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.delete(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\nprint(session)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/clone": { - "get": { - "tags": ["sessions"], - "summary": "Clone Session", - "description": "Clone a session, optionally up to a specific message", - "operationId": "clone_session_v2_workspaces__workspace_id__sessions__session_id__clone_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 to clone", - "title": "Session Id" - }, - "description": "ID of the session to clone" - }, - { - "name": "message_id", - "in": "query", - "required": false, - "schema": { - "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" - } - ], - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.clone('workspace_id', 'session_id');\n\nconsole.log(session.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.clone(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\nprint(session.id)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/peers": { - "post": { - "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": "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 add to 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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.peers.add('workspace_id', 'session_id', { foo: {} });\n\nconsole.log(session.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.peers.add(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n body={\n \"foo\": {}\n },\n)\nprint(session.id)" - } - ] - }, - "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" - } - } - } - }, - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.peers.set('workspace_id', 'session_id', { foo: {} });\n\nconsole.log(session.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.peers.set(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n body={\n \"foo\": {}\n },\n)\nprint(session.id)" - } - ] - }, - "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": "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": "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst session = await client.workspaces.sessions.peers.remove('workspace_id', 'session_id', ['string']);\n\nconsole.log(session.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession = client.workspaces.sessions.peers.remove(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n body=[\"string\"],\n)\nprint(session.id)" - } - ] - }, - "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const peer of client.workspaces.sessions.peers.list('workspace_id', 'session_id')) {\n console.log(peer.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.sessions.peers.list(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst sessionPeerConfig = await client.workspaces.sessions.peers.getConfig(\n 'workspace_id',\n 'session_id',\n 'peer_id',\n);\n\nconsole.log(sessionPeerConfig.observe_me);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nsession_peer_config = client.workspaces.sessions.peers.get_config(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n session_id=\"session_id\",\n)\nprint(session_peer_config.observe_me)" - } - ] - }, - "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.sessions.peers.setConfig('workspace_id', 'session_id', 'peer_id');\n\nconsole.log(response);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.sessions.peers.set_config(\n peer_id=\"peer_id\",\n workspace_id=\"workspace_id\",\n session_id=\"session_id\",\n)\nprint(response)" - } - ] - } - }, - "/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 an optional token limit which the entire context must fit into.\nIf not provided, the context will be exhaustive (within configured max tokens). To do this, we allocate 40% of the token limit\nto the summary, and 60% to recent messages -- as many as can fit. Note that the summary will usually take up less space than\nthis. If the caller does not want a summary, we allocate all the tokens to recent messages.", - "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", - "maximum": 100000 - }, - { - "type": "null" - } - ], - "description": "Number of tokens to use for the context. Includes summary if set to true. Includes representation and peer card if they are included in the response. If not provided, the context will be exhaustive (within 100000 tokens)", - "title": "Tokens" - }, - "description": "Number of tokens to use for the context. Includes summary if set to true. Includes representation and peer card if they are included in the response. If not provided, the context will be exhaustive (within 100000 tokens)" - }, - { - "name": "last_message", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "The most recent message, used to fetch semantically relevant observations", - "title": "Last Message" - }, - "description": "The most recent message, used to fetch semantically relevant observations" - }, - { - "name": "summary", - "in": "query", - "required": false, - "schema": { - "type": "boolean", - "description": "Whether or not to include a summary *if* one is available for the session", - "default": true, - "title": "Summary" - }, - "description": "Whether or not to include a summary *if* one is available for the session" - }, - { - "name": "peer_target", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "The target of the perspective. If given without `peer_perspective`, will get the Honcho-level representation and peer card for this peer. If given with `peer_perspective`, will get the representation and card for this peer *from the perspective of that peer*.", - "title": "Peer Target" - }, - "description": "The target of the perspective. If given without `peer_perspective`, will get the Honcho-level representation and peer card for this peer. If given with `peer_perspective`, will get the representation and card for this peer *from the perspective of that peer*." - }, - { - "name": "peer_perspective", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "A peer to get context for. If given, response will attempt to include representation and card from the perspective of that peer. Must be provided with `peer_target`.", - "title": "Peer Perspective" - }, - "description": "A peer to get context for. If given, response will attempt to include representation and card from the perspective of that peer. Must be provided with `peer_target`." - } - ], - "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.sessions.getContext('workspace_id', 'session_id');\n\nconsole.log(response.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.sessions.get_context(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\nprint(response.id)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/summaries": { - "get": { - "tags": ["sessions"], - "summary": "Get Session Summaries", - "description": "Get available summaries for a session.\n\nReturns both short and long summaries if available, including metadata like\nthe message ID they cover up to, creation timestamp, and token count.", - "operationId": "get_session_summaries_v2_workspaces__workspace_id__sessions__session_id__summaries_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" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SessionSummaries" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.sessions.summaries('workspace_id', 'session_id');\n\nconsole.log(response.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.sessions.summaries(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\nprint(response.id)" - } - ] - } - }, - "/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" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MessageSearchOptions", - "description": "Message search parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Message" - }, - "title": "Response Search Session V2 Workspaces Workspace Id Sessions Session Id Search Post" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst messages = await client.workspaces.sessions.search('workspace_id', 'session_id', { query: 'query' });\n\nconsole.log(messages);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessages = client.workspaces.sessions.search(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n query=\"query\",\n)\nprint(messages)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/": { - "post": { - "tags": ["messages"], - "summary": "Create Messages For Session", - "description": "Create messages for a session with JSON data (original functionality).", - "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", - "title": "Workspace Id" - } - }, - { - "name": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "title": "Session Id" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MessageBatchCreate" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Message" - }, - "title": "Response Create Messages For Session V2 Workspaces Workspace Id Sessions Session Id Messages Post" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst messages = await client.workspaces.sessions.messages.create('workspace_id', 'session_id', {\n messages: [{ content: 'content', peer_id: 'peer_id' }],\n});\n\nconsole.log(messages);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessages = client.workspaces.sessions.messages.create(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n messages=[{\n \"content\": \"content\",\n \"peer_id\": \"peer_id\",\n }],\n)\nprint(messages)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/upload": { - "post": { - "tags": ["messages"], - "summary": "Create Messages With File", - "description": "Create messages from uploaded files. Files are converted to text and split into multiple messages.", - "operationId": "create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post", - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "parameters": [ - { - "name": "workspace_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "title": "Workspace Id" - } - }, - { - "name": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "title": "Session Id" - } - } - ], - "requestBody": { - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/Body_create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Message" - }, - "title": "Response Create Messages With File V2 Workspaces Workspace Id Sessions Session Id Messages Upload Post" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst messages = await client.workspaces.sessions.messages.upload('workspace_id', 'session_id', {\n file: fs.createReadStream('path/to/file'),\n peer_id: 'peer_id',\n});\n\nconsole.log(messages);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessages = client.workspaces.sessions.messages.upload(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n file=b\"raw file contents\",\n peer_id=\"peer_id\",\n)\nprint(messages)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/list": { - "post": { - "tags": ["messages"], - "summary": "Get Messages", - "description": "Get all messages for a session", - "operationId": "get_messages_v2_workspaces__workspace_id__sessions__session_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": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the session", - "title": "Session Id" - }, - "description": "ID of the session" - }, - { - "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/MessageGet" - }, - { - "type": "null" - } - ], - "description": "Filtering options for the messages list", - "title": "Options" - } - } - } - }, - "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" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const message of client.workspaces.sessions.messages.list('workspace_id', 'session_id')) {\n console.log(message.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.sessions.messages.list(\n session_id=\"session_id\",\n workspace_id=\"workspace_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/sessions/{session_id}/messages/{message_id}": { - "get": { - "tags": ["messages"], - "summary": "Get Message", - "description": "Get a Message by ID", - "operationId": "get_message_v2_workspaces__workspace_id__sessions__session_id__messages__message_id__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": "message_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the message to retrieve", - "title": "Message Id" - }, - "description": "ID of the message to retrieve" - } - ], - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst message = await client.workspaces.sessions.messages.retrieve(\n 'workspace_id',\n 'session_id',\n 'message_id',\n);\n\nconsole.log(message.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessage = client.workspaces.sessions.messages.retrieve(\n message_id=\"message_id\",\n workspace_id=\"workspace_id\",\n session_id=\"session_id\",\n)\nprint(message.id)" - } - ] - }, - "put": { - "tags": ["messages"], - "summary": "Update Message", - "description": "Update the metadata of a Message", - "operationId": "update_message_v2_workspaces__workspace_id__sessions__session_id__messages__message_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": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the session", - "title": "Session Id" - }, - "description": "ID of the session" - }, - { - "name": "message_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "ID of the message to update", - "title": "Message Id" - }, - "description": "ID of the message to update" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MessageUpdate", - "description": "Updated message parameters" - } - } - } - }, - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst message = await client.workspaces.sessions.messages.update('workspace_id', 'session_id', 'message_id');\n\nconsole.log(message.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nmessage = client.workspaces.sessions.messages.update(\n message_id=\"message_id\",\n workspace_id=\"workspace_id\",\n session_id=\"session_id\",\n)\nprint(message.id)" - } - ] - } - }, - "/v2/keys": { - "post": { - "tags": ["keys"], - "summary": "Create Key", - "description": "Create a new Key", - "operationId": "create_key_v2_keys_post", - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "parameters": [ - { - "name": "workspace_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "ID of the workspace to scope the key to", - "title": "Workspace Id" - }, - "description": "ID of the workspace to scope the key to" - }, - { - "name": "peer_id", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "description": "ID of the peer to scope the key to", - "title": "Peer Id" - }, - "description": "ID of the peer to scope the key to" - }, - { - "name": "session_id", - "in": "query", - "required": false, - "schema": { - "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": "expires_at", - "in": "query", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string", - "format": "date-time" - }, - { - "type": "null" - } - ], - "title": "Expires At" - } - } - ], - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst key = await client.keys.create();\n\nconsole.log(key);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nkey = client.keys.create()\nprint(key)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/webhooks": { - "post": { - "tags": ["webhooks"], - "summary": "Get Or Create Webhook Endpoint", - "description": "Get or create a webhook endpoint URL.", - "operationId": "get_or_create_webhook_endpoint_v2_workspaces__workspace_id__webhooks_post", - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "parameters": [ - { - "name": "workspace_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Workspace ID", - "title": "Workspace Id" - }, - "description": "Workspace ID" - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/WebhookEndpointCreate", - "description": "Webhook endpoint parameters" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/WebhookEndpoint" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst webhookEndpoint = await client.workspaces.webhooks.getOrCreate('workspace_id', { url: 'url' });\n\nconsole.log(webhookEndpoint.id);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nwebhook_endpoint = client.workspaces.webhooks.get_or_create(\n workspace_id=\"workspace_id\",\n url=\"url\",\n)\nprint(webhook_endpoint.id)" - } - ] - }, - "get": { - "tags": ["webhooks"], - "summary": "List Webhook Endpoints", - "description": "List all webhook endpoints, optionally filtered by workspace.", - "operationId": "list_webhook_endpoints_v2_workspaces__workspace_id__webhooks_get", - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "parameters": [ - { - "name": "workspace_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Workspace ID", - "title": "Workspace Id" - }, - "description": "Workspace ID" - }, - { - "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_WebhookEndpoint_" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-codeSamples": [ - { - "lang": "JavaScript", - "source": "import Honcho from '@honcho-ai/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\n// Automatically fetches more pages as needed.\nfor await (const webhookEndpoint of client.workspaces.webhooks.list('workspace_id')) {\n console.log(webhookEndpoint.id);\n}" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\npage = client.workspaces.webhooks.list(\n workspace_id=\"workspace_id\",\n)\npage = page.items[0]\nprint(page.id)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/webhooks/{endpoint_id}": { - "delete": { - "tags": ["webhooks"], - "summary": "Delete Webhook Endpoint", - "description": "Delete a specific webhook endpoint.", - "operationId": "delete_webhook_endpoint_v2_workspaces__workspace_id__webhooks__endpoint_id__delete", - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "parameters": [ - { - "name": "workspace_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Workspace ID", - "title": "Workspace Id" - }, - "description": "Workspace ID" - }, - { - "name": "endpoint_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Webhook endpoint ID", - "title": "Endpoint Id" - }, - "description": "Webhook endpoint ID" - } - ], - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst webhook = await client.workspaces.webhooks.delete('workspace_id', 'endpoint_id');\n\nconsole.log(webhook);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nwebhook = client.workspaces.webhooks.delete(\n endpoint_id=\"endpoint_id\",\n workspace_id=\"workspace_id\",\n)\nprint(webhook)" - } - ] - } - }, - "/v2/workspaces/{workspace_id}/webhooks/test": { - "get": { - "tags": ["webhooks"], - "summary": "Test Emit", - "description": "Test publishing a webhook event.", - "operationId": "test_emit_v2_workspaces__workspace_id__webhooks_test_get", - "security": [ - { - "HTTPBearer": [] - }, - {} - ], - "parameters": [ - { - "name": "workspace_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "Workspace ID", - "title": "Workspace Id" - }, - "description": "Workspace ID" - } - ], - "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/core';\n\nconst client = new Honcho({\n apiKey: 'My API Key',\n});\n\nconst response = await client.workspaces.webhooks.testEmit('workspace_id');\n\nconsole.log(response);" - }, - { - "lang": "Python", - "source": "from honcho_core import Honcho\n\nclient = Honcho(\n api_key=\"My API Key\",\n)\nresponse = client.workspaces.webhooks.test_emit(\n \"workspace_id\",\n)\nprint(response)" - } - ] - } - }, - "/metrics": { - "get": { - "summary": "Metrics", - "description": "Prometheus metrics endpoint", - "operationId": "metrics_metrics_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": {} - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Body_create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post": { - "properties": { - "file": { - "type": "string", - "format": "binary", - "title": "File" - }, - "peer_id": { - "type": "string", - "title": "Peer Id" - } - }, - "type": "object", - "required": ["file", "peer_id"], - "title": "Body_create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post" - }, - "DeductiveObservation": { - "properties": { - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "message_ids": { - "items": { - "prefixItems": [ - { - "type": "integer" - }, - { - "type": "integer" - } - ], - "type": "array", - "maxItems": 2, - "minItems": 2 - }, - "type": "array", - "title": "Message Ids" - }, - "session_name": { - "type": "string", - "title": "Session Name" - }, - "premises": { - "items": { - "type": "string" - }, - "type": "array", - "title": "Premises", - "description": "Supporting premises or evidence for this conclusion" - }, - "conclusion": { - "type": "string", - "title": "Conclusion", - "description": "The deductive conclusion" - } - }, - "type": "object", - "required": ["created_at", "message_ids", "session_name", "conclusion"], - "title": "DeductiveObservation", - "description": "Deductive observation with multiple premises and one conclusion, plus metadata." - }, - "DeriverStatus": { - "properties": { - "total_work_units": { - "type": "integer", - "title": "Total Work Units", - "description": "Total work units" - }, - "completed_work_units": { - "type": "integer", - "title": "Completed Work Units", - "description": "Completed work units" - }, - "in_progress_work_units": { - "type": "integer", - "title": "In Progress Work Units", - "description": "Work units currently being processed" - }, - "pending_work_units": { - "type": "integer", - "title": "Pending Work Units", - "description": "Work units waiting to be processed" - }, - "sessions": { - "anyOf": [ - { - "additionalProperties": { - "$ref": "#/components/schemas/SessionDeriverStatus" - }, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Sessions", - "description": "Per-session status when not filtered by session" - } - }, - "type": "object", - "required": [ - "total_work_units", - "completed_work_units", - "in_progress_work_units", - "pending_work_units" - ], - "title": "DeriverStatus" - }, - "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" - }, - "query": { - "type": "string", - "maxLength": 10000, - "minLength": 1, - "title": "Query", - "description": "Dialectic API Prompt" - }, - "stream": { - "type": "boolean", - "title": "Stream", - "default": false - } - }, - "type": "object", - "required": ["query"], - "title": "DialecticOptions" - }, - "ExplicitObservation": { - "properties": { - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "message_ids": { - "items": { - "prefixItems": [ - { - "type": "integer" - }, - { - "type": "integer" - } - ], - "type": "array", - "maxItems": 2, - "minItems": 2 - }, - "type": "array", - "title": "Message Ids" - }, - "session_name": { - "type": "string", - "title": "Session Name" - }, - "content": { - "type": "string", - "title": "Content", - "description": "The explicit observation" - } - }, - "type": "object", - "required": ["created_at", "message_ids", "session_name", "content"], - "title": "ExplicitObservation", - "description": "Explicit observation with content and metadata." - }, - "HTTPValidationError": { - "properties": { - "detail": { - "items": { - "$ref": "#/components/schemas/ValidationError" - }, - "type": "array", - "title": "Detail" - } - }, - "type": "object", - "title": "HTTPValidationError" - }, - "Message": { - "properties": { - "id": { - "type": "string", - "title": "Id" - }, - "content": { - "type": "string", - "title": "Content" - }, - "peer_id": { - "type": "string", - "title": "Peer Id" - }, - "session_id": { - "type": "string", - "title": "Session Id" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "workspace_id": { - "type": "string", - "title": "Workspace Id" - }, - "token_count": { - "type": "integer", - "title": "Token Count" - } - }, - "type": "object", - "required": [ - "id", - "content", - "peer_id", - "session_id", - "created_at", - "workspace_id", - "token_count" - ], - "title": "Message" - }, - "MessageBatchCreate": { - "properties": { - "messages": { - "items": { - "$ref": "#/components/schemas/MessageCreate" - }, - "type": "array", - "maxItems": 100, - "minItems": 1, - "title": "Messages" - } - }, - "type": "object", - "required": ["messages"], - "title": "MessageBatchCreate", - "description": "Schema for batch message creation with a max of 100 messages" - }, - "MessageCreate": { - "properties": { - "content": { - "type": "string", - "maxLength": 25000, - "minLength": 0, - "title": "Content" - }, - "peer_id": { - "type": "string", - "title": "Peer Id" - }, - "metadata": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Metadata" - }, - "created_at": { - "anyOf": [ - { - "type": "string", - "format": "date-time" - }, - { - "type": "null" - } - ], - "title": "Created At" - } - }, - "type": "object", - "required": ["content", "peer_id"], - "title": "MessageCreate" - }, - "MessageGet": { - "properties": { - "filters": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Filters" - } - }, - "type": "object", - "title": "MessageGet" - }, - "MessageSearchOptions": { - "properties": { - "query": { - "type": "string", - "title": "Query", - "description": "Search query" - }, - "filters": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Filters", - "description": "Filters to scope the search" - }, - "limit": { - "type": "integer", - "maximum": 100, - "minimum": 1, - "title": "Limit", - "description": "Number of results to return", - "default": 10 - } - }, - "type": "object", - "required": ["query"], - "title": "MessageSearchOptions" - }, - "MessageUpdate": { - "properties": { - "metadata": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Metadata" - } - }, - "type": "object", - "title": "MessageUpdate" - }, - "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", "page", "size"], - "title": "Page[Message]" - }, - "Page_Peer_": { - "properties": { - "items": { - "items": { - "$ref": "#/components/schemas/Peer" - }, - "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", "page", "size"], - "title": "Page[Peer]" - }, - "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", "page", "size"], - "title": "Page[Session]" - }, - "Page_WebhookEndpoint_": { - "properties": { - "items": { - "items": { - "$ref": "#/components/schemas/WebhookEndpoint" - }, - "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", "page", "size"], - "title": "Page[WebhookEndpoint]" - }, - "Page_Workspace_": { - "properties": { - "items": { - "items": { - "$ref": "#/components/schemas/Workspace" - }, - "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", "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" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata" - }, - "configuration": { - "additionalProperties": true, - "type": "object", - "title": "Configuration" - } - }, - "type": "object", - "required": ["id", "workspace_id", "created_at"], - "title": "Peer" - }, - "PeerCardResponse": { - "properties": { - "peer_card": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "title": "Peer Card", - "description": "The peer card content, or None if not found" - } - }, - "type": "object", - "title": "PeerCardResponse" - }, - "PeerCreate": { - "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" - }, - "configuration": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Configuration" - } - }, - "type": "object", - "required": ["id"], - "title": "PeerCreate" - }, - "PeerGet": { - "properties": { - "filters": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Filters" - } - }, - "type": "object", - "title": "PeerGet" - }, - "PeerRepresentationGet": { - "properties": { - "session_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Session Id", - "description": "Get the working representation within this session" - }, - "target": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Target", - "description": "Optional peer ID to get the representation for, from the perspective of this peer" - } - }, - "type": "object", - "title": "PeerRepresentationGet" - }, - "PeerUpdate": { - "properties": { - "metadata": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Metadata" - }, - "configuration": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Configuration" - } - }, - "type": "object", - "title": "PeerUpdate" - }, - "Representation": { - "properties": { - "explicit": { - "items": { - "$ref": "#/components/schemas/ExplicitObservation" - }, - "type": "array", - "title": "Explicit", - "description": "Facts LITERALLY stated by the user - direct quotes or clear paraphrases only, no interpretation or inference. Example: ['The user is 25 years old', 'The user has a dog']" - }, - "deductive": { - "items": { - "$ref": "#/components/schemas/DeductiveObservation" - }, - "type": "array", - "title": "Deductive", - "description": "Conclusions that MUST be true given explicit facts and premises - strict logical necessities. Each deduction should have premises and a single conclusion." - } - }, - "type": "object", - "title": "Representation", - "description": "A Representation is a traversable and diffable map of observations.\nAt the base, we have a list of explicit observations, derived from a peer's messages.\n\nFrom there, deductive observations can be made by establishing logical relationships between explicit observations.\n\nIn the future, we can add more levels of reasoning on top of these.\n\nAll of a peer's observations are stored as documents in a collection. These documents can be queried in various ways\nto produce this Representation object.\n\nAdditionally, a \"working representation\" is a version of this data structure representing the most recent observations\nwithin a single session.\n\nA representation can have a maximum number of observations, which is applied individually to each level of reasoning.\nIf a maximum is set, observations are added and removed in FIFO order." - }, - "Session": { - "properties": { - "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" - }, - "configuration": { - "additionalProperties": true, - "type": "object", - "title": "Configuration" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - } - }, - "type": "object", - "required": ["id", "is_active", "workspace_id", "created_at"], - "title": "Session" - }, - "SessionContext": { - "properties": { - "id": { - "type": "string", - "title": "Id" - }, - "messages": { - "items": { - "$ref": "#/components/schemas/Message" - }, - "type": "array", - "title": "Messages" - }, - "summary": { - "anyOf": [ - { - "$ref": "#/components/schemas/Summary" - }, - { - "type": "null" - } - ], - "description": "The summary if available" - }, - "peer_representation": { - "anyOf": [ - { - "$ref": "#/components/schemas/Representation" - }, - { - "type": "null" - } - ], - "description": "The peer representation, if context is requested from a specific perspective" - }, - "peer_card": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "title": "Peer Card", - "description": "The peer card, if context is requested from a specific perspective" - } - }, - "type": "object", - "required": ["id", "messages"], - "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" - }, - "SessionDeriverStatus": { - "properties": { - "session_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Session Id", - "description": "Session ID if filtered by session" - }, - "total_work_units": { - "type": "integer", - "title": "Total Work Units", - "description": "Total work units" - }, - "completed_work_units": { - "type": "integer", - "title": "Completed Work Units", - "description": "Completed work units" - }, - "in_progress_work_units": { - "type": "integer", - "title": "In Progress Work Units", - "description": "Work units currently being processed" - }, - "pending_work_units": { - "type": "integer", - "title": "Pending Work Units", - "description": "Work units waiting to be processed" - } - }, - "type": "object", - "required": [ - "total_work_units", - "completed_work_units", - "in_progress_work_units", - "pending_work_units" - ], - "title": "SessionDeriverStatus" - }, - "SessionGet": { - "properties": { - "filters": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Filters" - } - }, - "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" - }, - "SessionSummaries": { - "properties": { - "id": { - "type": "string", - "title": "Id" - }, - "short_summary": { - "anyOf": [ - { - "$ref": "#/components/schemas/Summary" - }, - { - "type": "null" - } - ], - "description": "The short summary if available" - }, - "long_summary": { - "anyOf": [ - { - "$ref": "#/components/schemas/Summary" - }, - { - "type": "null" - } - ], - "description": "The long summary if available" - } - }, - "type": "object", - "required": ["id"], - "title": "SessionSummaries" - }, - "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" - }, - "Summary": { - "properties": { - "content": { - "type": "string", - "title": "Content", - "description": "The summary text" - }, - "message_id": { - "type": "string", - "title": "Message Id", - "description": "The public ID of the message that this summary covers up to" - }, - "summary_type": { - "type": "string", - "title": "Summary Type", - "description": "The type of summary (short or long)" - }, - "created_at": { - "type": "string", - "title": "Created At", - "description": "The timestamp of when the summary was created (ISO format)" - }, - "token_count": { - "type": "integer", - "title": "Token Count", - "description": "The number of tokens in the summary text" - } - }, - "type": "object", - "required": [ - "content", - "message_id", - "summary_type", - "created_at", - "token_count" - ], - "title": "Summary" - }, - "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" - }, - "WebhookEndpoint": { - "properties": { - "id": { - "type": "string", - "title": "Id" - }, - "workspace_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Workspace Id" - }, - "url": { - "type": "string", - "title": "Url" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - } - }, - "type": "object", - "required": ["id", "workspace_id", "url", "created_at"], - "title": "WebhookEndpoint" - }, - "WebhookEndpointCreate": { - "properties": { - "url": { - "type": "string", - "title": "Url" - } - }, - "type": "object", - "required": ["url"], - "title": "WebhookEndpointCreate" - }, - "Workspace": { - "properties": { - "id": { - "type": "string", - "title": "Id" - }, - "metadata": { - "additionalProperties": true, - "type": "object", - "title": "Metadata" - }, - "configuration": { - "additionalProperties": true, - "type": "object", - "title": "Configuration" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - } - }, - "type": "object", - "required": ["id", "created_at"], - "title": "Workspace" - }, - "WorkspaceCreate": { - "properties": { - "id": { - "type": "string", - "maxLength": 100, - "minLength": 1, - "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": ["id"], - "title": "WorkspaceCreate" - }, - "WorkspaceGet": { - "properties": { - "filters": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Filters" - } - }, - "type": "object", - "title": "WorkspaceGet" - }, - "WorkspaceUpdate": { - "properties": { - "metadata": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Metadata" - }, - "configuration": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Configuration" - } - }, - "type": "object", - "title": "WorkspaceUpdate" - } - }, - "securitySchemes": { - "HTTPBearer": { - "type": "http", - "scheme": "bearer" - } - } - } -} diff --git a/docs/v2/openapi.documented.yml b/docs/v2/openapi.documented.yml new file mode 100644 index 00000000..a3942cb9 --- /dev/null +++ b/docs/v2/openapi.documented.yml @@ -0,0 +1,3894 @@ +openapi: 3.1.0 +info: + title: Honcho API + summary: The Identity Layer for the Agentic World + description: Honcho is a platform for giving agents user-centric memory and social cognition + contact: + name: Plastic Labs + url: https://honcho.dev/ + email: hello@plasticlabs.ai + version: 2.4.0 +servers: + - url: http://localhost:8000 + description: Local Development Server + - url: https://demo.honcho.dev + description: Demo Server + - url: https://api.honcho.dev + description: Production SaaS Platform +paths: + /v2/workspaces: + post: + tags: + - workspaces + summary: Get Or Create Workspace + description: |- + Get a Workspace by ID. + + If workspace_id is provided as a query parameter, it uses that (must match JWT workspace_id). + Otherwise, it uses the workspace_id from the JWT. + 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/Workspace' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + security: + - HTTPBearer: [] + - {} + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const workspace = await client.workspaces.getOrCreate({ id: 'id' }); + + console.log(workspace.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + workspace = client.workspaces.get_or_create( + id="id", + ) + print(workspace.id) + /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 + - 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/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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + // Automatically fetches more pages as needed. + for await (const workspace of client.workspaces.list()) { + console.log(workspace.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.list() + page = page.items[0] + print(page.id) + /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/WorkspaceUpdate' + description: Updated workspace parameters + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Workspace' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const workspace = await client.workspaces.update('workspace_id'); + + console.log(workspace.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + workspace = client.workspaces.update( + workspace_id="workspace_id", + ) + print(workspace.id) + delete: + tags: + - workspaces + summary: Delete Workspace + description: Delete a Workspace + operationId: delete_workspace_v2_workspaces__workspace_id__delete + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: path + required: true + schema: + type: string + description: ID of the workspace to delete + title: Workspace Id + description: ID of the workspace to delete + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Workspace' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const workspace = await client.workspaces.delete('workspace_id'); + + console.log(workspace.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + workspace = client.workspaces.delete( + "workspace_id", + ) + print(workspace.id) + /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 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/MessageSearchOptions' + description: 'Message search parameters ' + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Message' + title: Response Search Workspace V2 Workspaces Workspace Id Search Post + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const messages = await client.workspaces.search('workspace_id', { query: 'query' }); + + console.log(messages); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + messages = client.workspaces.search( + workspace_id="workspace_id", + query="query", + ) + print(messages) + /v2/workspaces/{workspace_id}/deriver/status: + get: + tags: + - workspaces + summary: Get Deriver Status + description: Get the deriver processing status, optionally scoped to an observer, sender, and/or session + operationId: get_deriver_status_v2_workspaces__workspace_id__deriver_status_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: observer_id + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: Optional observer ID to filter by + title: Observer Id + description: Optional observer ID to filter by + - name: sender_id + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: Optional sender ID to filter by + title: Sender Id + description: Optional sender ID to filter by + - name: session_id + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: Optional session ID to filter by + title: Session Id + description: Optional session ID to filter by + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/DeriverStatus' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const deriverStatus = await client.workspaces.deriverStatus('workspace_id'); + + console.log(deriverStatus.completed_work_units); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + deriver_status = client.workspaces.deriver_status( + workspace_id="workspace_id", + ) + print(deriver_status.completed_work_units) + /v2/workspaces/{workspace_id}/peers/list: + post: + 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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + // Automatically fetches more pages as needed. + for await (const peer of client.workspaces.peers.list('workspace_id')) { + console.log(peer.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.peers.list( + workspace_id="workspace_id", + ) + page = page.items[0] + print(page.id) + /v2/workspaces/{workspace_id}/peers: + post: + tags: + - peers + summary: Get Or Create Peer + description: |- + Get a Peer by ID + + If peer_id is provided as a query parameter, it uses that (must match JWT workspace_id). + Otherwise, it uses the peer_id from the JWT. + 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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const peer = await client.workspaces.peers.getOrCreate('workspace_id', { id: 'id' }); + + console.log(peer.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + peer = client.workspaces.peers.get_or_create( + workspace_id="workspace_id", + id="id", + ) + print(peer.id) + /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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const peer = await client.workspaces.peers.update('workspace_id', 'peer_id'); + + console.log(peer.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + peer = client.workspaces.peers.update( + peer_id="peer_id", + workspace_id="workspace_id", + ) + print(peer.id) + /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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + // Automatically fetches more pages as needed. + for await (const session of client.workspaces.peers.sessions.list('workspace_id', 'peer_id')) { + console.log(session.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.peers.sessions.list( + peer_id="peer_id", + workspace_id="workspace_id", + ) + page = page.items[0] + print(page.id) + /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: + properties: + content: + title: Content + type: string + required: + - content + title: DialecticResponse + type: object + text/event-stream: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const response = await client.workspaces.peers.chat('workspace_id', 'peer_id', { query: 'x' }); + + console.log(response.content); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.peers.chat( + peer_id="peer_id", + workspace_id="workspace_id", + query="x", + ) + print(response.content) + /v2/workspaces/{workspace_id}/peers/{peer_id}/representation: + post: + tags: + - peers + summary: Get Working Representation + description: >- + Get a peer's working representation for a session. + + + If a session_id is provided in the body, we get the working representation of the peer in that + session. + + If a target is provided, we get the representation of the target from the perspective of the peer. + + If no target is provided, we get the omniscient Honcho representation of the peer. + operationId: get_working_representation_v2_workspaces__workspace_id__peers__peer_id__representation_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/PeerRepresentationGet' + description: Options for getting the peer representation + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: object + additionalProperties: true + title: >- + Response Get Working Representation V2 Workspaces Workspace Id Peers Peer Id + Representation Post + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const response = await client.workspaces.peers.workingRepresentation('workspace_id', 'peer_id'); + + console.log(response); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.peers.working_representation( + peer_id="peer_id", + workspace_id="workspace_id", + ) + print(response) + /v2/workspaces/{workspace_id}/peers/{peer_id}/card: + get: + tags: + - peers + summary: Get Peer Card + description: |- + Get a peer card for a specific peer relationship. + + Returns the peer card that the observer peer has for the target peer if it exists. + If no target is specified, returns the observer's own peer card. + operationId: get_peer_card_v2_workspaces__workspace_id__peers__peer_id__card_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: peer_id + in: path + required: true + schema: + type: string + description: ID of the observer peer + title: Peer Id + description: ID of the observer peer + - name: target + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: The peer whose card to retrieve. If not provided, returns the observer's own card + title: Target + description: The peer whose card to retrieve. If not provided, returns the observer's own card + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PeerCardResponse' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const response = await client.workspaces.peers.card('workspace_id', 'peer_id'); + + console.log(response.peer_card); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.peers.card( + peer_id="peer_id", + workspace_id="workspace_id", + ) + print(response.peer_card) + /v2/workspaces/{workspace_id}/peers/{peer_id}/search: + post: + tags: + - peers + summary: Search Peer + description: Search a Peer + operationId: search_peer_v2_workspaces__workspace_id__peers__peer_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: 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/MessageSearchOptions' + description: 'Message search parameters ' + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Message' + title: Response Search Peer V2 Workspaces Workspace Id Peers Peer Id Search Post + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const messages = await client.workspaces.peers.search('workspace_id', 'peer_id', { query: 'query' + }); + + + console.log(messages); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + messages = client.workspaces.peers.search( + peer_id="peer_id", + workspace_id="workspace_id", + query="query", + ) + print(messages) + /v2/workspaces/{workspace_id}/sessions: + post: + tags: + - sessions + summary: Get Or Create Session + description: |- + Get a specific session in a workspace. + + If session_id is provided as a query parameter, it verifies the session is in the workspace. + Otherwise, it uses the session_id from the JWT for verification. + operationId: get_or_create_session_v2_workspaces__workspace_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 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SessionCreate' + description: Session creation parameters + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const session = await client.workspaces.sessions.getOrCreate('workspace_id', { id: 'id' }); + + console.log(session.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.get_or_create( + workspace_id="workspace_id", + id="id", + ) + print(session.id) + /v2/workspaces/{workspace_id}/sessions/list: + post: + tags: + - sessions + summary: Get Sessions + description: Get All Sessions in a Workspace + operationId: get_sessions_v2_workspaces__workspace_id__sessions_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/SessionGet' + - type: 'null' + description: Filtering and pagination 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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + // Automatically fetches more pages as needed. + for await (const session of client.workspaces.sessions.list('workspace_id')) { + console.log(session.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.sessions.list( + workspace_id="workspace_id", + ) + page = page.items[0] + print(page.id) + /v2/workspaces/{workspace_id}/sessions/{session_id}: + put: + tags: + - sessions + summary: Update Session + description: Update the metadata of a Session + operationId: update_session_v2_workspaces__workspace_id__sessions__session_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: session_id + in: path + required: true + schema: + type: string + description: ID of the session to update + title: Session Id + description: ID of the session to update + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SessionUpdate' + description: Updated session parameters + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const session = await client.workspaces.sessions.update('workspace_id', 'session_id'); + + console.log(session.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.update( + session_id="session_id", + workspace_id="workspace_id", + ) + print(session.id) + delete: + tags: + - sessions + summary: Delete Session + description: Delete a session by marking it as inactive + operationId: delete_session_v2_workspaces__workspace_id__sessions__session_id__delete + 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 to delete + title: Session Id + description: ID of the session 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const session = await client.workspaces.sessions.delete('workspace_id', 'session_id'); + + console.log(session); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.delete( + session_id="session_id", + workspace_id="workspace_id", + ) + print(session) + /v2/workspaces/{workspace_id}/sessions/{session_id}/clone: + get: + tags: + - sessions + summary: Clone Session + description: Clone a session, optionally up to a specific message + operationId: clone_session_v2_workspaces__workspace_id__sessions__session_id__clone_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 to clone + title: Session Id + description: ID of the session to clone + - name: message_id + in: query + required: false + schema: + 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 + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const session = await client.workspaces.sessions.clone('workspace_id', 'session_id'); + + console.log(session.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.clone( + session_id="session_id", + workspace_id="workspace_id", + ) + print(session.id) + /v2/workspaces/{workspace_id}/sessions/{session_id}/peers: + post: + 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: 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 add to 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' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const session = await client.workspaces.sessions.peers.add('workspace_id', 'session_id', { foo: {} + }); + + + console.log(session.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.peers.add( + session_id="session_id", + workspace_id="workspace_id", + body={ + "foo": {} + }, + ) + print(session.id) + 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 + 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/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const session = await client.workspaces.sessions.peers.set('workspace_id', 'session_id', { foo: {} + }); + + + console.log(session.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.peers.set( + session_id="session_id", + workspace_id="workspace_id", + body={ + "foo": {} + }, + ) + print(session.id) + 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: 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: 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' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const session = await client.workspaces.sessions.peers.remove('workspace_id', 'session_id', + ['string']); + + + console.log(session.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session = client.workspaces.sessions.peers.remove( + session_id="session_id", + workspace_id="workspace_id", + body=["string"], + ) + print(session.id) + 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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + // Automatically fetches more pages as needed. + for await (const peer of client.workspaces.sessions.peers.list('workspace_id', 'session_id')) { + console.log(peer.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.sessions.peers.list( + session_id="session_id", + workspace_id="workspace_id", + ) + page = page.items[0] + print(page.id) + /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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const sessionPeerConfig = await client.workspaces.sessions.peers.getConfig( + 'workspace_id', + 'session_id', + 'peer_id', + ); + + console.log(sessionPeerConfig.observe_me); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + session_peer_config = client.workspaces.sessions.peers.get_config( + peer_id="peer_id", + workspace_id="workspace_id", + session_id="session_id", + ) + print(session_peer_config.observe_me) + 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' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const response = await client.workspaces.sessions.peers.setConfig('workspace_id', 'session_id', + 'peer_id'); + + + console.log(response); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.sessions.peers.set_config( + peer_id="peer_id", + workspace_id="workspace_id", + session_id="session_id", + ) + print(response) + /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 an optional token limit which the + entire context must fit into. + + If not provided, the context will be exhaustive (within configured max tokens). To do this, we + allocate 40% of the token limit + + to the summary, and 60% to recent messages -- as many as can fit. Note that the summary will usually + take up less space than + + this. If the caller does not want a summary, we allocate all the tokens to recent messages. + 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 + maximum: 100000 + - type: 'null' + description: >- + Number of tokens to use for the context. Includes summary if set to true. Includes + representation and peer card if they are included in the response. If not provided, the context + will be exhaustive (within 100000 tokens) + title: Tokens + description: >- + Number of tokens to use for the context. Includes summary if set to true. Includes representation + and peer card if they are included in the response. If not provided, the context will be + exhaustive (within 100000 tokens) + - name: last_message + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: The most recent message, used to fetch semantically relevant observations + title: Last Message + description: The most recent message, used to fetch semantically relevant observations + - name: summary + in: query + required: false + schema: + type: boolean + description: Whether or not to include a summary *if* one is available for the session + default: true + title: Summary + description: Whether or not to include a summary *if* one is available for the session + - name: peer_target + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: >- + The target of the perspective. If given without `peer_perspective`, will get the Honcho-level + representation and peer card for this peer. If given with `peer_perspective`, will get the + representation and card for this peer *from the perspective of that peer*. + title: Peer Target + description: >- + The target of the perspective. If given without `peer_perspective`, will get the Honcho-level + representation and peer card for this peer. If given with `peer_perspective`, will get the + representation and card for this peer *from the perspective of that peer*. + - name: peer_perspective + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: >- + A peer to get context for. If given, response will attempt to include representation and card + from the perspective of that peer. Must be provided with `peer_target`. + title: Peer Perspective + description: >- + A peer to get context for. If given, response will attempt to include representation and card from + the perspective of that peer. Must be provided with `peer_target`. + 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' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const response = await client.workspaces.sessions.getContext('workspace_id', 'session_id'); + + console.log(response.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.sessions.get_context( + session_id="session_id", + workspace_id="workspace_id", + ) + print(response.id) + /v2/workspaces/{workspace_id}/sessions/{session_id}/summaries: + get: + tags: + - sessions + summary: Get Session Summaries + description: |- + Get available summaries for a session. + + Returns both short and long summaries if available, including metadata like + the message ID they cover up to, creation timestamp, and token count. + operationId: get_session_summaries_v2_workspaces__workspace_id__sessions__session_id__summaries_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 + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/SessionSummaries' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const response = await client.workspaces.sessions.summaries('workspace_id', 'session_id'); + + console.log(response.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.sessions.summaries( + session_id="session_id", + workspace_id="workspace_id", + ) + print(response.id) + /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 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/MessageSearchOptions' + description: Message search parameters + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Message' + title: Response Search Session V2 Workspaces Workspace Id Sessions Session Id Search Post + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const messages = await client.workspaces.sessions.search('workspace_id', 'session_id', { query: + 'query' }); + + + console.log(messages); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + messages = client.workspaces.sessions.search( + session_id="session_id", + workspace_id="workspace_id", + query="query", + ) + print(messages) + /v2/workspaces/{workspace_id}/sessions/{session_id}/messages/: + post: + tags: + - messages + summary: Create Messages For Session + description: Create messages for a session with JSON data (original functionality). + 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 + title: Workspace Id + - name: session_id + in: path + required: true + schema: + type: string + title: Session Id + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/MessageBatchCreate' + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Message' + title: >- + Response Create Messages For Session V2 Workspaces Workspace Id Sessions Session Id + Messages Post + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const messages = await client.workspaces.sessions.messages.create('workspace_id', 'session_id', { + messages: [{ content: 'content', peer_id: 'peer_id' }], + }); + + console.log(messages); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + messages = client.workspaces.sessions.messages.create( + session_id="session_id", + workspace_id="workspace_id", + messages=[{ + "content": "content", + "peer_id": "peer_id", + }], + ) + print(messages) + /v2/workspaces/{workspace_id}/sessions/{session_id}/messages/upload: + post: + tags: + - messages + summary: Create Messages With File + description: Create messages from uploaded files. Files are converted to text and split into multiple messages. + operationId: create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: path + required: true + schema: + type: string + title: Workspace Id + - name: session_id + in: path + required: true + schema: + type: string + title: Session Id + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: >- + #/components/schemas/Body_create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Message' + title: >- + Response Create Messages With File V2 Workspaces Workspace Id Sessions Session Id + Messages Upload Post + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const messages = await client.workspaces.sessions.messages.upload('workspace_id', 'session_id', { + file: fs.createReadStream('path/to/file'), + peer_id: 'peer_id', + }); + + console.log(messages); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + messages = client.workspaces.sessions.messages.upload( + session_id="session_id", + workspace_id="workspace_id", + file=b"raw file contents", + peer_id="peer_id", + ) + print(messages) + /v2/workspaces/{workspace_id}/sessions/{session_id}/messages/list: + post: + tags: + - messages + summary: Get Messages + description: Get all messages for a session + operationId: get_messages_v2_workspaces__workspace_id__sessions__session_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: session_id + in: path + required: true + schema: + type: string + description: ID of the session + title: Session Id + description: ID of the session + - 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/MessageGet' + - type: 'null' + description: Filtering options for the messages list + title: Options + 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' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + // Automatically fetches more pages as needed. + + for await (const message of client.workspaces.sessions.messages.list('workspace_id', + 'session_id')) { + console.log(message.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.sessions.messages.list( + session_id="session_id", + workspace_id="workspace_id", + ) + page = page.items[0] + print(page.id) + /v2/workspaces/{workspace_id}/sessions/{session_id}/messages/{message_id}: + get: + tags: + - messages + summary: Get Message + description: Get a Message by ID + operationId: get_message_v2_workspaces__workspace_id__sessions__session_id__messages__message_id__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: message_id + in: path + required: true + schema: + type: string + description: ID of the message to retrieve + title: Message Id + description: ID of the message to retrieve + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const message = await client.workspaces.sessions.messages.retrieve( + 'workspace_id', + 'session_id', + 'message_id', + ); + + console.log(message.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + message = client.workspaces.sessions.messages.retrieve( + message_id="message_id", + workspace_id="workspace_id", + session_id="session_id", + ) + print(message.id) + put: + tags: + - messages + summary: Update Message + description: Update the metadata of a Message + operationId: update_message_v2_workspaces__workspace_id__sessions__session_id__messages__message_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: session_id + in: path + required: true + schema: + type: string + description: ID of the session + title: Session Id + description: ID of the session + - name: message_id + in: path + required: true + schema: + type: string + description: ID of the message to update + title: Message Id + description: ID of the message to update + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/MessageUpdate' + description: Updated message parameters + 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/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const message = await client.workspaces.sessions.messages.update('workspace_id', 'session_id', + 'message_id'); + + + console.log(message.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + message = client.workspaces.sessions.messages.update( + message_id="message_id", + workspace_id="workspace_id", + session_id="session_id", + ) + print(message.id) + /v2/keys: + post: + tags: + - keys + summary: Create Key + description: Create a new Key + operationId: create_key_v2_keys_post + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: ID of the workspace to scope the key to + title: Workspace Id + description: ID of the workspace to scope the key to + - name: peer_id + in: query + required: false + schema: + anyOf: + - type: string + - type: 'null' + description: ID of the peer to scope the key to + title: Peer Id + description: ID of the peer to scope the key to + - name: session_id + in: query + required: false + schema: + 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: expires_at + in: query + required: false + schema: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Expires At + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const key = await client.keys.create(); + + console.log(key); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + key = client.keys.create() + print(key) + /v2/workspaces/{workspace_id}/webhooks: + post: + tags: + - webhooks + summary: Get Or Create Webhook Endpoint + description: Get or create a webhook endpoint URL. + operationId: get_or_create_webhook_endpoint_v2_workspaces__workspace_id__webhooks_post + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: path + required: true + schema: + type: string + description: Workspace ID + title: Workspace Id + description: Workspace ID + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookEndpointCreate' + description: Webhook endpoint parameters + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookEndpoint' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: >- + import Honcho from '@honcho-ai/core'; + + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + + const webhookEndpoint = await client.workspaces.webhooks.getOrCreate('workspace_id', { url: 'url' + }); + + + console.log(webhookEndpoint.id); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + webhook_endpoint = client.workspaces.webhooks.get_or_create( + workspace_id="workspace_id", + url="url", + ) + print(webhook_endpoint.id) + get: + tags: + - webhooks + summary: List Webhook Endpoints + description: List all webhook endpoints, optionally filtered by workspace. + operationId: list_webhook_endpoints_v2_workspaces__workspace_id__webhooks_get + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: path + required: true + schema: + type: string + description: Workspace ID + title: Workspace Id + description: Workspace ID + - 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_WebhookEndpoint_' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from '@honcho-ai/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + // Automatically fetches more pages as needed. + for await (const webhookEndpoint of client.workspaces.webhooks.list('workspace_id')) { + console.log(webhookEndpoint.id); + } + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + page = client.workspaces.webhooks.list( + workspace_id="workspace_id", + ) + page = page.items[0] + print(page.id) + /v2/workspaces/{workspace_id}/webhooks/{endpoint_id}: + delete: + tags: + - webhooks + summary: Delete Webhook Endpoint + description: Delete a specific webhook endpoint. + operationId: delete_webhook_endpoint_v2_workspaces__workspace_id__webhooks__endpoint_id__delete + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: path + required: true + schema: + type: string + description: Workspace ID + title: Workspace Id + description: Workspace ID + - name: endpoint_id + in: path + required: true + schema: + type: string + description: Webhook endpoint ID + title: Endpoint Id + description: Webhook endpoint ID + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const webhook = await client.workspaces.webhooks.delete('workspace_id', 'endpoint_id'); + + console.log(webhook); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + webhook = client.workspaces.webhooks.delete( + endpoint_id="endpoint_id", + workspace_id="workspace_id", + ) + print(webhook) + /v2/workspaces/{workspace_id}/webhooks/test: + get: + tags: + - webhooks + summary: Test Emit + description: Test publishing a webhook event. + operationId: test_emit_v2_workspaces__workspace_id__webhooks_test_get + security: + - HTTPBearer: [] + - {} + parameters: + - name: workspace_id + in: path + required: true + schema: + type: string + description: Workspace ID + title: Workspace Id + description: Workspace ID + 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/core'; + + const client = new Honcho({ + apiKey: 'My API Key', + }); + + const response = await client.workspaces.webhooks.testEmit('workspace_id'); + + console.log(response); + - lang: Python + source: |- + from honcho_core import Honcho + + client = Honcho( + api_key="My API Key", + ) + response = client.workspaces.webhooks.test_emit( + "workspace_id", + ) + print(response) + /metrics: + get: + summary: Metrics + description: Prometheus metrics endpoint + operationId: metrics_metrics_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} +components: + schemas: + Body_create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post: + properties: + file: + type: string + format: binary + title: File + peer_id: + type: string + title: Peer Id + type: object + required: + - file + - peer_id + title: Body_create_messages_with_file_v2_workspaces__workspace_id__sessions__session_id__messages_upload_post + DeductiveObservation: + properties: + created_at: + type: string + format: date-time + title: Created At + message_ids: + items: + prefixItems: + - type: integer + - type: integer + type: array + maxItems: 2 + minItems: 2 + type: array + title: Message Ids + session_name: + type: string + title: Session Name + premises: + items: + type: string + type: array + title: Premises + description: Supporting premises or evidence for this conclusion + conclusion: + type: string + title: Conclusion + description: The deductive conclusion + type: object + required: + - created_at + - message_ids + - session_name + - conclusion + title: DeductiveObservation + description: Deductive observation with multiple premises and one conclusion, plus metadata. + DeriverStatus: + properties: + total_work_units: + type: integer + title: Total Work Units + description: Total work units + completed_work_units: + type: integer + title: Completed Work Units + description: Completed work units + in_progress_work_units: + type: integer + title: In Progress Work Units + description: Work units currently being processed + pending_work_units: + type: integer + title: Pending Work Units + description: Work units waiting to be processed + sessions: + anyOf: + - additionalProperties: + $ref: '#/components/schemas/SessionDeriverStatus' + type: object + - type: 'null' + title: Sessions + description: Per-session status when not filtered by session + type: object + required: + - total_work_units + - completed_work_units + - in_progress_work_units + - pending_work_units + title: DeriverStatus + 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 + query: + type: string + maxLength: 10000 + minLength: 1 + title: Query + description: Dialectic API Prompt + stream: + type: boolean + title: Stream + default: false + type: object + required: + - query + title: DialecticOptions + ExplicitObservation: + properties: + created_at: + type: string + format: date-time + title: Created At + message_ids: + items: + prefixItems: + - type: integer + - type: integer + type: array + maxItems: 2 + minItems: 2 + type: array + title: Message Ids + session_name: + type: string + title: Session Name + content: + type: string + title: Content + description: The explicit observation + type: object + required: + - created_at + - message_ids + - session_name + - content + title: ExplicitObservation + description: Explicit observation with content and metadata. + HTTPValidationError: + properties: + detail: + items: + $ref: '#/components/schemas/ValidationError' + type: array + title: Detail + type: object + title: HTTPValidationError + Message: + properties: + id: + type: string + title: Id + content: + type: string + title: Content + peer_id: + type: string + title: Peer Id + session_id: + type: string + title: Session Id + metadata: + additionalProperties: true + type: object + title: Metadata + created_at: + type: string + format: date-time + title: Created At + workspace_id: + type: string + title: Workspace Id + token_count: + type: integer + title: Token Count + type: object + required: + - id + - content + - peer_id + - session_id + - created_at + - workspace_id + - token_count + title: Message + MessageBatchCreate: + properties: + messages: + items: + $ref: '#/components/schemas/MessageCreate' + type: array + maxItems: 100 + minItems: 1 + title: Messages + type: object + required: + - messages + title: MessageBatchCreate + description: Schema for batch message creation with a max of 100 messages + MessageCreate: + properties: + content: + type: string + maxLength: 25000 + minLength: 0 + title: Content + peer_id: + type: string + title: Peer Id + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + created_at: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Created At + type: object + required: + - content + - peer_id + title: MessageCreate + MessageGet: + properties: + filters: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filters + type: object + title: MessageGet + MessageSearchOptions: + properties: + query: + type: string + title: Query + description: Search query + filters: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filters + description: Filters to scope the search + limit: + type: integer + maximum: 100 + minimum: 1 + title: Limit + description: Number of results to return + default: 10 + type: object + required: + - query + title: MessageSearchOptions + MessageUpdate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + type: object + title: MessageUpdate + 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 + - page + - size + title: Page[Message] + Page_Peer_: + properties: + items: + items: + $ref: '#/components/schemas/Peer' + 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 + - page + - size + title: Page[Peer] + 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 + - page + - size + title: Page[Session] + Page_WebhookEndpoint_: + properties: + items: + items: + $ref: '#/components/schemas/WebhookEndpoint' + 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 + - page + - size + title: Page[WebhookEndpoint] + Page_Workspace_: + properties: + items: + items: + $ref: '#/components/schemas/Workspace' + 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 + - 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 + metadata: + additionalProperties: true + type: object + title: Metadata + configuration: + additionalProperties: true + type: object + title: Configuration + type: object + required: + - id + - workspace_id + - created_at + title: Peer + PeerCardResponse: + properties: + peer_card: + anyOf: + - items: + type: string + type: array + - type: 'null' + title: Peer Card + description: The peer card content, or None if not found + type: object + title: PeerCardResponse + PeerCreate: + 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 + configuration: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Configuration + type: object + required: + - id + title: PeerCreate + PeerGet: + properties: + filters: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filters + type: object + title: PeerGet + PeerRepresentationGet: + properties: + session_id: + anyOf: + - type: string + - type: 'null' + title: Session Id + description: Get the working representation within this session + target: + anyOf: + - type: string + - type: 'null' + title: Target + description: Optional peer ID to get the representation for, from the perspective of this peer + type: object + title: PeerRepresentationGet + PeerUpdate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + configuration: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Configuration + type: object + title: PeerUpdate + Representation: + properties: + explicit: + items: + $ref: '#/components/schemas/ExplicitObservation' + type: array + title: Explicit + description: >- + Facts LITERALLY stated by the user - direct quotes or clear paraphrases only, no interpretation or + inference. Example: ['The user is 25 years old', 'The user has a dog'] + deductive: + items: + $ref: '#/components/schemas/DeductiveObservation' + type: array + title: Deductive + description: >- + Conclusions that MUST be true given explicit facts and premises - strict logical necessities. Each + deduction should have premises and a single conclusion. + type: object + title: Representation + description: >- + A Representation is a traversable and diffable map of observations. + + At the base, we have a list of explicit observations, derived from a peer's messages. + + + From there, deductive observations can be made by establishing logical relationships between explicit + observations. + + + In the future, we can add more levels of reasoning on top of these. + + + All of a peer's observations are stored as documents in a collection. These documents can be queried + in various ways + + to produce this Representation object. + + + Additionally, a "working representation" is a version of this data structure representing the most + recent observations + + within a single session. + + + A representation can have a maximum number of observations, which is applied individually to each + level of reasoning. + + If a maximum is set, observations are added and removed in FIFO order. + Session: + properties: + 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 + configuration: + additionalProperties: true + type: object + title: Configuration + created_at: + type: string + format: date-time + title: Created At + type: object + required: + - id + - is_active + - workspace_id + - created_at + title: Session + SessionContext: + properties: + id: + type: string + title: Id + messages: + items: + $ref: '#/components/schemas/Message' + type: array + title: Messages + summary: + anyOf: + - $ref: '#/components/schemas/Summary' + - type: 'null' + description: The summary if available + peer_representation: + anyOf: + - $ref: '#/components/schemas/Representation' + - type: 'null' + description: The peer representation, if context is requested from a specific perspective + peer_card: + anyOf: + - items: + type: string + type: array + - type: 'null' + title: Peer Card + description: The peer card, if context is requested from a specific perspective + type: object + required: + - id + - messages + 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 + SessionDeriverStatus: + properties: + session_id: + anyOf: + - type: string + - type: 'null' + title: Session Id + description: Session ID if filtered by session + total_work_units: + type: integer + title: Total Work Units + description: Total work units + completed_work_units: + type: integer + title: Completed Work Units + description: Completed work units + in_progress_work_units: + type: integer + title: In Progress Work Units + description: Work units currently being processed + pending_work_units: + type: integer + title: Pending Work Units + description: Work units waiting to be processed + type: object + required: + - total_work_units + - completed_work_units + - in_progress_work_units + - pending_work_units + title: SessionDeriverStatus + SessionGet: + properties: + filters: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filters + 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 + SessionSummaries: + properties: + id: + type: string + title: Id + short_summary: + anyOf: + - $ref: '#/components/schemas/Summary' + - type: 'null' + description: The short summary if available + long_summary: + anyOf: + - $ref: '#/components/schemas/Summary' + - type: 'null' + description: The long summary if available + type: object + required: + - id + title: SessionSummaries + 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 + Summary: + properties: + content: + type: string + title: Content + description: The summary text + message_id: + type: string + title: Message Id + description: The public ID of the message that this summary covers up to + summary_type: + type: string + title: Summary Type + description: The type of summary (short or long) + created_at: + type: string + title: Created At + description: The timestamp of when the summary was created (ISO format) + token_count: + type: integer + title: Token Count + description: The number of tokens in the summary text + type: object + required: + - content + - message_id + - summary_type + - created_at + - token_count + title: Summary + 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 + WebhookEndpoint: + properties: + id: + type: string + title: Id + workspace_id: + anyOf: + - type: string + - type: 'null' + title: Workspace Id + url: + type: string + title: Url + created_at: + type: string + format: date-time + title: Created At + type: object + required: + - id + - workspace_id + - url + - created_at + title: WebhookEndpoint + WebhookEndpointCreate: + properties: + url: + type: string + title: Url + type: object + required: + - url + title: WebhookEndpointCreate + Workspace: + properties: + id: + type: string + title: Id + metadata: + additionalProperties: true + type: object + title: Metadata + configuration: + additionalProperties: true + type: object + title: Configuration + created_at: + type: string + format: date-time + title: Created At + type: object + required: + - id + - created_at + title: Workspace + WorkspaceCreate: + properties: + id: + type: string + maxLength: 100 + minLength: 1 + 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: + - id + title: WorkspaceCreate + WorkspaceGet: + properties: + filters: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filters + type: object + title: WorkspaceGet + WorkspaceUpdate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + configuration: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Configuration + type: object + title: WorkspaceUpdate + securitySchemes: + HTTPBearer: + type: http + scheme: bearer diff --git a/migrations/versions/08894082221a_replace_collection_name_with_observer_.py b/migrations/versions/08894082221a_replace_collection_name_with_observer_.py index 9b387574..2e27a5a8 100644 --- a/migrations/versions/08894082221a_replace_collection_name_with_observer_.py +++ b/migrations/versions/08894082221a_replace_collection_name_with_observer_.py @@ -10,6 +10,7 @@ from collections.abc import Sequence import sqlalchemy as sa from alembic import op +from nanoid import generate as generate_nanoid from sqlalchemy import text from migrations.utils import column_exists, constraint_exists, fk_exists, index_exists @@ -25,25 +26,47 @@ depends_on: str | Sequence[str] | None = None def upgrade() -> None: """Replace collections.name and documents.collection_name with observer and observed fields.""" schema = settings.DB.SCHEMA - inspector = sa.inspect(op.get_bind()) connection = op.get_bind() # SESSION_NAME MIGRATION - # Replace NULL session_name values with empty strings and make column non-nullable + # Replace NULL session_name values with __global_observations__ and make column non-nullable # This only applies to documents table - # Update documents table - connection.execute( + inspector = sa.inspect(connection) + + # query documents table to get ALL workspace_names that have documents without a session_name + workspace_names = connection.execute( text( - """ - UPDATE documents - SET session_name = '' - WHERE session_name IS NULL + f""" + SELECT DISTINCT workspace_name FROM {schema}.documents WHERE session_name IS NULL """ ) - ) - if column_exists("documents", "session_name", inspector): - op.alter_column("documents", "session_name", nullable=False, schema=schema) + ).fetchall() + + if workspace_names and column_exists("sessions", "name", inspector): + # Create __global_observations__ session for EACH workspace that needs it + for (workspace_name,) in workspace_names: + session_id = generate_nanoid() + connection.execute( + text( + f""" + INSERT INTO {schema}.sessions (id, name, workspace_name, is_active) VALUES (:session_id, '__global_observations__', :workspace_name, true) ON CONFLICT DO NOTHING + """ + ), + {"session_id": session_id, "workspace_name": workspace_name}, + ) + # Update all documents with NULL session_name + connection.execute( + text( + f""" + UPDATE {schema}.documents + SET session_name = '__global_observations__' + WHERE session_name IS NULL + """ + ), + ) + + op.alter_column("documents", "session_name", nullable=False, schema=schema) # COLLECTIONS TABLE # Step 1: Add new observer and observed columns to collections @@ -64,17 +87,21 @@ def upgrade() -> None: # Step 2: Populate collections observer and observed from existing name field # The logic is: # - observer = peer_name (the exact peer ID) - # - If name is "global_representation", observed = peer_name - # - Otherwise, observed = name with the "observer_" prefix stripped + # - If name is "global_representation", observed = peer_name (self-observation) + # - If name starts with peer_name + "_", extract the observed part (pattern: observer_observed) + # - If name ends with "_" + peer_name, extract the first part (pattern: observed_observer) + # - Otherwise (legacy edge cases), observed = name itself connection.execute( text( - """ - UPDATE collections + f""" + UPDATE {schema}.collections SET observer = peer_name, observed = CASE WHEN name = 'global_representation' THEN peer_name - ELSE substring(name from length(peer_name) + 2) + WHEN name LIKE peer_name || '_%' THEN substring(name from length(peer_name) + 2) + WHEN name LIKE '%_' || peer_name THEN substring(name from 1 for length(name) - length(peer_name) - 1) + ELSE name END WHERE observer IS NULL OR observed IS NULL """ @@ -108,18 +135,18 @@ def upgrade() -> None: while True: result = connection.execute( text( - """ + f""" WITH batch AS ( SELECT d.ctid - FROM documents d + FROM {schema}.documents d WHERE d.observer IS NULL OR d.observed IS NULL LIMIT :batch_size ) - UPDATE documents d + UPDATE {schema}.documents d SET observer = c.observer, observed = c.observed - FROM collections c, batch + FROM {schema}.collections c, batch WHERE d.ctid = batch.ctid AND d.collection_name = c.name AND d.peer_name = c.peer_name @@ -329,8 +356,8 @@ def downgrade() -> None: # Step 2: Populate collections name from observer and observed connection.execute( text( - """ - UPDATE collections + f""" + UPDATE {schema}.collections SET name = CASE WHEN observer = observed THEN 'global_representation' ELSE observer || '_' || observed @@ -354,8 +381,8 @@ def downgrade() -> None: # Populate peer_name with observer value connection.execute( text( - """ - UPDATE collections + f""" + UPDATE {schema}.collections SET peer_name = observer WHERE peer_name IS NULL """ @@ -391,8 +418,8 @@ def downgrade() -> None: # Step 5: Populate documents collection_name from observer and observed connection.execute( text( - """ - UPDATE documents + f""" + UPDATE {schema}.documents SET collection_name = CASE WHEN observer = observed THEN 'global_representation' ELSE observer || '_' || observed @@ -416,8 +443,8 @@ def downgrade() -> None: # Populate peer_name with observed value connection.execute( text( - """ - UPDATE documents + f""" + UPDATE {schema}.documents SET peer_name = observed WHERE peer_name IS NULL """ diff --git a/sdks/python/CHANGELOG.md b/sdks/python/CHANGELOG.md index bc4a1f33..e22a6d7d 100644 --- a/sdks/python/CHANGELOG.md +++ b/sdks/python/CHANGELOG.md @@ -5,13 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.5.0] - 2025-10-08 +## [1.5.0] - 2025-10-09 + +### Added + +- Delete workspace method ### Changed - message_id of `Summary` model is a string nanoid +- Get Context can return Peer Card & Peer Representation -## [1.4.1] — 2025-10-09 +## [1.4.1] — 2025-10-01 ### Added diff --git a/sdks/python/pyproject.toml b/sdks/python/pyproject.toml index c780d5c4..3132f09d 100644 --- a/sdks/python/pyproject.toml +++ b/sdks/python/pyproject.toml @@ -8,7 +8,7 @@ authors = [ { name = "Plastic Labs", email = "hello@plasticlabs.ai" }, ] dependencies = [ - "honcho-core>=1.5.0", + "honcho-core>=1.5.1", "httpx>=0.28.0, <1", "pydantic>=2.0.0, <3", "typing-extensions>=4.12.0; python_version < \"3.12\"", diff --git a/sdks/python/src/honcho/async_client/client.py b/sdks/python/src/honcho/async_client/client.py index bdc01fa8..2929d88f 100644 --- a/sdks/python/src/honcho/async_client/client.py +++ b/sdks/python/src/honcho/async_client/client.py @@ -8,7 +8,7 @@ from typing import Any, Literal import httpx from honcho_core import AsyncHoncho as AsyncHonchoCore from honcho_core import Honcho as HonchoCore -from honcho_core.types import DeriverStatus +from honcho_core.types import DeriverStatus, Workspace from honcho_core.types.workspaces.peer import Peer as PeerCore from honcho_core.types.workspaces.session import Session as SessionCore from honcho_core.types.workspaces.sessions.message import Message @@ -337,6 +337,26 @@ class AsyncHoncho(BaseModel): workspace_ids.append(workspace.id) return workspace_ids + @validate_call + async def delete_workspace( + self, + workspace_id: str = Field( + ..., min_length=1, description="ID of the workspace to delete" + ), + ) -> Workspace: + """ + Delete a workspace. + + Makes an async API call to delete the specified workspace. + + Args: + workspace_id: The ID of the workspace to delete + + Returns: + The deleted Workspace object + """ + return await self._client.workspaces.delete(workspace_id) + @validate_call async def search( self, diff --git a/sdks/python/src/honcho/async_client/session.py b/sdks/python/src/honcho/async_client/session.py index fb2bea00..3610367e 100644 --- a/sdks/python/src/honcho/async_client/session.py +++ b/sdks/python/src/honcho/async_client/session.py @@ -427,11 +427,23 @@ class AsyncSession(BaseModel): tokens: int | None = Field( None, gt=0, description="Maximum number of tokens to include in the context" ), + peer_target: str | None = Field( + None, + description="A peer ID to get context for. If given *without* `peer_perspective`, a representation and peer card will be included from the omniscient Honcho-level view of `peer_target`. If given *with* `peer_perspective`, will get the representation and card for `peer_target` *from the perspective of `peer_perspective`*.", + ), + last_user_message: str | Message | None = Field( + None, + description="The most recent message (string or Message object), used to fetch semantically relevant observations and returned as part of the context object. Use this alongside `peer_target` to get a more focused context -- does nothing if `peer_target` is not provided.", + ), + peer_perspective: str | None = Field( + None, + description="A peer ID to get context *from the perspective of*. If given, response will attempt to include representation and card from the perspective of `peer_perspective`. Must be provided with `peer_target`.", + ), ) -> SessionContext: """ Get optimized context for this session within a token limit. - Makes an async API call to retrieve a curated list of messages that provides + Makes an API call to retrieve a curated list of messages that provides optimal context for the conversation while staying within the specified token limit. Uses tiktoken for token counting, so results should be compatible with OpenAI models. @@ -440,6 +452,9 @@ class AsyncSession(BaseModel): summary: Whether to include summary information tokens: Maximum number of tokens to include in the context. Will default to Honcho server configuration if not provided. + peer_target: A peer ID to get context for. If given *without* `peer_perspective`, a representation and peer card will be included from the omniscient Honcho-level view of `peer_target`. If given *with* `peer_perspective`, will get the representation and card for `peer_target` *from the perspective of `peer_perspective`*. + last_user_message: The most recent message (string or Message object), used to fetch semantically relevant observations and returned as part of the context object. Use this alongside `peer_target` to get a more focused context -- does nothing if `peer_target` is not provided. + peer_perspective: A peer ID to get context *from the perspective of*. If given, response will attempt to include representation and card from the perspective of `peer_perspective`. Must be provided with `peer_target`. Returns: A SessionContext object containing the optimized message history and @@ -450,11 +465,32 @@ class AsyncSession(BaseModel): Token counting is performed using tiktoken. For models using different tokenizers, you may need to adjust the token limit accordingly. """ + + if peer_target is None and peer_perspective is not None: + raise ValueError( + "You must provide a `peer_target` when `peer_perspective` is provided" + ) + + if peer_target is None and last_user_message is not None: + raise ValueError( + "You must provide a `peer_target` when `last_user_message` is provided" + ) + + last_user_message_id = ( + last_user_message.id + if isinstance(last_user_message, Message) + else last_user_message + ) context = await self._client.workspaces.sessions.get_context( session_id=self.id, workspace_id=self.workspace_id, tokens=tokens if tokens is not None else omit, summary=summary, + last_message=last_user_message_id + if last_user_message_id is not None + else omit, + peer_target=peer_target if peer_target is not None else omit, + peer_perspective=peer_perspective if peer_perspective is not None else omit, ) # Convert the honcho_core summary to our Summary if it exists @@ -469,7 +505,13 @@ class AsyncSession(BaseModel): ) return SessionContext( - session_id=self.id, messages=context.messages, summary=session_summary + session_id=self.id, + messages=context.messages, + summary=session_summary, + peer_representation=str(context.peer_representation) + if context.peer_representation + else None, + peer_card=context.peer_card, ) async def get_summaries(self) -> SessionSummaries: diff --git a/sdks/python/src/honcho/client.py b/sdks/python/src/honcho/client.py index 777c5e4e..2c494ce6 100644 --- a/sdks/python/src/honcho/client.py +++ b/sdks/python/src/honcho/client.py @@ -6,7 +6,7 @@ from typing import Any, Literal import httpx from honcho_core import Honcho as HonchoCore -from honcho_core.types import DeriverStatus +from honcho_core.types import DeriverStatus, Workspace from honcho_core.types.workspaces.peer import Peer as PeerCore from honcho_core.types.workspaces.session import Session as SessionCore from honcho_core.types.workspaces.sessions.message import Message @@ -316,6 +316,26 @@ class Honcho(BaseModel): workspaces = self._client.workspaces.list(filters=filters) return [workspace.id for workspace in workspaces] + @validate_call + def delete_workspace( + self, + workspace_id: str = Field( + ..., min_length=1, description="ID of the workspace to delete" + ), + ) -> Workspace: + """ + Delete a workspace. + + Makes an API call to delete the specified workspace. + + Args: + workspace_id: The ID of the workspace to delete + + Returns: + The deleted Workspace object + """ + return self._client.workspaces.delete(workspace_id) + @validate_call def search( self, diff --git a/sdks/python/src/honcho/session.py b/sdks/python/src/honcho/session.py index 193887b5..51a7f20c 100644 --- a/sdks/python/src/honcho/session.py +++ b/sdks/python/src/honcho/session.py @@ -407,6 +407,18 @@ class Session(BaseModel): tokens: int | None = Field( None, gt=0, description="Maximum number of tokens to include in the context" ), + peer_target: str | None = Field( + None, + description="A peer ID to get context for. If given *without* `peer_perspective`, a representation and peer card will be included from the omniscient Honcho-level view of `peer_target`. If given *with* `peer_perspective`, will get the representation and card for `peer_target` *from the perspective of `peer_perspective`*.", + ), + last_user_message: str | Message | None = Field( + None, + description="The most recent message (string or Message object), used to fetch semantically relevant observations and returned as part of the context object. Use this alongside `peer_target` to get a more focused context -- does nothing if `peer_target` is not provided.", + ), + peer_perspective: str | None = Field( + None, + description="A peer ID to get context *from the perspective of*. If given, response will attempt to include representation and card from the perspective of `peer_perspective`. Must be provided with `peer_target`.", + ), ) -> SessionContext: """ Get optimized context for this session within a token limit. @@ -420,6 +432,9 @@ class Session(BaseModel): summary: Whether to include summary information tokens: Maximum number of tokens to include in the context. Will default to Honcho server configuration if not provided. + peer_target: A peer ID to get context for. If given *without* `peer_perspective`, a representation and peer card will be included from the omniscient Honcho-level view of `peer_target`. If given *with* `peer_perspective`, will get the representation and card for `peer_target` *from the perspective of `peer_perspective`*. + last_user_message: The most recent message (string or Message object), used to fetch semantically relevant observations and returned as part of the context object. Use this alongside `peer_target` to get a more focused context -- does nothing if `peer_target` is not provided. + peer_perspective: A peer ID to get context *from the perspective of*. If given, response will attempt to include representation and card from the perspective of `peer_perspective`. Must be provided with `peer_target`. Returns: A SessionContext object containing the optimized message history and @@ -430,11 +445,32 @@ class Session(BaseModel): Token counting is performed using tiktoken. For models using different tokenizers, you may need to adjust the token limit accordingly. """ + + if peer_target is None and peer_perspective is not None: + raise ValueError( + "You must provide a `peer_target` when `peer_perspective` is provided" + ) + + if peer_target is None and last_user_message is not None: + raise ValueError( + "You must provide a `peer_target` when `last_user_message` is provided" + ) + + last_user_message_id = ( + last_user_message.id + if isinstance(last_user_message, Message) + else last_user_message + ) context = self._client.workspaces.sessions.get_context( session_id=self.id, workspace_id=self.workspace_id, tokens=tokens if tokens is not None else omit, summary=summary, + last_message=last_user_message_id + if last_user_message_id is not None + else omit, + peer_target=peer_target if peer_target is not None else omit, + peer_perspective=peer_perspective if peer_perspective is not None else omit, ) # Convert the honcho_core summary to our Summary if it exists @@ -449,7 +485,13 @@ class Session(BaseModel): ) return SessionContext( - session_id=self.id, messages=context.messages, summary=session_summary + session_id=self.id, + messages=context.messages, + summary=session_summary, + peer_representation=str(context.peer_representation) + if context.peer_representation + else None, + peer_card=context.peer_card, ) def get_summaries(self) -> SessionSummaries: diff --git a/sdks/python/src/honcho/session_context.py b/sdks/python/src/honcho/session_context.py index 45017075..0c657fe1 100644 --- a/sdks/python/src/honcho/session_context.py +++ b/sdks/python/src/honcho/session_context.py @@ -58,6 +58,14 @@ class SessionContext(BaseModel): summary: Summary | None = Field( None, description="Summary of the session history prior to the message cutoff" ) + peer_representation: str | None = Field( + None, + description="The peer representation, if context is requested from a specific perspective", + ) + peer_card: list[str] | None = Field( + None, + description="The peer card, if context is requested from a specific perspective", + ) @validate_call def __init__( @@ -72,6 +80,14 @@ class SessionContext(BaseModel): None, description="Summary of the session history prior to the message cutoff", ), + peer_representation: str | None = Field( + None, + description="The peer representation, if context is requested from a specific perspective", + ), + peer_card: list[str] | None = Field( + None, + description="The peer card, if context is requested from a specific perspective", + ), ) -> None: """ Initialize a new SessionContext. @@ -84,6 +100,8 @@ class SessionContext(BaseModel): session_id=session_id, messages=messages, summary=summary, + peer_representation=peer_representation, + peer_card=peer_card, ) def to_openai( @@ -117,14 +135,30 @@ class SessionContext(BaseModel): } for message in self.messages ] + system_messages: list[dict[str, str]] = [] + + if self.peer_representation: + peer_representation_message = { + "role": "system", + "content": f"{self.peer_representation}", + } + system_messages.append(peer_representation_message) + + if self.peer_card: + peer_card_message = { + "role": "system", + "content": f"{self.peer_card}", + } + system_messages.append(peer_card_message) if self.summary: summary_message = { "role": "system", "content": f"{self.summary.content}", } - return [summary_message, *messages] - return messages + system_messages.append(summary_message) + + return system_messages + messages def to_anthropic( self, @@ -164,14 +198,30 @@ class SessionContext(BaseModel): } for message in self.messages ] + system_messages: list[dict[str, str]] = [] + + if self.peer_representation: + peer_representation_message = { + "role": "user", + "content": f"{self.peer_representation}", + } + system_messages.append(peer_representation_message) + + if self.peer_card: + peer_card_message = { + "role": "user", + "content": f"{self.peer_card}", + } + system_messages.append(peer_card_message) if self.summary: summary_message = { "role": "user", "content": f"{self.summary.content}", } - return [summary_message, *messages] - return messages + system_messages.append(summary_message) + + return system_messages + messages def __len__(self) -> int: """ diff --git a/sdks/typescript/CHANGELOG.md b/sdks/typescript/CHANGELOG.md index 4e00824c..ee4dc631 100644 --- a/sdks/typescript/CHANGELOG.md +++ b/sdks/typescript/CHANGELOG.md @@ -5,13 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.5.0] - 2025-10-08 +## [1.5.0] - 2025-10-09 + +### Added + +- Delete workspace method ### Changed - message_id of `Summary` model is a string nanoid +- Get Context can return Peer Card & Peer Representation -## [1.4.1] — 2025-10-09 +## [1.4.1] — 2025-10-01 ### Added diff --git a/sdks/typescript/bun.lock b/sdks/typescript/bun.lock index b4ad630e..dcffc7b3 100644 --- a/sdks/typescript/bun.lock +++ b/sdks/typescript/bun.lock @@ -4,7 +4,7 @@ "": { "name": "@honcho-ai/sdk", "dependencies": { - "@honcho-ai/core": "^1.5.0", + "@honcho-ai/core": "^1.5.1", "@types/node": "^24.0.1", "zod": "4.0.0", }, @@ -108,7 +108,7 @@ "@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="], - "@honcho-ai/core": ["@honcho-ai/core@1.5.0", "", { "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", "abort-controller": "^3.0.0", "agentkeepalive": "^4.2.1", "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", "node-fetch": "^2.6.7" } }, "sha512-kjYhCO0S9Ll3DfVpK8MetjY1PlD9FG6QGtudlMnSwfTWGzXFjL/OafpoE3SZ3c9BVY48JIbW9IttFUZFekv/xg=="], + "@honcho-ai/core": ["@honcho-ai/core@1.5.1", "", { "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", "abort-controller": "^3.0.0", "agentkeepalive": "^4.2.1", "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", "node-fetch": "^2.6.7" } }, "sha512-lbYtMTcL2AxdcIl5ZKenogeTlVMnE7buJWvAFOCLp0yQxcezyA/R9FPvLz2UGRApLsiplLNWhftML+3QBjIIJA=="], "@istanbuljs/load-nyc-config": ["@istanbuljs/load-nyc-config@1.1.0", "", { "dependencies": { "camelcase": "^5.3.1", "find-up": "^4.1.0", "get-package-type": "^0.1.0", "js-yaml": "^3.13.1", "resolve-from": "^5.0.0" } }, "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ=="], diff --git a/sdks/typescript/package.json b/sdks/typescript/package.json index 583a6bad..8701165a 100644 --- a/sdks/typescript/package.json +++ b/sdks/typescript/package.json @@ -20,7 +20,7 @@ "test:coverage": "jest --coverage" }, "dependencies": { - "@honcho-ai/core": "^1.5.0", + "@honcho-ai/core": "^1.5.1", "@types/node": "^24.0.1", "zod": "4.0.0" }, diff --git a/sdks/typescript/src/client.ts b/sdks/typescript/src/client.ts index 0400381c..cd6ed695 100644 --- a/sdks/typescript/src/client.ts +++ b/sdks/typescript/src/client.ts @@ -314,6 +314,20 @@ export class Honcho { return ids } + /** + * Delete a workspace. + * + * Makes an API call to delete the specified workspace. + * + * @param workspaceId - The ID of the workspace to delete + * @returns Promise resolving to the deleted Workspace object + */ + async deleteWorkspace( + workspaceId: string + ): Promise>> { + return await this._client.workspaces.delete(workspaceId) + } + /** * Search for messages in the current workspace. * diff --git a/sdks/typescript/src/session.ts b/sdks/typescript/src/session.ts index 6bc3e16f..aae0e309 100644 --- a/sdks/typescript/src/session.ts +++ b/sdks/typescript/src/session.ts @@ -451,10 +451,21 @@ export class Session { * compatible with OpenAI models. The context optimization balances * recency and relevance to provide the best conversational context. * - * @param summary - Whether to include summary information in the context. - * When true, includes session summary if available. Defaults to true - * @param tokens - Maximum number of tokens to include in the context. If not provided, - * uses the server's default configuration + * @param options - Configuration options for context retrieval + * @param options.summary - Whether to include summary information in the context. + * When true, includes session summary if available. Defaults to true + * @param options.tokens - Maximum number of tokens to include in the context. If not provided, + * uses the server's default configuration + * @param options.peerTarget - The target of the perspective. If given without `peerPerspective`, + * will get the Honcho-level representation and peer card for this peer. + * If given with `peerPerspective`, will get the representation and card + * for this peer from the perspective of that peer. + * @param options.lastUserMessage - The most recent message, used to fetch semantically relevant + * observations and returned as part of the context object. + * Can be either a message ID string or a Message object. + * @param options.peerPerspective - A peer to get context for. If given, response will attempt to + * include representation and card from the perspective of that peer. + * Must be provided with `peerTarget`. * @returns Promise resolving to a SessionContext object containing the optimized * message history and summary (if available) that maximizes conversational * context while respecting the token limit @@ -462,25 +473,103 @@ export class Session { * @note Token counting is performed using tiktoken. For models using different * tokenizers, you may need to adjust the token limit accordingly. */ + async getContext( + summary?: boolean, + tokens?: number, + peerTarget?: string | Peer, + lastUserMessage?: string | Message, + peerPerspective?: string | Peer + ): Promise async getContext(options?: { summary?: boolean tokens?: number - }): Promise { + peerTarget?: string | Peer + lastUserMessage?: string | Message + peerPerspective?: string | Peer + }): Promise + async getContext( + summaryOrOptions?: + | boolean + | { + summary?: boolean + tokens?: number + peerTarget?: string | Peer + lastUserMessage?: string | Message + peerPerspective?: string | Peer + }, + tokens?: number, + peerTarget?: string | Peer, + lastUserMessage?: string | Message, + peerPerspective?: string | Peer + ): Promise { + // Normalize positional arguments into options object + let options: { + summary?: boolean + tokens?: number + peerTarget?: string + lastUserMessage?: string + peerPerspective?: string + } + + if ( + typeof summaryOrOptions === 'boolean' || + (summaryOrOptions === undefined && arguments.length > 1) + ) { + // Positional arguments pattern + options = { + summary: summaryOrOptions as boolean | undefined, + tokens, + peerTarget: typeof peerTarget === 'object' ? peerTarget.id : peerTarget, + lastUserMessage: + typeof lastUserMessage === 'string' + ? lastUserMessage + : lastUserMessage?.id, + peerPerspective: + typeof peerPerspective === 'object' + ? peerPerspective.id + : peerPerspective, + } + } else { + // Options object pattern + options = (summaryOrOptions as typeof options) || {} + } + const contextParams = ContextParamsSchema.parse({ - summary: options?.summary, - tokens: options?.tokens, + summary: options.summary, + tokens: options.tokens, + peerTarget: options.peerTarget, + lastUserMessage: options.lastUserMessage, + peerPerspective: options.peerPerspective, }) + + // Extract message ID if lastUserMessage is a Message object + const lastMessageId = + typeof contextParams.lastUserMessage === 'string' + ? contextParams.lastUserMessage + : contextParams.lastUserMessage?.id + const context = await this._client.workspaces.sessions.getContext( this.workspaceId, this.id, { tokens: contextParams.tokens, summary: contextParams.summary, + last_message: lastMessageId, + peer_target: contextParams.peerTarget, + peer_perspective: contextParams.peerPerspective, } ) // Convert the summary response to Summary object if present const summary = context.summary ? new Summary(context.summary) : null - return new SessionContext(this.id, context.messages, summary) + return new SessionContext( + this.id, + context.messages, + summary, + context.peer_representation + ? JSON.stringify(context.peer_representation) + : null, + context.peer_card ?? null + ) } /** diff --git a/sdks/typescript/src/session_context.ts b/sdks/typescript/src/session_context.ts index 538844c2..6eca21e0 100644 --- a/sdks/typescript/src/session_context.ts +++ b/sdks/typescript/src/session_context.ts @@ -102,21 +102,37 @@ export class SessionContext { */ readonly summary: Summary | null + /** + * The peer representation, if context is requested from a specific perspective. + */ + readonly peerRepresentation: string | null + + /** + * The peer card, if context is requested from a specific perspective. + */ + readonly peerCard: string[] | null + /** * Initialize a new SessionContext. * * @param sessionId ID of the session this context belongs to * @param messages List of Message objects to include in the context * @param summary Summary of the session history prior to the message cutoff + * @param peerRepresentation The peer representation, if context is requested from a specific perspective + * @param peerCard The peer card, if context is requested from a specific perspective */ constructor( sessionId: string, messages: Message[], - summary: Summary | null = null + summary: Summary | null = null, + peerRepresentation: string | null = null, + peerCard: string[] | null = null ) { this.sessionId = sessionId this.messages = messages this.summary = summary + this.peerRepresentation = peerRepresentation + this.peerCard = peerCard } /** @@ -136,18 +152,36 @@ export class SessionContext { assistant: string | Peer ): Array<{ role: string; content: string; name?: string }> { const assistantId = typeof assistant === 'string' ? assistant : assistant.id - const summaryMessage = this.summary - ? { - role: 'system', - content: `${this.summary.content}`, - } - : null const messages = this.messages.map((message) => ({ role: message.peer_id === assistantId ? 'assistant' : 'user', name: message.peer_id, content: message.content, })) - return summaryMessage ? [summaryMessage, ...messages] : messages + + const systemMessages: Array<{ role: string; content: string }> = [] + + if (this.peerRepresentation) { + systemMessages.push({ + role: 'system', + content: `${this.peerRepresentation}`, + }) + } + + if (this.peerCard) { + systemMessages.push({ + role: 'system', + content: `${this.peerCard}`, + }) + } + + if (this.summary) { + systemMessages.push({ + role: 'system', + content: `${this.summary.content}`, + }) + } + + return [...systemMessages, ...messages] } /** @@ -170,12 +204,6 @@ export class SessionContext { assistant: string | Peer ): Array<{ role: string; content: string }> { const assistantId = typeof assistant === 'string' ? assistant : assistant.id - const summaryMessage = this.summary - ? { - role: 'user', - content: `${this.summary.content}`, - } - : null const messages = this.messages.map((message) => message.peer_id === assistantId ? { @@ -187,7 +215,31 @@ export class SessionContext { content: `${message.peer_id}: ${message.content}`, } ) - return summaryMessage ? [summaryMessage, ...messages] : messages + + const systemMessages: Array<{ role: string; content: string }> = [] + + if (this.peerRepresentation) { + systemMessages.push({ + role: 'user', + content: `${this.peerRepresentation}`, + }) + } + + if (this.peerCard) { + systemMessages.push({ + role: 'user', + content: `${this.peerCard}`, + }) + } + + if (this.summary) { + systemMessages.push({ + role: 'user', + content: `${this.summary.content}`, + }) + } + + return [...systemMessages, ...messages] } /** diff --git a/sdks/typescript/src/validation.ts b/sdks/typescript/src/validation.ts index 3c30943b..e5e405c8 100644 --- a/sdks/typescript/src/validation.ts +++ b/sdks/typescript/src/validation.ts @@ -1,3 +1,4 @@ +import type { Message } from '@honcho-ai/core/resources/workspaces/sessions/messages' import { z } from 'zod' /** @@ -123,16 +124,56 @@ export const ChatQuerySchema = z.object({ sessionId: z.string().optional(), }) +/** + * Schema for validating Message objects from the core SDK. + */ +const MessageSchema: z.ZodType = z.object({ + id: z.string(), + content: z.string(), + created_at: z.string(), + peer_id: z.string(), + session_id: z.string(), + token_count: z.number(), + workspace_id: z.string(), + metadata: z.record(z.string(), z.unknown()).optional(), +}) as z.ZodType + /** * Schema for context retrieval parameters. */ -export const ContextParamsSchema = z.object({ - summary: z.boolean().optional(), - tokens: z - .number() - .positive('Token limit must be a positive number') - .optional(), -}) +export const ContextParamsSchema = z + .object({ + summary: z.boolean().optional(), + tokens: z + .number() + .positive('Token limit must be a positive number') + .optional(), + lastUserMessage: z + .union([ + z.string().min(1, 'Last user message must be a non-empty string'), + MessageSchema, + ]) + .optional(), + peerTarget: PeerIdSchema.optional(), + peerPerspective: PeerIdSchema.optional(), + }) + .superRefine((data, ctx) => { + if (data.lastUserMessage && !data.peerTarget) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'peerTarget is required when lastUserMessage is provided', + path: ['lastUserMessage'], + }) + } + + if (data.peerPerspective && !data.peerTarget) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'peerTarget is required when peerPerspective is provided', + path: ['peerPerspective'], + }) + } + }) /** * Schema for deriver status options. diff --git a/src/crud/__init__.py b/src/crud/__init__.py index f00a6ae1..69a4799e 100644 --- a/src/crud/__init__.py +++ b/src/crud/__init__.py @@ -44,7 +44,12 @@ from .webhook import ( get_or_create_webhook_endpoint, list_webhook_endpoints, ) -from .workspace import get_all_workspaces, get_or_create_workspace, update_workspace +from .workspace import ( + delete_workspace, + get_all_workspaces, + get_or_create_workspace, + update_workspace, +) __all__ = [ # Collection @@ -93,6 +98,7 @@ __all__ = [ "delete_webhook_endpoint", "list_webhook_endpoints", # Workspace + "delete_workspace", "get_or_create_workspace", "get_all_workspaces", "update_workspace", diff --git a/src/crud/peer.py b/src/crud/peer.py index 1e14aed7..cad234c8 100644 --- a/src/crud/peer.py +++ b/src/crud/peer.py @@ -166,7 +166,7 @@ async def update_peer( honcho_peer.configuration = peer.configuration await db.commit() - logger.info(f"Peer {peer_name} updated successfully") + logger.debug(f"Peer {peer_name} updated successfully") return honcho_peer diff --git a/src/crud/representation.py b/src/crud/representation.py index ed88bf4b..09eaeae7 100644 --- a/src/crud/representation.py +++ b/src/crud/representation.py @@ -300,9 +300,7 @@ class RepresentationManager: db, query=include_semantic_query, top_k=semantic_observations, - max_distance=semantic_search_max_distance - if semantic_search_max_distance is not None - else 0.3, + max_distance=semantic_search_max_distance, ) representation.merge_representation( Representation.from_documents(semantic_docs) @@ -322,11 +320,6 @@ class RepresentationManager: db, top_k=recent_observations, session_name=session_name ) - if not recent_docs: - logger.warning( - f"No observations for {self.observed} (observer: {self.observer}) found. Normal if brand-new peer." - ) - representation.merge_representation(Representation.from_documents(recent_docs)) return representation @@ -336,7 +329,7 @@ class RepresentationManager: db: AsyncSession, query: str, top_k: int, - max_distance: float, + max_distance: float | None = None, level: str | None = None, conversation_context: str = "", ) -> list[models.Document]: @@ -348,8 +341,8 @@ class RepresentationManager: query, level, conversation_context, - max_distance, top_k, + max_distance, ) else: documents = await crud.query_documents( @@ -433,8 +426,8 @@ class RepresentationManager: query: str, level: str, conversation_context: str, - max_distance: float, count: int, + max_distance: float | None = None, ) -> list[models.Document]: """Query documents for a specific level.""" documents = await crud.query_documents( diff --git a/src/crud/session.py b/src/crud/session.py index 0e050a8b..b3adf591 100644 --- a/src/crud/session.py +++ b/src/crud/session.py @@ -117,7 +117,7 @@ async def get_or_create_session( except IntegrityError: await db.rollback() logger.debug( - f"Race condition detected for session: {session.name}, retrying get" + "Race condition detected for session: %s, retrying get", session.name ) if _retry: raise ConflictException( @@ -220,7 +220,7 @@ async def update_session( honcho_session.configuration = session.configuration await db.commit() - logger.info(f"Session {session_name} updated successfully") + logger.debug("Session %s updated successfully", session_name) return honcho_session @@ -257,7 +257,7 @@ async def delete_session( honcho_session.is_active = False await db.commit() - logger.info(f"Session {session_name} marked as inactive") + logger.debug("Session %s marked as inactive", session_name) return True @@ -358,7 +358,7 @@ async def clone_session( db.add(new_session_peer) await db.commit() - logger.info(f"Session {original_session_name} cloned successfully") + logger.debug("Session %s cloned successfully", original_session_name) return new_session diff --git a/src/crud/webhook.py b/src/crud/webhook.py index d2216cb2..1dcc29a8 100644 --- a/src/crud/webhook.py +++ b/src/crud/webhook.py @@ -58,7 +58,7 @@ async def get_or_create_webhook_endpoint( await db.commit() await db.refresh(webhook_endpoint) - logger.info(f"Webhook endpoint created: {webhook.url}") + logger.debug("Webhook endpoint created: %s", webhook.url) return schemas.WebhookEndpoint.model_validate(webhook_endpoint) @@ -112,4 +112,4 @@ async def delete_webhook_endpoint( await db.delete(endpoint) await db.commit() - logger.info(f"Webhook endpoint {endpoint_id} deleted") + logger.debug("Webhook endpoint %s deleted", endpoint_id) diff --git a/src/crud/workspace.py b/src/crud/workspace.py index 0f3e63b4..d9af943c 100644 --- a/src/crud/workspace.py +++ b/src/crud/workspace.py @@ -1,7 +1,7 @@ from logging import getLogger from typing import Any -from sqlalchemy import Select, select +from sqlalchemy import Select, delete, func, select from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.asyncio import AsyncSession @@ -38,7 +38,7 @@ async def get_or_create_workspace( if existing_workspace is not None: # Workspace already exists - logger.debug(f"Found existing workspace: {workspace.name}") + logger.debug("Found existing workspace: %s", workspace.name) return existing_workspace # Workspace doesn't exist, create a new one @@ -50,7 +50,7 @@ async def get_or_create_workspace( try: db.add(honcho_workspace) await db.commit() - logger.info(f"Workspace created successfully: {workspace.name}") + logger.debug("Workspace created successfully: %s", workspace.name) return honcho_workspace except IntegrityError: await db.rollback() @@ -134,5 +134,117 @@ async def update_workspace( honcho_workspace.configuration = workspace.configuration await db.commit() - logger.info(f"Workspace with id {honcho_workspace.id} updated successfully") + logger.debug("Workspace with id %s updated successfully", honcho_workspace.id) return honcho_workspace + + +async def delete_workspace(db: AsyncSession, workspace_name: str) -> schemas.Workspace: + """ + Delete a workspace. + + Args: + db: Database session + workspace_name: Name of the workspace + + Returns: + A snapshot of the deleted workspace as a Pydantic schema + """ + logger.warning("Deleting workspace %s", workspace_name) + stmt = select(models.Workspace).where(models.Workspace.name == workspace_name) + result = await db.execute(stmt) + honcho_workspace = result.scalar_one_or_none() + + if honcho_workspace is None: + logger.warning("Workspace %s not found", workspace_name) + raise ResourceNotFoundException() + + # Create a snapshot of the workspace data before deletion + workspace_snapshot = schemas.Workspace( + name=honcho_workspace.name, + h_metadata=honcho_workspace.h_metadata, + configuration=honcho_workspace.configuration, + created_at=honcho_workspace.created_at, + ) + + # order is important here. + # delete all active queue sessions referencing this workspace first (using work_unit_key parsing) + # then queue items referencing this workspace + + # then embeddings + # then documents + # then collections + # then messages + + # then webhook endpoints + # then session_peers + # then sessions + # then peers + # then workspace + + # Delete ActiveQueueSession entries first + # Work unit keys have format: {task_type}:{workspace_name}:{...} + # Extract workspace_name from position 2 (second component after splitting by ':') + try: + await db.execute( + delete(models.ActiveQueueSession).where( + func.split_part(models.ActiveQueueSession.work_unit_key, ":", 2) + == workspace_name + ) + ) + + # Then delete QueueItem entries + await db.execute( + delete(models.QueueItem).where( + func.split_part(models.QueueItem.work_unit_key, ":", 2) + == workspace_name + ) + ) + + await db.execute( + delete(models.MessageEmbedding).where( + models.MessageEmbedding.workspace_name == workspace_name + ) + ) + await db.execute( + delete(models.Document).where( + models.Document.workspace_name == workspace_name + ) + ) + await db.execute( + delete(models.Collection).where( + models.Collection.workspace_name == workspace_name + ) + ) + await db.execute( + delete(models.Message).where( + models.Message.workspace_name == workspace_name + ) + ) + + await db.execute( + delete(models.WebhookEndpoint).where( + models.WebhookEndpoint.workspace_name == workspace_name + ) + ) + await db.execute( + delete(models.SessionPeer).where( + models.SessionPeer.workspace_name == workspace_name + ) + ) + await db.execute( + delete(models.Session).where( + models.Session.workspace_name == workspace_name + ) + ) + await db.execute( + delete(models.Peer).where(models.Peer.workspace_name == workspace_name) + ) + await db.delete(honcho_workspace) + await db.commit() + logger.debug("Workspace %s deleted", workspace_name) + except Exception as e: + logger.error("Failed to delete workspace %s: %s", workspace_name, e) + await db.rollback() + raise e + + return workspace_snapshot diff --git a/src/deriver/consumer.py b/src/deriver/consumer.py index 59aab370..20e0b1b0 100644 --- a/src/deriver/consumer.py +++ b/src/deriver/consumer.py @@ -58,7 +58,7 @@ async def process_item(task_type: str, queue_payload: dict[str, Any]) -> None: message_public_id = validated.message_public_id if not message_public_id: - logger.info( + logger.debug( "Fetching message public ID for message %s", validated.message_id ) async with tracked_db(operation_name="summary_fallback") as db: diff --git a/src/deriver/deriver.py b/src/deriver/deriver.py index 4be32527..15900e86 100644 --- a/src/deriver/deriver.py +++ b/src/deriver/deriver.py @@ -17,7 +17,7 @@ from src.utils.logging import ( accumulate_metric, conditional_observe, log_performance_metrics, - log_representation, + # log_representation, ) from src.utils.peer_card import PeerCardQuery from src.utils.representation import PromptRepresentation, Representation @@ -65,6 +65,8 @@ async def critical_analysis_call( json_mode=True, stop_seqs=[" \n", "\n\n\n\n"], thinking_budget_tokens=settings.DERIVER.THINKING_BUDGET_TOKENS, + reasoning_effort="minimal", + verbosity="medium", enable_retry=True, retry_attempts=3, ) @@ -161,13 +163,6 @@ async def process_representation_tasks_batch( observer=observer, observed=observed, ) - if speaker_peer_card is None: - logger.warning( - "No peer card found for %s. Normal if brand-new peer.", - observed, - ) - else: - logger.info("Using peer card: %s", speaker_peer_card) else: speaker_peer_card = None @@ -228,7 +223,7 @@ async def process_representation_tasks_batch( "ms", ) - logger.info( + logger.debug( "Using working representation with %s explicit, %s deductive observations", len(working_representation.explicit), len(working_representation.deductive), @@ -262,7 +257,7 @@ async def process_representation_tasks_batch( ) # Display final observations in a beautiful tree - log_representation(final_observations) + # log_representation(final_observations) # Calculate and log overall timing overall_duration = (time.perf_counter() - overall_start) * 1000 @@ -431,10 +426,9 @@ class CertaintyReasoner: """ try: response = await peer_card_call(old_peer_card, new_observations) - logger.info("Jettisoned notes from peer card: %s", response.notes) new_peer_card = response.card if not new_peer_card: - logger.info("No changes to peer card") + # no changes return # even with a dedicated notes field, we still need to prune notes out of the card new_peer_card = [ @@ -442,7 +436,12 @@ class CertaintyReasoner: for observation in new_peer_card if not observation.lower().startswith(("note", "notes")) ] - logger.info("New peer card: %s", new_peer_card) + accumulate_metric( + f"deriver_{self.ctx[-1].id}_{self.observer}", + "new_peer_card", + "\n".join(new_peer_card), + "blob", + ) async with tracked_db("deriver.update_peer_card") as db: await crud.set_peer_card( db, diff --git a/src/deriver/enqueue.py b/src/deriver/enqueue.py index ee66a6be..a9eb736e 100644 --- a/src/deriver/enqueue.py +++ b/src/deriver/enqueue.py @@ -343,7 +343,7 @@ async def generate_queue_records( observed, ) - logger.info( + logger.debug( "message %s from %s created %s queue items", message_id, observed, diff --git a/src/deriver/queue_manager.py b/src/deriver/queue_manager.py index 1b488b61..fbe463a0 100644 --- a/src/deriver/queue_manager.py +++ b/src/deriver/queue_manager.py @@ -161,7 +161,6 @@ class QueueManager: ) ) await db.commit() - logger.info("Cleanup completed successfully") except Exception as e: logger.error(f"Error during cleanup: {str(e)}") if settings.SENTRY.ENABLED: diff --git a/src/dialectic/chat.py b/src/dialectic/chat.py index cfca960b..b134b043 100644 --- a/src/dialectic/chat.py +++ b/src/dialectic/chat.py @@ -197,12 +197,11 @@ async def chat( "dialectic_model": settings.DIALECTIC.MODEL, } ) - logger.info( - "Received query:\n'%s'\nobserver: %s, observed: %s%s\n", - query, - observer, - observed, - f", session: {session_name}" if session_name else "", + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "query", + f"{query}\n\nobserver: {observer}\nobserved: {observed}\n{f'session: {session_name}' if session_name else ''}", + "blob", ) start_time = time.perf_counter() @@ -226,19 +225,28 @@ async def chat( working_rep_duration, "ms", ) - logger.info( - "Retrieved working representation with %s explicit, %s deductive observations", + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "working_rep_explicit", len(working_representation.explicit), + "count", + ) + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "working_rep_deductive", len(working_representation.deductive), + "count", ) working_representation_str = str(working_representation) context_window_size -= max(0, estimate_tokens(working_representation_str)) - logger.info( - "Constructed working representation:\n%s\n", + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "working_rep", working_representation_str, + "blob", ) # 2. Recent conversation history -------------------------------------------- @@ -252,14 +260,18 @@ async def chat( token_limit=context_window_size, include_summary=True, ) - logger.info("Retrieved recent conversation history") else: recent_history = None - logger.info( - "Query is not session-scoped, skipping recent conversation history" - ) - context_window_size -= max(0, estimate_tokens(recent_history or "")) + recent_history_tokens = estimate_tokens(recent_history or "") + context_window_size -= max(0, recent_history_tokens) + + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "recent_history_tokens", + recent_history_tokens, + "tokens", + ) accumulate_metric( f"dialectic_chat_{dialectic_chat_uuid}", @@ -282,9 +294,25 @@ async def chat( observed_peer_card = None if observed_peer_card: - logger.info("Retrieved peer cards:\n%s\n%s", peer_card, observed_peer_card) + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "peer_card", + "\n".join(peer_card) if peer_card else "", + "blob", + ) + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "observed_peer_card", + "\n".join(observed_peer_card), + "blob", + ) else: - logger.info("Retrieved peer card:\n%s", peer_card) + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "peer_card", + "\n".join(peer_card) if peer_card else "", + "blob", + ) else: peer_card = None observed_peer_card = None @@ -292,6 +320,20 @@ async def chat( # 4. Dialectic call -------------------------------------------------------- dialectic_call_start_time = time.perf_counter() if stream: + elapsed = (time.perf_counter() - start_time) * 1000 + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "response", + "(no logged response, streaming=true)", + "blob", + ) + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "duration_to_streaming", + elapsed, + "ms", + ) + log_performance_metrics("dialectic_chat", dialectic_chat_uuid) return await dialectic_stream( query, working_representation_str, @@ -312,6 +354,12 @@ async def chat( observed=observed, ) dialectic_call_duration = (time.perf_counter() - dialectic_call_start_time) * 1000 + accumulate_metric( + f"dialectic_chat_{dialectic_chat_uuid}", + "response", + response, + "blob", + ) accumulate_metric( f"dialectic_chat_{dialectic_chat_uuid}", "dialectic_call", @@ -326,5 +374,4 @@ async def chat( ) log_performance_metrics("dialectic_chat", dialectic_chat_uuid) - # Convert AnthropicCallResponse to string for compatibility - return str(response) + return response diff --git a/src/dialectic/prompts.py b/src/dialectic/prompts.py index db4a9392..7d1fbb55 100644 --- a/src/dialectic/prompts.py +++ b/src/dialectic/prompts.py @@ -48,6 +48,16 @@ The user's known biographical information: If the user's name or nickname is known, exclusively refer to them by that name. """ + recent_conversation_history_section = ( + f""" + +{recent_conversation_history} + +""" + if recent_conversation_history + else "" + ) + return c( f""" You are a context synthesis agent that operates as a natural language API for AI applications. Your role is to analyze application queries about users and synthesize relevant conclusions into coherent, actionable insights that directly address what the application needs to know. @@ -122,11 +132,10 @@ Provide a natural language response that: {query_target} - -{recent_conversation_history} - - {query} + +{recent_conversation_history_section} + {working_representation} """ ) diff --git a/src/embedding_client.py b/src/embedding_client.py index 6e0a1195..08c61758 100644 --- a/src/embedding_client.py +++ b/src/embedding_client.py @@ -350,7 +350,7 @@ class EmbeddingClient: self._instance = _EmbeddingClient( api_key=api_key, provider=provider ) - logger.info( + logger.debug( f"Initialized embedding client with provider: {provider}" ) diff --git a/src/routers/messages.py b/src/routers/messages.py index 36f32b7a..9c858c8e 100644 --- a/src/routers/messages.py +++ b/src/routers/messages.py @@ -139,8 +139,9 @@ async def create_messages_with_file( ] background_tasks.add_task(enqueue, payloads) - logger.info( - f"Batch of {len(created_messages)} messages created from file uploads and queued for processing" + logger.debug( + "Batch of %s messages created from file uploads and queued for processing", + len(created_messages), ) prometheus.MESSAGES_CREATED.labels( workspace_name=workspace_id, @@ -218,7 +219,7 @@ async def update_message( session_name=session_id, message_id=message_id, ) - logger.info(f"Message {message_id} updated successfully") + logger.debug("Message %s updated successfully", message_id) return updated_message except ValueError as e: logger.warning(f"Failed to update message {message_id}: {str(e)}") diff --git a/src/routers/sessions.py b/src/routers/sessions.py index fafb310e..2174e0ae 100644 --- a/src/routers/sessions.py +++ b/src/routers/sessions.py @@ -7,7 +7,7 @@ from fastapi_pagination import Page from fastapi_pagination.ext.sqlalchemy import apaginate from sqlalchemy.ext.asyncio import AsyncSession -from src import config, crud, models, schemas +from src import config, crud, schemas from src.dependencies import db, tracked_db from src.exceptions import ( AuthenticationException, @@ -87,7 +87,7 @@ async def _get_session_context_task( session_id: str, token_limit: int, include_summary: bool, -) -> tuple[schemas.Summary | None, list[models.Message]]: +) -> tuple[schemas.Summary | None, list[schemas.Message]]: """ Atomic task to get session context using tracked_db. @@ -101,13 +101,16 @@ async def _get_session_context_task( Tuple of (summary, messages) """ async with tracked_db("get_session_context") as db: - return await summarizer.get_session_context( + summary, messages = await summarizer.get_session_context( db, workspace_name=workspace_id, session_name=session_id, token_limit=token_limit, include_summary=include_summary, ) + # Convert SQLAlchemy models to Pydantic schemas while session is active + message_schemas = [schemas.Message.model_validate(msg) for msg in messages] + return summary, message_schemas @router.post( @@ -202,7 +205,7 @@ async def update_session( updated_session = await crud.update_session( db, workspace_name=workspace_id, session_name=session_id, session=session ) - logger.info(f"Session {session_id} updated successfully") + logger.debug("Session %s updated successfully", session_id) return updated_session except ValueError as e: logger.warning(f"Failed to update session {session_id}: {str(e)}") @@ -225,7 +228,7 @@ async def delete_session( await crud.delete_session( db, workspace_name=workspace_id, session_name=session_id ) - logger.info(f"Session {session_id} deleted successfully") + logger.debug("Session %s deleted successfully", session_id) return {"message": "Session deleted successfully"} except ValueError as e: logger.warning(f"Failed to delete session {session_id}: {str(e)}") @@ -256,7 +259,7 @@ async def clone_session( original_session_name=session_id, cutoff_message_id=message_id, ) - logger.info(f"Session {session_id} cloned successfully") + logger.debug("Session %s cloned successfully", session_id) return cloned_session except ValueError as e: logger.warning(f"Failed to clone session {session_id}: {str(e)}") @@ -288,7 +291,7 @@ async def add_peers_to_session( ), workspace_name=workspace_id, ) - logger.info(f"Added peers to session {session_id} successfully") + logger.debug("Added peers to session %s successfully", session_id) return session except ValueError as e: logger.warning(f"Failed to add peers to session {session_id}: {str(e)}") @@ -324,7 +327,7 @@ async def set_session_peers( session=schemas.SessionCreate(name=session_id), workspace_name=workspace_id, ) - logger.info(f"Set peers for session {session_id} successfully") + logger.debug("Set peers for session %s successfully", session_id) return session except ValueError as e: logger.warning(f"Failed to set peers for session {session_id}: {str(e)}") @@ -360,7 +363,7 @@ async def remove_peers_from_session( session=schemas.SessionCreate(name=session_id), workspace_name=workspace_id, ) - logger.info(f"Removed peers from session {session_id} successfully") + logger.debug("Removed peers from session %s successfully", session_id) return session except ValueError as e: logger.warning(f"Failed to remove peers from session {session_id}: {str(e)}") @@ -411,8 +414,8 @@ async def set_peer_config( peer_name=peer_id, config=config, ) - logger.info( - f"Set peer config for {peer_id} in session {session_id} successfully" + logger.debug( + "Set peer config for %s in session %s successfully", peer_id, session_id ) return Response(status_code=200) except ValueError as e: @@ -501,7 +504,7 @@ async def get_session_context( ) return schemas.SessionContext( name=session_id, - messages=messages, # pyright: ignore -- db message type and schema message type are different, but excess gets removed by schema + messages=messages, summary=summary, ) @@ -540,7 +543,7 @@ async def get_session_context( return schemas.SessionContext( name=session_id, - messages=messages, # pyright: ignore -- db message type and schema message type are different, but excess gets removed by schema + messages=messages, summary=summary, peer_representation=representation, peer_card=card, diff --git a/src/routers/workspaces.py b/src/routers/workspaces.py index 2c10b5d0..7138f6fd 100644 --- a/src/routers/workspaces.py +++ b/src/routers/workspaces.py @@ -92,6 +92,19 @@ async def update_workspace( return honcho_workspace +@router.delete( + "/{workspace_id}", + response_model=schemas.Workspace, + dependencies=[Depends(require_auth(workspace_name="workspace_id"))], +) +async def delete_workspace( + workspace_id: str = Path(..., description="ID of the workspace to delete"), + db: AsyncSession = db, +): + """Delete a Workspace""" + return await crud.delete_workspace(db, workspace_name=workspace_id) + + @router.post( "/{workspace_id}/search", response_model=list[schemas.Message], diff --git a/src/utils/clients.py b/src/utils/clients.py index d5f1e235..920af15a 100644 --- a/src/utils/clients.py +++ b/src/utils/clients.py @@ -370,8 +370,6 @@ async def honcho_llm_call_inner( "model": params["model"], "messages": params["messages"], } - if stop_seqs: - openai_params["stop"] = stop_seqs if "gpt-5" in model: openai_params["max_completion_tokens"] = params["max_tokens"] if reasoning_effort: @@ -399,6 +397,8 @@ async def honcho_llm_call_inner( "schema": response_model.model_json_schema(), }, } + if stop_seqs: + openai_params["stop"] = stop_seqs response: ChatCompletion = await client.chat.completions.create( # pyright: ignore **openai_params ) @@ -505,7 +505,7 @@ async def honcho_llm_call_inner( case genai.Client(): if response_model is None: gemini_response: GenerateContentResponse = ( - client.models.generate_content( + await client.aio.models.generate_content( model=model, contents=prompt, config={ @@ -519,8 +519,8 @@ async def honcho_llm_call_inner( # Safely extract response data text_content = gemini_response.text if gemini_response.text else "" token_count = ( - gemini_response.candidates[0].token_count or 0 - if gemini_response.candidates + gemini_response.usage_metadata.candidates_token_count or 0 + if gemini_response.usage_metadata else 0 ) finish_reason = ( @@ -537,7 +537,7 @@ async def honcho_llm_call_inner( ) else: - gemini_response = client.models.generate_content( + gemini_response = await client.aio.models.generate_content( model=model, contents=prompt, config={ @@ -547,8 +547,8 @@ async def honcho_llm_call_inner( ) token_count = ( - gemini_response.candidates[0].token_count or 0 - if gemini_response.candidates + gemini_response.usage_metadata.candidates_token_count or 0 + if gemini_response.usage_metadata else 0 ) finish_reason = ( diff --git a/src/utils/logging.py b/src/utils/logging.py index 8d28e1db..ca615899 100644 --- a/src/utils/logging.py +++ b/src/utils/logging.py @@ -10,8 +10,10 @@ from typing import Any from fastapi import Request from rich import box -from rich.console import Console +from rich.console import Console, Group, RenderableType +from rich.panel import Panel from rich.table import Table +from rich.text import Text from rich.tree import Tree from src.config import settings @@ -157,17 +159,23 @@ def log_performance_metrics( if COLLECT_METRICS_LOCAL: append_metrics_to_file(task_slug, task_name, metrics) + # Remove metrics with "blob" unit type. They get printed separately below the table. + blob_metrics: list[tuple[str, str | int | float, str]] = [] + non_blob_metrics: list[tuple[str, str | int | float, str]] = [] + for metric in metrics: + (blob_metrics if metric[2] == "blob" else non_blob_metrics).append(metric) + table = Table( - title=f"{title} - {task_name}", show_header=True, header_style="bold green", - box=box.ROUNDED, + box=None, + padding=(0, 1), ) table.add_column("Metric", style="cyan", width=30) table.add_column("Value", justify="right", style="yellow", width=15) table.add_column("Unit", style="dim", width=8) - for metric, value, unit in metrics: + for metric, value, unit in non_blob_metrics: if unit == "ms": formatted_value = f"{value:.0f}" elif unit == "s": @@ -177,9 +185,25 @@ def log_performance_metrics( table.add_row(metric.replace("_", " ").title(), formatted_value, unit) - if metrics: - console.print(table) - console.print() + # Build content for the panel + content_items: list[RenderableType] = [table] + + if blob_metrics: + content_items.append(Text("")) # Empty line separator + for metric, value, _unit in blob_metrics: + content_items.append(Text(f"{metric}:", style="bold cyan")) + content_items.append(Text(str(value))) + + panel = Panel( + Group(*content_items), + title=f"[bold green]{title} - {task_name}[/]", + box=box.ROUNDED, + padding=(1, 2), + width=80, + ) + + console.print(panel) + console.print() def normalize_template_path(path: str) -> str: diff --git a/src/utils/summarizer.py b/src/utils/summarizer.py index e99bd14b..be21009d 100644 --- a/src/utils/summarizer.py +++ b/src/utils/summarizer.py @@ -49,7 +49,7 @@ def to_schema_summary(s: Summary) -> schemas.Summary: summary_type=s["summary_type"], created_at=s["created_at"], token_count=s["token_count"], - message_public_id=s["message_public_id"], + message_public_id=s.get("message_public_id", ""), ) @@ -195,9 +195,6 @@ async def summarize_if_needed( session_name: The session name message_id: The message ID """ - - logger.debug("Checking if summaries should be created for session %s", session_name) - should_create_long: bool = message_seq_in_session % MESSAGES_PER_LONG_SUMMARY == 0 should_create_short: bool = message_seq_in_session % MESSAGES_PER_SHORT_SUMMARY == 0 @@ -214,11 +211,11 @@ async def summarize_if_needed( SummaryType.LONG, message_public_id, ) - logger.info( - "Saved long summary for session %s covering up to message %s (%s in session)", - session_name, - message_id, + accumulate_metric( + f"summary_{workspace_name}_{message_id}", + "long_summary_up_to_message", message_seq_in_session, + "count", ) async def create_short_summary(): @@ -231,11 +228,11 @@ async def summarize_if_needed( SummaryType.SHORT, message_public_id, ) - logger.info( - "Saved short summary for session %s covering up to message %s (%s in session)", - session_name, - message_id, + accumulate_metric( + f"summary_{workspace_name}_{message_id}", + "short_summary_up_to_message", message_seq_in_session, + "count", ) await asyncio.gather( @@ -255,11 +252,11 @@ async def summarize_if_needed( SummaryType.LONG, message_public_id, ) - logger.info( - "Saved long summary for session %s covering up to message %s (%s in session)", - session_name, - message_id, + accumulate_metric( + f"summary_{workspace_name}_{message_id}", + "long_summary_up_to_message", message_seq_in_session, + "count", ) elif should_create_short: await _create_and_save_summary( @@ -270,11 +267,11 @@ async def summarize_if_needed( SummaryType.SHORT, message_public_id, ) - logger.info( - "Saved short summary for session %s covering up to message %s (%s in session)", - session_name, - message_id, + accumulate_metric( + f"summary_{workspace_name}_{message_id}", + "short_summary_up_to_message", message_seq_in_session, + "count", ) @@ -294,7 +291,7 @@ async def _create_and_save_summary( 4. Save the new summary to the database """ - logger.info("Creating new %s summary", summary_type.name) + logger.debug("Creating new %s summary", summary_type.name) # Time summarization step summary_start = time.perf_counter() @@ -329,6 +326,19 @@ async def _create_and_save_summary( session_name, ) + accumulate_metric( + f"summary_{workspace_name}_{message_id}", + f"{summary_type.name}_summary_text", + new_summary["content"], + "blob", + ) + accumulate_metric( + f"summary_{workspace_name}_{message_id}", + f"{summary_type.name}_summary_size", + new_summary["token_count"], + "tokens", + ) + summary_duration = (time.perf_counter() - summary_start) * 1000 accumulate_metric( f"summary_{workspace_name}_{message_id}", @@ -374,9 +384,6 @@ async def _create_summary( logger.error( "Generated summary is empty! This may indicate a token limit issue." ) - - logger.info("Summary text: %s", summary_text) - logger.info("Summary size: %s tokens", summary_tokens) except Exception: logger.exception("Error generating summary!") # Fallback to a basic summary in case of error @@ -387,13 +394,6 @@ async def _create_summary( ) summary_tokens = 50 - accumulate_metric( - f"summary_{messages[-1].workspace_name}_{messages[-1].id}", - f"{summary_type.name}_summary_size", - response.output_tokens if response else f"{summary_tokens} (est.)", - "tokens", - ) - return Summary( content=summary_text, message_id=messages[-1].id if messages else 0, @@ -621,7 +621,7 @@ async def get_session_context( summary_type=latest_long_summary["summary_type"], created_at=latest_long_summary["created_at"], token_count=latest_long_summary["token_count"], - message_public_id=latest_long_summary["message_public_id"], + message_public_id=latest_long_summary.get("message_public_id", ""), ) messages_tokens = token_limit - latest_long_summary["token_count"] messages_start_id = latest_long_summary["message_id"] @@ -634,12 +634,12 @@ async def get_session_context( summary_type=latest_short_summary["summary_type"], created_at=latest_short_summary["created_at"], token_count=latest_short_summary["token_count"], - message_public_id=latest_short_summary["message_public_id"], + message_public_id=latest_short_summary.get("message_public_id", ""), ) messages_tokens = token_limit - latest_short_summary["token_count"] messages_start_id = latest_short_summary["message_id"] else: - logger.warning( + logger.debug( "No summary available for get_context call with token limit %s, returning empty string. Normal if brand-new session. long_summary_len: %s, short_summary_len: %s", token_limit, long_len, diff --git a/src/webhooks/webhook_delivery.py b/src/webhooks/webhook_delivery.py index 4573c79c..d9587009 100644 --- a/src/webhooks/webhook_delivery.py +++ b/src/webhooks/webhook_delivery.py @@ -23,7 +23,7 @@ async def deliver_webhook(db: AsyncSession, payload: WebhookPayload) -> None: try: webhook_urls = await _get_webhook_urls(db, payload.workspace_name) if not webhook_urls: - logger.info( + logger.debug( f"No webhook endpoints for workspace {payload.workspace_name}, skipping." ) return @@ -59,7 +59,7 @@ async def deliver_webhook(db: AsyncSession, payload: WebhookPayload) -> None: for url, result in zip(webhook_urls, results, strict=False): if isinstance(result, httpx.Response): if 200 <= result.status_code < 300: - logger.info( + logger.debug( f"Successfully delivered webhook {payload.event_type} to {url}" ) else: diff --git a/tests/bench/harness.py b/tests/bench/harness.py index f7f235a0..09bb7840 100755 --- a/tests/bench/harness.py +++ b/tests/bench/harness.py @@ -28,27 +28,28 @@ class HonchoHarness: Orchestrates running Honcho with a Docker database for development. """ - def __init__(self, db_port: int, project_root: Path) -> None: + def __init__( + self, db_port: int, api_port: int, project_root: Path, instance_id: int = 0 + ) -> None: """ - Initialize the harness with database port and project root. + Initialize the harness with database port, API port, and project root. Args: db_port: Port for the PostgreSQL database + api_port: Port for the FastAPI server project_root: Path to the Honcho project root + instance_id: Instance identifier for pool management """ self.db_port: int = db_port + self.api_port: int = api_port self.project_root: Path = project_root + self.instance_id: int = instance_id self.temp_dir: Path | None = None self.docker_compose_file: Path | None = None self.processes: list[tuple[str, subprocess.Popen[str]]] = [] self.env_file_backup: Path | None = None self.output_threads: list[threading.Thread] = [] - # Set environment variables in the current process - # This ensures they're inherited by all subprocesses - for key, value in self.get_database_env_vars().items(): - os.environ[key] = value - def create_temp_docker_compose(self) -> Path: """ Create a temporary docker-compose.yml with the specified database port. @@ -67,6 +68,14 @@ class HonchoHarness: # Add a unique project name to avoid conflicts compose_data["name"] = f"honcho_harness_{self.db_port}" + # remove init.sql mount since we use provision_db.py for setup + if "volumes" in compose_data["services"]["database"]: + compose_data["services"]["database"]["volumes"] = [ + vol + for vol in compose_data["services"]["database"]["volumes"] + if "init.sql" not in vol + ] + # Create temporary file self.temp_dir = Path(tempfile.mkdtemp(prefix="honcho_harness_")) self.docker_compose_file = self.temp_dir / "docker-compose.yml" @@ -200,32 +209,35 @@ class HonchoHarness: """ Provision the database using the provision_db.py script. """ - print("Provisioning database...") + print(f"[Instance {self.instance_id}] Provisioning database...") - # Run the provision script + # Run the provision script with explicit environment variables provision_script = self.project_root / "scripts" / "provision_db.py" + env = os.environ.copy() + env.update(self.get_database_env_vars()) + result = subprocess.run( [sys.executable, str(provision_script)], cwd=self.project_root, capture_output=True, text=True, + env=env, ) if result.returncode != 0: print(f"Failed to provision database: {result.stderr}") sys.exit(1) - print("Database provisioned successfully") + print(f"[Instance {self.instance_id}] Database provisioned successfully") def verify_empty_database(self) -> None: """ Verify that the database is empty with no workspaces and an empty queue. """ - try: import psycopg - # Connect to the database + # Connect to the database using instance-specific connection string conn_string = ( f"postgresql://testuser:testpwd@localhost:{self.db_port}/honcho" ) @@ -245,14 +257,20 @@ class HonchoHarness: # Report results if workspace_count != 0 or queue_count != 0: - print("āŒ Database verification failed: Database is not empty") + print( + f"[Instance {self.instance_id}] āŒ Database verification failed: Database is not empty" + ) print( "This may indicate an issue with the database provisioning or cleanup." ) sys.exit(1) + print( + f"[Instance {self.instance_id}] āœ… Database verification passed: Database is empty" + ) + except Exception as e: - print(f"āŒ Error verifying database: {e}") + print(f"[Instance {self.instance_id}] āŒ Error verifying database: {e}") print("Unable to verify database state. Continuing anyway...") def start_fastapi_server(self) -> subprocess.Popen[str]: @@ -262,7 +280,13 @@ class HonchoHarness: Returns: Process object for the FastAPI server """ - print("Starting FastAPI server...") + print( + f"[Instance {self.instance_id}] Starting FastAPI server on port {self.api_port}..." + ) + + # Create environment with instance-specific database connection + env = os.environ.copy() + env.update(self.get_database_env_vars()) process = subprocess.Popen( [ @@ -273,7 +297,7 @@ class HonchoHarness: "--host", "0.0.0.0", "--port", - "8000", + str(self.api_port), "--no-access-log", "--workers", "1", @@ -284,9 +308,10 @@ class HonchoHarness: text=True, bufsize=0, universal_newlines=True, + env=env, ) - self.processes.append(("FastAPI Server", process)) + self.processes.append((f"FastAPI [{self.instance_id}]", process)) return process def start_deriver(self) -> subprocess.Popen[str]: @@ -296,7 +321,11 @@ class HonchoHarness: Returns: Process object for the deriver """ - print("Starting deriver...") + print(f"[Instance {self.instance_id}] Starting deriver...") + + # Create environment with instance-specific database connection + env = os.environ.copy() + env.update(self.get_database_env_vars()) process = subprocess.Popen( [sys.executable, "-m", "src.deriver"], @@ -306,9 +335,10 @@ class HonchoHarness: text=True, bufsize=0, universal_newlines=True, + env=env, ) - self.processes.append(("Deriver", process)) + self.processes.append((f"[{self.instance_id}]", process)) return process def stream_process_output(self, name: str, process: subprocess.Popen[str]) -> None: @@ -357,16 +387,20 @@ class HonchoHarness: Returns: True if server is ready, False otherwise """ - print("Waiting for FastAPI server to be ready...") + print( + f"[Instance {self.instance_id}] Waiting for FastAPI server to be ready..." + ) start_time = time.time() while time.time() - start_time < timeout: try: import requests - response = requests.get("http://localhost:8000/docs", timeout=5) + response = requests.get( + f"http://localhost:{self.api_port}/docs", timeout=5 + ) if response.status_code == 200: - print("FastAPI server is ready!") + print(f"[Instance {self.instance_id}] FastAPI server is ready!") return True except Exception: pass @@ -436,11 +470,8 @@ try: print_settings(value, full_key, max_depth, current_depth + 1) else: # Mask sensitive information - if isinstance(value, str) and any(sensitive in value.lower() for sensitive in ['password', 'secret', 'key', 'token']): - if 'testpwd' in value: - masked_value = value.replace('testpwd', '***') - else: - masked_value = '***' + if isinstance(full_key, str) and any(sensitive in full_key.lower() for sensitive in ['password', 'secret', 'key', 'uri']): + masked_value = '*' * len(value) if value else 'None' else: masked_value = value print(f" {{key}}: {{masked_value}}") @@ -462,12 +493,16 @@ except Exception as e: with open(script_file, "w") as f: f.write(config_script) - # Run the script + # Run the script with instance-specific environment + env = os.environ.copy() + env.update(self.get_database_env_vars()) + result = subprocess.run( [sys.executable, str(script_file)], cwd=self.project_root, capture_output=True, text=True, + env=env, ) if result.returncode == 0: @@ -597,10 +632,10 @@ except Exception as e: _deriver_process = self.start_deriver() print("\n" + "=" * 60) - print("šŸŽ‰ Honcho is running!") + print(f"šŸŽ‰ Honcho Instance {self.instance_id} is running!") print(f"šŸ“Š Database: localhost:{self.db_port}") - print("🌐 API Server: http://localhost:8000") - print("šŸ“š API Docs: http://localhost:8000/docs") + print(f"🌐 API Server: http://localhost:{self.api_port}") + print(f"šŸ“š API Docs: http://localhost:{self.api_port}/docs") print("šŸ”„ Deriver: Running") print("=" * 60) print("Press Ctrl+C to stop all services") @@ -632,6 +667,164 @@ except Exception as e: self.cleanup() +class HonchoHarnessPool: + """ + Manages a pool of HonchoHarness instances for parallel testing. + """ + + def __init__( + self, pool_size: int, base_db_port: int, base_api_port: int, project_root: Path + ) -> None: + """ + Initialize a pool of Honcho harnesses. + + Args: + pool_size: Number of Honcho instances to create + base_db_port: Base port for PostgreSQL databases (each instance gets base + instance_id) + base_api_port: Base port for FastAPI servers (each instance gets base + instance_id) + project_root: Path to the Honcho project root + """ + self.pool_size: int = pool_size + self.base_db_port: int = base_db_port + self.base_api_port: int = base_api_port + self.project_root: Path = project_root + self.harnesses: list[HonchoHarness] = [] + + # Create all harness instances + for i in range(pool_size): + harness = HonchoHarness( + db_port=base_db_port + i, + api_port=base_api_port + i, + project_root=project_root, + instance_id=i, + ) + self.harnesses.append(harness) + + def run(self) -> None: + """ + Run all Honcho harnesses in the pool. + """ + try: + print(f"\n{'=' * 80}") + print(f"Starting Honcho Pool with {self.pool_size} instances") + print(f"{'=' * 80}\n") + + # Backup existing .env and copy test .env file + # This provides API keys while we override DB settings via environment variables + if self.harnesses: + self.harnesses[0].backup_env_file() + # Copy .env file from tests/bench to get API keys + shutil.copy( + self.project_root / "tests" / "bench" / ".env", + self.project_root / ".env", + ) + + # Remove DB_CONNECTION_URI from .env to ensure env vars take precedence + env_file = self.project_root / ".env" + if env_file.exists(): + with open(env_file) as f: + lines = f.readlines() + with open(env_file, "w") as f: + for line in lines: + # Skip DB_CONNECTION_URI lines + if not line.strip().startswith("DB_CONNECTION_URI"): + f.write(line) + + # Start all harnesses + for harness in self.harnesses: + print(f"\n--- Starting Instance {harness.instance_id} ---") + + # Create temporary docker-compose.yml + harness.create_temp_docker_compose() + + # Create an empty .env file in temp directory + if harness.temp_dir and harness.temp_dir.exists(): + (harness.temp_dir / ".env").touch() + else: + raise Exception( + f"Temporary directory does not exist for instance {harness.instance_id}" + ) + + # Start database + harness.start_database() + + # Wait for database to be ready + if not harness.wait_for_database(): + print( + f"Database failed to start for instance {harness.instance_id}. Exiting." + ) + sys.exit(1) + + # Provision database + harness.provision_database() + + # Verify database is empty + harness.verify_empty_database() + + # Start FastAPI server + harness.start_fastapi_server() + + # Wait for FastAPI to be ready + if not harness.wait_for_fastapi(): + print( + f"FastAPI server failed to start for instance {harness.instance_id}. Exiting." + ) + sys.exit(1) + + # Start deriver + harness.start_deriver() + + # Start output streaming threads + for name, process in harness.processes: + thread = threading.Thread( + target=harness.stream_process_output, + args=(name, process), + daemon=True, + ) + thread.start() + harness.output_threads.append(thread) + + print(f"āœ… Instance {harness.instance_id} is ready!") + + # Print summary + print(f"\n{'=' * 80}") + print(f"šŸŽ‰ All {self.pool_size} Honcho instances are running!") + print(f"{'=' * 80}") + for harness in self.harnesses: + print(f"\nInstance {harness.instance_id}:") + print(f" šŸ“Š Database: localhost:{harness.db_port}") + print(f" 🌐 API Server: http://localhost:{harness.api_port}") + print(f" šŸ“š API Docs: http://localhost:{harness.api_port}/docs") + print(f"\n{'=' * 80}") + print("Press Ctrl+C to stop all services") + print(f"{'=' * 80}\n") + + # Monitor all processes for unexpected termination + while True: + for harness in self.harnesses: + for name, process in harness.processes: + if process.poll() is not None: + print(f"āŒ {name} has stopped unexpectedly") + return + time.sleep(1) + + except KeyboardInterrupt: + print("\nšŸ›‘ Received interrupt signal") + except Exception as e: + print(f"āŒ Error: {e}") + finally: + self.cleanup() + + def cleanup(self) -> None: + """ + Clean up all harnesses in the pool. + """ + print("\nCleaning up pool...") + for harness in self.harnesses: + print(f"\n--- Cleaning up Instance {harness.instance_id} ---") + harness.cleanup() + + def main(): """ Main entry point for the Honcho harness. @@ -642,6 +835,7 @@ def main(): epilog=""" Examples: %(prog)s --port 5433 # Run with database on port 5433 + %(prog)s --pool-size 4 # Run pool of 4 instances (ports 5433-5436, APIs 8000-8003) %(prog)s --port 5434 --project-root /path/to/honcho # Custom project root """, ) @@ -650,7 +844,21 @@ Examples: "--port", type=int, default=5433, - help="Port for the PostgreSQL database (default: 5433)", + help="Base port for the PostgreSQL database (default: 5433)", + ) + + parser.add_argument( + "--api-port", + type=int, + default=8000, + help="Base port for the FastAPI server (default: 8000)", + ) + + parser.add_argument( + "--pool-size", + type=int, + default=1, + help="Number of Honcho instances to run in parallel (default: 1)", ) parser.add_argument( @@ -662,6 +870,11 @@ Examples: args = parser.parse_args() + # Validate pool size + if args.pool_size <= 0: + print(f"Error: Pool size must be positive, got {args.pool_size}") + sys.exit(1) + # Validate project root if not (args.project_root / "src" / "main.py").exists(): print( @@ -682,9 +895,23 @@ Examples: print(f"Error: Required file {file_path} not found in {args.project_root}") sys.exit(1) - # Create and run the harness - harness = HonchoHarness(args.port, args.project_root) - harness.run() + # Create and run the harness or pool + if args.pool_size > 1: + pool = HonchoHarnessPool( + pool_size=args.pool_size, + base_db_port=args.port, + base_api_port=args.api_port, + project_root=args.project_root, + ) + pool.run() + else: + harness = HonchoHarness( + db_port=args.port, + api_port=args.api_port, + project_root=args.project_root, + instance_id=0, + ) + harness.run() if __name__ == "__main__": diff --git a/tests/bench/longmem.py b/tests/bench/longmem.py index 05d2b63e..6557ad74 100644 --- a/tests/bench/longmem.py +++ b/tests/bench/longmem.py @@ -38,10 +38,13 @@ Optional arguments: ``` --anthropic-api-key: Anthropic API key for response judging (can be set in .env as LLM_ANTHROPIC_API_KEY or provided as an argument) --timeout: Timeout for deriver queue to empty in seconds (default: 10 minutes) ---honcho-url: URL of the running Honcho instance (default: http://localhost:8000) +--base-api-port: Base port for Honcho API instances (default: 8000) +--pool-size: Number of Honcho instances in the pool (default: 1) --batch-size: Number of questions to run concurrently in each batch (default: 10) --json-output: Path to write JSON summary results for analytics (if not provided, creates timestamped file in tests/bench/eval_results) --merge-sessions: Merge all sessions within a question into a single session (default: False) +--cleanup-workspace: Delete workspace after executing each question (default: False) +--use-get-context: Use get_context + judge LLM instead of dialectic .chat endpoint (default: False) ``` ## Other notes @@ -57,10 +60,11 @@ import os import time from datetime import datetime from pathlib import Path -from typing import Any +from typing import Any, cast import tiktoken from anthropic import AsyncAnthropic +from anthropic.types import MessageParam from dotenv import load_dotenv from honcho import AsyncHoncho from honcho.async_client.session import SessionPeerConfig @@ -115,26 +119,35 @@ class LongMemEvalRunner: def __init__( self, - honcho_url: str = "http://localhost:8000", + base_api_port: int = 8000, + pool_size: int = 1, anthropic_api_key: str | None = None, timeout_seconds: int | None = None, merge_sessions: bool = False, + cleanup_workspace: bool = False, + use_get_context: bool = False, ): """ Initialize the test runner. Args: - honcho_url: URL of the running Honcho instance + base_api_port: Base port for Honcho API instances (default: 8000) + pool_size: Number of Honcho instances in the pool (default: 1) anthropic_api_key: Anthropic API key for judging responses timeout_seconds: Timeout for deriver queue in seconds merge_sessions: If True, merge all sessions within a question into one session + cleanup_workspace: If True, delete workspace after executing question (default: False) + use_get_context: If True, use get_context + judge LLM instead of dialectic .chat endpoint """ - self.honcho_url: str = honcho_url + self.base_api_port: int = base_api_port + self.pool_size: int = pool_size self.anthropic_api_key: str | None = anthropic_api_key self.timeout_seconds: int = ( timeout_seconds if timeout_seconds is not None else 10000 ) self.merge_sessions: bool = merge_sessions + self.cleanup_workspace: bool = cleanup_workspace + self.use_get_context: bool = use_get_context # Initialize metrics collector self.metrics_collector: MetricsCollector = MetricsCollector() @@ -162,6 +175,20 @@ class LongMemEvalRunner: raise ValueError("LLM_ANTHROPIC_API_KEY is not set") self.anthropic_client = AsyncAnthropic(api_key=api_key) + def get_honcho_url_for_index(self, question_index: int) -> str: + """ + Get the Honcho URL for a given question index using round-robin distribution. + + Args: + question_index: Index of the question in the test file + + Returns: + URL of the Honcho instance to use for this question + """ + instance_id = question_index % self.pool_size + port = self.base_api_port + instance_id + return f"http://localhost:{port}" + def _format_duration(self, total_seconds: float) -> str: """Format a duration in seconds into a human-readable string. @@ -201,7 +228,20 @@ class LongMemEvalRunner: for session_messages in haystack_sessions: for msg in session_messages: content = msg.get("content", "") - total_tokens += len(tokenizer.encode(content)) + try: + total_tokens += len( + tokenizer.encode( + content, + disallowed_special=( + tokenizer.special_tokens_set - {"<|endoftext|>"} + ), + ) + ) + except Exception: + total_tokens += len(content) // 4 + self.logger.warning( + f"Error tokenizing content. Using rough estimate of {len(content) // 4} tokens" + ) return total_tokens @@ -281,12 +321,15 @@ class LongMemEvalRunner: with open(test_file) as f: return json.load(f) - async def create_honcho_client(self, workspace_id: str) -> AsyncHoncho: + async def create_honcho_client( + self, workspace_id: str, honcho_url: str + ) -> AsyncHoncho: """ Create a Honcho client for a specific workspace. Args: workspace_id: Workspace ID for the test + honcho_url: URL of the Honcho instance Returns: AsyncHoncho client instance @@ -294,7 +337,7 @@ class LongMemEvalRunner: return AsyncHoncho( environment="local", workspace_id=workspace_id, - base_url=self.honcho_url, + base_url=honcho_url, ) async def wait_for_deriver_queue_empty( @@ -358,7 +401,7 @@ Actual response: "{actual_response}" Evaluate whether the actual response correctly answers the question based on the expected answer. Focus on factual accuracy and evidence that the AI accessed the correct memory.""" response = await self.anthropic_client.messages.create( - model="claude-sonnet-4-20250514", + model="claude-sonnet-4-5", max_tokens=300, temperature=0.0, system=system_prompt, @@ -402,12 +445,15 @@ Evaluate whether the actual response correctly answers the question based on the "reasoning": f"Fallback string matching due to error: {'Match found' if is_correct else 'No match found'}", } - async def execute_question(self, question_data: dict[str, Any]) -> TestResult: + async def execute_question( + self, question_data: dict[str, Any], honcho_url: str + ) -> TestResult: """ Execute a single longmemeval question. Args: question_data: Dictionary containing question data + honcho_url: URL of the Honcho instance to use Returns: Test execution results @@ -428,10 +474,11 @@ Evaluate whether the actual response correctly answers the question based on the ) output_lines.append(f"Question: {question_with_date}") output_lines.append(f"Expected: {expected_answer}") + output_lines.append(f"Using Honcho instance: {honcho_url}") # Create workspace for this question workspace_id = f"{question_id}_{question_type}" - honcho_client = await self.create_honcho_client(workspace_id) + honcho_client = await self.create_honcho_client(workspace_id, honcho_url) results: TestResult = { "question_id": question_id, @@ -579,6 +626,7 @@ Evaluate whether the actual response correctly answers the question based on the ) ) else: + merged_session_id = None # create separate sessions # Zip together dates, session IDs, and session content for session_date, session_id, session_messages in zip( @@ -663,7 +711,9 @@ Evaluate whether the actual response correctly answers the question based on the ) if honcho_messages: - await session.add_messages(honcho_messages) + for i in range(0, len(honcho_messages), 100): + batch = honcho_messages[i : i + 100] + await session.add_messages(batch) results["sessions_created"].append( SessionResult( @@ -688,13 +738,59 @@ Evaluate whether the actual response correctly answers the question based on the output_lines.append(f"\nAsking question: {question_with_date}") try: - # Use the appropriate peer based on question type - if is_assistant_type: - # For assistant questions, use the assistant peer - actual_response = await assistant_peer.chat(question_with_date) + if self.use_get_context: + # Use get_context instead of dialectic .chat endpoint + # Get the session to retrieve context from + if not self.merge_sessions or merged_session_id is None: + raise ValueError( + "Merged session ID is required when using get_context. Set --merge-sessions to True." + ) + session = await honcho_client.session(id=merged_session_id) + + # Get context for the appropriate peer + peer_id = "assistant" if is_assistant_type else "user" + context = await session.get_context( + summary=True, + peer_target=peer_id, + last_user_message=question, + ) + + # Format context using to_anthropic method + context_messages = context.to_anthropic(assistant="assistant") + + # Add the question as the final user message + context_messages.append( + {"role": "user", "content": question_with_date} + ) + + # Call Anthropic API to generate response + response = await self.anthropic_client.messages.create( + model="claude-sonnet-4-5", + max_tokens=1024, + messages=cast(list[MessageParam], context_messages), + ) + + if not response.content: + raise ValueError("Anthropic returned empty response") + + content_block = response.content[0] + actual_response = getattr(content_block, "text", "") else: - # For user questions, use the user peer (default behavior) - actual_response = await user_peer.chat(question_with_date) + # Use the appropriate peer based on question type + if is_assistant_type: + # For assistant questions, use the assistant peer + actual_response = await assistant_peer.chat(question_with_date) + else: + # For user questions, use the user peer (default behavior) + actual_response = await user_peer.chat(question_with_date) + + # Clean up workspace if requested + if self.cleanup_workspace: + try: + await honcho_client.delete_workspace(workspace_id) + print(f"[{workspace_id}] cleaned up workspace") + except Exception as e: + print(f"Failed to delete workspace: {e}") actual_response = ( actual_response if isinstance(actual_response, str) else "" @@ -790,6 +886,10 @@ Evaluate whether the actual response correctly answers the question based on the print( f"found {len(questions)} {'question' if len(questions) == 1 else 'questions'} in {test_file}" ) + if self.pool_size > 1: + print( + f"distributing questions across {self.pool_size} Honcho instances (ports {self.base_api_port}-{self.base_api_port + self.pool_size - 1})" + ) overall_start = time.time() @@ -807,9 +907,12 @@ Evaluate whether the actual response correctly answers the question based on the ) print(f"{'=' * 60}") - # Run questions in current batch concurrently + # Run questions in current batch concurrently, distributing via round-robin batch_results: list[TestResult] = await asyncio.gather( - *[self.execute_question(q) for q in batch] + *[ + self.execute_question(q, self.get_honcho_url_for_index(i + idx)) + for idx, q in enumerate(batch) + ] ) # Print detailed per-question outputs for this batch @@ -983,7 +1086,8 @@ Evaluate whether the actual response correctly answers the question based on the "test_file": str(test_file), "execution_timestamp": datetime.now().isoformat(), "runner_version": "1.0.0", - "honcho_url": self.honcho_url, + "base_api_port": self.base_api_port, + "pool_size": self.pool_size, "timeout_seconds": self.timeout_seconds, "deriver_settings": settings.DERIVER.model_dump(), "dialectic_settings": settings.DIALECTIC.model_dump(), @@ -1034,7 +1138,8 @@ async def main() -> int: epilog=""" Examples: %(prog)s --test-file tests/bench/longmemeval_data/longmemeval_s.json # Run longmemeval tests - %(prog)s --honcho-url http://localhost:8000 # Custom Honcho URL + %(prog)s --test-file test.json --pool-size 4 # Use 4 Honcho instances + %(prog)s --test-file test.json --base-api-port 8000 --pool-size 4 # Custom base port with pool """, ) @@ -1046,10 +1151,17 @@ Examples: ) parser.add_argument( - "--honcho-url", - type=str, - default="http://localhost:8000", - help="URL of the running Honcho instance (default: http://localhost:8000)", + "--base-api-port", + type=int, + default=8000, + help="Base port for Honcho API instances (default: 8000)", + ) + + parser.add_argument( + "--pool-size", + type=int, + default=1, + help="Number of Honcho instances in the pool (default: 1)", ) parser.add_argument( @@ -1084,6 +1196,18 @@ Examples: help="Merge all sessions within a question into a single session (default: False)", ) + parser.add_argument( + "--cleanup-workspace", + action="store_true", + help="Delete workspace after executing each question (default: False)", + ) + + parser.add_argument( + "--use-get-context", + action="store_true", + help="Use get_context + judge LLM instead of dialectic .chat endpoint (default: False)", + ) + args = parser.parse_args() # Validate arguments @@ -1095,12 +1219,19 @@ Examples: print(f"Error: Batch size must be positive, got {args.batch_size}") return 1 + if args.pool_size <= 0: + print(f"Error: Pool size must be positive, got {args.pool_size}") + return 1 + # Create test runner runner = LongMemEvalRunner( - honcho_url=args.honcho_url, + base_api_port=args.base_api_port, + pool_size=args.pool_size, anthropic_api_key=args.anthropic_api_key, timeout_seconds=args.timeout, merge_sessions=args.merge_sessions, + cleanup_workspace=args.cleanup_workspace, + use_get_context=args.use_get_context, ) try: diff --git a/tests/conftest.py b/tests/conftest.py index 58da6027..844a2769 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -351,10 +351,8 @@ def mock_llm_call_functions(): mock_critical_analysis_result._response = mock_response mock_critical_analysis.return_value = mock_critical_analysis_result - # Create a proper async mock result for dialectic_call - mock_dialectic_result = MagicMock() - mock_dialectic_result.content = "Test dialectic response" - mock_dialectic_call.return_value = mock_dialectic_result + # Mock dialectic_call to return a string (matching actual return type) + mock_dialectic_call.return_value = "Test dialectic response" mock_dialectic_stream.return_value = AsyncMock() diff --git a/tests/crud/test_workspace.py b/tests/crud/test_workspace.py new file mode 100644 index 00000000..a9d32fb6 --- /dev/null +++ b/tests/crud/test_workspace.py @@ -0,0 +1,498 @@ +import pytest +from nanoid import generate as generate_nanoid +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from src import crud, models, schemas +from src.exceptions import ResourceNotFoundException + + +class TestWorkspaceCRUD: + """Test suite for workspace CRUD operations""" + + @pytest.mark.asyncio + async def test_delete_workspace_not_found(self, db_session: AsyncSession): + """Test delete_workspace with non-existent workspace raises ResourceNotFoundException""" + with pytest.raises(ResourceNotFoundException): + await crud.delete_workspace(db_session, "nonexistent_workspace") + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_peers( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete peers""" + test_workspace, _test_peer = sample_data + + # Create additional peer + peer2 = models.Peer( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(peer2) + await db_session.flush() + + # Verify peers exist + stmt = select(models.Peer).where( + models.Peer.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + peers = result.scalars().all() + assert len(peers) == 2 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify peers are deleted + result = await db_session.execute(stmt) + peers = result.scalars().all() + assert len(peers) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_sessions( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete sessions""" + test_workspace, _test_peer = sample_data + + # Create sessions + session1 = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + session2 = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add_all([session1, session2]) + await db_session.flush() + + # Verify sessions exist + stmt = select(models.Session).where( + models.Session.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + sessions = result.scalars().all() + assert len(sessions) == 2 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify sessions are deleted + result = await db_session.execute(stmt) + sessions = result.scalars().all() + assert len(sessions) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_messages( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete messages""" + test_workspace, test_peer = sample_data + + # Create session + session = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(session) + await db_session.flush() + + # Create messages + message1 = models.Message( + content="Test message 1", + workspace_name=test_workspace.name, + session_name=session.name, + peer_name=test_peer.name, + ) + message2 = models.Message( + content="Test message 2", + workspace_name=test_workspace.name, + session_name=session.name, + peer_name=test_peer.name, + ) + db_session.add_all([message1, message2]) + await db_session.flush() + + # Verify messages exist + stmt = select(models.Message).where( + models.Message.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + messages = result.scalars().all() + assert len(messages) == 2 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify messages are deleted + result = await db_session.execute(stmt) + messages = result.scalars().all() + assert len(messages) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_collections( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete collections""" + test_workspace, test_peer = sample_data + + # Create collection + collection = models.Collection( + workspace_name=test_workspace.name, + observer=test_peer.name, + observed=test_peer.name, + ) + db_session.add(collection) + await db_session.flush() + + # Verify collection exists + stmt = select(models.Collection).where( + models.Collection.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + collections = result.scalars().all() + assert len(collections) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify collection is deleted + result = await db_session.execute(stmt) + collections = result.scalars().all() + assert len(collections) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_documents( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete documents""" + test_workspace, test_peer = sample_data + + # Create collection + collection = models.Collection( + workspace_name=test_workspace.name, + observer=test_peer.name, + observed=test_peer.name, + ) + db_session.add(collection) + await db_session.flush() + + # Create session for document + session = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(session) + await db_session.flush() + + # Create document + document = models.Document( + workspace_name=test_workspace.name, + observer=test_peer.name, + observed=test_peer.name, + session_name=session.name, + content="Test document content", + embedding=[0.1] * 1536, # Mock embedding vector + ) + db_session.add(document) + await db_session.flush() + + # Verify document exists + stmt = select(models.Document).where( + models.Document.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + documents = result.scalars().all() + assert len(documents) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify document is deleted + result = await db_session.execute(stmt) + documents = result.scalars().all() + assert len(documents) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_session_peers( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete session_peers associations""" + test_workspace, test_peer = sample_data + + # Create session + session = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(session) + await db_session.flush() + + # Add peer to session + from src.models import session_peers_table + + stmt = session_peers_table.insert().values( + workspace_name=test_workspace.name, + session_name=session.name, + peer_name=test_peer.name, + ) + await db_session.execute(stmt) + await db_session.flush() + + # Verify session_peer association exists + stmt = select(session_peers_table).where( + session_peers_table.c.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + session_peers = result.all() + assert len(session_peers) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify session_peer association is deleted + result = await db_session.execute(stmt) + session_peers = result.all() + assert len(session_peers) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_webhooks( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete webhook endpoints""" + test_workspace, _test_peer = sample_data + + # Create webhook endpoint + webhook = models.WebhookEndpoint( + workspace_name=test_workspace.name, + url="https://example.com/webhook", + ) + db_session.add(webhook) + await db_session.flush() + + # Verify webhook exists + stmt = select(models.WebhookEndpoint).where( + models.WebhookEndpoint.workspace_name == test_workspace.name + ) + result = await db_session.execute(stmt) + webhooks = result.scalars().all() + assert len(webhooks) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify webhook is deleted + result = await db_session.execute(stmt) + webhooks = result.scalars().all() + assert len(webhooks) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_queue_items( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete queue items""" + test_workspace, test_peer = sample_data + + # Create session + session = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(session) + await db_session.flush() + + # Create queue item with work_unit_key containing workspace name + # Format: {task_type}:{workspace_name}:{...} + queue_item = models.QueueItem( + work_unit_key=f"representation:{test_workspace.name}:{session.name}:{test_peer.name}:{test_peer.name}", + task_type="representation", + payload={"test": "data"}, + ) + db_session.add(queue_item) + await db_session.flush() + + # Verify queue item exists + stmt = select(models.QueueItem) + result = await db_session.execute(stmt) + queue_items = result.scalars().all() + assert len(queue_items) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify queue item is deleted + result = await db_session.execute(stmt) + queue_items = result.scalars().all() + assert len(queue_items) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_cascade_active_queue_sessions( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that deleting a workspace cascades to delete active queue sessions""" + test_workspace, test_peer = sample_data + + # Create session + session = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(session) + await db_session.flush() + + # Create active queue session with work_unit_key containing workspace name + # Format: {task_type}:{workspace_name}:{...} + active_queue = models.ActiveQueueSession( + work_unit_key=f"representation:{test_workspace.name}:{session.name}:{test_peer.name}:{test_peer.name}", + ) + db_session.add(active_queue) + await db_session.flush() + + # Verify active queue session exists + stmt = select(models.ActiveQueueSession) + result = await db_session.execute(stmt) + active_queues = result.scalars().all() + assert len(active_queues) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify active queue session is deleted + result = await db_session.execute(stmt) + active_queues = result.scalars().all() + assert len(active_queues) == 0 + + @pytest.mark.asyncio + async def test_delete_workspace_returns_deleted_workspace( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test that delete_workspace returns the deleted workspace object""" + test_workspace, _test_peer = sample_data + + # Store workspace details before deletion + workspace_name = test_workspace.name + + # Delete workspace + deleted_workspace = await crud.delete_workspace(db_session, test_workspace.name) + + # Verify returned workspace matches the deleted workspace + assert deleted_workspace.name == workspace_name + assert isinstance(deleted_workspace, schemas.Workspace) + + @pytest.mark.asyncio + async def test_delete_workspace_complex_cascade( + self, + db_session: AsyncSession, + sample_data: tuple[models.Workspace, models.Peer], + ): + """Test deleting a workspace with multiple related resources of different types""" + test_workspace, test_peer = sample_data + + # Create additional peer + peer2 = models.Peer( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add(peer2) + + # Create sessions + session1 = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + session2 = models.Session( + name=str(generate_nanoid()), workspace_name=test_workspace.name + ) + db_session.add_all([session1, session2]) + await db_session.flush() + + # Create messages + message1 = models.Message( + content="Test message 1", + workspace_name=test_workspace.name, + session_name=session1.name, + peer_name=test_peer.name, + ) + message2 = models.Message( + content="Test message 2", + workspace_name=test_workspace.name, + session_name=session2.name, + peer_name=peer2.name, + ) + db_session.add_all([message1, message2]) + + # Create collection and document + collection = models.Collection( + workspace_name=test_workspace.name, + observer=test_peer.name, + observed=peer2.name, + ) + db_session.add(collection) + await db_session.flush() + + document = models.Document( + workspace_name=test_workspace.name, + observer=test_peer.name, + observed=peer2.name, + session_name=session1.name, + content="Test document", + embedding=[0.1] * 1536, # Mock embedding vector + ) + db_session.add(document) + + # Create webhook + webhook = models.WebhookEndpoint( + workspace_name=test_workspace.name, + url="https://example.com/webhook", + ) + db_session.add(webhook) + await db_session.flush() + + # Count all resources before deletion + peer_stmt = select(models.Peer).where( + models.Peer.workspace_name == test_workspace.name + ) + session_stmt = select(models.Session).where( + models.Session.workspace_name == test_workspace.name + ) + message_stmt = select(models.Message).where( + models.Message.workspace_name == test_workspace.name + ) + collection_stmt = select(models.Collection).where( + models.Collection.workspace_name == test_workspace.name + ) + document_stmt = select(models.Document).where( + models.Document.workspace_name == test_workspace.name + ) + webhook_stmt = select(models.WebhookEndpoint).where( + models.WebhookEndpoint.workspace_name == test_workspace.name + ) + + # Verify all resources exist + assert len((await db_session.execute(peer_stmt)).scalars().all()) == 2 + assert len((await db_session.execute(session_stmt)).scalars().all()) == 2 + assert len((await db_session.execute(message_stmt)).scalars().all()) == 2 + assert len((await db_session.execute(collection_stmt)).scalars().all()) == 1 + assert len((await db_session.execute(document_stmt)).scalars().all()) == 1 + assert len((await db_session.execute(webhook_stmt)).scalars().all()) == 1 + + # Delete workspace + await crud.delete_workspace(db_session, test_workspace.name) + + # Verify all related resources are deleted + assert len((await db_session.execute(peer_stmt)).scalars().all()) == 0 + assert len((await db_session.execute(session_stmt)).scalars().all()) == 0 + assert len((await db_session.execute(message_stmt)).scalars().all()) == 0 + assert len((await db_session.execute(collection_stmt)).scalars().all()) == 0 + assert len((await db_session.execute(document_stmt)).scalars().all()) == 0 + assert len((await db_session.execute(webhook_stmt)).scalars().all()) == 0 diff --git a/tests/routes/test_workspaces.py b/tests/routes/test_workspaces.py index 7cdaa335..f43e4dbe 100644 --- a/tests/routes/test_workspaces.py +++ b/tests/routes/test_workspaces.py @@ -264,3 +264,252 @@ def test_search_workspace_nonexistent(client: TestClient): # Should return empty list for nonexistent workspace assert isinstance(data, list) assert len(data) == 0 + + +def test_delete_workspace(client: TestClient): + """Test deleting a workspace""" + name = str(generate_nanoid()) + + # Create a workspace + response = client.post("/v2/workspaces", json={"name": name}) + assert response.status_code == 200 + workspace = response.json() + assert workspace["id"] == name + + # Delete the workspace + response = client.delete(f"/v2/workspaces/{name}") + assert response.status_code == 200 + deleted_workspace = response.json() + assert deleted_workspace["id"] == name + + # Verify the workspace no longer exists by trying to update it + response = client.put( + f"/v2/workspaces/{name}", json={"metadata": {"test": "value"}} + ) + # Should create a new workspace since the old one was deleted + assert response.status_code == 200 + + +def test_delete_nonexistent_workspace(client: TestClient): + """Test deleting a workspace that doesn't exist""" + nonexistent_workspace_id = str(generate_nanoid()) + + response = client.delete(f"/v2/workspaces/{nonexistent_workspace_id}") + assert response.status_code == 404 + data = response.json() + assert "detail" in data + assert "not found" in data["detail"].lower() + + +def test_delete_workspace_with_peers(client: TestClient): + """Test deleting a workspace that has peers""" + workspace_name = str(generate_nanoid()) + + # Create workspace + response = client.post("/v2/workspaces", json={"name": workspace_name}) + assert response.status_code == 200 + + # Create peers + peer1_name = str(generate_nanoid()) + peer2_name = str(generate_nanoid()) + response = client.post( + f"/v2/workspaces/{workspace_name}/peers", json={"name": peer1_name} + ) + assert response.status_code == 200 + response = client.post( + f"/v2/workspaces/{workspace_name}/peers", json={"name": peer2_name} + ) + assert response.status_code == 200 + + # Delete workspace + response = client.delete(f"/v2/workspaces/{workspace_name}") + assert response.status_code == 200 + + +def test_delete_workspace_with_sessions(client: TestClient): + """Test deleting a workspace that has sessions""" + workspace_name = str(generate_nanoid()) + + # Create workspace + response = client.post("/v2/workspaces", json={"name": workspace_name}) + assert response.status_code == 200 + + # Create peer + peer_name = str(generate_nanoid()) + response = client.post( + f"/v2/workspaces/{workspace_name}/peers", json={"name": peer_name} + ) + assert response.status_code == 200 + + # Create sessions + session1_name = str(generate_nanoid()) + session2_name = str(generate_nanoid()) + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions", json={"name": session1_name} + ) + assert response.status_code == 200 + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions", json={"name": session2_name} + ) + assert response.status_code == 200 + + # Delete workspace + response = client.delete(f"/v2/workspaces/{workspace_name}") + assert response.status_code == 200 + + +def test_delete_workspace_with_messages(client: TestClient): + """Test deleting a workspace that has messages""" + workspace_name = str(generate_nanoid()) + + # Create workspace + response = client.post("/v2/workspaces", json={"name": workspace_name}) + assert response.status_code == 200 + + # Create peer + peer_name = str(generate_nanoid()) + response = client.post( + f"/v2/workspaces/{workspace_name}/peers", json={"name": peer_name} + ) + assert response.status_code == 200 + + # Create session + session_name = str(generate_nanoid()) + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions", json={"name": session_name} + ) + assert response.status_code == 200 + + # Add peer to session + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions/{session_name}/peers", + json={peer_name: {}}, + ) + assert response.status_code == 200 + + # Create messages + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions/{session_name}/messages", + json={ + "messages": [ + {"content": "Test message 1", "peer_id": peer_name}, + {"content": "Test message 2", "peer_id": peer_name}, + ] + }, + ) + assert response.status_code == 200 + + # Delete workspace + response = client.delete(f"/v2/workspaces/{workspace_name}") + assert response.status_code == 200 + + +def test_delete_workspace_with_webhooks(client: TestClient): + """Test deleting a workspace that has webhooks""" + workspace_name = str(generate_nanoid()) + + # Create workspace + response = client.post("/v2/workspaces", json={"name": workspace_name}) + assert response.status_code == 200 + + # Create webhook + response = client.post( + f"/v2/workspaces/{workspace_name}/webhooks", + json={ + "url": "https://example.com/webhook", + }, + ) + assert response.status_code == 200 + + # Delete workspace + response = client.delete(f"/v2/workspaces/{workspace_name}") + assert response.status_code == 200 + + # Verify webhook is deleted by checking workspace doesn't exist + response = client.get(f"/v2/workspaces/{workspace_name}/webhooks") + # This should either return 404 or empty list depending on implementation + assert response.status_code in [404, 200] + + +def test_delete_workspace_cascade(client: TestClient): + """Test that deleting a workspace cascades to all related resources""" + workspace_name = str(generate_nanoid()) + + # Create workspace with complex structure + response = client.post( + "/v2/workspaces", + json={"name": workspace_name, "metadata": {"test": "cascade"}}, + ) + assert response.status_code == 200 + + # Create multiple peers + peer_names = [str(generate_nanoid()) for _ in range(3)] + for peer_name in peer_names: + response = client.post( + f"/v2/workspaces/{workspace_name}/peers", json={"name": peer_name} + ) + assert response.status_code == 200 + + # Create multiple sessions + session_names = [str(generate_nanoid()) for _ in range(2)] + for session_name in session_names: + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions", json={"name": session_name} + ) + assert response.status_code == 200 + + # Add peers to sessions and create messages + for session_name in session_names: + for peer_name in peer_names[:2]: # Add 2 peers to each session + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions/{session_name}/peers", + json={peer_name: {}}, + ) + assert response.status_code == 200 + + # Create messages in session + response = client.post( + f"/v2/workspaces/{workspace_name}/sessions/{session_name}/messages", + json={ + "messages": [ + { + "content": f"Test message in {session_name}", + "peer_id": peer_names[0], + } + ] + }, + ) + assert response.status_code == 200 + + # Delete the workspace + response = client.delete(f"/v2/workspaces/{workspace_name}") + assert response.status_code == 200 + deleted_workspace = response.json() + assert deleted_workspace["id"] == workspace_name + assert deleted_workspace["metadata"]["test"] == "cascade" + + +def test_delete_workspace_returns_workspace_data(client: TestClient): + """Test that delete workspace returns the deleted workspace data""" + name = str(generate_nanoid()) + metadata = {"key": "value", "number": 42} + configuration = {"feature": True} + + # Create workspace with metadata and configuration + response = client.post( + "/v2/workspaces", + json={"name": name, "metadata": metadata, "configuration": configuration}, + ) + assert response.status_code == 200 + created_workspace = response.json() + + # Delete workspace + response = client.delete(f"/v2/workspaces/{name}") + assert response.status_code == 200 + deleted_workspace = response.json() + + # Verify returned data matches original workspace + assert deleted_workspace["id"] == created_workspace["id"] + assert deleted_workspace["metadata"] == metadata + assert deleted_workspace["configuration"] == configuration + assert "created_at" in deleted_workspace diff --git a/tests/utils/test_clients.py b/tests/utils/test_clients.py index 93816c85..c6552926 100644 --- a/tests/utils/test_clients.py +++ b/tests/utils/test_clients.py @@ -542,10 +542,15 @@ class TestGoogleClient: mock_response.text = "Hello from Gemini" mock_finish_reason = Mock() mock_finish_reason.name = "STOP" - mock_response.candidates = [ - Mock(token_count=5, finish_reason=mock_finish_reason) - ] - mock_client.models.generate_content.return_value = mock_response + mock_response.candidates = [Mock(finish_reason=mock_finish_reason)] + # Mock the usage_metadata with candidates_token_count + mock_usage_metadata = Mock() + mock_usage_metadata.candidates_token_count = 5 + mock_response.usage_metadata = mock_usage_metadata + # Mock the async aio interface + mock_aio = Mock() + mock_aio.models.generate_content = AsyncMock(return_value=mock_response) + mock_client.aio = mock_aio with patch.dict(CLIENTS, {"google": mock_client}): response = await honcho_llm_call_inner( @@ -569,10 +574,15 @@ class TestGoogleClient: mock_response.text = '{"result": "success"}' mock_finish_reason = Mock() mock_finish_reason.name = "STOP" - mock_response.candidates = [ - Mock(token_count=10, finish_reason=mock_finish_reason) - ] - mock_client.models.generate_content.return_value = mock_response + mock_response.candidates = [Mock(finish_reason=mock_finish_reason)] + # Mock the usage_metadata with candidates_token_count + mock_usage_metadata = Mock() + mock_usage_metadata.candidates_token_count = 10 + mock_response.usage_metadata = mock_usage_metadata + # Mock the async aio interface + mock_aio = Mock() + mock_aio.models.generate_content = AsyncMock(return_value=mock_response) + mock_client.aio = mock_aio with patch.dict(CLIENTS, {"google": mock_client}): _response = await honcho_llm_call_inner( @@ -584,8 +594,8 @@ class TestGoogleClient: ) # Verify JSON mode was set in config - mock_client.models.generate_content.assert_called_once() - call_args = mock_client.models.generate_content.call_args + mock_aio.models.generate_content.assert_called_once() + call_args = mock_aio.models.generate_content.call_args assert ( call_args.kwargs["config"]["response_mime_type"] == "application/json" ) @@ -600,10 +610,15 @@ class TestGoogleClient: mock_response.parsed = mock_parsed mock_finish_reason = Mock() mock_finish_reason.name = "STOP" - mock_response.candidates = [ - Mock(token_count=15, finish_reason=mock_finish_reason) - ] - mock_client.models.generate_content.return_value = mock_response + mock_response.candidates = [Mock(finish_reason=mock_finish_reason)] + # Mock the usage_metadata with candidates_token_count + mock_usage_metadata = Mock() + mock_usage_metadata.candidates_token_count = 15 + mock_response.usage_metadata = mock_usage_metadata + # Mock the async aio interface + mock_aio = Mock() + mock_aio.models.generate_content = AsyncMock(return_value=mock_response) + mock_client.aio = mock_aio with patch.dict(CLIENTS, {"google": mock_client}): response = await honcho_llm_call_inner( @@ -620,8 +635,8 @@ class TestGoogleClient: assert response.content.age == 25 # Verify structured output config - mock_client.models.generate_content.assert_called_once() - call_args = mock_client.models.generate_content.call_args + mock_aio.models.generate_content.assert_called_once() + call_args = mock_aio.models.generate_content.call_args config = call_args.kwargs["config"] assert config["response_mime_type"] == "application/json" assert config["response_schema"] == SampleTestModel @@ -682,7 +697,12 @@ class TestGoogleClient: mock_response = Mock() mock_response.text = "Response text" mock_response.candidates = [] # Empty candidates - mock_client.models.generate_content.return_value = mock_response + # Mock usage_metadata as None to test fallback + mock_response.usage_metadata = None + # Mock the async aio interface + mock_aio = Mock() + mock_aio.models.generate_content = AsyncMock(return_value=mock_response) + mock_client.aio = mock_aio with patch.dict(CLIENTS, {"google": mock_client}): response = await honcho_llm_call_inner( diff --git a/uv.lock b/uv.lock index 5a2041ec..9d96e1cf 100644 --- a/uv.lock +++ b/uv.lock @@ -780,7 +780,7 @@ dev = [ [package.metadata] requires-dist = [ - { name = "honcho-core", specifier = ">=1.5.0" }, + { name = "honcho-core", specifier = ">=1.5.1" }, { name = "httpx", specifier = ">=0.28.0,<1" }, { name = "pydantic", specifier = ">=2.0.0,<3" }, { name = "typing-extensions", marker = "python_full_version < '3.12'", specifier = ">=4.12.0" }, @@ -791,7 +791,7 @@ dev = [{ name = "ruff", specifier = ">=0.11.13" }] [[package]] name = "honcho-core" -version = "1.5.0" +version = "1.5.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -801,9 +801,9 @@ dependencies = [ { name = "sniffio" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/75/cd/05d2a21afd037673637e390de411cd66ca56b07e524cd7ead65c655a2b49/honcho_core-1.5.0.tar.gz", hash = "sha256:4876195dad16db437117d40a1d5e34ff88974e8eca6d093f3653b4ac2bda3c6d", size = 132236, upload-time = "2025-10-08T18:30:15.777Z" } +sdist = { url = "https://files.pythonhosted.org/packages/a7/9f/6246f02a301a5fa1b9cd00784fafbb3f812feebfaa10a5135104885547da/honcho_core-1.5.1.tar.gz", hash = "sha256:d76da6657707df76ff464ac6874925f31c9e83fe8de51daeb0b10986385e02c7", size = 132626, upload-time = "2025-10-09T20:01:03.07Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ef/4e/9ef193bba00c521be1152791d2ba37a98bdb58ece8f8ce7863b710a4f511/honcho_core-1.5.0-py3-none-any.whl", hash = "sha256:01db345371d6e80230b202c797a73f9f086dc244936522dbc39efb05f4cee306", size = 123210, upload-time = "2025-10-08T18:30:14.277Z" }, + { url = "https://files.pythonhosted.org/packages/a4/92/87e7c894175fa6aab5e49fac51a234290bc2e46d6723617edc154e0ec675/honcho_core-1.5.1-py3-none-any.whl", hash = "sha256:740cff160e2d9e6dc98ad39f566c1b96f5413ec1abdb415d2fd70f66151cf61a", size = 123292, upload-time = "2025-10-09T20:01:01.57Z" }, ] [[package]]