hindsight-api 0.3.0__py3-none-any.whl → 0.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. hindsight_api/__init__.py +1 -1
  2. hindsight_api/admin/cli.py +59 -0
  3. hindsight_api/alembic/versions/h3c4d5e6f7g8_mental_models_v4.py +112 -0
  4. hindsight_api/alembic/versions/i4d5e6f7g8h9_delete_opinions.py +41 -0
  5. hindsight_api/alembic/versions/j5e6f7g8h9i0_mental_model_versions.py +95 -0
  6. hindsight_api/alembic/versions/k6f7g8h9i0j1_add_directive_subtype.py +58 -0
  7. hindsight_api/alembic/versions/l7g8h9i0j1k2_add_worker_columns.py +109 -0
  8. hindsight_api/alembic/versions/m8h9i0j1k2l3_mental_model_id_to_text.py +41 -0
  9. hindsight_api/alembic/versions/n9i0j1k2l3m4_learnings_and_pinned_reflections.py +134 -0
  10. hindsight_api/alembic/versions/o0j1k2l3m4n5_migrate_mental_models_data.py +113 -0
  11. hindsight_api/alembic/versions/p1k2l3m4n5o6_new_knowledge_architecture.py +194 -0
  12. hindsight_api/alembic/versions/q2l3m4n5o6p7_fix_mental_model_fact_type.py +50 -0
  13. hindsight_api/alembic/versions/r3m4n5o6p7q8_add_reflect_response_to_reflections.py +47 -0
  14. hindsight_api/alembic/versions/s4n5o6p7q8r9_add_consolidated_at_to_memory_units.py +53 -0
  15. hindsight_api/alembic/versions/t5o6p7q8r9s0_rename_mental_models_to_observations.py +134 -0
  16. hindsight_api/alembic/versions/u6p7q8r9s0t1_mental_models_text_id.py +41 -0
  17. hindsight_api/alembic/versions/v7q8r9s0t1u2_add_max_tokens_to_mental_models.py +50 -0
  18. hindsight_api/api/http.py +1120 -93
  19. hindsight_api/api/mcp.py +11 -191
  20. hindsight_api/config.py +174 -46
  21. hindsight_api/engine/consolidation/__init__.py +5 -0
  22. hindsight_api/engine/consolidation/consolidator.py +926 -0
  23. hindsight_api/engine/consolidation/prompts.py +77 -0
  24. hindsight_api/engine/cross_encoder.py +153 -22
  25. hindsight_api/engine/directives/__init__.py +5 -0
  26. hindsight_api/engine/directives/models.py +37 -0
  27. hindsight_api/engine/embeddings.py +136 -13
  28. hindsight_api/engine/interface.py +32 -13
  29. hindsight_api/engine/llm_wrapper.py +505 -43
  30. hindsight_api/engine/memory_engine.py +2101 -1094
  31. hindsight_api/engine/mental_models/__init__.py +14 -0
  32. hindsight_api/engine/mental_models/models.py +53 -0
  33. hindsight_api/engine/reflect/__init__.py +18 -0
  34. hindsight_api/engine/reflect/agent.py +933 -0
  35. hindsight_api/engine/reflect/models.py +109 -0
  36. hindsight_api/engine/reflect/observations.py +186 -0
  37. hindsight_api/engine/reflect/prompts.py +483 -0
  38. hindsight_api/engine/reflect/tools.py +437 -0
  39. hindsight_api/engine/reflect/tools_schema.py +250 -0
  40. hindsight_api/engine/response_models.py +130 -4
  41. hindsight_api/engine/retain/bank_utils.py +79 -201
  42. hindsight_api/engine/retain/fact_extraction.py +81 -48
  43. hindsight_api/engine/retain/fact_storage.py +5 -8
  44. hindsight_api/engine/retain/link_utils.py +5 -8
  45. hindsight_api/engine/retain/orchestrator.py +1 -55
  46. hindsight_api/engine/retain/types.py +2 -2
  47. hindsight_api/engine/search/graph_retrieval.py +2 -2
  48. hindsight_api/engine/search/link_expansion_retrieval.py +164 -29
  49. hindsight_api/engine/search/mpfp_retrieval.py +1 -1
  50. hindsight_api/engine/search/retrieval.py +14 -14
  51. hindsight_api/engine/search/think_utils.py +41 -140
  52. hindsight_api/engine/search/trace.py +0 -1
  53. hindsight_api/engine/search/tracer.py +2 -5
  54. hindsight_api/engine/search/types.py +0 -3
  55. hindsight_api/engine/task_backend.py +112 -196
  56. hindsight_api/engine/utils.py +0 -151
  57. hindsight_api/extensions/__init__.py +10 -1
  58. hindsight_api/extensions/builtin/tenant.py +11 -4
  59. hindsight_api/extensions/operation_validator.py +81 -4
  60. hindsight_api/extensions/tenant.py +26 -0
  61. hindsight_api/main.py +28 -5
  62. hindsight_api/mcp_local.py +12 -53
  63. hindsight_api/mcp_tools.py +494 -0
  64. hindsight_api/models.py +0 -2
  65. hindsight_api/worker/__init__.py +11 -0
  66. hindsight_api/worker/main.py +296 -0
  67. hindsight_api/worker/poller.py +486 -0
  68. {hindsight_api-0.3.0.dist-info → hindsight_api-0.4.1.dist-info}/METADATA +12 -6
  69. hindsight_api-0.4.1.dist-info/RECORD +112 -0
  70. {hindsight_api-0.3.0.dist-info → hindsight_api-0.4.1.dist-info}/entry_points.txt +1 -0
  71. hindsight_api/engine/retain/observation_regeneration.py +0 -254
  72. hindsight_api/engine/search/observation_utils.py +0 -125
  73. hindsight_api/engine/search/scoring.py +0 -159
  74. hindsight_api-0.3.0.dist-info/RECORD +0 -82
  75. {hindsight_api-0.3.0.dist-info → hindsight_api-0.4.1.dist-info}/WHEEL +0 -0
@@ -160,14 +160,14 @@ class MemoryEngineInterface(ABC):
160
160
  request_context: "RequestContext",
161
161
  ) -> dict[str, Any]:
162
162
  """
163
- Get bank profile including disposition and background.
163
+ Get bank profile including disposition and mission.
164
164
 
165
165
  Args:
166
166
  bank_id: The memory bank ID.
167
167
  request_context: Request context for authentication.
168
168
 
169
169
  Returns:
170
- Bank profile dict.
170
+ Bank profile dict with bank_id, name, disposition, and mission.
171
171
  """
172
172
  ...
173
173
 
@@ -190,25 +190,44 @@ class MemoryEngineInterface(ABC):
190
190
  ...
191
191
 
192
192
  @abstractmethod
193
- async def merge_bank_background(
193
+ async def merge_bank_mission(
194
194
  self,
195
195
  bank_id: str,
196
196
  new_info: str,
197
197
  *,
198
- update_disposition: bool = True,
199
198
  request_context: "RequestContext",
200
199
  ) -> dict[str, Any]:
201
200
  """
202
- Merge new background information into bank profile.
201
+ Merge new mission information into bank profile.
203
202
 
204
203
  Args:
205
204
  bank_id: The memory bank ID.
206
- new_info: New background information to merge.
207
- update_disposition: Whether to infer disposition from background.
205
+ new_info: New mission information to merge.
208
206
  request_context: Request context for authentication.
209
207
 
210
208
  Returns:
211
- Updated background info.
209
+ Updated mission info.
210
+ """
211
+ ...
212
+
213
+ @abstractmethod
214
+ async def set_bank_mission(
215
+ self,
216
+ bank_id: str,
217
+ mission: str,
218
+ *,
219
+ request_context: "RequestContext",
220
+ ) -> dict[str, Any]:
221
+ """
222
+ Set the bank's mission (replaces existing).
223
+
224
+ Args:
225
+ bank_id: The memory bank ID.
226
+ mission: The mission text.
227
+ request_context: Request context for authentication.
228
+
229
+ Returns:
230
+ Dict with bank_id and mission.
212
231
  """
213
232
  ...
214
233
 
@@ -518,7 +537,7 @@ class MemoryEngineInterface(ABC):
518
537
  bank_id: str,
519
538
  *,
520
539
  request_context: "RequestContext",
521
- ) -> list[dict[str, Any]]:
540
+ ) -> dict[str, Any]:
522
541
  """
523
542
  List async operations for a bank.
524
543
 
@@ -527,7 +546,7 @@ class MemoryEngineInterface(ABC):
527
546
  request_context: Request context for authentication.
528
547
 
529
548
  Returns:
530
- List of operation dicts with id, task_type, status, etc.
549
+ Dict with 'total' (int) and 'operations' (list of operation dicts).
531
550
  """
532
551
  ...
533
552
 
@@ -561,16 +580,16 @@ class MemoryEngineInterface(ABC):
561
580
  bank_id: str,
562
581
  *,
563
582
  name: str | None = None,
564
- background: str | None = None,
583
+ mission: str | None = None,
565
584
  request_context: "RequestContext",
566
585
  ) -> dict[str, Any]:
567
586
  """
568
- Update bank name and/or background.
587
+ Update bank name and/or mission.
569
588
 
570
589
  Args:
571
590
  bank_id: The memory bank ID.
572
591
  name: New bank name (optional).
573
- background: New background text (optional, replaces existing).
592
+ mission: New mission text (optional, replaces existing).
574
593
  request_context: Request context for authentication.
575
594
 
576
595
  Returns: