stigmer-sdk 0.1.0.dev0__py3-none-any.whl
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/__init__.py +152 -0
- stigmer/_billing.py +220 -0
- stigmer/_client.py +124 -0
- stigmer/_gen/__init__.py +152 -0
- stigmer/_gen/_agent.py +343 -0
- stigmer/_gen/_apikey.py +146 -0
- stigmer/_gen/_bidi.py +40 -0
- stigmer/_gen/_channel.py +384 -0
- stigmer/_gen/_channelapp.py +169 -0
- stigmer/_gen/_client.py +65 -0
- stigmer/_gen/_errors.py +98 -0
- stigmer/_gen/_eval.py +178 -0
- stigmer/_gen/_evalrun.py +206 -0
- stigmer/_gen/_federationissuer.py +145 -0
- stigmer/_gen/_grant.py +187 -0
- stigmer/_gen/_identityaccount.py +212 -0
- stigmer/_gen/_invitation.py +117 -0
- stigmer/_gen/_license.py +174 -0
- stigmer/_gen/_memory.py +143 -0
- stigmer/_gen/_oauthapp.py +154 -0
- stigmer/_gen/_organization.py +223 -0
- stigmer/_gen/_plan.py +130 -0
- stigmer/_gen/_plugin.py +195 -0
- stigmer/_gen/_providerkey.py +54 -0
- stigmer/_gen/_run.py +536 -0
- stigmer/_gen/_schedule.py +219 -0
- stigmer/_gen/_score.py +184 -0
- stigmer/_gen/_scoringrule.py +102 -0
- stigmer/_gen/_session.py +243 -0
- stigmer/_gen/_skill.py +166 -0
- stigmer/_gen/_subscription.py +97 -0
- stigmer/_gen/_team.py +124 -0
- stigmer/_gen/_types.py +43 -0
- stigmer/_gen/_vault.py +293 -0
- stigmer/_github.py +95 -0
- stigmer/_interceptors.py +85 -0
- stigmer/_runner_adapter.py +58 -0
- stigmer/_search.py +97 -0
- stigmer/_skill.py +101 -0
- stigmer/_tokens.py +137 -0
- stigmer/_transport.py +47 -0
- stigmer/py.typed +0 -0
- stigmer_sdk-0.1.0.dev0.dist-info/METADATA +232 -0
- stigmer_sdk-0.1.0.dev0.dist-info/RECORD +45 -0
- stigmer_sdk-0.1.0.dev0.dist-info/WHEEL +4 -0
stigmer/__init__.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Stigmer Python SDK — typed API client for all Stigmer platform resources.
|
|
2
|
+
|
|
3
|
+
Usage::
|
|
4
|
+
|
|
5
|
+
from stigmer import StigmerClient, AgentInput
|
|
6
|
+
|
|
7
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
8
|
+
agent = client.agents.create(AgentInput(name="my-agent", org="my-org"))
|
|
9
|
+
print(agent.metadata.name)
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from ._billing import (
|
|
13
|
+
BillingClient,
|
|
14
|
+
CreateBillingPortalSessionParams,
|
|
15
|
+
CreatePaymentMethodSetupSessionParams,
|
|
16
|
+
RetireModelPricingBaselineParams,
|
|
17
|
+
UpsertModelPricingBaselineParams,
|
|
18
|
+
)
|
|
19
|
+
from ._client import StigmerClient
|
|
20
|
+
from ._runner_adapter import RunnerAdapter
|
|
21
|
+
from ._github import GitHubClient, GitHubRepoParams
|
|
22
|
+
from ._search import ApiResourceKind, SearchClient, SearchParams, SearchResponse
|
|
23
|
+
from ._tokens import MintUserTokenResult, TokenClient
|
|
24
|
+
|
|
25
|
+
# --- Resource clients and input types (generated) --------------------------
|
|
26
|
+
|
|
27
|
+
from ._gen._agent import (
|
|
28
|
+
AgentClient,
|
|
29
|
+
AgentInput,
|
|
30
|
+
AgentMcpServerInput,
|
|
31
|
+
RunConfigInput,
|
|
32
|
+
)
|
|
33
|
+
from ._gen._apikey import ApiKeyClient, ApiKeyInput
|
|
34
|
+
from ._gen._federationissuer import FederationIssuerClient, FederationIssuerInput
|
|
35
|
+
from ._gen._grant import ApiResourceRefInput, GrantClient, GrantInput
|
|
36
|
+
from ._gen._identityaccount import IdentityAccountClient, IdentityAccountInput
|
|
37
|
+
from ._gen._oauthapp import OAuthAppClient, OAuthAppInput
|
|
38
|
+
from ._gen._organization import OrganizationClient, OrganizationInput
|
|
39
|
+
from ._gen._plugin import PluginClient
|
|
40
|
+
from ._gen._run import (
|
|
41
|
+
AttachmentInput,
|
|
42
|
+
RunClient,
|
|
43
|
+
RunInput,
|
|
44
|
+
)
|
|
45
|
+
from ._gen._session import (
|
|
46
|
+
GitRepoSourceInput,
|
|
47
|
+
LocalPathSourceInput,
|
|
48
|
+
SessionClient,
|
|
49
|
+
SessionInput,
|
|
50
|
+
WorkspaceEntryInput,
|
|
51
|
+
WorkspaceSourceInput,
|
|
52
|
+
)
|
|
53
|
+
from ._gen._skill import SkillClient, SkillInput
|
|
54
|
+
from ._gen._vault import (
|
|
55
|
+
VaultClient,
|
|
56
|
+
VaultConnectionInput,
|
|
57
|
+
VaultConnectionSignInInput,
|
|
58
|
+
VaultInput,
|
|
59
|
+
VaultSecretInput,
|
|
60
|
+
)
|
|
61
|
+
from ._skill import MAX_INLINE_ARTIFACT_BYTES, RoutedSkillClient
|
|
62
|
+
|
|
63
|
+
# --- Shared types (generated) ----------------------------------------------
|
|
64
|
+
|
|
65
|
+
from ._gen._types import (
|
|
66
|
+
DeleteResourceInput,
|
|
67
|
+
ResourceRef,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# --- Error types (generated) -----------------------------------------------
|
|
71
|
+
|
|
72
|
+
from ._gen._errors import (
|
|
73
|
+
ErrorCode,
|
|
74
|
+
StigmerError,
|
|
75
|
+
is_not_found,
|
|
76
|
+
is_permission_denied,
|
|
77
|
+
is_retryable,
|
|
78
|
+
is_unauthenticated,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
__all__ = [
|
|
83
|
+
# Client
|
|
84
|
+
"StigmerClient",
|
|
85
|
+
# Runner adapter
|
|
86
|
+
"RunnerAdapter",
|
|
87
|
+
# Billing
|
|
88
|
+
"BillingClient",
|
|
89
|
+
"CreateBillingPortalSessionParams",
|
|
90
|
+
"CreatePaymentMethodSetupSessionParams",
|
|
91
|
+
"RetireModelPricingBaselineParams",
|
|
92
|
+
"UpsertModelPricingBaselineParams",
|
|
93
|
+
# GitHub
|
|
94
|
+
"GitHubClient",
|
|
95
|
+
"GitHubRepoParams",
|
|
96
|
+
# Search
|
|
97
|
+
"ApiResourceKind",
|
|
98
|
+
"SearchClient",
|
|
99
|
+
"SearchParams",
|
|
100
|
+
"SearchResponse",
|
|
101
|
+
# User tokens
|
|
102
|
+
"MintUserTokenResult",
|
|
103
|
+
"TokenClient",
|
|
104
|
+
# Resource clients
|
|
105
|
+
"AgentClient",
|
|
106
|
+
"ApiKeyClient",
|
|
107
|
+
"FederationIssuerClient",
|
|
108
|
+
"GrantClient",
|
|
109
|
+
"IdentityAccountClient",
|
|
110
|
+
"OAuthAppClient",
|
|
111
|
+
"OrganizationClient",
|
|
112
|
+
"PluginClient",
|
|
113
|
+
"RunClient",
|
|
114
|
+
"SessionClient",
|
|
115
|
+
"SkillClient",
|
|
116
|
+
"VaultClient",
|
|
117
|
+
"RoutedSkillClient",
|
|
118
|
+
"MAX_INLINE_ARTIFACT_BYTES",
|
|
119
|
+
# Input types
|
|
120
|
+
"AgentInput",
|
|
121
|
+
"AgentMcpServerInput",
|
|
122
|
+
"ApiKeyInput",
|
|
123
|
+
"ApiResourceRefInput",
|
|
124
|
+
"AttachmentInput",
|
|
125
|
+
"DeleteResourceInput",
|
|
126
|
+
"FederationIssuerInput",
|
|
127
|
+
"GitRepoSourceInput",
|
|
128
|
+
"GrantInput",
|
|
129
|
+
"IdentityAccountInput",
|
|
130
|
+
"LocalPathSourceInput",
|
|
131
|
+
"OAuthAppInput",
|
|
132
|
+
"OrganizationInput",
|
|
133
|
+
"RunInput",
|
|
134
|
+
"RunConfigInput",
|
|
135
|
+
"SessionInput",
|
|
136
|
+
"SkillInput",
|
|
137
|
+
"VaultConnectionInput",
|
|
138
|
+
"VaultConnectionSignInInput",
|
|
139
|
+
"VaultInput",
|
|
140
|
+
"VaultSecretInput",
|
|
141
|
+
"WorkspaceEntryInput",
|
|
142
|
+
"WorkspaceSourceInput",
|
|
143
|
+
# Shared types
|
|
144
|
+
"ResourceRef",
|
|
145
|
+
# Errors
|
|
146
|
+
"ErrorCode",
|
|
147
|
+
"StigmerError",
|
|
148
|
+
"is_not_found",
|
|
149
|
+
"is_permission_denied",
|
|
150
|
+
"is_retryable",
|
|
151
|
+
"is_unauthenticated",
|
|
152
|
+
]
|
stigmer/_billing.py
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"""Billing client for the Stigmer SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Iterator
|
|
7
|
+
|
|
8
|
+
import grpc
|
|
9
|
+
|
|
10
|
+
from ai.stigmer.billing.v1 import billing_account_pb2
|
|
11
|
+
from ai.stigmer.billing.v1 import command_pb2_grpc
|
|
12
|
+
from ai.stigmer.billing.v1 import io_pb2 as billing_io_pb2
|
|
13
|
+
from ai.stigmer.billing.v1 import model_pricing_baseline_pb2
|
|
14
|
+
from ai.stigmer.billing.v1 import query_pb2_grpc
|
|
15
|
+
|
|
16
|
+
from ._gen._errors import wrap_error
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class CreateBillingPortalSessionParams:
|
|
21
|
+
"""Parameters for creating a Stripe Billing Portal session."""
|
|
22
|
+
|
|
23
|
+
org: str
|
|
24
|
+
return_url: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class CreatePaymentMethodSetupSessionParams:
|
|
29
|
+
"""Parameters for creating a Stripe Checkout Session that saves a card."""
|
|
30
|
+
|
|
31
|
+
org: str
|
|
32
|
+
success_url: str
|
|
33
|
+
cancel_url: str
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class UpsertModelPricingBaselineParams:
|
|
38
|
+
"""Parameters for creating or revising a model registry baseline entry."""
|
|
39
|
+
|
|
40
|
+
baseline: model_pricing_baseline_pb2.ModelPricingBaseline
|
|
41
|
+
"""The baseline entry to create or revise, keyed by
|
|
42
|
+
(model_id, provider, harness). Lifecycle fields (baseline_id, status,
|
|
43
|
+
decision stamps, pricing effective_at) are server-owned and ignored."""
|
|
44
|
+
revision_note: str = ""
|
|
45
|
+
"""Optional operator note recorded on the revision for the audit trail."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class RetireModelPricingBaselineParams:
|
|
50
|
+
"""Parameters for retiring a model from the registry catalog."""
|
|
51
|
+
|
|
52
|
+
model_id: str
|
|
53
|
+
provider: str
|
|
54
|
+
harness: str
|
|
55
|
+
revision_note: str = ""
|
|
56
|
+
"""Optional operator note recorded on the retirement."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class BillingClient:
|
|
60
|
+
"""Billing bounded-context client.
|
|
61
|
+
|
|
62
|
+
Wraps the user-facing billing RPCs: the organization's billing account
|
|
63
|
+
(its Stripe customer), the Stripe portal and card setup sessions, and
|
|
64
|
+
the operator model-pricing surfaces. Responses are returned as proto
|
|
65
|
+
messages — the proto types are the contract. Token usage is read from
|
|
66
|
+
the run client's usage reports (``get_run_usage_report``,
|
|
67
|
+
``get_session_usage_report``, ``get_agent_usage_report``,
|
|
68
|
+
``get_org_usage_report``), counted in tokens and never priced.
|
|
69
|
+
|
|
70
|
+
The proxy's metering write (``recordLlmCallUsage``) is not exposed;
|
|
71
|
+
only the server calls it.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
def __init__(self, channel: grpc.Channel) -> None:
|
|
75
|
+
self._command = command_pb2_grpc.BillingCommandControllerStub(channel)
|
|
76
|
+
self._query = query_pb2_grpc.BillingQueryControllerStub(channel)
|
|
77
|
+
|
|
78
|
+
# ── Account ──────────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
def get_or_create_billing_account(
|
|
81
|
+
self, org: str
|
|
82
|
+
) -> billing_account_pb2.BillingAccount:
|
|
83
|
+
"""Provision or retrieve the billing account for an organization.
|
|
84
|
+
|
|
85
|
+
Idempotent: creates the account on first call, returns the existing
|
|
86
|
+
account on subsequent calls.
|
|
87
|
+
"""
|
|
88
|
+
req = billing_io_pb2.GetOrCreateBillingAccountInput(org=org)
|
|
89
|
+
try:
|
|
90
|
+
return self._command.getOrCreateBillingAccount(req)
|
|
91
|
+
except grpc.RpcError as e:
|
|
92
|
+
raise wrap_error(e) from e
|
|
93
|
+
|
|
94
|
+
def get_billing_account(self, org: str) -> billing_account_pb2.BillingAccount:
|
|
95
|
+
"""Retrieve the billing account for an organization."""
|
|
96
|
+
req = billing_io_pb2.GetBillingAccountInput(org=org)
|
|
97
|
+
try:
|
|
98
|
+
return self._query.getBillingAccount(req)
|
|
99
|
+
except grpc.RpcError as e:
|
|
100
|
+
raise wrap_error(e) from e
|
|
101
|
+
|
|
102
|
+
# ── Stripe ───────────────────────────────────────────────────────────
|
|
103
|
+
|
|
104
|
+
def create_billing_portal_session(
|
|
105
|
+
self, params: CreateBillingPortalSessionParams
|
|
106
|
+
) -> billing_io_pb2.CreateBillingPortalSessionResponse:
|
|
107
|
+
"""Create a Stripe Billing Portal session for payment method management.
|
|
108
|
+
|
|
109
|
+
Returns the Stripe-hosted portal URL. The caller should redirect the
|
|
110
|
+
user to ``portal_url``; changes are synced back via webhooks.
|
|
111
|
+
"""
|
|
112
|
+
req = billing_io_pb2.CreateBillingPortalSessionInput(
|
|
113
|
+
org=params.org,
|
|
114
|
+
return_url=params.return_url,
|
|
115
|
+
)
|
|
116
|
+
try:
|
|
117
|
+
return self._command.createBillingPortalSession(req)
|
|
118
|
+
except grpc.RpcError as e:
|
|
119
|
+
raise wrap_error(e) from e
|
|
120
|
+
|
|
121
|
+
def create_payment_method_setup_session(
|
|
122
|
+
self, params: CreatePaymentMethodSetupSessionParams
|
|
123
|
+
) -> billing_io_pb2.CreatePaymentMethodSetupSessionResponse:
|
|
124
|
+
"""Create a Stripe Checkout Session that saves a payment method.
|
|
125
|
+
|
|
126
|
+
Returns the Stripe-hosted setup URL. The caller should redirect the
|
|
127
|
+
user to ``setup_url``. This is how an organization puts a card on
|
|
128
|
+
file for its plan's invoices; nothing is charged.
|
|
129
|
+
"""
|
|
130
|
+
req = billing_io_pb2.CreatePaymentMethodSetupSessionInput(
|
|
131
|
+
org=params.org,
|
|
132
|
+
success_url=params.success_url,
|
|
133
|
+
cancel_url=params.cancel_url,
|
|
134
|
+
)
|
|
135
|
+
try:
|
|
136
|
+
return self._command.createPaymentMethodSetupSession(req)
|
|
137
|
+
except grpc.RpcError as e:
|
|
138
|
+
raise wrap_error(e) from e
|
|
139
|
+
|
|
140
|
+
# ── Pricing ──────────────────────────────────────────────────────────
|
|
141
|
+
|
|
142
|
+
def list_model_pricing_baselines(
|
|
143
|
+
self,
|
|
144
|
+
include_history: bool = False,
|
|
145
|
+
page_size: int = 0,
|
|
146
|
+
page_token: str = "",
|
|
147
|
+
) -> billing_io_pb2.ModelPricingBaselinesResponse:
|
|
148
|
+
"""Retrieve one page of the model registry baseline catalog.
|
|
149
|
+
|
|
150
|
+
ACTIVE entries by default, or the full append-only revision history
|
|
151
|
+
with ``include_history=True``. ``page_size`` 0 asks for the default
|
|
152
|
+
page of 50, and above 100 reads 100; pass a response's
|
|
153
|
+
``next_page_token`` as ``page_token`` to continue.
|
|
154
|
+
|
|
155
|
+
Platform-operator surface (``can_manage_model_pricing`` on
|
|
156
|
+
``platform:stigmer``): rates are the providers' list prices.
|
|
157
|
+
"""
|
|
158
|
+
req = billing_io_pb2.ListModelPricingBaselinesInput(
|
|
159
|
+
include_history=include_history,
|
|
160
|
+
page_size=page_size,
|
|
161
|
+
page_token=page_token,
|
|
162
|
+
)
|
|
163
|
+
try:
|
|
164
|
+
return self._query.listModelPricingBaselines(req)
|
|
165
|
+
except grpc.RpcError as e:
|
|
166
|
+
raise wrap_error(e) from e
|
|
167
|
+
|
|
168
|
+
def list_model_pricing_baselines_all(
|
|
169
|
+
self,
|
|
170
|
+
include_history: bool = False,
|
|
171
|
+
page_size: int = 0,
|
|
172
|
+
page_token: str = "",
|
|
173
|
+
) -> Iterator[model_pricing_baseline_pb2.ModelPricingBaseline]:
|
|
174
|
+
"""Every baseline of the catalog, page after page: follows
|
|
175
|
+
``next_page_token`` from ``page_token`` until the catalog ends."""
|
|
176
|
+
token = page_token
|
|
177
|
+
while True:
|
|
178
|
+
page = self.list_model_pricing_baselines(include_history, page_size, token)
|
|
179
|
+
yield from page.entries
|
|
180
|
+
if not page.next_page_token:
|
|
181
|
+
return
|
|
182
|
+
token = page.next_page_token
|
|
183
|
+
|
|
184
|
+
def upsert_model_pricing_baseline(
|
|
185
|
+
self, params: UpsertModelPricingBaselineParams
|
|
186
|
+
) -> model_pricing_baseline_pb2.ModelPricingBaseline:
|
|
187
|
+
"""Create or revise one model registry baseline entry.
|
|
188
|
+
|
|
189
|
+
Append-only: an existing ACTIVE entry for the same
|
|
190
|
+
(model_id, provider, harness) key is superseded, never mutated, and
|
|
191
|
+
the registry is rebuilt immediately. Returns the new
|
|
192
|
+
revision with server-stamped lifecycle fields.
|
|
193
|
+
"""
|
|
194
|
+
req = billing_io_pb2.UpsertModelPricingBaselineInput(
|
|
195
|
+
baseline=params.baseline,
|
|
196
|
+
revision_note=params.revision_note,
|
|
197
|
+
)
|
|
198
|
+
try:
|
|
199
|
+
return self._command.upsertModelPricingBaseline(req)
|
|
200
|
+
except grpc.RpcError as e:
|
|
201
|
+
raise wrap_error(e) from e
|
|
202
|
+
|
|
203
|
+
def retire_model_pricing_baseline(
|
|
204
|
+
self, params: RetireModelPricingBaselineParams
|
|
205
|
+
) -> model_pricing_baseline_pb2.ModelPricingBaseline:
|
|
206
|
+
"""Retire one model from the registry catalog.
|
|
207
|
+
|
|
208
|
+
The rebuilt registry drops it from every price surface; the document
|
|
209
|
+
is kept for audit and the key can be revived by a subsequent upsert.
|
|
210
|
+
"""
|
|
211
|
+
req = billing_io_pb2.RetireModelPricingBaselineInput(
|
|
212
|
+
model_id=params.model_id,
|
|
213
|
+
provider=params.provider,
|
|
214
|
+
harness=params.harness,
|
|
215
|
+
revision_note=params.revision_note,
|
|
216
|
+
)
|
|
217
|
+
try:
|
|
218
|
+
return self._command.retireModelPricingBaseline(req)
|
|
219
|
+
except grpc.RpcError as e:
|
|
220
|
+
raise wrap_error(e) from e
|
stigmer/_client.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""Top-level Stigmer API client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Literal
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
|
|
8
|
+
import grpc
|
|
9
|
+
|
|
10
|
+
from ._billing import BillingClient
|
|
11
|
+
from ._gen._client import GeneratedClient
|
|
12
|
+
from ._github import GitHubClient
|
|
13
|
+
from ._runner_adapter import RunnerAdapter
|
|
14
|
+
from ._search import SearchClient
|
|
15
|
+
from ._skill import RoutedSkillClient
|
|
16
|
+
from ._tokens import TokenClient
|
|
17
|
+
from ._transport import DEFAULT_TARGET, create_channel
|
|
18
|
+
|
|
19
|
+
ExecutionTargetOption = Literal["local", "cloud"]
|
|
20
|
+
|
|
21
|
+
_EXECUTION_TARGET_MAP = {
|
|
22
|
+
"local": 1, # EXECUTION_TARGET_LOCAL
|
|
23
|
+
"cloud": 2, # EXECUTION_TARGET_CLOUD
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class StigmerClient(GeneratedClient):
|
|
28
|
+
"""Stigmer API client.
|
|
29
|
+
|
|
30
|
+
Extends the code-generated :class:`GeneratedClient` so every resource
|
|
31
|
+
sub-client (agents, sessions, plugins, oauthapps, …) is inherited
|
|
32
|
+
automatically — new resource clients added by codegen appear on this
|
|
33
|
+
class without manual wiring.
|
|
34
|
+
|
|
35
|
+
On top of the generated resource clients, ``StigmerClient`` adds:
|
|
36
|
+
|
|
37
|
+
- Configuration and gRPC channel setup
|
|
38
|
+
- Cross-resource :attr:`search` client
|
|
39
|
+
- :attr:`github` OAuth integration client
|
|
40
|
+
- :attr:`billing` bounded-context client
|
|
41
|
+
- :attr:`tokens` user-token minting client (service-account keys)
|
|
42
|
+
|
|
43
|
+
Usage::
|
|
44
|
+
|
|
45
|
+
client = StigmerClient("sk_live_abc123")
|
|
46
|
+
agent = client.agents.get("agent-id")
|
|
47
|
+
client.close()
|
|
48
|
+
|
|
49
|
+
As a context manager::
|
|
50
|
+
|
|
51
|
+
with StigmerClient("sk_live_abc123") as client:
|
|
52
|
+
agent = client.agents.get("agent-id")
|
|
53
|
+
|
|
54
|
+
With an app-level execution target::
|
|
55
|
+
|
|
56
|
+
client = StigmerClient("sk_live_abc123", execution_target="local")
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
search: SearchClient
|
|
60
|
+
github: GitHubClient
|
|
61
|
+
billing: BillingClient
|
|
62
|
+
tokens: TokenClient
|
|
63
|
+
skills: RoutedSkillClient
|
|
64
|
+
default_execution_target: int
|
|
65
|
+
runner_adapter: RunnerAdapter | None
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
api_key: str,
|
|
70
|
+
*,
|
|
71
|
+
base_url: str = DEFAULT_TARGET,
|
|
72
|
+
insecure: bool = False,
|
|
73
|
+
execution_target: ExecutionTargetOption | None = None,
|
|
74
|
+
runner_adapter: RunnerAdapter | None = None,
|
|
75
|
+
) -> None:
|
|
76
|
+
"""Create a Stigmer client.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
api_key: Stigmer API key (``sk_live_...``).
|
|
80
|
+
base_url: gRPC target address. Defaults to ``api.stigmer.ai:443``.
|
|
81
|
+
insecure: Disable TLS (local development only).
|
|
82
|
+
execution_target: Default execution target for all sessions
|
|
83
|
+
created through this client. ``"local"`` means the client
|
|
84
|
+
provides runners; ``"cloud"`` means the server provisions
|
|
85
|
+
sandboxes. ``None`` lets the server decide.
|
|
86
|
+
runner_adapter: Runner adapter for local execution lifecycle
|
|
87
|
+
management. When ``execution_target`` is ``"local"``, the
|
|
88
|
+
adapter is driven when a session opens and closes.
|
|
89
|
+
Cloud consumers omit this.
|
|
90
|
+
"""
|
|
91
|
+
if not api_key:
|
|
92
|
+
raise ValueError("stigmer: API key is required")
|
|
93
|
+
|
|
94
|
+
self._channel = create_channel(base_url, api_key, insecure=insecure)
|
|
95
|
+
super().__init__(self._channel)
|
|
96
|
+
|
|
97
|
+
self.default_execution_target = (
|
|
98
|
+
_EXECUTION_TARGET_MAP[execution_target] if execution_target else 0
|
|
99
|
+
)
|
|
100
|
+
self.runner_adapter = runner_adapter
|
|
101
|
+
self.search = SearchClient(self._channel)
|
|
102
|
+
self.github = GitHubClient(self._channel)
|
|
103
|
+
self.billing = BillingClient(self._channel)
|
|
104
|
+
self.tokens = TokenClient(self._channel)
|
|
105
|
+
# Shadow the inherited generated client with the size-routing wrapper
|
|
106
|
+
# (stigmer#675): `client.skills.push` simply works for any valid
|
|
107
|
+
# skill size — large artifacts ride the HTTP transfer lane.
|
|
108
|
+
self.skills = RoutedSkillClient(self._channel)
|
|
109
|
+
|
|
110
|
+
def close(self) -> None:
|
|
111
|
+
"""Release the underlying gRPC channel."""
|
|
112
|
+
if self._channel is not None:
|
|
113
|
+
self._channel.close()
|
|
114
|
+
|
|
115
|
+
def __enter__(self) -> StigmerClient:
|
|
116
|
+
return self
|
|
117
|
+
|
|
118
|
+
def __exit__(
|
|
119
|
+
self,
|
|
120
|
+
exc_type: type[BaseException] | None,
|
|
121
|
+
exc_val: BaseException | None,
|
|
122
|
+
exc_tb: TracebackType | None,
|
|
123
|
+
) -> None:
|
|
124
|
+
self.close()
|
stigmer/_gen/__init__.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
from ._bidi import BidiStream
|
|
4
|
+
from ._client import GeneratedClient
|
|
5
|
+
from ._agent import AgentClient, AgentInput, EnvVarDeclarationInput, HookSourceInput, HookConfigInput, HookGroupInput, HookHandlerInput, RunConfigInput, AgentMcpServerInput
|
|
6
|
+
from ._apikey import ApiKeyClient, ApiKeyInput
|
|
7
|
+
from ._channel import ChannelClient, ChannelInput, WebChannelConfigInput, WebChannelMessagesInput, SlackChannelConfigInput, WhatsAppChannelConfigInput
|
|
8
|
+
from ._channelapp import ChannelAppClient, ChannelAppInput, SlackChannelAppConfigInput, WhatsAppChannelAppConfigInput
|
|
9
|
+
from ._eval import EvalClient, EvalInput
|
|
10
|
+
from ._evalrun import EvalRunClient, EvalRunInput, EvalRunCaseSourceInput, EvalRunTargetInput
|
|
11
|
+
from ._federationissuer import FederationIssuerClient, FederationIssuerInput
|
|
12
|
+
from ._grant import GrantClient, GrantInput, ApiResourceRefInput
|
|
13
|
+
from ._identityaccount import IdentityAccountClient, IdentityAccountInput, IdentityAccountPreferencesInput
|
|
14
|
+
from ._invitation import InvitationClient, InvitationInput
|
|
15
|
+
from ._license import LicenseClient, LicenseInput, LicenseCustomerInput, EntitlementsInput, EntitlementLimitsInput
|
|
16
|
+
from ._memory import MemoryClient, MemoryInput, MemoryProvenanceInput
|
|
17
|
+
from ._oauthapp import OAuthAppClient, OAuthAppInput
|
|
18
|
+
from ._organization import OrganizationClient, OrganizationInput, OrganizationPreferencesInput, OrganizationPoliciesInput, OrganizationEmbeddingInput
|
|
19
|
+
from ._plan import PlanClient, PlanInput, PlanTermsInput
|
|
20
|
+
from ._plugin import PluginClient, PluginInput, PluginAuthorInput
|
|
21
|
+
from ._providerkey import ProviderKeyClient
|
|
22
|
+
from ._run import RunClient, RunInput, SessionSpecInput, WorkspaceEntryInput, WorkspaceSourceInput, GitRepoSourceInput, LocalPathSourceInput, AttachmentInput, ConversationCatchupInput, EvalCaseContextInput, EvalMockServerInput, EvalMockToolInput, EvalMockPluginHomeInput, EvalMockAgentHomeInput
|
|
23
|
+
from ._schedule import ScheduleClient, ScheduleInput, AgentInvocationInput
|
|
24
|
+
from ._score import ScoreClient, ScoreInput, ScoreCriterionInput
|
|
25
|
+
from ._scoringrule import ScoringRuleClient, ScoringRuleInput
|
|
26
|
+
from ._session import SessionClient, SessionInput
|
|
27
|
+
from ._skill import SkillClient, SkillInput
|
|
28
|
+
from ._subscription import SubscriptionClient, SubscriptionInput
|
|
29
|
+
from ._team import TeamClient, TeamInput
|
|
30
|
+
from ._vault import VaultClient, VaultInput, VaultSecretInput, VaultConnectionInput, VaultConnectionSignInInput
|
|
31
|
+
from ._types import (
|
|
32
|
+
DeleteResourceInput,
|
|
33
|
+
ResourceRef,
|
|
34
|
+
)
|
|
35
|
+
from ._errors import (
|
|
36
|
+
ErrorCode,
|
|
37
|
+
StigmerError,
|
|
38
|
+
is_not_found,
|
|
39
|
+
is_permission_denied,
|
|
40
|
+
is_retryable,
|
|
41
|
+
is_unauthenticated,
|
|
42
|
+
is_unimplemented,
|
|
43
|
+
wrap_error,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"GeneratedClient",
|
|
48
|
+
"AgentClient",
|
|
49
|
+
"AgentInput",
|
|
50
|
+
"EnvVarDeclarationInput",
|
|
51
|
+
"HookSourceInput",
|
|
52
|
+
"HookConfigInput",
|
|
53
|
+
"HookGroupInput",
|
|
54
|
+
"HookHandlerInput",
|
|
55
|
+
"RunConfigInput",
|
|
56
|
+
"AgentMcpServerInput",
|
|
57
|
+
"ApiKeyClient",
|
|
58
|
+
"ApiKeyInput",
|
|
59
|
+
"ChannelClient",
|
|
60
|
+
"ChannelInput",
|
|
61
|
+
"WebChannelConfigInput",
|
|
62
|
+
"WebChannelMessagesInput",
|
|
63
|
+
"SlackChannelConfigInput",
|
|
64
|
+
"WhatsAppChannelConfigInput",
|
|
65
|
+
"ChannelAppClient",
|
|
66
|
+
"ChannelAppInput",
|
|
67
|
+
"SlackChannelAppConfigInput",
|
|
68
|
+
"WhatsAppChannelAppConfigInput",
|
|
69
|
+
"EvalClient",
|
|
70
|
+
"EvalInput",
|
|
71
|
+
"EvalRunClient",
|
|
72
|
+
"EvalRunInput",
|
|
73
|
+
"EvalRunCaseSourceInput",
|
|
74
|
+
"EvalRunTargetInput",
|
|
75
|
+
"FederationIssuerClient",
|
|
76
|
+
"FederationIssuerInput",
|
|
77
|
+
"GrantClient",
|
|
78
|
+
"GrantInput",
|
|
79
|
+
"ApiResourceRefInput",
|
|
80
|
+
"IdentityAccountClient",
|
|
81
|
+
"IdentityAccountInput",
|
|
82
|
+
"IdentityAccountPreferencesInput",
|
|
83
|
+
"InvitationClient",
|
|
84
|
+
"InvitationInput",
|
|
85
|
+
"LicenseClient",
|
|
86
|
+
"LicenseInput",
|
|
87
|
+
"LicenseCustomerInput",
|
|
88
|
+
"EntitlementsInput",
|
|
89
|
+
"EntitlementLimitsInput",
|
|
90
|
+
"MemoryClient",
|
|
91
|
+
"MemoryInput",
|
|
92
|
+
"MemoryProvenanceInput",
|
|
93
|
+
"OAuthAppClient",
|
|
94
|
+
"OAuthAppInput",
|
|
95
|
+
"OrganizationClient",
|
|
96
|
+
"OrganizationInput",
|
|
97
|
+
"OrganizationPreferencesInput",
|
|
98
|
+
"OrganizationPoliciesInput",
|
|
99
|
+
"OrganizationEmbeddingInput",
|
|
100
|
+
"PlanClient",
|
|
101
|
+
"PlanInput",
|
|
102
|
+
"PlanTermsInput",
|
|
103
|
+
"PluginClient",
|
|
104
|
+
"PluginInput",
|
|
105
|
+
"PluginAuthorInput",
|
|
106
|
+
"ProviderKeyClient",
|
|
107
|
+
"RunClient",
|
|
108
|
+
"RunInput",
|
|
109
|
+
"SessionSpecInput",
|
|
110
|
+
"WorkspaceEntryInput",
|
|
111
|
+
"WorkspaceSourceInput",
|
|
112
|
+
"GitRepoSourceInput",
|
|
113
|
+
"LocalPathSourceInput",
|
|
114
|
+
"AttachmentInput",
|
|
115
|
+
"ConversationCatchupInput",
|
|
116
|
+
"EvalCaseContextInput",
|
|
117
|
+
"EvalMockServerInput",
|
|
118
|
+
"EvalMockToolInput",
|
|
119
|
+
"EvalMockPluginHomeInput",
|
|
120
|
+
"EvalMockAgentHomeInput",
|
|
121
|
+
"ScheduleClient",
|
|
122
|
+
"ScheduleInput",
|
|
123
|
+
"AgentInvocationInput",
|
|
124
|
+
"ScoreClient",
|
|
125
|
+
"ScoreInput",
|
|
126
|
+
"ScoreCriterionInput",
|
|
127
|
+
"ScoringRuleClient",
|
|
128
|
+
"ScoringRuleInput",
|
|
129
|
+
"SessionClient",
|
|
130
|
+
"SessionInput",
|
|
131
|
+
"SkillClient",
|
|
132
|
+
"SkillInput",
|
|
133
|
+
"SubscriptionClient",
|
|
134
|
+
"SubscriptionInput",
|
|
135
|
+
"TeamClient",
|
|
136
|
+
"TeamInput",
|
|
137
|
+
"VaultClient",
|
|
138
|
+
"VaultInput",
|
|
139
|
+
"VaultSecretInput",
|
|
140
|
+
"VaultConnectionInput",
|
|
141
|
+
"VaultConnectionSignInInput",
|
|
142
|
+
"DeleteResourceInput",
|
|
143
|
+
"ResourceRef",
|
|
144
|
+
"ErrorCode",
|
|
145
|
+
"StigmerError",
|
|
146
|
+
"is_not_found",
|
|
147
|
+
"is_permission_denied",
|
|
148
|
+
"is_retryable",
|
|
149
|
+
"is_unauthenticated",
|
|
150
|
+
"is_unimplemented",
|
|
151
|
+
"wrap_error",
|
|
152
|
+
]
|