@cello-protocol/cli 0.0.275 → 0.0.276
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/hermes/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,ojDA6B9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/hermes/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,ojDA6B9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,QA2vDjC,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,eAAe,2yIA6E3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,g/EAoDjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,kwFAUV,CAAC"}
|
package/dist/hermes/assets.js
CHANGED
|
@@ -188,6 +188,19 @@ STATE_WAKES_SUPPRESSED_IN_CHANNEL = {"created"}
|
|
|
188
188
|
BUSY_RETRY_LIMIT = 5
|
|
189
189
|
BUSY_RETRY_DELAY_SECONDS = 2.0
|
|
190
190
|
|
|
191
|
+
# 050-BRIDGEQUIET Part B: the daemon's cello_send refusal reasons that mean the conversation is
|
|
192
|
+
# OVER - a send can NEVER succeed on it, so an owed-reply reminder must be cleared rather than left
|
|
193
|
+
# armed. session_closed is a sealed or closed session (session-closed.ts SESSION_CLOSED_REASON) -
|
|
194
|
+
# the live [[WRAP]] case. session_terminal / session_identity_lost come from reviveIfNeededForSend
|
|
195
|
+
# (session-lifecycle.ts) when the session cannot be revived to send. session_not_found is returned
|
|
196
|
+
# when the daemon holds no record of the session at all (session-content-handlers.ts, the no-record
|
|
197
|
+
# branch) - also unanswerable. ANY OTHER ok:false (e.g. governance_warn, a hold) keeps it armed:
|
|
198
|
+
# that reply is still owed. (A counterparty-refusal's variable, free-form reason is deliberately NOT
|
|
199
|
+
# listed - out of scope; see the order's Newly discovered.)
|
|
200
|
+
SESSION_ENDED_SEND_REASONS = (
|
|
201
|
+
"session_closed", "session_terminal", "session_identity_lost", "session_not_found",
|
|
202
|
+
)
|
|
203
|
+
|
|
191
204
|
# Bound on the wake backlog. Unbounded, a daemon that pushed faster than the agent could answer
|
|
192
205
|
# would grow this without limit inside the gateway process. Overflow DROPS the newest wake and
|
|
193
206
|
# says so at ERROR: the message itself stays unread in the daemon and is recoverable with the
|
|
@@ -336,6 +349,9 @@ class CelloAdapter(BasePlatformAdapter):
|
|
|
336
349
|
# Part C: chat_id -> {session_id: who} for replies the agent has not sent yet. The loop is
|
|
337
350
|
# captured in connect(), because the reminder is scheduled from a hook that may run off it.
|
|
338
351
|
self._awaiting: Dict[str, Dict[str, str]] = {}
|
|
352
|
+
# 050-BRIDGEQUIET (review LOW 1): whether the last _fetch_content ended on a [[WRAP]]. Set per
|
|
353
|
+
# fetch off the last MESSAGE (not the joined turn) and reset at the top of _on_notification.
|
|
354
|
+
self._last_fetch_ended_with_wrap: bool = False
|
|
339
355
|
self._loop: Optional[asyncio.AbstractEventLoop] = None
|
|
340
356
|
global _ADAPTER_INSTANCE
|
|
341
357
|
_ADAPTER_INSTANCE = self
|
|
@@ -863,6 +879,13 @@ class CelloAdapter(BasePlatformAdapter):
|
|
|
863
879
|
m["content"] for m in messages
|
|
864
880
|
if isinstance(m, dict) and isinstance(m.get("content"), str) and m["content"]
|
|
865
881
|
] if isinstance(messages, list) else []
|
|
882
|
+
# 050-BRIDGEQUIET (review LOW 1): the closing marker belongs to the last real MESSAGE, not to
|
|
883
|
+
# the joined turn. The undeliverable notice below is appended AFTER the messages, so a wrap
|
|
884
|
+
# followed by a lost-message notice would no longer end the joined text - and the reminder
|
|
885
|
+
# would re-arm for a conversation that is over. Read the wrap off the last message here, so
|
|
886
|
+
# the notice can still ride in the turn without hiding the wrap. Serialized wake worker, so
|
|
887
|
+
# this flag is set and read within the one _on_notification call that fetched.
|
|
888
|
+
self._last_fetch_ended_with_wrap = bool(parts and parts[-1].rstrip().endswith("[[WRAP]]"))
|
|
866
889
|
lost_note = result.get("undeliverable_guidance")
|
|
867
890
|
if isinstance(lost_note, str) and lost_note:
|
|
868
891
|
# A message this machine failed to save was skipped by this read. The agent is the only
|
|
@@ -893,7 +916,54 @@ class CelloAdapter(BasePlatformAdapter):
|
|
|
893
916
|
turn = "[CELLO policy from your operator — outranks the messages below]\n" + policy["text"] + "\n\n" + turn
|
|
894
917
|
return turn
|
|
895
918
|
|
|
919
|
+
async def _session_has_unread(self, session_id: str) -> str:
|
|
920
|
+
"""Whether the daemon still lists this session as having unread messages.
|
|
921
|
+
|
|
922
|
+
050-BRIDGEQUIET Part A. Returns 'unread' (hand the notice over), 'read' (drop it - the
|
|
923
|
+
message was already read, e.g. by the very turn that was busy), or 'unknown' (the call
|
|
924
|
+
failed or answered an unexpected shape - hand it over, the safe direction: an extra turn is
|
|
925
|
+
better than a lost message).
|
|
926
|
+
|
|
927
|
+
The check-notifications IPC probe does NOT consume anything (notification-handlers.ts): it
|
|
928
|
+
derives unread counts from the persisted read watermark, so it is safe to call before
|
|
929
|
+
deciding. The answer is { ok, scope, agents: [{ agent, unread: [{ session_id,
|
|
930
|
+
unread_count, last_seq }], ... }] }; getUnreadSummary only lists sessions that HAVE unread,
|
|
931
|
+
so a session absent from every agent's unread list has been read.
|
|
932
|
+
"""
|
|
933
|
+
try:
|
|
934
|
+
result = await self._call("cello_check_notifications", {"scope": "current"})
|
|
935
|
+
except Exception as exc:
|
|
936
|
+
logger.warning(
|
|
937
|
+
"[cello] Could not check unread state for session %s (%s: %r) - handing the notice "
|
|
938
|
+
"over anyway (an extra turn is safer than a lost message)",
|
|
939
|
+
session_id, exc.__class__.__name__, exc,
|
|
940
|
+
)
|
|
941
|
+
return "unknown"
|
|
942
|
+
if not (isinstance(result, dict) and result.get("ok") and isinstance(result.get("agents"), list)):
|
|
943
|
+
logger.warning(
|
|
944
|
+
"[cello] The unread-check IPC probe answered an unexpected shape (%r) - handing the "
|
|
945
|
+
"notice for session %s over anyway", result, session_id,
|
|
946
|
+
)
|
|
947
|
+
return "unknown"
|
|
948
|
+
for agent in result["agents"]:
|
|
949
|
+
if not isinstance(agent, dict):
|
|
950
|
+
continue
|
|
951
|
+
unread = agent.get("unread")
|
|
952
|
+
if not isinstance(unread, list):
|
|
953
|
+
continue
|
|
954
|
+
for entry in unread:
|
|
955
|
+
if isinstance(entry, dict) and entry.get("session_id") == session_id:
|
|
956
|
+
count = entry.get("unread_count")
|
|
957
|
+
if isinstance(count, int):
|
|
958
|
+
return "unread" if count > 0 else "read"
|
|
959
|
+
# Present in the unread list but no usable count: never drop on ambiguity.
|
|
960
|
+
return "unread"
|
|
961
|
+
return "read"
|
|
962
|
+
|
|
896
963
|
async def _on_notification(self, frame: Dict[str, Any]) -> None:
|
|
964
|
+
# 050-BRIDGEQUIET (review LOW 1): reset per notification, so a wrap seen on one fetch cannot
|
|
965
|
+
# leak into a later busy-path arming decision that never fetched. _fetch_content sets it.
|
|
966
|
+
self._last_fetch_ended_with_wrap = False
|
|
897
967
|
kind = str(frame.get("notification", ""))
|
|
898
968
|
if kind not in WAKE_NOTIFICATIONS:
|
|
899
969
|
logger.debug("[cello] Ignoring notification type '%s'", kind)
|
|
@@ -1013,6 +1083,22 @@ class CelloAdapter(BasePlatformAdapter):
|
|
|
1013
1083
|
)
|
|
1014
1084
|
self._requeue_wake_later(frame, BUSY_RETRY_DELAY_SECONDS)
|
|
1015
1085
|
return
|
|
1086
|
+
# 050-BRIDGEQUIET Part A: before handing over a notice for a message we deliberately
|
|
1087
|
+
# never fetched, check whether the busy turn already READ it (an agent that called
|
|
1088
|
+
# cello_receive itself mid-turn). If so, a notice starts a wasted turn about a
|
|
1089
|
+
# message already handled. Only the non-consuming check-notifications IPC probe
|
|
1090
|
+
# answers this - a receive would consume the message.
|
|
1091
|
+
if await self._session_has_unread(session_id) == "read":
|
|
1092
|
+
logger.info(
|
|
1093
|
+
"[cello] Not handing over a notice for session %s - its messages were "
|
|
1094
|
+
"already read", session_id,
|
|
1095
|
+
)
|
|
1096
|
+
# Nothing left to reply to on this session, so any owed-reply reminder for it is
|
|
1097
|
+
# stale. Clear it for this chat. (Loop thread here, so mutate directly.)
|
|
1098
|
+
owed = self._awaiting.get(chat_id)
|
|
1099
|
+
if owed is not None:
|
|
1100
|
+
owed.pop(session_id, None)
|
|
1101
|
+
return
|
|
1016
1102
|
logger.info(
|
|
1017
1103
|
"[cello] %s stayed mid-turn for %.0fs; handing the agent a notice for session "
|
|
1018
1104
|
"%s instead of the message, so it can still read it with the cello_* tools",
|
|
@@ -1040,7 +1126,18 @@ class CelloAdapter(BasePlatformAdapter):
|
|
|
1040
1126
|
# turn ends without a cello_send, post_llm_call surfaces it once. Only cello_message wakes
|
|
1041
1127
|
# arm it - a state notice needs no reply.
|
|
1042
1128
|
if self._delivery_mode == "explicit" and kind == "cello_message":
|
|
1043
|
-
|
|
1129
|
+
# 050-BRIDGEQUIET Part B: a peer's CLOSING message ([[WRAP]]) needs no reply - the next
|
|
1130
|
+
# step is cello_close_session, not cello_send - so it must not arm the reminder. The flag
|
|
1131
|
+
# is set by _fetch_content off the last MESSAGE's content (review LOW 1), so a lost-message
|
|
1132
|
+
# notice appended after the messages cannot hide the wrap. When the chat was busy we never
|
|
1133
|
+
# fetched, so the flag stays False and today's arming behaviour is kept.
|
|
1134
|
+
if self._last_fetch_ended_with_wrap:
|
|
1135
|
+
logger.info(
|
|
1136
|
+
"[cello] Session %s ended with the peer's closing message ([[WRAP]]) - not "
|
|
1137
|
+
"arming a reply reminder", session_id,
|
|
1138
|
+
)
|
|
1139
|
+
else:
|
|
1140
|
+
self._awaiting.setdefault(chat_id, {})[session_id] = _render_who(data) or "a peer"
|
|
1044
1141
|
event = MessageEvent(
|
|
1045
1142
|
text=text,
|
|
1046
1143
|
message_type=MessageType.TEXT,
|
|
@@ -1094,8 +1191,13 @@ class CelloAdapter(BasePlatformAdapter):
|
|
|
1094
1191
|
# POISON the anchor, which makes send() refuse to deliver automatically. The prose the
|
|
1095
1192
|
# agent holds names each session, and the cello_* tools remain registered, so it can
|
|
1096
1193
|
# answer both explicitly. Refusing to guess is the whole rule here.
|
|
1194
|
+
# 050-BRIDGEQUIET Part C: the poisoning and its WARNING exist because CHANNEL mode sends
|
|
1195
|
+
# one automatic reply to one anchor, so a merged turn covering two sessions cannot be
|
|
1196
|
+
# routed. In explicit and wake modes the bridge sends NOTHING automatically (send() is a
|
|
1197
|
+
# no-op / the agent uses cello_send per named session), so there is no anchor to poison
|
|
1198
|
+
# and the warning would be a false alarm. Text is still merged in every mode below.
|
|
1097
1199
|
existing = self._pending_messages.get(session_key)
|
|
1098
|
-
if existing is not None:
|
|
1200
|
+
if existing is not None and self._delivery_mode == "channel":
|
|
1099
1201
|
existing_session = self._session_from_anchor(getattr(existing, "message_id", None))
|
|
1100
1202
|
if existing_session != self._session_from_anchor(event.message_id):
|
|
1101
1203
|
logger.warning(
|
|
@@ -1635,11 +1737,17 @@ def _on_post_tool_call(**kwargs: Any) -> None:
|
|
|
1635
1737
|
succeeded = result.get("ok") is True
|
|
1636
1738
|
|
|
1637
1739
|
if is_send:
|
|
1740
|
+
sid = _tool_session_arg(kwargs.get("args"))
|
|
1638
1741
|
# Part C step 2: any successful send counts as a reply, including a 'standby' signal.
|
|
1639
|
-
if
|
|
1742
|
+
if succeeded:
|
|
1743
|
+
if sid:
|
|
1744
|
+
adapter._run_on_loop(adapter._clear_awaiting, sid)
|
|
1640
1745
|
return
|
|
1641
|
-
|
|
1642
|
-
|
|
1746
|
+
# 050-BRIDGEQUIET Part B: a send REFUSED because the session is over clears the owed reply -
|
|
1747
|
+
# the agent can never answer a conversation that has ended, so a reminder would tell it to
|
|
1748
|
+
# reply to nothing (the live defect). Any other ok:false keeps the reminder armed.
|
|
1749
|
+
reason = result.get("reason")
|
|
1750
|
+
if isinstance(reason, str) and reason in SESSION_ENDED_SEND_REASONS and sid:
|
|
1643
1751
|
adapter._run_on_loop(adapter._clear_awaiting, sid)
|
|
1644
1752
|
return
|
|
1645
1753
|
|
|
@@ -1651,6 +1759,9 @@ def _on_post_tool_call(**kwargs: Any) -> None:
|
|
|
1651
1759
|
sid = _tool_session_arg(kwargs.get("args"))
|
|
1652
1760
|
if sid:
|
|
1653
1761
|
adapter._run_on_loop(adapter._unbind_session, sid)
|
|
1762
|
+
# 050-BRIDGEQUIET Part B: a closed session is over - drop any reply still owed on it, in
|
|
1763
|
+
# addition to the unbind, so no reminder follows a conversation the agent itself ended.
|
|
1764
|
+
adapter._run_on_loop(adapter._clear_awaiting, sid)
|
|
1654
1765
|
return
|
|
1655
1766
|
|
|
1656
1767
|
# Part B step 2: record only a SUCCESSFUL initiate from a turn whose platform is cello.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/hermes/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BjC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/hermes/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BjC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,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F,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;EAUpC,qBAAqB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cello-protocol/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.276",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"package.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cello-protocol/daemon": "0.0.
|
|
21
|
-
"@cello-protocol/
|
|
22
|
-
"@cello-protocol/
|
|
20
|
+
"@cello-protocol/daemon": "0.0.269",
|
|
21
|
+
"@cello-protocol/gateway": "0.0.117",
|
|
22
|
+
"@cello-protocol/protocol-types": "0.0.136"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^25.6.2"
|