codespar 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.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: codespar
3
+ Version: 0.1.0
4
+ Summary: Python SDK for CodeSpar — commerce infrastructure for AI agents in Latin America.
5
+ Project-URL: Homepage, https://codespar.dev
6
+ Project-URL: Documentation, https://docs.codespar.dev
7
+ Project-URL: Repository, https://github.com/codespar/codespar
8
+ Project-URL: Issues, https://github.com/codespar/codespar/issues
9
+ Author-email: CodeSpar <hello@codespar.dev>
10
+ License: MIT
11
+ Keywords: agents,ai,commerce,latam,mcp,nfe,pix,stripe
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: httpx>=0.27.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: mypy>=1.11; extra == 'dev'
26
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
27
+ Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.6; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # codespar — Python SDK
33
+
34
+ Commerce infrastructure for AI agents in Latin America. Pix, NF-e,
35
+ WhatsApp, shipping, banking — one API, no provider-key boilerplate.
36
+
37
+ [![PyPI](https://img.shields.io/pypi/v/codespar.svg)](https://pypi.org/project/codespar/)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/codespar.svg)](https://pypi.org/project/codespar/)
39
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/codespar/codespar/blob/main/LICENSE)
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install codespar
45
+ ```
46
+
47
+ Python 3.10+ required.
48
+
49
+ ## Quick start
50
+
51
+ ```python
52
+ from codespar import CodeSpar
53
+
54
+ cs = CodeSpar(api_key="csk_live_...")
55
+
56
+ session = cs.create(
57
+ "user_123",
58
+ preset="brazilian", # zoop, nuvem-fiscal, melhor-envio, z-api, omie
59
+ # project_id="prj_...", # optional — defaults to the org's default project
60
+ )
61
+
62
+ result = session.send(
63
+ "Charge R$500 via Pix to +5511999887766 and send the QR code by WhatsApp."
64
+ )
65
+ print(result.message)
66
+ for call in result.tool_calls:
67
+ print(f" → {call.tool_name} ({call.duration_ms}ms)")
68
+
69
+ session.close()
70
+ cs.close()
71
+ ```
72
+
73
+ Or as a context manager:
74
+
75
+ ```python
76
+ with CodeSpar(api_key="csk_live_...") as cs:
77
+ session = cs.create("user_123", preset="brazilian")
78
+ print(session.send("Quero pagar R$125 via Pix").message)
79
+ ```
80
+
81
+ ## Streaming
82
+
83
+ ```python
84
+ for event in session.send_stream("Process order #BR-7721"):
85
+ if event.type == "assistant_text":
86
+ print(event.content, end="", flush=True)
87
+ elif event.type == "tool_use":
88
+ print(f"\n→ calling {event.name}...")
89
+ elif event.type == "tool_result":
90
+ print(f" {event.tool_call.status} in {event.tool_call.duration_ms}ms")
91
+ ```
92
+
93
+ ## Async
94
+
95
+ ```python
96
+ import asyncio
97
+ from codespar import AsyncCodeSpar
98
+
99
+ async def main():
100
+ async with AsyncCodeSpar(api_key="csk_live_...") as cs:
101
+ session = await cs.create("user_123", preset="brazilian")
102
+ result = await session.send("charge R$500 via Pix")
103
+ print(result.message)
104
+ await session.close()
105
+
106
+ asyncio.run(main())
107
+ ```
108
+
109
+ ## Multi-environment (projects)
110
+
111
+ CodeSpar scopes every session to an environment (`prj_<id>`). Pass a
112
+ project id on the client for the whole lifetime, or per-session when
113
+ you want to target a different environment:
114
+
115
+ ```python
116
+ # Pin every session this client spawns to the staging project
117
+ cs = CodeSpar(api_key="csk_live_...", project_id="prj_staging0123abcd")
118
+
119
+ # Override per session
120
+ session = cs.create("user_123", preset="brazilian", project_id="prj_prod0123abcd")
121
+ ```
122
+
123
+ When you omit `project_id`, CodeSpar routes to the org's **default
124
+ project** — always defined, self-healed on first read.
125
+
126
+ ## Raw HTTP proxy
127
+
128
+ Skip the agent loop and hit a provider API directly through CodeSpar's
129
+ credential vault:
130
+
131
+ ```python
132
+ from codespar import ProxyRequest
133
+
134
+ response = session.proxy_execute(ProxyRequest(
135
+ server="stripe-acp",
136
+ endpoint="/v1/charges",
137
+ method="POST",
138
+ body={"amount": 2000, "currency": "brl"},
139
+ ))
140
+ print(response.status, response.data)
141
+ ```
142
+
143
+ No API key leaves your machine — CodeSpar injects it server-side.
144
+
145
+ ## Connect Links (OAuth)
146
+
147
+ ```python
148
+ from codespar import AuthConfig
149
+
150
+ link = session.authorize(
151
+ "stripe-acp",
152
+ AuthConfig(redirect_uri="https://your.app/connected"),
153
+ )
154
+ print(f"Open this URL to connect Stripe: {link.authorize_url}")
155
+ ```
156
+
157
+ After the user completes the OAuth flow, CodeSpar stores the tokens in
158
+ the per-project vault and forwards them back to `redirect_uri` with
159
+ `?status=connected&connection_id=<id>` appended.
160
+
161
+ ## Errors
162
+
163
+ Every failure is wrapped:
164
+
165
+ ```python
166
+ from codespar import ApiError, ConfigError, StreamError
167
+
168
+ try:
169
+ session = cs.create("user_123", preset="brazilian")
170
+ except ConfigError as exc:
171
+ print(f"Bad config: {exc}")
172
+ except ApiError as exc:
173
+ print(f"Backend said {exc.status}: {exc.code}")
174
+ ```
175
+
176
+ ## Design parity with the JS SDK
177
+
178
+ This package mirrors [`@codespar/sdk`](https://www.npmjs.com/package/@codespar/sdk)
179
+ method-for-method. Same backend, same payloads, same preset names — pick
180
+ the language that fits your stack without giving anything up.
181
+
182
+ ## Links
183
+
184
+ - [Documentation](https://docs.codespar.dev)
185
+ - [Dashboard](https://dashboard.codespar.dev)
186
+ - [JS SDK (npm)](https://www.npmjs.com/package/@codespar/sdk)
187
+ - [Report a bug](https://github.com/codespar/codespar/issues)
@@ -0,0 +1,11 @@
1
+ codespar/__init__.py,sha256=6vvuAQWnGMA79an6cQjNdI8Ze0UpQUbLQMYYMT93mdA,2260
2
+ codespar/_async_client.py,sha256=a3vNjn0FnXe1jC4ukIu560kHsq62EWc254knmRi_S0c,5705
3
+ codespar/_async_session.py,sha256=yZss19IwQyZ4PXH248JHO3RLoUOtyOjtpfKcZ0YADHA,15158
4
+ codespar/_http.py,sha256=vl3qTOd7xmJ-g7bRrQAnSWFzB2soJY8GUy8ppRSp_ic,4615
5
+ codespar/_presets.py,sha256=7H-rEi35YP3yHFCtFtn0ansW46B7BoUky8TV4i_aA40,1239
6
+ codespar/_sync_client.py,sha256=D9UjETCfzwVIJ7j3awf4of_mcQmOsP4Q7YoRlwYwLyM,7006
7
+ codespar/errors.py,sha256=rUgDCIWlnAtF_TtZkjc7YVta87RGwOagVestvbycaV8,1307
8
+ codespar/types.py,sha256=kx0-CBOBRYY80NV1WCXd17mkSl-WJnO5JlswaW5ZjPI,4812
9
+ codespar-0.1.0.dist-info/METADATA,sha256=IOAKy0QW8rkVuYYPNMOjjwT4bhzSoOqVUPtC5-7Gp-I,5627
10
+ codespar-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
11
+ codespar-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any