Memories 上下文排查
- 作者仓库星标 27
- 许可证 Apache-2.0
- 作者仓库 memories
memories-sdk
Use the SDK packages when an application needs memories.sh programmatically. Prefer @memories.sh/core for direct typed API access and @memories.sh/ai-sdk only when the caller already uses the Vercel AI SDK.
Workflow
- Pick the integration surface:
- Use
@memories.sh/corefor backend routes, workers, cron jobs, and non-AI-SDK agents. - Use
@memories.sh/ai-sdkforgenerateText,streamText, middleware, or tool loops built onai. - If the task is about the CLI or MCP configuration, switch to
memories-cliormemories-mcp.
- Use
- Set scope before writing code:
- Keep
MEMORIES_API_KEYserver-side. tenantIdselects the tenant or workspace database.userIdnarrows memory to a user inside that tenant.projectIdnarrows reads and writes to a product area, repo, or feature slice.
- Keep
- Use the narrowest pattern that solves the task:
- Direct CRUD or context lookup:
MemoriesClient - Automatic prompt injection:
memoriesMiddleware - Agent loops with explicit memory tools:
memoriesToolsandmemoriesSystemPrompt - Fetch once and reuse:
preloadContext - Persist after completion:
createMemoriesOnFinish
- Direct CRUD or context lookup:
- Verify the integration:
- Confirm the same scope is used on both reads and writes.
- Catch
MemoriesClientError. - Do not expose the API key to browser-only code.
Quick Start
@memories.sh/core
import { MemoriesClient } from "@memories.sh/core"
const client = new MemoriesClient({
apiKey: [REDACTED:credential],
tenantId: "acme-prod",
userId: "user_123",
})
const context = await client.context.get({
query: "billing architecture",
projectId: "dashboard",
mode: "all",
strategy: "hybrid",
limit: 8,
})
await client.memories.add({
content: "Enterprise billing uses Stripe invoices.",
type: "fact",
projectId: "dashboard",
tags: ["billing"],
})
@memories.sh/ai-sdk
import { generateText, stepCountIs, wrapLanguageModel } from "ai"
import { openai } from "@ai-sdk/openai"
import {
memoriesMiddleware,
memoriesSystemPrompt,
memoriesTools,
} from "@memories.sh/ai-sdk"
const model = wrapLanguageModel({
model: openai("gpt-4o"),
middleware: memoriesMiddleware({
tenantId: "acme-prod",
userId: "user_123",
projectId: "dashboard",
}),
})
const result = await generateText({
model,
system: memoriesSystemPrompt(),
tools: memoriesTools({
tenantId: "acme-prod",
userId: "user_123",
projectId: "dashboard",
}),
stopWhen: stepCountIs(5),
prompt: "Summarize prior decisions about billing.",
})
console.log(result.text)
Decision Guide
- Need direct typed access from your own backend code: use
MemoriesClient - Need automatic context injection into prompts or messages: use
memoriesMiddleware - Need the model to read or write memory explicitly through tools: use
memoriesTools - Need to manage stored skill files or procedure fragments: use
client.skills.*or the AI SDK skill-file tools - Need tenant, key, or embedding usage administration: use
client.management.* - Need internals of the memories monorepo or server endpoints: use
memories-dev
Reference Files
references/core.md: direct client methods, transport choices, errors, management APIs, and skill-file APIsreferences/ai-sdk.md: middleware, tools, preload, post-finish persistence, and query extraction patternsreferences/scoping.md: tenant/user/project scoping rules, server-side safety, and debugging checklist
- 流狐分类
- 工程开发
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @webrenew · Apache-2.0
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Workflow
Pick the integration surface: Use @memories.sh/core for backend routes, workers, cron jobs, and non-AI-SDK agents. Use @memories.sh/ai-sdk for generateText, streamText, middleware, or tool loops built on ai.
Quick Start
Quick Start
# memories-sdk
Use the SDK packages when an application needs memories.sh programmatically. Prefer `@memories.sh/core` for direct typed API access and `@memories.sh/ai-sdk` only when the caller already uses the Vercel AI SDK.
## Workflow
1. Pick the integration surface:
- Use `@memories.sh/core` for backend routes, workers, cron jobs, and non-AI-SDK agents.
- Use `@memories.sh/ai-sdk` for `generateText`, `streamText`, middleware, or tool loops built on `ai`.
- If the task is about the CLI or MCP configuration, switch to `memories-cli` or `memories-mcp`.
2. Set scope before writing code:
- Keep `MEMORIES_API_KEY` server-side.
- `tenantId` selects the tenant or workspace database.
- `userId` narrows memory to a user inside that tenant.
- `projectId` narrows reads and writes to a product area, repo, or feature slice.
3. Use the narrowest pattern that solves the task:
- Direct CRUD or context lookup: `MemoriesClient`
- Automatic prompt injection: `memoriesMiddleware`
- Agent loops with explicit memory tools: `memoriesTools` and `memoriesSystemPrompt`
- Fetch once and reuse: `preloadContext`
- Persist after completion: `createMemoriesOnFinish`
4. Verify the integration:
- Confirm the same scope is used on both reads and writes.
- Catch `MemoriesClientError`.
- Do not expose the API key to browser-only code.
## Quick Start
### `@memories.sh/core`
```ts
import { MemoriesClient } from "@memories.sh/core"
const client = new MemoriesClient({
apiKey: [REDACTED:credential],
tenantId: "acme-prod",
userId: "user_123",
})
const context = await client.context.get({
query: "billing architecture",
projectId: "dashboard",
mode: "all",
strategy: "hybrid",
limit: 8,
})
await client.memories.add({
… 证据边界与执行链路
作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Workflow → Quick Start → @memories.sh/core → @memories.sh/ai-sdk → Decision Guide → Reference Files
要点 -> Use the SDK packages when an application needs memories.sh programmatically. · 1. Pick the integration surface: - Use @memories.sh/core for backend routes, workers, cron jobs, and non-AI-SDK agents.
文件/命令 -> @memories.sh/core · @memories.sh/ai-sdk · generateText · streamText · memories-cli · memories-mcp · MEMORIESAPIKEY · tenantId
内容 SHA-256 -> 3c30f54e7b11
方法与流程
适用与边界
原文中的明确线索
@memories.sh/core、@memories.sh/ai-sdk、generateText、streamText、memories-cli、memories-mcp、MEMORIESAPIKEY、tenantId