dobby-collector 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,20 @@
1
+ # Virtual environments
2
+ .venv/
3
+ venv/
4
+ env/
5
+
6
+ # Build artifacts
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ __pycache__/
11
+ *.pyc
12
+ *.pyo
13
+
14
+ # Tool caches
15
+ .pytest_cache/
16
+ .mypy_cache/
17
+ .ruff_cache/
18
+ .tox/
19
+ .coverage
20
+ htmlcov/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dobby AI, Inc.
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,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: dobby-collector
3
+ Version: 0.1.0
4
+ Summary: Telemetry collector for AI agents — stream runs, tools, LLM calls, and chains to the Dobby AI Control Plane for governance
5
+ Project-URL: Homepage, https://dobby-ai.com
6
+ Project-URL: Documentation, https://docs.dobby-ai.com/sdk/python-collector
7
+ Project-URL: Repository, https://github.com/gil-dobby/repo-dobby
8
+ Project-URL: Issues, https://github.com/gil-dobby/repo-dobby/issues
9
+ Author-email: Dobby AI <dev@dobby-ai.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agents,ai,autogen,compliance,crewai,governance,langchain,observability,telemetry
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: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: httpx>=0.25.0
25
+ Requires-Dist: uuid-utils>=0.7.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.8.0; extra == 'dev'
28
+ Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
29
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
30
+ Requires-Dist: ruff>=0.3.0; extra == 'dev'
31
+ Provides-Extra: langchain
32
+ Requires-Dist: langchain-core>=0.2.0; extra == 'langchain'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # dobby-collector
36
+
37
+ > Telemetry collector for AI agents — stream runs, tools, LLM calls, and chains to the **[Dobby AI Control Plane](https://dobby-ai.com)** for governance and compliance.
38
+
39
+ [![Status](https://img.shields.io/badge/status-alpha-orange.svg)](https://github.com/gil-dobby/repo-dobby)
40
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/)
41
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
42
+
43
+ `dobby-collector` is the **customer-side** Python package for sending telemetry from any AI agent — LangChain, CrewAI, AutoGen, plain OpenAI/Anthropic SDKs, or custom code — to Dobby's governance plane. Every captured run gets evaluated by the Policy Scanner against your imported Compliance Packs (SOC 2, GDPR, EU AI Act, etc.) and surfaces violations in the Dobby dashboard.
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install dobby-collector
49
+ ```
50
+
51
+ ## Quickstart
52
+
53
+ ```python
54
+ from dobby_collector import init, track, span, start_run, end_run
55
+
56
+ # 1. Initialize once at agent startup
57
+ init(
58
+ api_key="dsdk_...", # Generate at /dashboard/workloads/connect/python-sdk
59
+ connector_id="wc_...", # Same wizard hands you the connector ID
60
+ framework="langchain", # or 'crewai' | 'autogen' | omit to auto-detect
61
+ )
62
+
63
+ # 2. Decorate tool functions
64
+ @track(name="search_database", kind="tool")
65
+ def search_db(query: str) -> list:
66
+ return db.execute(query)
67
+
68
+ # 3. Use spans for fine-grained capture
69
+ with span("retrieval", kind="tool", inputs={"query": "find AI startups"}):
70
+ docs = retriever.invoke("find AI startups")
71
+
72
+ # 4. Wrap agent invocations in start/end_run
73
+ run = start_run(name="weekly_report", inputs={"week": "2026-W19"})
74
+ try:
75
+ output = my_agent.run("Generate the weekly report")
76
+ end_run(run, outputs={"report": output}, status="success")
77
+ except Exception as e:
78
+ end_run(run, error=str(e), status="error")
79
+ raise
80
+ ```
81
+
82
+ The SDK runs a background thread that flushes events every 10 seconds (or immediately on terminal `run.completed` / `run.failed` events). Telemetry **never blocks** your agent — buffer overflow drops the oldest events silently.
83
+
84
+ ## What gets captured
85
+
86
+ | What | When | Captured fields |
87
+ |---|---|---|
88
+ | **Run boundaries** | `start_run` / `end_run` | inputs, outputs, status, duration |
89
+ | **Tool calls** | `@track(kind="tool")` or `span(kind="tool")` | tool name, args, output, duration |
90
+ | **LLM calls** | LangChain auto-instrument (Phase 2b), or `@track(kind="llm")` | model, prompt, completion, tokens, latency |
91
+ | **Custom spans** | `@track()` / `span()` | name, inputs, outputs, duration |
92
+
93
+ ## Config reference
94
+
95
+ ```python
96
+ init(
97
+ api_key="dsdk_...", # REQUIRED — or set DOBBY_API_KEY env var
98
+ connector_id="wc_...", # REQUIRED — or set DOBBY_CONNECTOR_ID env var
99
+ base_url="https://dobby-ai.com", # Override for self-hosted; or DOBBY_BASE_URL env
100
+ flush_interval_seconds=10.0, # How often the sender thread flushes
101
+ max_buffer_events=10_000, # Ring buffer cap (oldest dropped on overflow)
102
+ framework="auto", # Hint or pin: 'langchain' | 'crewai' | 'autogen'
103
+ host_fingerprint=None, # Optional hostname/container ID for multi-replica
104
+ pii_redact=False, # Opt-in: redact emails/SSNs/credit cards (Phase 2b)
105
+ exclude_fields=[], # Fields to scrub from `data` payloads (Phase 2b)
106
+ )
107
+ ```
108
+
109
+ ## Environment variables
110
+
111
+ The SDK reads these as fallbacks for `init()` args:
112
+
113
+ | Env var | Default | Purpose |
114
+ |---|---|---|
115
+ | `DOBBY_API_KEY` | — | Connector bearer token (`dsdk_*`) — minted by the wizard |
116
+ | `DOBBY_CONNECTOR_ID` | — | Workload connector ID (`wc_*`) |
117
+ | `DOBBY_BASE_URL` | `https://dobby-ai.com` | Dobby control-plane URL |
118
+
119
+ Set them in your deployment config and skip the corresponding `init()` args.
120
+
121
+ ## Lifecycle
122
+
123
+ ```python
124
+ from dobby_collector import init, shutdown
125
+
126
+ init(...)
127
+ # ... your agent runs ...
128
+ shutdown(timeout_seconds=5.0) # Drains buffer + stops sender thread
129
+ ```
130
+
131
+ `shutdown()` auto-fires via `atexit` if you forget, but call it explicitly when possible — `atexit` hooks have less time to drain before SIGTERM.
132
+
133
+ ## Status
134
+
135
+ **Phase 2a (this release):** Manual instrumentation API — `init`, `track`, `span`, `start_run`, `end_run`, `shutdown`. In-memory ring buffer + background sender + HTTP retries.
136
+
137
+ **Phase 2b (next):**
138
+ - LangChain auto-instrument via `BaseCallbackHandler` — zero code changes for LangChain agents
139
+ - DLQ to local SQLite — events survive network outages
140
+
141
+ **Phase 4:** CrewAI / AutoGen / OpenAI SDK / Anthropic SDK auto-instrument.
142
+
143
+ ## License
144
+
145
+ MIT — see [LICENSE](LICENSE).
146
+
147
+ ## Links
148
+
149
+ - Full spec: [docs/spikes/dobby-collector-sdk-spec.md](https://github.com/gil-dobby/repo-dobby/blob/main/docs/spikes/dobby-collector-sdk-spec.md)
150
+ - Dobby AI Platform: [dobby-ai.com](https://dobby-ai.com)
151
+ - Documentation: [docs.dobby-ai.com/sdk/python-collector](https://docs.dobby-ai.com/sdk/python-collector)
@@ -0,0 +1,117 @@
1
+ # dobby-collector
2
+
3
+ > Telemetry collector for AI agents — stream runs, tools, LLM calls, and chains to the **[Dobby AI Control Plane](https://dobby-ai.com)** for governance and compliance.
4
+
5
+ [![Status](https://img.shields.io/badge/status-alpha-orange.svg)](https://github.com/gil-dobby/repo-dobby)
6
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/)
7
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
8
+
9
+ `dobby-collector` is the **customer-side** Python package for sending telemetry from any AI agent — LangChain, CrewAI, AutoGen, plain OpenAI/Anthropic SDKs, or custom code — to Dobby's governance plane. Every captured run gets evaluated by the Policy Scanner against your imported Compliance Packs (SOC 2, GDPR, EU AI Act, etc.) and surfaces violations in the Dobby dashboard.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install dobby-collector
15
+ ```
16
+
17
+ ## Quickstart
18
+
19
+ ```python
20
+ from dobby_collector import init, track, span, start_run, end_run
21
+
22
+ # 1. Initialize once at agent startup
23
+ init(
24
+ api_key="dsdk_...", # Generate at /dashboard/workloads/connect/python-sdk
25
+ connector_id="wc_...", # Same wizard hands you the connector ID
26
+ framework="langchain", # or 'crewai' | 'autogen' | omit to auto-detect
27
+ )
28
+
29
+ # 2. Decorate tool functions
30
+ @track(name="search_database", kind="tool")
31
+ def search_db(query: str) -> list:
32
+ return db.execute(query)
33
+
34
+ # 3. Use spans for fine-grained capture
35
+ with span("retrieval", kind="tool", inputs={"query": "find AI startups"}):
36
+ docs = retriever.invoke("find AI startups")
37
+
38
+ # 4. Wrap agent invocations in start/end_run
39
+ run = start_run(name="weekly_report", inputs={"week": "2026-W19"})
40
+ try:
41
+ output = my_agent.run("Generate the weekly report")
42
+ end_run(run, outputs={"report": output}, status="success")
43
+ except Exception as e:
44
+ end_run(run, error=str(e), status="error")
45
+ raise
46
+ ```
47
+
48
+ The SDK runs a background thread that flushes events every 10 seconds (or immediately on terminal `run.completed` / `run.failed` events). Telemetry **never blocks** your agent — buffer overflow drops the oldest events silently.
49
+
50
+ ## What gets captured
51
+
52
+ | What | When | Captured fields |
53
+ |---|---|---|
54
+ | **Run boundaries** | `start_run` / `end_run` | inputs, outputs, status, duration |
55
+ | **Tool calls** | `@track(kind="tool")` or `span(kind="tool")` | tool name, args, output, duration |
56
+ | **LLM calls** | LangChain auto-instrument (Phase 2b), or `@track(kind="llm")` | model, prompt, completion, tokens, latency |
57
+ | **Custom spans** | `@track()` / `span()` | name, inputs, outputs, duration |
58
+
59
+ ## Config reference
60
+
61
+ ```python
62
+ init(
63
+ api_key="dsdk_...", # REQUIRED — or set DOBBY_API_KEY env var
64
+ connector_id="wc_...", # REQUIRED — or set DOBBY_CONNECTOR_ID env var
65
+ base_url="https://dobby-ai.com", # Override for self-hosted; or DOBBY_BASE_URL env
66
+ flush_interval_seconds=10.0, # How often the sender thread flushes
67
+ max_buffer_events=10_000, # Ring buffer cap (oldest dropped on overflow)
68
+ framework="auto", # Hint or pin: 'langchain' | 'crewai' | 'autogen'
69
+ host_fingerprint=None, # Optional hostname/container ID for multi-replica
70
+ pii_redact=False, # Opt-in: redact emails/SSNs/credit cards (Phase 2b)
71
+ exclude_fields=[], # Fields to scrub from `data` payloads (Phase 2b)
72
+ )
73
+ ```
74
+
75
+ ## Environment variables
76
+
77
+ The SDK reads these as fallbacks for `init()` args:
78
+
79
+ | Env var | Default | Purpose |
80
+ |---|---|---|
81
+ | `DOBBY_API_KEY` | — | Connector bearer token (`dsdk_*`) — minted by the wizard |
82
+ | `DOBBY_CONNECTOR_ID` | — | Workload connector ID (`wc_*`) |
83
+ | `DOBBY_BASE_URL` | `https://dobby-ai.com` | Dobby control-plane URL |
84
+
85
+ Set them in your deployment config and skip the corresponding `init()` args.
86
+
87
+ ## Lifecycle
88
+
89
+ ```python
90
+ from dobby_collector import init, shutdown
91
+
92
+ init(...)
93
+ # ... your agent runs ...
94
+ shutdown(timeout_seconds=5.0) # Drains buffer + stops sender thread
95
+ ```
96
+
97
+ `shutdown()` auto-fires via `atexit` if you forget, but call it explicitly when possible — `atexit` hooks have less time to drain before SIGTERM.
98
+
99
+ ## Status
100
+
101
+ **Phase 2a (this release):** Manual instrumentation API — `init`, `track`, `span`, `start_run`, `end_run`, `shutdown`. In-memory ring buffer + background sender + HTTP retries.
102
+
103
+ **Phase 2b (next):**
104
+ - LangChain auto-instrument via `BaseCallbackHandler` — zero code changes for LangChain agents
105
+ - DLQ to local SQLite — events survive network outages
106
+
107
+ **Phase 4:** CrewAI / AutoGen / OpenAI SDK / Anthropic SDK auto-instrument.
108
+
109
+ ## License
110
+
111
+ MIT — see [LICENSE](LICENSE).
112
+
113
+ ## Links
114
+
115
+ - Full spec: [docs/spikes/dobby-collector-sdk-spec.md](https://github.com/gil-dobby/repo-dobby/blob/main/docs/spikes/dobby-collector-sdk-spec.md)
116
+ - Dobby AI Platform: [dobby-ai.com](https://dobby-ai.com)
117
+ - Documentation: [docs.dobby-ai.com/sdk/python-collector](https://docs.dobby-ai.com/sdk/python-collector)
@@ -0,0 +1,93 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dobby-collector"
7
+ version = "0.1.0"
8
+ description = "Telemetry collector for AI agents — stream runs, tools, LLM calls, and chains to the Dobby AI Control Plane for governance"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "Dobby AI", email = "dev@dobby-ai.com" },
14
+ ]
15
+ keywords = [
16
+ "ai",
17
+ "agents",
18
+ "telemetry",
19
+ "observability",
20
+ "governance",
21
+ "compliance",
22
+ "langchain",
23
+ "crewai",
24
+ "autogen",
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 3 - Alpha",
28
+ "Intended Audience :: Developers",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.9",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Topic :: Software Development :: Libraries :: Python Modules",
36
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
37
+ ]
38
+ dependencies = [
39
+ "httpx>=0.25.0",
40
+ "uuid-utils>=0.7.0",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ langchain = [
45
+ "langchain-core>=0.2.0",
46
+ ]
47
+ dev = [
48
+ "pytest>=7.0.0",
49
+ "pytest-httpx>=0.30.0",
50
+ "ruff>=0.3.0",
51
+ "mypy>=1.8.0",
52
+ ]
53
+
54
+ [project.urls]
55
+ Homepage = "https://dobby-ai.com"
56
+ Documentation = "https://docs.dobby-ai.com/sdk/python-collector"
57
+ Repository = "https://github.com/gil-dobby/repo-dobby"
58
+ Issues = "https://github.com/gil-dobby/repo-dobby/issues"
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = ["src/dobby_collector"]
62
+
63
+ [tool.ruff]
64
+ line-length = 100
65
+ target-version = "py39"
66
+
67
+ [tool.ruff.lint]
68
+ select = ["E", "F", "I", "B", "UP", "SIM"]
69
+ ignore = [
70
+ "E501", # line-length handled by formatter
71
+ "UP006", # py3.9: keep List/Dict/Tuple — PEP 585 generic syntax is 3.9+ but Optional rewrites need 3.10
72
+ "UP007", # py3.9: keep Union[X, Y] — X | Y needs 3.10+
73
+ "UP035", # py3.9: typing.List/Dict imports are still needed
74
+ "UP045", # py3.9: keep Optional[X] — X | None needs 3.10+
75
+ ]
76
+
77
+ [tool.mypy]
78
+ # Use a tooling version that the installed mypy understands (>=3.10).
79
+ # Runtime support is still py3.9+ (enforced by `requires-python` above).
80
+ python_version = "3.10"
81
+ strict = true
82
+ warn_unreachable = true
83
+ disallow_untyped_defs = true
84
+ disallow_incomplete_defs = true
85
+ check_untyped_defs = true
86
+ no_implicit_optional = true
87
+ warn_redundant_casts = true
88
+ warn_unused_ignores = true
89
+
90
+ [tool.pytest.ini_options]
91
+ testpaths = ["tests"]
92
+ python_files = "test_*.py"
93
+ addopts = "-v --tb=short"
@@ -0,0 +1,41 @@
1
+ """
2
+ dobby-collector — telemetry collector for AI agents
3
+ ====================================================
4
+
5
+ Capture every run, LLM call, tool invocation, and chain step from your AI
6
+ agent. Stream them to the Dobby AI Control Plane (https://dobby-ai.com) for
7
+ governance, compliance, and observability.
8
+
9
+ Quickstart:
10
+ from dobby_collector import init, track, span, start_run, end_run, shutdown
11
+
12
+ init(api_key="gk_user_...", connector_id="wc_...")
13
+
14
+ @track(name="search_db", kind="tool")
15
+ def search_db(query): ...
16
+
17
+ run = start_run(name="weekly_report", inputs={"week": "2026-W19"})
18
+ with span("retrieval", inputs={"query": q}):
19
+ docs = retriever.invoke(q)
20
+ end_run(run, outputs={"summary": "..."}, status="success")
21
+
22
+ shutdown() # at process exit (auto-fires via atexit if you forget)
23
+
24
+ Full spec: docs/spikes/dobby-collector-sdk-spec.md
25
+ """
26
+
27
+ from ._api import RunHandle, end_run, span, start_run, track
28
+ from ._config import SDK_VERSION, init, shutdown
29
+
30
+ __version__ = SDK_VERSION
31
+
32
+ __all__ = [
33
+ "init",
34
+ "shutdown",
35
+ "track",
36
+ "span",
37
+ "start_run",
38
+ "end_run",
39
+ "RunHandle",
40
+ "__version__",
41
+ ]