flock-core 0.1.1__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flock-core might be problematic. Click here for more details.

Files changed (405) hide show
  1. flock/__init__.py +1 -4
  2. flock/agents/__init__.py +0 -3
  3. flock/agents/batch_agent.py +140 -175
  4. flock/agents/loop_agent.py +117 -178
  5. flock/agents/trigger_agent.py +113 -191
  6. flock/agents/user_agent.py +145 -230
  7. flock/core/__init__.py +1 -7
  8. flock/core/context/context.py +211 -0
  9. flock/core/context/context_manager.py +34 -0
  10. flock/core/{context_vars.py → context/context_vars.py} +8 -6
  11. flock/core/execution/local_executor.py +27 -0
  12. flock/core/execution/temporal_executor.py +40 -0
  13. flock/core/flock.py +199 -208
  14. flock/core/flock_agent.py +492 -0
  15. flock/core/logging/__init__.py +2 -18
  16. flock/core/logging/formatters/base_formatter.py +36 -0
  17. flock/core/logging/formatters/formatter_factory.py +38 -0
  18. flock/core/logging/formatters/pprint_formatter.py +18 -0
  19. flock/core/logging/formatters/rich_formatters.py +132 -0
  20. flock/core/logging/formatters/theme_builder.py +480 -0
  21. flock/core/logging/formatters/themed_formatter.py +442 -0
  22. flock/core/logging/logging.py +123 -0
  23. flock/core/mixin/dspy_integration.py +171 -0
  24. flock/core/mixin/prompt_parser.py +125 -0
  25. flock/core/registry/agent_registry.py +103 -0
  26. flock/core/tools/basic_tools.py +273 -98
  27. flock/core/tools/dev_tools/github.py +161 -0
  28. flock/core/util/cli_helper.py +21 -0
  29. flock/core/util/input_resolver.py +156 -0
  30. flock/core/util/serializable.py +93 -0
  31. flock/themes/3024-day.toml +39 -0
  32. flock/themes/3024-night.toml +77 -0
  33. flock/themes/aardvark-blue.toml +77 -0
  34. flock/themes/abernathy.toml +77 -0
  35. flock/themes/adventure.toml +77 -0
  36. flock/themes/adventuretime.toml +77 -0
  37. flock/themes/afterglow.toml +77 -0
  38. flock/themes/alabaster.toml +77 -0
  39. flock/themes/alienblood.toml +77 -0
  40. flock/themes/andromeda.toml +77 -0
  41. flock/themes/apple-classic.toml +77 -0
  42. flock/themes/apple-system-colors.toml +77 -0
  43. flock/themes/arcoiris.toml +77 -0
  44. flock/themes/argonaut copy.toml +77 -0
  45. flock/themes/argonaut.toml +39 -0
  46. flock/themes/arthur.toml +77 -0
  47. flock/themes/ateliersulphurpool.toml +77 -0
  48. flock/themes/atom.toml +38 -0
  49. flock/themes/atom_test.toml +65 -0
  50. flock/themes/atomonelight.toml +77 -0
  51. flock/themes/aurora.toml +77 -0
  52. flock/themes/ayu copy.toml +77 -0
  53. flock/themes/ayu-light.toml +77 -0
  54. flock/themes/ayu-mirage.toml +77 -0
  55. flock/themes/ayu.toml +39 -0
  56. flock/themes/banana-blueberry.toml +77 -0
  57. flock/themes/batman.toml +77 -0
  58. flock/themes/belafonte-day.toml +77 -0
  59. flock/themes/belafonte-night.toml +77 -0
  60. flock/themes/birdsofparadise.toml +77 -0
  61. flock/themes/blazer.toml +77 -0
  62. flock/themes/blue-matrix.toml +77 -0
  63. flock/themes/blueberrypie.toml +77 -0
  64. flock/themes/bluedolphin.toml +77 -0
  65. flock/themes/blulocodark.toml +77 -0
  66. flock/themes/blulocolight.toml +77 -0
  67. flock/themes/borland.toml +77 -0
  68. flock/themes/breeze.toml +77 -0
  69. flock/themes/bright-lights.toml +77 -0
  70. flock/themes/broadcast.toml +77 -0
  71. flock/themes/brogrammer.toml +77 -0
  72. flock/themes/builtin-dark.toml +77 -0
  73. flock/themes/builtin-light.toml +77 -0
  74. flock/themes/builtin-pastel-dark.toml +77 -0
  75. flock/themes/builtin-solarized-dark.toml +77 -0
  76. flock/themes/builtin-solarized-light.toml +77 -0
  77. flock/themes/builtin-tango-dark.toml +77 -0
  78. flock/themes/builtin-tango-light.toml +77 -0
  79. flock/themes/c64.toml +77 -0
  80. flock/themes/calamity.toml +77 -0
  81. flock/themes/catppuccin-frappe.toml +77 -0
  82. flock/themes/catppuccin-latte.toml +77 -0
  83. flock/themes/catppuccin-macchiato.toml +77 -0
  84. flock/themes/catppuccin-mocha.toml +77 -0
  85. flock/themes/cga.toml +77 -0
  86. flock/themes/chalk.toml +77 -0
  87. flock/themes/chalkboard.toml +77 -0
  88. flock/themes/challengerdeep.toml +77 -0
  89. flock/themes/chester.toml +77 -0
  90. flock/themes/ciapre.toml +77 -0
  91. flock/themes/clrs.toml +77 -0
  92. flock/themes/cobalt-neon.toml +77 -0
  93. flock/themes/cobalt2.toml +77 -0
  94. flock/themes/coffee-theme.toml +77 -0
  95. flock/themes/crayonponyfish.toml +77 -0
  96. flock/themes/cutiepro.toml +77 -0
  97. flock/themes/cyberdyne.toml +77 -0
  98. flock/themes/cyberpunk.toml +77 -0
  99. flock/themes/cyberpunkscarletprotocol.toml +77 -0
  100. flock/themes/dark+.toml +77 -0
  101. flock/themes/dark-pastel.toml +77 -0
  102. flock/themes/darkermatrix.toml +77 -0
  103. flock/themes/darkmatrix.toml +77 -0
  104. flock/themes/darkside.toml +77 -0
  105. flock/themes/dayfox.toml +77 -0
  106. flock/themes/deep.toml +77 -0
  107. flock/themes/desert.toml +77 -0
  108. flock/themes/dimidium.toml +77 -0
  109. flock/themes/dimmedmonokai.toml +77 -0
  110. flock/themes/django.toml +77 -0
  111. flock/themes/djangorebornagain.toml +77 -0
  112. flock/themes/djangosmooth.toml +77 -0
  113. flock/themes/doom-peacock.toml +77 -0
  114. flock/themes/doomone.toml +77 -0
  115. flock/themes/dotgov.toml +77 -0
  116. flock/themes/dracula+.toml +77 -0
  117. flock/themes/dracula.toml +77 -0
  118. flock/themes/duckbones.toml +77 -0
  119. flock/themes/duotone-dark.toml +77 -0
  120. flock/themes/earthsong.toml +77 -0
  121. flock/themes/elemental.toml +77 -0
  122. flock/themes/elementary.toml +77 -0
  123. flock/themes/encom.toml +77 -0
  124. flock/themes/espresso-libre.toml +77 -0
  125. flock/themes/espresso.toml +77 -0
  126. flock/themes/everblush.toml +77 -0
  127. flock/themes/fahrenheit.toml +77 -0
  128. flock/themes/fairyfloss.toml +77 -0
  129. flock/themes/farmhouse-dark.toml +77 -0
  130. flock/themes/farmhouse-light.toml +77 -0
  131. flock/themes/fideloper.toml +77 -0
  132. flock/themes/firefly-traditional.toml +77 -0
  133. flock/themes/firefoxdev.toml +77 -0
  134. flock/themes/firewatch.toml +77 -0
  135. flock/themes/fishtank.toml +77 -0
  136. flock/themes/flat.toml +77 -0
  137. flock/themes/flatland.toml +77 -0
  138. flock/themes/flexoki-dark.toml +77 -0
  139. flock/themes/flexoki-light.toml +77 -0
  140. flock/themes/floraverse.toml +77 -0
  141. flock/themes/forestblue.toml +77 -0
  142. flock/themes/framer.toml +77 -0
  143. flock/themes/frontenddelight.toml +77 -0
  144. flock/themes/funforrest.toml +77 -0
  145. flock/themes/galaxy.toml +77 -0
  146. flock/themes/galizur.toml +77 -0
  147. flock/themes/github-dark.toml +77 -0
  148. flock/themes/github.toml +77 -0
  149. flock/themes/glacier.toml +77 -0
  150. flock/themes/grape.toml +77 -0
  151. flock/themes/grass.toml +77 -0
  152. flock/themes/grey-green.toml +77 -0
  153. flock/themes/gruber-darker.toml +77 -0
  154. flock/themes/gruvboxdark.toml +77 -0
  155. flock/themes/gruvboxdarkhard.toml +77 -0
  156. flock/themes/gruvboxlight.toml +77 -0
  157. flock/themes/guezwhoz.toml +77 -0
  158. flock/themes/hacktober.toml +77 -0
  159. flock/themes/hardcore.toml +77 -0
  160. flock/themes/harper.toml +77 -0
  161. flock/themes/hax0r-blue.toml +77 -0
  162. flock/themes/hax0r-gr33n.toml +77 -0
  163. flock/themes/hax0r-r3d.toml +77 -0
  164. flock/themes/highway.toml +77 -0
  165. flock/themes/hipster-green.toml +77 -0
  166. flock/themes/hivacruz.toml +77 -0
  167. flock/themes/homebrew.toml +77 -0
  168. flock/themes/hopscotch.256.toml +77 -0
  169. flock/themes/hopscotch.toml +77 -0
  170. flock/themes/hurtado.toml +77 -0
  171. flock/themes/hybrid.toml +77 -0
  172. flock/themes/ic-green-ppl.toml +77 -0
  173. flock/themes/ic-orange-ppl.toml +77 -0
  174. flock/themes/iceberg-dark.toml +77 -0
  175. flock/themes/iceberg-light.toml +77 -0
  176. flock/themes/idea.toml +77 -0
  177. flock/themes/idletoes.toml +77 -0
  178. flock/themes/ir-black.toml +77 -0
  179. flock/themes/iterm2-dark-background.toml +77 -0
  180. flock/themes/iterm2-default.toml +77 -0
  181. flock/themes/iterm2-light-background.toml +77 -0
  182. flock/themes/iterm2-pastel-dark-background.toml +77 -0
  183. flock/themes/iterm2-smoooooth.toml +77 -0
  184. flock/themes/iterm2-solarized-dark.toml +77 -0
  185. flock/themes/iterm2-solarized-light.toml +77 -0
  186. flock/themes/iterm2-tango-dark.toml +77 -0
  187. flock/themes/iterm2-tango-light.toml +77 -0
  188. flock/themes/jackie-brown.toml +77 -0
  189. flock/themes/japanesque.toml +77 -0
  190. flock/themes/jellybeans.toml +77 -0
  191. flock/themes/jetbrains-darcula.toml +77 -0
  192. flock/themes/jubi.toml +77 -0
  193. flock/themes/kanagawabones.toml +77 -0
  194. flock/themes/kibble.toml +77 -0
  195. flock/themes/kolorit.toml +77 -0
  196. flock/themes/konsolas.toml +77 -0
  197. flock/themes/kurokula.toml +77 -0
  198. flock/themes/lab-fox.toml +77 -0
  199. flock/themes/laser.toml +77 -0
  200. flock/themes/later-this-evening.toml +77 -0
  201. flock/themes/lavandula.toml +77 -0
  202. flock/themes/liquidcarbon.toml +77 -0
  203. flock/themes/liquidcarbontransparent.toml +77 -0
  204. flock/themes/liquidcarbontransparentinverse.toml +77 -0
  205. flock/themes/lovelace.toml +77 -0
  206. flock/themes/man-page.toml +77 -0
  207. flock/themes/mariana.toml +77 -0
  208. flock/themes/material.toml +77 -0
  209. flock/themes/materialdark.toml +77 -0
  210. flock/themes/materialdarker.toml +77 -0
  211. flock/themes/materialdesigncolors.toml +77 -0
  212. flock/themes/materialocean.toml +77 -0
  213. flock/themes/mathias.toml +77 -0
  214. flock/themes/matrix.toml +77 -0
  215. flock/themes/medallion.toml +77 -0
  216. flock/themes/mellifluous.toml +77 -0
  217. flock/themes/midnight-in-mojave.toml +77 -0
  218. flock/themes/mirage.toml +77 -0
  219. flock/themes/misterioso.toml +77 -0
  220. flock/themes/molokai.toml +77 -0
  221. flock/themes/monalisa.toml +77 -0
  222. flock/themes/monokai-remastered.toml +77 -0
  223. flock/themes/monokai-soda.toml +77 -0
  224. flock/themes/monokai-vivid.toml +77 -0
  225. flock/themes/n0tch2k.toml +77 -0
  226. flock/themes/neobones-dark.toml +77 -0
  227. flock/themes/neobones-light.toml +77 -0
  228. flock/themes/neon.toml +77 -0
  229. flock/themes/neopolitan.toml +77 -0
  230. flock/themes/neutron.toml +77 -0
  231. flock/themes/night-owlish-light.toml +77 -0
  232. flock/themes/nightfox.toml +77 -0
  233. flock/themes/nightlion-v1.toml +77 -0
  234. flock/themes/nightlion-v2.toml +77 -0
  235. flock/themes/niji.toml +77 -0
  236. flock/themes/nocturnal-winter.toml +77 -0
  237. flock/themes/nord-light.toml +77 -0
  238. flock/themes/nord.toml +77 -0
  239. flock/themes/novel.toml +77 -0
  240. flock/themes/nvimdark.toml +77 -0
  241. flock/themes/nvimlight.toml +77 -0
  242. flock/themes/obsidian.toml +77 -0
  243. flock/themes/ocean.toml +77 -0
  244. flock/themes/oceanic-next.toml +77 -0
  245. flock/themes/oceanicmaterial.toml +77 -0
  246. flock/themes/ollie.toml +77 -0
  247. flock/themes/onehalfdark.toml +77 -0
  248. flock/themes/onehalflight.toml +77 -0
  249. flock/themes/operator-mono-dark.toml +77 -0
  250. flock/themes/overnight-slumber.toml +77 -0
  251. flock/themes/oxocarbon.toml +77 -0
  252. flock/themes/palenighthc.toml +77 -0
  253. flock/themes/pandora.toml +77 -0
  254. flock/themes/paraiso-dark.toml +77 -0
  255. flock/themes/paulmillr.toml +77 -0
  256. flock/themes/pencildark.toml +77 -0
  257. flock/themes/pencillight.toml +77 -0
  258. flock/themes/peppermint.toml +77 -0
  259. flock/themes/piatto-light.toml +77 -0
  260. flock/themes/pnevma.toml +77 -0
  261. flock/themes/popping-and-locking.toml +77 -0
  262. flock/themes/primary.toml +77 -0
  263. flock/themes/pro-light.toml +77 -0
  264. flock/themes/pro.toml +77 -0
  265. flock/themes/purple-rain.toml +77 -0
  266. flock/themes/purplepeter.toml +77 -0
  267. flock/themes/rapture.toml +77 -0
  268. flock/themes/raycast-dark.toml +77 -0
  269. flock/themes/raycast-light.toml +77 -0
  270. flock/themes/rebecca.toml +77 -0
  271. flock/themes/red-alert.toml +77 -0
  272. flock/themes/red-planet.toml +77 -0
  273. flock/themes/red-sands.toml +77 -0
  274. flock/themes/relaxed.toml +77 -0
  275. flock/themes/retro.toml +77 -0
  276. flock/themes/rippedcasts.toml +77 -0
  277. flock/themes/rose-pine-dawn.toml +77 -0
  278. flock/themes/rose-pine-moon.toml +77 -0
  279. flock/themes/rose-pine.toml +77 -0
  280. flock/themes/rouge-2.toml +77 -0
  281. flock/themes/royal.toml +77 -0
  282. flock/themes/ryuuko.toml +77 -0
  283. flock/themes/sakura.toml +77 -0
  284. flock/themes/scarlet-protocol.toml +77 -0
  285. flock/themes/seafoam-pastel.toml +77 -0
  286. flock/themes/seashells.toml +77 -0
  287. flock/themes/seoulbones-dark.toml +77 -0
  288. flock/themes/seoulbones-light.toml +77 -0
  289. flock/themes/seti.toml +77 -0
  290. flock/themes/shades-of-purple.toml +77 -0
  291. flock/themes/shaman.toml +77 -0
  292. flock/themes/slate.toml +77 -0
  293. flock/themes/sleepyhollow.toml +77 -0
  294. flock/themes/smyck.toml +77 -0
  295. flock/themes/snazzy.toml +77 -0
  296. flock/themes/softserver.toml +77 -0
  297. flock/themes/solarized-darcula.toml +77 -0
  298. flock/themes/solarized-dark---patched.toml +77 -0
  299. flock/themes/solarized-dark-higher-contrast.toml +77 -0
  300. flock/themes/spacedust.toml +77 -0
  301. flock/themes/spacegray-eighties-dull.toml +77 -0
  302. flock/themes/spacegray-eighties.toml +77 -0
  303. flock/themes/spacegray.toml +77 -0
  304. flock/themes/spiderman.toml +77 -0
  305. flock/themes/spring.toml +77 -0
  306. flock/themes/square.toml +77 -0
  307. flock/themes/sublette.toml +77 -0
  308. flock/themes/subliminal.toml +77 -0
  309. flock/themes/sugarplum.toml +77 -0
  310. flock/themes/sundried.toml +77 -0
  311. flock/themes/symfonic.toml +77 -0
  312. flock/themes/synthwave-everything.toml +77 -0
  313. flock/themes/synthwave.toml +77 -0
  314. flock/themes/synthwavealpha.toml +77 -0
  315. flock/themes/tango-adapted.toml +77 -0
  316. flock/themes/tango-half-adapted.toml +77 -0
  317. flock/themes/teerb.toml +77 -0
  318. flock/themes/terafox.toml +77 -0
  319. flock/themes/terminal-basic.toml +77 -0
  320. flock/themes/thayer-bright.toml +77 -0
  321. flock/themes/the-hulk.toml +77 -0
  322. flock/themes/tinacious-design-(dark).toml +77 -0
  323. flock/themes/tinacious-design-(light).toml +77 -0
  324. flock/themes/tokyonight-day.toml +77 -0
  325. flock/themes/tokyonight-storm.toml +77 -0
  326. flock/themes/tokyonight.toml +77 -0
  327. flock/themes/tomorrow-night-blue.toml +77 -0
  328. flock/themes/tomorrow-night-bright.toml +77 -0
  329. flock/themes/tomorrow-night-burns.toml +77 -0
  330. flock/themes/tomorrow-night-eighties.toml +77 -0
  331. flock/themes/tomorrow-night.toml +77 -0
  332. flock/themes/tomorrow.toml +77 -0
  333. flock/themes/toychest.toml +77 -0
  334. flock/themes/treehouse.toml +77 -0
  335. flock/themes/twilight.toml +77 -0
  336. flock/themes/ubuntu.toml +77 -0
  337. flock/themes/ultradark.toml +77 -0
  338. flock/themes/ultraviolent.toml +77 -0
  339. flock/themes/underthesea.toml +77 -0
  340. flock/themes/unikitty.toml +77 -0
  341. flock/themes/urple.toml +77 -0
  342. flock/themes/vaughn.toml +77 -0
  343. flock/themes/vesper.toml +77 -0
  344. flock/themes/vibrantink.toml +77 -0
  345. flock/themes/vimbones.toml +77 -0
  346. flock/themes/violet-dark.toml +77 -0
  347. flock/themes/violet-light.toml +77 -0
  348. flock/themes/warmneon.toml +77 -0
  349. flock/themes/wez.toml +77 -0
  350. flock/themes/whimsy.toml +77 -0
  351. flock/themes/wildcherry.toml +77 -0
  352. flock/themes/wilmersdorf.toml +77 -0
  353. flock/themes/wombat.toml +77 -0
  354. flock/themes/wryan.toml +77 -0
  355. flock/themes/xcodedark.toml +77 -0
  356. flock/themes/xcodedarkhc.toml +77 -0
  357. flock/themes/xcodelight.toml +77 -0
  358. flock/themes/xcodelighthc.toml +77 -0
  359. flock/themes/xcodewwdc.toml +77 -0
  360. flock/themes/zenbones-dark.toml +77 -0
  361. flock/themes/zenbones-light.toml +77 -0
  362. flock/themes/zenbones.toml +77 -0
  363. flock/themes/zenburn.toml +77 -0
  364. flock/themes/zenburned.toml +77 -0
  365. flock/themes/zenwritten-dark.toml +77 -0
  366. flock/themes/zenwritten-light.toml +77 -0
  367. flock/workflow/activities.py +117 -115
  368. flock/workflow/agent_activities.py +24 -26
  369. flock/workflow/temporal_setup.py +38 -37
  370. flock/workflow/workflow.py +58 -53
  371. flock_core-0.2.1.dist-info/METADATA +287 -0
  372. flock_core-0.2.1.dist-info/RECORD +375 -0
  373. {flock_core-0.1.1.dist-info → flock_core-0.2.1.dist-info}/licenses/LICENSE +21 -21
  374. flock/agents/declarative_agent.py +0 -166
  375. flock/app/components/__init__.py +0 -14
  376. flock/app/components/charts/agent_workflow.py +0 -14
  377. flock/app/components/charts/core_architecture.py +0 -14
  378. flock/app/components/charts/tool_system.py +0 -14
  379. flock/app/components/history_grid.py +0 -168
  380. flock/app/components/history_grid_alt.py +0 -189
  381. flock/app/components/sidebar.py +0 -19
  382. flock/app/components/theme.py +0 -9
  383. flock/app/components/util.py +0 -18
  384. flock/app/hive_app.py +0 -118
  385. flock/app/html/d3.html +0 -179
  386. flock/app/modules/__init__.py +0 -12
  387. flock/app/modules/about.py +0 -17
  388. flock/app/modules/agent_detail.py +0 -70
  389. flock/app/modules/agent_list.py +0 -59
  390. flock/app/modules/playground.py +0 -322
  391. flock/app/modules/settings.py +0 -96
  392. flock/core/agent.py +0 -150
  393. flock/core/agent_registry.py +0 -162
  394. flock/core/context.py +0 -279
  395. flock/core/handoff/handoff_base.py +0 -12
  396. flock/core/logging/error_handler.py +0 -84
  397. flock/core/logging/formatters.py +0 -122
  398. flock/core/logging/handlers.py +0 -117
  399. flock/core/logging/logger.py +0 -107
  400. flock/core/serializable.py +0 -206
  401. flock_core-0.1.1.dist-info/METADATA +0 -449
  402. flock_core-0.1.1.dist-info/RECORD +0 -48
  403. flock_core-0.1.1.dist-info/entry_points.txt +0 -2
  404. /flock/{core/config/declarative_agent_config.py → workflow/__init__.py} +0 -0
  405. {flock_core-0.1.1.dist-info → flock_core-0.2.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,156 @@
1
+ """Utility functions for resolving input keys to their corresponding values."""
2
+
3
+ from flock.core.context.context import FlockContext
4
+
5
+
6
+ def split_top_level(s: str) -> list[str]:
7
+ """Split a string on commas that are not enclosed within brackets, parentheses, or quotes.
8
+
9
+ This function iterates over the string while keeping track of the nesting level. It
10
+ only splits on commas when the nesting level is zero. It also properly handles quoted
11
+ substrings.
12
+
13
+ Args:
14
+ s (str): The input string.
15
+
16
+ Returns:
17
+ List[str]: A list of substrings split at top-level commas.
18
+ """
19
+ parts = []
20
+ current = []
21
+ level = 0
22
+ in_quote = False
23
+ quote_char = ""
24
+
25
+ for char in s:
26
+ # If inside a quote, only exit when the matching quote is found.
27
+ if in_quote:
28
+ current.append(char)
29
+ if char == quote_char:
30
+ in_quote = False
31
+ elif char == "\\":
32
+ # Include escape sequences
33
+ continue
34
+ continue
35
+
36
+ # Check for the start of a quote.
37
+ if char in ('"', "'"):
38
+ in_quote = True
39
+ quote_char = char
40
+ current.append(char)
41
+ continue
42
+
43
+ # Track nesting.
44
+ if char in "([{":
45
+ level += 1
46
+ elif char in ")]}":
47
+ level -= 1
48
+
49
+ # Split on commas if not nested.
50
+ if char == "," and level == 0:
51
+ parts.append("".join(current).strip())
52
+ current = []
53
+ else:
54
+ current.append(char)
55
+ if current:
56
+ parts.append("".join(current).strip())
57
+ return parts
58
+
59
+
60
+ def _parse_keys(keys: list[str]) -> list[str]:
61
+ """Split a comma‐separated string and strip any type annotations.
62
+
63
+ For example, "a, b: list[str]" becomes ["a", "b"].
64
+ """
65
+ res_keys = []
66
+ for key in keys:
67
+ if "|" in key:
68
+ key = key.split("|")[0].strip()
69
+ if ":" in key:
70
+ key = key.split(":")[0].strip()
71
+ res_keys.append(key)
72
+ return res_keys
73
+
74
+
75
+ def top_level_to_keys(s: str) -> list[str]:
76
+ """Convert a top-level comma-separated string to a list of keys."""
77
+ top_level_split = split_top_level(s)
78
+ return _parse_keys(top_level_split)
79
+
80
+
81
+ def resolve_inputs(
82
+ input_spec: str, context: FlockContext, previous_agent_name: str
83
+ ) -> dict:
84
+ """Build a dictionary of inputs based on the input specification string and the provided context.
85
+
86
+ The lookup rules are:
87
+ - "context" (case-insensitive): returns the entire context.
88
+ - "context.property": returns an attribute from the context.
89
+ - "def.agent_name": returns the agent definition for the given agent.
90
+ - "agent_name": returns the most up2date record from the given agent's history.
91
+ - "agent_name.property": returns the value of a property from the state variable keyed by "agent_name.property".
92
+ - "property": searches the history for the most recent value of a property.
93
+ - Otherwise, if no matching value is found, fallback to the FLOCK_INITIAL_INPUT.
94
+
95
+ -> Recommendations:
96
+ - prefix your agent variables with the agent name or a short handle to avoid conflicts.
97
+ eg. agent name: "idea_agent", variable: "ia_idea" (ia = idea agent)
98
+ - or set hand off mode to strict to avoid conflicts.
99
+ with strict mode, the agent will only accept inputs from the previous agent.
100
+
101
+ Args:
102
+ input_spec: Comma-separated input keys (e.g., "query" or "agent_name.property").
103
+ context: A FlockContext instance.
104
+
105
+ Returns:
106
+ A dictionary mapping each input key to its resolved value.
107
+ """
108
+ split_input = split_top_level(input_spec)
109
+ keys = _parse_keys(split_input)
110
+ inputs = {}
111
+
112
+ for key in keys:
113
+ split_key = key.split(".")
114
+
115
+ # Case 1: A single key
116
+ if len(split_key) == 1:
117
+ # Special keyword: "context"
118
+ if key.lower() == "context":
119
+ inputs[key] = context
120
+ continue
121
+
122
+ # Try to get a historic record for an agent (if any)
123
+ historic_records = context.get_agent_history(key)
124
+ if historic_records:
125
+ # You may choose to pass the entire record or just its data.
126
+ inputs[key] = historic_records[0].data
127
+ continue
128
+
129
+ # Fallback to the most recent value in the state
130
+ historic_value = context.get_most_recent_value(key)
131
+ if historic_value is not None:
132
+ inputs[key] = historic_value
133
+ continue
134
+
135
+ # Fallback to the initial input
136
+ inputs[key] = context.get_variable("flock." + key)
137
+
138
+ # Case 2: A compound key (e.g., "agent_name.property" or "context.property")
139
+ elif len(split_key) == 2:
140
+ entity_name, property_name = split_key
141
+
142
+ if entity_name.lower() == "context":
143
+ # Try to fetch the attribute from the context
144
+ inputs[key] = getattr(context, property_name, None)
145
+ continue
146
+
147
+ if entity_name.lower() == "def":
148
+ # Return the agent definition for the given property name
149
+ inputs[key] = context.get_agent_definition(property_name)
150
+ continue
151
+
152
+ # Otherwise, attempt to look up a state variable with the key "agent_name.property"
153
+ inputs[key] = context.get_variable(f"{entity_name}.{property_name}")
154
+ continue
155
+
156
+ return inputs
@@ -0,0 +1,93 @@
1
+ """Module for serializable objects in the system."""
2
+
3
+ import json
4
+ from abc import ABC, abstractmethod
5
+ from pathlib import Path
6
+ from typing import Any, TypeVar
7
+
8
+ import cloudpickle
9
+ import msgpack
10
+
11
+ T = TypeVar("T", bound="Serializable")
12
+
13
+
14
+ class Serializable(ABC):
15
+ """Base class for all serializable objects in the system.
16
+
17
+ Provides methods for serializing/deserializing objects to various formats.
18
+ """
19
+
20
+ @abstractmethod
21
+ def to_dict(self) -> dict[str, Any]:
22
+ """Convert instance to dictionary representation."""
23
+ pass
24
+
25
+ @classmethod
26
+ @abstractmethod
27
+ def from_dict(cls: type[T], data: dict[str, Any]) -> T:
28
+ """Create instance from dictionary representation."""
29
+ pass
30
+
31
+ def to_json(self) -> str:
32
+ """Serialize to JSON string."""
33
+ try:
34
+ return json.dumps(self.to_dict())
35
+ except Exception:
36
+ raise
37
+
38
+ @classmethod
39
+ def from_json(cls: type[T], json_str: str) -> T:
40
+ """Create instance from JSON string."""
41
+ try:
42
+ return cls.from_dict(json.loads(json_str))
43
+ except Exception:
44
+ raise
45
+
46
+ def to_msgpack(self, path: Path | None = None) -> bytes:
47
+ """Serialize to msgpack bytes."""
48
+ try:
49
+ msgpack_bytes = msgpack.packb(self.to_dict())
50
+ if path:
51
+ path.write_bytes(msgpack_bytes)
52
+ return msgpack_bytes
53
+ except Exception:
54
+ raise
55
+
56
+ @classmethod
57
+ def from_msgpack(cls: type[T], msgpack_bytes: bytes) -> T:
58
+ """Create instance from msgpack bytes."""
59
+ try:
60
+ return cls.from_dict(msgpack.unpackb(msgpack_bytes))
61
+ except Exception:
62
+ raise
63
+
64
+ @classmethod
65
+ def from_msgpack_file(cls: type[T], path: Path) -> T:
66
+ """Create instance from msgpack file."""
67
+ try:
68
+ return cls.from_msgpack(path.read_bytes())
69
+ except Exception:
70
+ raise
71
+
72
+ def to_pickle(self) -> bytes:
73
+ """Serialize to pickle bytes."""
74
+ try:
75
+ return cloudpickle.dumps(self)
76
+ except Exception:
77
+ raise
78
+
79
+ @classmethod
80
+ def from_pickle(cls, pickle_bytes: bytes) -> T:
81
+ """Create instance from pickle bytes."""
82
+ try:
83
+ return cloudpickle.loads(pickle_bytes)
84
+ except Exception:
85
+ raise
86
+
87
+ @classmethod
88
+ def from_pickle_file(cls: type[T], path: Path) -> T:
89
+ """Create instance from pickle file."""
90
+ try:
91
+ return cls.from_pickle(path.read_bytes())
92
+ except Exception:
93
+ raise
@@ -0,0 +1,39 @@
1
+ [rich]
2
+ table_show_lines = false
3
+ table_box = "SIMPLE"
4
+ table_header_align = "left"
5
+ table_row_styles = [ "", "italic",]
6
+ panel_padding = [ 1, 1,]
7
+ panel_title_align = "right"
8
+
9
+ [colors.bright]
10
+ black = "#5c5855"
11
+ blue = "#807d7c"
12
+ cyan = "#cdab53"
13
+ green = "#3a3432"
14
+ magenta = "#d6d5d4"
15
+ red = "#e8bbd0"
16
+ white = "#f7f7f7"
17
+ yellow = "#4a4543"
18
+
19
+ [colors.cursor]
20
+ cursor = "#4a4543"
21
+ text = "#f7f7f7"
22
+
23
+ [colors.normal]
24
+ black = "#090300"
25
+ blue = "#01a0e4"
26
+ cyan = "#b5e4f4"
27
+ green = "#01a252"
28
+ magenta = "#a16a94"
29
+ red = "#db2d20"
30
+ white = "#a5a2a2"
31
+ yellow = "#fded02"
32
+
33
+ [colors.primary]
34
+ background = "#f7f7f7"
35
+ foreground = "#4a4543"
36
+
37
+ [colors.selection]
38
+ background = "#a5a2a2"
39
+ text = "#4a4543"
@@ -0,0 +1,77 @@
1
+ [rich]
2
+ panel_style = "on #090300"
3
+ table_header_style = "bold #a5a2a2 on #4a4543"
4
+ table_title_style = "bold #a5a2a2"
5
+ table_border_style = "#807d7c"
6
+ panel_border_style = "#807d7c"
7
+ column_output = "bold #a5a2a2"
8
+ column_value = "#a5a2a2"
9
+ bright_black = "#5c5855"
10
+ bright_blue = "#807d7c"
11
+ bright_cyan = "#cdab53"
12
+ bright_green = "#3a3432"
13
+ bright_magenta = "#d6d5d4"
14
+ bright_red = "#e8bbd0"
15
+ bright_white = "#f7f7f7"
16
+ bright_yellow = "#4a4543"
17
+ normal_black = "#090300"
18
+ normal_blue = "#01a0e4"
19
+ normal_cyan = "#b5e4f4"
20
+ normal_green = "#01a252"
21
+ normal_magenta = "#a16a94"
22
+ normal_red = "#db2d20"
23
+ normal_white = "#a5a2a2"
24
+ normal_yellow = "#fded02"
25
+ cursor_cursor = "#a5a2a2"
26
+ cursor_text = "#090300"
27
+ table_show_lines = false
28
+ table_box = "MINIMAL"
29
+ panel_padding = [ 1, 1,]
30
+ panel_title_align = "center"
31
+ table_row_styles = [ "", "dim",]
32
+ table_safe_box = true
33
+ table_padding = [ 0, 1,]
34
+ table_collapse_padding = false
35
+ table_pad_edge = true
36
+ table_expand = false
37
+ table_show_footer = false
38
+ table_show_edge = true
39
+ table_leading = 0
40
+ table_style = "none"
41
+ table_footer_style = "none"
42
+ table_caption_style = "none"
43
+ table_title_justify = "center"
44
+ table_caption_justify = "center"
45
+ table_highlight = false
46
+
47
+ [colors.bright]
48
+ black = "#5c5855"
49
+ blue = "#807d7c"
50
+ cyan = "#cdab53"
51
+ green = "#3a3432"
52
+ magenta = "#d6d5d4"
53
+ red = "#e8bbd0"
54
+ white = "#f7f7f7"
55
+ yellow = "#4a4543"
56
+
57
+ [colors.cursor]
58
+ cursor = "#a5a2a2"
59
+ text = "#090300"
60
+
61
+ [colors.normal]
62
+ black = "#090300"
63
+ blue = "#01a0e4"
64
+ cyan = "#b5e4f4"
65
+ green = "#01a252"
66
+ magenta = "#a16a94"
67
+ red = "#db2d20"
68
+ white = "#a5a2a2"
69
+ yellow = "#fded02"
70
+
71
+ [colors.primary]
72
+ background = "#090300"
73
+ foreground = "#a5a2a2"
74
+
75
+ [colors.selection]
76
+ background = "#4a4543"
77
+ text = "#a5a2a2"
@@ -0,0 +1,77 @@
1
+ [rich]
2
+ panel_style = "on #102040"
3
+ table_header_style = "bold #000000 on #bfdbfe"
4
+ table_title_style = "bold #dddddd"
5
+ table_border_style = "#60a4ec"
6
+ panel_border_style = "#60a4ec"
7
+ column_output = "bold #dddddd"
8
+ column_value = "#dddddd"
9
+ bright_black = "#454545"
10
+ bright_blue = "#60a4ec"
11
+ bright_cyan = "#60b6cb"
12
+ bright_green = "#95dc55"
13
+ bright_magenta = "#e26be2"
14
+ bright_red = "#f05b50"
15
+ bright_white = "#f7f7f7"
16
+ bright_yellow = "#ffe763"
17
+ normal_black = "#191919"
18
+ normal_blue = "#1370d3"
19
+ normal_cyan = "#008eb0"
20
+ normal_green = "#4b8c0f"
21
+ normal_magenta = "#c43ac3"
22
+ normal_red = "#aa342e"
23
+ normal_white = "#bebebe"
24
+ normal_yellow = "#dbba00"
25
+ cursor_cursor = "#007acc"
26
+ cursor_text = "#bfdbfe"
27
+ table_show_lines = true
28
+ table_box = "ROUNDED"
29
+ panel_padding = [ 1, 2,]
30
+ panel_title_align = "center"
31
+ table_row_styles = [ "", "underline",]
32
+ table_safe_box = true
33
+ table_padding = [ 0, 1,]
34
+ table_collapse_padding = false
35
+ table_pad_edge = true
36
+ table_expand = false
37
+ table_show_footer = false
38
+ table_show_edge = true
39
+ table_leading = 0
40
+ table_style = "none"
41
+ table_footer_style = "none"
42
+ table_caption_style = "none"
43
+ table_title_justify = "center"
44
+ table_caption_justify = "center"
45
+ table_highlight = false
46
+
47
+ [colors.bright]
48
+ black = "#454545"
49
+ blue = "#60a4ec"
50
+ cyan = "#60b6cb"
51
+ green = "#95dc55"
52
+ magenta = "#e26be2"
53
+ red = "#f05b50"
54
+ white = "#f7f7f7"
55
+ yellow = "#ffe763"
56
+
57
+ [colors.cursor]
58
+ cursor = "#007acc"
59
+ text = "#bfdbfe"
60
+
61
+ [colors.normal]
62
+ black = "#191919"
63
+ blue = "#1370d3"
64
+ cyan = "#008eb0"
65
+ green = "#4b8c0f"
66
+ magenta = "#c43ac3"
67
+ red = "#aa342e"
68
+ white = "#bebebe"
69
+ yellow = "#dbba00"
70
+
71
+ [colors.primary]
72
+ background = "#102040"
73
+ foreground = "#dddddd"
74
+
75
+ [colors.selection]
76
+ background = "#bfdbfe"
77
+ text = "#000000"
@@ -0,0 +1,77 @@
1
+ [rich]
2
+ panel_style = "on #111416"
3
+ table_header_style = "bold #333333 on #eeeeec"
4
+ table_title_style = "bold #eeeeec"
5
+ table_border_style = "#11b5f6"
6
+ panel_border_style = "#11b5f6"
7
+ column_output = "bold #eeeeec"
8
+ column_value = "#eeeeec"
9
+ bright_black = "#404040"
10
+ bright_blue = "#11b5f6"
11
+ bright_cyan = "#00ffff"
12
+ bright_green = "#00ff00"
13
+ bright_magenta = "#ff00ff"
14
+ bright_red = "#ff0000"
15
+ bright_white = "#ffffff"
16
+ bright_yellow = "#ffff00"
17
+ normal_black = "#000000"
18
+ normal_blue = "#1093f5"
19
+ normal_cyan = "#00cdcd"
20
+ normal_green = "#00cd00"
21
+ normal_magenta = "#cd00cd"
22
+ normal_red = "#cd0000"
23
+ normal_white = "#faebd7"
24
+ normal_yellow = "#cdcd00"
25
+ cursor_cursor = "#bbbbbb"
26
+ cursor_text = "#ffffff"
27
+ table_show_lines = true
28
+ table_box = "HEAVY"
29
+ panel_padding = [ 2, 2,]
30
+ panel_title_align = "center"
31
+ table_row_styles = [ "", "italic",]
32
+ table_safe_box = true
33
+ table_padding = [ 0, 1,]
34
+ table_collapse_padding = false
35
+ table_pad_edge = true
36
+ table_expand = false
37
+ table_show_footer = false
38
+ table_show_edge = true
39
+ table_leading = 0
40
+ table_style = "none"
41
+ table_footer_style = "none"
42
+ table_caption_style = "none"
43
+ table_title_justify = "center"
44
+ table_caption_justify = "center"
45
+ table_highlight = false
46
+
47
+ [colors.bright]
48
+ black = "#404040"
49
+ blue = "#11b5f6"
50
+ cyan = "#00ffff"
51
+ green = "#00ff00"
52
+ magenta = "#ff00ff"
53
+ red = "#ff0000"
54
+ white = "#ffffff"
55
+ yellow = "#ffff00"
56
+
57
+ [colors.cursor]
58
+ cursor = "#bbbbbb"
59
+ text = "#ffffff"
60
+
61
+ [colors.normal]
62
+ black = "#000000"
63
+ blue = "#1093f5"
64
+ cyan = "#00cdcd"
65
+ green = "#00cd00"
66
+ magenta = "#cd00cd"
67
+ red = "#cd0000"
68
+ white = "#faebd7"
69
+ yellow = "#cdcd00"
70
+
71
+ [colors.primary]
72
+ background = "#111416"
73
+ foreground = "#eeeeec"
74
+
75
+ [colors.selection]
76
+ background = "#eeeeec"
77
+ text = "#333333"
@@ -0,0 +1,77 @@
1
+ [rich]
2
+ panel_style = "on #040404"
3
+ table_header_style = "bold #ffffff on #606060"
4
+ table_title_style = "bold #feffff"
5
+ table_border_style = "#97d7ef"
6
+ panel_border_style = "#97d7ef"
7
+ column_output = "bold #feffff"
8
+ column_value = "#feffff"
9
+ bright_black = "#685656"
10
+ bright_blue = "#97d7ef"
11
+ bright_cyan = "#bdcfe5"
12
+ bright_green = "#99b52c"
13
+ bright_magenta = "#aa7900"
14
+ bright_red = "#d76b42"
15
+ bright_white = "#e4d5c7"
16
+ bright_yellow = "#ffb670"
17
+ normal_black = "#040404"
18
+ normal_blue = "#417ab3"
19
+ normal_cyan = "#bdcfe5"
20
+ normal_green = "#5da602"
21
+ normal_magenta = "#e5c499"
22
+ normal_red = "#d84a33"
23
+ normal_white = "#dbded8"
24
+ normal_yellow = "#eebb6e"
25
+ cursor_cursor = "#feffff"
26
+ cursor_text = "#000000"
27
+ table_show_lines = false
28
+ table_box = "SIMPLE"
29
+ panel_padding = [ 0, 2,]
30
+ panel_title_align = "center"
31
+ table_row_styles = [ ""]
32
+ table_safe_box = true
33
+ table_padding = [ 0, 1,]
34
+ table_collapse_padding = false
35
+ table_pad_edge = true
36
+ table_expand = false
37
+ table_show_footer = false
38
+ table_show_edge = true
39
+ table_leading = 0
40
+ table_style = "none"
41
+ table_footer_style = "none"
42
+ table_caption_style = "none"
43
+ table_title_justify = "center"
44
+ table_caption_justify = "center"
45
+ table_highlight = false
46
+
47
+ [colors.bright]
48
+ black = "#685656"
49
+ blue = "#97d7ef"
50
+ cyan = "#bdcfe5"
51
+ green = "#99b52c"
52
+ magenta = "#aa7900"
53
+ red = "#d76b42"
54
+ white = "#e4d5c7"
55
+ yellow = "#ffb670"
56
+
57
+ [colors.cursor]
58
+ cursor = "#feffff"
59
+ text = "#000000"
60
+
61
+ [colors.normal]
62
+ black = "#040404"
63
+ blue = "#417ab3"
64
+ cyan = "#bdcfe5"
65
+ green = "#5da602"
66
+ magenta = "#e5c499"
67
+ red = "#d84a33"
68
+ white = "#dbded8"
69
+ yellow = "#eebb6e"
70
+
71
+ [colors.primary]
72
+ background = "#040404"
73
+ foreground = "#feffff"
74
+
75
+ [colors.selection]
76
+ background = "#606060"
77
+ text = "#ffffff"
@@ -0,0 +1,77 @@
1
+ [rich]
2
+ panel_style = "on #1f1d45"
3
+ table_header_style = "bold #f3d9c4 on #706b4e"
4
+ table_title_style = "bold #f8dcc0"
5
+ table_border_style = "#1997c6"
6
+ panel_border_style = "#1997c6"
7
+ column_output = "bold #f8dcc0"
8
+ column_value = "#f8dcc0"
9
+ bright_black = "#4e7cbf"
10
+ bright_blue = "#1997c6"
11
+ bright_cyan = "#c8faf4"
12
+ bright_green = "#9eff6e"
13
+ bright_magenta = "#9b5953"
14
+ bright_red = "#fc5f5a"
15
+ bright_white = "#f6f5fb"
16
+ bright_yellow = "#efc11a"
17
+ normal_black = "#050404"
18
+ normal_blue = "#0f4ac6"
19
+ normal_cyan = "#70a598"
20
+ normal_green = "#4ab118"
21
+ normal_magenta = "#665993"
22
+ normal_red = "#bd0013"
23
+ normal_white = "#f8dcc0"
24
+ normal_yellow = "#e7741e"
25
+ cursor_cursor = "#efbf38"
26
+ cursor_text = "#08080a"
27
+ table_show_lines = true
28
+ table_box = "MINIMAL"
29
+ panel_padding = [ 1, 2,]
30
+ panel_title_align = "right"
31
+ table_row_styles = [ "", "dim",]
32
+ table_safe_box = true
33
+ table_padding = [ 0, 1,]
34
+ table_collapse_padding = false
35
+ table_pad_edge = true
36
+ table_expand = false
37
+ table_show_footer = false
38
+ table_show_edge = true
39
+ table_leading = 0
40
+ table_style = "none"
41
+ table_footer_style = "none"
42
+ table_caption_style = "none"
43
+ table_title_justify = "center"
44
+ table_caption_justify = "center"
45
+ table_highlight = true
46
+
47
+ [colors.bright]
48
+ black = "#4e7cbf"
49
+ blue = "#1997c6"
50
+ cyan = "#c8faf4"
51
+ green = "#9eff6e"
52
+ magenta = "#9b5953"
53
+ red = "#fc5f5a"
54
+ white = "#f6f5fb"
55
+ yellow = "#efc11a"
56
+
57
+ [colors.cursor]
58
+ cursor = "#efbf38"
59
+ text = "#08080a"
60
+
61
+ [colors.normal]
62
+ black = "#050404"
63
+ blue = "#0f4ac6"
64
+ cyan = "#70a598"
65
+ green = "#4ab118"
66
+ magenta = "#665993"
67
+ red = "#bd0013"
68
+ white = "#f8dcc0"
69
+ yellow = "#e7741e"
70
+
71
+ [colors.primary]
72
+ background = "#1f1d45"
73
+ foreground = "#f8dcc0"
74
+
75
+ [colors.selection]
76
+ background = "#706b4e"
77
+ text = "#f3d9c4"