Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
moejs: v0.1.0-alpha.11, at its new module path github.com/MoeForge/moejs
yetone60520ddb3bfd
diff --git a/THIRD_PARTY_NOTICES b/THIRD_PARTY_NOTICESnew file mode 100644index 000000000..67db0dcc6--- /dev/null+++ b/THIRD_PARTY_NOTICES@@ -0,0 +1,391 @@+magpie third-party notices+==========================++magpie is built with moejs (https://github.com/MoeForge/moejs,+Apache License 2.0), a JavaScript engine that runs gateway plugins. moejs+compiles the material below into every magpie binary, and its notices,+sections 1 to 4 of moejs's THIRD_PARTY_NOTICES at v0.1.0-alpha.11,+follow verbatim.++------------------------------------------------------------------------+1. Unicode CLDR 48.0+------------------------------------------------------------------------++What: The Unicode Common Locale Data Repository: locale data such as+ names, date, time and number patterns and symbols, plural rules,+ time zone names, locale aliases, likely subtags and supplemental+ data, as Intl uses them.+Upstream: Unicode CLDR 48.0, https://cldr.unicode.org/+ https://unicode.org/Public/cldr/48/cldr-common-48.zip+ https://github.com/unicode-org/cldr, tag release-48+License: Unicode License v3 (SPDX: Unicode-3.0)++Files:+ engine/intl_locale_tables.go generated by internal/gen/cldr from+ engine/intl_date_tables.go CLDR 48.0+ engine/intl_number_tables.go+ engine/intl_supp_tables.go+ engine/intl_tz_tables.go generated by internal/gen/cldr from+ CLDR 48.0 and tzdata 2026c (section 7)+ engine/collate.go lists in the CLDR root collation order+ engine/builtin_intl_locale_info.go CLDR's collation types+ engine/testdata/intl_plurals.xml.gz+ engine/testdata/intl_ordinals.xml.gz+ CLDR's common/supplemental/plurals.xml+ and ordinals.xml+ engine/testdata/intl_date_node.json.gz+ engine/testdata/intl_number_node.json.gz+ engine/testdata/intl_tz_icu.json.gz+ engine/testdata/langtag_icu.json.gz+ engine/testdata/intl_probe.node.txt+ expected outputs recorded from Node.js+ 24 (ICU 78.3 with CLDR 48.0), which+ contain CLDR data++The text below is the LICENSE file of https://github.com/unicode-org/cldr at+tag release-48.++UNICODE LICENSE V3++COPYRIGHT AND PERMISSION NOTICE++Copyright © 2004-2025 Unicode, Inc.++NOTICE TO USER: Carefully read the following legal agreement. BY+DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR+SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE+TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT+DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.++Permission is hereby granted, free of charge, to any person obtaining a+copy of data files and any associated documentation (the "Data Files") or+software and any associated documentation (the "Software") to deal in the+Data Files or Software without restriction, including without limitation+the rights to use, copy, modify, merge, publish, distribute, and/or sell+copies of the Data Files or Software, and to permit persons to whom the+Data Files or Software are furnished to do so, provided that either (a)+this copyright and permission notice appear with all copies of the Data+Files or Software, or (b) this copyright and permission notice appear in+associated Documentation.++THE DATA FILES AND SOFTWARE ARE 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 OF+THIRD PARTY RIGHTS.++IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE+BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,+OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA+FILES OR SOFTWARE.++Except as contained in this notice, the name of a copyright holder shall+not be used in advertising or otherwise to promote the sale, use or other+dealings in these Data Files or Software without prior written+authorization of the copyright holder.++SPDX-License-Identifier: Unicode-3.0++------------------------------------------------------------------------+2. Unicode Character Database and IDNA data, Unicode 17.0.0+------------------------------------------------------------------------++What: Unicode character properties (general categories, scripts,+ binary properties, case mappings and foldings, emoji data),+ normalization and decomposition data, the UAX #29 segmentation+ properties and break tests, the normalization test, and the+ UTS #46 IDNA mapping table.+Upstream: The Unicode Standard 17.0.0, https://www.unicode.org/Public/17.0.0/+ (ucd/, ucd/auxiliary/, ucd/emoji/, ucd/extracted/, emoji/, idna/)+License: Unicode License v3 (SPDX: Unicode-3.0). The files say+ "© 2025 Unicode®, Inc." and refer to+ https://www.unicode.org/terms_of_use.html, which puts them under+ the license below.++Files:+ internal/regexpsyntax/unicode_tables.go generated by internal/gen/ucd+ engine/unicode_norm_tables.go generated by internal/gen/ucd -norm+ engine/unicode_seg_tables.go generated by internal/gen/ucd -seg+ engine/decomp_tables.go generated by internal/gen/decomp+ webapi/internal/whatwgurl/idna_tables.go generated by internal/gen/idna+ engine/testdata/grapheme_break_test.txt.gz+ engine/testdata/word_break_test.txt.gz+ engine/testdata/sentence_break_test.txt.gz+ engine/testdata/normalization_test.txt.gz+ GraphemeBreakTest.txt, WordBreakTest.txt,+ SentenceBreakTest.txt and+ NormalizationTest.txt, trimmed+ webapi/internal/whatwgurl/testdata/IdnaTestV2.json.gz+ webapi/internal/whatwgurl/testdata/IdnaTestV2-removed.json+ web-platform-tests' conversion of+ IdnaTestV2.txt (see also section 5)++The text below is https://www.unicode.org/license.txt as published on+2026-10-24.++UNICODE LICENSE V3++COPYRIGHT AND PERMISSION NOTICE++Copyright © 1991-2026 Unicode, Inc.++NOTICE TO USER: Carefully read the following legal agreement. BY+DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR+SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE+TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT+DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.++Permission is hereby granted, free of charge, to any person obtaining a+copy of data files and any associated documentation (the "Data Files") or+software and any associated documentation (the "Software") to deal in the+Data Files or Software without restriction, including without limitation+the rights to use, copy, modify, merge, publish, distribute, and/or sell+copies of the Data Files or Software, and to permit persons to whom the+Data Files or Software are furnished to do so, provided that either (a)+this copyright and permission notice appear with all copies of the Data+Files or Software, or (b) this copyright and permission notice appear in+associated Documentation.++THE DATA FILES AND SOFTWARE ARE 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 OF+THIRD PARTY RIGHTS.++IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE+BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,+OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA+FILES OR SOFTWARE.++Except as contained in this notice, the name of a copyright holder shall+not be used in advertising or otherwise to promote the sale, use or other+dealings in these Data Files or Software without prior written+authorization of the copyright holder.++------------------------------------------------------------------------+3. ICU 78.3 (ported code)+------------------------------------------------------------------------++What: International Components for Unicode. moejs ports parts of+ ICU4C's date, time zone and number formatting to Go, so that Intl+ formats as V8 with ICU does.+Upstream: ICU 78.3, https://icu.unicode.org/+ https://github.com/unicode-org/icu, tag release-78.3+License: Unicode License v3 (SPDX: Unicode-3.0). Parts of the ported ICU+ files are also "Copyright (C) 1997-2016, International Business+ Machines Corporation and others" under the ICU License for ICU+ 1.8.1 to ICU 57.1.++Files:+ engine/intl_date_pattern.go DateTimePatternGenerator (i18n/dtptngen.cpp)+ engine/intl_date_range.go DateIntervalFormat and DateIntervalInfo+ (i18n/dtitvfmt.cpp, dtitvinf.cpp)+ engine/intl_date_format.go SimpleDateFormat (i18n/smpdtfmt.cpp)+ engine/intl_tz.go TimeZoneFormat, TimeZoneNames and+ TimeZoneGenericNames (i18n/tzfmt.cpp,+ tznames_impl.cpp, tzgnames.cpp)+ engine/intl_number_format.go the number formatter and+ NumberRangeFormatter (i18n/number_*.cpp,+ numrange_impl.cpp)+ engine/intl_number_pattern.go number patterns+ (i18n/number_patternstring.cpp,+ number_affixutils.cpp,+ number_patternmodifier.cpp)+ engine/builtin_intl_datetimeformat.go+ the style patterns of SimpleDateFormat+ internal/gen/cldr/date.go ICU's reading of CLDR's calendar data+ (DateFormatSymbols, DayPeriodRules)+ internal/gen/cldr/tz.go ICU's reading of CLDR's time zone data+ (getCanonicalCountry, getReferenceZoneID,+ the offset patterns) and the spans in which+ ICU's DST flag differs from tzdata's+ engine/segment.go the word-like status of a segment, after+ internal/gen/ucd/seg.go ICU's word break rules+ (data/brkitr/rules/word.txt)++The texts below are the first two parts of the LICENSE file of+https://github.com/unicode-org/icu at tag release-78.3: the Unicode License+v3 and the ICU License for ICU 1.8.1 to ICU 57.1. The rest of that file+covers third-party components of ICU (dictionaries, Google double-conversion,+build scripts and others) that moejs does not use.++UNICODE LICENSE V3++COPYRIGHT AND PERMISSION NOTICE++Copyright © 2016-2025 Unicode, Inc.++NOTICE TO USER: Carefully read the following legal agreement. BY+DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR+SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE+TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT+DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.++Permission is hereby granted, free of charge, to any person obtaining a+copy of data files and any associated documentation (the "Data Files") or+software and any associated documentation (the "Software") to deal in the+Data Files or Software without restriction, including without limitation+the rights to use, copy, modify, merge, publish, distribute, and/or sell+copies of the Data Files or Software, and to permit persons to whom the+Data Files or Software are furnished to do so, provided that either (a)+this copyright and permission notice appear with all copies of the Data+Files or Software, or (b) this copyright and permission notice appear in+associated Documentation.++THE DATA FILES AND SOFTWARE ARE 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 OF+THIRD PARTY RIGHTS.++IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE+BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,+OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA+FILES OR SOFTWARE.++Except as contained in this notice, the name of a copyright holder shall+not be used in advertising or otherwise to promote the sale, use or other+dealings in these Data Files or Software without prior written+authorization of the copyright holder.++SPDX-License-Identifier: Unicode-3.0++----------------------------------------------------------------------++ICU License - ICU 1.8.1 to ICU 57.1++COPYRIGHT AND PERMISSION NOTICE++Copyright (c) 1995-2016 International Business Machines Corporation and others+All rights reserved.++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, and/or sell copies of the Software, and to permit persons+to whom the Software is furnished to do so, provided that the above+copyright notice(s) and this permission notice appear in all copies of+the Software and that both the above copyright notice(s) and this+permission notice appear in supporting documentation.++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+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.++Except as contained in this notice, the name of a copyright holder+shall not be used in advertising or otherwise to promote the sale, use+or other dealings in this Software without prior written authorization+of the copyright holder.++All trademarks and registered trademarks mentioned herein are the+property of their respective owners.++------------------------------------------------------------------------+4. V8 (ported code)+------------------------------------------------------------------------++What: Google's JavaScript engine. moejs ports V8's date string parser+ and the code behind V8's stack traces and error messages, so that+ Date.parse, Error.prototype.stack and TypeError messages match+ Node.js.+Upstream: V8, https://v8.dev/+ https://chromium.googlesource.com/v8/v8 (mirror+ https://github.com/v8/v8), branch-heads/13.6 (the V8 of Node.js 24)+License: BSD-3-Clause. The ported files carry "Copyright <year> the V8+ project authors. All rights reserved.": 2011 for+ src/date/dateparser* and src/execution/messages.cc, 2012 for+ src/ast/prettyprinter.cc, 2018 for+ src/objects/js-date-time-format.cc and 2019 for+ src/objects/call-site-info.cc.++Files:+ engine/date_parse.go DateParser (src/date/dateparser.h,+ dateparser-inl.h, dateparser.cc)+ engine/interp_stack.go stack trace serialization+ (src/objects/call-site-info.cc:+ SerializeJSStackFrame, AppendMethodCall,+ AppendFileLocation and the functions they+ call)+ engine/builtin_error.go Error.captureStackTrace+ (ErrorUtils::CaptureStackTrace,+ src/execution/messages.cc)+ compiler/callee.go CallPrinter (src/ast/prettyprinter.cc)+ engine/builtin_intl_datetimeformat.go+ ReplaceSkeleton, HourCycleFromPattern and+ ReplaceHourCycleInPattern+ (src/objects/js-date-time-format.cc)++The text below is the LICENSE file of V8 at branch-heads/13.6.++This license applies to all parts of V8 that are not externally+maintained libraries. The externally maintained libraries used by V8+are:++ - PCRE test suite, located in+ test/mjsunit/third_party/regexp-pcre/regexp-pcre.js. This is based on the+ test suite from PCRE-7.3, which is copyrighted by the University+ of Cambridge and Google, Inc. The copyright notice and license+ are embedded in regexp-pcre.js.++ - Layout tests, located in test/mjsunit/third_party/object-keys. These are+ based on layout tests from webkit.org which are copyrighted by+ Apple Computer, Inc. and released under a 3-clause BSD license.++ - Strongtalk assembler, the basis of the files assembler-arm-inl.h,+ assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h,+ assembler-ia32.cc, assembler-ia32.h, assembler-x64-inl.h,+ assembler-x64.cc, assembler-x64.h, assembler.cc and assembler.h.+ This code is copyrighted by Sun Microsystems Inc. and released+ under a 3-clause BSD license.++ - Valgrind client API header, located at third_party/valgrind/valgrind.h+ This is released under the BSD license.++ - The Wasm C/C++ API headers, located at third_party/wasm-api/wasm.{h,hh}+ This is released under the Apache license. The API's upstream prototype+ implementation also formed the basis of V8's implementation in+ src/wasm/c-api.cc.++These libraries have their own licenses; we recommend you read them,+as their terms may differ from the terms below.++Further license information can be found in LICENSE files located in+sub-directories.++Copyright 2014, the V8 project authors. 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.+ * Neither the name of Google Inc. 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+OWNER 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.+diff --git a/docs/reference.md b/docs/reference.mdindex c513889fd..6ec9a036d 100644--- a/docs/reference.md+++ b/docs/reference.md@@ -1076,7 +1076,7 @@ export function onEvent(ev, ctx) {}```-Middleware runs inside the gateway in [moejs](https://github.com/Calcium-Ion/moejs),+Middleware runs inside the gateway in [moejs](https://github.com/MoeForge/moejs),a JavaScript engine written in Go (about a microsecond a streamed event),not on Bun: no timers, `fetch` or Node APIs, and imports only of filesbeside it. A hook that throws or takes too long (250 ms a request, 50 ms andiff --git a/docs/subsystems/gateway-middleware.md b/docs/subsystems/gateway-middleware.mdindex 713870ab0..87fbb9b3f 100644--- a/docs/subsystems/gateway-middleware.md+++ b/docs/subsystems/gateway-middleware.md@@ -1,6 +1,6 @@# Gateway middleware-A plugin can be a JS gateway plugin: JavaScript that magpie runs inside its gateway on the requests agents send and the replies they get back (middleware), on the order a pool's accounts or keys are tried in (`strategies`), and on each usage row (`onUsage`), whatever provider serves them. It is separate from the provider plugins in [Provider and plugin ownership](provider-plugins.md), which run on Bun in the plugin host. Middleware runs in the gateway's own process on [moejs](https://github.com/Calcium-Ion/moejs), a JavaScript engine written in Go, because it sits on every request and every streamed event.+A plugin can be a JS gateway plugin: JavaScript that magpie runs inside its gateway on the requests agents send and the replies they get back (middleware), on the order a pool's accounts or keys are tried in (`strategies`), and on each usage row (`onUsage`), whatever provider serves them. It is separate from the provider plugins in [Provider and plugin ownership](provider-plugins.md), which run on Bun in the plugin host. Middleware runs in the gateway's own process on [moejs](https://github.com/MoeForge/moejs), a JavaScript engine written in Go, because it sits on every request and every streamed event.## Responsibilities and sources of truthdiff --git a/go.mod b/go.modindex 47912812e..c2d4adb5a 100644--- a/go.mod+++ b/go.mod@@ -3,7 +3,7 @@ module github.com/yetone/magpiego 1.26.8require (- github.com/Calcium-Ion/moejs v0.1.0-alpha.4+ github.com/MoeForge/moejs v0.1.0-alpha.11github.com/charmbracelet/bubbles v0.21.1github.com/charmbracelet/bubbletea v1.3.10github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834diff --git a/go.sum b/go.sumindex 81a58133a..cc6b4dea9 100644--- a/go.sum+++ b/go.sum@@ -1,7 +1,7 @@git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 h1:N3IGoHHp9pb6mj1cbXbuaSXV/UMKwmbKLf53nQmtqMA=git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc=-github.com/Calcium-Ion/moejs v0.1.0-alpha.4 h1:SQOx8HsTzfW8fZgSnR3KQ5IPa49P0klo6pRGCsfYVC4=-github.com/Calcium-Ion/moejs v0.1.0-alpha.4/go.mod h1:9YqHj36EV7pzV/vlEYSw49f3oggeJFdmqcjM9TmDpHs=+github.com/MoeForge/moejs v0.1.0-alpha.11 h1:VVDuqn14Dzlhcs17gDp3X43uvKkxi7OK7SZvkd0moEc=+github.com/MoeForge/moejs v0.1.0-alpha.11/go.mod h1:YG2Y3bZuThN7hkSBext9MHPUPSrAIdpiE+6v+QO+LX0=github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=diff --git a/internal/agentplug/agentplug.go b/internal/agentplug/agentplug.goindex 0e3a2ad8e..45fa8d711 100644--- a/internal/agentplug/agentplug.go+++ b/internal/agentplug/agentplug.go@@ -49,7 +49,7 @@ import ("sync/atomic""time"- "github.com/Calcium-Ion/moejs"+ "github.com/MoeForge/moejs""github.com/yetone/magpie/internal/jsmod""github.com/yetone/magpie/internal/plugin")diff --git a/internal/jsmod/jsmod.go b/internal/jsmod/jsmod.goindex eea4e97df..f4fcf67ec 100644--- a/internal/jsmod/jsmod.go+++ b/internal/jsmod/jsmod.go@@ -10,7 +10,7 @@ import ("path/filepath""strings"- "github.com/Calcium-Ion/moejs"+ "github.com/MoeForge/moejs")// Compile compiles the module in file and the modules it imports, whichdiff --git a/internal/middleware/middleware.go b/internal/middleware/middleware.goindex 2830edc81..3f6734b60 100644--- a/internal/middleware/middleware.go+++ b/internal/middleware/middleware.go@@ -24,7 +24,7 @@ import ("sync/atomic""time"- "github.com/Calcium-Ion/moejs"+ "github.com/MoeForge/moejs""github.com/yetone/magpie/internal/filememo""github.com/yetone/magpie/internal/jsmod""github.com/yetone/magpie/internal/plugin"diff --git a/internal/middleware/points.go b/internal/middleware/points.goindex d9e7b02a1..41b3dac49 100644--- a/internal/middleware/points.go+++ b/internal/middleware/points.go@@ -33,7 +33,7 @@ import ("sync/atomic""time"- "github.com/Calcium-Ion/moejs"+ "github.com/MoeForge/moejs""github.com/yetone/magpie/internal/beat""github.com/yetone/magpie/internal/filememo"diff --git a/internal/middleware/run.go b/internal/middleware/run.goindex e923a09d4..6ef57b2ba 100644--- a/internal/middleware/run.go+++ b/internal/middleware/run.go@@ -8,7 +8,7 @@ import ("strings""time"- "github.com/Calcium-Ion/moejs"+ "github.com/MoeForge/moejs""github.com/yetone/magpie/internal/gwmw")diff --git a/site/public/docs/ja/plugins.html b/site/public/docs/ja/plugins.htmlindex 0f209f0fc..f721b90d2 100644--- a/site/public/docs/ja/plugins.html+++ b/site/public/docs/ja/plugins.html@@ -692,7 +692,7 @@ magpie plugin options model-map '{"mapping": {"fast": "deepseek/deepseek-chat"}}<h3 id="middleware-options"><a class="anchor" href="#middleware-options">オプション</a></h3><p>ミドルウェアは設定を <code>ctx.options</code> から読みます。これは <code>plugins.json</code> のそのエントリの <code>options</code> です。<span class="ui">プラグイン → インストール済み</span> でミドルウェアの <span class="ui">オプション</span> ボタンを押すとその行で JSON として編集でき、<code>magpie plugin options <名前> '<json>'</code> でも設定できます(<code>off</code> で消去)。名前はパッケージ名、spec、短い名前のどれでもかまいません:<code>@magpie-community/middleware-model-map</code> なら <code>model-map</code> です。次のリクエストから反映されます。パッケージは <code>package.json</code> の <code>"magpie": { "options": { … } }</code> でオプションの例を示せます。未設定のときエディタはそれから始まりますが、保存するまでミドルウェアはオプションなしで動きます。</p><h3>動き方</h3>- <p>ミドルウェアは Bun では動きません。ゲートウェイ自身のプロセスの中で、Go で書かれた JavaScript エンジン <a href="https://github.com/Calcium-Ion/moejs">moejs</a> によって動きます。応答は数千のイベントとしてストリームされ、各イベントがミドルウェアの処理を待つからです。1 イベントでのフック呼び出しは約 1 マイクロ秒で済みますが、Bun との往復だと数十マイクロ秒かかります。各ミドルウェアのコンパイルは一度だけで、リクエストごとに専用のランタイムを使います。そのためリクエストは並行に処理され、同じリクエストのフック同士は <code>ctx.state</code> を共有します。</p>+ <p>ミドルウェアは Bun では動きません。ゲートウェイ自身のプロセスの中で、Go で書かれた JavaScript エンジン <a href="https://github.com/MoeForge/moejs">moejs</a> によって動きます。応答は数千のイベントとしてストリームされ、各イベントがミドルウェアの処理を待つからです。1 イベントでのフック呼び出しは約 1 マイクロ秒で済みますが、Bun との往復だと数十マイクロ秒かかります。各ミドルウェアのコンパイルは一度だけで、リクエストごとに専用のランタイムを使います。そのためリクエストは並行に処理され、同じリクエストのフック同士は <code>ctx.state</code> を共有します。</p><ul><li><b>宣言のしかた。</b><code>package.json</code> に <code>"magpie": { "middleware": "./mw.js" }</code> と書くか、<code>*.middleware.js</code>(または <code>.mjs</code>)という名前の単一ファイルにします。<code>main</code> も <code>exports</code> もないパッケージはミドルウェア専用で、プラグインホストは読み込みません。両方あるパッケージはプロバイダプラグインとミドルウェアを兼ねます。</li><li><b>インポート。</b>プラグイン内のファイルだけを相対パスで読み込めます。ここに <code>node_modules</code> はないので、使う依存はファイルにバンドルしてください。</li>diff --git a/site/public/docs/plugins.html b/site/public/docs/plugins.htmlindex 95d19c9c9..84b8fbd16 100644--- a/site/public/docs/plugins.html+++ b/site/public/docs/plugins.html@@ -692,7 +692,7 @@ magpie plugin options model-map '{"mapping": {"fast": "deepseek/deepseek-chat"}}<h3 id="middleware-options"><a class="anchor" href="#middleware-options">Options</a></h3><p>A middleware reads its settings from <code>ctx.options</code>, which are its entry’s <code>options</code> in <code>plugins.json</code>. Set them in <span class="ui">Plugins → Installed</span> with the middleware’s <span class="ui">Options</span> button, which edits them as JSON in its row, or with <code>magpie plugin options <name> '<json>'</code> (<code>off</code> clears them). The name can be the package’s, its spec, or its short name: <code>model-map</code> for <code>@magpie-community/middleware-model-map</code>. They apply from the next request on. A package can suggest options with <code>"magpie": { "options": { … } }</code> in its <code>package.json</code>: the editor starts from those when none are set, but a middleware runs with no options until you save some.</p><h3>How it runs</h3>- <p>Middleware isn’t run on Bun. It runs inside the gateway’s own process, in <a href="https://github.com/Calcium-Ion/moejs">moejs</a>, a JavaScript engine written in Go, because a reply streams thousands of events and each one waits for it. A hook on one event costs about a microsecond; a round trip to Bun would cost tens. Each middleware is compiled once, and each request gets a runtime of its own, so requests run in parallel and a request’s hooks share <code>ctx.state</code>.</p>+ <p>Middleware isn’t run on Bun. It runs inside the gateway’s own process, in <a href="https://github.com/MoeForge/moejs">moejs</a>, a JavaScript engine written in Go, because a reply streams thousands of events and each one waits for it. A hook on one event costs about a microsecond; a round trip to Bun would cost tens. Each middleware is compiled once, and each request gets a runtime of its own, so requests run in parallel and a request’s hooks share <code>ctx.state</code>.</p><ul><li><b>Declaring it.</b> <code>"magpie": { "middleware": "./mw.js" }</code> in <code>package.json</code>, or a single file named <code>*.middleware.js</code> (or <code>.mjs</code>). A package with no <code>main</code> and no <code>exports</code> is only middleware, and the plugin host leaves it alone; one with both is a provider plugin and middleware at once.</li><li><b>Imports.</b> Only files inside the plugin, by relative path. There is no <code>node_modules</code> here: bundle what you import into the file.</li>diff --git a/site/public/docs/zh/plugins.html b/site/public/docs/zh/plugins.htmlindex 05d5e6d9e..ed51fed81 100644--- a/site/public/docs/zh/plugins.html+++ b/site/public/docs/zh/plugins.html@@ -692,7 +692,7 @@ magpie plugin options model-map '{"mapping": {"fast": "deepseek/deepseek-chat"}}<h3 id="middleware-options"><a class="anchor" href="#middleware-options">选项</a></h3><p>中间件从 <code>ctx.options</code> 读取设置,也就是 <code>plugins.json</code> 里它那一项的 <code>options</code>。可以在<span class="ui">插件 → 已安装</span>里点中间件的<span class="ui">选项</span>按钮,在它那一行里以 JSON 编辑;也可以用 <code>magpie plugin options <名字> '<json>'</code>(<code>off</code> 清除)。名字可以是包名、spec 或短名:<code>@magpie-community/middleware-model-map</code> 的短名是 <code>model-map</code>。从下一个请求起生效。包可以在 <code>package.json</code> 里用 <code>"magpie": { "options": { … } }</code> 给出建议的选项:没有设置时编辑框以它为起点,但在你保存之前,中间件运行时没有选项。</p><h3>运行方式</h3>- <p>中间件不在 Bun 里运行,而是在网关自己的进程里,用 Go 写的 JavaScript 引擎 <a href="https://github.com/Calcium-Ion/moejs">moejs</a> 运行。原因是一个回复会流式传输成千上万个事件,每个事件都要等它处理完。在一个事件上调用一次钩子大约耗时 1 微秒,而和 Bun 往返一次要几十微秒。每个中间件只编译一次,每个请求有自己的运行时,所以请求之间可以并行,同一个请求的各个钩子共享 <code>ctx.state</code>。</p>+ <p>中间件不在 Bun 里运行,而是在网关自己的进程里,用 Go 写的 JavaScript 引擎 <a href="https://github.com/MoeForge/moejs">moejs</a> 运行。原因是一个回复会流式传输成千上万个事件,每个事件都要等它处理完。在一个事件上调用一次钩子大约耗时 1 微秒,而和 Bun 往返一次要几十微秒。每个中间件只编译一次,每个请求有自己的运行时,所以请求之间可以并行,同一个请求的各个钩子共享 <code>ctx.state</code>。</p><ul><li><b>声明方式。</b>在 <code>package.json</code> 里写 <code>"magpie": { "middleware": "./mw.js" }</code>,或者用一个名为 <code>*.middleware.js</code>(或 <code>.mjs</code>)的单文件。没有 <code>main</code> 也没有 <code>exports</code> 的包只是中间件,插件宿主不会加载它;两者都有的包既是供应商插件,也是中间件。</li><li><b>导入。</b>只能用相对路径导入插件目录里的文件。这里没有 <code>node_modules</code>,用到的依赖请打包进文件。</li>