flock-core 0.5.22__py3-none-any.whl → 0.5.24__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.

flock/core/agent.py CHANGED
@@ -226,11 +226,7 @@ class Agent(metaclass=AutoTracedMeta):
226
226
  comp_name = self._component_display_name(component)
227
227
  priority = getattr(component, "priority", 0)
228
228
  logger.info(
229
- "Agent %s: utility added: component=%s, priority=%s, total_utilities=%s",
230
- self.name,
231
- comp_name,
232
- priority,
233
- len(self.utilities),
229
+ f"Agent {self.name}: utility added: component={comp_name}, priority={priority}, total_utilities={len(self.utilities)}"
234
230
  )
235
231
  self.utilities.sort(key=lambda comp: getattr(comp, "priority", 0))
236
232
 
@@ -492,13 +492,17 @@ class Flock(metaclass=AutoTracedMeta):
492
492
 
493
493
  # Runtime --------------------------------------------------------------
494
494
 
495
- async def run_until_idle(self) -> None:
495
+ async def run_until_idle(self, *, wait_for_input: bool = False) -> None:
496
496
  """Wait for all scheduled agent tasks to complete.
497
497
 
498
498
  This method blocks until the blackboard reaches a stable state where no
499
499
  agents are queued for execution. Essential for batch processing and ensuring
500
500
  all agent cascades complete before continuing.
501
501
 
502
+ Args:
503
+ wait_for_input: If True, waits for user input before returning (default: False).
504
+ Useful for debugging or step-by-step execution.
505
+
502
506
  Note:
503
507
  Automatically resets circuit breaker counters and shuts down MCP connections
504
508
  when idle. Used with publish() for event-driven workflows.
@@ -514,6 +518,12 @@ class Flock(metaclass=AutoTracedMeta):
514
518
  >>> await flock.publish_many([task1, task2, task3])
515
519
  >>> await flock.run_until_idle() # All tasks processed in parallel
516
520
 
521
+ >>> # Step-by-step execution with user prompts
522
+ >>> await flock.publish(task1)
523
+ >>> await flock.run_until_idle(wait_for_input=True) # Pauses for user input
524
+ >>> await flock.publish(task2)
525
+ >>> await flock.run_until_idle(wait_for_input=True) # Pauses again
526
+
517
527
  See Also:
518
528
  - publish(): Event-driven artifact publishing
519
529
  - publish_many(): Batch publishing for parallel execution
@@ -553,6 +563,12 @@ class Flock(metaclass=AutoTracedMeta):
553
563
  # Automatically shutdown MCP connections when idle
554
564
  await self.shutdown(include_components=False)
555
565
 
566
+ # Wait for user input if requested
567
+ if wait_for_input:
568
+ # Use asyncio.to_thread to avoid blocking the event loop
569
+ # since input() is a blocking I/O operation
570
+ await asyncio.to_thread(input, "Press any key to continue....")
571
+
556
572
  async def direct_invoke(
557
573
  self, agent: Agent, inputs: Sequence[BaseModel | Mapping[str, Any] | Artifact]
558
574
  ) -> list[Artifact]:
@@ -715,6 +731,7 @@ class Flock(metaclass=AutoTracedMeta):
715
731
  partition_key: str | None = None,
716
732
  tags: set[str] | None = None,
717
733
  is_dashboard: bool = False,
734
+ schedule_immediately: bool = True,
718
735
  ) -> Artifact:
719
736
  """Publish an artifact to the blackboard (event-driven).
720
737
 
@@ -727,16 +744,22 @@ class Flock(metaclass=AutoTracedMeta):
727
744
  partition_key=partition_key,
728
745
  tags=tags,
729
746
  is_dashboard=is_dashboard,
747
+ schedule_immediately=schedule_immediately,
730
748
  )
731
749
 
732
750
  async def publish_many(
733
- self, objects: Iterable[BaseModel | dict | Artifact], **kwargs: Any
751
+ self,
752
+ objects: Iterable[BaseModel | dict | Artifact],
753
+ schedule_immediately: bool = True,
754
+ **kwargs: Any,
734
755
  ) -> list[Artifact]:
735
756
  """Publish multiple artifacts at once (event-driven).
736
757
 
737
758
  Delegates to ArtifactManager for batch publishing.
738
759
  """
739
- return await self._artifact_manager.publish_many(objects, **kwargs)
760
+ return await self._artifact_manager.publish_many(
761
+ objects, schedule_immediately=schedule_immediately, **kwargs
762
+ )
740
763
 
741
764
  # -----------------------------------------------------------------------------
742
765
  # NEW DIRECT INVOCATION API - Explicit Control
@@ -53,6 +53,7 @@ class ArtifactManager:
53
53
  partition_key: str | None = None,
54
54
  tags: set[str] | None = None,
55
55
  is_dashboard: bool = False,
56
+ schedule_immediately: bool = True,
56
57
  ) -> Artifact:
57
58
  """Publish an artifact to the blackboard (event-driven).
58
59
 
@@ -125,12 +126,18 @@ class ArtifactManager:
125
126
  "Expected BaseModel, dict, or Artifact."
126
127
  )
127
128
 
128
- # Persist and schedule matching agents
129
- await self.persist_and_schedule(artifact)
129
+ if schedule_immediately:
130
+ await self.persist_and_schedule(artifact)
131
+ else:
132
+ await self.persist(artifact)
133
+
130
134
  return artifact
131
135
 
132
136
  async def publish_many(
133
- self, objects: Iterable[BaseModel | dict | Artifact], **kwargs: Any
137
+ self,
138
+ objects: Iterable[BaseModel | dict | Artifact],
139
+ schedule_immediately: bool = True,
140
+ **kwargs: Any,
134
141
  ) -> list[Artifact]:
135
142
  """Publish multiple artifacts at once (event-driven).
136
143
 
@@ -150,7 +157,9 @@ class ArtifactManager:
150
157
  """
151
158
  artifacts = []
152
159
  for obj in objects:
153
- artifact = await self.publish(obj, **kwargs)
160
+ artifact = await self.publish(
161
+ obj, schedule_immediately=schedule_immediately, **kwargs
162
+ )
154
163
  artifacts.append(artifact)
155
164
  return artifacts
156
165
 
@@ -164,5 +173,14 @@ class ArtifactManager:
164
173
  self._orchestrator.metrics["artifacts_published"] += 1
165
174
  await self._scheduler.schedule_artifact(artifact)
166
175
 
176
+ async def persist(self, artifact: Artifact) -> None:
177
+ """Persist artifact to store without scheduling.
178
+
179
+ Args:
180
+ artifact: Artifact to publish
181
+ """
182
+ await self._store.publish(artifact)
183
+ self._orchestrator.metrics["artifacts_published"] += 1
184
+
167
185
 
168
186
  __all__ = ["ArtifactManager"]
@@ -4,13 +4,13 @@ This module provides a singleton service for generating and caching embeddings
4
4
  using sentence-transformers.
5
5
  """
6
6
 
7
- import logging
7
+ from flock.logging.logging import get_logger
8
8
  from collections import OrderedDict
9
9
 
10
10
  import numpy as np
11
11
 
12
12
 
13
- logger = logging.getLogger(__name__)
13
+ logger = get_logger(__name__)
14
14
 
15
15
 
16
16
  class LRUCache:
@@ -213,6 +213,10 @@ class EmbeddingService:
213
213
 
214
214
  similarity = dot_product / (norm1 * norm2)
215
215
 
216
+ logger.debug(
217
+ f"Computed similarity: {similarity:.4f} between texts '{text1}' and '{text2}'",
218
+ )
219
+
216
220
  # Clamp to [0, 1] and handle floating point errors
217
221
  return float(max(0.0, min(1.0, similarity)))
218
222
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flock-core
3
- Version: 0.5.22
3
+ Version: 0.5.24
4
4
  Summary: Flock: A declrative framework for building and orchestrating AI agents.
5
5
  Author-email: Andre Ratzenberger <andre.ratzenberger@whiteduck.de>
6
6
  License: MIT
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
43
43
  <a href="LICENSE" target="_blank"><img alt="License" src="https://img.shields.io/github/license/whiteducksoftware/flock?style=for-the-badge"></a>
44
44
  <a href="https://whiteduck.de" target="_blank"><img alt="Built by white duck" src="https://img.shields.io/badge/Built%20by-white%20duck%20GmbH-white?style=for-the-badge&labelColor=black"></a>
45
45
  <a href="https://codecov.io/gh/whiteducksoftware/flock" target="_blank"><img alt="Test Coverage" src="https://codecov.io/gh/whiteducksoftware/flock/branch/main/graph/badge.svg?token=YOUR_TOKEN_HERE&style=for-the-badge"></a>
46
- <img alt="Tests" src="https://img.shields.io/badge/tests-1300+-brightgreen?style=for-the-badge">
46
+ <img alt="Tests" src="https://img.shields.io/badge/tests-1400+-brightgreen?style=for-the-badge">
47
47
  </p>
48
48
 
49
49
  ---
@@ -23,10 +23,10 @@ flock/components/orchestrator/circuit_breaker.py,sha256=SH4pNFpe7MnkIRuK5TmRFBBO
23
23
  flock/components/orchestrator/collection.py,sha256=oTXDqNZgliwVqZO8e49mX3yEWxflzeZdD7UnbcHWypk,5572
24
24
  flock/components/orchestrator/deduplication.py,sha256=w4fwg3nLmb2TXPSSN3GEq5XPwviEEmmwu3fceSejBXw,2464
25
25
  flock/core/__init__.py,sha256=pEE4dbPtSEIC1WQYK8USWbF0EmZhccTfDO7eh7lzD-s,574
26
- flock/core/agent.py,sha256=6Slehv1vWawSdT2oLw7LWm75M1H1PnY7sbnmr5z-OBA,38190
26
+ flock/core/agent.py,sha256=iP6AfNUb_446eu-4NAJsqVuGLyf4H46n-aZUXw1Jqk4,38118
27
27
  flock/core/artifacts.py,sha256=dHDjn3DgS0Yo62oFoafQcdYNtqFrqLCzkvUytwm5VGU,2532
28
28
  flock/core/context_provider.py,sha256=1RG4lYhDNTshAQA1PwZELtUF2UDdC5NZWcBlE4BKDtc,20260
29
- flock/core/orchestrator.py,sha256=oebGAPie5TyHDtvVKRWfR9E1UrTtSKl-D7tcCrke_w0,42199
29
+ flock/core/orchestrator.py,sha256=Fgl32VKWzW-xzVhfbEnhJCFiZVJhpNiYR9hHcd12TPE,43214
30
30
  flock/core/store.py,sha256=4Zyh73RjjiUTtYTYiZ1pajWVXWKIew0dFERTNgQxRAA,31964
31
31
  flock/core/subscription.py,sha256=x2kkbaAbqFqR2woCYhc0a7Xi2k4-EYt8-LCNnTtN-jQ,10768
32
32
  flock/core/visibility.py,sha256=uwscg32t6Dp9LuA_EVDT5-_1lotzZWWS9Dl1foyJDxo,2926
@@ -219,7 +219,7 @@ flock/models/__init__.py,sha256=724PD_4bRX0rFdBDXzP0Pwr-OUntq0LIH48bMmtfcM0,266
219
219
  flock/models/system_artifacts.py,sha256=f4O-gErJRy5aMFVDh6ZGcj_5Gr130WnG28m5AfhnbxU,1083
220
220
  flock/orchestrator/__init__.py,sha256=u4DDXcwCSGrpHYbkdA4eP4W9Uj9vNMF6qxxUtygwmEU,1728
221
221
  flock/orchestrator/artifact_collector.py,sha256=XUB4dmx2tzq0p2CkYfP4NowfBkryp3DNA9jb7PWEIDk,6419
222
- flock/orchestrator/artifact_manager.py,sha256=fXqyU1pRDLf7MRxK86CMHr7uDOeeom_PEZ-3pVZxTj0,5775
222
+ flock/orchestrator/artifact_manager.py,sha256=TR5gZqWehNFkeHxfFUIPU_P7-JnWVjK43sy3THVh-9I,6288
223
223
  flock/orchestrator/batch_accumulator.py,sha256=WbIQqQz03LRLPe9yJsf_6TgppofE2tN_7f60P38n2S8,8027
224
224
  flock/orchestrator/component_runner.py,sha256=pf068DRGw4unh4K09Y8gt-OLM3FLm6CHQQ3d13jzkmM,14266
225
225
  flock/orchestrator/context_builder.py,sha256=Wp7_lzu_F7y-be6uiplur0VGauuP58NSmu1foXFfZc0,6244
@@ -235,7 +235,7 @@ flock/patches/__init__.py,sha256=KfRTpO_rz547iKxJDknymar1P3lS_8AhDh-sR1BkcZ0,194
235
235
  flock/patches/dspy_streaming_patch.py,sha256=OQeLYWmL-7rqudphMwERnpvXhXamnvYn3xNcySajacY,2879
236
236
  flock/semantic/__init__.py,sha256=ECd5EhdJjnlNA3BJiVlArvvJlVVjUPBlL5aH0Au7P5g,1568
237
237
  flock/semantic/context_provider.py,sha256=qkJ2_KHBZk2Mjj3cvtdzdIkvZON79WFLkHUTeyGn7X0,5793
238
- flock/semantic/embedding_service.py,sha256=R4pDy3sq4phDU2wn71F7gxcVM-HegXVtKZRiw_amu90,7018
238
+ flock/semantic/embedding_service.py,sha256=_oRl9z7srZu55gokLxt7IntsgfL9UcEKNLfpqy3hyQ8,7166
239
239
  flock/storage/__init__.py,sha256=9-p-RTpxGJOksfDavbpUsTghSIjDGtWCEC3bpVuYZY0,249
240
240
  flock/storage/artifact_aggregator.py,sha256=wMpoXjko9UmfMmQ_qUTzSX-nhb0k8BVRlzRLHlkKEug,5176
241
241
  flock/storage/in_memory/__init__.py,sha256=XPYxGNnpDjiv_L1tj8AxfORA_xHP16FV8t5UqrhtFLk,138
@@ -594,8 +594,8 @@ flock/utils/utilities.py,sha256=E3EQDo5SLU4XeoL3-PCc4lOatJHFEkMHKbZhnGhdMG4,1248
594
594
  flock/utils/validation.py,sha256=Vqzd8Qi73ttJNSHdr8EUEonyfzAYWVfEyW0fhLs1bA4,1847
595
595
  flock/utils/visibility.py,sha256=riJfHFWH8R2vk3DU7PYNi2LMaE8cy8pnMvxxiqWq-4I,2349
596
596
  flock/utils/visibility_utils.py,sha256=eGA28aL8FnGyGzsbVNvqI1UoPauu1Jedl5LUZ5oWZZ0,3874
597
- flock_core-0.5.22.dist-info/METADATA,sha256=Z1NgLhDZlzreyvJzT5HGzmr01NSlGtzC4OiLKx71Uhg,31235
598
- flock_core-0.5.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
599
- flock_core-0.5.22.dist-info/entry_points.txt,sha256=UQdPmtHd97gSA_IdLt9MOd-1rrf_WO-qsQeIiHWVrp4,42
600
- flock_core-0.5.22.dist-info/licenses/LICENSE,sha256=U3IZuTbC0yLj7huwJdldLBipSOHF4cPf6cUOodFiaBE,1072
601
- flock_core-0.5.22.dist-info/RECORD,,
597
+ flock_core-0.5.24.dist-info/METADATA,sha256=iyV6ZB20p-jjY0xckuwZnPlmf-bfYOQDlYJkwgrkwNY,31235
598
+ flock_core-0.5.24.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
599
+ flock_core-0.5.24.dist-info/entry_points.txt,sha256=UQdPmtHd97gSA_IdLt9MOd-1rrf_WO-qsQeIiHWVrp4,42
600
+ flock_core-0.5.24.dist-info/licenses/LICENSE,sha256=U3IZuTbC0yLj7huwJdldLBipSOHF4cPf6cUOodFiaBE,1072
601
+ flock_core-0.5.24.dist-info/RECORD,,