agents-over-telegram 0.11.7 → 0.11.8
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.
- package/README.md +1 -1
- package/docs/HOSTS.md +1 -0
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/requirements/build.txt +2 -2
- package/requirements/runtime.txt +2 -2
- package/src/agents_over_telegram/__init__.py +1 -1
- package/src/agents_over_telegram/core.py +1 -1
- package/src/agents_over_telegram/hosts.py +18 -3
- package/src/agents_over_telegram/push.py +71 -24
- package/src/agents_over_telegram/relay_api.py +8 -6
- package/uv.lock +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Agents over Telegram (AOT) connects a coding agent project to a Telegram group o
|
|
|
4
4
|
|
|
5
5
|
## Supported agent hosts
|
|
6
6
|
|
|
7
|
-
Version 0.11.
|
|
7
|
+
Version 0.11.8 supports **Claude Code**, **Codex**, **Pi**, **Amp** and **Antigravity** (the `agy` CLI and the desktop app), and, untested, **Grok Bot** (see [hosts](docs/HOSTS.md#grok-bot-untested)). Every host works the same way: you install AOT for the host once, then ask the agent to connect each project. A new Telegram message reaches the running agent without a typed prompt: an idle agent wakes up, and a busy agent gets a notice at its next safe point. The notice never contains the message text; the agent reads it with its scoped Telegram tools.
|
|
8
8
|
|
|
9
9
|
[Agent hosts](docs/HOSTS.md) explains how each integration works and lists exactly what was tested. Most host checks used real host processes with a fake Telegram transport, not live Telegram.
|
|
10
10
|
|
package/docs/HOSTS.md
CHANGED
|
@@ -64,6 +64,7 @@ This needs the plugin to be loaded in the session. When the plugin is installed
|
|
|
64
64
|
- With [keep-alive](OPERATIONS.md#keep-an-idle-claude-code-session-listening) on, the waiter instead wakes the session once when its 23 hours end. The notice says that there are no new messages and asks the model to end the turn. That turn end starts a new waiter. Only the session's current waiter does this, and only while Claude Code still runs. A waiter that handed over to a newer one, or whose host exited, stays quiet.
|
|
65
65
|
- Each waiter writes one line to `wake.log` in the state directory when it starts and when it exits, with the reason: `woken`, `keep_alive_refresh`, `replaced`, `host_gone`, `parent_changed`, `runtime_moved`, `watch_ended:<reason>`, `error:<type>` or `signal:<name>` (for `SIGTERM`, `SIGHUP` and `SIGINT`). A waiter killed with `SIGKILL` leaves a start line with no exit line. The file is private and holds no message text. Past 256 KB it moves to `wake.log.1`. Read it when a session stopped waking up.
|
|
66
66
|
- Only the session working in the project folder (or a subfolder) is that project's agent. Claude Code gives a worktree session, or any session it starts in another folder, the parent project's `CLAUDE_PROJECT_DIR`. The launcher compares that with the `cwd` in the hook input and stays silent when the session works outside the project, or in a separate git checkout inside it, such as a Claude Code CLI worktree in `<project>/.claude/worktrees/`. Before 0.11.4 such a session ran its own waiter for the parent's client and could take the parent's wake. `AOT_PROJECT_DIR` set explicitly still wins.
|
|
67
|
+
- Two sessions in the same project folder, such as a forked side session, share the project's connection. Each of them is told about each new delivery once, so a session that leaves a message unread does not keep the other one from waking. The first session to poll the message handles it. Before 0.11.8 only one of them was told, and a side session that left the message unread could delay it until the next prompt in the main session.
|
|
67
68
|
- Do not start `aot watch` with the agent's Monitor tool as an extra waker. Those commands run inside the Claude Code sandbox, which cannot write the AOT state folder, so `aot watch` fails with `storage_error`. The `asyncRewake` hook runs outside the sandbox and is the wake path.
|
|
68
69
|
- The launcher passes exit status 2 on only when the runtime printed a real notice. A runtime that predates `aot wake` fails with status 2 and a usage message, and that must not wake the session.
|
|
69
70
|
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agents-over-telegram"
|
|
7
|
-
version = "0.11.
|
|
7
|
+
version = "0.11.8"
|
|
8
8
|
description = "One human-owned Telegram bot, multiple isolated logical agent conversations"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
license = "Apache-2.0"
|
package/requirements/build.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Generated by scripts/export_requirements.py; do not edit.
|
|
2
|
-
# uv.lock-sha256:
|
|
3
|
-
# pyproject.toml-sha256:
|
|
2
|
+
# uv.lock-sha256: a240ce2d950c52103124aaa2bb61c832dcf4bab9ee4ca01d3e1241c1f6a4232e
|
|
3
|
+
# pyproject.toml-sha256: 6ead5cc88b7667cfc93d5d4b55861508005e322a1e4d43708442a6d4828902c6
|
|
4
4
|
hatchling==1.27.0 \
|
|
5
5
|
--hash=sha256:971c296d9819abb3811112fc52c7a9751c8d381898f36533bb16f9791e941fd6 \
|
|
6
6
|
--hash=sha256:d3a2f3567c4f926ea39849cdf924c7e99e6686c9c8e288ae1037c8fa2a5d937b
|
package/requirements/runtime.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Generated by scripts/export_requirements.py; do not edit.
|
|
2
|
-
# uv.lock-sha256:
|
|
3
|
-
# pyproject.toml-sha256:
|
|
2
|
+
# uv.lock-sha256: a240ce2d950c52103124aaa2bb61c832dcf4bab9ee4ca01d3e1241c1f6a4232e
|
|
3
|
+
# pyproject.toml-sha256: 6ead5cc88b7667cfc93d5d4b55861508005e322a1e4d43708442a6d4828902c6
|
|
4
4
|
annotated-types==0.8.0 \
|
|
5
5
|
--hash=sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7 \
|
|
6
6
|
--hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""Local, scoped communication between agents and a human-owned Telegram bot."""
|
|
2
|
-
__version__ = "0.11.
|
|
2
|
+
__version__ = "0.11.8"
|
|
@@ -2135,7 +2135,7 @@ class Core:
|
|
|
2135
2135
|
for start in range(0, len(stale), 500):
|
|
2136
2136
|
chunk = stale[start:start + 500]
|
|
2137
2137
|
marks = ','.join('?' * len(chunk))
|
|
2138
|
-
for table in ('push_announcements', 'relay_deliveries'):
|
|
2138
|
+
for table in ('push_announcements', 'push_listener_announcements', 'relay_deliveries'):
|
|
2139
2139
|
if table in tables:
|
|
2140
2140
|
db.execute(f'DELETE FROM {table} WHERE inbox_id IN ({marks})', chunk)
|
|
2141
2141
|
db.execute(f'DELETE FROM inbox WHERE context=1 AND id IN ({marks})', chunk)
|
|
@@ -104,6 +104,7 @@ def hook_answer(args, raw: str) -> dict | None:
|
|
|
104
104
|
state = Path(profile['state_dir'])
|
|
105
105
|
if not state.is_dir():
|
|
106
106
|
return None
|
|
107
|
+
payload = _with_listener(payload, profile['client_id'], payload.get('session_id'))
|
|
107
108
|
answer = _relayed_hook(state, Path(profile['client_file']), event, payload)
|
|
108
109
|
if answer is _NO_RELAY:
|
|
109
110
|
# No relay: this hook does the inbox work on its own database handle.
|
|
@@ -218,7 +219,9 @@ def antigravity_answer(args, payload: dict) -> dict | None:
|
|
|
218
219
|
state = Path(profile['state_dir'])
|
|
219
220
|
if not state.is_dir():
|
|
220
221
|
return None
|
|
221
|
-
answer = _inbox_answer(args, state, profile, mapped,
|
|
222
|
+
answer = _inbox_answer(args, state, profile, mapped,
|
|
223
|
+
_with_listener({'hook_event_name': mapped}, profile['client_id'],
|
|
224
|
+
payload.get('conversationId')))
|
|
222
225
|
notice = None
|
|
223
226
|
if isinstance(answer, dict):
|
|
224
227
|
notice = answer.get('reason') or (answer.get('hookSpecificOutput') or {}).get('additionalContext')
|
|
@@ -252,7 +255,19 @@ def _inbox_answer(args, state: Path, profile: dict, event: str, payload: dict):
|
|
|
252
255
|
return answer
|
|
253
256
|
# The hook input fields hook_response reads; the rest (prompts, tool output)
|
|
254
257
|
# never leaves this process.
|
|
255
|
-
_HOOK_FIELDS = ('tool_name', 'stop_hook_active')
|
|
258
|
+
_HOOK_FIELDS = ('tool_name', 'stop_hook_active', 'listener')
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _with_listener(payload: dict, client_id: str, session) -> dict:
|
|
262
|
+
"""The hook input plus this session's wake key, so the session hears of each delivery once.
|
|
263
|
+
|
|
264
|
+
A host input never chooses the key itself: any listener field in it is replaced.
|
|
265
|
+
"""
|
|
266
|
+
session = _session_id(session)
|
|
267
|
+
payload = {k: v for k, v in payload.items() if k != 'listener'}
|
|
268
|
+
if session:
|
|
269
|
+
payload['listener'] = wake_key(client_id, session)
|
|
270
|
+
return payload
|
|
256
271
|
|
|
257
272
|
|
|
258
273
|
def _relayed_hook(state: Path, client_file: Path, event: str, payload: dict):
|
|
@@ -552,7 +567,7 @@ def _wake(args, log=None) -> int:
|
|
|
552
567
|
|
|
553
568
|
try:
|
|
554
569
|
result = watch(core, client_id, emit, collect=True, duration=duration, keep_running=keep_running,
|
|
555
|
-
remote=remote)
|
|
570
|
+
remote=remote, listener=key)
|
|
556
571
|
except _Woken:
|
|
557
572
|
if antigravity:
|
|
558
573
|
# Antigravity wakes the agent when this background command ends
|
|
@@ -71,6 +71,14 @@ def ensure_tables(core) -> None:
|
|
|
71
71
|
client_id TEXT NOT NULL REFERENCES clients(id),
|
|
72
72
|
surface TEXT NOT NULL, announced REAL NOT NULL)''')
|
|
73
73
|
db.execute('CREATE INDEX IF NOT EXISTS push_announcements_client ON push_announcements(client_id)')
|
|
74
|
+
# One row per delivery and listening session (its wake key). Sessions
|
|
75
|
+
# that share a connection, such as a forked side session, each get
|
|
76
|
+
# their own notice, so one that leaves a message unread cannot use up
|
|
77
|
+
# the only wake.
|
|
78
|
+
db.execute('''CREATE TABLE IF NOT EXISTS push_listener_announcements (
|
|
79
|
+
inbox_id TEXT NOT NULL REFERENCES inbox(id),
|
|
80
|
+
listener TEXT NOT NULL, client_id TEXT NOT NULL REFERENCES clients(id),
|
|
81
|
+
announced REAL NOT NULL, PRIMARY KEY(inbox_id, listener))''')
|
|
74
82
|
|
|
75
83
|
|
|
76
84
|
def _sender(payload: dict) -> str | None:
|
|
@@ -120,22 +128,31 @@ def _wakes_at_once(payload: dict, binding, exempt: set[str]) -> bool:
|
|
|
120
128
|
return 'owner' in exempt and from_owner
|
|
121
129
|
|
|
122
130
|
|
|
123
|
-
def last_notice(db, client_id: str) -> float | None:
|
|
124
|
-
"""When this client was last told about new work, by a push notice or a desktop wake.
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
def last_notice(db, client_id: str, listener: str | None = None) -> float | None:
|
|
132
|
+
"""When this client was last told about new work, by a push notice or a desktop wake.
|
|
133
|
+
|
|
134
|
+
With a listener, only that session's own push notices count, so a notice
|
|
135
|
+
to another session that shares the connection never holds this one back.
|
|
136
|
+
"""
|
|
137
|
+
tables = {row[0] for row in db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name IN "
|
|
138
|
+
"('push_announcements','push_listener_announcements','relay_notifications')")}
|
|
127
139
|
times = []
|
|
128
|
-
if
|
|
140
|
+
if listener is not None:
|
|
141
|
+
if 'push_listener_announcements' in tables:
|
|
142
|
+
times.append(db.execute('SELECT max(announced) FROM push_listener_announcements WHERE client_id=? '
|
|
143
|
+
'AND listener=?', (client_id, listener)).fetchone()[0])
|
|
144
|
+
elif 'push_announcements' in tables:
|
|
129
145
|
times.append(db.execute('SELECT max(announced) FROM push_announcements WHERE client_id=?',
|
|
130
146
|
(client_id,)).fetchone()[0])
|
|
131
|
-
if 'relay_notifications' in tables:
|
|
147
|
+
if listener is None and 'relay_notifications' in tables:
|
|
148
|
+
# A desktop wake reaches another session, so it never paces a listener.
|
|
132
149
|
times.append(db.execute("SELECT max(created) FROM relay_notifications WHERE client_id=? "
|
|
133
150
|
"AND status='accepted'", (client_id,)).fetchone()[0])
|
|
134
151
|
times = [value for value in times if value is not None]
|
|
135
152
|
return max(times) if times else None
|
|
136
153
|
|
|
137
154
|
|
|
138
|
-
def held(db, binding, payloads, now) -> bool:
|
|
155
|
+
def held(db, binding, payloads, now, listener: str | None = None) -> bool:
|
|
139
156
|
"""Wake batching: hold a notice for these deliveries until the connection's interval has passed.
|
|
140
157
|
|
|
141
158
|
After a notice (a push notice or a desktop wake), the next one waits
|
|
@@ -147,39 +164,63 @@ def held(db, binding, payloads, now) -> bool:
|
|
|
147
164
|
interval = binding['wake_interval']
|
|
148
165
|
if not interval:
|
|
149
166
|
return False
|
|
150
|
-
last = last_notice(db, binding['client_id'])
|
|
167
|
+
last = last_notice(db, binding['client_id'], listener)
|
|
151
168
|
if last is None or now - last >= interval:
|
|
152
169
|
return False
|
|
153
170
|
exempt = set() if binding['wake_exempt'] == 'none' else set(binding['wake_exempt'].split(','))
|
|
154
171
|
return not any(_wakes_at_once(payload, binding, exempt) for payload in payloads)
|
|
155
172
|
|
|
156
173
|
|
|
157
|
-
|
|
174
|
+
_LISTENER = re.compile(r'[0-9a-f]{24}')
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _listener(value) -> str | None:
|
|
178
|
+
"""A session's wake key, or None for a caller that names no session."""
|
|
179
|
+
return value if isinstance(value, str) and _LISTENER.fullmatch(value) else None
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def claim_new(core, client_id: str, surface: str, *, limit: int = 50, listener: str | None = None
|
|
183
|
+
) -> dict[str, Any] | None:
|
|
158
184
|
"""Atomically record and summarize deliveries not yet announced to this client.
|
|
159
185
|
|
|
186
|
+
With a listener (a session's wake key), "not yet announced" counts for that
|
|
187
|
+
session only, so every session that shares the connection hears of each
|
|
188
|
+
delivery once. Without one, a delivery is announced once for the client.
|
|
160
189
|
Paused or suspended connections announce nothing; their work stays queued.
|
|
161
190
|
Deliveries already leased by a poll are skipped because a host is handling them.
|
|
162
191
|
"""
|
|
163
192
|
if surface not in SURFACES:
|
|
164
193
|
raise CoreError('invalid_push_surface')
|
|
194
|
+
listener = _listener(listener)
|
|
165
195
|
now = core.clock()
|
|
166
196
|
with core._tx() as db:
|
|
167
197
|
binding = core._binding(db, client_id)
|
|
168
198
|
if binding['paused'] or binding['suspended']:
|
|
169
199
|
return None
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
200
|
+
if listener is None:
|
|
201
|
+
rows = db.execute('''SELECT i.id,i.payload FROM inbox i
|
|
202
|
+
LEFT JOIN push_announcements p ON p.inbox_id=i.id
|
|
203
|
+
WHERE i.client_id=? AND i.acknowledged=0 AND p.inbox_id IS NULL
|
|
204
|
+
AND (i.lease_until IS NULL OR i.lease_until<=?)
|
|
205
|
+
ORDER BY i.created,i.rowid LIMIT ?''', (client_id, now, limit)).fetchall()
|
|
206
|
+
else:
|
|
207
|
+
rows = db.execute('''SELECT i.id,i.payload FROM inbox i
|
|
208
|
+
LEFT JOIN push_listener_announcements p ON p.inbox_id=i.id AND p.listener=?
|
|
209
|
+
WHERE i.client_id=? AND i.acknowledged=0 AND p.inbox_id IS NULL
|
|
210
|
+
AND (i.lease_until IS NULL OR i.lease_until<=?)
|
|
211
|
+
ORDER BY i.created,i.rowid LIMIT ?''', (listener, client_id, now, limit)).fetchall()
|
|
175
212
|
if not rows:
|
|
176
213
|
return None
|
|
177
|
-
if held(db, binding, [json.loads(row['payload']) for row in rows], now):
|
|
214
|
+
if held(db, binding, [json.loads(row['payload']) for row in rows], now, listener):
|
|
178
215
|
return None
|
|
179
216
|
senders: list[str] = []
|
|
180
217
|
for row in rows:
|
|
181
|
-
|
|
182
|
-
|
|
218
|
+
# The first announcement stays the record of when the client heard of it.
|
|
219
|
+
db.execute('INSERT OR IGNORE INTO push_announcements(inbox_id,client_id,surface,announced) '
|
|
220
|
+
'VALUES(?,?,?,?)', (row['id'], client_id, surface, now))
|
|
221
|
+
if listener is not None:
|
|
222
|
+
db.execute('INSERT OR IGNORE INTO push_listener_announcements(inbox_id,listener,client_id,announced) '
|
|
223
|
+
'VALUES(?,?,?,?)', (row['id'], listener, client_id, now))
|
|
183
224
|
label = _sender(json.loads(row['payload']))
|
|
184
225
|
if label and label not in senders and len(senders) < MAX_SENDERS:
|
|
185
226
|
senders.append(label)
|
|
@@ -228,16 +269,21 @@ def _pending_on_relay(remote) -> int | None:
|
|
|
228
269
|
return pending if isinstance(pending, int) and not isinstance(pending, bool) else None
|
|
229
270
|
|
|
230
271
|
|
|
231
|
-
def prepare_watch(core, client_id: str, announce_backlog: bool = True) -> None:
|
|
272
|
+
def prepare_watch(core, client_id: str, announce_backlog: bool = True, listener: str | None = None) -> None:
|
|
232
273
|
"""Set a watcher up: the push tables, and without announce_backlog, the waiting work marked as known."""
|
|
233
274
|
ensure_tables(core)
|
|
234
275
|
if announce_backlog:
|
|
235
276
|
return
|
|
277
|
+
listener = _listener(listener)
|
|
236
278
|
with core._tx() as db:
|
|
237
279
|
core._client(db, client_id)
|
|
238
280
|
db.execute('''INSERT OR IGNORE INTO push_announcements(inbox_id,client_id,surface,announced)
|
|
239
281
|
SELECT id,client_id,'watch',? FROM inbox WHERE client_id=? AND acknowledged=0''',
|
|
240
282
|
(core.clock(), client_id))
|
|
283
|
+
if listener is not None:
|
|
284
|
+
db.execute('''INSERT OR IGNORE INTO push_listener_announcements(inbox_id,listener,client_id,announced)
|
|
285
|
+
SELECT id,?,client_id,? FROM inbox WHERE client_id=? AND acknowledged=0''',
|
|
286
|
+
(listener, core.clock(), client_id))
|
|
241
287
|
|
|
242
288
|
|
|
243
289
|
def watch(core, client_id: str, emit: Callable[[dict], None], *, collect: bool = False,
|
|
@@ -246,7 +292,7 @@ def watch(core, client_id: str, emit: Callable[[dict], None], *, collect: bool =
|
|
|
246
292
|
announce_backlog: bool = True,
|
|
247
293
|
keep_running: Callable[[], bool] | None = None,
|
|
248
294
|
wait_for_change: Callable[[float], bool] | None = None,
|
|
249
|
-
remote: Any = None) -> dict[str, Any]:
|
|
295
|
+
remote: Any = None, listener: str | None = None) -> dict[str, Any]:
|
|
250
296
|
"""Emit one event per batch of new deliveries until the duration ends.
|
|
251
297
|
|
|
252
298
|
``keep_running`` is checked once per cycle; the CLI uses it to stop when the
|
|
@@ -277,7 +323,7 @@ def watch(core, client_id: str, emit: Callable[[dict], None], *, collect: bool =
|
|
|
277
323
|
relay = remote is not None
|
|
278
324
|
if relay:
|
|
279
325
|
try:
|
|
280
|
-
remote.prepare_watch(announce_backlog)
|
|
326
|
+
remote.prepare_watch(announce_backlog, listener)
|
|
281
327
|
except (Unavailable, Lost):
|
|
282
328
|
# Setting up is idempotent, so a lost answer is safe to redo here.
|
|
283
329
|
relay = False
|
|
@@ -293,7 +339,7 @@ def watch(core, client_id: str, emit: Callable[[dict], None], *, collect: bool =
|
|
|
293
339
|
if not local_ready:
|
|
294
340
|
# Already waiting work stays announced once: a backlog the relay
|
|
295
341
|
# marked is in the same table.
|
|
296
|
-
prepare_watch(core, client_id, announce_backlog or relay)
|
|
342
|
+
prepare_watch(core, client_id, announce_backlog or relay, listener)
|
|
297
343
|
local_ready = True
|
|
298
344
|
|
|
299
345
|
if not relay:
|
|
@@ -316,7 +362,7 @@ def watch(core, client_id: str, emit: Callable[[dict], None], *, collect: bool =
|
|
|
316
362
|
relayed = waiter(limit)
|
|
317
363
|
if relayed and remote is not None:
|
|
318
364
|
try:
|
|
319
|
-
event = remote.claim('watch')
|
|
365
|
+
event = remote.claim('watch', listener)
|
|
320
366
|
lost_announced = False
|
|
321
367
|
except Lost:
|
|
322
368
|
# The relay may have recorded the claim already, so a local claim
|
|
@@ -374,7 +420,7 @@ def watch(core, client_id: str, emit: Callable[[dict], None], *, collect: bool =
|
|
|
374
420
|
break
|
|
375
421
|
core.judge() # a "yes" becomes a delivery, announced right after
|
|
376
422
|
try:
|
|
377
|
-
event = claim_new(core, client_id, 'watch')
|
|
423
|
+
event = claim_new(core, client_id, 'watch', listener=listener)
|
|
378
424
|
except CoreError as error:
|
|
379
425
|
if error.code in FATAL_CODES:
|
|
380
426
|
return stopped(error.code)
|
|
@@ -424,7 +470,8 @@ def hook_response(core, client_id: str, event: str, payload: dict) -> dict[str,
|
|
|
424
470
|
return None
|
|
425
471
|
if event == 'Stop' and payload.get('stop_hook_active') is True:
|
|
426
472
|
return None
|
|
427
|
-
|
|
473
|
+
# The host process names its session, so each session hears of a delivery once.
|
|
474
|
+
claimed = claim_new(core, client_id, 'hook', listener=payload.get('listener'))
|
|
428
475
|
if claimed is None and event in ('SessionStart', 'UserPromptSubmit'):
|
|
429
476
|
claimed = pending_summary(core, client_id)
|
|
430
477
|
if event in ('SessionStart', 'UserPromptSubmit'):
|
|
@@ -281,9 +281,11 @@ class Relay:
|
|
|
281
281
|
return {'protocol': PROTOCOL, 'ok': False, 'error': 'bad_request'}
|
|
282
282
|
result = push.hook_response(self.core, client_id, event, payload)
|
|
283
283
|
elif op == 'claim':
|
|
284
|
-
result = push.claim_new(self.core, client_id, request.get('surface')
|
|
284
|
+
result = push.claim_new(self.core, client_id, request.get('surface'),
|
|
285
|
+
listener=request.get('listener'))
|
|
285
286
|
else: # watch_prepare
|
|
286
|
-
push.prepare_watch(self.core, client_id, request.get('announce_backlog') is not False
|
|
287
|
+
push.prepare_watch(self.core, client_id, request.get('announce_backlog') is not False,
|
|
288
|
+
request.get('listener'))
|
|
287
289
|
result = None
|
|
288
290
|
except CoreError as error:
|
|
289
291
|
return {'protocol': PROTOCOL, 'ok': True, 'error_code': error.code}
|
|
@@ -554,11 +556,11 @@ class Node:
|
|
|
554
556
|
def hook(self, event, payload):
|
|
555
557
|
return self._op('hook', event=event, payload=payload)
|
|
556
558
|
|
|
557
|
-
def claim(self, surface):
|
|
558
|
-
return self._op('claim', surface=surface)
|
|
559
|
+
def claim(self, surface, listener=None):
|
|
560
|
+
return self._op('claim', surface=surface, listener=listener)
|
|
559
561
|
|
|
560
|
-
def prepare_watch(self, announce_backlog):
|
|
561
|
-
self._op('watch_prepare', announce_backlog=announce_backlog)
|
|
562
|
+
def prepare_watch(self, announce_backlog, listener=None):
|
|
563
|
+
self._op('watch_prepare', announce_backlog=announce_backlog, listener=listener)
|
|
562
564
|
|
|
563
565
|
def wait(self, timeout):
|
|
564
566
|
return self.waiter(timeout)
|