codespar 0.3.0__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codespar-0.9.0/CHANGELOG.md +26 -0
- {codespar-0.3.0 → codespar-0.9.0}/PKG-INFO +43 -1
- {codespar-0.3.0 → codespar-0.9.0}/README.md +42 -0
- {codespar-0.3.0 → codespar-0.9.0}/pyproject.toml +1 -1
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/__init__.py +65 -1
- codespar-0.9.0/src/codespar/_async_session.py +958 -0
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/_http.py +55 -1
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/_sync_client.py +72 -0
- codespar-0.9.0/src/codespar/types.py +508 -0
- codespar-0.9.0/tests/test_session.py +522 -0
- codespar-0.3.0/src/codespar/_async_session.py +0 -420
- codespar-0.3.0/src/codespar/types.py +0 -209
- codespar-0.3.0/tests/test_session.py +0 -244
- {codespar-0.3.0 → codespar-0.9.0}/.gitignore +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/examples/README.md +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/examples/async_basic.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/examples/connect_link.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/examples/ecommerce_checkout.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/examples/pix_payment.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/examples/proxy_execute.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/_async_client.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/_presets.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/errors.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/src/codespar/py.typed +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/tests/__init__.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/tests/test_config.py +0 -0
- {codespar-0.3.0 → codespar-0.9.0}/tests/test_streaming.py +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# codespar (Python SDK) — CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
- New: `AsyncSession.payment_status_stream(tool_call_id, *, on_update=None)`.
|
|
6
|
+
Opens an SSE stream against
|
|
7
|
+
`GET /v1/tool-calls/:id/payment-status/stream`, invokes `on_update`
|
|
8
|
+
(sync or async callable) for the initial snapshot + every state
|
|
9
|
+
change, and returns the last envelope observed once the backend
|
|
10
|
+
closes the stream (5s after terminal state). Cancel by wrapping
|
|
11
|
+
the awaitable in an `asyncio.Task` and calling `.cancel()`.
|
|
12
|
+
- New: `AsyncSession.verification_status_stream(tool_call_id, *, on_update=None)`
|
|
13
|
+
— KYC sibling with the same lifecycle.
|
|
14
|
+
- New: matching sync wrappers `Session.payment_status_stream` and
|
|
15
|
+
`Session.verification_status_stream` on the blocking client.
|
|
16
|
+
- New: `_http.stream_sse_get(...)` helper, GET-based SSE iterator
|
|
17
|
+
yielding `(event_name, payload)` tuples and filtering heartbeat
|
|
18
|
+
comment frames. The existing `stream_sse` (POST-based) is kept for
|
|
19
|
+
the chat-loop's `send_stream`.
|
|
20
|
+
- Polling siblings (`payment_status` / `verification_status`) stay
|
|
21
|
+
live for backward compat.
|
|
22
|
+
- User-Agent bumped to `codespar-python/0.9.0`.
|
|
23
|
+
|
|
24
|
+
## 0.8.0
|
|
25
|
+
|
|
26
|
+
Previous release. See git log for prior entries.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codespar
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Python SDK for CodeSpar — commerce infrastructure for AI agents in Latin America.
|
|
5
5
|
Project-URL: Homepage, https://codespar.dev
|
|
6
6
|
Project-URL: Documentation, https://docs.codespar.dev
|
|
@@ -78,6 +78,48 @@ with CodeSpar(api_key="csk_live_...") as cs:
|
|
|
78
78
|
print(session.send("Quero pagar R$125 via Pix").message)
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
## Tool discovery + connection wizard
|
|
82
|
+
|
|
83
|
+
Beyond `session.execute(tool, params)`, the SDK exposes typed wrappers
|
|
84
|
+
for the F3.M2 meta-tools `codespar_discover` and
|
|
85
|
+
`codespar_manage_connections`:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from codespar import CodeSpar, ConnectionWizardOptions, DiscoverOptions
|
|
89
|
+
|
|
90
|
+
with CodeSpar(api_key="csk_live_...") as cs:
|
|
91
|
+
session = cs.create("user_123", preset="brazilian")
|
|
92
|
+
|
|
93
|
+
# Find the right tool for a free-form use case.
|
|
94
|
+
found = session.discover(
|
|
95
|
+
"send a pix payment",
|
|
96
|
+
DiscoverOptions(country="BR", limit=3),
|
|
97
|
+
)
|
|
98
|
+
if found.recommended:
|
|
99
|
+
print(found.recommended.server_id, found.recommended.tool_name)
|
|
100
|
+
print(f" status: {found.recommended.connection_status}")
|
|
101
|
+
|
|
102
|
+
# Surface the connection wizard if the recommended server isn't
|
|
103
|
+
# connected. NEVER pass credentials through this method —
|
|
104
|
+
# credentials only travel via the dashboard's connect modal or
|
|
105
|
+
# the OAuth callback. The wizard returns a deep-link the agent
|
|
106
|
+
# surfaces so the user finishes setup in their browser.
|
|
107
|
+
if found.recommended and found.recommended.connection_status == "disconnected":
|
|
108
|
+
wiz = session.connection_wizard(
|
|
109
|
+
ConnectionWizardOptions(
|
|
110
|
+
action="initiate",
|
|
111
|
+
server_id=found.recommended.server_id,
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
if wiz.initiate:
|
|
115
|
+
print("Connect:", wiz.initiate.connect_url)
|
|
116
|
+
for line in wiz.initiate.instructions:
|
|
117
|
+
print(" ·", line)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Async users have the same surface on `AsyncSession`
|
|
121
|
+
(`await session.discover(...)`, `await session.connection_wizard(...)`).
|
|
122
|
+
|
|
81
123
|
## Streaming
|
|
82
124
|
|
|
83
125
|
```python
|
|
@@ -47,6 +47,48 @@ with CodeSpar(api_key="csk_live_...") as cs:
|
|
|
47
47
|
print(session.send("Quero pagar R$125 via Pix").message)
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Tool discovery + connection wizard
|
|
51
|
+
|
|
52
|
+
Beyond `session.execute(tool, params)`, the SDK exposes typed wrappers
|
|
53
|
+
for the F3.M2 meta-tools `codespar_discover` and
|
|
54
|
+
`codespar_manage_connections`:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from codespar import CodeSpar, ConnectionWizardOptions, DiscoverOptions
|
|
58
|
+
|
|
59
|
+
with CodeSpar(api_key="csk_live_...") as cs:
|
|
60
|
+
session = cs.create("user_123", preset="brazilian")
|
|
61
|
+
|
|
62
|
+
# Find the right tool for a free-form use case.
|
|
63
|
+
found = session.discover(
|
|
64
|
+
"send a pix payment",
|
|
65
|
+
DiscoverOptions(country="BR", limit=3),
|
|
66
|
+
)
|
|
67
|
+
if found.recommended:
|
|
68
|
+
print(found.recommended.server_id, found.recommended.tool_name)
|
|
69
|
+
print(f" status: {found.recommended.connection_status}")
|
|
70
|
+
|
|
71
|
+
# Surface the connection wizard if the recommended server isn't
|
|
72
|
+
# connected. NEVER pass credentials through this method —
|
|
73
|
+
# credentials only travel via the dashboard's connect modal or
|
|
74
|
+
# the OAuth callback. The wizard returns a deep-link the agent
|
|
75
|
+
# surfaces so the user finishes setup in their browser.
|
|
76
|
+
if found.recommended and found.recommended.connection_status == "disconnected":
|
|
77
|
+
wiz = session.connection_wizard(
|
|
78
|
+
ConnectionWizardOptions(
|
|
79
|
+
action="initiate",
|
|
80
|
+
server_id=found.recommended.server_id,
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
if wiz.initiate:
|
|
84
|
+
print("Connect:", wiz.initiate.connect_url)
|
|
85
|
+
for line in wiz.initiate.instructions:
|
|
86
|
+
print(" ·", line)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Async users have the same surface on `AsyncSession`
|
|
90
|
+
(`await session.discover(...)`, `await session.connection_wizard(...)`).
|
|
91
|
+
|
|
50
92
|
## Streaming
|
|
51
93
|
|
|
52
94
|
```python
|
|
@@ -40,18 +40,43 @@ from .types import (
|
|
|
40
40
|
AssistantTextEvent,
|
|
41
41
|
AuthConfig,
|
|
42
42
|
AuthResult,
|
|
43
|
+
ChargeArgs,
|
|
44
|
+
ChargeBuyer,
|
|
45
|
+
ChargeMethod,
|
|
46
|
+
ChargeResult,
|
|
47
|
+
ConnectionDifficulty,
|
|
48
|
+
ConnectionStatus,
|
|
49
|
+
ConnectionStatusRow,
|
|
50
|
+
ConnectionWizardInstructions,
|
|
51
|
+
ConnectionWizardOptions,
|
|
52
|
+
ConnectionWizardResult,
|
|
53
|
+
DiscoverOptions,
|
|
54
|
+
DiscoverPlanStep,
|
|
55
|
+
DiscoverResult,
|
|
56
|
+
DiscoverToolMatch,
|
|
43
57
|
DoneEvent,
|
|
44
58
|
ErrorEvent,
|
|
45
59
|
HttpMethod,
|
|
46
60
|
ManageConnections,
|
|
61
|
+
PaymentStatus,
|
|
62
|
+
PaymentStatusEvent,
|
|
63
|
+
PaymentStatusResult,
|
|
47
64
|
Preset,
|
|
48
65
|
ProxyRequest,
|
|
49
66
|
ProxyResult,
|
|
67
|
+
RequiredSecret,
|
|
68
|
+
SearchStrategy,
|
|
50
69
|
SendResult,
|
|
51
70
|
ServerConnection,
|
|
52
71
|
SessionConfig,
|
|
53
72
|
SessionInfo,
|
|
54
73
|
SessionStatus,
|
|
74
|
+
ShipAction,
|
|
75
|
+
ShipAddress,
|
|
76
|
+
ShipArgs,
|
|
77
|
+
ShipItem,
|
|
78
|
+
ShipResult,
|
|
79
|
+
ShipServiceLevel,
|
|
55
80
|
StreamEvent,
|
|
56
81
|
Tool,
|
|
57
82
|
ToolCallRecord,
|
|
@@ -59,9 +84,13 @@ from .types import (
|
|
|
59
84
|
ToolResultEvent,
|
|
60
85
|
ToolUseEvent,
|
|
61
86
|
UserMessageEvent,
|
|
87
|
+
VerificationStatus,
|
|
88
|
+
VerificationStatusEvent,
|
|
89
|
+
VerificationStatusResult,
|
|
90
|
+
WizardAction,
|
|
62
91
|
)
|
|
63
92
|
|
|
64
|
-
__version__ = "0.
|
|
93
|
+
__version__ = "0.9.0"
|
|
65
94
|
|
|
66
95
|
__all__ = [
|
|
67
96
|
"ApiError",
|
|
@@ -71,20 +100,43 @@ __all__ = [
|
|
|
71
100
|
# Connect Links
|
|
72
101
|
"AuthConfig",
|
|
73
102
|
"AuthResult",
|
|
103
|
+
# Inbound charge (codespar_charge)
|
|
104
|
+
"ChargeArgs",
|
|
105
|
+
"ChargeBuyer",
|
|
106
|
+
"ChargeMethod",
|
|
107
|
+
"ChargeResult",
|
|
74
108
|
# Clients
|
|
75
109
|
"CodeSpar",
|
|
76
110
|
# Errors
|
|
77
111
|
"CodeSparError",
|
|
78
112
|
"ConfigError",
|
|
113
|
+
# Connection wizard (codespar_manage_connections)
|
|
114
|
+
"ConnectionDifficulty",
|
|
115
|
+
"ConnectionStatus",
|
|
116
|
+
"ConnectionStatusRow",
|
|
117
|
+
"ConnectionWizardInstructions",
|
|
118
|
+
"ConnectionWizardOptions",
|
|
119
|
+
"ConnectionWizardResult",
|
|
120
|
+
# Tool discovery (codespar_discover)
|
|
121
|
+
"DiscoverOptions",
|
|
122
|
+
"DiscoverPlanStep",
|
|
123
|
+
"DiscoverResult",
|
|
124
|
+
"DiscoverToolMatch",
|
|
79
125
|
"DoneEvent",
|
|
80
126
|
"ErrorEvent",
|
|
81
127
|
"HttpMethod",
|
|
82
128
|
"ManageConnections",
|
|
83
129
|
"NotConnectedError",
|
|
130
|
+
# Async settlement (codespar_pay etc.)
|
|
131
|
+
"PaymentStatus",
|
|
132
|
+
"PaymentStatusEvent",
|
|
133
|
+
"PaymentStatusResult",
|
|
84
134
|
"Preset",
|
|
85
135
|
# Proxy
|
|
86
136
|
"ProxyRequest",
|
|
87
137
|
"ProxyResult",
|
|
138
|
+
"RequiredSecret",
|
|
139
|
+
"SearchStrategy",
|
|
88
140
|
"SendResult",
|
|
89
141
|
"ServerConnection",
|
|
90
142
|
"Session",
|
|
@@ -93,6 +145,13 @@ __all__ = [
|
|
|
93
145
|
# Session output
|
|
94
146
|
"SessionInfo",
|
|
95
147
|
"SessionStatus",
|
|
148
|
+
# Shipping (codespar_ship)
|
|
149
|
+
"ShipAction",
|
|
150
|
+
"ShipAddress",
|
|
151
|
+
"ShipArgs",
|
|
152
|
+
"ShipItem",
|
|
153
|
+
"ShipResult",
|
|
154
|
+
"ShipServiceLevel",
|
|
96
155
|
"StreamError",
|
|
97
156
|
# Streaming events
|
|
98
157
|
"StreamEvent",
|
|
@@ -102,6 +161,11 @@ __all__ = [
|
|
|
102
161
|
"ToolResultEvent",
|
|
103
162
|
"ToolUseEvent",
|
|
104
163
|
"UserMessageEvent",
|
|
164
|
+
# Async KYC verification (codespar_kyc)
|
|
165
|
+
"VerificationStatus",
|
|
166
|
+
"VerificationStatusEvent",
|
|
167
|
+
"VerificationStatusResult",
|
|
168
|
+
"WizardAction",
|
|
105
169
|
# Version
|
|
106
170
|
"__version__",
|
|
107
171
|
]
|