ai-memory-layer-client 4.0.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,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-memory-layer-client
3
+ Version: 4.0.0
4
+ Summary: Python REST client for the memory-layer server
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/gstarling/memory-layer
7
+ Project-URL: Documentation, https://github.com/gstarling/memory-layer/tree/main/clients/python
8
+ Project-URL: Issues, https://github.com/gstarling/memory-layer/issues
9
+ Keywords: ai,memory,agent,retrieval
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: httpx<1.0.0,>=0.27.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: build<2.0.0,>=1.2.0; extra == "dev"
23
+ Requires-Dist: pytest<9.0.0,>=8.3.0; extra == "dev"
24
+ Requires-Dist: pytest-asyncio<1.0.0,>=0.24.0; extra == "dev"
25
+ Requires-Dist: pytest-httpx<1.0.0,>=0.35.0; extra == "dev"
26
+ Requires-Dist: ruff<1.0.0,>=0.7.0; extra == "dev"
27
+
28
+ # memory-layer-client
29
+
30
+ Python client for the `memory-layer` HTTP service.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pip install memory-layer-client
36
+ ```
37
+
38
+ For local development and tests:
39
+
40
+ ```bash
41
+ pip install -e '.[dev]'
42
+ pytest
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ```python
48
+ from memory_layer_client import MemoryClient, MemoryRuntimeClient, MemoryScope
49
+
50
+ client = MemoryClient(
51
+ "http://localhost:3100",
52
+ api_key="dev-key",
53
+ default_scope=MemoryScope(
54
+ tenant_id="acme",
55
+ system_id="python-worker",
56
+ collaboration_id="release-42",
57
+ scope_id="run-42",
58
+ ),
59
+ )
60
+ runtime = MemoryRuntimeClient(client)
61
+
62
+ result = runtime.run_turn(
63
+ "Remember that deployments must stay blue-green.",
64
+ lambda prepared: "Stored. I will keep rollout constraints in memory.",
65
+ )
66
+ print(result.prepared.prompt)
67
+ ```
68
+
69
+ ## Async Client
70
+
71
+ ```python
72
+ import asyncio
73
+ from memory_layer_client import AsyncMemoryClient, AsyncMemoryRuntimeClient
74
+
75
+ async def main() -> None:
76
+ client = AsyncMemoryClient("http://localhost:3100", api_key="dev-key")
77
+ runtime = AsyncMemoryRuntimeClient(client)
78
+ result = await runtime.run_turn(
79
+ "Track migration status.",
80
+ lambda prepared: "I will keep the migration status in memory.",
81
+ )
82
+ health = await client.health()
83
+ print(result.prepared.context.token_estimate, health.active_turn_count)
84
+ await client.aclose()
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ ## Scope Resolution
90
+
91
+ Each request can inherit a default scope and override it per call. This matches the multi-tenant routing model used by the HTTP server.
92
+
93
+ `MemoryScope` also supports `collaboration_id`, so Python clients can participate in shared multi-agent workspaces the same way the TypeScript server and SDK do.
94
+
95
+ ## Hosted Runtime And Changes
96
+
97
+ ```python
98
+ from memory_layer_client import MemoryClient, MemoryRuntimeClient
99
+
100
+ client = MemoryClient("http://localhost:3100")
101
+ runtime = MemoryRuntimeClient(client)
102
+
103
+ knowledge = client.list_knowledge(limit=20)
104
+ detail = client.inspect_knowledge(knowledge.items[0]["id"])
105
+ changes = client.poll_changes("2026-03-01T00:00:00Z", scope_level="workspace")
106
+ cross_scope = client.search_cross_scope("rollback", scope_level="workspace")
107
+ prepared = runtime.before_model_call("What changed in the shared workspace?")
108
+ print(prepared.prompt)
109
+ for event in client.stream_events(event_types=["knowledge_change"], scope_level="workspace"):
110
+ print(event.type, event.meta)
111
+ break
112
+ ```
113
+
114
+ ## CLI
115
+
116
+ ```bash
117
+ memory-layer-client --base-url http://localhost:3100 health
118
+ memory-layer-client --base-url http://localhost:3100 search "rollback checklist"
119
+ memory-layer-client --base-url http://localhost:3100 inspect-knowledge --limit 10
120
+ memory-layer-client --base-url http://localhost:3100 run-reverification --admin-key secret
121
+ ```
@@ -0,0 +1,94 @@
1
+ # memory-layer-client
2
+
3
+ Python client for the `memory-layer` HTTP service.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install memory-layer-client
9
+ ```
10
+
11
+ For local development and tests:
12
+
13
+ ```bash
14
+ pip install -e '.[dev]'
15
+ pytest
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```python
21
+ from memory_layer_client import MemoryClient, MemoryRuntimeClient, MemoryScope
22
+
23
+ client = MemoryClient(
24
+ "http://localhost:3100",
25
+ api_key="dev-key",
26
+ default_scope=MemoryScope(
27
+ tenant_id="acme",
28
+ system_id="python-worker",
29
+ collaboration_id="release-42",
30
+ scope_id="run-42",
31
+ ),
32
+ )
33
+ runtime = MemoryRuntimeClient(client)
34
+
35
+ result = runtime.run_turn(
36
+ "Remember that deployments must stay blue-green.",
37
+ lambda prepared: "Stored. I will keep rollout constraints in memory.",
38
+ )
39
+ print(result.prepared.prompt)
40
+ ```
41
+
42
+ ## Async Client
43
+
44
+ ```python
45
+ import asyncio
46
+ from memory_layer_client import AsyncMemoryClient, AsyncMemoryRuntimeClient
47
+
48
+ async def main() -> None:
49
+ client = AsyncMemoryClient("http://localhost:3100", api_key="dev-key")
50
+ runtime = AsyncMemoryRuntimeClient(client)
51
+ result = await runtime.run_turn(
52
+ "Track migration status.",
53
+ lambda prepared: "I will keep the migration status in memory.",
54
+ )
55
+ health = await client.health()
56
+ print(result.prepared.context.token_estimate, health.active_turn_count)
57
+ await client.aclose()
58
+
59
+ asyncio.run(main())
60
+ ```
61
+
62
+ ## Scope Resolution
63
+
64
+ Each request can inherit a default scope and override it per call. This matches the multi-tenant routing model used by the HTTP server.
65
+
66
+ `MemoryScope` also supports `collaboration_id`, so Python clients can participate in shared multi-agent workspaces the same way the TypeScript server and SDK do.
67
+
68
+ ## Hosted Runtime And Changes
69
+
70
+ ```python
71
+ from memory_layer_client import MemoryClient, MemoryRuntimeClient
72
+
73
+ client = MemoryClient("http://localhost:3100")
74
+ runtime = MemoryRuntimeClient(client)
75
+
76
+ knowledge = client.list_knowledge(limit=20)
77
+ detail = client.inspect_knowledge(knowledge.items[0]["id"])
78
+ changes = client.poll_changes("2026-03-01T00:00:00Z", scope_level="workspace")
79
+ cross_scope = client.search_cross_scope("rollback", scope_level="workspace")
80
+ prepared = runtime.before_model_call("What changed in the shared workspace?")
81
+ print(prepared.prompt)
82
+ for event in client.stream_events(event_types=["knowledge_change"], scope_level="workspace"):
83
+ print(event.type, event.meta)
84
+ break
85
+ ```
86
+
87
+ ## CLI
88
+
89
+ ```bash
90
+ memory-layer-client --base-url http://localhost:3100 health
91
+ memory-layer-client --base-url http://localhost:3100 search "rollback checklist"
92
+ memory-layer-client --base-url http://localhost:3100 inspect-knowledge --limit 10
93
+ memory-layer-client --base-url http://localhost:3100 run-reverification --admin-key secret
94
+ ```
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-memory-layer-client
3
+ Version: 4.0.0
4
+ Summary: Python REST client for the memory-layer server
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/gstarling/memory-layer
7
+ Project-URL: Documentation, https://github.com/gstarling/memory-layer/tree/main/clients/python
8
+ Project-URL: Issues, https://github.com/gstarling/memory-layer/issues
9
+ Keywords: ai,memory,agent,retrieval
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: httpx<1.0.0,>=0.27.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: build<2.0.0,>=1.2.0; extra == "dev"
23
+ Requires-Dist: pytest<9.0.0,>=8.3.0; extra == "dev"
24
+ Requires-Dist: pytest-asyncio<1.0.0,>=0.24.0; extra == "dev"
25
+ Requires-Dist: pytest-httpx<1.0.0,>=0.35.0; extra == "dev"
26
+ Requires-Dist: ruff<1.0.0,>=0.7.0; extra == "dev"
27
+
28
+ # memory-layer-client
29
+
30
+ Python client for the `memory-layer` HTTP service.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pip install memory-layer-client
36
+ ```
37
+
38
+ For local development and tests:
39
+
40
+ ```bash
41
+ pip install -e '.[dev]'
42
+ pytest
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ```python
48
+ from memory_layer_client import MemoryClient, MemoryRuntimeClient, MemoryScope
49
+
50
+ client = MemoryClient(
51
+ "http://localhost:3100",
52
+ api_key="dev-key",
53
+ default_scope=MemoryScope(
54
+ tenant_id="acme",
55
+ system_id="python-worker",
56
+ collaboration_id="release-42",
57
+ scope_id="run-42",
58
+ ),
59
+ )
60
+ runtime = MemoryRuntimeClient(client)
61
+
62
+ result = runtime.run_turn(
63
+ "Remember that deployments must stay blue-green.",
64
+ lambda prepared: "Stored. I will keep rollout constraints in memory.",
65
+ )
66
+ print(result.prepared.prompt)
67
+ ```
68
+
69
+ ## Async Client
70
+
71
+ ```python
72
+ import asyncio
73
+ from memory_layer_client import AsyncMemoryClient, AsyncMemoryRuntimeClient
74
+
75
+ async def main() -> None:
76
+ client = AsyncMemoryClient("http://localhost:3100", api_key="dev-key")
77
+ runtime = AsyncMemoryRuntimeClient(client)
78
+ result = await runtime.run_turn(
79
+ "Track migration status.",
80
+ lambda prepared: "I will keep the migration status in memory.",
81
+ )
82
+ health = await client.health()
83
+ print(result.prepared.context.token_estimate, health.active_turn_count)
84
+ await client.aclose()
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ ## Scope Resolution
90
+
91
+ Each request can inherit a default scope and override it per call. This matches the multi-tenant routing model used by the HTTP server.
92
+
93
+ `MemoryScope` also supports `collaboration_id`, so Python clients can participate in shared multi-agent workspaces the same way the TypeScript server and SDK do.
94
+
95
+ ## Hosted Runtime And Changes
96
+
97
+ ```python
98
+ from memory_layer_client import MemoryClient, MemoryRuntimeClient
99
+
100
+ client = MemoryClient("http://localhost:3100")
101
+ runtime = MemoryRuntimeClient(client)
102
+
103
+ knowledge = client.list_knowledge(limit=20)
104
+ detail = client.inspect_knowledge(knowledge.items[0]["id"])
105
+ changes = client.poll_changes("2026-03-01T00:00:00Z", scope_level="workspace")
106
+ cross_scope = client.search_cross_scope("rollback", scope_level="workspace")
107
+ prepared = runtime.before_model_call("What changed in the shared workspace?")
108
+ print(prepared.prompt)
109
+ for event in client.stream_events(event_types=["knowledge_change"], scope_level="workspace"):
110
+ print(event.type, event.meta)
111
+ break
112
+ ```
113
+
114
+ ## CLI
115
+
116
+ ```bash
117
+ memory-layer-client --base-url http://localhost:3100 health
118
+ memory-layer-client --base-url http://localhost:3100 search "rollback checklist"
119
+ memory-layer-client --base-url http://localhost:3100 inspect-knowledge --limit 10
120
+ memory-layer-client --base-url http://localhost:3100 run-reverification --admin-key secret
121
+ ```
@@ -0,0 +1,19 @@
1
+ README.md
2
+ pyproject.toml
3
+ ai_memory_layer_client.egg-info/PKG-INFO
4
+ ai_memory_layer_client.egg-info/SOURCES.txt
5
+ ai_memory_layer_client.egg-info/dependency_links.txt
6
+ ai_memory_layer_client.egg-info/entry_points.txt
7
+ ai_memory_layer_client.egg-info/requires.txt
8
+ ai_memory_layer_client.egg-info/top_level.txt
9
+ memory_layer_client/__init__.py
10
+ memory_layer_client/cli.py
11
+ memory_layer_client/client.py
12
+ memory_layer_client/models.py
13
+ memory_layer_client/py.typed
14
+ memory_layer_client/runtime.py
15
+ tests/test_async_client.py
16
+ tests/test_cli.py
17
+ tests/test_client.py
18
+ tests/test_models.py
19
+ tests/test_runtime.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ memory-layer-client = memory_layer_client.cli:main
@@ -0,0 +1,8 @@
1
+ httpx<1.0.0,>=0.27.0
2
+
3
+ [dev]
4
+ build<2.0.0,>=1.2.0
5
+ pytest<9.0.0,>=8.3.0
6
+ pytest-asyncio<1.0.0,>=0.24.0
7
+ pytest-httpx<1.0.0,>=0.35.0
8
+ ruff<1.0.0,>=0.7.0
@@ -0,0 +1,114 @@
1
+ """memory-layer-client: Python REST client for the memory-layer server."""
2
+
3
+ from .client import AsyncMemoryClient, MemoryClient, MemoryLayerError
4
+ from .models import (
5
+ ActorRef,
6
+ Association,
7
+ AssociationGraph,
8
+ AssociationNode,
9
+ AuditListResponse,
10
+ ChangeListResponse,
11
+ CoordinationState,
12
+ CognitiveMemoryItem,
13
+ CognitiveSearchHit,
14
+ CognitiveSearchResult,
15
+ CompactionLogListResponse,
16
+ CompactResponse,
17
+ ContextResponse,
18
+ CreatedResource,
19
+ DueReverificationResponse,
20
+ EpisodeRecap,
21
+ EpisodeSearchResponse,
22
+ EpisodeSourceReference,
23
+ EpisodeSummary,
24
+ HandoffListResponse,
25
+ HandoffRecord,
26
+ HealthResponse,
27
+ KnowledgeInspectionResponse,
28
+ KnowledgeListResponse,
29
+ MaintenanceResponse,
30
+ MemoryEvent,
31
+ MemoryEventRecord,
32
+ MemoryScope,
33
+ MonitorResponse,
34
+ Playbook,
35
+ PlaybookRevision,
36
+ PlaybookSearchHit,
37
+ PreparedMemoryTurn,
38
+ Profile,
39
+ ProfileEntry,
40
+ ReadyResponse,
41
+ ReflectResult,
42
+ ReverificationResponse,
43
+ RevisePlaybookResult,
44
+ RuntimeTurnResult,
45
+ SearchResponse,
46
+ StoredExchange,
47
+ StoredTurn,
48
+ TemporalDiffResponse,
49
+ TemporalEventLogResponse,
50
+ TemporalStateResponse,
51
+ TrustAssessmentResponse,
52
+ WorkClaim,
53
+ WorkClaimListResponse,
54
+ )
55
+ from .runtime import AsyncMemoryRuntimeClient, MemoryRuntimeClient, format_prompt
56
+
57
+ __all__ = [
58
+ "ActorRef",
59
+ "Association",
60
+ "AssociationGraph",
61
+ "AssociationNode",
62
+ "AsyncMemoryClient",
63
+ "AsyncMemoryRuntimeClient",
64
+ "AuditListResponse",
65
+ "ChangeListResponse",
66
+ "CoordinationState",
67
+ "CognitiveMemoryItem",
68
+ "CognitiveSearchHit",
69
+ "CognitiveSearchResult",
70
+ "CompactResponse",
71
+ "CompactionLogListResponse",
72
+ "ContextResponse",
73
+ "CreatedResource",
74
+ "DueReverificationResponse",
75
+ "EpisodeRecap",
76
+ "EpisodeSearchResponse",
77
+ "EpisodeSourceReference",
78
+ "EpisodeSummary",
79
+ "HandoffListResponse",
80
+ "HandoffRecord",
81
+ "HealthResponse",
82
+ "KnowledgeInspectionResponse",
83
+ "KnowledgeListResponse",
84
+ "MaintenanceResponse",
85
+ "MemoryEvent",
86
+ "MemoryEventRecord",
87
+ "MemoryClient",
88
+ "MemoryLayerError",
89
+ "MemoryScope",
90
+ "MemoryRuntimeClient",
91
+ "MonitorResponse",
92
+ "Playbook",
93
+ "PlaybookRevision",
94
+ "PlaybookSearchHit",
95
+ "PreparedMemoryTurn",
96
+ "Profile",
97
+ "ProfileEntry",
98
+ "ReadyResponse",
99
+ "ReflectResult",
100
+ "ReverificationResponse",
101
+ "RevisePlaybookResult",
102
+ "RuntimeTurnResult",
103
+ "SearchResponse",
104
+ "StoredExchange",
105
+ "StoredTurn",
106
+ "TemporalDiffResponse",
107
+ "TemporalEventLogResponse",
108
+ "TemporalStateResponse",
109
+ "TrustAssessmentResponse",
110
+ "WorkClaim",
111
+ "WorkClaimListResponse",
112
+ "format_prompt",
113
+ ]
114
+ __version__ = "4.0.0"
@@ -0,0 +1,199 @@
1
+ """Command-line entry point for the memory-layer Python client."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ from dataclasses import asdict, is_dataclass
8
+ from typing import Any
9
+
10
+ from .client import MemoryClient
11
+ from .models import MemoryScope
12
+
13
+
14
+ def _add_scope_arguments(parser: argparse.ArgumentParser) -> None:
15
+ parser.add_argument("--tenant-id")
16
+ parser.add_argument("--system-id")
17
+ parser.add_argument("--scope-id")
18
+ parser.add_argument("--workspace-id")
19
+ parser.add_argument("--collaboration-id")
20
+
21
+
22
+ def _resolve_scope(args: argparse.Namespace) -> MemoryScope | None:
23
+ if args.tenant_id and args.system_id and args.scope_id:
24
+ return MemoryScope(
25
+ tenant_id=args.tenant_id,
26
+ system_id=args.system_id,
27
+ scope_id=args.scope_id,
28
+ workspace_id=args.workspace_id,
29
+ collaboration_id=args.collaboration_id,
30
+ )
31
+ return None
32
+
33
+
34
+ def _to_payload(value: Any) -> Any:
35
+ if is_dataclass(value):
36
+ return asdict(value)
37
+ return value
38
+
39
+
40
+ def build_parser() -> argparse.ArgumentParser:
41
+ parser = argparse.ArgumentParser(prog="memory-layer-client")
42
+ parser.add_argument("--base-url", default="http://localhost:3100")
43
+ parser.add_argument("--api-key")
44
+ parser.add_argument("--admin-key")
45
+ parser.add_argument("--timeout", type=float, default=10.0)
46
+
47
+ subparsers = parser.add_subparsers(dest="command", required=True)
48
+
49
+ store_turn = subparsers.add_parser("store-turn")
50
+ store_turn.add_argument("role")
51
+ store_turn.add_argument("content")
52
+ store_turn.add_argument("--actor")
53
+ _add_scope_arguments(store_turn)
54
+
55
+ store_exchange = subparsers.add_parser("store-exchange")
56
+ store_exchange.add_argument("user_content")
57
+ store_exchange.add_argument("assistant_content")
58
+ _add_scope_arguments(store_exchange)
59
+
60
+ context = subparsers.add_parser("context")
61
+ context.add_argument("--query")
62
+ _add_scope_arguments(context)
63
+
64
+ search = subparsers.add_parser("search")
65
+ search.add_argument("query")
66
+ search.add_argument("--limit", type=int)
67
+ _add_scope_arguments(search)
68
+
69
+ cross_scope = subparsers.add_parser("search-cross-scope")
70
+ cross_scope.add_argument("query")
71
+ cross_scope.add_argument("--scope-level", default="workspace")
72
+ cross_scope.add_argument("--limit", type=int)
73
+ _add_scope_arguments(cross_scope)
74
+
75
+ learn_fact = subparsers.add_parser("learn-fact")
76
+ learn_fact.add_argument("fact")
77
+ learn_fact.add_argument("fact_type")
78
+ learn_fact.add_argument("--confidence", default="high")
79
+ _add_scope_arguments(learn_fact)
80
+
81
+ for name in ("health", "live", "ready", "inspect-monitor"):
82
+ subparser = subparsers.add_parser(name)
83
+ _add_scope_arguments(subparser)
84
+
85
+ changes = subparsers.add_parser("changes")
86
+ changes.add_argument("--since", required=True)
87
+ changes.add_argument("--scope-level", default="scope")
88
+ _add_scope_arguments(changes)
89
+
90
+ inspect_knowledge = subparsers.add_parser("inspect-knowledge")
91
+ inspect_knowledge.add_argument("--knowledge-id", type=int)
92
+ inspect_knowledge.add_argument("--limit", type=int)
93
+ inspect_knowledge.add_argument("--cursor", type=int)
94
+ _add_scope_arguments(inspect_knowledge)
95
+
96
+ audits = subparsers.add_parser("inspect-audits")
97
+ audits.add_argument("--knowledge-id", type=int)
98
+ audits.add_argument("--limit", type=int)
99
+ _add_scope_arguments(audits)
100
+
101
+ compactions = subparsers.add_parser("inspect-compactions")
102
+ compactions.add_argument("--limit", type=int)
103
+ _add_scope_arguments(compactions)
104
+
105
+ inspect_reverification = subparsers.add_parser("inspect-reverification")
106
+ inspect_reverification.add_argument("--limit", type=int)
107
+ _add_scope_arguments(inspect_reverification)
108
+
109
+ run_reverification = subparsers.add_parser("run-reverification")
110
+ run_reverification.add_argument("--limit", type=int)
111
+ _add_scope_arguments(run_reverification)
112
+
113
+ reverify_one = subparsers.add_parser("reverify-knowledge")
114
+ reverify_one.add_argument("knowledge_id", type=int)
115
+ _add_scope_arguments(reverify_one)
116
+
117
+ return parser
118
+
119
+
120
+ def main(argv: list[str] | None = None) -> int:
121
+ parser = build_parser()
122
+ args = parser.parse_args(argv)
123
+ scope = _resolve_scope(args)
124
+ client = MemoryClient(
125
+ args.base_url,
126
+ api_key=args.api_key,
127
+ default_scope=scope,
128
+ timeout=args.timeout,
129
+ )
130
+ try:
131
+ if args.command == "store-turn":
132
+ result = client.store_turn(args.role, args.content, actor=args.actor, scope=scope)
133
+ elif args.command == "store-exchange":
134
+ result = client.store_exchange(args.user_content, args.assistant_content, scope=scope)
135
+ elif args.command == "context":
136
+ result = client.get_context(query=args.query, scope=scope)
137
+ elif args.command == "search":
138
+ result = client.search(args.query, limit=args.limit, scope=scope)
139
+ elif args.command == "search-cross-scope":
140
+ result = client.search_cross_scope(
141
+ args.query,
142
+ scope_level=args.scope_level,
143
+ limit=args.limit,
144
+ scope=scope,
145
+ )
146
+ elif args.command == "learn-fact":
147
+ result = client.learn_fact(
148
+ args.fact,
149
+ args.fact_type,
150
+ confidence=args.confidence,
151
+ scope=scope,
152
+ )
153
+ elif args.command == "health":
154
+ result = client.health(scope=scope)
155
+ elif args.command == "live":
156
+ result = client.live()
157
+ elif args.command == "ready":
158
+ result = client.ready()
159
+ elif args.command == "changes":
160
+ result = client.poll_changes(args.since, scope_level=args.scope_level, scope=scope)
161
+ elif args.command == "inspect-knowledge":
162
+ if args.knowledge_id is not None:
163
+ result = client.inspect_knowledge(args.knowledge_id, scope=scope)
164
+ else:
165
+ result = client.list_knowledge(limit=args.limit, cursor=args.cursor, scope=scope)
166
+ elif args.command == "inspect-audits":
167
+ result = client.list_audits(
168
+ knowledge_id=args.knowledge_id,
169
+ limit=args.limit,
170
+ scope=scope,
171
+ )
172
+ elif args.command == "inspect-monitor":
173
+ result = client.inspect_monitor(scope=scope)
174
+ elif args.command == "inspect-compactions":
175
+ result = client.inspect_compactions(limit=args.limit, scope=scope)
176
+ elif args.command == "inspect-reverification":
177
+ result = client.inspect_reverification(limit=args.limit, scope=scope)
178
+ elif args.command == "run-reverification":
179
+ result = client.run_reverification(
180
+ limit=args.limit,
181
+ scope=scope,
182
+ admin_key=args.admin_key,
183
+ )
184
+ elif args.command == "reverify-knowledge":
185
+ result = client.reverify_knowledge(
186
+ args.knowledge_id,
187
+ scope=scope,
188
+ admin_key=args.admin_key,
189
+ )
190
+ else:
191
+ parser.error(f"Unknown command: {args.command}")
192
+ print(json.dumps(_to_payload(result), indent=2))
193
+ return 0
194
+ finally:
195
+ client.close()
196
+
197
+
198
+ if __name__ == "__main__":
199
+ raise SystemExit(main())