@slashml/memory 1.0.15 → 1.1.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/README.md +45 -3
- package/bin/cli.js +1153 -22
- package/dist/index.d.ts +92 -0
- package/dist/index.js +343 -5
- package/dist/index.mjs +3 -0
- package/package.json +3 -4
- package/src/index.ts +486 -4
package/README.md
CHANGED
|
@@ -71,13 +71,13 @@ await client.forget("Refresh tokens expire after 7 days", {
|
|
|
71
71
|
Install the `/ ml` MCP server into Cursor, Claude Code, or Windsurf:
|
|
72
72
|
|
|
73
73
|
```bash
|
|
74
|
-
npx @slashml/memory --init --skill cursor --api-key "$SLASHML_API_KEY"
|
|
74
|
+
npx -y @slashml/memory@latest --init --skill cursor --api-key "$SLASHML_API_KEY"
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Install ambient lifecycle hooks (`UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`) into `~/.claude/settings.json`:
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
npx @slashml/memory --install-hooks --api-key "$SLASHML_API_KEY"
|
|
80
|
+
npx -y @slashml/memory@latest --install-hooks --api-key "$SLASHML_API_KEY"
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
Or evaluate an agent action / prompt programmatically via `client.intervene()`:
|
|
@@ -118,7 +118,49 @@ const masked = await triage.redact({ text: "Contact alice@acme.io for billing" }
|
|
|
118
118
|
const hits = await triage.search("Who handles billing?", { userId: "alice" });
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
## Swarm Memory, Delegated Tokens & Runtime Guardrails
|
|
122
|
+
|
|
123
|
+
Mint scoped coordinator/worker tokens, promote validated run findings into durable project memory, and guard TypeScript tools, MCP servers, or container shells with synchronous policy enforcement and per-agent redaction:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { MemoryClient, guardTools } from "@slashml/memory";
|
|
127
|
+
|
|
128
|
+
const coord = new MemoryClient({ apiKey: process.env.SLASHML_API_KEY, projectId: "proj_payments" });
|
|
129
|
+
const { token: workerToken } = await coord.mintWorkerToken("worker-1", {
|
|
130
|
+
tier: "worker",
|
|
131
|
+
runId: "run_42",
|
|
132
|
+
projectId: "proj_payments",
|
|
133
|
+
redactPolicy: "soc2_coding",
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const worker = new MemoryClient({ apiKey: workerToken, projectId: "proj_payments", runId: "run_42" });
|
|
137
|
+
const tools = guardTools(
|
|
138
|
+
{
|
|
139
|
+
runSql: async ({ sql }: { sql: string }) => executeQuery(sql),
|
|
140
|
+
},
|
|
141
|
+
{ client: worker, redactPolicy: "soc2_coding" },
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Promote validated run findings to durable project memory and revoke worker access
|
|
145
|
+
await coord.promoteRun({ runId: "run_42", targetProjectId: "proj_payments", discardUnpromoted: true });
|
|
146
|
+
await coord.revokeAgentTokens("worker-1");
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
CLI guardrails for MCP servers and agent containers:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Mint / promote / revoke from CI or orchestrator scripts
|
|
153
|
+
npx -y @slashml/memory mint-token --agent worker-1 --tier worker --run run_42 --project proj_payments --print-env
|
|
154
|
+
npx -y @slashml/memory promote --run run_42 --project proj_payments --discard-unpromoted
|
|
155
|
+
npx -y @slashml/memory revoke-token --agent worker-1
|
|
156
|
+
|
|
157
|
+
# Wrap any stdio or HTTP MCP server with synchronous PreToolUse blocking + output redaction
|
|
158
|
+
npx -y @slashml/memory wrap-mcp -- npx -y @modelcontextprotocol/server-postgres "$DATABASE_URL"
|
|
159
|
+
npx -y @slashml/memory wrap-mcp --url https://mcp.example.com/mcp
|
|
160
|
+
|
|
161
|
+
# Install PATH shims in agent containers for mutating CLIs (psql, git, kubectl, terraform, etc.)
|
|
162
|
+
npx -y @slashml/memory install-shell-guards --bin-dir /usr/local/slashml-guards/bin
|
|
163
|
+
```
|
|
122
164
|
|
|
123
165
|
## License
|
|
124
166
|
|