@mastra/mcp-docs-server 0.13.21 → 0.13.22-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 +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +8 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +81 -81
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +25 -25
- package/.docs/organized/changelogs/create-mastra.md +17 -17
- package/.docs/organized/changelogs/mastra.md +29 -29
- package/.docs/organized/code-examples/heads-up-game.md +4 -4
- package/.docs/raw/memory/memory-processors.mdx +5 -0
- package/.docs/raw/memory/overview.mdx +159 -104
- package/.docs/raw/memory/semantic-recall.mdx +5 -0
- package/.docs/raw/memory/working-memory.mdx +5 -0
- package/.docs/raw/reference/agents/agent.mdx +6 -0
- package/.docs/raw/reference/agents/generateVNext.mdx +2 -1
- package/.docs/raw/reference/agents/listAgents.mdx +68 -0
- package/.docs/raw/reference/agents/streamVNext.mdx +1 -1
- package/.docs/raw/reference/client-js/agents.mdx +54 -1
- package/.docs/raw/reference/client-js/workflows.mdx +36 -17
- package/.docs/raw/reference/core/mastra-class.mdx +2 -2
- package/.docs/raw/reference/memory/Memory.mdx +91 -239
- package/.docs/raw/reference/memory/createThread.mdx +36 -16
- package/.docs/raw/reference/memory/deleteMessages.mdx +39 -74
- package/.docs/raw/reference/memory/getThreadById.mdx +11 -11
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +26 -29
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +46 -124
- package/.docs/raw/reference/memory/query.mdx +76 -90
- package/CHANGELOG.md +7 -0
- package/README.md +8 -0
- package/package.json +4 -4
|
@@ -1,95 +1,60 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
slug: reference/memory/deleteMessages
|
|
5
|
-
categorySlug: reference
|
|
6
|
-
layout: guide
|
|
2
|
+
title: "Reference: Memory.deleteMessages() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.deleteMessages()` method in Mastra, which deletes multiple messages by their IDs."
|
|
7
4
|
---
|
|
8
5
|
|
|
9
|
-
#
|
|
6
|
+
# Memory.deleteMessages()
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
The `.deleteMessages()` method deletes multiple messages by their IDs.
|
|
12
9
|
|
|
13
|
-
##
|
|
10
|
+
## Usage Example
|
|
14
11
|
|
|
15
|
-
```typescript
|
|
16
|
-
memory
|
|
17
|
-
|
|
18
|
-
type MessageDeleteInput =
|
|
19
|
-
| string[] // Array of message IDs
|
|
20
|
-
| { id: string }[] // Array of message objects
|
|
12
|
+
```typescript copy
|
|
13
|
+
await memory?.deleteMessages(["671ae63f-3a91-4082-a907-fe7de78e10ec"]);
|
|
21
14
|
```
|
|
22
15
|
|
|
23
16
|
## Parameters
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
<PropertiesTable
|
|
19
|
+
content={[
|
|
20
|
+
{
|
|
21
|
+
name: "messageIds",
|
|
22
|
+
type: "string[]",
|
|
23
|
+
description: "Array of message IDs to delete",
|
|
24
|
+
isOptional: false,
|
|
25
|
+
},
|
|
26
|
+
]}
|
|
27
|
+
/>
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
<PropertiesTable
|
|
32
|
+
content={[
|
|
33
|
+
{
|
|
34
|
+
name: "void",
|
|
35
|
+
type: "Promise<void>",
|
|
36
|
+
description: "A promise that resolves when all messages are deleted",
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
## Extended usage example
|
|
36
42
|
|
|
37
|
-
```typescript
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Using an array with a single message object
|
|
42
|
-
await memory.deleteMessages([{ id: 'msg-123' }]);
|
|
43
|
-
```
|
|
43
|
+
```typescript filename="src/test-memory.ts" showLineNumbers copy
|
|
44
|
+
import { mastra } from "./mastra";
|
|
45
|
+
import { UIMessageWithMetadata } from "@mastra/core/agent";
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
// Using an array of string IDs
|
|
49
|
-
await memory.deleteMessages(['msg-1', 'msg-2', 'msg-3']);
|
|
50
|
-
|
|
51
|
-
// Using an array of message objects
|
|
52
|
-
await memory.deleteMessages([
|
|
53
|
-
{ id: 'msg-1' },
|
|
54
|
-
{ id: 'msg-2' },
|
|
55
|
-
{ id: 'msg-3' }
|
|
56
|
-
]);
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Using with client SDK
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
// Get a thread instance
|
|
63
|
-
const thread = client.getAgent('my-agent').getThread('thread-123');
|
|
64
|
-
|
|
65
|
-
// Delete a single message
|
|
66
|
-
await thread.deleteMessages(['msg-123']);
|
|
67
|
-
|
|
68
|
-
// Delete multiple messages
|
|
69
|
-
await thread.deleteMessages(['msg-1', 'msg-2', 'msg-3']);
|
|
70
|
-
|
|
71
|
-
// Delete using message objects (useful when you have message data)
|
|
72
|
-
const messagesToDelete = messages.map(msg => ({ id: msg.id }));
|
|
73
|
-
await thread.deleteMessages(messagesToDelete);
|
|
74
|
-
```
|
|
47
|
+
const agent = mastra.getAgent("agent");
|
|
48
|
+
const memory = await agent.getMemory();
|
|
75
49
|
|
|
76
|
-
|
|
50
|
+
const { uiMessages } = await memory!.query({ threadId: "thread-123" });
|
|
77
51
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
await memory.deleteMessages(['msg-1', 'msg-2', 'msg-3']);
|
|
81
|
-
console.log('Messages deleted successfully');
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error('Failed to delete messages:', error);
|
|
84
|
-
}
|
|
52
|
+
const messageIds = uiMessages.map((message: UIMessageWithMetadata) => message.id);
|
|
53
|
+
await memory?.deleteMessages([...messageIds]);
|
|
85
54
|
```
|
|
86
55
|
|
|
87
|
-
##
|
|
56
|
+
## Related
|
|
88
57
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
- All message IDs must be non-empty strings
|
|
93
|
-
- An empty array will result in no operation (no error thrown)
|
|
94
|
-
- Messages from different threads can be deleted in the same operation
|
|
95
|
-
- When using message objects, only the `id` property is required
|
|
58
|
+
- [Memory Class Reference](/reference/memory/Memory.mdx)
|
|
59
|
+
- [query](/reference/memory/query.mdx)
|
|
60
|
+
- [Getting Started with Memory](/docs/memory/overview.mdx)
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Memory.getThreadById() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID."
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Memory.getThreadById()
|
|
7
|
+
|
|
8
|
+
The `.getThreadById()` method retrieves a specific thread by its ID.
|
|
4
9
|
|
|
5
10
|
## Usage Example
|
|
6
11
|
|
|
7
12
|
```typescript
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const memory = new Memory(config);
|
|
11
|
-
|
|
12
|
-
const thread = await memory.getThreadById({ threadId: "thread-123" });
|
|
13
|
+
await memory?.getThreadById({ threadId: "thread-123" });
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
## Parameters
|
|
@@ -30,10 +31,9 @@ const thread = await memory.getThreadById({ threadId: "thread-123" });
|
|
|
30
31
|
<PropertiesTable
|
|
31
32
|
content={[
|
|
32
33
|
{
|
|
33
|
-
name: "
|
|
34
|
-
type: "Promise",
|
|
35
|
-
description:
|
|
36
|
-
"A promise that resolves to the thread associated with the given ID, or null if not found.",
|
|
34
|
+
name: "thread",
|
|
35
|
+
type: "Promise<StorageThreadType | null>",
|
|
36
|
+
description: "A promise that resolves to the thread associated with the given ID, or null if not found.",
|
|
37
37
|
},
|
|
38
38
|
]}
|
|
39
39
|
/>
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Memory.getThreadsByResourceId() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.getThreadsByResourceId()` method in Mastra, which retrieves all threads that belong to a specific resource."
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Memory.getThreadsByResourceId()
|
|
7
|
+
|
|
8
|
+
The `.getThreadsByResourceId()` function retrieves all threads associated with a specific resource ID from storage. Threads can be sorted by creation or modification time in ascending or descending order.
|
|
4
9
|
|
|
5
10
|
## Usage Example
|
|
6
11
|
|
|
7
12
|
```typescript
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const memory = new Memory(config);
|
|
11
|
-
|
|
12
|
-
// Basic usage - returns threads sorted by createdAt DESC (default)
|
|
13
|
-
const threads = await memory.getThreadsByResourceId({
|
|
14
|
-
resourceId: "resource-123",
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Custom sorting by updatedAt in ascending order
|
|
18
|
-
const threadsByUpdate = await memory.getThreadsByResourceId({
|
|
19
|
-
resourceId: "resource-123",
|
|
20
|
-
orderBy: "updatedAt",
|
|
21
|
-
sortDirection: "ASC",
|
|
22
|
-
});
|
|
13
|
+
await memory?.getThreadsByResourceId({ resourceId: "user-123" });
|
|
23
14
|
```
|
|
24
15
|
|
|
25
16
|
## Parameters
|
|
@@ -40,24 +31,13 @@ const threadsByUpdate = await memory.getThreadsByResourceId({
|
|
|
40
31
|
},
|
|
41
32
|
{
|
|
42
33
|
name: "sortDirection",
|
|
43
|
-
type: "ThreadSortDirection",
|
|
34
|
+
type: "ThreadSortDirection",
|
|
44
35
|
description: "Sort order direction. Accepts 'ASC' or 'DESC'. Default: 'DESC'",
|
|
45
36
|
isOptional: true,
|
|
46
37
|
},
|
|
47
38
|
]}
|
|
48
39
|
/>
|
|
49
40
|
|
|
50
|
-
## Type Definitions
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
type ThreadOrderBy = 'createdAt' | 'updatedAt';
|
|
54
|
-
type ThreadSortDirection = 'ASC' | 'DESC';
|
|
55
|
-
|
|
56
|
-
interface ThreadSortOptions {
|
|
57
|
-
orderBy?: ThreadOrderBy;
|
|
58
|
-
sortDirection?: ThreadSortDirection;
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
41
|
|
|
62
42
|
## Returns
|
|
63
43
|
|
|
@@ -72,6 +52,23 @@ interface ThreadSortOptions {
|
|
|
72
52
|
]}
|
|
73
53
|
/>
|
|
74
54
|
|
|
55
|
+
## Extended usage example
|
|
56
|
+
|
|
57
|
+
```typescript filename="src/test-memory.ts" showLineNumbers copy
|
|
58
|
+
import { mastra } from "./mastra";
|
|
59
|
+
|
|
60
|
+
const agent = mastra.getAgent("agent");
|
|
61
|
+
const memory = await agent.getMemory();
|
|
62
|
+
|
|
63
|
+
const thread = await memory?.getThreadsByResourceId({
|
|
64
|
+
resourceId: "user-123",
|
|
65
|
+
orderBy: "updatedAt",
|
|
66
|
+
sortDirection: "ASC"
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(thread);
|
|
70
|
+
```
|
|
71
|
+
|
|
75
72
|
### Related
|
|
76
73
|
|
|
77
74
|
- [Memory Class Reference](/reference/memory/Memory.mdx)
|
|
@@ -1,55 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Memory.getThreadsByResourceIdPaginated() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.getThreadsByResourceIdPaginated()` method in Mastra, which retrieves threads associated with a specific resource ID with pagination support."
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Memory.getThreadsByResourceIdPaginated()
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { Memory } from "@mastra/core/memory";
|
|
8
|
+
The `.getThreadsByResourceIdPaginated()` method retrieves threads associated with a specific resource ID with pagination support.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Usage Example
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
resourceId: "
|
|
12
|
+
```typescript copy
|
|
13
|
+
await memory.getThreadsByResourceIdPaginated({
|
|
14
|
+
resourceId: "user-123",
|
|
15
15
|
page: 0,
|
|
16
|
-
perPage:
|
|
16
|
+
perPage: 10
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
console.log(result.threads);
|
|
20
|
-
console.log(result.total);
|
|
21
|
-
console.log(result.hasMore);
|
|
22
|
-
|
|
23
|
-
// Custom pagination with sorting
|
|
24
|
-
const customResult = await memory.getThreadsByResourceIdPaginated({
|
|
25
|
-
resourceId: "resource-123",
|
|
26
|
-
page: 2,
|
|
27
|
-
perPage: 50,
|
|
28
|
-
orderBy: "updatedAt",
|
|
29
|
-
sortDirection: "ASC",
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Process paginated results
|
|
33
|
-
let currentPage = 0;
|
|
34
|
-
let hasMorePages = true;
|
|
35
|
-
|
|
36
|
-
while (hasMorePages) {
|
|
37
|
-
const pageResult = await memory.getThreadsByResourceIdPaginated({
|
|
38
|
-
resourceId: "user-456",
|
|
39
|
-
page: currentPage,
|
|
40
|
-
perPage: 25,
|
|
41
|
-
orderBy: "createdAt",
|
|
42
|
-
sortDirection: "DESC",
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Process threads
|
|
46
|
-
pageResult.threads.forEach(thread => {
|
|
47
|
-
console.log(`Thread: ${thread.id}, Created: ${thread.createdAt}`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
hasMorePages = pageResult.hasMore;
|
|
51
|
-
currentPage++;
|
|
52
|
-
}
|
|
53
18
|
```
|
|
54
19
|
|
|
55
20
|
## Parameters
|
|
@@ -59,126 +24,83 @@ while (hasMorePages) {
|
|
|
59
24
|
{
|
|
60
25
|
name: "resourceId",
|
|
61
26
|
type: "string",
|
|
62
|
-
description: "The ID of the resource whose threads are to be retrieved
|
|
27
|
+
description: "The ID of the resource whose threads are to be retrieved",
|
|
63
28
|
isOptional: false,
|
|
64
29
|
},
|
|
65
30
|
{
|
|
66
31
|
name: "page",
|
|
67
32
|
type: "number",
|
|
68
|
-
description: "Page number to retrieve
|
|
33
|
+
description: "Page number to retrieve",
|
|
69
34
|
isOptional: false,
|
|
70
35
|
},
|
|
71
36
|
{
|
|
72
37
|
name: "perPage",
|
|
73
38
|
type: "number",
|
|
74
|
-
description: "Number of threads to return per page
|
|
39
|
+
description: "Number of threads to return per page",
|
|
75
40
|
isOptional: false,
|
|
76
41
|
},
|
|
77
42
|
{
|
|
78
43
|
name: "orderBy",
|
|
79
|
-
type: "
|
|
80
|
-
description: "Field to sort threads by
|
|
44
|
+
type: "'createdAt' | 'updatedAt'",
|
|
45
|
+
description: "Field to sort threads by",
|
|
81
46
|
isOptional: true,
|
|
82
47
|
},
|
|
83
48
|
{
|
|
84
49
|
name: "sortDirection",
|
|
85
|
-
type: "
|
|
86
|
-
description: "Sort order direction
|
|
50
|
+
type: "'ASC' | 'DESC'",
|
|
51
|
+
description: "Sort order direction",
|
|
87
52
|
isOptional: true,
|
|
88
53
|
},
|
|
89
54
|
]}
|
|
90
55
|
/>
|
|
91
56
|
|
|
92
|
-
## Type Definitions
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
type ThreadOrderBy = 'createdAt' | 'updatedAt';
|
|
96
|
-
type ThreadSortDirection = 'ASC' | 'DESC';
|
|
97
|
-
|
|
98
|
-
interface ThreadSortOptions {
|
|
99
|
-
orderBy?: ThreadOrderBy;
|
|
100
|
-
sortDirection?: ThreadSortDirection;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
interface PaginationInfo {
|
|
104
|
-
total: number; // Total number of threads across all pages
|
|
105
|
-
page: number; // Current page number
|
|
106
|
-
perPage: number; // Number of threads per page
|
|
107
|
-
hasMore: boolean; // Whether additional pages exist
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
57
|
## Returns
|
|
112
58
|
|
|
113
59
|
<PropertiesTable
|
|
114
60
|
content={[
|
|
115
61
|
{
|
|
116
|
-
name: "
|
|
117
|
-
type: "StorageThreadType[]",
|
|
118
|
-
description: "
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: "total",
|
|
122
|
-
type: "number",
|
|
123
|
-
description: "Total number of threads associated with the resource ID across all pages.",
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: "page",
|
|
127
|
-
type: "number",
|
|
128
|
-
description: "Current page number.",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: "perPage",
|
|
132
|
-
type: "number",
|
|
133
|
-
description: "Number of threads returned per page as specified in the request.",
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: "hasMore",
|
|
137
|
-
type: "boolean",
|
|
138
|
-
description: "Indicates whether additional pages of results are available.",
|
|
62
|
+
name: "result",
|
|
63
|
+
type: "Promise<PaginationInfo & { threads: StorageThreadType[] }>",
|
|
64
|
+
description: "A promise that resolves to paginated thread results with metadata",
|
|
139
65
|
},
|
|
140
66
|
]}
|
|
141
67
|
/>
|
|
142
68
|
|
|
143
|
-
##
|
|
144
|
-
|
|
145
|
-
### Performance Considerations
|
|
146
|
-
|
|
147
|
-
This method executes database-level pagination using LIMIT/OFFSET operations (or equivalent), which provides better performance and memory usage compared to retrieving all threads and paginating in application code.
|
|
148
|
-
|
|
149
|
-
### Default Values
|
|
69
|
+
## Extended usage example
|
|
150
70
|
|
|
151
|
-
-
|
|
152
|
-
|
|
71
|
+
```typescript filename="src/test-memory.ts" showLineNumbers copy
|
|
72
|
+
import { mastra } from "./mastra";
|
|
153
73
|
|
|
154
|
-
|
|
74
|
+
const agent = mastra.getAgent("agent");
|
|
75
|
+
const memory = await agent.getMemory();
|
|
155
76
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- Use `getThreadsByResourceId` when you need all threads for a resource
|
|
159
|
-
- Use `getThreadsByResourceIdPaginated` when working with potentially large thread collections or implementing UI pagination
|
|
77
|
+
let currentPage = 0;
|
|
78
|
+
let hasMorePages = true;
|
|
160
79
|
|
|
161
|
-
|
|
80
|
+
while (hasMorePages) {
|
|
81
|
+
const threads = await memory?.getThreadsByResourceIdPaginated({
|
|
82
|
+
resourceId: "user-123",
|
|
83
|
+
page: currentPage,
|
|
84
|
+
perPage: 25,
|
|
85
|
+
orderBy: "createdAt",
|
|
86
|
+
sortDirection: "ASC"
|
|
87
|
+
});
|
|
162
88
|
|
|
163
|
-
|
|
89
|
+
if (!threads) {
|
|
90
|
+
console.log("No threads");
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
164
93
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const result = await memory.getThreadsByResourceIdPaginated({
|
|
168
|
-
resourceId: "resource-123",
|
|
169
|
-
page: 0,
|
|
170
|
-
perPage: 100,
|
|
94
|
+
threads.threads.forEach((thread) => {
|
|
95
|
+
console.log(`Thread: ${thread.id}, Created: ${thread.createdAt}`);
|
|
171
96
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.error("Failed to retrieve paginated threads:", error);
|
|
97
|
+
|
|
98
|
+
hasMorePages = threads.hasMore;
|
|
99
|
+
currentPage++;
|
|
178
100
|
}
|
|
179
101
|
```
|
|
180
102
|
|
|
181
|
-
|
|
103
|
+
## Related
|
|
182
104
|
|
|
183
105
|
- [Memory Class Reference](/reference/memory/Memory.mdx)
|
|
184
106
|
- [getThreadsByResourceId](/reference/memory/getThreadsByResourceId.mdx) - Non-paginated version
|