persona-sdk-python 0.1.2__tar.gz → 0.2.3__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.
- persona_sdk_python-0.2.3/DEPLOY.md +112 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/PKG-INFO +1 -1
- persona_sdk_python-0.2.3/bitbucket-pipelines.yml +17 -0
- persona_sdk_python-0.2.3/persona_sdk/__init__.py +100 -0
- persona_sdk_python-0.2.3/persona_sdk/auth/__init__.py +11 -0
- persona_sdk_python-0.2.3/persona_sdk/auth/api_key_auth.py +14 -0
- persona_sdk_python-0.2.3/persona_sdk/auth/base.py +17 -0
- persona_sdk_python-0.2.3/persona_sdk/auth/bearer_token_auth.py +14 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/client.py +34 -6
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/pyproject.toml +1 -1
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/uv.lock +138 -129
- persona_sdk_python-0.1.2/README.md +0 -351
- persona_sdk_python-0.1.2/persona_sdk/__init__.py +0 -32
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/.gitignore +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/__init__.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/agents.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/credentials.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/features.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/knowledge_bases.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/missions.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/projects.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/service_prices.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/sessions.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/triggers.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/api/workflows.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/runners/__init__.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/runners/agent_runner.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/runners/resource_retriever.py +0 -0
- {persona_sdk_python-0.1.2 → persona_sdk_python-0.2.3}/persona_sdk/runners/tool_invoker.py +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Deploy to PyPI
|
|
2
|
+
|
|
3
|
+
Operational guide for publishing `persona-sdk-python` to PyPI.
|
|
4
|
+
|
|
5
|
+
Reference: same strategy used by `applica-iam-client`.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
### 1. PyPI account
|
|
12
|
+
|
|
13
|
+
- Go to https://pypi.org/account/register/
|
|
14
|
+
- If the account already exists (e.g. the one used for `applica-iam-client`), skip this step
|
|
15
|
+
|
|
16
|
+
### 2. PyPI API Token
|
|
17
|
+
|
|
18
|
+
1. Login at https://pypi.org
|
|
19
|
+
2. Go to **Account Settings** → **API tokens**
|
|
20
|
+
3. Click **Add API token**
|
|
21
|
+
- Name: `persona-sdk-python-deploy`
|
|
22
|
+
- Scope: **Entire account** (for the first release, you can restrict to the project later)
|
|
23
|
+
4. Copy the token (starts with `pypi-...`) — it is shown only once
|
|
24
|
+
|
|
25
|
+
### 3. Configure the token on Bitbucket
|
|
26
|
+
|
|
27
|
+
1. Go to the Bitbucket repository for `persona-sdk-python`
|
|
28
|
+
2. **Repository settings** → **Pipelines** → **Repository variables**
|
|
29
|
+
3. Add:
|
|
30
|
+
- **Name:** `PYPI_TOKEN`
|
|
31
|
+
- **Value:** the copied token (e.g. `pypi-AgEIcH...`)
|
|
32
|
+
- **Secured:** checked
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Automated Release (Bitbucket Pipelines)
|
|
37
|
+
|
|
38
|
+
Every push to `main` automatically publishes a new version.
|
|
39
|
+
|
|
40
|
+
The version is computed as `0.1.{BITBUCKET_BUILD_NUMBER}`, so it auto-increments
|
|
41
|
+
(e.g. build #1 → `0.1.1`, build #14 → `0.1.14`, build #203 → `0.1.203`).
|
|
42
|
+
|
|
43
|
+
When you want a major/minor bump, change the prefix in `bitbucket-pipelines.yml`
|
|
44
|
+
(e.g. from `0.1.` to `0.2.` or `1.0.`).
|
|
45
|
+
|
|
46
|
+
### Flow:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
git push origin main
|
|
50
|
+
│
|
|
51
|
+
▼
|
|
52
|
+
Pipeline triggers
|
|
53
|
+
│
|
|
54
|
+
▼
|
|
55
|
+
Updates version in pyproject.toml (0.1.$BUILD_NUMBER)
|
|
56
|
+
│
|
|
57
|
+
▼
|
|
58
|
+
Build (sdist + wheel)
|
|
59
|
+
│
|
|
60
|
+
▼
|
|
61
|
+
Upload to PyPI via twine with $PYPI_TOKEN
|
|
62
|
+
│
|
|
63
|
+
▼
|
|
64
|
+
Creates git tag (0.1.$BUILD_NUMBER) and pushes it
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Manual Release (from local machine)
|
|
70
|
+
|
|
71
|
+
If you want to publish without the pipeline, from your terminal:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd /path/to/persona-sdk-python
|
|
75
|
+
|
|
76
|
+
# 1. Update the version in pyproject.toml
|
|
77
|
+
# Edit the line: version = "0.1.X"
|
|
78
|
+
|
|
79
|
+
# 2. Build
|
|
80
|
+
pip install build
|
|
81
|
+
python -m build
|
|
82
|
+
|
|
83
|
+
# 3. Upload
|
|
84
|
+
pip install twine
|
|
85
|
+
twine upload dist/* -u __token__ -p pypi-YOUR_TOKEN_HERE
|
|
86
|
+
|
|
87
|
+
# 4. Tag
|
|
88
|
+
git tag -a 0.1.X -m "0.1.X"
|
|
89
|
+
git push origin 0.1.X
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Verification
|
|
95
|
+
|
|
96
|
+
After release, verify that the package is available:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install persona-sdk-python --upgrade
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or check at: https://pypi.org/project/persona-sdk-python/
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## First Release — Checklist
|
|
107
|
+
|
|
108
|
+
- [ ] PyPI account created/existing
|
|
109
|
+
- [ ] API Token generated on PyPI
|
|
110
|
+
- [ ] Token configured as `PYPI_TOKEN` in Bitbucket repository variables
|
|
111
|
+
- [ ] Push to `main` → pipeline runs → package published
|
|
112
|
+
- [ ] `pip install persona-sdk-python` works
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
image: python:3.12
|
|
2
|
+
|
|
3
|
+
pipelines:
|
|
4
|
+
default:
|
|
5
|
+
- step:
|
|
6
|
+
name: Publish to PyPI
|
|
7
|
+
caches:
|
|
8
|
+
- pip
|
|
9
|
+
script:
|
|
10
|
+
- apt-get update && apt-get install -y git
|
|
11
|
+
- pip install build twine
|
|
12
|
+
- export VERSION=0.2.$BITBUCKET_BUILD_NUMBER
|
|
13
|
+
- sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
|
|
14
|
+
- python -m build
|
|
15
|
+
- twine upload dist/* -u __token__ -p $PYPI_TOKEN
|
|
16
|
+
- git tag -a $VERSION -m "$VERSION"
|
|
17
|
+
- git push origin $VERSION
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
from persona_sdk.api.agents import AgentsApi
|
|
4
|
+
from persona_sdk.api.credentials import CredentialsApi
|
|
5
|
+
from persona_sdk.api.features import FeaturesApi
|
|
6
|
+
from persona_sdk.api.knowledge_bases import KnowledgeBasesApi
|
|
7
|
+
from persona_sdk.api.missions import MissionsApi
|
|
8
|
+
from persona_sdk.api.projects import ProjectsApi
|
|
9
|
+
from persona_sdk.api.service_prices import ServicePricesApi
|
|
10
|
+
from persona_sdk.api.sessions import SessionsApi
|
|
11
|
+
from persona_sdk.api.triggers import TriggersApi
|
|
12
|
+
from persona_sdk.api.workflows import WorkflowsApi
|
|
13
|
+
from persona_sdk.auth import (
|
|
14
|
+
ApiKeyAuthenticationProvider,
|
|
15
|
+
AuthenticationProvider,
|
|
16
|
+
BearerTokenAuthenticationProvider,
|
|
17
|
+
)
|
|
18
|
+
from persona_sdk.client import PersonaClient
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"PersonaSdk",
|
|
22
|
+
"PersonaClient",
|
|
23
|
+
"AuthenticationProvider",
|
|
24
|
+
"ApiKeyAuthenticationProvider",
|
|
25
|
+
"BearerTokenAuthenticationProvider",
|
|
26
|
+
"AgentsApi",
|
|
27
|
+
"CredentialsApi",
|
|
28
|
+
"FeaturesApi",
|
|
29
|
+
"KnowledgeBasesApi",
|
|
30
|
+
"MissionsApi",
|
|
31
|
+
"ProjectsApi",
|
|
32
|
+
"ServicePricesApi",
|
|
33
|
+
"SessionsApi",
|
|
34
|
+
"TriggersApi",
|
|
35
|
+
"WorkflowsApi",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class PersonaSdk:
|
|
40
|
+
"""
|
|
41
|
+
Persona SDK facade.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
base_url: Base URL of persona-core (e.g. https://persona.applica.guru/api).
|
|
45
|
+
auth: An ``AuthenticationProvider`` (preferred) or a plain string with
|
|
46
|
+
the API key / JWT token. Strings are wrapped in
|
|
47
|
+
``ApiKeyAuthenticationProvider`` for backwards compatibility.
|
|
48
|
+
proxy: Optional HTTP proxy URL.
|
|
49
|
+
workflows_url: Optional separate base URL for the workflows service.
|
|
50
|
+
If provided, a second client is created using the same auth.
|
|
51
|
+
api_key: Deprecated keyword-only alias for ``auth``. Provided for
|
|
52
|
+
backwards compatibility with previous SDK versions.
|
|
53
|
+
|
|
54
|
+
Examples:
|
|
55
|
+
Using an API key (legacy)::
|
|
56
|
+
|
|
57
|
+
sdk = PersonaSdk("http://localhost:8000", "prs_my_key")
|
|
58
|
+
|
|
59
|
+
Using an IAM Bearer token::
|
|
60
|
+
|
|
61
|
+
from persona_sdk import BearerTokenAuthenticationProvider
|
|
62
|
+
sdk = PersonaSdk(
|
|
63
|
+
"http://localhost:8000",
|
|
64
|
+
BearerTokenAuthenticationProvider(jwt_token),
|
|
65
|
+
)
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
def __init__(
|
|
69
|
+
self,
|
|
70
|
+
base_url: str,
|
|
71
|
+
auth: Union[str, AuthenticationProvider, None] = None,
|
|
72
|
+
proxy: str = None,
|
|
73
|
+
workflows_url: str = None,
|
|
74
|
+
api_key: str = None,
|
|
75
|
+
):
|
|
76
|
+
# Backwards compatibility: keep the legacy `api_key` keyword
|
|
77
|
+
if auth is None:
|
|
78
|
+
if api_key is None:
|
|
79
|
+
raise ValueError("Either 'auth' or 'api_key' must be provided")
|
|
80
|
+
auth = api_key
|
|
81
|
+
|
|
82
|
+
self.client = PersonaClient(base_url, auth, proxy=proxy)
|
|
83
|
+
self.workflows_client = (
|
|
84
|
+
PersonaClient(workflows_url, auth) if workflows_url else self.client
|
|
85
|
+
)
|
|
86
|
+
self.agents = AgentsApi(self.client)
|
|
87
|
+
self.workflows = WorkflowsApi(self.workflows_client)
|
|
88
|
+
self.triggers = TriggersApi(self.client)
|
|
89
|
+
self.sessions = SessionsApi(self.client)
|
|
90
|
+
self.credentials = CredentialsApi(self.client)
|
|
91
|
+
self.knowledge_bases = KnowledgeBasesApi(self.client)
|
|
92
|
+
self.projects = ProjectsApi(self.client)
|
|
93
|
+
self.features = FeaturesApi(self.client)
|
|
94
|
+
self.missions = MissionsApi(self.client)
|
|
95
|
+
self.service_prices = ServicePricesApi(self.client)
|
|
96
|
+
|
|
97
|
+
async def close(self):
|
|
98
|
+
await self.client.close()
|
|
99
|
+
if self.workflows_client is not self.client:
|
|
100
|
+
await self.workflows_client.close()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Authentication providers for the Persona SDK."""
|
|
2
|
+
|
|
3
|
+
from persona_sdk.auth.api_key_auth import ApiKeyAuthenticationProvider
|
|
4
|
+
from persona_sdk.auth.base import AuthenticationProvider
|
|
5
|
+
from persona_sdk.auth.bearer_token_auth import BearerTokenAuthenticationProvider
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"AuthenticationProvider",
|
|
9
|
+
"ApiKeyAuthenticationProvider",
|
|
10
|
+
"BearerTokenAuthenticationProvider",
|
|
11
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""API key authentication provider (sends x-persona-apikey header)."""
|
|
2
|
+
|
|
3
|
+
from persona_sdk.auth.base import AuthenticationProvider
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ApiKeyAuthenticationProvider(AuthenticationProvider):
|
|
7
|
+
def __init__(self, api_key: str):
|
|
8
|
+
self.api_key = api_key
|
|
9
|
+
|
|
10
|
+
def headers(self) -> dict[str, str]:
|
|
11
|
+
return {"x-persona-apikey": self.api_key}
|
|
12
|
+
|
|
13
|
+
def credentials(self) -> str:
|
|
14
|
+
return self.api_key
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Base authentication provider interface."""
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AuthenticationProvider(ABC):
|
|
7
|
+
"""Abstract base class for authentication providers."""
|
|
8
|
+
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def headers(self) -> dict[str, str]:
|
|
11
|
+
"""Return the HTTP headers required for authentication."""
|
|
12
|
+
...
|
|
13
|
+
|
|
14
|
+
@abstractmethod
|
|
15
|
+
def credentials(self) -> str:
|
|
16
|
+
"""Return the raw credentials (api key or token)."""
|
|
17
|
+
...
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Bearer token authentication provider (sends Authorization: Bearer header)."""
|
|
2
|
+
|
|
3
|
+
from persona_sdk.auth.base import AuthenticationProvider
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BearerTokenAuthenticationProvider(AuthenticationProvider):
|
|
7
|
+
def __init__(self, token: str):
|
|
8
|
+
self.token = token
|
|
9
|
+
|
|
10
|
+
def headers(self) -> dict[str, str]:
|
|
11
|
+
return {"Authorization": f"Bearer {self.token}"}
|
|
12
|
+
|
|
13
|
+
def credentials(self) -> str:
|
|
14
|
+
return self.token
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
1
3
|
import httpx
|
|
2
4
|
|
|
5
|
+
from persona_sdk.auth import (
|
|
6
|
+
ApiKeyAuthenticationProvider,
|
|
7
|
+
AuthenticationProvider,
|
|
8
|
+
)
|
|
9
|
+
|
|
3
10
|
|
|
4
11
|
class PersonaClient:
|
|
5
12
|
"""
|
|
@@ -7,21 +14,42 @@ class PersonaClient:
|
|
|
7
14
|
|
|
8
15
|
Args:
|
|
9
16
|
base_url: The base URL of the Persona API (e.g. http://localhost:8000).
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
auth: An ``AuthenticationProvider`` (recommended) or a plain string
|
|
18
|
+
containing the API key / JWT token. Strings are wrapped in
|
|
19
|
+
``ApiKeyAuthenticationProvider`` and sent as ``x-persona-apikey``
|
|
20
|
+
for backwards compatibility.
|
|
21
|
+
proxy: Optional HTTP proxy URL.
|
|
22
|
+
|
|
23
|
+
Note:
|
|
24
|
+
The ``x-persona-apikey`` header accepts both plain API keys and
|
|
25
|
+
internal MCP JWT tokens. For IAM Bearer authentication use
|
|
26
|
+
``BearerTokenAuthenticationProvider``.
|
|
13
27
|
"""
|
|
14
28
|
|
|
15
|
-
def __init__(
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
base_url: str,
|
|
32
|
+
auth: Union[str, AuthenticationProvider],
|
|
33
|
+
proxy: str = None,
|
|
34
|
+
):
|
|
16
35
|
self.base_url = base_url.rstrip("/")
|
|
17
|
-
|
|
36
|
+
if isinstance(auth, str):
|
|
37
|
+
self.auth_provider: AuthenticationProvider = ApiKeyAuthenticationProvider(auth)
|
|
38
|
+
else:
|
|
39
|
+
self.auth_provider = auth
|
|
40
|
+
|
|
18
41
|
self._client = httpx.AsyncClient(
|
|
19
42
|
base_url=self.base_url,
|
|
20
|
-
headers=
|
|
43
|
+
headers=self.auth_provider.headers(),
|
|
21
44
|
timeout=30.0,
|
|
22
45
|
proxy=proxy,
|
|
23
46
|
)
|
|
24
47
|
|
|
48
|
+
@property
|
|
49
|
+
def api_key(self) -> str:
|
|
50
|
+
"""Backwards-compatible alias returning the credentials string."""
|
|
51
|
+
return self.auth_provider.credentials()
|
|
52
|
+
|
|
25
53
|
async def get(self, path: str, params: dict = None) -> dict:
|
|
26
54
|
response = await self._client.get(path, params=params)
|
|
27
55
|
response.raise_for_status()
|