deepzora 0.1.0: Deepzora as a magpie agent through a reversible TOML bridge (#1043)

Adds @magpie-community/agent-deepzora: Deepzora on magpie's Agents page, through a reversible bridge that adds a magpie-agent provider to ~/.deepzora/config.toml and the key to ~/.deepzora/.env, and puts both back on disconnect. The package is reasonix-desktop's bridge with Deepzora's names; vendor.mjs is byte for byte the merged reasonix-desktop copy (sha256 46e08060…).

Run at the reviewed head 858f09aa, on a separate test Mac, Bun 1.4.2 and Node 22.22.0, temp HOME:
- bun test packages/deepzora: 12 pass; node --test: 12 pass
- bun scripts/check.mjs: ok; npm pack --dry-run: 13 files, 57.0 kB
- a probe over the bridge in temp dirs (corrupt and half-written TOML, user edits across a switch and a disconnect, pre-existing keys in four forms, CRLF, read-only dir, 0-byte config): each as expected
- full root bun test at 858f09aa: 8482 pass, 20 skip, 0 fail

Broken by hand: 17 breaks, 13 red. Four stay green (an edited credential on switch, a half-written control file read as disconnect, no provider_access cleanup, no lock), the same gaps reasonix-desktop's tests have; listed in the review.

Not tried: a real Deepzora binary or session, acceptance.mjs and resident-acceptance.mjs, Windows (Deepzora uses %APPDATA%\deepzora there; the descriptor has no per-OS paths), a Deepzora Desktop settings save while connected.

The first npm publish of @magpie-community/agent-deepzora is the maintainer's.

Co-authored-by: SivanCola <SivanCola@users.noreply.github.com>
This commit is contained in:
SivanCola
2026-11-12 16:27:26 +08:00
committed by GitHub
co-authored by SivanCola
parent 2479b36f23
commit 8768126af3
19 changed files with 1873 additions and 0 deletions
+1
View File
@@ -281,6 +281,7 @@ it off puts the config back.
| [aider](packages/aider) | [Aider](https://aider.chat): `~/.aider.conf.yml`, through litellm's `openai/` prefix |
| [nanobot](packages/nanobot) | [nanobot](https://github.com/HKUDS/nanobot): Magpie's model becomes nanobot's default preset, and Library gives it MCP servers and default-workspace skills; restart nanobot after MCP changes |
| [reasonix-desktop](packages/reasonix-desktop) | [Reasonix 1.x](https://github.com/esengine/DeepSeek-Reasonix/tree/main-v2) Desktop and CLI: reversible global TOML/dotenv bridge; restart Reasonix after choosing a model. Separate from the built-in Studio 2.x adapter |
| [deepzora](packages/deepzora) | [Deepzora](https://github.com/SivanCola/deepzora) Desktop, CLI and ACP: reversible global TOML/dotenv bridge; restart Deepzora after choosing a model |
| [bub](packages/bub) | [Bub](https://bub.build): `~/.bub/config.yml`, as the `magpie:` provider (needs Bub 0.5.1 or later) |
| [kilo](packages/kilo) | [Kilo Code](https://kilo.ai): `~/.config/kilo/kilo.jsonc`, through an OpenAI-compatible provider |
| [junie](packages/junie) | [Junie CLI](https://junie.jetbrains.com/): an explicit `/v1/models` seed for its full picker and Magpie's selected model as the launch default; no LiteLLM |
+13
View File
@@ -0,0 +1,13 @@
# Deepzora icon
The PNG embedded in `package.json` (`magpie.icon`) and `deepzora.agent.js`
(`agent.icon`) is the unmodified official Deepzora 128 × 128 application icon.
Source: [SivanCola/deepzora at ad855397cdfdaf2ba7e3e3414583ba777412cbe4](https://github.com/SivanCola/deepzora/blob/ad855397cdfdaf2ba7e3e3414583ba777412cbe4/desktop/build/linux/icons/hicolor/128x128/apps/deepzora-desktop.png).
The icon is distributed under the source project's AGPL-3.0-only license;
see `LICENSE-ICON`. Deepzora's [brand policy](https://github.com/SivanCola/deepzora/blob/ad855397cdfdaf2ba7e3e3414583ba777412cbe4/TRADEMARK_POLICY.md)
also applies. It identifies the compatible agent in Magpie.
The plugin's original code remains MIT licensed under `LICENSE`. The package
license expression includes both the code and the separately licensed icon.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 SivanCola
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+23
View File
@@ -0,0 +1,23 @@
Copyright (c) 2015, Scott Motte
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+661
View File
@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
+24
View File
@@ -0,0 +1,24 @@
Copyright (c) Squirrel Chat et al., All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+105
View File
@@ -0,0 +1,105 @@
# Deepzora
Adds [Deepzora](https://github.com/SivanCola/deepzora) Desktop, CLI and ACP to
Magpie's Agents page as **Deepzora**, ID `deepzora`.
```sh
magpie plugin add @magpie-community/agent-deepzora
```
Choose a model on its Agent row, wait about a second with Magpie running, then
restart Deepzora and start a new conversation. Explicit project
`deepzora.toml` defaults, CLI `--model` flags and existing session selections
retain their precedence.
## Configuration and restoration
This package includes an Agent descriptor and a companion running in Magpie's
Bun plugin host. The generic Agent writer supports JSON/YAML/dotenv, not TOML
with a separate credential file. No Deepzora source changes, host patches,
extra daemon or upstream provider login are required. Parsing libraries are
vendored at exact versions with their licenses; installation needs no build
script or runtime dependency download.
The descriptor writes `~/.deepzora/magpie-agent.json`. The host bridges it into
`~/.deepzora/config.toml`, adding the `magpie-agent` OpenAI Chat Completions
provider and default model. The assigned gateway key goes into
`~/.deepzora/.env` as `MAGPIE_DEEPZORA_API_KEY`, never into TOML or logs.
Deepzora sends requests to Magpie; Magpie handles upstream credentials and
protocol conversion. Known context/output sizes and image support follow the
chosen model. Existing providers and unrelated settings are kept.
Choose the Agent's default to disconnect, wait for the bridge, then restart
Deepzora. Normal plugin-host exit flushes a pending disconnect, including
disabling the plugin with Magpie running. With CLI-only operation, restore
while the package is still enabled before removing it:
```sh
magpie deepzora default
magpie plugin list --json
# Remove after restoration completes:
magpie plugin rm @magpie-community/agent-deepzora
```
The one-shot fallback is `node cli.mjs sync` from this package. After a forced
host kill, re-enable the package and disconnect to finish restoration.
Private backups and a replayable transaction journal live in
`~/.deepzora/.magpie-bridge/`. They contain original credential-file contents;
keep them private and retain them if recovery pauses. Writes use private
files and atomic replacement. Untouched files restore byte for byte;
unrelated edits and Deepzora startup migrations are merged and retained.
TOML comments and formatting can change during connection and after a merged
restoration. Manual changes to managed fields pause synchronization. Existing
uses of the reserved provider or credential name are refused. Do not edit
Deepzora's model settings while switching models.
## Compatibility
Verified on macOS with unmodified Magpie 0.1.3850 and Deepzora CLI v0.0.4
against a local model fixture, including resident-host plugin disable.
The default paths target macOS/Linux with the shared global `config.toml` and
`.env`. On Windows or with custom `DEEPZORA_HOME`, install a local copy and
change the descriptor's `dir` and `config` to the same actual Deepzora data
directory. The bridge derives TOML and `.env` paths from the descriptor's
`config`; it cannot infer another process's environment. Native Windows
acceptance is not claimed.
Do not enable this package and `github:SivanCola/magpie-agent-deepzora` at the
same time: they register the same Agent and manage the same files. To switch,
restore defaults and remove the standalone package first, then install this
package and select a model again.
## Development
```sh
bun test ./packages/deepzora
bun scripts/check.mjs deepzora
MAGPIE_BIN=/path/to/magpie DEEPZORA_BIN=/path/to/deepzora node packages/deepzora/acceptance.mjs
MAGPIE_BIN=/path/to/magpie node packages/deepzora/resident-acceptance.mjs
```
Acceptance uses disposable homes and a localhost model fixture. It installs
the actual package in Magpie, verifies model selection and restoration, and
optionally checks an unchanged Deepzora CLI sends the selected model and
exact assigned credential. No saved accounts or paid inference requests are
used. See [THIRD_PARTY.md](THIRD_PARTY.md) for code and asset attribution.
## 中文
把 **Deepzora** 桌面版、CLI 和 ACP 加到 Magpie 的 Agent 页,ID 为
`deepzora`。安装后选模型,保持 Magpie 运行并等待约一秒,再重启 Deepzora、
新建会话。项目配置、CLI 参数和已有会话仍按各自优先级生效。
插件随包桥接 TOML 和独立 `.env`,保留原有供应商及无关设置,不修改原程序。
网关密钥只写入全局 `.env`,不写入 TOML 或日志。解析库已随包提供,
无需额外下载依赖。备份包含原始凭据文件,请妥善保管。
卸载前先在 Agent 页恢复默认;仅用 CLI 时先执行上面的 `default` 和
`plugin list --json` 两步。Magpie 运行期间正常关闭插件宿主会补做恢复;
强制终止后需要重新启用插件并断开。同步期间不要手工改动受管理的供应商、
默认模型或凭据。Windows 和自定义目录请先按上述说明修改路径。
从独立 GitHub 插件迁移时,先恢复默认并卸载旧插件,再安装本包、重新选模型;
两个包不能同时启用。插件代码采用 MIT 许可,图标单独采用 AGPL-3.0-only,
解析库保留 BSD 许可,详见来源说明。
+38
View File
@@ -0,0 +1,38 @@
# Source and licenses
The Agent descriptor and original bridge are from
[SivanCola/magpie-agent-deepzora at a547f57](https://github.com/SivanCola/magpie-agent-deepzora/tree/a547f57),
MIT, copyright (c) 2026 SivanCola. See `LICENSE`.
The host-exit restoration, reserved-credential protection, additional tests
and dependency bundling follow the existing MIT-licensed
[`reasonix-desktop` package at 907847b](https://github.com/magpie-community/plugins/tree/907847b/packages/reasonix-desktop).
The Deepzora provider fields, Agent ID and configuration paths remain
Deepzora-specific; it does not use the Reasonix adapter.
The embedded PNG is Deepzora's unmodified 128 × 128 application icon,
AGPL-3.0-only. See `ASSET_NOTICE.md` for its exact source and brand policy,
and `LICENSE-ICON` for its license. This asset is separately licensed from
the plugin code.
`vendor.mjs` bundles these exact parsers so this Agent needs no runtime
dependency installation or build scripts:
- `smol-toml` 1.9.1, BSD-3-Clause (`LICENSE-SMOL-TOML`).
- `dotenv` 18.0.9, BSD-2-Clause (`LICENSE-DOTENV`). Only `parse` is exported;
the bridge never calls dotenv's environment-loading functions.
The bundle is byte-identical to the existing `reasonix-desktop/vendor.mjs`.
To regenerate in this package folder with Bun 1.4.4:
```sh
npm install --no-save --ignore-scripts --package-lock=false smol-toml@1.9.1 dotenv@18.0.9
bun build vendor-entry.mjs --target=node --format=esm --minify --outfile=vendor.mjs
```
## 中文
Agent 入口与原始桥接来自独立 Deepzora 插件,补充保护与测试沿用社区已有的
Reasonix 桥接模式,均保留 MIT 许可。图标采用单独的 AGPL-3.0-only 许可,
来源和品牌政策见 `ASSET_NOTICE.md`。TOML 和 dotenv 解析器以固定版本打包,
保留 BSD 许可;无需安装运行时依赖或执行构建脚本。
+96
View File
@@ -0,0 +1,96 @@
// Optional native acceptance. Everything uses disposable homes and a localhost
// model fixture: no user config, subscription credentials or paid model calls.
import assert from "node:assert/strict"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import http from "node:http"
import { execFile } from "node:child_process"
import { promisify } from "node:util"
import { fileURLToPath } from "node:url"
import { parseTOML as parse, parseEnv } from "./vendor.mjs"
const exec = promisify(execFile)
const root = fs.mkdtempSync(path.join(os.tmpdir(), "magpie-deepzora-native-"))
const repo = fileURLToPath(new URL(".", import.meta.url))
const magpie = process.env.MAGPIE_BIN || "magpie"
const deepzora = process.env.DEEPZORA_BIN
const env = { ...process.env, HOME: root, USERPROFILE: root, XDG_CONFIG_HOME: path.join(root, ".config"), XDG_CACHE_HOME: path.join(root, ".cache"), XDG_STATE_HOME: path.join(root, ".state"), DEEPZORA_HOME: path.join(root, ".deepzora"), DEEPZORA_STATE_HOME: path.join(root, ".deepzora-state"), MAGPIE_NO_ACCOUNTS: "1" }
const dz = env.DEEPZORA_HOME
const config = path.join(dz, "config.toml")
const control = path.join(dz, "magpie-agent.json")
const run = async (bin, args) => exec(bin, args, { cwd: root, env, timeout: 120000, maxBuffer: 2 << 20 })
let requests = 0
let expectedKey = ""
const server = http.createServer(async (req, res) => {
let raw = ""
for await (const chunk of req) raw += chunk
if (req.method === "GET") {
res.setHeader("content-type", "application/json")
res.end(JSON.stringify({ object: "list", data: [{ id: "fixture/test-model", object: "model" }] }))
return
}
const body = JSON.parse(raw)
assert.equal(req.url, "/v1/chat/completions")
assert.equal(body.model, "fixture/test-model")
assert.equal(req.headers.authorization, `Bearer ${expectedKey}`)
requests++
if (body.stream) {
res.setHeader("content-type", "text/event-stream")
res.end(`data: ${JSON.stringify({ id: "fixture", object: "chat.completion.chunk", choices: [{ index: 0, delta: { role: "assistant", content: "bridge-ok" }, finish_reason: null }] })}\n\ndata: ${JSON.stringify({ id: "fixture", object: "chat.completion.chunk", choices: [{ index: 0, delta: {}, finish_reason: "stop" }] })}\n\ndata: [DONE]\n\n`)
} else {
res.setHeader("content-type", "application/json")
res.end(JSON.stringify({ id: "fixture", object: "chat.completion", choices: [{ index: 0, message: { role: "assistant", content: "bridge-ok" }, finish_reason: "stop" }], usage: { prompt_tokens: 10, completion_tokens: 2, total_tokens: 12 } }))
}
})
try {
await new Promise(resolve => server.listen(0, "127.0.0.1", resolve))
const base = `http://127.0.0.1:${server.address().port}/v1`
fs.mkdirSync(dz, { recursive: true })
fs.mkdirSync(path.join(env.XDG_CONFIG_HOME, "magpie"), { recursive: true })
const original = '# native acceptance fixture\ndefault_model="mine/model"\n[[providers]]\nname="mine"\nkind="openai"\nbase_url="http://127.0.0.1:49998/v1"\nmodels=["model"]\n'
fs.writeFileSync(config, original)
fs.writeFileSync(path.join(dz, ".env"), "OTHER_KEY=fixture-original\n")
fs.writeFileSync(path.join(env.XDG_CONFIG_HOME, "magpie/providers.json"), JSON.stringify({ providers: [{ id: "fixture", name: "Fixture", key: "fixture-only", chat: base, models: ["test-model"] }] }))
await run(magpie, ["plugin", "add", repo])
const agents = await run(magpie, ["agents"])
assert.match(agents.stdout, /Deepzora/)
await run(magpie, ["deepzora", "fixture/test-model"])
// Loading the real plugin host executes the companion bridge.
const loaded = await run(magpie, ["plugin", "list", "--json"])
assert.ok(!JSON.parse(loaded.stdout).loaded.some(plugin => plugin.error))
assert.equal(parse(fs.readFileSync(config, "utf8")).default_model, "magpie-agent/fixture/test-model")
console.log("PASS: Magpie installs and discovers the agent; its plugin host bridges the selected model")
if (deepzora) {
expectedKey = parseEnv(fs.readFileSync(path.join(dz, ".env"))).MAGPIE_DEEPZORA_API_KEY
assert.ok(expectedKey)
// Keep Magpie's selected ID and assigned key. Redirect only the isolated
// control file to a local API fixture so no live gateway account is used.
const cfg = JSON.parse(fs.readFileSync(control, "utf8"))
cfg.baseURL = base
fs.writeFileSync(control, JSON.stringify(cfg))
await run(process.execPath, [path.join(repo, "cli.mjs"), "sync"])
const result = await run(deepzora, ["-p", "Reply with bridge-ok", "--output-format", "json"])
assert.ok(requests > 0)
assert.match(result.stdout, /bridge-ok/)
console.log("PASS: unchanged Deepzora sends its selected model and assigned credential to the local API")
}
await run(magpie, ["deepzora", "default"])
await run(process.execPath, [path.join(repo, "cli.mjs"), "sync"])
if (deepzora) {
// Deepzora may migrate its config on startup; keep those unrelated edits.
const restored = parse(fs.readFileSync(config, "utf8"))
assert.equal(restored.default_model, "mine/model")
assert.deepEqual(restored.providers.map(p => p.name), ["mine"])
assert.equal(restored.providers[0].base_url, "http://127.0.0.1:49998/v1")
} else {
assert.equal(fs.readFileSync(config, "utf8"), original)
}
assert.equal(fs.readFileSync(path.join(dz, ".env"), "utf8"), "OTHER_KEY=fixture-original\n")
console.log("PASS: disconnect restores selection and credentials, preserving unrelated Deepzora edits")
} finally {
server.closeAllConnections()
await new Promise(resolve => server.close(resolve))
fs.rmSync(root, { recursive: true, force: true })
}
+217
View File
@@ -0,0 +1,217 @@
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { randomUUID } from "node:crypto"
import { isDeepStrictEqual } from "node:util"
import { parseTOML, stringify, parseEnv } from "./vendor.mjs"
import { agent } from "./deepzora.agent.js"
export const PROVIDER = "magpie-agent"
export const KEY = "MAGPIE_DEEPZORA_API_KEY"
const active = new Map()
const parse = (text) => parseTOML(text || "", { integersAsBigInt: "asNeeded" })
export function pathsFor(home = os.homedir()) {
const control = agent.config.replace(/^~(?=\/|$)/, home)
if (!path.isAbsolute(control)) throw new Error("Agent config must name an absolute path or ~/ path")
const deepzora = path.dirname(control)
return {
control,
config: path.join(deepzora, "config.toml"),
env: path.join(deepzora, ".env"),
state: path.join(deepzora, ".magpie-bridge", "state.json"),
}
}
function read(file) {
try {
const st = fs.lstatSync(file)
if (!st.isFile() || st.isSymbolicLink()) throw new Error("Bridge refuses non-regular files")
return fs.readFileSync(file, "utf8")
} catch (e) {
if (e.code === "ENOENT") return null
throw e
}
}
function write(file, text) {
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 })
// Preserve the user's directory; all bridge-created files are private.
if (text === null) {
fs.rmSync(file, { force: true })
return
}
const temp = path.join(path.dirname(file), `.magpie-${randomUUID()}.tmp`)
try {
fs.writeFileSync(temp, text, { mode: 0o600, flag: "wx" })
fs.renameSync(temp, file)
} finally {
fs.rmSync(temp, { force: true })
}
}
function json(file) {
const raw = read(file)
return raw === null ? null : JSON.parse(raw)
}
function lock(file) {
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 })
try {
fs.writeFileSync(file, String(process.pid), { mode: 0o600, flag: "wx" })
} catch (e) {
if (e.code !== "EEXIST") throw e
const pid = Number(read(file))
if (!Number.isSafeInteger(pid) || pid <= 0) throw new Error("Invalid bridge lock; inspect .magpie-bridge/lock")
try { process.kill(pid, 0) } catch (error) {
if (error.code !== "ESRCH") throw error
fs.unlinkSync(file)
return lock(file)
}
throw new Error("Another bridge operation is running")
}
return () => fs.unlinkSync(file)
}
// A durable journal precedes every multi-file change. Recovery accepts only
// the exact before/after states; concurrent edits are never overwritten.
function recover(p) {
const journalPath = p.state + ".pending"
const journal = json(journalPath)
if (!journal) return
for (const change of journal.changes) {
if (![p.config, p.env].includes(change.file)) throw new Error("Invalid bridge journal target")
const current = read(change.file)
if (current !== change.before && current !== change.after) throw new Error("Bridge recovery paused: configuration changed; retain .magpie-bridge for recovery")
}
for (const change of journal.changes) if (read(change.file) !== change.after) write(change.file, change.after)
write(p.state, journal.state === null ? null : JSON.stringify(journal.state))
fs.unlinkSync(journalPath)
}
function commit(p, changes, state) {
for (const change of changes) {
if (read(change.file) !== change.before) throw new Error("Configuration changed during bridge update; retry")
}
write(p.state + ".pending", JSON.stringify({ changes, state }))
recover(p)
}
function desired(control) {
if (!control?.gatewayKey && !control?.baseURL) return null
if (typeof control.model !== "string" || !control.model.trim() || typeof control.gatewayKey !== "string" || !control.gatewayKey || typeof control.baseURL !== "string") throw new Error("Incomplete Magpie connection; select its model again")
const url = new URL(control.baseURL)
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error("Invalid Magpie gateway URL")
if (/[\r\n'\\]/.test(control.gatewayKey)) throw new Error("Unsupported gateway key encoding")
const entry = {
name: PROVIDER, display_name: "Magpie", kind: "openai", base_url: control.baseURL,
models: [control.model], default: control.model, api_key_env: KEY,
}
const info = control.modelInfo || {}
if (Number.isSafeInteger(info.context) && info.context > 0) entry.context_window = info.context
if (Number.isSafeInteger(info.output) && info.output > 0) entry.max_output_tokens = info.output
if (typeof info.images === "boolean") entry.model_overrides = { [control.model]: { vision: info.images } }
return { entry, key: control.gatewayKey, ref: `${PROVIDER}/${control.model}` }
}
function patchKey(raw, value) {
const text = raw || ""
// Refuse ambiguous multiline assignments of the owned key instead of
// touching another credential's continuation lines.
const lines = text.split(/(?<=\n)/)
const pattern = new RegExp(`^\\s*(?:export\\s+)?${KEY}\\s*=`)
const found = lines.filter(line => pattern.test(line))
if (found.length > 1) throw new Error("Duplicate bridge credential assignments")
if (found.length && parseEnv(found[0])[KEY] !== parseEnv(text)[KEY]) throw new Error("Multiline bridge credentials are unsupported")
const eol = text.includes("\r\n") ? "\r\n" : "\n"
const assignment = value === undefined ? "" : `${KEY}='${value}'${eol}`
if (found.length) return lines.map(line => pattern.test(line) ? assignment : line).join("")
return value === undefined ? text : text + (text && !text.endsWith("\n") ? eol : "") + assignment
}
function assertOwned(cfg, env, state) {
const previous = parse(state.lastConfig)
if (!isDeepStrictEqual(cfg.providers?.find(p => p.name === PROVIDER), previous.providers?.find(p => p.name === PROVIDER))) throw new Error("Managed Magpie provider was edited; disconnect before reconnecting")
if (cfg.default_model !== previous.default_model) throw new Error("Default model was edited; disconnect before reconnecting")
if (parseEnv(env || "")[KEY] !== parseEnv(state.lastEnv || "")[KEY]) throw new Error("Bridge credential was edited; disconnect before reconnecting")
}
function restoredConfig(config, state) {
if (config === state.lastConfig) return state.originalConfig
const cfg = parse(config)
const original = parse(state.originalConfig)
const previous = parse(state.lastConfig)
const entry = cfg.providers?.find(p => p.name === PROVIDER)
if (entry && !isDeepStrictEqual(entry, previous.providers?.find(p => p.name === PROVIDER))) throw new Error("Managed provider changed; restore it before disconnecting (backup retained)")
cfg.providers = (cfg.providers || []).filter(p => p.name !== PROVIDER)
if (!cfg.providers.length && !Object.hasOwn(original, "providers")) delete cfg.providers
if (cfg.default_model === previous.default_model) {
if (Object.hasOwn(original, "default_model")) cfg.default_model = original.default_model
else delete cfg.default_model
}
if (Array.isArray(cfg.desktop?.provider_access) && !original.desktop?.provider_access?.includes(PROVIDER)) cfg.desktop.provider_access = cfg.desktop.provider_access.filter(name => name !== PROVIDER)
return stringify(cfg)
}
function restoredEnv(env, state) {
if (env === state.lastEnv) return state.originalEnv
const mine = parseEnv(state.lastEnv || "")[KEY]
return parseEnv(env || "")[KEY] === mine ? patchKey(env, parseEnv(state.originalEnv || "")[KEY]) : env
}
export function syncBridge(p = pathsFor()) {
if (read(p.control) === null && read(p.state) === null && read(p.state + ".pending") === null) return "disconnected"
const unlock = lock(path.join(path.dirname(p.state), "lock"))
try {
recover(p)
const state = json(p.state)
const control = json(p.control)
const want = desired(control)
if (!want && !state) return "disconnected"
const config = read(p.config)
const env = read(p.env)
const cfg = parse(config)
if (want) {
if (state) assertOwned(cfg, env, state)
else {
if (cfg.providers?.some(entry => entry.name === PROVIDER)) throw new Error("Provider magpie-agent already exists; rename it before connecting")
if (Object.hasOwn(parseEnv(env || ""), KEY) || cfg.providers?.some(entry => entry.api_key_env === KEY)) throw new Error("Bridge credential name already belongs to existing configuration")
}
const next = { ...cfg, default_model: want.ref, providers: [...(cfg.providers || []).filter(entry => entry.name !== PROVIDER), want.entry] }
if (Array.isArray(cfg.desktop?.provider_access)) next.desktop = { ...cfg.desktop, provider_access: [...new Set([...cfg.desktop.provider_access, PROVIDER])] }
const nextConfig = isDeepStrictEqual(cfg, next) ? config : stringify(next)
const nextEnv = parseEnv(env || "")[KEY] === want.key ? env : patchKey(env, want.key)
if (state && config === nextConfig && env === nextEnv) return "connected"
const nextState = {
version: 1,
originalConfig: state ? restoredConfig(config, state) : config,
originalEnv: state ? restoredEnv(env, state) : env,
lastConfig: nextConfig, lastEnv: nextEnv,
}
commit(p, [{ file: p.env, before: env, after: nextEnv }, { file: p.config, before: config, after: nextConfig }], nextState)
return "connected"
}
const nextConfig = restoredConfig(config, state)
const nextEnv = restoredEnv(env, state)
commit(p, [{ file: p.config, before: config, after: nextConfig }, { file: p.env, before: env, after: nextEnv }], null)
return "disconnected"
} finally { unlock() }
}
export function startBridge(p = pathsFor(), { interval = 750, onError = () => console.error("Deepzora bridge paused; run magpie-deepzora sync for details (configuration retained).") } = {}) {
if (active.has(p.state)) return active.get(p.state)
let previousError = ""
const tick = () => {
try { syncBridge(p); previousError = "" } catch (error) {
// Parser errors can contain a source line; never write those to logs.
if (error.message !== previousError) onError()
previousError = error.message
}
}
tick()
const timer = setInterval(tick, interval)
timer.unref?.()
const stop = () => { clearInterval(timer); active.delete(p.state) }
active.set(p.state, stop)
return stop
}
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env node
import { syncBridge } from "./bridge.mjs"
if (!process.argv[2] || process.argv[2] === "sync") {
try { console.log(`Deepzora bridge: ${syncBridge()}`) } catch {
console.error("Deepzora bridge could not synchronize. Check JSON/TOML syntax, reserved provider/credential conflicts, file permissions and .magpie-bridge recovery files. Source contents and keys are omitted.")
process.exitCode = 1
}
} else {
console.error("Usage: magpie-deepzora sync")
process.exitCode = 2
}
File diff suppressed because one or more lines are too long
+237
View File
@@ -0,0 +1,237 @@
import assert from "node:assert/strict"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { test } from "node:test"
import { spawnSync } from "node:child_process"
import { parseTOML as parse, stringify, parseEnv } from "./vendor.mjs"
import { PROVIDER, KEY, syncBridge, startBridge } from "./bridge.mjs"
import { agent, connect } from "./deepzora.agent.js"
const originalConfig = `# User's comments and preferences
config_version = 12
default_model = "mine/model"
[agent]
compact_ratio = 0.8
[desktop]
provider_access = ["mine"]
[[providers]]
name = "mine"
kind = "openai"
base_url = "http://127.0.0.1:9999/v1"
models = ["model"]
api_key_env = "MY_API_KEY"
`
const originalEnv = "# existing secret\r\nMY_API_KEY=fixture-original\r\n"
function fixture(t) {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "magpie-deepzora-"))
t.after(() => fs.rmSync(root, { recursive: true, force: true }))
const p = { control: path.join(root, "magpie-agent.json"), config: path.join(root, "config.toml"), env: path.join(root, ".env"), state: path.join(root, ".magpie-bridge/state.json") }
fs.writeFileSync(p.config, originalConfig)
fs.writeFileSync(p.env, originalEnv)
const select = (id = "vendor/model-v1", key = "fixture-gateway-key") => {
const model = { id, context: 200000, output: 16000, images: true }
fs.writeFileSync(p.control, JSON.stringify({ model: id, ...connect({ model, gateway: { v1: "http://127.0.0.1:3425/v1", key } }) }))
}
return { p, select, disconnect: () => fs.writeFileSync(p.control, "{}") }
}
test("agent descriptor and sandbox hook expose one selected model", () => {
assert.equal(agent.id, "deepzora")
assert.equal(agent.format, "json")
assert.equal(agent.model, "model")
assert.throws(() => connect({ gateway: {} }), /Choose a model/)
})
test("connect, switch, restart bridge, disconnect restores exact original bytes", t => {
const { p, select, disconnect } = fixture(t)
select()
assert.equal(syncBridge(p), "connected")
let cfg = parse(fs.readFileSync(p.config, "utf8"))
assert.equal(cfg.default_model, "magpie-agent/vendor/model-v1")
assert.equal(cfg.providers.length, 2)
assert.deepEqual(cfg.providers[0], parse(originalConfig).providers[0])
assert.equal(cfg.providers[1].model_overrides["vendor/model-v1"].vision, true)
assert.deepEqual(cfg.desktop.provider_access, ["mine", PROVIDER])
const env = parseEnv(fs.readFileSync(p.env))
assert.equal(env.MY_API_KEY, "fixture-original")
assert.equal(env[KEY], "fixture-gateway-key")
assert.ok(!fs.readFileSync(p.config, "utf8").includes("fixture-gateway-key"))
if (process.platform !== "win32") {
for (const file of [p.state, p.control, p.config, p.env]) {
if (file === p.control) continue // Magpie owns that file's permissions.
assert.equal(fs.statSync(file).mode & 0o777, 0o600)
}
}
const before = fs.statSync(p.config).mtimeMs
assert.equal(syncBridge(p), "connected")
assert.equal(fs.statSync(p.config).mtimeMs, before)
select("vendor/model-v2", "fixture-key-2")
assert.equal(syncBridge(p), "connected")
cfg = parse(fs.readFileSync(p.config, "utf8"))
assert.equal(cfg.default_model, "magpie-agent/vendor/model-v2")
assert.equal(cfg.providers.length, 2)
disconnect()
assert.equal(syncBridge(p), "disconnected")
assert.equal(fs.readFileSync(p.config, "utf8"), originalConfig)
assert.equal(fs.readFileSync(p.env, "utf8"), originalEnv)
assert.ok(!fs.existsSync(p.state))
})
test("first installation and disconnect leave originally absent files absent", t => {
const { p, select, disconnect } = fixture(t)
fs.unlinkSync(p.config)
fs.unlinkSync(p.env)
select()
syncBridge(p)
disconnect()
syncBridge(p)
assert.ok(!fs.existsSync(p.config))
assert.ok(!fs.existsSync(p.env))
})
test("unrelated edits during connection survive switching and disconnect", t => {
const { p, select, disconnect } = fixture(t)
select()
syncBridge(p)
const cfg = parse(fs.readFileSync(p.config, "utf8"))
cfg.language = "zh"
fs.writeFileSync(p.config, stringify(cfg))
fs.appendFileSync(p.env, "NEW_SECRET=fixture-new\n")
select("p/new")
syncBridge(p)
disconnect()
syncBridge(p)
assert.equal(parse(fs.readFileSync(p.config, "utf8")).language, "zh")
assert.equal(parseEnv(fs.readFileSync(p.env)).NEW_SECRET, "fixture-new")
assert.equal(parseEnv(fs.readFileSync(p.env)).MY_API_KEY, "fixture-original")
assert.ok(!Object.hasOwn(parseEnv(fs.readFileSync(p.env)), KEY))
})
test("manual default and key edits are not overwritten", t => {
const { p, select, disconnect } = fixture(t)
select()
syncBridge(p)
const cfg = parse(fs.readFileSync(p.config, "utf8"))
cfg.default_model = "mine/other"
fs.writeFileSync(p.config, stringify(cfg))
fs.appendFileSync(p.env, `${KEY}=manual-key\n`)
assert.throws(() => syncBridge(p), /Default model was edited/)
disconnect()
syncBridge(p)
assert.equal(parse(fs.readFileSync(p.config, "utf8")).default_model, "mine/other")
assert.equal(parseEnv(fs.readFileSync(p.env))[KEY], "manual-key")
})
test("a conflicting provider is refused without writes", t => {
const { p, select } = fixture(t)
fs.writeFileSync(p.config, `[[providers]]\nname="${PROVIDER}"\nmodels=["manual"]\n`)
const before = fs.readFileSync(p.config, "utf8")
select()
assert.throws(() => syncBridge(p), /already exists/)
assert.equal(fs.readFileSync(p.config, "utf8"), before)
assert.equal(fs.readFileSync(p.env, "utf8"), originalEnv)
})
test("existing bridge-named credentials and references are never taken over", t => {
const { p, select } = fixture(t)
select()
const conflict = originalEnv + `${KEY}=fixture-user-key\n`
fs.writeFileSync(p.env, conflict)
assert.throws(() => syncBridge(p), /credential name already belongs/)
assert.equal(fs.readFileSync(p.config, "utf8"), originalConfig)
assert.equal(fs.readFileSync(p.env, "utf8"), conflict)
fs.writeFileSync(p.env, originalEnv)
const cfg = parse(originalConfig)
cfg.providers[0].api_key_env = KEY
const referenced = stringify(cfg)
fs.writeFileSync(p.config, referenced)
assert.throws(() => syncBridge(p), /credential name already belongs/)
assert.equal(fs.readFileSync(p.config, "utf8"), referenced)
assert.equal(fs.readFileSync(p.env, "utf8"), originalEnv)
})
test("invalid TOML and incomplete connection do not touch configuration or credentials", t => {
const { p, select } = fixture(t)
select()
fs.writeFileSync(p.config, "default_model = [broken")
assert.throws(() => syncBridge(p))
assert.equal(fs.readFileSync(p.env, "utf8"), originalEnv)
assert.ok(!fs.existsSync(p.state))
fs.writeFileSync(p.config, originalConfig)
fs.writeFileSync(p.control, JSON.stringify({ baseURL: "http://localhost/v1" }))
assert.throws(() => syncBridge(p), /Incomplete/)
assert.equal(fs.readFileSync(p.config, "utf8"), originalConfig)
})
test("interrupted journal recovers, but external edits stop recovery before writes", t => {
const { p, select } = fixture(t)
select()
syncBridge(p)
const state = JSON.parse(fs.readFileSync(p.state, "utf8"))
const nextEnv = state.lastEnv + "EXTRA=ok\n"
const pending = { state: { ...state, lastEnv: nextEnv }, changes: [{ file: p.env, before: state.lastEnv, after: nextEnv }, { file: p.config, before: state.originalConfig, after: state.lastConfig }] }
fs.writeFileSync(p.state + ".pending", JSON.stringify(pending))
fs.writeFileSync(p.env, nextEnv)
syncBridge(p)
assert.ok(!fs.existsSync(p.state + ".pending"))
fs.writeFileSync(p.state + ".pending", JSON.stringify(pending))
fs.writeFileSync(p.config, "language='changed'\n")
assert.throws(() => syncBridge(p), /recovery paused/)
assert.equal(fs.readFileSync(p.config, "utf8"), "language='changed'\n")
})
test("symlinked target is refused", { skip: process.platform === "win32" }, t => {
const { p, select } = fixture(t)
fs.renameSync(p.config, p.config + ".real")
fs.symlinkSync(p.config + ".real", p.config)
select()
assert.throws(() => syncBridge(p), /non-regular/)
assert.equal(fs.readFileSync(p.config + ".real", "utf8"), originalConfig)
})
test("polling bridge follows selection and shuts down cleanly", async t => {
const { p, select, disconnect } = fixture(t)
let errors = 0
const stop = startBridge(p, { interval: 20, onError: () => errors++ })
t.after(stop)
select()
await new Promise(resolve => setTimeout(resolve, 80))
assert.equal(parse(fs.readFileSync(p.config, "utf8")).default_model, "magpie-agent/vendor/model-v1")
disconnect()
await new Promise(resolve => setTimeout(resolve, 80))
assert.equal(fs.readFileSync(p.config, "utf8"), originalConfig)
assert.equal(errors, 0)
})
test("normal host exit flushes a disconnect and leaves an active connection configured", t => {
const plugin = new URL("./index.mjs", import.meta.url).href
for (const disconnect of [true, false]) {
const home = fs.mkdtempSync(path.join(os.tmpdir(), "deepzora-host-exit-"))
t.after(() => fs.rmSync(home, { recursive: true, force: true }))
const dir = path.join(home, ".deepzora")
fs.mkdirSync(dir)
const config = path.join(dir, "config.toml")
const envFile = path.join(dir, ".env")
const control = path.join(dir, "magpie-agent.json")
fs.writeFileSync(config, originalConfig)
fs.writeFileSync(envFile, originalEnv)
fs.writeFileSync(control, JSON.stringify({ model: "fixture/model", baseURL: "http://127.0.0.1:3425/v1", gatewayKey: "fixture-assigned-key" }))
const result = spawnSync(process.execPath, ["--input-type=module", "-e", `
import fs from "node:fs";
import plugin from ${JSON.stringify(plugin)};
await plugin();
${disconnect ? `fs.writeFileSync(${JSON.stringify(control)}, "{}");` : ""}
process.exit(0);
`], { env: { ...process.env, HOME: home, USERPROFILE: home }, timeout: 10000, encoding: "utf8" })
assert.equal(result.status, 0, result.stderr)
if (disconnect) {
assert.equal(fs.readFileSync(config, "utf8"), originalConfig)
assert.equal(fs.readFileSync(envFile, "utf8"), originalEnv)
} else {
assert.equal(parse(fs.readFileSync(config, "utf8")).default_model, "magpie-agent/fixture/model")
assert.equal(parseEnv(fs.readFileSync(envFile))[KEY], "fixture-assigned-key")
}
}
})
+22
View File
@@ -0,0 +1,22 @@
import { pathsFor, startBridge, syncBridge } from "./bridge.mjs"
const instance = Symbol.for("magpie.deepzora.bridge.v1")
// The Agent entry runs in moejs; this companion runs in the shared Bun host
// because current Magpie cannot edit TOML and a separate dotenv file there.
export default async function DeepzoraBridgePlugin() {
if (!globalThis[instance]) {
const paths = pathsFor()
const stop = startBridge(paths)
globalThis[instance] = { stop }
// Magpie restores the control JSON before closing the host on disable or
// removal. Flush it synchronously on normal exit, without taking over the
// shared host's signals or terminating other plugins.
process.once("exit", () => {
try { syncBridge(paths) } catch {
console.error("Deepzora bridge restoration paused; configuration and recovery files retained.")
}
})
}
return {}
}
File diff suppressed because one or more lines are too long
+67
View File
@@ -0,0 +1,67 @@
// Exercise normal plugin disable in a real resident Magpie host. No accounts,
// real agent configuration, or inference requests are used.
import assert from "node:assert/strict"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import net from "node:net"
import { spawn, execFile } from "node:child_process"
import { promisify } from "node:util"
import { fileURLToPath } from "node:url"
import { parseTOML } from "./vendor.mjs"
const exec = promisify(execFile)
const root = fs.mkdtempSync(path.join(os.tmpdir(), "deepzora-resident-"))
const repo = path.resolve(fileURLToPath(new URL(".", import.meta.url)))
const magpie = process.env.MAGPIE_BIN || "magpie"
const probe = net.createServer()
await new Promise(resolve => probe.listen(0, "127.0.0.1", resolve))
const port = probe.address().port
await new Promise(resolve => probe.close(resolve))
const addr = `127.0.0.1:${port}`
const env = { ...process.env, HOME: root, USERPROFILE: root, XDG_CONFIG_HOME: path.join(root, ".config"), XDG_CACHE_HOME: path.join(root, ".cache"), XDG_STATE_HOME: path.join(root, ".state"), DEEPZORA_HOME: path.join(root, ".deepzora"), DEEPZORA_STATE_HOME: path.join(root, ".deepzora-state"), MAGPIE_NO_ACCOUNTS: "1", MAGPIE_ADDR: addr }
const dir = env.DEEPZORA_HOME
const config = path.join(dir, "config.toml")
const credentials = path.join(dir, ".env")
const original = '# resident fixture\ndefault_model = "mine/model"\n'
const run = args => exec(magpie, args, { cwd: root, env, timeout: 120000, maxBuffer: 2 << 20 })
const until = async predicate => {
const deadline = Date.now() + 20000
while (Date.now() < deadline) {
if (await predicate()) return
await new Promise(resolve => setTimeout(resolve, 100))
}
throw new Error("Resident Magpie did not complete the expected state transition")
}
let child
let closed
try {
fs.mkdirSync(dir, { recursive: true })
fs.mkdirSync(path.join(env.XDG_CONFIG_HOME, "magpie"), { recursive: true })
fs.writeFileSync(config, original)
fs.writeFileSync(credentials, "OTHER_KEY=fixture-original\n")
fs.writeFileSync(path.join(env.XDG_CONFIG_HOME, "magpie/providers.json"), JSON.stringify({ providers: [{ id: "fixture", name: "Fixture", key: "fixture-only", chat: "http://127.0.0.1:9/v1", models: ["model"] }] }))
await run(["plugin", "add", repo])
await run(["deepzora", "fixture/model"])
child = spawn(magpie, ["serve"], { cwd: root, env, stdio: "ignore" })
closed = new Promise(resolve => child.once("exit", resolve))
await until(async () => {
try { return (await fetch(`http://${addr}/api/hello`, { signal: AbortSignal.timeout(500) })).ok } catch { return false }
})
await fetch(`http://${addr}/v1/models`, { signal: AbortSignal.timeout(10000) })
await until(() => parseTOML(fs.readFileSync(config, "utf8")).default_model === "magpie-agent/fixture/model")
await run(["plugin", "off", repo])
// Refreshing the catalog observes plugins.json and closes the old host.
await fetch(`http://${addr}/v1/models`, { signal: AbortSignal.timeout(10000) })
await until(() => fs.readFileSync(config, "utf8") === original)
assert.equal(fs.readFileSync(credentials, "utf8"), "OTHER_KEY=fixture-original\n")
console.log("PASS: disabling the plugin with resident Magpie restores TOML and credentials without a manual sync")
} finally {
if (child && child.exitCode === null) {
child.kill("SIGTERM")
const timer = setTimeout(() => child.kill("SIGKILL"), 3000)
await closed
clearTimeout(timer)
}
fs.rmSync(root, { recursive: true, force: true })
}
+3
View File
@@ -0,0 +1,3 @@
// Regenerate vendor.mjs with Bun 1.4.4; see THIRD_PARTY.md.
export { parse as parseTOML, stringify } from "smol-toml"
export { parse as parseEnv } from "dotenv"
+255
View File
@@ -0,0 +1,255 @@
import{createRequire as _e}from"node:module";var ke=Object.create;var{getPrototypeOf:De,defineProperty:pe,getOwnPropertyNames:$e}=Object;var de=Object.prototype.hasOwnProperty;function Se(e){return this[e]}var Ie,Ne,qe=(e,r,i)=>{var o=e!=null&&typeof e==="object";if(o){var l=r?Ie??=new WeakMap:Ne??=new WeakMap,n=l.get(e);if(n)return n}i=e!=null?ke(De(e)):{};let t=r||!e||!e.__esModule||!de.call(e,"default")?pe(i,"default",{value:e,enumerable:!0}):i;if(e&&typeof e==="object"||typeof e==="function"){for(let f of $e(e))if(!de.call(t,f))pe(t,f,{get:Se.bind(e,f),enumerable:!0})}if(o)l.set(e,t);return t};var Pe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var P=_e(import.meta.url);var Oe=Pe(function(kr,Q){var ne=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(i){throw r=0,i}},ye=ne((e,r)=>{function i(l){return typeof l=="string"?!["false","0","no","off",""].includes(l.toLowerCase()):!!l}function o(l=process.env){let n={};for(let t of["ENCODING","PATH","QUIET","DEBUG","OVERRIDE","FAST"]){let f=l[`DOTENV_${t}`]!=null?l[`DOTENV_${t}`]:l[`DOTENV_CONFIG_${t}`];f!=null&&(n[t.toLowerCase()]=t==="ENCODING"||t==="PATH"?f:i(f))}return n}r.exports={parseBoolean:i,optionsFromEnv:o}}),Ee=ne((e,r)=>{var i=P("fs"),o=P("path"),l=P("os"),{URL:n,fileURLToPath:t}=P("url"),{parseBoolean:f,optionsFromEnv:v}=ye(),h=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg,p=new Uint8Array(256);for(let s=48;s<=57;s++)p[s]=1;for(let s=65;s<=90;s++)p[s]=1;for(let s=97;s<=122;s++)p[s]=1;p[45]=1,p[46]=1,p[95]=1;function c(s){let g={},a=s.toString();a=a.replace(/\r\n?/mg,`
`);let C;for(;(C=h.exec(a))!=null;){let u=C[1],y=C[2]||"";y=y.trim();let E=y[0];y=y.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),E==='"'&&(y=y.replace(/\\n/g,`
`),y=y.replace(/\\r/g,"\r")),g[u]=y}return g}function m(s){return s<=32?s===32||s>=9&&s<=13:s>=160&&(s===160||s===5760||s>=8192&&s<=8202||s===8232||s===8233||s===8239||s===8287||s===12288||s===65279)}function b(s){return s===10||s===8232||s===8233}function k(s){let g={},a=typeof s=="string"?s:s.toString();a.indexOf("\r")!==-1&&(a=a.replace(/\r\n?/g,`
`));let C=a.length,u=0;for(;u<C;){let y=a.charCodeAt(u);for(;u<C&&m(y);)u++,y=a.charCodeAt(u);if(u>=C)break;if(y===35){for(;u<C&&!b(a.charCodeAt(u));)u++;continue}let E=-1;if(y===101&&u+6<C&&a.charCodeAt(u+1)===120&&a.charCodeAt(u+2)===112&&a.charCodeAt(u+3)===111&&a.charCodeAt(u+4)===114&&a.charCodeAt(u+5)===116){let U=a.charCodeAt(u+6);if(m(U)){let O=u+7;for(;O<C&&m(a.charCodeAt(O));)O++;p[a.charCodeAt(O)]&&(E=u+6,u=O)}else y=a.charCodeAt(u)}let H=u,G=0;for(;u<C&&(G=a.charCodeAt(u),p[G]);)u++;if(u===H){for(;u<C&&!b(a.charCodeAt(u));)u++;continue}let oe=a.slice(H,u),ee=u;if(u>=C&&(G=0),m(G))do u++,G=u<C?a.charCodeAt(u):0;while(m(G));if(G===61)u++;else if(G===58&&u===ee&&u+1<C&&m(a.charCodeAt(u+1)))u+=2;else{for(u=E===-1?ee:E;u<C&&!b(a.charCodeAt(u));)u++;continue}let L=u,N=u;for(;N<C&&m(a.charCodeAt(N));)N++;let z=a.charCodeAt(N),q,le=!1;if(z===39||z===34||z===96){let U=a[N],O=a.indexOf(U,N+1),j=-1,B=-1;for(;O!==-1;){let K=a.charCodeAt(O-1)===92,Z=O+1;for(;Z<C&&!b(a.charCodeAt(Z))&&m(a.charCodeAt(Z));)Z++;if((Z===C||b(a.charCodeAt(Z))||a.charCodeAt(Z)===35)&&(j=O,B=Z),!K)break;O=a.indexOf(U,O+1)}if(j!==-1){if(q=a.slice(N+1,j),u=B,a.charCodeAt(u)===35)for(;u<C&&!b(a.charCodeAt(u));)u++;le=!0}}if(!le){let U=a.indexOf(`
`,L);U===-1&&(U=C);let O;if(C<4096)O=a.indexOf("#",L),(O===-1||O>U)&&(O=U);else for(O=L;O<U&&a.charCodeAt(O)!==35;)O++;let j=L,B=O;for(;j<B&&m(a.charCodeAt(j));)j++;for(;B>j&&m(a.charCodeAt(B-1));)B--;let K=a.charCodeAt(j);if(q=a.slice(j,B),q.includes("\u2028")||q.includes("\u2029")?q=q.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"):B-j>=2&&(K===39||K===34||K===96)&&a.charCodeAt(B-1)===K&&(q=a.slice(j+1,B-1)),u=O,O<U)for(;u<C&&!b(a.charCodeAt(u));)u++}z===34&&(le||N<u)&&q.indexOf("\\")!==-1&&(q=q.replace(/\\n/g,`
`).replace(/\\r/g,"\r")),g[oe]=q}return g}function A(s,g){return g&&f(g.fast)?k(s):c(s)}function T(s){console.log(`┆ ${s}`)}function w(s){console.error(`◇ ${s}`)}function S(s){return s[0]==="~"?o.join(l.homedir(),s.slice(1)):s}function V(s={}){let g={...s};for(let a of Object.keys(g))g[a]===void 0&&delete g[a];return{...v(),...g}}function M(s){s=V(s);let g=o.resolve(process.cwd(),".env"),a="utf8",C=process.env;s&&s.processEnv!=null&&(C=s.processEnv);let u=f(s&&s.debug);s&&s.encoding?a=s.encoding:u&&T("no encoding is specified (UTF-8 is used by default)");let y=[g];if(s&&s.path)if(!Array.isArray(s.path))y=[S(s.path)];else{y=[];for(let L of s.path)y.push(S(L))}let E,H={},G={fast:s.fast};for(let L of y)try{let N=I.parse(i.readFileSync(L,{encoding:a}),G);I.populate(H,N,s)}catch(N){u&&T(`failed to load ${L} ${N.message}`),E=N}let oe=I.populate(C,H,s),ee=f(Object.prototype.hasOwnProperty.call(s,"quiet")?s.quiet:v(C).quiet);if(u||!ee){let L=Object.keys(oe).length,N=[];for(let z of y)try{let q=o.relative(process.cwd(),z instanceof n?t(z):z);N.push(q)}catch(q){u&&T(`failed to load ${z} ${q.message}`),E=q}w(`injected env (${L}) from ${N.join(",")}`)}return E?{parsed:H,error:E}:{parsed:H}}function D(s){return I.configDotenv(s)}function F(s,g,a={}){let C=f(a&&a.debug),u=f(a&&a.override),y={};if(s===null||typeof s!="object"||g===null||typeof g!="object"){let E=Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw E.code="OBJECT_REQUIRED",E}for(let E of Object.keys(g))Object.prototype.hasOwnProperty.call(s,E)?(u===!0&&(s[E]=g[E],y[E]=g[E]),C&&T(u===!0?`"${E}" is already defined and WAS overwritten`:`"${E}" is already defined and was NOT overwritten`)):(s[E]=g[E],y[E]=g[E]);return y}var I={configDotenv:M,config:D,parse:A,populate:F};r.exports.configDotenv=I.configDotenv,r.exports.config=I.config,r.exports.parse=I.parse,r.exports.populate=I.populate,r.exports=I}),He=ne((e,r)=>{var i=P("child_process"),o=P("fs"),l=P("path");function n(p){let c=['"'],m=0;for(let b of p){if(b==="\\"){m++;continue}b==='"'?c.push("\\".repeat(m*2+1),'"'):c.push("\\".repeat(m),b),m=0}return c.push("\\".repeat(m*2),'"'),c.join("")}function t(p,c=1){for(let m=0;m<c;m++){let b=[];for(let k of p){let A=k.charCodeAt(0),T=A>=48&&A<=57||A>=65&&A<=90||A>=97&&A<=122,w="\\/:._-".includes(k);!T&&!w&&A<128&&b.push("^"),b.push(k)}p=b.join("")}return p}function f(p,c){let m=Object.keys(p).reverse().find((b)=>b.toUpperCase()===c);return m===void 0?void 0:p[m]}function v(p,c,m){let b=(f(c,"PATHEXT")||".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean),k=b.some((T)=>p.toLowerCase().endsWith(T.toLowerCase()))?["",...b]:[...b,""],A=/[\\/]/.test(p)?[m]:[m,...(f(c,"PATH")||"").split(";")];for(let T of A)for(let w of k){let S=l.resolve(m,T.replace(/^"|"$/g,""),p+w);try{if(o.statSync(S).isFile())return S}catch{}}}function h(p,c,m){if(process.platform!=="win32")return i.spawn(p,c,m);let b=m.env||process.env,k=v(p,b,m.cwd||process.cwd());if(k&&/\.(?:exe|com)$/i.test(k))return i.spawn(k,c,m);let A=/\.(?:bat|cmd)$/i.test(k||p),T=[t(l.normalize(k||p))];for(let S of c)T.push(t(n(S),A?2:1));let w=T.join(" ");return i.spawn(f(b,"COMSPEC")||"cmd.exe",["/d","/v:off","/s","/c",`"${w}"`],{...m,windowsVerbatimArguments:!0})}r.exports=h}),Ke=ne((e,r)=>{var i=P("fs"),o=P("os"),l=P("path"),n=P("child_process"),t=He(),f=Ee(),{optionsFromEnv:v}=ye();function h(){console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]","","Run a command with environment variables from a .env file.","Place dotenv options before the command; all following arguments go to the command.","","Options:"," -f, --file <paths> .env paths, comma-separated or repeated (default: .env)"," -q, --quiet suppress the injected env message"," --debug enable debug logging"," --override override existing environment variables"," --fast use the faster character-scanner parser","","Environment variables (DOTENV_CONFIG_* names remain as fallbacks):"," DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,"," DOTENV_DEBUG, DOTENV_OVERRIDE,"," DOTENV_FAST"].join(`
`))}function p(A){let T=[],w=!1,S,V,M,D,F=-1;for(let s=0;s<A.length;s++){let g=A[s];if(g==="--"){F=s+1;break}if(g==="--help"||g==="-h")return{help:!0};if(g==="--quiet"||g==="-q"){S=!0;continue}if(g==="--debug"){V=!0;continue}if(g==="--override"){M=!0;continue}if(g==="--fast"){D=!0;continue}if(g==="-f"||g==="--file"||g.startsWith("-f=")||g.startsWith("--file=")){let a=g.indexOf("="),C=a===-1?g:g.slice(0,a),u=a===-1?A[++s]:g.slice(a+1);if(!u||u==="--")return{error:`${C} requires a path`};let y=u.split(",").map((E)=>E.trim()).filter(Boolean);if(y.length===0)return{error:`${C} requires a path`};T.push(...y),w=!0;continue}if(g.startsWith("-"))return{error:`unknown option: ${g}`};F=s;break}let I=F===-1?[]:A.slice(F);return{paths:T,pathSet:w,quiet:S,debug:V,override:M,fast:D,command:I}}function c(A){return A[0]==="~"?l.join(o.homedir(),A.slice(1)):A}function m(A){let T=v(),w={encoding:T.encoding||"utf8",quiet:T.quiet,debug:T.debug===!0,override:T.override===!0,fast:T.fast===!0,paths:[".env"],defaultPath:!0};return T.path&&(w.paths=[T.path],w.defaultPath=!1),A.pathSet&&(w.paths=A.paths,w.defaultPath=!1),A.quiet!=null&&(w.quiet=A.quiet),A.debug!=null&&(w.debug=A.debug),A.override!=null&&(w.override=A.override),A.fast!=null&&(w.fast=A.fast),w}function b(A){let T={},w=[],S={override:A.override,debug:A.debug};for(let V of A.paths){let M=l.resolve(process.cwd(),c(V));try{let D=f.parse(i.readFileSync(M,{encoding:A.encoding}),{fast:A.fast});f.populate(T,D,S),w.push(V)}catch(D){if(A.debug&&console.log(`┆ failed to load ${V} ${D.message}`),!(A.defaultPath&&D.code==="ENOENT"))throw D}}return{injected:f.populate(process.env,T,S),loadedPaths:w}}function k(A){let T=A[0];if(T==="--help"||T==="-h"){h();return}if(T!=="run"){h(),process.exitCode=1;return}let w=p(A.slice(1));if(w.help){h();return}if(w.error){console.error(`dotenv: ${w.error}`),h(),process.exitCode=1;return}if(w.command.length===0){h(),process.exitCode=1;return}let S=m(w);try{let a=b(S);if(!(S.quiet==null?v().quiet:S.quiet)){let C=`◇ injected env (${Object.keys(a.injected).length})`;a.loadedPaths.length>0&&(C+=` from ${a.loadedPaths.join(", ")}`),console.error(C)}}catch(a){console.error(`dotenv: ${a.message}`),process.exitCode=1;return}let V=!!process.stdin.isTTY,M=process.platform!=="win32"&&!V,D=t(w.command[0],w.command.slice(1),{stdio:"inherit",detached:M}),F=new Map,I=0;function s(a){if(!(!D.pid||D.exitCode!==null||D.signalCode!==null)){if(process.platform==="win32"){n.spawnSync("taskkill",["/pid",String(D.pid),"/T","/F"],{stdio:"ignore"});return}try{process.kill(M?-D.pid:D.pid,a)}catch(C){if(C.code!=="ESRCH")throw C}}}function g(){for(let[a,C]of F)process.removeListener(a,C)}for(let a of["SIGINT","SIGTERM","SIGHUP","SIGQUIT"]){let C=()=>{if(a==="SIGINT"){if(I++,V&&process.platform!=="win32"&&I===1)return;if(I>1){s(I===2?"SIGTERM":"SIGKILL");return}}s(a)};F.set(a,C),process.on(a,C)}D.on("error",function(a){g(),console.error(`dotenv: ${a.message}`),process.exitCode=1}),D.on("exit",function(a,C){g(),typeof a=="number"?process.exit(a):(setInterval(()=>{},1000),process.kill(process.pid,C))})}r.exports=k,r===P.main&&k(process.argv.slice(2))}),X=Ee(),Or=Ke();Q.exports=X;Q.exports.config=X.config;Q.exports.configDotenv=X.configDotenv;Q.exports.parse=X.parse;Q.exports.populate=X.populate});/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/function je(e,r){let i=e.slice(0,r).split(/\r?\n/);return[i.length,i.pop().length+1]}function Ve(e,r,i){let o=e.split(/\r?\n/),l="",n=(Math.log10(r+1)|0)+1;for(let t=r-1;t<=r+1;t++){let f=o[t-1];if(!f)continue;if(l+=t.toString().padEnd(n," "),l+=": ",l+=f,l+=`
`,t===r)l+=" ".repeat(n+i+2),l+=`^
`}return l}class d extends Error{line;column;codeblock;constructor(e,r){let[i,o]=je(r.toml,r.ptr),l=Ve(r.toml,i,o);super(`Invalid TOML document: ${e}
${l}`,r);this.line=i,this.column=o,this.codeblock=l}static x(e,r,i){throw new d(e,{toml:r.s,ptr:i??r.p})}}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/function re(e){let r=e.p,i=e.s.charCodeAt(e.p++),o=i,l=i===39,n=i===e.s.charCodeAt(e.p)&&i===e.s.charCodeAt(e.p+1);if(n){if((i=e.s.charCodeAt(e.p+=2))===10)e.p++;else if(i===13&&e.s.charCodeAt(e.p+1)===10)e.p+=2}let t="",f=e.p,v=0;for(;e.p<e.s.length;e.p++)if(i=e.s.charCodeAt(e.p),n&&(i===10||i===13&&e.s.charCodeAt(e.p+1)===10))v=v&&3;else if(i<32&&i!==9||i===127)d.x("control characters are not allowed in strings",e);else if((!v||v===3)&&i===o&&(!n||e.s.charCodeAt(e.p+1)===o&&e.s.charCodeAt(e.p+2)===o)){if(n){if(e.s.charCodeAt(e.p+3)===o)e.p++;if(e.s.charCodeAt(e.p+3)===o)e.p++}if(!v){let h=e.s.slice(f,e.p);t=t?t+h:h}return e.p+=n?3:1,t}else if(!v){if(!l&&i===92)t+=e.s.slice(f,f=e.p),v=1}else if(v===1)if(i===120||i===117||i===85){let h=e.p++-1,p=0,c=i===120?2:i===117?4:8;for(let m=0;m<c;m++,e.p++){let b=e.s.charCodeAt(e.p),k=b>=48&&b<=57?b-48:b>=65&&b<=70?b-65+10:b>=97&&b<=102?b-97+10:-1;if(k<0)d.x("invalid non-hex character in unicode escape",e);p=p<<4|k}if(p<0||p>1114111||p>=55296&&p<=57343)d.x("invalid unicode escape",e,h);t+=String.fromCodePoint(p),f=e.p--,v=0}else if(n&&(i===32||i===9))v=2;else{if(i===98)t+="\b";else if(i===116)t+="\t";else if(i===110)t+=`
`;else if(i===102)t+="\f";else if(i===114)t+="\r";else if(i===101)t+="\x1B";else if(i===34)t+='"';else if(i===92)t+="\\";else d.x("unrecognised escape sequence",e);f=e.p+1,v=0}else if(i!==32&&i!==9){if(v===2)d.x("invalid escape: only line-ending whitespace may be escaped",e,f);v=!l&&i===92?1:0,f=e.p}d.x("unfinished string",e,r)}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/var Le=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class W extends Date{#r=!1;#t=!1;#e=null;constructor(e,r,i){let o=!0,l=!0,n="Z",t;if(typeof e==="string")if(r)e:{if(r<3){if(+e.slice(11,13)>23){e="";break e}if(r===2)n=null,e+="Z";else if((t=e.charCodeAt(e.length-1))!==90&&t!==122)n=e.slice(e.length-6);if(i)e=e.slice(0,10)+"T"+e.slice(11)}else if(r===4)e=+e.slice(0,2)>23?"":`0000-01-01T${e}Z`;o=r!==4,l=r!==3}else{let f=e.match(Le);if(f){if(!f[1])o=!1,e=`0000-01-01T${e}`;if(l=!!f[2],l&&e[10]===" "&&(e=e.replace(" ","T")),f[2]&&+f[2]>23)e="";else if(n=f[3]||null,!n&&l)e+="Z"}else e=""}super(e);if(!isNaN(this.getTime()))this.#r=o,this.#t=l,this.#e=n}isDateTime(){return this.#r&&this.#t}isLocal(){return!this.#r||!this.#t||!this.#e}isDate(){return this.#r&&!this.#t}isTime(){return this.#t&&!this.#r}isValid(){return this.#r||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#e===null)return e.slice(0,-1);if(this.#e==="Z"||this.#e==="z")return e;let r=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return r=this.#e[0]==="-"?r:-r,new Date(this.getTime()-r*60000).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(e,r="Z"){let i=new W(e);return i.#e=r,i}static wrapAsLocalDateTime(e){let r=new W(e);return r.#e=null,r}static wrapAsLocalDate(e){let r=new W(e);return r.#t=!1,r.#e=null,r}static wrapAsLocalTime(e){let r=new W(e);return r.#r=!1,r.#e=null,r}}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/function _(e,r=10){return r===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+r}function ae(e,r){return e===32||e===9||e===10||e===13||r&&(e===r||e===44)||e===35}function Y(e,r){let i=e.p,o=e.s.charCodeAt(e.p);if(o===91||o===123){e.d--||d.x("document contains excessively nested structures. aborting.",e);let l=o===91?me(e):ce(e);return e.d++,l}if(o===34||o===39)return re(e);if(o===116){if(e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)d.x("invalid value",e,i);return e.p++,!0}if(o===102){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)d.x("invalid value",e,i);return e.p++,!1}if(o===43||o===45)return te(e,e.p,e.s.charCodeAt(++e.p),44-o,r);if(e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45)return Ue(e,o,r);if(e.s.charCodeAt(e.p+2)===58)return Be(e,o,r);return te(e,e.p,o,0,r)}function te(e,r,i,o,l){let n=i,t=0,f=!1;if(n===105){if(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)d.x("invalid value",e,r);return e.p++,(o||1)/0}if(n===110){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)d.x("invalid value",e,r);return e.p++,NaN}if(n===48){if(++e.p>=e.s.length||ae(n=e.s.charCodeAt(e.p),l))return e.bi===!0?0n:0;if(!o){if(n===120)return se(e,r,16,l);else if(n===98)return se(e,r,2,l);else if(n===111)return se(e,r,8,l)}if(n===46)t=2;else if(n===101||n===69)t=4;else d.x("illegal leading zero",e,r)}else if(!_(n))d.x("invalid value",e,r);while(++e.p<e.s.length&&(n=e.s.charCodeAt(e.p),!ae(n,l))){if(!t)t=1;if(n===95){if(!(t&1))d.x("illegal underscore",e);t+=11,f=!0}else if(t===1&&n===46)t=2;else if((t===1||t===3)&&(n===101||n===69))t=4;else if(t===4&&(n===43||n===45))t=6;else if(!_(n))d.x("illegal character in numeric literal",e);else if(t>9)t-=11;else if(!(t&1))t++}if(!t){let h=(i-48)*(o||1);return e.bi===!0?BigInt(h):h}if(!(t&1))d.x("unfinished numeric value",e,r);let v=e.s.slice(r,e.p);if(f)v=v.replaceAll("_","");return t>1?parseFloat(v):he(e,v,10,r)}function se(e,r,i,o){let l,n=1;while(++e.p<e.s.length&&(l=e.s.charCodeAt(e.p),!ae(l,o)))if(l===95){if(n&1)d.x("illegal underscore",e);n=3}else if(!_(l,i))d.x("illegal character in numeric literal",e);else if(n&1)n--;if(n&1)d.x("unfinished numeric value",e);let t=e.s.slice(r+2,e.p);if(n)t=t.replaceAll("_","");return he(e,t,i,r)}function he(e,r,i,o){if(e.bi!==!0)e:{let l=parseInt(r,i);if(!Number.isSafeInteger(l)){if(e.bi)break e;d.x("integer value cannot be represented losslessly",e,o)}return l}return i===10?BigInt(r):BigInt((i===2?"0b":i===8?"0o":"0x")+r)}function Ue(e,r,i){let o=e.p++,l;if(!_(r)||!_(e.s.charCodeAt(e.p++))||!_(e.s.charCodeAt(e.p++))||!_(e.s.charCodeAt(e.p++)))return te(e,e.p=o,r,0,i);if(e.p+=5,!_(e.s.charCodeAt(e.p++)))d.x("invalid date-time: date part is malformed",e,o);if(e.p>=e.s.length||((r=e.s.charCodeAt(e.p))!==32||(l=!0,!_(e.s.charCodeAt(e.p+1))))&&r!==84&&r!==116){let t=e.s.slice(o,e.p);return J(e,t,3,!1,o)}if(e.s.charCodeAt(e.p+=3)!==58)d.x("invalid date-time: time part is malformed",e,o);if(e.s.charCodeAt(e.p+=3)===58)e.p+=3;if(e.s.charCodeAt(e.p)===46)while(_(e.s.charCodeAt(++e.p)));if(r=e.s.charCodeAt(e.p)){if(r===90||r===122){let t=e.s.slice(o,++e.p);return J(e,t,1,l,o,"[+00:00]")}if(r===43||r===45){let t=e.s.slice(o,e.p+=6);return J(e,t,1,l,o,!e.ld&&"["+e.s.slice(e.p-6,e.p)+"]")}}let n=e.s.slice(o,e.p);return J(e,n,2,l,o)}function Be(e,r,i){let o=e.p;if(!_(r)||!_(e.s.charCodeAt(++e.p)))return te(e,--e.p,r,0,i);if(e.s.charCodeAt(e.p+=4)===58)e.p+=3;if(e.s.charCodeAt(e.p)===46)while(_(e.s.charCodeAt(++e.p)));let l=e.s.slice(o,e.p);return J(e,l,4,!1,o)}function J(e,r,i,o,l,n){if(e.ld){let t=new W(r,i,o);if(!t.isValid())d.x("invalid date",e,l);return t}try{if(n)r+=n;switch(i){case 1:return Temporal.ZonedDateTime.from(r);case 2:return Temporal.PlainDateTime.from(r);case 3:return Temporal.PlainDate.from(r);case 4:return Temporal.PlainTime.from(r)}}catch(t){d.x(t instanceof Error?t.message:""+t,e,l)}}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/function Re(e){for(;e.p<e.s.length;e.p++){let r=e.s.charCodeAt(e.p);if(r===10)break;if(r===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}if(r<32&&r!==9||r===127)d.x("control characters are not allowed in comments",e)}}function R(e,r,i){let o;while(e.p<e.s.length){while(e.p<e.s.length&&((o=e.s.charCodeAt(e.p))===32||o===9||!r&&(o===10||o===13&&e.s.charCodeAt(e.p+1)===10)))e.p++;if(i||o!==35)break;Re(e)}}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/function ie(e,r=61){let i,o=0,l=[],n,t=e.s.charCodeAt(i=e.p);do if(t===r){if(!o)d.x("unexpected end of key",e);if(o===1)l.push(e.s.slice(n,e.p));return e.p++,l}else if(t===46){if(!o)d.x("illegal empty bare key",e);if(o===1)l.push(e.s.slice(n,e.p));o=0}else if(!o&&(t===34||t===39)){if(t===e.s.charCodeAt(e.p+1)&&t===e.s.charCodeAt(e.p+2))d.x("illegal quoted key: multiline strings are not allowed",e);l.push(re(e)),o=2,e.p--}else if(t===32||t===9){if(o===1)l.push(e.s.slice(n,e.p)),o=2}else if(o===2||t<48&&t!==45||t>57&&t<65||t>90&&t<97&&t!==95||t>122)d.x("illegal character in key",e);else if(!o)o=1,n=e.p;while(t=e.s.charCodeAt(++e.p));d.x("incomplete key-value: cannot find end of key",e,i)}function ce(e){let r=e.p++,i=Object.create(null),o=new Set,l;while(e.p<e.s.length){if(R(e),(l=e.s.charCodeAt(e.p))===125)return e.p++,i;let n,t=i,f=!1,v=e.p,h=ie(e);for(let c=0;c<h.length;c++){if(c)t=f?t[n]:t[n]=Object.create(null);if(n=h[c],(f=Object.hasOwn(t,n))&&(typeof t[n]!=="object"||o.has(t[n])))d.x("trying to redefine an already defined value",e,v);let m=n==="__proto__";if(e.uk&&(m||n==="constructor")){t=e.uk!==1&&d.x("document contains an unsafe property",e,v);break}if(!f&&m)Object.defineProperty(t,n,{enumerable:!0,configurable:!0,writable:!0})}if(f)d.x("trying to redefine an already defined value",e,v);R(e,!0,!0);let p=Y(e,125);if(t&&typeof(t[n]=p)==="object")o.add(p);if(R(e),(l=e.s.charCodeAt(e.p++))===125)return i;if(l!==44)d.x("expected comma or end of structure",e,e.p-1)}d.x("unfinished table",e,r)}function me(e){let r=e.p++,i=[],o;while(e.p<e.s.length){if(R(e),(o=e.s.charCodeAt(e.p))===93)return e.p++,i;if(i.push(Y(e,93)),R(e),(o=e.s.charCodeAt(e.p++))===93)return i;if(o!==44)d.x("expected comma or end of structure",e,e.p-1)}d.x("unfinished array",e,r)}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/function ge(e,r,i,o,l){let n=i,t=o,f,v=!1,h;for(let p=0;p<r.length;p++){if(p){if(n=v?n[f]:n[f]=Object.create(null),t=(h=t[f]).c,l===0&&(h.t===1||h.t===2))return null;if(h.t===2){let c=n.length-1;n=n[c],t=t[c].c}}if(f=r[p],(v=Object.hasOwn(n,f))&&t[f]?.t===0&&t[f]?.d)return null;if(!v){let c=f==="__proto__";if(e.uk&&(c||f==="constructor"))return!1;if(c)Object.defineProperty(n,f,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(t,f,{enumerable:!0,configurable:!0,writable:!0});t[f]={t:p<r.length-1&&l===2?3:l,d:!1,i:0,c:Object.create(null)}}}if(h=t[f],h.t!==l&&!(l===1&&h.t===3))return null;if(l===2){if(!h.d)h.d=!0,n[f]=[];n[f].push(n=Object.create(null)),h.c[h.i++]=h={t:1,d:!1,i:0,c:Object.create(null)}}if(h.d)return null;if(h.d=!0,l===1)n=v?n[f]:n[f]=Object.create(null);else if(l===0&&v)return null;return[f,n,h.c]}function Ce(e,r,i){if(r===null||e.uk===2)d.x(r===null?"trying to redefine an already defined table or value":"document contains an unsafe property",e,i)}function Ae(e,r={}){let i={s:e,p:0,d:r.maxDepth??1000,bi:r.integersAsBigInt??!1,ld:r.useLegacyDate??!0,uk:r.unsafeKeyBehaviour==="throw"?2:r.unsafeKeyBehaviour==="drop"?1:0},o=Object.create(null),l=Object.create(null),n,t=!1,f=o,v=l;if(e.charCodeAt(0)===65279)i.p++;R(i);while(i.p<e.length){if(e.charCodeAt(i.p)===91){let h=e.charCodeAt(++i.p)===91;n=i.p+=+h,t=!1;let p=ie(i,93);if(h){if(e.charCodeAt(i.p)!==93)d.x("expected end of table array declaration",i);i.p++}let c=ge(i,p,o,l,h?2:1);if(!c)Ce(i,c,n),t=!0;else v=c[2],f=c[1]}else{n=i.p;let h=ie(i),p=ge(i,h,f,v,0);if(!p&&!t)Ce(i,p,n);R(i,!0,!0);let c=Y(i,void 0);if(p&&!t)p[1][p[0]]=c}if(R(i,!0),i.p<e.length&&(n=e.charCodeAt(i.p))!==10&&(n!==13||e.charCodeAt(i.p+1)!==10))d.x("each key-value declaration must be followed by an end-of-line",i);R(i)}return o}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/var Ge=/^[a-z0-9-_]+$/i,ve=!!"".isWellFormed;function x(e){let r=typeof e;if(r==="object"){if(Array.isArray(e))return"array";if(typeof e.getUTCDate==="function"&&e instanceof Date)return"date";if(globalThis.Temporal){if(e.until){if(e instanceof Temporal.ZonedDateTime)return"temporal/tz+uc";if(e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainDate)return"temporal/uc";if(e instanceof Temporal.PlainTime||e instanceof Temporal.Instant)return"temporal";if(e instanceof Temporal.PlainYearMonth)return"temporal/x"}else if(e.toPlainDate&&e instanceof Temporal.PlainMonthDay||e.negated&&e instanceof Temporal.Duration)return"temporal/x"}}return r}function Me(e){for(let r=0;r<e.length;r++)if(x(e[r])!=="object")return!1;return e.length!=0}function be(e){return JSON.stringify(e).replaceAll("","\\u007f")}function Fe(e){return be(ve?e.toWellFormed():e)}function Te(e){if(Ge.test(e))return e;if(ve&&!e.isWellFormed())throw RangeError("key contains illegal lone surrogates");return be(e)}function fe(e,r,i,o,l){if(i===0)throw Error("Could not stringify the object: maximum object depth exceeded");switch(r){case"number":if(isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Number.isInteger(e)&&(o||!Number.isSafeInteger(e)))return e.toFixed(1);case"bigint":case"boolean":case"temporal":return e.toString();case"string":return Fe(e);case"date":if(isNaN(e.getTime()))throw TypeError("cannot serialize invalid date");return e.toISOString();case"object":return ze(e,i,o,l);case"array":return Ze(e,i,o,l);case"temporal/tz+uc":if(l){let n=e.timeZoneId,t=n.charCodeAt(0);if(t!==43&&t!==45&&(t!==85&&t!==71&&t!==90&&t!==69||n!=="UTC"&&n!=="UCT"&&n!=="Universal"&&n!=="Zulu"&&!n.startsWith("GMT")&&n!=="Greenwich"&&!n.startsWith("Etc/")))throw TypeError("Temporal objects with an IANA timezone are not allowed in Temporal strict mode")}case"temporal/uc":if(l&&e.calendarId!=="iso8601")throw TypeError("Temporal objects with a non-default calendar are not allowed in Temporal strict mode");return e.toString({calendarName:"never",timeZoneName:"never"});case"temporal/x":throw TypeError("Unsupported "+e[Symbol.toStringTag])}}function ze(e,r,i,o){let l=Object.keys(e);if(l.length===0)return"{}";let n="{ ";for(let t=0;t<l.length;t++){let f=l[t];if(t)n+=", ";n+=Te(f)+" = "+fe(e[f],x(e[f]),r-1,i,o)}return n+" }"}function Ze(e,r,i,o){if(e.length===0)return"[]";let l="[ ";for(let n=0;n<e.length;n++){if(n)l+=", ";if(e[n]===null||e[n]===void 0)throw TypeError("arrays cannot contain null or undefined values");l+=fe(e[n],x(e[n]),r-1,i,o)}return l+" ]"}function We(e,r,i,o,l){if(i===0)throw Error("Could not stringify the object: maximum object depth exceeded");let n="";for(let t=0;t<e.length;t++)n+=`${n&&`
`}[[${r}]]
`,n+=ue(0,e[t],r,i,o,l);return n}function ue(e,r,i,o,l,n){if(o===0)throw Error("Could not stringify the object: maximum object depth exceeded");let t="",f="",v=Object.keys(r);for(let h=0;h<v.length;h++){let p=v[h];if(r[p]!==null&&r[p]!==void 0){let c=x(r[p]);if(c==="symbol"||c==="function")throw TypeError(`cannot serialize values of type '${c}'`);let m=Te(p);if(c==="array"&&Me(r[p]))f+=(f&&`
`)+We(r[p],i?`${i}.${m}`:m,o-1,l,n);else if(c==="object"){let b=i?`${i}.${m}`:m;f+=(f&&`
`)+ue(b,r[p],b,o-1,l,n)}else t+=m,t+=" = ",t+=fe(r[p],c,o,l,n),t+=`
`}}if(e&&(t||!f))t=t?`[${e}]
${t}`:`[${e}]`;return t&&f?`${t}
${f}`:t||f}function we(e,{maxDepth:r=1000,numbersAsFloat:i=!1,strictTemporal:o=!1}={}){if(x(e)!=="object")throw TypeError("stringify can only be called with an object");let l=ue(0,e,"",r,i,o);if(l[l.length-1]!==`
`)return l+`
`;return l}/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/var Qe=qe(Oe(),1);var Ir=Qe.parse;export{Ir as parseEnv,Ae as parseTOML,we as stringify};
+2
View File
@@ -121,6 +121,8 @@
"summary": { "en": "nanobot (HKUDS/nanobot) on magpie's Agents page: pick one of magpie's models for it, give it Library MCP servers and skills, and switch it off to put its config back.", "zh": "把 nanobot(HKUDS/nanobot)加到 magpie 的 Agent 页:给它选 magpie 的模型、勾选资源库的 MCP 服务与技能,关掉即恢复它原来的配置。" } },
{ "package": "@magpie-community/agent-reasonix-desktop", "name": "Reasonix 1.x", "kind": "agent", "community": true, "icon": "reasonix-color",
"summary": { "en": "Reasonix 1.x Desktop and CLI on Magpie's models, preserving existing providers. Restart Reasonix after choosing a model; disconnect before uninstalling. Separate from the built-in Reasonix Studio 2.x adapter.", "zh": "为 Reasonix 1.x 桌面版和 CLI 选择 Magpie 模型,保留原有供应商;选模型后重启 Reasonix,卸载前先断开。与内置的 Reasonix Studio 2.x 适配器分开。" } },
{ "package": "@magpie-community/agent-deepzora", "name": "Deepzora", "kind": "agent", "community": true, "icon": "https://raw.githubusercontent.com/SivanCola/deepzora/ad855397cdfdaf2ba7e3e3414583ba777412cbe4/desktop/build/linux/icons/hicolor/128x128/apps/deepzora-desktop.png",
"summary": { "en": "Deepzora Desktop, CLI and ACP on Magpie's models, with a reversible TOML/dotenv bridge that preserves existing providers. Restart Deepzora after choosing a model; disconnect before uninstalling. Disable the standalone Deepzora plugin before switching to this package.", "zh": "为 Deepzora 桌面版、CLI 和 ACP 选择 Magpie 模型,通过可恢复的 TOML/dotenv 桥接保留原有供应商。选模型后重启 Deepzora,卸载前先断开;从独立 Deepzora 插件迁移时先停用旧包。" } },
{ "package": "@magpie-community/agent-pig", "name": "PiG", "kind": "agent", "community": true,
"summary": { "en": "PiG (Pi in Go): add Magpie's endpoint and model catalog, choose models in PiG, and keep startup settings unchanged.", "zh": "为 PiG(Pi in Go)注入 Magpie 端点与模型列表,在 PiG 内选择模型,保持启动设置不变。" } },
{ "package": "@magpie-community/agent-bub", "name": "Bub", "kind": "agent", "community": true,