@lamplitisles/codex-for-love 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/vendor/IMPORTS.md +3 -2
- package/vendor/build/_app/immutable/assets/0.D3rCUG9u.css +2 -0
- package/vendor/build/_app/immutable/chunks/utqCDLTs.js +1 -0
- package/vendor/build/_app/immutable/entry/{app.BP5g3Nlw.js → app.BbmlpP2X.js} +2 -2
- package/vendor/build/_app/immutable/entry/start.BmMe00-v.js +1 -0
- package/vendor/build/_app/immutable/nodes/{1.Da3Wny27.js → 1.DXp8K3IS.js} +1 -1
- package/vendor/build/_app/immutable/nodes/{2.B57CsN6q.js → 2.DVm7T6dW.js} +38 -38
- package/vendor/build/_app/version.json +1 -1
- package/vendor/build/index.html +8 -8
- package/vendor/config.example.toml +6 -8
- package/vendor/runtime/cli.mjs +54 -170
- package/vendor/runtime/companion-mcp.mjs +1076 -10
- package/vendor/build/_app/immutable/assets/0.CGGimnj2.css +0 -2
- package/vendor/build/_app/immutable/chunks/C1lTIQVt.js +0 -1
- package/vendor/build/_app/immutable/entry/start.SkCiAosv.js +0 -1
- /package/vendor/build/_app/immutable/nodes/{0.C1vi8tBo.js → 0.Wk08-krq.js} +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import process$1 from "node:process";
|
|
2
|
-
import { randomInt, randomUUID } from "node:crypto";
|
|
2
|
+
import { createHash, randomInt, randomUUID } from "node:crypto";
|
|
3
3
|
import { mkdir, readFile, rename, rmdir, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { execFile } from "node:child_process";
|
|
6
|
+
import { promisify } from "node:util";
|
|
5
7
|
//#region \0rolldown/runtime.js
|
|
6
8
|
var __create = Object.create;
|
|
7
9
|
var __defProp = Object.defineProperty;
|
|
@@ -4361,7 +4363,7 @@ const _parse = (_Err) => {
|
|
|
4361
4363
|
};
|
|
4362
4364
|
return fn;
|
|
4363
4365
|
};
|
|
4364
|
-
const parse$
|
|
4366
|
+
const parse$2 = /* @__PURE__*/ _parse($ZodRealError);
|
|
4365
4367
|
const _parseAsync = (_Err) => {
|
|
4366
4368
|
const fn = async (schema, value, _ctx, params) => {
|
|
4367
4369
|
const ctx = _ctx ? {
|
|
@@ -8447,7 +8449,7 @@ const ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
|
|
|
8447
8449
|
own(this, "with", value);
|
|
8448
8450
|
},
|
|
8449
8451
|
parse(data, params) {
|
|
8450
|
-
return parse$
|
|
8452
|
+
return parse$2(this, data, params, { callee: this.parse });
|
|
8451
8453
|
},
|
|
8452
8454
|
parseAsync(data, params) {
|
|
8453
8455
|
return parseAsync$1(this, data, params, { callee: this.parseAsync });
|
|
@@ -8672,12 +8674,12 @@ const initializer = (inst, issues) => {
|
|
|
8672
8674
|
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
|
|
8673
8675
|
//#endregion
|
|
8674
8676
|
//#region node_modules/.pnpm/zod@4.6.2/node_modules/zod/v4/classic/parse.js
|
|
8675
|
-
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
8677
|
+
const parse$1 = /* @__PURE__ */ _parse(ZodRealError);
|
|
8676
8678
|
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
8677
8679
|
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
8678
8680
|
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
8679
8681
|
const encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
8680
|
-
const decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
8682
|
+
const decode$1 = /* @__PURE__ */ _decode(ZodRealError);
|
|
8681
8683
|
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
8682
8684
|
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
8683
8685
|
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
@@ -8804,7 +8806,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
8804
8806
|
own(this, "~standard", value);
|
|
8805
8807
|
},
|
|
8806
8808
|
parse: function _parse(data, params) {
|
|
8807
|
-
return parse(this, data, params, { callee: _parse });
|
|
8809
|
+
return parse$1(this, data, params, { callee: _parse });
|
|
8808
8810
|
},
|
|
8809
8811
|
parseAsync: async function _parseAsync(data, params) {
|
|
8810
8812
|
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
@@ -8831,7 +8833,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
8831
8833
|
return encode(this, data, params, { callee: _encode });
|
|
8832
8834
|
},
|
|
8833
8835
|
decode: function _decode(data, params) {
|
|
8834
|
-
return decode(this, data, params, { callee: _decode });
|
|
8836
|
+
return decode$1(this, data, params, { callee: _decode });
|
|
8835
8837
|
},
|
|
8836
8838
|
encodeAsync: async function _encodeAsync(data, params) {
|
|
8837
8839
|
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
@@ -9039,6 +9041,9 @@ const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
|
|
|
9039
9041
|
$ZodURL.init(inst, def);
|
|
9040
9042
|
ZodStringFormat.init(inst, def);
|
|
9041
9043
|
});
|
|
9044
|
+
function url(params) {
|
|
9045
|
+
return /* @__PURE__ */ _url(ZodURL, params);
|
|
9046
|
+
}
|
|
9042
9047
|
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
|
|
9043
9048
|
$ZodEmoji.init(inst, def);
|
|
9044
9049
|
ZodStringFormat.init(inst, def);
|
|
@@ -21884,9 +21889,1030 @@ function partnerPaths(workspace) {
|
|
|
21884
21889
|
};
|
|
21885
21890
|
}
|
|
21886
21891
|
//#endregion
|
|
21892
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
|
|
21893
|
+
/*!
|
|
21894
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
21895
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21896
|
+
*
|
|
21897
|
+
* Redistribution and use in source and binary forms, with or without
|
|
21898
|
+
* modification, are permitted provided that the following conditions are met:
|
|
21899
|
+
*
|
|
21900
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
21901
|
+
* list of conditions and the following disclaimer.
|
|
21902
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
21903
|
+
* this list of conditions and the following disclaimer in the
|
|
21904
|
+
* documentation and/or other materials provided with the distribution.
|
|
21905
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
21906
|
+
* may be used to endorse or promote products derived from this software without
|
|
21907
|
+
* specific prior written permission.
|
|
21908
|
+
*
|
|
21909
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
21910
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21911
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21912
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21913
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21914
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21915
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21916
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21917
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
21918
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
21919
|
+
*/
|
|
21920
|
+
let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
21921
|
+
var TomlDate = class TomlDate extends Date {
|
|
21922
|
+
#hasDate = false;
|
|
21923
|
+
#hasTime = false;
|
|
21924
|
+
#offset = null;
|
|
21925
|
+
constructor(date) {
|
|
21926
|
+
let hasDate = true;
|
|
21927
|
+
let hasTime = true;
|
|
21928
|
+
let offset = "Z";
|
|
21929
|
+
if (typeof date === "string") {
|
|
21930
|
+
let match = date.match(DATE_TIME_RE);
|
|
21931
|
+
if (match) {
|
|
21932
|
+
if (!match[1]) {
|
|
21933
|
+
hasDate = false;
|
|
21934
|
+
date = `0000-01-01T${date}`;
|
|
21935
|
+
}
|
|
21936
|
+
hasTime = !!match[2];
|
|
21937
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
21938
|
+
if (match[2] && +match[2] > 23) date = "";
|
|
21939
|
+
else {
|
|
21940
|
+
offset = match[3] || null;
|
|
21941
|
+
date = date.toUpperCase();
|
|
21942
|
+
if (!offset && hasTime) date += "Z";
|
|
21943
|
+
}
|
|
21944
|
+
} else date = "";
|
|
21945
|
+
}
|
|
21946
|
+
super(date);
|
|
21947
|
+
if (!isNaN(this.getTime())) {
|
|
21948
|
+
this.#hasDate = hasDate;
|
|
21949
|
+
this.#hasTime = hasTime;
|
|
21950
|
+
this.#offset = offset;
|
|
21951
|
+
}
|
|
21952
|
+
}
|
|
21953
|
+
isDateTime() {
|
|
21954
|
+
return this.#hasDate && this.#hasTime;
|
|
21955
|
+
}
|
|
21956
|
+
isLocal() {
|
|
21957
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
21958
|
+
}
|
|
21959
|
+
isDate() {
|
|
21960
|
+
return this.#hasDate && !this.#hasTime;
|
|
21961
|
+
}
|
|
21962
|
+
isTime() {
|
|
21963
|
+
return this.#hasTime && !this.#hasDate;
|
|
21964
|
+
}
|
|
21965
|
+
isValid() {
|
|
21966
|
+
return this.#hasDate || this.#hasTime;
|
|
21967
|
+
}
|
|
21968
|
+
toISOString() {
|
|
21969
|
+
let iso = super.toISOString();
|
|
21970
|
+
if (this.isDate()) return iso.slice(0, 10);
|
|
21971
|
+
if (this.isTime()) return iso.slice(11, 23);
|
|
21972
|
+
if (this.#offset === null) return iso.slice(0, -1);
|
|
21973
|
+
if (this.#offset === "Z") return iso;
|
|
21974
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
21975
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
21976
|
+
return (/* @__PURE__ */ new Date(this.getTime() - offset * 6e4)).toISOString().slice(0, -1) + this.#offset;
|
|
21977
|
+
}
|
|
21978
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
21979
|
+
let date = new TomlDate(jsDate);
|
|
21980
|
+
date.#offset = offset;
|
|
21981
|
+
return date;
|
|
21982
|
+
}
|
|
21983
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
21984
|
+
let date = new TomlDate(jsDate);
|
|
21985
|
+
date.#offset = null;
|
|
21986
|
+
return date;
|
|
21987
|
+
}
|
|
21988
|
+
static wrapAsLocalDate(jsDate) {
|
|
21989
|
+
let date = new TomlDate(jsDate);
|
|
21990
|
+
date.#hasTime = false;
|
|
21991
|
+
date.#offset = null;
|
|
21992
|
+
return date;
|
|
21993
|
+
}
|
|
21994
|
+
static wrapAsLocalTime(jsDate) {
|
|
21995
|
+
let date = new TomlDate(jsDate);
|
|
21996
|
+
date.#hasDate = false;
|
|
21997
|
+
date.#offset = null;
|
|
21998
|
+
return date;
|
|
21999
|
+
}
|
|
22000
|
+
};
|
|
22001
|
+
//#endregion
|
|
22002
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/error.js
|
|
22003
|
+
/*!
|
|
22004
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22005
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22006
|
+
*
|
|
22007
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22008
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22009
|
+
*
|
|
22010
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22011
|
+
* list of conditions and the following disclaimer.
|
|
22012
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22013
|
+
* this list of conditions and the following disclaimer in the
|
|
22014
|
+
* documentation and/or other materials provided with the distribution.
|
|
22015
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22016
|
+
* may be used to endorse or promote products derived from this software without
|
|
22017
|
+
* specific prior written permission.
|
|
22018
|
+
*
|
|
22019
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22020
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22021
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22022
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22023
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22024
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22025
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22026
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22027
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22028
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22029
|
+
*/
|
|
22030
|
+
function getLineColFromPtr(string, ptr) {
|
|
22031
|
+
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
22032
|
+
return [lines.length, lines.pop().length + 1];
|
|
22033
|
+
}
|
|
22034
|
+
function makeCodeBlock(string, line, column) {
|
|
22035
|
+
let lines = string.split(/\r\n|\n|\r/g);
|
|
22036
|
+
let codeblock = "";
|
|
22037
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
22038
|
+
for (let i = line - 1; i <= line + 1; i++) {
|
|
22039
|
+
let l = lines[i - 1];
|
|
22040
|
+
if (!l) continue;
|
|
22041
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
22042
|
+
codeblock += ": ";
|
|
22043
|
+
codeblock += l;
|
|
22044
|
+
codeblock += "\n";
|
|
22045
|
+
if (i === line) {
|
|
22046
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
22047
|
+
codeblock += "^\n";
|
|
22048
|
+
}
|
|
22049
|
+
}
|
|
22050
|
+
return codeblock;
|
|
22051
|
+
}
|
|
22052
|
+
var TomlError = class extends Error {
|
|
22053
|
+
line;
|
|
22054
|
+
column;
|
|
22055
|
+
codeblock;
|
|
22056
|
+
constructor(message, options) {
|
|
22057
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
22058
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
22059
|
+
super(`Invalid TOML document: ${message}\n\n${codeblock}`, options);
|
|
22060
|
+
this.line = line;
|
|
22061
|
+
this.column = column;
|
|
22062
|
+
this.codeblock = codeblock;
|
|
22063
|
+
}
|
|
22064
|
+
};
|
|
22065
|
+
//#endregion
|
|
22066
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/util.js
|
|
22067
|
+
/*!
|
|
22068
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22069
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22070
|
+
*
|
|
22071
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22072
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22073
|
+
*
|
|
22074
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22075
|
+
* list of conditions and the following disclaimer.
|
|
22076
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22077
|
+
* this list of conditions and the following disclaimer in the
|
|
22078
|
+
* documentation and/or other materials provided with the distribution.
|
|
22079
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22080
|
+
* may be used to endorse or promote products derived from this software without
|
|
22081
|
+
* specific prior written permission.
|
|
22082
|
+
*
|
|
22083
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22084
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22085
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22086
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22087
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22088
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22089
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22090
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22091
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22092
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22093
|
+
*/
|
|
22094
|
+
/** @internal */
|
|
22095
|
+
function indexOfNewline(str, start = 0) {
|
|
22096
|
+
let idx = str.indexOf("\n", start);
|
|
22097
|
+
if (str.charCodeAt(idx - 1) === 13) idx--;
|
|
22098
|
+
return idx;
|
|
22099
|
+
}
|
|
22100
|
+
/** @internal */
|
|
22101
|
+
function skipComment(ctx) {
|
|
22102
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
22103
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
22104
|
+
if (c === 10) break;
|
|
22105
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
22106
|
+
ctx.p++;
|
|
22107
|
+
break;
|
|
22108
|
+
}
|
|
22109
|
+
if (c < 32 && c !== 9 || c === 127) throw new TomlError("control characters are not allowed in comments", {
|
|
22110
|
+
toml: ctx.s,
|
|
22111
|
+
ptr: ctx.p
|
|
22112
|
+
});
|
|
22113
|
+
}
|
|
22114
|
+
}
|
|
22115
|
+
/** @internal */
|
|
22116
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
22117
|
+
let c;
|
|
22118
|
+
while (1) {
|
|
22119
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) ctx.p++;
|
|
22120
|
+
if (banComments || c !== 35) break;
|
|
22121
|
+
skipComment(ctx);
|
|
22122
|
+
}
|
|
22123
|
+
}
|
|
22124
|
+
/** @internal */
|
|
22125
|
+
function skipUntil(ctx, sep, end) {
|
|
22126
|
+
let ptr = ctx.p;
|
|
22127
|
+
if (!end) {
|
|
22128
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
22129
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
22130
|
+
return;
|
|
22131
|
+
}
|
|
22132
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
22133
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
22134
|
+
if (c === 35) skipComment(ctx);
|
|
22135
|
+
else if (c === end || c === sep) return;
|
|
22136
|
+
}
|
|
22137
|
+
throw new TomlError("cannot find end of structure", {
|
|
22138
|
+
toml: ctx.s,
|
|
22139
|
+
ptr
|
|
22140
|
+
});
|
|
22141
|
+
}
|
|
22142
|
+
//#endregion
|
|
22143
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
|
|
22144
|
+
/*!
|
|
22145
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22146
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22147
|
+
*
|
|
22148
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22149
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22150
|
+
*
|
|
22151
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22152
|
+
* list of conditions and the following disclaimer.
|
|
22153
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22154
|
+
* this list of conditions and the following disclaimer in the
|
|
22155
|
+
* documentation and/or other materials provided with the distribution.
|
|
22156
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22157
|
+
* may be used to endorse or promote products derived from this software without
|
|
22158
|
+
* specific prior written permission.
|
|
22159
|
+
*
|
|
22160
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22161
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22162
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22163
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22164
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22165
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22166
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22167
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22168
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22169
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22170
|
+
*/
|
|
22171
|
+
let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
22172
|
+
let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
22173
|
+
let LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
22174
|
+
/** @internal */
|
|
22175
|
+
function parseString(ctx) {
|
|
22176
|
+
let start = ctx.p;
|
|
22177
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
22178
|
+
let first = c;
|
|
22179
|
+
let isLiteral = c === 39;
|
|
22180
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
22181
|
+
if (isMultiline) {
|
|
22182
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10) ctx.p++;
|
|
22183
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) ctx.p += 2;
|
|
22184
|
+
}
|
|
22185
|
+
let parsed = "";
|
|
22186
|
+
let sliceStart = ctx.p;
|
|
22187
|
+
let state = 0;
|
|
22188
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
22189
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
22190
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) state = state && 3;
|
|
22191
|
+
else if (c < 32 && c !== 9 || c === 127) throw new TomlError("control characters are not allowed in strings", {
|
|
22192
|
+
toml: ctx.s,
|
|
22193
|
+
ptr: ctx.p
|
|
22194
|
+
});
|
|
22195
|
+
else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
22196
|
+
if (isMultiline) {
|
|
22197
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
|
|
22198
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
|
|
22199
|
+
}
|
|
22200
|
+
if (!state) parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
22201
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
22202
|
+
return parsed;
|
|
22203
|
+
} else if (!state) {
|
|
22204
|
+
if (!isLiteral && c === 92) {
|
|
22205
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
22206
|
+
state = 1;
|
|
22207
|
+
}
|
|
22208
|
+
} else if (state === 1) {
|
|
22209
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
22210
|
+
let value = 0;
|
|
22211
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
22212
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
22213
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
22214
|
+
let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
|
|
22215
|
+
if (digit < 0) throw new TomlError("invalid non-hex character in unicode escape", {
|
|
22216
|
+
toml: ctx.s,
|
|
22217
|
+
ptr: ctx.p + 1
|
|
22218
|
+
});
|
|
22219
|
+
value = value << 4 | digit;
|
|
22220
|
+
}
|
|
22221
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) throw new TomlError("invalid unicode escape", {
|
|
22222
|
+
toml: ctx.s,
|
|
22223
|
+
ptr: ctx.p
|
|
22224
|
+
});
|
|
22225
|
+
parsed += String.fromCodePoint(value);
|
|
22226
|
+
sliceStart = ctx.p + 1;
|
|
22227
|
+
state = 0;
|
|
22228
|
+
} else if (c === 32 || c === 9) state = 2;
|
|
22229
|
+
else {
|
|
22230
|
+
if (c === 98) parsed += "\b";
|
|
22231
|
+
else if (c === 116) parsed += " ";
|
|
22232
|
+
else if (c === 110) parsed += "\n";
|
|
22233
|
+
else if (c === 102) parsed += "\f";
|
|
22234
|
+
else if (c === 114) parsed += "\r";
|
|
22235
|
+
else if (c === 101) parsed += "\x1B";
|
|
22236
|
+
else if (c === 34) parsed += "\"";
|
|
22237
|
+
else if (c === 92) parsed += "\\";
|
|
22238
|
+
else throw new TomlError("unrecognized escape sequence", {
|
|
22239
|
+
toml: ctx.s,
|
|
22240
|
+
ptr: ctx.p
|
|
22241
|
+
});
|
|
22242
|
+
sliceStart = ctx.p + 1;
|
|
22243
|
+
state = 0;
|
|
22244
|
+
}
|
|
22245
|
+
} else if (c !== 32 && c !== 9) {
|
|
22246
|
+
if (state === 2) throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
22247
|
+
toml: ctx.s,
|
|
22248
|
+
ptr: sliceStart
|
|
22249
|
+
});
|
|
22250
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
22251
|
+
sliceStart = ctx.p;
|
|
22252
|
+
}
|
|
22253
|
+
}
|
|
22254
|
+
throw new TomlError("unfinished string", {
|
|
22255
|
+
toml: ctx.s,
|
|
22256
|
+
ptr: start
|
|
22257
|
+
});
|
|
22258
|
+
}
|
|
22259
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
22260
|
+
let value = ctx.s.slice(start, end);
|
|
22261
|
+
let commentIdx = value.indexOf("#");
|
|
22262
|
+
if (commentIdx > 0) {
|
|
22263
|
+
skipComment({
|
|
22264
|
+
s: value,
|
|
22265
|
+
p: commentIdx,
|
|
22266
|
+
d: 0
|
|
22267
|
+
});
|
|
22268
|
+
value = value.slice(0, commentIdx);
|
|
22269
|
+
}
|
|
22270
|
+
return value.trimEnd();
|
|
22271
|
+
}
|
|
22272
|
+
/** @internal */
|
|
22273
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
22274
|
+
let ptr = ctx.p;
|
|
22275
|
+
let err = {
|
|
22276
|
+
toml: ctx.s,
|
|
22277
|
+
ptr
|
|
22278
|
+
};
|
|
22279
|
+
skipUntil(ctx, 44, end);
|
|
22280
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
22281
|
+
if (!value) throw new TomlError("incomplete declaration: value expected", err);
|
|
22282
|
+
if (value === "-inf") return -Infinity;
|
|
22283
|
+
if (value === "inf" || value === "+inf") return Infinity;
|
|
22284
|
+
if (value === "nan" || value === "+nan" || value === "-nan") return NaN;
|
|
22285
|
+
if (value === "-0") return integersAsBigInt ? 0n : 0;
|
|
22286
|
+
let isInt = INT_REGEX.test(value);
|
|
22287
|
+
if (isInt || FLOAT_REGEX.test(value)) {
|
|
22288
|
+
if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed", err);
|
|
22289
|
+
value = value.replace(/_/g, "");
|
|
22290
|
+
let numeric = +value;
|
|
22291
|
+
if (isNaN(numeric)) throw new TomlError("invalid number", err);
|
|
22292
|
+
if (isInt) {
|
|
22293
|
+
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly", err);
|
|
22294
|
+
if (isInt || integersAsBigInt === true) numeric = BigInt(value);
|
|
22295
|
+
}
|
|
22296
|
+
return numeric;
|
|
22297
|
+
}
|
|
22298
|
+
const date = new TomlDate(value);
|
|
22299
|
+
if (!date.isValid()) throw new TomlError("invalid value", err);
|
|
22300
|
+
return date;
|
|
22301
|
+
}
|
|
22302
|
+
//#endregion
|
|
22303
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/extract.js
|
|
22304
|
+
/*!
|
|
22305
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22306
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22307
|
+
*
|
|
22308
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22309
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22310
|
+
*
|
|
22311
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22312
|
+
* list of conditions and the following disclaimer.
|
|
22313
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22314
|
+
* this list of conditions and the following disclaimer in the
|
|
22315
|
+
* documentation and/or other materials provided with the distribution.
|
|
22316
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22317
|
+
* may be used to endorse or promote products derived from this software without
|
|
22318
|
+
* specific prior written permission.
|
|
22319
|
+
*
|
|
22320
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22321
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22322
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22323
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22324
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22325
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22326
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22327
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22328
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22329
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22330
|
+
*/
|
|
22331
|
+
/** @internal */
|
|
22332
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
22333
|
+
let ptr = ctx.p;
|
|
22334
|
+
let c = ctx.s.charCodeAt(ptr);
|
|
22335
|
+
if (c === 91 || c === 123) {
|
|
22336
|
+
if (!ctx.d--) throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
22337
|
+
toml: ctx.s,
|
|
22338
|
+
ptr
|
|
22339
|
+
});
|
|
22340
|
+
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
22341
|
+
ctx.d++;
|
|
22342
|
+
return value;
|
|
22343
|
+
}
|
|
22344
|
+
if (c === 34 || c === 39) return parseString(ctx);
|
|
22345
|
+
if (c === 116) {
|
|
22346
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101) throw new TomlError("invalid value", {
|
|
22347
|
+
toml: ctx.s,
|
|
22348
|
+
ptr
|
|
22349
|
+
});
|
|
22350
|
+
ctx.p++;
|
|
22351
|
+
return true;
|
|
22352
|
+
}
|
|
22353
|
+
if (c === 102) {
|
|
22354
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101) throw new TomlError("invalid value", {
|
|
22355
|
+
toml: ctx.s,
|
|
22356
|
+
ptr
|
|
22357
|
+
});
|
|
22358
|
+
ctx.p++;
|
|
22359
|
+
return false;
|
|
22360
|
+
}
|
|
22361
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
22362
|
+
}
|
|
22363
|
+
//#endregion
|
|
22364
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
|
|
22365
|
+
/*!
|
|
22366
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22367
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22368
|
+
*
|
|
22369
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22370
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22371
|
+
*
|
|
22372
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22373
|
+
* list of conditions and the following disclaimer.
|
|
22374
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22375
|
+
* this list of conditions and the following disclaimer in the
|
|
22376
|
+
* documentation and/or other materials provided with the distribution.
|
|
22377
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22378
|
+
* may be used to endorse or promote products derived from this software without
|
|
22379
|
+
* specific prior written permission.
|
|
22380
|
+
*
|
|
22381
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22382
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22383
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22384
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22385
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22386
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22387
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22388
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22389
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22390
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22391
|
+
*/
|
|
22392
|
+
let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
22393
|
+
/** @internal */
|
|
22394
|
+
function parseKey(ctx, end = "=") {
|
|
22395
|
+
let start = ctx.p;
|
|
22396
|
+
let dot = start - 1;
|
|
22397
|
+
let parsed = [];
|
|
22398
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
22399
|
+
if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
22400
|
+
toml: ctx.s,
|
|
22401
|
+
ptr: start
|
|
22402
|
+
});
|
|
22403
|
+
do {
|
|
22404
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
22405
|
+
if (c !== 32 && c !== 9) {
|
|
22406
|
+
if (c === 34 || c === 39) {
|
|
22407
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) throw new TomlError("multiline strings are not allowed in keys", {
|
|
22408
|
+
toml: ctx.s,
|
|
22409
|
+
ptr: ctx.p
|
|
22410
|
+
});
|
|
22411
|
+
let part = parseString(ctx);
|
|
22412
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
22413
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
22414
|
+
let newLine = indexOfNewline(strEnd);
|
|
22415
|
+
if (newLine > -1) throw new TomlError("newlines are not allowed in keys", {
|
|
22416
|
+
toml: ctx.s,
|
|
22417
|
+
ptr: newLine
|
|
22418
|
+
});
|
|
22419
|
+
if (strEnd.trimStart()) throw new TomlError("found extra tokens after the string part", {
|
|
22420
|
+
toml: ctx.s,
|
|
22421
|
+
ptr: ctx.p
|
|
22422
|
+
});
|
|
22423
|
+
if (endPtr < ctx.p) {
|
|
22424
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
22425
|
+
if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
22426
|
+
toml: ctx.s,
|
|
22427
|
+
ptr: start
|
|
22428
|
+
});
|
|
22429
|
+
}
|
|
22430
|
+
parsed.push(part);
|
|
22431
|
+
} else {
|
|
22432
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
22433
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
22434
|
+
if (!KEY_PART_RE.test(part)) throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
22435
|
+
toml: ctx.s,
|
|
22436
|
+
ptr: ctx.p
|
|
22437
|
+
});
|
|
22438
|
+
parsed.push(part.trimEnd());
|
|
22439
|
+
}
|
|
22440
|
+
}
|
|
22441
|
+
} while (dot + 1 && dot < endPtr);
|
|
22442
|
+
ctx.p = endPtr + 1;
|
|
22443
|
+
skipVoid(ctx, true, true);
|
|
22444
|
+
return parsed;
|
|
22445
|
+
}
|
|
22446
|
+
/** @internal */
|
|
22447
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
22448
|
+
let res = {};
|
|
22449
|
+
let seen = /* @__PURE__ */ new Set();
|
|
22450
|
+
let c;
|
|
22451
|
+
ctx.p++;
|
|
22452
|
+
while (ctx.p < ctx.s.length) {
|
|
22453
|
+
skipVoid(ctx);
|
|
22454
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
22455
|
+
ctx.p++;
|
|
22456
|
+
return res;
|
|
22457
|
+
}
|
|
22458
|
+
let k;
|
|
22459
|
+
let t = res;
|
|
22460
|
+
let hasOwn = false;
|
|
22461
|
+
let p = ctx.p;
|
|
22462
|
+
let key = parseKey(ctx);
|
|
22463
|
+
for (let i = 0; i < key.length; i++) {
|
|
22464
|
+
if (i) t = hasOwn ? t[k] : t[k] = {};
|
|
22465
|
+
k = key[i];
|
|
22466
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError("trying to redefine an already defined value", {
|
|
22467
|
+
toml: ctx.s,
|
|
22468
|
+
ptr: p
|
|
22469
|
+
});
|
|
22470
|
+
if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
|
|
22471
|
+
enumerable: true,
|
|
22472
|
+
configurable: true,
|
|
22473
|
+
writable: true
|
|
22474
|
+
});
|
|
22475
|
+
}
|
|
22476
|
+
if (hasOwn) throw new TomlError("trying to redefine an already defined value", {
|
|
22477
|
+
toml: ctx.s,
|
|
22478
|
+
ptr: ctx.p
|
|
22479
|
+
});
|
|
22480
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
22481
|
+
seen.add(t[k] = value);
|
|
22482
|
+
skipVoid(ctx);
|
|
22483
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) return res;
|
|
22484
|
+
if (c !== 44) throw new TomlError("expected comma or end of structure", {
|
|
22485
|
+
toml: ctx.s,
|
|
22486
|
+
ptr: ctx.p - 1
|
|
22487
|
+
});
|
|
22488
|
+
}
|
|
22489
|
+
throw new TomlError("unfinished table encountered", {
|
|
22490
|
+
toml: ctx.s,
|
|
22491
|
+
ptr: ctx.p
|
|
22492
|
+
});
|
|
22493
|
+
}
|
|
22494
|
+
/** @internal */
|
|
22495
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
22496
|
+
let res = [];
|
|
22497
|
+
let c;
|
|
22498
|
+
ctx.p++;
|
|
22499
|
+
while (ctx.p < ctx.s.length) {
|
|
22500
|
+
skipVoid(ctx);
|
|
22501
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
22502
|
+
ctx.p++;
|
|
22503
|
+
return res;
|
|
22504
|
+
}
|
|
22505
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
22506
|
+
skipVoid(ctx);
|
|
22507
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) return res;
|
|
22508
|
+
if (c !== 44) throw new TomlError("expected comma or end of structure", {
|
|
22509
|
+
toml: ctx.s,
|
|
22510
|
+
ptr: ctx.p - 1
|
|
22511
|
+
});
|
|
22512
|
+
}
|
|
22513
|
+
throw new TomlError("unfinished array encountered", {
|
|
22514
|
+
toml: ctx.s,
|
|
22515
|
+
ptr: ctx.p
|
|
22516
|
+
});
|
|
22517
|
+
}
|
|
22518
|
+
//#endregion
|
|
22519
|
+
//#region node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
|
|
22520
|
+
/*!
|
|
22521
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22522
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22523
|
+
*
|
|
22524
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22525
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22526
|
+
*
|
|
22527
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22528
|
+
* list of conditions and the following disclaimer.
|
|
22529
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22530
|
+
* this list of conditions and the following disclaimer in the
|
|
22531
|
+
* documentation and/or other materials provided with the distribution.
|
|
22532
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22533
|
+
* may be used to endorse or promote products derived from this software without
|
|
22534
|
+
* specific prior written permission.
|
|
22535
|
+
*
|
|
22536
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22537
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22538
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22539
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22540
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22541
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22542
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22543
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22544
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22545
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22546
|
+
*/
|
|
22547
|
+
function peekTable(key, table, meta, type) {
|
|
22548
|
+
let t = table;
|
|
22549
|
+
let m = meta;
|
|
22550
|
+
let k;
|
|
22551
|
+
let hasOwn = false;
|
|
22552
|
+
let state;
|
|
22553
|
+
for (let i = 0; i < key.length; i++) {
|
|
22554
|
+
if (i) {
|
|
22555
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
22556
|
+
m = (state = m[k]).c;
|
|
22557
|
+
if (type === 0 && (state.t === 1 || state.t === 2)) return null;
|
|
22558
|
+
if (state.t === 2) {
|
|
22559
|
+
let l = t.length - 1;
|
|
22560
|
+
t = t[l];
|
|
22561
|
+
m = m[l].c;
|
|
22562
|
+
}
|
|
22563
|
+
}
|
|
22564
|
+
k = key[i];
|
|
22565
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
|
|
22566
|
+
if (!hasOwn) {
|
|
22567
|
+
if (k === "__proto__") {
|
|
22568
|
+
Object.defineProperty(t, k, {
|
|
22569
|
+
enumerable: true,
|
|
22570
|
+
configurable: true,
|
|
22571
|
+
writable: true
|
|
22572
|
+
});
|
|
22573
|
+
Object.defineProperty(m, k, {
|
|
22574
|
+
enumerable: true,
|
|
22575
|
+
configurable: true,
|
|
22576
|
+
writable: true
|
|
22577
|
+
});
|
|
22578
|
+
}
|
|
22579
|
+
m[k] = {
|
|
22580
|
+
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
22581
|
+
d: false,
|
|
22582
|
+
i: 0,
|
|
22583
|
+
c: {}
|
|
22584
|
+
};
|
|
22585
|
+
}
|
|
22586
|
+
}
|
|
22587
|
+
state = m[k];
|
|
22588
|
+
if (state.t !== type && !(type === 1 && state.t === 3)) return null;
|
|
22589
|
+
if (type === 2) {
|
|
22590
|
+
if (!state.d) {
|
|
22591
|
+
state.d = true;
|
|
22592
|
+
t[k] = [];
|
|
22593
|
+
}
|
|
22594
|
+
t[k].push(t = {});
|
|
22595
|
+
state.c[state.i++] = state = {
|
|
22596
|
+
t: 1,
|
|
22597
|
+
d: false,
|
|
22598
|
+
i: 0,
|
|
22599
|
+
c: {}
|
|
22600
|
+
};
|
|
22601
|
+
}
|
|
22602
|
+
if (state.d) return null;
|
|
22603
|
+
state.d = true;
|
|
22604
|
+
if (type === 1) t = hasOwn ? t[k] : t[k] = {};
|
|
22605
|
+
else if (type === 0 && hasOwn) return null;
|
|
22606
|
+
return [
|
|
22607
|
+
k,
|
|
22608
|
+
t,
|
|
22609
|
+
state.c
|
|
22610
|
+
];
|
|
22611
|
+
}
|
|
22612
|
+
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
22613
|
+
let ctx = {
|
|
22614
|
+
s: toml,
|
|
22615
|
+
p: 0,
|
|
22616
|
+
d: maxDepth
|
|
22617
|
+
};
|
|
22618
|
+
let res = {};
|
|
22619
|
+
let meta = {};
|
|
22620
|
+
let tmp;
|
|
22621
|
+
let tbl = res;
|
|
22622
|
+
let m = meta;
|
|
22623
|
+
skipVoid(ctx);
|
|
22624
|
+
while (ctx.p < toml.length) {
|
|
22625
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
22626
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
22627
|
+
tmp = ctx.p += +isTableArray;
|
|
22628
|
+
let k = parseKey(ctx, "]");
|
|
22629
|
+
if (isTableArray) {
|
|
22630
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) throw new TomlError("expected end of table declaration", {
|
|
22631
|
+
toml,
|
|
22632
|
+
ptr: ctx.p - 1
|
|
22633
|
+
});
|
|
22634
|
+
ctx.p++;
|
|
22635
|
+
}
|
|
22636
|
+
let p = peekTable(k, res, meta, isTableArray ? 2 : 1);
|
|
22637
|
+
if (!p) throw new TomlError("trying to redefine an already defined table or value", {
|
|
22638
|
+
toml,
|
|
22639
|
+
ptr: tmp
|
|
22640
|
+
});
|
|
22641
|
+
m = p[2];
|
|
22642
|
+
tbl = p[1];
|
|
22643
|
+
} else {
|
|
22644
|
+
tmp = ctx.p;
|
|
22645
|
+
let p = peekTable(parseKey(ctx), tbl, m, 0);
|
|
22646
|
+
if (!p) throw new TomlError("trying to redefine an already defined table or value", {
|
|
22647
|
+
toml,
|
|
22648
|
+
ptr: tmp
|
|
22649
|
+
});
|
|
22650
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
22651
|
+
}
|
|
22652
|
+
skipVoid(ctx, true);
|
|
22653
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
22654
|
+
toml,
|
|
22655
|
+
ptr: ctx.p
|
|
22656
|
+
});
|
|
22657
|
+
skipVoid(ctx);
|
|
22658
|
+
}
|
|
22659
|
+
return res;
|
|
22660
|
+
}
|
|
22661
|
+
//#endregion
|
|
22662
|
+
//#region apps/partner/runtime/config.ts
|
|
22663
|
+
/** The app-server protocol contract tested by this application. */
|
|
22664
|
+
const SUPPORTED_CODEX_VERSION = "0.154.0";
|
|
22665
|
+
const DEFAULT_CODEX_MODEL = "gpt-5.6-luna";
|
|
22666
|
+
const schema = object({
|
|
22667
|
+
name: string().min(1),
|
|
22668
|
+
persona: string().min(1),
|
|
22669
|
+
state: string().default("./state"),
|
|
22670
|
+
workspace: string().optional(),
|
|
22671
|
+
avatars: object({
|
|
22672
|
+
companion: string().min(1),
|
|
22673
|
+
user: string().min(1)
|
|
22674
|
+
}).strict().optional(),
|
|
22675
|
+
port: number().int().min(1024).max(65535).default(3082),
|
|
22676
|
+
codex: object({
|
|
22677
|
+
command: string().min(1).default("codex-app-server"),
|
|
22678
|
+
model: string().min(1).default(DEFAULT_CODEX_MODEL),
|
|
22679
|
+
version: literal(SUPPORTED_CODEX_VERSION).default(SUPPORTED_CODEX_VERSION),
|
|
22680
|
+
home: string().min(1).optional(),
|
|
22681
|
+
provenance: string().min(1).optional(),
|
|
22682
|
+
local_compaction: boolean().default(false)
|
|
22683
|
+
}).strict().default({
|
|
22684
|
+
command: "codex-app-server",
|
|
22685
|
+
model: DEFAULT_CODEX_MODEL,
|
|
22686
|
+
version: SUPPORTED_CODEX_VERSION,
|
|
22687
|
+
local_compaction: false
|
|
22688
|
+
}),
|
|
22689
|
+
speech: object({
|
|
22690
|
+
endpoint: url().default("https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation"),
|
|
22691
|
+
tts: object({
|
|
22692
|
+
provider: _enum([
|
|
22693
|
+
"minimax",
|
|
22694
|
+
"alibaba",
|
|
22695
|
+
"bytedance"
|
|
22696
|
+
]),
|
|
22697
|
+
voice: string().min(1)
|
|
22698
|
+
}).strict().optional()
|
|
22699
|
+
}).strict().optional()
|
|
22700
|
+
}).strict();
|
|
22701
|
+
async function loadConfig(path) {
|
|
22702
|
+
const config = schema.parse(parse(await readFile(path, "utf8")));
|
|
22703
|
+
const base = dirname(resolve(path));
|
|
22704
|
+
return {
|
|
22705
|
+
...config,
|
|
22706
|
+
configPath: resolve(path),
|
|
22707
|
+
state: resolve(base, config.state),
|
|
22708
|
+
persona: resolve(base, config.persona),
|
|
22709
|
+
workspace: resolve(base, config.workspace ?? `${config.state}/workspace`),
|
|
22710
|
+
avatars: config.avatars ? {
|
|
22711
|
+
companion: resolve(base, config.avatars.companion),
|
|
22712
|
+
user: resolve(base, config.avatars.user)
|
|
22713
|
+
} : void 0,
|
|
22714
|
+
codex: {
|
|
22715
|
+
...config.codex,
|
|
22716
|
+
home: config.codex.home ? resolve(base, config.codex.home) : void 0,
|
|
22717
|
+
provenance: config.codex.provenance ? resolve(base, config.codex.provenance) : void 0
|
|
22718
|
+
}
|
|
22719
|
+
};
|
|
22720
|
+
}
|
|
22721
|
+
/** Alibaba STT/TTS reuses speech; ByteDance TTS keeps its separate secret. */
|
|
22722
|
+
const credentialSchema = object({
|
|
22723
|
+
speech: string().min(1).optional(),
|
|
22724
|
+
tts: string().min(1).optional()
|
|
22725
|
+
}).strict();
|
|
22726
|
+
async function loadCredentials(state) {
|
|
22727
|
+
try {
|
|
22728
|
+
return credentialSchema.parse(JSON.parse(await readFile(resolve(state, "credentials.json"), "utf8")));
|
|
22729
|
+
} catch (error) {
|
|
22730
|
+
if (error.code === "ENOENT") return {};
|
|
22731
|
+
throw error;
|
|
22732
|
+
}
|
|
22733
|
+
}
|
|
22734
|
+
//#endregion
|
|
22735
|
+
//#region apps/partner/src/lib/companion/voice-contract.ts
|
|
22736
|
+
const PARAM_TOKEN = "[a-z0-9!#$&^_.+-]+";
|
|
22737
|
+
new RegExp(`^audio\\/[a-z0-9][a-z0-9.+-]*(?:\\s*;\\s*${PARAM_TOKEN}=${PARAM_TOKEN})*$`, "u");
|
|
22738
|
+
//#endregion
|
|
22739
|
+
//#region apps/partner/runtime/speech.ts
|
|
22740
|
+
const MAX_AUDIO_BYTES = 10485760;
|
|
22741
|
+
const MAX_RESPONSE_BYTES = Math.ceil(MAX_AUDIO_BYTES / 3) * 4 + 65536;
|
|
22742
|
+
const pending = /* @__PURE__ */ new Map();
|
|
22743
|
+
const BTD_ENDPOINT = "https://openspeech.bytedance.com/api/v3/tts/unidirectional/sse";
|
|
22744
|
+
const execFileAsync = promisify(execFile);
|
|
22745
|
+
function decode(value) {
|
|
22746
|
+
const source = value.replace(/^data:[^;,]+;base64,/u, "");
|
|
22747
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/u.test(source) || source.length % 4 === 1) return;
|
|
22748
|
+
return new Uint8Array(Buffer.from(source, "base64"));
|
|
22749
|
+
}
|
|
22750
|
+
async function bounded(response, limit) {
|
|
22751
|
+
if (!response.body) throw new Error("Missing provider response");
|
|
22752
|
+
const parts = [];
|
|
22753
|
+
let total = 0;
|
|
22754
|
+
for await (const part of response.body) {
|
|
22755
|
+
total += part.byteLength;
|
|
22756
|
+
if (total > limit) throw new Error("Provider response too large");
|
|
22757
|
+
parts.push(part);
|
|
22758
|
+
}
|
|
22759
|
+
return Buffer.concat(parts);
|
|
22760
|
+
}
|
|
22761
|
+
async function provider(options) {
|
|
22762
|
+
const init = options.provider === "alibaba" ? {
|
|
22763
|
+
method: "POST",
|
|
22764
|
+
signal: options.signal,
|
|
22765
|
+
headers: {
|
|
22766
|
+
authorization: `Bearer ${options.credential}`,
|
|
22767
|
+
"content-type": "application/json"
|
|
22768
|
+
},
|
|
22769
|
+
body: JSON.stringify({
|
|
22770
|
+
model: options.model,
|
|
22771
|
+
input: {
|
|
22772
|
+
text: options.text,
|
|
22773
|
+
voice: options.voice,
|
|
22774
|
+
language_type: "Chinese"
|
|
22775
|
+
},
|
|
22776
|
+
parameters: { format: "mp3" },
|
|
22777
|
+
stream: false
|
|
22778
|
+
})
|
|
22779
|
+
} : {
|
|
22780
|
+
method: "POST",
|
|
22781
|
+
signal: options.signal,
|
|
22782
|
+
headers: {
|
|
22783
|
+
accept: "text/event-stream",
|
|
22784
|
+
"content-type": "application/json",
|
|
22785
|
+
"X-Api-Key": options.credential,
|
|
22786
|
+
"X-Api-Resource-Id": options.model
|
|
22787
|
+
},
|
|
22788
|
+
body: JSON.stringify({
|
|
22789
|
+
user: { uid: "dsh-speech" },
|
|
22790
|
+
req_params: {
|
|
22791
|
+
text: options.text,
|
|
22792
|
+
speaker: options.voice,
|
|
22793
|
+
audio_params: {
|
|
22794
|
+
format: "mp3",
|
|
22795
|
+
sample_rate: 24e3
|
|
22796
|
+
}
|
|
22797
|
+
}
|
|
22798
|
+
})
|
|
22799
|
+
};
|
|
22800
|
+
const response = await options.fetchImpl(options.provider === "bytedance" ? BTD_ENDPOINT : options.endpoint, init);
|
|
22801
|
+
if (!response.ok) throw new Error("Speech provider rejected the request");
|
|
22802
|
+
const raw = await bounded(response, MAX_RESPONSE_BYTES);
|
|
22803
|
+
if (options.provider === "alibaba") {
|
|
22804
|
+
const audio = JSON.parse(new TextDecoder().decode(raw))?.output?.audio;
|
|
22805
|
+
let bytes = audio?.data ? decode(audio.data) : void 0;
|
|
22806
|
+
if (!bytes && audio?.url) {
|
|
22807
|
+
const r = await options.fetchImpl(audio.url, { signal: options.signal });
|
|
22808
|
+
if (!r.ok) throw new Error("Invalid provider audio");
|
|
22809
|
+
bytes = await bounded(r, MAX_AUDIO_BYTES);
|
|
22810
|
+
}
|
|
22811
|
+
if (!bytes?.byteLength || bytes.byteLength > MAX_AUDIO_BYTES) throw new Error("Invalid provider audio");
|
|
22812
|
+
return bytes;
|
|
22813
|
+
}
|
|
22814
|
+
const chunks = [];
|
|
22815
|
+
let total = 0;
|
|
22816
|
+
for (const line of new TextDecoder().decode(raw).split(/\r?\n/u)) {
|
|
22817
|
+
if (!line.trim() || line.startsWith("event:")) continue;
|
|
22818
|
+
if (!line.startsWith("data:")) throw new Error("Invalid provider response");
|
|
22819
|
+
const frame = JSON.parse(line.slice(5));
|
|
22820
|
+
if (frame.code === 0 && frame.data) {
|
|
22821
|
+
const b = decode(frame.data);
|
|
22822
|
+
if (!b || (total += b.byteLength) > MAX_AUDIO_BYTES) throw new Error("Invalid provider audio");
|
|
22823
|
+
chunks.push(b);
|
|
22824
|
+
} else if (frame.code !== 0 && frame.code !== 2e7) throw new Error("Speech provider rejected the request");
|
|
22825
|
+
}
|
|
22826
|
+
const bytes = Buffer.concat(chunks);
|
|
22827
|
+
if (!bytes.byteLength) throw new Error("Invalid provider audio");
|
|
22828
|
+
return bytes;
|
|
22829
|
+
}
|
|
22830
|
+
async function minimax(options) {
|
|
22831
|
+
await options.execFileImpl("mmx", [
|
|
22832
|
+
"--non-interactive",
|
|
22833
|
+
"speech",
|
|
22834
|
+
"synthesize",
|
|
22835
|
+
"--model",
|
|
22836
|
+
"speech-2.8-hd",
|
|
22837
|
+
"--text",
|
|
22838
|
+
options.text,
|
|
22839
|
+
"--voice",
|
|
22840
|
+
options.voice,
|
|
22841
|
+
"--format",
|
|
22842
|
+
"mp3",
|
|
22843
|
+
"--out",
|
|
22844
|
+
options.output
|
|
22845
|
+
], {
|
|
22846
|
+
signal: options.signal,
|
|
22847
|
+
timeout: 6e4,
|
|
22848
|
+
maxBuffer: 65536
|
|
22849
|
+
});
|
|
22850
|
+
const bytes = await readFile(options.output);
|
|
22851
|
+
if (!bytes.byteLength || bytes.byteLength > MAX_AUDIO_BYTES) throw new Error("Invalid MiniMax audio");
|
|
22852
|
+
}
|
|
22853
|
+
async function synthesizeSpeech(options) {
|
|
22854
|
+
const text = options.text.replace(/[\s\u00a0]+/gu, " ").trim();
|
|
22855
|
+
if (!text || Array.from(text).length > 240) throw new Error("Invalid speech passage");
|
|
22856
|
+
const profile = options.provider === "minimax" ? "speech-2.8-hd" : options.model;
|
|
22857
|
+
if (options.provider !== "minimax" && (!options.endpoint || !options.model || !options.credential)) throw new Error("Speech synthesis is unavailable");
|
|
22858
|
+
const key = createHash("sha256").update(JSON.stringify([
|
|
22859
|
+
2,
|
|
22860
|
+
options.provider,
|
|
22861
|
+
profile,
|
|
22862
|
+
options.voice,
|
|
22863
|
+
text
|
|
22864
|
+
])).digest("hex");
|
|
22865
|
+
const path = join(options.audioDir, `${key}.mp3`);
|
|
22866
|
+
try {
|
|
22867
|
+
if ((await readFile(path)).byteLength) return key;
|
|
22868
|
+
} catch {}
|
|
22869
|
+
if (pending.has(path)) return pending.get(path);
|
|
22870
|
+
const task = (async () => {
|
|
22871
|
+
const signal = AbortSignal.any([options.signal ?? new AbortController().signal, AbortSignal.timeout(6e4)]);
|
|
22872
|
+
await mkdir(options.audioDir, { recursive: true });
|
|
22873
|
+
const temp = join(options.audioDir, `.${randomUUID()}.tmp`);
|
|
22874
|
+
try {
|
|
22875
|
+
if (options.provider === "minimax") await minimax({
|
|
22876
|
+
text,
|
|
22877
|
+
voice: options.voice,
|
|
22878
|
+
output: temp,
|
|
22879
|
+
signal,
|
|
22880
|
+
execFileImpl: options.execFileImpl ?? execFileAsync
|
|
22881
|
+
});
|
|
22882
|
+
else {
|
|
22883
|
+
const bytes = await provider({
|
|
22884
|
+
provider: options.provider,
|
|
22885
|
+
endpoint: options.endpoint,
|
|
22886
|
+
model: options.model,
|
|
22887
|
+
credential: options.credential,
|
|
22888
|
+
voice: options.voice,
|
|
22889
|
+
text,
|
|
22890
|
+
signal,
|
|
22891
|
+
fetchImpl: options.fetchImpl ?? fetch
|
|
22892
|
+
});
|
|
22893
|
+
await writeFile(temp, bytes, {
|
|
22894
|
+
mode: 384,
|
|
22895
|
+
flag: "wx"
|
|
22896
|
+
});
|
|
22897
|
+
}
|
|
22898
|
+
await rename(temp, path);
|
|
22899
|
+
} finally {
|
|
22900
|
+
await unlink(temp).catch(() => void 0);
|
|
22901
|
+
}
|
|
22902
|
+
return key;
|
|
22903
|
+
})();
|
|
22904
|
+
pending.set(path, task);
|
|
22905
|
+
try {
|
|
22906
|
+
return await task;
|
|
22907
|
+
} finally {
|
|
22908
|
+
if (pending.get(path) === task) pending.delete(path);
|
|
22909
|
+
}
|
|
22910
|
+
}
|
|
22911
|
+
//#endregion
|
|
21887
22912
|
//#region apps/partner/runtime/companion-mcp.ts
|
|
21888
22913
|
const workspace = process.argv[2];
|
|
21889
22914
|
if (!workspace) throw new Error("Companion MCP requires a workspace path");
|
|
22915
|
+
const configPath = process.argv[3];
|
|
21890
22916
|
const journal = partnerPaths(workspace).relationshipJournal;
|
|
21891
22917
|
const server = new McpServer({
|
|
21892
22918
|
name: "companion",
|
|
@@ -21903,14 +22929,14 @@ const reaction = {
|
|
|
21903
22929
|
reason: string()
|
|
21904
22930
|
}).strict().optional()
|
|
21905
22931
|
};
|
|
21906
|
-
server.registerTool("
|
|
22932
|
+
server.registerTool("update_relationship", {
|
|
21907
22933
|
description: "Record a current mood or relationship reaction with concise factual reasons.",
|
|
21908
22934
|
inputSchema: reaction
|
|
21909
22935
|
}, async (input) => ({ content: [{
|
|
21910
22936
|
type: "text",
|
|
21911
22937
|
text: JSON.stringify(await updateRelationshipJournal(journal, canonicalizeRelationshipUpdate(input)))
|
|
21912
22938
|
}] }));
|
|
21913
|
-
server.registerTool("
|
|
22939
|
+
server.registerTool("set_signature", {
|
|
21914
22940
|
description: "Set a short profile signature with a concise factual reason.",
|
|
21915
22941
|
inputSchema: {
|
|
21916
22942
|
signature: string(),
|
|
@@ -21923,7 +22949,7 @@ server.registerTool("companion_set_signature", {
|
|
|
21923
22949
|
reason: canonicalizeChangeReason(input.reason)
|
|
21924
22950
|
} }))
|
|
21925
22951
|
}] }));
|
|
21926
|
-
server.registerTool("
|
|
22952
|
+
server.registerTool("read_relationship_history", {
|
|
21927
22953
|
description: "Read recent relationship state records.",
|
|
21928
22954
|
inputSchema: { limit: number().int().min(1).max(20).optional() }
|
|
21929
22955
|
}, async (input) => ({ content: [{
|
|
@@ -21942,6 +22968,46 @@ server.registerTool("roll_dice", {
|
|
|
21942
22968
|
type: "text",
|
|
21943
22969
|
text: JSON.stringify(rollDice(input))
|
|
21944
22970
|
}] }));
|
|
22971
|
+
server.registerTool("send_voice", {
|
|
22972
|
+
description: "Send one standalone Voice message. Use only for a short deliberate spoken message; it never adds a transcript.",
|
|
22973
|
+
inputSchema: { text: string().trim().min(1).max(240) }
|
|
22974
|
+
}, async ({ text }) => {
|
|
22975
|
+
try {
|
|
22976
|
+
if (!configPath) throw new Error("Voice dispatch is unavailable");
|
|
22977
|
+
const config = await loadConfig(configPath);
|
|
22978
|
+
const tts = config.speech?.tts;
|
|
22979
|
+
if (!tts) throw new Error("Voice dispatch is unavailable");
|
|
22980
|
+
const credentials = await loadCredentials(config.state);
|
|
22981
|
+
const audioDir = partnerPaths(workspace).audio;
|
|
22982
|
+
const id = tts.provider === "minimax" ? await synthesizeSpeech({
|
|
22983
|
+
...tts,
|
|
22984
|
+
text,
|
|
22985
|
+
audioDir
|
|
22986
|
+
}) : await synthesizeSpeech({
|
|
22987
|
+
...tts,
|
|
22988
|
+
endpoint: "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation",
|
|
22989
|
+
model: tts.provider === "alibaba" ? "qwen3-tts-flash" : "seed-tts-2.0",
|
|
22990
|
+
credential: tts.provider === "alibaba" ? credentials.speech ?? "" : credentials.tts ?? "",
|
|
22991
|
+
text,
|
|
22992
|
+
audioDir
|
|
22993
|
+
});
|
|
22994
|
+
return { content: [{
|
|
22995
|
+
type: "text",
|
|
22996
|
+
text: JSON.stringify({
|
|
22997
|
+
kind: "voice",
|
|
22998
|
+
audioId: id
|
|
22999
|
+
})
|
|
23000
|
+
}] };
|
|
23001
|
+
} catch (error) {
|
|
23002
|
+
return {
|
|
23003
|
+
content: [{
|
|
23004
|
+
type: "text",
|
|
23005
|
+
text: "Voice synthesis failed"
|
|
23006
|
+
}],
|
|
23007
|
+
isError: true
|
|
23008
|
+
};
|
|
23009
|
+
}
|
|
23010
|
+
});
|
|
21945
23011
|
await server.connect(new StdioServerTransport());
|
|
21946
23012
|
//#endregion
|
|
21947
23013
|
export {};
|