ommlds 0.0.0.dev466__py3-none-any.whl → 0.0.0.dev512__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. ommlds/.omlish-manifests.json +404 -31
  2. ommlds/README.md +11 -0
  3. ommlds/__about__.py +21 -12
  4. ommlds/_hacks/__init__.py +4 -0
  5. ommlds/_hacks/funcs.py +110 -0
  6. ommlds/_hacks/names.py +158 -0
  7. ommlds/_hacks/params.py +73 -0
  8. ommlds/_hacks/patches.py +0 -3
  9. ommlds/backends/anthropic/protocol/__init__.py +13 -1
  10. ommlds/backends/anthropic/protocol/_dataclasses.py +1625 -0
  11. ommlds/backends/anthropic/protocol/sse/events.py +2 -0
  12. ommlds/backends/anthropic/protocol/types.py +5 -7
  13. ommlds/backends/cerebras/__init__.py +7 -0
  14. ommlds/backends/cerebras/_dataclasses.py +4254 -0
  15. ommlds/backends/cerebras/_marshal.py +24 -0
  16. ommlds/backends/cerebras/clients.py +9 -0
  17. ommlds/backends/cerebras/protocol.py +310 -0
  18. ommlds/backends/google/protocol/__init__.py +13 -0
  19. ommlds/backends/google/protocol/_dataclasses.py +5997 -0
  20. ommlds/backends/google/protocol/types.py +6 -8
  21. ommlds/backends/groq/__init__.py +7 -0
  22. ommlds/backends/groq/_dataclasses.py +3901 -0
  23. ommlds/backends/groq/_marshal.py +23 -0
  24. ommlds/backends/groq/clients.py +9 -0
  25. ommlds/backends/groq/protocol.py +247 -0
  26. ommlds/{huggingface.py → backends/huggingface/cache.py} +1 -6
  27. ommlds/backends/huggingface/cli.py +208 -0
  28. ommlds/backends/llamacpp/logging.py +4 -1
  29. ommlds/backends/mlx/caching.py +7 -3
  30. ommlds/backends/mlx/cli.py +10 -7
  31. ommlds/backends/mlx/generation.py +18 -16
  32. ommlds/backends/mlx/limits.py +10 -6
  33. ommlds/backends/mlx/loading.py +7 -4
  34. ommlds/backends/ollama/__init__.py +7 -0
  35. ommlds/backends/ollama/_dataclasses.py +3940 -0
  36. ommlds/backends/ollama/cli.py +36 -0
  37. ommlds/backends/ollama/protocol.py +201 -0
  38. ommlds/backends/openai/protocol/__init__.py +15 -1
  39. ommlds/backends/openai/protocol/_common.py +3 -5
  40. ommlds/backends/openai/protocol/_dataclasses.py +7708 -0
  41. ommlds/backends/tavily/__init__.py +7 -0
  42. ommlds/backends/tavily/_dataclasses.py +1734 -0
  43. ommlds/backends/tavily/protocol.py +299 -0
  44. ommlds/backends/tinygrad/models/llama3/__init__.py +22 -14
  45. ommlds/backends/torch/backends.py +1 -1
  46. ommlds/backends/transformers/__init__.py +14 -0
  47. ommlds/backends/transformers/filecache.py +109 -0
  48. ommlds/backends/transformers/streamers.py +73 -0
  49. ommlds/cli/__init__.py +7 -0
  50. ommlds/cli/_dataclasses.py +3835 -0
  51. ommlds/cli/asyncs.py +30 -0
  52. ommlds/cli/backends/catalog.py +88 -0
  53. ommlds/cli/backends/configs.py +9 -0
  54. ommlds/cli/backends/inject.py +100 -42
  55. ommlds/cli/{sessions/chat/backends → backends}/injection.py +1 -1
  56. ommlds/cli/backends/meta.py +82 -0
  57. ommlds/cli/{sessions/chat/backends → backends}/types.py +11 -1
  58. ommlds/cli/{sessions/chat/content → content}/messages.py +2 -2
  59. ommlds/cli/{sessions/chat/content → content}/strings.py +1 -1
  60. ommlds/cli/inject.py +17 -8
  61. ommlds/cli/inputs/asyncs.py +32 -0
  62. ommlds/cli/inputs/sync.py +75 -0
  63. ommlds/cli/main.py +346 -114
  64. ommlds/cli/rendering/configs.py +9 -0
  65. ommlds/cli/{sessions/chat/rendering → rendering}/inject.py +4 -5
  66. ommlds/cli/{sessions/chat/rendering → rendering}/markdown.py +1 -1
  67. ommlds/cli/{sessions/chat/rendering → rendering}/raw.py +1 -1
  68. ommlds/cli/{sessions/chat/rendering → rendering}/types.py +7 -1
  69. ommlds/cli/secrets.py +22 -0
  70. ommlds/cli/sessions/base.py +1 -10
  71. ommlds/cli/sessions/chat/configs.py +13 -30
  72. ommlds/cli/sessions/chat/drivers/ai/configs.py +13 -0
  73. ommlds/cli/sessions/chat/drivers/ai/events.py +57 -0
  74. ommlds/cli/sessions/chat/{chat → drivers}/ai/inject.py +15 -12
  75. ommlds/cli/sessions/chat/{chat → drivers}/ai/rendering.py +8 -8
  76. ommlds/cli/sessions/chat/{chat → drivers}/ai/services.py +5 -5
  77. ommlds/cli/sessions/chat/{chat → drivers}/ai/tools.py +4 -8
  78. ommlds/cli/sessions/chat/{chat → drivers}/ai/types.py +10 -1
  79. ommlds/cli/sessions/chat/drivers/configs.py +25 -0
  80. ommlds/cli/sessions/chat/drivers/events/inject.py +27 -0
  81. ommlds/cli/sessions/chat/drivers/events/injection.py +14 -0
  82. ommlds/cli/sessions/chat/drivers/events/manager.py +16 -0
  83. ommlds/cli/sessions/chat/drivers/events/types.py +44 -0
  84. ommlds/cli/sessions/chat/drivers/impl.py +50 -0
  85. ommlds/cli/sessions/chat/drivers/inject.py +70 -0
  86. ommlds/cli/sessions/chat/drivers/state/configs.py +13 -0
  87. ommlds/cli/sessions/chat/drivers/state/ids.py +25 -0
  88. ommlds/cli/sessions/chat/drivers/state/inject.py +83 -0
  89. ommlds/cli/sessions/chat/{chat → drivers}/state/inmemory.py +1 -6
  90. ommlds/cli/sessions/chat/{chat → drivers}/state/storage.py +18 -12
  91. ommlds/cli/sessions/chat/{chat → drivers}/state/types.py +11 -6
  92. ommlds/cli/sessions/chat/drivers/tools/configs.py +22 -0
  93. ommlds/cli/sessions/chat/drivers/tools/confirmation.py +44 -0
  94. ommlds/cli/sessions/chat/drivers/tools/errorhandling.py +39 -0
  95. ommlds/cli/sessions/chat/{tools → drivers/tools}/execution.py +3 -4
  96. ommlds/cli/sessions/chat/drivers/tools/fs/__init__.py +0 -0
  97. ommlds/cli/sessions/chat/drivers/tools/fs/configs.py +12 -0
  98. ommlds/cli/sessions/chat/drivers/tools/fs/inject.py +35 -0
  99. ommlds/cli/sessions/chat/drivers/tools/inject.py +83 -0
  100. ommlds/cli/sessions/chat/{tools → drivers/tools}/injection.py +20 -5
  101. ommlds/cli/sessions/chat/{tools → drivers/tools}/rendering.py +3 -3
  102. ommlds/cli/sessions/chat/drivers/tools/todo/__init__.py +0 -0
  103. ommlds/cli/sessions/chat/drivers/tools/todo/configs.py +12 -0
  104. ommlds/cli/sessions/chat/drivers/tools/todo/inject.py +31 -0
  105. ommlds/cli/sessions/chat/drivers/tools/weather/__init__.py +0 -0
  106. ommlds/cli/sessions/chat/drivers/tools/weather/configs.py +12 -0
  107. ommlds/cli/sessions/chat/drivers/tools/weather/inject.py +22 -0
  108. ommlds/cli/sessions/chat/{tools/weather.py → drivers/tools/weather/tools.py} +1 -1
  109. ommlds/cli/sessions/chat/drivers/types.py +31 -0
  110. ommlds/cli/sessions/chat/drivers/user/__init__.py +0 -0
  111. ommlds/cli/sessions/chat/drivers/user/configs.py +14 -0
  112. ommlds/cli/sessions/chat/drivers/user/inject.py +41 -0
  113. ommlds/cli/sessions/chat/facades/__init__.py +0 -0
  114. ommlds/cli/sessions/chat/facades/commands/__init__.py +0 -0
  115. ommlds/cli/sessions/chat/facades/commands/base.py +83 -0
  116. ommlds/cli/sessions/chat/facades/commands/configs.py +9 -0
  117. ommlds/cli/sessions/chat/facades/commands/inject.py +41 -0
  118. ommlds/cli/sessions/chat/facades/commands/injection.py +15 -0
  119. ommlds/cli/sessions/chat/facades/commands/manager.py +59 -0
  120. ommlds/cli/sessions/chat/facades/commands/simple.py +34 -0
  121. ommlds/cli/sessions/chat/facades/commands/types.py +13 -0
  122. ommlds/cli/sessions/chat/facades/configs.py +11 -0
  123. ommlds/cli/sessions/chat/facades/facade.py +26 -0
  124. ommlds/cli/sessions/chat/facades/inject.py +35 -0
  125. ommlds/cli/sessions/chat/facades/ui.py +34 -0
  126. ommlds/cli/sessions/chat/inject.py +10 -49
  127. ommlds/cli/sessions/chat/interfaces/__init__.py +0 -0
  128. ommlds/cli/sessions/chat/interfaces/bare/__init__.py +0 -0
  129. ommlds/cli/sessions/chat/interfaces/bare/configs.py +15 -0
  130. ommlds/cli/sessions/chat/interfaces/bare/inject.py +69 -0
  131. ommlds/cli/sessions/chat/interfaces/bare/interactive.py +49 -0
  132. ommlds/cli/sessions/chat/interfaces/bare/oneshot.py +21 -0
  133. ommlds/cli/sessions/chat/{tools/confirmation.py → interfaces/bare/tools.py} +3 -22
  134. ommlds/cli/sessions/chat/interfaces/base.py +13 -0
  135. ommlds/cli/sessions/chat/interfaces/configs.py +11 -0
  136. ommlds/cli/sessions/chat/interfaces/inject.py +29 -0
  137. ommlds/cli/sessions/chat/interfaces/textual/__init__.py +0 -0
  138. ommlds/cli/sessions/chat/interfaces/textual/app.py +429 -0
  139. ommlds/cli/sessions/chat/interfaces/textual/configs.py +11 -0
  140. ommlds/cli/sessions/chat/interfaces/textual/facades.py +19 -0
  141. ommlds/cli/sessions/chat/interfaces/textual/inject.py +111 -0
  142. ommlds/cli/sessions/chat/interfaces/textual/inputhistory.py +174 -0
  143. ommlds/cli/sessions/chat/interfaces/textual/interface.py +24 -0
  144. ommlds/cli/sessions/chat/interfaces/textual/styles/__init__.py +29 -0
  145. ommlds/cli/sessions/chat/interfaces/textual/styles/input.tcss +53 -0
  146. ommlds/cli/sessions/chat/interfaces/textual/styles/markdown.tcss +7 -0
  147. ommlds/cli/sessions/chat/interfaces/textual/styles/messages.tcss +167 -0
  148. ommlds/cli/sessions/chat/interfaces/textual/tools.py +38 -0
  149. ommlds/cli/sessions/chat/interfaces/textual/widgets/__init__.py +0 -0
  150. ommlds/cli/sessions/chat/interfaces/textual/widgets/input.py +70 -0
  151. ommlds/cli/sessions/chat/interfaces/textual/widgets/messages.py +207 -0
  152. ommlds/cli/sessions/chat/session.py +8 -13
  153. ommlds/cli/sessions/completion/configs.py +5 -6
  154. ommlds/cli/sessions/completion/inject.py +15 -2
  155. ommlds/cli/sessions/completion/session.py +10 -18
  156. ommlds/cli/sessions/configs.py +10 -0
  157. ommlds/cli/sessions/embedding/configs.py +5 -6
  158. ommlds/cli/sessions/embedding/inject.py +15 -2
  159. ommlds/cli/sessions/embedding/session.py +10 -18
  160. ommlds/cli/sessions/inject.py +15 -15
  161. ommlds/cli/state/storage.py +8 -2
  162. ommlds/minichain/__init__.py +217 -60
  163. ommlds/minichain/_dataclasses.py +20640 -0
  164. ommlds/minichain/_typedvalues.py +15 -8
  165. ommlds/minichain/backends/catalogs/base.py +20 -1
  166. ommlds/minichain/backends/catalogs/simple.py +2 -2
  167. ommlds/minichain/backends/catalogs/strings.py +13 -10
  168. ommlds/minichain/backends/impls/anthropic/chat.py +28 -5
  169. ommlds/minichain/backends/impls/anthropic/names.py +3 -3
  170. ommlds/minichain/backends/impls/anthropic/protocol.py +2 -2
  171. ommlds/minichain/backends/impls/anthropic/stream.py +23 -18
  172. ommlds/minichain/backends/impls/cerebras/__init__.py +0 -0
  173. ommlds/minichain/backends/impls/cerebras/chat.py +82 -0
  174. ommlds/minichain/backends/impls/cerebras/names.py +45 -0
  175. ommlds/minichain/backends/impls/cerebras/protocol.py +143 -0
  176. ommlds/minichain/backends/impls/cerebras/stream.py +114 -0
  177. ommlds/minichain/backends/impls/duckduckgo/search.py +5 -1
  178. ommlds/minichain/backends/impls/dummy/__init__.py +0 -0
  179. ommlds/minichain/backends/impls/dummy/chat.py +69 -0
  180. ommlds/minichain/backends/impls/google/chat.py +20 -84
  181. ommlds/minichain/backends/impls/google/names.py +6 -0
  182. ommlds/minichain/backends/impls/google/protocol.py +105 -0
  183. ommlds/minichain/backends/impls/google/search.py +10 -5
  184. ommlds/minichain/backends/impls/google/stream.py +64 -142
  185. ommlds/minichain/backends/impls/google/tools.py +2 -2
  186. ommlds/minichain/backends/impls/groq/__init__.py +0 -0
  187. ommlds/minichain/backends/impls/groq/chat.py +77 -0
  188. ommlds/minichain/backends/impls/groq/names.py +48 -0
  189. ommlds/minichain/backends/impls/groq/protocol.py +143 -0
  190. ommlds/minichain/backends/impls/groq/stream.py +114 -0
  191. ommlds/minichain/backends/impls/huggingface/repos.py +1 -5
  192. ommlds/minichain/backends/impls/llamacpp/chat.py +15 -3
  193. ommlds/minichain/backends/impls/llamacpp/completion.py +7 -3
  194. ommlds/minichain/backends/impls/llamacpp/stream.py +38 -19
  195. ommlds/minichain/backends/impls/mistral.py +9 -2
  196. ommlds/minichain/backends/impls/mlx/chat.py +100 -23
  197. ommlds/minichain/backends/impls/ollama/__init__.py +0 -0
  198. ommlds/minichain/backends/impls/ollama/chat.py +193 -0
  199. ommlds/minichain/backends/impls/ollama/protocol.py +144 -0
  200. ommlds/minichain/backends/impls/openai/chat.py +14 -7
  201. ommlds/minichain/backends/impls/openai/completion.py +9 -2
  202. ommlds/minichain/backends/impls/openai/embedding.py +9 -2
  203. ommlds/minichain/backends/impls/openai/format.py +117 -115
  204. ommlds/minichain/backends/impls/openai/names.py +33 -5
  205. ommlds/minichain/backends/impls/openai/stream.py +61 -70
  206. ommlds/minichain/backends/impls/sentencepiece/tokens.py +9 -6
  207. ommlds/minichain/backends/impls/tavily.py +66 -0
  208. ommlds/minichain/backends/impls/tinygrad/chat.py +17 -14
  209. ommlds/minichain/backends/impls/tokenizers/tokens.py +9 -6
  210. ommlds/minichain/backends/impls/transformers/sentence.py +5 -2
  211. ommlds/minichain/backends/impls/transformers/tokens.py +9 -6
  212. ommlds/minichain/backends/impls/transformers/transformers.py +139 -20
  213. ommlds/minichain/backends/strings/parsing.py +2 -2
  214. ommlds/minichain/backends/strings/resolving.py +7 -2
  215. ommlds/minichain/chat/choices/stream/__init__.py +0 -0
  216. ommlds/minichain/chat/{stream → choices/stream}/adapters.py +7 -7
  217. ommlds/minichain/chat/choices/stream/joining.py +31 -0
  218. ommlds/minichain/chat/choices/stream/services.py +45 -0
  219. ommlds/minichain/chat/choices/stream/types.py +43 -0
  220. ommlds/minichain/chat/content.py +42 -0
  221. ommlds/minichain/chat/messages.py +46 -42
  222. ommlds/minichain/chat/stream/_marshal.py +4 -4
  223. ommlds/minichain/chat/stream/joining.py +56 -43
  224. ommlds/minichain/chat/stream/services.py +15 -15
  225. ommlds/minichain/chat/stream/types.py +17 -24
  226. ommlds/minichain/chat/templating.py +3 -3
  227. ommlds/minichain/content/__init__.py +20 -3
  228. ommlds/minichain/content/_marshal.py +181 -55
  229. ommlds/minichain/content/code.py +26 -0
  230. ommlds/minichain/content/composite.py +28 -0
  231. ommlds/minichain/content/content.py +27 -0
  232. ommlds/minichain/content/dynamic.py +12 -0
  233. ommlds/minichain/content/emphasis.py +27 -0
  234. ommlds/minichain/content/images.py +2 -2
  235. ommlds/minichain/content/json.py +2 -2
  236. ommlds/minichain/content/link.py +13 -0
  237. ommlds/minichain/content/markdown.py +12 -0
  238. ommlds/minichain/content/metadata.py +10 -0
  239. ommlds/minichain/content/namespaces.py +8 -0
  240. ommlds/minichain/content/placeholders.py +10 -9
  241. ommlds/minichain/content/quote.py +26 -0
  242. ommlds/minichain/content/raw.py +49 -0
  243. ommlds/minichain/content/recursive.py +12 -0
  244. ommlds/minichain/content/resources.py +22 -0
  245. ommlds/minichain/content/section.py +26 -0
  246. ommlds/minichain/content/sequence.py +17 -3
  247. ommlds/minichain/content/standard.py +32 -0
  248. ommlds/minichain/content/tag.py +28 -0
  249. ommlds/minichain/content/templates.py +13 -0
  250. ommlds/minichain/content/text.py +2 -2
  251. ommlds/minichain/content/transform/__init__.py +0 -0
  252. ommlds/minichain/content/transform/json.py +55 -0
  253. ommlds/minichain/content/transform/markdown.py +8 -0
  254. ommlds/minichain/content/transform/materialize.py +59 -0
  255. ommlds/minichain/content/transform/metadata.py +16 -0
  256. ommlds/minichain/content/transform/namespaces.py +20 -0
  257. ommlds/minichain/content/transform/placeholders.py +60 -0
  258. ommlds/minichain/content/{prepare.py → transform/prepare.py} +10 -15
  259. ommlds/minichain/content/transform/recursive.py +54 -0
  260. ommlds/minichain/content/transform/resources.py +58 -0
  261. ommlds/minichain/content/transform/standard.py +43 -0
  262. ommlds/minichain/content/{transforms → transform}/stringify.py +1 -7
  263. ommlds/minichain/content/transform/strings.py +33 -0
  264. ommlds/minichain/content/transform/templates.py +25 -0
  265. ommlds/minichain/content/transform/types.py +18 -0
  266. ommlds/minichain/content/transform/visitors.py +38 -0
  267. ommlds/minichain/content/visitors.py +218 -0
  268. ommlds/minichain/http/__init__.py +0 -0
  269. ommlds/minichain/http/stream.py +195 -0
  270. ommlds/minichain/lib/fs/tools/read.py +1 -1
  271. ommlds/minichain/lib/fs/tools/recursivels/rendering.py +1 -1
  272. ommlds/minichain/lib/fs/tools/recursivels/running.py +1 -1
  273. ommlds/minichain/lib/todo/tools/write.py +2 -1
  274. ommlds/minichain/lib/todo/types.py +1 -1
  275. ommlds/minichain/llms/types.py +4 -0
  276. ommlds/minichain/metadata.py +56 -2
  277. ommlds/minichain/models/configs.py +2 -2
  278. ommlds/minichain/models/names.py +2 -0
  279. ommlds/minichain/registries/globals.py +18 -4
  280. ommlds/minichain/resources.py +49 -3
  281. ommlds/minichain/search.py +1 -1
  282. ommlds/minichain/services/README.md +154 -0
  283. ommlds/minichain/services/__init__.py +6 -2
  284. ommlds/minichain/services/_marshal.py +46 -10
  285. ommlds/minichain/services/_origclasses.py +11 -0
  286. ommlds/minichain/services/_typedvalues.py +8 -3
  287. ommlds/minichain/services/requests.py +73 -3
  288. ommlds/minichain/services/responses.py +73 -3
  289. ommlds/minichain/services/services.py +9 -0
  290. ommlds/minichain/standard.py +8 -0
  291. ommlds/minichain/stream/services.py +43 -17
  292. ommlds/minichain/text/applypatch.py +2 -1
  293. ommlds/minichain/text/toolparsing/llamacpp/types.py +1 -1
  294. ommlds/minichain/tokens/specials.py +1 -1
  295. ommlds/minichain/tools/execution/catalog.py +2 -2
  296. ommlds/minichain/tools/execution/errorhandling.py +36 -0
  297. ommlds/minichain/tools/execution/errors.py +2 -2
  298. ommlds/minichain/tools/execution/executors.py +1 -1
  299. ommlds/minichain/tools/fns.py +1 -1
  300. ommlds/minichain/tools/jsonschema.py +2 -2
  301. ommlds/minichain/tools/reflect.py +11 -7
  302. ommlds/minichain/tools/types.py +16 -19
  303. ommlds/minichain/vectors/_marshal.py +1 -1
  304. ommlds/minichain/vectors/embeddings.py +1 -1
  305. ommlds/minichain/wrappers/__init__.py +7 -0
  306. ommlds/minichain/wrappers/firstinwins.py +144 -0
  307. ommlds/minichain/wrappers/instrument.py +146 -0
  308. ommlds/minichain/wrappers/retry.py +168 -0
  309. ommlds/minichain/wrappers/services.py +98 -0
  310. ommlds/minichain/wrappers/stream.py +57 -0
  311. ommlds/nanochat/LICENSE +21 -0
  312. ommlds/nanochat/__init__.py +0 -0
  313. ommlds/nanochat/rustbpe/LICENSE +21 -0
  314. ommlds/nanochat/rustbpe/README.md +10 -0
  315. ommlds/nanochat/tokenizers.py +440 -0
  316. ommlds/specs/__init__.py +0 -0
  317. ommlds/specs/mcp/__init__.py +0 -0
  318. ommlds/specs/mcp/_marshal.py +23 -0
  319. ommlds/specs/mcp/clients.py +146 -0
  320. ommlds/specs/mcp/protocol.py +369 -0
  321. ommlds/tools/git.py +84 -64
  322. ommlds/tools/ocr.py +1 -1
  323. ommlds/wiki/analyze.py +2 -2
  324. ommlds/wiki/models.py +4 -4
  325. ommlds/wiki/text/mfh.py +9 -9
  326. ommlds/wiki/utils/xml.py +5 -5
  327. {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/METADATA +28 -21
  328. ommlds-0.0.0.dev512.dist-info/RECORD +534 -0
  329. {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/WHEEL +1 -1
  330. ommlds/cli/backends/standard.py +0 -20
  331. ommlds/cli/sessions/chat/backends/catalog.py +0 -56
  332. ommlds/cli/sessions/chat/backends/inject.py +0 -37
  333. ommlds/cli/sessions/chat/chat/state/inject.py +0 -40
  334. ommlds/cli/sessions/chat/chat/user/inject.py +0 -61
  335. ommlds/cli/sessions/chat/chat/user/interactive.py +0 -29
  336. ommlds/cli/sessions/chat/chat/user/oneshot.py +0 -25
  337. ommlds/cli/sessions/chat/chat/user/types.py +0 -15
  338. ommlds/cli/sessions/chat/driver.py +0 -43
  339. ommlds/cli/sessions/chat/tools/inject.py +0 -145
  340. ommlds/minichain/backends/impls/openai/format2.py +0 -210
  341. ommlds/minichain/content/materialize.py +0 -196
  342. ommlds/minichain/content/simple.py +0 -47
  343. ommlds/minichain/content/transforms/base.py +0 -46
  344. ommlds/minichain/content/transforms/interleave.py +0 -70
  345. ommlds/minichain/content/transforms/squeeze.py +0 -72
  346. ommlds/minichain/content/transforms/strings.py +0 -24
  347. ommlds/minichain/content/types.py +0 -43
  348. ommlds/minichain/stream/wrap.py +0 -62
  349. ommlds-0.0.0.dev466.dist-info/RECORD +0 -376
  350. /ommlds/{cli/sessions/chat/backends → backends/huggingface}/__init__.py +0 -0
  351. /ommlds/cli/{sessions/chat/chat → content}/__init__.py +0 -0
  352. /ommlds/cli/{sessions/chat/chat/ai → inputs}/__init__.py +0 -0
  353. /ommlds/cli/{sessions/chat/chat/state → rendering}/__init__.py +0 -0
  354. /ommlds/cli/sessions/chat/{chat/user → drivers}/__init__.py +0 -0
  355. /ommlds/cli/sessions/chat/{content → drivers/ai}/__init__.py +0 -0
  356. /ommlds/cli/sessions/chat/{chat → drivers}/ai/injection.py +0 -0
  357. /ommlds/cli/sessions/chat/{phases → drivers/events}/__init__.py +0 -0
  358. /ommlds/cli/sessions/chat/{rendering → drivers/phases}/__init__.py +0 -0
  359. /ommlds/cli/sessions/chat/{phases → drivers/phases}/inject.py +0 -0
  360. /ommlds/cli/sessions/chat/{phases → drivers/phases}/injection.py +0 -0
  361. /ommlds/cli/sessions/chat/{phases → drivers/phases}/manager.py +0 -0
  362. /ommlds/cli/sessions/chat/{phases → drivers/phases}/types.py +0 -0
  363. /ommlds/cli/sessions/chat/{tools → drivers/state}/__init__.py +0 -0
  364. /ommlds/{minichain/content/transforms → cli/sessions/chat/drivers/tools}/__init__.py +0 -0
  365. {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/entry_points.txt +0 -0
  366. {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/licenses/LICENSE +0 -0
  367. {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,174 @@
1
+ import abc
2
+ import json
3
+ import os
4
+ import typing as ta
5
+
6
+ from omlish import lang
7
+
8
+
9
+ ##
10
+
11
+
12
+ class InputHistoryStorage(lang.Abstract):
13
+ @abc.abstractmethod
14
+ def load(self) -> list[str]:
15
+ raise NotImplementedError
16
+
17
+ @abc.abstractmethod
18
+ def save(self, entries: ta.Sequence[str]) -> None:
19
+ raise NotImplementedError
20
+
21
+
22
+ class InMemoryInputHistoryStorage(InputHistoryStorage):
23
+ def __init__(self) -> None:
24
+ super().__init__()
25
+
26
+ self._entries: list[str] = []
27
+
28
+ def load(self) -> list[str]:
29
+ return list(self._entries)
30
+
31
+ def save(self, entries: ta.Sequence[str]) -> None:
32
+ self._entries = list(entries)
33
+
34
+
35
+ class FileInputHistoryStorage(InputHistoryStorage):
36
+ def __init__(self, *, path: str) -> None:
37
+ super().__init__()
38
+
39
+ self._path = path
40
+
41
+ def load(self) -> list[str]:
42
+ if not os.path.exists(self._path):
43
+ return []
44
+
45
+ try:
46
+ with open(self._path) as f:
47
+ data = json.load(f)
48
+ if isinstance(data, list) and all(isinstance(e, str) for e in data):
49
+ return data
50
+ return []
51
+ except (json.JSONDecodeError, OSError):
52
+ return []
53
+
54
+ def save(self, entries: ta.Sequence[str]) -> None:
55
+ try:
56
+ dir_path = os.path.dirname(self._path)
57
+ if dir_path:
58
+ os.makedirs(dir_path, exist_ok=True)
59
+ with open(self._path, 'w') as f:
60
+ json.dump(list(entries), f, indent=2)
61
+ except OSError:
62
+ pass
63
+
64
+
65
+ ##
66
+
67
+
68
+ class InputHistoryManager:
69
+ """
70
+ Manages input history with readline-style navigation.
71
+
72
+ History position semantics:
73
+ - Position starts at len(history) (one past the end)
74
+ - Moving 'previous' decrements position
75
+ - Moving 'next' increments position
76
+ - Position is clamped to [0, len(history)]
77
+ - Position len(history) represents 'no history item selected'
78
+ """
79
+
80
+ def __init__(
81
+ self,
82
+ *,
83
+ storage: InputHistoryStorage,
84
+ max_entries: int = 1000,
85
+ ) -> None:
86
+ super().__init__()
87
+
88
+ self._storage = storage
89
+ self._max_entries = max_entries
90
+
91
+ self._entries: list[str] = self._storage.load()
92
+ self._position: int = len(self._entries)
93
+ self._current_draft: str = ''
94
+
95
+ def add(self, text: str) -> None:
96
+ """Add a new history entry and reset position."""
97
+
98
+ if not text.strip():
99
+ return
100
+
101
+ # Don't add duplicate consecutive entries
102
+ if self._entries and self._entries[-1] == text:
103
+ self.reset_position()
104
+ return
105
+
106
+ self._entries.append(text)
107
+
108
+ # Trim to max size
109
+ if len(self._entries) > self._max_entries:
110
+ self._entries = self._entries[-self._max_entries:]
111
+
112
+ self._storage.save(self._entries)
113
+ self.reset_position()
114
+
115
+ def get_previous(self, text: str | None = None) -> str | None:
116
+ """
117
+ Navigate to previous (older) history entry.
118
+
119
+ Args:
120
+ text: Current text in the input field (saved as draft when at end of history)
121
+
122
+ Returns:
123
+ The previous history entry, or None if at the beginning
124
+ """
125
+
126
+ if not self._entries:
127
+ return None
128
+
129
+ # Save current draft if we're at the end
130
+ if self._position == len(self._entries) and text is not None:
131
+ self._current_draft = text
132
+
133
+ # Move to previous entry
134
+ if self._position > 0:
135
+ self._position -= 1
136
+ return self._entries[self._position]
137
+
138
+ # Already at oldest entry
139
+ return self._entries[0] if self._entries else None
140
+
141
+ def get_next(self, text: str | None = None) -> str | None:
142
+ """
143
+ Navigate to next (newer) history entry.
144
+
145
+ Args:
146
+ text: Current text in the input field (unused for now)
147
+
148
+ Returns:
149
+ The next history entry, the saved draft if moving past the end, or None
150
+ """
151
+
152
+ if not self._entries:
153
+ return None
154
+
155
+ # Move to next entry
156
+ if self._position < len(self._entries):
157
+ self._position += 1
158
+
159
+ # If we moved past the end, return the draft
160
+ if self._position == len(self._entries):
161
+ draft = self._current_draft
162
+ self._current_draft = ''
163
+ return draft
164
+
165
+ return self._entries[self._position]
166
+
167
+ # Already at newest position
168
+ return None
169
+
170
+ def reset_position(self) -> None:
171
+ """Reset history position to the end (no history item selected)."""
172
+
173
+ self._position = len(self._entries)
174
+ self._current_draft = ''
@@ -0,0 +1,24 @@
1
+ from omdev.tui import textual as tx
2
+
3
+ from ..base import ChatInterface
4
+ from .app import ChatApp
5
+
6
+
7
+ ##
8
+
9
+
10
+ class TextualChatInterface(ChatInterface):
11
+ def __init__(
12
+ self,
13
+ *,
14
+ app: ChatApp,
15
+ ) -> None:
16
+ super().__init__()
17
+
18
+ self._app = app
19
+
20
+ async def run(self) -> None:
21
+ # FIXME: move lol
22
+ tx.set_root_logger_to_devtools(self._app.devtools)
23
+
24
+ await self._app.run_async()
@@ -0,0 +1,29 @@
1
+ import io as _io
2
+
3
+ from omlish import lang as _lang
4
+
5
+
6
+ ##
7
+
8
+
9
+ @_lang.cached_function
10
+ def read_app_css() -> str:
11
+ tcss_rsrcs = [
12
+ rsrc
13
+ for rsrc in _lang.get_relative_resources(globals=globals()).values()
14
+ if rsrc.name.endswith('.tcss')
15
+ ]
16
+
17
+ out = _io.StringIO()
18
+
19
+ for i, rsrc in enumerate(tcss_rsrcs):
20
+ if i:
21
+ out.write('\n\n')
22
+
23
+ out.write(f'/*** {rsrc.name} ***/\n')
24
+ out.write('\n')
25
+
26
+ out.write(rsrc.read_text().strip())
27
+ out.write('\n')
28
+
29
+ return out.getvalue()
@@ -0,0 +1,53 @@
1
+ #input-outer {
2
+ width: 100%;
3
+ height: auto;
4
+
5
+ background: $background-darken-3;
6
+ }
7
+
8
+ #input-vertical {
9
+ width: 100%;
10
+ height: auto;
11
+
12
+ margin: 0 1 1 1;
13
+
14
+ padding: 0;
15
+ }
16
+
17
+ #input-vertical2 {
18
+ width: 100%;
19
+ height: auto;
20
+
21
+ border: round $foreground-muted;
22
+
23
+ padding: 0 1;
24
+ }
25
+
26
+ #input-horizontal {
27
+ width: 100%;
28
+ height: auto;
29
+ }
30
+
31
+ #input-glyph {
32
+ width: auto;
33
+
34
+ padding: 0 1 0 0;
35
+
36
+ background: transparent;
37
+ color: $primary;
38
+
39
+ text-style: bold;
40
+ }
41
+
42
+ #input {
43
+ width: 1fr;
44
+ height: auto;
45
+ max-height: 16;
46
+
47
+ border: none;
48
+
49
+ padding: 0;
50
+
51
+ background: transparent;
52
+ color: $text;
53
+ }
@@ -0,0 +1,7 @@
1
+ Markdown MarkdownFence {
2
+ max-width: 95%;
3
+
4
+ overflow-x: auto;
5
+
6
+ scrollbar-size-horizontal: 1;
7
+ }
@@ -0,0 +1,167 @@
1
+ /* Container */
2
+
3
+ #messages-container {
4
+ width: 100%;
5
+ height: 1fr;
6
+
7
+ scrollbar-gutter: stable;
8
+
9
+ background: $background-darken-3;
10
+
11
+ text-align: left;
12
+
13
+ scrollbar-size: 1 1;
14
+ }
15
+
16
+
17
+ /* Divider */
18
+
19
+ .message-divider {
20
+ height: 1;
21
+ margin: 1 0 0 0;
22
+
23
+ border-top: solid $primary;
24
+ }
25
+
26
+
27
+ /* Base Message */
28
+
29
+ .message {
30
+ width: 1fr;
31
+ height: auto;
32
+
33
+ margin: 1 0 0 0;
34
+
35
+ padding-right: 1;
36
+
37
+ layout: stream;
38
+ }
39
+
40
+ .message-glyph {
41
+ width: auto;
42
+ height: auto;
43
+
44
+ background: transparent;
45
+ color: $primary;
46
+
47
+ text-style: bold;
48
+ }
49
+
50
+ .message-outer {
51
+ width: 1fr;
52
+ height: auto;
53
+
54
+ align: left top;
55
+ }
56
+
57
+ .message-inner {
58
+ width: 1fr;
59
+ height: auto;
60
+ }
61
+
62
+
63
+ /* Welcome Message */
64
+
65
+ .welcome-message {
66
+ margin: 0;
67
+
68
+ padding: 1 2 1 1;
69
+
70
+ border: round;
71
+ }
72
+
73
+ .welcome-message-outer {
74
+ }
75
+
76
+ .welcome-message-content {
77
+ }
78
+
79
+
80
+ /* User Message */
81
+
82
+ .user-message {
83
+ }
84
+
85
+ .user-message-outer {
86
+ }
87
+
88
+ .user-message-glyph {
89
+ }
90
+
91
+ .user-message-inner {
92
+ }
93
+
94
+
95
+ /* Ai Message */
96
+
97
+ .ai-message {
98
+ }
99
+
100
+ .ai-message-outer {
101
+ }
102
+
103
+ .ai-message-glyph {
104
+ }
105
+
106
+ .ai-message-inner {
107
+ padding: 0;
108
+
109
+ Markdown {
110
+ width: 100%;
111
+ height: auto;
112
+
113
+ margin: 0;
114
+ padding: 0;
115
+ }
116
+ }
117
+
118
+
119
+ /* Tool Confirmation Message */
120
+
121
+ .tool-confirmation-message {
122
+ }
123
+
124
+ .tool-confirmation-message-outer {
125
+ }
126
+
127
+ .tool-confirmation-message-glyph {
128
+ }
129
+
130
+ .tool-confirmation-message-inner {
131
+ }
132
+
133
+ .tool-confirmation-message-inner-open {
134
+ background: $warning-lighten-3 15%;
135
+ }
136
+
137
+ .tool-confirmation-message-inner-closed {
138
+ }
139
+
140
+ .tool-confirmation-message-outer-content {
141
+ }
142
+
143
+ .tool-confirmation-message-inner-content {
144
+ background: $background;
145
+
146
+ margin: 1;
147
+ padding: 1;
148
+ }
149
+
150
+ .tool-confirmation-message-controls {
151
+ margin: 1;
152
+ }
153
+
154
+
155
+ /* Ui Message */
156
+
157
+ .ui-message {
158
+ }
159
+
160
+ .ui-message-glyph {
161
+ }
162
+
163
+ .ui-message-outer {
164
+ }
165
+
166
+ .ui-message-inner {
167
+ }
@@ -0,0 +1,38 @@
1
+ from omlish.formats import json
2
+
3
+ from ...... import minichain as mc
4
+ from ...drivers.tools.confirmation import ToolExecutionConfirmation
5
+ from ...drivers.tools.confirmation import ToolExecutionRequestDeniedError
6
+ from .app import ChatAppGetter
7
+
8
+
9
+ ##
10
+
11
+
12
+ class ChatAppToolExecutionConfirmation(ToolExecutionConfirmation):
13
+ def __init__(
14
+ self,
15
+ *,
16
+ app: ChatAppGetter,
17
+ ) -> None:
18
+ super().__init__()
19
+
20
+ self._app = app
21
+
22
+ async def confirm_tool_execution_or_raise(
23
+ self,
24
+ use: 'mc.ToolUse',
25
+ entry: 'mc.ToolCatalogEntry',
26
+ ) -> None:
27
+ tr_dct = dict(
28
+ id=use.id,
29
+ name=entry.spec.name,
30
+ args=use.args,
31
+ # spec=msh.marshal(tce.spec),
32
+ )
33
+
34
+ if not await (await self._app()).confirm_tool_use(
35
+ 'Execute requested tool?',
36
+ json.dumps_pretty(tr_dct),
37
+ ):
38
+ raise ToolExecutionRequestDeniedError
@@ -0,0 +1,70 @@
1
+ import dataclasses as dc
2
+ import typing as ta
3
+
4
+ from omdev.tui import textual as tx
5
+
6
+
7
+ ##
8
+
9
+
10
+ class InputTextArea(tx.TextArea):
11
+ @dc.dataclass()
12
+ class Submitted(tx.Message):
13
+ text: str
14
+
15
+ @dc.dataclass()
16
+ class HistoryPrevious(tx.Message):
17
+ text: str
18
+
19
+ @dc.dataclass()
20
+ class HistoryNext(tx.Message):
21
+ text: str
22
+
23
+ @dc.dataclass()
24
+ class HistoryReset(tx.Message):
25
+ pass
26
+
27
+ def __init__(self, **kwargs: ta.Any) -> None:
28
+ super().__init__(**kwargs)
29
+
30
+ BINDINGS: ta.ClassVar[ta.Sequence[tx.Binding]] = [ # type: ignore[assignment]
31
+ tx.Binding(
32
+ 'enter',
33
+ 'submit',
34
+ priority=True,
35
+ ),
36
+ tx.Binding(
37
+ 'ctrl+p',
38
+ 'history_previous',
39
+ ),
40
+ tx.Binding(
41
+ 'ctrl+n',
42
+ 'history_next',
43
+ ),
44
+ ]
45
+
46
+ def action_submit(self) -> None:
47
+ if text := self.text.strip():
48
+ self.post_message(self.Submitted(text))
49
+
50
+ def action_cursor_up(self, select: bool = False) -> None:
51
+ # FIXME: if empty -> history_previous
52
+ super().action_cursor_up(select=select)
53
+
54
+ def action_cursor_down(self, select: bool = False) -> None:
55
+ super().action_cursor_down(select=select)
56
+
57
+ def action_history_previous(self) -> None:
58
+ self.post_message(self.HistoryPrevious(self.text))
59
+
60
+ def action_history_next(self) -> None:
61
+ self.post_message(self.HistoryNext(self.text))
62
+
63
+
64
+ class InputOuter(tx.Static):
65
+ def compose(self) -> tx.ComposeResult:
66
+ with tx.Vertical(id='input-vertical'):
67
+ with tx.Vertical(id='input-vertical2'):
68
+ with tx.Horizontal(id='input-horizontal'):
69
+ yield tx.Static('>', id='input-glyph')
70
+ yield InputTextArea(placeholder='...', id='input')