agentlog-sdk 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,37 @@
1
+ # Build output
2
+ bin/
3
+
4
+ # Go
5
+ *.exe
6
+ *.exe~
7
+ *.dll
8
+ *.so
9
+ *.dylib
10
+ *.test
11
+ *.out
12
+
13
+ # IDE
14
+ .idea/
15
+ .vscode/
16
+ *.swp
17
+ *.swo
18
+ *~
19
+
20
+ # OS
21
+ .DS_Store
22
+ Thumbs.db
23
+
24
+ # Python
25
+ __pycache__/
26
+ *.py[cod]
27
+ *.egg-info/
28
+ .venv/
29
+ .pytest_cache/
30
+ dist/
31
+
32
+ # MkDocs build output
33
+ docs-site/site/
34
+
35
+ # agentlog data (local runtime state)
36
+ *.pid
37
+ *.sock
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agentlog contributors
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,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentlog-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for agentlog - a local-first decision log daemon for agentic workflows
5
+ Project-URL: Homepage, https://byronxlg.github.io/agentlog/
6
+ Project-URL: Documentation, https://byronxlg.github.io/agentlog/docs/
7
+ Project-URL: Repository, https://github.com/byronxlg/agentlog
8
+ Project-URL: Issues, https://github.com/byronxlg/agentlog/issues
9
+ Author: agentlog contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agent,agentic,decision-log,llm,logging
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+
26
+ # agentlog Python SDK
27
+
28
+ Python client for [agentlog](https://github.com/byronxlg/agentlog) - a local-first decision log daemon for agentic workflows.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install agentlog-sdk
34
+ ```
35
+
36
+ ## Quickstart
37
+
38
+ ```python
39
+ import agentlog
40
+
41
+ agentlog.write("decision", "Use PostgreSQL for persistence")
42
+ entries = agentlog.query("database")
43
+ ```
44
+
45
+ ## Requirements
46
+
47
+ - Python 3.9+
48
+ - A running `agentlogd` daemon (see the main project README)
49
+
50
+ ## Usage
51
+
52
+ ### Writing entries
53
+
54
+ ```python
55
+ import agentlog
56
+
57
+ # Write a decision entry (session created automatically)
58
+ agentlog.write(
59
+ "decision",
60
+ "Use Redis for caching",
61
+ body="Redis provides sub-millisecond reads and built-in TTL support.",
62
+ tags=["infrastructure", "caching"],
63
+ files=["config/redis.yaml"],
64
+ )
65
+
66
+ # Supported entry types: decision, attempt_failed, deferred, assumption, question
67
+ agentlog.write("assumption", "All users have Python 3.9+")
68
+ agentlog.write("question", "Should we use async or sync HTTP client?")
69
+ ```
70
+
71
+ ### Searching entries
72
+
73
+ ```python
74
+ # Full-text search
75
+ results = agentlog.query("database migration")
76
+
77
+ # Search with filters
78
+ results = agentlog.query("caching", type="decision", limit=5)
79
+ ```
80
+
81
+ ### Listing entries
82
+
83
+ ```python
84
+ # List entries by type
85
+ entries = agentlog.log(type="decision")
86
+
87
+ # List entries by session
88
+ entries = agentlog.log(session="your-session-id")
89
+
90
+ # List entries by tag
91
+ entries = agentlog.log(tag="infrastructure")
92
+
93
+ # List entries from the last hour
94
+ entries = agentlog.log(since="1h")
95
+ ```
96
+
97
+ ### Getting context for prompts
98
+
99
+ ```python
100
+ # Get a formatted text block for prompt injection
101
+ context = agentlog.context(query="authentication")
102
+ print(context)
103
+ # Output:
104
+ # # Recent decisions
105
+ #
106
+ # ## [decision] Use JWT for API auth (2026-03-15 10:30)
107
+ # JWTs are stateless and work well with our microservices architecture.
108
+ # Tags: auth, api
109
+ # Files: internal/auth/jwt.go
110
+ ```
111
+
112
+ ### Using the client class directly
113
+
114
+ ```python
115
+ from agentlog import AgentlogClient
116
+
117
+ # Custom socket path
118
+ client = AgentlogClient(agentlog_dir="/custom/path")
119
+
120
+ # Or explicit socket path
121
+ client = AgentlogClient(socket_path="/tmp/agentlogd.sock")
122
+
123
+ # All methods are available on the client instance
124
+ entry_id = client.write("decision", "Use gRPC for internal services")
125
+ ```
126
+
127
+ ### Configuration
128
+
129
+ The SDK looks for the daemon socket at `~/.agentlog/agentlogd.sock` by default.
130
+ Override this with:
131
+
132
+ - The `AGENTLOG_DIR` environment variable
133
+ - The `agentlog_dir` constructor argument
134
+ - The `socket_path` constructor argument (takes precedence)
135
+
136
+ ### Error handling
137
+
138
+ ```python
139
+ from agentlog import AgentlogError, ConnectionError, DaemonNotRunning
140
+
141
+ try:
142
+ agentlog.write("decision", "Test entry")
143
+ except DaemonNotRunning:
144
+ print("Start the daemon first: agentlog start")
145
+ except ConnectionError as e:
146
+ print(f"Connection failed: {e}")
147
+ except AgentlogError as e:
148
+ print(f"Unexpected error: {e}")
149
+ ```
150
+
151
+ ## Development
152
+
153
+ ```bash
154
+ # Install in development mode
155
+ pip install -e sdk/python/
156
+
157
+ # Run tests
158
+ python -m pytest sdk/python/tests/ -v
159
+
160
+ # Run only unit tests (no daemon required)
161
+ python -m pytest sdk/python/tests/test_client.py -v
162
+ ```
@@ -0,0 +1,137 @@
1
+ # agentlog Python SDK
2
+
3
+ Python client for [agentlog](https://github.com/byronxlg/agentlog) - a local-first decision log daemon for agentic workflows.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install agentlog-sdk
9
+ ```
10
+
11
+ ## Quickstart
12
+
13
+ ```python
14
+ import agentlog
15
+
16
+ agentlog.write("decision", "Use PostgreSQL for persistence")
17
+ entries = agentlog.query("database")
18
+ ```
19
+
20
+ ## Requirements
21
+
22
+ - Python 3.9+
23
+ - A running `agentlogd` daemon (see the main project README)
24
+
25
+ ## Usage
26
+
27
+ ### Writing entries
28
+
29
+ ```python
30
+ import agentlog
31
+
32
+ # Write a decision entry (session created automatically)
33
+ agentlog.write(
34
+ "decision",
35
+ "Use Redis for caching",
36
+ body="Redis provides sub-millisecond reads and built-in TTL support.",
37
+ tags=["infrastructure", "caching"],
38
+ files=["config/redis.yaml"],
39
+ )
40
+
41
+ # Supported entry types: decision, attempt_failed, deferred, assumption, question
42
+ agentlog.write("assumption", "All users have Python 3.9+")
43
+ agentlog.write("question", "Should we use async or sync HTTP client?")
44
+ ```
45
+
46
+ ### Searching entries
47
+
48
+ ```python
49
+ # Full-text search
50
+ results = agentlog.query("database migration")
51
+
52
+ # Search with filters
53
+ results = agentlog.query("caching", type="decision", limit=5)
54
+ ```
55
+
56
+ ### Listing entries
57
+
58
+ ```python
59
+ # List entries by type
60
+ entries = agentlog.log(type="decision")
61
+
62
+ # List entries by session
63
+ entries = agentlog.log(session="your-session-id")
64
+
65
+ # List entries by tag
66
+ entries = agentlog.log(tag="infrastructure")
67
+
68
+ # List entries from the last hour
69
+ entries = agentlog.log(since="1h")
70
+ ```
71
+
72
+ ### Getting context for prompts
73
+
74
+ ```python
75
+ # Get a formatted text block for prompt injection
76
+ context = agentlog.context(query="authentication")
77
+ print(context)
78
+ # Output:
79
+ # # Recent decisions
80
+ #
81
+ # ## [decision] Use JWT for API auth (2026-03-15 10:30)
82
+ # JWTs are stateless and work well with our microservices architecture.
83
+ # Tags: auth, api
84
+ # Files: internal/auth/jwt.go
85
+ ```
86
+
87
+ ### Using the client class directly
88
+
89
+ ```python
90
+ from agentlog import AgentlogClient
91
+
92
+ # Custom socket path
93
+ client = AgentlogClient(agentlog_dir="/custom/path")
94
+
95
+ # Or explicit socket path
96
+ client = AgentlogClient(socket_path="/tmp/agentlogd.sock")
97
+
98
+ # All methods are available on the client instance
99
+ entry_id = client.write("decision", "Use gRPC for internal services")
100
+ ```
101
+
102
+ ### Configuration
103
+
104
+ The SDK looks for the daemon socket at `~/.agentlog/agentlogd.sock` by default.
105
+ Override this with:
106
+
107
+ - The `AGENTLOG_DIR` environment variable
108
+ - The `agentlog_dir` constructor argument
109
+ - The `socket_path` constructor argument (takes precedence)
110
+
111
+ ### Error handling
112
+
113
+ ```python
114
+ from agentlog import AgentlogError, ConnectionError, DaemonNotRunning
115
+
116
+ try:
117
+ agentlog.write("decision", "Test entry")
118
+ except DaemonNotRunning:
119
+ print("Start the daemon first: agentlog start")
120
+ except ConnectionError as e:
121
+ print(f"Connection failed: {e}")
122
+ except AgentlogError as e:
123
+ print(f"Unexpected error: {e}")
124
+ ```
125
+
126
+ ## Development
127
+
128
+ ```bash
129
+ # Install in development mode
130
+ pip install -e sdk/python/
131
+
132
+ # Run tests
133
+ python -m pytest sdk/python/tests/ -v
134
+
135
+ # Run only unit tests (no daemon required)
136
+ python -m pytest sdk/python/tests/test_client.py -v
137
+ ```
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "agentlog-sdk"
7
+ version = "0.1.0"
8
+ description = "Python SDK for agentlog - a local-first decision log daemon for agentic workflows"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "agentlog contributors" },
14
+ ]
15
+ keywords = ["agent", "logging", "decision-log", "llm", "agentic"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://byronxlg.github.io/agentlog/"
31
+ Documentation = "https://byronxlg.github.io/agentlog/docs/"
32
+ Repository = "https://github.com/byronxlg/agentlog"
33
+ Issues = "https://github.com/byronxlg/agentlog/issues"
34
+
35
+ [tool.hatch.build.targets.wheel]
36
+ packages = ["src/agentlog"]
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["tests"]
@@ -0,0 +1,117 @@
1
+ """agentlog - Python SDK for the agentlog decision log daemon.
2
+
3
+ Usage::
4
+
5
+ import agentlog
6
+
7
+ agentlog.write("decision", "Use PostgreSQL for persistence")
8
+ entries = agentlog.query("database")
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from .client import AgentlogClient, VALID_ENTRY_TYPES
14
+ from .errors import AgentlogError, ConnectionError, DaemonNotRunning
15
+
16
+ __all__ = [
17
+ "AgentlogClient",
18
+ "AgentlogError",
19
+ "ConnectionError",
20
+ "DaemonNotRunning",
21
+ "VALID_ENTRY_TYPES",
22
+ "write",
23
+ "query",
24
+ "log",
25
+ "context",
26
+ ]
27
+
28
+ _default_client: AgentlogClient | None = None
29
+
30
+
31
+ def _get_default_client() -> AgentlogClient:
32
+ """Return the module-level default client, creating it on first use."""
33
+ global _default_client
34
+ if _default_client is None:
35
+ _default_client = AgentlogClient()
36
+ return _default_client
37
+
38
+
39
+ def write(
40
+ type: str,
41
+ title: str,
42
+ body: str | None = None,
43
+ tags: list[str] | None = None,
44
+ files: list[str] | None = None,
45
+ session: str | None = None,
46
+ ) -> str:
47
+ """Write a decision entry to the log.
48
+
49
+ Convenience wrapper around :meth:`AgentlogClient.write` using the
50
+ module-level default client.
51
+
52
+ Args:
53
+ type: Entry type (decision, attempt_failed, deferred, assumption, question).
54
+ title: Short summary of the decision.
55
+ body: Optional longer description.
56
+ tags: Optional list of tags.
57
+ files: Optional list of file references.
58
+ session: Optional session ID.
59
+
60
+ Returns:
61
+ The ID of the written entry.
62
+ """
63
+ return _get_default_client().write(
64
+ type=type, title=title, body=body, tags=tags, files=files, session=session,
65
+ )
66
+
67
+
68
+ def query(
69
+ text: str,
70
+ type: str | None = None,
71
+ session: str | None = None,
72
+ tag: str | None = None,
73
+ file: str | None = None,
74
+ since: str | None = None,
75
+ until: str | None = None,
76
+ limit: int = 20,
77
+ ) -> list[dict]:
78
+ """Full-text search for entries.
79
+
80
+ Convenience wrapper around :meth:`AgentlogClient.query`.
81
+ """
82
+ return _get_default_client().query(
83
+ text=text, type=type, session=session, tag=tag, file=file,
84
+ since=since, until=until, limit=limit,
85
+ )
86
+
87
+
88
+ def log(
89
+ type: str | None = None,
90
+ session: str | None = None,
91
+ tag: str | None = None,
92
+ file: str | None = None,
93
+ since: str | None = None,
94
+ until: str | None = None,
95
+ limit: int = 50,
96
+ offset: int = 0,
97
+ ) -> list[dict]:
98
+ """List entries with filters.
99
+
100
+ Convenience wrapper around :meth:`AgentlogClient.log`.
101
+ """
102
+ return _get_default_client().log(
103
+ type=type, session=session, tag=tag, file=file,
104
+ since=since, until=until, limit=limit, offset=offset,
105
+ )
106
+
107
+
108
+ def context(
109
+ query: str | None = None,
110
+ session: str | None = None,
111
+ limit: int = 10,
112
+ ) -> str:
113
+ """Return a structured context string suitable for prompt injection.
114
+
115
+ Convenience wrapper around :meth:`AgentlogClient.context`.
116
+ """
117
+ return _get_default_client().context(query=query, session=session, limit=limit)