Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,7 @@ keyword-binders = [
derived-spellings = [
{ family = "agent_comms.nominal.declared_family:DeclaredFamily", rule = "agent_comms.nominal.declared_family:declared_words", affix = "affix", spelling = "declared_name" },
]
# Stdlib-only fast-path hook: importing agent_comms at module top level runs Core on every tool call.
forbidden-imports = [
{ from = "agent_comms_hooks.antigravity", to = ["agent_comms"] },
]
13 changes: 4 additions & 9 deletions src/agent_comms/cli_bridges/antigravity_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
from agent_comms.cli_bridges.cli_protocol import HistoryRecord, TaggedWire
from agent_comms.cli_bridges.runtime_updates import (
ActiveItem,
CatchUpReadingPhase,
FinishedItem,
FinishedTurn,
LiveReadingPhase,
ReadingPhase,
RuntimeInfoObserved,
RuntimeUpdate,
Expand Down Expand Up @@ -96,14 +98,10 @@ def window_ended(self, session: AntigravitySession) -> tuple[RuntimeUpdate, ...]


@dataclass
class AntigravityCatchUp(AntigravityReaderPhase):
class AntigravityCatchUp(CatchUpReadingPhase, AntigravityReaderPhase):
pending: tuple[StatusUpdate, ...] = ()
latest_info: tuple[RuntimeInfoObserved, ...] = ()

def runtime_info(self, update: RuntimeInfoObserved) -> tuple[RuntimeUpdate, ...]:
self.latest_info = (update,)
return ()

def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
self.pending = (update,)
return ()
Expand All @@ -113,10 +111,7 @@ def window_ended(self, session: AntigravitySession) -> tuple[RuntimeUpdate, ...]
return (*self.latest_info, *self.pending)


class AntigravityLive(AntigravityReaderPhase):
def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
return (update,)

class AntigravityLive(LiveReadingPhase, AntigravityReaderPhase):
def window_ended(self, session: AntigravitySession) -> tuple[RuntimeUpdate, ...]:
return ()

Expand Down
13 changes: 4 additions & 9 deletions src/agent_comms/cli_bridges/claude_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
ActiveItem,
AllTurnsCancelled,
AllTurnsEnded,
CatchUpReadingPhase,
FinishedItem,
HiddenItem,
HistoryNotice,
LiveReadingPhase,
OfferedToolsObserved,
ReadingPhase,
RuntimeInfoObserved,
Expand Down Expand Up @@ -364,7 +366,7 @@ def unturned_finish(self) -> tuple[RuntimeUpdate, ...]: ...


@dataclass
class CatchUp(ClaudeReaderPhase):
class CatchUp(CatchUpReadingPhase, ClaudeReaderPhase):
pending: tuple[StatusUpdate, ...] = ()
latest_tools: tuple[OfferedToolsObserved, ...] = ()
latest_info: tuple[RuntimeInfoObserved, ...] = ()
Expand All @@ -373,10 +375,6 @@ def offered(self, update: OfferedToolsObserved) -> tuple[RuntimeUpdate, ...]:
self.latest_tools = (update,)
return ()

def runtime_info(self, update: RuntimeInfoObserved) -> tuple[RuntimeUpdate, ...]:
self.latest_info = (update,)
return ()

def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
self.pending = (update,)
return ()
Expand All @@ -393,10 +391,7 @@ def unturned_finish(self) -> tuple[RuntimeUpdate, ...]:
return ()


class Live(ClaudeReaderPhase):
def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
return (update,)

class Live(LiveReadingPhase, ClaudeReaderPhase):
def window_ended(self, session: ClaudeSession) -> tuple[RuntimeUpdate, ...]:
return ()

Expand Down
32 changes: 24 additions & 8 deletions src/agent_comms/cli_bridges/runtime_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,21 @@ def runtime_info(self, update: RuntimeInfoObserved) -> tuple[RuntimeUpdate, ...]
return (update,)


class CatchUpReadingPhase(ReadingPhase):
"""A transcript reading phase that buffers catch-up updates before going live."""

def runtime_info(self, update: RuntimeInfoObserved) -> tuple[RuntimeUpdate, ...]:
self.latest_info = (update,)
return ()


class LiveReadingPhase(ReadingPhase):
"""A live transcript reading phase that emits status updates immediately."""

def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
return (update,)


@dataclass(frozen=True)
class RuntimeUpdate(ABC):
"""One change a runtime reports about its thread."""
Expand Down Expand Up @@ -477,8 +492,15 @@ def accumulate(self, output: ThreadOutput) -> tuple[RuntimeUpdate, ...]:
return output.active_item(self)


class EventRecordingRuntimeUpdate(RuntimeUpdate):
"""A runtime update that adds its events directly to an import buffer."""

def add_to(self, history: ImportBuffer) -> None:
history.add(self.events)


@dataclass(frozen=True)
class FinishedItem(TurnItem, RuntimeUpdate):
class FinishedItem(TurnItem, EventRecordingRuntimeUpdate):
"""One CLI item's complete presentation, identified by its producer."""

events: tuple[TranscriptEvent, ...]
Expand All @@ -500,9 +522,6 @@ def retain_before(self, later: set[TurnItem]) -> bool:
def page_record(self, turn_id: NativeTurnId, item_id: NativeItemId) -> FinishedItem:
return self

def add_to(self, history: ImportBuffer) -> None:
history.add(self.events)


@dataclass(frozen=True)
class PageItem(TurnItem):
Expand Down Expand Up @@ -553,15 +572,12 @@ def write(self, transcript: ExternalTranscript, records: tuple[FinishedItem, ...


@dataclass(frozen=True)
class HiddenItem(UnpublishedRuntimeUpdate):
class HiddenItem(EventRecordingRuntimeUpdate, UnpublishedRuntimeUpdate):
"""Conversation the live view does not show, because the thread shows it another way
(a bus delivery) or because only the person's own prompts are shown; history keeps it."""

events: tuple[TranscriptEvent, ...]

def add_to(self, history: ImportBuffer) -> None:
history.add(self.events)


@dataclass(frozen=True)
class Summarized(UnpublishedRuntimeUpdate):
Expand Down
3 changes: 0 additions & 3 deletions src/agent_comms/execution/cli_inbox_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class CliInboxRuntime(UnwrittenRuntimeLocation):

path: str = ""

def is_resumable(self) -> bool:
return False

def require_forkable(self) -> None:
pass

Expand Down
5 changes: 3 additions & 2 deletions src/agent_comms/execution/unstarted_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ def history_source(self, root, incarnation):
class UnwrittenRuntimeLocation(ExternalTranscriptLocation, declared_name=None):
"""A runtime location with no recorded transcript write timestamp."""

def is_resumable(self) -> bool:
return False

def last_written(self) -> float:
return 0.0


@dataclass(frozen=True)
class UnstartedRuntime(UnwrittenRuntimeLocation):
owner: type[AgentBackend]
def is_resumable(self) -> bool:
return False

@property
def backend(self):
Expand Down
21 changes: 10 additions & 11 deletions src/agent_comms/messaging/channel_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,23 @@ class ReplyRoute(ABC):
@abstractmethod
def target(self, target_name: str, sender: str) -> str: ...

def sql(self, column: str, sender: str, names: tuple[str, ...]) -> tuple[str, tuple[str, ...]]:
target = self.target(column, sender)
return self._sql_step(column, sender, names, target)

@abstractmethod
def sql(
self, column: str, sender: str, names: tuple[str, ...],
) -> tuple[str, tuple[str, ...]]: ...
def _sql_step(self, column: str, sender: str, names: tuple[str, ...], target) -> tuple[str, tuple[str, ...]]:
...


class SenderReply(ReplyRoute):
def target(self, target_name: str, sender: str) -> str:
return sender

def sql(
self, column: str, sender: str, names: tuple[str, ...],
) -> tuple[str, tuple[str, ...]]:
def _sql_step(self, column: str, sender: str, names: tuple[str, ...], target) -> tuple[str, tuple[str, ...]]:
marks = ",".join("?" for _ in names)
return (
f"{self.target(column, sender)} IN ({marks}) AND NOT ({ChannelReply.channel_sql(column)})",
f"{target} IN ({marks}) AND NOT ({ChannelReply.channel_sql(column)})",
names,
)

Expand All @@ -271,10 +272,8 @@ class ChannelReply(ReplyRoute):
def target(self, target_name: str, sender: str) -> str:
return target_name

def sql(
self, column: str, sender: str, names: tuple[str, ...],
) -> tuple[str, tuple[str, ...]]:
return f"{self.target(column, sender)}=?", names
def _sql_step(self, column: str, sender: str, names: tuple[str, ...], target) -> tuple[str, tuple[str, ...]]:
return f"{target}=?", names

@staticmethod
def channel_sql(column: str) -> str:
Expand Down
17 changes: 9 additions & 8 deletions src/agent_comms/messaging/read_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,17 @@ def recorded_keys(self, snapshot: RegistryProvenance) -> Iterable[Conversation]:
def in_targets(self, targets: Collection[str], snapshot: RegistryProvenance) -> bool: ...


@dataclass(frozen=True, slots=True)
class AllConversation(Conversation):
"""An explicit whole-bus read applies to every conversation in this source."""
class NamedConversation(Conversation, declared_name=None):
"""A conversation whose identity does not depend on per-incarnation DM resolution."""

def resolved(self, snapshot: RegistryProvenance):
def resolved(self, snapshot: RegistryProvenance) -> Self:
return self


@dataclass(frozen=True, slots=True)
class AllConversation(NamedConversation):
"""An explicit whole-bus read applies to every conversation in this source."""

def scope(self, snapshot: RegistryProvenance) -> AllChannelDisplayScope:

return AllChannelDisplayScope(AnyChannel.address())
Expand All @@ -623,12 +627,9 @@ def in_targets(self, targets: Collection[str], snapshot: RegistryProvenance) ->


@dataclass(frozen=True, slots=True)
class ChannelConversation(Conversation):
class ChannelConversation(NamedConversation):
target: str

def resolved(self, snapshot: RegistryProvenance) -> ChannelConversation:
return self

def scope(self, snapshot: RegistryProvenance) -> ChannelDisplayScope:
return ChannelDisplayScope(self.target, frozenset((self.target,)))

Expand Down
20 changes: 15 additions & 5 deletions src/agent_comms/planning/goal_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,23 @@ def before_transition(self, goal: Goal, ctx: GoalActionContext) -> None:
)


class WaitCompletingGoalAction(GoalAction, declared_name=None):
"""A goal action sharing wait-completion handling."""

def complete_wait(self, ctx: GoalActionContext) -> None:
pass


@dataclass(frozen=True, kw_only=True)
class StandbyGoalAction(
WaitCompletingGoalAction,
ActivatingGoalAction,
GoalReportAction,
ModelInvocable,
RuntimeInvocable,
):
wait_for: tuple[str, ...] = ()
reviewed_inputs: tuple[Annotated[InputKey, InputKeyText], ...] = ()
def complete_wait(self, ctx: GoalActionContext) -> None:
pass


def prepare(self, goals: GoalActionStore, name: str, actor: type) -> GoalAction[Goal]:
Expand Down Expand Up @@ -488,10 +494,14 @@ def create(self, ctx: GoalActionContext) -> NoGoal:


@dataclass(frozen=True, kw_only=True)
class EditGoalAction(GoalAction[Goal], OwnerInvocable, RuntimeInvocable, PeerInvocable):
class EditGoalAction(
WaitCompletingGoalAction,
GoalAction[Goal],
OwnerInvocable,
RuntimeInvocable,
PeerInvocable,
):
text: str
def complete_wait(self, ctx: GoalActionContext) -> None:
pass


def change(self, goal: Goal, ctx: GoalActionContext) -> Goal:
Expand Down
13 changes: 7 additions & 6 deletions src/agent_comms/registry/thread_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,16 @@ def presentation(
return replace(super().presentation(title, activity, idle), summary="CLI inbox · no bridge")


class ServiceThreadStatus(PublishingPresence, ThreadStatus):
"""A service can publish, but has no executable roster row or owner controls."""
class HiddenThreadStatus(ThreadStatus, declared_name=None):
"""A thread status excluded from user roster views."""

def in_view(self, visibility: RosterVisibility) -> bool:
return False


class ServiceThreadStatus(PublishingPresence, HiddenThreadStatus):
"""A service can publish, but has no executable roster row or owner controls."""

def external_registered(self, thread: PresenceThread, now: float) -> ThreadStatus:
return self

Expand Down Expand Up @@ -545,10 +549,7 @@ def active_checkout_matches(self, thread):
return ()


class DeletingThreadStatus(ThreadStatus):
def in_view(self, visibility: RosterVisibility) -> bool:
return False

class DeletingThreadStatus(HiddenThreadStatus):
def require_deleting(self) -> None:
pass

Expand Down
Loading
Loading