Files
langgraph/libs/cli/langgraph_cli/deploy.py
T
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>John Kennedyopen-swe[bot] <open-swe@users.noreply.github.com>
be999ad38a chore(deps): bump the minor-and-patch group in /libs/cli with 5 updates (#8251)
Bumps the minor-and-patch group in /libs/cli with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [click](https://github.com/pallets/click) | `8.4.1` | `8.4.2` |
| [pytest](https://github.com/pytest-dev/pytest) | `9.0.3` | `9.1.1` |
| [ruff](https://github.com/astral-sh/ruff) | `0.15.15` | `0.15.20` |
| [ty](https://github.com/astral-sh/ty) | `0.0.43` | `0.0.55` |
| [hatch](https://github.com/pypa/hatch) | `1.16.5` | `1.17.0` |

Updates `click` from 8.4.1 to 8.4.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pallets/click/releases">click's
releases</a>.</em></p>
<blockquote>
<h2>8.4.2</h2>
<p>This is the Click 8.4.1 fix release, which fixes bugs but does not
otherwise change behavior and should not result in breaking changes
compared to the latest feature release.</p>
<p>PyPI: <a
href="https://pypi.org/project/click/8.4.2/">https://pypi.org/project/click/8.4.2/</a>
Changes: <a
href="https://click.palletsprojects.com/page/changes/#version-8-4-2">https://click.palletsprojects.com/page/changes/#version-8-4-2</a>
Milestone: <a
href="https://github.com/pallets/click/milestone/34">https://github.com/pallets/click/milestone/34</a></p>
<ul>
<li>Fix Fish shell completion broken in <code>8.4.0</code> by <a
href="https://redirect.github.com/pallets/click/issues/3126">#3126</a>.
Newlines and
tabs in option help text are now escaped, keeping the original
completion
format while still supporting multi-line help. <a
href="https://redirect.github.com/pallets/click/issues/3502">#3502</a>
<a
href="https://redirect.github.com/pallets/click/issues/3043">#3043</a>
<a
href="https://redirect.github.com/pallets/click/issues/3504">#3504</a>
<a
href="https://redirect.github.com/pallets/click/issues/3508">#3508</a></li>
<li>Deprecated commands and options with empty or missing help text no
longer
render a stray leading space before the <code>(DEPRECATED)</code> label.
<a
href="https://redirect.github.com/pallets/click/issues/3509">#3509</a></li>
<li>A {class}<code>Group</code> with
<code>invoke_without_command=True</code> marks its subcommand as
optional in the usage help, showing <code>[COMMAND]</code> instead of
<code>COMMAND</code>.
<a
href="https://redirect.github.com/pallets/click/issues/3059">#3059</a>
<a
href="https://redirect.github.com/pallets/click/issues/3507">#3507</a></li>
<li><code>echo_via_pager</code> flushes after each write, so passing a
generator streams
output to the pager incrementally instead of staying hidden until the
pipe
buffer fills. <a
href="https://redirect.github.com/pallets/click/issues/3242">#3242</a>
<a
href="https://redirect.github.com/pallets/click/issues/2542">#2542</a>
<a
href="https://redirect.github.com/pallets/click/issues/3534">#3534</a></li>
<li><code>echo_via_pager</code> and <code>get_pager_file</code> no
longer close a borrowed stdout
stream when no external pager runs, completing the partial
<code>I/O operation on closed file</code> fix from <a
href="https://redirect.github.com/pallets/click/issues/3482">#3482</a>.
<a
href="https://redirect.github.com/pallets/click/issues/3449">#3449</a>
<a
href="https://redirect.github.com/pallets/click/issues/3533">#3533</a></li>
<li>Fix CLI usage symopsis for optional arguments producing double
square brackets
<code>[[a|b|c]]...</code> whose type already brackets their metavar. <a
href="https://redirect.github.com/pallets/click/issues/3578">#3578</a></li>
<li>{func}<code>version_option</code> resolves a
<code>package_name</code> that does not match an
installed distribution as an import (top-level module) name via
{func}<code>importlib.metadata.packages_distributions</code>. Packages
whose
top-level module name differs from their distribution name
(<code>PIL</code> vs
<code>Pillow</code>, <code>jwt</code> vs <code>PyJWT</code>) no longer
raise <code>RuntimeError</code> out of the
box. <a
href="https://redirect.github.com/pallets/click/issues/2331">#2331</a>
<a
href="https://redirect.github.com/pallets/click/issues/1884">#1884</a>
<a
href="https://redirect.github.com/pallets/click/issues/3125">#3125</a>
<a
href="https://redirect.github.com/pallets/click/issues/3582">#3582</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pallets/click/blob/main/CHANGES.md">click's
changelog</a>.</em></p>
<blockquote>
<h2>Version 8.4.2</h2>
<p>Released 2026-06-24</p>
<ul>
<li>Fix Fish shell completion broken in <code>8.4.0</code> by
{pr}<code>3126</code>. Newlines and
tabs in option help text are now escaped, keeping the original
completion
format while still supporting multi-line help. {issue}<code>3502</code>
{issue}<code>3043</code> {pr}<code>3504</code>
{pr}<code>3508</code></li>
<li>Deprecated commands and options with empty or missing help text no
longer
render a stray leading space before the <code>(DEPRECATED)</code> label.
{pr}<code>3509</code></li>
<li>A {class}<code>Group</code> with
<code>invoke_without_command=True</code> marks its subcommand as
optional in the usage help, showing <code>[COMMAND]</code> instead of
<code>COMMAND</code>.
{issue}<code>3059</code> {pr}<code>3507</code></li>
<li><code>echo_via_pager</code> flushes after each write, so passing a
generator streams
output to the pager incrementally instead of staying hidden until the
pipe
buffer fills. {issue}<code>3242</code> {issue}<code>2542</code>
{pr}<code>3534</code></li>
<li><code>echo_via_pager</code> and <code>get_pager_file</code> no
longer close a borrowed stdout
stream when no external pager runs, completing the partial
<code>I/O operation on closed file</code> fix from
{pr}<code>3482</code>. {issue}<code>3449</code>
{pr}<code>3533</code></li>
<li>Fix CLI usage symopsis for optional arguments producing double
square brackets
<code>[[a|b|c]]...</code> whose type already brackets their metavar.
{pr}<code>3578</code></li>
<li>{func}<code>version_option</code> resolves a
<code>package_name</code> that does not match an
installed distribution as an import (top-level module) name via
{func}<code>importlib.metadata.packages_distributions</code>. Packages
whose
top-level module name differs from their distribution name
(<code>PIL</code> vs
<code>Pillow</code>, <code>jwt</code> vs <code>PyJWT</code>) no longer
raise <code>RuntimeError</code> out of the
box. {issue}<code>2331</code> {issue}<code>1884</code>
{issue}<code>3125</code> {pr}<code>3582</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pallets/click/commit/b2e30a175449cfda909ee4fbf4a29a6a071cad53"><code>b2e30a1</code></a>
Release version 8.4.2</li>
<li><a
href="https://github.com/pallets/click/commit/7a16b20e8a8a9bb57c7b4f6f15f60f6597478a49"><code>7a16b20</code></a>
Fix <code>package_name</code> resolution when module differs from
distribution name (<a
href="https://redirect.github.com/pallets/click/issues/3582">#3582</a>)</li>
<li><a
href="https://github.com/pallets/click/commit/bec59289d8cf9b9b4010642b2fee483e5f8eeefc"><code>bec5928</code></a>
Fix <code>package_name</code> resolution when top-level module differs
from distribution...</li>
<li><a
href="https://github.com/pallets/click/commit/916883afad450c0c9bbc4212817900949131adbd"><code>916883a</code></a>
Fix tests to not rely on <code>-Wdefault</code> option (<a
href="https://redirect.github.com/pallets/click/issues/3591">#3591</a>)</li>
<li><a
href="https://github.com/pallets/click/commit/09195f6a92972c4e1bbb5493686456e6ba624520"><code>09195f6</code></a>
Fix double-bracketing of choices in synopsis (<a
href="https://redirect.github.com/pallets/click/issues/3578">#3578</a>)</li>
<li><a
href="https://github.com/pallets/click/commit/1557e265222c431b1e4d6c4dd6754006ed10dc02"><code>1557e26</code></a>
Check for warning exception with idiomatic context manager</li>
<li><a
href="https://github.com/pallets/click/commit/d9ff13369ac78d9acff693faa79f26badd566ab3"><code>d9ff133</code></a>
Static typing improvements in <code>click.shell_completion</code> (<a
href="https://redirect.github.com/pallets/click/issues/3460">#3460</a>)</li>
<li><a
href="https://github.com/pallets/click/commit/762c97eef7c1b3779678992f26a553a2a8c80793"><code>762c97e</code></a>
Fix double-bracketing of choices in synopsis</li>
<li><a
href="https://github.com/pallets/click/commit/8929d392781c8113bc569f388c15c47b94f86581"><code>8929d39</code></a>
Convert changes to markdown. (<a
href="https://redirect.github.com/pallets/click/issues/3559">#3559</a>)</li>
<li><a
href="https://github.com/pallets/click/commit/237be507dbe3e653f6b41b3ea53266805534e8cd"><code>237be50</code></a>
Move changes headings down a level.</li>
<li>Additional commits viewable in <a
href="https://github.com/pallets/click/compare/8.4.1...8.4.2">compare
view</a></li>
</ul>
</details>
<br />

Updates `pytest` from 9.0.3 to 9.1.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pytest-dev/pytest/releases">pytest's
releases</a>.</em></p>
<blockquote>
<h2>9.1.1</h2>
<h1>pytest 9.1.1 (2026-06-19)</h1>
<h2>Bug fixes</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14220">#14220</a>:
Fixed a logic bug in <code>pytest.RaisesGroup</code> which would might
cause it to display incorrect &quot;It matches <!-- raw HTML omitted
-->FooError()<!-- raw HTML omitted --> which was paired with <!-- raw
HTML omitted -->BarError<!-- raw HTML omitted -->&quot; messages.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14591">#14591</a>:
Fixed a regression in pytest 9.1.0 which caused overriding a
parametrized fixture with an indirect <!-- raw HTML omitted --><a
href="https://github.com/pytest"><code>@​pytest</code></a>.mark.parametrize<!--
raw HTML omitted --> to fail with &quot;duplicate parametrization of
'&lt;fixture name&gt;'&quot;.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14606">#14606</a>:
Fixed <code>list-item</code> typing errors from mypy in
<code>@pytest.mark.parametrize &lt;pytest.mark.parametrize
ref&gt;</code> <code>argvalues</code> parameter.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14608">#14608</a>:
Fixed a regression in pytest 9.1.0 where <code>conftest.py</code> files
located in <code>&lt;invocation dir&gt;/test*</code> were no longer
loaded as initial conftests when invoked without arguments.
This could cause certain hooks (like <code>pytest_addoption</code>) in
these files to not fire.</li>
</ul>
<h2>9.1.0</h2>
<h1>pytest 9.1.0 (2026-06-13)</h1>
<h2>Removals and backward incompatible breaking changes</h2>
<ul>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14533">#14533</a>:
When using <code>--doctest-modules</code>, autouse fixtures with
<code>module</code>, <code>package</code> or <code>session</code> scope
that are defined inline in Python test modules (not plugins or
conftests) will now possibly execute twice.</p>
<p>If this is undesirable, move the fixture definition to a
<code>conftest.py</code> file if possible.</p>
<p>Technical explanation for those interested:
When using <!-- raw HTML omitted -->--doctest-modules<!-- raw HTML
omitted -->, pytest possibly collects Python modules twice, once as
<code>pytest.Module</code> and once as a <code>DoctestModule</code>
(depending on the configuration).
Due to improvements in pytest's fixture implementation, if e.g. the
<code>DoctestModule</code> collects a fixture, it is now visible to it
only, and not to the <code>Module</code>.
This means that both need to register the fixtures independently.</p>
</li>
</ul>
<h2>Deprecations (removal in next major release)</h2>
<ul>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/10819">#10819</a>:
Added a deprecation warning for class-scoped fixtures defined as
instance methods (without <code>@classmethod</code>). Such fixtures set
attributes on a different instance than the test methods use, leading to
unexpected behavior. Use <code>@classmethod</code> decorator instead --
by <code>yastcher</code>.</p>
<p>See <code>10819</code> and <code>14011</code>.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/12882">#12882</a>:
Calling <code>request.getfixturevalue()
&lt;pytest.FixtureRequest.getfixturevalue&gt;</code> during teardown to
request a fixture that was not already requested is now deprecated and
will become an error in pytest 10.</p>
<p>See <code>dynamic-fixture-request-during-teardown</code> for
details.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13409">#13409</a>:
Using non-<code>~collections.abc.Collection</code> iterables (such as
generators, iterators, or custom iterable objects) for the
<code>argvalues</code> parameter in <code>@pytest.mark.parametrize
&lt;pytest.mark.parametrize ref&gt;</code> and
<code>metafunc.parametrize &lt;pytest.Metafunc.parametrize&gt;</code> is
now deprecated.</p>
<p>These iterables get exhausted after the first iteration,
leading to tests getting unexpectedly skipped in cases such as running
<code>pytest.main()</code> multiple times,
using class-level parametrize decorators,
or collecting tests multiple times.</p>
<p>See <code>parametrize-iterators</code> for details and
suggestions.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13946">#13946</a>:
The private <code>config.inicfg</code> attribute is now deprecated.
Use <code>config.getini() &lt;pytest.Config.getini&gt;</code> to access
configuration values instead.</p>
<p>See <code>config-inicfg</code> for more details.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14004">#14004</a>:
Passing <code>baseid</code> to <code>~pytest.FixtureDef</code> or
<code>nodeid</code> strings to fixture registration APIs is now
deprecated. These are internal pytest APIs that are used by some
plugins.</p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pytest-dev/pytest/commit/cf470ec0bf7eb89cd97dd56df4859eae5db46447"><code>cf470ec</code></a>
Prepare release version 9.1.1</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/e0c8ce6cc5db1f08363be6f152c32e6838df2690"><code>e0c8ce6</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14625">#14625</a>
from pytest-dev/patchback/backports/9.1.x/a07c31a97...</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/1b82d1694fce22385ee7a4287917fbafbaf2e757"><code>1b82d16</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14624">#14624</a>
from pytest-dev/patchback/backports/9.1.x/b375b79ec...</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/501c4bc784da3b08bfcaa64858eba5d15dc59e53"><code>501c4bc</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14596">#14596</a>
from bluetech/doc-classmethod</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/b61f588e36e9377c3d1d3f06bece1da0fc31d9ca"><code>b61f588</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14622">#14622</a>
from chrisburr/fix-14608-initial-conftest-test-subdir</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/9a567e009f4d2da3ce1721c6db3109cb5744d40a"><code>9a567e0</code></a>
[automated] Update plugin list (<a
href="https://redirect.github.com/pytest-dev/pytest/issues/14617">#14617</a>)
(<a
href="https://redirect.github.com/pytest-dev/pytest/issues/14618">#14618</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/ef8b2993e5b48639e4a3d97d0525df9760781384"><code>ef8b299</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14620">#14620</a>
from pytest-dev/patchback/backports/9.1.x/680f9f3ed...</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/66abd0784d4cb7c1ba44ab9a8896506cd4985acc"><code>66abd07</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14220">#14220</a>
from bysiber/fix-stale-iexp-raisesgroup</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/79fbf93b666cac5f27c9dad047943d47b766c8d5"><code>79fbf93</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14612">#14612</a>
from pytest-dev/patchback/backports/9.1.x/974ed48b6...</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/0d312eb876177e9f1c04262b54060a41034ebf5c"><code>0d312eb</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14611">#14611</a>
from bluetech/parametrize-argvalues-typing</li>
<li>Additional commits viewable in <a
href="https://github.com/pytest-dev/pytest/compare/9.0.3...9.1.1">compare
view</a></li>
</ul>
</details>
<br />

Updates `ruff` from 0.15.15 to 0.15.20
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ruff/releases">ruff's
releases</a>.</em></p>
<blockquote>
<h2>0.15.20</h2>
<h2>Release Notes</h2>
<p>Released on 2026-06-25.</p>
<h3>Preview features</h3>
<ul>
<li>Allow human-readable names in rule selectors (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25887">#25887</a>)</li>
<li>Emit a warning instead of an error for unknown rule selectors (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26113">#26113</a>)</li>
<li>Match <code>noqa</code> shebang handling in <code>ruff:ignore</code>
comments (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26286">#26286</a>)</li>
<li>[<code>ruff</code>] Remove <code>pytest-fixture-autouse</code>
(<code>RUF076</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26240">#26240</a>,
<a
href="https://redirect.github.com/astral-sh/ruff/pull/26371">#26371</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Add versioning sections to custom crate READMEs (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26317">#26317</a>)</li>
<li>Update <code>ruff_python_parser</code> README for crates.io (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26315">#26315</a>)</li>
<li>[<code>perflint</code>] Clarify that <code>PERF402</code> applies to
any iterable (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26242">#26242</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a
href="https://github.com/dhruvmanila"><code>@​dhruvmanila</code></a></li>
<li><a
href="https://github.com/MichaReiser"><code>@​MichaReiser</code></a></li>
<li><a href="https://github.com/ntBre"><code>@​ntBre</code></a></li>
<li><a
href="https://github.com/trilamsr"><code>@​trilamsr</code></a></li>
</ul>
<h2>Install ruff 0.15.20</h2>
<h3>Install prebuilt binaries via shell script</h3>
<pre lang="sh"><code>curl --proto '=https' --tlsv1.2 -LsSf
https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-installer.sh
| sh
</code></pre>
<h3>Install prebuilt binaries via powershell script</h3>
<pre lang="sh"><code>powershell -ExecutionPolicy Bypass -c &quot;irm
https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-installer.ps1
| iex&quot;
</code></pre>
<h2>Download ruff 0.15.20</h2>
<table>
<thead>
<tr>
<th>File</th>
<th>Platform</th>
<th>Checksum</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-aarch64-apple-darwin.tar.gz">ruff-aarch64-apple-darwin.tar.gz</a></td>
<td>Apple Silicon macOS</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-aarch64-apple-darwin.tar.gz.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-x86_64-apple-darwin.tar.gz">ruff-x86_64-apple-darwin.tar.gz</a></td>
<td>Intel macOS</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-x86_64-apple-darwin.tar.gz.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-aarch64-pc-windows-msvc.zip">ruff-aarch64-pc-windows-msvc.zip</a></td>
<td>ARM64 Windows</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-aarch64-pc-windows-msvc.zip.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-i686-pc-windows-msvc.zip">ruff-i686-pc-windows-msvc.zip</a></td>
<td>x86 Windows</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-i686-pc-windows-msvc.zip.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-x86_64-pc-windows-msvc.zip">ruff-x86_64-pc-windows-msvc.zip</a></td>
<td>x64 Windows</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-x86_64-pc-windows-msvc.zip.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-aarch64-unknown-linux-gnu.tar.gz">ruff-aarch64-unknown-linux-gnu.tar.gz</a></td>
<td>ARM64 Linux</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-aarch64-unknown-linux-gnu.tar.gz.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-i686-unknown-linux-gnu.tar.gz">ruff-i686-unknown-linux-gnu.tar.gz</a></td>
<td>x86 Linux</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.15.20/ruff-i686-unknown-linux-gnu.tar.gz.sha256">checksum</a></td>
</tr>
</tbody>
</table>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md">ruff's
changelog</a>.</em></p>
<blockquote>
<h2>0.15.20</h2>
<p>Released on 2026-06-25.</p>
<h3>Preview features</h3>
<ul>
<li>Allow human-readable names in rule selectors (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25887">#25887</a>)</li>
<li>Emit a warning instead of an error for unknown rule selectors (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26113">#26113</a>)</li>
<li>Match <code>noqa</code> shebang handling in <code>ruff:ignore</code>
comments (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26286">#26286</a>)</li>
<li>[<code>ruff</code>] Remove <code>pytest-fixture-autouse</code>
(<code>RUF076</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26240">#26240</a>,
<a
href="https://redirect.github.com/astral-sh/ruff/pull/26371">#26371</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Add versioning sections to custom crate READMEs (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26317">#26317</a>)</li>
<li>Update <code>ruff_python_parser</code> README for crates.io (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26315">#26315</a>)</li>
<li>[<code>perflint</code>] Clarify that <code>PERF402</code> applies to
any iterable (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26242">#26242</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a
href="https://github.com/dhruvmanila"><code>@​dhruvmanila</code></a></li>
<li><a
href="https://github.com/MichaReiser"><code>@​MichaReiser</code></a></li>
<li><a href="https://github.com/ntBre"><code>@​ntBre</code></a></li>
<li><a
href="https://github.com/trilamsr"><code>@​trilamsr</code></a></li>
</ul>
<h2>0.15.19</h2>
<p>Released on 2026-06-23.</p>
<h3>Preview features</h3>
<ul>
<li>Support human-readable names when hovering suppression comments and
in code actions (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26114">#26114</a>)</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li>Fall back to default settings when editor-only settings are invalid
(<a
href="https://redirect.github.com/astral-sh/ruff/pull/26244">#26244</a>)</li>
<li>Fix panic when inserting text at a notebook cell boundary (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26111">#26111</a>)</li>
</ul>
<h3>Rule changes</h3>
<ul>
<li>[<code>pylint</code>] Update fix suggestions for
<code>__floor__</code>, <code>__trunc__</code>,
<code>__length_hint__</code>, and <code>__matmul__</code> variants
(<code>PLC2801</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26239">#26239</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Avoid allocating when parsing single string literals (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26200">#26200</a>)</li>
<li>Avoid reallocating singleton call arguments (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26223">#26223</a>)</li>
<li>Lazily create source files for lint diagnostics (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26226">#26226</a>)</li>
<li>Optimize formatter text width and indentation (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26236">#26236</a>)</li>
<li>Reserve capacity for builtin bindings (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26229">#26229</a>)</li>
<li>Skip repeated-key checks for singleton dictionaries (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26228">#26228</a>)</li>
<li>Use ArrayVec for qualified name segments (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26224">#26224</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/astral-sh/ruff/commit/f82a36b6baf8c0547a17bbde6c0d927ccd45d938"><code>f82a36b</code></a>
Bump 0.15.20 (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26376">#26376</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/af329438b55d5aa8ca28725f17abbae63b5c815d"><code>af32943</code></a>
Improve the summarise-ecosystem-results skill (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26378">#26378</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/485ebab5de692aad34720898cd80245b6092ba86"><code>485ebab</code></a>
Remove <code>RUF076</code> name from schema (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26371">#26371</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/ef81835ce3da615346584dc446de0fe26bfc154b"><code>ef81835</code></a>
[ty] Implement rust-analyzer's &quot;Click for full compiler
diagnostic&quot; feature (...</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/572b31e2377a701a7365f069f6ef87002962cb2b"><code>572b31e</code></a>
[<code>ruff</code>] Remove <code>pytest-fixture-autouse</code>
(<code>RUF076</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26240">#26240</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/f703f219d7fddd1a4abba9fa81e34773c185a4b9"><code>f703f21</code></a>
Allow human-readable names in rule selectors (<a
href="https://redirect.github.com/astral-sh/ruff/issues/25887">#25887</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/0d726b28ee35413926145ffef4ac1143cae9ea1e"><code>0d726b2</code></a>
[ty] Reuse equality semantics for membership compatibility (<a
href="https://redirect.github.com/astral-sh/ruff/issues/25955">#25955</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/dbe6e9848c3f78fdaf543cfc000939ebc73b5f00"><code>dbe6e98</code></a>
[ty] Infer definite equality comparison results (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26337">#26337</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/e700ea357a2196d76b58eb89b2031ddb5ca896e0"><code>e700ea3</code></a>
[ty] Prove TypedDict structural patterns exhaustive (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26285">#26285</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/6a0d2ec93959d966430b8c39d4de5c3e8a88e911"><code>6a0d2ec</code></a>
[ty] Widen inferred class-valued instance attributes (<a
href="https://redirect.github.com/astral-sh/ruff/issues/26338">#26338</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/astral-sh/ruff/compare/0.15.15...0.15.20">compare
view</a></li>
</ul>
</details>
<br />

Updates `ty` from 0.0.43 to 0.0.55
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ty/releases">ty's
releases</a>.</em></p>
<blockquote>
<h2>0.0.55</h2>
<h2>Release Notes</h2>
<p>Released on 2026-06-26.</p>
<h3>LSP server</h3>
<ul>
<li>Render full diagnostics in color (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26384">#26384</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Document colored diagnostic output (<a
href="https://redirect.github.com/astral-sh/ty/pull/3858">#3858</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Improve vendored filesystem concurrency (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26408">#26408</a>)</li>
<li>Optimize enum comparisons in equality evaluation (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26340">#26340</a>)</li>
<li>Remove redundant semantic index shrinks (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26392">#26392</a>)</li>
<li>Use never-change durability for one-shot checks (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26359">#26359</a>)</li>
</ul>
<h3>Core type checking</h3>
<ul>
<li>Correct enum alias detection and scalar constructors (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26345">#26345</a>)</li>
<li>Fix structural pattern binding inference (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26411">#26411</a>)</li>
<li>Improve variable-length tuple slicing (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26151">#26151</a>)</li>
<li>Infer class and mapping pattern bindings (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25941">#25941</a>)</li>
<li>Infer empty collection constructors from later uses (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26389">#26389</a>)</li>
<li>Skip shadowed submodule bindings during import analysis (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26385">#26385</a>)</li>
<li>Sync vendored typeshed stubs (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26406">#26406</a>).
<a
href="https://github.com/python/typeshed/compare/8e6a886ca5b14742924be721d345a619762d6e93...3c6221722aac5bd9dbfc5fbf7b4f0bf64b2c5724">Typeshed
diff</a></li>
<li>Track literal iterable emptiness for reachability (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25222">#25222</a>)</li>
<li>Validate positional class patterns against
<code>__match_args__</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26195">#26195</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a
href="https://github.com/charliermarsh"><code>@​charliermarsh</code></a></li>
<li><a href="https://github.com/carljm"><code>@​carljm</code></a></li>
<li><a
href="https://github.com/AlexWaygood"><code>@​AlexWaygood</code></a></li>
<li><a
href="https://github.com/MichaReiser"><code>@​MichaReiser</code></a></li>
<li><a href="https://github.com/mtshiba"><code>@​mtshiba</code></a></li>
<li><a
href="https://github.com/felixscherz"><code>@​felixscherz</code></a></li>
</ul>
<h2>Install ty 0.0.55</h2>
<h3>Install prebuilt binaries via shell script</h3>
<pre lang="sh"><code>curl --proto '=https' --tlsv1.2 -LsSf
https://releases.astral.sh/github/ty/releases/download/0.0.55/ty-installer.sh
| sh
</code></pre>
<h3>Install prebuilt binaries via powershell script</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ty/blob/main/CHANGELOG.md">ty's
changelog</a>.</em></p>
<blockquote>
<h2>0.0.55</h2>
<p>Released on 2026-06-26.</p>
<h3>LSP server</h3>
<ul>
<li>Render full diagnostics in color (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26384">#26384</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Document colored diagnostic output (<a
href="https://redirect.github.com/astral-sh/ty/pull/3858">#3858</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Improve vendored filesystem concurrency (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26408">#26408</a>)</li>
<li>Optimize enum comparisons in equality evaluation (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26340">#26340</a>)</li>
<li>Remove redundant semantic index shrinks (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26392">#26392</a>)</li>
<li>Use never-change durability for one-shot checks (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26359">#26359</a>)</li>
</ul>
<h3>Core type checking</h3>
<ul>
<li>Correct enum alias detection and scalar constructors (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26345">#26345</a>)</li>
<li>Fix structural pattern binding inference (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26411">#26411</a>)</li>
<li>Improve variable-length tuple slicing (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26151">#26151</a>)</li>
<li>Infer class and mapping pattern bindings (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25941">#25941</a>)</li>
<li>Infer empty collection constructors from later uses (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26389">#26389</a>)</li>
<li>Skip shadowed submodule bindings during import analysis (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26385">#26385</a>)</li>
<li>Sync vendored typeshed stubs (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26406">#26406</a>).
<a
href="https://github.com/python/typeshed/compare/8e6a886ca5b14742924be721d345a619762d6e93...3c6221722aac5bd9dbfc5fbf7b4f0bf64b2c5724">Typeshed
diff</a></li>
<li>Track literal iterable emptiness for reachability (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25222">#25222</a>)</li>
<li>Validate positional class patterns against
<code>__match_args__</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26195">#26195</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a
href="https://github.com/charliermarsh"><code>@​charliermarsh</code></a></li>
<li><a href="https://github.com/carljm"><code>@​carljm</code></a></li>
<li><a
href="https://github.com/AlexWaygood"><code>@​AlexWaygood</code></a></li>
<li><a
href="https://github.com/MichaReiser"><code>@​MichaReiser</code></a></li>
<li><a href="https://github.com/mtshiba"><code>@​mtshiba</code></a></li>
<li><a
href="https://github.com/felixscherz"><code>@​felixscherz</code></a></li>
</ul>
<h2>0.0.54</h2>
<p>Released on 2026-06-25.</p>
<h3>Bug fixes</h3>
<ul>
<li>Avoid duplicate configuration error output (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26375">#26375</a>)</li>
<li>Avoid stack overflows in reachability analysis (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26272">#26272</a>)</li>
<li>Fix divergent recursive tuple cycle handling in ty (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26316">#26316</a>)</li>
<li>Fix panic from relation queries during cycle recovery (<a
href="https://redirect.github.com/astral-sh/ruff/pull/26335">#26335</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/astral-sh/ty/commit/42869400da56f4ee7ce752141f81b50bb318e4e2"><code>4286940</code></a>
Bump version to 0.0.55 (<a
href="https://redirect.github.com/astral-sh/ty/issues/3866">#3866</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/5374b30ff462ef6e59d23dc9ba515007b02464a8"><code>5374b30</code></a>
Update benchmarks for ty 0.0.54 (<a
href="https://redirect.github.com/astral-sh/ty/issues/3865">#3865</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/3ed874d053ff9529c9fd0205a6d3bbe6a7407535"><code>3ed874d</code></a>
Document colored diagnostic output (<a
href="https://redirect.github.com/astral-sh/ty/issues/3858">#3858</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/bf8a7dd584f53d67d873c750afc1494331f93502"><code>bf8a7dd</code></a>
Bump version to 0.0.54</li>
<li><a
href="https://github.com/astral-sh/ty/commit/78e094dfaf6245514f124b043b18c9a20edd8f08"><code>78e094d</code></a>
Document the <code>fullDiagnosticOutput</code> extension to the Language
Server Protocol...</li>
<li><a
href="https://github.com/astral-sh/ty/commit/7bda89e5069d747bd7f54513dcd0263157a8f694"><code>7bda89e</code></a>
Document ty's <code>@Todo</code> type in the typing FAQ (<a
href="https://redirect.github.com/astral-sh/ty/issues/3847">#3847</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/66a94cde4970b405a770e4c6ef4ac2a9bb6bf733"><code>66a94cd</code></a>
Update maturin to v1.14.0 (<a
href="https://redirect.github.com/astral-sh/ty/issues/3840">#3840</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/dc2b39d1e29e55a4a6d83486fffa936ba5121a72"><code>dc2b39d</code></a>
Update prek dependencies (<a
href="https://redirect.github.com/astral-sh/ty/issues/3839">#3839</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/23f26f98a22d3a0df412846506f3af6e76cf48e4"><code>23f26f9</code></a>
Bump version to 0.0.53 (<a
href="https://redirect.github.com/astral-sh/ty/issues/3841">#3841</a>)</li>
<li><a
href="https://github.com/astral-sh/ty/commit/13f91b093e004c76aa548a221c7b577dfbdd7ea6"><code>13f91b0</code></a>
Bump version to 0.0.52 (<a
href="https://redirect.github.com/astral-sh/ty/issues/3828">#3828</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/astral-sh/ty/compare/0.0.43...0.0.55">compare
view</a></li>
</ul>
</details>
<br />

Updates `hatch` from 1.16.5 to 1.17.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pypa/hatch/releases">hatch's
releases</a>.</em></p>
<blockquote>
<h2>Hatchling v1.17.0</h2>
<p><em><strong>Added:</strong></em></p>
<ul>
<li>The <code>app</code> build target now embeds the project version in
the name of binaries</li>
</ul>
<h2>Hatch v1.17.0</h2>
<p><em><strong>Changed:</strong></em></p>
<ul>
<li>The <code>hatch fmt</code> command is now deprecated in favor of the
new <code>hatch check</code> command group</li>
<li>Migrate HTTP client from <code>httpx</code> to
<code>httpx2</code></li>
</ul>
<p><em><strong>Added:</strong></em></p>
<ul>
<li>Add <code>hatch check</code> command group with subcommands for
<code>check code</code> (linting), <code>check fmt</code> (formatting),
and <code>check types</code> (type checking)</li>
<li>Add <code>hatch check types</code> command for type checking using
Pyrefly, with <code>--summarize</code> and <code>--cover</code>
flags</li>
<li>Add <code>hatch env lock</code> command to generate PEP 751
compliant lockfiles (<code>pylock.toml</code>) for environments</li>
<li>Add <code>hatch dep lock</code> and <code>hatch lock</code> commands
as shortcuts for locking the active environment</li>
<li>Add <code>hatch dep sync</code> command for syncing dependencies
from a lockfile</li>
<li>Add pluggable dependency locker interface with built-in UV and pip
implementations</li>
<li>Add <code>--cover-xml</code> and <code>--cover-xml-output</code>
flags to the <code>hatch test</code> command for generating XML coverage
reports</li>
<li>Add linehaul telemetry data to User-Agent header for PyPI download
statistics</li>
<li>Auto-create environment when locking if it doesn't exist</li>
</ul>
<p><em><strong>Fixed:</strong></em></p>
<ul>
<li>Fix help output formatting for the <code>run</code> command</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pypa/hatch/commit/37b00c3d2221438fa79084b92e81ee1819d6c630"><code>37b00c3</code></a>
release Hatchling v1.30.1 (<a
href="https://redirect.github.com/pypa/hatch/issues/2298">#2298</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/0446d99ef6461644624e8bdc461fd3c0a684a13c"><code>0446d99</code></a>
Update history for new patch release of hatchling after fixing default
metada...</li>
<li><a
href="https://github.com/pypa/hatch/commit/4f5cdf094ec515488777705fc01e484ddd4f3e5f"><code>4f5cdf0</code></a>
Make 2.4 metadata default until other tools support it. (<a
href="https://redirect.github.com/pypa/hatch/issues/2296">#2296</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/0497be09d555c300851d55344104e9aea2f9f200"><code>0497be0</code></a>
Fix draft release uploads. (<a
href="https://redirect.github.com/pypa/hatch/issues/2293">#2293</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/3aae0faf98a5e90c146d5af21738e049ecac471e"><code>3aae0fa</code></a>
Fix hatchling to use Metadata 2.4 (<a
href="https://redirect.github.com/pypa/hatch/issues/2291">#2291</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/5ee41893d556aaa862d32621e37bb179646c60e8"><code>5ee4189</code></a>
release Hatch v1.17.0 (<a
href="https://redirect.github.com/pypa/hatch/issues/2290">#2290</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/6109ee756a79d1341798a47517d778d149807b15"><code>6109ee7</code></a>
release Hatchling v1.30.0 (<a
href="https://redirect.github.com/pypa/hatch/issues/2289">#2289</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/246e22bb1681b74ff493ec60aa8849d95ce048fe"><code>246e22b</code></a>
Block duplicate files in wheel archives (closes <a
href="https://redirect.github.com/pypa/hatch/issues/2066">#2066</a>) (<a
href="https://redirect.github.com/pypa/hatch/issues/2269">#2269</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/d2afcb6003321c9dca1628b2840ec4acb1e1a9ef"><code>d2afcb6</code></a>
Update docs as pre-release for 1.17.0 (<a
href="https://redirect.github.com/pypa/hatch/issues/2287">#2287</a>)</li>
<li><a
href="https://github.com/pypa/hatch/commit/818d2841958f0797f0e4ed014b9f0a8123d11b63"><code>818d284</code></a>
Feat hatch check command with new sub command for types (<a
href="https://redirect.github.com/pypa/hatch/issues/2278">#2278</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/pypa/hatch/compare/hatch-v1.16.5...hatch-v1.17.0">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: John Kennedy <65985482+jkennedyvz@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-07-03 16:41:54 -07:00

2077 lines
70 KiB
Python

"""Deploy command and subcommands for the LangGraph CLI."""
import base64
import json as json_mod
import os
import pathlib
import platform
import re
import tempfile
import time
from collections.abc import Callable, Sequence
from contextlib import contextmanager
from dataclasses import dataclass, field
from datetime import datetime, timezone
import click
import click.exceptions
from dotenv import dotenv_values, set_key
import langgraph_cli.config
from langgraph_cli.analytics import log_command
from langgraph_cli.constants import DEFAULT_CONFIG
from langgraph_cli.dependency_tracking import find_tracked_packages
from langgraph_cli.docker import build_docker_image, can_build_locally
from langgraph_cli.exec import Runner, subp_exec
from langgraph_cli.host_backend import HostBackendClient, HostBackendError
from langgraph_cli.progress import Progress
from langgraph_cli.util import warn_non_wolfi_distro
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
RESERVED_ENV_VARS = frozenset(
[
# LANGCHAIN_RESERVED_ENV_VARS from host-backend
"LANGCHAIN_TRACING_V2",
"LANGSMITH_TRACING_V2",
"LANGCHAIN_ENDPOINT",
"LANGCHAIN_PROJECT",
"LANGSMITH_PROJECT",
"LANGSMITH_LANGGRAPH_GIT_REPO",
"LANGGRAPH_GIT_REPO_PATH",
"LANGCHAIN_API_KEY",
"LANGSMITH_CONTROL_PLANE_API_KEY",
"POSTGRES_URI",
"POSTGRES_PASSWORD",
"DATABASE_URI",
"LANGSMITH_LANGGRAPH_GIT_REF",
"LANGSMITH_LANGGRAPH_GIT_REF_SHA",
"LANGGRAPH_AUTH_TYPE",
"LANGSMITH_AUTH_ENDPOINT",
"LANGSMITH_TENANT_ID",
"LANGSMITH_AUTH_VERIFY_TENANT_ID",
"LANGSMITH_HOST_PROJECT_ID",
"LANGSMITH_HOST_PROJECT_NAME",
"LANGSMITH_HOST_REVISION_ID",
"LOG_JSON",
"LOG_DICT_TRACEBACKS",
"REDIS_URI",
"LANGCHAIN_CALLBACKS_BACKGROUND",
"DD_TRACE_PSYCOPG_ENABLED",
"DD_TRACE_REDIS_ENABLED",
"LANGSMITH_DEPLOYMENT_NAME",
"LANGGRAPH_CLOUD_LICENSE_KEY",
# ALLOWED_SELF_HOSTED_ENV_VARS (rejected for non-self-hosted)
"LANGSMITH_API_KEY",
"LANGSMITH_ENDPOINT",
"POSTGRES_URI_CUSTOM",
"REDIS_URI_CUSTOM",
"PATH",
"PORT",
"MOUNT_PREFIX",
"LSD_ENV",
"LSD_DD_API_KEY",
"LSD_DD_ENDPOINT",
"LSD_DEPLOYMENT_TYPE",
]
)
_API_KEY_ENV_NAMES = (
"LANGGRAPH_HOST_API_KEY",
"LANGSMITH_API_KEY",
"LANGCHAIN_API_KEY",
)
_DEPLOYMENT_NAME_ENV = "LANGSMITH_DEPLOYMENT_NAME"
_TERMINAL_STATUSES = frozenset(
[
"DEPLOYED",
"CREATE_FAILED",
"BUILD_FAILED",
"DEPLOY_FAILED",
"SKIPPED",
]
)
# ---------------------------------------------------------------------------
# Data structures
# ---------------------------------------------------------------------------
@dataclass
class BuildResult:
"""Captures the outcome of a build stage so the shared wait tail can be
parameterized identically for both local and remote builds."""
updated: dict = field(default_factory=dict)
progress_message: str = ""
timeout_seconds: int = 300
poll_interval_seconds: int = 1
no_result_message: str = "Deployment updated"
on_poll: Callable[[str, str, Callable[[str], None]], None] | None = None
on_interrupt: Callable[[str], None] | None = None
show_build_logs_on_failure: bool = False
# ---------------------------------------------------------------------------
# Structured output emitter
# ---------------------------------------------------------------------------
_emitter: "_Emitter | None" = None
_no_input: bool = False
class _Emitter:
"""Dual-mode output: JSON-lines (``--json``) or human-readable click text."""
def __init__(self, json_mode: bool) -> None:
self._json = json_mode
@property
def json_mode(self) -> bool:
return self._json
# -- Structured event helpers ------------------------------------------
def step(self, step: int, message: str, **extra: object) -> None:
if self._json:
self._write({"event": "step", "step": step, "message": message, **extra})
else:
click.secho(f"{step}. {message}", fg="cyan")
def info(self, message: str, **extra: object) -> None:
if self._json:
self._write({"event": "info", "message": message, **extra})
else:
click.secho(f" {message}", fg="green")
def warn(self, message: str, **extra: object) -> None:
"""Warning nested under a step. Text mode indents; JSON mode strips leading whitespace."""
if self._json:
self._write({"event": "warn", "message": message.lstrip(), **extra})
else:
click.secho(f" {message}", fg="yellow")
def note(self, message: str, **extra: object) -> None:
"""Top-level banner (pre-step). Text mode does not indent."""
if self._json:
self._write({"event": "note", "message": message, **extra})
else:
click.secho(message, fg="yellow")
def error(self, message: str, **extra: object) -> None:
if self._json:
self._write({"event": "error", "message": message, **extra})
else:
click.secho(f" {message}", fg="red")
def status_change(
self,
status: str,
elapsed_seconds: float,
finished: bool = False,
) -> None:
mins, secs = divmod(int(elapsed_seconds), 60)
elapsed_str = f"{mins}m {secs:02d}s" if mins else f"{secs}s"
if self._json:
self._write(
{
"event": "status_change",
"status": status,
"elapsed_seconds": round(elapsed_seconds, 1),
"message": f"{status}... ({elapsed_str})",
}
)
else:
click.echo(f" {status}... ({elapsed_str})")
def log(self, message: str) -> None:
if self._json:
self._write({"event": "log", "message": message})
else:
click.echo(f" | {message}")
def status_url(self, url: str) -> None:
if self._json:
self._write({"event": "status_url", "url": url})
else:
click.secho(f" View status: {url}", fg="cyan")
def result(
self,
status: str,
*,
deployment_id: str,
url: str | None = None,
status_url: str | None = None,
fallback_status_message: str | None = None,
) -> None:
if self._json:
if status == "succeeded":
message = "Deployment successful!"
elif status == "failed":
message = "Deployment failed"
else:
message = "Timed out waiting for deployment."
payload: dict = {
"event": "result",
"status": status,
"deployment_id": deployment_id,
"message": message,
}
if url:
payload["url"] = url
if status_url:
payload["status_url"] = status_url
self._write(payload)
else:
if status == "succeeded":
click.secho(" Deployment successful!", fg="green")
if url:
click.secho(f" URL: {url}", fg="green")
if status_url:
click.secho(f" View status: {status_url}", fg="green")
elif status == "failed":
click.secho(" Deployment failed", fg="red")
if status_url:
click.secho(f" View status: {status_url}", fg="red")
elif status == "timed_out":
click.secho(" Timed out waiting for deployment.", fg="yellow")
if status_url:
click.secho(f" Check status at: {status_url}", fg="yellow")
elif fallback_status_message:
click.secho(f" {fallback_status_message}", fg="yellow")
def heartbeat(self, status: str, elapsed_seconds: float) -> None:
if self._json:
mins, secs = divmod(int(elapsed_seconds), 60)
elapsed_str = f"{mins}m {secs:02d}s" if mins else f"{secs}s"
self._write(
{
"event": "heartbeat",
"status": status,
"elapsed_seconds": round(elapsed_seconds, 1),
"message": f"{status}... ({elapsed_str})",
}
)
def upload_progress(self, size_mb: float, pct: int) -> None:
if self._json:
self._write(
{
"event": "upload_progress",
"size_mb": round(size_mb, 1),
"pct": pct,
}
)
else:
click.echo(f"\r Uploading ({size_mb:.1f} MB)... {pct}%", nl=False)
def _write(self, obj: dict) -> None:
import sys as _sys
_sys.stdout.write(json_mod.dumps(obj, default=str) + "\n")
_sys.stdout.flush()
def _get_emitter() -> _Emitter:
"""Return the module-level emitter (falls back to text mode)."""
return _emitter or _Emitter(json_mode=False)
# ---------------------------------------------------------------------------
# Validators
# ---------------------------------------------------------------------------
def validate_deployment_selector(deployment_id: str | None, name: str | None) -> None:
"""Ensure either deployment_id or name is provided."""
if deployment_id:
return
if not name:
raise click.UsageError("Either --deployment-id or --name is required.")
def validate_deploy_commands(
install_command: str | None, build_command: str | None
) -> None:
"""Validate optional deploy commands for disallowed content."""
if install_command and langgraph_cli.config.has_disallowed_build_command_content(
install_command
):
raise click.UsageError(
"install_command contains disallowed characters or patterns."
)
if build_command and langgraph_cli.config.has_disallowed_build_command_content(
build_command
):
raise click.UsageError(
"build_command contains disallowed characters or patterns."
)
# ---------------------------------------------------------------------------
# Deployment lookup
# ---------------------------------------------------------------------------
def find_deployment_id_by_name(
client: HostBackendClient, name: str | None
) -> str | None:
"""Return deployment ID for an exact name match, or None if not found."""
if not name:
return None
existing = client.list_deployments(name_contains=name)
if isinstance(existing, dict):
for dep in existing.get("resources", []):
if isinstance(dep, dict) and dep.get("name") == name:
found_id = dep.get("id")
if found_id:
return str(found_id)
return None
# ---------------------------------------------------------------------------
# Formatting helpers
# ---------------------------------------------------------------------------
def normalize_name(value: str | None) -> str:
"""Sanitize a deployment/directory name into a valid deployment name.
LangSmith Deployment names only allow lowercase
alphanumeric characters and hyphens ([a-z0-9-]).
Invalid characters are replaced with hyphens.
"""
if not value:
return "app"
slug = re.sub(r"[^a-z0-9-]+", "-", value.lower()).strip("-")
return slug or "app"
def normalize_image_tag(value: str) -> str:
"""Validate and return a Docker image tag.
Tags may only contain [A-Za-z0-9_.-]. Defaults to "latest" when empty.
"""
if not value:
value = "latest"
if not re.fullmatch(r"[A-Za-z0-9_.-]+", value):
raise click.UsageError(
"Image tag may only contain characters A-Z, a-z, 0-9, '_', '-', '.'"
)
return value
def _validate_prebuilt_image(runner, image: str, *, verbose: bool) -> None:
"""Ensure a prebuilt image exists locally for linux/amd64."""
try:
stdout, _ = runner.run(
subp_exec(
"docker",
"image",
"inspect",
"--format",
"{{.Os}}/{{.Architecture}}",
image,
verbose=verbose,
collect=True,
)
)
except FileNotFoundError:
raise click.ClickException(
"Docker is required but not installed.\n"
"Install Docker Desktop: https://docs.docker.com/get-docker/"
) from None
except click.exceptions.Exit:
raise click.ClickException(
f"Docker image '{image}' was not found locally. Build or pull the image "
"before deploying with --image."
) from None
image_platform = (stdout or "").strip()
if image_platform != "linux/amd64":
detected = image_platform or "unknown"
raise click.ClickException(
f"Docker image '{image}' targets {detected}, but LangSmith Deployment "
"requires linux/amd64. Rebuild or pull the image for linux/amd64 before "
"deploying with --image."
)
def _extract_deployment_url(deployment: dict[str, object]) -> str:
source_config = deployment.get("source_config")
if isinstance(source_config, dict):
custom_url = source_config.get("custom_url")
if isinstance(custom_url, str) and custom_url:
return custom_url
return "-"
def format_deployments_table(deployments: Sequence[dict[str, object]]) -> str:
headers = ("Deployment ID", "Deployment Name", "Deployment URL")
rows = [
(
str(deployment.get("id", "-") or "-"),
str(deployment.get("name", "-") or "-"),
_extract_deployment_url(deployment),
)
for deployment in deployments
]
widths = [
max(len(headers[index]), *(len(row[index]) for row in rows))
for index in range(len(headers))
]
def format_row(row: Sequence[str]) -> str:
return " ".join(value.ljust(widths[index]) for index, value in enumerate(row))
lines = [format_row(headers), format_row(tuple("-" * width for width in widths))]
lines.extend(format_row(row) for row in rows)
return "\n".join(lines)
def format_revisions_table(revisions: Sequence[dict[str, object]]) -> str:
headers = ("Revision ID", "Status", "Created At")
latest_deployed_seen = False
rows = []
for revision in revisions:
status = str(revision.get("status", "-") or "-")
if status == "DEPLOYED":
if latest_deployed_seen:
status = "REPLACED"
else:
latest_deployed_seen = True
rows.append(
(
str(revision.get("id", "-") or "-"),
status,
str(revision.get("created_at", "-") or "-"),
)
)
widths = [
max(len(headers[index]), *(len(row[index]) for row in rows))
for index in range(len(headers))
]
def format_row(row: Sequence[str]) -> str:
return " ".join(value.ljust(widths[index]) for index, value in enumerate(row))
lines = [format_row(headers), format_row(tuple("-" * width for width in widths))]
lines.extend(format_row(row) for row in rows)
return "\n".join(lines)
def format_timestamp(ts) -> str:
"""Convert a timestamp (epoch ms or string) to a readable string."""
if isinstance(ts, (int, float)):
dt = datetime.fromtimestamp(ts / 1000, tz=timezone.utc)
return dt.strftime("%Y-%m-%d %H:%M:%S")
return str(ts) if ts else ""
def format_log_entry(entry: dict) -> str:
"""Format a single log entry for display."""
ts = format_timestamp(entry.get("timestamp", ""))
level = entry.get("level", "")
message = entry.get("message", "")
if ts and level:
return f"[{ts}] [{level}] {message}"
elif ts:
return f"[{ts}] {message}"
return message
def level_fg(level: str) -> str | None:
"""Return click color for a log level."""
level_upper = level.upper() if level else ""
if level_upper in {"ERROR", "CRITICAL"}:
return "red"
if level_upper == "WARNING":
return "yellow"
return None
# ---------------------------------------------------------------------------
# Env / secrets helpers
# ---------------------------------------------------------------------------
def _resolve_env_path(
config_json: dict, config_path: pathlib.Path
) -> pathlib.Path | None:
"""Return the .env file path implied by the config, or None for inline dicts."""
env_field = config_json.get("env")
if isinstance(env_field, dict) and env_field:
return None
if isinstance(env_field, str):
env_path = (config_path.parent / env_field).resolve()
if not env_path.exists():
_get_emitter().note(
f"Warning: env file '{env_field}' specified in langgraph.json not found."
)
return None
return env_path
return pathlib.Path.cwd() / ".env"
def _parse_env_from_config(
config_json: dict, config_path: pathlib.Path
) -> dict[str, str]:
"""Resolve env vars from langgraph.json 'env' field or a .env fallback."""
env_field = config_json.get("env")
if isinstance(env_field, dict) and env_field:
return {str(k): str(v) for k, v in env_field.items()}
env_path = _resolve_env_path(config_json, config_path)
if env_path is None:
return {}
return {k: v for k, v in dotenv_values(env_path).items() if v is not None}
def _env_without_deployment_name(env_vars: dict[str, str]) -> dict[str, str]:
"""Return env vars copy with deployment-name key removed."""
filtered = dict(env_vars)
filtered.pop(_DEPLOYMENT_NAME_ENV, None)
return filtered
def _secrets_from_env(
env_vars: dict[str, str],
) -> list[dict[str, str]]:
"""Convert env dict to secrets list, filtering reserved vars with warnings."""
secrets: list[dict[str, str]] = []
for name, value in env_vars.items():
if name in RESERVED_ENV_VARS:
_get_emitter().note(f"Skipping reserved env var: {name}")
continue
if not value:
continue
secrets.append({"name": name, "value": value})
return secrets
# ---------------------------------------------------------------------------
# Build mode resolution
# ---------------------------------------------------------------------------
def _resolve_build_mode(
remote_build_flag: bool | None,
*,
force_local: bool = False,
) -> tuple[bool, str | None]:
"""Determine whether to use a remote build.
Returns (use_remote_build, local_build_error). Raises UsageError when
--no-remote is set but the machine cannot build locally. When
`force_local` is set, the function short-circuits and always selects a
local build.
"""
if force_local:
return False, None
local_build_supported, local_build_error = can_build_locally()
if remote_build_flag is True:
return True, local_build_error
if remote_build_flag is False:
if not local_build_supported:
details = "\n\nOr re-run with --remote to use remote builds."
raise click.UsageError(
f"{local_build_error or 'Unable to build locally.'}{details}"
)
return False, None
# auto-detect
return not local_build_supported, local_build_error
# ---------------------------------------------------------------------------
# Deployment orchestration helpers
# ---------------------------------------------------------------------------
def _log_deploy_step(step: int, message: str, **extra: object) -> None:
_get_emitter().step(step, message, **extra)
def _resolve_deployment(
client: HostBackendClient,
step: int,
deployment_id: str | None,
name: str | None,
*,
not_found_message: str,
) -> tuple[str | None, bool, int]:
"""Resolve an existing deployment by ID or exact name match."""
needs_creation = False
if deployment_id:
_log_deploy_step(step, f"Using deployment {deployment_id}")
_call_host_backend_with_optional_tenant(
client, lambda c: c.get_deployment(deployment_id)
)
return deployment_id, needs_creation, step + 1
_log_deploy_step(step, f"Looking up deployment '{name}'")
found_id = _call_host_backend_with_optional_tenant(
client, lambda c: find_deployment_id_by_name(c, name)
)
em = _get_emitter()
if found_id:
deployment_id = str(found_id)
em.info(f"Found existing deployment (ID: {deployment_id})")
else:
needs_creation = True
em.warn(not_found_message)
return deployment_id, needs_creation, step + 1
def _create_deployment(
client: HostBackendClient,
step: int,
*,
name: str,
deployment_type: str,
source: str,
config_rel: str | None = None,
secrets: list[dict[str, str]] | None = None,
) -> tuple[str, int]:
"""Create a deployment and return its ID and next step number."""
_log_deploy_step(step, f"Creating deployment '{name}'")
created = client.create_deployment(
name=name,
deployment_type=deployment_type,
source=source,
config_path=config_rel,
secrets=secrets,
)
created_id = created.get("id") if isinstance(created, dict) else None
if not isinstance(created_id, str) or not created_id:
raise HostBackendError(
"POST /v2/deployments succeeded but response missing a valid 'id'"
)
_get_emitter().info(f"Deployment ID: {created_id}", deployment_id=created_id)
return created_id, step + 1
def _smith_dashboard_base_url(host_url: str | None) -> str:
"""Derive the LangSmith dashboard base URL from the API host URL."""
from urllib.parse import urlparse
if not host_url:
return "https://smith.langchain.com"
parsed = urlparse(host_url)
hostname = parsed.hostname or ""
if hostname in ("localhost", "127.0.0.1"):
return host_url.rstrip("/")
api_host_suffix = "api.host.langchain.com"
if hostname == api_host_suffix:
return "https://smith.langchain.com"
if hostname.endswith(f".{api_host_suffix}"):
prefix = hostname[: -(len(api_host_suffix) + 1)]
return f"https://{prefix}.smith.langchain.com"
return "https://smith.langchain.com"
def _get_deployment_status_url(
updated: object, deployment_id: str, host_url: str | None = None
) -> str | None:
"""Compute the LangSmith dashboard URL for a deployment, if possible."""
tenant_id = updated.get("tenant_id") if isinstance(updated, dict) else None
if not tenant_id:
return None
base = _smith_dashboard_base_url(host_url)
return f"{base}/o/{tenant_id}/host/deployments/{deployment_id}"
def _emit_deployment_status_url(
updated: object, deployment_id: str, host_url: str | None = None
) -> str | None:
"""Emit the deployment status URL and return it."""
url = _get_deployment_status_url(updated, deployment_id, host_url)
if url:
_get_emitter().status_url(url)
return url
def _poll_revision_status(
client: HostBackendClient,
deployment_id: str,
*,
progress_message: str,
timeout_seconds: int,
poll_interval_seconds: int,
on_poll: Callable[[str, str, Callable[[str], None]], None] | None = None,
on_interrupt: Callable[[str], None] | None = None,
) -> tuple[str, str | None]:
"""Poll latest revision status until terminal status or timeout."""
em = _get_emitter()
revisions_resp = client.list_revisions(deployment_id, limit=1)
resources = (
revisions_resp.get("resources", []) if isinstance(revisions_resp, dict) else []
)
if not resources:
return "", None
revision_id = str(resources[0]["id"])
last_status = ""
deadline = time.time() + timeout_seconds
start_time = time.monotonic()
last_heartbeat = start_time
json_mode = em.json_mode
with Progress(
message=progress_message, elapsed=True, json_mode=json_mode
) as set_progress:
while time.time() < deadline:
try:
rev = client.get_revision(deployment_id, revision_id)
except KeyboardInterrupt:
set_progress("")
if on_interrupt is not None:
on_interrupt(revision_id)
raise click.exceptions.Exit(1) from None
raise
status = (
rev.get("status", "UNKNOWN") if isinstance(rev, dict) else "UNKNOWN"
)
if status != last_status:
set_progress("")
if last_status:
em.status_change(last_status, time.monotonic() - start_time)
last_status = status
if status in _TERMINAL_STATUSES:
break
set_progress(f"{status}...")
last_heartbeat = time.monotonic()
elif json_mode and time.monotonic() - last_heartbeat > 10:
em.heartbeat(last_status, time.monotonic() - start_time)
last_heartbeat = time.monotonic()
if on_poll is not None:
on_poll(status, revision_id, set_progress)
time.sleep(poll_interval_seconds)
else:
set_progress("")
return last_status, revision_id
def _print_deployment_result(
client: HostBackendClient,
deployment_id: str,
last_status: str,
*,
dashboard_label: str,
status_url: str | None = None,
) -> None:
"""Print final deployment status and raise on failure."""
em = _get_emitter()
dep_info = client.get_deployment(deployment_id)
custom_url = None
if isinstance(dep_info, dict):
sc = dep_info.get("source_config")
if isinstance(sc, dict):
custom_url = sc.get("custom_url")
if last_status == "DEPLOYED":
em.result(
"succeeded",
deployment_id=deployment_id,
url=custom_url,
status_url=status_url,
)
elif last_status in ("BUILD_FAILED", "DEPLOY_FAILED", "CREATE_FAILED"):
em.result(
"failed",
deployment_id=deployment_id,
status_url=status_url,
)
raise click.exceptions.Exit(1)
else:
em.result(
"timed_out",
deployment_id=deployment_id,
status_url=status_url,
fallback_status_message=(
f"Check status in the LangSmith {dashboard_label}."
),
)
# ---------------------------------------------------------------------------
# Docker push auth
# ---------------------------------------------------------------------------
@contextmanager
def _docker_config_for_token(registry_host: str, token: str):
"""Create a temporary Docker config with only the push token.
Yields the path to a temporary config directory that can be passed
to `docker --config <path>` so that system credential helpers
(e.g. gcloud) don't interfere with the push token.
"""
auth_b64 = base64.b64encode(f"oauth2accesstoken:{token}".encode()).decode()
config_data = {"auths": {registry_host: {"auth": auth_b64}}}
with tempfile.TemporaryDirectory() as tmpdir:
with open(os.path.join(tmpdir, "config.json"), "w") as f:
json_mod.dump(config_data, f)
yield tmpdir
# ---------------------------------------------------------------------------
# GCS upload
# ---------------------------------------------------------------------------
_UPLOAD_TIMEOUT_SECONDS = 300
_BYTES_PER_MIB = 1_048_576
class _ProgressReader:
"""File-like wrapper that reports upload progress via the emitter."""
def __init__(self, fobj, file_size: int, emitter: "_Emitter"):
self._fobj = fobj
self._file_size = file_size
self._emitter = emitter
self._uploaded = 0
def read(self, size=-1):
data = self._fobj.read(size)
if data:
self._uploaded += len(data)
pct = (
int(self._uploaded * 100 / self._file_size) if self._file_size else 100
)
self._emitter.upload_progress(self._file_size / _BYTES_PER_MIB, pct)
return data
def __len__(self):
return self._file_size
def _upload_to_gcs(signed_url: str, file_path: str, file_size: int) -> None:
"""Upload tarball to GCS via signed PUT URL with progress display."""
import urllib.error
import urllib.request
em = _get_emitter()
with open(file_path, "rb") as f:
reader = _ProgressReader(f, file_size, em)
req = urllib.request.Request(
signed_url,
data=reader,
method="PUT",
headers={
"Content-Type": "application/gzip",
"Content-Length": str(file_size),
"X-Goog-Content-Length-Range": "0,209715200",
},
)
try:
urllib.request.urlopen(req, timeout=_UPLOAD_TIMEOUT_SECONDS)
except urllib.error.HTTPError as err:
detail = err.read().decode("utf-8", errors="ignore")
raise click.ClickException(
f"Upload failed with status {err.code}: {detail}"
) from None
if not em.json_mode:
click.echo()
# ---------------------------------------------------------------------------
# Build runners
# ---------------------------------------------------------------------------
def _resolve_pushed_image_digest(
runner,
*,
remote_image: str,
docker_config_dir: str | None,
verbose: bool,
) -> str:
"""Return ``{registry}/{repo}@sha256:<hex>`` for a freshly-pushed image.
Reads ``RepoDigests`` via ``docker image inspect`` — the local daemon
records the registry's manifest digest there after a successful push.
Falls back to ``remote_image`` with a warning if no matching digest is
found, rather than failing the deploy.
"""
# rsplit preserves ``:port`` in the registry host.
repo_no_tag = remote_image.rsplit(":", 1)[0]
args: list[str] = ["docker"]
if docker_config_dir:
args += ["--config", docker_config_dir]
args += ["image", "inspect", "--format", "{{json .RepoDigests}}", remote_image]
stdout, _ = runner.run(subp_exec(*args, collect=True, verbose=verbose))
try:
digests = json_mod.loads(stdout or "[]") or []
except json_mod.JSONDecodeError:
digests = []
for d in digests:
if isinstance(d, str) and d.startswith(f"{repo_no_tag}@sha256:"):
return d
_get_emitter().warn(
f"Could not resolve image digest for {remote_image}; "
"falling back to the tag-based reference. Re-run with --verbose for details."
)
return remote_image
def _run_local_build(
*,
client: HostBackendClient,
deployment_id: str,
step: int,
config: pathlib.Path,
config_json: dict,
verbose: bool,
pull: bool,
api_version: str | None,
base_image: str | None,
image_name: str | None,
prebuilt_image: str | None,
name: str | None,
tag: str,
install_command: str | None,
build_command: str | None,
docker_build_args: Sequence[str],
secrets: list[dict[str, str]],
tracked_packages: list[str] | None,
) -> BuildResult:
"""Build locally with Docker, push to registry, update deployment."""
# Use buildx to cross-compile for amd64 when running on a non-x86_64 host
# (e.g. Apple Silicon). On amd64 hosts, plain docker build is sufficient.
needs_buildx = platform.machine() != "x86_64"
local_tag = f"langgraph-deploy-tmp:{int(time.time())}"
image_to_push = prebuilt_image or local_tag
with Runner() as runner:
if prebuilt_image:
_log_deploy_step(step, f"Validating image {prebuilt_image}")
_validate_prebuilt_image(runner, prebuilt_image, verbose=verbose)
click.secho(" Image is available for linux/amd64", fg="green")
else:
# -- Step: Build image --
_log_deploy_step(step, "Building image")
if needs_buildx:
build_flags: list[str] = [
"--platform",
"linux/amd64",
"--load",
]
if not verbose:
build_flags.append("--progress=quiet")
with Progress(message="Building...", elapsed=not verbose):
build_docker_image(
runner,
lambda _msg: None,
config,
config_json,
base_image,
api_version,
pull,
local_tag,
docker_build_args,
install_command,
build_command,
docker_command=("docker", "buildx", "build"),
extra_flags=build_flags,
verbose=verbose,
)
else:
with Progress(message="Building...", elapsed=not verbose):
build_docker_image(
runner,
lambda _msg: None,
config,
config_json,
base_image,
api_version,
pull,
local_tag,
docker_build_args,
install_command,
build_command,
verbose=verbose,
)
step += 1
# -- Step: Get push token and authenticate --
_log_deploy_step(step, "Requesting push token")
try:
push_data = client.request_push_token(deployment_id)
except HostBackendError as err:
if (
err.status_code == 400
and "only available for 'internal_docker' source deployments"
in err.message
):
raise click.ClickException(
f"Deployment '{deployment_id}' was not created by 'langgraph deploy' "
"and cannot be updated with this command.\n"
"Please create a new deployment by running 'langgraph deploy' "
"without --deployment-id, or use a different --name."
) from None
raise
deployment_token = push_data.get("token")
registry_url = push_data.get("registry_url")
if not deployment_token or not registry_url:
raise click.ClickException(
"Push token response missing token or registry_url"
)
step += 1
normalized_registry = registry_url.rstrip("/")
if "://" in normalized_registry:
normalized_registry = normalized_registry.split("//", 1)[1]
repo_seed = image_name or name or config.parent.name
repo_name = normalize_name(repo_seed)
tag_value = normalize_image_tag(tag)
remote_image = f"{normalized_registry}/{repo_name}:{tag_value}"
registry_host = normalized_registry.split("/")[0]
# Use a clean Docker config with only the push token so that
# system credential helpers (e.g. gcloud) don't interfere.
with _docker_config_for_token(registry_host, deployment_token) as cfg:
_log_deploy_step(step, f"Logging into {registry_host}")
token_input = (
deployment_token
if deployment_token.endswith("\n")
else f"{deployment_token}\n"
)
runner.run(
subp_exec(
"docker",
"--config",
cfg,
"login",
"-u",
"oauth2accesstoken",
"--password-stdin",
registry_host,
input=token_input,
verbose=verbose,
)
)
step += 1
# -- Step: Tag and push --
_log_deploy_step(step, f"Pushing image {remote_image}")
runner.run(
subp_exec(
"docker",
"tag",
image_to_push,
remote_image,
verbose=verbose,
)
)
max_push_retries = 3
for attempt in range(max_push_retries):
try:
with Progress(message="Pushing...", elapsed=not verbose):
runner.run(
subp_exec(
"docker",
"--config",
cfg,
"push",
remote_image,
verbose=verbose,
)
)
break
except click.exceptions.Exit:
if attempt < max_push_retries - 1:
_get_emitter().warn(
f" Push failed, retrying (attempt {attempt + 2} of {max_push_retries})..."
)
else:
raise
step += 1
resolved_image = _resolve_pushed_image_digest(
runner,
remote_image=remote_image,
docker_config_dir=None,
verbose=verbose,
)
# -- Step: Update deployment --
_log_deploy_step(step, f"Updating deployment {deployment_id}")
updated = client.update_deployment(
deployment_id,
resolved_image,
secrets=secrets,
tracked_packages=tracked_packages,
)
return BuildResult(
updated=updated if isinstance(updated, dict) else {},
progress_message="Deploying...",
timeout_seconds=300,
poll_interval_seconds=1,
no_result_message="Deployment updated",
)
def _run_remote_build(
*,
client: HostBackendClient,
deployment_id: str,
step: int,
config: pathlib.Path,
config_json: dict,
verbose: bool,
install_command: str | None,
build_command: str | None,
secrets: list[dict[str, str]],
tracked_packages: list[str] | None,
) -> BuildResult:
"""Upload source tarball and trigger a remote build."""
from langgraph_cli.archive import create_archive
em = _get_emitter()
_log_deploy_step(step, "Creating source archive")
with create_archive(config, config_json) as (archive_path, file_size, config_rel):
em.info(f"Archive created ({file_size / _BYTES_PER_MIB:.1f} MB)")
step += 1
_log_deploy_step(step, "Requesting upload URL")
upload_data = client.request_upload_url(deployment_id)
signed_url = upload_data.get("upload_url")
object_path = upload_data.get("object_path")
if not signed_url or not object_path:
raise click.ClickException("Upload URL response missing required fields")
step += 1
_log_deploy_step(step, "Uploading source")
_upload_to_gcs(signed_url, archive_path, file_size)
step += 1
_log_deploy_step(step, "Triggering remote build")
updated = client.update_deployment_internal_source(
deployment_id,
source_tarball_path=object_path,
config_path=config_rel,
secrets=secrets,
install_command=install_command,
build_command=build_command,
tracked_packages=tracked_packages,
)
log_offset: str | None = None
logs_header_printed = False
def _stream_build_logs(
status: str, revision_id: str, set_progress: Callable[[str], None]
) -> None:
nonlocal log_offset, logs_header_printed
if not (verbose and status in ("AWAITING_BUILD", "BUILDING")):
return
try:
logs_resp = client.get_build_logs(
deployment_id,
revision_id,
{"order": "asc", "limit": 50, "offset": log_offset}
if log_offset
else {"order": "asc", "limit": 50},
)
if isinstance(logs_resp, dict):
entries = logs_resp.get("logs", [])
has_output = any(entry.get("message") for entry in entries)
if has_output:
set_progress("")
if not logs_header_printed:
em.info(f"{status} (build logs):")
logs_header_printed = True
for entry in entries:
msg = entry.get("message", "")
if msg:
em.log(msg)
log_offset = logs_resp.get("next_offset") or log_offset
if has_output:
set_progress(f"{status}...")
except Exception:
pass
def _handle_interrupt(revision_id: str) -> None:
em.warn(
f"\nInterrupted. Deployment ID: {deployment_id}, Revision ID: {revision_id}"
)
em.warn("The build will continue remotely.")
return BuildResult(
updated=updated if isinstance(updated, dict) else {},
progress_message="",
timeout_seconds=900,
poll_interval_seconds=3,
no_result_message="Build triggered",
on_poll=_stream_build_logs,
on_interrupt=_handle_interrupt,
show_build_logs_on_failure=True,
)
# ---------------------------------------------------------------------------
# Host backend client factory
# ---------------------------------------------------------------------------
def _create_host_backend_client(
host_url: str | None,
api_key: str | None,
env_vars: dict[str, str] | None = None,
) -> HostBackendClient:
if env_vars is None:
env_vars = _parse_env_from_config({}, pathlib.Path.cwd() / DEFAULT_CONFIG)
resolved_api_key = api_key
if not resolved_api_key:
for key_name in _API_KEY_ENV_NAMES:
val = env_vars.get(key_name)
if val:
resolved_api_key = val
break
val = os.environ.get(key_name)
if val:
resolved_api_key = val
break
if not resolved_api_key:
if _no_input:
raise click.ClickException(
"No LangSmith API key found. Set LANGSMITH_API_KEY in the "
"environment or .env file."
)
click.secho(
"No LangSmith API key found. Create one at Settings > API Keys in LangSmith.",
fg="yellow",
)
resolved_api_key = click.prompt("Enter LangSmith API key", hide_input=True)
tenant_id = env_vars.get("LANGSMITH_TENANT_ID") or os.environ.get(
"LANGSMITH_TENANT_ID"
)
return HostBackendClient(host_url, resolved_api_key, tenant_id=tenant_id)
def _call_host_backend_with_optional_tenant(
client: HostBackendClient,
operation: Callable[[HostBackendClient], object],
) -> object:
"""Run *operation*, prompting for a workspace ID on org-scoped 403s.
On success the original *client* is returned as-is. If the user is
prompted for a workspace ID, the tenant header is set on *client*
in-place so all subsequent calls through the same instance are
tenant-aware.
"""
prompted_for_tenant = False
while True:
try:
return operation(client)
except HostBackendError as err:
if (
not prompted_for_tenant
and err.status_code == 403
and "requires workspace specification" in err.message
):
if _no_input:
raise click.ClickException(
"API key is org-scoped and requires a workspace ID. "
"Set LANGSMITH_TENANT_ID in your .env file or "
"use a workspace-scoped API key."
) from None
click.secho(
"Your API key is org-scoped and requires a workspace ID.",
fg="yellow",
)
click.secho(
"Find your workspace ID in LangSmith under Settings > Workspaces.",
fg="yellow",
)
client._client.headers["X-Tenant-ID"] = click.prompt("Workspace ID")
prompted_for_tenant = True
continue
if err.status_code == 403 and "not enabled" in err.message.lower():
smith_base = _smith_dashboard_base_url(client._base_url)
raise HostBackendError(
"LangSmith Deployment is not enabled for this organization. "
f"Enable it at {smith_base}/host/deployments"
" (ensure this matches the organization for your API key).",
status_code=403,
) from None
raise
# ---------------------------------------------------------------------------
# Click options shared by deploy commands
# ---------------------------------------------------------------------------
OPT_HOST_API_KEY = click.option(
"--api-key",
envvar="LANGGRAPH_HOST_API_KEY",
help=(
"API key. Can also be set via LANGGRAPH_HOST_API_KEY, "
"LANGSMITH_API_KEY, or LANGCHAIN_API_KEY environment variable or .env file."
),
)
OPT_HOST_DEPLOYMENT_NAME = click.option(
"--name",
envvar=_DEPLOYMENT_NAME_ENV,
help=(
"Deployment name. Can also be set via LANGSMITH_DEPLOYMENT_NAME "
"environment variable or .env file. Defaults to current directory name "
"if --deployment-id is not provided."
),
)
OPT_HOST_URL = click.option(
"--host-url",
envvar="LANGGRAPH_HOST_URL",
default="https://api.host.langchain.com",
hidden=True,
)
OPT_VERBOSE = click.option(
"--verbose",
is_flag=True,
default=False,
help="Show more output from the server logs",
)
class NestedHelpGroup(click.Group):
"""Click group that shows one level of nested subcommands in top-level help."""
def format_commands(
self, ctx: click.Context, formatter: click.HelpFormatter
) -> None:
command_entries: list[tuple[str, click.Command]] = []
# Collect the top-level commands first, then append one level of nested
# subcommands using names like "deploy list" so they show up in the
# top-level help output.
for command_name in self.list_commands(ctx):
command = self.get_command(ctx, command_name)
if command is None or command.hidden:
continue
command_entries.append((command_name, command))
if isinstance(command, click.Group):
# Build a child context so Click resolves the subcommands the same
# way it would for the nested group itself.
sub_ctx = click.Context(command, info_name=command_name, parent=ctx)
for subcommand_name in command.list_commands(sub_ctx):
subcommand = command.get_command(sub_ctx, subcommand_name)
if subcommand is None or subcommand.hidden:
continue
command_entries.append(
(f"{command_name} {subcommand_name}", subcommand)
)
# Compute the available width for help text up front so we can truncate
# descriptions before handing them to Click. That keeps each command on
# a single line instead of allowing wrapped descriptions.
command_width = max((len(name) for name, _ in command_entries), default=0)
help_width = max(formatter.width - command_width - 6, 10)
rows = [
(name, command.get_short_help_str(help_width))
for name, command in command_entries
]
if rows:
# Render the flattened command list using Click's standard
# definition-list formatter so alignment stays consistent with the
# rest of the CLI help output.
with formatter.section("Commands"):
formatter.write_dl(rows)
class DeployGroup(NestedHelpGroup):
"""Group that treats leading '-' args as passthrough docker flags."""
def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:
"""Treat leading option-like subcommand tokens as passthrough args.
Click stores the unresolved nested command token on the context after
`Group.parse_args()` runs, but the backing attribute changed across
supported Click versions. Click 8.1.x stores the value directly on
`protected_args`, while Click 8.2+ stores it on `_protected_args`
and exposes `protected_args` as a deprecated compatibility property.
Since this package allows `click>=8.1.7`, we need to check both
names to support the full version range without relying on one
version-specific internal detail.
"""
result = super().parse_args(ctx, args)
protected_args = ctx.__dict__.get("protected_args")
if protected_args is None:
protected_args = ctx.__dict__.get("_protected_args", [])
if protected_args and protected_args[0].startswith("-"):
ctx.args = [*protected_args, *ctx.args]
if "protected_args" in ctx.__dict__:
ctx.protected_args = []
elif "_protected_args" in ctx.__dict__:
ctx._protected_args = []
return ctx.args
return result
def _deploy_base_options(
func: Callable | None = None,
*,
include_docker_args: bool = True,
validate_config_path: bool = True,
):
"""Apply shared deploy flags.
The group shares most options but should not consume subcommands, so the
docker build args are only attached when requested.
"""
def _apply(target: Callable) -> Callable:
decorators = [
OPT_HOST_API_KEY,
OPT_HOST_DEPLOYMENT_NAME,
click.option(
"--deployment-id",
help=(
"ID of an existing deployment to update. If omitted, "
"--name is used to find or create the deployment."
),
),
click.option(
"--deployment-type",
type=click.Choice(["dev", "prod"]),
default="dev",
show_default=True,
help="Deployment type (used when creating a new deployment).",
),
click.option(
"--no-wait",
is_flag=True,
default=False,
help="Skip waiting for deployment status.",
),
OPT_VERBOSE,
OPT_HOST_URL,
click.option("--image-name", hidden=True),
click.option(
"--tag",
"-t",
default="latest",
show_default=True,
help="Tag to use for the pushed deployment image.",
),
click.option(
"--image",
help=(
"Use an existing local image reference (e.g. repo:tag) and "
"skip building. The image must target linux/amd64."
),
),
click.option(
"--config",
"-c",
default=DEFAULT_CONFIG,
hidden=True,
type=click.Path(
exists=validate_config_path,
file_okay=True,
dir_okay=False,
resolve_path=True,
path_type=pathlib.Path,
),
),
click.option("--pull/--no-pull", default=True, hidden=True),
click.option("--base-image", hidden=True),
click.option("--install-command", hidden=True),
click.option("--build-command", hidden=True),
click.option("--api-version", type=str, hidden=True),
click.option(
"--remote/--no-remote",
"remote_build_flag",
default=None,
help=(
"Force remote or local build. By default, builds remotely "
"if Docker is not available locally."
),
),
click.option(
"--json",
"json_output",
is_flag=True,
default=False,
help="Emit structured JSON-lines to stdout instead of human-readable text.",
),
click.option(
"--no-input",
is_flag=True,
default=False,
help="Never prompt for input; fail with an error if a required value is missing.",
),
]
if include_docker_args:
# Only attach build args to the default command; on the group they
# would capture subcommand names like `list` before Click resolves
# them, making those subcommands unreachable.
decorators.append(
click.argument("docker_build_args", nargs=-1, type=click.UNPROCESSED)
)
for decorator in reversed(decorators):
target = decorator(target)
return target
return _apply(func) if func is not None else _apply
# ---------------------------------------------------------------------------
# Deploy CLI group and commands
# ---------------------------------------------------------------------------
@click.group(
cls=DeployGroup,
help=(
"[Beta] Build and deploy a LangGraph image to LangSmith Deployment.\n\n"
"This command is in beta and under active development. "
"Expect frequent updates and improvements.\n\n"
"Run from the root of your LangGraph project (where langgraph.json "
"is located). This command also accepts build flags (--base-image, "
"--config, --pull, etc.). See 'langgraph build --help' for details."
),
context_settings=dict(ignore_unknown_options=True, allow_extra_args=True),
invoke_without_command=True, # allow `deploy` click group to execute without command
)
@_deploy_base_options(include_docker_args=False, validate_config_path=False)
@click.pass_context
@log_command
def deploy(ctx: click.Context, **_: object):
# We register deploy as both a group and a command here.
# if we detect no subcommand, we run _deploy_cmd (basically run langgraph deploy as a top level command)
# otherwise, we return None here and click will proceed to actually run the subcommand (list or delete)
if ctx.invoked_subcommand is not None:
return
docker_build_args = tuple(ctx.args)
ctx.args = [] # Prevent Click from re-processing passthrough args later.
return ctx.forward(_deploy_cmd, docker_build_args=docker_build_args)
@_deploy_base_options()
@click.command(context_settings=dict(ignore_unknown_options=True))
def _deploy_cmd(
config: pathlib.Path,
pull: bool,
verbose: bool,
api_version: str | None,
host_url: str | None,
api_key: str | None,
deployment_id: str | None,
deployment_type: str,
name: str | None,
image_name: str | None,
image: str | None,
tag: str,
base_image: str | None,
install_command: str | None,
build_command: str | None,
no_wait: bool,
remote_build_flag: bool | None,
docker_build_args: Sequence[str],
json_output: bool,
no_input: bool,
):
global _emitter, _no_input
_emitter = _Emitter(json_mode=json_output)
_no_input = no_input
em = _emitter
em.note(
"Note: 'langgraph deploy' is in beta. Expect frequent updates and improvements."
)
if not json_output:
click.echo()
# -- 1. Preflight --
validate_deploy_commands(install_command, build_command)
config_json = langgraph_cli.config.validate_config_file(config)
warn_non_wolfi_distro(config_json, emit=em.note)
env_vars = _parse_env_from_config(config_json, config)
if not deployment_id and not name:
name = env_vars.get(_DEPLOYMENT_NAME_ENV)
if not deployment_id and not name:
default_name = normalize_name(pathlib.Path.cwd().name)
if no_input:
name = default_name
else:
name = click.prompt("Deployment name", default=default_name)
if name and not deployment_id:
name = normalize_name(name)
if not no_input:
env_path = _resolve_env_path(config_json, config)
if env_path is not None:
set_key(str(env_path), _DEPLOYMENT_NAME_ENV, name)
em.info(f"Saved deployment name to {env_path}")
secrets = _secrets_from_env(_env_without_deployment_name(env_vars))
if image and remote_build_flag is True:
raise click.UsageError("--image cannot be combined with --remote builds.")
use_remote_build, local_build_error = _resolve_build_mode(
remote_build_flag, force_local=image is not None
)
if use_remote_build and remote_build_flag is None and local_build_error:
em.note(f"{local_build_error}\nUsing remote build instead.")
if not json_output:
click.echo()
# -- 2. Resolve / create deployment --
client = _create_host_backend_client(host_url, api_key, env_vars=env_vars)
step = 1
deployment_id, needs_creation, step = _resolve_deployment(
client,
step,
deployment_id,
name,
not_found_message=(
"No deployment found. Will create."
if use_remote_build
else "No deployment found. Will create after build."
),
)
if needs_creation:
deployment_id, step = _create_deployment(
client,
step,
name=name,
deployment_type=deployment_type,
source="internal_source" if use_remote_build else "internal_docker",
secrets=secrets,
)
if not deployment_id:
raise click.ClickException("Failed to determine deployment ID")
# Scan local sources for tracked packages so the new revision carries
# the same metadata GitHub-backed deploys produce. Failures must never
# block a deploy.
try:
tracked_packages = find_tracked_packages(config, config_json) or None
except Exception as exc:
em.warn(f"Skipped tracked-package scan: {exc}")
tracked_packages = None
# -- 3. Build (divergent path) --
if use_remote_build:
build_result = _run_remote_build(
client=client,
deployment_id=deployment_id,
step=step,
config=config,
config_json=config_json,
verbose=verbose,
install_command=install_command,
build_command=build_command,
secrets=secrets,
tracked_packages=tracked_packages,
)
else:
build_result = _run_local_build(
client=client,
deployment_id=deployment_id,
step=step,
config=config,
config_json=config_json,
verbose=verbose,
pull=pull,
api_version=api_version,
base_image=base_image,
image_name=image_name,
prebuilt_image=image,
name=name,
tag=tag,
install_command=install_command,
build_command=build_command,
docker_build_args=docker_build_args,
secrets=secrets,
tracked_packages=tracked_packages,
)
# -- 4. Shared wait + result --
dep_status_url = _emit_deployment_status_url(
build_result.updated,
deployment_id,
host_url,
)
if no_wait:
em.info(build_result.no_result_message)
return
last_status, revision_id = _poll_revision_status(
client,
deployment_id,
progress_message=build_result.progress_message,
timeout_seconds=build_result.timeout_seconds,
poll_interval_seconds=build_result.poll_interval_seconds,
on_poll=build_result.on_poll,
on_interrupt=build_result.on_interrupt,
)
if not last_status:
em.info(build_result.no_result_message)
return
if (
build_result.show_build_logs_on_failure
and last_status == "BUILD_FAILED"
and not verbose
and revision_id is not None
):
em.error("Last build log lines:")
try:
logs_resp = client.get_build_logs(
deployment_id,
revision_id,
{"order": "desc", "limit": 30},
)
if isinstance(logs_resp, dict):
entries = list(reversed(logs_resp.get("logs", [])))
for entry in entries:
msg = entry.get("message", "")
if msg:
em.log(msg)
except Exception:
em.error("(failed to fetch build logs)")
em.warn("Re-run with --verbose to see full build output.")
_print_deployment_result(
client,
deployment_id,
last_status,
dashboard_label="Deployment dashboard",
status_url=dep_status_url,
)
# ---------------------------------------------------------------------------
# deploy list
# ---------------------------------------------------------------------------
@OPT_HOST_API_KEY
@OPT_HOST_URL
@click.option(
"--name-contains",
default="",
help="Only show deployments whose names contain this value.",
)
@deploy.command("list", help="[Beta] List LangSmith Deployments.")
def deploy_list(api_key: str | None, host_url: str | None, name_contains: str) -> None:
client = _create_host_backend_client(host_url, api_key)
response = _call_host_backend_with_optional_tenant(
client,
lambda c: c.list_deployments(name_contains=name_contains),
)
resources = response.get("resources") if isinstance(response, dict) else None
deployments = (
[item for item in resources if isinstance(item, dict)]
if isinstance(resources, list)
else []
)
if not deployments:
click.echo("No deployments found.")
return
click.echo(format_deployments_table(deployments))
# ---------------------------------------------------------------------------
# deploy revisions
# ---------------------------------------------------------------------------
@deploy.group(
"revisions", cls=NestedHelpGroup, help="[Beta] Manage deployment revisions."
)
def deploy_revisions() -> None:
pass
@OPT_HOST_API_KEY
@OPT_HOST_URL
@click.option(
"--limit",
type=int,
default=10,
show_default=True,
help="Maximum number of revisions to return.",
)
@click.argument("deployment_id")
@deploy_revisions.command(
"list",
help=(
"[Beta] List revisions for a LangSmith Deployment.\n\n"
"Use the `deploy list` command to list deployment IDs."
),
)
def deploy_revisions_list(
api_key: str | None, host_url: str | None, limit: int, deployment_id: str
) -> None:
client = _create_host_backend_client(host_url, api_key)
response = _call_host_backend_with_optional_tenant(
client,
lambda c: c.list_revisions(deployment_id, limit=limit),
)
resources = response.get("resources") if isinstance(response, dict) else None
revisions = (
[item for item in resources if isinstance(item, dict)]
if isinstance(resources, list)
else []
)
if not revisions:
click.echo(f"No revisions found for deployment {deployment_id}.")
return
click.echo(format_revisions_table(revisions))
# ---------------------------------------------------------------------------
# deploy delete
# ---------------------------------------------------------------------------
@OPT_HOST_API_KEY
@OPT_HOST_URL
@click.option(
"--force",
is_flag=True,
default=False,
help="Delete without prompting for confirmation.",
)
@click.argument("deployment_id")
@deploy.command(
"delete",
help=(
"[Beta] Delete a LangSmith Deployment.\n\n"
"Use the `deploy list` command to list deployment IDs."
),
)
def deploy_delete(
api_key: str | None, host_url: str | None, force: bool, deployment_id: str
) -> None:
if not force:
response = click.prompt(
click.style(
f"Are you sure you want to delete deployment ID {deployment_id}? (Y/n)",
fg="yellow",
),
default="Y",
show_default=False,
)
if response.strip().lower() not in {"y", "yes"}:
raise click.Abort()
client = _create_host_backend_client(host_url, api_key)
_call_host_backend_with_optional_tenant(
client,
lambda c: c.delete_deployment(deployment_id),
)
click.secho(f"Deleted deployment {deployment_id}.", fg="green")
# ---------------------------------------------------------------------------
# deploy logs
# ---------------------------------------------------------------------------
@OPT_HOST_API_KEY
@OPT_HOST_DEPLOYMENT_NAME
@click.option(
"--deployment-id",
help="Deployment ID. If omitted, --name is used to find the deployment.",
)
@click.option(
"--type",
"log_type",
type=click.Choice(["deploy", "build"]),
default="deploy",
show_default=True,
help=(
"Log stream to fetch: 'deploy' shows agent server runtime logs; "
"'build' shows build logs (for deployments built remotely)."
),
)
@click.option(
"--revision-id",
help="Specific revision ID. For build logs, defaults to latest revision.",
)
@click.option(
"--level",
type=click.Choice(
["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], case_sensitive=False
),
help="Filter by log level.",
)
@click.option(
"--limit",
type=int,
default=100,
show_default=True,
help="Max log entries to fetch.",
)
@click.option(
"--query",
"-q",
help="Search string filter.",
)
@click.option(
"--start-time",
help="ISO8601 start time (e.g. 2026-03-08T00:00:00Z).",
)
@click.option(
"--end-time",
help="ISO8601 end time. (e.g. 2026-03-08T00:00:00Z)",
)
@click.option(
"--follow",
"-f",
is_flag=True,
default=False,
help="Continuously poll for new logs.",
)
@OPT_HOST_URL
@deploy.command(
"logs",
help=(
"[Beta] Fetch LangSmith Deployment logs. Use 'deploy' for agent runtime "
"logs, or 'build' for remote build logs."
),
)
@log_command
def deploy_logs(
api_key: str | None,
name: str | None,
deployment_id: str | None,
log_type: str,
revision_id: str | None,
level: str | None,
limit: int,
query: str | None,
start_time: str | None,
end_time: str | None,
follow: bool,
host_url: str,
):
env_vars = _parse_env_from_config({}, pathlib.Path.cwd() / DEFAULT_CONFIG)
client = _create_host_backend_client(host_url, api_key, env_vars=env_vars)
if not deployment_id and not name:
name = env_vars.get(_DEPLOYMENT_NAME_ENV)
validate_deployment_selector(deployment_id, name)
if deployment_id:
dep_id = deployment_id
else:
found = _call_host_backend_with_optional_tenant(
client, lambda c: find_deployment_id_by_name(c, name)
)
if not found:
raise click.ClickException(f"Deployment '{name}' not found.")
dep_id = str(found)
if log_type == "build" and not revision_id:
revisions_resp = client.list_revisions(dep_id, limit=1)
resources = (
revisions_resp.get("resources", [])
if isinstance(revisions_resp, dict)
else []
)
if not resources:
raise click.ClickException(
"No revisions found for this deployment. Cannot fetch build logs."
)
revision_id = str(resources[0]["id"])
click.secho(f"Using latest revision: {revision_id}", fg="cyan")
payload: dict = {"limit": limit, "order": "desc"}
if level:
payload["level"] = level.upper()
if query:
payload["query"] = query
if start_time:
payload["start_time"] = start_time
if end_time:
payload["end_time"] = end_time
def _fetch(request_payload: dict) -> list[dict]:
if log_type == "build":
resp = client.get_build_logs(dep_id, revision_id, request_payload)
else:
resp = client.get_deploy_logs(dep_id, request_payload, revision_id)
if isinstance(resp, dict):
return resp.get("logs", [])
return []
def _print_entries(entries: list[dict], *, reverse: bool = False) -> None:
iterable = reversed(entries) if reverse else entries
for entry in iterable:
line = format_log_entry(entry)
fg = level_fg(entry.get("level", ""))
click.secho(line, fg=fg)
def _fetch_and_print(request_payload: dict, *, reverse: bool = False) -> list[dict]:
entries = _fetch(request_payload)
_print_entries(entries, reverse=reverse)
return entries
def _fetch_and_print_new(request_payload: dict, seen_ids: set[str]) -> list[dict]:
entries = _fetch(request_payload)
new = [e for e in entries if e.get("id", "") not in seen_ids]
if new:
_print_entries(new)
seen_ids.update(e.get("id", "") for e in new)
return new
# initial log fetch will be newest -> oldest, so we need to reverse
entries = _fetch_and_print(payload, reverse=True)
if not follow:
if not entries:
click.secho("No log entries found.", fg="yellow")
return
payload["order"] = "asc"
seen_ids: set[str] = {e.get("id", "") for e in entries if e.get("id")}
def _update_start_time(ts) -> None:
if ts is None:
return
if isinstance(ts, (int, float)):
dt = datetime.fromtimestamp(ts / 1000, tz=timezone.utc)
payload["start_time"] = dt.isoformat()
else:
payload["start_time"] = str(ts)
if entries:
# entries are in descending order here, so index 0 is the newest log
_update_start_time(entries[0].get("timestamp"))
try:
while True:
time.sleep(2)
new_entries = _fetch_and_print_new(payload, seen_ids)
if new_entries:
_update_start_time(new_entries[-1].get("timestamp"))
except KeyboardInterrupt:
click.echo("\nStopped.")