coco-framework 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 (436) hide show
  1. coco_framework-0.1.0/.gitignore +14 -0
  2. coco_framework-0.1.0/LICENSE +24 -0
  3. coco_framework-0.1.0/NOTICE +15 -0
  4. coco_framework-0.1.0/PKG-INFO +184 -0
  5. coco_framework-0.1.0/README.md +96 -0
  6. coco_framework-0.1.0/UPSTREAM.md +116 -0
  7. coco_framework-0.1.0/libs/checkpoint/LICENSE +21 -0
  8. coco_framework-0.1.0/libs/checkpoint/README.md +5 -0
  9. coco_framework-0.1.0/libs/checkpoint/coco_graph/cache/base/__init__.py +48 -0
  10. coco_framework-0.1.0/libs/checkpoint/coco_graph/cache/base/py.typed +0 -0
  11. coco_framework-0.1.0/libs/checkpoint/coco_graph/cache/memory/__init__.py +73 -0
  12. coco_framework-0.1.0/libs/checkpoint/coco_graph/cache/redis/__init__.py +144 -0
  13. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/base/__init__.py +861 -0
  14. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/base/id.py +109 -0
  15. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/base/py.typed +0 -0
  16. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/memory/__init__.py +698 -0
  17. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/memory/py.typed +0 -0
  18. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/__init__.py +0 -0
  19. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/_msgpack.py +97 -0
  20. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/base.py +64 -0
  21. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/encrypted.py +80 -0
  22. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/event_hooks.py +52 -0
  23. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/jsonplus.py +883 -0
  24. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/py.typed +0 -0
  25. coco_framework-0.1.0/libs/checkpoint/coco_graph/checkpoint/serde/types.py +68 -0
  26. coco_framework-0.1.0/libs/checkpoint/coco_graph/store/base/__init__.py +1322 -0
  27. coco_framework-0.1.0/libs/checkpoint/coco_graph/store/base/batch.py +371 -0
  28. coco_framework-0.1.0/libs/checkpoint/coco_graph/store/base/embed.py +436 -0
  29. coco_framework-0.1.0/libs/checkpoint/coco_graph/store/base/py.typed +0 -0
  30. coco_framework-0.1.0/libs/checkpoint/coco_graph/store/memory/__init__.py +592 -0
  31. coco_framework-0.1.0/libs/checkpoint/coco_graph/store/memory/py.typed +0 -0
  32. coco_framework-0.1.0/libs/checkpoint/pyproject.toml +89 -0
  33. coco_framework-0.1.0/libs/checkpoint-conformance/README.md +5 -0
  34. coco_framework-0.1.0/libs/checkpoint-postgres/LICENSE +21 -0
  35. coco_framework-0.1.0/libs/checkpoint-postgres/README.md +5 -0
  36. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/__init__.py +602 -0
  37. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/_ainternal.py +23 -0
  38. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/_internal.py +21 -0
  39. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/aio.py +691 -0
  40. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/base.py +666 -0
  41. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/py.typed +0 -0
  42. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/checkpoint/postgres/shallow.py +967 -0
  43. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/store/postgres/__init__.py +4 -0
  44. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/store/postgres/aio.py +592 -0
  45. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/store/postgres/base.py +1480 -0
  46. coco_framework-0.1.0/libs/checkpoint-postgres/coco_graph/store/postgres/py.typed +0 -0
  47. coco_framework-0.1.0/libs/checkpoint-postgres/pyproject.toml +88 -0
  48. coco_framework-0.1.0/libs/checkpoint-sqlite/LICENSE +21 -0
  49. coco_framework-0.1.0/libs/checkpoint-sqlite/README.md +5 -0
  50. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/cache/sqlite/__init__.py +120 -0
  51. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/checkpoint/sqlite/__init__.py +645 -0
  52. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/checkpoint/sqlite/_delta.py +172 -0
  53. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/checkpoint/sqlite/aio.py +738 -0
  54. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/checkpoint/sqlite/py.typed +0 -0
  55. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/checkpoint/sqlite/utils.py +116 -0
  56. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/store/sqlite/__init__.py +4 -0
  57. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/store/sqlite/aio.py +632 -0
  58. coco_framework-0.1.0/libs/checkpoint-sqlite/coco_graph/store/sqlite/base.py +1514 -0
  59. coco_framework-0.1.0/libs/checkpoint-sqlite/pyproject.toml +90 -0
  60. coco_framework-0.1.0/libs/coco_graph/LICENSE +21 -0
  61. coco_framework-0.1.0/libs/coco_graph/README.md +5 -0
  62. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/__init__.py +4 -0
  63. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_cache.py +31 -0
  64. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_config.py +474 -0
  65. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_constants.py +140 -0
  66. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_fields.py +213 -0
  67. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_future.py +220 -0
  68. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_pydantic.py +275 -0
  69. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_queue.py +124 -0
  70. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_replay.py +90 -0
  71. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_retry.py +29 -0
  72. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_runnable.py +969 -0
  73. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_scratchpad.py +19 -0
  74. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_serde.py +253 -0
  75. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_timeout.py +25 -0
  76. coco_framework-0.1.0/libs/coco_graph/coco_graph/_internal/_typing.py +54 -0
  77. coco_framework-0.1.0/libs/coco_graph/coco_graph/callbacks.py +394 -0
  78. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/__init__.py +29 -0
  79. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/any_value.py +72 -0
  80. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/base.py +121 -0
  81. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/binop.py +155 -0
  82. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/delta.py +202 -0
  83. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/ephemeral_value.py +79 -0
  84. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/last_value.py +151 -0
  85. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/named_barrier_value.py +167 -0
  86. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/topic.py +94 -0
  87. coco_framework-0.1.0/libs/coco_graph/coco_graph/channels/untracked_value.py +73 -0
  88. coco_framework-0.1.0/libs/coco_graph/coco_graph/config.py +196 -0
  89. coco_framework-0.1.0/libs/coco_graph/coco_graph/constants.py +64 -0
  90. coco_framework-0.1.0/libs/coco_graph/coco_graph/errors.py +241 -0
  91. coco_framework-0.1.0/libs/coco_graph/coco_graph/func/__init__.py +620 -0
  92. coco_framework-0.1.0/libs/coco_graph/coco_graph/graph/__init__.py +12 -0
  93. coco_framework-0.1.0/libs/coco_graph/coco_graph/graph/_branch.py +225 -0
  94. coco_framework-0.1.0/libs/coco_graph/coco_graph/graph/_node.py +103 -0
  95. coco_framework-0.1.0/libs/coco_graph/coco_graph/graph/message.py +437 -0
  96. coco_framework-0.1.0/libs/coco_graph/coco_graph/graph/state.py +1978 -0
  97. coco_framework-0.1.0/libs/coco_graph/coco_graph/graph/ui.py +227 -0
  98. coco_framework-0.1.0/libs/coco_graph/coco_graph/managed/__init__.py +3 -0
  99. coco_framework-0.1.0/libs/coco_graph/coco_graph/managed/base.py +31 -0
  100. coco_framework-0.1.0/libs/coco_graph/coco_graph/managed/is_last_step.py +24 -0
  101. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/__init__.py +3 -0
  102. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_algo.py +1460 -0
  103. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_call.py +298 -0
  104. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_checkpoint.py +331 -0
  105. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_config.py +0 -0
  106. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_draw.py +294 -0
  107. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_executor.py +223 -0
  108. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_io.py +174 -0
  109. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_log.py +3 -0
  110. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_loop.py +1988 -0
  111. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_messages.py +461 -0
  112. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_read.py +312 -0
  113. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_retry.py +854 -0
  114. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_runner.py +941 -0
  115. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_tools.py +268 -0
  116. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_utils.py +221 -0
  117. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_validate.py +120 -0
  118. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/_write.py +192 -0
  119. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/debug.py +302 -0
  120. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/main.py +4364 -0
  121. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/protocol.py +288 -0
  122. coco_framework-0.1.0/libs/coco_graph/coco_graph/pregel/types.py +38 -0
  123. coco_framework-0.1.0/libs/coco_graph/coco_graph/py.typed +0 -0
  124. coco_framework-0.1.0/libs/coco_graph/coco_graph/runtime.py +350 -0
  125. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/__init__.py +45 -0
  126. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/_convert.py +32 -0
  127. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/_mux.py +523 -0
  128. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/_types.py +330 -0
  129. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/run_stream.py +735 -0
  130. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/stream_channel.py +341 -0
  131. coco_framework-0.1.0/libs/coco_graph/coco_graph/stream/transformers.py +1039 -0
  132. coco_framework-0.1.0/libs/coco_graph/coco_graph/types.py +1079 -0
  133. coco_framework-0.1.0/libs/coco_graph/coco_graph/typing.py +48 -0
  134. coco_framework-0.1.0/libs/coco_graph/coco_graph/utils/__init__.py +1 -0
  135. coco_framework-0.1.0/libs/coco_graph/coco_graph/utils/config.py +4 -0
  136. coco_framework-0.1.0/libs/coco_graph/coco_graph/utils/runnable.py +3 -0
  137. coco_framework-0.1.0/libs/coco_graph/coco_graph/version.py +13 -0
  138. coco_framework-0.1.0/libs/coco_graph/coco_graph/warnings.py +69 -0
  139. coco_framework-0.1.0/libs/coco_graph/pyproject.toml +130 -0
  140. coco_framework-0.1.0/libs/coco_v1/LICENSE +21 -0
  141. coco_framework-0.1.0/libs/coco_v1/README.md +5 -0
  142. coco_framework-0.1.0/libs/coco_v1/coco/__init__.py +3 -0
  143. coco_framework-0.1.0/libs/coco_v1/coco/agents/__init__.py +9 -0
  144. coco_framework-0.1.0/libs/coco_v1/coco/agents/_subagent_transformer.py +307 -0
  145. coco_framework-0.1.0/libs/coco_v1/coco/agents/factory.py +2164 -0
  146. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/__init__.py +100 -0
  147. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/_execution.py +385 -0
  148. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/_redaction.py +454 -0
  149. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/_retry.py +134 -0
  150. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/_trace_policy.py +61 -0
  151. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/context_editing.py +306 -0
  152. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/file_search.py +433 -0
  153. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/human_in_the_loop.py +680 -0
  154. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/internal_call_transformer.py +108 -0
  155. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/model_call_limit.py +267 -0
  156. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/model_fallback.py +417 -0
  157. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/model_retry.py +327 -0
  158. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/pii.py +878 -0
  159. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/provider_tool_search.py +307 -0
  160. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/shell_tool.py +949 -0
  161. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/summarization.py +910 -0
  162. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/todo.py +357 -0
  163. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/tool_call_limit.py +495 -0
  164. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/tool_emulator.py +251 -0
  165. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/tool_error.py +209 -0
  166. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/tool_retry.py +421 -0
  167. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/tool_selection.py +515 -0
  168. coco_framework-0.1.0/libs/coco_v1/coco/agents/middleware/types.py +2201 -0
  169. coco_framework-0.1.0/libs/coco_v1/coco/agents/structured_output.py +472 -0
  170. coco_framework-0.1.0/libs/coco_v1/coco/chat_models/__init__.py +7 -0
  171. coco_framework-0.1.0/libs/coco_v1/coco/chat_models/base.py +1082 -0
  172. coco_framework-0.1.0/libs/coco_v1/coco/embeddings/__init__.py +18 -0
  173. coco_framework-0.1.0/libs/coco_v1/coco/embeddings/base.py +279 -0
  174. coco_framework-0.1.0/libs/coco_v1/coco/mcp/__init__.py +36 -0
  175. coco_framework-0.1.0/libs/coco_v1/coco/mcp/adapter.py +245 -0
  176. coco_framework-0.1.0/libs/coco_v1/coco/mcp/elicitation.py +394 -0
  177. coco_framework-0.1.0/libs/coco_v1/coco/mcp/tools.py +307 -0
  178. coco_framework-0.1.0/libs/coco_v1/coco/messages/__init__.py +73 -0
  179. coco_framework-0.1.0/libs/coco_v1/coco/py.typed +0 -0
  180. coco_framework-0.1.0/libs/coco_v1/coco/rate_limiters/__init__.py +13 -0
  181. coco_framework-0.1.0/libs/coco_v1/coco/tools/__init__.py +22 -0
  182. coco_framework-0.1.0/libs/coco_v1/coco/tools/tool_node.py +20 -0
  183. coco_framework-0.1.0/libs/coco_v1/examples/mcp/README.md +31 -0
  184. coco_framework-0.1.0/libs/coco_v1/pyproject.toml +170 -0
  185. coco_framework-0.1.0/libs/core/LICENSE +21 -0
  186. coco_framework-0.1.0/libs/core/README.md +5 -0
  187. coco_framework-0.1.0/libs/core/coco_core/__init__.py +20 -0
  188. coco_framework-0.1.0/libs/core/coco_core/_api/__init__.py +87 -0
  189. coco_framework-0.1.0/libs/core/coco_core/_api/beta_decorator.py +266 -0
  190. coco_framework-0.1.0/libs/core/coco_core/_api/deprecation.py +637 -0
  191. coco_framework-0.1.0/libs/core/coco_core/_api/internal.py +23 -0
  192. coco_framework-0.1.0/libs/core/coco_core/_api/path.py +50 -0
  193. coco_framework-0.1.0/libs/core/coco_core/_import_utils.py +41 -0
  194. coco_framework-0.1.0/libs/core/coco_core/_protocol.py +625 -0
  195. coco_framework-0.1.0/libs/core/coco_core/_security/__init__.py +36 -0
  196. coco_framework-0.1.0/libs/core/coco_core/_security/_exceptions.py +9 -0
  197. coco_framework-0.1.0/libs/core/coco_core/_security/_policy.py +313 -0
  198. coco_framework-0.1.0/libs/core/coco_core/_security/_ssrf_protection.py +155 -0
  199. coco_framework-0.1.0/libs/core/coco_core/_security/_transport.py +254 -0
  200. coco_framework-0.1.0/libs/core/coco_core/agents.py +258 -0
  201. coco_framework-0.1.0/libs/core/coco_core/caches.py +272 -0
  202. coco_framework-0.1.0/libs/core/coco_core/callbacks/__init__.py +132 -0
  203. coco_framework-0.1.0/libs/core/coco_core/callbacks/base.py +1229 -0
  204. coco_framework-0.1.0/libs/core/coco_core/callbacks/file.py +266 -0
  205. coco_framework-0.1.0/libs/core/coco_core/callbacks/manager.py +2826 -0
  206. coco_framework-0.1.0/libs/core/coco_core/callbacks/stdout.py +123 -0
  207. coco_framework-0.1.0/libs/core/coco_core/callbacks/streaming_stdout.py +154 -0
  208. coco_framework-0.1.0/libs/core/coco_core/callbacks/usage.py +124 -0
  209. coco_framework-0.1.0/libs/core/coco_core/chat_history.py +267 -0
  210. coco_framework-0.1.0/libs/core/coco_core/chat_loaders.py +26 -0
  211. coco_framework-0.1.0/libs/core/coco_core/chat_sessions.py +19 -0
  212. coco_framework-0.1.0/libs/core/coco_core/cross_encoders.py +18 -0
  213. coco_framework-0.1.0/libs/core/coco_core/document_loaders/__init__.py +36 -0
  214. coco_framework-0.1.0/libs/core/coco_core/document_loaders/base.py +155 -0
  215. coco_framework-0.1.0/libs/core/coco_core/document_loaders/blob_loaders.py +38 -0
  216. coco_framework-0.1.0/libs/core/coco_core/documents/__init__.py +55 -0
  217. coco_framework-0.1.0/libs/core/coco_core/documents/base.py +347 -0
  218. coco_framework-0.1.0/libs/core/coco_core/documents/compressor.py +74 -0
  219. coco_framework-0.1.0/libs/core/coco_core/documents/transformers.py +79 -0
  220. coco_framework-0.1.0/libs/core/coco_core/embeddings/__init__.py +31 -0
  221. coco_framework-0.1.0/libs/core/coco_core/embeddings/embeddings.py +78 -0
  222. coco_framework-0.1.0/libs/core/coco_core/embeddings/fake.py +129 -0
  223. coco_framework-0.1.0/libs/core/coco_core/env.py +22 -0
  224. coco_framework-0.1.0/libs/core/coco_core/example_selectors/__init__.py +47 -0
  225. coco_framework-0.1.0/libs/core/coco_core/example_selectors/base.py +60 -0
  226. coco_framework-0.1.0/libs/core/coco_core/example_selectors/length_based.py +131 -0
  227. coco_framework-0.1.0/libs/core/coco_core/example_selectors/semantic_similarity.py +366 -0
  228. coco_framework-0.1.0/libs/core/coco_core/exceptions.py +166 -0
  229. coco_framework-0.1.0/libs/core/coco_core/globals.py +72 -0
  230. coco_framework-0.1.0/libs/core/coco_core/indexing/__init__.py +53 -0
  231. coco_framework-0.1.0/libs/core/coco_core/indexing/api.py +954 -0
  232. coco_framework-0.1.0/libs/core/coco_core/indexing/base.py +661 -0
  233. coco_framework-0.1.0/libs/core/coco_core/indexing/in_memory.py +104 -0
  234. coco_framework-0.1.0/libs/core/coco_core/language_models/__init__.py +116 -0
  235. coco_framework-0.1.0/libs/core/coco_core/language_models/_compat_bridge.py +844 -0
  236. coco_framework-0.1.0/libs/core/coco_core/language_models/_utils.py +343 -0
  237. coco_framework-0.1.0/libs/core/coco_core/language_models/base.py +500 -0
  238. coco_framework-0.1.0/libs/core/coco_core/language_models/chat_model_stream.py +1525 -0
  239. coco_framework-0.1.0/libs/core/coco_core/language_models/chat_models.py +2748 -0
  240. coco_framework-0.1.0/libs/core/coco_core/language_models/fake.py +137 -0
  241. coco_framework-0.1.0/libs/core/coco_core/language_models/fake_chat_models.py +396 -0
  242. coco_framework-0.1.0/libs/core/coco_core/language_models/llms.py +1569 -0
  243. coco_framework-0.1.0/libs/core/coco_core/language_models/model_profile.py +183 -0
  244. coco_framework-0.1.0/libs/core/coco_core/load/__init__.py +44 -0
  245. coco_framework-0.1.0/libs/core/coco_core/load/_validation.py +191 -0
  246. coco_framework-0.1.0/libs/core/coco_core/load/dump.py +120 -0
  247. coco_framework-0.1.0/libs/core/coco_core/load/load.py +828 -0
  248. coco_framework-0.1.0/libs/core/coco_core/load/mapping.py +1097 -0
  249. coco_framework-0.1.0/libs/core/coco_core/load/serializable.py +406 -0
  250. coco_framework-0.1.0/libs/core/coco_core/messages/__init__.py +198 -0
  251. coco_framework-0.1.0/libs/core/coco_core/messages/ai.py +854 -0
  252. coco_framework-0.1.0/libs/core/coco_core/messages/base.py +518 -0
  253. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/__init__.py +112 -0
  254. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/anthropic.py +534 -0
  255. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/bedrock.py +108 -0
  256. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/bedrock_converse.py +329 -0
  257. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/coco_v0.py +303 -0
  258. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/google_genai.py +610 -0
  259. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/google_vertexai.py +21 -0
  260. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/groq.py +157 -0
  261. coco_framework-0.1.0/libs/core/coco_core/messages/block_translators/openai.py +1089 -0
  262. coco_framework-0.1.0/libs/core/coco_core/messages/chat.py +64 -0
  263. coco_framework-0.1.0/libs/core/coco_core/messages/content.py +1488 -0
  264. coco_framework-0.1.0/libs/core/coco_core/messages/function.py +62 -0
  265. coco_framework-0.1.0/libs/core/coco_core/messages/human.py +70 -0
  266. coco_framework-0.1.0/libs/core/coco_core/messages/modifier.py +33 -0
  267. coco_framework-0.1.0/libs/core/coco_core/messages/system.py +70 -0
  268. coco_framework-0.1.0/libs/core/coco_core/messages/tool.py +418 -0
  269. coco_framework-0.1.0/libs/core/coco_core/messages/utils.py +2442 -0
  270. coco_framework-0.1.0/libs/core/coco_core/output_parsers/__init__.py +101 -0
  271. coco_framework-0.1.0/libs/core/coco_core/output_parsers/base.py +361 -0
  272. coco_framework-0.1.0/libs/core/coco_core/output_parsers/format_instructions.py +16 -0
  273. coco_framework-0.1.0/libs/core/coco_core/output_parsers/json.py +139 -0
  274. coco_framework-0.1.0/libs/core/coco_core/output_parsers/list.py +249 -0
  275. coco_framework-0.1.0/libs/core/coco_core/output_parsers/openai_functions.py +324 -0
  276. coco_framework-0.1.0/libs/core/coco_core/output_parsers/openai_tools.py +383 -0
  277. coco_framework-0.1.0/libs/core/coco_core/output_parsers/pydantic.py +141 -0
  278. coco_framework-0.1.0/libs/core/coco_core/output_parsers/string.py +63 -0
  279. coco_framework-0.1.0/libs/core/coco_core/output_parsers/transform.py +175 -0
  280. coco_framework-0.1.0/libs/core/coco_core/output_parsers/xml.py +301 -0
  281. coco_framework-0.1.0/libs/core/coco_core/outputs/__init__.py +66 -0
  282. coco_framework-0.1.0/libs/core/coco_core/outputs/chat_generation.py +147 -0
  283. coco_framework-0.1.0/libs/core/coco_core/outputs/chat_result.py +39 -0
  284. coco_framework-0.1.0/libs/core/coco_core/outputs/generation.py +80 -0
  285. coco_framework-0.1.0/libs/core/coco_core/outputs/llm_result.py +112 -0
  286. coco_framework-0.1.0/libs/core/coco_core/outputs/run_info.py +22 -0
  287. coco_framework-0.1.0/libs/core/coco_core/prompt_values.py +161 -0
  288. coco_framework-0.1.0/libs/core/coco_core/prompts/__init__.py +101 -0
  289. coco_framework-0.1.0/libs/core/coco_core/prompts/base.py +508 -0
  290. coco_framework-0.1.0/libs/core/coco_core/prompts/chat.py +1495 -0
  291. coco_framework-0.1.0/libs/core/coco_core/prompts/dict.py +177 -0
  292. coco_framework-0.1.0/libs/core/coco_core/prompts/few_shot.py +483 -0
  293. coco_framework-0.1.0/libs/core/coco_core/prompts/few_shot_with_templates.py +239 -0
  294. coco_framework-0.1.0/libs/core/coco_core/prompts/image.py +177 -0
  295. coco_framework-0.1.0/libs/core/coco_core/prompts/loading.py +296 -0
  296. coco_framework-0.1.0/libs/core/coco_core/prompts/message.py +97 -0
  297. coco_framework-0.1.0/libs/core/coco_core/prompts/prompt.py +312 -0
  298. coco_framework-0.1.0/libs/core/coco_core/prompts/string.py +399 -0
  299. coco_framework-0.1.0/libs/core/coco_core/prompts/structured.py +214 -0
  300. coco_framework-0.1.0/libs/core/coco_core/py.typed +0 -0
  301. coco_framework-0.1.0/libs/core/coco_core/rate_limiters.py +254 -0
  302. coco_framework-0.1.0/libs/core/coco_core/retrievers.py +328 -0
  303. coco_framework-0.1.0/libs/core/coco_core/runnables/__init__.py +136 -0
  304. coco_framework-0.1.0/libs/core/coco_core/runnables/base.py +6725 -0
  305. coco_framework-0.1.0/libs/core/coco_core/runnables/branch.py +457 -0
  306. coco_framework-0.1.0/libs/core/coco_core/runnables/config.py +712 -0
  307. coco_framework-0.1.0/libs/core/coco_core/runnables/configurable.py +710 -0
  308. coco_framework-0.1.0/libs/core/coco_core/runnables/fallbacks.py +663 -0
  309. coco_framework-0.1.0/libs/core/coco_core/runnables/graph.py +741 -0
  310. coco_framework-0.1.0/libs/core/coco_core/runnables/graph_ascii.py +366 -0
  311. coco_framework-0.1.0/libs/core/coco_core/runnables/graph_mermaid.py +503 -0
  312. coco_framework-0.1.0/libs/core/coco_core/runnables/graph_png.py +215 -0
  313. coco_framework-0.1.0/libs/core/coco_core/runnables/history.py +631 -0
  314. coco_framework-0.1.0/libs/core/coco_core/runnables/passthrough.py +849 -0
  315. coco_framework-0.1.0/libs/core/coco_core/runnables/retry.py +379 -0
  316. coco_framework-0.1.0/libs/core/coco_core/runnables/router.py +239 -0
  317. coco_framework-0.1.0/libs/core/coco_core/runnables/schema.py +188 -0
  318. coco_framework-0.1.0/libs/core/coco_core/runnables/utils.py +798 -0
  319. coco_framework-0.1.0/libs/core/coco_core/stores.py +291 -0
  320. coco_framework-0.1.0/libs/core/coco_core/structured_query.py +203 -0
  321. coco_framework-0.1.0/libs/core/coco_core/sys_info.py +154 -0
  322. coco_framework-0.1.0/libs/core/coco_core/tools/__init__.py +95 -0
  323. coco_framework-0.1.0/libs/core/coco_core/tools/base.py +1948 -0
  324. coco_framework-0.1.0/libs/core/coco_core/tools/convert.py +497 -0
  325. coco_framework-0.1.0/libs/core/coco_core/tools/render.py +67 -0
  326. coco_framework-0.1.0/libs/core/coco_core/tools/retriever.py +94 -0
  327. coco_framework-0.1.0/libs/core/coco_core/tools/simple.py +208 -0
  328. coco_framework-0.1.0/libs/core/coco_core/tools/structured.py +322 -0
  329. coco_framework-0.1.0/libs/core/coco_core/tracers/__init__.py +47 -0
  330. coco_framework-0.1.0/libs/core/coco_core/tracers/_compat.py +95 -0
  331. coco_framework-0.1.0/libs/core/coco_core/tracers/_context.py +337 -0
  332. coco_framework-0.1.0/libs/core/coco_core/tracers/_streaming.py +53 -0
  333. coco_framework-0.1.0/libs/core/coco_core/tracers/base.py +955 -0
  334. coco_framework-0.1.0/libs/core/coco_core/tracers/coco.py +279 -0
  335. coco_framework-0.1.0/libs/core/coco_core/tracers/context.py +205 -0
  336. coco_framework-0.1.0/libs/core/coco_core/tracers/core.py +766 -0
  337. coco_framework-0.1.0/libs/core/coco_core/tracers/event_stream.py +1101 -0
  338. coco_framework-0.1.0/libs/core/coco_core/tracers/log_stream.py +765 -0
  339. coco_framework-0.1.0/libs/core/coco_core/tracers/memory_stream.py +200 -0
  340. coco_framework-0.1.0/libs/core/coco_core/tracers/root_listeners.py +130 -0
  341. coco_framework-0.1.0/libs/core/coco_core/tracers/run_collector.py +40 -0
  342. coco_framework-0.1.0/libs/core/coco_core/tracers/schemas.py +14 -0
  343. coco_framework-0.1.0/libs/core/coco_core/tracers/stdout.py +205 -0
  344. coco_framework-0.1.0/libs/core/coco_core/utils/__init__.py +111 -0
  345. coco_framework-0.1.0/libs/core/coco_core/utils/_gateway.py +274 -0
  346. coco_framework-0.1.0/libs/core/coco_core/utils/_merge.py +218 -0
  347. coco_framework-0.1.0/libs/core/coco_core/utils/aiter.py +357 -0
  348. coco_framework-0.1.0/libs/core/coco_core/utils/env.py +86 -0
  349. coco_framework-0.1.0/libs/core/coco_core/utils/formatting.py +80 -0
  350. coco_framework-0.1.0/libs/core/coco_core/utils/function_calling.py +869 -0
  351. coco_framework-0.1.0/libs/core/coco_core/utils/html.py +132 -0
  352. coco_framework-0.1.0/libs/core/coco_core/utils/image.py +15 -0
  353. coco_framework-0.1.0/libs/core/coco_core/utils/input.py +82 -0
  354. coco_framework-0.1.0/libs/core/coco_core/utils/interactive_env.py +12 -0
  355. coco_framework-0.1.0/libs/core/coco_core/utils/iter.py +229 -0
  356. coco_framework-0.1.0/libs/core/coco_core/utils/json.py +230 -0
  357. coco_framework-0.1.0/libs/core/coco_core/utils/json_schema.py +273 -0
  358. coco_framework-0.1.0/libs/core/coco_core/utils/mustache.py +706 -0
  359. coco_framework-0.1.0/libs/core/coco_core/utils/pydantic.py +631 -0
  360. coco_framework-0.1.0/libs/core/coco_core/utils/strings.py +69 -0
  361. coco_framework-0.1.0/libs/core/coco_core/utils/usage.py +61 -0
  362. coco_framework-0.1.0/libs/core/coco_core/utils/utils.py +528 -0
  363. coco_framework-0.1.0/libs/core/coco_core/utils/uuid.py +57 -0
  364. coco_framework-0.1.0/libs/core/coco_core/vectorstores/__init__.py +53 -0
  365. coco_framework-0.1.0/libs/core/coco_core/vectorstores/base.py +1111 -0
  366. coco_framework-0.1.0/libs/core/coco_core/vectorstores/in_memory.py +546 -0
  367. coco_framework-0.1.0/libs/core/coco_core/vectorstores/utils.py +163 -0
  368. coco_framework-0.1.0/libs/core/coco_core/version.py +3 -0
  369. coco_framework-0.1.0/libs/core/pyproject.toml +144 -0
  370. coco_framework-0.1.0/libs/partners/anthropic/LICENSE +21 -0
  371. coco_framework-0.1.0/libs/partners/anthropic/README.md +5 -0
  372. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/__init__.py +15 -0
  373. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/_client_utils.py +81 -0
  374. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/_compat.py +228 -0
  375. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/_sdk_compat.py +124 -0
  376. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/_version.py +3 -0
  377. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/chat_models.py +3349 -0
  378. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/data/__init__.py +1 -0
  379. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/data/_profiles.py +491 -0
  380. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/data/profile_augmentations.toml +69 -0
  381. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/experimental.py +140 -0
  382. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/llms.py +428 -0
  383. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/middleware/__init__.py +25 -0
  384. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/middleware/anthropic_tools.py +1197 -0
  385. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/middleware/bash.py +84 -0
  386. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/middleware/file_search.py +360 -0
  387. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/middleware/prompt_caching.py +276 -0
  388. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/output_parsers.py +93 -0
  389. coco_framework-0.1.0/libs/partners/anthropic/coco_anthropic/py.typed +0 -0
  390. coco_framework-0.1.0/libs/partners/anthropic/pyproject.toml +146 -0
  391. coco_framework-0.1.0/libs/partners/openai/LICENSE +21 -0
  392. coco_framework-0.1.0/libs/partners/openai/README.md +5 -0
  393. coco_framework-0.1.0/libs/partners/openai/coco_openai/__init__.py +20 -0
  394. coco_framework-0.1.0/libs/partners/openai/coco_openai/_compat.py +45 -0
  395. coco_framework-0.1.0/libs/partners/openai/coco_openai/_version.py +3 -0
  396. coco_framework-0.1.0/libs/partners/openai/coco_openai/chat_models/__init__.py +6 -0
  397. coco_framework-0.1.0/libs/partners/openai/coco_openai/chat_models/_client_utils.py +684 -0
  398. coco_framework-0.1.0/libs/partners/openai/coco_openai/chat_models/_compat.py +525 -0
  399. coco_framework-0.1.0/libs/partners/openai/coco_openai/chat_models/azure.py +1227 -0
  400. coco_framework-0.1.0/libs/partners/openai/coco_openai/chat_models/base.py +5654 -0
  401. coco_framework-0.1.0/libs/partners/openai/coco_openai/chat_models/codex.py +557 -0
  402. coco_framework-0.1.0/libs/partners/openai/coco_openai/chatgpt_oauth.py +1063 -0
  403. coco_framework-0.1.0/libs/partners/openai/coco_openai/data/__init__.py +1 -0
  404. coco_framework-0.1.0/libs/partners/openai/coco_openai/data/_profiles.py +1655 -0
  405. coco_framework-0.1.0/libs/partners/openai/coco_openai/data/profile_augmentations.toml +127 -0
  406. coco_framework-0.1.0/libs/partners/openai/coco_openai/embeddings/__init__.py +6 -0
  407. coco_framework-0.1.0/libs/partners/openai/coco_openai/embeddings/azure.py +240 -0
  408. coco_framework-0.1.0/libs/partners/openai/coco_openai/embeddings/base.py +820 -0
  409. coco_framework-0.1.0/libs/partners/openai/coco_openai/llms/__init__.py +6 -0
  410. coco_framework-0.1.0/libs/partners/openai/coco_openai/llms/azure.py +249 -0
  411. coco_framework-0.1.0/libs/partners/openai/coco_openai/llms/base.py +919 -0
  412. coco_framework-0.1.0/libs/partners/openai/coco_openai/middleware/__init__.py +11 -0
  413. coco_framework-0.1.0/libs/partners/openai/coco_openai/middleware/openai_moderation.py +484 -0
  414. coco_framework-0.1.0/libs/partners/openai/coco_openai/output_parsers/__init__.py +9 -0
  415. coco_framework-0.1.0/libs/partners/openai/coco_openai/output_parsers/tools.py +9 -0
  416. coco_framework-0.1.0/libs/partners/openai/coco_openai/py.typed +0 -0
  417. coco_framework-0.1.0/libs/partners/openai/coco_openai/tools/__init__.py +5 -0
  418. coco_framework-0.1.0/libs/partners/openai/coco_openai/tools/custom_tool.py +111 -0
  419. coco_framework-0.1.0/libs/partners/openai/pyproject.toml +173 -0
  420. coco_framework-0.1.0/libs/prebuilt/LICENSE +21 -0
  421. coco_framework-0.1.0/libs/prebuilt/README.md +5 -0
  422. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/__init__.py +23 -0
  423. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/_tool_call_stream.py +117 -0
  424. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/_tool_call_transformer.py +165 -0
  425. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/chat_agent_executor.py +1015 -0
  426. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/interrupt.py +105 -0
  427. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/py.typed +0 -0
  428. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/tool_node.py +2030 -0
  429. coco_framework-0.1.0/libs/prebuilt/coco_graph/prebuilt/tool_validator.py +221 -0
  430. coco_framework-0.1.0/libs/prebuilt/pyproject.toml +101 -0
  431. coco_framework-0.1.0/libs/standard-tests/LICENSE +21 -0
  432. coco_framework-0.1.0/libs/standard-tests/README.md +5 -0
  433. coco_framework-0.1.0/pyproject.toml +172 -0
  434. coco_framework-0.1.0/scripts/build.py +234 -0
  435. coco_framework-0.1.0/scripts/dev.sh +70 -0
  436. coco_framework-0.1.0/scripts/sync_upstream.py +441 -0
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .coverage
8
+ .coverage.*
9
+ htmlcov/
10
+ *.egg-info/
11
+ *.whl
12
+ *.tar.gz
13
+ dist/
14
+ build/
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) LangChain, Inc.
4
+ Copyright (c) 2024 LangChain, Inc.
5
+ Copyright (c) 2026 Coco AI Pty Ltd
6
+
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ coco-framework
2
+
3
+ Everything under libs/ is derived from two MIT-licensed projects and renamed by
4
+ scripts/sync_upstream.py:
5
+
6
+ langchain-ai/langchain Copyright (c) LangChain, Inc.
7
+ langchain-ai/langgraph Copyright (c) 2024 LangChain, Inc.
8
+
9
+ libs/core/coco_core/_protocol.py is vendored from langchain-protocol 0.0.19,
10
+ Copyright (c) 2026 LangChain, Inc., MIT.
11
+
12
+ Each library under libs/ keeps its upstream LICENSE file unchanged. UPSTREAM.md
13
+ records the commit each library was taken from and every patch applied after
14
+ the rename. Changes are Copyright (c) 2026 Coco AI Pty Ltd, under the same MIT
15
+ licence.
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.5
2
+ Name: coco-framework
3
+ Version: 0.1.0
4
+ Summary: The agent runtime for Coco: core messages, tools, runnables, stateful agent graphs, checkpointers, and model integrations.
5
+ Project-URL: Homepage, https://trustcoco.ai
6
+ Project-URL: Repository, https://github.com/coco-ai-au/coco-framework
7
+ License: MIT License
8
+
9
+ Copyright (c) LangChain, Inc.
10
+ Copyright (c) 2024 LangChain, Inc.
11
+ Copyright (c) 2026 Coco AI Pty Ltd
12
+
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ License-File: NOTICE
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3 :: Only
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Programming Language :: Python :: 3.13
42
+ Classifier: Programming Language :: Python :: 3.14
43
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
44
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
45
+ Requires-Python: <4.0.0,>=3.10.0
46
+ Requires-Dist: aiosqlite>=0.20.0
47
+ Requires-Dist: anthropic<2.0.0,>=0.120.0
48
+ Requires-Dist: jsonpatch<2.0.0,>=1.33.0
49
+ Requires-Dist: openai<4.0.0,>=2.26.0
50
+ Requires-Dist: ormsgpack>=1.12.0
51
+ Requires-Dist: packaging<27.0.0,>=23.2.0
52
+ Requires-Dist: pydantic<3.0.0,>=2.7.4
53
+ Requires-Dist: pyyaml<7.0.0,>=5.3.0
54
+ Requires-Dist: sqlite-vec>=0.1.6
55
+ Requires-Dist: tenacity!=8.4.0,<10.0.0,>=8.1.0
56
+ Requires-Dist: tiktoken<1.0.0,>=0.7.0
57
+ Requires-Dist: typing-extensions<5.0.0,>=4.7.0
58
+ Requires-Dist: uuid-utils<1.0,>=0.12.0
59
+ Requires-Dist: xxhash>=3.5.0
60
+ Provides-Extra: all
61
+ Requires-Dist: aiosqlite>=0.20.0; extra == 'all'
62
+ Requires-Dist: anthropic<2.0.0,>=0.120.0; extra == 'all'
63
+ Requires-Dist: azure-identity<2.0.0,>=1.15.0; extra == 'all'
64
+ Requires-Dist: fastmcp<4.0.0,>=3.1.1; extra == 'all'
65
+ Requires-Dist: openai<4.0.0,>=2.26.0; extra == 'all'
66
+ Requires-Dist: ormsgpack>=1.12.0; extra == 'all'
67
+ Requires-Dist: psycopg-pool>=3.2.0; extra == 'all'
68
+ Requires-Dist: psycopg>=3.2.0; extra == 'all'
69
+ Requires-Dist: sqlite-vec>=0.1.6; extra == 'all'
70
+ Requires-Dist: tiktoken<1.0.0,>=0.7.0; extra == 'all'
71
+ Provides-Extra: anthropic
72
+ Requires-Dist: anthropic<2.0.0,>=0.120.0; extra == 'anthropic'
73
+ Provides-Extra: azure-identity
74
+ Requires-Dist: azure-identity<2.0.0,>=1.15.0; extra == 'azure-identity'
75
+ Provides-Extra: mcp
76
+ Requires-Dist: fastmcp<4.0.0,>=3.1.1; extra == 'mcp'
77
+ Provides-Extra: openai
78
+ Requires-Dist: openai<4.0.0,>=2.26.0; extra == 'openai'
79
+ Requires-Dist: tiktoken<1.0.0,>=0.7.0; extra == 'openai'
80
+ Provides-Extra: postgres
81
+ Requires-Dist: ormsgpack>=1.12.0; extra == 'postgres'
82
+ Requires-Dist: psycopg-pool>=3.2.0; extra == 'postgres'
83
+ Requires-Dist: psycopg>=3.2.0; extra == 'postgres'
84
+ Provides-Extra: sqlite
85
+ Requires-Dist: aiosqlite>=0.20.0; extra == 'sqlite'
86
+ Requires-Dist: sqlite-vec>=0.1.6; extra == 'sqlite'
87
+ Description-Content-Type: text/markdown
88
+
89
+ # coco-framework
90
+
91
+ The agent runtime for Coco: LangChain and LangGraph, forked at pinned commits and
92
+ renamed to Coco by one script. Agents built on it get Coco's check on every tool
93
+ call from `../coco-sdk`.
94
+
95
+ ```python
96
+ from coco.agents import create_agent
97
+ from coco_core.tools import tool
98
+ from coco_graph.checkpoint.memory import InMemorySaver
99
+ from coco_openai import ChatOpenAI
100
+ ```
101
+
102
+ ## Install
103
+
104
+ Install the full framework directly with `pip`:
105
+
106
+ ```bash
107
+ pip install . # from a local checkout
108
+ pip install -e . # editable development install
109
+ pip install "git+https://github.com/coco-ai-au/coco-framework.git"
110
+ ```
111
+
112
+ Or use the coco-sdk environment, which installs every library here:
113
+
114
+ ```bash
115
+ cd ../coco-sdk && uv sync && source .venv/bin/activate
116
+ ```
117
+
118
+ To work on the fork itself or build and publish the distributions:
119
+
120
+ ```bash
121
+ python3 scripts/sync_upstream.py --report # rebuild libs/ from the pins, list leftover upstream names
122
+ scripts/dev.sh setup # .venv with every library and its test/build tools
123
+ scripts/dev.sh test # each library's upstream unit tests, renamed
124
+ python3 scripts/build.py --clean # build and verify all 9 trustcoco-* wheels + sdists in dist/
125
+ python3 scripts/build.py --include-root # also build the bundled coco-framework distribution
126
+ python3 scripts/build.py --publish # upload built distributions with twine/uv
127
+ ```
128
+
129
+ `sync_upstream.py` needs the upstream clones at the pinned commits in
130
+ `build_reference/` above this folder (or `COCO_UPSTREAM_DIR`).
131
+
132
+ ## What is here
133
+
134
+ | Layer | Distribution | Import | From upstream |
135
+ |---|---|---|---|
136
+ | Core | `trustcoco-core` | `coco_core` | `langchain-core` 1.6.5 |
137
+ | Graph | `trustcoco-graph`, `-prebuilt`, `-checkpoint`, `-checkpoint-sqlite`, `-checkpoint-postgres` | `coco_graph` | `langgraph` 1.2.12 and its libraries |
138
+ | Agents | `trustcoco` | `coco` | `langchain` 1.4.2 |
139
+ | Models | `trustcoco-openai`, `trustcoco-anthropic` | `coco_openai`, `coco_anthropic` | the two partner packages |
140
+
141
+ Messages, tools, runnables and prompts; `StateGraph`, the runtime, `interrupt()`
142
+ and checkpointers; `create_agent` and its middleware; an OpenAI-compatible and an
143
+ Anthropic chat model.
144
+
145
+ Left out: upstream's hosted-platform clients (`langgraph-sdk`, the CLI,
146
+ `RemoteGraph`), its tracing client (`langsmith`, replaced by a local `CocoTracer`
147
+ that sends nothing), text splitters, community integrations and JavaScript.
148
+
149
+ ## How the fork is made
150
+
151
+ `scripts/sync_upstream.py` copies the pinned upstream libraries into `libs/`,
152
+ renames modules, distributions, classes and environment variables, removes the
153
+ hosted-platform paths, copies Coco's own files from `overlay/`, and applies
154
+ `patches/`. It runs again on every upstream bump, and a bump lands only when the
155
+ renamed upstream tests pass. Nobody edits `libs/` by hand.
156
+
157
+ [`UPSTREAM.md`](UPSTREAM.md) lists the pins, every name mapping, every removed
158
+ path, overlay file and patch with its reason, and the test results.
159
+
160
+ ## Where Coco attaches
161
+
162
+ `create_agent` runs every tool call through `wrap_tool_call`. `CocoGuard` from
163
+ coco-sdk is that middleware: it runs the call, denies it with a reason, or pauses
164
+ the graph with `interrupt()` until a person decides. The session a contract reads
165
+ is the graph's thread id. The framework carries no Coco enforcement code, which
166
+ keeps the fork mechanical.
167
+
168
+ ## Decisions
169
+
170
+ | Question | Decided |
171
+ |---|---|
172
+ | Compatibility with upstream integrations | A clean rename. Upstream partner packages import `langchain_core` and do not load here; we fork a provider when a design partner needs one |
173
+ | Package names | `trustcoco-*` distributions, `coco*` imports. PyPI on the day we open source |
174
+ | Guard on by default | Yes, once the SDK is stable: `create_agent` installs `CocoGuard` in Monitor, with a logged opt out. Not built yet |
175
+ | Upstream cadence | Pinned. Bump for a fix we need; review the gap each quarter |
176
+
177
+ Publishes as wheels to Coco's private package index by `scripts/build.py --publish`
178
+ (or `coco-sdk/scripts/publish.sh`); the install is in coco-sdk's README. PyPI on the
179
+ day we open source.
180
+
181
+ ## Licence
182
+
183
+ MIT. `LICENSE` keeps "Copyright (c) LangChain, Inc." beside ours, and `NOTICE`
184
+ names what derives from upstream. The Coco name replaces theirs everywhere else.
@@ -0,0 +1,96 @@
1
+ # coco-framework
2
+
3
+ The agent runtime for Coco: LangChain and LangGraph, forked at pinned commits and
4
+ renamed to Coco by one script. Agents built on it get Coco's check on every tool
5
+ call from `../coco-sdk`.
6
+
7
+ ```python
8
+ from coco.agents import create_agent
9
+ from coco_core.tools import tool
10
+ from coco_graph.checkpoint.memory import InMemorySaver
11
+ from coco_openai import ChatOpenAI
12
+ ```
13
+
14
+ ## Install
15
+
16
+ Install the full framework directly with `pip`:
17
+
18
+ ```bash
19
+ pip install . # from a local checkout
20
+ pip install -e . # editable development install
21
+ pip install "git+https://github.com/coco-ai-au/coco-framework.git"
22
+ ```
23
+
24
+ Or use the coco-sdk environment, which installs every library here:
25
+
26
+ ```bash
27
+ cd ../coco-sdk && uv sync && source .venv/bin/activate
28
+ ```
29
+
30
+ To work on the fork itself or build and publish the distributions:
31
+
32
+ ```bash
33
+ python3 scripts/sync_upstream.py --report # rebuild libs/ from the pins, list leftover upstream names
34
+ scripts/dev.sh setup # .venv with every library and its test/build tools
35
+ scripts/dev.sh test # each library's upstream unit tests, renamed
36
+ python3 scripts/build.py --clean # build and verify all 9 trustcoco-* wheels + sdists in dist/
37
+ python3 scripts/build.py --include-root # also build the bundled coco-framework distribution
38
+ python3 scripts/build.py --publish # upload built distributions with twine/uv
39
+ ```
40
+
41
+ `sync_upstream.py` needs the upstream clones at the pinned commits in
42
+ `build_reference/` above this folder (or `COCO_UPSTREAM_DIR`).
43
+
44
+ ## What is here
45
+
46
+ | Layer | Distribution | Import | From upstream |
47
+ |---|---|---|---|
48
+ | Core | `trustcoco-core` | `coco_core` | `langchain-core` 1.6.5 |
49
+ | Graph | `trustcoco-graph`, `-prebuilt`, `-checkpoint`, `-checkpoint-sqlite`, `-checkpoint-postgres` | `coco_graph` | `langgraph` 1.2.12 and its libraries |
50
+ | Agents | `trustcoco` | `coco` | `langchain` 1.4.2 |
51
+ | Models | `trustcoco-openai`, `trustcoco-anthropic` | `coco_openai`, `coco_anthropic` | the two partner packages |
52
+
53
+ Messages, tools, runnables and prompts; `StateGraph`, the runtime, `interrupt()`
54
+ and checkpointers; `create_agent` and its middleware; an OpenAI-compatible and an
55
+ Anthropic chat model.
56
+
57
+ Left out: upstream's hosted-platform clients (`langgraph-sdk`, the CLI,
58
+ `RemoteGraph`), its tracing client (`langsmith`, replaced by a local `CocoTracer`
59
+ that sends nothing), text splitters, community integrations and JavaScript.
60
+
61
+ ## How the fork is made
62
+
63
+ `scripts/sync_upstream.py` copies the pinned upstream libraries into `libs/`,
64
+ renames modules, distributions, classes and environment variables, removes the
65
+ hosted-platform paths, copies Coco's own files from `overlay/`, and applies
66
+ `patches/`. It runs again on every upstream bump, and a bump lands only when the
67
+ renamed upstream tests pass. Nobody edits `libs/` by hand.
68
+
69
+ [`UPSTREAM.md`](UPSTREAM.md) lists the pins, every name mapping, every removed
70
+ path, overlay file and patch with its reason, and the test results.
71
+
72
+ ## Where Coco attaches
73
+
74
+ `create_agent` runs every tool call through `wrap_tool_call`. `CocoGuard` from
75
+ coco-sdk is that middleware: it runs the call, denies it with a reason, or pauses
76
+ the graph with `interrupt()` until a person decides. The session a contract reads
77
+ is the graph's thread id. The framework carries no Coco enforcement code, which
78
+ keeps the fork mechanical.
79
+
80
+ ## Decisions
81
+
82
+ | Question | Decided |
83
+ |---|---|
84
+ | Compatibility with upstream integrations | A clean rename. Upstream partner packages import `langchain_core` and do not load here; we fork a provider when a design partner needs one |
85
+ | Package names | `trustcoco-*` distributions, `coco*` imports. PyPI on the day we open source |
86
+ | Guard on by default | Yes, once the SDK is stable: `create_agent` installs `CocoGuard` in Monitor, with a logged opt out. Not built yet |
87
+ | Upstream cadence | Pinned. Bump for a fix we need; review the gap each quarter |
88
+
89
+ Publishes as wheels to Coco's private package index by `scripts/build.py --publish`
90
+ (or `coco-sdk/scripts/publish.sh`); the install is in coco-sdk's README. PyPI on the
91
+ day we open source.
92
+
93
+ ## Licence
94
+
95
+ MIT. `LICENSE` keeps "Copyright (c) LangChain, Inc." beside ours, and `NOTICE`
96
+ names what derives from upstream. The Coco name replaces theirs everywhere else.
@@ -0,0 +1,116 @@
1
+ # Upstream
2
+
3
+ `scripts/sync_upstream.py` builds `libs/` from these pins. To move a pin, check the
4
+ clone out at the new commit, change the commit in the script and in this file, run
5
+ the script, and land the change only when the renamed tests pass.
6
+
7
+ | Upstream | Commit | Date | Versions |
8
+ |---|---|---|---|
9
+ | langchain-ai/langchain | `d750819` | 27 Sep 2026 | langchain-core 1.6.5, langchain-tests 1.1.9, langchain 1.4.2, langchain-openai 1.6.6, langchain-anthropic 1.7.4 |
10
+ | langchain-ai/langgraph | `07b3318` | 27 Sep 2026 | langgraph 1.2.12, langgraph-prebuilt 1.1.0, langgraph-checkpoint 4.2.0 |
11
+
12
+ | Folder | Distribution | Import | From |
13
+ |---|---|---|---|
14
+ | `libs/core` | `trustcoco-core` | `coco_core` | `langchain/libs/core` |
15
+ | `libs/standard-tests` | `trustcoco-tests`, test only | `coco_tests` | `langchain/libs/standard-tests` |
16
+ | `libs/coco_graph` | `trustcoco-graph` | `coco_graph` | `langgraph/libs/langgraph` |
17
+ | `libs/checkpoint` | `trustcoco-graph-checkpoint` | `coco_graph.checkpoint` | `langgraph/libs/checkpoint` |
18
+ | `libs/checkpoint-sqlite` | `trustcoco-graph-checkpoint-sqlite` | `coco_graph.checkpoint.sqlite` | `langgraph/libs/checkpoint-sqlite` |
19
+ | `libs/checkpoint-postgres` | `trustcoco-graph-checkpoint-postgres` | `coco_graph.checkpoint.postgres` | `langgraph/libs/checkpoint-postgres` |
20
+ | `libs/checkpoint-conformance` | `trustcoco-graph-checkpoint-conformance`, test only | `coco_graph.checkpoint.conformance` | `langgraph/libs/checkpoint-conformance` |
21
+ | `libs/prebuilt` | `trustcoco-graph-prebuilt` | `coco_graph.prebuilt` | `langgraph/libs/prebuilt` |
22
+ | `libs/coco_v1` | `trustcoco` | `coco` | `langchain/libs/langchain_v1` |
23
+ | `libs/partners/openai` | `trustcoco-openai` | `coco_openai` | `langchain/libs/partners/openai` |
24
+ | `libs/partners/anthropic` | `trustcoco-anthropic` | `coco_anthropic` | `langchain/libs/partners/anthropic` |
25
+
26
+ Folder names are upstream's after the rename, so the relative paths upstream writes
27
+ between its libraries still resolve. Versions follow upstream's until we cut our own,
28
+ so the ranges between libraries keep resolving.
29
+
30
+ ## What the rename does
31
+
32
+ - Module names: `langchain_core` to `coco_core`, `langgraph` to `coco_graph`,
33
+ `langchain` to `coco`, `langchain_openai` to `coco_openai` and so on.
34
+ - Distribution names: `langchain-*` to `trustcoco-*`, `langgraph-*` to
35
+ `trustcoco-graph-*`, `langchain` to `trustcoco`, `langgraph` to `trustcoco-graph`.
36
+ - Class and constant names: `LangChain` to `Coco`, `LangGraph` to `CocoGraph`,
37
+ `LANGCHAIN_` to `COCO_`, `LANGGRAPH_` to `COCO_GRAPH_`.
38
+ - Kept as written: every URL, the names of external packages (`langsmith`,
39
+ `langchain-protocol`), the upstream platform's API key variables, and the tracing
40
+ variables `langsmith` reads.
41
+ - Dropped: dependencies and sources for libraries we do not fork, and extras naming
42
+ a `trustcoco-*` package we do not produce.
43
+ - Our pyproject links and a generated README replace upstream's. `LICENSE` files are
44
+ never rewritten.
45
+
46
+ ## Removed
47
+
48
+ | Path | Why |
49
+ |---|---|
50
+ | `coco_graph/pregel/remote.py`, `_remote_run_stream.py` and their two test files | `RemoteGraph` is the client for upstream's hosted platform. Its `langgraph-sdk` dependency installs upstream's `langchain-core` beside ours |
51
+ | `coco_core/tracers/evaluation.py`, `coco_core/document_loaders/langsmith.py` | The evaluation tracer and the dataset loader call the upstream vendor's hosted service |
52
+ | `coco_tests/_langsmith_plugin.py` | A pytest plugin that reports test runs to the same service |
53
+ | Tests of the above, and the tracing interop tests in core and the graph | They exercise the vendor's tracing client |
54
+
55
+ ## Coco's own files
56
+
57
+ `overlay/<folder>/` is copied over the renamed library before the patches run.
58
+
59
+ | File | What it is |
60
+ |---|---|
61
+ | `core/coco_core/_protocol.py` | The agent streaming protocol types, vendored from `langchain-protocol` 0.0.19 (MIT). The rename points every import of that package here |
62
+ | `core/coco_core/tracers/_context.py` | The tracing context, `traceable`, the environment helpers and the `RunTree` run record, with the names and shapes upstream imported from its vendor's tracing client. Nothing leaves the process. The script points those imports here (`TRACING_IMPORTS`) |
63
+ | `core/coco_core/tracers/coco.py` | `CocoTracer`, replacing upstream's tracer at that path. Same interface, keeps runs in memory, sends nothing |
64
+
65
+ ## Patches
66
+
67
+ Applied in order after the rename, from `patches/<folder>/`.
68
+
69
+ | Patch | Why |
70
+ |---|---|
71
+ | `core/001-guard-import-names-trustcoco.patch` | `guard_import` told users to `pip install coco-core`. Coco modules ship in `trustcoco-*` distributions |
72
+ | `coco_graph/001-base-user-without-platform-client.patch` | `runtime.py` imported `BaseUser` from `langgraph-sdk`. Defined locally as a runtime-checkable protocol, the same shape |
73
+ | `coco_v1/001-test-distribution-name.patch` | A test lists dependency names, and the rename read its bare `"langgraph"` as a module |
74
+ | `core/002-tracing-without-vendor-client.patch` | Drops the removed evaluation tracer and loader from the package exports, and one test of the vendor's `@traceable` |
75
+ | `core/003-sys-info-distribution-names.patch` | Maps `coco` and `coco_*` module names to `trustcoco` and `trustcoco-*` distributions when `print_sys_info` queries `importlib.metadata` |
76
+ | `coco_graph/002-tests-without-vendor-tracing.patch` | Drops two tests that trace a graph through the vendor's client |
77
+ | `coco_graph/003-version-distribution-name.patch` | Looks up `trustcoco-graph` (with fallback to `coco-framework` and `__package__`) in `coco_graph/version.py` so `__version__` resolves when installed |
78
+ | `coco_v1/002-provider-package-names.patch` | Maps `coco_*` provider module names to `trustcoco-*` in `init_chat_model` and `init_embeddings` install hints, and isolates the missing-`coco_anthropic` test when `trustcoco-anthropic` is installed |
79
+ | `checkpoint/001-version-distribution-name.patch` | Queries the `trustcoco` distribution in `ensure_embeddings` version checks and install hints |
80
+ | `checkpoint-postgres/001-version-distribution-name.patch` | Queries `trustcoco-graph` in the `checkpoint-postgres` compatibility version check |
81
+
82
+ To make a patch: sync, copy the file aside, edit it under `libs/`, then
83
+ `diff -u --label a/<path> --label b/<path> <copy> libs/<folder>/<path> > patches/<folder>/NNN-name.patch`
84
+ with `<path>` relative to the library folder, and sync again to check it applies.
85
+
86
+ ## Upstream packages no longer needed
87
+
88
+ Removed 28 Sep 2026. `import langsmith` and `import langchain_protocol` fail in the
89
+ framework venv, and every library imports without them.
90
+
91
+ - `langsmith`, the upstream vendor's tracing client, replaced by
92
+ `coco_core.tracers._context`.
93
+ - `langchain-protocol`, the streaming message types, vendored as `coco_core._protocol`.
94
+
95
+ ## Tests
96
+
97
+ `scripts/dev.sh setup` creates `.venv` and installs every library editable.
98
+ `scripts/dev.sh test` runs each library's unit tests. Run on 28 Sep 2026 at the pins
99
+ above, after the vendor client came out:
100
+
101
+ | Library | Result | Notes |
102
+ |---|---|---|
103
+ | core | 2197 passed | 96 fewer than before the vendor client came out: the removed tracer, loader and interop tests |
104
+ | standard-tests | 148 passed | the removed pytest plugin's tests account for the difference |
105
+ | coco_graph | 1977 passed | upstream's four failures under the first rename are fixed by `coco_graph/001`; two tracing tests removed by `002`. One timing-dependent test failed once under `-n 16` on a loaded machine and passed on three reruns |
106
+ | prebuilt | 228 passed | |
107
+ | checkpoint | 159 passed, 16 skipped | the skipped tests need Redis |
108
+ | checkpoint-sqlite | 128 passed | a few tests retry once, as upstream configures |
109
+ | checkpoint-conformance | 1 passed | |
110
+ | checkpoint-postgres | not run | needs a Postgres server; upstream starts one with Docker |
111
+ | coco_v1 | 1219 passed | missing-`coco_anthropic` test isolated with `monkeypatch` in `coco_v1/002` so all 20 tests in `test_tool_emulator.py` pass when `trustcoco-anthropic` is installed |
112
+ | partners/openai | 669 passed | token counting downloads tiktoken encodings |
113
+ | partners/anthropic | 410 passed | |
114
+
115
+ Before the fixes, the same failing tests were run against untouched upstream in the
116
+ same environment to separate rename bugs from environment gaps.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 LangChain, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ # trustcoco-graph-checkpoint
2
+
3
+ Checkpoint interfaces and the in-memory checkpointer for Coco graphs.
4
+
5
+ Part of coco-framework. Generated from upstream by `scripts/sync_upstream.py`; see `UPSTREAM.md` for the pinned source and `NOTICE` for attribution. Do not edit files here by hand.
@@ -0,0 +1,48 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+ from collections.abc import Mapping, Sequence
5
+ from typing import Generic, TypeVar
6
+
7
+ from coco_graph.checkpoint.serde.base import SerializerProtocol
8
+ from coco_graph.checkpoint.serde.jsonplus import JsonPlusSerializer
9
+
10
+ ValueT = TypeVar("ValueT")
11
+ Namespace = tuple[str, ...]
12
+ FullKey = tuple[Namespace, str]
13
+
14
+
15
+ class BaseCache(ABC, Generic[ValueT]):
16
+ """Base class for a cache."""
17
+
18
+ serde: SerializerProtocol = JsonPlusSerializer(pickle_fallback=False)
19
+
20
+ def __init__(self, *, serde: SerializerProtocol | None = None) -> None:
21
+ """Initialize the cache with a serializer."""
22
+ self.serde = serde or self.serde
23
+
24
+ @abstractmethod
25
+ def get(self, keys: Sequence[FullKey]) -> dict[FullKey, ValueT]:
26
+ """Get the cached values for the given keys."""
27
+
28
+ @abstractmethod
29
+ async def aget(self, keys: Sequence[FullKey]) -> dict[FullKey, ValueT]:
30
+ """Asynchronously get the cached values for the given keys."""
31
+
32
+ @abstractmethod
33
+ def set(self, pairs: Mapping[FullKey, tuple[ValueT, int | None]]) -> None:
34
+ """Set the cached values for the given keys and TTLs."""
35
+
36
+ @abstractmethod
37
+ async def aset(self, pairs: Mapping[FullKey, tuple[ValueT, int | None]]) -> None:
38
+ """Asynchronously set the cached values for the given keys and TTLs."""
39
+
40
+ @abstractmethod
41
+ def clear(self, namespaces: Sequence[Namespace] | None = None) -> None:
42
+ """Delete the cached values for the given namespaces.
43
+ If no namespaces are provided, clear all cached values."""
44
+
45
+ @abstractmethod
46
+ async def aclear(self, namespaces: Sequence[Namespace] | None = None) -> None:
47
+ """Asynchronously delete the cached values for the given namespaces.
48
+ If no namespaces are provided, clear all cached values."""
@@ -0,0 +1,73 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ import threading
5
+ from collections.abc import Mapping, Sequence
6
+
7
+ from coco_graph.cache.base import BaseCache, FullKey, Namespace, ValueT
8
+ from coco_graph.checkpoint.serde.base import SerializerProtocol
9
+
10
+
11
+ class InMemoryCache(BaseCache[ValueT]):
12
+ def __init__(self, *, serde: SerializerProtocol | None = None):
13
+ super().__init__(serde=serde)
14
+ self._cache: dict[Namespace, dict[str, tuple[str, bytes, float | None]]] = {}
15
+ self._lock = threading.RLock()
16
+
17
+ def get(self, keys: Sequence[FullKey]) -> dict[FullKey, ValueT]:
18
+ """Get the cached values for the given keys."""
19
+ with self._lock:
20
+ if not keys:
21
+ return {}
22
+ now = datetime.datetime.now(datetime.timezone.utc).timestamp()
23
+ values: dict[FullKey, ValueT] = {}
24
+ for ns_tuple, key in keys:
25
+ ns = Namespace(ns_tuple)
26
+ if ns in self._cache and key in self._cache[ns]:
27
+ enc, val, expiry = self._cache[ns][key]
28
+ if expiry is None or now < expiry:
29
+ values[(ns, key)] = self.serde.loads_typed((enc, val))
30
+ else:
31
+ del self._cache[ns][key]
32
+ return values
33
+
34
+ async def aget(self, keys: Sequence[FullKey]) -> dict[FullKey, ValueT]:
35
+ """Asynchronously get the cached values for the given keys."""
36
+ return self.get(keys)
37
+
38
+ def set(self, keys: Mapping[FullKey, tuple[ValueT, int | None]]) -> None:
39
+ """Set the cached values for the given keys."""
40
+ with self._lock:
41
+ now = datetime.datetime.now(datetime.timezone.utc)
42
+ for (ns, key), (value, ttl) in keys.items():
43
+ if ttl is not None:
44
+ delta = datetime.timedelta(seconds=ttl)
45
+ expiry: float | None = (now + delta).timestamp()
46
+ else:
47
+ expiry = None
48
+ if ns not in self._cache:
49
+ self._cache[ns] = {}
50
+ self._cache[ns][key] = (
51
+ *self.serde.dumps_typed(value),
52
+ expiry,
53
+ )
54
+
55
+ async def aset(self, keys: Mapping[FullKey, tuple[ValueT, int | None]]) -> None:
56
+ """Asynchronously set the cached values for the given keys."""
57
+ self.set(keys)
58
+
59
+ def clear(self, namespaces: Sequence[Namespace] | None = None) -> None:
60
+ """Delete the cached values for the given namespaces.
61
+ If no namespaces are provided, clear all cached values."""
62
+ with self._lock:
63
+ if namespaces is None:
64
+ self._cache.clear()
65
+ else:
66
+ for ns in namespaces:
67
+ if ns in self._cache:
68
+ del self._cache[ns]
69
+
70
+ async def aclear(self, namespaces: Sequence[Namespace] | None = None) -> None:
71
+ """Asynchronously delete the cached values for the given namespaces.
72
+ If no namespaces are provided, clear all cached values."""
73
+ self.clear(namespaces)