memsy 0.3.0__tar.gz

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.
Files changed (110) hide show
  1. memsy-0.3.0/.gitignore +30 -0
  2. memsy-0.3.0/CHANGELOG.md +179 -0
  3. memsy-0.3.0/CLAUDE.md +37 -0
  4. memsy-0.3.0/PKG-INFO +551 -0
  5. memsy-0.3.0/README.md +526 -0
  6. memsy-0.3.0/memsy/__init__.py +160 -0
  7. memsy-0.3.0/memsy/_http.py +204 -0
  8. memsy-0.3.0/memsy/async_client.py +200 -0
  9. memsy-0.3.0/memsy/async_control.py +119 -0
  10. memsy-0.3.0/memsy/client.py +200 -0
  11. memsy-0.3.0/memsy/control.py +125 -0
  12. memsy-0.3.0/memsy/control_resources/__init__.py +18 -0
  13. memsy-0.3.0/memsy/control_resources/billing.py +55 -0
  14. memsy-0.3.0/memsy/control_resources/events.py +89 -0
  15. memsy-0.3.0/memsy/control_resources/interest.py +89 -0
  16. memsy-0.3.0/memsy/control_resources/keys.py +103 -0
  17. memsy-0.3.0/memsy/control_resources/usage.py +93 -0
  18. memsy-0.3.0/memsy/exceptions.py +190 -0
  19. memsy-0.3.0/memsy/models.py +802 -0
  20. memsy-0.3.0/memsy/py.typed +0 -0
  21. memsy-0.3.0/memsy/resources/__init__.py +15 -0
  22. memsy-0.3.0/memsy/resources/memories.py +113 -0
  23. memsy-0.3.0/memsy/resources/orgs.py +123 -0
  24. memsy-0.3.0/memsy/resources/roles.py +137 -0
  25. memsy-0.3.0/memsy/resources/teams.py +137 -0
  26. memsy-0.3.0/pyproject.toml +60 -0
  27. memsy-0.3.0/tests/__init__.py +1 -0
  28. memsy-0.3.0/tests/test_async_client.py +201 -0
  29. memsy-0.3.0/tests/test_client.py +353 -0
  30. memsy-0.3.0/tests/test_control_client.py +277 -0
  31. memsy-0.3.0/tests/test_errors.py +362 -0
  32. memsy-0.3.0/tests/test_models.py +511 -0
  33. memsy-0.3.0/tests/test_resources.py +249 -0
  34. memsy-0.3.0/tests/test_retry.py +168 -0
  35. memsy-0.3.0/tests/test_usage_headers.py +222 -0
  36. memsy-0.3.0/uv.lock +507 -0
  37. memsy-0.3.0/website/LICENSE +21 -0
  38. memsy-0.3.0/website/README.md +59 -0
  39. memsy-0.3.0/website/__tests__/components/callout.test.tsx +46 -0
  40. memsy-0.3.0/website/__tests__/components/card.test.tsx +59 -0
  41. memsy-0.3.0/website/__tests__/components/tabs.test.tsx +61 -0
  42. memsy-0.3.0/website/__tests__/theme-config.test.ts +50 -0
  43. memsy-0.3.0/website/__tests__/utils.test.ts +25 -0
  44. memsy-0.3.0/website/app/api/og/route.tsx +92 -0
  45. memsy-0.3.0/website/app/api/search/route.ts +6 -0
  46. memsy-0.3.0/website/app/components/docs/docs-header.tsx +97 -0
  47. memsy-0.3.0/website/app/components/docs/docs-pager.tsx +41 -0
  48. memsy-0.3.0/website/app/components/docs/docs-sidebar.tsx +194 -0
  49. memsy-0.3.0/website/app/components/docs/docs-tabs.tsx +62 -0
  50. memsy-0.3.0/website/app/components/docs/docs-toc.tsx +61 -0
  51. memsy-0.3.0/website/app/components/docs/mdx/accordion.tsx +56 -0
  52. memsy-0.3.0/website/app/components/docs/mdx/callout.tsx +102 -0
  53. memsy-0.3.0/website/app/components/docs/mdx/card.tsx +110 -0
  54. memsy-0.3.0/website/app/components/docs/mdx/code-block.tsx +42 -0
  55. memsy-0.3.0/website/app/components/docs/mdx/frame.tsx +14 -0
  56. memsy-0.3.0/website/app/components/docs/mdx/index.tsx +167 -0
  57. memsy-0.3.0/website/app/components/docs/mdx/pre.tsx +82 -0
  58. memsy-0.3.0/website/app/components/docs/mdx/steps.tsx +59 -0
  59. memsy-0.3.0/website/app/components/docs/mdx/tabs.tsx +116 -0
  60. memsy-0.3.0/website/app/components/docs/mdx/youtube.tsx +18 -0
  61. memsy-0.3.0/website/app/components/docs/mobile-sidebar.tsx +351 -0
  62. memsy-0.3.0/website/app/components/docs/search-dialog.tsx +286 -0
  63. memsy-0.3.0/website/app/components/docs/theme-toggle.tsx +35 -0
  64. memsy-0.3.0/website/app/docs/[[...slug]]/page.tsx +141 -0
  65. memsy-0.3.0/website/app/docs/layout.tsx +75 -0
  66. memsy-0.3.0/website/app/globals.css +164 -0
  67. memsy-0.3.0/website/app/layout.tsx +47 -0
  68. memsy-0.3.0/website/app/llms-full.txt/route.ts +97 -0
  69. memsy-0.3.0/website/app/llms.txt/route.ts +56 -0
  70. memsy-0.3.0/website/app/page.tsx +5 -0
  71. memsy-0.3.0/website/app/providers/theme-provider.tsx +8 -0
  72. memsy-0.3.0/website/content/docs/actors-and-sessions.mdx +68 -0
  73. memsy-0.3.0/website/content/docs/async-client.mdx +89 -0
  74. memsy-0.3.0/website/content/docs/async-memsy-client.mdx +80 -0
  75. memsy-0.3.0/website/content/docs/async-processing.mdx +73 -0
  76. memsy-0.3.0/website/content/docs/console-memories.mdx +136 -0
  77. memsy-0.3.0/website/content/docs/control-client.mdx +187 -0
  78. memsy-0.3.0/website/content/docs/error-handling.mdx +177 -0
  79. memsy-0.3.0/website/content/docs/events-and-memories.mdx +79 -0
  80. memsy-0.3.0/website/content/docs/exceptions.mdx +156 -0
  81. memsy-0.3.0/website/content/docs/faq.mdx +55 -0
  82. memsy-0.3.0/website/content/docs/index.mdx +46 -0
  83. memsy-0.3.0/website/content/docs/ingesting-events.mdx +129 -0
  84. memsy-0.3.0/website/content/docs/installation.mdx +57 -0
  85. memsy-0.3.0/website/content/docs/memsy-client.mdx +208 -0
  86. memsy-0.3.0/website/content/docs/meta.json +31 -0
  87. memsy-0.3.0/website/content/docs/models.mdx +507 -0
  88. memsy-0.3.0/website/content/docs/onboarding.mdx +183 -0
  89. memsy-0.3.0/website/content/docs/quickstart.mdx +185 -0
  90. memsy-0.3.0/website/content/docs/retries.mdx +72 -0
  91. memsy-0.3.0/website/content/docs/searching-memory.mdx +111 -0
  92. memsy-0.3.0/website/content/docs/signup.mdx +61 -0
  93. memsy-0.3.0/website/content/docs/usage-and-rate-limits.mdx +116 -0
  94. memsy-0.3.0/website/lib/docs-source.ts +7 -0
  95. memsy-0.3.0/website/lib/docs-tabs.ts +78 -0
  96. memsy-0.3.0/website/lib/page-icons.tsx +82 -0
  97. memsy-0.3.0/website/lib/theme-config.ts +92 -0
  98. memsy-0.3.0/website/lib/utils.ts +6 -0
  99. memsy-0.3.0/website/next-env.d.ts +6 -0
  100. memsy-0.3.0/website/next.config.mjs +15 -0
  101. memsy-0.3.0/website/package-lock.json +11396 -0
  102. memsy-0.3.0/website/package.json +45 -0
  103. memsy-0.3.0/website/postcss.config.mjs +7 -0
  104. memsy-0.3.0/website/public/logo.txt +1 -0
  105. memsy-0.3.0/website/public/logo_dark.jpeg +0 -0
  106. memsy-0.3.0/website/public/logo_light.jpeg +0 -0
  107. memsy-0.3.0/website/source.config.ts +22 -0
  108. memsy-0.3.0/website/tailwind.config.ts +40 -0
  109. memsy-0.3.0/website/tsconfig.json +42 -0
  110. memsy-0.3.0/website/vitest.config.ts +16 -0
memsy-0.3.0/.gitignore ADDED
@@ -0,0 +1,30 @@
1
+ # Python
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.egg-info/
6
+ *.egg
7
+ dist/
8
+ build/
9
+ .eggs/
10
+ .pytest_cache/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+ .venv/
14
+ venv/
15
+ .env
16
+ .env.*
17
+
18
+ # Node / JS
19
+ node_modules/
20
+
21
+ # Docs site (python-sdk/website — Next.js + Fumadocs / Unmint)
22
+ website/.next/
23
+ website/.source/
24
+ website/.unmint/
25
+ website/out/
26
+
27
+ # OS / editor
28
+ .DS_Store
29
+ .vscode/
30
+ .idea/
@@ -0,0 +1,179 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.3.0] - 2026-04-29
11
+
12
+ ### Breaking Changes
13
+
14
+ - **`org_id` removed**: The deprecated `org_id` parameter has been deleted from `search()` and
15
+ the `org_id` field removed from `EventPayload`. Organization context is inferred from the API
16
+ key. Passing `org_id` now raises `TypeError`. *Migration: remove any `org_id=...` kwargs.*
17
+
18
+ - **`MemsyAuthError` alias removed**: The backwards-compat alias deprecated in 0.2.0 has been
19
+ deleted. Use `AuthenticationError` directly.
20
+
21
+ ### Added
22
+
23
+ - **`role_id` and `team_id` on `EventPayload`**: Two new optional fields for scoping events to
24
+ a hierarchy role or team. Both are emitted in the request body when set.
25
+
26
+ ```python
27
+ EventPayload(
28
+ actor_id="user_1", session_id="s1",
29
+ kind="user_message", content="...",
30
+ role_id="role_eng", team_id="team_platform",
31
+ )
32
+ ```
33
+
34
+ - **`MemsyControlClient` and `AsyncMemsyControlClient`**: New clients for the Memsy control-plane
35
+ API (`api/`). Exposes account, billing, key management, usage reporting, event browsing, and
36
+ interest endpoints via typed sub-resource accessors.
37
+
38
+ ```python
39
+ from memsy import MemsyControlClient
40
+
41
+ control = MemsyControlClient(base_url="https://api.memsy.io/api", api_key="msy_...")
42
+ me = control.me()
43
+ events = control.events.list(limit=20)
44
+ summary = control.billing.summary() # admin-only
45
+ key = control.keys.create("ci-key") # admin-only
46
+ ```
47
+
48
+ - **Onboarding sub-resources on `MemsyClient`**: `client.orgs`, `client.roles`, `client.teams`
49
+ expose full CRUD + `regenerate_prompt` for the memsy-core onboarding hierarchy.
50
+
51
+ ```python
52
+ client.orgs.create(org_id="my-org", name="My Org", focus="AI assistant for our users")
53
+ roles = client.roles.list(org_id="my-org")
54
+ client.teams.delete(team_id="t1", org_id="my-org")
55
+ ```
56
+
57
+ - **Console memories sub-resource on `MemsyClient`**: `client.memories` exposes
58
+ `list()`, `stats()`, and `get(memory_id)` for browsing memories in the authenticated org.
59
+
60
+ ```python
61
+ stats = client.memories.stats()
62
+ page = client.memories.list(kind="semantic", limit=20)
63
+ item = client.memories.get("uuid-here")
64
+ ```
65
+
66
+ - **`HealthResponse.billing_enabled` and `HealthResponse.components`**: New optional fields
67
+ surfacing the enriched `/health` response from memsy-core 2.1.0 and the api/ service.
68
+
69
+ - **`SourceEvent` dataclass and `SearchResult.source_events` property**: When `search()` is
70
+ called with `include_source_events=True`, the result metadata now has a typed accessor:
71
+
72
+ ```python
73
+ results = client.search("preferences", include_source_events=True)
74
+ for r in results.results:
75
+ for evt in r.source_events: # list[SourceEvent]
76
+ print(evt.event_id, evt.content)
77
+ ```
78
+
79
+ Additional typed properties on `SearchResult`: `title`, `summary`, `tags`, `entities`,
80
+ `source_event_ids`, `kind`, `type`, `strength`, `confidence`, `observed_at`.
81
+
82
+ - **New exception classes** for previously unclassified error codes:
83
+ - `OrgIdNotAllowedError` (400) — free-tier guard when `org_id` is sent in request body
84
+ - `SeatRequiredError` (403) — endpoint requires an assigned seat
85
+ - `OrgLimitReachedError` (403) — org tier cap hit; carries `limit`, `current`
86
+ - `KeyLimitReachedError` (403) — API key tier cap hit; carries `limit`, `current`
87
+ - `BillingNotEnabledError` (403) — billing endpoint called on free tier; carries `interest_path`
88
+ - `SeatLimitReachedError` (409) — seat purchase limit reached
89
+
90
+ - **Shared `HttpCoreMixin` in `memsy/_http.py`**: Error classification, header parsing, and
91
+ detail extraction are now shared between `MemsyClient` and `MemsyControlClient` via a mixin,
92
+ ensuring consistent error handling across both services.
93
+
94
+ - **New models**: `MeResponse`, `UsageSummaryResponse`, `DimensionUsage`,
95
+ `UsageTimeseriesResponse`, `TimeseriesPoint`, `BillingSummary`, `PaymentMethod`,
96
+ `UpcomingInvoice`, `Invoice`, `ApiKeyInfo`, `ApiKeyListResponse`, `CreateKeyResponse`,
97
+ `EventItemResponse`, `EventListResponse`, `ProInterestResponse`, `OrgResource`,
98
+ `RoleResource`, `TeamResource`, `MemoryScopeInfo`, `MemoryItemResource`,
99
+ `MemoryListResponse`, `MemoryStatsResponse`, `SourceEvent`.
100
+
101
+ - **204 No Content handling**: `_request` in both clients now returns `None` body (instead of
102
+ raising `JSONDecodeError`) for DELETE endpoints that respond with 204 No Content.
103
+
104
+ - **Python 3.13 classifier** added to `pyproject.toml`.
105
+
106
+ ### Fixed
107
+
108
+ - `_extract_detail` now correctly unwraps FastAPI's `{"detail": {"error": ..., "message": ...}}`
109
+ envelope in addition to the flat `{"error": ..., "message": ...}` shape returned by memsy-core's
110
+ `MemsyHTTPError` handler.
111
+
112
+ ---
113
+
114
+ ## [0.2.0] - 2026-03-27
115
+
116
+ ### Added
117
+ - **Usage header parsing**: Responses now include `usage` and `rate_limit` attributes parsed from `X-Usage-*` and `X-RateLimit-*` headers
118
+ (#GAP-SDK-03, #GAP-SDK-06)
119
+ ```python
120
+ result = client.search("query")
121
+ print(result.usage.api_calls) # 100
122
+ print(result.usage.plan) # "pro"
123
+ print(result.rate_limit.remaining) # 950
124
+ ```
125
+
126
+ - **429 retry logic**: Automatic retry with exponential backoff on 429 responses (#GAP-SDK-02)
127
+ - Max 3 retries by default
128
+ - Respects `Retry-After` header
129
+ - Configurable via `max_retries` and `retry_backoff` parameters
130
+
131
+ - **New error types**: More granular exception handling (#GAP-SDK-04)
132
+ - `AuthenticationError` (401) - Invalid/missing API key
133
+ - `AuthorizationError` (403) - Wrong scope
134
+ - `FeatureNotAvailable` (403) - Feature gated by tier
135
+ - `RateLimitExceeded` (429) - Rate limit hit
136
+ - `UsageLimitExceeded` (429) - Quota exceeded
137
+ - All include `upgrade_url`, `current_tier`, `dimension`, etc. where applicable
138
+
139
+ - **Retry configuration**: `MemsyClient` now accepts `max_retries` and `retry_backoff` parameters (#GAP-SDK-07)
140
+ ```python
141
+ client = MemsyClient(
142
+ base_url="https://api.memsy.io",
143
+ api_key="***",
144
+ max_retries=5,
145
+ retry_backoff=2.0,
146
+ )
147
+ ```
148
+
149
+ - **Type checking support**: Added `py.typed` marker for mypy compatibility (#GAP-SDK-12)
150
+
151
+ ### Changed
152
+ - **Authentication header**: Changed from `x-api-key` to `Authorization: Bearer` (#GAP-SDK-01)
153
+ - This is the documented standard and is automatically handled
154
+ - No code changes required for users
155
+
156
+ - **`org_id` removal**: `org_id` parameter is no longer required in request bodies (#GAP-SDK-05)
157
+ - `search()` no longer requires `org_id` parameter
158
+ - `EventPayload` no longer requires `org_id` field
159
+ - Organization is now inferred from API key context
160
+ - **Breaking change**: This is a breaking API change. See migration guide in README.
161
+ - Passing `org_id` still works but is deprecated (will be removed in future version)
162
+
163
+ ```python
164
+ # Before (v0.1.x)
165
+ results = client.search("query", org_id="org_1")
166
+
167
+ # After (v0.2.x)
168
+ results = client.search("query") # org_id inferred from API key
169
+ ```
170
+
171
+ - **Error classification**: The `_request` method now properly classifies errors based on response body and headers (#GAP-SDK-04)
172
+ - 403 with `feature_not_available` error code → `FeatureNotAvailable`
173
+ - 429 with `usage_limit_exceeded` error code → `UsageLimitExceeded`
174
+ - 429 with other errors → `RateLimitExceeded`
175
+
176
+ ### Deprecated
177
+ - `org_id` parameter in `search()` method - **removed in v0.3.0**
178
+ - `org_id` field in `EventPayload` - **removed in v0.3.0**
179
+ - `MemsyAuthError` - **removed in v0.3.0**. Use `AuthenticationError` instead
memsy-0.3.0/CLAUDE.md ADDED
@@ -0,0 +1,37 @@
1
+ # Memsy Python SDK
2
+
3
+ Thin client library for external consumers. Wraps memsy-core and api endpoints. Published to PyPI.
4
+
5
+ ## Commands
6
+
7
+ ```bash
8
+ uv run pytest tests/ -v # Run tests
9
+ ruff check memsy/ # Lint
10
+ ruff format memsy/ # Format
11
+ ```
12
+
13
+ ## Architecture
14
+
15
+ ```
16
+ memsy/
17
+ ├── client.py # Main MemsyClient class
18
+ ├── models.py # Public-facing Pydantic models (MemsyEvent, RetrievalResult, ...)
19
+ └── exceptions.py # SDK-specific exceptions
20
+ ```
21
+
22
+ ## Key Rules
23
+
24
+ - This is a **public API** — semver strictly enforced; breaking changes require major version bump
25
+ - Keep the surface area small — don't expose internal memsy-core implementation details
26
+ - All public methods must be documented with docstrings
27
+ - Pydantic models in `models.py` are the contract — never change field names without a deprecation cycle
28
+ - Async client (`AsyncMemsyClient`) must mirror the sync client
29
+
30
+ ## Version
31
+
32
+ See `CHANGELOG.md` for version history. Update it for every release.
33
+
34
+ ## Watch Out For
35
+
36
+ - SDK depends on `memsy-core` indirectly — version pin carefully in `pyproject.toml`
37
+ - Tests mock the HTTP layer — don't hit real endpoints in unit tests