Search the caller's own threads by the words of their titles, descriptions and messages
The caller's own threads, and nobody else's (ADR 0039, ADR 0068): what it finds is always a subset of what listThreads lists for the same archived and branches, for every role (an administrator finds their own too). Another person's thread is never a hit, by its title or by its content. The permission is thread.read. A POST, though it is a safe read that writes nothing: the query is a person's words, and they must not be in a URL, a proxy's access log or a trace. The media type is exactly application/json (a parameter such as charset is allowed; application/problem+json and application/json-seq are not): any other is a 415. The checks run in one order, so two errors never leave a client guessing: 401, 429, 403, 415, then the body's shape (400 bad_request: one JSON object, only the five members, each of its type, none twice, no null), q (400 query_empty, query_too_long), limit's range, archived, branches, the cursor (400 bad_cursor), and last the store (503). The vectors of requests.json hold every case.
Every rule is in thread-search-v1.md, with vectors: what a word is, how it is folded (Café, cafe and CAFÉ are one word; cœur is coeur), how the query is read, when a document matches (every term is the start of one word of one title, one description or one message), what is searched (titles, descriptions, a person's messages and an agent's final answers; not working text, reasoning, steps, tool results or file names), how the snippet is cut and its offsets, and the order. A second client reads that page and gets the same threads, snippets and order as this server.
Order: rank descending (2: the title matches, 1: the description, 0: only messages), then the thread's id descending (the newest created first). A page that is read later differs from an earlier one only when a thread was renamed, deleted or written to in between.
Client recipe (the server enforces every rule above; a client only offers the box):
- If
getConfighas nosearch, offer no box. - Debounce about 250 ms, cancel the request in flight when the text changes, and drop an answer that is not for the latest text.
- Send
{"q": text}; do not trim, fold or bound it yourself. Draw each result withthread.title, and each hit'ssnippet.textsplit atmatches(UTF-16 code unit offsets) into plain and marked runs, with an ellipsis wherecutStartorcutEnd. Never interpret the text as markup. SaymessageHitsbeyond the hits shown.query.termssays what was searched for. - A message hit opens the thread at its
seq(getThreadHistorywithsince=<seq>, as for a#m-<seq>link); a title or description hit opens the thread as usual. - For more, send the same request with
cursorset tonext, untilnextis absent. - On 429 wait
Retry-After; on 503 say that the search is unavailable and offer to try again.
A query that keeps no term (a, !!) is a 200 with terms: [] and no result.
Authorizations
A JWT signed by the configured issuer (RS256, RS384, ES256 or EdDSA), with the configured audience. Read when auth.mode is jwt or jwt_or_proxy_header. A missing or refused token gets 401 with WWW-Authenticate: Bearer; an issuer whose keys cannot be fetched gets 503.
A JWT as bearerToken, bound to the key of the client (cnf.jkt, RFC 7638), sent as Authorization: DPoP <token> with one DPoP header holding a proof signed by that key (RFC 9449, ADR 0054). Read only when auth.dpop is configured. A bad proof gets 401 with WWW-Authenticate: DPoP error="invalid_dpop_proof", algs="ES256 EdDSA", a bad or unbound token error="invalid_token".
Set by oauth2-proxy after OIDC login; requests without it get 401. Read when auth.mode is proxy_header (the default) or jwt_or_proxy_header without a bearer token.
Request Body
Responses
One page of results