@agntn/tools 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/_chunks/libs/typebox.d.mts +869 -535
- package/dist/_chunks/libs/typebox.d.mts.map +1 -1
- package/dist/_chunks/libs/typebox.mjs +234 -3
- package/dist/_chunks/libs/typebox.mjs.map +1 -1
- package/dist/_chunks/src.mjs +158 -0
- package/dist/_chunks/src.mjs.map +1 -0
- package/dist/ai.d.mts +3 -4
- package/dist/ai.d.mts.map +1 -1
- package/dist/ai.mjs +1 -1
- package/dist/cli.d.mts +65 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +393 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +38 -20
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -90
- package/dist/mcp.d.mts +6 -7
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +2 -1
- package/dist/mcp.mjs.map +1 -1
- package/dist/omp.d.mts +4 -5
- package/dist/omp.d.mts.map +1 -1
- package/dist/omp.mjs +1 -1
- package/dist/pi.d.mts +3 -4
- package/dist/pi.d.mts.map +1 -1
- package/dist/pi.mjs +1 -1
- package/package.json +19 -16
- package/dist/index.mjs.map +0 -1
|
@@ -134,6 +134,9 @@ function IsUnsafePropertyKey(key) {
|
|
|
134
134
|
function HasPropertyKey(value, key) {
|
|
135
135
|
return IsUnsafePropertyKey(key) ? Object.prototype.hasOwnProperty.call(value, key) : key in value;
|
|
136
136
|
}
|
|
137
|
+
function EntriesRegExp(value) {
|
|
138
|
+
return Keys(value).map((key) => [new RegExp(`^${key}$`), value[key]]);
|
|
139
|
+
}
|
|
137
140
|
function Entries(value) {
|
|
138
141
|
return Object.entries(value);
|
|
139
142
|
}
|
|
@@ -5620,8 +5623,236 @@ function Errors(...args) {
|
|
|
5620
5623
|
const [_, errors] = Errors$1(context, type, value);
|
|
5621
5624
|
return errors;
|
|
5622
5625
|
}
|
|
5623
|
-
|
|
5624
|
-
|
|
5626
|
+
function Clone(value) {
|
|
5627
|
+
return Clone$1(value);
|
|
5628
|
+
}
|
|
5629
|
+
function IsOk(value) {
|
|
5630
|
+
return IsObject$1(value) && HasPropertyKey(value, "value");
|
|
5631
|
+
}
|
|
5632
|
+
function Ok(value) {
|
|
5633
|
+
return { value };
|
|
5634
|
+
}
|
|
5635
|
+
function TryArray(value) {
|
|
5636
|
+
return IsArray$1(value) ? Ok(value) : Ok([value]);
|
|
5637
|
+
}
|
|
5638
|
+
function FromBoolean$4(value) {
|
|
5639
|
+
return IsEqual(value, true) ? Ok(BigInt(1)) : Ok(BigInt(0));
|
|
5640
|
+
}
|
|
5641
|
+
const bigintPattern = /^-?(0|[1-9]\d*)n$/;
|
|
5642
|
+
const decimalPattern = /^-?(0|[1-9]\d*)\.\d+$/;
|
|
5643
|
+
const integerPattern = /^-?(0|[1-9]\d*)$/;
|
|
5644
|
+
function IsStringBigIntLike(value) {
|
|
5645
|
+
return bigintPattern.test(value);
|
|
5646
|
+
}
|
|
5647
|
+
function IsStringDecimalLike(value) {
|
|
5648
|
+
return decimalPattern.test(value);
|
|
5649
|
+
}
|
|
5650
|
+
function IsStringIntegerLike(value) {
|
|
5651
|
+
return integerPattern.test(value);
|
|
5652
|
+
}
|
|
5653
|
+
function FromString$5(value) {
|
|
5654
|
+
const lowercase = value.toLowerCase();
|
|
5655
|
+
return IsStringBigIntLike(value) ? Ok(BigInt(value.slice(0, value.length - 1))) : IsStringDecimalLike(value) ? Ok(BigInt(value.split(".")[0])) : IsStringIntegerLike(value) ? Ok(BigInt(value)) : IsEqual(lowercase, "false") ? Ok(BigInt(0)) : IsEqual(lowercase, "true") ? Ok(BigInt(1)) : void 0;
|
|
5656
|
+
}
|
|
5657
|
+
function TryBigInt(value) {
|
|
5658
|
+
return IsBigInt$1(value) ? Ok(value) : IsBoolean$2(value) ? FromBoolean$4(value) : IsNumber$2(value) ? Ok(BigInt(Math.trunc(value))) : IsNull$1(value) ? Ok(BigInt(0)) : IsString$2(value) ? FromString$5(value) : IsUndefined$1(value) ? Ok(BigInt(0)) : void 0;
|
|
5659
|
+
}
|
|
5660
|
+
function FromBigInt$4(value) {
|
|
5661
|
+
return IsEqual(value, BigInt(0)) ? Ok(false) : IsEqual(value, BigInt(1)) ? Ok(true) : void 0;
|
|
5662
|
+
}
|
|
5663
|
+
function FromNumber$3(value) {
|
|
5664
|
+
return IsEqual(value, 0) ? Ok(false) : IsEqual(value, 1) ? Ok(true) : void 0;
|
|
5665
|
+
}
|
|
5666
|
+
function FromString$4(value) {
|
|
5667
|
+
return IsEqual(value.toLowerCase(), "false") ? Ok(false) : IsEqual(value.toLowerCase(), "true") ? Ok(true) : IsEqual(value, "0") ? Ok(false) : IsEqual(value, "1") ? Ok(true) : void 0;
|
|
5668
|
+
}
|
|
5669
|
+
function TryBoolean(value) {
|
|
5670
|
+
return IsBigInt$1(value) ? FromBigInt$4(value) : IsBoolean$2(value) ? Ok(value) : IsNumber$2(value) ? FromNumber$3(value) : IsNull$1(value) ? Ok(false) : IsString$2(value) ? FromString$4(value) : IsUndefined$1(value) ? Ok(false) : void 0;
|
|
5671
|
+
}
|
|
5672
|
+
function FromBigInt$3(value) {
|
|
5673
|
+
return IsEqual(value, BigInt(0)) ? Ok(null) : void 0;
|
|
5674
|
+
}
|
|
5675
|
+
function FromBoolean$3(value) {
|
|
5676
|
+
return IsEqual(value, false) ? Ok(null) : void 0;
|
|
5677
|
+
}
|
|
5678
|
+
function FromNumber$2(value) {
|
|
5679
|
+
return IsEqual(value, 0) ? Ok(null) : void 0;
|
|
5680
|
+
}
|
|
5681
|
+
function FromString$3(value) {
|
|
5682
|
+
const lowercase = value.toLowerCase();
|
|
5683
|
+
return IsEqual(lowercase, "undefined") || IsEqual(lowercase, "null") || IsEqual(value, "") || IsEqual(value, "0") ? Ok(null) : void 0;
|
|
5684
|
+
}
|
|
5685
|
+
function TryNull(value) {
|
|
5686
|
+
return IsBigInt$1(value) ? FromBigInt$3(value) : IsBoolean$2(value) ? FromBoolean$3(value) : IsNumber$2(value) ? FromNumber$2(value) : IsNull$1(value) ? Ok(null) : IsString$2(value) ? FromString$3(value) : IsUndefined$1(value) ? Ok(null) : void 0;
|
|
5687
|
+
}
|
|
5688
|
+
const maxBigInt = BigInt(Number.MAX_SAFE_INTEGER);
|
|
5689
|
+
const minBigInt = BigInt(Number.MIN_SAFE_INTEGER);
|
|
5690
|
+
function FromBigInt$2(value) {
|
|
5691
|
+
return value <= maxBigInt && value >= minBigInt ? Ok(Number(value)) : void 0;
|
|
5692
|
+
}
|
|
5693
|
+
function FromBoolean$2(value) {
|
|
5694
|
+
return Ok(value ? 1 : 0);
|
|
5695
|
+
}
|
|
5696
|
+
function FromString$2(value) {
|
|
5697
|
+
const coerced = +value;
|
|
5698
|
+
if (IsNumber$2(coerced)) return Ok(coerced);
|
|
5699
|
+
const lowercase = value.toLowerCase();
|
|
5700
|
+
if (IsEqual(lowercase, "false")) return Ok(0);
|
|
5701
|
+
if (IsEqual(lowercase, "true")) return Ok(1);
|
|
5702
|
+
const result = TryBigInt(value);
|
|
5703
|
+
if (IsOk(result)) return result.value <= maxBigInt && result.value >= minBigInt ? Ok(Number(result.value)) : void 0;
|
|
5704
|
+
}
|
|
5705
|
+
function TryNumber(value) {
|
|
5706
|
+
return IsBigInt$1(value) ? FromBigInt$2(value) : IsBoolean$2(value) ? FromBoolean$2(value) : IsNumber$2(value) ? Ok(value) : IsNull$1(value) ? Ok(0) : IsString$2(value) ? FromString$2(value) : IsUndefined$1(value) ? Ok(0) : void 0;
|
|
5707
|
+
}
|
|
5708
|
+
function TryString(value) {
|
|
5709
|
+
return IsBigInt$1(value) ? Ok(value.toString()) : IsBoolean$2(value) ? Ok(value.toString()) : IsNumber$2(value) ? Ok(value.toString()) : IsNull$1(value) ? Ok("null") : IsString$2(value) ? Ok(value) : IsUndefined$1(value) ? Ok("") : void 0;
|
|
5710
|
+
}
|
|
5711
|
+
function FromBigInt$1(value) {
|
|
5712
|
+
return IsEqual(value, BigInt(0)) ? Ok(void 0) : void 0;
|
|
5713
|
+
}
|
|
5714
|
+
function FromBoolean$1(value) {
|
|
5715
|
+
return IsEqual(value, false) ? Ok(void 0) : void 0;
|
|
5716
|
+
}
|
|
5717
|
+
function FromNumber$1(value) {
|
|
5718
|
+
return IsEqual(value, 0) ? Ok(void 0) : void 0;
|
|
5719
|
+
}
|
|
5720
|
+
function FromString$1(value) {
|
|
5721
|
+
const lowercase = value.toLowerCase();
|
|
5722
|
+
return IsEqual(lowercase, "undefined") || IsEqual(lowercase, "null") || IsEqual(value, "") || IsEqual(value, "0") ? Ok(void 0) : void 0;
|
|
5723
|
+
}
|
|
5724
|
+
function TryUndefined(value) {
|
|
5725
|
+
return IsBigInt$1(value) ? FromBigInt$1(value) : IsBoolean$2(value) ? FromBoolean$1(value) : IsNumber$2(value) ? FromNumber$1(value) : IsNull$1(value) ? Ok(void 0) : IsString$2(value) ? FromString$1(value) : IsUndefined$1(value) ? Ok(value) : void 0;
|
|
5726
|
+
}
|
|
5727
|
+
function FromArray$2(context, type, value) {
|
|
5728
|
+
return TryArray(value).value.map((value) => FromType$2(context, type.items, value));
|
|
5729
|
+
}
|
|
5730
|
+
function FromBigInt(_context, _type, value) {
|
|
5731
|
+
const result = TryBigInt(value);
|
|
5732
|
+
return IsOk(result) ? result.value : value;
|
|
5733
|
+
}
|
|
5734
|
+
function FromBoolean(_context, _type, value) {
|
|
5735
|
+
const result = TryBoolean(value);
|
|
5736
|
+
return IsOk(result) ? result.value : value;
|
|
5737
|
+
}
|
|
5738
|
+
function FromCyclic$2(context, type, value) {
|
|
5739
|
+
return FromType$2({
|
|
5740
|
+
...context,
|
|
5741
|
+
...type.$defs
|
|
5742
|
+
}, Ref$1(type.$ref), value);
|
|
5743
|
+
}
|
|
5744
|
+
function FromEnum(context, type, value) {
|
|
5745
|
+
return FromType$2(context, Evaluate(type), value);
|
|
5746
|
+
}
|
|
5747
|
+
function FromInteger(_context, _type, value) {
|
|
5748
|
+
const result = TryNumber(value);
|
|
5749
|
+
return IsOk(result) ? Math.trunc(result.value) : value;
|
|
5750
|
+
}
|
|
5751
|
+
function FromIntersect$2(context, type, value) {
|
|
5752
|
+
return FromType$2(context, Evaluate(Instantiate(context, type)), value);
|
|
5753
|
+
}
|
|
5754
|
+
function FromLiteralBigInt(_context, type, value) {
|
|
5755
|
+
const result = TryBigInt(value);
|
|
5756
|
+
return IsOk(result) && IsEqual(type.const, result.value) ? result.value : value;
|
|
5757
|
+
}
|
|
5758
|
+
function FromLiteralBoolean(_context, type, value) {
|
|
5759
|
+
const result = TryBoolean(value);
|
|
5760
|
+
return IsOk(result) && IsEqual(type.const, result.value) ? result.value : value;
|
|
5761
|
+
}
|
|
5762
|
+
function FromLiteralNumber(_context, type, value) {
|
|
5763
|
+
const result = TryNumber(value);
|
|
5764
|
+
return IsOk(result) && IsEqual(type.const, result.value) ? result.value : value;
|
|
5765
|
+
}
|
|
5766
|
+
function FromLiteralString(_context, type, value) {
|
|
5767
|
+
const result = TryString(value);
|
|
5768
|
+
return IsOk(result) && IsEqual(type.const, result.value) ? result.value : value;
|
|
5769
|
+
}
|
|
5770
|
+
function FromLiteral(context, type, value) {
|
|
5771
|
+
if (IsEqual(type.const, value)) return value;
|
|
5772
|
+
return IsLiteralBigInt(type) ? FromLiteralBigInt(context, type, value) : IsLiteralBoolean(type) ? FromLiteralBoolean(context, type, value) : IsLiteralNumber(type) ? FromLiteralNumber(context, type, value) : IsLiteralString(type) ? FromLiteralString(context, type, value) : Unreachable$1();
|
|
5773
|
+
}
|
|
5774
|
+
function FromNull(_context, _type, value) {
|
|
5775
|
+
const result = TryNull(value);
|
|
5776
|
+
return IsOk(result) ? result.value : value;
|
|
5777
|
+
}
|
|
5778
|
+
function FromNumber(_context, _type, value) {
|
|
5779
|
+
const result = TryNumber(value);
|
|
5780
|
+
return IsOk(result) ? result.value : value;
|
|
5781
|
+
}
|
|
5782
|
+
function FromAdditionalProperties(context, entries, additionalProperties, value) {
|
|
5783
|
+
const keys = Keys(value);
|
|
5784
|
+
for (const [regexp, _] of entries) for (const key of keys) if (!regexp.test(key)) value[key] = FromType$2(context, additionalProperties, value[key]);
|
|
5785
|
+
return value;
|
|
5786
|
+
}
|
|
5787
|
+
function IsOptionalUndefined(property, key, value) {
|
|
5788
|
+
return IsOptional(property) && IsUndefined$1(value[key]);
|
|
5789
|
+
}
|
|
5790
|
+
function FromProperties(context, type, value) {
|
|
5791
|
+
const entries = EntriesRegExp(type.properties);
|
|
5792
|
+
const keys = Keys(value);
|
|
5793
|
+
for (const [regexp, property] of entries) for (const key of keys) {
|
|
5794
|
+
if (!regexp.test(key) || IsOptionalUndefined(property, key, value)) continue;
|
|
5795
|
+
value[key] = FromType$2(context, property, value[key]);
|
|
5796
|
+
}
|
|
5797
|
+
return HasPropertyKey(type, "additionalProperties") && IsObject$1(type.additionalProperties) ? FromAdditionalProperties(context, entries, type.additionalProperties, value) : value;
|
|
5798
|
+
}
|
|
5799
|
+
function FromObject$2(context, type, value) {
|
|
5800
|
+
return IsObjectNotArray(value) ? FromProperties(context, type, value) : value;
|
|
5801
|
+
}
|
|
5802
|
+
function FromPatternProperties(context, type, value) {
|
|
5803
|
+
const entries = EntriesRegExp(type.patternProperties);
|
|
5804
|
+
const keys = Keys(value);
|
|
5805
|
+
for (const [regexp, schema] of entries) for (const key of keys) if (regexp.test(key)) value[key] = FromType$2(context, schema, value[key]);
|
|
5806
|
+
return HasPropertyKey(type, "additionalProperties") && IsObject$1(type.additionalProperties) ? FromAdditionalProperties(context, entries, type.additionalProperties, value) : value;
|
|
5807
|
+
}
|
|
5808
|
+
function FromRecord$2(context, type, value) {
|
|
5809
|
+
return IsObjectNotArray(value) ? FromPatternProperties(context, type, value) : value;
|
|
5810
|
+
}
|
|
5811
|
+
function FromRef$2(context, type, value) {
|
|
5812
|
+
return HasPropertyKey(context, type.$ref) ? FromType$2(context, context[type.$ref], value) : value;
|
|
5813
|
+
}
|
|
5814
|
+
function FromString(_context, _type, value) {
|
|
5815
|
+
const result = TryString(value);
|
|
5816
|
+
return IsOk(result) ? result.value : value;
|
|
5817
|
+
}
|
|
5818
|
+
function FromTemplateLiteral(context, type, value) {
|
|
5819
|
+
return FromType$2(context, Evaluate(type), value);
|
|
5820
|
+
}
|
|
5821
|
+
function FromTuple$2(context, type, value) {
|
|
5822
|
+
if (!IsArray$1(value)) return value;
|
|
5823
|
+
for (let index = 0; index < Math.min(type.items.length, value.length); index++) value[index] = FromType$2(context, type.items[index], value[index]);
|
|
5824
|
+
return value;
|
|
5825
|
+
}
|
|
5826
|
+
function FromUndefined(_context, _type, value) {
|
|
5827
|
+
const result = TryUndefined(value);
|
|
5828
|
+
return IsOk(result) ? result.value : value;
|
|
5829
|
+
}
|
|
5830
|
+
function FromUnion$2(context, type, value) {
|
|
5831
|
+
if (type.anyOf.some((type) => Check(context, type, value))) return value;
|
|
5832
|
+
const selected = type.anyOf.map((type) => FromType$2(context, type, Clone(value))).find((value) => Check(context, type, value));
|
|
5833
|
+
return IsUndefined$1(selected) ? value : selected;
|
|
5834
|
+
}
|
|
5835
|
+
function FromVoid(_context, _type, value) {
|
|
5836
|
+
return IsOk(TryUndefined(value)) ? void 0 : value;
|
|
5837
|
+
}
|
|
5838
|
+
function FromType$2(context, type, value) {
|
|
5839
|
+
return IsArray(type) ? FromArray$2(context, type, value) : IsBigInt(type) ? FromBigInt(context, type, value) : IsBoolean(type) ? FromBoolean(context, type, value) : IsCyclic(type) ? FromCyclic$2(context, type, value) : IsEnum$1(type) ? FromEnum(context, type, value) : IsInteger(type) ? FromInteger(context, type, value) : IsIntersect(type) ? FromIntersect$2(context, type, value) : IsLiteral(type) ? FromLiteral(context, type, value) : IsNull(type) ? FromNull(context, type, value) : IsNumber(type) ? FromNumber(context, type, value) : IsObject(type) ? FromObject$2(context, type, value) : IsRecord(type) ? FromRecord$2(context, type, value) : IsRef$1(type) ? FromRef$2(context, type, value) : IsString(type) ? FromString(context, type, value) : IsTemplateLiteral(type) ? FromTemplateLiteral(context, type, value) : IsTuple(type) ? FromTuple$2(context, type, value) : IsUndefined(type) ? FromUndefined(context, type, value) : IsUnion(type) ? FromUnion$2(context, type, value) : IsVoid(type) ? FromVoid(context, type, value) : value;
|
|
5840
|
+
}
|
|
5841
|
+
function Convert(...args) {
|
|
5842
|
+
const [context, type, value] = Match$3(args, {
|
|
5843
|
+
3: (context, type, value) => [
|
|
5844
|
+
context,
|
|
5845
|
+
type,
|
|
5846
|
+
value
|
|
5847
|
+
],
|
|
5848
|
+
2: (type, value) => [
|
|
5849
|
+
{},
|
|
5850
|
+
type,
|
|
5851
|
+
value
|
|
5852
|
+
]
|
|
5853
|
+
});
|
|
5854
|
+
return FromType$2(context, type, value);
|
|
5855
|
+
}
|
|
5625
5856
|
Union([
|
|
5626
5857
|
_Object_$1({
|
|
5627
5858
|
type: Literal("insert"),
|
|
@@ -5638,6 +5869,6 @@ Union([
|
|
|
5638
5869
|
path: String$2()
|
|
5639
5870
|
})
|
|
5640
5871
|
]);
|
|
5641
|
-
export { Check, Errors, type_exports };
|
|
5872
|
+
export { Check, Convert, Errors, type_exports };
|
|
5642
5873
|
|
|
5643
5874
|
//# sourceMappingURL=typebox.mjs.map
|