Skip to content

Commit 65f92aa

Browse files
committed
Add initial implementation of MemoryLayer SDK and configuration files
0 parents  commit 65f92aa

File tree

303 files changed

+64067
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

303 files changed

+64067
-0
lines changed

.claude-plugin/marketplace.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
3+
"name": "memorylayer.ai",
4+
"description": "Persistent memory System - never lose context to compaction again",
5+
"owner": {
6+
"name": "scitrera.ai",
7+
"email": "open-source-team@scitrera.com"
8+
},
9+
"plugins": [
10+
{
11+
"name": "memorylayer",
12+
"description": "Persistent memory system designed to work seamlessly with Claude agents. MemoryLayer proactively preserves important context before compaction and allows agents to recall relevant information on demand, ensuring critical knowledge is never lost.",
13+
"version": "0.0.3",
14+
"author": {
15+
"name": "scitrera.ai",
16+
"email": "open-source-team@scitrera.com"
17+
},
18+
"source": "/memorylayer-cc-plugin",
19+
"category": "productivity",
20+
"homepage": "https://memorylayer.ai",
21+
"tags": [
22+
"memory",
23+
"context",
24+
"persistence",
25+
"knowledge-graph",
26+
"recall",
27+
"compaction"
28+
]
29+
}
30+
]
31+
}

.github/workflows/release.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Release workflow: build and publish all packages on version tags
2+
#
3+
# Trigger: push a tag matching 'v*' (e.g., v0.0.3) to main
4+
#
5+
# Required setup:
6+
# PyPI - Configure trusted publishing for each Python package at
7+
# https://pypi.org/manage/project/<name>/settings/publishing/
8+
# Set: Owner=scitrera, Repo=memorylayer, Workflow=release.yml, Environment=pypi
9+
# npm - Create an automation token at https://www.npmjs.com/settings/<user>/tokens
10+
# Add as repository secret: NPM_TOKEN
11+
# Docker Hub - Create an access token at https://hub.docker.com/settings/security
12+
# Add as repository secrets: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN
13+
14+
name: Release
15+
16+
on:
17+
push:
18+
tags:
19+
- "v*"
20+
21+
# Cancel any in-progress release for a previous tag
22+
concurrency:
23+
group: release-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
# ──────────────────────────────────────────────────────────────────
31+
# Python packages → PyPI (trusted publishing, no token needed)
32+
# ──────────────────────────────────────────────────────────────────
33+
publish-python:
34+
name: "PyPI: ${{ matrix.package.name }}"
35+
runs-on: ubuntu-latest
36+
permissions:
37+
id-token: write # OIDC for PyPI trusted publishing
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
package:
42+
- { dir: memorylayer-sdk-python, name: memorylayer-client }
43+
- { dir: memorylayer-core-python, name: memorylayer-server }
44+
- { dir: memorylayer-sdk-langchain-python, name: memorylayer-langchain }
45+
- { dir: memorylayer-sdk-llamaindex-python, name: memorylayer-llamaindex }
46+
environment:
47+
name: pypi
48+
url: https://pypi.org/project/${{ matrix.package.name }}/
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: actions/setup-python@v5
53+
with:
54+
python-version: "3.12"
55+
56+
- name: Install build tools
57+
run: pip install --upgrade build
58+
59+
- name: Build package
60+
working-directory: ${{ matrix.package.dir }}
61+
run: python -m build
62+
63+
- name: Publish to PyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
packages-dir: ${{ matrix.package.dir }}/dist/
67+
68+
# ──────────────────────────────────────────────────────────────────
69+
# TypeScript SDK → npm
70+
# ──────────────────────────────────────────────────────────────────
71+
publish-npm-sdk:
72+
name: "npm: @scitrera/memorylayer-sdk"
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- uses: actions/setup-node@v4
78+
with:
79+
node-version: "20"
80+
registry-url: "https://registry.npmjs.org"
81+
82+
- name: Install dependencies
83+
working-directory: memorylayer-sdk-typescript
84+
run: npm install
85+
86+
- name: Build
87+
working-directory: memorylayer-sdk-typescript
88+
run: npm run build
89+
90+
- name: Publish to npm
91+
working-directory: memorylayer-sdk-typescript
92+
run: npm publish --access public
93+
env:
94+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
95+
96+
# ──────────────────────────────────────────────────────────────────
97+
# TypeScript MCP server → npm (after SDK is published)
98+
# ──────────────────────────────────────────────────────────────────
99+
publish-npm-mcp:
100+
name: "npm: @scitrera/memorylayer-mcp-server"
101+
needs: publish-npm-sdk
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- uses: actions/setup-node@v4
107+
with:
108+
node-version: "20"
109+
registry-url: "https://registry.npmjs.org"
110+
111+
- name: Replace local SDK reference with registry version
112+
working-directory: memorylayer-mcp-typescript
113+
run: |
114+
VERSION="${GITHUB_REF_NAME#v}"
115+
sed -i 's|"file:../memorylayer-sdk-typescript"|"^'"${VERSION}"'"|' package.json
116+
117+
- name: Wait for SDK availability on npm
118+
run: |
119+
VERSION="${GITHUB_REF_NAME#v}"
120+
for i in $(seq 1 30); do
121+
if npm view "@scitrera/memorylayer-sdk@${VERSION}" version 2>/dev/null; then
122+
echo "SDK v${VERSION} is available on npm"
123+
exit 0
124+
fi
125+
echo "Waiting for @scitrera/memorylayer-sdk@${VERSION} (attempt ${i}/30)..."
126+
sleep 10
127+
done
128+
echo "::error::SDK not available on npm after 5 minutes"
129+
exit 1
130+
131+
- name: Install dependencies
132+
working-directory: memorylayer-mcp-typescript
133+
run: npm install
134+
135+
- name: Build
136+
working-directory: memorylayer-mcp-typescript
137+
run: npm run build
138+
139+
- name: Publish to npm
140+
working-directory: memorylayer-mcp-typescript
141+
run: npm publish --access public
142+
env:
143+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
144+
145+
# ──────────────────────────────────────────────────────────────────
146+
# Docker image → Docker Hub (after memorylayer-server is on PyPI)
147+
# ──────────────────────────────────────────────────────────────────
148+
publish-docker:
149+
name: "Docker: scitrera/memorylayer-server"
150+
needs: publish-python
151+
runs-on: ubuntu-latest
152+
steps:
153+
- uses: actions/checkout@v4
154+
155+
- name: Wait for memorylayer-server on PyPI
156+
run: |
157+
VERSION="${GITHUB_REF_NAME#v}"
158+
for i in $(seq 1 30); do
159+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
160+
"https://pypi.org/pypi/memorylayer-server/${VERSION}/json")
161+
if [ "${STATUS}" = "200" ]; then
162+
echo "memorylayer-server ${VERSION} is available on PyPI"
163+
exit 0
164+
fi
165+
echo "Waiting for memorylayer-server ${VERSION} on PyPI (attempt ${i}/30)..."
166+
sleep 10
167+
done
168+
echo "::error::memorylayer-server not available on PyPI after 5 minutes"
169+
exit 1
170+
171+
- name: Extract metadata for Docker
172+
id: meta
173+
uses: docker/metadata-action@v5
174+
with:
175+
images: scitrera/memorylayer-server
176+
tags: |
177+
type=semver,pattern={{version}}
178+
type=semver,pattern={{major}}.{{minor}}
179+
type=raw,value=latest
180+
181+
- uses: docker/setup-qemu-action@v3
182+
183+
- uses: docker/setup-buildx-action@v3
184+
185+
- name: Log in to Docker Hub
186+
uses: docker/login-action@v3
187+
with:
188+
username: ${{ secrets.DOCKERHUB_USERNAME }}
189+
password: ${{ secrets.DOCKERHUB_TOKEN }}
190+
191+
- name: Build and push
192+
uses: docker/build-push-action@v6
193+
with:
194+
context: .
195+
file: Dockerfile
196+
push: true
197+
tags: ${{ steps.meta.outputs.tags }}
198+
labels: ${{ steps.meta.outputs.labels }}
199+
platforms: linux/amd64,linux/arm64
200+
cache-from: type=gha
201+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.astro/
2+
.omc/
3+
dist/
4+
node_modules/
5+
node-modules/
6+
.venv/
7+
__pycache__/
8+
*.pyc
9+
uv.lock
10+
package-lock.json

Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM python:3.12-slim AS base
2+
3+
LABEL maintainer="Scitrera <open-source-team@scitrera.com>"
4+
LABEL org.opencontainers.image.source="https://github.com/scitrera/memorylayer"
5+
LABEL org.opencontainers.image.description="MemoryLayer.ai - Memory infrastructure for LLM-powered agents"
6+
LABEL org.opencontainers.image.licenses="Apache-2.0"
7+
8+
# Prevent Python from writing .pyc files and enable unbuffered output
9+
ENV PYTHONDONTWRITEBYTECODE=1 \
10+
PYTHONUNBUFFERED=1
11+
12+
# Install system dependencies required by native extensions (sqlite-vec, etc.)
13+
RUN apt-get update && \
14+
apt-get install -y --no-install-recommends \
15+
build-essential \
16+
curl \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
# Create non-root user
20+
RUN groupadd --gid 1000 memorylayer && \
21+
useradd --uid 1000 --gid memorylayer --create-home memorylayer
22+
23+
# Set up persistent data directory
24+
RUN mkdir -p /data && chown memorylayer:memorylayer /data
25+
VOLUME /data
26+
27+
WORKDIR /app
28+
29+
# Install memorylayer-server with all optional dependencies from PyPI
30+
RUN pip install --no-cache-dir "memorylayer-server[all]"
31+
32+
# Remove build tools no longer needed at runtime
33+
RUN apt-get purge -y build-essential && \
34+
apt-get autoremove -y && \
35+
rm -rf /var/lib/apt/lists/*
36+
37+
# Switch to non-root user
38+
USER memorylayer
39+
40+
# Container defaults:
41+
# - Bind to 0.0.0.0 (code default 127.0.0.1 is unreachable from outside the container)
42+
# - Use local sentence-transformers for embeddings (no API key required)
43+
ENV MEMORYLAYER_SERVER_HOST=0.0.0.0 \
44+
MEMORYLAYER_SERVER_PORT=61001 \
45+
MEMORYLAYER_DATA_DIR=/data \
46+
MEMORYLAYER_EMBEDDING_PROVIDER=local
47+
48+
EXPOSE 61001
49+
50+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
51+
CMD curl -f http://localhost:61001/health || exit 1
52+
53+
ENTRYPOINT ["memorylayer"]
54+
CMD ["serve"]

0 commit comments

Comments
 (0)