tarsk 0.5.39 → 0.5.40

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.
Files changed (2) hide show
  1. package/dist/index.js +346 -3660
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,36 +1,13 @@
1
1
  #!/usr/bin/env node
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
4
  var __esm = (fn, res) => function __init() {
9
5
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
6
  };
11
- var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
- };
14
7
  var __export = (target, all) => {
15
8
  for (var name in all)
16
9
  __defProp(target, name, { get: all[name], enumerable: true });
17
10
  };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
- // If the importer is in node compatibility mode or this is not an ESM
28
- // file that has been converted to a CommonJS file using a Babel-
29
- // compatible transform (i.e. "__esModule" has not been set), then set
30
- // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
33
- ));
34
11
 
35
12
  // src/core/tarsk-debug.ts
36
13
  function isTarskDebugLoggingEnabled() {
@@ -970,463 +947,6 @@ var init_database = __esm({
970
947
  }
971
948
  });
972
949
 
973
- // ../node_modules/.bun/ignore@7.0.5/node_modules/ignore/index.js
974
- var require_ignore = __commonJS({
975
- "../node_modules/.bun/ignore@7.0.5/node_modules/ignore/index.js"(exports, module) {
976
- function makeArray(subject) {
977
- return Array.isArray(subject) ? subject : [subject];
978
- }
979
- var UNDEFINED = void 0;
980
- var EMPTY = "";
981
- var SPACE = " ";
982
- var ESCAPE = "\\";
983
- var REGEX_TEST_BLANK_LINE = /^\s+$/;
984
- var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
985
- var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
986
- var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
987
- var REGEX_SPLITALL_CRLF = /\r?\n/g;
988
- var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
989
- var REGEX_TEST_TRAILING_SLASH = /\/$/;
990
- var SLASH = "/";
991
- var TMP_KEY_IGNORE = "node-ignore";
992
- if (typeof Symbol !== "undefined") {
993
- TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
994
- }
995
- var KEY_IGNORE = TMP_KEY_IGNORE;
996
- var define = (object, key, value) => {
997
- Object.defineProperty(object, key, { value });
998
- return value;
999
- };
1000
- var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
1001
- var RETURN_FALSE = () => false;
1002
- var sanitizeRange = (range) => range.replace(
1003
- REGEX_REGEXP_RANGE,
1004
- (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
1005
- );
1006
- var cleanRangeBackSlash = (slashes) => {
1007
- const { length } = slashes;
1008
- return slashes.slice(0, length - length % 2);
1009
- };
1010
- var REPLACERS = [
1011
- [
1012
- // Remove BOM
1013
- // TODO:
1014
- // Other similar zero-width characters?
1015
- /^\uFEFF/,
1016
- () => EMPTY
1017
- ],
1018
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
1019
- [
1020
- // (a\ ) -> (a )
1021
- // (a ) -> (a)
1022
- // (a ) -> (a)
1023
- // (a \ ) -> (a )
1024
- /((?:\\\\)*?)(\\?\s+)$/,
1025
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
1026
- ],
1027
- // Replace (\ ) with ' '
1028
- // (\ ) -> ' '
1029
- // (\\ ) -> '\\ '
1030
- // (\\\ ) -> '\\ '
1031
- [
1032
- /(\\+?)\s/g,
1033
- (_, m1) => {
1034
- const { length } = m1;
1035
- return m1.slice(0, length - length % 2) + SPACE;
1036
- }
1037
- ],
1038
- // Escape metacharacters
1039
- // which is written down by users but means special for regular expressions.
1040
- // > There are 12 characters with special meanings:
1041
- // > - the backslash \,
1042
- // > - the caret ^,
1043
- // > - the dollar sign $,
1044
- // > - the period or dot .,
1045
- // > - the vertical bar or pipe symbol |,
1046
- // > - the question mark ?,
1047
- // > - the asterisk or star *,
1048
- // > - the plus sign +,
1049
- // > - the opening parenthesis (,
1050
- // > - the closing parenthesis ),
1051
- // > - and the opening square bracket [,
1052
- // > - the opening curly brace {,
1053
- // > These special characters are often called "metacharacters".
1054
- [
1055
- /[\\$.|*+(){^]/g,
1056
- (match) => `\\${match}`
1057
- ],
1058
- [
1059
- // > a question mark (?) matches a single character
1060
- /(?!\\)\?/g,
1061
- () => "[^/]"
1062
- ],
1063
- // leading slash
1064
- [
1065
- // > A leading slash matches the beginning of the pathname.
1066
- // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
1067
- // A leading slash matches the beginning of the pathname
1068
- /^\//,
1069
- () => "^"
1070
- ],
1071
- // replace special metacharacter slash after the leading slash
1072
- [
1073
- /\//g,
1074
- () => "\\/"
1075
- ],
1076
- [
1077
- // > A leading "**" followed by a slash means match in all directories.
1078
- // > For example, "**/foo" matches file or directory "foo" anywhere,
1079
- // > the same as pattern "foo".
1080
- // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
1081
- // > under directory "foo".
1082
- // Notice that the '*'s have been replaced as '\\*'
1083
- /^\^*\\\*\\\*\\\//,
1084
- // '**/foo' <-> 'foo'
1085
- () => "^(?:.*\\/)?"
1086
- ],
1087
- // starting
1088
- [
1089
- // there will be no leading '/'
1090
- // (which has been replaced by section "leading slash")
1091
- // If starts with '**', adding a '^' to the regular expression also works
1092
- /^(?=[^^])/,
1093
- function startingReplacer() {
1094
- return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
1095
- }
1096
- ],
1097
- // two globstars
1098
- [
1099
- // Use lookahead assertions so that we could match more than one `'/**'`
1100
- /\\\/\\\*\\\*(?=\\\/|$)/g,
1101
- // Zero, one or several directories
1102
- // should not use '*', or it will be replaced by the next replacer
1103
- // Check if it is not the last `'/**'`
1104
- (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
1105
- ],
1106
- // normal intermediate wildcards
1107
- [
1108
- // Never replace escaped '*'
1109
- // ignore rule '\*' will match the path '*'
1110
- // 'abc.*/' -> go
1111
- // 'abc.*' -> skip this rule,
1112
- // coz trailing single wildcard will be handed by [trailing wildcard]
1113
- /(^|[^\\]+)(\\\*)+(?=.+)/g,
1114
- // '*.js' matches '.js'
1115
- // '*.js' doesn't match 'abc'
1116
- (_, p1, p2) => {
1117
- const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
1118
- return p1 + unescaped;
1119
- }
1120
- ],
1121
- [
1122
- // unescape, revert step 3 except for back slash
1123
- // For example, if a user escape a '\\*',
1124
- // after step 3, the result will be '\\\\\\*'
1125
- /\\\\\\(?=[$.|*+(){^])/g,
1126
- () => ESCAPE
1127
- ],
1128
- [
1129
- // '\\\\' -> '\\'
1130
- /\\\\/g,
1131
- () => ESCAPE
1132
- ],
1133
- [
1134
- // > The range notation, e.g. [a-zA-Z],
1135
- // > can be used to match one of the characters in a range.
1136
- // `\` is escaped by step 3
1137
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
1138
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
1139
- ],
1140
- // ending
1141
- [
1142
- // 'js' will not match 'js.'
1143
- // 'ab' will not match 'abc'
1144
- /(?:[^*])$/,
1145
- // WTF!
1146
- // https://git-scm.com/docs/gitignore
1147
- // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
1148
- // which re-fixes #24, #38
1149
- // > If there is a separator at the end of the pattern then the pattern
1150
- // > will only match directories, otherwise the pattern can match both
1151
- // > files and directories.
1152
- // 'js*' will not match 'a.js'
1153
- // 'js/' will not match 'a.js'
1154
- // 'js' will match 'a.js' and 'a.js/'
1155
- (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
1156
- ]
1157
- ];
1158
- var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
1159
- var MODE_IGNORE = "regex";
1160
- var MODE_CHECK_IGNORE = "checkRegex";
1161
- var UNDERSCORE = "_";
1162
- var TRAILING_WILD_CARD_REPLACERS = {
1163
- [MODE_IGNORE](_, p1) {
1164
- const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
1165
- return `${prefix}(?=$|\\/$)`;
1166
- },
1167
- [MODE_CHECK_IGNORE](_, p1) {
1168
- const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
1169
- return `${prefix}(?=$|\\/$)`;
1170
- }
1171
- };
1172
- var makeRegexPrefix = (pattern) => REPLACERS.reduce(
1173
- (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
1174
- pattern
1175
- );
1176
- var isString = (subject) => typeof subject === "string";
1177
- var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
1178
- var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
1179
- var IgnoreRule = class {
1180
- constructor(pattern, mark, body, ignoreCase, negative, prefix) {
1181
- this.pattern = pattern;
1182
- this.mark = mark;
1183
- this.negative = negative;
1184
- define(this, "body", body);
1185
- define(this, "ignoreCase", ignoreCase);
1186
- define(this, "regexPrefix", prefix);
1187
- }
1188
- get regex() {
1189
- const key = UNDERSCORE + MODE_IGNORE;
1190
- if (this[key]) {
1191
- return this[key];
1192
- }
1193
- return this._make(MODE_IGNORE, key);
1194
- }
1195
- get checkRegex() {
1196
- const key = UNDERSCORE + MODE_CHECK_IGNORE;
1197
- if (this[key]) {
1198
- return this[key];
1199
- }
1200
- return this._make(MODE_CHECK_IGNORE, key);
1201
- }
1202
- _make(mode, key) {
1203
- const str = this.regexPrefix.replace(
1204
- REGEX_REPLACE_TRAILING_WILDCARD,
1205
- // It does not need to bind pattern
1206
- TRAILING_WILD_CARD_REPLACERS[mode]
1207
- );
1208
- const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
1209
- return define(this, key, regex);
1210
- }
1211
- };
1212
- var createRule2 = ({
1213
- pattern,
1214
- mark
1215
- }, ignoreCase) => {
1216
- let negative = false;
1217
- let body = pattern;
1218
- if (body.indexOf("!") === 0) {
1219
- negative = true;
1220
- body = body.substr(1);
1221
- }
1222
- body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
1223
- const regexPrefix = makeRegexPrefix(body);
1224
- return new IgnoreRule(
1225
- pattern,
1226
- mark,
1227
- body,
1228
- ignoreCase,
1229
- negative,
1230
- regexPrefix
1231
- );
1232
- };
1233
- var RuleManager2 = class {
1234
- constructor(ignoreCase) {
1235
- this._ignoreCase = ignoreCase;
1236
- this._rules = [];
1237
- }
1238
- _add(pattern) {
1239
- if (pattern && pattern[KEY_IGNORE]) {
1240
- this._rules = this._rules.concat(pattern._rules._rules);
1241
- this._added = true;
1242
- return;
1243
- }
1244
- if (isString(pattern)) {
1245
- pattern = {
1246
- pattern
1247
- };
1248
- }
1249
- if (checkPattern(pattern.pattern)) {
1250
- const rule = createRule2(pattern, this._ignoreCase);
1251
- this._added = true;
1252
- this._rules.push(rule);
1253
- }
1254
- }
1255
- // @param {Array<string> | string | Ignore} pattern
1256
- add(pattern) {
1257
- this._added = false;
1258
- makeArray(
1259
- isString(pattern) ? splitPattern(pattern) : pattern
1260
- ).forEach(this._add, this);
1261
- return this._added;
1262
- }
1263
- // Test one single path without recursively checking parent directories
1264
- //
1265
- // - checkUnignored `boolean` whether should check if the path is unignored,
1266
- // setting `checkUnignored` to `false` could reduce additional
1267
- // path matching.
1268
- // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1269
- // @returns {TestResult} true if a file is ignored
1270
- test(path7, checkUnignored, mode) {
1271
- let ignored = false;
1272
- let unignored = false;
1273
- let matchedRule;
1274
- this._rules.forEach((rule) => {
1275
- const { negative } = rule;
1276
- if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
1277
- return;
1278
- }
1279
- const matched = rule[mode].test(path7);
1280
- if (!matched) {
1281
- return;
1282
- }
1283
- ignored = !negative;
1284
- unignored = negative;
1285
- matchedRule = negative ? UNDEFINED : rule;
1286
- });
1287
- const ret = {
1288
- ignored,
1289
- unignored
1290
- };
1291
- if (matchedRule) {
1292
- ret.rule = matchedRule;
1293
- }
1294
- return ret;
1295
- }
1296
- };
1297
- var throwError = (message, Ctor) => {
1298
- throw new Ctor(message);
1299
- };
1300
- var checkPath = (path7, originalPath, doThrow) => {
1301
- if (!isString(path7)) {
1302
- return doThrow(
1303
- `path must be a string, but got \`${originalPath}\``,
1304
- TypeError
1305
- );
1306
- }
1307
- if (!path7) {
1308
- return doThrow(`path must not be empty`, TypeError);
1309
- }
1310
- if (checkPath.isNotRelative(path7)) {
1311
- const r = "`path.relative()`d";
1312
- return doThrow(
1313
- `path should be a ${r} string, but got "${originalPath}"`,
1314
- RangeError
1315
- );
1316
- }
1317
- return true;
1318
- };
1319
- var isNotRelative = (path7) => REGEX_TEST_INVALID_PATH.test(path7);
1320
- checkPath.isNotRelative = isNotRelative;
1321
- checkPath.convert = (p) => p;
1322
- var Ignore = class {
1323
- constructor({
1324
- ignorecase = true,
1325
- ignoreCase = ignorecase,
1326
- allowRelativePaths = false
1327
- } = {}) {
1328
- define(this, KEY_IGNORE, true);
1329
- this._rules = new RuleManager2(ignoreCase);
1330
- this._strictPathCheck = !allowRelativePaths;
1331
- this._initCache();
1332
- }
1333
- _initCache() {
1334
- this._ignoreCache = /* @__PURE__ */ Object.create(null);
1335
- this._testCache = /* @__PURE__ */ Object.create(null);
1336
- }
1337
- add(pattern) {
1338
- if (this._rules.add(pattern)) {
1339
- this._initCache();
1340
- }
1341
- return this;
1342
- }
1343
- // legacy
1344
- addPattern(pattern) {
1345
- return this.add(pattern);
1346
- }
1347
- // @returns {TestResult}
1348
- _test(originalPath, cache, checkUnignored, slices) {
1349
- const path7 = originalPath && checkPath.convert(originalPath);
1350
- checkPath(
1351
- path7,
1352
- originalPath,
1353
- this._strictPathCheck ? throwError : RETURN_FALSE
1354
- );
1355
- return this._t(path7, cache, checkUnignored, slices);
1356
- }
1357
- checkIgnore(path7) {
1358
- if (!REGEX_TEST_TRAILING_SLASH.test(path7)) {
1359
- return this.test(path7);
1360
- }
1361
- const slices = path7.split(SLASH).filter(Boolean);
1362
- slices.pop();
1363
- if (slices.length) {
1364
- const parent = this._t(
1365
- slices.join(SLASH) + SLASH,
1366
- this._testCache,
1367
- true,
1368
- slices
1369
- );
1370
- if (parent.ignored) {
1371
- return parent;
1372
- }
1373
- }
1374
- return this._rules.test(path7, false, MODE_CHECK_IGNORE);
1375
- }
1376
- _t(path7, cache, checkUnignored, slices) {
1377
- if (path7 in cache) {
1378
- return cache[path7];
1379
- }
1380
- if (!slices) {
1381
- slices = path7.split(SLASH).filter(Boolean);
1382
- }
1383
- slices.pop();
1384
- if (!slices.length) {
1385
- return cache[path7] = this._rules.test(path7, checkUnignored, MODE_IGNORE);
1386
- }
1387
- const parent = this._t(
1388
- slices.join(SLASH) + SLASH,
1389
- cache,
1390
- checkUnignored,
1391
- slices
1392
- );
1393
- return cache[path7] = parent.ignored ? parent : this._rules.test(path7, checkUnignored, MODE_IGNORE);
1394
- }
1395
- ignores(path7) {
1396
- return this._test(path7, this._ignoreCache, false).ignored;
1397
- }
1398
- createFilter() {
1399
- return (path7) => !this.ignores(path7);
1400
- }
1401
- filter(paths) {
1402
- return makeArray(paths).filter(this.createFilter());
1403
- }
1404
- // @returns {TestResult}
1405
- test(path7) {
1406
- return this._test(path7, this._testCache, true);
1407
- }
1408
- };
1409
- var factory = (options) => new Ignore(options);
1410
- var isPathValid = (path7) => checkPath(path7 && checkPath.convert(path7), path7, RETURN_FALSE);
1411
- var setupWindows = () => {
1412
- const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
1413
- checkPath.convert = makePosix;
1414
- const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
1415
- checkPath.isNotRelative = (path7) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path7) || isNotRelative(path7);
1416
- };
1417
- if (
1418
- // Detect `process` so that it can run in browsers.
1419
- typeof process !== "undefined" && process.platform === "win32"
1420
- ) {
1421
- setupWindows();
1422
- }
1423
- module.exports = factory;
1424
- factory.default = factory;
1425
- module.exports.isPathValid = isPathValid;
1426
- define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
1427
- }
1428
- });
1429
-
1430
950
  // src/server.ts
1431
951
  import { createAdaptorServer } from "@hono/node-server";
1432
952
  import { serveStatic } from "@hono/node-server/serve-static";
@@ -1948,2804 +1468,197 @@ function extractGeneratedImageFromEvents(events) {
1948
1468
  }
1949
1469
  }
1950
1470
  }
1951
- } catch {
1952
- const refs = parseGeneratedImagePayload(event.content);
1953
- if (refs?.imageUrl) {
1954
- collected.imageUrl = refs.imageUrl;
1955
- }
1956
- if (refs?.imageData) {
1957
- collected.imageData = refs.imageData;
1958
- }
1959
- }
1960
- }
1961
- return collected;
1962
- }
1963
-
1964
- // ../shared/dist/tool-display.js
1965
- var toolDisplayRegistry = [
1966
- { name: "agent", displayName: "Subagent", activeDisplayName: "Subagent" },
1967
- { name: "ask_user", displayName: "Ask", activeDisplayName: "Asking" },
1968
- { name: "bash", displayName: "Ran", activeDisplayName: "Running" },
1969
- { name: "code_search", displayName: "Code Search", activeDisplayName: "Searching" },
1970
- { name: "edit", displayName: "Edit", activeDisplayName: "Editing" },
1971
- { name: "execute_skill_script", displayName: "Run Script", activeDisplayName: "Running Script" },
1972
- { name: "fetch", displayName: "Fetch", activeDisplayName: "Fetching" },
1973
- { name: "find", displayName: "Find", activeDisplayName: "Finding" },
1974
- { name: "find_images", displayName: "Find Images", activeDisplayName: "Finding Images" },
1975
- { name: "generate_image", displayName: "Make Image", activeDisplayName: "Making Image" },
1976
- { name: "grep", displayName: "Search", activeDisplayName: "Searching" },
1977
- { name: "ls", displayName: "List", activeDisplayName: "Listing" },
1978
- { name: "mcp", displayName: "Tool", activeDisplayName: "Tool" },
1979
- { name: "read", displayName: "Read", activeDisplayName: "Reading" },
1980
- {
1981
- name: "read_skill_reference",
1982
- displayName: "Read Reference",
1983
- activeDisplayName: "Reading Reference"
1984
- },
1985
- { name: "run_js", displayName: "Run JS", activeDisplayName: "Running JS" },
1986
- { name: "simple_grep", displayName: "Search", activeDisplayName: "Searching" },
1987
- { name: "todo", displayName: "Todo", activeDisplayName: "Updating" },
1988
- { name: "tool_search", displayName: "Find Tools", activeDisplayName: "Finding Tools" },
1989
- { name: "write", displayName: "Write", activeDisplayName: "Writing" }
1990
- ];
1991
- var displayByName = new Map(toolDisplayRegistry.map((entry) => [entry.name, entry]));
1992
-
1993
- // ../shared/dist/providers.js
1994
- var LOCAL_PROVIDER_ID = "local";
1995
- var LOCAL_PROVIDER_NAME = "Local";
1996
- var LOCAL_PROVIDER_DEFAULT_API_URL = "http://127.0.0.1:8000/v1";
1997
- var LOCAL_API_URL_ENV = "LOCAL_API_URL";
1998
- var LOCAL_API_KEY_ENV = "LOCAL_API_KEY";
1999
- function resolveLocalProviderApiUrl(envValues) {
2000
- const override = envValues[LOCAL_API_URL_ENV]?.trim();
2001
- if (override) {
2002
- return override;
2003
- }
2004
- return LOCAL_PROVIDER_DEFAULT_API_URL;
2005
- }
2006
- function isLocalProvider(providerId) {
2007
- return providerId.toLowerCase() === LOCAL_PROVIDER_ID;
2008
- }
2009
-
2010
- // ../shared/dist/web-fetch.js
2011
- var WEB_FETCH_MAX_URL_LENGTH = 2e3;
2012
- var WEB_FETCH_TIMEOUT_MS = 6e4;
2013
- var WEB_FETCH_MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
2014
- var WEB_FETCH_MAX_CONTENT_CHARS = 1e5;
2015
- var WEB_FETCH_MAX_REDIRECTS = 10;
2016
- var WEB_FETCH_CACHE_TTL_MS = 15 * 60 * 1e3;
2017
- var WEB_FETCH_CACHE_MAX_BYTES = 50 * 1024 * 1024;
2018
- var WEB_FETCH_USER_AGENT = "Tarsk-Agent-Fetch/1.0 (+https://tarsk.dev)";
2019
- var WEB_FETCH_FAST_PATH_MAX_BYTES = 32768;
2020
- var WEB_FETCH_PREAPPROVED_DOMAINS = [
2021
- "developer.mozilla.org",
2022
- "docs.npmjs.com",
2023
- "www.npmjs.com",
2024
- "registry.npmjs.org",
2025
- "github.com",
2026
- "raw.githubusercontent.com",
2027
- "stackoverflow.com",
2028
- "www.stackoverflow.com",
2029
- "en.wikipedia.org",
2030
- "pkg.go.dev",
2031
- "docs.rs",
2032
- "doc.rust-lang.org",
2033
- "bun.sh",
2034
- "docs.anthropic.com",
2035
- "platform.openai.com",
2036
- "react.dev",
2037
- "nextjs.org",
2038
- "tailwindcss.com",
2039
- "vitest.dev",
2040
- "esbuild.github.io",
2041
- "nodejs.org",
2042
- "typescriptlang.org",
2043
- "hono.dev",
2044
- "sqlite.org"
2045
- ];
2046
- function normalizeFetchHostname(hostname2) {
2047
- const lower = hostname2.toLowerCase();
2048
- return lower.startsWith("www.") ? lower.slice(4) : lower;
2049
- }
2050
- function isPreapprovedFetchDomain(hostname2) {
2051
- const normalized = normalizeFetchHostname(hostname2);
2052
- return WEB_FETCH_PREAPPROVED_DOMAINS.some((domain) => normalizeFetchHostname(domain) === normalized);
2053
- }
2054
- function isSameFetchHost(a, b) {
2055
- return normalizeFetchHostname(a) === normalizeFetchHostname(b);
2056
- }
2057
-
2058
- // ../shared/dist/explorer-media.js
2059
- var EXPLORER_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
2060
- "png",
2061
- "jpg",
2062
- "jpeg",
2063
- "gif",
2064
- "webp",
2065
- "svg",
2066
- "ico",
2067
- "bmp",
2068
- "tiff",
2069
- "tif"
2070
- ]);
2071
- var EXPLORER_VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "webm", "mov", "avi"]);
2072
- var EXPLORER_MEDIA_MIME_TYPES = {
2073
- png: "image/png",
2074
- jpg: "image/jpeg",
2075
- jpeg: "image/jpeg",
2076
- gif: "image/gif",
2077
- webp: "image/webp",
2078
- svg: "image/svg+xml",
2079
- ico: "image/x-icon",
2080
- bmp: "image/bmp",
2081
- tiff: "image/tiff",
2082
- tif: "image/tiff",
2083
- mp4: "video/mp4",
2084
- webm: "video/webm",
2085
- mov: "video/quicktime",
2086
- avi: "video/x-msvideo"
2087
- };
2088
- function getFileExtension(filename) {
2089
- const trimmed = filename.trim();
2090
- const basename5 = trimmed.split(/[/\\]/).pop() ?? trimmed;
2091
- const dotIndex = basename5.lastIndexOf(".");
2092
- if (dotIndex <= 0 || dotIndex === basename5.length - 1) {
2093
- return "";
2094
- }
2095
- return basename5.slice(dotIndex + 1).toLowerCase();
2096
- }
2097
- function getExplorerFileMediaType(path7, name) {
2098
- const ext = getFileExtension(path7) || (name ? getFileExtension(name) : "");
2099
- if (!ext) {
2100
- return null;
2101
- }
2102
- if (EXPLORER_IMAGE_EXTENSIONS.has(ext)) {
2103
- return "image";
2104
- }
2105
- if (EXPLORER_VIDEO_EXTENSIONS.has(ext)) {
2106
- return "video";
2107
- }
2108
- return null;
2109
- }
2110
-
2111
- // src/server.ts
2112
- import fs3 from "fs";
2113
- import { Hono as Hono26 } from "hono";
2114
- import { cors } from "hono/cors";
2115
- import open3 from "open";
2116
- import path5 from "path";
2117
- import { fileURLToPath as fileURLToPath2 } from "url";
2118
-
2119
- // src/agent/agent.executor.ts
2120
- import { Agent as Agent2 } from "@earendil-works/pi-agent-core";
2121
- import { streamSimple } from "@earendil-works/pi-ai";
2122
- import { resolve as resolve3, isAbsolute as isAbsolute3 } from "path";
2123
-
2124
- // src/features/mcp/mcp.status.ts
2125
- function formatMcpStatusForChat(line, options) {
2126
- const text = options?.includeLabel ? `[MCP] ${line}` : line;
2127
- return `${text}
2128
- `;
2129
- }
2130
- function createMcpThinkingEvent(content) {
2131
- return { type: "thinking", content };
2132
- }
2133
-
2134
- // src/tools/bash.ts
2135
- import { randomBytes as randomBytes2 } from "node:crypto";
2136
- import { createWriteStream, existsSync as existsSync3 } from "node:fs";
2137
- import { tmpdir } from "node:os";
2138
- import { join as join3 } from "node:path";
2139
-
2140
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
2141
- var value_exports = {};
2142
- __export(value_exports, {
2143
- HasPropertyKey: () => HasPropertyKey,
2144
- IsArray: () => IsArray,
2145
- IsAsyncIterator: () => IsAsyncIterator,
2146
- IsBigInt: () => IsBigInt,
2147
- IsBoolean: () => IsBoolean,
2148
- IsDate: () => IsDate,
2149
- IsFunction: () => IsFunction,
2150
- IsIterator: () => IsIterator,
2151
- IsNull: () => IsNull,
2152
- IsNumber: () => IsNumber,
2153
- IsObject: () => IsObject,
2154
- IsRegExp: () => IsRegExp,
2155
- IsString: () => IsString,
2156
- IsSymbol: () => IsSymbol,
2157
- IsUint8Array: () => IsUint8Array,
2158
- IsUndefined: () => IsUndefined
2159
- });
2160
- function HasPropertyKey(value, key) {
2161
- return key in value;
2162
- }
2163
- function IsAsyncIterator(value) {
2164
- return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
2165
- }
2166
- function IsArray(value) {
2167
- return Array.isArray(value);
2168
- }
2169
- function IsBigInt(value) {
2170
- return typeof value === "bigint";
2171
- }
2172
- function IsBoolean(value) {
2173
- return typeof value === "boolean";
2174
- }
2175
- function IsDate(value) {
2176
- return value instanceof globalThis.Date;
2177
- }
2178
- function IsFunction(value) {
2179
- return typeof value === "function";
2180
- }
2181
- function IsIterator(value) {
2182
- return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
2183
- }
2184
- function IsNull(value) {
2185
- return value === null;
2186
- }
2187
- function IsNumber(value) {
2188
- return typeof value === "number";
2189
- }
2190
- function IsObject(value) {
2191
- return typeof value === "object" && value !== null;
2192
- }
2193
- function IsRegExp(value) {
2194
- return value instanceof globalThis.RegExp;
2195
- }
2196
- function IsString(value) {
2197
- return typeof value === "string";
2198
- }
2199
- function IsSymbol(value) {
2200
- return typeof value === "symbol";
2201
- }
2202
- function IsUint8Array(value) {
2203
- return value instanceof globalThis.Uint8Array;
2204
- }
2205
- function IsUndefined(value) {
2206
- return value === void 0;
2207
- }
2208
-
2209
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
2210
- function ArrayType(value) {
2211
- return value.map((value2) => Visit(value2));
2212
- }
2213
- function DateType(value) {
2214
- return new Date(value.getTime());
2215
- }
2216
- function Uint8ArrayType(value) {
2217
- return new Uint8Array(value);
2218
- }
2219
- function RegExpType(value) {
2220
- return new RegExp(value.source, value.flags);
2221
- }
2222
- function ObjectType(value) {
2223
- const result = {};
2224
- for (const key of Object.getOwnPropertyNames(value)) {
2225
- result[key] = Visit(value[key]);
2226
- }
2227
- for (const key of Object.getOwnPropertySymbols(value)) {
2228
- result[key] = Visit(value[key]);
2229
- }
2230
- return result;
2231
- }
2232
- function Visit(value) {
2233
- return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
2234
- }
2235
- function Clone(value) {
2236
- return Visit(value);
2237
- }
2238
-
2239
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
2240
- function CloneType(schema, options) {
2241
- return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
2242
- }
2243
-
2244
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
2245
- function IsObject2(value) {
2246
- return value !== null && typeof value === "object";
2247
- }
2248
- function IsArray2(value) {
2249
- return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
2250
- }
2251
- function IsUndefined2(value) {
2252
- return value === void 0;
2253
- }
2254
- function IsNumber2(value) {
2255
- return typeof value === "number";
2256
- }
2257
-
2258
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/system/policy.mjs
2259
- var TypeSystemPolicy;
2260
- (function(TypeSystemPolicy2) {
2261
- TypeSystemPolicy2.InstanceMode = "default";
2262
- TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
2263
- TypeSystemPolicy2.AllowArrayObject = false;
2264
- TypeSystemPolicy2.AllowNaN = false;
2265
- TypeSystemPolicy2.AllowNullVoid = false;
2266
- function IsExactOptionalProperty(value, key) {
2267
- return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
2268
- }
2269
- TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
2270
- function IsObjectLike(value) {
2271
- const isObject = IsObject2(value);
2272
- return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
2273
- }
2274
- TypeSystemPolicy2.IsObjectLike = IsObjectLike;
2275
- function IsRecordLike(value) {
2276
- return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
2277
- }
2278
- TypeSystemPolicy2.IsRecordLike = IsRecordLike;
2279
- function IsNumberLike(value) {
2280
- return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
2281
- }
2282
- TypeSystemPolicy2.IsNumberLike = IsNumberLike;
2283
- function IsVoidLike(value) {
2284
- const isUndefined = IsUndefined2(value);
2285
- return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
2286
- }
2287
- TypeSystemPolicy2.IsVoidLike = IsVoidLike;
2288
- })(TypeSystemPolicy || (TypeSystemPolicy = {}));
2289
-
2290
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
2291
- function ImmutableArray(value) {
2292
- return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
2293
- }
2294
- function ImmutableDate(value) {
2295
- return value;
2296
- }
2297
- function ImmutableUint8Array(value) {
2298
- return value;
2299
- }
2300
- function ImmutableRegExp(value) {
2301
- return value;
2302
- }
2303
- function ImmutableObject(value) {
2304
- const result = {};
2305
- for (const key of Object.getOwnPropertyNames(value)) {
2306
- result[key] = Immutable(value[key]);
2307
- }
2308
- for (const key of Object.getOwnPropertySymbols(value)) {
2309
- result[key] = Immutable(value[key]);
2310
- }
2311
- return globalThis.Object.freeze(result);
2312
- }
2313
- function Immutable(value) {
2314
- return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
2315
- }
2316
-
2317
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
2318
- function CreateType(schema, options) {
2319
- const result = options !== void 0 ? { ...options, ...schema } : schema;
2320
- switch (TypeSystemPolicy.InstanceMode) {
2321
- case "freeze":
2322
- return Immutable(result);
2323
- case "clone":
2324
- return Clone(result);
2325
- default:
2326
- return result;
2327
- }
2328
- }
2329
-
2330
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
2331
- var TypeBoxError = class extends Error {
2332
- constructor(message) {
2333
- super(message);
2334
- }
2335
- };
2336
-
2337
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
2338
- var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
2339
- var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
2340
- var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
2341
- var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
2342
- var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
2343
-
2344
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
2345
- function IsReadonly(value) {
2346
- return IsObject(value) && value[ReadonlyKind] === "Readonly";
2347
- }
2348
- function IsOptional(value) {
2349
- return IsObject(value) && value[OptionalKind] === "Optional";
2350
- }
2351
- function IsAny(value) {
2352
- return IsKindOf(value, "Any");
2353
- }
2354
- function IsArgument(value) {
2355
- return IsKindOf(value, "Argument");
2356
- }
2357
- function IsArray3(value) {
2358
- return IsKindOf(value, "Array");
2359
- }
2360
- function IsAsyncIterator2(value) {
2361
- return IsKindOf(value, "AsyncIterator");
2362
- }
2363
- function IsBigInt2(value) {
2364
- return IsKindOf(value, "BigInt");
2365
- }
2366
- function IsBoolean2(value) {
2367
- return IsKindOf(value, "Boolean");
2368
- }
2369
- function IsComputed(value) {
2370
- return IsKindOf(value, "Computed");
2371
- }
2372
- function IsConstructor(value) {
2373
- return IsKindOf(value, "Constructor");
2374
- }
2375
- function IsDate2(value) {
2376
- return IsKindOf(value, "Date");
2377
- }
2378
- function IsFunction2(value) {
2379
- return IsKindOf(value, "Function");
2380
- }
2381
- function IsInteger(value) {
2382
- return IsKindOf(value, "Integer");
2383
- }
2384
- function IsIntersect(value) {
2385
- return IsKindOf(value, "Intersect");
2386
- }
2387
- function IsIterator2(value) {
2388
- return IsKindOf(value, "Iterator");
2389
- }
2390
- function IsKindOf(value, kind) {
2391
- return IsObject(value) && Kind in value && value[Kind] === kind;
2392
- }
2393
- function IsLiteralValue(value) {
2394
- return IsBoolean(value) || IsNumber(value) || IsString(value);
2395
- }
2396
- function IsLiteral(value) {
2397
- return IsKindOf(value, "Literal");
2398
- }
2399
- function IsMappedKey(value) {
2400
- return IsKindOf(value, "MappedKey");
2401
- }
2402
- function IsMappedResult(value) {
2403
- return IsKindOf(value, "MappedResult");
2404
- }
2405
- function IsNever(value) {
2406
- return IsKindOf(value, "Never");
2407
- }
2408
- function IsNot(value) {
2409
- return IsKindOf(value, "Not");
2410
- }
2411
- function IsNull2(value) {
2412
- return IsKindOf(value, "Null");
2413
- }
2414
- function IsNumber3(value) {
2415
- return IsKindOf(value, "Number");
2416
- }
2417
- function IsObject3(value) {
2418
- return IsKindOf(value, "Object");
2419
- }
2420
- function IsPromise(value) {
2421
- return IsKindOf(value, "Promise");
2422
- }
2423
- function IsRecord(value) {
2424
- return IsKindOf(value, "Record");
2425
- }
2426
- function IsRef(value) {
2427
- return IsKindOf(value, "Ref");
2428
- }
2429
- function IsRegExp2(value) {
2430
- return IsKindOf(value, "RegExp");
2431
- }
2432
- function IsString2(value) {
2433
- return IsKindOf(value, "String");
2434
- }
2435
- function IsSymbol2(value) {
2436
- return IsKindOf(value, "Symbol");
2437
- }
2438
- function IsTemplateLiteral(value) {
2439
- return IsKindOf(value, "TemplateLiteral");
2440
- }
2441
- function IsThis(value) {
2442
- return IsKindOf(value, "This");
2443
- }
2444
- function IsTransform(value) {
2445
- return IsObject(value) && TransformKind in value;
2446
- }
2447
- function IsTuple(value) {
2448
- return IsKindOf(value, "Tuple");
2449
- }
2450
- function IsUndefined3(value) {
2451
- return IsKindOf(value, "Undefined");
2452
- }
2453
- function IsUnion(value) {
2454
- return IsKindOf(value, "Union");
2455
- }
2456
- function IsUint8Array2(value) {
2457
- return IsKindOf(value, "Uint8Array");
2458
- }
2459
- function IsUnknown(value) {
2460
- return IsKindOf(value, "Unknown");
2461
- }
2462
- function IsUnsafe(value) {
2463
- return IsKindOf(value, "Unsafe");
2464
- }
2465
- function IsVoid(value) {
2466
- return IsKindOf(value, "Void");
2467
- }
2468
- function IsKind(value) {
2469
- return IsObject(value) && Kind in value && IsString(value[Kind]);
2470
- }
2471
- function IsSchema(value) {
2472
- return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean2(value) || IsBigInt2(value) || IsAsyncIterator2(value) || IsComputed(value) || IsConstructor(value) || IsDate2(value) || IsFunction2(value) || IsInteger(value) || IsIntersect(value) || IsIterator2(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull2(value) || IsNumber3(value) || IsObject3(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString2(value) || IsSymbol2(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array2(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
2473
- }
2474
-
2475
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
2476
- var type_exports = {};
2477
- __export(type_exports, {
2478
- IsAny: () => IsAny2,
2479
- IsArgument: () => IsArgument2,
2480
- IsArray: () => IsArray4,
2481
- IsAsyncIterator: () => IsAsyncIterator3,
2482
- IsBigInt: () => IsBigInt3,
2483
- IsBoolean: () => IsBoolean3,
2484
- IsComputed: () => IsComputed2,
2485
- IsConstructor: () => IsConstructor2,
2486
- IsDate: () => IsDate3,
2487
- IsFunction: () => IsFunction3,
2488
- IsImport: () => IsImport,
2489
- IsInteger: () => IsInteger2,
2490
- IsIntersect: () => IsIntersect2,
2491
- IsIterator: () => IsIterator3,
2492
- IsKind: () => IsKind2,
2493
- IsKindOf: () => IsKindOf2,
2494
- IsLiteral: () => IsLiteral2,
2495
- IsLiteralBoolean: () => IsLiteralBoolean,
2496
- IsLiteralNumber: () => IsLiteralNumber,
2497
- IsLiteralString: () => IsLiteralString,
2498
- IsLiteralValue: () => IsLiteralValue2,
2499
- IsMappedKey: () => IsMappedKey2,
2500
- IsMappedResult: () => IsMappedResult2,
2501
- IsNever: () => IsNever2,
2502
- IsNot: () => IsNot2,
2503
- IsNull: () => IsNull3,
2504
- IsNumber: () => IsNumber4,
2505
- IsObject: () => IsObject4,
2506
- IsOptional: () => IsOptional2,
2507
- IsPromise: () => IsPromise2,
2508
- IsProperties: () => IsProperties,
2509
- IsReadonly: () => IsReadonly2,
2510
- IsRecord: () => IsRecord2,
2511
- IsRecursive: () => IsRecursive,
2512
- IsRef: () => IsRef2,
2513
- IsRegExp: () => IsRegExp3,
2514
- IsSchema: () => IsSchema2,
2515
- IsString: () => IsString3,
2516
- IsSymbol: () => IsSymbol3,
2517
- IsTemplateLiteral: () => IsTemplateLiteral2,
2518
- IsThis: () => IsThis2,
2519
- IsTransform: () => IsTransform2,
2520
- IsTuple: () => IsTuple2,
2521
- IsUint8Array: () => IsUint8Array3,
2522
- IsUndefined: () => IsUndefined4,
2523
- IsUnion: () => IsUnion2,
2524
- IsUnionLiteral: () => IsUnionLiteral,
2525
- IsUnknown: () => IsUnknown2,
2526
- IsUnsafe: () => IsUnsafe2,
2527
- IsVoid: () => IsVoid2,
2528
- TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
2529
- });
2530
- var TypeGuardUnknownTypeError = class extends TypeBoxError {
2531
- };
2532
- var KnownTypes = [
2533
- "Argument",
2534
- "Any",
2535
- "Array",
2536
- "AsyncIterator",
2537
- "BigInt",
2538
- "Boolean",
2539
- "Computed",
2540
- "Constructor",
2541
- "Date",
2542
- "Enum",
2543
- "Function",
2544
- "Integer",
2545
- "Intersect",
2546
- "Iterator",
2547
- "Literal",
2548
- "MappedKey",
2549
- "MappedResult",
2550
- "Not",
2551
- "Null",
2552
- "Number",
2553
- "Object",
2554
- "Promise",
2555
- "Record",
2556
- "Ref",
2557
- "RegExp",
2558
- "String",
2559
- "Symbol",
2560
- "TemplateLiteral",
2561
- "This",
2562
- "Tuple",
2563
- "Undefined",
2564
- "Union",
2565
- "Uint8Array",
2566
- "Unknown",
2567
- "Void"
2568
- ];
2569
- function IsPattern(value) {
2570
- try {
2571
- new RegExp(value);
2572
- return true;
2573
- } catch {
2574
- return false;
2575
- }
2576
- }
2577
- function IsControlCharacterFree(value) {
2578
- if (!IsString(value))
2579
- return false;
2580
- for (let i = 0; i < value.length; i++) {
2581
- const code = value.charCodeAt(i);
2582
- if (code >= 7 && code <= 13 || code === 27 || code === 127) {
2583
- return false;
2584
- }
2585
- }
2586
- return true;
2587
- }
2588
- function IsAdditionalProperties(value) {
2589
- return IsOptionalBoolean(value) || IsSchema2(value);
2590
- }
2591
- function IsOptionalBigInt(value) {
2592
- return IsUndefined(value) || IsBigInt(value);
2593
- }
2594
- function IsOptionalNumber(value) {
2595
- return IsUndefined(value) || IsNumber(value);
2596
- }
2597
- function IsOptionalBoolean(value) {
2598
- return IsUndefined(value) || IsBoolean(value);
2599
- }
2600
- function IsOptionalString(value) {
2601
- return IsUndefined(value) || IsString(value);
2602
- }
2603
- function IsOptionalPattern(value) {
2604
- return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
2605
- }
2606
- function IsOptionalFormat(value) {
2607
- return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
2608
- }
2609
- function IsOptionalSchema(value) {
2610
- return IsUndefined(value) || IsSchema2(value);
2611
- }
2612
- function IsReadonly2(value) {
2613
- return IsObject(value) && value[ReadonlyKind] === "Readonly";
2614
- }
2615
- function IsOptional2(value) {
2616
- return IsObject(value) && value[OptionalKind] === "Optional";
2617
- }
2618
- function IsAny2(value) {
2619
- return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
2620
- }
2621
- function IsArgument2(value) {
2622
- return IsKindOf2(value, "Argument") && IsNumber(value.index);
2623
- }
2624
- function IsArray4(value) {
2625
- return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
2626
- }
2627
- function IsAsyncIterator3(value) {
2628
- return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
2629
- }
2630
- function IsBigInt3(value) {
2631
- return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
2632
- }
2633
- function IsBoolean3(value) {
2634
- return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
2635
- }
2636
- function IsComputed2(value) {
2637
- return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
2638
- }
2639
- function IsConstructor2(value) {
2640
- return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
2641
- }
2642
- function IsDate3(value) {
2643
- return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
2644
- }
2645
- function IsFunction3(value) {
2646
- return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
2647
- }
2648
- function IsImport(value) {
2649
- return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
2650
- }
2651
- function IsInteger2(value) {
2652
- return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
2653
- }
2654
- function IsProperties(value) {
2655
- return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
2656
- }
2657
- function IsIntersect2(value) {
2658
- return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
2659
- }
2660
- function IsIterator3(value) {
2661
- return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
2662
- }
2663
- function IsKindOf2(value, kind) {
2664
- return IsObject(value) && Kind in value && value[Kind] === kind;
2665
- }
2666
- function IsLiteralString(value) {
2667
- return IsLiteral2(value) && IsString(value.const);
2668
- }
2669
- function IsLiteralNumber(value) {
2670
- return IsLiteral2(value) && IsNumber(value.const);
2671
- }
2672
- function IsLiteralBoolean(value) {
2673
- return IsLiteral2(value) && IsBoolean(value.const);
2674
- }
2675
- function IsLiteral2(value) {
2676
- return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
2677
- }
2678
- function IsLiteralValue2(value) {
2679
- return IsBoolean(value) || IsNumber(value) || IsString(value);
2680
- }
2681
- function IsMappedKey2(value) {
2682
- return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
2683
- }
2684
- function IsMappedResult2(value) {
2685
- return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
2686
- }
2687
- function IsNever2(value) {
2688
- return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
2689
- }
2690
- function IsNot2(value) {
2691
- return IsKindOf2(value, "Not") && IsSchema2(value.not);
2692
- }
2693
- function IsNull3(value) {
2694
- return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
2695
- }
2696
- function IsNumber4(value) {
2697
- return IsKindOf2(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
2698
- }
2699
- function IsObject4(value) {
2700
- return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
2701
- }
2702
- function IsPromise2(value) {
2703
- return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
2704
- }
2705
- function IsRecord2(value) {
2706
- return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
2707
- const keys = Object.getOwnPropertyNames(schema.patternProperties);
2708
- return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
2709
- })(value);
2710
- }
2711
- function IsRecursive(value) {
2712
- return IsObject(value) && Hint in value && value[Hint] === "Recursive";
2713
- }
2714
- function IsRef2(value) {
2715
- return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
2716
- }
2717
- function IsRegExp3(value) {
2718
- return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
2719
- }
2720
- function IsString3(value) {
2721
- return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
2722
- }
2723
- function IsSymbol3(value) {
2724
- return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
2725
- }
2726
- function IsTemplateLiteral2(value) {
2727
- return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
2728
- }
2729
- function IsThis2(value) {
2730
- return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
2731
- }
2732
- function IsTransform2(value) {
2733
- return IsObject(value) && TransformKind in value;
2734
- }
2735
- function IsTuple2(value) {
2736
- return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
2737
- (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
2738
- }
2739
- function IsUndefined4(value) {
2740
- return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
2741
- }
2742
- function IsUnionLiteral(value) {
2743
- return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
2744
- }
2745
- function IsUnion2(value) {
2746
- return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
2747
- }
2748
- function IsUint8Array3(value) {
2749
- return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
2750
- }
2751
- function IsUnknown2(value) {
2752
- return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
2753
- }
2754
- function IsUnsafe2(value) {
2755
- return IsKindOf2(value, "Unsafe");
2756
- }
2757
- function IsVoid2(value) {
2758
- return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
2759
- }
2760
- function IsKind2(value) {
2761
- return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
2762
- }
2763
- function IsSchema2(value) {
2764
- return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed2(value) || IsConstructor2(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect2(value) || IsIterator3(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull3(value) || IsNumber4(value) || IsObject4(value) || IsPromise2(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array3(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
2765
- }
2766
-
2767
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
2768
- var PatternBoolean = "(true|false)";
2769
- var PatternNumber = "(0|[1-9][0-9]*)";
2770
- var PatternString = "(.*)";
2771
- var PatternNever = "(?!.*)";
2772
- var PatternBooleanExact = `^${PatternBoolean}$`;
2773
- var PatternNumberExact = `^${PatternNumber}$`;
2774
- var PatternStringExact = `^${PatternString}$`;
2775
- var PatternNeverExact = `^${PatternNever}$`;
2776
-
2777
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
2778
- function SetIncludes(T, S) {
2779
- return T.includes(S);
2780
- }
2781
- function SetDistinct(T) {
2782
- return [...new Set(T)];
2783
- }
2784
- function SetIntersect(T, S) {
2785
- return T.filter((L) => S.includes(L));
2786
- }
2787
- function SetIntersectManyResolve(T, Init) {
2788
- return T.reduce((Acc, L) => {
2789
- return SetIntersect(Acc, L);
2790
- }, Init);
2791
- }
2792
- function SetIntersectMany(T) {
2793
- return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
2794
- }
2795
- function SetUnionMany(T) {
2796
- const Acc = [];
2797
- for (const L of T)
2798
- Acc.push(...L);
2799
- return Acc;
2800
- }
2801
-
2802
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
2803
- function Any(options) {
2804
- return CreateType({ [Kind]: "Any" }, options);
2805
- }
2806
-
2807
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
2808
- function Array2(items, options) {
2809
- return CreateType({ [Kind]: "Array", type: "array", items }, options);
2810
- }
2811
-
2812
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
2813
- function Argument(index) {
2814
- return CreateType({ [Kind]: "Argument", index });
2815
- }
2816
-
2817
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
2818
- function AsyncIterator(items, options) {
2819
- return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
2820
- }
2821
-
2822
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
2823
- function Computed(target, parameters, options) {
2824
- return CreateType({ [Kind]: "Computed", target, parameters }, options);
2825
- }
2826
-
2827
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
2828
- function DiscardKey(value, key) {
2829
- const { [key]: _, ...rest } = value;
2830
- return rest;
2831
- }
2832
- function Discard(value, keys) {
2833
- return keys.reduce((acc, key) => DiscardKey(acc, key), value);
2834
- }
2835
-
2836
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
2837
- function Never(options) {
2838
- return CreateType({ [Kind]: "Never", not: {} }, options);
2839
- }
2840
-
2841
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
2842
- function MappedResult(properties) {
2843
- return CreateType({
2844
- [Kind]: "MappedResult",
2845
- properties
2846
- });
2847
- }
2848
-
2849
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
2850
- function Constructor(parameters, returns, options) {
2851
- return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
2852
- }
2853
-
2854
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
2855
- function Function(parameters, returns, options) {
2856
- return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
2857
- }
2858
-
2859
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
2860
- function UnionCreate(T, options) {
2861
- return CreateType({ [Kind]: "Union", anyOf: T }, options);
2862
- }
2863
-
2864
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
2865
- function IsUnionOptional(types) {
2866
- return types.some((type) => IsOptional(type));
2867
- }
2868
- function RemoveOptionalFromRest(types) {
2869
- return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
2870
- }
2871
- function RemoveOptionalFromType(T) {
2872
- return Discard(T, [OptionalKind]);
2873
- }
2874
- function ResolveUnion(types, options) {
2875
- const isOptional = IsUnionOptional(types);
2876
- return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
2877
- }
2878
- function UnionEvaluated(T, options) {
2879
- return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
2880
- }
2881
-
2882
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
2883
- function Union(types, options) {
2884
- return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
2885
- }
2886
-
2887
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
2888
- var TemplateLiteralParserError = class extends TypeBoxError {
2889
- };
2890
- function Unescape(pattern) {
2891
- return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
2892
- }
2893
- function IsNonEscaped(pattern, index, char) {
2894
- return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
2895
- }
2896
- function IsOpenParen(pattern, index) {
2897
- return IsNonEscaped(pattern, index, "(");
2898
- }
2899
- function IsCloseParen(pattern, index) {
2900
- return IsNonEscaped(pattern, index, ")");
2901
- }
2902
- function IsSeparator(pattern, index) {
2903
- return IsNonEscaped(pattern, index, "|");
2904
- }
2905
- function IsGroup(pattern) {
2906
- if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
2907
- return false;
2908
- let count = 0;
2909
- for (let index = 0; index < pattern.length; index++) {
2910
- if (IsOpenParen(pattern, index))
2911
- count += 1;
2912
- if (IsCloseParen(pattern, index))
2913
- count -= 1;
2914
- if (count === 0 && index !== pattern.length - 1)
2915
- return false;
2916
- }
2917
- return true;
2918
- }
2919
- function InGroup(pattern) {
2920
- return pattern.slice(1, pattern.length - 1);
2921
- }
2922
- function IsPrecedenceOr(pattern) {
2923
- let count = 0;
2924
- for (let index = 0; index < pattern.length; index++) {
2925
- if (IsOpenParen(pattern, index))
2926
- count += 1;
2927
- if (IsCloseParen(pattern, index))
2928
- count -= 1;
2929
- if (IsSeparator(pattern, index) && count === 0)
2930
- return true;
2931
- }
2932
- return false;
2933
- }
2934
- function IsPrecedenceAnd(pattern) {
2935
- for (let index = 0; index < pattern.length; index++) {
2936
- if (IsOpenParen(pattern, index))
2937
- return true;
2938
- }
2939
- return false;
2940
- }
2941
- function Or(pattern) {
2942
- let [count, start] = [0, 0];
2943
- const expressions = [];
2944
- for (let index = 0; index < pattern.length; index++) {
2945
- if (IsOpenParen(pattern, index))
2946
- count += 1;
2947
- if (IsCloseParen(pattern, index))
2948
- count -= 1;
2949
- if (IsSeparator(pattern, index) && count === 0) {
2950
- const range2 = pattern.slice(start, index);
2951
- if (range2.length > 0)
2952
- expressions.push(TemplateLiteralParse(range2));
2953
- start = index + 1;
2954
- }
2955
- }
2956
- const range = pattern.slice(start);
2957
- if (range.length > 0)
2958
- expressions.push(TemplateLiteralParse(range));
2959
- if (expressions.length === 0)
2960
- return { type: "const", const: "" };
2961
- if (expressions.length === 1)
2962
- return expressions[0];
2963
- return { type: "or", expr: expressions };
2964
- }
2965
- function And(pattern) {
2966
- function Group(value, index) {
2967
- if (!IsOpenParen(value, index))
2968
- throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
2969
- let count = 0;
2970
- for (let scan = index; scan < value.length; scan++) {
2971
- if (IsOpenParen(value, scan))
2972
- count += 1;
2973
- if (IsCloseParen(value, scan))
2974
- count -= 1;
2975
- if (count === 0)
2976
- return [index, scan];
2977
- }
2978
- throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
2979
- }
2980
- function Range(pattern2, index) {
2981
- for (let scan = index; scan < pattern2.length; scan++) {
2982
- if (IsOpenParen(pattern2, scan))
2983
- return [index, scan];
2984
- }
2985
- return [index, pattern2.length];
2986
- }
2987
- const expressions = [];
2988
- for (let index = 0; index < pattern.length; index++) {
2989
- if (IsOpenParen(pattern, index)) {
2990
- const [start, end] = Group(pattern, index);
2991
- const range = pattern.slice(start, end + 1);
2992
- expressions.push(TemplateLiteralParse(range));
2993
- index = end;
2994
- } else {
2995
- const [start, end] = Range(pattern, index);
2996
- const range = pattern.slice(start, end);
2997
- if (range.length > 0)
2998
- expressions.push(TemplateLiteralParse(range));
2999
- index = end - 1;
3000
- }
3001
- }
3002
- return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
3003
- }
3004
- function TemplateLiteralParse(pattern) {
3005
- return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
3006
- }
3007
- function TemplateLiteralParseExact(pattern) {
3008
- return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
3009
- }
3010
-
3011
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
3012
- var TemplateLiteralFiniteError = class extends TypeBoxError {
3013
- };
3014
- function IsNumberExpression(expression) {
3015
- return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
3016
- }
3017
- function IsBooleanExpression(expression) {
3018
- return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
3019
- }
3020
- function IsStringExpression(expression) {
3021
- return expression.type === "const" && expression.const === ".*";
3022
- }
3023
- function IsTemplateLiteralExpressionFinite(expression) {
3024
- return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
3025
- throw new TemplateLiteralFiniteError(`Unknown expression type`);
3026
- })();
3027
- }
3028
- function IsTemplateLiteralFinite(schema) {
3029
- const expression = TemplateLiteralParseExact(schema.pattern);
3030
- return IsTemplateLiteralExpressionFinite(expression);
3031
- }
3032
-
3033
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
3034
- var TemplateLiteralGenerateError = class extends TypeBoxError {
3035
- };
3036
- function* GenerateReduce(buffer) {
3037
- if (buffer.length === 1)
3038
- return yield* buffer[0];
3039
- for (const left of buffer[0]) {
3040
- for (const right of GenerateReduce(buffer.slice(1))) {
3041
- yield `${left}${right}`;
3042
- }
3043
- }
3044
- }
3045
- function* GenerateAnd(expression) {
3046
- return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
3047
- }
3048
- function* GenerateOr(expression) {
3049
- for (const expr of expression.expr)
3050
- yield* TemplateLiteralExpressionGenerate(expr);
3051
- }
3052
- function* GenerateConst(expression) {
3053
- return yield expression.const;
3054
- }
3055
- function* TemplateLiteralExpressionGenerate(expression) {
3056
- return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
3057
- throw new TemplateLiteralGenerateError("Unknown expression");
3058
- })();
3059
- }
3060
- function TemplateLiteralGenerate(schema) {
3061
- const expression = TemplateLiteralParseExact(schema.pattern);
3062
- return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
3063
- }
3064
-
3065
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
3066
- function Literal(value, options) {
3067
- return CreateType({
3068
- [Kind]: "Literal",
3069
- const: value,
3070
- type: typeof value
3071
- }, options);
3072
- }
3073
-
3074
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
3075
- function Boolean2(options) {
3076
- return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
3077
- }
3078
-
3079
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
3080
- function BigInt(options) {
3081
- return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
3082
- }
3083
-
3084
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
3085
- function Number2(options) {
3086
- return CreateType({ [Kind]: "Number", type: "number" }, options);
3087
- }
3088
-
3089
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
3090
- function String2(options) {
3091
- return CreateType({ [Kind]: "String", type: "string" }, options);
3092
- }
3093
-
3094
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
3095
- function* FromUnion(syntax) {
3096
- const trim = syntax.trim().replace(/"|'/g, "");
3097
- return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
3098
- const literals = trim.split("|").map((literal) => Literal(literal.trim()));
3099
- return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
3100
- })();
3101
- }
3102
- function* FromTerminal(syntax) {
3103
- if (syntax[1] !== "{") {
3104
- const L = Literal("$");
3105
- const R = FromSyntax(syntax.slice(1));
3106
- return yield* [L, ...R];
3107
- }
3108
- for (let i = 2; i < syntax.length; i++) {
3109
- if (syntax[i] === "}") {
3110
- const L = FromUnion(syntax.slice(2, i));
3111
- const R = FromSyntax(syntax.slice(i + 1));
3112
- return yield* [...L, ...R];
3113
- }
3114
- }
3115
- yield Literal(syntax);
3116
- }
3117
- function* FromSyntax(syntax) {
3118
- for (let i = 0; i < syntax.length; i++) {
3119
- if (syntax[i] === "$") {
3120
- const L = Literal(syntax.slice(0, i));
3121
- const R = FromTerminal(syntax.slice(i));
3122
- return yield* [L, ...R];
3123
- }
3124
- }
3125
- yield Literal(syntax);
3126
- }
3127
- function TemplateLiteralSyntax(syntax) {
3128
- return [...FromSyntax(syntax)];
3129
- }
3130
-
3131
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
3132
- var TemplateLiteralPatternError = class extends TypeBoxError {
3133
- };
3134
- function Escape(value) {
3135
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3136
- }
3137
- function Visit2(schema, acc) {
3138
- return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` : IsInteger(schema) ? `${acc}${PatternNumber}` : IsBigInt2(schema) ? `${acc}${PatternNumber}` : IsString2(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean2(schema) ? `${acc}${PatternBoolean}` : (() => {
3139
- throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
3140
- })();
3141
- }
3142
- function TemplateLiteralPattern(kinds) {
3143
- return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
3144
- }
3145
-
3146
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
3147
- function TemplateLiteralToUnion(schema) {
3148
- const R = TemplateLiteralGenerate(schema);
3149
- const L = R.map((S) => Literal(S));
3150
- return UnionEvaluated(L);
3151
- }
3152
-
3153
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
3154
- function TemplateLiteral(unresolved, options) {
3155
- const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
3156
- return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
3157
- }
3158
-
3159
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
3160
- function FromTemplateLiteral(templateLiteral) {
3161
- const keys = TemplateLiteralGenerate(templateLiteral);
3162
- return keys.map((key) => key.toString());
3163
- }
3164
- function FromUnion2(types) {
3165
- const result = [];
3166
- for (const type of types)
3167
- result.push(...IndexPropertyKeys(type));
3168
- return result;
3169
- }
3170
- function FromLiteral(literalValue) {
3171
- return [literalValue.toString()];
3172
- }
3173
- function IndexPropertyKeys(type) {
3174
- return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
3175
- }
3176
-
3177
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
3178
- function FromProperties(type, properties, options) {
3179
- const result = {};
3180
- for (const K2 of Object.getOwnPropertyNames(properties)) {
3181
- result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
3182
- }
3183
- return result;
3184
- }
3185
- function FromMappedResult(type, mappedResult, options) {
3186
- return FromProperties(type, mappedResult.properties, options);
3187
- }
3188
- function IndexFromMappedResult(type, mappedResult, options) {
3189
- const properties = FromMappedResult(type, mappedResult, options);
3190
- return MappedResult(properties);
3191
- }
3192
-
3193
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
3194
- function FromRest(types, key) {
3195
- return types.map((type) => IndexFromPropertyKey(type, key));
3196
- }
3197
- function FromIntersectRest(types) {
3198
- return types.filter((type) => !IsNever(type));
3199
- }
3200
- function FromIntersect(types, key) {
3201
- return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
3202
- }
3203
- function FromUnionRest(types) {
3204
- return types.some((L) => IsNever(L)) ? [] : types;
3205
- }
3206
- function FromUnion3(types, key) {
3207
- return UnionEvaluated(FromUnionRest(FromRest(types, key)));
3208
- }
3209
- function FromTuple(types, key) {
3210
- return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
3211
- }
3212
- function FromArray(type, key) {
3213
- return key === "[number]" ? type : Never();
3214
- }
3215
- function FromProperty(properties, propertyKey) {
3216
- return propertyKey in properties ? properties[propertyKey] : Never();
3217
- }
3218
- function IndexFromPropertyKey(type, propertyKey) {
3219
- return IsIntersect(type) ? FromIntersect(type.allOf, propertyKey) : IsUnion(type) ? FromUnion3(type.anyOf, propertyKey) : IsTuple(type) ? FromTuple(type.items ?? [], propertyKey) : IsArray3(type) ? FromArray(type.items, propertyKey) : IsObject3(type) ? FromProperty(type.properties, propertyKey) : Never();
3220
- }
3221
- function IndexFromPropertyKeys(type, propertyKeys) {
3222
- return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
3223
- }
3224
- function FromSchema(type, propertyKeys) {
3225
- return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
3226
- }
3227
- function Index(type, key, options) {
3228
- if (IsRef(type) || IsRef(key)) {
3229
- const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
3230
- if (!IsSchema(type) || !IsSchema(key))
3231
- throw new TypeBoxError(error);
3232
- return Computed("Index", [type, key]);
3233
- }
3234
- if (IsMappedResult(key))
3235
- return IndexFromMappedResult(type, key, options);
3236
- if (IsMappedKey(key))
3237
- return IndexFromMappedKey(type, key, options);
3238
- return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
3239
- }
3240
-
3241
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
3242
- function MappedIndexPropertyKey(type, key, options) {
3243
- return { [key]: Index(type, [key], Clone(options)) };
3244
- }
3245
- function MappedIndexPropertyKeys(type, propertyKeys, options) {
3246
- return propertyKeys.reduce((result, left) => {
3247
- return { ...result, ...MappedIndexPropertyKey(type, left, options) };
3248
- }, {});
3249
- }
3250
- function MappedIndexProperties(type, mappedKey, options) {
3251
- return MappedIndexPropertyKeys(type, mappedKey.keys, options);
3252
- }
3253
- function IndexFromMappedKey(type, mappedKey, options) {
3254
- const properties = MappedIndexProperties(type, mappedKey, options);
3255
- return MappedResult(properties);
3256
- }
3257
-
3258
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
3259
- function Iterator(items, options) {
3260
- return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
3261
- }
3262
-
3263
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
3264
- function RequiredArray(properties) {
3265
- return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
3266
- }
3267
- function _Object(properties, options) {
3268
- const required = RequiredArray(properties);
3269
- const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
3270
- return CreateType(schema, options);
3271
- }
3272
- var Object2 = _Object;
3273
-
3274
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
3275
- function Promise2(item, options) {
3276
- return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
3277
- }
3278
-
3279
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
3280
- function RemoveReadonly(schema) {
3281
- return CreateType(Discard(schema, [ReadonlyKind]));
3282
- }
3283
- function AddReadonly(schema) {
3284
- return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
3285
- }
3286
- function ReadonlyWithFlag(schema, F) {
3287
- return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
3288
- }
3289
- function Readonly(schema, enable) {
3290
- const F = enable ?? true;
3291
- return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
3292
- }
3293
-
3294
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
3295
- function FromProperties2(K, F) {
3296
- const Acc = {};
3297
- for (const K2 of globalThis.Object.getOwnPropertyNames(K))
3298
- Acc[K2] = Readonly(K[K2], F);
3299
- return Acc;
3300
- }
3301
- function FromMappedResult2(R, F) {
3302
- return FromProperties2(R.properties, F);
3303
- }
3304
- function ReadonlyFromMappedResult(R, F) {
3305
- const P = FromMappedResult2(R, F);
3306
- return MappedResult(P);
3307
- }
3308
-
3309
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
3310
- function Tuple(types, options) {
3311
- return CreateType(types.length > 0 ? { [Kind]: "Tuple", type: "array", items: types, additionalItems: false, minItems: types.length, maxItems: types.length } : { [Kind]: "Tuple", type: "array", minItems: types.length, maxItems: types.length }, options);
3312
- }
3313
-
3314
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
3315
- function FromMappedResult3(K, P) {
3316
- return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
3317
- }
3318
- function MappedKeyToKnownMappedResultProperties(K) {
3319
- return { [K]: Literal(K) };
3320
- }
3321
- function MappedKeyToUnknownMappedResultProperties(P) {
3322
- const Acc = {};
3323
- for (const L of P)
3324
- Acc[L] = Literal(L);
3325
- return Acc;
3326
- }
3327
- function MappedKeyToMappedResultProperties(K, P) {
3328
- return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
3329
- }
3330
- function FromMappedKey(K, P) {
3331
- const R = MappedKeyToMappedResultProperties(K, P);
3332
- return FromMappedResult3(K, R);
3333
- }
3334
- function FromRest2(K, T) {
3335
- return T.map((L) => FromSchemaType(K, L));
3336
- }
3337
- function FromProperties3(K, T) {
3338
- const Acc = {};
3339
- for (const K2 of globalThis.Object.getOwnPropertyNames(T))
3340
- Acc[K2] = FromSchemaType(K, T[K2]);
3341
- return Acc;
3342
- }
3343
- function FromSchemaType(K, T) {
3344
- const options = { ...T };
3345
- return (
3346
- // unevaluated modifier types
3347
- IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
3348
- // unevaluated mapped types
3349
- IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
3350
- // unevaluated types
3351
- IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction2(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator2(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator2(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect(T) ? Intersect(FromRest2(K, T.allOf), options) : IsUnion(T) ? Union(FromRest2(K, T.anyOf), options) : IsTuple(T) ? Tuple(FromRest2(K, T.items ?? []), options) : IsObject3(T) ? Object2(FromProperties3(K, T.properties), options) : IsArray3(T) ? Array2(FromSchemaType(K, T.items), options) : IsPromise(T) ? Promise2(FromSchemaType(K, T.item), options) : T
3352
- )
3353
- )
3354
- );
3355
- }
3356
- function MappedFunctionReturnType(K, T) {
3357
- const Acc = {};
3358
- for (const L of K)
3359
- Acc[L] = FromSchemaType(L, T);
3360
- return Acc;
3361
- }
3362
- function Mapped(key, map, options) {
3363
- const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
3364
- const RT = map({ [Kind]: "MappedKey", keys: K });
3365
- const R = MappedFunctionReturnType(K, RT);
3366
- return Object2(R, options);
3367
- }
3368
-
3369
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
3370
- function RemoveOptional(schema) {
3371
- return CreateType(Discard(schema, [OptionalKind]));
3372
- }
3373
- function AddOptional(schema) {
3374
- return CreateType({ ...schema, [OptionalKind]: "Optional" });
3375
- }
3376
- function OptionalWithFlag(schema, F) {
3377
- return F === false ? RemoveOptional(schema) : AddOptional(schema);
3378
- }
3379
- function Optional(schema, enable) {
3380
- const F = enable ?? true;
3381
- return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
3382
- }
3383
-
3384
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
3385
- function FromProperties4(P, F) {
3386
- const Acc = {};
3387
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3388
- Acc[K2] = Optional(P[K2], F);
3389
- return Acc;
3390
- }
3391
- function FromMappedResult4(R, F) {
3392
- return FromProperties4(R.properties, F);
3393
- }
3394
- function OptionalFromMappedResult(R, F) {
3395
- const P = FromMappedResult4(R, F);
3396
- return MappedResult(P);
3397
- }
3398
-
3399
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
3400
- function IntersectCreate(T, options = {}) {
3401
- const allObjects = T.every((schema) => IsObject3(schema));
3402
- const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
3403
- return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
3404
- }
3405
-
3406
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
3407
- function IsIntersectOptional(types) {
3408
- return types.every((left) => IsOptional(left));
3409
- }
3410
- function RemoveOptionalFromType2(type) {
3411
- return Discard(type, [OptionalKind]);
3412
- }
3413
- function RemoveOptionalFromRest2(types) {
3414
- return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
3415
- }
3416
- function ResolveIntersect(types, options) {
3417
- return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
3418
- }
3419
- function IntersectEvaluated(types, options = {}) {
3420
- if (types.length === 1)
3421
- return CreateType(types[0], options);
3422
- if (types.length === 0)
3423
- return Never(options);
3424
- if (types.some((schema) => IsTransform(schema)))
3425
- throw new Error("Cannot intersect transform types");
3426
- return ResolveIntersect(types, options);
3427
- }
3428
-
3429
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
3430
- function Intersect(types, options) {
3431
- if (types.length === 1)
3432
- return CreateType(types[0], options);
3433
- if (types.length === 0)
3434
- return Never(options);
3435
- if (types.some((schema) => IsTransform(schema)))
3436
- throw new Error("Cannot intersect transform types");
3437
- return IntersectCreate(types, options);
3438
- }
3439
-
3440
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
3441
- function Ref(...args2) {
3442
- const [$ref, options] = typeof args2[0] === "string" ? [args2[0], args2[1]] : [args2[0].$id, args2[1]];
3443
- if (typeof $ref !== "string")
3444
- throw new TypeBoxError("Ref: $ref must be a string");
3445
- return CreateType({ [Kind]: "Ref", $ref }, options);
3446
- }
3447
-
3448
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
3449
- function FromComputed(target, parameters) {
3450
- return Computed("Awaited", [Computed(target, parameters)]);
3451
- }
3452
- function FromRef($ref) {
3453
- return Computed("Awaited", [Ref($ref)]);
3454
- }
3455
- function FromIntersect2(types) {
3456
- return Intersect(FromRest3(types));
3457
- }
3458
- function FromUnion4(types) {
3459
- return Union(FromRest3(types));
3460
- }
3461
- function FromPromise(type) {
3462
- return Awaited(type);
3463
- }
3464
- function FromRest3(types) {
3465
- return types.map((type) => Awaited(type));
3466
- }
3467
- function Awaited(type, options) {
3468
- return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
3469
- }
3470
-
3471
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
3472
- function FromRest4(types) {
3473
- const result = [];
3474
- for (const L of types)
3475
- result.push(KeyOfPropertyKeys(L));
3476
- return result;
3477
- }
3478
- function FromIntersect3(types) {
3479
- const propertyKeysArray = FromRest4(types);
3480
- const propertyKeys = SetUnionMany(propertyKeysArray);
3481
- return propertyKeys;
3482
- }
3483
- function FromUnion5(types) {
3484
- const propertyKeysArray = FromRest4(types);
3485
- const propertyKeys = SetIntersectMany(propertyKeysArray);
3486
- return propertyKeys;
3487
- }
3488
- function FromTuple2(types) {
3489
- return types.map((_, indexer) => indexer.toString());
3490
- }
3491
- function FromArray2(_) {
3492
- return ["[number]"];
3493
- }
3494
- function FromProperties5(T) {
3495
- return globalThis.Object.getOwnPropertyNames(T);
3496
- }
3497
- function FromPatternProperties(patternProperties) {
3498
- if (!includePatternProperties)
3499
- return [];
3500
- const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
3501
- return patternPropertyKeys.map((key) => {
3502
- return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
3503
- });
3504
- }
3505
- function KeyOfPropertyKeys(type) {
3506
- return IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion5(type.anyOf) : IsTuple(type) ? FromTuple2(type.items ?? []) : IsArray3(type) ? FromArray2(type.items) : IsObject3(type) ? FromProperties5(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
3507
- }
3508
- var includePatternProperties = false;
3509
-
3510
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
3511
- function FromComputed2(target, parameters) {
3512
- return Computed("KeyOf", [Computed(target, parameters)]);
3513
- }
3514
- function FromRef2($ref) {
3515
- return Computed("KeyOf", [Ref($ref)]);
3516
- }
3517
- function KeyOfFromType(type, options) {
3518
- const propertyKeys = KeyOfPropertyKeys(type);
3519
- const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
3520
- const result = UnionEvaluated(propertyKeyTypes);
3521
- return CreateType(result, options);
3522
- }
3523
- function KeyOfPropertyKeysToRest(propertyKeys) {
3524
- return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
3525
- }
3526
- function KeyOf(type, options) {
3527
- return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
3528
- }
3529
-
3530
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
3531
- function FromProperties6(properties, options) {
3532
- const result = {};
3533
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
3534
- result[K2] = KeyOf(properties[K2], Clone(options));
3535
- return result;
3536
- }
3537
- function FromMappedResult5(mappedResult, options) {
3538
- return FromProperties6(mappedResult.properties, options);
3539
- }
3540
- function KeyOfFromMappedResult(mappedResult, options) {
3541
- const properties = FromMappedResult5(mappedResult, options);
3542
- return MappedResult(properties);
3543
- }
3544
-
3545
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
3546
- function CompositeKeys(T) {
3547
- const Acc = [];
3548
- for (const L of T)
3549
- Acc.push(...KeyOfPropertyKeys(L));
3550
- return SetDistinct(Acc);
3551
- }
3552
- function FilterNever(T) {
3553
- return T.filter((L) => !IsNever(L));
3554
- }
3555
- function CompositeProperty(T, K) {
3556
- const Acc = [];
3557
- for (const L of T)
3558
- Acc.push(...IndexFromPropertyKeys(L, [K]));
3559
- return FilterNever(Acc);
3560
- }
3561
- function CompositeProperties(T, K) {
3562
- const Acc = {};
3563
- for (const L of K) {
3564
- Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
3565
- }
3566
- return Acc;
3567
- }
3568
- function Composite(T, options) {
3569
- const K = CompositeKeys(T);
3570
- const P = CompositeProperties(T, K);
3571
- const R = Object2(P, options);
3572
- return R;
3573
- }
3574
-
3575
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
3576
- function Date2(options) {
3577
- return CreateType({ [Kind]: "Date", type: "Date" }, options);
3578
- }
3579
-
3580
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
3581
- function Null(options) {
3582
- return CreateType({ [Kind]: "Null", type: "null" }, options);
3583
- }
3584
-
3585
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
3586
- function Symbol2(options) {
3587
- return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
3588
- }
3589
-
3590
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
3591
- function Undefined(options) {
3592
- return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
3593
- }
3594
-
3595
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
3596
- function Uint8Array2(options) {
3597
- return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
3598
- }
3599
-
3600
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
3601
- function Unknown(options) {
3602
- return CreateType({ [Kind]: "Unknown" }, options);
3603
- }
3604
-
3605
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
3606
- function FromArray3(T) {
3607
- return T.map((L) => FromValue(L, false));
3608
- }
3609
- function FromProperties7(value) {
3610
- const Acc = {};
3611
- for (const K of globalThis.Object.getOwnPropertyNames(value))
3612
- Acc[K] = Readonly(FromValue(value[K], false));
3613
- return Acc;
3614
- }
3615
- function ConditionalReadonly(T, root) {
3616
- return root === true ? T : Readonly(T);
3617
- }
3618
- function FromValue(value, root) {
3619
- return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ? BigInt() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
3620
- }
3621
- function Const(T, options) {
3622
- return CreateType(FromValue(T, true), options);
3623
- }
3624
-
3625
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
3626
- function ConstructorParameters(schema, options) {
3627
- return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
3628
- }
3629
-
3630
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
3631
- function Enum(item, options) {
3632
- if (IsUndefined(item))
3633
- throw new Error("Enum undefined or empty");
3634
- const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
3635
- const values2 = [...new Set(values1)];
3636
- const anyOf = values2.map((value) => Literal(value));
3637
- return Union(anyOf, { ...options, [Hint]: "Enum" });
3638
- }
3639
-
3640
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
3641
- var ExtendsResolverError = class extends TypeBoxError {
3642
- };
3643
- var ExtendsResult;
3644
- (function(ExtendsResult2) {
3645
- ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
3646
- ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
3647
- ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
3648
- })(ExtendsResult || (ExtendsResult = {}));
3649
- function IntoBooleanResult(result) {
3650
- return result === ExtendsResult.False ? result : ExtendsResult.True;
3651
- }
3652
- function Throw(message) {
3653
- throw new ExtendsResolverError(message);
3654
- }
3655
- function IsStructuralRight(right) {
3656
- return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
3657
- }
3658
- function StructuralRight(left, right) {
3659
- return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
3660
- }
3661
- function FromAnyRight(left, right) {
3662
- return ExtendsResult.True;
3663
- }
3664
- function FromAny(left, right) {
3665
- return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) && right.anyOf.some((schema) => type_exports.IsAny(schema) || type_exports.IsUnknown(schema)) ? ExtendsResult.True : type_exports.IsUnion(right) ? ExtendsResult.Union : type_exports.IsUnknown(right) ? ExtendsResult.True : type_exports.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
3666
- }
3667
- function FromArrayRight(left, right) {
3668
- return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
3669
- }
3670
- function FromArray4(left, right) {
3671
- return type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
3672
- }
3673
- function FromAsyncIterator(left, right) {
3674
- return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
3675
- }
3676
- function FromBigInt(left, right) {
3677
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
3678
- }
3679
- function FromBooleanRight(left, right) {
3680
- return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
3681
- }
3682
- function FromBoolean(left, right) {
3683
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
3684
- }
3685
- function FromConstructor(left, right) {
3686
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
3687
- }
3688
- function FromDate(left, right) {
3689
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
3690
- }
3691
- function FromFunction(left, right) {
3692
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
3693
- }
3694
- function FromIntegerRight(left, right) {
3695
- return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
3696
- }
3697
- function FromInteger(left, right) {
3698
- return type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
3699
- }
3700
- function FromIntersectRight(left, right) {
3701
- return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3702
- }
3703
- function FromIntersect4(left, right) {
3704
- return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3705
- }
3706
- function FromIterator(left, right) {
3707
- return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
3708
- }
3709
- function FromLiteral2(left, right) {
3710
- return type_exports.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
3711
- }
3712
- function FromNeverRight(left, right) {
3713
- return ExtendsResult.False;
3714
- }
3715
- function FromNever(left, right) {
3716
- return ExtendsResult.True;
3717
- }
3718
- function UnwrapTNot(schema) {
3719
- let [current, depth] = [schema, 0];
3720
- while (true) {
3721
- if (!type_exports.IsNot(current))
3722
- break;
3723
- current = current.not;
3724
- depth += 1;
3725
- }
3726
- return depth % 2 === 0 ? current : Unknown();
3727
- }
3728
- function FromNot(left, right) {
3729
- return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
3730
- }
3731
- function FromNull(left, right) {
3732
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
3733
- }
3734
- function FromNumberRight(left, right) {
3735
- return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
3736
- }
3737
- function FromNumber(left, right) {
3738
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
3739
- }
3740
- function IsObjectPropertyCount(schema, count) {
3741
- return Object.getOwnPropertyNames(schema.properties).length === count;
3742
- }
3743
- function IsObjectStringLike(schema) {
3744
- return IsObjectArrayLike(schema);
3745
- }
3746
- function IsObjectSymbolLike(schema) {
3747
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && type_exports.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (type_exports.IsString(schema.properties.description.anyOf[0]) && type_exports.IsUndefined(schema.properties.description.anyOf[1]) || type_exports.IsString(schema.properties.description.anyOf[1]) && type_exports.IsUndefined(schema.properties.description.anyOf[0]));
3748
- }
3749
- function IsObjectNumberLike(schema) {
3750
- return IsObjectPropertyCount(schema, 0);
3751
- }
3752
- function IsObjectBooleanLike(schema) {
3753
- return IsObjectPropertyCount(schema, 0);
3754
- }
3755
- function IsObjectBigIntLike(schema) {
3756
- return IsObjectPropertyCount(schema, 0);
3757
- }
3758
- function IsObjectDateLike(schema) {
3759
- return IsObjectPropertyCount(schema, 0);
3760
- }
3761
- function IsObjectUint8ArrayLike(schema) {
3762
- return IsObjectArrayLike(schema);
3763
- }
3764
- function IsObjectFunctionLike(schema) {
3765
- const length = Number2();
3766
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
3767
- }
3768
- function IsObjectConstructorLike(schema) {
3769
- return IsObjectPropertyCount(schema, 0);
3770
- }
3771
- function IsObjectArrayLike(schema) {
3772
- const length = Number2();
3773
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
3774
- }
3775
- function IsObjectPromiseLike(schema) {
3776
- const then = Function([Any()], Any());
3777
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
3778
- }
3779
- function Property(left, right) {
3780
- return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
3781
- }
3782
- function FromObjectRight(left, right) {
3783
- return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) || type_exports.IsLiteralString(left) && IsObjectStringLike(right) || type_exports.IsLiteralNumber(left) && IsObjectNumberLike(right) || type_exports.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsBigInt(left) && IsObjectBigIntLike(right) || type_exports.IsString(left) && IsObjectStringLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsNumber(left) && IsObjectNumberLike(right) || type_exports.IsInteger(left) && IsObjectNumberLike(right) || type_exports.IsBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || type_exports.IsDate(left) && IsObjectDateLike(right) || type_exports.IsConstructor(left) && IsObjectConstructorLike(right) || type_exports.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : type_exports.IsRecord(left) && type_exports.IsString(RecordKey(left)) ? (() => {
3784
- return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
3785
- })() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
3786
- return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
3787
- })() : ExtendsResult.False;
3788
- }
3789
- function FromObject(left, right) {
3790
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
3791
- for (const key of Object.getOwnPropertyNames(right.properties)) {
3792
- if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
3793
- return ExtendsResult.False;
3794
- }
3795
- if (type_exports.IsOptional(right.properties[key])) {
3796
- return ExtendsResult.True;
3797
- }
3798
- if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
3799
- return ExtendsResult.False;
3800
- }
3801
- }
3802
- return ExtendsResult.True;
3803
- })();
3804
- }
3805
- function FromPromise2(left, right) {
3806
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !type_exports.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
3807
- }
3808
- function RecordKey(schema) {
3809
- return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
3810
- }
3811
- function RecordValue(schema) {
3812
- return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
3813
- }
3814
- function FromRecordRight(left, right) {
3815
- const [Key, Value] = [RecordKey(right), RecordValue(right)];
3816
- return type_exports.IsLiteralString(left) && type_exports.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : type_exports.IsUint8Array(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsString(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsArray(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsObject(left) ? (() => {
3817
- for (const key of Object.getOwnPropertyNames(left.properties)) {
3818
- if (Property(Value, left.properties[key]) === ExtendsResult.False) {
3819
- return ExtendsResult.False;
3820
- }
3821
- }
3822
- return ExtendsResult.True;
3823
- })() : ExtendsResult.False;
3824
- }
3825
- function FromRecord(left, right) {
3826
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
3827
- }
3828
- function FromRegExp(left, right) {
3829
- const L = type_exports.IsRegExp(left) ? String2() : left;
3830
- const R = type_exports.IsRegExp(right) ? String2() : right;
3831
- return Visit3(L, R);
3832
- }
3833
- function FromStringRight(left, right) {
3834
- return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
3835
- }
3836
- function FromString(left, right) {
3837
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
3838
- }
3839
- function FromSymbol(left, right) {
3840
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
3841
- }
3842
- function FromTemplateLiteral2(left, right) {
3843
- return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
3844
- }
3845
- function IsArrayOfTuple(left, right) {
3846
- return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
3847
- }
3848
- function FromTupleRight(left, right) {
3849
- return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
3850
- }
3851
- function FromTuple3(left, right) {
3852
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : type_exports.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !type_exports.IsTuple(right) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) || !value_exports.IsUndefined(left.items) && value_exports.IsUndefined(right.items) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit3(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3853
- }
3854
- function FromUint8Array(left, right) {
3855
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
3856
- }
3857
- function FromUndefined(left, right) {
3858
- return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsVoid(right) ? FromVoidRight(left, right) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
3859
- }
3860
- function FromUnionRight(left, right) {
3861
- return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3862
- }
3863
- function FromUnion6(left, right) {
3864
- return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3865
- }
3866
- function FromUnknownRight(left, right) {
3867
- return ExtendsResult.True;
3868
- }
3869
- function FromUnknown(left, right) {
3870
- return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : type_exports.IsArray(right) ? FromArrayRight(left, right) : type_exports.IsTuple(right) ? FromTupleRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
3871
- }
3872
- function FromVoidRight(left, right) {
3873
- return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
3874
- }
3875
- function FromVoid(left, right) {
3876
- return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
3877
- }
3878
- function Visit3(left, right) {
3879
- return (
3880
- // resolvable
3881
- type_exports.IsTemplateLiteral(left) || type_exports.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : type_exports.IsRegExp(left) || type_exports.IsRegExp(right) ? FromRegExp(left, right) : type_exports.IsNot(left) || type_exports.IsNot(right) ? FromNot(left, right) : (
3882
- // standard
3883
- type_exports.IsAny(left) ? FromAny(left, right) : type_exports.IsArray(left) ? FromArray4(left, right) : type_exports.IsBigInt(left) ? FromBigInt(left, right) : type_exports.IsBoolean(left) ? FromBoolean(left, right) : type_exports.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : type_exports.IsConstructor(left) ? FromConstructor(left, right) : type_exports.IsDate(left) ? FromDate(left, right) : type_exports.IsFunction(left) ? FromFunction(left, right) : type_exports.IsInteger(left) ? FromInteger(left, right) : type_exports.IsIntersect(left) ? FromIntersect4(left, right) : type_exports.IsIterator(left) ? FromIterator(left, right) : type_exports.IsLiteral(left) ? FromLiteral2(left, right) : type_exports.IsNever(left) ? FromNever(left, right) : type_exports.IsNull(left) ? FromNull(left, right) : type_exports.IsNumber(left) ? FromNumber(left, right) : type_exports.IsObject(left) ? FromObject(left, right) : type_exports.IsRecord(left) ? FromRecord(left, right) : type_exports.IsString(left) ? FromString(left, right) : type_exports.IsSymbol(left) ? FromSymbol(left, right) : type_exports.IsTuple(left) ? FromTuple3(left, right) : type_exports.IsPromise(left) ? FromPromise2(left, right) : type_exports.IsUint8Array(left) ? FromUint8Array(left, right) : type_exports.IsUndefined(left) ? FromUndefined(left, right) : type_exports.IsUnion(left) ? FromUnion6(left, right) : type_exports.IsUnknown(left) ? FromUnknown(left, right) : type_exports.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`)
3884
- )
3885
- );
3886
- }
3887
- function ExtendsCheck(left, right) {
3888
- return Visit3(left, right);
3889
- }
3890
-
3891
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
3892
- function FromProperties8(P, Right, True, False, options) {
3893
- const Acc = {};
3894
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3895
- Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
3896
- return Acc;
3897
- }
3898
- function FromMappedResult6(Left, Right, True, False, options) {
3899
- return FromProperties8(Left.properties, Right, True, False, options);
3900
- }
3901
- function ExtendsFromMappedResult(Left, Right, True, False, options) {
3902
- const P = FromMappedResult6(Left, Right, True, False, options);
3903
- return MappedResult(P);
3904
- }
3905
-
3906
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
3907
- function ExtendsResolve(left, right, trueType, falseType) {
3908
- const R = ExtendsCheck(left, right);
3909
- return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
3910
- }
3911
- function Extends(L, R, T, F, options) {
3912
- return IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
3913
- }
3914
-
3915
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
3916
- function FromPropertyKey(K, U, L, R, options) {
3917
- return {
3918
- [K]: Extends(Literal(K), U, L, R, Clone(options))
3919
- };
3920
- }
3921
- function FromPropertyKeys(K, U, L, R, options) {
3922
- return K.reduce((Acc, LK) => {
3923
- return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
3924
- }, {});
3925
- }
3926
- function FromMappedKey2(K, U, L, R, options) {
3927
- return FromPropertyKeys(K.keys, U, L, R, options);
3928
- }
3929
- function ExtendsFromMappedKey(T, U, L, R, options) {
3930
- const P = FromMappedKey2(T, U, L, R, options);
3931
- return MappedResult(P);
3932
- }
3933
-
3934
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
3935
- function ExcludeFromTemplateLiteral(L, R) {
3936
- return Exclude(TemplateLiteralToUnion(L), R);
3937
- }
3938
-
3939
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
3940
- function ExcludeRest(L, R) {
3941
- const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
3942
- return excluded.length === 1 ? excluded[0] : Union(excluded);
3943
- }
3944
- function Exclude(L, R, options = {}) {
3945
- if (IsTemplateLiteral(L))
3946
- return CreateType(ExcludeFromTemplateLiteral(L, R), options);
3947
- if (IsMappedResult(L))
3948
- return CreateType(ExcludeFromMappedResult(L, R), options);
3949
- return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
3950
- }
3951
-
3952
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
3953
- function FromProperties9(P, U) {
3954
- const Acc = {};
3955
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3956
- Acc[K2] = Exclude(P[K2], U);
3957
- return Acc;
3958
- }
3959
- function FromMappedResult7(R, T) {
3960
- return FromProperties9(R.properties, T);
3961
- }
3962
- function ExcludeFromMappedResult(R, T) {
3963
- const P = FromMappedResult7(R, T);
3964
- return MappedResult(P);
3965
- }
3966
-
3967
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
3968
- function ExtractFromTemplateLiteral(L, R) {
3969
- return Extract(TemplateLiteralToUnion(L), R);
3970
- }
3971
-
3972
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
3973
- function ExtractRest(L, R) {
3974
- const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
3975
- return extracted.length === 1 ? extracted[0] : Union(extracted);
3976
- }
3977
- function Extract(L, R, options) {
3978
- if (IsTemplateLiteral(L))
3979
- return CreateType(ExtractFromTemplateLiteral(L, R), options);
3980
- if (IsMappedResult(L))
3981
- return CreateType(ExtractFromMappedResult(L, R), options);
3982
- return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
3983
- }
3984
-
3985
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
3986
- function FromProperties10(P, T) {
3987
- const Acc = {};
3988
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3989
- Acc[K2] = Extract(P[K2], T);
3990
- return Acc;
3991
- }
3992
- function FromMappedResult8(R, T) {
3993
- return FromProperties10(R.properties, T);
3994
- }
3995
- function ExtractFromMappedResult(R, T) {
3996
- const P = FromMappedResult8(R, T);
3997
- return MappedResult(P);
3998
- }
3999
-
4000
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
4001
- function InstanceType(schema, options) {
4002
- return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
4003
- }
4004
-
4005
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
4006
- function ReadonlyOptional(schema) {
4007
- return Readonly(Optional(schema));
4008
- }
4009
-
4010
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
4011
- function RecordCreateFromPattern(pattern, T, options) {
4012
- return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
4013
- }
4014
- function RecordCreateFromKeys(K, T, options) {
4015
- const result = {};
4016
- for (const K2 of K)
4017
- result[K2] = T;
4018
- return Object2(result, { ...options, [Hint]: "Record" });
4019
- }
4020
- function FromTemplateLiteralKey(K, T, options) {
4021
- return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
4022
- }
4023
- function FromUnionKey(key, type, options) {
4024
- return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
4025
- }
4026
- function FromLiteralKey(key, type, options) {
4027
- return RecordCreateFromKeys([key.toString()], type, options);
4028
- }
4029
- function FromRegExpKey(key, type, options) {
4030
- return RecordCreateFromPattern(key.source, type, options);
4031
- }
4032
- function FromStringKey(key, type, options) {
4033
- const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
4034
- return RecordCreateFromPattern(pattern, type, options);
4035
- }
4036
- function FromAnyKey(_, type, options) {
4037
- return RecordCreateFromPattern(PatternStringExact, type, options);
4038
- }
4039
- function FromNeverKey(_key, type, options) {
4040
- return RecordCreateFromPattern(PatternNeverExact, type, options);
4041
- }
4042
- function FromBooleanKey(_key, type, options) {
4043
- return Object2({ true: type, false: type }, options);
4044
- }
4045
- function FromIntegerKey(_key, type, options) {
4046
- return RecordCreateFromPattern(PatternNumberExact, type, options);
4047
- }
4048
- function FromNumberKey(_, type, options) {
4049
- return RecordCreateFromPattern(PatternNumberExact, type, options);
4050
- }
4051
- function Record(key, type, options = {}) {
4052
- return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean2(key) ? FromBooleanKey(key, type, options) : IsInteger(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString2(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
4053
- }
4054
- function RecordPattern(record) {
4055
- return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
4056
- }
4057
- function RecordKey2(type) {
4058
- const pattern = RecordPattern(type);
4059
- return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
4060
- }
4061
- function RecordValue2(type) {
4062
- return type.patternProperties[RecordPattern(type)];
4063
- }
4064
-
4065
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
4066
- function FromConstructor2(args2, type) {
4067
- type.parameters = FromTypes(args2, type.parameters);
4068
- type.returns = FromType(args2, type.returns);
4069
- return type;
4070
- }
4071
- function FromFunction2(args2, type) {
4072
- type.parameters = FromTypes(args2, type.parameters);
4073
- type.returns = FromType(args2, type.returns);
4074
- return type;
4075
- }
4076
- function FromIntersect5(args2, type) {
4077
- type.allOf = FromTypes(args2, type.allOf);
4078
- return type;
4079
- }
4080
- function FromUnion7(args2, type) {
4081
- type.anyOf = FromTypes(args2, type.anyOf);
4082
- return type;
4083
- }
4084
- function FromTuple4(args2, type) {
4085
- if (IsUndefined(type.items))
4086
- return type;
4087
- type.items = FromTypes(args2, type.items);
4088
- return type;
4089
- }
4090
- function FromArray5(args2, type) {
4091
- type.items = FromType(args2, type.items);
4092
- return type;
4093
- }
4094
- function FromAsyncIterator2(args2, type) {
4095
- type.items = FromType(args2, type.items);
4096
- return type;
4097
- }
4098
- function FromIterator2(args2, type) {
4099
- type.items = FromType(args2, type.items);
4100
- return type;
4101
- }
4102
- function FromPromise3(args2, type) {
4103
- type.item = FromType(args2, type.item);
4104
- return type;
4105
- }
4106
- function FromObject2(args2, type) {
4107
- const mappedProperties = FromProperties11(args2, type.properties);
4108
- return { ...type, ...Object2(mappedProperties) };
4109
- }
4110
- function FromRecord2(args2, type) {
4111
- const mappedKey = FromType(args2, RecordKey2(type));
4112
- const mappedValue = FromType(args2, RecordValue2(type));
4113
- const result = Record(mappedKey, mappedValue);
4114
- return { ...type, ...result };
4115
- }
4116
- function FromArgument(args2, argument) {
4117
- return argument.index in args2 ? args2[argument.index] : Unknown();
4118
- }
4119
- function FromProperty2(args2, type) {
4120
- const isReadonly = IsReadonly(type);
4121
- const isOptional = IsOptional(type);
4122
- const mapped = FromType(args2, type);
4123
- return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
4124
- }
4125
- function FromProperties11(args2, properties) {
4126
- return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
4127
- return { ...result, [key]: FromProperty2(args2, properties[key]) };
4128
- }, {});
4129
- }
4130
- function FromTypes(args2, types) {
4131
- return types.map((type) => FromType(args2, type));
4132
- }
4133
- function FromType(args2, type) {
4134
- return IsConstructor(type) ? FromConstructor2(args2, type) : IsFunction2(type) ? FromFunction2(args2, type) : IsIntersect(type) ? FromIntersect5(args2, type) : IsUnion(type) ? FromUnion7(args2, type) : IsTuple(type) ? FromTuple4(args2, type) : IsArray3(type) ? FromArray5(args2, type) : IsAsyncIterator2(type) ? FromAsyncIterator2(args2, type) : IsIterator2(type) ? FromIterator2(args2, type) : IsPromise(type) ? FromPromise3(args2, type) : IsObject3(type) ? FromObject2(args2, type) : IsRecord(type) ? FromRecord2(args2, type) : IsArgument(type) ? FromArgument(args2, type) : type;
4135
- }
4136
- function Instantiate(type, args2) {
4137
- return FromType(args2, CloneType(type));
4138
- }
4139
-
4140
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
4141
- function Integer(options) {
4142
- return CreateType({ [Kind]: "Integer", type: "integer" }, options);
4143
- }
4144
-
4145
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
4146
- function MappedIntrinsicPropertyKey(K, M, options) {
4147
- return {
4148
- [K]: Intrinsic(Literal(K), M, Clone(options))
4149
- };
4150
- }
4151
- function MappedIntrinsicPropertyKeys(K, M, options) {
4152
- const result = K.reduce((Acc, L) => {
4153
- return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
4154
- }, {});
4155
- return result;
4156
- }
4157
- function MappedIntrinsicProperties(T, M, options) {
4158
- return MappedIntrinsicPropertyKeys(T["keys"], M, options);
4159
- }
4160
- function IntrinsicFromMappedKey(T, M, options) {
4161
- const P = MappedIntrinsicProperties(T, M, options);
4162
- return MappedResult(P);
4163
- }
4164
-
4165
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
4166
- function ApplyUncapitalize(value) {
4167
- const [first, rest] = [value.slice(0, 1), value.slice(1)];
4168
- return [first.toLowerCase(), rest].join("");
4169
- }
4170
- function ApplyCapitalize(value) {
4171
- const [first, rest] = [value.slice(0, 1), value.slice(1)];
4172
- return [first.toUpperCase(), rest].join("");
4173
- }
4174
- function ApplyUppercase(value) {
4175
- return value.toUpperCase();
4176
- }
4177
- function ApplyLowercase(value) {
4178
- return value.toLowerCase();
4179
- }
4180
- function FromTemplateLiteral3(schema, mode, options) {
4181
- const expression = TemplateLiteralParseExact(schema.pattern);
4182
- const finite = IsTemplateLiteralExpressionFinite(expression);
4183
- if (!finite)
4184
- return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
4185
- const strings = [...TemplateLiteralExpressionGenerate(expression)];
4186
- const literals = strings.map((value) => Literal(value));
4187
- const mapped = FromRest5(literals, mode);
4188
- const union = Union(mapped);
4189
- return TemplateLiteral([union], options);
4190
- }
4191
- function FromLiteralValue(value, mode) {
4192
- return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
4193
- }
4194
- function FromRest5(T, M) {
4195
- return T.map((L) => Intrinsic(L, M));
4196
- }
4197
- function Intrinsic(schema, mode, options = {}) {
4198
- return (
4199
- // Intrinsic-Mapped-Inference
4200
- IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
4201
- // Standard-Inference
4202
- IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
4203
- // Default Type
4204
- CreateType(schema, options)
4205
- )
4206
- )
4207
- );
4208
- }
4209
-
4210
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
4211
- function Capitalize(T, options = {}) {
4212
- return Intrinsic(T, "Capitalize", options);
4213
- }
4214
-
4215
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
4216
- function Lowercase(T, options = {}) {
4217
- return Intrinsic(T, "Lowercase", options);
4218
- }
4219
-
4220
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
4221
- function Uncapitalize(T, options = {}) {
4222
- return Intrinsic(T, "Uncapitalize", options);
4223
- }
4224
-
4225
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
4226
- function Uppercase(T, options = {}) {
4227
- return Intrinsic(T, "Uppercase", options);
4228
- }
4229
-
4230
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
4231
- function FromProperties12(properties, propertyKeys, options) {
4232
- const result = {};
4233
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
4234
- result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
4235
- return result;
4236
- }
4237
- function FromMappedResult9(mappedResult, propertyKeys, options) {
4238
- return FromProperties12(mappedResult.properties, propertyKeys, options);
4239
- }
4240
- function OmitFromMappedResult(mappedResult, propertyKeys, options) {
4241
- const properties = FromMappedResult9(mappedResult, propertyKeys, options);
4242
- return MappedResult(properties);
4243
- }
4244
-
4245
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
4246
- function FromIntersect6(types, propertyKeys) {
4247
- return types.map((type) => OmitResolve(type, propertyKeys));
4248
- }
4249
- function FromUnion8(types, propertyKeys) {
4250
- return types.map((type) => OmitResolve(type, propertyKeys));
4251
- }
4252
- function FromProperty3(properties, key) {
4253
- const { [key]: _, ...R } = properties;
4254
- return R;
4255
- }
4256
- function FromProperties13(properties, propertyKeys) {
4257
- return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
4258
- }
4259
- function FromObject3(type, propertyKeys, properties) {
4260
- const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4261
- const mappedProperties = FromProperties13(properties, propertyKeys);
4262
- return Object2(mappedProperties, options);
4263
- }
4264
- function UnionFromPropertyKeys(propertyKeys) {
4265
- const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
4266
- return Union(result);
4267
- }
4268
- function OmitResolve(type, propertyKeys) {
4269
- return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
4270
- }
4271
- function Omit(type, key, options) {
4272
- const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
4273
- const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
4274
- const isTypeRef = IsRef(type);
4275
- const isKeyRef = IsRef(key);
4276
- return IsMappedResult(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({ ...OmitResolve(type, propertyKeys), ...options });
4277
- }
4278
-
4279
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
4280
- function FromPropertyKey2(type, key, options) {
4281
- return { [key]: Omit(type, [key], Clone(options)) };
4282
- }
4283
- function FromPropertyKeys2(type, propertyKeys, options) {
4284
- return propertyKeys.reduce((Acc, LK) => {
4285
- return { ...Acc, ...FromPropertyKey2(type, LK, options) };
4286
- }, {});
4287
- }
4288
- function FromMappedKey3(type, mappedKey, options) {
4289
- return FromPropertyKeys2(type, mappedKey.keys, options);
4290
- }
4291
- function OmitFromMappedKey(type, mappedKey, options) {
4292
- const properties = FromMappedKey3(type, mappedKey, options);
4293
- return MappedResult(properties);
4294
- }
4295
-
4296
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
4297
- function FromProperties14(properties, propertyKeys, options) {
4298
- const result = {};
4299
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
4300
- result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
4301
- return result;
4302
- }
4303
- function FromMappedResult10(mappedResult, propertyKeys, options) {
4304
- return FromProperties14(mappedResult.properties, propertyKeys, options);
4305
- }
4306
- function PickFromMappedResult(mappedResult, propertyKeys, options) {
4307
- const properties = FromMappedResult10(mappedResult, propertyKeys, options);
4308
- return MappedResult(properties);
4309
- }
4310
-
4311
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
4312
- function FromIntersect7(types, propertyKeys) {
4313
- return types.map((type) => PickResolve(type, propertyKeys));
4314
- }
4315
- function FromUnion9(types, propertyKeys) {
4316
- return types.map((type) => PickResolve(type, propertyKeys));
4317
- }
4318
- function FromProperties15(properties, propertyKeys) {
4319
- const result = {};
4320
- for (const K2 of propertyKeys)
4321
- if (K2 in properties)
4322
- result[K2] = properties[K2];
4323
- return result;
4324
- }
4325
- function FromObject4(Type2, keys, properties) {
4326
- const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
4327
- const mappedProperties = FromProperties15(properties, keys);
4328
- return Object2(mappedProperties, options);
4329
- }
4330
- function UnionFromPropertyKeys2(propertyKeys) {
4331
- const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
4332
- return Union(result);
4333
- }
4334
- function PickResolve(type, propertyKeys) {
4335
- return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
4336
- }
4337
- function Pick(type, key, options) {
4338
- const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
4339
- const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
4340
- const isTypeRef = IsRef(type);
4341
- const isKeyRef = IsRef(key);
4342
- return IsMappedResult(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({ ...PickResolve(type, propertyKeys), ...options });
4343
- }
4344
-
4345
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
4346
- function FromPropertyKey3(type, key, options) {
4347
- return {
4348
- [key]: Pick(type, [key], Clone(options))
4349
- };
4350
- }
4351
- function FromPropertyKeys3(type, propertyKeys, options) {
4352
- return propertyKeys.reduce((result, leftKey) => {
4353
- return { ...result, ...FromPropertyKey3(type, leftKey, options) };
4354
- }, {});
4355
- }
4356
- function FromMappedKey4(type, mappedKey, options) {
4357
- return FromPropertyKeys3(type, mappedKey.keys, options);
4358
- }
4359
- function PickFromMappedKey(type, mappedKey, options) {
4360
- const properties = FromMappedKey4(type, mappedKey, options);
4361
- return MappedResult(properties);
4362
- }
4363
-
4364
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
4365
- function FromComputed3(target, parameters) {
4366
- return Computed("Partial", [Computed(target, parameters)]);
4367
- }
4368
- function FromRef3($ref) {
4369
- return Computed("Partial", [Ref($ref)]);
4370
- }
4371
- function FromProperties16(properties) {
4372
- const partialProperties = {};
4373
- for (const K of globalThis.Object.getOwnPropertyNames(properties))
4374
- partialProperties[K] = Optional(properties[K]);
4375
- return partialProperties;
4376
- }
4377
- function FromObject5(type, properties) {
4378
- const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4379
- const mappedProperties = FromProperties16(properties);
4380
- return Object2(mappedProperties, options);
4381
- }
4382
- function FromRest6(types) {
4383
- return types.map((type) => PartialResolve(type));
4384
- }
4385
- function PartialResolve(type) {
4386
- return (
4387
- // Mappable
4388
- IsComputed(type) ? FromComputed3(type.target, type.parameters) : IsRef(type) ? FromRef3(type.$ref) : IsIntersect(type) ? Intersect(FromRest6(type.allOf)) : IsUnion(type) ? Union(FromRest6(type.anyOf)) : IsObject3(type) ? FromObject5(type, type.properties) : (
4389
- // Intrinsic
4390
- IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
4391
- // Passthrough
4392
- Object2({})
4393
- )
4394
- )
4395
- );
4396
- }
4397
- function Partial(type, options) {
4398
- if (IsMappedResult(type)) {
4399
- return PartialFromMappedResult(type, options);
4400
- } else {
4401
- return CreateType({ ...PartialResolve(type), ...options });
4402
- }
4403
- }
4404
-
4405
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
4406
- function FromProperties17(K, options) {
4407
- const Acc = {};
4408
- for (const K2 of globalThis.Object.getOwnPropertyNames(K))
4409
- Acc[K2] = Partial(K[K2], Clone(options));
4410
- return Acc;
4411
- }
4412
- function FromMappedResult11(R, options) {
4413
- return FromProperties17(R.properties, options);
4414
- }
4415
- function PartialFromMappedResult(R, options) {
4416
- const P = FromMappedResult11(R, options);
4417
- return MappedResult(P);
4418
- }
4419
-
4420
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
4421
- function FromComputed4(target, parameters) {
4422
- return Computed("Required", [Computed(target, parameters)]);
4423
- }
4424
- function FromRef4($ref) {
4425
- return Computed("Required", [Ref($ref)]);
4426
- }
4427
- function FromProperties18(properties) {
4428
- const requiredProperties = {};
4429
- for (const K of globalThis.Object.getOwnPropertyNames(properties))
4430
- requiredProperties[K] = Discard(properties[K], [OptionalKind]);
4431
- return requiredProperties;
4432
- }
4433
- function FromObject6(type, properties) {
4434
- const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
4435
- const mappedProperties = FromProperties18(properties);
4436
- return Object2(mappedProperties, options);
4437
- }
4438
- function FromRest7(types) {
4439
- return types.map((type) => RequiredResolve(type));
4440
- }
4441
- function RequiredResolve(type) {
4442
- return (
4443
- // Mappable
4444
- IsComputed(type) ? FromComputed4(type.target, type.parameters) : IsRef(type) ? FromRef4(type.$ref) : IsIntersect(type) ? Intersect(FromRest7(type.allOf)) : IsUnion(type) ? Union(FromRest7(type.anyOf)) : IsObject3(type) ? FromObject6(type, type.properties) : (
4445
- // Intrinsic
4446
- IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
4447
- // Passthrough
4448
- Object2({})
4449
- )
4450
- )
4451
- );
4452
- }
4453
- function Required(type, options) {
4454
- if (IsMappedResult(type)) {
4455
- return RequiredFromMappedResult(type, options);
4456
- } else {
4457
- return CreateType({ ...RequiredResolve(type), ...options });
4458
- }
4459
- }
4460
-
4461
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
4462
- function FromProperties19(P, options) {
4463
- const Acc = {};
4464
- for (const K2 of globalThis.Object.getOwnPropertyNames(P))
4465
- Acc[K2] = Required(P[K2], options);
4466
- return Acc;
4467
- }
4468
- function FromMappedResult12(R, options) {
4469
- return FromProperties19(R.properties, options);
4470
- }
4471
- function RequiredFromMappedResult(R, options) {
4472
- const P = FromMappedResult12(R, options);
4473
- return MappedResult(P);
4474
- }
4475
-
4476
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
4477
- function DereferenceParameters(moduleProperties, types) {
4478
- return types.map((type) => {
4479
- return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
4480
- });
4481
- }
4482
- function Dereference(moduleProperties, ref) {
4483
- return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
4484
- }
4485
- function FromAwaited(parameters) {
4486
- return Awaited(parameters[0]);
4487
- }
4488
- function FromIndex(parameters) {
4489
- return Index(parameters[0], parameters[1]);
4490
- }
4491
- function FromKeyOf(parameters) {
4492
- return KeyOf(parameters[0]);
4493
- }
4494
- function FromPartial(parameters) {
4495
- return Partial(parameters[0]);
4496
- }
4497
- function FromOmit(parameters) {
4498
- return Omit(parameters[0], parameters[1]);
4499
- }
4500
- function FromPick(parameters) {
4501
- return Pick(parameters[0], parameters[1]);
4502
- }
4503
- function FromRequired(parameters) {
4504
- return Required(parameters[0]);
4505
- }
4506
- function FromComputed5(moduleProperties, target, parameters) {
4507
- const dereferenced = DereferenceParameters(moduleProperties, parameters);
4508
- return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
4509
- }
4510
- function FromArray6(moduleProperties, type) {
4511
- return Array2(FromType2(moduleProperties, type));
4512
- }
4513
- function FromAsyncIterator3(moduleProperties, type) {
4514
- return AsyncIterator(FromType2(moduleProperties, type));
4515
- }
4516
- function FromConstructor3(moduleProperties, parameters, instanceType) {
4517
- return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
4518
- }
4519
- function FromFunction3(moduleProperties, parameters, returnType) {
4520
- return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
4521
- }
4522
- function FromIntersect8(moduleProperties, types) {
4523
- return Intersect(FromTypes2(moduleProperties, types));
4524
- }
4525
- function FromIterator3(moduleProperties, type) {
4526
- return Iterator(FromType2(moduleProperties, type));
4527
- }
4528
- function FromObject7(moduleProperties, properties) {
4529
- return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
4530
- return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
4531
- }, {}));
4532
- }
4533
- function FromRecord3(moduleProperties, type) {
4534
- const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
4535
- const result = CloneType(type);
4536
- result.patternProperties[pattern] = value;
4537
- return result;
4538
- }
4539
- function FromTransform(moduleProperties, transform) {
4540
- return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
4541
- }
4542
- function FromTuple5(moduleProperties, types) {
4543
- return Tuple(FromTypes2(moduleProperties, types));
4544
- }
4545
- function FromUnion10(moduleProperties, types) {
4546
- return Union(FromTypes2(moduleProperties, types));
4547
- }
4548
- function FromTypes2(moduleProperties, types) {
4549
- return types.map((type) => FromType2(moduleProperties, type));
4550
- }
4551
- function FromType2(moduleProperties, type) {
4552
- return (
4553
- // Modifiers
4554
- IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
4555
- // Transform
4556
- IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
4557
- // Types
4558
- IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator2(type) ? CreateType(FromAsyncIterator3(moduleProperties, type.items), type) : IsComputed(type) ? CreateType(FromComputed5(moduleProperties, type.target, type.parameters)) : IsConstructor(type) ? CreateType(FromConstructor3(moduleProperties, type.parameters, type.returns), type) : IsFunction2(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator2(type) ? CreateType(FromIterator3(moduleProperties, type.items), type) : IsObject3(type) ? CreateType(FromObject7(moduleProperties, type.properties), type) : IsRecord(type) ? CreateType(FromRecord3(moduleProperties, type)) : IsTuple(type) ? CreateType(FromTuple5(moduleProperties, type.items || []), type) : IsUnion(type) ? CreateType(FromUnion10(moduleProperties, type.anyOf), type) : type
4559
- )
4560
- )
4561
- );
4562
- }
4563
- function ComputeType(moduleProperties, key) {
4564
- return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
4565
- }
4566
- function ComputeModuleProperties(moduleProperties) {
4567
- return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
4568
- return { ...result, [key]: ComputeType(moduleProperties, key) };
4569
- }, {});
4570
- }
4571
-
4572
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
4573
- var TModule = class {
4574
- constructor($defs) {
4575
- const computed = ComputeModuleProperties($defs);
4576
- const identified = this.WithIdentifiers(computed);
4577
- this.$defs = identified;
4578
- }
4579
- /** `[Json]` Imports a Type by Key. */
4580
- Import(key, options) {
4581
- const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
4582
- return CreateType({ [Kind]: "Import", $defs, $ref: key });
4583
- }
4584
- // prettier-ignore
4585
- WithIdentifiers($defs) {
4586
- return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
4587
- return { ...result, [key]: { ...$defs[key], $id: key } };
4588
- }, {});
1471
+ } catch {
1472
+ const refs = parseGeneratedImagePayload(event.content);
1473
+ if (refs?.imageUrl) {
1474
+ collected.imageUrl = refs.imageUrl;
1475
+ }
1476
+ if (refs?.imageData) {
1477
+ collected.imageData = refs.imageData;
1478
+ }
1479
+ }
4589
1480
  }
4590
- };
4591
- function Module(properties) {
4592
- return new TModule(properties);
4593
- }
4594
-
4595
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
4596
- function Not(type, options) {
4597
- return CreateType({ [Kind]: "Not", not: type }, options);
1481
+ return collected;
4598
1482
  }
4599
1483
 
4600
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
4601
- function Parameters(schema, options) {
4602
- return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
4603
- }
1484
+ // ../shared/dist/tool-display.js
1485
+ var toolDisplayRegistry = [
1486
+ { name: "agent", displayName: "Subagent", activeDisplayName: "Subagent" },
1487
+ { name: "ask_user", displayName: "Ask", activeDisplayName: "Asking" },
1488
+ { name: "bash", displayName: "Ran", activeDisplayName: "Running" },
1489
+ { name: "code_search", displayName: "Code Search", activeDisplayName: "Searching" },
1490
+ { name: "edit", displayName: "Edit", activeDisplayName: "Editing" },
1491
+ { name: "execute_skill_script", displayName: "Run Script", activeDisplayName: "Running Script" },
1492
+ { name: "fetch", displayName: "Fetch", activeDisplayName: "Fetching" },
1493
+ { name: "find", displayName: "Find", activeDisplayName: "Finding" },
1494
+ { name: "find_images", displayName: "Find Images", activeDisplayName: "Finding Images" },
1495
+ { name: "generate_image", displayName: "Make Image", activeDisplayName: "Making Image" },
1496
+ { name: "grep", displayName: "Search", activeDisplayName: "Searching" },
1497
+ { name: "ls", displayName: "List", activeDisplayName: "Listing" },
1498
+ { name: "mcp", displayName: "Tool", activeDisplayName: "Tool" },
1499
+ { name: "read", displayName: "Read", activeDisplayName: "Reading" },
1500
+ {
1501
+ name: "read_skill_reference",
1502
+ displayName: "Read Reference",
1503
+ activeDisplayName: "Reading Reference"
1504
+ },
1505
+ { name: "run_js", displayName: "Run JS", activeDisplayName: "Running JS" },
1506
+ { name: "simple_grep", displayName: "Search", activeDisplayName: "Searching" },
1507
+ { name: "todo", displayName: "Todo", activeDisplayName: "Updating" },
1508
+ { name: "tool_search", displayName: "Find Tools", activeDisplayName: "Finding Tools" },
1509
+ { name: "write", displayName: "Write", activeDisplayName: "Writing" }
1510
+ ];
1511
+ var displayByName = new Map(toolDisplayRegistry.map((entry) => [entry.name, entry]));
4604
1512
 
4605
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
4606
- var Ordinal = 0;
4607
- function Recursive(callback, options = {}) {
4608
- if (IsUndefined(options.$id))
4609
- options.$id = `T${Ordinal++}`;
4610
- const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
4611
- thisType.$id = options.$id;
4612
- return CreateType({ [Hint]: "Recursive", ...thisType }, options);
1513
+ // ../shared/dist/providers.js
1514
+ var LOCAL_PROVIDER_ID = "local";
1515
+ var LOCAL_PROVIDER_NAME = "Local";
1516
+ var LOCAL_PROVIDER_DEFAULT_API_URL = "http://127.0.0.1:8000/v1";
1517
+ var LOCAL_API_URL_ENV = "LOCAL_API_URL";
1518
+ var LOCAL_API_KEY_ENV = "LOCAL_API_KEY";
1519
+ function resolveLocalProviderApiUrl(envValues) {
1520
+ const override = envValues[LOCAL_API_URL_ENV]?.trim();
1521
+ if (override) {
1522
+ return override;
1523
+ }
1524
+ return LOCAL_PROVIDER_DEFAULT_API_URL;
4613
1525
  }
4614
-
4615
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
4616
- function RegExp2(unresolved, options) {
4617
- const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
4618
- return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
1526
+ function isLocalProvider(providerId) {
1527
+ return providerId.toLowerCase() === LOCAL_PROVIDER_ID;
4619
1528
  }
4620
1529
 
4621
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
4622
- function RestResolve(T) {
4623
- return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
1530
+ // ../shared/dist/web-fetch.js
1531
+ var WEB_FETCH_MAX_URL_LENGTH = 2e3;
1532
+ var WEB_FETCH_TIMEOUT_MS = 6e4;
1533
+ var WEB_FETCH_MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
1534
+ var WEB_FETCH_MAX_CONTENT_CHARS = 1e5;
1535
+ var WEB_FETCH_MAX_REDIRECTS = 10;
1536
+ var WEB_FETCH_CACHE_TTL_MS = 15 * 60 * 1e3;
1537
+ var WEB_FETCH_CACHE_MAX_BYTES = 50 * 1024 * 1024;
1538
+ var WEB_FETCH_USER_AGENT = "Tarsk-Agent-Fetch/1.0 (+https://tarsk.dev)";
1539
+ var WEB_FETCH_FAST_PATH_MAX_BYTES = 32768;
1540
+ var WEB_FETCH_PREAPPROVED_DOMAINS = [
1541
+ "developer.mozilla.org",
1542
+ "docs.npmjs.com",
1543
+ "www.npmjs.com",
1544
+ "registry.npmjs.org",
1545
+ "github.com",
1546
+ "raw.githubusercontent.com",
1547
+ "stackoverflow.com",
1548
+ "www.stackoverflow.com",
1549
+ "en.wikipedia.org",
1550
+ "pkg.go.dev",
1551
+ "docs.rs",
1552
+ "doc.rust-lang.org",
1553
+ "bun.sh",
1554
+ "docs.anthropic.com",
1555
+ "platform.openai.com",
1556
+ "react.dev",
1557
+ "nextjs.org",
1558
+ "tailwindcss.com",
1559
+ "vitest.dev",
1560
+ "esbuild.github.io",
1561
+ "nodejs.org",
1562
+ "typescriptlang.org",
1563
+ "hono.dev",
1564
+ "sqlite.org"
1565
+ ];
1566
+ function normalizeFetchHostname(hostname2) {
1567
+ const lower = hostname2.toLowerCase();
1568
+ return lower.startsWith("www.") ? lower.slice(4) : lower;
4624
1569
  }
4625
- function Rest(T) {
4626
- return RestResolve(T);
1570
+ function isPreapprovedFetchDomain(hostname2) {
1571
+ const normalized = normalizeFetchHostname(hostname2);
1572
+ return WEB_FETCH_PREAPPROVED_DOMAINS.some((domain) => normalizeFetchHostname(domain) === normalized);
4627
1573
  }
4628
-
4629
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
4630
- function ReturnType(schema, options) {
4631
- return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
1574
+ function isSameFetchHost(a, b) {
1575
+ return normalizeFetchHostname(a) === normalizeFetchHostname(b);
4632
1576
  }
4633
1577
 
4634
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
4635
- var TransformDecodeBuilder = class {
4636
- constructor(schema) {
4637
- this.schema = schema;
4638
- }
4639
- Decode(decode) {
4640
- return new TransformEncodeBuilder(this.schema, decode);
4641
- }
1578
+ // ../shared/dist/explorer-media.js
1579
+ var EXPLORER_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
1580
+ "png",
1581
+ "jpg",
1582
+ "jpeg",
1583
+ "gif",
1584
+ "webp",
1585
+ "svg",
1586
+ "ico",
1587
+ "bmp",
1588
+ "tiff",
1589
+ "tif"
1590
+ ]);
1591
+ var EXPLORER_VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "webm", "mov", "avi"]);
1592
+ var EXPLORER_MEDIA_MIME_TYPES = {
1593
+ png: "image/png",
1594
+ jpg: "image/jpeg",
1595
+ jpeg: "image/jpeg",
1596
+ gif: "image/gif",
1597
+ webp: "image/webp",
1598
+ svg: "image/svg+xml",
1599
+ ico: "image/x-icon",
1600
+ bmp: "image/bmp",
1601
+ tiff: "image/tiff",
1602
+ tif: "image/tiff",
1603
+ mp4: "video/mp4",
1604
+ webm: "video/webm",
1605
+ mov: "video/quicktime",
1606
+ avi: "video/x-msvideo"
4642
1607
  };
4643
- var TransformEncodeBuilder = class {
4644
- constructor(schema, decode) {
4645
- this.schema = schema;
4646
- this.decode = decode;
1608
+ function getFileExtension(filename) {
1609
+ const trimmed = filename.trim();
1610
+ const basename5 = trimmed.split(/[/\\]/).pop() ?? trimmed;
1611
+ const dotIndex = basename5.lastIndexOf(".");
1612
+ if (dotIndex <= 0 || dotIndex === basename5.length - 1) {
1613
+ return "";
4647
1614
  }
4648
- EncodeTransform(encode, schema) {
4649
- const Encode = (value) => schema[TransformKind].Encode(encode(value));
4650
- const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
4651
- const Codec = { Encode, Decode };
4652
- return { ...schema, [TransformKind]: Codec };
1615
+ return basename5.slice(dotIndex + 1).toLowerCase();
1616
+ }
1617
+ function getExplorerFileMediaType(path7, name) {
1618
+ const ext = getFileExtension(path7) || (name ? getFileExtension(name) : "");
1619
+ if (!ext) {
1620
+ return null;
4653
1621
  }
4654
- EncodeSchema(encode, schema) {
4655
- const Codec = { Decode: this.decode, Encode: encode };
4656
- return { ...schema, [TransformKind]: Codec };
1622
+ if (EXPLORER_IMAGE_EXTENSIONS.has(ext)) {
1623
+ return "image";
4657
1624
  }
4658
- Encode(encode) {
4659
- return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
1625
+ if (EXPLORER_VIDEO_EXTENSIONS.has(ext)) {
1626
+ return "video";
4660
1627
  }
4661
- };
4662
- function Transform(schema) {
4663
- return new TransformDecodeBuilder(schema);
4664
- }
4665
-
4666
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
4667
- function Unsafe(options = {}) {
4668
- return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
4669
- }
4670
-
4671
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
4672
- function Void(options) {
4673
- return CreateType({ [Kind]: "Void", type: "void" }, options);
4674
- }
4675
-
4676
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
4677
- var type_exports2 = {};
4678
- __export(type_exports2, {
4679
- Any: () => Any,
4680
- Argument: () => Argument,
4681
- Array: () => Array2,
4682
- AsyncIterator: () => AsyncIterator,
4683
- Awaited: () => Awaited,
4684
- BigInt: () => BigInt,
4685
- Boolean: () => Boolean2,
4686
- Capitalize: () => Capitalize,
4687
- Composite: () => Composite,
4688
- Const: () => Const,
4689
- Constructor: () => Constructor,
4690
- ConstructorParameters: () => ConstructorParameters,
4691
- Date: () => Date2,
4692
- Enum: () => Enum,
4693
- Exclude: () => Exclude,
4694
- Extends: () => Extends,
4695
- Extract: () => Extract,
4696
- Function: () => Function,
4697
- Index: () => Index,
4698
- InstanceType: () => InstanceType,
4699
- Instantiate: () => Instantiate,
4700
- Integer: () => Integer,
4701
- Intersect: () => Intersect,
4702
- Iterator: () => Iterator,
4703
- KeyOf: () => KeyOf,
4704
- Literal: () => Literal,
4705
- Lowercase: () => Lowercase,
4706
- Mapped: () => Mapped,
4707
- Module: () => Module,
4708
- Never: () => Never,
4709
- Not: () => Not,
4710
- Null: () => Null,
4711
- Number: () => Number2,
4712
- Object: () => Object2,
4713
- Omit: () => Omit,
4714
- Optional: () => Optional,
4715
- Parameters: () => Parameters,
4716
- Partial: () => Partial,
4717
- Pick: () => Pick,
4718
- Promise: () => Promise2,
4719
- Readonly: () => Readonly,
4720
- ReadonlyOptional: () => ReadonlyOptional,
4721
- Record: () => Record,
4722
- Recursive: () => Recursive,
4723
- Ref: () => Ref,
4724
- RegExp: () => RegExp2,
4725
- Required: () => Required,
4726
- Rest: () => Rest,
4727
- ReturnType: () => ReturnType,
4728
- String: () => String2,
4729
- Symbol: () => Symbol2,
4730
- TemplateLiteral: () => TemplateLiteral,
4731
- Transform: () => Transform,
4732
- Tuple: () => Tuple,
4733
- Uint8Array: () => Uint8Array2,
4734
- Uncapitalize: () => Uncapitalize,
4735
- Undefined: () => Undefined,
4736
- Union: () => Union,
4737
- Unknown: () => Unknown,
4738
- Unsafe: () => Unsafe,
4739
- Uppercase: () => Uppercase,
4740
- Void: () => Void
4741
- });
1628
+ return null;
1629
+ }
1630
+
1631
+ // src/server.ts
1632
+ import fs3 from "fs";
1633
+ import { Hono as Hono26 } from "hono";
1634
+ import { cors } from "hono/cors";
1635
+ import open3 from "open";
1636
+ import path5 from "path";
1637
+ import { fileURLToPath as fileURLToPath2 } from "url";
1638
+
1639
+ // src/agent/agent.executor.ts
1640
+ import { Agent as Agent2 } from "@earendil-works/pi-agent-core";
1641
+ import { streamSimple } from "@earendil-works/pi-ai";
1642
+ import { resolve as resolve3, isAbsolute as isAbsolute3 } from "path";
4742
1643
 
4743
- // ../node_modules/.bun/@sinclair+typebox@0.34.49/node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
4744
- var Type = type_exports2;
1644
+ // src/features/mcp/mcp.status.ts
1645
+ function formatMcpStatusForChat(line, options) {
1646
+ const text = options?.includeLabel ? `[MCP] ${line}` : line;
1647
+ return `${text}
1648
+ `;
1649
+ }
1650
+ function createMcpThinkingEvent(content) {
1651
+ return { type: "thinking", content };
1652
+ }
4745
1653
 
4746
1654
  // src/tools/bash.ts
4747
1655
  init_tarsk_debug();
4748
1656
  init_utils();
1657
+ import { randomBytes as randomBytes2 } from "node:crypto";
1658
+ import { createWriteStream, existsSync as existsSync3 } from "node:fs";
1659
+ import { tmpdir } from "node:os";
1660
+ import { join as join3 } from "node:path";
1661
+ import { Type } from "@sinclair/typebox";
4749
1662
 
4750
1663
  // src/tools/shell.ts
4751
1664
  init_utils();
@@ -5697,260 +2610,12 @@ Command timed out after ${secs} seconds` : `Command timed out after ${secs} seco
5697
2610
  var bashTool = createBashTool(process.cwd());
5698
2611
 
5699
2612
  // src/tools/edit.ts
2613
+ import { Type as Type2 } from "@sinclair/typebox";
5700
2614
  import { constants as constants2 } from "fs";
5701
2615
  import { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
5702
2616
 
5703
- // ../node_modules/.bun/diff@8.0.4/node_modules/diff/libesm/diff/base.js
5704
- var Diff = class {
5705
- diff(oldStr, newStr, options = {}) {
5706
- let callback;
5707
- if (typeof options === "function") {
5708
- callback = options;
5709
- options = {};
5710
- } else if ("callback" in options) {
5711
- callback = options.callback;
5712
- }
5713
- const oldString = this.castInput(oldStr, options);
5714
- const newString = this.castInput(newStr, options);
5715
- const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
5716
- const newTokens = this.removeEmpty(this.tokenize(newString, options));
5717
- return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
5718
- }
5719
- diffWithOptionsObj(oldTokens, newTokens, options, callback) {
5720
- var _a;
5721
- const done = (value) => {
5722
- value = this.postProcess(value, options);
5723
- if (callback) {
5724
- setTimeout(function() {
5725
- callback(value);
5726
- }, 0);
5727
- return void 0;
5728
- } else {
5729
- return value;
5730
- }
5731
- };
5732
- const newLen = newTokens.length, oldLen = oldTokens.length;
5733
- let editLength = 1;
5734
- let maxEditLength = newLen + oldLen;
5735
- if (options.maxEditLength != null) {
5736
- maxEditLength = Math.min(maxEditLength, options.maxEditLength);
5737
- }
5738
- const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
5739
- const abortAfterTimestamp = Date.now() + maxExecutionTime;
5740
- const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
5741
- let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
5742
- if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
5743
- return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
5744
- }
5745
- let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
5746
- const execEditLength = () => {
5747
- for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
5748
- let basePath;
5749
- const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
5750
- if (removePath) {
5751
- bestPath[diagonalPath - 1] = void 0;
5752
- }
5753
- let canAdd = false;
5754
- if (addPath) {
5755
- const addPathNewPos = addPath.oldPos - diagonalPath;
5756
- canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
5757
- }
5758
- const canRemove = removePath && removePath.oldPos + 1 < oldLen;
5759
- if (!canAdd && !canRemove) {
5760
- bestPath[diagonalPath] = void 0;
5761
- continue;
5762
- }
5763
- if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
5764
- basePath = this.addToPath(addPath, true, false, 0, options);
5765
- } else {
5766
- basePath = this.addToPath(removePath, false, true, 1, options);
5767
- }
5768
- newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
5769
- if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
5770
- return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
5771
- } else {
5772
- bestPath[diagonalPath] = basePath;
5773
- if (basePath.oldPos + 1 >= oldLen) {
5774
- maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
5775
- }
5776
- if (newPos + 1 >= newLen) {
5777
- minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
5778
- }
5779
- }
5780
- }
5781
- editLength++;
5782
- };
5783
- if (callback) {
5784
- (function exec() {
5785
- setTimeout(function() {
5786
- if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
5787
- return callback(void 0);
5788
- }
5789
- if (!execEditLength()) {
5790
- exec();
5791
- }
5792
- }, 0);
5793
- })();
5794
- } else {
5795
- while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
5796
- const ret = execEditLength();
5797
- if (ret) {
5798
- return ret;
5799
- }
5800
- }
5801
- }
5802
- }
5803
- addToPath(path7, added, removed, oldPosInc, options) {
5804
- const last = path7.lastComponent;
5805
- if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
5806
- return {
5807
- oldPos: path7.oldPos + oldPosInc,
5808
- lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
5809
- };
5810
- } else {
5811
- return {
5812
- oldPos: path7.oldPos + oldPosInc,
5813
- lastComponent: { count: 1, added, removed, previousComponent: last }
5814
- };
5815
- }
5816
- }
5817
- extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
5818
- const newLen = newTokens.length, oldLen = oldTokens.length;
5819
- let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
5820
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
5821
- newPos++;
5822
- oldPos++;
5823
- commonCount++;
5824
- if (options.oneChangePerToken) {
5825
- basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
5826
- }
5827
- }
5828
- if (commonCount && !options.oneChangePerToken) {
5829
- basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
5830
- }
5831
- basePath.oldPos = oldPos;
5832
- return newPos;
5833
- }
5834
- equals(left, right, options) {
5835
- if (options.comparator) {
5836
- return options.comparator(left, right);
5837
- } else {
5838
- return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
5839
- }
5840
- }
5841
- removeEmpty(array) {
5842
- const ret = [];
5843
- for (let i = 0; i < array.length; i++) {
5844
- if (array[i]) {
5845
- ret.push(array[i]);
5846
- }
5847
- }
5848
- return ret;
5849
- }
5850
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5851
- castInput(value, options) {
5852
- return value;
5853
- }
5854
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5855
- tokenize(value, options) {
5856
- return Array.from(value);
5857
- }
5858
- join(chars) {
5859
- return chars.join("");
5860
- }
5861
- postProcess(changeObjects, options) {
5862
- return changeObjects;
5863
- }
5864
- get useLongestToken() {
5865
- return false;
5866
- }
5867
- buildValues(lastComponent, newTokens, oldTokens) {
5868
- const components = [];
5869
- let nextComponent;
5870
- while (lastComponent) {
5871
- components.push(lastComponent);
5872
- nextComponent = lastComponent.previousComponent;
5873
- delete lastComponent.previousComponent;
5874
- lastComponent = nextComponent;
5875
- }
5876
- components.reverse();
5877
- const componentLen = components.length;
5878
- let componentPos = 0, newPos = 0, oldPos = 0;
5879
- for (; componentPos < componentLen; componentPos++) {
5880
- const component = components[componentPos];
5881
- if (!component.removed) {
5882
- if (!component.added && this.useLongestToken) {
5883
- let value = newTokens.slice(newPos, newPos + component.count);
5884
- value = value.map(function(value2, i) {
5885
- const oldValue = oldTokens[oldPos + i];
5886
- return oldValue.length > value2.length ? oldValue : value2;
5887
- });
5888
- component.value = this.join(value);
5889
- } else {
5890
- component.value = this.join(newTokens.slice(newPos, newPos + component.count));
5891
- }
5892
- newPos += component.count;
5893
- if (!component.added) {
5894
- oldPos += component.count;
5895
- }
5896
- } else {
5897
- component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
5898
- oldPos += component.count;
5899
- }
5900
- }
5901
- return components;
5902
- }
5903
- };
5904
-
5905
- // ../node_modules/.bun/diff@8.0.4/node_modules/diff/libesm/diff/line.js
5906
- var LineDiff = class extends Diff {
5907
- constructor() {
5908
- super(...arguments);
5909
- this.tokenize = tokenize;
5910
- }
5911
- equals(left, right, options) {
5912
- if (options.ignoreWhitespace) {
5913
- if (!options.newlineIsToken || !left.includes("\n")) {
5914
- left = left.trim();
5915
- }
5916
- if (!options.newlineIsToken || !right.includes("\n")) {
5917
- right = right.trim();
5918
- }
5919
- } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
5920
- if (left.endsWith("\n")) {
5921
- left = left.slice(0, -1);
5922
- }
5923
- if (right.endsWith("\n")) {
5924
- right = right.slice(0, -1);
5925
- }
5926
- }
5927
- return super.equals(left, right, options);
5928
- }
5929
- };
5930
- var lineDiff = new LineDiff();
5931
- function diffLines(oldStr, newStr, options) {
5932
- return lineDiff.diff(oldStr, newStr, options);
5933
- }
5934
- function tokenize(value, options) {
5935
- if (options.stripTrailingCr) {
5936
- value = value.replace(/\r\n/g, "\n");
5937
- }
5938
- const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
5939
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
5940
- linesAndNewlines.pop();
5941
- }
5942
- for (let i = 0; i < linesAndNewlines.length; i++) {
5943
- const line = linesAndNewlines[i];
5944
- if (i % 2 && !options.newlineIsToken) {
5945
- retLines[retLines.length - 1] += line;
5946
- } else {
5947
- retLines.push(line);
5948
- }
5949
- }
5950
- return retLines;
5951
- }
5952
-
5953
2617
  // src/tools/edit-diff.ts
2618
+ import * as Diff from "diff";
5954
2619
  function detectLineEnding(content) {
5955
2620
  const crlfIdx = content.indexOf("\r\n");
5956
2621
  const lfIdx = content.indexOf("\n");
@@ -6002,7 +2667,7 @@ function stripBom(content) {
6002
2667
  return content.startsWith("\uFEFF") ? { bom: "\uFEFF", text: content.slice(1) } : { bom: "", text: content };
6003
2668
  }
6004
2669
  function generateDiffString(oldContent, newContent, contextLines = 4) {
6005
- const parts = diffLines(oldContent, newContent);
2670
+ const parts = Diff.diffLines(oldContent, newContent);
6006
2671
  const output = [];
6007
2672
  const oldLines = oldContent.split("\n");
6008
2673
  const newLines = newContent.split("\n");
@@ -6099,10 +2764,10 @@ async function withAbortSignal(signal, operation) {
6099
2764
  }
6100
2765
 
6101
2766
  // src/tools/edit.ts
6102
- var editSchema = Type.Object({
6103
- path: Type.String({ description: "Path to the file to edit (relative or absolute)" }),
6104
- oldText: Type.String({ description: "Exact text to find and replace (must match exactly)" }),
6105
- newText: Type.String({ description: "New text to replace the old text with" })
2767
+ var editSchema = Type2.Object({
2768
+ path: Type2.String({ description: "Path to the file to edit (relative or absolute)" }),
2769
+ oldText: Type2.String({ description: "Exact text to find and replace (must match exactly)" }),
2770
+ newText: Type2.String({ description: "New text to replace the old text with" })
6106
2771
  });
6107
2772
  var defaultEditOperations = {
6108
2773
  readFile: (path7) => fsReadFile(path7),
@@ -6171,18 +2836,19 @@ function createEditTool(cwd, options) {
6171
2836
  var editTool = createEditTool(process.cwd());
6172
2837
 
6173
2838
  // src/tools/find.ts
2839
+ import { Type as Type3 } from "@sinclair/typebox";
6174
2840
  import { existsSync as existsSync4 } from "fs";
6175
2841
  import os2 from "node:os";
6176
2842
  import path from "path";
6177
2843
  import { globSync } from "glob";
6178
- var findSchema = Type.Object({
6179
- pattern: Type.String({
2844
+ var findSchema = Type3.Object({
2845
+ pattern: Type3.String({
6180
2846
  description: "Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'"
6181
2847
  }),
6182
- path: Type.Optional(
6183
- Type.String({ description: "Directory to search in (default: current directory)" })
2848
+ path: Type3.Optional(
2849
+ Type3.String({ description: "Directory to search in (default: current directory)" })
6184
2850
  ),
6185
- limit: Type.Optional(Type.Number({ description: "Maximum number of results (default: 1000)" }))
2851
+ limit: Type3.Optional(Type3.Number({ description: "Maximum number of results (default: 1000)" }))
6186
2852
  });
6187
2853
  var DEFAULT_LIMIT = 1e3;
6188
2854
  var defaultFindOperations = {
@@ -6292,8 +2958,9 @@ function createFindTool(cwd, options) {
6292
2958
  var findTool = createFindTool(process.cwd());
6293
2959
 
6294
2960
  // src/tools/grep.ts
6295
- import { createInterface } from "node:readline";
6296
2961
  init_utils();
2962
+ import { createInterface } from "node:readline";
2963
+ import { Type as Type4 } from "@sinclair/typebox";
6297
2964
  import { readFileSync, statSync } from "fs";
6298
2965
  import path2 from "path";
6299
2966
 
@@ -6319,25 +2986,25 @@ function resolveBin(name) {
6319
2986
  }
6320
2987
 
6321
2988
  // src/tools/grep.ts
6322
- var grepSchema = Type.Object({
6323
- pattern: Type.String({ description: "Search pattern (regex or literal string)" }),
6324
- path: Type.Optional(
6325
- Type.String({ description: "Directory or file to search (default: current directory)" })
2989
+ var grepSchema = Type4.Object({
2990
+ pattern: Type4.String({ description: "Search pattern (regex or literal string)" }),
2991
+ path: Type4.Optional(
2992
+ Type4.String({ description: "Directory or file to search (default: current directory)" })
6326
2993
  ),
6327
- glob: Type.Optional(Type.String({ description: "Filter files by glob pattern, e.g. '*.ts'" })),
6328
- ignoreCase: Type.Optional(
6329
- Type.Boolean({ description: "Case-insensitive search (default: false)" })
2994
+ glob: Type4.Optional(Type4.String({ description: "Filter files by glob pattern, e.g. '*.ts'" })),
2995
+ ignoreCase: Type4.Optional(
2996
+ Type4.Boolean({ description: "Case-insensitive search (default: false)" })
6330
2997
  ),
6331
- literal: Type.Optional(
6332
- Type.Boolean({
2998
+ literal: Type4.Optional(
2999
+ Type4.Boolean({
6333
3000
  description: "Treat pattern as literal string instead of regex (default: false)"
6334
3001
  })
6335
3002
  ),
6336
- context: Type.Optional(
6337
- Type.Number({ description: "Number of lines before/after each match (default: 0)" })
3003
+ context: Type4.Optional(
3004
+ Type4.Number({ description: "Number of lines before/after each match (default: 0)" })
6338
3005
  ),
6339
- limit: Type.Optional(
6340
- Type.Number({ description: "Maximum number of matches to return (default: 100)" })
3006
+ limit: Type4.Optional(
3007
+ Type4.Number({ description: "Maximum number of matches to return (default: 100)" })
6341
3008
  )
6342
3009
  });
6343
3010
  var DEFAULT_LIMIT2 = 100;
@@ -6555,80 +3222,81 @@ function createSimpleGrepTool(cwd, options) {
6555
3222
  var simpleGrepTool = createSimpleGrepTool(process.cwd());
6556
3223
 
6557
3224
  // src/tools/rip-grep.ts
3225
+ import { Type as Type5 } from "@sinclair/typebox";
6558
3226
  import { statSync as statSync2 } from "node:fs";
6559
3227
  import path3 from "node:path";
6560
3228
  import { ripgrep } from "ripgrep";
6561
3229
  var VCS_DIRECTORIES_TO_EXCLUDE = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
6562
3230
  var DEFAULT_HEAD_LIMIT = 250;
6563
- var ripGrepSchema = Type.Object({
6564
- pattern: Type.String({
3231
+ var ripGrepSchema = Type5.Object({
3232
+ pattern: Type5.String({
6565
3233
  description: "The regular expression pattern to search for in file contents"
6566
3234
  }),
6567
- path: Type.Optional(
6568
- Type.String({
3235
+ path: Type5.Optional(
3236
+ Type5.String({
6569
3237
  description: "File or directory to search in (rg PATH). Defaults to current working directory."
6570
3238
  })
6571
3239
  ),
6572
- glob: Type.Optional(
6573
- Type.String({
3240
+ glob: Type5.Optional(
3241
+ Type5.String({
6574
3242
  description: 'Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}") - maps to rg --glob'
6575
3243
  })
6576
3244
  ),
6577
- output_mode: Type.Optional(
6578
- Type.Union(
6579
- [Type.Literal("content"), Type.Literal("files_with_matches"), Type.Literal("count")],
3245
+ output_mode: Type5.Optional(
3246
+ Type5.Union(
3247
+ [Type5.Literal("content"), Type5.Literal("files_with_matches"), Type5.Literal("count")],
6580
3248
  {
6581
3249
  description: 'Output mode: "content" shows matching lines (supports -A/-B/-C context, -n line numbers, head_limit), "files_with_matches" shows file paths (supports head_limit), "count" shows match counts (supports head_limit). Defaults to "content".'
6582
3250
  }
6583
3251
  )
6584
3252
  ),
6585
- "-B": Type.Optional(
6586
- Type.Number({
3253
+ "-B": Type5.Optional(
3254
+ Type5.Number({
6587
3255
  description: 'Number of lines to show before each match (rg -B). Requires output_mode: "content", ignored otherwise.'
6588
3256
  })
6589
3257
  ),
6590
- "-A": Type.Optional(
6591
- Type.Number({
3258
+ "-A": Type5.Optional(
3259
+ Type5.Number({
6592
3260
  description: 'Number of lines to show after each match (rg -A). Requires output_mode: "content", ignored otherwise.'
6593
3261
  })
6594
3262
  ),
6595
- "-C": Type.Optional(
6596
- Type.Number({
3263
+ "-C": Type5.Optional(
3264
+ Type5.Number({
6597
3265
  description: "Alias for context. Requires output_mode: content."
6598
3266
  })
6599
3267
  ),
6600
- context: Type.Optional(
6601
- Type.Number({
3268
+ context: Type5.Optional(
3269
+ Type5.Number({
6602
3270
  description: 'Number of lines to show before and after each match (rg -C). Requires output_mode: "content", ignored otherwise.'
6603
3271
  })
6604
3272
  ),
6605
- "-n": Type.Optional(
6606
- Type.Boolean({
3273
+ "-n": Type5.Optional(
3274
+ Type5.Boolean({
6607
3275
  description: 'Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise. Defaults to true.'
6608
3276
  })
6609
3277
  ),
6610
- "-i": Type.Optional(
6611
- Type.Boolean({
3278
+ "-i": Type5.Optional(
3279
+ Type5.Boolean({
6612
3280
  description: "Case insensitive search (rg -i)"
6613
3281
  })
6614
3282
  ),
6615
- type: Type.Optional(
6616
- Type.String({
3283
+ type: Type5.Optional(
3284
+ Type5.String({
6617
3285
  description: "File type to search (rg --type). Common types: js, py, rust, go, java, etc. More efficient than include for standard file types."
6618
3286
  })
6619
3287
  ),
6620
- head_limit: Type.Optional(
6621
- Type.Number({
3288
+ head_limit: Type5.Optional(
3289
+ Type5.Number({
6622
3290
  description: 'Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes. Defaults to 250 when unspecified. Pass 0 for unlimited.'
6623
3291
  })
6624
3292
  ),
6625
- offset: Type.Optional(
6626
- Type.Number({
3293
+ offset: Type5.Optional(
3294
+ Type5.Number({
6627
3295
  description: 'Skip first N lines/entries before applying head_limit, equivalent to "| tail -n +N | head -N". Works across all output modes. Defaults to 0.'
6628
3296
  })
6629
3297
  ),
6630
- multiline: Type.Optional(
6631
- Type.Boolean({
3298
+ multiline: Type5.Optional(
3299
+ Type5.Boolean({
6632
3300
  description: "Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false."
6633
3301
  })
6634
3302
  )
@@ -6922,14 +3590,15 @@ var ripGrepTool = createRipGrepTool(process.cwd());
6922
3590
 
6923
3591
  // src/tools/code-search.ts
6924
3592
  init_database();
3593
+ import { Type as Type6 } from "@sinclair/typebox";
6925
3594
 
6926
3595
  // src/tools/code-search-indexer.ts
6927
- var import_ignore = __toESM(require_ignore(), 1);
6928
3596
  init_database();
6929
3597
  init_tarsk_debug();
6930
3598
  import { readFileSync as readFileSync2 } from "fs";
6931
3599
  import { readFile, opendir } from "fs/promises";
6932
3600
  import { join as join4, relative as relative2, extname } from "path";
3601
+ import ignore from "ignore";
6933
3602
  var SKIP_DIRS = /* @__PURE__ */ new Set([
6934
3603
  "node_modules",
6935
3604
  ".git",
@@ -6999,7 +3668,7 @@ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
6999
3668
  var MAX_FILE_SIZE = 512 * 1024;
7000
3669
  var BATCH_SIZE = 50;
7001
3670
  function readGitignore(dirPath) {
7002
- const ig = (0, import_ignore.default)();
3671
+ const ig = ignore();
7003
3672
  try {
7004
3673
  const content = readFileSync2(join4(dirPath, ".gitignore"), "utf8");
7005
3674
  ig.add(content);
@@ -7110,39 +3779,39 @@ async function invalidateThreadIndex(threadId) {
7110
3779
 
7111
3780
  // src/tools/code-search.ts
7112
3781
  var DEFAULT_LIMIT3 = 30;
7113
- var codeSearchSchema = Type.Object({
7114
- query: Type.Optional(
7115
- Type.String({
3782
+ var codeSearchSchema = Type6.Object({
3783
+ query: Type6.Optional(
3784
+ Type6.String({
7116
3785
  description: 'FTS5 full-text search on plain identifier/word tokens (e.g. "validateEmail", "email validation"). Multi-word queries use proximity matching automatically. Supports "quoted phrases", prefix*, and boolean operators (A OR B, A NOT B). Special characters (backslashes, brackets, dots) are stripped \u2014 do NOT put regex patterns here. For regex use `pattern`.'
7117
3786
  })
7118
3787
  ),
7119
- pattern: Type.Optional(
7120
- Type.String({
3788
+ pattern: Type6.Optional(
3789
+ Type6.String({
7121
3790
  description: "JavaScript regex for searching file content, e.g. 'function\\s+\\w+\\s*\\(' or 'class\\s+\\w+Service'. Works standalone (scans all indexed files) or combined with `query` to pre-filter by FTS first. By default matched line by line; set `multiline: true` for cross-line patterns. Case-insensitive unless the pattern contains uppercase letters."
7122
3791
  })
7123
3792
  ),
7124
- filePath: Type.Optional(
7125
- Type.String({
3793
+ filePath: Type6.Optional(
3794
+ Type6.String({
7126
3795
  description: "Search by file path pattern, e.g. 'camp.page.ts', 'src/app/camp', or 'src/**/camp/*.ts'. Supports glob wildcards (* and **). Returns file paths only, no content."
7127
3796
  })
7128
3797
  ),
7129
- fileGlob: Type.Optional(
7130
- Type.String({
3798
+ fileGlob: Type6.Optional(
3799
+ Type6.String({
7131
3800
  description: "Restrict FTS/regex results to files matching this glob, e.g. '*.ts', '**/camp/*.ts'. Applied before the result limit."
7132
3801
  })
7133
3802
  ),
7134
- limit: Type.Optional(
7135
- Type.Number({
3803
+ limit: Type6.Optional(
3804
+ Type6.Number({
7136
3805
  description: `Maximum number of file matches to return (default: ${DEFAULT_LIMIT3})`
7137
3806
  })
7138
3807
  ),
7139
- offset: Type.Optional(
7140
- Type.Number({
3808
+ offset: Type6.Optional(
3809
+ Type6.Number({
7141
3810
  description: "Number of file matches to skip for pagination (default: 0). Use with `limit` to page through results when the match limit or output size is reached."
7142
3811
  })
7143
3812
  ),
7144
- multiline: Type.Optional(
7145
- Type.Boolean({
3813
+ multiline: Type6.Optional(
3814
+ Type6.Boolean({
7146
3815
  description: "When true, apply `pattern` to the full file content rather than line by line, so patterns can span multiple lines. Use `[\\s\\S]` instead of `.` to match newlines within the pattern (e.g. '@Component\\({[\\s\\S]*?templateUrl:' or 'templateUrl:[\\s\\S]*?styleUrl:'). Has no effect without `pattern`."
7147
3816
  })
7148
3817
  )
@@ -7538,14 +4207,15 @@ var codeSearchTool = createCodeSearchTool(
7538
4207
  );
7539
4208
 
7540
4209
  // src/tools/ls.ts
4210
+ import { Type as Type7 } from "@sinclair/typebox";
7541
4211
  import { existsSync as existsSync5, readdirSync as readdirSync2, statSync as statSync3 } from "fs";
7542
4212
  import nodePath from "path";
7543
- var lsSchema = Type.Object({
7544
- path: Type.Optional(
7545
- Type.String({ description: "Directory to list (default: current directory)" })
4213
+ var lsSchema = Type7.Object({
4214
+ path: Type7.Optional(
4215
+ Type7.String({ description: "Directory to list (default: current directory)" })
7546
4216
  ),
7547
- limit: Type.Optional(
7548
- Type.Number({ description: "Maximum number of entries to return (default: 500)" })
4217
+ limit: Type7.Optional(
4218
+ Type7.Number({ description: "Maximum number of entries to return (default: 500)" })
7549
4219
  )
7550
4220
  });
7551
4221
  var DEFAULT_LIMIT4 = 500;
@@ -7650,14 +4320,15 @@ function createLsTool(cwd, options) {
7650
4320
  var lsTool = createLsTool(process.cwd());
7651
4321
 
7652
4322
  // src/tools/read.ts
4323
+ import { Type as Type8 } from "@sinclair/typebox";
7653
4324
  import { constants as constants3 } from "fs";
7654
4325
  import { access as fsAccess2, readFile as fsReadFile2 } from "fs/promises";
7655
- var readSchema = Type.Object({
7656
- path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
7657
- offset: Type.Optional(
7658
- Type.Number({ description: "Line number to start reading from (1-indexed)" })
4326
+ var readSchema = Type8.Object({
4327
+ path: Type8.String({ description: "Path to the file to read (relative or absolute)" }),
4328
+ offset: Type8.Optional(
4329
+ Type8.Number({ description: "Line number to start reading from (1-indexed)" })
7659
4330
  ),
7660
- limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" }))
4331
+ limit: Type8.Optional(Type8.Number({ description: "Maximum number of lines to read" }))
7661
4332
  });
7662
4333
  var defaultReadOperations = {
7663
4334
  readFile: (path7) => fsReadFile2(path7),
@@ -7735,11 +4406,12 @@ function createReadTool(cwd, options) {
7735
4406
  var readTool = createReadTool(process.cwd());
7736
4407
 
7737
4408
  // src/tools/write.ts
4409
+ import { Type as Type9 } from "@sinclair/typebox";
7738
4410
  import { mkdir as fsMkdir, writeFile as fsWriteFile2 } from "fs/promises";
7739
4411
  import { dirname } from "path";
7740
- var writeSchema = Type.Object({
7741
- path: Type.String({ description: "Path to the file to write (relative or absolute)" }),
7742
- content: Type.String({ description: "Content to write to the file" })
4412
+ var writeSchema = Type9.Object({
4413
+ path: Type9.String({ description: "Path to the file to write (relative or absolute)" }),
4414
+ content: Type9.String({ description: "Content to write to the file" })
7743
4415
  });
7744
4416
  var defaultWriteOperations = {
7745
4417
  writeFile: (path7, content) => fsWriteFile2(path7, content, "utf-8"),
@@ -7795,10 +4467,11 @@ function createWriteTool(cwd, options) {
7795
4467
  var writeTool = createWriteTool(process.cwd());
7796
4468
 
7797
4469
  // src/tools/skill-tool.ts
4470
+ init_utils();
7798
4471
  import { readdir } from "fs/promises";
7799
4472
  import { join as join5, extname as extname2 } from "path";
7800
4473
  import { existsSync as existsSync6, statSync as statSync4 } from "fs";
7801
- init_utils();
4474
+ import { Type as Type10 } from "@sinclair/typebox";
7802
4475
  function getInterpreter(scriptPath) {
7803
4476
  const ext = extname2(scriptPath);
7804
4477
  switch (ext) {
@@ -7863,13 +4536,13 @@ async function executeScript(scriptPath, args2, cwd, timeout = 30) {
7863
4536
  });
7864
4537
  });
7865
4538
  }
7866
- var skillScriptSchema = Type.Object({
7867
- skillName: Type.String({ description: "Name of the skill" }),
7868
- scriptName: Type.String({ description: "Name of the script to execute (without path)" }),
7869
- args: Type.Optional(
7870
- Type.Array(Type.String(), { description: "Arguments to pass to the script" })
4539
+ var skillScriptSchema = Type10.Object({
4540
+ skillName: Type10.String({ description: "Name of the skill" }),
4541
+ scriptName: Type10.String({ description: "Name of the script to execute (without path)" }),
4542
+ args: Type10.Optional(
4543
+ Type10.Array(Type10.String(), { description: "Arguments to pass to the script" })
7871
4544
  ),
7872
- timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (default: 30)" }))
4545
+ timeout: Type10.Optional(Type10.Number({ description: "Timeout in seconds (default: 30)" }))
7873
4546
  });
7874
4547
  function buildSkillScriptCommand(scriptPath, args2) {
7875
4548
  const interpreter = getInterpreter(scriptPath);
@@ -7978,15 +4651,16 @@ ${result.stderr}
7978
4651
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
7979
4652
  import { join as join6, normalize, relative as relative3 } from "path";
7980
4653
  import { existsSync as existsSync7 } from "fs";
4654
+ import { Type as Type11 } from "@sinclair/typebox";
7981
4655
  function isPathSafe(basePath, requestedPath) {
7982
4656
  const normalized = normalize(requestedPath);
7983
4657
  const fullPath = join6(basePath, normalized);
7984
4658
  const relativePath = relative3(basePath, fullPath);
7985
4659
  return !relativePath.startsWith("..") && !relativePath.startsWith("/");
7986
4660
  }
7987
- var skillReferenceSchema = Type.Object({
7988
- skillName: Type.String({ description: "Name of the skill" }),
7989
- referencePath: Type.String({
4661
+ var skillReferenceSchema = Type11.Object({
4662
+ skillName: Type11.String({ description: "Name of the skill" }),
4663
+ referencePath: Type11.String({
7990
4664
  description: `Path to the reference file relative to the skill's references/ directory (e.g., "api-reference.md" or "guides/setup.md")`
7991
4665
  })
7992
4666
  });
@@ -8095,17 +4769,18 @@ async function listReferencesRecursive(dir, prefix = "") {
8095
4769
  }
8096
4770
 
8097
4771
  // src/tools/ask-user.ts
8098
- var askUserSchema = Type.Object({
8099
- question: Type.String({
4772
+ import { Type as Type12 } from "@sinclair/typebox";
4773
+ var askUserSchema = Type12.Object({
4774
+ question: Type12.String({
8100
4775
  description: "A clear, specific question to ask the user. Frame it to help clarify ambiguous requirements, confirm decisions, or gather preferences needed to proceed."
8101
4776
  }),
8102
- options: Type.Optional(
8103
- Type.Array(Type.String(), {
4777
+ options: Type12.Optional(
4778
+ Type12.Array(Type12.String(), {
8104
4779
  description: "Optional list of predefined answer choices. The user can pick one or type a custom response. Use when there are a small number of clear alternatives."
8105
4780
  })
8106
4781
  ),
8107
- context: Type.Optional(
8108
- Type.String({
4782
+ context: Type12.Optional(
4783
+ Type12.String({
8109
4784
  description: "Optional brief context explaining why this question is being asked, so the user understands the impact of their answer."
8110
4785
  })
8111
4786
  )
@@ -8161,6 +4836,7 @@ var askUserTool = createAskUserTool();
8161
4836
 
8162
4837
  // src/tools/todo.ts
8163
4838
  init_database();
4839
+ import { Type as Type13 } from "@sinclair/typebox";
8164
4840
 
8165
4841
  // src/features/todos/todos.database.ts
8166
4842
  init_database();
@@ -8251,46 +4927,46 @@ ${learnings}
8251
4927
  }
8252
4928
 
8253
4929
  // src/tools/todo.ts
8254
- var todoSchema = Type.Object({
8255
- action: Type.Union(
4930
+ var todoSchema = Type13.Object({
4931
+ action: Type13.Union(
8256
4932
  [
8257
- Type.Literal("add"),
8258
- Type.Literal("update"),
8259
- Type.Literal("list"),
8260
- Type.Literal("delete"),
8261
- Type.Literal("learnings")
4933
+ Type13.Literal("add"),
4934
+ Type13.Literal("update"),
4935
+ Type13.Literal("list"),
4936
+ Type13.Literal("delete"),
4937
+ Type13.Literal("learnings")
8262
4938
  ],
8263
4939
  {
8264
4940
  description: "Operation to perform: 'add' creates new items, 'update' changes status, 'list' returns all items, 'delete' removes items, 'learnings' appends text to progress.txt for cross-iteration memory."
8265
4941
  }
8266
4942
  ),
8267
- descriptions: Type.Optional(
8268
- Type.Array(Type.String(), {
4943
+ descriptions: Type13.Optional(
4944
+ Type13.Array(Type13.String(), {
8269
4945
  description: "Todo item descriptions. Required for 'add'. Provide one or more descriptions to create multiple items at once."
8270
4946
  })
8271
4947
  ),
8272
- ids: Type.Optional(
8273
- Type.Array(Type.String(), {
4948
+ ids: Type13.Optional(
4949
+ Type13.Array(Type13.String(), {
8274
4950
  description: "Todo item IDs. Required for 'update' and 'delete'. Provide one or more IDs to update or delete multiple items at once."
8275
4951
  })
8276
4952
  ),
8277
- status: Type.Optional(
8278
- Type.Union([Type.Literal("pending"), Type.Literal("working"), Type.Literal("done")], {
4953
+ status: Type13.Optional(
4954
+ Type13.Union([Type13.Literal("pending"), Type13.Literal("working"), Type13.Literal("done")], {
8279
4955
  description: "New status for 'update'. Applied to all specified IDs. 'pending' = not started, 'working' = in progress, 'done' = complete."
8280
4956
  })
8281
4957
  ),
8282
- assignedTo: Type.Optional(
8283
- Type.String({
4958
+ assignedTo: Type13.Optional(
4959
+ Type13.String({
8284
4960
  description: "Who items are assigned to. Defaults to 'agent'. Applied to all specified items."
8285
4961
  })
8286
4962
  ),
8287
- passes: Type.Optional(
8288
- Type.Boolean({
4963
+ passes: Type13.Optional(
4964
+ Type13.Boolean({
8289
4965
  description: "Whether the story's quality checks passed. Used in Ralph mode to mark stories as verified. Set to true when checks pass after implementation."
8290
4966
  })
8291
4967
  ),
8292
- learnings: Type.Optional(
8293
- Type.String({
4968
+ learnings: Type13.Optional(
4969
+ Type13.String({
8294
4970
  description: "Text to append to progress.txt. Required for 'learnings' action. Records patterns, gotchas, and context discovered during implementation."
8295
4971
  })
8296
4972
  )
@@ -9038,6 +5714,7 @@ function clearMCPToolCache(projectPath) {
9038
5714
  }
9039
5715
 
9040
5716
  // src/tools/generate-image.ts
5717
+ import { Type as Type14 } from "@sinclair/typebox";
9041
5718
  import { mkdir as fsMkdir2, writeFile as fsWriteFile3 } from "fs/promises";
9042
5719
  import { dirname as dirname2 } from "path";
9043
5720
 
@@ -9562,14 +6239,14 @@ async function searchImage(query, size, signal) {
9562
6239
  }
9563
6240
 
9564
6241
  // src/tools/generate-image.ts
9565
- var generateImageSchema = Type.Object({
9566
- prompt: Type.String({ description: "Text description of the image to generate" }),
9567
- model: Type.Optional(
9568
- Type.String({
6242
+ var generateImageSchema = Type14.Object({
6243
+ prompt: Type14.String({ description: "Text description of the image to generate" }),
6244
+ model: Type14.Optional(
6245
+ Type14.String({
9569
6246
  description: "Image model name or ID to use (e.g. 'dall-e-3', 'gpt-image-1', 'google/gemini-2.5-flash-image'). If omitted the first enabled image model is used."
9570
6247
  })
9571
6248
  ),
9572
- save_to_file: Type.String({
6249
+ save_to_file: Type14.String({
9573
6250
  description: "File path (relative to the project root) to save the generated image to, e.g. 'assets/logo.png' or 'docs/diagram.png'. The file and any parent directories will be created automatically. The image is also returned as data so it can be displayed."
9574
6251
  })
9575
6252
  });
@@ -9863,29 +6540,30 @@ async function executeGenerateImage(options) {
9863
6540
  }
9864
6541
 
9865
6542
  // src/tools/find-images.ts
6543
+ import { Type as Type15 } from "@sinclair/typebox";
9866
6544
  import { mkdir as fsMkdir3, writeFile as fsWriteFile4 } from "fs/promises";
9867
6545
  import { dirname as dirname3 } from "path";
9868
- var findImagesSchema = Type.Object({
9869
- query: Type.String({ description: "Search term for the image (e.g. 'sunset over mountains')" }),
9870
- size: Type.Optional(
9871
- Type.Union(
6546
+ var findImagesSchema = Type15.Object({
6547
+ query: Type15.String({ description: "Search term for the image (e.g. 'sunset over mountains')" }),
6548
+ size: Type15.Optional(
6549
+ Type15.Union(
9872
6550
  [
9873
- Type.Literal("original"),
9874
- Type.Literal("large2x"),
9875
- Type.Literal("large"),
9876
- Type.Literal("medium"),
9877
- Type.Literal("small"),
9878
- Type.Literal("portrait"),
9879
- Type.Literal("landscape"),
9880
- Type.Literal("tiny")
6551
+ Type15.Literal("original"),
6552
+ Type15.Literal("large2x"),
6553
+ Type15.Literal("large"),
6554
+ Type15.Literal("medium"),
6555
+ Type15.Literal("small"),
6556
+ Type15.Literal("portrait"),
6557
+ Type15.Literal("landscape"),
6558
+ Type15.Literal("tiny")
9881
6559
  ],
9882
6560
  {
9883
6561
  description: "Image size variant: original, large2x, large, medium (default), small, portrait, landscape, tiny"
9884
6562
  }
9885
6563
  )
9886
6564
  ),
9887
- save_to_file: Type.Optional(
9888
- Type.String({
6565
+ save_to_file: Type15.Optional(
6566
+ Type15.String({
9889
6567
  description: "File path relative to the project root to save the image to (e.g. 'assets/hero.jpg'). Parent directories are created automatically. If omitted the image is returned as base64 data only."
9890
6568
  })
9891
6569
  )
@@ -9955,11 +6633,12 @@ function createFindImagesTool(cwd) {
9955
6633
 
9956
6634
  // src/tools/execute-browser-js.ts
9957
6635
  init_tarsk_debug();
9958
- var runWebWorkerSchema = Type.Object({
9959
- intention: Type.String({
6636
+ import { Type as Type16 } from "@sinclair/typebox";
6637
+ var runWebWorkerSchema = Type16.Object({
6638
+ intention: Type16.String({
9960
6639
  description: "A short description of what this code execution is trying to accomplish."
9961
6640
  }),
9962
- code: Type.String({
6641
+ code: Type16.String({
9963
6642
  description: "The javascript code to execute in browser context(not nodejs). The environment provides an async function `callTool(toolName, params)` which allows calling any of the other available tools by name. callTool always returns `{ text: string | null, error: string | null }`. On success `text` contains the result and `error` is null. On failure `error` contains the error message and `text` is null. Example: `const r = await callTool('read', { path: 'foo.ts' }); if (r.error) return r.error; return r.text;`."
9964
6643
  })
9965
6644
  });
@@ -10092,6 +6771,9 @@ function looksLikeMissingReturn(code) {
10092
6771
  }
10093
6772
  var runWebWorkerTool = createRunWebWorkerTool();
10094
6773
 
6774
+ // src/tools/fetch.ts
6775
+ import { Type as Type17 } from "@sinclair/typebox";
6776
+
10095
6777
  // src/features/web-fetch/content-processor.ts
10096
6778
  import { completeSimple as completeSimple2 } from "@earendil-works/pi-ai";
10097
6779
 
@@ -11682,9 +8364,9 @@ function truncateFetchUrl(url, maxLength = 80) {
11682
8364
  }
11683
8365
 
11684
8366
  // src/tools/fetch.ts
11685
- var fetchSchema = Type.Object({
11686
- url: Type.String({ description: "Fully qualified URL to fetch (http or https)" }),
11687
- prompt: Type.String({
8367
+ var fetchSchema = Type17.Object({
8368
+ url: Type17.String({ description: "Fully qualified URL to fetch (http or https)" }),
8369
+ prompt: Type17.String({
11688
8370
  description: "What to extract or summarize from the page content"
11689
8371
  })
11690
8372
  });
@@ -11781,12 +8463,13 @@ function createFetchTool(options) {
11781
8463
  }
11782
8464
 
11783
8465
  // src/tools/tool-search.ts
11784
- var toolSearchSchema = Type.Object({
11785
- query: Type.String({
8466
+ import { Type as Type18 } from "@sinclair/typebox";
8467
+ var toolSearchSchema = Type18.Object({
8468
+ query: Type18.String({
11786
8469
  description: 'Search query to find tools. Use "select:name1,name2" to fetch exact tools by name, or keywords to search by description.'
11787
8470
  }),
11788
- max_results: Type.Optional(
11789
- Type.Number({
8471
+ max_results: Type18.Optional(
8472
+ Type18.Number({
11790
8473
  description: "Maximum number of results to return (default: 5)"
11791
8474
  })
11792
8475
  )
@@ -12381,6 +9064,9 @@ async function* loadCodingToolsWithMcpStatus(cwd, options) {
12381
9064
  return result;
12382
9065
  }
12383
9066
 
9067
+ // src/tools/agent-tool.ts
9068
+ import { Type as Type19 } from "@sinclair/typebox";
9069
+
12384
9070
  // src/agent/agent.subagent-executor.ts
12385
9071
  import { Agent } from "@earendil-works/pi-agent-core";
12386
9072
 
@@ -12728,15 +9414,15 @@ async function executeSubagent(options) {
12728
9414
  }
12729
9415
 
12730
9416
  // src/tools/agent-tool.ts
12731
- var agentToolSchema = Type.Object({
12732
- prompt: Type.String({ description: "The task or question for the subagent to work on" }),
12733
- agentName: Type.Optional(
12734
- Type.String({
9417
+ var agentToolSchema = Type19.Object({
9418
+ prompt: Type19.String({ description: "The task or question for the subagent to work on" }),
9419
+ agentName: Type19.Optional(
9420
+ Type19.String({
12735
9421
  description: "Name of a defined agent (from AGENT.md) to use. If omitted, a general-purpose subagent is created."
12736
9422
  })
12737
9423
  ),
12738
- description: Type.Optional(
12739
- Type.String({
9424
+ description: Type19.Optional(
9425
+ Type19.String({
12740
9426
  description: "A short (3-5 word) label describing what the subagent will do"
12741
9427
  })
12742
9428
  )