Logotipo de Query

Query

OrganizaciónPopular
GetStream
query

How list endpoints take filters and sorts, modelled on Stream's query syntax. Read before adding a filter, a sort, or a query endpoint.

Descripción general

EditorGetStream
RepositorioAgents
Nombre de la habilidadquery
Estrellas
8.2K
Forks
709
Archivos incluidos
Solo instrucciones
LicenciaApache-2.0
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando la petición encaja con la habilidad.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por GetStream en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Query en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/GetStream/Agents/tree/main/.claude/skills/query
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/GetStream/Agents.git /tmp/Agents
mkdir -p .claude/skills
cp -r /tmp/Agents/.claude/skills/query .claude/skills/query
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Query en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición encaja con la habilidad, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Query automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Query no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición que encaja con la habilidad, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

Query

One filter language for every list, the one getstream.io uses for users, channels, messages and calls. A caller who has written one Stream query can write ours.

Paging is the pagination skill (.claude/skills/pagination/SKILL.md). Read it first: this skill decides which rows, that one decides where the page starts.

Shape

A resource that needs more than a couple of equality filters gets POST /v1/<resource>/query, operationId query<Resources>:

json
{
  "filter": {"state": "closed", "created_at": {"$gte": "2026-09-01T00:00:00Z"}},
  "sort": [{"field": "created_at", "direction": -1}],
  "limit": 25,
  "cursor": "…"
}

The answer is a page, {items, has_more, next_cursor}, as in pagination.

  • POST because a filter is a tree, and a tree in a query string is unreadable. It still reads and nothing changes.
  • A simple GET list with a couple of query parameters stays as it is. Add query<Resources> beside it when it outgrows them; don't add a tenth query parameter.
  • filter is optional. An empty filter is every row the caller may see.

Stream calls the field filter_conditions. We call it filter; the grammar is the same.

Filter grammar

A filter is a JSON object. Keys are field names or logical operators, and all keys at one level are ANDed.

OperatorMeaningExample
$eqequal; a bare value is shorthand{"state": "closed"}
$inequal to any of a list{"agent": {"$in": ["a", "b"]}}
$gt $gte $lt $lterange, on numbers and RFC3339 times{"created_at": {"$lt": "…"}}
$existsthe field is set or not{"ended_at": {"$exists": false}}
$containsarray holds the value; object holds every key and value{"custom": {"$contains": {"team": "x"}}}
$autocompleteprefix match on a name{"title": {"$autocomplete": "sup"}}
$qfull-text match{"title": {"$q": "billing refund"}}
$and $ora list of filters{"$or": [{"state": "running"}, {"agent": "x"}]}

custom.<key> is shorthand for $contains on the custom object: {"custom.team": "x"} is {"custom": {"$contains": {"team": "x"}}}.

Not supported, and a 400: $ne, $nin, $nor, $not, regexes. Negative filters walk every row that does not match instead of seeking to the ones that do. Rewrite them as a positive $in. Stream allows $ne only on id and booleans; we allow $ne only on booleans, where it is just $eq with the other value.

Rules

  • Each endpoint declares an allow-list: field → operators, and the column each field reads. Anything else is a 400 that names the field and the operator. Never pass a caller's field name into SQL; it is looked up in the allow-list and the column comes from there.
  • Only allow what an index serves. If (customer_id, agent, created_at, id) exists, agent gets $eq and $in; a field with no index gets nothing until it has one. Custom fields get $eq/$contains only, as containment (@>), which a jsonb_path_ops GIN index on the JSONB column answers. Never $exists on a custom key: key-exists (?, ?|, ?&) needs the default jsonb_ops index, which is several times larger.
  • $and/$or nest one level deep at most, and $in takes at most 100 values. Deeper trees are a 400; they are how a list becomes a table scan.
  • Scope is not a filter. The handler ANDs the customer, and for end users the user, onto whatever arrived, as SessionFilter.UserID does. A caller cannot widen it by writing $or.
  • Values are typed by the field: a time must parse as RFC3339, a number as a number, an enum as one of its values. A wrong type is a 400, not an empty page.

Sort

sort is a list of {"field", "direction"}, direction 1 ascending or -1 descending, as Stream does it. Fields come from a sort allow-list, usually two or three indexed columns.

  • Omitted, the endpoint's default applies, e.g. created_at descending.
  • The server appends id in the direction of the last key, so the order is total.
  • The cursor holds every sort key and a fingerprint of the sort. A cursor sent with a different sort is a 400. See pagination for why the keys are in the cursor.
  • One index per allowed sort, behind the filters it is used with.

Paging

As in pagination: limit + cursor, never offset. Stream Chat's queries page by offset with a 1,000 row ceiling; Stream Video's queryCalls hands back a next pointer. We do what Video does.

  • filter and sort are resent with every page. The cursor is only a position.
  • The next page is the filter ANDed with (sort keys, id) < (cursor values), flipped to > for ascending keys.
  • Fetch limit + 1 for has_more. No counts.

Go

Put the grammar in one package and reuse it; an endpoint only supplies its allow-lists.

  • A short allow-list needs no parser. querySessions (internal/api/session_query.go) declares its filter as closed Huma structs, with one struct per operator (Equals, TextMatch), so the schema validates the request and documents it too. Combinations the schema cannot express, such as a text search with project_id, are refused in sessionQueryOf. The cursor carries the sort, so a cursor from one sort is refused by another. Start here, and move to a tree only when $and, $or or $in are needed.
  • Parse the body into a tree once, validating against the allow-list as you go. The handler gets a typed tree or an invalidRequest APIError.
  • Compile the tree to bun Where clauses with bound values. Field names never reach SQL as text.
  • Where a list merges rows held in memory with rows in Postgres, like live sessions in Manager.find, the same tree needs a Match(item) too, so both halves filter and sort alike.
  • Document the allowed fields, operators and sorts in the operation's description; that is what a caller reads.
  • Tests follow the go-testing skill: one per allowed operator, one for a rejected field and a rejected operator, one for a nested $or, and one that pages a filtered, sorted list to the end without repeating or skipping a row.

SDKs

Go first, as AGENTS.md says. The filter is a plain map in every SDK (map[string]any, a dict, an object), which is how Stream's SDKs take filter_conditions. Sort is a typed list. List methods follow the cursor the way Items.Unwind does.

Preguntas frecuentes

¿Qué hace la habilidad de IA Query?

How list endpoints take filters and sorts, modelled on Stream's query syntax. Read before adding a filter, a sort, or a query endpoint.

¿Por qué usar Query en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Query está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Query en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/GetStream/Agents/tree/main/.claude/skills/query. TypingMind lee el archivo SKILL.md de esa carpeta e instala su contenido como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Query?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Query?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Query con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Query?

Sí. GetStream la ha publicado en GitHub bajo la licencia Apache-2.0. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver el directorio

Crea ya tu propio espacio de trabajo con IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇