Skip to content

feat: add contact book and agent discovery hooks - #153

Open
yarolegovich wants to merge 1 commit into
yarolegovich/ai-catalogfrom
yarolegovich/contacts
Open

yarolegovich wants to merge 1 commit into
yarolegovich/ai-catalogfrom
yarolegovich/contacts

Conversation

@yarolegovich

Copy link
Copy Markdown
Member

Stacked on #152; review only the last commit.

  • Added a2a contact add/remove/get/list. The contact book is an AI Catalog at ~/.config/a2a-cli/catalog.json that only a2a-cli writes, registered in the shared ~/.ai-catalog store as a2a-contacts after every change, so ai-catalog search/show sees contacts. If the store can't be updated, the contact is still saved and a2a warns.
  • contact add accepts anything -a accepts (host, card URL, file, catalog identifier, --catalog <name|url>, a single-agent catalog URL). Catalog entries are copied as listed, with identifier, publisher and trust manifest, so signatures stay verifiable; a relative entry URL is made absolute. A plain card gets urn:ai-catalog:a2a-cli:<name>. The name and note live under the org.a2aproject.a2a-cli entry extension.
  • -a <name> resolves a contact, and a contact's identifier takes precedence over registered catalogs, so an identifier that's ambiguous across catalogs resolves once it's a contact. The registered copy of the contact book is skipped in those lookups.
  • Added the hidden a2a hook and a2a hook probe, and the agent plugin ships hooks/hooks.json for SessionStart, UserPromptSubmit and PostToolBatch. The hook injects contacts and agents discovered on sites in the conversation, never entries of registered catalogs; the skill points agents to a2a catalog search for those.
  • Discovery was rebuilt from the prototype branch: the hook never touches the network, a detached probe fills the card cache, and the probe guard refuses link-local addresses and public-to-internal redirects. Compared to the prototype, probes honor HTTPS_PROXY/NO_PROXY (best-effort check on the locally resolved target), connection failures, 5xx and 429 aren't cached as misses, a JSON document without a name and interface isn't treated as a card, injected text drops Unicode control and bidi characters, and contacts and discovered blocks are capped so one event stays under the 10,000-character hook limit.
  • Moved atomic writes to internal/atomicfile, used by the AI Catalog store, the contact book, the card cache and session state.

Fixes #138

Keep trusted agents in an AI Catalog owned by a2a-cli and register it in
the shared ai-catalog store, so other tools see contacts too. Tell coding
agents about contacts and about agents discovered on sites mentioned in
the conversation through harness hooks.

- a2a contact add/remove/get/list; add accepts any -a reference and
  copies catalog entries with their identifier, publisher and trust
  manifest
- -a <name> resolves a contact, and a contact's identifier takes
  precedence over registered catalogs
- hidden a2a hook / hook probe for SessionStart, UserPromptSubmit and
  PostToolBatch, shipped in the agent plugin

Fixes #138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant