persona-core 0.1.0__tar.gz

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 (326) hide show
  1. persona_core-0.1.0/.gitignore +68 -0
  2. persona_core-0.1.0/CHANGELOG.md +48 -0
  3. persona_core-0.1.0/LICENSE +77 -0
  4. persona_core-0.1.0/PKG-INFO +197 -0
  5. persona_core-0.1.0/README.md +139 -0
  6. persona_core-0.1.0/SPEC.md +245 -0
  7. persona_core-0.1.0/examples/astrid_tenancy_law.yaml +71 -0
  8. persona_core-0.1.0/examples/kai_research.yaml +78 -0
  9. persona_core-0.1.0/examples/maren_writing_coach.yaml +69 -0
  10. persona_core-0.1.0/pyproject.toml +140 -0
  11. persona_core-0.1.0/research/README.md +56 -0
  12. persona_core-0.1.0/research/RESEARCH_VERSION +4 -0
  13. persona_core-0.1.0/research/report.pdf +0 -0
  14. persona_core-0.1.0/scripts/sync-research.sh +68 -0
  15. persona_core-0.1.0/src/persona/__init__.py +1 -0
  16. persona_core-0.1.0/src/persona/audit.py +268 -0
  17. persona_core-0.1.0/src/persona/auth/__init__.py +34 -0
  18. persona_core-0.1.0/src/persona/auth/jwt_verifier.py +156 -0
  19. persona_core-0.1.0/src/persona/autonomy.py +365 -0
  20. persona_core-0.1.0/src/persona/backends/__init__.py +80 -0
  21. persona_core-0.1.0/src/persona/backends/_factory.py +72 -0
  22. persona_core-0.1.0/src/persona/backends/_tool_shim.py +299 -0
  23. persona_core-0.1.0/src/persona/backends/config.py +132 -0
  24. persona_core-0.1.0/src/persona/backends/credentials.py +454 -0
  25. persona_core-0.1.0/src/persona/backends/errors.py +351 -0
  26. persona_core-0.1.0/src/persona/backends/hf_local.py +459 -0
  27. persona_core-0.1.0/src/persona/backends/multi_model.py +544 -0
  28. persona_core-0.1.0/src/persona/backends/ollama.py +482 -0
  29. persona_core-0.1.0/src/persona/backends/openai_compat.py +1296 -0
  30. persona_core-0.1.0/src/persona/backends/openrouter_catalog.py +428 -0
  31. persona_core-0.1.0/src/persona/backends/protocol.py +146 -0
  32. persona_core-0.1.0/src/persona/backends/types.py +258 -0
  33. persona_core-0.1.0/src/persona/cli/__init__.py +7 -0
  34. persona_core-0.1.0/src/persona/cli/audit_cmd.py +108 -0
  35. persona_core-0.1.0/src/persona/cli/chat_cmd.py +191 -0
  36. persona_core-0.1.0/src/persona/cli/init_cmd.py +121 -0
  37. persona_core-0.1.0/src/persona/cli/main.py +33 -0
  38. persona_core-0.1.0/src/persona/cli/run_cmd.py +23 -0
  39. persona_core-0.1.0/src/persona/cli/validate_cmd.py +34 -0
  40. persona_core-0.1.0/src/persona/config.py +134 -0
  41. persona_core-0.1.0/src/persona/credits/__init__.py +48 -0
  42. persona_core-0.1.0/src/persona/credits/service.py +269 -0
  43. persona_core-0.1.0/src/persona/documents/__init__.py +27 -0
  44. persona_core-0.1.0/src/persona/documents/chunker.py +331 -0
  45. persona_core-0.1.0/src/persona/documents/errors.py +102 -0
  46. persona_core-0.1.0/src/persona/documents/ingest.py +246 -0
  47. persona_core-0.1.0/src/persona/documents/parsers/__init__.py +219 -0
  48. persona_core-0.1.0/src/persona/documents/parsers/csv.py +219 -0
  49. persona_core-0.1.0/src/persona/documents/parsers/docx.py +225 -0
  50. persona_core-0.1.0/src/persona/documents/parsers/pdf.py +227 -0
  51. persona_core-0.1.0/src/persona/documents/parsers/text.py +223 -0
  52. persona_core-0.1.0/src/persona/documents/parsers/xlsx.py +219 -0
  53. persona_core-0.1.0/src/persona/errors.py +206 -0
  54. persona_core-0.1.0/src/persona/history.py +144 -0
  55. persona_core-0.1.0/src/persona/imagegen/__init__.py +73 -0
  56. persona_core-0.1.0/src/persona/imagegen/_factory.py +454 -0
  57. persona_core-0.1.0/src/persona/imagegen/_merge.py +234 -0
  58. persona_core-0.1.0/src/persona/imagegen/cloudflare_image.py +277 -0
  59. persona_core-0.1.0/src/persona/imagegen/config.py +166 -0
  60. persona_core-0.1.0/src/persona/imagegen/errors.py +99 -0
  61. persona_core-0.1.0/src/persona/imagegen/fal_image.py +646 -0
  62. persona_core-0.1.0/src/persona/imagegen/multi_model_image.py +520 -0
  63. persona_core-0.1.0/src/persona/imagegen/nvidia_image.py +758 -0
  64. persona_core-0.1.0/src/persona/imagegen/openai_image.py +497 -0
  65. persona_core-0.1.0/src/persona/imagegen/openrouter_image.py +599 -0
  66. persona_core-0.1.0/src/persona/imagegen/protocol.py +130 -0
  67. persona_core-0.1.0/src/persona/imagegen/result.py +148 -0
  68. persona_core-0.1.0/src/persona/imagegen/safety.py +524 -0
  69. persona_core-0.1.0/src/persona/imagegen/tool.py +576 -0
  70. persona_core-0.1.0/src/persona/logging.py +140 -0
  71. persona_core-0.1.0/src/persona/py.typed +0 -0
  72. persona_core-0.1.0/src/persona/registry.py +278 -0
  73. persona_core-0.1.0/src/persona/sandbox/__init__.py +56 -0
  74. persona_core-0.1.0/src/persona/sandbox/egress.py +334 -0
  75. persona_core-0.1.0/src/persona/sandbox/errors.py +143 -0
  76. persona_core-0.1.0/src/persona/sandbox/image/Dockerfile +139 -0
  77. persona_core-0.1.0/src/persona/sandbox/image/README.md +180 -0
  78. persona_core-0.1.0/src/persona/sandbox/image/requirements.in +69 -0
  79. persona_core-0.1.0/src/persona/sandbox/image/requirements.txt +1004 -0
  80. persona_core-0.1.0/src/persona/sandbox/local_docker.py +1204 -0
  81. persona_core-0.1.0/src/persona/sandbox/protocol.py +305 -0
  82. persona_core-0.1.0/src/persona/sandbox/result.py +163 -0
  83. persona_core-0.1.0/src/persona/sandbox/scripts/README.md +146 -0
  84. persona_core-0.1.0/src/persona/sandbox/scripts/setup-sandbox-net.sh +159 -0
  85. persona_core-0.1.0/src/persona/sandbox/scripts/teardown-sandbox-net.sh +52 -0
  86. persona_core-0.1.0/src/persona/sandbox/tool.py +509 -0
  87. persona_core-0.1.0/src/persona/schema/__init__.py +59 -0
  88. persona_core-0.1.0/src/persona/schema/chunks.py +204 -0
  89. persona_core-0.1.0/src/persona/schema/content.py +83 -0
  90. persona_core-0.1.0/src/persona/schema/conversation.py +127 -0
  91. persona_core-0.1.0/src/persona/schema/documents.py +269 -0
  92. persona_core-0.1.0/src/persona/schema/persona.py +325 -0
  93. persona_core-0.1.0/src/persona/schema/skills.py +54 -0
  94. persona_core-0.1.0/src/persona/schema/tools.py +106 -0
  95. persona_core-0.1.0/src/persona/skills/__init__.py +55 -0
  96. persona_core-0.1.0/src/persona/skills/_frontmatter.py +90 -0
  97. persona_core-0.1.0/src/persona/skills/_tokens.py +43 -0
  98. persona_core-0.1.0/src/persona/skills/builtin/__init__.py +0 -0
  99. persona_core-0.1.0/src/persona/skills/builtin/data_analysis/SKILL.md +191 -0
  100. persona_core-0.1.0/src/persona/skills/builtin/data_analysis/supplements/chart_families.md +188 -0
  101. persona_core-0.1.0/src/persona/skills/builtin/data_analysis/supplements/large_datasets.md +135 -0
  102. persona_core-0.1.0/src/persona/skills/builtin/data_analysis/supplements/styling.md +141 -0
  103. persona_core-0.1.0/src/persona/skills/builtin/document_drafting/SKILL.md +179 -0
  104. persona_core-0.1.0/src/persona/skills/builtin/docx_generation/SKILL.md +126 -0
  105. persona_core-0.1.0/src/persona/skills/builtin/docx_generation/supplements/images.md +115 -0
  106. persona_core-0.1.0/src/persona/skills/builtin/docx_generation/supplements/styles.md +148 -0
  107. persona_core-0.1.0/src/persona/skills/builtin/docx_generation/supplements/tables.md +148 -0
  108. persona_core-0.1.0/src/persona/skills/builtin/docx_generation/supplements/toc.md +120 -0
  109. persona_core-0.1.0/src/persona/skills/builtin/pdf_generation/SKILL.md +187 -0
  110. persona_core-0.1.0/src/persona/skills/builtin/pdf_generation/supplements/flowables.md +253 -0
  111. persona_core-0.1.0/src/persona/skills/builtin/pdf_generation/supplements/images.md +235 -0
  112. persona_core-0.1.0/src/persona/skills/builtin/pdf_generation/supplements/pagination.md +270 -0
  113. persona_core-0.1.0/src/persona/skills/builtin/pptx_generation/SKILL.md +187 -0
  114. persona_core-0.1.0/src/persona/skills/builtin/pptx_generation/supplements/charts.md +260 -0
  115. persona_core-0.1.0/src/persona/skills/builtin/pptx_generation/supplements/layouts.md +202 -0
  116. persona_core-0.1.0/src/persona/skills/builtin/pptx_generation/supplements/theme.md +200 -0
  117. persona_core-0.1.0/src/persona/skills/builtin/web_research/SKILL.md +323 -0
  118. persona_core-0.1.0/src/persona/skills/builtin/xlsx_generation/SKILL.md +197 -0
  119. persona_core-0.1.0/src/persona/skills/builtin/xlsx_generation/supplements/charts.md +212 -0
  120. persona_core-0.1.0/src/persona/skills/builtin/xlsx_generation/supplements/formatting.md +205 -0
  121. persona_core-0.1.0/src/persona/skills/builtin/xlsx_generation/supplements/formulas.md +171 -0
  122. persona_core-0.1.0/src/persona/skills/index.py +53 -0
  123. persona_core-0.1.0/src/persona/skills/injector.py +132 -0
  124. persona_core-0.1.0/src/persona/skills/scanner.py +197 -0
  125. persona_core-0.1.0/src/persona/skills/use_skill_tool.py +138 -0
  126. persona_core-0.1.0/src/persona/stores/__init__.py +59 -0
  127. persona_core-0.1.0/src/persona/stores/backend.py +93 -0
  128. persona_core-0.1.0/src/persona/stores/base.py +366 -0
  129. persona_core-0.1.0/src/persona/stores/chroma.py +253 -0
  130. persona_core-0.1.0/src/persona/stores/document_store.py +201 -0
  131. persona_core-0.1.0/src/persona/stores/embedder.py +118 -0
  132. persona_core-0.1.0/src/persona/stores/episodic.py +77 -0
  133. persona_core-0.1.0/src/persona/stores/errors.py +24 -0
  134. persona_core-0.1.0/src/persona/stores/identity.py +27 -0
  135. persona_core-0.1.0/src/persona/stores/policy.py +220 -0
  136. persona_core-0.1.0/src/persona/stores/postgres.py +281 -0
  137. persona_core-0.1.0/src/persona/stores/protocol.py +125 -0
  138. persona_core-0.1.0/src/persona/stores/self_facts.py +39 -0
  139. persona_core-0.1.0/src/persona/stores/versioning.py +181 -0
  140. persona_core-0.1.0/src/persona/stores/worldview.py +31 -0
  141. persona_core-0.1.0/src/persona/tools/__init__.py +65 -0
  142. persona_core-0.1.0/src/persona/tools/_factory.py +114 -0
  143. persona_core-0.1.0/src/persona/tools/_sandbox.py +173 -0
  144. persona_core-0.1.0/src/persona/tools/audit.py +137 -0
  145. persona_core-0.1.0/src/persona/tools/builtin/__init__.py +0 -0
  146. persona_core-0.1.0/src/persona/tools/builtin/_search_providers.py +151 -0
  147. persona_core-0.1.0/src/persona/tools/builtin/file_read.py +125 -0
  148. persona_core-0.1.0/src/persona/tools/builtin/file_write.py +185 -0
  149. persona_core-0.1.0/src/persona/tools/builtin/web_fetch.py +329 -0
  150. persona_core-0.1.0/src/persona/tools/builtin/web_search.py +162 -0
  151. persona_core-0.1.0/src/persona/tools/errors.py +27 -0
  152. persona_core-0.1.0/src/persona/tools/formatting.py +121 -0
  153. persona_core-0.1.0/src/persona/tools/mcp/__init__.py +0 -0
  154. persona_core-0.1.0/src/persona/tools/mcp/adapter.py +119 -0
  155. persona_core-0.1.0/src/persona/tools/mcp/client.py +283 -0
  156. persona_core-0.1.0/src/persona/tools/protocol.py +274 -0
  157. persona_core-0.1.0/src/persona/tools/toolbox.py +145 -0
  158. persona_core-0.1.0/tests/__init__.py +0 -0
  159. persona_core-0.1.0/tests/_embedder.py +36 -0
  160. persona_core-0.1.0/tests/_mock_backend.py +107 -0
  161. persona_core-0.1.0/tests/_sandbox_fakes.py +125 -0
  162. persona_core-0.1.0/tests/conftest.py +12 -0
  163. persona_core-0.1.0/tests/contract/.gitkeep +0 -0
  164. persona_core-0.1.0/tests/contract/__init__.py +0 -0
  165. persona_core-0.1.0/tests/contract/test_chat_backend_contract.py +372 -0
  166. persona_core-0.1.0/tests/contract/test_tool_contract.py +63 -0
  167. persona_core-0.1.0/tests/external/__init__.py +12 -0
  168. persona_core-0.1.0/tests/external/test_nvidia_smoke.py +356 -0
  169. persona_core-0.1.0/tests/fixtures/documents/corrupt.docx +1 -0
  170. persona_core-0.1.0/tests/fixtures/documents/corrupt.pdf +1 -0
  171. persona_core-0.1.0/tests/fixtures/documents/corrupt.xlsx +1 -0
  172. persona_core-0.1.0/tests/fixtures/documents/oversize.csv +2001 -0
  173. persona_core-0.1.0/tests/fixtures/documents/oversize.xlsx +0 -0
  174. persona_core-0.1.0/tests/fixtures/documents/sample-text.pdf +27 -0
  175. persona_core-0.1.0/tests/fixtures/documents/sample.csv +6 -0
  176. persona_core-0.1.0/tests/fixtures/documents/sample.docx +0 -0
  177. persona_core-0.1.0/tests/fixtures/documents/sample.md +17 -0
  178. persona_core-0.1.0/tests/fixtures/documents/sample.py +10 -0
  179. persona_core-0.1.0/tests/fixtures/documents/sample.txt +7 -0
  180. persona_core-0.1.0/tests/fixtures/documents/sample.xlsx +0 -0
  181. persona_core-0.1.0/tests/fixtures/documents/scanned-like.pdf +35 -0
  182. persona_core-0.1.0/tests/fixtures/personas/invalid/01_missing_identity.yaml +2 -0
  183. persona_core-0.1.0/tests/fixtures/personas/invalid/02_unknown_top_level_field.yaml +7 -0
  184. persona_core-0.1.0/tests/fixtures/personas/invalid/03_wrong_type_for_constraints.yaml +7 -0
  185. persona_core-0.1.0/tests/fixtures/personas/invalid/04_schema_version_mismatch.yaml +5 -0
  186. persona_core-0.1.0/tests/fixtures/personas/invalid/05_worldview_invalid_epistemic.yaml +9 -0
  187. persona_core-0.1.0/tests/fixtures/personas/invalid/06_self_fact_confidence_out_of_range.yaml +9 -0
  188. persona_core-0.1.0/tests/fixtures/personas/invalid/07_routing_invalid_tier.yaml +8 -0
  189. persona_core-0.1.0/tests/fixtures/personas/invalid/08_identity_empty_name.yaml +6 -0
  190. persona_core-0.1.0/tests/fixtures/personas/invalid/09_episodic_naive_datetime.yaml +9 -0
  191. persona_core-0.1.0/tests/fixtures/personas/invalid/10_embedding_dim_zero.yaml +9 -0
  192. persona_core-0.1.0/tests/fixtures/personas/valid/01_minimal.yaml +5 -0
  193. persona_core-0.1.0/tests/fixtures/personas/valid/02_astrid_no_persona_id.yaml +11 -0
  194. persona_core-0.1.0/tests/fixtures/personas/valid/03_legal_assistant_full.yaml +46 -0
  195. persona_core-0.1.0/tests/fixtures/personas/valid/04_explicit_routing.yaml +9 -0
  196. persona_core-0.1.0/tests/fixtures/personas/valid/05_writing_coach.yaml +28 -0
  197. persona_core-0.1.0/tests/fixtures/personas/valid/06_research_assistant.yaml +28 -0
  198. persona_core-0.1.0/tests/fixtures/personas/valid/07_with_episodic.yaml +13 -0
  199. persona_core-0.1.0/tests/fixtures/personas/valid/08_empty_lists.yaml +11 -0
  200. persona_core-0.1.0/tests/fixtures/personas/valid/09_contested_worldview.yaml +15 -0
  201. persona_core-0.1.0/tests/fixtures/personas/valid/10_explicit_owner.yaml +8 -0
  202. persona_core-0.1.0/tests/integration/.gitkeep +0 -0
  203. persona_core-0.1.0/tests/integration/__init__.py +0 -0
  204. persona_core-0.1.0/tests/integration/sandbox/__init__.py +0 -0
  205. persona_core-0.1.0/tests/integration/sandbox/_attacks.py +597 -0
  206. persona_core-0.1.0/tests/integration/sandbox/_fixtures/etc_passwd_baseline.txt +18 -0
  207. persona_core-0.1.0/tests/integration/sandbox/conftest.py +75 -0
  208. persona_core-0.1.0/tests/integration/sandbox/test_security_suite.py +292 -0
  209. persona_core-0.1.0/tests/integration/test_builtin_skills.py +518 -0
  210. persona_core-0.1.0/tests/integration/test_chart_quality_bar.py +386 -0
  211. persona_core-0.1.0/tests/integration/test_cli_chat.py +110 -0
  212. persona_core-0.1.0/tests/integration/test_document_store_no_leak.py +355 -0
  213. persona_core-0.1.0/tests/integration/test_registry.py +120 -0
  214. persona_core-0.1.0/tests/integration/test_stateful_iteration.py +168 -0
  215. persona_core-0.1.0/tests/integration/test_stores_chroma.py +423 -0
  216. persona_core-0.1.0/tests/unit/.gitkeep +0 -0
  217. persona_core-0.1.0/tests/unit/__init__.py +0 -0
  218. persona_core-0.1.0/tests/unit/auth/test_jwt_verifier.py +195 -0
  219. persona_core-0.1.0/tests/unit/backends/__init__.py +0 -0
  220. persona_core-0.1.0/tests/unit/backends/test_backends_config.py +221 -0
  221. persona_core-0.1.0/tests/unit/backends/test_backends_errors.py +110 -0
  222. persona_core-0.1.0/tests/unit/backends/test_backends_protocol.py +137 -0
  223. persona_core-0.1.0/tests/unit/backends/test_backends_types.py +306 -0
  224. persona_core-0.1.0/tests/unit/backends/test_capabilities_vision.py +477 -0
  225. persona_core-0.1.0/tests/unit/backends/test_credentials.py +406 -0
  226. persona_core-0.1.0/tests/unit/backends/test_errors_hierarchy.py +223 -0
  227. persona_core-0.1.0/tests/unit/backends/test_factory.py +143 -0
  228. persona_core-0.1.0/tests/unit/backends/test_hf_local.py +387 -0
  229. persona_core-0.1.0/tests/unit/backends/test_hf_local_vision.py +168 -0
  230. persona_core-0.1.0/tests/unit/backends/test_multi_model_chat.py +638 -0
  231. persona_core-0.1.0/tests/unit/backends/test_ollama.py +412 -0
  232. persona_core-0.1.0/tests/unit/backends/test_ollama_vision.py +280 -0
  233. persona_core-0.1.0/tests/unit/backends/test_openai_compat.py +1223 -0
  234. persona_core-0.1.0/tests/unit/backends/test_openai_compat_vision.py +761 -0
  235. persona_core-0.1.0/tests/unit/backends/test_openrouter_catalog.py +284 -0
  236. persona_core-0.1.0/tests/unit/backends/test_openrouter_catalog_contract.py +112 -0
  237. persona_core-0.1.0/tests/unit/backends/test_tool_shim.py +244 -0
  238. persona_core-0.1.0/tests/unit/backends/test_vision_round_trip.py +293 -0
  239. persona_core-0.1.0/tests/unit/documents/__init__.py +0 -0
  240. persona_core-0.1.0/tests/unit/documents/test_chunker.py +288 -0
  241. persona_core-0.1.0/tests/unit/documents/test_empty_extraction_flag.py +342 -0
  242. persona_core-0.1.0/tests/unit/documents/test_errors.py +94 -0
  243. persona_core-0.1.0/tests/unit/documents/test_ingest.py +357 -0
  244. persona_core-0.1.0/tests/unit/documents/test_parser_csv.py +162 -0
  245. persona_core-0.1.0/tests/unit/documents/test_parser_docx.py +83 -0
  246. persona_core-0.1.0/tests/unit/documents/test_parser_pdf.py +123 -0
  247. persona_core-0.1.0/tests/unit/documents/test_parser_text.py +135 -0
  248. persona_core-0.1.0/tests/unit/documents/test_parser_xlsx.py +102 -0
  249. persona_core-0.1.0/tests/unit/imagegen/__init__.py +0 -0
  250. persona_core-0.1.0/tests/unit/imagegen/test_cloudflare_image.py +193 -0
  251. persona_core-0.1.0/tests/unit/imagegen/test_config.py +255 -0
  252. persona_core-0.1.0/tests/unit/imagegen/test_contract.py +927 -0
  253. persona_core-0.1.0/tests/unit/imagegen/test_errors.py +195 -0
  254. persona_core-0.1.0/tests/unit/imagegen/test_factory.py +269 -0
  255. persona_core-0.1.0/tests/unit/imagegen/test_factory_from_env.py +394 -0
  256. persona_core-0.1.0/tests/unit/imagegen/test_fal_image.py +895 -0
  257. persona_core-0.1.0/tests/unit/imagegen/test_merge.py +333 -0
  258. persona_core-0.1.0/tests/unit/imagegen/test_multi_model_image.py +622 -0
  259. persona_core-0.1.0/tests/unit/imagegen/test_nvidia_image.py +658 -0
  260. persona_core-0.1.0/tests/unit/imagegen/test_openai_image.py +607 -0
  261. persona_core-0.1.0/tests/unit/imagegen/test_openrouter_image.py +577 -0
  262. persona_core-0.1.0/tests/unit/imagegen/test_protocol.py +222 -0
  263. persona_core-0.1.0/tests/unit/imagegen/test_result.py +304 -0
  264. persona_core-0.1.0/tests/unit/imagegen/test_safety.py +516 -0
  265. persona_core-0.1.0/tests/unit/imagegen/test_tool.py +665 -0
  266. persona_core-0.1.0/tests/unit/sandbox/__init__.py +0 -0
  267. persona_core-0.1.0/tests/unit/sandbox/test_chart_path_contract.py +170 -0
  268. persona_core-0.1.0/tests/unit/sandbox/test_egress.py +287 -0
  269. persona_core-0.1.0/tests/unit/sandbox/test_errors.py +103 -0
  270. persona_core-0.1.0/tests/unit/sandbox/test_image_manifest.py +329 -0
  271. persona_core-0.1.0/tests/unit/sandbox/test_large_dataset_triage.py +183 -0
  272. persona_core-0.1.0/tests/unit/sandbox/test_local_docker.py +880 -0
  273. persona_core-0.1.0/tests/unit/sandbox/test_protocol.py +144 -0
  274. persona_core-0.1.0/tests/unit/sandbox/test_result.py +246 -0
  275. persona_core-0.1.0/tests/unit/sandbox/test_tool.py +565 -0
  276. persona_core-0.1.0/tests/unit/sandbox/test_tool_session_recovery.py +267 -0
  277. persona_core-0.1.0/tests/unit/schema/__init__.py +0 -0
  278. persona_core-0.1.0/tests/unit/schema/_conversation_message_snapshots.json +396 -0
  279. persona_core-0.1.0/tests/unit/schema/test_content.py +183 -0
  280. persona_core-0.1.0/tests/unit/schema/test_conversation.py +238 -0
  281. persona_core-0.1.0/tests/unit/skills/__init__.py +0 -0
  282. persona_core-0.1.0/tests/unit/skills/_fakes.py +40 -0
  283. persona_core-0.1.0/tests/unit/skills/_fixtures/malformed_skill/SKILL.md +7 -0
  284. persona_core-0.1.0/tests/unit/skills/_fixtures/missing_description_skill/SKILL.md +7 -0
  285. persona_core-0.1.0/tests/unit/skills/_fixtures/valid_skill/SKILL.md +15 -0
  286. persona_core-0.1.0/tests/unit/skills/test_frontmatter.py +190 -0
  287. persona_core-0.1.0/tests/unit/skills/test_index.py +214 -0
  288. persona_core-0.1.0/tests/unit/skills/test_injector.py +261 -0
  289. persona_core-0.1.0/tests/unit/skills/test_scanner.py +314 -0
  290. persona_core-0.1.0/tests/unit/skills/test_tokens.py +143 -0
  291. persona_core-0.1.0/tests/unit/skills/test_use_skill_tool.py +349 -0
  292. persona_core-0.1.0/tests/unit/stores/test_document_store.py +332 -0
  293. persona_core-0.1.0/tests/unit/test_audit.py +224 -0
  294. persona_core-0.1.0/tests/unit/test_autonomy.py +223 -0
  295. persona_core-0.1.0/tests/unit/test_autonomy_learner.py +289 -0
  296. persona_core-0.1.0/tests/unit/test_chunks.py +191 -0
  297. persona_core-0.1.0/tests/unit/test_cli.py +168 -0
  298. persona_core-0.1.0/tests/unit/test_errors.py +94 -0
  299. persona_core-0.1.0/tests/unit/test_examples_validate.py +78 -0
  300. persona_core-0.1.0/tests/unit/test_history.py +176 -0
  301. persona_core-0.1.0/tests/unit/test_logging.py +171 -0
  302. persona_core-0.1.0/tests/unit/test_schema_conversation.py +94 -0
  303. persona_core-0.1.0/tests/unit/test_schema_documents.py +318 -0
  304. persona_core-0.1.0/tests/unit/test_schema_persona.py +326 -0
  305. persona_core-0.1.0/tests/unit/test_schema_voice.py +113 -0
  306. persona_core-0.1.0/tests/unit/test_stores_backend.py +98 -0
  307. persona_core-0.1.0/tests/unit/test_stores_policy.py +262 -0
  308. persona_core-0.1.0/tests/unit/test_stores_postgres_helpers.py +120 -0
  309. persona_core-0.1.0/tests/unit/test_tools_skills.py +175 -0
  310. persona_core-0.1.0/tests/unit/test_versioning.py +172 -0
  311. persona_core-0.1.0/tests/unit/tools/__init__.py +0 -0
  312. persona_core-0.1.0/tests/unit/tools/builtin/__init__.py +0 -0
  313. persona_core-0.1.0/tests/unit/tools/builtin/test_file_tools.py +472 -0
  314. persona_core-0.1.0/tests/unit/tools/builtin/test_web_fetch.py +458 -0
  315. persona_core-0.1.0/tests/unit/tools/builtin/test_web_search.py +306 -0
  316. persona_core-0.1.0/tests/unit/tools/mcp/__init__.py +0 -0
  317. persona_core-0.1.0/tests/unit/tools/mcp/test_mcp_adapter.py +239 -0
  318. persona_core-0.1.0/tests/unit/tools/mcp/test_mcp_client.py +279 -0
  319. persona_core-0.1.0/tests/unit/tools/test_sandbox.py +376 -0
  320. persona_core-0.1.0/tests/unit/tools/test_sandbox_path_hints.py +123 -0
  321. persona_core-0.1.0/tests/unit/tools/test_tool_decorator.py +290 -0
  322. persona_core-0.1.0/tests/unit/tools/test_toolbox.py +216 -0
  323. persona_core-0.1.0/tests/unit/tools/test_tools_errors.py +97 -0
  324. persona_core-0.1.0/tests/unit/tools/test_tools_factory.py +279 -0
  325. persona_core-0.1.0/tests/unit/tools/test_tools_formatting.py +171 -0
  326. persona_core-0.1.0/tests/unit/tools/test_tools_protocol.py +264 -0
@@ -0,0 +1,68 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .venv/
8
+ *.egg
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .pytest_cache/
12
+ htmlcov/
13
+ .coverage
14
+ coverage.xml
15
+
16
+ # Environment
17
+ .env
18
+ .env.local
19
+ .env.*.local
20
+ .secrets/
21
+
22
+ # IDEs
23
+ .vscode/
24
+ .idea/
25
+ .claude/
26
+ *.swp
27
+ *.swo
28
+ *~
29
+
30
+ # OS
31
+ .DS_Store
32
+ Thumbs.db
33
+
34
+ # Node (web app)
35
+ node_modules/
36
+ .next/
37
+ out/
38
+
39
+ # ChromaDB local storage
40
+ .chroma/
41
+
42
+ # Persona working directories
43
+ .persona_work/
44
+ .persona_audit/
45
+
46
+ # UV — uv.lock IS committed (reproducible builds; Dockerfile COPYs it
47
+ # into the image; the CI deploy fails without it).
48
+
49
+ # rsync atomic-write tempfiles
50
+ .*.??????
51
+
52
+ # Docker
53
+ docker-compose.override.yml
54
+
55
+ # Operational caches / temp workspaces
56
+ .playwright-mcp/
57
+ .tmp_smoke_workspace/
58
+
59
+ # Spec 16 D-16-X-3: inspection artifacts (.docx/.pptx/.xlsx/.pdf) are binary;
60
+ # evidence at close-out is the per-row scorecard in state.md, not the binaries.
61
+ docs/specs/phase2/spec_16/inspection/
62
+
63
+ # Spec 17 T09 chart-inspection artifacts (.png) are binary; same discipline —
64
+ # scorecards in state.md are the close-out evidence, not the PNG files.
65
+ docs/specs/phase2/spec_17/inspection/
66
+ packages/web/evidence/
67
+ docs/*
68
+ CLAUDE.md
@@ -0,0 +1,48 @@
1
+ # Changelog — persona-core
2
+
3
+ All notable changes to `persona-core` are recorded here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+ The project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ Per-spec entries are added by the close-out phase of each spec. The authoritative
9
+ project-wide changelog lives at [`/CHANGELOG.md`](../../CHANGELOG.md); this file
10
+ mirrors only the `persona-core`-touching surface.
11
+
12
+ ---
13
+
14
+ ## [Unreleased]
15
+
16
+ (empty — future post-v0.1 work lands here)
17
+
18
+ ---
19
+
20
+ ## [1.0.0] — 2026-06-07
21
+
22
+ > **First public, API-stable release of the open-source `persona-core` library under Apache 2.0 (D-11-8).** Includes the Spec V1 JWT-verifier extraction, the Spec 19 amendment set landed during the v0.1 close-out (file-write produced-files / host-out debug logging / credits-service domain relocation), and all prior spec close-outs (Spec 01 schema/stores → Spec 18 routing). Per-package version pin tracks the library's stable public API; product v0.1.0 = the git tag on the system release.
23
+
24
+ ### Added (Spec V1 cross-spec extraction)
25
+
26
+ - **`persona.auth.jwt_verifier`** — `make_jwt_verifier(config)` + `AuthenticatedUser` factory; new `JwtVerifierConfig: Protocol` (structural subtype satisfied implicitly by `APIConfig` and `VoiceConfig` via the `jwt_algorithms_list` `@property`). `AuthenticationError` relocated from `persona_api.errors` to `persona.errors`; `python-jose[cryptography]` moved to persona-core deps. persona-api re-exports preserve byte-for-byte back-compat (D-V1-X-jwt-verifier-extraction; Spec 08 additive amendment, 9th in the additive-extension chain per D-12-X / D-16-X / D-F4-X-bare-ref-resolution precedent).
27
+ - Source: [`packages/core/src/persona/auth/jwt_verifier.py`](src/persona/auth/jwt_verifier.py).
28
+
29
+ ### Added (Spec 19 amendment set — chain entries 14 / 15 / 20)
30
+
31
+ - **L2 (chain 14) D-19-X-file-write-produced-files** — `file_write` tool surfaces produced-files metadata via the produced-files contract so downstream renderers consume host-written outputs identically to sandbox-produced files. Closed-spec additive extension; no Spec 03 reopen.
32
+ - **L4 (chain 15) D-19-X-host-out-debug-logging** — host-out path emits one debug log entry per produced-file emission (loguru `persona.tools.file_write` component). Diagnostic-only; gated behind log level.
33
+ - **L6c (chain 20) D-19-X-credits-service-domain-relocation** — credits-service domain primitives relocated from `persona-api` into `persona-core` (domain home; API keeps the persistence + composition root). Boundary types stay Pydantic v2 frozen `extra="forbid"` per D-12-14 precedent; persona-api `services.credits_service` re-exports the domain shapes to preserve all existing call sites.
34
+
35
+ ### Inherited (close-out roll-up from 2026-05-29 — 2026-06-06)
36
+
37
+ The following persona-core close-outs are folded into the 1.0.0 anchor; full per-spec rationale lives in [`/CHANGELOG.md`](../../CHANGELOG.md):
38
+
39
+ - **Spec 17 — Data Analysis and Visualisation.** `data_analysis` built-in skill pack; bytes-persistence layer (`CodeSandbox.copy_produced_file_to` + `read_produced_file_bytes`; `ProducedFileSizeError`); runtime call site for cross-turn `intermediate/*` staging.
40
+ - **Spec 16 — Document Generation Skills.** Four built-in skill packs (`docx_generation`, `pptx_generation`, `xlsx_generation`, `pdf_generation`); M1a runtime affordance (`persona.skills.collect_skill_supplements`); D-16-2-supplements-relative-path production fix.
41
+ - **Spec 15 — Image Generation.** `ImageBackend` Protocol + OpenAI gpt-image-1 + Flux 1.1 [pro] (fal.ai) backends; `identity.visual_style` additive schema extension; three-layer safety with categorical hard-line filter; `make_generate_image_tool` AsyncTool factory; `merge_visual_style` deterministic suffix-conditioning template.
42
+ - **Spec 14 — Document Ingestion.** `DocumentChunk` sibling schema; `DocumentStore` conversation-scoped store; five parsers (txt/md/code, csv, docx, xlsx, pdf) with lazy-import + `MissingDependencyError` discipline; size-aware ingest strategy with D-14-1 3000-token threshold + ladder.
43
+ - **Spec 13 — Vision and Multimodal Input.** `ImageContent` + `ImageRef` schema; `images` JSONB column shape; Pillow downscale-with-hard-ceiling.
44
+ - **Spec 12 — Code Execution Sandbox.** `CodeSandbox` Protocol; `LocalDockerSandbox` (R-12-2 hardening); `make_code_execution_tool`.
45
+
46
+ ### Inherited (prior versions — Spec 11 launch and earlier)
47
+
48
+ The 1.0.0 anchor subsumes the prior per-spec `[0.x.0]` line: Spec 11 launch (SSRF guard, structured `tool_calls`, streaming `call_id` reconstruction), Spec 04 skills, Spec 03 tools/MCP/Toolbox, Spec 02 backends, Spec 01 foundation (schema, stores, registry, history manager, audit). See [`/CHANGELOG.md`](../../CHANGELOG.md) `[1.0.0]` (2026-05-29) and prior `[0.x.0]` blocks.
@@ -0,0 +1,77 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
12
+
13
+ ## Distribution License
14
+
15
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
16
+
17
+ ## Notices
18
+
19
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms, the copyright notice, and the patent notice.
20
+
21
+ If you modify the software, you must include in any modified copies of the software a prominent notice stating that you have modified the software.
22
+
23
+ ## Changes and New Works License
24
+
25
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
26
+
27
+ ## Patent License
28
+
29
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
30
+
31
+ ## Noncommercial Purposes
32
+
33
+ Any noncommercial purpose is a permitted purpose.
34
+
35
+ ## Personal Uses
36
+
37
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
38
+
39
+ ## Noncommercial Organizations
40
+
41
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
42
+
43
+ ## Fair Use
44
+
45
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
46
+
47
+ ## No Other Rights
48
+
49
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
50
+
51
+ ## Patent Defense
52
+
53
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
54
+
55
+ ## Violations
56
+
57
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
58
+
59
+ ## No Liability
60
+
61
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
62
+
63
+ ## Definitions
64
+
65
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
66
+
67
+ **You** refers to the individual or entity agreeing to these terms.
68
+
69
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
70
+
71
+ **Your licenses** are all the licenses granted to you for the software under these terms.
72
+
73
+ **Use** means anything you do with the software requiring one of your licenses.
74
+
75
+ ---
76
+
77
+ Copyright 2026 Yasin Hessnawi
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: persona-core
3
+ Version: 0.1.0
4
+ Summary: Build AI personas with typed memory and tier-routed model selection.
5
+ Project-URL: Homepage, https://github.com/yasinhessnawi1/Open-Persona
6
+ Project-URL: Repository, https://github.com/yasinhessnawi1/Open-Persona
7
+ Project-URL: Issues, https://github.com/yasinhessnawi1/Open-Persona/issues
8
+ Project-URL: Changelog, https://github.com/yasinhessnawi1/Open-Persona/blob/main/CHANGELOG.md
9
+ Author-email: Yasin Hessnawi <yasinhessnawi1@gmail.com>
10
+ License-Expression: PolyForm-Noncommercial-1.0.0
11
+ License-File: LICENSE
12
+ Keywords: agent,agentic,ai,llm,persona,pgvector,rag,typed-memory
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: Other/Proprietary License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: POSIX
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: anthropic<1,>=0.30
29
+ Requires-Dist: chromadb<2,>=1.0
30
+ Requires-Dist: fal-client<2,>=1.0
31
+ Requires-Dist: httpx<1,>=0.27
32
+ Requires-Dist: loguru<1,>=0.7
33
+ Requires-Dist: mcp<2,>=1.0
34
+ Requires-Dist: openai<2,>=1.30
35
+ Requires-Dist: pydantic-settings<3,>=2.3
36
+ Requires-Dist: pydantic<3,>=2.7
37
+ Requires-Dist: python-jose[cryptography]<4,>=3.3
38
+ Requires-Dist: pyyaml<7,>=6.0
39
+ Requires-Dist: regex<2027,>=2024.0
40
+ Requires-Dist: sentence-transformers<4,>=3.0
41
+ Requires-Dist: tiktoken<1,>=0.7
42
+ Requires-Dist: trafilatura<3,>=2.0
43
+ Requires-Dist: typer<1,>=0.12
44
+ Provides-Extra: local
45
+ Requires-Dist: accelerate<1,>=0.31; extra == 'local'
46
+ Requires-Dist: bitsandbytes<1,>=0.43; extra == 'local'
47
+ Requires-Dist: torch<3,>=2.3; extra == 'local'
48
+ Requires-Dist: transformers<5,>=4.42; extra == 'local'
49
+ Provides-Extra: postgres
50
+ Requires-Dist: pgvector<1,>=0.3; extra == 'postgres'
51
+ Requires-Dist: psycopg[binary]<4,>=3.1; extra == 'postgres'
52
+ Requires-Dist: sqlalchemy<3,>=2.0; extra == 'postgres'
53
+ Provides-Extra: sandbox
54
+ Requires-Dist: docker<8,>=7; extra == 'sandbox'
55
+ Provides-Extra: test
56
+ Requires-Dist: pypdf<7,>=6.0; extra == 'test'
57
+ Description-Content-Type: text/markdown
58
+
59
+ # persona-core
60
+
61
+ > Source-available Python library for building AI personas with typed memory
62
+ > and tier-routed model selection. Noncommercial use only.
63
+
64
+ **Status:** PolyForm Noncommercial 1.0.0 · Source Available (Noncommercial Use Only)
65
+
66
+ ## What it is
67
+
68
+ `persona-core` lets you author a persona as a single YAML document (identity,
69
+ constraints, self-facts, worldview claims with epistemic tags, tools, skills)
70
+ and run it against any of seven model providers — Anthropic, OpenAI, DeepSeek,
71
+ Groq, Together, NVIDIA, OpenRouter, local Ollama, or local HF — with four
72
+ typed memory stores (identity, self-facts, worldview, episodic) backed by
73
+ ChromaDB or Postgres + pgvector. Ships the schema, the four memory stores
74
+ behind a `MemoryStore` protocol, the backend layer behind a `ChatBackend`
75
+ protocol, a sandboxed tool layer (`Toolbox`, MCP client, built-in
76
+ `web_search` / `web_fetch` / `file_read` / `file_write`), a skills layer
77
+ (`SkillScanner` + `SkillInjector` + six built-in skill packs), a vision
78
+ layer (`ImageContent` + `ImageBackend`), document ingestion + generation,
79
+ a code-execution sandbox protocol, an `AuditLogger` protocol with a JSONL
80
+ default, per-component loguru logging, and a `persona` CLI. Every other
81
+ Open Persona package depends on this one; this one depends on nothing inside
82
+ Open Persona.
83
+
84
+ ## Install
85
+
86
+ ```bash
87
+ pip install persona-core # core + Chroma + frontier SDKs
88
+ pip install persona-core[local] # adds torch / transformers for local HF inference
89
+ pip install persona-core[postgres] # adds psycopg + pgvector for the Postgres backend
90
+ pip install persona-core[sandbox] # adds docker SDK for LocalDockerSandbox
91
+ ```
92
+
93
+ Python ≥ 3.11.
94
+
95
+ For workspace development from the monorepo:
96
+
97
+ ```bash
98
+ git clone https://github.com/yasinhessnawi1/Open-Persona.git
99
+ cd open-persona
100
+ uv sync --all-packages
101
+ ```
102
+
103
+ ## Run
104
+
105
+ Author and chat with a persona from the terminal:
106
+
107
+ ```bash
108
+ persona init # interactive → astrid.yaml
109
+ persona validate examples/astrid_tenancy_law.yaml
110
+ export PERSONA_PROVIDER=deepseek
111
+ export PERSONA_MODEL=deepseek-chat
112
+ export PERSONA_API_KEY=<your-key>
113
+ persona chat examples/astrid_tenancy_law.yaml
114
+ persona audit examples/astrid_tenancy_law.yaml # tail the JSONL audit log
115
+ ```
116
+
117
+ Three example personas ship in [`examples/`](examples/):
118
+ `astrid_tenancy_law.yaml` (Norwegian tenancy-law assistant),
119
+ `kai_research.yaml` (research assistant), `maren_writing_coach.yaml`
120
+ (tool-free writing coach).
121
+
122
+ Programmatic use:
123
+
124
+ ```python
125
+ import asyncio
126
+ from pathlib import Path
127
+
128
+ from persona.schema.persona import Persona
129
+ from persona.backends import OpenAICompatibleBackend, BackendConfig
130
+ from persona.schema.conversation import ConversationMessage
131
+
132
+ async def main() -> None:
133
+ persona = Persona.from_yaml(Path("examples/astrid_tenancy_law.yaml"))
134
+ backend = OpenAICompatibleBackend(
135
+ BackendConfig(provider="deepseek", model="deepseek-chat")
136
+ )
137
+ system = f"You are {persona.identity.name}, {persona.identity.role}."
138
+ reply = await backend.chat([
139
+ ConversationMessage(role="system", content=system, created_at=None),
140
+ ConversationMessage(role="user", content="Hva sier husleieloven om mugg?", created_at=None),
141
+ ])
142
+ print(reply.content)
143
+
144
+ asyncio.run(main())
145
+ ```
146
+
147
+ For the full conversation loop with router, tool dispatch, episodic
148
+ write-back and per-turn logging, compose with `persona-runtime`.
149
+
150
+ ## Test
151
+
152
+ ```bash
153
+ uv run pytest packages/core # unit + contract (default)
154
+ uv run pytest packages/core -m integration # needs Postgres in Docker
155
+ uv run mypy packages/core/src --strict
156
+ uv run ruff check packages/core
157
+ ```
158
+
159
+ ## Highlights
160
+
161
+ - Frozen Pydantic v2 boundary models, `extra="forbid"` everywhere
162
+ - Deterministic chunk IDs: `{persona_id}::{store_kind}::{index:04d}`
163
+ - Versioned append-only stores; identity is immutable at runtime
164
+ - SHA-256 `content_hash` on every chunk; one `AuditEvent` per mutation
165
+ - Three-source write policy: `system` / `user` / `persona_self`
166
+ - 2k-token-budgeted skill injection (`SkillInjector.TOKEN_BUDGET`)
167
+ - Native tool calls (Anthropic / OpenAI / DeepSeek / Groq / Together / NVIDIA /
168
+ OpenRouter) + prompt-shim fallback (Ollama / HF local)
169
+ - MCP Streamable HTTP client + adapter
170
+ - Sandboxed file tools (path resolver rejects `..`, abs paths, symlink
171
+ escape, NUL bytes, mixed separators)
172
+ - Six built-in skill packs: `web_research`, `document_drafting`,
173
+ `docx_generation`, `pptx_generation`, `xlsx_generation`, `pdf_generation`
174
+ - Image generation backends (OpenAI gpt-image-1, fal.ai Flux 1.1 [pro])
175
+ with three-layer safety + categorical hard-line filter
176
+ - Vision input (`ImageContent`) + document ingestion + a `CodeSandbox`
177
+ protocol with `LocalDockerSandbox` reference implementation
178
+
179
+ ## Architecture role
180
+
181
+ `persona-core` is layer 4 of the Open Persona stack — the source-available
182
+ foundation. A persona is a YAML document; the schema, the typed memory
183
+ stores, the model-provider adapters, and the tool/skill machinery all live
184
+ here. `persona-runtime` composes the orchestration loop on top of this
185
+ library; `persona-api` exposes it over HTTP; `persona-web` is the browser
186
+ front-end. The dependency arrow points one way — `persona-core` imports
187
+ nothing from the upper layers.
188
+
189
+ ## Contribute
190
+
191
+ Contributions welcome under the same PolyForm Noncommercial 1.0.0 license.
192
+ The package is source-available for noncommercial use; commercial use
193
+ requires a separate license — contact the rights holder. Issues and pull
194
+ requests welcome at
195
+ [github.com/yasinhessnawi1/Open-Persona](https://github.com/yasinhessnawi1/Open-Persona).
196
+ See [LICENSE](LICENSE) and the package
197
+ [`SPEC.md`](SPEC.md) for the public surface.
@@ -0,0 +1,139 @@
1
+ # persona-core
2
+
3
+ > Source-available Python library for building AI personas with typed memory
4
+ > and tier-routed model selection. Noncommercial use only.
5
+
6
+ **Status:** PolyForm Noncommercial 1.0.0 · Source Available (Noncommercial Use Only)
7
+
8
+ ## What it is
9
+
10
+ `persona-core` lets you author a persona as a single YAML document (identity,
11
+ constraints, self-facts, worldview claims with epistemic tags, tools, skills)
12
+ and run it against any of seven model providers — Anthropic, OpenAI, DeepSeek,
13
+ Groq, Together, NVIDIA, OpenRouter, local Ollama, or local HF — with four
14
+ typed memory stores (identity, self-facts, worldview, episodic) backed by
15
+ ChromaDB or Postgres + pgvector. Ships the schema, the four memory stores
16
+ behind a `MemoryStore` protocol, the backend layer behind a `ChatBackend`
17
+ protocol, a sandboxed tool layer (`Toolbox`, MCP client, built-in
18
+ `web_search` / `web_fetch` / `file_read` / `file_write`), a skills layer
19
+ (`SkillScanner` + `SkillInjector` + six built-in skill packs), a vision
20
+ layer (`ImageContent` + `ImageBackend`), document ingestion + generation,
21
+ a code-execution sandbox protocol, an `AuditLogger` protocol with a JSONL
22
+ default, per-component loguru logging, and a `persona` CLI. Every other
23
+ Open Persona package depends on this one; this one depends on nothing inside
24
+ Open Persona.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pip install persona-core # core + Chroma + frontier SDKs
30
+ pip install persona-core[local] # adds torch / transformers for local HF inference
31
+ pip install persona-core[postgres] # adds psycopg + pgvector for the Postgres backend
32
+ pip install persona-core[sandbox] # adds docker SDK for LocalDockerSandbox
33
+ ```
34
+
35
+ Python ≥ 3.11.
36
+
37
+ For workspace development from the monorepo:
38
+
39
+ ```bash
40
+ git clone https://github.com/yasinhessnawi1/Open-Persona.git
41
+ cd open-persona
42
+ uv sync --all-packages
43
+ ```
44
+
45
+ ## Run
46
+
47
+ Author and chat with a persona from the terminal:
48
+
49
+ ```bash
50
+ persona init # interactive → astrid.yaml
51
+ persona validate examples/astrid_tenancy_law.yaml
52
+ export PERSONA_PROVIDER=deepseek
53
+ export PERSONA_MODEL=deepseek-chat
54
+ export PERSONA_API_KEY=<your-key>
55
+ persona chat examples/astrid_tenancy_law.yaml
56
+ persona audit examples/astrid_tenancy_law.yaml # tail the JSONL audit log
57
+ ```
58
+
59
+ Three example personas ship in [`examples/`](examples/):
60
+ `astrid_tenancy_law.yaml` (Norwegian tenancy-law assistant),
61
+ `kai_research.yaml` (research assistant), `maren_writing_coach.yaml`
62
+ (tool-free writing coach).
63
+
64
+ Programmatic use:
65
+
66
+ ```python
67
+ import asyncio
68
+ from pathlib import Path
69
+
70
+ from persona.schema.persona import Persona
71
+ from persona.backends import OpenAICompatibleBackend, BackendConfig
72
+ from persona.schema.conversation import ConversationMessage
73
+
74
+ async def main() -> None:
75
+ persona = Persona.from_yaml(Path("examples/astrid_tenancy_law.yaml"))
76
+ backend = OpenAICompatibleBackend(
77
+ BackendConfig(provider="deepseek", model="deepseek-chat")
78
+ )
79
+ system = f"You are {persona.identity.name}, {persona.identity.role}."
80
+ reply = await backend.chat([
81
+ ConversationMessage(role="system", content=system, created_at=None),
82
+ ConversationMessage(role="user", content="Hva sier husleieloven om mugg?", created_at=None),
83
+ ])
84
+ print(reply.content)
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ For the full conversation loop with router, tool dispatch, episodic
90
+ write-back and per-turn logging, compose with `persona-runtime`.
91
+
92
+ ## Test
93
+
94
+ ```bash
95
+ uv run pytest packages/core # unit + contract (default)
96
+ uv run pytest packages/core -m integration # needs Postgres in Docker
97
+ uv run mypy packages/core/src --strict
98
+ uv run ruff check packages/core
99
+ ```
100
+
101
+ ## Highlights
102
+
103
+ - Frozen Pydantic v2 boundary models, `extra="forbid"` everywhere
104
+ - Deterministic chunk IDs: `{persona_id}::{store_kind}::{index:04d}`
105
+ - Versioned append-only stores; identity is immutable at runtime
106
+ - SHA-256 `content_hash` on every chunk; one `AuditEvent` per mutation
107
+ - Three-source write policy: `system` / `user` / `persona_self`
108
+ - 2k-token-budgeted skill injection (`SkillInjector.TOKEN_BUDGET`)
109
+ - Native tool calls (Anthropic / OpenAI / DeepSeek / Groq / Together / NVIDIA /
110
+ OpenRouter) + prompt-shim fallback (Ollama / HF local)
111
+ - MCP Streamable HTTP client + adapter
112
+ - Sandboxed file tools (path resolver rejects `..`, abs paths, symlink
113
+ escape, NUL bytes, mixed separators)
114
+ - Six built-in skill packs: `web_research`, `document_drafting`,
115
+ `docx_generation`, `pptx_generation`, `xlsx_generation`, `pdf_generation`
116
+ - Image generation backends (OpenAI gpt-image-1, fal.ai Flux 1.1 [pro])
117
+ with three-layer safety + categorical hard-line filter
118
+ - Vision input (`ImageContent`) + document ingestion + a `CodeSandbox`
119
+ protocol with `LocalDockerSandbox` reference implementation
120
+
121
+ ## Architecture role
122
+
123
+ `persona-core` is layer 4 of the Open Persona stack — the source-available
124
+ foundation. A persona is a YAML document; the schema, the typed memory
125
+ stores, the model-provider adapters, and the tool/skill machinery all live
126
+ here. `persona-runtime` composes the orchestration loop on top of this
127
+ library; `persona-api` exposes it over HTTP; `persona-web` is the browser
128
+ front-end. The dependency arrow points one way — `persona-core` imports
129
+ nothing from the upper layers.
130
+
131
+ ## Contribute
132
+
133
+ Contributions welcome under the same PolyForm Noncommercial 1.0.0 license.
134
+ The package is source-available for noncommercial use; commercial use
135
+ requires a separate license — contact the rights holder. Issues and pull
136
+ requests welcome at
137
+ [github.com/yasinhessnawi1/Open-Persona](https://github.com/yasinhessnawi1/Open-Persona).
138
+ See [LICENSE](LICENSE) and the package
139
+ [`SPEC.md`](SPEC.md) for the public surface.