feat: add ae_journal_list tool
Lists all Aether Journals for the configured account via POST /v3/crud/journal/search with no filters (account scoped by header). Returns name + id_random for each journal so the agent can discover available journals before searching or writing entries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -112,6 +112,52 @@ def _sync_journal_search(query: str, journal_id: str | None, max_results: int) -
|
||||
return "\n".join(lines).strip()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tool: ae_journal_list
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def journal_list() -> str:
|
||||
"""List all journals accessible to the configured AE account."""
|
||||
err = _check_config()
|
||||
if err:
|
||||
return err
|
||||
return await asyncio.to_thread(_sync_journal_list)
|
||||
|
||||
|
||||
def _sync_journal_list() -> str:
|
||||
import requests
|
||||
|
||||
url = f"{settings.ae_api_url}/v3/crud/journal/search"
|
||||
try:
|
||||
resp = requests.post(
|
||||
url,
|
||||
headers=_headers(),
|
||||
json={"page_size": 100},
|
||||
timeout=settings.ae_api_timeout,
|
||||
)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
except Exception as e:
|
||||
logger.warning("ae_journal_list failed: %s", e)
|
||||
return f"Journal list error: {e}"
|
||||
|
||||
journals = data.get("data", [])
|
||||
if not journals:
|
||||
return "No journals found for this account."
|
||||
|
||||
lines = [f"Journals ({len(journals)}):\n"]
|
||||
for j in journals:
|
||||
jid = j.get("journal_id") or j.get("id_random") or j.get("id") or "?"
|
||||
name = j.get("name") or "(untitled)"
|
||||
desc = j.get("description") or ""
|
||||
line = f"- **{name}** — id: `{jid}`"
|
||||
if desc:
|
||||
line += f"\n {desc}"
|
||||
lines.append(line)
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tool: ae_journal_entry_create
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user