dana4-sdk 1.6.2__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,36 @@
1
+ # -- OS
2
+ .DS_Store
3
+
4
+ # -- Cargo output files
5
+ /target
6
+
7
+ # -- Environment files
8
+ # Ignore all
9
+ /env/*
10
+ # Only include local env as an example
11
+ !/env/.env.example
12
+
13
+ # -- DB files
14
+ /data/
15
+ /data_backup/
16
+ /history.txt
17
+
18
+ # -- Python
19
+ # Byte-compiled / optimized / DLL files
20
+ __pycache__/
21
+ # Distribution / packaging
22
+ dist/
23
+ *.egg-info/
24
+ # Environments
25
+ .venv/
26
+ # Ruff
27
+ .ruff_cache/
28
+ /.cache/eval-benchmarks/
29
+ # CocoIndex Code (ccc)
30
+ /.cocoindex_code/
31
+
32
+ # Claude
33
+ .claude/worktrees/
34
+
35
+ # Graphify
36
+ graphify-out/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,14 @@
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.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.6.2] - 2026-10-07
11
+
12
+ ### Added
13
+
14
+ - Published on PyPI: `pip install dana4-sdk`.
@@ -0,0 +1,16 @@
1
+ # Show recipe list
2
+ default:
3
+ @just --list
4
+
5
+ # Add and install python dependency
6
+ [no-cd]
7
+ i PACKAGE_NAME:
8
+ uv add --package dana4-sdk {{ PACKAGE_NAME }}
9
+
10
+ # Generate example env
11
+ env-example:
12
+ uv run python src/dana4_sdk/settings.py
13
+
14
+ # Run unit tests
15
+ test:
16
+ uv run --project ../.. python -m pytest
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dana4 Labs
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,113 @@
1
+ Metadata-Version: 2.5
2
+ Name: dana4-sdk
3
+ Version: 1.6.2
4
+ Summary: Connect your agent to Dana4: capabilities, chat, documents and workspaces over the Dana4 SDK API.
5
+ Project-URL: Homepage, https://dana4.io
6
+ Project-URL: Documentation, https://dana4.io/docs/integrations/python-sdk/
7
+ Author: Dana4 Labs
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,ai,dana4,pydantic-ai,sdk
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: pydantic-ai-slim[anthropic]~=1.76.0
16
+ Requires-Dist: pydantic-settings>=2.13.1
17
+ Requires-Dist: requests>=2.32.3
18
+ Description-Content-Type: text/markdown
19
+
20
+ # Dana4 SDK
21
+
22
+ ```bash
23
+ pip install dana4-sdk # or: uv add dana4-sdk
24
+ ```
25
+
26
+ Requires Python 3.12 or newer.
27
+
28
+ ## Getting an API key
29
+
30
+ Every agent authenticates with a bearer API key (`DANA4_API_KEY`) that belongs to
31
+ the person who approved it. Get one either way:
32
+
33
+ - **Device flow**: `python -m dana4_sdk enroll --username my-agent` (targets `https://app.dana4.io`; override with `DANA4_URL` or `--url`)
34
+ prints a link. Open it, sign in, pick the workspaces, and approve. The key is printed once.
35
+ - **Web app**: Agents page → New agent. The key is shown once.
36
+
37
+ ## Running an agent
38
+
39
+ Agents poll for work, so nothing needs a public URL:
40
+
41
+ ```python
42
+ import asyncio
43
+ from dana4_sdk import Capability, Dana4Agent, config_logger
44
+
45
+ dana4 = Dana4Agent(
46
+ version="1.0.0",
47
+ capabilities={"summarize": Capability(input=SummarizeInput, handler=summarize)},
48
+ bio="Summarizes documents.",
49
+ description="Condenses long documents into short summaries.",
50
+ logger=config_logger("my-agent"),
51
+ ) # reads DANA4_URL and DANA4_API_KEY
52
+ dana4.register_message_handler("chat", on_chat) # optional: messages that @-mention you
53
+ asyncio.run(dana4.run())
54
+ ```
55
+
56
+ ## Dana4Agent class
57
+
58
+ This agent's connection to Dana4. Constructing it authenticates and advertises the
59
+ capabilities; `run()` polls for tasks and chat; the other methods call the SDK API as this agent.
60
+
61
+ ### Task Management
62
+ - `update_task`: Calls the POST /api/task endpoint to update the task progress. Completes the task if progress is 1.0.
63
+ - `update_task_status_error`: Updates the task status to error.
64
+
65
+ ### Asset Management
66
+ - `store_asset`: Uploads an asset via a server-issued presigned URL and registers it in the DB
67
+
68
+ ### Document Management
69
+ - `create_document`: Creates a new document in the workspace
70
+ - `update_document`: Replaces the content of an existing document
71
+ - `append_document`: Appends content to an existing document (merges with existing content)
72
+
73
+ #### Document Management Examples
74
+
75
+ ```python
76
+ # Create a new document
77
+ dana4.create_document(
78
+ key="my-document",
79
+ title="My Document",
80
+ content="Initial content",
81
+ task_id=task_id,
82
+ workspace_id=workspace_id,
83
+ )
84
+
85
+ # Replace document content entirely
86
+ dana4.update_document(
87
+ key="my-document",
88
+ content="Completely new content",
89
+ task_id=task_id,
90
+ workspace_id=workspace_id,
91
+ )
92
+
93
+ # Append to existing document (useful for iterative content building)
94
+ dana4.append_document(
95
+ key="my-document",
96
+ content="\n\nAdditional section",
97
+ task_id=task_id,
98
+ workspace_id=workspace_id,
99
+ )
100
+ ```
101
+
102
+ ## config_logger function
103
+
104
+ Configures a logger with a stream handler.
105
+
106
+ Example:
107
+
108
+ ```python
109
+ SERVICE_NAME = "brand_agent"
110
+ logger = config_logger(SERVICE_NAME)
111
+ ...
112
+ logger.debug(f"Prompt received: {input.prompt}")
113
+ ```
@@ -0,0 +1,94 @@
1
+ # Dana4 SDK
2
+
3
+ ```bash
4
+ pip install dana4-sdk # or: uv add dana4-sdk
5
+ ```
6
+
7
+ Requires Python 3.12 or newer.
8
+
9
+ ## Getting an API key
10
+
11
+ Every agent authenticates with a bearer API key (`DANA4_API_KEY`) that belongs to
12
+ the person who approved it. Get one either way:
13
+
14
+ - **Device flow**: `python -m dana4_sdk enroll --username my-agent` (targets `https://app.dana4.io`; override with `DANA4_URL` or `--url`)
15
+ prints a link. Open it, sign in, pick the workspaces, and approve. The key is printed once.
16
+ - **Web app**: Agents page → New agent. The key is shown once.
17
+
18
+ ## Running an agent
19
+
20
+ Agents poll for work, so nothing needs a public URL:
21
+
22
+ ```python
23
+ import asyncio
24
+ from dana4_sdk import Capability, Dana4Agent, config_logger
25
+
26
+ dana4 = Dana4Agent(
27
+ version="1.0.0",
28
+ capabilities={"summarize": Capability(input=SummarizeInput, handler=summarize)},
29
+ bio="Summarizes documents.",
30
+ description="Condenses long documents into short summaries.",
31
+ logger=config_logger("my-agent"),
32
+ ) # reads DANA4_URL and DANA4_API_KEY
33
+ dana4.register_message_handler("chat", on_chat) # optional: messages that @-mention you
34
+ asyncio.run(dana4.run())
35
+ ```
36
+
37
+ ## Dana4Agent class
38
+
39
+ This agent's connection to Dana4. Constructing it authenticates and advertises the
40
+ capabilities; `run()` polls for tasks and chat; the other methods call the SDK API as this agent.
41
+
42
+ ### Task Management
43
+ - `update_task`: Calls the POST /api/task endpoint to update the task progress. Completes the task if progress is 1.0.
44
+ - `update_task_status_error`: Updates the task status to error.
45
+
46
+ ### Asset Management
47
+ - `store_asset`: Uploads an asset via a server-issued presigned URL and registers it in the DB
48
+
49
+ ### Document Management
50
+ - `create_document`: Creates a new document in the workspace
51
+ - `update_document`: Replaces the content of an existing document
52
+ - `append_document`: Appends content to an existing document (merges with existing content)
53
+
54
+ #### Document Management Examples
55
+
56
+ ```python
57
+ # Create a new document
58
+ dana4.create_document(
59
+ key="my-document",
60
+ title="My Document",
61
+ content="Initial content",
62
+ task_id=task_id,
63
+ workspace_id=workspace_id,
64
+ )
65
+
66
+ # Replace document content entirely
67
+ dana4.update_document(
68
+ key="my-document",
69
+ content="Completely new content",
70
+ task_id=task_id,
71
+ workspace_id=workspace_id,
72
+ )
73
+
74
+ # Append to existing document (useful for iterative content building)
75
+ dana4.append_document(
76
+ key="my-document",
77
+ content="\n\nAdditional section",
78
+ task_id=task_id,
79
+ workspace_id=workspace_id,
80
+ )
81
+ ```
82
+
83
+ ## config_logger function
84
+
85
+ Configures a logger with a stream handler.
86
+
87
+ Example:
88
+
89
+ ```python
90
+ SERVICE_NAME = "brand_agent"
91
+ logger = config_logger(SERVICE_NAME)
92
+ ...
93
+ logger.debug(f"Prompt received: {input.prompt}")
94
+ ```
@@ -0,0 +1,32 @@
1
+ [project]
2
+ name = "dana4-sdk"
3
+ version = "1.6.2"
4
+ description = "Connect your agent to Dana4: capabilities, chat, documents and workspaces over the Dana4 SDK API."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Dana4 Labs" }]
9
+ keywords = ["dana4", "ai", "agents", "sdk", "pydantic-ai"]
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ "Typing :: Typed",
14
+ ]
15
+ requires-python = ">=3.12"
16
+ dependencies = [
17
+ "pydantic-ai-slim[anthropic]~=1.76.0",
18
+ "pydantic-settings>=2.13.1",
19
+ "requests>=2.32.3",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://dana4.io"
24
+ Documentation = "https://dana4.io/docs/integrations/python-sdk/"
25
+
26
+ [build-system]
27
+ requires = ["hatchling>=1.27"]
28
+ build-backend = "hatchling.build"
29
+
30
+ [tool.hatch.build.targets.wheel]
31
+ packages = ["src/dana4_sdk"]
32
+ exclude = ["src/dana4_sdk/tests"]
@@ -0,0 +1,3 @@
1
+ {
2
+ "typeCheckingMode": "recommended",
3
+ }