@mindstudio-ai/agent 0.1.90 → 0.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms.txt CHANGED
@@ -1857,11 +1857,21 @@ export const Policies = dataSources.defineDataSource('policies');
1857
1857
 
1858
1858
  // search
1859
1859
  const { results } = await Policies.search('what are the payment terms?', { topK: 5 });
1860
- // options: topK (default 5, max 50), scoreThreshold, rerank, hybrid — the last two default on
1860
+ // options: topK (default 5, max 50), scoreThreshold, filter, mode, maxPerDocument, highlight, rerank, hybrid
1861
1861
  const context = results.map((r) => r.text).join(String.fromCharCode(10, 10));
1862
1862
 
1863
+ // narrow before ranking: metadata tags, filename, pages, required words
1864
+ await Policies.search('termination clause', {
1865
+ filter: { metadata: { department: 'legal', year: [2025, 2026] }, phrase: 'notice period' },
1866
+ maxPerDocument: 2, // stop one document monopolizing the results
1867
+ });
1868
+
1869
+ // mode: 'hybrid' (default) | 'semantic' | 'lexical'. Lexical skips the query
1870
+ // embedding — fastest, right for identifier-shaped queries (error codes, SKUs).
1871
+ await Policies.search('ERR-7741X', { mode: 'lexical' });
1872
+
1863
1873
  // add a document (background — poll documents() for status)
1864
- await Policies.add(buffer, { filename: 'policy.pdf', contentType: 'application/pdf' });
1874
+ await Policies.add(buffer, { filename: 'policy.pdf', contentType: 'application/pdf', metadata: { department: 'legal' } });
1865
1875
  const docs = await Policies.documents();
1866
1876
 
1867
1877
  // introspection — what is in the corpus, and how one document was split
@@ -1871,14 +1881,18 @@ const chunks = await Policies.chunks(docs[0].id); // why a document does o
1871
1881
 
1872
1882
  `SearchHit`: `{ score, text, citation: { documentId, filename, pageNumber, chunkIndex, headingPath, boundingBox?, url } }`. `citation.url` is a stable on-domain link to the source document — drop it in an `<a href>`. `(documentId, chunkIndex)` is a chunk's stable identity — key an eval set on that, not on `text`.
1873
1883
 
1874
- Also on each hit: `retrievalRank`/`retrievalScore` (position before reranking — compare with the final position to see what reranking did). Two opt-in search options for debugging: `explain: true` adds `explain.{dense,lexical,matchedVia}` so you can see which half of hybrid found a hit, and `expand: 1` adds `neighbors.{before,after}` for surrounding context. Neither changes the results or their order.
1884
+ Also on each hit: `retrievalRank`/`retrievalScore` (position before reranking — compare with the final position to see what reranking did). Three opt-in search options for debugging and display: `explain: true` adds `explain.{dense,lexical,matchedVia}` so you can see which half of hybrid found a hit; `expand: 1` adds `neighbors.{before,after}` for surrounding context; `highlight: true` adds `matches` — `{start, end}` offsets of query terms in `text`, for rendering highlights. None of them changes the results or their order.
1885
+
1886
+ `filter` fields (all AND together, and only narrow): `metadata` (per-key equals, or any-of via an array), `filename`, `documentIds`, `pages: {min?, max?}`, `contains` (all words, any order), `phrase` (exact adjacent sequence). Document metadata is set at add time: scalars only, ≤16 keys, keys `[a-zA-Z0-9_-]`. Re-adding the same bytes with different metadata updates the tags in place — no re-processing.
1875
1887
 
1876
1888
  Search is deterministic for a fixed corpus and configuration — same query, same order — so regression checks are meaningful. `search()` also returns `latencyMs`.
1877
1889
 
1878
- Supported: pdf, docx, pptx, xlsx, odt, rtf, epub, images, txt, md, json, csv, html.
1890
+ Other methods: `stats()`, `documents()`, `chunks(documentId, {vectors?})`, `remove(documentId)`, `ensure(name?)` (rarely needed — `add` and `search` create-on-reference), and `DataSource.contentHash(bytes)` to check for an existing document before adding.
1891
+
1892
+ Supported: pdf, docx, pptx, xlsx, odt, rtf, epub, images, txt, md, json, csv, tsv, log, html.
1879
1893
 
1880
1894
  Adding the same bytes twice is free — documents are content-addressed, so a re-add is a no-op when this source has already processed those exact bytes under its current configuration. Only reconfiguring the source makes a re-add do work again, and that is an explicit owner-triggered migration, never a side effect of a deploy.
1881
1895
 
1882
- `rerank` and `hybrid` are free to change and take effect on the next search. How documents are chunked and embedded is configured on the corpus itself with `mindstudio-prod datasources config` — not in code — and changing it on a populated source is rejected rather than silently rebuilding.
1896
+ Everything in `SearchOptions` — `mode`, `filter`, `rerank`, `hybrid`, `maxPerDocument`, `highlight` — is free to change and takes effect on the next search. How documents are chunked and embedded is configured on the corpus itself with `mindstudio-prod datasources config` — not in code — and changing it on a populated source is rejected rather than silently rebuilding.
1883
1897
 
1884
1898
  **A data source is live and shared.** Unlike database tables there is no dev copy and no per-release isolation: adding or removing a document changes what the deployed app retrieves, immediately. Scenarios never reset a data source, and re-ingesting a large corpus costs real money.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.90",
3
+ "version": "0.1.92",
4
4
  "description": "TypeScript SDK for MindStudio direct step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,6 +26,7 @@
26
26
  "codegen": "tsx scripts/codegen.ts",
27
27
  "typecheck": "tsc --noEmit",
28
28
  "postinstall": "node dist/postinstall.js || true",
29
+ "bump-consumers": "node scripts/bump-consumers.mjs",
29
30
  "prepare": "npm run build",
30
31
  "prepublishOnly": "npm run build"
31
32
  },