getmnemo-anthropic 0.1.0 → 0.1.1
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/README.md +61 -9
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# getmnemo-anthropic
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Mnemo helper for the Anthropic SDK. Wraps `messages.create` with a single
|
|
4
4
|
`memory` tool (search + add), prompt caching on the system block, and
|
|
5
5
|
optional extended thinking — the recommended setup for any long-lived Claude
|
|
6
6
|
assistant.
|
|
@@ -8,25 +8,32 @@ assistant.
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm install
|
|
11
|
+
npm install getmnemo-anthropic @anthropic-ai/sdk
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
`getmnemo` (the core SDK) is pulled in automatically as a dependency. You only
|
|
15
|
+
need `@anthropic-ai/sdk` because you construct the Anthropic client yourself and
|
|
16
|
+
pass it in.
|
|
17
|
+
|
|
18
|
+
Get your Mnemo API key and workspace ID from
|
|
19
|
+
[app.mnemohq.com/settings/api-keys](https://app.mnemohq.com/settings/api-keys).
|
|
20
|
+
|
|
14
21
|
## Quickstart (30 seconds)
|
|
15
22
|
|
|
16
23
|
```ts
|
|
17
24
|
import Anthropic from "@anthropic-ai/sdk";
|
|
18
|
-
import {
|
|
19
|
-
import { withMemoryTool } from "
|
|
25
|
+
import { Mnemo } from "getmnemo";
|
|
26
|
+
import { withMemoryTool } from "getmnemo-anthropic";
|
|
20
27
|
|
|
21
28
|
const claude = new Anthropic();
|
|
22
|
-
const
|
|
23
|
-
apiKey: process.env.
|
|
24
|
-
workspaceId: process.env.
|
|
29
|
+
const memory = new Mnemo({
|
|
30
|
+
apiKey: process.env.GETMNEMO_API_KEY!,
|
|
31
|
+
workspaceId: process.env.GETMNEMO_WORKSPACE_ID!,
|
|
25
32
|
});
|
|
26
33
|
|
|
27
34
|
const agent = withMemoryTool({
|
|
28
35
|
client: claude,
|
|
29
|
-
|
|
36
|
+
getmnemo: memory,
|
|
30
37
|
model: "claude-sonnet-4-7",
|
|
31
38
|
thinkingBudgetTokens: 4000,
|
|
32
39
|
});
|
|
@@ -51,6 +58,51 @@ console.log("memory tool calls:", result.memoryToolCalls);
|
|
|
51
58
|
- Optionally enables extended thinking with a configurable token budget.
|
|
52
59
|
- Returns the final transcript so you can persist it elsewhere.
|
|
53
60
|
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
`withMemoryTool(options)` returns a wrapper with a single `run(input)` method.
|
|
64
|
+
|
|
65
|
+
### `withMemoryTool(options)`
|
|
66
|
+
|
|
67
|
+
| Option | Type | Default | Description |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| `client` | `Anthropic` | — | An `@anthropic-ai/sdk` client (anything with `messages.create`). |
|
|
70
|
+
| `getmnemo` | `Mnemo` | — | A `Mnemo` instance from `getmnemo`. |
|
|
71
|
+
| `model` | `string` | `"claude-sonnet-4-7"` | Default model; override per call. |
|
|
72
|
+
| `maxTokens` | `number` | `1024` | Default `max_tokens`; override per call. |
|
|
73
|
+
| `searchLimit` | `number` | `5` | Default top-k for memory search (clamped to 1–50). |
|
|
74
|
+
| `cacheSystem` | `boolean` | `true` | Wrap the system prompt with `cache_control: { type: "ephemeral" }`. |
|
|
75
|
+
| `thinkingBudgetTokens` | `number` | — | Enable extended thinking with this token budget. |
|
|
76
|
+
| `metadata` | `Record<string, unknown>` | `{}` | Static metadata merged into every persisted memory. |
|
|
77
|
+
| `maxIterations` | `number` | `6` | Hard cap on tool-use loop iterations. |
|
|
78
|
+
|
|
79
|
+
### `run(input)`
|
|
80
|
+
|
|
81
|
+
| Field | Type | Description |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `messages` | `ChatMessage[]` | Conversation so far (required). |
|
|
84
|
+
| `system` | `string` | Optional system prompt. |
|
|
85
|
+
| `model` | `string` | Per-call model override. |
|
|
86
|
+
| `maxTokens` | `number` | Per-call `max_tokens` override. |
|
|
87
|
+
| `metadata` | `Record<string, unknown>` | Per-call metadata merged into persisted memories. |
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
|
|
91
|
+
| Field | Type | Description |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `text` | `string` | Final assistant text, concatenated across blocks. |
|
|
94
|
+
| `responses` | `MessagesCreateResult[]` | Every raw API response from the tool-use loop. |
|
|
95
|
+
| `memoryToolCalls` | `number` | How many times the memory tool ran. |
|
|
96
|
+
| `messages` | `ChatMessage[]` | Final messages array after the loop — store this as your transcript. |
|
|
97
|
+
|
|
98
|
+
The package also exports `MEMORY_TOOL_NAME` (the literal tool name, `"memory"`)
|
|
99
|
+
and the `WithMemoryTool*` / `WithMemoryRun*` types.
|
|
100
|
+
|
|
101
|
+
## Links
|
|
102
|
+
|
|
103
|
+
- Docs: [mnemohq.com](https://mnemohq.com)
|
|
104
|
+
- API keys: [app.mnemohq.com/settings/api-keys](https://app.mnemohq.com/settings/api-keys)
|
|
105
|
+
|
|
54
106
|
## License
|
|
55
107
|
|
|
56
108
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "getmnemo-anthropic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Mnemo helper for the Anthropic SDK — memory tool, prompt caching, and extended thinking wired together.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
"tool-use",
|
|
31
31
|
"prompt-caching"
|
|
32
32
|
],
|
|
33
|
-
"author":
|
|
33
|
+
"author": {
|
|
34
|
+
"name": "Mnemo",
|
|
35
|
+
"url": "https://mnemohq.com"
|
|
36
|
+
},
|
|
34
37
|
"license": "MIT",
|
|
35
38
|
"repository": {
|
|
36
39
|
"type": "git",
|
|
@@ -50,5 +53,5 @@
|
|
|
50
53
|
"engines": {
|
|
51
54
|
"node": ">=18.17.0"
|
|
52
55
|
},
|
|
53
|
-
"homepage": "https://
|
|
56
|
+
"homepage": "https://mnemohq.com"
|
|
54
57
|
}
|