@mastra/rag 2.2.0-alpha.0 → 2.2.1-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @mastra/rag
2
2
 
3
+ ## 2.2.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed a security issue where several parsing and tracing paths could slow down on malformed or attacker-crafted input. Normal behavior is unchanged, and these packages now handle pathological input in linear time. ([#15566](https://github.com/mastra-ai/mastra/pull/15566))
8
+
9
+ - Updated dependencies [[`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9)]:
10
+ - @mastra/core@1.26.0-alpha.10
11
+
12
+ ## 2.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Add RAG observability (#10898) ([#15137](https://github.com/mastra-ai/mastra/pull/15137))
17
+
18
+ Surfaces RAG ingestion and query operations in Mastra's AI tracing.
19
+
20
+ New span types in `@mastra/core/observability`:
21
+ - `RAG_INGESTION` (root) — wraps an ingestion pipeline run
22
+ - `RAG_EMBEDDING` — embedding call (used by ingestion and query)
23
+ - `RAG_VECTOR_OPERATION` — vector store I/O (`query`/`upsert`/`delete`/`fetch`)
24
+ - `RAG_ACTION` — `chunk` / `extract_metadata` / `rerank`
25
+ - `GRAPH_ACTION` — non-RAG graph `build` / `traverse` / `update` / `prune`
26
+
27
+ New helpers exported from `@mastra/core/observability`:
28
+ - `startRagIngestion(opts)` — manual: returns `{ span, observabilityContext }`
29
+ - `withRagIngestion(opts, fn)` — scoped: runs `fn(observabilityContext)`,
30
+ attaches the return value as the span's output, routes thrown errors to
31
+ `span.error(...)`
32
+
33
+ Wired in `@mastra/rag`:
34
+ - `vectorQuerySearch` emits `RAG_EMBEDDING` (mode: `query`) and
35
+ `RAG_VECTOR_OPERATION` (operation: `query`)
36
+ - `rerank` / `rerankWithScorer` emit `RAG_ACTION` (action: `rerank`)
37
+ - `MDocument.chunk` emits `RAG_ACTION` (action: `chunk`) and
38
+ `RAG_ACTION` (action: `extract_metadata`)
39
+ - `createGraphRAGTool` emits `GRAPH_ACTION` (action: `build` / `traverse`)
40
+ - `createVectorQueryTool` and `createGraphRAGTool` thread
41
+ `observabilityContext` from the agent's `TOOL_CALL` span automatically
42
+
43
+ All new instrumentation is opt-in: functions accept an optional
44
+ `observabilityContext` and no-op when absent, so existing callers are
45
+ unaffected.
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [[`8db7663`](https://github.com/mastra-ai/mastra/commit/8db7663c9a9c735828094c359d2e327fd4f8fba3), [`153e864`](https://github.com/mastra-ai/mastra/commit/153e86476b425db7cd0dc8490050096e92964a38), [`715710d`](https://github.com/mastra-ai/mastra/commit/715710d12fa47cf88e09d41f13843eddc29327b0), [`378c6c4`](https://github.com/mastra-ai/mastra/commit/378c6c4755726e8d8cf83a14809b350b90d46c62), [`9f91fd5`](https://github.com/mastra-ai/mastra/commit/9f91fd538ab2a44f8cc740bcad8e51205f74fbea), [`ba6fa9c`](https://github.com/mastra-ai/mastra/commit/ba6fa9cc0f3e1912c49fd70d4c3bb8c44903ddaa)]:
50
+ - @mastra/core@1.24.0
51
+
3
52
  ## 2.2.0-alpha.0
4
53
 
5
54
  ### Minor Changes
@@ -3,7 +3,7 @@ name: mastra-rag
3
3
  description: Documentation for @mastra/rag. Use when working with @mastra/rag APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/rag"
6
- version: "2.2.0-alpha.0"
6
+ version: "2.2.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0-alpha.0",
2
+ "version": "2.2.1-alpha.0",
3
3
  "package": "@mastra/rag",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-markdown.d.ts","sourceRoot":"","sources":["../../../src/document/transformers/semantic-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AASzC,qBAAa,2BAA4B,SAAQ,eAAe;IAC9D,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAmB;gBAE9B,EACV,aAAmB,EACnB,YAA4B,EAC5B,SAAS,EACT,SAAS,EAAE,iBAAiB,EAC5B,cAA0B,EAC1B,iBAAyB,EACzB,GAAG,WAAW,EACf,GAAE,4BAA4B,GAAG;QAAE,SAAS,CAAC,EAAE,QAAQ,CAAA;KAAO;IAkB/D,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,sBAAsB;IA2D9B,OAAO,CAAC,qBAAqB;IAqC7B,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAgB/C,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,QAAQ,EAAE;IAuB/E,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,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/E,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE;IAYrD,MAAM,CAAC,YAAY,CAAC,EAClB,YAA4B,EAC5B,SAAS,EACT,OAAY,GACb,EAAE;QACD,YAAY,CAAC,EAAE,gBAAgB,CAAC;QAChC,SAAS,CAAC,EAAE,aAAa,CAAC;QAC1B,OAAO,CAAC,EAAE,4BAA4B,CAAC;KACxC,GAAG,2BAA2B;CA6BhC"}
package/dist/index.cjs CHANGED
@@ -6109,7 +6109,7 @@ var SemanticMarkdownTransformer = class _SemanticMarkdownTransformer extends Tex
6109
6109
  let currentTitle = "";
6110
6110
  let currentDepth = 0;
6111
6111
  let inCodeBlock = false;
6112
- const headerRegex = /^(#+)\s+(.+)$/;
6112
+ const headerRegex = /^(#{1,6})[ \t]+(\S[^\n]{0,1024})$/;
6113
6113
  for (let i = 0; i < lines.length; i++) {
6114
6114
  const line = lines[i];
6115
6115
  const headerMatch = line.match(headerRegex);