| name | description | allowed-tools | user-invocable | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
library-search |
Search for books and order them from Norwegian libraries. Use when the user wants to find a book, check library availability, reserve/order a book, check loans, renew loans, or request interlibrary loans. Triggers on "find book", "search library", "order book", "reserve book", "check availability", "renew loan", "library", "bibsok", "hamar bibliotek", "interlibrary loan", "fjernlån". |
|
true |
Search for books in the Hamar public library and the national library catalog (Biblioteksøk), and order/reserve them for pickup at Hamar bibliotek.
Read credentials from /Users/stian/src/research/.env:
HAMAR_BIB_EMAIL— email for hamar.bib.no loginHAMAR_BIB_PASSWORD— password for both systemsHAMAR_BIB_BORROWER_NUMBER— library card number (format: N + 9 digits), used for bibsok.no login
Always load credentials at the start:
source /Users/stian/src/research/.envThere are two library systems:
| System | URL | Use for | Login with |
|---|---|---|---|
| Hamar Bibliotek | https://hamar.bib.no/cgi-bin/m2 |
Local books at Hamar library | Email + password |
| Biblioteksøk | https://bibsok.no/ |
National catalog + interlibrary loans | Borrower number + password |
Always pick up at Hamar bibliotek (the default for both systems).
- Start with Hamar Bibliotek if the user wants a common/popular book — faster pickup if available locally
- Use Biblioteksøk if the book isn't found locally, or the user specifically wants an interlibrary loan
- Use the BIBSYS SRU API for quick bibliographic lookups (no auth, returns MARCXML) — useful when you just need to check if a book exists or get its ISBN
agent-browser open "https://hamar.bib.no/cgi-bin/m2?mode=login" && agent-browser wait --load networkidle && agent-browser snapshot -i
# Fill lnr field with email, passord field with password
agent-browser fill @LNR_REF "$HAMAR_BIB_EMAIL" && agent-browser fill @PASSORD_REF "$HAMAR_BIB_PASSWORD"
agent-browser click @LOGIN_BUTTON_REF && agent-browser wait --load networkidleAfter login, search from the homepage:
agent-browser open "https://hamar.bib.no/cgi-bin/m2" && agent-browser wait --load networkidle && agent-browser snapshot -i
# Fill the search field (pubsok_txt_0) and submit
agent-browser fill @SEARCH_REF "search terms" && agent-browser press Enter && agent-browser wait --load networkidle
agent-browser snapshot -iSearch results show for each book:
- Title and author (linked)
- Format: Bok/DVD/etc, Language, Year
- Availability: green "X ledig" (available) or red "Ikke ledig" (unavailable)
- "Bestill..." button to reserve
- "Vis mer" button for details
Present results to user as a numbered list with title, author, year, and availability status.
# Click "Bestill..." on the desired result
agent-browser click @BESTILL_REF && agent-browser wait --load networkidle && agent-browser snapshot -i
# The form shows pickup location radio buttons — Hamar bibliotek should be default/selected
# Click "Bekreft bestilling" to confirm
agent-browser click @CONFIRM_REF && agent-browser wait --load networkidle
agent-browser snapshot -i # Verify confirmationPickup locations: "Hamar bibliotek" (always use this) or "Hamar bibl.Vang".
agent-browser open "https://hamar.bib.no/cgi-bin/m2?mode=mappami" && agent-browser wait --load networkidle && agent-browser snapshot -iShows:
- Mine reserveringer — ordered/reserved books with "Endre"/"Avbestill" buttons
- Mine lån — currently borrowed books with due dates and "Forleng lånet" (renew) buttons
- "Forleng alle lån" button to renew everything at once
# To renew all loans at once:
agent-browser click @RENEW_ALL_REF && agent-browser wait --load networkidle
# Or click individual "Forleng lånet" buttons| Page | URL |
|---|---|
| Profile | ?mode=lninfo |
| History | ?mode=historikk |
| Wishlist | ?mode=lister-vis |
| Messages | ?mode=saker-vissaker |
agent-browser open "https://bibsok.no/?mode=logginn" && agent-browser wait --load networkidle && agent-browser snapshot -i
# Fill lnr with borrower number, passord with password
agent-browser fill @LNR_REF "$HAMAR_BIB_BORROWER_NUMBER" && agent-browser fill @PASSORD_REF "$HAMAR_BIB_PASSWORD"
agent-browser click @LOGIN_BUTTON_REF && agent-browser wait --load networkidleSearch URL pattern — can be opened directly:
https://bibsok.no/?mode=vt&pubsok_txt_0={QUERY}
With field-specific search:
https://bibsok.no/?mode=vt&pubsok_txt_0={QUERY}&pubsok_kval_0={FIELD}
Field codes for pubsok_kval_0:
| Code | Field |
|---|---|
| (empty) | All fields |
/HT |
Exact title |
/TI |
Words in title |
/PE |
Author |
/EO |
Subject |
/IS |
ISBN |
/KL |
Dewey number |
Filters:
| Parameter | Example values |
|---|---|
avgr_medier |
ff=l (books), ff=di (audiobooks), lf=t (comics) |
avgr_spraak |
sp=nor, sp=eng, sp=swe, sp=ger, sp=fre |
avgr_bn |
bn=a (adults), bn=j eller bn=d (children/youth) |
aarfra / aartil |
Year range (4-digit years) |
sortering |
relevans, aar, tittel, ordord |
Example searches:
# Simple search
agent-browser open "https://bibsok.no/?mode=vt&pubsok_txt_0=Kierkegaard" && agent-browser wait --load networkidle && agent-browser snapshot -i
# ISBN search
agent-browser open "https://bibsok.no/?mode=vt&pubsok_txt_0=9788249511129&pubsok_kval_0=/IS" && agent-browser wait --load networkidle && agent-browser snapshot -i
# Books by author in Norwegian
agent-browser open "https://bibsok.no/?mode=vt&pubsok_txt_0=Ibsen&pubsok_kval_0=/PE&avgr_medier=ff%3Dl&avgr_spraak=sp%3Dnor" && agent-browser wait --load networkidle && agent-browser snapshot -iPresent results to user as a numbered list.
After finding a book, extract its TNR from the detail page link:
# Navigate to book detail
agent-browser open "https://bibsok.no/?tnr={TNR}" && agent-browser wait --load networkidle && agent-browser snapshot -i
# Must be logged in. Click "Bestill" button
agent-browser click @BESTILL_REF && agent-browser wait --load networkidle && agent-browser snapshot -i
# The order page defaults to Hamar bibliotek as pickup. Confirm with "Reserver"
agent-browser click @RESERVER_REF && agent-browser wait --load networkidle
agent-browser snapshot -i # Verify confirmationHamar bibliotek code is 2040300 — it should be the default pickup library.
For quick lookups without browser automation. No auth required:
curl -s 'https://bibsys-network.alma.exlibrisgroup.com/view/sru/47BIBSYS_NETWORK?version=1.2&operation=searchRetrieve&recordSchema=marcxml&query=alma.all_for_ui=SEARCH_TERM&maximumRecords=10'CQL query fields:
alma.all_for_ui=TERM— search all fieldsalma.title="PHRASE"— by titlealma.creator=NAME— by authoralma.isbn=NUMBER— by ISBN
Combine with AND: alma.creator=Ibsen AND alma.title=Hedda
Returns MARCXML. Key MARC fields:
- 020 = ISBN
- 100 = Author
- 245 = Title
- 260/264 = Publisher/year
- 300 = Pages
Use this for quick existence checks or to find ISBNs before searching in the other systems.
- Always present results clearly — numbered list with title, author, year, availability
- Ask before ordering — confirm with the user which book to reserve
- Try local first — check Hamar bib before suggesting interlibrary loan
- Report availability — tell the user if a book is available now or must be waited for
- After ordering, confirm — read back the confirmation to the user
- Close browser when done — run
agent-browser closeafter completing all operations