Skip to content

feat(agent): message people as an agent — connect, ask, replies and a signed webhook - #163

Merged
xergioalex merged 6 commits into
mainfrom
release__agent_messenger
Dec 3, 2026
Merged

xergioalex merged 6 commits into
mainfrom
release__agent_messenger

Conversation

@xergioalex

Copy link
Copy Markdown
Member

What

An agent can now message a person through Dailybot and read the answer — "use Dailybot to message me" just works.

  • dailybot agent connect "<name>" [--description] [-p] — needs dailybot login; mints an agent credential (dbagt_…) and stores it in ~/.config/dailybot/messenger.json (0600, per profile). The token is never printed, only its prefix. Same name again → same agent, fresh credential.
  • dailybot agent me — the agent behind the stored credential.
  • dailybot agent ask --to <email|usr_id> "<text>" [-o X ...] [--wait 30m] [--json] — 2–6 options for a one-tap decision; --wait long-polls replies for that question_id.
  • dailybot agent replies [--wait] [--follow] [--json] — new answers since the last call (cursor stored per profile; --follow streams JSON Lines).
  • dailybot agent webhook set <https-url> / show / remove — signed webhook; the secret is shown once.

Decisions

  • Credential isolation. Messenger commands send only Authorization: Agent <token>, never an API key or the login session, and only to the API host that minted the token. connect sends only the login session (the API key is not even a fallback, so a refusal names the real problem).
  • Webhook verbs side by side. webhook register/unregister keep the older API-key flow unchanged; set/show/remove are the messenger webhook. No behaviour switches on what the profile holds, so neither command changes meaning under an existing script.
  • Timeout exit code is 124, not 2: Click and this CLI use 2 for usage errors, and an agent must not read a typo as "nobody answered". 124 is the timeout(1) convention.
  • ask --wait reads from the stored cursor without moving it, so agent replies still lists every answer.
  • New file messenger.json instead of new keys in agents.json (Rule 16: stored schemas untouched).

Contract (API built in parallel)

POST /v1/messaging/agents/connect/, GET /agents/me/, POST /agents/me/ask/ ({person, text, options?}), GET /agents/me/replies/?after=&wait=, GET/PUT/DELETE /agents/me/webhook/; errors use the messaging envelope {code, message, detail, retry_after, request_id}. Documented in docs/API_REFERENCE.md.

Tests

tests/agent_messenger_test.py (38): storage mode and cursor rules, wire (Agent scheme, no fallback, connect never sends the key, wait clamp/timeout), every command incl. not-v4, revoked credential, rate limit, timeout exit, terminal-safe reply text. Full suite: 4352 passed; ruff check/format and mypy clean.

CHANGELOG is generated by semantic-release from the feat: commit, so it is not edited by hand.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AY6kxNxkCZG2pPJSh1Bxer


Carries the commits of #161 by @mauriciomdb, reopened from a maintainer account so the AI review gate runs.

mauriciomdb and others added 3 commits December 3, 2026 17:20
… signed webhook

dailybot agent connect mints an agent credential with the login session and
stores it in messenger.json (0600, token never printed). agent ask asks one
person (options for a one-tap decision, --wait to block for the answer; exit
124 on timeout), agent replies returns new answers with a stored cursor, and
agent webhook set/show/remove manage the signed webhook. The older
API-key agent webhook and message commands are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AY6kxNxkCZG2pPJSh1Bxer
connect explains a name owned by someone else (409 name_taken, exit 2) and a
paused agent (403); replies asks for full pages (limit 50) and documents that
a first call returns the last 7 days.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AY6kxNxkCZG2pPJSh1Bxer
The API nests the agent as agent.participant {id, display_name}; connect now
stores and shows the real agent id and name, agent me renders the same shape,
and ask checks options locally (unique, at most 80 characters).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AY6kxNxkCZG2pPJSh1Bxer
@github-actions

This comment has been minimized.

github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the pr-reviewed Passed AI code review label Dec 3, 2026
@github-actions

This comment has been minimized.

github-actions[bot]

This comment was marked as outdated.

- A replies page that does not move the cursor ends the drain (agent replies)
  or pauses the wait (ask --wait), so a repeated page is never replayed.
- ask --wait first catches up to the newest reply, so a long backlog never eats
  the wait; a question without question_id is refused under --wait.
- The stored credential matches an equivalent API origin (case, default port).
- A cursor write never restores a token that connect replaced meanwhile.
- --follow with --wait is a usage error; a bad .dailybot/profile.json answers
  in JSON under --json.
- messenger.json is listed with the files that hold secrets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xergioalex xergioalex added Ready Trigger AI code review and removed Ready Trigger AI code review labels Dec 3, 2026
@github-actions

This comment has been minimized.

github-actions[bot]

This comment was marked as outdated.

@xergioalex xergioalex added Ready Trigger AI code review and removed Ready Trigger AI code review labels Dec 3, 2026
@github-actions

This comment has been minimized.

github-actions[bot]

This comment was marked as outdated.

…ebhook set

- ask --wait and replies --wait re-read the clock after each poll: pause on a
  page with nothing new, never sleep past the deadline.
- webhook show never prints a secret; only webhook set shows it, once.
- A stored credential without its API host fails closed.
- --wait durations given as integers are range-checked too.
- Reconnecting on an equivalent host keeps the replies cursor.
- Tests: follow streams and stops on Ctrl-C, show hides the secret, the
  host-less credential, the deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xergioalex xergioalex added Ready Trigger AI code review and removed Ready Trigger AI code review labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

AI review for c1316c8 — ✅ done

View review →

Highest severity: none

Verifier: 0 checked · 0 verified · 0 downgraded · 0 refuted · 0 unverified · 0 skipped — grok-4.5 (economy), 0s

Strictness gate: ✅ highest severity none ≤ critical threshold

0 inline comment(s) attached.

Usage: 332.7k in (84% cached) · 4.7k out · est. $0.22 · 7 turns · 88s

Iteration-Aware Review: gen 4, round 1, policy=first-pass-exhaustive (new_commits, mode=incremental) — 0 surfaced.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review — 0 finding(s): 0 critical · 0 warning · 0 info

Check: ✅ passing — strictness block-on-critical: highest severity none ≤ critical threshold

No findings posted inline.

Summary

Verdict

Prior review items are fixed. The follow-up commit hardens host binding, wait loops, webhook secret display, duration bounds, and reconnect cursor matching, with matching tests.

What changed since last review

c1316c8 addresses the open findings:

  1. Host binding — empty or missing api_url fails closed (credential_host_mismatch); the client is always pinned to the mint host.
  2. Wait loops — ask --wait and replies --wait re-read the clock after each poll and sleep min(FOLLOW_IDLE_PAUSE_SECS, left), never past the deadline.
  3. Webhook secret — print_messenger_webhook(..., show_secret=False) by default; only webhook set passes show_secret=True. Human show no longer prints a secret even if GET returns one.
  4. DurationType — integer inputs go through the same 1s–7d bounds as strings (bool excluded).
  5. Reconnect cursor — uses same_api_origin so equivalent hosts keep the replies cursor.
  6. Tests — host-less credential, equivalent-host reconnect, --follow stream + Ctrl-C, deadline sleep cap, show hides secret, integer duration refusals.

Remaining note (not re-posted)

_fetch_new still stops the drain when a page has results but does not advance next_cursor. That is intentional: results are already collected, and continuing would repeat the page. API_REFERENCE documents next_cursor always present and “a page that does not move the cursor ends the drain.”

Release decision

Recommendation: approve


Since last review (65252b5 → c1316c8): resolved 8 · still open 0 · regressed 0 · new 0 · 8 auto-retired (fix corroborated; thread already collapsed).

Prior findings

  • retired dailybot_cli/commands/agent_messenger.py:393 (verified_fixed)
  • retired dailybot_cli/commands/agent_messenger.py:612 (verified_fixed)
  • retired dailybot_cli/display.py:2986 (verified_fixed)
  • retired dailybot_cli/commands/agent_messenger.py:162 (verified_fixed)
  • retired dailybot_cli/commands/agent_messenger.py:100 (verified_fixed)
  • retired dailybot_cli/config.py:1701 (verified_fixed)
  • retired dailybot_cli/commands/agent_messenger.py:538 (verified_fixed)
  • retired tests/agent_messenger_test.py:610 (verified_fixed)

Check status: ✅ passing — strictness block-on-critical, highest severity in effect none: highest severity none ≤ critical threshold.

This line is written by the reviewer runtime after the gate ran and matches the check conclusion and the tracking comment. Any recommendation above is the model's advisory opinion, not the gate.

@xergioalex
xergioalex merged commit 6d151cf into main Dec 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-reviewed Passed AI code review Ready Trigger AI code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants