vercel-internal-core 0.2.0__tar.gz → 0.2.2__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.
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/.gitignore +3 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/PKG-INFO +2 -2
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/pyproject.toml +1 -1
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/byte_stream.py +12 -23
- vercel_internal_core-0.2.2/vercel/_internal/core/detect_agent.py +45 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/transport.py +21 -5
- vercel_internal_core-0.2.2/vercel/_internal/core/version.py +1 -0
- vercel_internal_core-0.2.0/vercel/_internal/core/version.py +0 -1
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/LICENSE +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/README.md +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/_vercel_hatch_build.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/hatch_build.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/__init__.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/errors.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/__init__.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/_compat.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/config.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/httpx.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/retry.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/iter_coroutine.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/options.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/polyfills/__init__.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/polyfills/_datetime.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/polyfills/_strenum.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/polyfills/_strenum_impl.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/polyfills/_typing.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/py.typed +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/session.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/time.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/typeutils.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/url.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/api/__init__.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/api/py.typed +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/errors/__init__.py +0 -0
- {vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/errors/py.typed +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: vercel-internal-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Shared internal runtime for Vercel Python packages
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Requires-Python: >=3.10
|
|
8
|
-
Requires-Dist: anyio<5,>=4.
|
|
8
|
+
Requires-Dist: anyio<5,>=4.11.0
|
|
9
9
|
Requires-Dist: httpx2>=2
|
|
10
10
|
Requires-Dist: typing-extensions<5,>=4.6.0; python_version < '3.12'
|
|
11
11
|
Description-Content-Type: text/markdown
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/byte_stream.py
RENAMED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Shared code consumes the async-shaped ``ReadableByteStream`` and
|
|
4
4
|
``StagingByteFile`` protocols. Callers select the runtime matching their public
|
|
5
5
|
API, then use its factories instead of constructing the private adapters directly.
|
|
6
|
-
The sync runtime
|
|
7
|
-
|
|
6
|
+
The sync runtime accepts buffers and blocking readers and never suspends. The async
|
|
7
|
+
runtime accepts buffers and async readers only; callers adapt blocking readers
|
|
8
|
+
before passing them to async code.
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
import inspect
|
|
@@ -37,15 +38,14 @@ class AsyncByteReader(Protocol):
|
|
|
37
38
|
|
|
38
39
|
BytesLike: TypeAlias = bytes | bytearray | memoryview
|
|
39
40
|
SyncByteSource: TypeAlias = BytesLike | SyncByteReader
|
|
40
|
-
AsyncByteSource: TypeAlias = AsyncByteReader
|
|
41
|
-
RawByteSource: TypeAlias = SyncByteSource | AsyncByteSource
|
|
41
|
+
AsyncByteSource: TypeAlias = BytesLike | AsyncByteReader
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class ReadableByteStream(Protocol):
|
|
45
45
|
"""Normalized readable stream consumed by shared internal workflows.
|
|
46
46
|
|
|
47
|
-
Its async shape hides whether a runtime performs the read inline
|
|
48
|
-
async source
|
|
47
|
+
Its async shape hides whether a runtime performs the read inline or awaits an
|
|
48
|
+
async source.
|
|
49
49
|
"""
|
|
50
50
|
|
|
51
51
|
async def read(self, size: int = -1, /) -> bytes: ...
|
|
@@ -126,16 +126,6 @@ class _AsyncReader:
|
|
|
126
126
|
return _bytes_result(await self._source.read(size))
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
class _ThreadedSyncReader:
|
|
130
|
-
"""Run a blocking reader on a worker thread for use by async workflows."""
|
|
131
|
-
|
|
132
|
-
def __init__(self, source: SyncByteReader) -> None:
|
|
133
|
-
self._source = source
|
|
134
|
-
|
|
135
|
-
async def read(self, size: int = -1, /) -> bytes:
|
|
136
|
-
return _bytes_result(await anyio.to_thread.run_sync(self._source.read, size))
|
|
137
|
-
|
|
138
|
-
|
|
139
129
|
class _SyncTemporaryFile:
|
|
140
130
|
"""Expose a blocking temporary file through non-suspending async methods."""
|
|
141
131
|
|
|
@@ -217,20 +207,20 @@ class SyncByteStreamRuntime:
|
|
|
217
207
|
class AsyncByteStreamRuntime:
|
|
218
208
|
"""Adapt byte primitives for execution under AnyIO.
|
|
219
209
|
|
|
220
|
-
Async readers are awaited directly
|
|
221
|
-
|
|
210
|
+
Async readers are awaited directly. Blocking readers are rejected rather than
|
|
211
|
+
moved to worker threads.
|
|
222
212
|
"""
|
|
223
213
|
|
|
224
214
|
@staticmethod
|
|
225
|
-
def reader(source:
|
|
215
|
+
def reader(source: AsyncByteSource) -> ReadableByteStream:
|
|
226
216
|
if isinstance(source, (bytes, bytearray, memoryview)):
|
|
227
217
|
return _MemoryReader(source)
|
|
228
218
|
read = getattr(source, "read", None)
|
|
229
219
|
if not callable(read):
|
|
230
220
|
raise TypeError("byte source must provide a callable read method")
|
|
231
|
-
if inspect.iscoroutinefunction(read):
|
|
232
|
-
|
|
233
|
-
return
|
|
221
|
+
if not inspect.iscoroutinefunction(read):
|
|
222
|
+
raise TypeError("async byte stream runtime does not support sync readers")
|
|
223
|
+
return _AsyncReader(source)
|
|
234
224
|
|
|
235
225
|
def temporary_file(self) -> AbstractAsyncContextManager[StagingByteFile]:
|
|
236
226
|
return cast(
|
|
@@ -244,7 +234,6 @@ __all__ = [
|
|
|
244
234
|
"AsyncByteSource",
|
|
245
235
|
"AsyncByteStreamRuntime",
|
|
246
236
|
"BytesLike",
|
|
247
|
-
"RawByteSource",
|
|
248
237
|
"ReadableByteStream",
|
|
249
238
|
"StagingByteFile",
|
|
250
239
|
"StagingFileRuntime",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Detect coding agents from the environment of the current process.
|
|
2
|
+
|
|
3
|
+
The checks mirror the environment-variable rules in @vercel/detect-agent 1.2.5.
|
|
4
|
+
Its filesystem-based Devin check is intentionally outside this utility's scope.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
from collections.abc import Mapping
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def detect_agent_name(environ: Mapping[str, str] | None = None) -> str | None:
|
|
14
|
+
"""Return the agent driving this process, if its environment identifies one."""
|
|
15
|
+
env = os.environ if environ is None else environ
|
|
16
|
+
|
|
17
|
+
declared = env.get("AI_AGENT", "").strip()
|
|
18
|
+
if declared:
|
|
19
|
+
if declared in {"github-copilot", "github-copilot-cli"}:
|
|
20
|
+
return "github-copilot"
|
|
21
|
+
return declared
|
|
22
|
+
|
|
23
|
+
if env.get("CURSOR_TRACE_ID"):
|
|
24
|
+
return "cursor"
|
|
25
|
+
if env.get("CURSOR_AGENT") or env.get("CURSOR_EXTENSION_HOST_ROLE") == "agent-exec":
|
|
26
|
+
return "cursor-cli"
|
|
27
|
+
if env.get("GEMINI_CLI"):
|
|
28
|
+
return "gemini"
|
|
29
|
+
if any(env.get(name) for name in ("CODEX_SANDBOX", "CODEX_CI", "CODEX_THREAD_ID")):
|
|
30
|
+
return "codex"
|
|
31
|
+
if env.get("ANTIGRAVITY_AGENT"):
|
|
32
|
+
return "antigravity"
|
|
33
|
+
if env.get("AUGMENT_AGENT"):
|
|
34
|
+
return "augment-cli"
|
|
35
|
+
if env.get("OPENCODE_CLIENT"):
|
|
36
|
+
return "opencode"
|
|
37
|
+
if env.get("CLAUDECODE") or env.get("CLAUDE_CODE"):
|
|
38
|
+
return "cowork" if env.get("CLAUDE_CODE_IS_COWORK") else "claude"
|
|
39
|
+
if env.get("REPL_ID"):
|
|
40
|
+
return "replit"
|
|
41
|
+
if any(
|
|
42
|
+
env.get(name) for name in ("COPILOT_MODEL", "COPILOT_ALLOW_ALL", "COPILOT_GITHUB_TOKEN")
|
|
43
|
+
):
|
|
44
|
+
return "github-copilot"
|
|
45
|
+
return None
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/transport.py
RENAMED
|
@@ -367,15 +367,22 @@ class _SyncStreamingRequest(StreamingRequest):
|
|
|
367
367
|
if self._closed:
|
|
368
368
|
raise anyio.ClosedResourceError
|
|
369
369
|
self._closed = True
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
early_error: BaseException | None = None
|
|
371
|
+
if not self._finished.is_set() or self._response is None:
|
|
372
|
+
try:
|
|
373
|
+
self._put(_STREAM_EOF)
|
|
374
|
+
except anyio.BrokenResourceError as exc:
|
|
375
|
+
early_error = exc
|
|
376
|
+
else:
|
|
377
|
+
early_error = anyio.BrokenResourceError()
|
|
375
378
|
self._thread.join()
|
|
376
379
|
self._raise_worker_error()
|
|
377
380
|
if self._response is None:
|
|
381
|
+
if early_error is not None:
|
|
382
|
+
raise early_error
|
|
378
383
|
raise anyio.BrokenResourceError
|
|
384
|
+
if early_error is not None and self._response.is_success:
|
|
385
|
+
raise anyio.BrokenResourceError from early_error
|
|
379
386
|
self._completed = True
|
|
380
387
|
return _SyncStreamingResponse(self._response, self._chunk_size)
|
|
381
388
|
|
|
@@ -540,16 +547,25 @@ class _AsyncStreamingRequest(StreamingRequest):
|
|
|
540
547
|
if self._closed:
|
|
541
548
|
raise anyio.ClosedResourceError
|
|
542
549
|
self._closed = True
|
|
550
|
+
early_error: BaseException | None = None
|
|
551
|
+
if self._done.is_set() and self._response is not None:
|
|
552
|
+
early_error = anyio.BrokenResourceError()
|
|
543
553
|
try:
|
|
544
554
|
await self._send.aclose()
|
|
545
555
|
await self._done.wait()
|
|
556
|
+
except anyio.BrokenResourceError as exc:
|
|
557
|
+
early_error = exc
|
|
546
558
|
except BaseException:
|
|
547
559
|
with anyio.CancelScope(shield=True):
|
|
548
560
|
await self.abort()
|
|
549
561
|
raise
|
|
550
562
|
self._raise_worker_error()
|
|
551
563
|
if self._response is None:
|
|
564
|
+
if early_error is not None:
|
|
565
|
+
raise early_error
|
|
552
566
|
raise anyio.BrokenResourceError
|
|
567
|
+
if early_error is not None and self._response.is_success:
|
|
568
|
+
raise anyio.BrokenResourceError from early_error
|
|
553
569
|
self._completed = True
|
|
554
570
|
return _AsyncStreamingResponse(self._response, self._chunk_size)
|
|
555
571
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/__init__.py
RENAMED
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/_compat.py
RENAMED
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/config.py
RENAMED
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/httpx.py
RENAMED
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/http/retry.py
RENAMED
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/iter_coroutine.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/polyfills/_typing.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vercel_internal_core-0.2.0 → vercel_internal_core-0.2.2}/vercel/_internal/core/typeutils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|