stigmer-sdk 0.1.0.dev0__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.
- stigmer_sdk-0.1.0.dev0/.gitignore +178 -0
- stigmer_sdk-0.1.0.dev0/Makefile +46 -0
- stigmer_sdk-0.1.0.dev0/PKG-INFO +232 -0
- stigmer_sdk-0.1.0.dev0/README.md +208 -0
- stigmer_sdk-0.1.0.dev0/pyproject.toml +36 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/__init__.py +152 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_billing.py +220 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_client.py +124 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/__init__.py +152 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_agent.py +343 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_apikey.py +146 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_bidi.py +40 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_channel.py +384 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_channelapp.py +169 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_client.py +65 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_errors.py +98 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_eval.py +178 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_evalrun.py +206 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_federationissuer.py +145 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_grant.py +187 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_identityaccount.py +212 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_invitation.py +117 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_license.py +174 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_memory.py +143 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_oauthapp.py +154 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_organization.py +223 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_plan.py +130 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_plugin.py +195 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_providerkey.py +54 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_run.py +536 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_schedule.py +219 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_score.py +184 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_scoringrule.py +102 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_session.py +243 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_skill.py +166 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_subscription.py +97 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_team.py +124 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_types.py +43 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_gen/_vault.py +293 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_github.py +95 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_interceptors.py +85 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_runner_adapter.py +58 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_search.py +97 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_skill.py +101 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_tokens.py +137 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/_transport.py +47 -0
- stigmer_sdk-0.1.0.dev0/src/stigmer/py.typed +0 -0
- stigmer_sdk-0.1.0.dev0/tests/__init__.py +0 -0
- stigmer_sdk-0.1.0.dev0/tests/test_agent_mcp_servers.py +48 -0
- stigmer_sdk-0.1.0.dev0/tests/test_billing.py +103 -0
- stigmer_sdk-0.1.0.dev0/tests/test_client.py +35 -0
- stigmer_sdk-0.1.0.dev0/tests/test_github.py +243 -0
- stigmer_sdk-0.1.0.dev0/tests/test_optional_scalar_presence.py +42 -0
- stigmer_sdk-0.1.0.dev0/tests/test_orgless_kind_input.py +37 -0
- stigmer_sdk-0.1.0.dev0/tests/test_pages.py +136 -0
- stigmer_sdk-0.1.0.dev0/tests/test_runner_adapter.py +89 -0
- stigmer_sdk-0.1.0.dev0/tests/test_skill_routing.py +149 -0
- stigmer_sdk-0.1.0.dev0/tests/test_tokens.py +137 -0
- stigmer_sdk-0.1.0.dev0/tests/test_transport.py +60 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Binaries for programs and plugins
|
|
2
|
+
*.exe
|
|
3
|
+
*.exe~
|
|
4
|
+
*.dll
|
|
5
|
+
*.so
|
|
6
|
+
*.dylib
|
|
7
|
+
bin/
|
|
8
|
+
dist/
|
|
9
|
+
# Turborepo's local task cache and per-package task logs (turbo.json).
|
|
10
|
+
.turbo
|
|
11
|
+
dist-slim/
|
|
12
|
+
dist-slim-pkgs/
|
|
13
|
+
# Per-arch trees the Docker image build stages (scripts/smoke-docker-image.mjs).
|
|
14
|
+
dist-slim-amd64/
|
|
15
|
+
dist-slim-arm64/
|
|
16
|
+
# The compose-runner image's CLI tarballs (scripts/stage-compose-runner-cli.mjs).
|
|
17
|
+
backend/services/runner/stage/
|
|
18
|
+
# The server library tarballs a consumer installs (scripts/stage-server-library.mjs).
|
|
19
|
+
backend/services/stigmer-server/stage/
|
|
20
|
+
|
|
21
|
+
# Desktop embedded-runner staging: a symlink in dev (setup-runner-dev.sh),
|
|
22
|
+
# the staged slim artifact in packaged builds (stage-runner-slim.sh).
|
|
23
|
+
client-apps/desktop/src-tauri/resources/runner
|
|
24
|
+
client-apps/desktop/src-tauri/resources/runtime
|
|
25
|
+
|
|
26
|
+
# Test binary, built with `go test -c`
|
|
27
|
+
*.test
|
|
28
|
+
|
|
29
|
+
# Output of the go coverage tool
|
|
30
|
+
*.out
|
|
31
|
+
coverage.txt
|
|
32
|
+
coverage.html
|
|
33
|
+
|
|
34
|
+
# A vitest run's v8 coverage (`--coverage.enabled`), in each package
|
|
35
|
+
coverage/
|
|
36
|
+
|
|
37
|
+
# Stryker's copies of the files it changes in place during a mutation sweep
|
|
38
|
+
# (scripts/mutation-sweep.mjs), which it removes when the run ends
|
|
39
|
+
.stryker-tmp/
|
|
40
|
+
|
|
41
|
+
# Go workspace sum file (auto-generated, can be ignored)
|
|
42
|
+
go.work.sum
|
|
43
|
+
|
|
44
|
+
# Dependency directories (Go)
|
|
45
|
+
vendor/
|
|
46
|
+
|
|
47
|
+
# Python
|
|
48
|
+
__pycache__/
|
|
49
|
+
*.py[cod]
|
|
50
|
+
*$py.class
|
|
51
|
+
*.so
|
|
52
|
+
.Python
|
|
53
|
+
build/
|
|
54
|
+
develop-eggs/
|
|
55
|
+
downloads/
|
|
56
|
+
eggs/
|
|
57
|
+
.eggs/
|
|
58
|
+
/lib/
|
|
59
|
+
/lib64/
|
|
60
|
+
parts/
|
|
61
|
+
sdist/
|
|
62
|
+
var/
|
|
63
|
+
wheels/
|
|
64
|
+
*.egg-info/
|
|
65
|
+
.installed.cfg
|
|
66
|
+
*.egg
|
|
67
|
+
# The setuptools sdist artifact (a FILE named MANIFEST). With
|
|
68
|
+
# core.ignorecase this pattern also swallows source directories named
|
|
69
|
+
# manifest/ (e.g. sdk/*/src/manifest) — the negation re-includes those
|
|
70
|
+
# while the artifact file stays ignored.
|
|
71
|
+
MANIFEST
|
|
72
|
+
!**/manifest/
|
|
73
|
+
*.pyc
|
|
74
|
+
.pytest_cache/
|
|
75
|
+
.coverage
|
|
76
|
+
htmlcov/
|
|
77
|
+
|
|
78
|
+
# Virtual environments
|
|
79
|
+
venv/
|
|
80
|
+
env/
|
|
81
|
+
ENV/
|
|
82
|
+
.venv
|
|
83
|
+
|
|
84
|
+
# IDEs
|
|
85
|
+
.idea/
|
|
86
|
+
.vscode/
|
|
87
|
+
*.swp
|
|
88
|
+
*.swo
|
|
89
|
+
*~
|
|
90
|
+
.DS_Store
|
|
91
|
+
|
|
92
|
+
# Java / Maven
|
|
93
|
+
target/
|
|
94
|
+
|
|
95
|
+
# Node.js
|
|
96
|
+
node_modules/
|
|
97
|
+
|
|
98
|
+
# Stigmer specific
|
|
99
|
+
.stigmer/
|
|
100
|
+
*.skill
|
|
101
|
+
*.db
|
|
102
|
+
*.db-shm
|
|
103
|
+
*.db-wal
|
|
104
|
+
|
|
105
|
+
# Temporary files
|
|
106
|
+
*.log
|
|
107
|
+
*.tmp
|
|
108
|
+
tmp/
|
|
109
|
+
|
|
110
|
+
# Proto generated files (tracked, but ignore in development)
|
|
111
|
+
# We'll commit generated code for now
|
|
112
|
+
# *.pb.go
|
|
113
|
+
# *_pb2.py
|
|
114
|
+
# *_pb2.pyi
|
|
115
|
+
|
|
116
|
+
# Build artifacts
|
|
117
|
+
*.o
|
|
118
|
+
*.a
|
|
119
|
+
*.out
|
|
120
|
+
.agent-runner-image-built
|
|
121
|
+
|
|
122
|
+
# Codegen tool binaries (go build drops these in the module/repo root)
|
|
123
|
+
/generator
|
|
124
|
+
/proto2schema
|
|
125
|
+
tools/codegen/generator/generator
|
|
126
|
+
|
|
127
|
+
# Go service binaries (prevent accidental commits of built binaries in service dirs)
|
|
128
|
+
backend/services/*/stigmer-server
|
|
129
|
+
backend/services/*/agent-runner
|
|
130
|
+
backend/services/*/cmd/*/server
|
|
131
|
+
backend/services/*/server
|
|
132
|
+
|
|
133
|
+
# npm auth tokens (never commit)
|
|
134
|
+
.npmrc
|
|
135
|
+
|
|
136
|
+
# Vale (downloaded style packages — run `vale sync` to fetch)
|
|
137
|
+
vale/styles/Google/
|
|
138
|
+
vale/styles/Microsoft/
|
|
139
|
+
vale/styles/alex/
|
|
140
|
+
|
|
141
|
+
# uv lockfile (project uses Poetry; uv.lock is auto-generated noise)
|
|
142
|
+
uv.lock
|
|
143
|
+
|
|
144
|
+
# Environment files (local secrets, never commit)
|
|
145
|
+
.env
|
|
146
|
+
.env_export
|
|
147
|
+
# Vite local env overrides (e.g. desktop .env.development.local — machine-specific paths)
|
|
148
|
+
.env*.local
|
|
149
|
+
|
|
150
|
+
# Integration test output
|
|
151
|
+
.test-output*/
|
|
152
|
+
|
|
153
|
+
# TypeDoc JSON intermediates (regenerated by `make gen-react-sdk-docs` /
|
|
154
|
+
# `gen-ink-sdk-docs` before every use; they embed the HEAD commit SHA in
|
|
155
|
+
# every source URL, so tracking them creates churn on every SDK commit)
|
|
156
|
+
sdk/*/typedoc-output.json
|
|
157
|
+
|
|
158
|
+
# Dev TLS certs (generated by gen-dev-certs.sh)
|
|
159
|
+
client-apps/desktop/scripts/.certs/
|
|
160
|
+
|
|
161
|
+
# Cursor
|
|
162
|
+
_cursor/
|
|
163
|
+
_aacursor/
|
|
164
|
+
*.bak
|
|
165
|
+
|
|
166
|
+
# Internal planning/history migrated to the private stigmer-cloud repo (do not re-add)
|
|
167
|
+
_changelog/
|
|
168
|
+
_investigations/
|
|
169
|
+
_projects/
|
|
170
|
+
_roles/
|
|
171
|
+
.cursor/plans/
|
|
172
|
+
|
|
173
|
+
# Compiled codegen toolchain binaries (built ad hoc via `go build` in tools/;
|
|
174
|
+
# the tools are always run via `go run ./tools/codegen/...` — never commit them)
|
|
175
|
+
/tools/generator
|
|
176
|
+
/tools/proto2schema
|
|
177
|
+
/tools/codegen/generator/generator
|
|
178
|
+
/tools/codegen/proto2schema/proto2schema
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Stigmer Python SDK - Makefile
|
|
2
|
+
|
|
3
|
+
.PHONY: help
|
|
4
|
+
help: ## Display this help message
|
|
5
|
+
@echo "Stigmer Python SDK - Available targets:"
|
|
6
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
7
|
+
|
|
8
|
+
.PHONY: codegen-clients
|
|
9
|
+
codegen-clients: ## Generate SDK client code from service schemas
|
|
10
|
+
@echo "Generating Python SDK client code..."
|
|
11
|
+
@echo " Wiping src/stigmer/_gen/ directory..."
|
|
12
|
+
@rm -rf src/stigmer/_gen
|
|
13
|
+
@mkdir -p src/stigmer/_gen
|
|
14
|
+
@# The generator runs from TypeScript source via the repo-pinned tsx
|
|
15
|
+
@# (never bare npx — oss#531) and reads proto metadata from
|
|
16
|
+
@# @stigmer/apis, which must be built first (incremental; a no-op when
|
|
17
|
+
@# fresh). A bare CI checkout has no dist/ — skipping this fails module
|
|
18
|
+
@# resolution.
|
|
19
|
+
@cd ../.. && test -x node_modules/.bin/tsx || { echo "error: node_modules/.bin/tsx not found — run 'npm install' at the repo root"; exit 1; }
|
|
20
|
+
@cd ../.. && npm run build -w @stigmer/apis --silent
|
|
21
|
+
@cd ../.. && node_modules/.bin/tsx tools/codegen/src/generator/main.ts \
|
|
22
|
+
--schema-dir tools/codegen/schemas \
|
|
23
|
+
--output-dir sdk/python/src/stigmer/_gen \
|
|
24
|
+
--target sdk-client-python
|
|
25
|
+
|
|
26
|
+
.PHONY: codegen
|
|
27
|
+
codegen: codegen-clients ## Run code generation pipeline
|
|
28
|
+
@echo ""
|
|
29
|
+
@echo "Python SDK code generation complete!"
|
|
30
|
+
@echo "Generated files live in src/stigmer/_gen/"
|
|
31
|
+
|
|
32
|
+
.PHONY: codegen-verify
|
|
33
|
+
codegen-verify: codegen ## Generate code and verify syntax
|
|
34
|
+
@echo "Verifying generated Python files..."
|
|
35
|
+
@python3 -c "import ast, pathlib; \
|
|
36
|
+
files = list(pathlib.Path('src/stigmer/_gen').glob('*.py')); \
|
|
37
|
+
[ast.parse(f.read_text()) for f in files]; \
|
|
38
|
+
print(f' {len(files)} files passed syntax check')"
|
|
39
|
+
@echo ""
|
|
40
|
+
@echo "Code generation verified successfully!"
|
|
41
|
+
|
|
42
|
+
.PHONY: clean
|
|
43
|
+
clean: ## Clean build artifacts
|
|
44
|
+
@rm -rf dist build *.egg-info src/*.egg-info
|
|
45
|
+
|
|
46
|
+
.DEFAULT_GOAL := help
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: stigmer-sdk
|
|
3
|
+
Version: 0.1.0.dev0
|
|
4
|
+
Summary: Stigmer Python SDK — typed API client for all Stigmer platform resources
|
|
5
|
+
Project-URL: Homepage, https://stigmer.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/stigmer/stigmer
|
|
7
|
+
Project-URL: Documentation, https://docs.stigmer.ai/sdk/python
|
|
8
|
+
Author-email: Stigmer <engineering@stigmer.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
Keywords: ai-agents,api-client,grpc,sdk,stigmer
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: grpcio>=1.60.0
|
|
21
|
+
Requires-Dist: protobuf>=6.32.0
|
|
22
|
+
Requires-Dist: stigmer-apis==0.1.0.dev0
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# stigmer
|
|
26
|
+
|
|
27
|
+
Python SDK for the Stigmer platform. Provides typed API clients for all Stigmer resources with authentication, error handling, and cross-resource search.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install stigmer-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`stigmer-apis` (generated protobuf stubs) is installed automatically as a dependency.
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from stigmer import StigmerClient, AgentInput
|
|
41
|
+
|
|
42
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
43
|
+
agent = client.agents.create(AgentInput(name="my-agent", org="my-org"))
|
|
44
|
+
print(agent.metadata.name)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or without a context manager:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
client = StigmerClient("sk_live_abc123")
|
|
51
|
+
agent = client.agents.get("agent-id")
|
|
52
|
+
client.close()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Resource Clients
|
|
56
|
+
|
|
57
|
+
Every resource type has a typed client accessible as a property on `StigmerClient`:
|
|
58
|
+
|
|
59
|
+
| Property | Resource |
|
|
60
|
+
|------------------------|--------------------|
|
|
61
|
+
| `agents` | Agent |
|
|
62
|
+
| `runs` | Run |
|
|
63
|
+
| `api_keys` | ApiKey |
|
|
64
|
+
| `grants` | Grant |
|
|
65
|
+
| `identity_accounts` | IdentityAccount |
|
|
66
|
+
| `federation_issuers` | FederationIssuer |
|
|
67
|
+
| `organizations` | Organization |
|
|
68
|
+
| `plugins` | Plugin |
|
|
69
|
+
| `sessions` | Session |
|
|
70
|
+
| `skills` | Skill |
|
|
71
|
+
| `vaults` | Vault |
|
|
72
|
+
| `search` | Cross-resource search |
|
|
73
|
+
| `tokens` | User-token minting (service-account keys) |
|
|
74
|
+
|
|
75
|
+
## Common Operations
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from ai.stigmer.agentic.agent.v1 import io_pb2 as agent_io_pb2
|
|
79
|
+
from ai.stigmer.commons.apiresource import io_pb2 as apiresource_io_pb2
|
|
80
|
+
from stigmer import StigmerClient, AgentInput, ResourceRef
|
|
81
|
+
|
|
82
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
83
|
+
# Create
|
|
84
|
+
agent = client.agents.create(AgentInput(
|
|
85
|
+
name="my-agent",
|
|
86
|
+
org="my-org",
|
|
87
|
+
description="Handles customer inquiries",
|
|
88
|
+
instructions="Be helpful and concise.",
|
|
89
|
+
))
|
|
90
|
+
|
|
91
|
+
# Get by ID
|
|
92
|
+
agent = client.agents.get("agent-id")
|
|
93
|
+
|
|
94
|
+
# Get by reference (org + slug)
|
|
95
|
+
agent = client.agents.get_by_reference(ResourceRef(org="my-org", slug="my-agent"))
|
|
96
|
+
|
|
97
|
+
# Update: read, change, then name the fields you changed. Every other
|
|
98
|
+
# field keeps its stored value. The read's etag makes the save fail with
|
|
99
|
+
# "aborted" if someone changed the agent since.
|
|
100
|
+
current = client.agents.get("agent-id")
|
|
101
|
+
current.spec.description = "Updated description"
|
|
102
|
+
updated = client.agents.update(current, ["spec.description"])
|
|
103
|
+
|
|
104
|
+
# Rename: change the slug people type. The id stays, so everything that
|
|
105
|
+
# points at the agent keeps working; the old slug reads for 30 days.
|
|
106
|
+
renamed = client.agents.rename(
|
|
107
|
+
apiresource_io_pb2.RenameInput(resource_id="agent-id", slug="support-bot")
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Delete
|
|
111
|
+
deleted = client.agents.delete("agent-id")
|
|
112
|
+
|
|
113
|
+
# List: one page of the org's agents, newest first. A page carries
|
|
114
|
+
# next_page_token while more follow; page_size 0 asks for the default 50.
|
|
115
|
+
page = client.agents.list(agent_io_pb2.ListAgentsRequest(org="my-org", page_size=20))
|
|
116
|
+
|
|
117
|
+
# Every agent, page after page: list_all follows the tokens.
|
|
118
|
+
for a in client.agents.list_all(agent_io_pb2.ListAgentsRequest(org="my-org")):
|
|
119
|
+
print(a.metadata.slug)
|
|
120
|
+
|
|
121
|
+
# Only the agents carrying every label given.
|
|
122
|
+
support = client.agents.list(
|
|
123
|
+
agent_io_pb2.ListAgentsRequest(org="my-org", labels={"team": "support"})
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Cross-Resource Search
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from stigmer import StigmerClient, ApiResourceKind, SearchParams
|
|
131
|
+
|
|
132
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
133
|
+
results = client.search.query(SearchParams(
|
|
134
|
+
kinds=[ApiResourceKind.agent, ApiResourceKind.skill],
|
|
135
|
+
org="my-org",
|
|
136
|
+
query="customer support",
|
|
137
|
+
))
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## User Tokens
|
|
141
|
+
|
|
142
|
+
A product that embeds Stigmer mints a short-lived token for each person
|
|
143
|
+
signed in to it, from its own backend, with an ordinary client built on a
|
|
144
|
+
service account's API key. The account must be an admin of the organization
|
|
145
|
+
the token is for, or of its parent organization; a person's key is refused.
|
|
146
|
+
Pass `access_token` to the React SDK's `StigmerProvider` through
|
|
147
|
+
`getAccessToken`:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from stigmer import StigmerClient
|
|
151
|
+
|
|
152
|
+
with StigmerClient(os.environ["STIGMER_API_KEY"]) as client:
|
|
153
|
+
result = client.tokens.mint_user_token(
|
|
154
|
+
org="acme",
|
|
155
|
+
user_id=user.id,
|
|
156
|
+
user_email=user.email,
|
|
157
|
+
user_name=user.name,
|
|
158
|
+
)
|
|
159
|
+
print(result.access_token, result.expires_at)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Billing
|
|
163
|
+
|
|
164
|
+
An organization's billing account (its Stripe customer), the Stripe portal
|
|
165
|
+
and card setup sessions. Token usage is read from the run client's usage
|
|
166
|
+
reports (`get_run_usage_report`, `get_session_usage_report`,
|
|
167
|
+
`get_agent_usage_report`, `get_org_usage_report`), counted in tokens and never
|
|
168
|
+
priced. Queries require `can_view_billing` on the org and the org's own
|
|
169
|
+
billing commands require `can_manage_billing`. The operator pricing methods
|
|
170
|
+
(`list_model_pricing_baselines`, `upsert_model_pricing_baseline`,
|
|
171
|
+
`retire_model_pricing_baseline`) require `can_manage_model_pricing` on the
|
|
172
|
+
platform:
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from stigmer import CreatePaymentMethodSetupSessionParams, StigmerClient
|
|
176
|
+
|
|
177
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
178
|
+
account = client.billing.get_billing_account(org)
|
|
179
|
+
|
|
180
|
+
setup = client.billing.create_payment_method_setup_session(
|
|
181
|
+
CreatePaymentMethodSetupSessionParams(
|
|
182
|
+
org=org,
|
|
183
|
+
success_url="https://example.com/billing?setup=success",
|
|
184
|
+
cancel_url="https://example.com/billing",
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Error Handling
|
|
190
|
+
|
|
191
|
+
All SDK operations raise `StigmerError` with structured error codes:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
from stigmer import StigmerClient, StigmerError, is_not_found, is_retryable
|
|
195
|
+
|
|
196
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
197
|
+
try:
|
|
198
|
+
agent = client.agents.get("nonexistent")
|
|
199
|
+
except StigmerError as err:
|
|
200
|
+
if is_not_found(err):
|
|
201
|
+
print("Agent not found")
|
|
202
|
+
elif is_retryable(err):
|
|
203
|
+
print("Transient error, retry later")
|
|
204
|
+
else:
|
|
205
|
+
print(f"Error [{err.code.value}]: {err}")
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Error codes: `not-found`, `permission-denied`, `unauthenticated`, `invalid-argument`, `already-exists`, `resource-exhausted`, `failed-precondition`, `internal`, `unavailable`, `cancelled`, `unknown`.
|
|
209
|
+
|
|
210
|
+
## Configuration
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
StigmerClient(
|
|
214
|
+
api_key: str, # Stigmer API key (required)
|
|
215
|
+
*,
|
|
216
|
+
base_url: str = "api.stigmer.ai:443", # gRPC target address
|
|
217
|
+
insecure: bool = False, # Skip TLS (local development only)
|
|
218
|
+
)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
For a CI job or a script, use a [service account's](https://stigmer.ai/docs/guides/authentication/service-accounts) API key, not a person's: it keeps working when that person leaves and works only in its own organization.
|
|
222
|
+
|
|
223
|
+
## Code Generation
|
|
224
|
+
|
|
225
|
+
The resource clients in `src/stigmer/_gen/` are generated from protobuf service schemas. To regenerate after proto changes:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
cd sdk/python
|
|
229
|
+
make codegen
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Handwritten code lives in `src/stigmer/` (outside `_gen/`): `_client.py`, `_transport.py`, `_interceptors.py`, `_search.py`, `_tokens.py`, and `__init__.py`.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# stigmer
|
|
2
|
+
|
|
3
|
+
Python SDK for the Stigmer platform. Provides typed API clients for all Stigmer resources with authentication, error handling, and cross-resource search.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install stigmer-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`stigmer-apis` (generated protobuf stubs) is installed automatically as a dependency.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from stigmer import StigmerClient, AgentInput
|
|
17
|
+
|
|
18
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
19
|
+
agent = client.agents.create(AgentInput(name="my-agent", org="my-org"))
|
|
20
|
+
print(agent.metadata.name)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or without a context manager:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
client = StigmerClient("sk_live_abc123")
|
|
27
|
+
agent = client.agents.get("agent-id")
|
|
28
|
+
client.close()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Resource Clients
|
|
32
|
+
|
|
33
|
+
Every resource type has a typed client accessible as a property on `StigmerClient`:
|
|
34
|
+
|
|
35
|
+
| Property | Resource |
|
|
36
|
+
|------------------------|--------------------|
|
|
37
|
+
| `agents` | Agent |
|
|
38
|
+
| `runs` | Run |
|
|
39
|
+
| `api_keys` | ApiKey |
|
|
40
|
+
| `grants` | Grant |
|
|
41
|
+
| `identity_accounts` | IdentityAccount |
|
|
42
|
+
| `federation_issuers` | FederationIssuer |
|
|
43
|
+
| `organizations` | Organization |
|
|
44
|
+
| `plugins` | Plugin |
|
|
45
|
+
| `sessions` | Session |
|
|
46
|
+
| `skills` | Skill |
|
|
47
|
+
| `vaults` | Vault |
|
|
48
|
+
| `search` | Cross-resource search |
|
|
49
|
+
| `tokens` | User-token minting (service-account keys) |
|
|
50
|
+
|
|
51
|
+
## Common Operations
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from ai.stigmer.agentic.agent.v1 import io_pb2 as agent_io_pb2
|
|
55
|
+
from ai.stigmer.commons.apiresource import io_pb2 as apiresource_io_pb2
|
|
56
|
+
from stigmer import StigmerClient, AgentInput, ResourceRef
|
|
57
|
+
|
|
58
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
59
|
+
# Create
|
|
60
|
+
agent = client.agents.create(AgentInput(
|
|
61
|
+
name="my-agent",
|
|
62
|
+
org="my-org",
|
|
63
|
+
description="Handles customer inquiries",
|
|
64
|
+
instructions="Be helpful and concise.",
|
|
65
|
+
))
|
|
66
|
+
|
|
67
|
+
# Get by ID
|
|
68
|
+
agent = client.agents.get("agent-id")
|
|
69
|
+
|
|
70
|
+
# Get by reference (org + slug)
|
|
71
|
+
agent = client.agents.get_by_reference(ResourceRef(org="my-org", slug="my-agent"))
|
|
72
|
+
|
|
73
|
+
# Update: read, change, then name the fields you changed. Every other
|
|
74
|
+
# field keeps its stored value. The read's etag makes the save fail with
|
|
75
|
+
# "aborted" if someone changed the agent since.
|
|
76
|
+
current = client.agents.get("agent-id")
|
|
77
|
+
current.spec.description = "Updated description"
|
|
78
|
+
updated = client.agents.update(current, ["spec.description"])
|
|
79
|
+
|
|
80
|
+
# Rename: change the slug people type. The id stays, so everything that
|
|
81
|
+
# points at the agent keeps working; the old slug reads for 30 days.
|
|
82
|
+
renamed = client.agents.rename(
|
|
83
|
+
apiresource_io_pb2.RenameInput(resource_id="agent-id", slug="support-bot")
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Delete
|
|
87
|
+
deleted = client.agents.delete("agent-id")
|
|
88
|
+
|
|
89
|
+
# List: one page of the org's agents, newest first. A page carries
|
|
90
|
+
# next_page_token while more follow; page_size 0 asks for the default 50.
|
|
91
|
+
page = client.agents.list(agent_io_pb2.ListAgentsRequest(org="my-org", page_size=20))
|
|
92
|
+
|
|
93
|
+
# Every agent, page after page: list_all follows the tokens.
|
|
94
|
+
for a in client.agents.list_all(agent_io_pb2.ListAgentsRequest(org="my-org")):
|
|
95
|
+
print(a.metadata.slug)
|
|
96
|
+
|
|
97
|
+
# Only the agents carrying every label given.
|
|
98
|
+
support = client.agents.list(
|
|
99
|
+
agent_io_pb2.ListAgentsRequest(org="my-org", labels={"team": "support"})
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Cross-Resource Search
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from stigmer import StigmerClient, ApiResourceKind, SearchParams
|
|
107
|
+
|
|
108
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
109
|
+
results = client.search.query(SearchParams(
|
|
110
|
+
kinds=[ApiResourceKind.agent, ApiResourceKind.skill],
|
|
111
|
+
org="my-org",
|
|
112
|
+
query="customer support",
|
|
113
|
+
))
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## User Tokens
|
|
117
|
+
|
|
118
|
+
A product that embeds Stigmer mints a short-lived token for each person
|
|
119
|
+
signed in to it, from its own backend, with an ordinary client built on a
|
|
120
|
+
service account's API key. The account must be an admin of the organization
|
|
121
|
+
the token is for, or of its parent organization; a person's key is refused.
|
|
122
|
+
Pass `access_token` to the React SDK's `StigmerProvider` through
|
|
123
|
+
`getAccessToken`:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from stigmer import StigmerClient
|
|
127
|
+
|
|
128
|
+
with StigmerClient(os.environ["STIGMER_API_KEY"]) as client:
|
|
129
|
+
result = client.tokens.mint_user_token(
|
|
130
|
+
org="acme",
|
|
131
|
+
user_id=user.id,
|
|
132
|
+
user_email=user.email,
|
|
133
|
+
user_name=user.name,
|
|
134
|
+
)
|
|
135
|
+
print(result.access_token, result.expires_at)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Billing
|
|
139
|
+
|
|
140
|
+
An organization's billing account (its Stripe customer), the Stripe portal
|
|
141
|
+
and card setup sessions. Token usage is read from the run client's usage
|
|
142
|
+
reports (`get_run_usage_report`, `get_session_usage_report`,
|
|
143
|
+
`get_agent_usage_report`, `get_org_usage_report`), counted in tokens and never
|
|
144
|
+
priced. Queries require `can_view_billing` on the org and the org's own
|
|
145
|
+
billing commands require `can_manage_billing`. The operator pricing methods
|
|
146
|
+
(`list_model_pricing_baselines`, `upsert_model_pricing_baseline`,
|
|
147
|
+
`retire_model_pricing_baseline`) require `can_manage_model_pricing` on the
|
|
148
|
+
platform:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from stigmer import CreatePaymentMethodSetupSessionParams, StigmerClient
|
|
152
|
+
|
|
153
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
154
|
+
account = client.billing.get_billing_account(org)
|
|
155
|
+
|
|
156
|
+
setup = client.billing.create_payment_method_setup_session(
|
|
157
|
+
CreatePaymentMethodSetupSessionParams(
|
|
158
|
+
org=org,
|
|
159
|
+
success_url="https://example.com/billing?setup=success",
|
|
160
|
+
cancel_url="https://example.com/billing",
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Error Handling
|
|
166
|
+
|
|
167
|
+
All SDK operations raise `StigmerError` with structured error codes:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from stigmer import StigmerClient, StigmerError, is_not_found, is_retryable
|
|
171
|
+
|
|
172
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
173
|
+
try:
|
|
174
|
+
agent = client.agents.get("nonexistent")
|
|
175
|
+
except StigmerError as err:
|
|
176
|
+
if is_not_found(err):
|
|
177
|
+
print("Agent not found")
|
|
178
|
+
elif is_retryable(err):
|
|
179
|
+
print("Transient error, retry later")
|
|
180
|
+
else:
|
|
181
|
+
print(f"Error [{err.code.value}]: {err}")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Error codes: `not-found`, `permission-denied`, `unauthenticated`, `invalid-argument`, `already-exists`, `resource-exhausted`, `failed-precondition`, `internal`, `unavailable`, `cancelled`, `unknown`.
|
|
185
|
+
|
|
186
|
+
## Configuration
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
StigmerClient(
|
|
190
|
+
api_key: str, # Stigmer API key (required)
|
|
191
|
+
*,
|
|
192
|
+
base_url: str = "api.stigmer.ai:443", # gRPC target address
|
|
193
|
+
insecure: bool = False, # Skip TLS (local development only)
|
|
194
|
+
)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
For a CI job or a script, use a [service account's](https://stigmer.ai/docs/guides/authentication/service-accounts) API key, not a person's: it keeps working when that person leaves and works only in its own organization.
|
|
198
|
+
|
|
199
|
+
## Code Generation
|
|
200
|
+
|
|
201
|
+
The resource clients in `src/stigmer/_gen/` are generated from protobuf service schemas. To regenerate after proto changes:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
cd sdk/python
|
|
205
|
+
make codegen
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Handwritten code lives in `src/stigmer/` (outside `_gen/`): `_client.py`, `_transport.py`, `_interceptors.py`, `_search.py`, `_tokens.py`, and `__init__.py`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "stigmer-sdk"
|
|
7
|
+
version = "0.1.0.dev0"
|
|
8
|
+
description = "Stigmer Python SDK — typed API client for all Stigmer platform resources"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [{ name = "Stigmer", email = "engineering@stigmer.ai" }]
|
|
13
|
+
keywords = ["stigmer", "sdk", "api-client", "grpc", "ai-agents"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Typing :: Typed",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"grpcio>=1.60.0",
|
|
26
|
+
"protobuf>=6.32.0",
|
|
27
|
+
"stigmer-apis==0.1.0.dev0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://stigmer.ai"
|
|
32
|
+
Repository = "https://github.com/stigmer/stigmer"
|
|
33
|
+
Documentation = "https://docs.stigmer.ai/sdk/python"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/stigmer"]
|