pydantic-claude-code 0.7.3__tar.gz → 0.7.5__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.
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/PKG-INFO +3 -3
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/README.md +2 -2
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/pyproject.toml +1 -1
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/__init__.py +1 -1
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/clai2.py +52 -8
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/config.py +1 -1
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/flow.py +4 -1
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_clai2.py +54 -6
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_flow.py +13 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/uv.lock +1 -1
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/.github/workflows/ci.yml +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/.github/workflows/publish.yml +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/.gitignore +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/LICENSE +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/examples/basic.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/install.sh +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/scripts/sync_gist.sh +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/__main__.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/auth.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/credentials.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/model.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/provider.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/py.typed +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/storage.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/updates.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/conftest.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_callback_server.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_credentials.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_install.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_integration.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_keyring_store.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_model.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_provider.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_refresh.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_storage.py +0 -0
- {pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/tests/test_updates.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pydantic-claude-code
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.5
|
|
4
4
|
Summary: Use your Claude Code subscription from a Pydantic AI Agent or CLAI2, with full tool support
|
|
5
5
|
Project-URL: Source, https://gist.github.com/mpfaffenberger/bd75c7b424ffdc6d81645bfe7de822d3
|
|
6
6
|
Project-URL: Homepage, https://pypi.org/project/pydantic-claude-code/
|
|
@@ -313,7 +313,7 @@ retries once on a 401, exactly like pydantic-ai's Codex provider. When the
|
|
|
313
313
|
refresh token itself is rejected, runs raise `ClaudeCodeSignInExpiredError`
|
|
314
314
|
(a `UserError`) telling you to sign in again.
|
|
315
315
|
|
|
316
|
-
Requests identify as Claude Code 2.1.
|
|
316
|
+
Requests identify as Claude Code 2.1.290. The persona
|
|
317
317
|
`"You are Claude Code, Anthropic's official CLI for Claude."` is prepended to
|
|
318
318
|
the system context (position 0), as the CLI sends it. The client version
|
|
319
319
|
matters: the subscription backend refuses newer models to older CLI versions
|
|
@@ -340,7 +340,7 @@ uv run pytest
|
|
|
340
340
|
|
|
341
341
|
To release, bump `version` in `pyproject.toml` and `__version__` in
|
|
342
342
|
`src/pydantic_ai_claude_code/__init__.py` (a test checks they match), merge, and
|
|
343
|
-
push a matching tag (`git tag v0.7.
|
|
343
|
+
push a matching tag (`git tag v0.7.5 && git push origin v0.7.5`). The `Publish` workflow tests,
|
|
344
344
|
builds, and uploads it to PyPI with the `PYPI_API_TOKEN` repository secret. Then run
|
|
345
345
|
`scripts/sync_gist.sh` to publish the release to the install gist, which is what the one-liner and the
|
|
346
346
|
update notice install from.
|
|
@@ -284,7 +284,7 @@ retries once on a 401, exactly like pydantic-ai's Codex provider. When the
|
|
|
284
284
|
refresh token itself is rejected, runs raise `ClaudeCodeSignInExpiredError`
|
|
285
285
|
(a `UserError`) telling you to sign in again.
|
|
286
286
|
|
|
287
|
-
Requests identify as Claude Code 2.1.
|
|
287
|
+
Requests identify as Claude Code 2.1.290. The persona
|
|
288
288
|
`"You are Claude Code, Anthropic's official CLI for Claude."` is prepended to
|
|
289
289
|
the system context (position 0), as the CLI sends it. The client version
|
|
290
290
|
matters: the subscription backend refuses newer models to older CLI versions
|
|
@@ -311,7 +311,7 @@ uv run pytest
|
|
|
311
311
|
|
|
312
312
|
To release, bump `version` in `pyproject.toml` and `__version__` in
|
|
313
313
|
`src/pydantic_ai_claude_code/__init__.py` (a test checks they match), merge, and
|
|
314
|
-
push a matching tag (`git tag v0.7.
|
|
314
|
+
push a matching tag (`git tag v0.7.5 && git push origin v0.7.5`). The `Publish` workflow tests,
|
|
315
315
|
builds, and uploads it to PyPI with the `PYPI_API_TOKEN` repository secret. Then run
|
|
316
316
|
`scripts/sync_gist.sh` to publish the release to the install gist, which is what the one-liner and the
|
|
317
317
|
update notice install from.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pydantic-claude-code"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.5"
|
|
8
8
|
description = "Use your Claude Code subscription from a Pydantic AI Agent or CLAI2, with full tool support"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10,<3.15"
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/__init__.py
RENAMED
|
@@ -26,7 +26,7 @@ from .model import ClaudeCodeModel
|
|
|
26
26
|
from .provider import ClaudeCodeProvider
|
|
27
27
|
from .storage import ClaudeCodeTokenStore, KeyringTokenStore, default_auth_path, default_store
|
|
28
28
|
|
|
29
|
-
__version__ = "0.7.
|
|
29
|
+
__version__ = "0.7.5"
|
|
30
30
|
"""Matches `version` in pyproject.toml (a test checks), so a copied folder knows its release."""
|
|
31
31
|
|
|
32
32
|
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/clai2.py
RENAMED
|
@@ -21,7 +21,7 @@ import asyncio
|
|
|
21
21
|
import dataclasses
|
|
22
22
|
import importlib
|
|
23
23
|
import sys
|
|
24
|
-
from collections.abc import Callable, Sequence
|
|
24
|
+
from collections.abc import Awaitable, Callable, Sequence
|
|
25
25
|
from datetime import datetime
|
|
26
26
|
from typing import IO, Any, cast, get_args
|
|
27
27
|
|
|
@@ -234,10 +234,20 @@ def status(source: ClaudeCodeConfig, profile: str | None = None) -> str:
|
|
|
234
234
|
return f"Signed in to {_account(profile)}; tokens are kept in {where}."
|
|
235
235
|
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
ReadPasteback = Callable[[], Awaitable[str | None]]
|
|
238
|
+
"""Reads the address the browser ended on; `None` when the user cancels."""
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
async def sign_in(
|
|
242
|
+
source: ClaudeCodeConfig,
|
|
243
|
+
show_url: Callable[[str], None],
|
|
244
|
+
profile: str | None = None,
|
|
245
|
+
*,
|
|
246
|
+
read_pasteback: ReadPasteback,
|
|
247
|
+
) -> str:
|
|
238
248
|
"""Sign in through the browser, or a pasted redirect address, and save the tokens to the chosen store."""
|
|
239
249
|
store = source.store(profile)
|
|
240
|
-
await login(store=store, on_url=show_url, read_pasteback=
|
|
250
|
+
await login(store=store, on_url=show_url, read_pasteback=read_pasteback)
|
|
241
251
|
first = config.MODELS[0]
|
|
242
252
|
if profile is not None:
|
|
243
253
|
return f"Signed in to {_account(profile)}. Run /model {PREFIX}@{profile}:{first}, or any other model."
|
|
@@ -245,11 +255,38 @@ async def sign_in(source: ClaudeCodeConfig, show_url: Callable[[str], None], pro
|
|
|
245
255
|
|
|
246
256
|
|
|
247
257
|
PASTE_PROMPT = "Or paste the address your browser ended on, then Enter (Esc cancels): "
|
|
258
|
+
PASTE_AGAIN = "No authorization code in that; paste the whole address, then Enter (Esc cancels): "
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def paste_reader(host: PluginHost[Any]) -> ReadPasteback:
|
|
262
|
+
"""How this CLAI2 build reads a pasted redirect address under the sign-in URL it just printed.
|
|
263
|
+
|
|
264
|
+
Newer builds draw a live panel, and a full-screen menu worker takes it off the screen, hiding the
|
|
265
|
+
printed URL with it. They offer `line_input.read_line`, which pins the prompt under the transcript
|
|
266
|
+
instead, so the URL stays visible. Older builds print straight to the terminal, where
|
|
267
|
+
`read_pasted_url` draws under the URL.
|
|
268
|
+
"""
|
|
269
|
+
try:
|
|
270
|
+
line_input = importlib.import_module("pydantic_clai2.ui.prompt.line_input")
|
|
271
|
+
except ImportError:
|
|
272
|
+
return lambda: run_worker(read_pasted_url)
|
|
273
|
+
|
|
274
|
+
async def read() -> str | None:
|
|
275
|
+
prompt = PASTE_PROMPT
|
|
276
|
+
while (text := await line_input.read_line(prompt, console=host.console, hidden=True)) is not None:
|
|
277
|
+
if parse_pasteback(text) is not None:
|
|
278
|
+
return text
|
|
279
|
+
prompt = PASTE_AGAIN
|
|
280
|
+
return None
|
|
281
|
+
|
|
282
|
+
return read
|
|
248
283
|
|
|
249
284
|
|
|
250
285
|
def read_pasted_url(keys: Callable[[], str] = menu_key, output: IO[str] = sys.stdout) -> str | None:
|
|
251
286
|
"""Read a pasted redirect address on one line, under the printed sign-in URL; `None` on Esc.
|
|
252
287
|
|
|
288
|
+
For CLAI2 builds without `line_input`: see `paste_reader`.
|
|
289
|
+
|
|
253
290
|
The address carries the authorization code, so it is counted, not echoed: a long URL would also wrap
|
|
254
291
|
and break the one-line redraw. `keys` is `run_worker`'s `menu_key`, which turns into `ctrl-c` when the
|
|
255
292
|
browser's callback wins and `login` cancels this read.
|
|
@@ -293,12 +330,18 @@ def sign_out(source: ClaudeCodeConfig, profile: str | None = None) -> str:
|
|
|
293
330
|
return f"Signed out of {_account(profile)}. The tokens stay valid at Anthropic until they expire."
|
|
294
331
|
|
|
295
332
|
|
|
296
|
-
async def configure(
|
|
333
|
+
async def configure(
|
|
334
|
+
source: ClaudeCodeConfig,
|
|
335
|
+
show_url: Callable[[str], None],
|
|
336
|
+
runners: Runners = TERMINAL,
|
|
337
|
+
*,
|
|
338
|
+
read_pasteback: ReadPasteback,
|
|
339
|
+
) -> str:
|
|
297
340
|
"""Open the settings menu until Esc or Save & close."""
|
|
298
341
|
|
|
299
342
|
async def account() -> list[str]:
|
|
300
343
|
try:
|
|
301
|
-
return [await sign_in(source, show_url)]
|
|
344
|
+
return [await sign_in(source, show_url, read_pasteback=read_pasteback)]
|
|
302
345
|
except UserError as exc:
|
|
303
346
|
return [str(exc)]
|
|
304
347
|
|
|
@@ -314,6 +357,7 @@ class ClaudeCodePlugin(Plugin[ClaudeCodeSettings]):
|
|
|
314
357
|
super().__init__(host, settings)
|
|
315
358
|
self.source = ClaudeCodeConfig(settings, host.save_settings)
|
|
316
359
|
self._providers = Providers()
|
|
360
|
+
self._read_pasteback = paste_reader(host)
|
|
317
361
|
self._update: asyncio.Task[str | None] | None = None
|
|
318
362
|
self.provider = ModelProvider(
|
|
319
363
|
prefix=PREFIX,
|
|
@@ -355,10 +399,10 @@ class ClaudeCodePlugin(Plugin[ClaudeCodeSettings]):
|
|
|
355
399
|
return await account_usage(provider)
|
|
356
400
|
|
|
357
401
|
async def _sign_in(self) -> str:
|
|
358
|
-
return await sign_in(self.source, self._show_url)
|
|
402
|
+
return await sign_in(self.source, self._show_url, read_pasteback=self._read_pasteback)
|
|
359
403
|
|
|
360
404
|
async def _sign_in_profile(self, profile: str) -> str:
|
|
361
|
-
return await sign_in(self.source, self._show_url, profile)
|
|
405
|
+
return await sign_in(self.source, self._show_url, profile, read_pasteback=self._read_pasteback)
|
|
362
406
|
|
|
363
407
|
def get_commands(self) -> Sequence[Command]:
|
|
364
408
|
return (
|
|
@@ -384,7 +428,7 @@ class ClaudeCodePlugin(Plugin[ClaudeCodeSettings]):
|
|
|
384
428
|
return await asyncio.to_thread(action, self.source, args[1] if len(args) == 2 else None)
|
|
385
429
|
|
|
386
430
|
async def configure(self) -> str:
|
|
387
|
-
return await configure(self.source, self._show_url)
|
|
431
|
+
return await configure(self.source, self._show_url, read_pasteback=self._read_pasteback)
|
|
388
432
|
|
|
389
433
|
async def on_session_start(self, event: SessionStart) -> None:
|
|
390
434
|
"""Check PyPI for a newer release in the background, so startup never waits on it."""
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/config.py
RENAMED
|
@@ -47,5 +47,5 @@ CALLBACK_TIMEOUT = 180
|
|
|
47
47
|
# appended (never replaced) by the auth layer so feature betas set by pydantic-ai survive.
|
|
48
48
|
ANTHROPIC_BETA = "oauth-2025-04-20"
|
|
49
49
|
# The subscription backend gates models on this version: Opus 5.5 answers 400 below 2.1.280.
|
|
50
|
-
USER_AGENT = "claude-cli/2.1.
|
|
50
|
+
USER_AGENT = "claude-cli/2.1.290 (external, cli)"
|
|
51
51
|
X_APP = "cli"
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/flow.py
RENAMED
|
@@ -207,12 +207,15 @@ async def login(
|
|
|
207
207
|
server = start_login_callback_server()
|
|
208
208
|
timeout = None if read_pasteback is not None else config.CALLBACK_TIMEOUT
|
|
209
209
|
callback = asyncio.ensure_future(asyncio.to_thread(server.received.wait, timeout))
|
|
210
|
-
paste
|
|
210
|
+
paste: asyncio.Future[str | None] | None = None
|
|
211
211
|
try:
|
|
212
212
|
redirect_uri = f"{config.REDIRECT_HOST}:{server.server_address[1]}/{config.REDIRECT_PATH}"
|
|
213
213
|
flow = ClaudeCodeOAuthFlow(redirect_uri=redirect_uri)
|
|
214
214
|
url = flow.authorization_url()
|
|
215
|
+
# Show the URL before the paste prompt starts: the prompt may take over the screen.
|
|
215
216
|
on_url(url)
|
|
217
|
+
if read_pasteback is not None:
|
|
218
|
+
paste = asyncio.ensure_future(read_pasteback())
|
|
216
219
|
# Launch the browser off the event path: on some macOS setups `webbrowser.open`
|
|
217
220
|
# hangs until the UI settles, which would starve the callback wait below.
|
|
218
221
|
threading.Thread(target=_open_browser, args=(url,), daemon=True).start()
|
|
@@ -8,6 +8,7 @@ import io
|
|
|
8
8
|
import shutil
|
|
9
9
|
import subprocess
|
|
10
10
|
import sys
|
|
11
|
+
import types
|
|
11
12
|
from collections.abc import Awaitable, Callable
|
|
12
13
|
from dataclasses import dataclass
|
|
13
14
|
from datetime import datetime, timezone
|
|
@@ -100,6 +101,10 @@ async def failing_login(
|
|
|
100
101
|
raise UserError("Claude Code OAuth callback timed out.")
|
|
101
102
|
|
|
102
103
|
|
|
104
|
+
async def no_paste() -> str | None:
|
|
105
|
+
return None
|
|
106
|
+
|
|
107
|
+
|
|
103
108
|
def pick(value: str) -> MenuResult:
|
|
104
109
|
return MenuResult(item=MenuItem(value, value=value))
|
|
105
110
|
|
|
@@ -239,7 +244,9 @@ async def test_the_update_check_can_be_turned_off(
|
|
|
239
244
|
|
|
240
245
|
|
|
241
246
|
async def test_bare_command_opens_the_settings_menu(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
242
|
-
async def fake_configure(
|
|
247
|
+
async def fake_configure(
|
|
248
|
+
source: ClaudeCodeConfig, show_url: Callable[[str], None], *, read_pasteback: clai2.ReadPasteback
|
|
249
|
+
) -> str:
|
|
243
250
|
show_url(URL)
|
|
244
251
|
return f"menu for {source.settings.credentials}"
|
|
245
252
|
|
|
@@ -256,7 +263,9 @@ async def test_menu_switches_storage_then_signs_in(monkeypatch: pytest.MonkeyPat
|
|
|
256
263
|
source = ClaudeCodeConfig(ClaudeCodeSettings(), saved.append)
|
|
257
264
|
urls: list[str] = []
|
|
258
265
|
|
|
259
|
-
message = await configure(
|
|
266
|
+
message = await configure(
|
|
267
|
+
source, urls.append, scripted(pick("credentials"), pick("account")), read_pasteback=no_paste
|
|
268
|
+
)
|
|
260
269
|
|
|
261
270
|
assert saved == [ClaudeCodeSettings(credentials="file")]
|
|
262
271
|
assert message.splitlines() == [
|
|
@@ -271,8 +280,9 @@ async def test_menu_switches_storage_then_signs_in(monkeypatch: pytest.MonkeyPat
|
|
|
271
280
|
async def test_menu_reports_a_failed_sign_in_and_an_untouched_menu(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
272
281
|
monkeypatch.setattr(clai2, "login", failing_login)
|
|
273
282
|
source = ClaudeCodeConfig(ClaudeCodeSettings(), lambda settings: None)
|
|
274
|
-
|
|
275
|
-
assert
|
|
283
|
+
menu = await configure(source, print, scripted(pick("account")), read_pasteback=no_paste)
|
|
284
|
+
assert menu == "Claude Code OAuth callback timed out."
|
|
285
|
+
assert await configure(source, print, scripted(), read_pasteback=no_paste) == "Claude Code settings unchanged."
|
|
276
286
|
|
|
277
287
|
|
|
278
288
|
def test_auto_follows_the_env_var_and_explicit_choices_do_not(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
@@ -403,13 +413,51 @@ async def test_sign_in_offers_the_paste_reader_to_login(monkeypatch: pytest.Monk
|
|
|
403
413
|
store.save(CREDS)
|
|
404
414
|
return CREDS
|
|
405
415
|
|
|
416
|
+
async def pasted() -> str | None:
|
|
417
|
+
return PASTED
|
|
418
|
+
|
|
406
419
|
monkeypatch.setattr(clai2, "login", pasting_login)
|
|
407
|
-
monkeypatch.setattr(clai2, "read_pasted_url", lambda: PASTED)
|
|
408
420
|
source = ClaudeCodeConfig(ClaudeCodeSettings(), lambda settings: None)
|
|
409
|
-
assert (await clai2.sign_in(source, print)).startswith("Signed in to Claude Code.")
|
|
421
|
+
assert (await clai2.sign_in(source, print, read_pasteback=pasted)).startswith("Signed in to Claude Code.")
|
|
410
422
|
assert offered == [PASTED]
|
|
411
423
|
|
|
412
424
|
|
|
425
|
+
async def test_builds_with_line_input_read_the_paste_under_the_url(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
426
|
+
"""A full-screen worker would hide the printed URL on these builds, so the paste goes through `read_line`."""
|
|
427
|
+
loaded = load()
|
|
428
|
+
answers = iter(["nope", PASTED])
|
|
429
|
+
asked: list[tuple[str, object, bool]] = []
|
|
430
|
+
|
|
431
|
+
async def read_line(prompt: str, *, console: Console, hidden: bool = False) -> str | None:
|
|
432
|
+
asked.append((prompt, console, hidden))
|
|
433
|
+
return next(answers)
|
|
434
|
+
|
|
435
|
+
line_input = types.ModuleType("pydantic_clai2.ui.prompt.line_input")
|
|
436
|
+
line_input.read_line = read_line # type: ignore[attr-defined]
|
|
437
|
+
monkeypatch.setitem(sys.modules, "pydantic_clai2.ui.prompt.line_input", line_input)
|
|
438
|
+
assert await clai2.paste_reader(loaded.host)() == PASTED
|
|
439
|
+
assert asked == [
|
|
440
|
+
(clai2.PASTE_PROMPT, loaded.host.console, True),
|
|
441
|
+
(clai2.PASTE_AGAIN, loaded.host.console, True),
|
|
442
|
+
]
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
async def test_a_cancelled_line_input_cancels_the_paste(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
446
|
+
async def read_line(prompt: str, *, console: Console, hidden: bool = False) -> str | None:
|
|
447
|
+
return None
|
|
448
|
+
|
|
449
|
+
line_input = types.ModuleType("pydantic_clai2.ui.prompt.line_input")
|
|
450
|
+
line_input.read_line = read_line # type: ignore[attr-defined]
|
|
451
|
+
monkeypatch.setitem(sys.modules, "pydantic_clai2.ui.prompt.line_input", line_input)
|
|
452
|
+
assert await clai2.paste_reader(load().host)() is None
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
async def test_older_builds_read_the_paste_in_a_worker(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
456
|
+
monkeypatch.setitem(sys.modules, "pydantic_clai2.ui.prompt.line_input", None)
|
|
457
|
+
monkeypatch.setattr(clai2, "read_pasted_url", lambda: PASTED)
|
|
458
|
+
assert await clai2.paste_reader(load().host)() == PASTED
|
|
459
|
+
|
|
460
|
+
|
|
413
461
|
@dataclass(frozen=True, kw_only=True)
|
|
414
462
|
class ProfileProvider(ModelProvider):
|
|
415
463
|
"""`ModelProvider` as a CLAI2 build with auth profiles declares it."""
|
|
@@ -6,6 +6,7 @@ import asyncio
|
|
|
6
6
|
import json
|
|
7
7
|
import threading
|
|
8
8
|
import time
|
|
9
|
+
from collections.abc import Awaitable
|
|
9
10
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
10
11
|
from urllib.parse import parse_qs, urlsplit
|
|
11
12
|
|
|
@@ -177,6 +178,18 @@ async def test_login_takes_a_pasted_address_when_the_callback_never_comes(token_
|
|
|
177
178
|
assert token_stub.last_body["redirect_uri"] == parse_qs(urlsplit(shown[0]).query)["redirect_uri"][0]
|
|
178
179
|
|
|
179
180
|
|
|
181
|
+
async def test_login_shows_the_url_before_asking_for_a_paste(token_stub, monkeypatch) -> None:
|
|
182
|
+
monkeypatch.setattr(flow, "_open_browser", lambda url: None)
|
|
183
|
+
shown: list[str] = []
|
|
184
|
+
|
|
185
|
+
def paste() -> Awaitable[str | None]:
|
|
186
|
+
assert shown, "the paste prompt started before the sign-in URL was shown"
|
|
187
|
+
return asyncio.sleep(0, _paste_from(shown[0]))
|
|
188
|
+
|
|
189
|
+
await flow.login(store=_MemoryStore(), on_url=shown.append, read_pasteback=paste)
|
|
190
|
+
assert token_stub.last_body["code"] == "pasted-code"
|
|
191
|
+
|
|
192
|
+
|
|
180
193
|
async def test_login_cancels_the_paste_read_when_the_browser_gets_through(token_stub, monkeypatch) -> None:
|
|
181
194
|
monkeypatch.setattr(flow, "_open_browser", lambda url: None)
|
|
182
195
|
cancelled = asyncio.Event()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/__main__.py
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/auth.py
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/credentials.py
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/model.py
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/provider.py
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/py.typed
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/storage.py
RENAMED
|
File without changes
|
{pydantic_claude_code-0.7.3 → pydantic_claude_code-0.7.5}/src/pydantic_ai_claude_code/updates.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|