
    $ju                     p   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlZ	  ej        d          Zn# ej        $ r dZY nw xY wd	e Zdd
lmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ d Z0 G d d          Z1dS )z
Clean, pythonic wrapper for the Hindsight API client.

This file is MAINTAINED and NOT auto-generated. It provides a high-level,
easy-to-use interface on top of the auto-generated OpenAPI client.
    N)datetime)metadata)Path)AnyLiteralzhindsight-clientz0.0.0zhindsight-client-python/)
	banks_apidirectives_apidocuments_apientities_api	files_api
memory_apimental_models_apimonitoring_apioperations_apiwebhooks_api)memory_itemrecall_requestreflect_requestretain_request)ReflectIncludeOptions)BankProfileResponse)FileRetainResponse)ListMemoryUnitsResponse)RecallResponse)RecallResult)ReflectResponse)RetainResponsec                     	 t          j                    }n7# t          $ r* t          j                    }t          j        |           Y nw xY w|                    |           S )z%Run an async coroutine synchronously.)asyncioget_event_loopRuntimeErrornew_event_loopset_event_looprun_until_complete)coroloops     i/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/hindsight_client/hindsight_client.py
_run_asyncr(   3   sm    %%'' % % %%''t$$$$$% ""4(((s    1A
	A
c            /          e Zd ZdZ	 	 	 ddededz  dededz  fdZed	ej	        fd
            Z
ed	ej        fd            Zed	ej        fd            Zed	ej        fd            Zed	ej        fd            Zed	ej        fd            Zed	ej        fd            Zed	ej        fd            Zed	e j!        fd            Z"ed	e#j$        fd            Z%d Z&d Z'd Z(d Z)	 	 	 	 	 	 	 	 ddedede*dz  dedz  dedz  de+eef         dz  de,e+eef                  dz  d e,e         dz  d!edz  d"e-d	e.fd#Z/	 	 	 dded$e,e+ee0f                  dedz  d%e,e         dz  d"e-d	e.fd&Z1	 	 dded'e,ee2z           dedz  d(e,e+ee0f                  dz  d	e3f
d)Z4	 	 	 	 	 	 	 	 	 	 	 	 	 	 dded/ed0e,e         dz  d1e5d2ed3e-d4edz  d5e-d6e5d7e-d8e5d9e-d:e5d e,e         dz  d;e6d<         d=e,e+ee0f                  dz  d	e7f"d>Z8	 	 	 	 	 	 	 	 	 	 	 dded/ed2ededz  d1e5dz  d@e+ee0f         dz  d e,e         dz  d;e6d<         dAe-d=e,e+ee0f                  dz  dBe,e         dz  dCe-dDe,e         dz  d	e9fdEZ:	 	 	 	 ddedHedz  dIedz  dJe5dKe5d	e;fdLZ<	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddedMedz  dNedz  dOe5dz  dPe5dz  dQe5dz  dRe+eef         dz  dSedz  dTedz  dUedz  dVe5dz  dWe-dz  dXedz  dYedz  dZedz  d	e=f d[Z>	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddedMedz  dNedz  dYedz  dOe5dz  dPe5dz  dQe5dz  dRe+eef         dz  dSedz  dTedz  dUedz  dVe5dz  dWe-dz  dXedz  dZedz  d	e=f d\Z?dedNed	e+ee0f         fd]Z@dedYed	e+ee0f         fd^ZA	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddedMedz  dNedz  dOe5dz  dPe5dz  dQe5dz  dRe+eef         dz  dSedz  dTedz  dUedz  dVe5dz  dWe-dz  dXedz  dYedz  dZedz  d	e=f d_ZBdedNed	e+ee0f         fd`ZCdedYed	e+ee0f         fdaZD	 	 	 dded$e,e+ee0f                  dedz  d%e,e         dz  d"e-d	e.fdbZE	 	 	 	 	 	 	 	 ddedede*dz  dedz  dedz  de+eef         dz  de,e+eef                  dz  d e,e         dz  d!edz  d"e-d	e.fdcZF	 	 	 	 	 	 	 	 	 	 	 	 	 	 dded/ed0e,e         dz  d1e5d2ed3e-d4edz  d5e-d6e5d7e-d8e5d9e-d:e5d e,e         dz  d;e6d<         d=e,e+ee0f                  dz  d	e7f"ddZG	 	 	 	 	 	 	 	 	 	 	 dded/ed2ededz  d1e5dz  d@e+ee0f         dz  d e,e         dz  d;e6d<         dAe-d=e,e+ee0f                  dz  dBe,e         dz  dCe-dDe,e         dz  d	e9fdeZH	 	 	 	 ddedMedfed e,e         dz  d1e5dz  dge+ee0f         dz  dhedz  fdiZIdded e,e         dz  fdjZJdedkefdlZKdedkefdmZL	 	 	 	 	 ddedkedMedz  dfedz  d e,e         dz  d1e5dz  dge+ee0f         dz  fdnZMdedkefdoZNdedkefdpZO	 	 	 ddedMededre5dse-d e,e         dz  fdtZPdded e,e         dz  fduZQdedvefdwZR	 	 	 	 	 ddedvedMedz  dedz  dre5dz  dse-dz  d e,e         dz  fdxZSdedvefdyZTded	e+ee0f         fdzZUded	e+ee0f         fd{ZVddddddddddddddddddddd|dedYedz  d}e5dz  dSedz  dTedz  dUedz  dVe5dz  d~edz  de+ee0f         dz  de,e         dz  de-dz  dWe-dz  dXedz  de5dz  de5dz  de5dz  dOe5dz  dPe5dz  dQe5dz  de,e         dz  de+eef         dz  d	e+ee0f         f,dZWdede+ee0f         d	e+ee0f         fdZXded	e+ee0f         fdZYded	e+ee0f         fdZZdefdZ[defdZ\dS )	Hindsightu]  
    High-level, easy-to-use Hindsight API client.

    This class provides simplified methods for the most common operations:
    retain, recall, reflect, bank management, mental models, and directives.

    **Async vs sync:** Every convenience method has an async counterpart
    prefixed with ``a`` (e.g. ``aretain``, ``arecall``, ``areflect``).
    **Prefer the async variants** (``aretain``, ``arecall``, ``areflect``, etc.)
    whenever you are inside an async context (``async def``, event loops,
    frameworks like FastAPI/LangGraph/CrewAI). The sync versions (``retain``,
    ``recall``, ``reflect``) are convenience wrappers that call
    ``asyncio.run_until_complete`` under the hood — they exist for scripts and
    REPLs but will raise errors if an event loop is already running.

    For operations not covered here (documents, entities, operations/async jobs,
    webhooks, file uploads, monitoring), use the low-level API clients exposed
    as properties on this class. These are auto-generated from the OpenAPI spec
    and cover the full API surface. **All low-level methods are async-only.**

    Example — async (preferred)::

        from hindsight_client import Hindsight

        client = Hindsight(base_url="http://localhost:8888", api_key="your-api-key")

        # Inside an async function — use the a* methods
        await client.aretain(bank_id="alice", content="Alice loves AI")
        response = await client.arecall(bank_id="alice", query="What does Alice like?")
        answer = await client.areflect(bank_id="alice", query="What are my interests?")

    Example — sync (scripts / REPLs only)::

        # Outside an async context — sync wrappers are available
        client.retain(bank_id="alice", content="Alice loves AI")
        response = client.recall(bank_id="alice", query="What does Alice like?")

    Example — low-level API for advanced operations::

        # Access documents, entities, operations, webhooks, etc.
        # All low-level methods are async-only — use 'await' or asyncio.run().

        # List documents in a bank
        docs = await client.documents.list_documents("alice")

        # Delete a specific document
        await client.documents.delete_document("alice", "doc-123")

        # Check async operation status
        status = await client.operations.get_operation_status("alice", "op-456")

        # List entities
        entities = await client.entities.list_entities("alice")

    Available low-level API properties:
        - ``client.memory``: Core memory operations (MemoryApi)
        - ``client.banks``: Bank management (BanksApi)
        - ``client.documents``: Document CRUD (DocumentsApi)
        - ``client.entities``: Entity browsing (EntitiesApi)
        - ``client.mental_models``: Mental model management (MentalModelsApi)
        - ``client.directives``: Directive management (DirectivesApi)
        - ``client.operations``: Async operation tracking (OperationsApi)
        - ``client.webhooks``: Webhook management (WebhooksApi)
        - ``client.files``: File upload (FilesApi)
        - ``client.monitoring``: Health/version checks (MonitoringApi)
    N     r@base_urlapi_keytimeout
user_agentc                 r   t          j        ||          }t          j        |          | _        |pt          | j        _        || _        |                    d          | _        || _	        |r| j        
                    dd|            t          j        | j                  | _        t          j        | j                  | _        t#          j        | j                  | _        t)          j        | j                  | _        t/          j        | j                  | _        t5          j        | j                  | _        t;          j        | j                  | _        tA          j!        | j                  | _"        tG          j$        | j                  | _%        tM          j'        | j                  | _(        dS )a  
        Initialize the Hindsight client.

        Args:
            base_url: The base URL of the Hindsight API server
            api_key: Optional API key for authentication (sent as Bearer token)
            timeout: Request timeout in seconds (default: 300.0)
            user_agent: Override the default ``User-Agent`` header. Integrations
                should set this to identify themselves (e.g.
                ``"hindsight-crewai/1.2.0"``). Defaults to
                ``hindsight-client-python/<version>``.
        )hostaccess_token/AuthorizationBearer N))hindsight_client_apiConfiguration	ApiClient_api_clientDEFAULT_USER_AGENTr/   _timeoutrstrip	_base_url_api_keyset_default_headerr   	MemoryApi_memory_apir   BanksApi
_banks_apir   MentalModelsApi_mental_models_apir	   DirectivesApi_directives_apir   FilesApi
_files_apir
   DocumentsApi_documents_apir   EntitiesApi_entities_apir   OperationsApi_operations_apir   WebhooksApi_webhooks_apir   MonitoringApi_monitoring_api)selfr,   r-   r.   r/   configs         r'   __init__zHindsight.__init__   sj   & &3PWXXX/9&AA&0&F4F#!-- 	V//AT7ATATUUU%/0@AA#,T-=>>"3"CDDT"U"U-;D<LMM#,T-=>>+89IJJ)5d6FGG-;D<LMM)5d6FGG-;D<LMM    returnc                     | j         S )uW   Low-level Memory API — retain, recall, reflect, list/clear memories, tags, and graph.)rA   rT   s    r'   memoryzHindsight.memory   s     rW   c                     | j         S )uS   Low-level Banks API — create, update, delete banks; stats; consolidation; config.)rC   rZ   s    r'   bankszHindsight.banks        rW   c                     | j         S )uK   Low-level Documents API — list, get, update, delete documents and chunks.)rK   rZ   s    r'   	documentszHindsight.documents   s     ""rW   c                     | j         S )uI   Low-level Entities API — list, get, and regenerate entity observations.)rM   rZ   s    r'   entitieszHindsight.entities        !!rW   c                     | j         S )uT   Low-level Mental Models API — create, list, get, update, refresh, delete, history.)rE   rZ   s    r'   mental_modelszHindsight.mental_models   s     &&rW   c                     | j         S )u?   Low-level Directives API — create, list, get, update, delete.)rG   rZ   s    r'   
directiveszHindsight.directives        ##rW   c                     | j         S )uN   Low-level Operations API — get status, list, cancel, retry async operations.)rO   rZ   s    r'   
operationszHindsight.operations   rh   rW   c                     | j         S )uP   Low-level Webhooks API — create, list, update, delete webhooks and deliveries.)rQ   rZ   s    r'   webhookszHindsight.webhooks   rc   rW   c                     | j         S )u0   Low-level Files API — upload and retain files.)rI   rZ   s    r'   fileszHindsight.files   r^   rW   c                     | j         S )u<   Low-level Monitoring API — health check, version, metrics.)rS   rZ   s    r'   
monitoringzHindsight.monitoring   rh   rW   c                     | S )zContext manager entry. rZ   s    r'   	__enter__zHindsight.__enter__   s    rW   c                 .    |                                   dS )zContext manager exit.N)close)rT   exc_typeexc_valexc_tbs       r'   __exit__zHindsight.__exit__   s    

rW   c                    | j         ry	 t          j                    }|                    | j                                                    dS # t
          $ r* t          | j                                                    Y dS w xY wdS )zAClose the API client (sync version - use aclose() in async code).N)r9   r   get_running_loopcreate_taskru   r!   r(   )rT   r&   s     r'   ru   zHindsight.close   s     	55/11   !1!7!7!9!9::::: 5 5 54+11334444445	5 	5s   ?A
 
0A>=A>c                 Z   K   | j         r!| j                                          d{V  dS dS )z%Close the API client (async version).N)r9   ru   rZ   s    r'   aclosezHindsight.aclose   sH       	+"((***********	+ 	+rW   Fbank_idcontent	timestampcontextdocument_idr   rb   tagsupdate_moderetain_asyncc                 V    ||||||d}|	|	|d<   |                      ||g||
          S )u  
        Store a single memory (sync wrapper — prefer :meth:`aretain` in async code).

        Args:
            bank_id: The memory bank ID
            content: Memory content
            timestamp: Optional event timestamp
            context: Optional context description
            document_id: Optional document ID for grouping
            metadata: Optional user-defined metadata
            entities: Optional list of entities [{"text": "...", "type": "..."}]
            tags: Optional list of tags for filtering memories during recall/reflect
            update_mode: How to handle existing documents ('replace' or 'append')
            retain_async: If True, process asynchronously in background (default: False)

        Returns:
            RetainResponse with success status
        r   r   r   r   rb   r   Nr   r   itemsr   r   )retain_batchrT   r   r   r   r   r   r   rb   r   r   r   items               r'   retainzHindsight.retain   s`    @ "   
  
 ""-D  &#%	 ! 
 
 	
rW   r   document_tagsc           	      P    t          |                     |||||                    S )u6  
        Store multiple memories in batch (sync wrapper — prefer :meth:`aretain_batch` in async code).

        Args:
            bank_id: The memory bank ID
            items: List of memory items, each a dict with 'content' (required) and optional keys:
                'timestamp', 'context', 'metadata', 'document_id', 'entities', 'tags',
                'observation_scopes' (str or list[list[str]]), 'strategy'.
            document_id: Optional document ID for grouping memories (applied to items that don't have their own)
            document_tags: Optional list of tags applied to all items in this batch (merged with per-item tags)
            retain_async: If True, process asynchronously in background (default: False)

        Returns:
            RetainResponse with success status and item count
        )r   r   r   r   r   )r(   aretain_batch)rT   r   r   r   r   r   s         r'   r   zHindsight.retain_batch*  s=    . '+)   
 
 	
rW   rn   files_metadatac                 8   g }|D ]?}t          |          }|                    |j        |                                f           @|pfd|D             }t	          j        d|i          }	t          | j                            |||	| j	                            S )u  
        Upload files and retain their contents as memories (sync wrapper).

        Files are automatically converted to text (PDF, DOCX, images via OCR, audio via
        transcription, and more) and ingested as memories. Processing is always asynchronous
        — use the returned operation IDs to track progress.

        Args:
            bank_id: The memory bank ID
            files: List of file paths to upload
            context: Optional context description applied to all files
            files_metadata: Optional per-file metadata list. If provided, must match the
                length of `files`. Each entry can have: context, document_id, tags, metadata.

        Returns:
            FileRetainResponse with operation_ids for tracking progress
        c                      g | ]
}rd ini S )r   rr   ).0_r   s     r'   
<listcomp>z*Hindsight.retain_files.<locals>.<listcomp>h  s(    !Y!Y!Ya'"I9g"6"6r!Y!Y!YrW   r   )r   rn   request_request_timeout)
r   appendname
read_bytesjsondumpsr(   rI   file_retainr;   )
rT   r   rn   r   r   	file_data	file_pathpathmetarequest_bodys
      `      r'   retain_fileszHindsight.retain_filesK  s    0 	 	= 	=I	??Ddi):):;<<<<Y!Y!Y!Y!YSX!Y!Y!Yz#3T":;;$/55gY`l  @D  @M5  N  N  O  O  	OrW      mid      anyquerytypes
max_tokensbudgettracequery_timestampinclude_entitiesmax_entity_tokensinclude_chunksmax_chunk_tokensinclude_source_factsmax_source_facts_tokens
tags_match)r   all
any_strict
all_strict
tag_groupsc                 f    t          |                     |||||||||	|
||||||                    S )uS  
        Recall memories using semantic similarity (sync wrapper — prefer :meth:`arecall` in async code).

        Args:
            bank_id: The memory bank ID
            query: Search query
            types: Optional list of fact types to filter (world, experience, opinion, observation)
            max_tokens: Maximum tokens in results (default: 4096)
            budget: Budget level for recall - "low", "mid", or "high" (default: "mid")
            trace: Enable trace output (default: False)
            query_timestamp: Optional ISO format date string (e.g., '2023-05-30T23:40:00')
            include_entities: Include entity observations in results (default: False)
            max_entity_tokens: Maximum tokens for entity observations (default: 500)
            include_chunks: Include raw text chunks in results (default: False)
            max_chunk_tokens: Maximum tokens for chunks (default: 8192)
            include_source_facts: Include source facts for observation-type results (default: False)
            max_source_facts_tokens: Maximum tokens for source facts (default: 4096)
            tags: Optional list of tags to filter memories by
            tags_match: How to match tags - "any" (OR, includes untagged), "all" (AND, includes untagged),
                "any_strict" (OR, excludes untagged), "all_strict" (AND, excludes untagged). Default: "any"
            tag_groups: Optional list of tag group filters for advanced boolean tag matching.

        Returns:
            RecallResponse with results, optional entities, optional chunks, optional source_facts, and optional trace
        )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r(   arecall)rT   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                    r'   recallzHindsight.recalln  s]    X LL% /!1"3-!1%9(?%%!   
 
 	
rW   lowresponse_schemainclude_facts
fact_typesexclude_mental_modelsexclude_mental_model_idsc                 `    t          |                     |||||||||	|
|||                    S )u  
        Generate a contextual answer based on bank identity and memories (sync wrapper — prefer :meth:`areflect` in async code).

        Args:
            bank_id: The memory bank ID
            query: The question or prompt
            budget: Budget level for reflection - "low", "mid", or "high" (default: "low")
            context: Optional additional context
            max_tokens: Maximum tokens for the response (server default: 4096)
            response_schema: Optional JSON Schema for structured output. When provided,
                the response will include a 'structured_output' field with the LLM
                response parsed according to this schema.
            tags: Optional list of tags to filter memories by
            tags_match: How to match tags - "any" (OR, includes untagged), "all" (AND, includes untagged),
                "any_strict" (OR, excludes untagged), "all_strict" (AND, excludes untagged). Default: "any"
            include_facts: If True, the response will include a 'based_on' field listing
                the memories, mental models, and directives used to construct the answer.
            tag_groups: Optional list of tag group filters for advanced boolean tag matching.
            fact_types: Optional list of fact types to include (world, experience, observation).
            exclude_mental_models: If True, exclude all mental models from reflection (default: False).
            exclude_mental_model_ids: Optional list of specific mental model IDs to exclude.

        Returns:
            ReflectResponse with answer text, optionally facts used, and optionally
            structured_output if response_schema was provided
        )r   r   r   r   r   r   r   r   r   r   r   r   r   )r(   areflect)rT   r   r   r   r   r   r   r   r   r   r   r   r   r   s                 r'   reflectzHindsight.reflect  sT    T MM% /%+%%&;)A   
 
 	
rW   d   r   typesearch_querylimitoffsetc           
      f    t          | j                            |||||| j                            S )ur   List memory units with pagination (sync wrapper — use ``await client.memory.list_memories(...)`` in async code).)r   r   qr   r   r   )r(   rA   list_memoriesr;   )rT   r   r   r   r   r   s         r'   r   zHindsight.list_memories  sE     **!% +  	
 	
 		
rW   r   missiondisposition_skepticismdisposition_literalismdisposition_empathydispositionretain_missionretain_extraction_moderetain_custom_instructionsretain_chunk_sizeenable_observationsobservations_missionreflect_mission
backgroundc                 d    t          |                     ||||||||||	|
||||                    S )u  Create or update a memory bank (sync wrapper — prefer :meth:`acreate_bank` in async code).

        Args:
            bank_id: Unique identifier for the bank
            name: Deprecated. Display label only.
            mission: Deprecated. Use reflect_mission instead.
            disposition_skepticism: Deprecated. Use update_bank_config(disposition_skepticism=...) instead.
            disposition_literalism: Deprecated. Use update_bank_config(disposition_literalism=...) instead.
            disposition_empathy: Deprecated. Use update_bank_config(disposition_empathy=...) instead.
            disposition: Deprecated. Use update_bank_config(disposition_skepticism=...) instead.
            retain_mission: Steers what gets extracted during retain(). Injected alongside built-in rules.
            retain_extraction_mode: Fact extraction mode: 'concise' (default), 'verbose', or 'custom'.
            retain_custom_instructions: Custom extraction prompt (only active when mode is 'custom').
            retain_chunk_size: Maximum token size for each content chunk during retain.
            enable_observations: Toggle automatic observation consolidation after retain().
            observations_mission: Controls what gets synthesised into observations. Replaces built-in rules.
            reflect_mission: Mission/context for Reflect operations.
            background: Optional background context for the bank.
        r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r(   _acreate_bankrT   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                   r'   create_bankzHindsight.create_bank  s\    J  /'='=$7'-'=+E"3$7%9%   
 
 	
rW   c           	        K   dd l }i }|||d<   |||d<   |||d<   |||d<   |||d<   n||                    d          |d<   |||d<   n||                    d	          |d<   |||d
<   n||                    d          |d
<   |	|	|d<   |
|
|d<   |||d<   |||d<   |||d<   |||d<   | j         d| }| j        rdd| j         ini }|                                4 d {V }|                    ||||                    | j                            4 d {V 	 }|                                 |	                                 d {V }t          j        |          cd d d           d {V  cd d d           d {V  S # 1 d {V swxY w Y   	 d d d           d {V  d S # 1 d {V swxY w Y   d S )Nr   r   r   r   r   r   
skepticismr   
literalismr   empathyr   r   r   r   r   r   /v1/default/banks/r4   r5   totalr   headersr.   )aiohttpgetr=   r>   ClientSessionputClientTimeoutr;   raise_for_statusr   r   model_validate)rT   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   bodyurlr   sessionrespdatas                          r'   r   zHindsight._acreate_bank8  s     $ 	!DL%DO&&5D"#!!+D!--CD)**$-8__\-J-JD)*!--CD)**$-8__\-J-JD)***=D&''$*5//)*D*DD&'%%3D!"!--CD)*%11KD-.((9D$%**=D&'++?D'(<<7<<BF-W?$=dm$=$=>>UW((** 	@ 	@ 	@ 	@ 	@ 	@ 	@g{{$9N9NUYUb9N9c9c #   @ @ @ @ @ @ @ @%%'''!YY[[((((((*9$??@ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s7   09F6*AF,F6
F	F6F	F66
G G c                 0    |                      ||          S )@Deprecated. Use update_bank_config(reflect_mission=...) instead.r   )r   rT   r   r   s      r'   set_missionzHindsight.set_missiony  s    999rW   c                 .    |                      ||          S )z#Deprecated alias for set_mission().)r   rT   r   r   s      r'   set_reflect_missionzHindsight.set_reflect_mission}  s    999rW   c                 Z   K   |                      ||||||||||	|
||||           d{V S )u  Create or update a memory bank (async — preferred over :meth:`create_bank`).

        Args:
            bank_id: Unique identifier for the bank
            name: Deprecated. Display label only.
            mission: Deprecated. Use reflect_mission instead.
            disposition_skepticism: Deprecated. Use update_bank_config(disposition_skepticism=...) instead.
            disposition_literalism: Deprecated. Use update_bank_config(disposition_literalism=...) instead.
            disposition_empathy: Deprecated. Use update_bank_config(disposition_empathy=...) instead.
            disposition: Deprecated. Use update_bank_config(disposition_skepticism=...) instead.
            retain_mission: Steers what gets extracted during retain(). Injected alongside built-in rules.
            retain_extraction_mode: Fact extraction mode: 'concise' (default), 'verbose', or 'custom'.
            retain_custom_instructions: Custom extraction prompt (only active when mode is 'custom').
            retain_chunk_size: Maximum token size for each content chunk during retain.
            enable_observations: Toggle automatic observation consolidation after retain().
            observations_mission: Controls what gets synthesised into observations. Replaces built-in rules.
            reflect_mission: Mission/context for Reflect operations.
            background: Optional background context for the bank.
        r   N)r   r   s                   r'   acreate_bankzHindsight.acreate_bank  sq      J ''+#9#9 3#)#9'A/ 3!5! ( 
 
 
 
 
 
 
 
 	
rW   c                 @   K   |                      ||           d{V S )r   r   N)r   r   s      r'   aset_missionzHindsight.aset_mission  s1      &&w&@@@@@@@@@rW   c                 >   K   |                      ||           d{V S )z$Deprecated alias for aset_mission().N)r  r   s      r'   aset_reflect_missionzHindsight.aset_reflect_mission  s.      &&w@@@@@@@@@rW   c                   K   ddl m ddlm} ddlm} g }|D ]'}	d}
|	                    d          rfd|	d         D             }
|	                    d          }| ||	          nd}d}|	                    d
           ||	d
         	          }|                    t          j	        |	d         ||	                    d          |	                    d          |	                    d          p||
|	                    d          ||	                    d          |	                    d          
  
                   )t          j        |||          }| j                            ||| j                   d{V S )u(  
        Store multiple memories in batch (async — preferred over :meth:`retain_batch`).

        Args:
            bank_id: The memory bank ID
            items: List of memory items, each a dict with 'content' (required) and optional keys:
                'timestamp', 'context', 'metadata', 'document_id', 'entities', 'tags',
                'observation_scopes' (str or list[list[str]]), 'strategy'.
            document_id: Optional document ID for grouping memories (applied to items that don't have their own)
            document_tags: Optional list of tags applied to all items in this batch (merged with per-item tags)
            retain_async: If True, process asynchronously in background (default: False)

        Returns:
            RetainResponse with success status and item count
        r   )EntityInput)ObservationScopes)	TimestampNrb   c                 \    g | ](} |d          |                     d                    )S )textr   )r
  r   )r   )r   er  s     r'   r   z+Hindsight.aretain_batch.<locals>.<listcomp>  s7    fffPQKKQvYQUU6]]KKKfffrW   r   )actual_instanceobservation_scopesr   r   r   r   r   strategyr   )
r   r   r   r   r   rb   r   r  r  r   )r   	var_asyncr   r   )(hindsight_client_api.models.entity_inputr  .hindsight_client_api.models.observation_scopesr  %hindsight_client_api.models.timestampr  r   r   r   
MemoryItemr   RetainRequestrA   retain_memoriesr;   )rT   r   r   r   r   r   r  r  memory_itemsr   rb   raw_tstimestamp_val
obs_scopesrequest_objr  s                  @r'   r   zHindsight.aretain_batch  s     . 	IHHHHHTTTTTTCCCCCC 	 	DHxx
## gffffUYZdUefffXXk**FAGASIIf====Y]MJxx,--9..tDX?YZZZ
& O+ HHY//!XXj11 $ 7 7 F;%&))'1!XXj11 $ 7 7       %2"'
 
 
 %55g{]a]j5kkkkkkkkkrW   c                 f   K   ||||||d}|	|	|d<   |                      ||g||
           d{V S )u  
        Store a single memory (async — preferred over :meth:`retain`).

        Args:
            bank_id: The memory bank ID
            content: Memory content
            timestamp: Optional event timestamp
            context: Optional context description
            document_id: Optional document ID for grouping
            metadata: Optional user-defined metadata
            entities: Optional list of entities [{"text": "...", "type": "..."}]
            tags: Optional list of tags for filtering memories during recall/reflect
            update_mode: How to handle existing documents ('replace' or 'append')
            retain_async: If True, process asynchronously in background (default: False)

        Returns:
            RetainResponse with success status
        r   Nr   r   )r   r   s               r'   aretainzHindsight.aretain  s      @ "   
  
 ""-D''&#%	 ( 
 
 
 
 
 
 
 
 	
rW   c                   K   ddl m}m}m}m} |                    |r|                    |	          nd|
r|                    |          nd|r|                    |          nd          }d}|ddl	m
 fd|D             }t          j        ||||||||||
  
        }| j                            ||| j        	           d{V S )
u<  
        Recall memories using semantic similarity (async — preferred over :meth:`recall`).

        Args:
            bank_id: The memory bank ID
            query: Search query
            types: Optional list of fact types to filter (world, experience, opinion, observation)
            max_tokens: Maximum tokens in results (default: 4096)
            budget: Budget level for recall - "low", "mid", or "high" (default: "mid")
            trace: Enable trace output (default: False)
            query_timestamp: Optional ISO format date string (e.g., '2023-05-30T23:40:00')
            include_entities: Include entity observations in results (default: False)
            max_entity_tokens: Maximum tokens for entity observations (default: 500)
            include_chunks: Include raw text chunks in results (default: False)
            max_chunk_tokens: Maximum tokens for chunks (default: 8192)
            include_source_facts: Include source facts for observation-type results (default: False)
            max_source_facts_tokens: Maximum tokens for source facts (default: 4096)
            tags: Optional list of tags to filter memories by
            tags_match: How to match tags - "any" (OR, includes untagged), "all" (AND, includes untagged),
                "any_strict" (OR, excludes untagged), "all_strict" (AND, excludes untagged). Default: "any"
            tag_groups: Optional list of tag group filters for advanced boolean tag matching.
                Each element is a dict representing a tag group node (TagGroupLeaf, TagGroupAnd,
                TagGroupOr, or TagGroupNot). Example::

                    [{"tags": ["customer"], "match": "all"}, {"not": {"tags": ["internal"]}}]

        Returns:
            RecallResponse with results, optional entities, optional chunks, optional source_facts, and optional trace
        r   )chunk_include_optionsentity_include_optionsinclude_optionssource_facts_include_options)r   N)rb   chunkssource_factsRecallRequestTagGroupsInnerc                 :    g | ]}                     |          S rr   	from_dictr   tgr&  s     r'   r   z%Hindsight.arecall.<locals>.<listcomp>t  (    ^^^R:DDRHH^^^rW   )
r   r   r   r   r   r   includer   r   r   r  )hindsight_client_api.modelsr  r   r!  r"  IncludeOptionsEntityIncludeOptionsChunkIncludeOptionsSourceFactsIncludeOptions;hindsight_client_api.models.recall_request_tag_groups_innerr&  r   RecallRequestrA   recall_memoriesr;   )rT   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r!  r"  include_optstag_groups_objsr  r&  s                           @r'   r   zHindsight.arecall/  sk     `	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 '55+@@L]@^^^]ku(<<HX<YYYqu#5OO[rOsss 6 
 
 !oooooo^^^^S]^^^O$2!+ !&
 
 
 %55g{]a]j5kkkkkkkkkrW   c                    K   |	rt          i           nd}d}|
ddlm fd|
D             }t          j        |||||||||||pd|          }| j                            ||| j                   d{V S )u  
        Generate a contextual answer based on bank identity and memories (async — preferred over :meth:`reflect`).

        Args:
            bank_id: The memory bank ID
            query: The question or prompt
            budget: Budget level for reflection - "low", "mid", or "high" (default: "low")
            context: Optional additional context
            max_tokens: Maximum tokens for the response (server default: 4096)
            response_schema: Optional JSON Schema for structured output. When provided,
                the response will include a 'structured_output' field with the LLM
                response parsed according to this schema.
            tags: Optional list of tags to filter memories by
            tags_match: How to match tags - "any" (OR, includes untagged), "all" (AND, includes untagged),
                "any_strict" (OR, excludes untagged), "all_strict" (AND, excludes untagged). Default: "any"
            include_facts: If True, the response will include a 'based_on' field listing
                the memories, mental models, and directives used to construct the answer.
            tag_groups: Optional list of tag group filters for advanced boolean tag matching.
            fact_types: Optional list of fact types to include (world, experience, observation).
            exclude_mental_models: If True, exclude all mental models from reflection (default: False).
            exclude_mental_model_ids: Optional list of specific mental model IDs to exclude.

        Returns:
            ReflectResponse with answer text, optionally facts used, and optionally
            structured_output if response_schema was provided
        )factsNr   r%  c                 :    g | ]}                     |          S rr   r(  r*  s     r'   r   z&Hindsight.areflect.<locals>.<listcomp>  r,  rW   )r   r   r   r   r   r   r   r-  r   r   r   r   r  )r   r3  r&  r   ReflectRequestrA   r   r;   )rT   r   r   r   r   r   r   r   r   r   r   r   r   r   r-  r7  r  r&  s                    @r'   r   zHindsight.areflect  s      T 6CL'b1111!oooooo^^^^S]^^^O%4!+!&!"7"?4%=
 
 
 %--g{UYUb-cccccccccrW   source_querytriggeridc                     ddl m}m}	 d}
|r |	j        di |}
|                    ||||||
          }t          | j                            ||| j                            S )u  
        Create a mental model (sync wrapper — use ``await client.mental_models.create_mental_model(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            name: Human-readable name for the mental model
            source_query: The query to run to generate content
            tags: Optional tags for filtering during retrieval
            max_tokens: Optional maximum tokens for the mental model content
            trigger: Optional trigger settings (e.g., {"refresh_after_consolidation": True})
            id: Optional custom ID for the mental model (alphanumeric lowercase with hyphens)

        Returns:
            CreateMentalModelResponse with operation_id
        r   )create_mental_model_requestmental_model_trigger_inputN)r>  r   r<  r   r   r=  r  rr   )	r.  r@  rA  MentalModelTriggerInputCreateMentalModelRequestr(   rE   create_mental_modelr;   )rT   r   r   r<  r   r   r=  r>  r@  rA  trigger_objr  s               r'   rD  zHindsight.create_mental_model  s    2 	hggggggg 	XL4LWWwWWK1JJ%! K 
 
 $1EEg{mqmzE{{|||rW   c                 `    t          | j                            ||| j                            S )u5  
        List all mental models in a bank (sync wrapper — use ``await client.mental_models.list_mental_models(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            tags: Optional tags to filter by

        Returns:
            ListMentalModelsResponse with items
        r   r   )r(   rE   list_mental_modelsr;   rT   r   r   s      r'   rH  zHindsight.list_mental_models  s/     $1DDWSWjnjwDxxyyyrW   mental_model_idc                 `    t          | j                            ||| j                            S )u"  
        Get a specific mental model (sync wrapper — use ``await client.mental_models.get_mental_model(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            mental_model_id: The mental model ID

        Returns:
            MentalModelResponse
        r  )r(   rE   get_mental_modelr;   rT   r   rJ  s      r'   rL  zHindsight.get_mental_model  s.     $1BB7Onrn{B||}}}rW   c                 `    t          | j                            ||| j                            S )u:  
        Refresh a mental model (sync wrapper — use ``await client.mental_models.refresh_mental_model(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            mental_model_id: The mental model ID

        Returns:
            RefreshMentalModelResponse with operation_id
        r  )r(   rE   refresh_mental_modelr;   rM  s      r'   rO  zHindsight.refresh_mental_model  s>     $1FFwP_rvrF  A  A  B  B  	BrW   c                     ddl m}m}	 d}
|r |j        di |}
|	                    |||||
          }t          | j                            |||| j                            S )u3  
        Update a mental model's metadata (sync wrapper — use ``await client.mental_models.update_mental_model(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            mental_model_id: The mental model ID
            name: Optional new name
            source_query: Optional new source query
            tags: Optional new tags
            max_tokens: Optional new max tokens
            trigger: Optional trigger settings (e.g., {"refresh_after_consolidation": True})

        Returns:
            MentalModelResponse
        r   )rA  update_mental_model_requestN)r   r<  r   r   r=  r  rr   )	r.  rA  rQ  rB  UpdateMentalModelRequestr(   rE   update_mental_modelr;   )rT   r   rJ  r   r<  r   r   r=  rA  rQ  rE  r  s               r'   rS  zHindsight.update_mental_model  s    2 	hggggggg 	XL4LWWwWWK1JJ%! K 
 
 $1EEg`k  C  LE  M  M  N  N  	NrW   c                 `    t          | j                            ||| j                            S )u   
        Delete a mental model (sync wrapper — use ``await client.mental_models.delete_mental_model(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            mental_model_id: The mental model ID
        r  )r(   rE   delete_mental_modelr;   rM  s      r'   rU  zHindsight.delete_mental_modelD  s7     $1EEgquq~E  A  A  	ArW   c                 `    t          | j                            ||| j                            S )u  
        Get the content change history of a mental model (sync wrapper — use ``await client.mental_models.get_mental_model_history(...)`` in async code).

        Returns a list of history entries (most recent first), each with
        ``previous_content`` and ``changed_at`` fields.

        Args:
            bank_id: The memory bank ID
            mental_model_id: The mental model ID
        r  )r(   rE   get_mental_model_historyr;   rM  s      r'   rW  z"Hindsight.get_mental_model_historyN  sB     $1JJ7Tcvz  wDJ  E  E  F  F  	FrW   Tpriority	is_activec                     ddl m} |                    |||||          }t          | j                            ||| j                            S )u  
        Create a directive (sync wrapper — use ``await client.directives.create_directive(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            name: Human-readable name for the directive
            content: The directive content/rules
            priority: Priority level (higher = injected first)
            is_active: Whether the directive is active
            tags: Optional tags for filtering

        Returns:
            DirectiveResponse
        r   )create_directive_requestr   r   rX  rY  r   r  )r.  r[  CreateDirectiveRequestr(   rG   create_directiver;   )	rT   r   r   r   rX  rY  r   r[  r  s	            r'   r^  zHindsight.create_directive]  sm    . 	IHHHHH.EE F 
 
 $.??gkgt?uuvvvrW   c                 `    t          | j                            ||| j                            S )u*  
        List all directives in a bank (sync wrapper — use ``await client.directives.list_directives(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            tags: Optional tags to filter by

        Returns:
            ListDirectivesResponse with items
        rG  )r(   rG   list_directivesr;   rI  s      r'   r`  zHindsight.list_directives  s.     $.>>wTdhdq>rrsssrW   directive_idc                 `    t          | j                            ||| j                            S )u  
        Get a specific directive (sync wrapper — use ``await client.directives.get_directive(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            directive_id: The directive ID

        Returns:
            DirectiveResponse
        r  )r(   rG   get_directiver;   rT   r   ra  s      r'   rc  zHindsight.get_directive  s.     $.<<Wleier<sstttrW   c                     ddl m} |                    |||||          }	t          | j                            |||	| j                            S )u  
        Update a directive (sync wrapper — use ``await client.directives.update_directive(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            directive_id: The directive ID
            name: Optional new name
            content: Optional new content
            priority: Optional new priority
            is_active: Optional new active status
            tags: Optional new tags

        Returns:
            DirectiveResponse
        r   )update_directive_requestr\  r  )r.  rf  UpdateDirectiveRequestr(   rG   update_directiver;   )
rT   r   ra  r   r   rX  rY  r   rf  r  s
             r'   rh  zHindsight.update_directive  s    2 	IHHHHH.EE F 
 
 $.??Wbuy  vC?  D  D  E  E  	ErW   c                 `    t          | j                            ||| j                            S )u   
        Delete a directive (sync wrapper — use ``await client.directives.delete_directive(...)`` in async code).

        Args:
            bank_id: The memory bank ID
            directive_id: The directive ID
        r  )r(   rG   delete_directiver;   rd  s      r'   rj  zHindsight.delete_directive  s.     $.??hlhu?vvwwwrW   c                 F    t          |                     |                    S )u  
        Get the resolved configuration for a bank (sync wrapper — use ``await client.banks.get_bank_config(...)`` in async code).

        Can be disabled on the server by setting ``HINDSIGHT_API_ENABLE_BANK_CONFIG_API=false``.

        Args:
            bank_id: The memory bank ID

        Returns:
            dict with ``bank_id``, ``config`` (fully resolved), and ``overrides`` (bank-level only)
        )r(   _aget_bank_configrT   r   s     r'   get_bank_configzHindsight.get_bank_config  s      $0099:::rW   c                   K   dd l }| j         d| d}| j        rdd| j         ini }|                                4 d {V }|                    |||                    | j                            4 d {V }|                                 |                                 d {V cd d d           d {V  cd d d           d {V  S # 1 d {V swxY w Y   	 d d d           d {V  d S # 1 d {V swxY w Y   d S Nr   r   /configr4   r5   r   )r   r.   )	r   r=   r>   r   r   r   r;   r   r   rT   r   r   r   r   r   r   s          r'   rl  zHindsight._aget_bank_config  sj     CC7CCCBF-W?$=dm$=$=>>UW((** 	) 	) 	) 	) 	) 	) 	)g{{3AVAV]a]jAVAkAk{ll ) ) ) ) ) ) )pt%%'''!YY[[(((((() ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)) ) ) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)6   8C3;.C)C3
C	C3C	C33
C= C=)r   reflect_source_facts_max_tokensr   r   r   r   retain_default_strategyretain_strategiesentity_labelsentities_allow_free_formr   r   consolidation_llm_batch_size%consolidation_source_facts_max_tokens5consolidation_source_facts_max_tokens_per_observationr   r   r   mcp_enabled_toolsllm_gemini_safety_settingsrt  ru  rv  rw  rx  ry  rz  r{  r|  r}  c                    d i d|d|d|d|d|d|d|d	|	d
|
d|d|d|d|d|d|d|d||||d                                 D             }t          |                     ||                    S )u	  
        Update configuration overrides for a bank (sync wrapper — use ``await client.banks.update_bank_config(...)`` in async code).

        Can be disabled on the server by setting ``HINDSIGHT_API_ENABLE_BANK_CONFIG_API=false``.

        Args:
            bank_id: The memory bank ID
            reflect_mission: Identity and reasoning framing for reflect().
            reflect_source_facts_max_tokens: Token budget for source facts in observation search
                during reflect. -1 to disable (default: -1).
            retain_mission: Steers what gets extracted during retain().
            retain_extraction_mode: Fact extraction mode: 'concise', 'verbose', or 'custom'.
            retain_custom_instructions: Custom extraction prompt (only active when mode is 'custom').
            retain_chunk_size: Maximum token size for each content chunk during retain.
            retain_default_strategy: Default retain strategy name.
            retain_strategies: Named strategy definitions (dict of strategy name to config).
            entity_labels: Controlled vocabulary for entity type classification.
                When set, extracted entities are classified into these labels.
            entities_allow_free_form: Whether to allow entity types outside entity_labels (default: True).
            enable_observations: Toggle automatic observation consolidation after retain().
            observations_mission: Controls what gets synthesised into observations.
            consolidation_llm_batch_size: Number of LLM calls to batch during consolidation.
            consolidation_source_facts_max_tokens: Max tokens for source facts across all observations
                in a consolidation pass.
            consolidation_source_facts_max_tokens_per_observation: Max tokens of source facts per
                individual observation in the consolidation prompt.
            disposition_skepticism: How skeptical vs trusting (1=trusting, 5=skeptical).
            disposition_literalism: How literally to interpret information (1=flexible, 5=literal).
            disposition_empathy: How much to consider emotional context (1=detached, 5=empathetic).
            mcp_enabled_tools: List of MCP tool names to enable for this bank.
            llm_gemini_safety_settings: Gemini/VertexAI safety setting overrides (category → threshold).

        Returns:
            dict with ``bank_id``, ``config`` (fully resolved), and ``overrides`` (bank-level only)
        c                     i | ]
\  }}|||S Nrr   )r   kvs      r'   
<dictcomp>z0Hindsight.update_bank_config.<locals>.<dictcomp>$  s/     
 
 
1, }/ q. }}rW   r   rt  r   r   r   r   ru  rv  rw  rx  r   r   ry  rz  r{  r   r   )r   r|  r}  )r   r(   _aupdate_bank_config)rT   r   r   rt  r   r   r   r   ru  rv  rw  rx  r   r   ry  rz  r{  r   r   r   r|  r}  updatess                          r'   update_bank_configzHindsight.update_bank_config  s?   F
 
!?13R !. )*@	
 -.H $%6 *+B $%6   +,D &': '(< /0L 89^ HI~  )*@!" )*@#$ (;%6.H)  * egg/
 
 
4 $33GWEEFFFrW   r  c           	        K   dd l }| j         d| d}| j        rdd| j         ini }|                                4 d {V }|                    |d|i||                    | j                            4 d {V 	 }|                                 |                                 d {V cd d d           d {V  cd d d           d {V  S # 1 d {V swxY w Y   	 d d d           d {V  d S # 1 d {V swxY w Y   d S )	Nr   r   rq  r4   r5   r  r   r   )	r   r=   r>   r   patchr   r;   r   r   )rT   r   r  r   r   r   r   r   s           r'   r  zHindsight._aupdate_bank_config@  s~     CC7CCCBF-W?$=dm$=$=>>UW((** 	) 	) 	) 	) 	) 	) 	)g}}9g.I^I^eierI^IsIs %   ) ) ) ) ) ) ) )%%'''!YY[[((((((	) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)) ) ) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s6   ;C7?.C-C7
C	C7C	 C77
DDc                 F    t          |                     |                    S )u  
        Reset all bank-level config overrides (sync wrapper — use ``await client.banks.reset_bank_config(...)`` in async code).

        Can be disabled on the server by setting ``HINDSIGHT_API_ENABLE_BANK_CONFIG_API=false``.

        Args:
            bank_id: The memory bank ID

        Returns:
            dict with ``bank_id``, ``config`` (fully resolved), and ``overrides`` (now empty)
        )r(   _areset_bank_configrm  s     r'   reset_bank_configzHindsight.reset_bank_configL  s      $227;;<<<rW   c                   K   dd l }| j         d| d}| j        rdd| j         ini }|                                4 d {V }|                    |||                    | j                            4 d {V }|                                 |                                 d {V cd d d           d {V  cd d d           d {V  S # 1 d {V swxY w Y   	 d d d           d {V  d S # 1 d {V swxY w Y   d S rp  )	r   r=   r>   r   deleter   r;   r   r   rr  s          r'   r  zHindsight._areset_bank_configZ  sj     CC7CCCBF-W?$=dm$=$=>>UW((** 	) 	) 	) 	) 	) 	) 	)g~~c7GDYDY`d`mDYDnDn~oo ) ) ) ) ) ) )sw%%'''!YY[[(((((() ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)) ) ) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)rs  c                 ^    t          | j                            || j                            S )u   
        Delete a memory bank (sync wrapper — prefer :meth:`adelete_bank` in async code).

        Args:
            bank_id: The memory bank ID
        r  )r(   rC   delete_bankr;   rm  s     r'   r  zHindsight.delete_bankd  s+     $/55gPTP]5^^___rW   c                 T   K   | j                             || j                   d{V S )u   
        Delete a memory bank (async — preferred over :meth:`delete_bank`).

        Args:
            bank_id: The memory bank ID
        r  N)rC   r  r;   rm  s     r'   adelete_bankzHindsight.adelete_bankm  s7       _004=0YYYYYYYYYrW   )Nr+   N)NNNNNNNF)NNF)NN)Nr   r   FNFr   Fr   Fr   Nr   N)r   NNNNr   FNNFN)NNr   r   )NNNNNNNNNNNNNN)NNNNr  )NNNNN)r   TN)]__name__
__module____qualname____doc__strfloatrV   propertyr   r@   r[   r   rB   r]   r
   rJ   r`   r   rL   rb   r   rD   re   r	   rF   rg   r   rN   rj   r   rP   rl   r   rH   rn   r   rR   rp   rs   ry   ru   r~   r   dictlistboolr   r   r   r   r   r   r   intr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r  r   r   rD  rH  rL  rO  rS  rU  rW  r^  r`  rc  rh  rj  rn  rl  r  r  r  r  r  r  rr   rW   r'   r*   r*   >   s       A AL #!%$N $N$N t$N 	$N
 $J$N $N $N $NV  
,       X  y)    X #=5 # # # X# ",2 " " " X" '0@ ' ' ' X' $N8 $ $ $ X$ $N8 $ $ $ X$ ",2 " " " X" y)    X $N8 $ $ $ X$    
5 
5 
5+ + + &*""&*.04!%"&".
 .
.
 .
 d?	.

 t.
 4Z.
 sCx.4'.
 tCH~&-.
 3i$.
 4Z.
 .
 
.
 .
 .
 .
h #'*."
 

 DcN#
 4Z	

 Cy4'
 
 

 
 
 
J #6:!O !O!O C$J!O t	!O
 T#s(^,t3!O 
!O !O !O !ON #'&*!&!$$ $%*'+!%HM26#?
 ?
?
 ?
 Cy4	?

 ?
 ?
 ?
 t?
 ?
 ?
 ?
 ?
 #?
 "%?
 3i$?
  DE!?
" c3h(4/#?
$ 
%?
 ?
 ?
 ?
J "!%15!%HM#26'+&+59:
 :
:
 :
 	:

 t:
 $J:
 c3h$.:
 3i$:
 DE:
 :
 c3h(4/:
 I$:
  $:
 #'s)d"2:
 
:
 :
 :
 :
~  #'
 

 Dj
 Dj	

 
 
 
!
 
 
 
.  "-1-1*./3%)-115(,+/+/&*!%!7
 7
7
 Dj7
 t	7

 !$d
7
 !$d
7
 !4Z7
 #u*%,7
 d
7
 !$d
7
 %($J7
 :7
 "D[7
 "Dj7
 t7
  $J!7
" 
#7
 7
 7
 7
x  "&*-1-1*./3%)-115(,+/+/!%!?@ ?@?@ Dj?@ t	?@
 t?@ !$d
?@ !$d
?@ !4Z?@ #u*%,?@ d
?@ !$d
?@ %($J?@ :?@ "D[?@ "Dj?@  $J!?@" 
#?@ ?@ ?@ ?@B:3 : :c3h : : : ::3 : :cSVh : : : :  "-1-1*./3%)-115(,+/+/&*!%!5
 5
5
 Dj5
 t	5

 !$d
5
 !$d
5
 !4Z5
 #u*%,5
 d
5
 !$d
5
 %($J5
 :5
 "D[5
 "Dj5
 t5
  $J!5
" 
#5
 5
 5
 5
nA# A AS#X A A A AA# A APTUXZ]U]P^ A A A A #'*.";l ;l;l DcN#;l 4Z	;l
 Cy4';l ;l 
;l ;l ;l ;lB &*""&*.04!%"&".
 .
.
 .
 d?	.

 t.
 4Z.
 sCx.4'.
 tCH~&-.
 3i$.
 4Z.
 .
 
.
 .
 .
 .
h #'&*!&!$$ $%*'+!%HM26#Tl TlTl Tl Cy4	Tl
 Tl Tl Tl tTl Tl Tl Tl Tl #Tl "%Tl 3i$Tl  DE!Tl" c3h(4/#Tl$ 
%Tl Tl Tl Tlt "!%15!%HM#26'+&+59Ad AdAd Ad 	Ad
 tAd $JAd c3h$.Ad 3i$Ad DEAd Ad c3h(4/Ad I$Ad  $Ad #'s)d"2Ad 
Ad Ad Ad AdT "&!%)-(} (}(} (} 	(}
 3i$(} $J(} c3h$&(} $J(} (} (} (}Tz z# zT#Y5E z z z z~ ~c ~ ~ ~ ~BC B# B B B B"  #'!%!%)-'N 'N'N 'N Dj	'N
 Dj'N 3i$'N $J'N c3h$&'N 'N 'N 'NRA3 A A A A AF Fc F F F F( !%!w !w!w !w 	!w
 !w !w 3i$!w !w !w !wFt ts t$s)d2B t t t tuS u u u u u"  "#!%!%#E #E#E #E Dj	#E
 t#E *#E $;#E 3i$#E #E #E #EJx x3 x x x x;s ;tCH~ ; ; ; ;)s )tCH~ ) ) ) ) '+6:%)-115(,.237*.04+/+/37<@LP-1-1*..2<@=]G ]G ]G]G
 t]G *-t]G d
]G !$d
]G %($J]G :]G "%t]G  S>D0]G Cy4']G  #'+!]G$ "D[%]G& "Dj']G( '*Dj)]G* 03Tz+]G, @CTz-]G0 !$d
1]G2 !$d
3]G4 !4Z5]G8  9t+9]G< %)cNT$9=]G> 
c3h?]G ]G ]G ]G~
)# 
)S#X 
)SWX[]`X`Sa 
) 
) 
) 
)= =c3h = = = =) )c3h ) ) ) )`3 ` ` ` `Z# Z Z Z Z Z ZrW   r*   )2r  r   r   r   	importlibr   pathlibr   typingr   r   r6   version_CLIENT_VERSIONPackageNotFoundErrorr:   hindsight_client_api.apir   r	   r
   r   r   r   r   r   r   r   r.  r   r   r   r   3hindsight_client_api.models.reflect_include_optionsr   1hindsight_client_api.models.bank_profile_responser   0hindsight_client_api.models.file_retain_responser   6hindsight_client_api.models.list_memory_units_responser   +hindsight_client_api.models.recall_responser   )hindsight_client_api.models.recall_resultr   ,hindsight_client_api.models.reflect_responser   +hindsight_client_api.models.retain_responser   r(   r*   rr   rW   r'   <module>r     sk                                   &h&'9::OO$   OOO BAA                                    V U U U U U Q Q Q Q Q Q O O O O O O Z Z Z Z Z Z F F F F F F B B B B B B H H H H H H F F F F F F) ) )vZ vZ vZ vZ vZ vZ vZ vZ vZ vZs   ; A
	A
