runmackerel 0.1.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.
@@ -0,0 +1,58 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.*
7
+ .yarn/*
8
+ !.yarn/patches
9
+ !.yarn/plugins
10
+ !.yarn/releases
11
+ !.yarn/versions
12
+
13
+ # testing
14
+ /coverage
15
+
16
+ # next.js
17
+ /.next/
18
+ /out/
19
+
20
+ # production
21
+ /build
22
+
23
+ # misc
24
+ .DS_Store
25
+ *.pem
26
+
27
+ # debug
28
+ npm-debug.log*
29
+ yarn-debug.log*
30
+ yarn-error.log*
31
+ .pnpm-debug.log*
32
+
33
+ # env files (can opt-in for committing if needed)
34
+ .env*
35
+ !.env.example
36
+
37
+ # vercel
38
+ .vercel
39
+
40
+ # typescript
41
+ *.tsbuildinfo
42
+ next-env.d.ts
43
+ cloudflare-env.d.ts
44
+
45
+ # cloudflare & opennext
46
+ /.open-next/
47
+ /.wrangler/
48
+ /workers/api-edge/build/
49
+
50
+ # rust
51
+ /target/
52
+
53
+ .data
54
+ .shots
55
+ /packages/*/dist/
56
+ __pycache__/
57
+ *.pyc
58
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mackerel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.5
2
+ Name: runmackerel
3
+ Version: 0.1.0
4
+ Summary: Python SDK, hydrators, and agent middleware for Mackerel pre-turn context routing
5
+ Project-URL: Homepage, https://runmackerel.com
6
+ Project-URL: Documentation, https://runmackerel.com/docs
7
+ Author-email: Mackerel <founders@runmackerel.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2026 Mackerel
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Keywords: agents,ai,context,mackerel,mcp,memory,recall,sdk
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Programming Language :: Python :: 3.13
40
+ Classifier: Programming Language :: Python :: 3.14
41
+ Classifier: Typing :: Typed
42
+ Requires-Python: >=3.10
43
+ Description-Content-Type: text/markdown
44
+
45
+ # `runmackerel`
46
+
47
+ Python SDK, canonical `mkref://` hydrators, turn-gated pre-turn middleware, and deterministic thread memory for [Mackerel](https://runmackerel.com).
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pip install runmackerel
53
+ ```
54
+
55
+ ## Quickstart — Thread Memory (New & Existing Threads)
56
+
57
+ ```python
58
+ import os
59
+ from openai import OpenAI
60
+ from runmackerel import MackerelClient, attach_thread_memory
61
+
62
+ mackerel = MackerelClient(api_key=os.environ["MACKEREL_API_KEY"], zdr=True)
63
+ memory = attach_thread_memory(
64
+ mackerel,
65
+ thread_id="session-42",
66
+ recall_mode="user_turns", # recalls once per user prompt; skips tool-loop continuations
67
+ )
68
+
69
+ # Attaching mid-project? Idempotently backfill existing history with preserved timestamps:
70
+ memory.backfill(existing_messages)
71
+
72
+ client = memory.wrap(OpenAI())
73
+ ```
74
+
75
+ ## Quickstart — Direct Recall & Hydration
76
+
77
+ ```python
78
+ from runmackerel import MackerelClient, file_hydrator, hydrate_pointers
79
+
80
+ client = MackerelClient(api_key="mk_...")
81
+ res = client.recall(
82
+ turns=[{"role": "user", "text": "What is our refund policy?"}],
83
+ groups=["role:support"],
84
+ source_ids=["rules_refunds"],
85
+ hydrate=True,
86
+ )
87
+ items = hydrate_pointers(
88
+ res["selected"],
89
+ {"file": file_hydrator(["."])},
90
+ vault_hydrated=res.get("hydrated"),
91
+ )
92
+ ```
93
+
94
+ ## Reliability & Safety Guarantees
95
+
96
+ - **Zero-hang by construction:** Finite clamped HTTP/socket timeouts with wall-clock chunked body read deadlines, cancelable backoff sleeps (`threading.Event`), non-blocking thread-pool shutdown (`wait=False, cancel_futures=True`), per-pointer hydrator timeouts, and bounded `body_store` / `get_principal` callback timeouts.
97
+ - **Cross-SDK deterministic `backfill()`:** Byte-for-byte identical deterministic `event_id` derivation and preserved UTC millisecond timestamps matching `@runmackerel/sdk`.
@@ -0,0 +1,53 @@
1
+ # `runmackerel`
2
+
3
+ Python SDK, canonical `mkref://` hydrators, turn-gated pre-turn middleware, and deterministic thread memory for [Mackerel](https://runmackerel.com).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install runmackerel
9
+ ```
10
+
11
+ ## Quickstart — Thread Memory (New & Existing Threads)
12
+
13
+ ```python
14
+ import os
15
+ from openai import OpenAI
16
+ from runmackerel import MackerelClient, attach_thread_memory
17
+
18
+ mackerel = MackerelClient(api_key=os.environ["MACKEREL_API_KEY"], zdr=True)
19
+ memory = attach_thread_memory(
20
+ mackerel,
21
+ thread_id="session-42",
22
+ recall_mode="user_turns", # recalls once per user prompt; skips tool-loop continuations
23
+ )
24
+
25
+ # Attaching mid-project? Idempotently backfill existing history with preserved timestamps:
26
+ memory.backfill(existing_messages)
27
+
28
+ client = memory.wrap(OpenAI())
29
+ ```
30
+
31
+ ## Quickstart — Direct Recall & Hydration
32
+
33
+ ```python
34
+ from runmackerel import MackerelClient, file_hydrator, hydrate_pointers
35
+
36
+ client = MackerelClient(api_key="mk_...")
37
+ res = client.recall(
38
+ turns=[{"role": "user", "text": "What is our refund policy?"}],
39
+ groups=["role:support"],
40
+ source_ids=["rules_refunds"],
41
+ hydrate=True,
42
+ )
43
+ items = hydrate_pointers(
44
+ res["selected"],
45
+ {"file": file_hydrator(["."])},
46
+ vault_hydrated=res.get("hydrated"),
47
+ )
48
+ ```
49
+
50
+ ## Reliability & Safety Guarantees
51
+
52
+ - **Zero-hang by construction:** Finite clamped HTTP/socket timeouts with wall-clock chunked body read deadlines, cancelable backoff sleeps (`threading.Event`), non-blocking thread-pool shutdown (`wait=False, cancel_futures=True`), per-pointer hydrator timeouts, and bounded `body_store` / `get_principal` callback timeouts.
53
+ - **Cross-SDK deterministic `backfill()`:** Byte-for-byte identical deterministic `event_id` derivation and preserved UTC millisecond timestamps matching `@runmackerel/sdk`.
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "runmackerel"
7
+ version = "0.1.0"
8
+ description = "Python SDK, hydrators, and agent middleware for Mackerel pre-turn context routing"
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Mackerel", email = "founders@runmackerel.com" }]
13
+ keywords = ["mackerel", "ai", "agents", "context", "memory", "mcp", "recall", "sdk"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Typing :: Typed",
26
+ ]
27
+ dependencies = []
28
+
29
+ [project.urls]
30
+ Homepage = "https://runmackerel.com"
31
+ Documentation = "https://runmackerel.com/docs"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/runmackerel"]
@@ -0,0 +1,86 @@
1
+ from .client import (
2
+ MackerelApiError,
3
+ MackerelClient,
4
+ is_retryable_http_status,
5
+ transition_http_request_state,
6
+ )
7
+ from .hydrators import (
8
+ PreSlicedPayload,
9
+ VerifiedVaultPayload,
10
+ file_hydrator,
11
+ format_untrusted_context_block,
12
+ git_hydrator,
13
+ hydrate_pointers,
14
+ pg_hydrator,
15
+ s3_range_hydrator,
16
+ vault_hydrator,
17
+ )
18
+ from .middleware import (
19
+ MackerelContextState,
20
+ classify_turn_boundary,
21
+ evaluate_turn_gate,
22
+ with_mackerel,
23
+ )
24
+ from .protocol import (
25
+ MKREF_SCHEMES,
26
+ DocumentChunk,
27
+ HydrationDriftError,
28
+ ParsedMkref,
29
+ build_mkref,
30
+ canonicalize_text,
31
+ is_binary_payload,
32
+ parse_mkref,
33
+ sha256_prefix16,
34
+ split_document,
35
+ verify_and_slice_utf8,
36
+ verify_and_slice_with_spans,
37
+ )
38
+ from .thread_memory import (
39
+ ThreadBodyStore,
40
+ ThreadMemory,
41
+ attach_thread_memory,
42
+ derive_deterministic_message_event_id,
43
+ extract_message_timestamp,
44
+ transition_backfill_state,
45
+ )
46
+
47
+ __version__ = "0.1.0"
48
+
49
+ __all__ = [
50
+ "__version__",
51
+ "MKREF_SCHEMES",
52
+ "DocumentChunk",
53
+ "HydrationDriftError",
54
+ "MackerelApiError",
55
+ "MackerelClient",
56
+ "MackerelContextState",
57
+ "ParsedMkref",
58
+ "PreSlicedPayload",
59
+ "ThreadBodyStore",
60
+ "ThreadMemory",
61
+ "VerifiedVaultPayload",
62
+ "attach_thread_memory",
63
+ "build_mkref",
64
+ "canonicalize_text",
65
+ "classify_turn_boundary",
66
+ "derive_deterministic_message_event_id",
67
+ "evaluate_turn_gate",
68
+ "extract_message_timestamp",
69
+ "file_hydrator",
70
+ "format_untrusted_context_block",
71
+ "git_hydrator",
72
+ "hydrate_pointers",
73
+ "is_binary_payload",
74
+ "is_retryable_http_status",
75
+ "parse_mkref",
76
+ "pg_hydrator",
77
+ "s3_range_hydrator",
78
+ "sha256_prefix16",
79
+ "split_document",
80
+ "transition_backfill_state",
81
+ "transition_http_request_state",
82
+ "vault_hydrator",
83
+ "verify_and_slice_utf8",
84
+ "verify_and_slice_with_spans",
85
+ "with_mackerel",
86
+ ]