@mastra/mcp-docs-server 0.13.7 β 0.13.8-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/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +60 -60
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +72 -72
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +52 -52
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +52 -52
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +73 -73
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Flance.md +30 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +50 -50
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +48 -48
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +32 -0
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Frag.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +31 -31
- package/.docs/organized/changelogs/create-mastra.md +10 -10
- package/.docs/organized/changelogs/mastra.md +70 -70
- package/.docs/raw/community/contributing-templates.mdx +1 -0
- package/.docs/raw/memory/overview.mdx +3 -1
- package/.docs/raw/memory/working-memory.mdx +67 -0
- package/.docs/raw/observability/logging.mdx +94 -19
- package/.docs/raw/reference/observability/logger.mdx +69 -50
- package/.docs/raw/reference/observability/providers/langfuse.mdx +47 -14
- package/.docs/raw/reference/workflows/dountil.mdx +1 -2
- package/.docs/raw/reference/workflows/dowhile.mdx +1 -2
- package/.docs/raw/reference/workflows/resume.mdx +13 -3
- package/.docs/raw/reference/workflows/step.mdx +0 -1
- package/.docs/raw/workflows/suspend-and-resume.mdx +13 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/prepare-docs/code-examples.d.ts +5 -0
- package/dist/prepare-docs/code-examples.d.ts.map +1 -0
- package/dist/prepare-docs/copy-raw.d.ts +2 -0
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -0
- package/dist/prepare-docs/package-changes.d.ts +5 -0
- package/dist/prepare-docs/package-changes.d.ts.map +1 -0
- package/dist/prepare-docs/prepare.d.ts +2 -1
- package/dist/prepare-docs/prepare.d.ts.map +1 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/tools/__tests__/test-setup.d.ts +5 -0
- package/dist/tools/__tests__/test-setup.d.ts.map +1 -0
- package/dist/tools/blog.d.ts +22 -0
- package/dist/tools/blog.d.ts.map +1 -0
- package/dist/tools/changes.d.ts +22 -0
- package/dist/tools/changes.d.ts.map +1 -0
- package/dist/tools/course.d.ts +85 -0
- package/dist/tools/course.d.ts.map +1 -0
- package/dist/tools/docs.d.ts +28 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/examples.d.ts +28 -0
- package/dist/tools/examples.d.ts.map +1 -0
- package/dist/utils.d.ts +62 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +6 -6
- package/dist/_tsup-dts-rollup.d.ts +0 -304
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# mastra
|
|
2
2
|
|
|
3
|
+
## 0.10.17-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 33dcb07: dependencies updates:
|
|
8
|
+
- Updated dependency [`@opentelemetry/instrumentation@^0.203.0` βοΈ](https://www.npmjs.com/package/@opentelemetry/instrumentation/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
9
|
+
- Updated dependency [`@opentelemetry/auto-instrumentations-node@^0.62.0` βοΈ](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node/v/0.62.0) (from `^0.60.1`, in `dependencies`)
|
|
10
|
+
- Updated dependency [`@opentelemetry/exporter-trace-otlp-grpc@^0.203.0` βοΈ](https://www.npmjs.com/package/@opentelemetry/exporter-trace-otlp-grpc/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
11
|
+
- Updated dependency [`@opentelemetry/exporter-trace-otlp-http@^0.203.0` βοΈ](https://www.npmjs.com/package/@opentelemetry/exporter-trace-otlp-http/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
12
|
+
- Updated dependency [`@opentelemetry/sdk-node@^0.203.0` βοΈ](https://www.npmjs.com/package/@opentelemetry/sdk-node/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
13
|
+
- Updated dependency [`@opentelemetry/semantic-conventions@^1.36.0` βοΈ](https://www.npmjs.com/package/@opentelemetry/semantic-conventions/v/1.36.0) (from `^1.34.0`, in `dependencies`)
|
|
14
|
+
- Updated dependencies [33dcb07]
|
|
15
|
+
- Updated dependencies [f90797b]
|
|
16
|
+
- Updated dependencies [d30b1a0]
|
|
17
|
+
- Updated dependencies [bff87f7]
|
|
18
|
+
- Updated dependencies [07fe7a2]
|
|
19
|
+
- Updated dependencies [b4a8df0]
|
|
20
|
+
- @mastra/core@0.12.1-alpha.0
|
|
21
|
+
- @mastra/mcp@0.10.9-alpha.0
|
|
22
|
+
- @mastra/deployer@0.12.1-alpha.0
|
|
23
|
+
|
|
24
|
+
## 0.10.16
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- bc6b44a: Extract tools import from `createHonoServer`; the function now receives tools via a prop on the `options` parameter.
|
|
29
|
+
- f442224: speech to text using voice config
|
|
30
|
+
- 7a7754f: Fast follow scorers fixing input types, improve llm scorer reliability, fix ui to display scores that are 0
|
|
31
|
+
- d8dec5e: add a cta to invite to deploy to cloud
|
|
32
|
+
- 6336993: Fix workflow input form overflow
|
|
33
|
+
- d5cc460: This change implements a fix to sourcemap mappings being off due to `removeDeployer` Babel plugin missing source map config.
|
|
34
|
+
- f42c4c2: update peer deps for packages to latest core range
|
|
35
|
+
- a5681f2: fix: pagination breaks trace grouping
|
|
36
|
+
- 89d2f4e: add TTS to the playground
|
|
37
|
+
- Updated dependencies [510e2c8]
|
|
38
|
+
- Updated dependencies [2f72fb2]
|
|
39
|
+
- Updated dependencies [27cc97a]
|
|
40
|
+
- Updated dependencies [832691b]
|
|
41
|
+
- Updated dependencies [557bb9d]
|
|
42
|
+
- Updated dependencies [27cc97a]
|
|
43
|
+
- Updated dependencies [3f89307]
|
|
44
|
+
- Updated dependencies [9eda7d4]
|
|
45
|
+
- Updated dependencies [9d49408]
|
|
46
|
+
- Updated dependencies [bc6b44a]
|
|
47
|
+
- Updated dependencies [41daa63]
|
|
48
|
+
- Updated dependencies [ad0a58b]
|
|
49
|
+
- Updated dependencies [254a36b]
|
|
50
|
+
- Updated dependencies [2ecf658]
|
|
51
|
+
- Updated dependencies [7a7754f]
|
|
52
|
+
- Updated dependencies [fc92d80]
|
|
53
|
+
- Updated dependencies [e0f73c6]
|
|
54
|
+
- Updated dependencies [0b89602]
|
|
55
|
+
- Updated dependencies [4d37822]
|
|
56
|
+
- Updated dependencies [23a6a7c]
|
|
57
|
+
- Updated dependencies [cda801d]
|
|
58
|
+
- Updated dependencies [a77c823]
|
|
59
|
+
- Updated dependencies [ff9c125]
|
|
60
|
+
- Updated dependencies [09bca64]
|
|
61
|
+
- Updated dependencies [9802f42]
|
|
62
|
+
- Updated dependencies [d5cc460]
|
|
63
|
+
- Updated dependencies [f42c4c2]
|
|
64
|
+
- Updated dependencies [b8efbb9]
|
|
65
|
+
- Updated dependencies [71466e7]
|
|
66
|
+
- Updated dependencies [0c99fbe]
|
|
67
|
+
- @mastra/core@0.12.0
|
|
68
|
+
- @mastra/deployer@0.12.0
|
|
69
|
+
- @mastra/loggers@0.10.5
|
|
70
|
+
- @mastra/mcp@0.10.8
|
|
71
|
+
|
|
3
72
|
## 0.10.16-alpha.3
|
|
4
73
|
|
|
5
74
|
### Patch Changes
|
|
@@ -229,74 +298,5 @@
|
|
|
229
298
|
- f9b1508: add the same agent table as in cloud and export it from the playground
|
|
230
299
|
- dfbeec6: Fix navigation to vnext AgentNetwork agents
|
|
231
300
|
- Updated dependencies [7776324]
|
|
232
|
-
- Updated dependencies [0b56518]
|
|
233
|
-
- Updated dependencies [db5cc15]
|
|
234
|
-
- Updated dependencies [2ba5b76]
|
|
235
|
-
- Updated dependencies [7b57e2c]
|
|
236
|
-
- Updated dependencies [5237998]
|
|
237
|
-
- Updated dependencies [c3a30de]
|
|
238
|
-
- Updated dependencies [37c1acd]
|
|
239
|
-
- Updated dependencies [1aa60b1]
|
|
240
|
-
- Updated dependencies [89ec9d4]
|
|
241
|
-
- Updated dependencies [cf3a184]
|
|
242
|
-
- Updated dependencies [fe4bbd4]
|
|
243
|
-
- Updated dependencies [d6bfd60]
|
|
244
|
-
- Updated dependencies [626b0f4]
|
|
245
|
-
- Updated dependencies [c22a91f]
|
|
246
|
-
- Updated dependencies [f7403ab]
|
|
247
|
-
- Updated dependencies [6c89d7f]
|
|
248
|
-
- @mastra/deployer@0.10.15
|
|
249
|
-
- @mastra/core@0.10.15
|
|
250
|
-
|
|
251
|
-
## 0.10.13-alpha.2
|
|
252
|
-
|
|
253
|
-
### Patch Changes
|
|
254
|
-
|
|
255
|
-
- 794d9f3: Fix thread creation in playground
|
|
256
|
-
- dfbeec6: Fix navigation to vnext AgentNetwork agents
|
|
257
|
-
|
|
258
|
-
## 0.10.13-alpha.1
|
|
259
|
-
|
|
260
|
-
### Patch Changes
|
|
261
|
-
|
|
262
|
-
- d49334d: export tool list for usage in cloud
|
|
263
|
-
- 9cdfcb5: fix infinite rerenders on agents table + share runtime context for cloud
|
|
264
|
-
- 45174f3: share network list between core and cloud
|
|
265
|
-
- 48f5532: export workflow list for usage in cloud
|
|
266
|
-
- 3e484be: Added CLI template option
|
|
267
|
-
- Updated dependencies [0b56518]
|
|
268
|
-
- Updated dependencies [2ba5b76]
|
|
269
|
-
- Updated dependencies [c3a30de]
|
|
270
|
-
- Updated dependencies [cf3a184]
|
|
271
|
-
- Updated dependencies [fe4bbd4]
|
|
272
|
-
- Updated dependencies [d6bfd60]
|
|
273
|
-
- @mastra/core@0.10.15-alpha.1
|
|
274
|
-
- @mastra/deployer@0.10.15-alpha.1
|
|
275
301
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
### Patch Changes
|
|
279
|
-
|
|
280
|
-
- 593631d: allow to pass ref to the link abstraction
|
|
281
|
-
- 5237998: Fix foreach output
|
|
282
|
-
- 1aa60b1: Pipe runtimeContext to vNext network agent stream and generate steps, wire up runtimeContext for vNext Networks in cliet SDK & playground
|
|
283
|
-
- 5130bcb: dependencies updates:
|
|
284
|
-
- Updated dependency [`swr@^2.3.4` βοΈ](https://www.npmjs.com/package/swr/v/2.3.4) (from `^2.3.3`, in `dependencies`)
|
|
285
|
-
- 984887a: dependencies updates:
|
|
286
|
-
- Updated dependency [`prettier@^3.6.2` βοΈ](https://www.npmjs.com/package/prettier/v/3.6.2) (from `^3.5.3`, in `dependencies`)
|
|
287
|
-
- aa9528a: Display reasoning in playground
|
|
288
|
-
- 626b0f4: [Cloud-126] Working Memory Playground - Added working memory to playground to allow users to view/edit working memory
|
|
289
|
-
- e1d0080: abstract Link component between cloud and core
|
|
290
|
-
- f9b1508: add the same agent table as in cloud and export it from the playground
|
|
291
|
-
- Updated dependencies [7776324]
|
|
292
|
-
- Updated dependencies [db5cc15]
|
|
293
|
-
- Updated dependencies [7b57e2c]
|
|
294
|
-
- Updated dependencies [5237998]
|
|
295
|
-
- Updated dependencies [37c1acd]
|
|
296
|
-
- Updated dependencies [1aa60b1]
|
|
297
|
-
- Updated dependencies [89ec9d4]
|
|
298
|
-
- Updated dependencies [626b0f4]
|
|
299
|
-
- Updated dependencies [c22a91f]
|
|
300
|
-
- Updated dependencies [f7403ab]
|
|
301
|
-
|
|
302
|
-
... 4605 more lines hidden. See full changelog in package directory.
|
|
302
|
+
... 4674 more lines hidden. See full changelog in package directory.
|
|
@@ -27,6 +27,7 @@ Create your template following the established patterns:
|
|
|
27
27
|
- Include comprehensive documentation
|
|
28
28
|
- Test thoroughly with fresh installations
|
|
29
29
|
- Follow all technical requirements
|
|
30
|
+
- Ensure the github repo is a template repo. [How to create a template repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository)
|
|
30
31
|
|
|
31
32
|
### 3. Submit for Review
|
|
32
33
|
|
|
@@ -68,7 +68,7 @@ Send a few messages and notice that it remembers information across turns:
|
|
|
68
68
|
|
|
69
69
|
Mastra organizes memory into threads, which are records that identify specific conversation histories, using two identifiers:
|
|
70
70
|
|
|
71
|
-
1. **`threadId`**: A
|
|
71
|
+
1. **`threadId`**: A globally unique conversation id (e.g., `support_123`). Thread IDs must be unique across all resources.
|
|
72
72
|
2. **`resourceId`**: The user or entity id that owns each thread (e.g., `user_123`, `org_456`).
|
|
73
73
|
|
|
74
74
|
The `resourceId` is particularly important for [resource-scoped working memory](./working-memory.mdx#resource-scoped-memory), which allows memory to persist across all conversation threads for the same user.
|
|
@@ -82,6 +82,8 @@ const response = await myMemoryAgent.stream("Hello, my name is Alice.", {
|
|
|
82
82
|
|
|
83
83
|
**Important:** without these ID's your agent will not use memory, even if memory is properly configured. The playground handles this for you, but you need to add ID's yourself when using memory in your application.
|
|
84
84
|
|
|
85
|
+
> **Thread ID Uniqueness:** Each thread ID must be globally unique across all resources. A thread is permanently associated with the resource that created it. If you need to have similar thread names for different resources (e.g., a "general" thread for multiple users), include the resource ID in the thread ID: `${resourceId}-general` or `user_alice_general`.
|
|
86
|
+
|
|
85
87
|
### Thread Title Generation
|
|
86
88
|
|
|
87
89
|
Mastra can automatically generate meaningful titles for conversation threads based on the user's first message. This helps organize and identify conversations in your application UI.
|
|
@@ -298,6 +298,73 @@ again because it has been stored in working memory.
|
|
|
298
298
|
If your agent is not properly updating working memory when you expect it to, you can add system
|
|
299
299
|
instructions on _how_ and _when_ to use this template in your agent's `instructions` setting.
|
|
300
300
|
|
|
301
|
+
## Setting Initial Working Memory
|
|
302
|
+
|
|
303
|
+
While agents typically update working memory through the `updateWorkingMemory` tool, you can also set initial working memory programmatically when creating or updating threads. This is useful for injecting user data (like their name, preferences, or other info) that you want available to the agent without passing it in every request.
|
|
304
|
+
|
|
305
|
+
### Setting Working Memory via Thread Metadata
|
|
306
|
+
|
|
307
|
+
When creating a thread, you can provide initial working memory through the metadata's `workingMemory` key:
|
|
308
|
+
|
|
309
|
+
```typescript filename="src/app/medical-consultation.ts" showLineNumbers copy
|
|
310
|
+
// Create a thread with initial working memory
|
|
311
|
+
const thread = await memory.createThread({
|
|
312
|
+
threadId: "thread-123",
|
|
313
|
+
resourceId: "user-456",
|
|
314
|
+
title: "Medical Consultation",
|
|
315
|
+
metadata: {
|
|
316
|
+
workingMemory: `# Patient Profile
|
|
317
|
+
- Name: John Doe
|
|
318
|
+
- Blood Type: O+
|
|
319
|
+
- Allergies: Penicillin
|
|
320
|
+
- Current Medications: None
|
|
321
|
+
- Medical History: Hypertension (controlled)
|
|
322
|
+
`
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// The agent will now have access to this information in all messages
|
|
327
|
+
await agent.generate("What's my blood type?", {
|
|
328
|
+
threadId: thread.id,
|
|
329
|
+
resourceId: "user-456"
|
|
330
|
+
});
|
|
331
|
+
// Response: "Your blood type is O+."
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Updating Working Memory Programmatically
|
|
335
|
+
|
|
336
|
+
You can also update an existing thread's working memory:
|
|
337
|
+
|
|
338
|
+
```typescript filename="src/app/medical-consultation.ts" showLineNumbers copy
|
|
339
|
+
// Update thread metadata to add/modify working memory
|
|
340
|
+
await memory.updateThread({
|
|
341
|
+
id: "thread-123",
|
|
342
|
+
title: thread.title,
|
|
343
|
+
metadata: {
|
|
344
|
+
...thread.metadata,
|
|
345
|
+
workingMemory: `# Patient Profile
|
|
346
|
+
- Name: John Doe
|
|
347
|
+
- Blood Type: O+
|
|
348
|
+
- Allergies: Penicillin, Ibuprofen // Updated
|
|
349
|
+
- Current Medications: Lisinopril 10mg daily // Added
|
|
350
|
+
- Medical History: Hypertension (controlled)
|
|
351
|
+
`
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Direct Memory Update
|
|
357
|
+
|
|
358
|
+
Alternatively, use the `updateWorkingMemory` method directly:
|
|
359
|
+
|
|
360
|
+
```typescript filename="src/app/medical-consultation.ts" showLineNumbers copy
|
|
361
|
+
await memory.updateWorkingMemory({
|
|
362
|
+
threadId: "thread-123",
|
|
363
|
+
resourceId: "user-456", // Required for resource-scoped memory
|
|
364
|
+
workingMemory: "Updated memory content..."
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
301
368
|
## Examples
|
|
302
369
|
|
|
303
370
|
- [Streaming working memory](/examples/memory/streaming-working-memory)
|
|
@@ -1,38 +1,113 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Logging | Mastra Observability Documentation"
|
|
3
|
-
description:
|
|
3
|
+
description: Learn how to use logging in Mastra to monitor execution, capture application behavior, and improve the accuracy of AI applications.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import Image from "next/image";
|
|
7
|
-
|
|
8
6
|
# Logging
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
Mastra's logging system captures function execution, input data, and output responses in a structured format.
|
|
9
|
+
|
|
10
|
+
When deploying to Mastra Cloud, logs are shown on the [Logs](../mastra-cloud/observability.mdx) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## PinoLogger
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
When [initializing a new Mastra project](../getting-started/installation.mdx) using the CLI, `PinoLogger` is included by default.
|
|
15
15
|
|
|
16
|
-
```typescript filename="mastra.
|
|
17
|
-
import { Mastra } from
|
|
18
|
-
import { PinoLogger } from
|
|
16
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers copy
|
|
17
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
18
|
+
import { PinoLogger } from '@mastra/loggers';
|
|
19
19
|
|
|
20
20
|
export const mastra = new Mastra({
|
|
21
|
-
//
|
|
21
|
+
// ...
|
|
22
22
|
logger: new PinoLogger({
|
|
23
|
-
name:
|
|
24
|
-
level:
|
|
23
|
+
name: 'Mastra',
|
|
24
|
+
level: 'info',
|
|
25
25
|
}),
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
> See the [PinoLogger](../../reference/observability/logger.mdx) API reference for all available configuration options.
|
|
30
|
+
|
|
31
|
+
## Logging from workflows and tools
|
|
32
|
+
|
|
33
|
+
Mastra provides access to a logger instance via the `mastra.getLogger()` method, available inside both workflow steps and tools. The logger supports standard severity levels: `debug`, `info`, `warn`, and `error`.
|
|
34
|
+
|
|
35
|
+
### Logging from workflow steps
|
|
36
|
+
|
|
37
|
+
Within a workflow step, access the logger via the `mastra` parameter inside the `execute` function. This allows you to log messages relevant to the stepβs execution.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
```typescript {8-9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
41
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
42
|
+
import { z } from "zod";
|
|
43
|
+
|
|
44
|
+
const step1 = createStep({
|
|
45
|
+
//...
|
|
46
|
+
execute: async ({ mastra }) => {
|
|
47
|
+
|
|
48
|
+
const logger = mastra.getLogger();
|
|
49
|
+
logger.info("workflow info log");
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
output: ""
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const testWorkflow = createWorkflow({...})
|
|
58
|
+
.then(step1)
|
|
59
|
+
.commit();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Logging from tools
|
|
63
|
+
|
|
64
|
+
Similarly, tools have access to the logger instance via the `mastra` parameter. Use this to log tool specific activity during execution.
|
|
30
65
|
|
|
31
|
-
-
|
|
32
|
-
|
|
66
|
+
```typescript {8-9} filename="src/mastra/tools/test-tool.ts" showLineNumbers copy
|
|
67
|
+
import { createTool } from "@mastra/core/tools";
|
|
68
|
+
import { z } from "zod";
|
|
33
69
|
|
|
34
|
-
|
|
70
|
+
export const testTool = createTool({
|
|
71
|
+
// ...
|
|
72
|
+
execute: async ({ mastra }) => {
|
|
35
73
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
74
|
+
const logger = mastra?.getLogger();
|
|
75
|
+
logger?.info("tool info log");
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
output: ""
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## Logging with additional data
|
|
86
|
+
|
|
87
|
+
Logger methods accept an optional second argument for additional data. This can be any value, such as an object, string, or number.
|
|
88
|
+
|
|
89
|
+
In this example, the log message includes an object with a key of `agent` and a value of the `testAgent` instance.
|
|
90
|
+
|
|
91
|
+
```typescript {11} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
92
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
93
|
+
import { z } from "zod";
|
|
94
|
+
|
|
95
|
+
const step1 = createStep({
|
|
96
|
+
//...
|
|
97
|
+
execute: async ({ mastra }) => {
|
|
98
|
+
|
|
99
|
+
const testAgent = mastra.getAgent("testAgent");
|
|
100
|
+
|
|
101
|
+
const logger = mastra.getLogger();
|
|
102
|
+
logger.info("workflow info log", { agent: testAgent });
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
output: ""
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const testWorkflow = createWorkflow({...})
|
|
111
|
+
.then(step1)
|
|
112
|
+
.commit();
|
|
113
|
+
```
|
|
@@ -1,86 +1,98 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference:
|
|
3
|
-
description: Documentation for
|
|
2
|
+
title: "Reference: PinoLogger | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for PinoLogger, which provides methods to record events at various severity levels.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# PinoLogger
|
|
7
7
|
|
|
8
|
-
A Logger instance is created
|
|
8
|
+
A Logger instance is created using `new PinoLogger()` and provides methods to record events at various severity levels.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
When deploying to Mastra Cloud, logs are displayed on the [Logs](../../docs/mastra-cloud/dashboard.mdx#logs) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
// Using a console logger
|
|
14
|
-
const logger = new PinoLogger({ name: "Mastra", level: "info" });
|
|
12
|
+
## Usage example
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
logger
|
|
14
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers copy
|
|
15
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
16
|
+
import { PinoLogger } from '@mastra/loggers';
|
|
17
|
+
|
|
18
|
+
export const mastra = new Mastra({
|
|
19
|
+
// ...
|
|
20
|
+
logger: new PinoLogger({
|
|
21
|
+
name: 'Mastra',
|
|
22
|
+
level: 'info',
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
##
|
|
27
|
+
## Parameters
|
|
26
28
|
|
|
27
29
|
<PropertiesTable
|
|
28
30
|
content={[
|
|
29
31
|
{
|
|
30
|
-
name: "
|
|
31
|
-
type: "
|
|
32
|
-
description: "
|
|
32
|
+
name: "name",
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "A label used to group and identify logs from this logger.",
|
|
33
35
|
},
|
|
34
|
-
|
|
35
|
-
name: "
|
|
36
|
-
type: "
|
|
37
|
-
description: "
|
|
36
|
+
{
|
|
37
|
+
name: "level",
|
|
38
|
+
type: `"debug" | "info" | "warn" | "error"`,
|
|
39
|
+
description: "Sets the minimum log level. Messages below this level are ignored.",
|
|
38
40
|
},
|
|
39
41
|
{
|
|
40
|
-
name: "
|
|
41
|
-
type: "
|
|
42
|
-
description: "
|
|
42
|
+
name: "transports",
|
|
43
|
+
type: "Record<string, LoggerTransport>",
|
|
44
|
+
description: "A map of transport instances used to persist logs.",
|
|
43
45
|
},
|
|
44
46
|
{
|
|
45
|
-
name: "
|
|
46
|
-
type: "
|
|
47
|
-
|
|
47
|
+
name: "overrideDefaultTransports",
|
|
48
|
+
type: "boolean",
|
|
49
|
+
isOptional: true,
|
|
50
|
+
description: "If true, disables the default console transport.",
|
|
48
51
|
},
|
|
49
52
|
{
|
|
50
|
-
name: "
|
|
51
|
-
type: "
|
|
53
|
+
name: "formatters",
|
|
54
|
+
type: "pino.LoggerOptions['formatters']",
|
|
52
55
|
isOptional: true,
|
|
53
|
-
description:
|
|
54
|
-
"Cleanup resources held by the logger (e.g., network connections for Upstash). Not all loggers implement this.",
|
|
56
|
+
description: "Custom Pino formatters for log serialization.",
|
|
55
57
|
},
|
|
56
58
|
]}
|
|
57
59
|
/>
|
|
58
60
|
|
|
59
|
-
**Note:** Some loggers require a `BaseLogMessage` object (with `message`, `destinationPath`, `type` fields). For instance, the `File` and `Upstash` loggers need structured messages.
|
|
60
61
|
|
|
61
|
-
## File
|
|
62
|
+
## File transport (structured logs)
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
Writes structured logs to a file using the `FileTransport`. The logger accepts a plain message as the first argument and structured metadata as the second argument. These are internally converted to a `BaseLogMessage` and persisted to the configured file path.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
```typescript filename="src/mastra/loggers/file-transport.ts" showLineNumbers copy
|
|
64
68
|
import { FileTransport } from "@mastra/loggers/file";
|
|
69
|
+
import { PinoLogger } from "@mastra/loggers/pino";
|
|
65
70
|
|
|
66
|
-
const fileLogger = new PinoLogger({
|
|
71
|
+
export const fileLogger = new PinoLogger({
|
|
67
72
|
name: "Mastra",
|
|
68
73
|
transports: { file: new FileTransport({ path: "test-dir/test.log" }) },
|
|
69
74
|
level: "warn",
|
|
70
75
|
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### File transport usage
|
|
71
79
|
|
|
80
|
+
```typescript showLineNumbers copy
|
|
72
81
|
fileLogger.warn("Low disk space", {
|
|
73
82
|
destinationPath: "system",
|
|
74
83
|
type: "WORKFLOW",
|
|
75
84
|
});
|
|
76
85
|
```
|
|
77
86
|
|
|
78
|
-
## Upstash
|
|
87
|
+
## Upstash transport (remote log drain)
|
|
79
88
|
|
|
80
|
-
|
|
89
|
+
Streams structured logs to a remote Redis list using the `UpstashTransport`. The logger accepts a string message and a structured metadata object. This enables centralized logging for distributed environments, supporting filtering by `destinationPath`, `type`, and `runId`.
|
|
90
|
+
|
|
91
|
+
```typescript filename="src/mastra/loggers/upstash-transport.ts" showLineNumbers copy
|
|
81
92
|
import { UpstashTransport } from "@mastra/loggers/upstash";
|
|
93
|
+
import { PinoLogger } from "@mastra/loggers/pino";
|
|
82
94
|
|
|
83
|
-
const
|
|
95
|
+
export const upstashLogger = new PinoLogger({
|
|
84
96
|
name: "Mastra",
|
|
85
97
|
transports: {
|
|
86
98
|
upstash: new UpstashTransport({
|
|
@@ -91,28 +103,35 @@ const logger = new PinoLogger({
|
|
|
91
103
|
},
|
|
92
104
|
level: "info",
|
|
93
105
|
});
|
|
106
|
+
```
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
|
|
109
|
+
### Upstash transport usage
|
|
110
|
+
|
|
111
|
+
```typescript showLineNumbers copy
|
|
112
|
+
upstashLogger.info("User signed in", {
|
|
97
113
|
destinationPath: "auth",
|
|
98
114
|
type: "AGENT",
|
|
99
115
|
runId: "run_123",
|
|
100
116
|
});
|
|
101
117
|
```
|
|
102
118
|
|
|
103
|
-
## Custom
|
|
119
|
+
## Custom transport
|
|
104
120
|
|
|
105
121
|
You can create custom transports using the `createCustomTransport` utility to integrate with any logging service or stream.
|
|
106
122
|
|
|
107
|
-
###
|
|
123
|
+
### Sentry transport example
|
|
108
124
|
|
|
109
|
-
|
|
125
|
+
Creates a custom transport using `createCustomTransport` and integrates it with a third-party logging stream such as `pino-sentry-transport`. This allows forwarding logs to an external system like Sentry for advanced monitoring and observability.
|
|
126
|
+
|
|
127
|
+
```typescript filename="src/mastra/loggers/sentry-transport.ts" showLineNumbers copy
|
|
110
128
|
import { createCustomTransport } from "@mastra/core/loggers";
|
|
111
|
-
import
|
|
129
|
+
import { PinoLogger } from "@mastra/loggers/pino";
|
|
130
|
+
import pinoSentry from "pino-sentry-transport";
|
|
112
131
|
|
|
113
132
|
const sentryStream = await pinoSentry({
|
|
114
133
|
sentry: {
|
|
115
|
-
dsn:
|
|
134
|
+
dsn: "YOUR_SENTRY_DSN",
|
|
116
135
|
_experiments: {
|
|
117
136
|
enableLogs: true,
|
|
118
137
|
},
|
|
@@ -121,9 +140,9 @@ const sentryStream = await pinoSentry({
|
|
|
121
140
|
|
|
122
141
|
const customTransport = createCustomTransport(sentryStream);
|
|
123
142
|
|
|
124
|
-
const
|
|
143
|
+
export const sentryLogger = new PinoLogger({
|
|
125
144
|
name: "Mastra",
|
|
126
|
-
transports: { sentry: customTransport },
|
|
127
145
|
level: "info",
|
|
146
|
+
transports: { sentry: customTransport },
|
|
128
147
|
});
|
|
129
|
-
```
|
|
148
|
+
```
|
|
@@ -11,36 +11,69 @@ Langfuse is an open-source observability platform designed specifically for LLM
|
|
|
11
11
|
|
|
12
12
|
## Configuration
|
|
13
13
|
|
|
14
|
-
To use Langfuse with Mastra, you
|
|
14
|
+
To use Langfuse with Mastra, you can configure it using either environment variables or directly in your Mastra configuration.
|
|
15
|
+
|
|
16
|
+
### Using Environment Variables
|
|
17
|
+
|
|
18
|
+
Set the following environment variables:
|
|
15
19
|
|
|
16
20
|
```env
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
OTEL_EXPORTER_OTLP_ENDPOINT="https://cloud.langfuse.com/api/public/otel/v1/traces" # πͺπΊ EU data region
|
|
22
|
+
# OTEL_EXPORTER_OTLP_ENDPOINT="https://us.cloud.langfuse.com/api/public/otel/v1/traces" # πΊπΈ US data region
|
|
23
|
+
|
|
24
|
+
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic ${AUTH_STRING}"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Where `AUTH_STRING` is the base64-encoded combination of your public and secret keys (see below).
|
|
28
|
+
|
|
29
|
+
### Generating AUTH_STRING
|
|
30
|
+
|
|
31
|
+
The authorization uses basic auth with your Langfuse API keys. You can generate the base64-encoded auth string using:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
echo -n "pk-lf-1234567890:sk-lf-1234567890" | base64
|
|
20
35
|
```
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
For long API keys on GNU systems, you may need to add `-w 0` to prevent auto-wrapping:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
echo -n "pk-lf-1234567890:sk-lf-1234567890" | base64 -w 0
|
|
41
|
+
```
|
|
23
42
|
|
|
24
43
|
## Implementation
|
|
25
44
|
|
|
26
|
-
Here's how to configure Mastra to use Langfuse:
|
|
45
|
+
Here's how to configure Mastra to use Langfuse with OpenTelemetry:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { Mastra } from "@mastra/core";
|
|
49
|
+
|
|
50
|
+
export const mastra = new Mastra({
|
|
51
|
+
// ... other config
|
|
52
|
+
telemetry: {
|
|
53
|
+
enabled: true,
|
|
54
|
+
export: {
|
|
55
|
+
type: 'otlp',
|
|
56
|
+
endpoint: 'https://cloud.langfuse.com/api/public/otel/v1/traces', // or your preferred endpoint
|
|
57
|
+
headers: {
|
|
58
|
+
Authorization: `Basic ${AUTH_STRING}`, // Your base64-encoded auth string
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Alternatively, if you're using environment variables, you can simplify the configuration:
|
|
27
66
|
|
|
28
67
|
```typescript
|
|
29
68
|
import { Mastra } from "@mastra/core";
|
|
30
|
-
import { LangfuseExporter } from "langfuse-vercel";
|
|
31
69
|
|
|
32
70
|
export const mastra = new Mastra({
|
|
33
71
|
// ... other config
|
|
34
72
|
telemetry: {
|
|
35
|
-
serviceName: "ai", // this must be set to "ai" so that the LangfuseExporter thinks it's an AI SDK trace
|
|
36
73
|
enabled: true,
|
|
37
74
|
export: {
|
|
38
|
-
type:
|
|
39
|
-
|
|
40
|
-
publicKey: process.env.LANGFUSE_PUBLIC_KEY,
|
|
41
|
-
secretKey: process.env.LANGFUSE_SECRET_KEY,
|
|
42
|
-
baseUrl: process.env.LANGFUSE_BASEURL,
|
|
43
|
-
}),
|
|
75
|
+
type: 'otlp',
|
|
76
|
+
// endpoint and headers will be read from OTEL_EXPORTER_OTLP_* env vars
|
|
44
77
|
},
|
|
45
78
|
},
|
|
46
79
|
});
|