nevarn-sdk 0.1.0__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.
nevarn/Client.py ADDED
@@ -0,0 +1,156 @@
1
+ """The Nevarn client: the routes an API key can call, and nothing that widens its bounds.
2
+
3
+ ``proposeIntent`` sends a bot's intent for a shadow ruling (scope
4
+ ``intents``); ``executeIntent`` and ``getExecution`` have one executed under
5
+ Decionis policy within the key's limits, on paper in Sandbox and live in
6
+ Production (``execute``); ``getMandate`` and ``getReceipt`` read the bot's
7
+ bounds and its execution receipts (``read``); ``halt`` turns the tenant's
8
+ signing off (``halt``); ``requestSpend`` files a supplier invoice
9
+ (``invoices``).
10
+ There is deliberately no method for limits, resume, keys, vendors or
11
+ approvals: those routes take an owner's session, and this client refuses
12
+ sessions.
13
+
14
+ Transport conventions follow the agents' tenant feed: no redirects are
15
+ followed, the timeout is 5 seconds, and neither the upstream body nor the
16
+ transport exception is re-raised, because both can carry the request.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import logging
22
+ from datetime import datetime
23
+ from uuid import UUID
24
+
25
+ import httpx
26
+
27
+ from .Config import ApiKey, BaseUrl
28
+ from .Errors import NevarnError, RateLimited, RedirectRefused, TransportError, UnexpectedResponse, forStatus
29
+ from .Execution import PATH as EXECUTION_PATH
30
+ from .Execution import Execution, ExecutionGate
31
+ from .Intent import PATH as INTENT_PATH
32
+ from .Intent import IntentRequest, IntentRuling
33
+ from .Mandate import HALT_PATH, Halted, HaltRequest, Mandate
34
+ from .Mandate import PATH as MANDATE_PATH
35
+ from .Receipt import Receipt, ReceiptGate
36
+ from .Spend import PATH as SPEND_PATH
37
+ from .Spend import Invoice, SpendRequest
38
+ from .Version import USER_AGENT
39
+
40
+ TIMEOUT_SECONDS = 5.0
41
+ log = logging.getLogger("nevarn")
42
+
43
+
44
+ class Client:
45
+ def __init__(self, *, baseUrl: str, apiKey: str | None = None, httpClient: httpx.Client | None = None) -> None:
46
+ self.baseUrl = BaseUrl(baseUrl)
47
+ self._key = ApiKey(apiKey)
48
+ self._http = httpClient if httpClient is not None else httpx.Client(follow_redirects=False)
49
+ self._ownsHttp = httpClient is None
50
+
51
+ def __repr__(self) -> str:
52
+ return f"Client(baseUrl={self.baseUrl.value!r}, apiKey=<redacted>)"
53
+
54
+ def __enter__(self) -> Client:
55
+ return self
56
+
57
+ def __exit__(self, *_exc) -> None:
58
+ self.close()
59
+
60
+ def close(self) -> None:
61
+ if self._ownsHttp:
62
+ self._http.close()
63
+
64
+ def requestSpend(
65
+ self,
66
+ *,
67
+ vendorId: UUID | str,
68
+ invoiceNumber: str,
69
+ amountMinor: int,
70
+ destinationAddress: str,
71
+ assetCode: str = "USDC",
72
+ chainId: int = 137,
73
+ dueAt: datetime | None = None,
74
+ proofHash: str | None = None,
75
+ ) -> Invoice:
76
+ """File an invoice; the platform's payables policy decides what is paid."""
77
+ request = SpendRequest(
78
+ vendorId=vendorId, invoiceNumber=invoiceNumber, amountMinor=amountMinor,
79
+ destinationAddress=destinationAddress, assetCode=assetCode, chainId=chainId,
80
+ dueAt=dueAt, proofHash=proofHash,
81
+ )
82
+ status, data = self._send("POST", SPEND_PATH, request.body())
83
+ return Invoice.fromJson(data, status=status)
84
+
85
+ def proposeIntent(self, *, strategy: str, intentKey: str, intent: dict) -> IntentRuling:
86
+ """Ask for a shadow ruling on an intent. Nothing is sent to a venue; reuse a key to retry safely."""
87
+ request = IntentRequest(strategy=strategy, intentKey=intentKey, intent=intent)
88
+ status, data = self._send("POST", INTENT_PATH, request.body())
89
+ return IntentRuling.fromJson(data, status=status)
90
+
91
+ def executeIntent(self, *, strategy: str, intentKey: str, intent: dict) -> Execution:
92
+ """Execute an intent within the key's limits: on paper in Sandbox, live in Production. Reuse a key to retry."""
93
+ request = IntentRequest(strategy=strategy, intentKey=intentKey, intent=intent)
94
+ status, data = self._send("POST", EXECUTION_PATH, request.body())
95
+ return Execution.fromJson(data, status=status)
96
+
97
+ def getExecution(self, executionId: UUID | str) -> Execution:
98
+ """One execution, by the id ``executeIntent`` returned, with its current state."""
99
+ path = ExecutionGate.path(executionId)
100
+ status, data = self._send("GET", path)
101
+ return Execution.fromJson(data, status=status, path=path)
102
+
103
+ def getMandate(self) -> Mandate:
104
+ """The bot's bounds as the console shows them. Read-only."""
105
+ status, data = self._send("GET", MANDATE_PATH)
106
+ return Mandate.fromJson(data, status=status)
107
+
108
+ def getReceipt(self, receiptId: UUID | str) -> Receipt:
109
+ """One execution receipt, by its execution's id."""
110
+ path = ReceiptGate.path(receiptId)
111
+ status, data = self._send("GET", path)
112
+ return Receipt.fromJson(data, status=status)
113
+
114
+ def halt(self, reason: str | None = None) -> Halted:
115
+ """Turn all of the tenant's signing off. Idempotent. There is no resume."""
116
+ status, data = self._send("POST", HALT_PATH, HaltRequest.body(reason))
117
+ return Halted.fromJson(data, status=status)
118
+
119
+ def _send(self, method: str, path: str, body: dict | None = None) -> tuple[int, object]:
120
+ headers = {
121
+ "Authorization": self._key.authorization(),
122
+ "User-Agent": USER_AGENT,
123
+ "Accept": "application/json",
124
+ }
125
+ try:
126
+ response = self._http.request(
127
+ method, self.baseUrl.join(path), json=body if method != "GET" else None, headers=headers,
128
+ timeout=TIMEOUT_SECONDS, follow_redirects=False,
129
+ )
130
+ except httpx.HTTPError:
131
+ log.warning("nevarn %s %s unreachable", method, path)
132
+ raise TransportError(path=path) from None
133
+ status = response.status_code
134
+ log.debug("nevarn %s %s -> %s", method, path, status)
135
+ if 300 <= status < 400:
136
+ raise RedirectRefused(status=status, path=path)
137
+ try:
138
+ data = response.json()
139
+ except ValueError:
140
+ data = None
141
+ if status in (200, 201):
142
+ if data is None:
143
+ raise UnexpectedResponse(status=status, path=path)
144
+ return status, data
145
+ raise self._failure(status, path, data, response.headers.get("retry-after"))
146
+
147
+ @staticmethod
148
+ def _failure(status: int, path: str, data: object, retryAfter: str | None) -> NevarnError:
149
+ error = data.get("error") if isinstance(data, dict) else None
150
+ code = error.get("code") if isinstance(error, dict) else None
151
+ code = code if isinstance(code, str) else None
152
+ kind = forStatus(status, path)
153
+ if kind is RateLimited:
154
+ seconds = int(retryAfter) if retryAfter and retryAfter.isdigit() else None
155
+ return RateLimited(status=status, code=code, path=path, retryAfter=seconds)
156
+ return kind(status=status, code=code, path=path)
nevarn/Config.py ADDED
@@ -0,0 +1,76 @@
1
+ """Where the client talks and what it presents: both explicit, both checked.
2
+
3
+ There is no default base URL, so a test or a script cannot reach production
4
+ by leaving one out, and plain http is accepted only for loopback. The key is
5
+ an ``nvk_`` merchant key from the constructor or ``NEVARN_API_KEY`` and
6
+ nothing else: a session token is refused outright, because an owner session
7
+ can raise the very limits an agent is supposed to be bounded by.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ import re
14
+ from urllib.parse import urlsplit
15
+
16
+ from .Errors import ConfigurationError, SessionTokenRefused
17
+
18
+ ENV_KEY = "NEVARN_API_KEY"
19
+ LOOPBACK = frozenset({"127.0.0.1", "localhost", "::1"})
20
+ _KEY = re.compile(r"nvk_[A-Za-z0-9_-]{16,128}")
21
+ #: A platform session (base64url JSON payload + "." + signature) or a JWT:
22
+ #: either way a JSON object first, which base64url-encodes to "eyJ".
23
+ _SESSION = re.compile(r"eyJ[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+){1,2}")
24
+
25
+
26
+ class BaseUrl:
27
+ """An https origin (optionally with a path prefix), or http on loopback."""
28
+
29
+ __slots__ = ("value",)
30
+
31
+ def __init__(self, raw: str) -> None:
32
+ if not isinstance(raw, str) or not raw.strip():
33
+ raise ConfigurationError()
34
+ parts = urlsplit(raw.strip())
35
+ try:
36
+ parts.port
37
+ except ValueError:
38
+ raise ConfigurationError() from None
39
+ host = (parts.hostname or "").lower()
40
+ secure = parts.scheme == "https" or (parts.scheme == "http" and host in LOOPBACK)
41
+ if not host or not secure or parts.username or parts.password or parts.query or parts.fragment:
42
+ raise ConfigurationError()
43
+ self.value = f"{parts.scheme}://{parts.netloc}{parts.path.rstrip('/')}"
44
+
45
+ def join(self, path: str) -> str:
46
+ return self.value + path
47
+
48
+ def __repr__(self) -> str:
49
+ return f"BaseUrl({self.value!r})"
50
+
51
+
52
+ class ApiKey:
53
+ """The secret, kept out of repr, str and equality."""
54
+
55
+ __slots__ = ("_secret",)
56
+
57
+ def __init__(self, secret: str | None) -> None:
58
+ if secret is None:
59
+ secret = os.environ.get(ENV_KEY)
60
+ if not isinstance(secret, str) or not secret.strip():
61
+ raise ConfigurationError()
62
+ secret = secret.strip()
63
+ token = secret[7:].strip() if secret.lower().startswith("bearer ") else secret
64
+ if _SESSION.fullmatch(token):
65
+ raise SessionTokenRefused()
66
+ if not _KEY.fullmatch(secret):
67
+ raise ConfigurationError()
68
+ self._secret = secret
69
+
70
+ def authorization(self) -> str:
71
+ return f"Bearer {self._secret}"
72
+
73
+ def __repr__(self) -> str:
74
+ return "ApiKey(<redacted>)"
75
+
76
+ __str__ = __repr__
nevarn/Errors.py ADDED
@@ -0,0 +1,159 @@
1
+ """Typed errors that carry the status, the platform code and the path template.
2
+
3
+ Nothing else. The upstream body, the request headers and the key are never
4
+ attached, and every message is a constant of its class, so an error can be
5
+ logged, shown to a model or sent to a tracker without leaking anything the
6
+ platform or the caller wrote.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import re
12
+
13
+ _CODE = re.compile(r"[a-z][a-z0-9_]{0,63}")
14
+
15
+
16
+ class NevarnError(Exception):
17
+ """Base class. ``status`` is None when the platform was never reached."""
18
+
19
+ message = "the Nevarn platform refused the request"
20
+
21
+ def __init__(self, *, status: int | None = None, code: str | None = None, path: str | None = None) -> None:
22
+ self.status = status
23
+ self.code = code if code and _CODE.fullmatch(code) else None
24
+ self.path = path
25
+ super().__init__(str(self))
26
+
27
+ def __str__(self) -> str:
28
+ facts = [f"status {self.status}" if self.status is not None else None, self.code, self.path]
29
+ detail = ", ".join(f for f in facts if f)
30
+ return f"{self.message} ({detail})" if detail else self.message
31
+
32
+ def __repr__(self) -> str:
33
+ return f"{type(self).__name__}(status={self.status!r}, code={self.code!r}, path={self.path!r})"
34
+
35
+ def toJson(self) -> dict:
36
+ return {"type": type(self).__name__, "status": self.status, "code": self.code,
37
+ "path": self.path, "message": self.message}
38
+
39
+
40
+ class ConfigurationError(NevarnError):
41
+ message = "the client is not configured: it needs an https (or loopback) base URL and an nvk_ API key"
42
+
43
+
44
+ class SessionTokenRefused(ConfigurationError):
45
+ message = "a session token is refused: this client accepts only an nvk_ API key"
46
+
47
+
48
+ class InvalidInput(NevarnError):
49
+ """A request the client will not send. ``field`` names the input, never its value."""
50
+
51
+ message = "the request was not sent: an input is invalid"
52
+
53
+ def __init__(self, field: str) -> None:
54
+ self.field = field
55
+ super().__init__()
56
+
57
+ def __str__(self) -> str:
58
+ return f"{self.message} ({self.field})"
59
+
60
+ def toJson(self) -> dict:
61
+ return {**super().toJson(), "field": self.field}
62
+
63
+
64
+ class NotAvailable(NevarnError):
65
+ """No API key can call this yet. Raised without a network call."""
66
+
67
+ message = "not available for API keys yet"
68
+
69
+ def __init__(self, *, dependency: str, path: str) -> None:
70
+ self.dependency = dependency
71
+ super().__init__(path=path)
72
+
73
+ def __str__(self) -> str:
74
+ return f"{self.message} ({self.path}, waiting on {self.dependency})"
75
+
76
+ def toJson(self) -> dict:
77
+ return {**super().toJson(), "dependency": self.dependency}
78
+
79
+
80
+ class TransportError(NevarnError):
81
+ message = "the Nevarn platform could not be reached"
82
+
83
+
84
+ class RedirectRefused(NevarnError):
85
+ message = "the platform answered with a redirect; it is not followed"
86
+
87
+
88
+ class UnexpectedResponse(NevarnError):
89
+ message = "the platform answered with something this client does not understand"
90
+
91
+
92
+ class Unauthorized(NevarnError):
93
+ message = "the API key was not accepted"
94
+
95
+
96
+ class Forbidden(NevarnError):
97
+ message = "the API key does not carry the scope this call needs (intents, execute, read, halt or invoices)"
98
+
99
+
100
+ class NotFound(NevarnError):
101
+ message = "the platform does not know that resource"
102
+
103
+
104
+ class Conflict(NevarnError):
105
+ message = "already filed: an invoice with this number, vendor, amount and address exists"
106
+
107
+
108
+ class IntentConflict(Conflict):
109
+ message = "this intent key was already used for other terms, or shadow mode is off on this deployment"
110
+
111
+
112
+ class ExecutionRefused(Conflict):
113
+ """The platform would not execute the intent. ``code`` says why; nothing was sent."""
114
+
115
+ message = ("not executed: a key or tenant limit, a halt, a replay, a reused intent key, "
116
+ "or a policy that is not released; the code says which")
117
+
118
+
119
+ class Rejected(NevarnError):
120
+ message = "the platform rejected the request as invalid"
121
+
122
+
123
+ class RateLimited(NevarnError):
124
+ message = "too many requests for this key; wait and try again"
125
+
126
+ def __init__(self, *, retryAfter: int | None = None, **facts) -> None:
127
+ self.retryAfter = retryAfter
128
+ super().__init__(**facts)
129
+
130
+ def toJson(self) -> dict:
131
+ return {**super().toJson(), "retry_after": self.retryAfter}
132
+
133
+
134
+ class ServerError(NevarnError):
135
+ message = "the Nevarn platform failed; check recent invoices before trying again"
136
+
137
+
138
+ _BY_STATUS: dict[int, type[NevarnError]] = {
139
+ 401: Unauthorized,
140
+ 403: Forbidden,
141
+ 404: NotFound,
142
+ 409: Conflict,
143
+ 422: Rejected,
144
+ 429: RateLimited,
145
+ }
146
+
147
+
148
+ #: Where a status means something narrower than its default class.
149
+ _BY_PATH: dict[tuple[str, int], type[NevarnError]] = {
150
+ ("/machine/intents", 409): IntentConflict,
151
+ ("/machine/executions", 409): ExecutionRefused,
152
+ }
153
+
154
+
155
+ def forStatus(status: int, path: str | None = None) -> type[NevarnError]:
156
+ """The error class a non-success status maps to, on this path."""
157
+ if status >= 500:
158
+ return ServerError
159
+ return _BY_PATH.get((path or "", status)) or _BY_STATUS.get(status, NevarnError)
nevarn/Execution.py ADDED
@@ -0,0 +1,108 @@
1
+ """execute_intent: have an intent executed under Decionis policy, within the key's limits.
2
+
3
+ ``POST /machine/executions`` with a key carrying ``execute`` takes the same
4
+ terms as ``proposeIntent``, and the same local secret check runs first.
5
+ Where it goes is the tenant's environment, never the bot's choice:
6
+
7
+ - Sandbox: filled on paper, in full at the stated terms. The policies are
8
+ asked in SHADOW; ``wouldExecute`` says whether Production would have
9
+ placed the order. Nothing reaches a venue.
10
+ - Production: queued as a trading execution, ruled in ENFORCEMENT right
11
+ before the venue call and sent with the tenant's own venue credentials.
12
+ At intake ``state`` is ``queued`` and ``verdict`` is None; read it back
13
+ with ``getExecution``.
14
+
15
+ A refusal raises ``ExecutionRefused`` (409) carrying the platform's code,
16
+ such as ``key_daily_limit_exceeded``, ``tenant_halted`` or
17
+ ``intent_replayed``; the key's minute window raises ``RateLimited`` (429).
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from dataclasses import dataclass
23
+ from uuid import UUID
24
+
25
+ from .Errors import InvalidInput, UnexpectedResponse
26
+
27
+ PATH = "/machine/executions"
28
+ READ_PATH = "/machine/executions/{execution_id}"
29
+ ENVIRONMENTS = ("sandbox", "production")
30
+ VERDICTS = ("execute", "block", "escalate", "do_nothing", "unavailable")
31
+
32
+
33
+ class ExecutionGate:
34
+ @staticmethod
35
+ def path(executionId: UUID | str) -> str:
36
+ try:
37
+ value = executionId if isinstance(executionId, UUID) else UUID(str(executionId))
38
+ except ValueError:
39
+ raise InvalidInput("execution_id") from None
40
+ return READ_PATH.format(execution_id=value)
41
+
42
+
43
+ def _optional(data: dict, name: str) -> str | None:
44
+ value = data.get(name)
45
+ return str(value) if value is not None else None
46
+
47
+
48
+ @dataclass(frozen=True)
49
+ class Execution:
50
+ """Where the execution went and how far it got. ``paper`` only in Sandbox, ``executionId`` only in Production."""
51
+
52
+ id: str
53
+ intentKey: str
54
+ strategy: str
55
+ environment: str
56
+ state: str
57
+ verdict: str | None
58
+ wouldExecute: bool | None
59
+ executed: bool
60
+ reasons: tuple[str, ...]
61
+ decisionId: str | None
62
+ rulings: tuple[dict, ...]
63
+ notionalMinor: int
64
+ paper: dict | None
65
+ executionId: str | None
66
+ venueReference: str | None
67
+ receiptId: str | None
68
+ createdAt: str
69
+
70
+ @classmethod
71
+ def fromJson(cls, data: object, *, status: int, path: str = PATH) -> Execution:
72
+ try:
73
+ if (not isinstance(data, dict) or data["mode"] != "execute" or data["environment"] not in ENVIRONMENTS
74
+ or (data.get("verdict") is not None and data["verdict"] not in VERDICTS)
75
+ or not isinstance(data["executed"], bool) or type(data["notional_minor"]) is not int):
76
+ raise ValueError
77
+ paper = data.get("paper")
78
+ return cls(
79
+ id=str(UUID(str(data["id"]))),
80
+ intentKey=str(data["intent_key"]),
81
+ strategy=str(data["strategy"]),
82
+ environment=str(data["environment"]),
83
+ state=str(data["state"]),
84
+ verdict=_optional(data, "verdict"),
85
+ wouldExecute=data.get("would_execute") if isinstance(data.get("would_execute"), bool) else None,
86
+ executed=data["executed"],
87
+ reasons=tuple(str(r) for r in data.get("reasons") or ()),
88
+ decisionId=_optional(data, "decision_id"),
89
+ rulings=tuple(dict(r) for r in data.get("rulings") or () if isinstance(r, dict)),
90
+ notionalMinor=data["notional_minor"],
91
+ paper=dict(paper) if isinstance(paper, dict) else None,
92
+ executionId=_optional(data, "execution_id"),
93
+ venueReference=_optional(data, "venue_reference"),
94
+ receiptId=_optional(data, "receipt_id"),
95
+ createdAt=str(data["created_at"]),
96
+ )
97
+ except (KeyError, TypeError, ValueError):
98
+ raise UnexpectedResponse(status=status, path=path) from None
99
+
100
+ def toJson(self) -> dict:
101
+ return {
102
+ "id": self.id, "intent_key": self.intentKey, "strategy": self.strategy, "mode": "execute",
103
+ "environment": self.environment, "state": self.state, "verdict": self.verdict,
104
+ "would_execute": self.wouldExecute, "executed": self.executed, "reasons": list(self.reasons),
105
+ "decision_id": self.decisionId, "rulings": list(self.rulings), "notional_minor": self.notionalMinor,
106
+ "paper": self.paper, "execution_id": self.executionId, "venue_reference": self.venueReference,
107
+ "receipt_id": self.receiptId, "created_at": self.createdAt,
108
+ }
nevarn/Intent.py ADDED
@@ -0,0 +1,125 @@
1
+ """propose_intent: what a bot would like traded, sent to ``POST /machine/intents``.
2
+
3
+ An intent is terms, never an order: no signature, no key, no URL. The
4
+ platform checks the terms against the strategy's venue model and asks
5
+ Decionis about them in SHADOW - the only mode an API key has - and records
6
+ the ruling. Nothing is sent to a venue; ``executed`` is always false.
7
+
8
+ The check here runs before anything leaves the bot's process: an intent
9
+ that carries a field named like a secret, or a value shaped like a private
10
+ key, is refused locally so the secret never reaches the network. The
11
+ platform checks everything again.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import re
17
+ from dataclasses import dataclass
18
+ from datetime import datetime
19
+ from typing import Any
20
+ from uuid import UUID
21
+
22
+ from .Errors import InvalidInput, UnexpectedResponse
23
+
24
+ PATH = "/machine/intents"
25
+ STRATEGIES = ("polymarket", "sports", "capital", "arbitrage")
26
+ VERDICTS = ("execute", "block", "escalate", "do_nothing", "unavailable")
27
+ _KEY = re.compile(r"[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}")
28
+ _SECRET_NAME = re.compile(r"private|secret|signature|mnemonic|passphrase|password|seed|api_?key|credential", re.I)
29
+ #: 32 bytes of hex: 0x-prefixed, or bare with a letter in it (a 64-digit decimal token id is not a key).
30
+ _PRIVATE_KEY = re.compile(r"0x[0-9a-fA-F]{64}|(?=[0-9]*[a-fA-F])[0-9a-fA-F]{64}")
31
+ _DEPTH = 4
32
+
33
+
34
+ def _clean(value: Any, depth: int = 0) -> Any:
35
+ """A JSON-ready copy, or InvalidInput("intent") naming nothing it carried."""
36
+ if depth > _DEPTH:
37
+ raise InvalidInput("intent")
38
+ if isinstance(value, dict):
39
+ out = {}
40
+ for key, item in value.items():
41
+ if not isinstance(key, str) or _SECRET_NAME.search(key):
42
+ raise InvalidInput("intent")
43
+ out[key] = _clean(item, depth + 1)
44
+ return out
45
+ if isinstance(value, (list, tuple)):
46
+ return [_clean(item, depth + 1) for item in value]
47
+ if isinstance(value, datetime):
48
+ if value.tzinfo is None:
49
+ raise InvalidInput("intent")
50
+ return value.isoformat()
51
+ if isinstance(value, str) and _PRIVATE_KEY.fullmatch(value):
52
+ raise InvalidInput("intent")
53
+ if value is None or isinstance(value, (str, bool, int)):
54
+ return value
55
+ if isinstance(value, float) and value == value and value not in (float("inf"), float("-inf")):
56
+ return value
57
+ raise InvalidInput("intent")
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ class IntentRequest:
62
+ strategy: str
63
+ intentKey: str
64
+ intent: dict
65
+
66
+ def __post_init__(self) -> None:
67
+ if self.strategy not in STRATEGIES:
68
+ raise InvalidInput("strategy")
69
+ if not isinstance(self.intentKey, str) or not _KEY.fullmatch(self.intentKey):
70
+ raise InvalidInput("intent_key")
71
+ if not isinstance(self.intent, dict) or not self.intent:
72
+ raise InvalidInput("intent")
73
+ object.__setattr__(self, "intent", _clean(self.intent))
74
+
75
+ def body(self) -> dict:
76
+ return {"strategy": self.strategy, "intent_key": self.intentKey, "intent": self.intent}
77
+
78
+
79
+ @dataclass(frozen=True)
80
+ class IntentRuling:
81
+ """The shadow ruling. ``wouldExecute`` is the answer; ``executed`` is always False."""
82
+
83
+ id: str
84
+ intentKey: str
85
+ strategy: str
86
+ mode: str
87
+ verdict: str
88
+ wouldExecute: bool
89
+ executed: bool
90
+ reasons: tuple[str, ...]
91
+ decisionId: str | None
92
+ rulings: tuple[dict, ...]
93
+ receiptId: str | None
94
+ createdAt: str
95
+
96
+ @classmethod
97
+ def fromJson(cls, data: object, *, status: int) -> IntentRuling:
98
+ try:
99
+ if not isinstance(data, dict) or data["verdict"] not in VERDICTS or data["executed"] is not False:
100
+ raise ValueError
101
+ ruling = cls(
102
+ id=str(UUID(str(data["id"]))),
103
+ intentKey=str(data["intent_key"]),
104
+ strategy=str(data["strategy"]),
105
+ mode=str(data["mode"]),
106
+ verdict=str(data["verdict"]),
107
+ wouldExecute=data["would_execute"] is True,
108
+ executed=False,
109
+ reasons=tuple(str(r) for r in data.get("reasons") or ()),
110
+ decisionId=str(data["decision_id"]) if data.get("decision_id") else None,
111
+ rulings=tuple(dict(r) for r in data.get("rulings") or () if isinstance(r, dict)),
112
+ receiptId=str(data["receipt_id"]) if data.get("receipt_id") else None,
113
+ createdAt=str(data["created_at"]),
114
+ )
115
+ except (KeyError, TypeError, ValueError):
116
+ raise UnexpectedResponse(status=status, path=PATH) from None
117
+ return ruling
118
+
119
+ def toJson(self) -> dict:
120
+ return {
121
+ "id": self.id, "intent_key": self.intentKey, "strategy": self.strategy, "mode": self.mode,
122
+ "verdict": self.verdict, "would_execute": self.wouldExecute, "executed": self.executed,
123
+ "reasons": list(self.reasons), "decision_id": self.decisionId, "rulings": list(self.rulings),
124
+ "receipt_id": self.receiptId, "created_at": self.createdAt,
125
+ }
nevarn/Mandate.py ADDED
@@ -0,0 +1,100 @@
1
+ """get_mandate and halt: the bot's bounds, read-only, and the one control it has.
2
+
3
+ ``getMandate`` reads ``GET /machine/mandate`` with a key carrying ``read``:
4
+ the limits, signing grants and payables policy the console shows, which
5
+ Decionis policy rules each strategy's intents, where executions go (the
6
+ tenant's Sandbox or Production) with the reading key's execute limits, and
7
+ this month's governed actions. It changes nothing.
8
+
9
+ ``halt`` posts ``POST /machine/halt`` with a key carrying ``halt``. The
10
+ platform turns the tenant's signing off with the literal ``False`` and stops
11
+ the bots' unfinished executions; the body carries an optional reason and
12
+ nothing else, and there is no resume - only the tenant's owner can turn
13
+ signing back on, from the console.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import re
19
+ from dataclasses import dataclass, field
20
+
21
+ from .Errors import InvalidInput, UnexpectedResponse
22
+
23
+ PATH = "/machine/mandate"
24
+ HALT_PATH = "/machine/halt"
25
+ REASON_MAX = 500
26
+ _CONTROL = re.compile(r"[\x00-\x08\x0b-\x1f\x7f]")
27
+
28
+
29
+ class HaltRequest:
30
+ """The halt body: ``{}`` or ``{"reason": ...}``. There is no field that could resume."""
31
+
32
+ @staticmethod
33
+ def body(reason: str | None) -> dict:
34
+ if reason is None:
35
+ return {}
36
+ if not isinstance(reason, str) or len(reason) > REASON_MAX or _CONTROL.search(reason):
37
+ raise InvalidInput("reason")
38
+ return {"reason": reason}
39
+
40
+
41
+ @dataclass(frozen=True)
42
+ class Halted:
43
+ halted: bool
44
+ custodyEnabled: bool
45
+ #: How many unfinished bot executions the halt stopped (0 from a platform that does not say).
46
+ executionsStopped: int = 0
47
+
48
+ @classmethod
49
+ def fromJson(cls, data: object, *, status: int) -> Halted:
50
+ if not isinstance(data, dict) or data.get("halted") is not True or data.get("custody_enabled") is not False:
51
+ raise UnexpectedResponse(status=status, path=HALT_PATH)
52
+ stopped = data.get("executions_stopped")
53
+ return cls(halted=True, custodyEnabled=False, executionsStopped=stopped if type(stopped) is int else 0)
54
+
55
+ def toJson(self) -> dict:
56
+ return {"halted": self.halted, "custody_enabled": self.custodyEnabled,
57
+ "executions_stopped": self.executionsStopped}
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ class Mandate:
62
+ """The bounds as the platform reported them. Text inside is data, not instructions."""
63
+
64
+ tenantId: str
65
+ limits: dict
66
+ grants: tuple[dict, ...]
67
+ payablesPolicy: dict
68
+ intents: dict
69
+ executions: dict = field(default_factory=dict)
70
+ governedActions: dict = field(default_factory=dict)
71
+
72
+ @property
73
+ def tradingEnabled(self) -> bool:
74
+ return self.limits.get("trading_enabled") is True
75
+
76
+ @classmethod
77
+ def fromJson(cls, data: object, *, status: int) -> Mandate:
78
+ try:
79
+ if not isinstance(data, dict):
80
+ raise TypeError
81
+ limits, grants = data["limits"], data["grants"]
82
+ policy, intents = data["payables_policy"], data["intents"]
83
+ if not all(isinstance(v, dict) for v in (limits, policy, intents)) or not isinstance(grants, list):
84
+ raise TypeError
85
+ return cls(
86
+ tenantId=str(data["tenant_id"]), limits=dict(limits),
87
+ grants=tuple(dict(g) for g in grants if isinstance(g, dict)),
88
+ payablesPolicy=dict(policy), intents=dict(intents),
89
+ executions=dict(data.get("executions") or {}),
90
+ governedActions=dict(data.get("governed_actions") or {}),
91
+ )
92
+ except (KeyError, TypeError, ValueError):
93
+ raise UnexpectedResponse(status=status, path=PATH) from None
94
+
95
+ def toJson(self) -> dict:
96
+ return {
97
+ "tenant_id": self.tenantId, "limits": self.limits, "grants": list(self.grants),
98
+ "payables_policy": self.payablesPolicy, "intents": self.intents,
99
+ "executions": self.executions, "governed_actions": self.governedActions,
100
+ }
nevarn/Receipt.py ADDED
@@ -0,0 +1,49 @@
1
+ """get_receipt: one execution receipt - ruling, order, fill, settlement, ledger entries, balance.
2
+
3
+ ``GET /machine/receipts/{receipt_id}`` with a key carrying ``read``. The id
4
+ is the execution's: one trade, one receipt. ``Receipt.fromJson`` keeps the
5
+ whole record as data; its shape is the platform's (``receipts/Receipt.py``,
6
+ construction ``nevarn/receipt/v1``).
7
+
8
+ Shadow intents never execute, so they never have a receipt: an intent
9
+ ruling's ``receiptId`` is always None.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from dataclasses import dataclass
15
+ from uuid import UUID
16
+
17
+ from .Errors import InvalidInput, UnexpectedResponse
18
+
19
+ PATH = "/machine/receipts/{receipt_id}"
20
+
21
+
22
+ class ReceiptGate:
23
+ @staticmethod
24
+ def path(receiptId: UUID | str) -> str:
25
+ try:
26
+ value = receiptId if isinstance(receiptId, UUID) else UUID(str(receiptId))
27
+ except ValueError:
28
+ raise InvalidInput("receipt_id") from None
29
+ return PATH.format(receipt_id=value)
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class Receipt:
34
+ """A receipt as the platform returned it; ``data`` is the whole record, as data."""
35
+
36
+ id: str
37
+ data: dict
38
+
39
+ @classmethod
40
+ def fromJson(cls, data: object, *, status: int) -> Receipt:
41
+ try:
42
+ if not isinstance(data, dict):
43
+ raise TypeError
44
+ return cls(id=str(UUID(str(data["id"]))), data=dict(data))
45
+ except (KeyError, TypeError, ValueError):
46
+ raise UnexpectedResponse(status=status, path=PATH) from None
47
+
48
+ def toJson(self) -> dict:
49
+ return dict(self.data)
nevarn/Spend.py ADDED
@@ -0,0 +1,137 @@
1
+ """request_spend: a supplier invoice filed with ``POST /machine/invoices``.
2
+
3
+ It is not a request for raw funds. The platform's payables evaluator decides
4
+ what happens: the vendor must already be verified and the destination must be
5
+ that vendor's payout address; tiers 1-2 are paid without a person, tier 3
6
+ waits for an owner, tier 4 is paid by the customer from their own wallet. A
7
+ second copy of the same invoice is a 409.
8
+
9
+ The request is checked here before it is sent, so a malformed call never
10
+ reaches the platform; the platform still checks everything again.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import re
16
+ from dataclasses import dataclass
17
+ from datetime import datetime
18
+ from uuid import UUID
19
+
20
+ from .Errors import InvalidInput, UnexpectedResponse
21
+
22
+ PATH = "/machine/invoices"
23
+ _ADDRESS = re.compile(r"0x[0-9a-fA-F]{40}")
24
+ _HASH = re.compile(r"0x[0-9a-fA-F]{64}")
25
+ _ASSET = re.compile(r"[A-Za-z0-9.]{2,16}")
26
+ _CONTROL = re.compile(r"[\x00-\x1f\x7f]")
27
+
28
+
29
+ def _integer(value: object) -> bool:
30
+ return isinstance(value, int) and not isinstance(value, bool)
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class SpendRequest:
35
+ vendorId: UUID | str
36
+ invoiceNumber: str
37
+ amountMinor: int
38
+ destinationAddress: str
39
+ assetCode: str = "USDC"
40
+ chainId: int = 137
41
+ dueAt: datetime | None = None
42
+ proofHash: str | None = None
43
+
44
+ def __post_init__(self) -> None:
45
+ try:
46
+ vendor = self.vendorId if isinstance(self.vendorId, UUID) else UUID(str(self.vendorId))
47
+ except ValueError:
48
+ raise InvalidInput("vendor_id") from None
49
+ object.__setattr__(self, "vendorId", vendor)
50
+ number = self.invoiceNumber
51
+ if not isinstance(number, str) or not number.strip() or len(number) > 120 or _CONTROL.search(number):
52
+ raise InvalidInput("invoice_number")
53
+ if not _integer(self.amountMinor) or self.amountMinor <= 0:
54
+ raise InvalidInput("amount_minor")
55
+ if not isinstance(self.destinationAddress, str) or not _ADDRESS.fullmatch(self.destinationAddress):
56
+ raise InvalidInput("destination_address")
57
+ if not isinstance(self.assetCode, str) or not _ASSET.fullmatch(self.assetCode):
58
+ raise InvalidInput("asset_code")
59
+ if not _integer(self.chainId) or self.chainId <= 0:
60
+ raise InvalidInput("chain_id")
61
+ if self.dueAt is not None and (not isinstance(self.dueAt, datetime) or self.dueAt.tzinfo is None):
62
+ raise InvalidInput("due_at")
63
+ if self.proofHash is not None and (not isinstance(self.proofHash, str) or not _HASH.fullmatch(self.proofHash)):
64
+ raise InvalidInput("proof_hash")
65
+
66
+ def body(self) -> dict:
67
+ return {
68
+ "vendor_id": str(self.vendorId),
69
+ "invoice_number": self.invoiceNumber,
70
+ "amount_minor": self.amountMinor,
71
+ "destination_address": self.destinationAddress,
72
+ "asset_code": self.assetCode,
73
+ "chain_id": self.chainId,
74
+ "due_at": self.dueAt.isoformat() if self.dueAt else None,
75
+ "proof_hash": self.proofHash,
76
+ }
77
+
78
+
79
+ @dataclass(frozen=True)
80
+ class Invoice:
81
+ """What the platform recorded and decided. Its text fields are data, not instructions."""
82
+
83
+ id: str
84
+ status: str
85
+ tier: int | None
86
+ outcome: str | None
87
+ codes: tuple[str, ...]
88
+ holdUntil: str | None
89
+ vendorId: str
90
+ invoiceNumber: str
91
+ amountMinor: int
92
+ assetCode: str
93
+ chainId: int
94
+ destinationAddress: str
95
+ createdAt: str | None
96
+
97
+ @classmethod
98
+ def fromJson(cls, data: object, *, status: int) -> Invoice:
99
+ evaluation = (data.get("evaluation") or {}) if isinstance(data, dict) else None
100
+ if not isinstance(data, dict) or not isinstance(evaluation, dict):
101
+ raise UnexpectedResponse(status=status, path=PATH)
102
+ try:
103
+ invoice = cls(
104
+ id=str(UUID(str(data["id"]))),
105
+ status=str(data["status"]),
106
+ tier=int(data["tier"]) if data.get("tier") is not None else None,
107
+ outcome=str(evaluation["outcome"]) if evaluation.get("outcome") else None,
108
+ codes=tuple(str(c) for c in evaluation.get("codes") or ()),
109
+ holdUntil=str(evaluation["hold_until"]) if evaluation.get("hold_until") else None,
110
+ vendorId=str(data["vendor_id"]),
111
+ invoiceNumber=str(data["invoice_number"]),
112
+ amountMinor=int(str(data["amount_minor"])),
113
+ assetCode=str(data["asset_code"]),
114
+ chainId=int(data["chain_id"]),
115
+ destinationAddress=str(data["destination_address"]),
116
+ createdAt=str(data["created_at"]) if data.get("created_at") else None,
117
+ )
118
+ except (KeyError, TypeError, ValueError):
119
+ raise UnexpectedResponse(status=status, path=PATH) from None
120
+ return invoice
121
+
122
+ def toJson(self) -> dict:
123
+ return {
124
+ "id": self.id,
125
+ "status": self.status,
126
+ "tier": self.tier,
127
+ "outcome": self.outcome,
128
+ "codes": list(self.codes),
129
+ "hold_until": self.holdUntil,
130
+ "vendor_id": self.vendorId,
131
+ "invoice_number": self.invoiceNumber,
132
+ "amount_minor": str(self.amountMinor),
133
+ "asset_code": self.assetCode,
134
+ "chain_id": self.chainId,
135
+ "destination_address": self.destinationAddress,
136
+ "created_at": self.createdAt,
137
+ }
nevarn/Version.py ADDED
@@ -0,0 +1,2 @@
1
+ VERSION = "0.1.0"
2
+ USER_AGENT = f"nevarn-sdk-python/{VERSION}"
nevarn/__init__.py ADDED
@@ -0,0 +1,44 @@
1
+ """Nevarn SDK: a thin client for an operator's own bot and servers.
2
+
3
+ ``proposeIntent`` (shadow rulings), ``executeIntent`` and ``getExecution``
4
+ (executions under Decionis policy), ``getMandate``, ``getReceipt``, ``halt``
5
+ and ``requestSpend``. The strategy contract is docs/strategy/Contract.md.
6
+ Licensed under the Apache License 2.0; use of the platform is licensed
7
+ separately, by governed actions or subscription.
8
+ """
9
+
10
+ from .Client import Client
11
+ from .Errors import (
12
+ Conflict,
13
+ ConfigurationError,
14
+ ExecutionRefused,
15
+ Forbidden,
16
+ IntentConflict,
17
+ InvalidInput,
18
+ NevarnError,
19
+ NotAvailable,
20
+ NotFound,
21
+ RateLimited,
22
+ RedirectRefused,
23
+ Rejected,
24
+ ServerError,
25
+ SessionTokenRefused,
26
+ TransportError,
27
+ Unauthorized,
28
+ UnexpectedResponse,
29
+ )
30
+ from .Execution import Execution
31
+ from .Intent import STRATEGIES, IntentRuling
32
+ from .Mandate import Halted, Mandate
33
+ from .Receipt import Receipt
34
+ from .Spend import Invoice
35
+ from .Version import VERSION
36
+
37
+ __version__ = VERSION
38
+ __all__ = [
39
+ "Client", "IntentRuling", "Execution", "Mandate", "Halted", "Receipt", "Invoice", "STRATEGIES", "VERSION",
40
+ "NevarnError", "ConfigurationError", "SessionTokenRefused", "InvalidInput", "NotAvailable", "IntentConflict",
41
+ "ExecutionRefused",
42
+ "TransportError", "RedirectRefused", "UnexpectedResponse", "Unauthorized", "Forbidden",
43
+ "NotFound", "Conflict", "Rejected", "RateLimited", "ServerError",
44
+ ]
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: nevarn-sdk
3
+ Version: 0.1.0
4
+ Summary: Thin client for the Nevarn platform API: a bot's intents, executions under Decionis policy, bounds, receipts and halt.
5
+ Author: Binaries Fort AB
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Documentation, https://nevarn.com/docs/sdk
8
+ Project-URL: Repository, https://github.com/orepos/Nevarn
9
+ Keywords: nevarn,trading,agents,decionis,bots
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ License-File: NOTICE
17
+ Requires-Dist: httpx<0.29,>=0.28.1
18
+ Dynamic: license-file
19
+
20
+ # nevarn-sdk (Python)
21
+
22
+ A thin client for the Nevarn platform API, for an operator's own bot and
23
+ servers. It adds no authority: a bot sends intents, never orders or keys, and
24
+ every method calls a route an `nvk_` API key is already scoped for. Contract:
25
+ `docs/strategy/Contract.md`; design: `docs/workplans/agent-sdk.design.md`.
26
+
27
+ Free to download, under the Apache License 2.0 (`LICENSE`, `NOTICE`). Using
28
+ the Nevarn platform it calls is licensed on the platform, by governed actions
29
+ or by subscription.
30
+
31
+ ```python
32
+ from datetime import datetime, timezone
33
+
34
+ import nevarn
35
+
36
+ client = nevarn.Client(baseUrl="https://<your platform API>") # key from NEVARN_API_KEY
37
+ print(client.getMandate().intents) # shadow mode, and the Decionis policy for each strategy
38
+ ruling = client.proposeIntent(
39
+ strategy="polymarket",
40
+ intentKey="momentum-1", # your idempotency key: reuse it to retry, never for other terms
41
+ intent={"token_id": "7132…", "side": "BUY", "maker_amount": 5_000_000,
42
+ "taker_amount": 10_000_000, "observed_at": datetime.now(timezone.utc)},
43
+ )
44
+ print(ruling.verdict, ruling.wouldExecute, ruling.reasons) # executed is always False in shadow
45
+
46
+ # With an `execute` key: on paper in the tenant's Sandbox, live in Production.
47
+ execution = client.executeIntent(strategy="polymarket", intentKey="momentum-2", intent={...})
48
+ print(execution.environment, execution.state, execution.paper) # "sandbox", "paper_filled", the fill
49
+ print(client.getExecution(execution.id).state) # Production: queued, then submitted, confirmed
50
+ ```
51
+
52
+ | Method | Route | Key scope | Today |
53
+ | --- | --- | --- | --- |
54
+ | `proposeIntent` | `POST /machine/intents` | `intents` | Shadow ruling; nothing is sent to a venue |
55
+ | `executeIntent` | `POST /machine/executions` | `execute` | Sandbox: a paper fill and shadow rulings. Production: queued, ruled in ENFORCEMENT at the venue, sent with the tenant's venue credentials |
56
+ | `getExecution` | `GET /machine/executions/{id}` | `execute` | One execution and its current state |
57
+ | `getMandate` | `GET /machine/mandate` | `read` | Limits, signing grants, payables policy, intent policies, the execution environment and key limits, this month's governed actions |
58
+ | `getReceipt` | `GET /machine/receipts/{id}` | `read` | One execution receipt, by the execution's id |
59
+ | `halt` | `POST /machine/halt` | `halt` | Turns all signing off and stops the bots' unfinished executions; there is no resume |
60
+ | `requestSpend` | `POST /machine/invoices` | `invoices` | Files a supplier invoice |
61
+
62
+ `proposeIntent` refuses, before sending, an intent with a field named like a
63
+ secret (`private_key`, `signature`, `apiKey`, …) or a value shaped like a
64
+ private key. A reused intent key with other terms raises `IntentConflict`
65
+ (409), as does an intent sent while the deployment has shadow mode off.
66
+
67
+ `executeIntent` takes the same terms and runs the same local check. Where the
68
+ order goes is the tenant's environment, never the bot's choice. An `execute`
69
+ key is minted by an owner with its own limits (orders a minute, the largest
70
+ order, a 24-hour total, in USDC minor units), and it executes `polymarket` and
71
+ `sports` intents. A refusal raises `ExecutionRefused` (409) whose `code` says
72
+ why: `key_order_limit_exceeded`, `key_daily_limit_exceeded`,
73
+ `tenant_order_limit_exceeded`, `tenant_halted`, `intent_replayed`,
74
+ `intent_key_reused`, `key_minted_without_wallet` (a key minted from a password
75
+ sign-in asked for Production; it executes in Sandbox only), `strategy_not_executable`,
76
+ `policy_not_published`, `policy_mapping_unpublished`, `runtime_adapter_unpinned` or
77
+ `authority_not_configured`. The key's minute window raises `RateLimited` (429).
78
+
79
+ `requestSpend` files a supplier invoice; it is not a request for raw funds. The
80
+ platform's payables policy decides the outcome: the vendor must already be
81
+ verified and the destination must be its payout address; tiers 1–2 are paid
82
+ automatically, tier 3 waits for an owner, tier 4 is paid by the customer. A
83
+ duplicate raises `Conflict` (409).
84
+
85
+ ## Guarantees
86
+
87
+ - The base URL is required and must be `https` (plain `http` only on
88
+ `127.0.0.1`, `localhost` or `[::1]`). There is no default.
89
+ - The key comes only from the constructor or `NEVARN_API_KEY`, must be an
90
+ `nvk_` key, and never appears in `repr`, errors or logs. Session tokens are
91
+ refused.
92
+ - Redirects are refused, the timeout is 5 seconds, and errors carry only the
93
+ status, the platform error code and the path template.
94
+ - There is no method for limits, resume, keys, vendors or approvals, and
95
+ `halt` takes only an optional reason.
96
+
97
+ ## Tests
98
+
99
+ ```bash
100
+ python -m pytest tests -q
101
+ ```
102
+
103
+ The platform contract tests are `apps/platform/tests/test_sdk_contract.py`
104
+ and `test_shadowbot_example.py`, which runs `examples/shadowbot` through the
105
+ real app.
106
+
107
+ ## Licence and release
108
+
109
+ Apache License 2.0 (`LICENSE`; `NOTICE` names Binaries Fort AB). The licence
110
+ covers this client only; the platform's use is licensed on the platform, by
111
+ governed actions or subscription.
112
+
113
+ Publishing stays the owner's: PyPI ownership of `nevarn-sdk` and the release
114
+ workflow. Until then the `Private :: Do Not Upload` classifier makes PyPI
115
+ refuse an upload; the owner removes it in the release change.
@@ -0,0 +1,16 @@
1
+ nevarn/Client.py,sha256=sj6uCezPmC2aOAqHBdhVzhNJIJOlj_xHNuOEFzzMKUk,6841
2
+ nevarn/Config.py,sha256=To18oaYuGsfXU5321spMUuaGlKdzXmPGOe8xysjxXdw,2665
3
+ nevarn/Errors.py,sha256=bPqh29fLfb5iHBK_uwUf8RxUGtjdEBAtH7kbb508r7g,5110
4
+ nevarn/Execution.py,sha256=bWudFTAn87E86VcR8h7V09lJHVbPsmS6JmbL_H7mx3c,4670
5
+ nevarn/Intent.py,sha256=lpsguf9Vw6FoRpeBqKyE_k5lBBUGdF0xHjvEwJQuzHY,5041
6
+ nevarn/Mandate.py,sha256=QHJORq2vPzUBy7tYHUCKPFlpOsntlUsPtAbSAHCd4CI,3961
7
+ nevarn/Receipt.py,sha256=_kUBcIS3cS2t42Xu3W5Zd8q42eNr7a7tEDjzUAqYfAI,1558
8
+ nevarn/Spend.py,sha256=k0q9_p8M5BSbCn5E8jaYNxfa5V4yv5l2crj1l3Wee1M,5449
9
+ nevarn/Version.py,sha256=3mX8ViawIKNSQi__R6OtIvLUJNdwk7_5Y_shTxSb7mY,62
10
+ nevarn/__init__.py,sha256=qmGwyQwcL2fo1qoMxe8K94RTFzBLfSixro3FjyNAim0,1437
11
+ nevarn_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
12
+ nevarn_sdk-0.1.0.dist-info/licenses/NOTICE,sha256=sUj7_8Ze0o0Ficc6bYdwiHmXgfGffvtAyWkANcNTolE,302
13
+ nevarn_sdk-0.1.0.dist-info/METADATA,sha256=9c9t98R0r8SN1tEowgBn9p8XqFWYQp9CvIaVOsaRJ1c,5922
14
+ nevarn_sdk-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
15
+ nevarn_sdk-0.1.0.dist-info/top_level.txt,sha256=_HDVyO8WoyjGj5YpoWpdSQQy8tmRN-oBhX6z4D8FgEk,7
16
+ nevarn_sdk-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,6 @@
1
+ Nevarn SDK for Python (nevarn-sdk)
2
+ Copyright 2026 Binaries Fort AB
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+ The licence covers this software only. Use of the Nevarn platform it calls is
6
+ licensed separately, on the platform, by governed actions or by subscription.
@@ -0,0 +1 @@
1
+ nevarn