@integrity-labs/agt-cli 0.15.24 → 0.15.31
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/dist/bin/agt.js +7 -3
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-YLZSW2GG.js → chunk-EFABVBMW.js} +79 -2
- package/dist/{chunk-YLZSW2GG.js.map → chunk-EFABVBMW.js.map} +1 -1
- package/dist/{claude-pair-runtime-5DOIHB44.js → claude-pair-runtime-VXNC2VEX.js} +12 -63
- package/dist/claude-pair-runtime-VXNC2VEX.js.map +1 -0
- package/dist/lib/manager-worker.js +29 -14
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/manager-supervisor-A23IZIWC.js +182 -0
- package/dist/manager-supervisor-A23IZIWC.js.map +1 -0
- package/mcp/slack-channel.js +420 -208
- package/mcp/telegram-channel.js +407 -206
- package/package.json +1 -1
- package/dist/claude-pair-runtime-5DOIHB44.js.map +0 -1
package/mcp/telegram-channel.js
CHANGED
|
@@ -14,9 +14,9 @@ var __export = (target, all) => {
|
|
|
14
14
|
};
|
|
15
15
|
var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let
|
|
18
|
-
if (!__hasOwnProp.call(to,
|
|
19
|
-
__defProp(to,
|
|
17
|
+
for (let key2 of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
19
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
@@ -165,15 +165,15 @@ var require_code = __commonJS({
|
|
|
165
165
|
return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
166
166
|
}
|
|
167
167
|
exports.safeStringify = safeStringify;
|
|
168
|
-
function getProperty(
|
|
169
|
-
return typeof
|
|
168
|
+
function getProperty(key2) {
|
|
169
|
+
return typeof key2 == "string" && exports.IDENTIFIER.test(key2) ? new _Code(`.${key2}`) : _`[${key2}]`;
|
|
170
170
|
}
|
|
171
171
|
exports.getProperty = getProperty;
|
|
172
|
-
function getEsmExportName(
|
|
173
|
-
if (typeof
|
|
174
|
-
return new _Code(`${
|
|
172
|
+
function getEsmExportName(key2) {
|
|
173
|
+
if (typeof key2 == "string" && exports.IDENTIFIER.test(key2)) {
|
|
174
|
+
return new _Code(`${key2}`);
|
|
175
175
|
}
|
|
176
|
-
throw new Error(`CodeGen: invalid export name: ${
|
|
176
|
+
throw new Error(`CodeGen: invalid export name: ${key2}, use explicit $id name mapping`);
|
|
177
177
|
}
|
|
178
178
|
exports.getEsmExportName = getEsmExportName;
|
|
179
179
|
function regexpCode(rx) {
|
|
@@ -800,11 +800,11 @@ var require_codegen = __commonJS({
|
|
|
800
800
|
// returns code for object literal for the passed argument list of key-value pairs
|
|
801
801
|
object(...keyValues) {
|
|
802
802
|
const code = ["{"];
|
|
803
|
-
for (const [
|
|
803
|
+
for (const [key2, value] of keyValues) {
|
|
804
804
|
if (code.length > 1)
|
|
805
805
|
code.push(",");
|
|
806
|
-
code.push(
|
|
807
|
-
if (
|
|
806
|
+
code.push(key2);
|
|
807
|
+
if (key2 !== value || this.opts.es5) {
|
|
808
808
|
code.push(":");
|
|
809
809
|
(0, code_1.addCodeArg)(code, value);
|
|
810
810
|
}
|
|
@@ -1079,17 +1079,17 @@ var require_util = __commonJS({
|
|
|
1079
1079
|
if (typeof schema === "boolean")
|
|
1080
1080
|
return;
|
|
1081
1081
|
const rules = self.RULES.keywords;
|
|
1082
|
-
for (const
|
|
1083
|
-
if (!rules[
|
|
1084
|
-
checkStrictMode(it, `unknown keyword: "${
|
|
1082
|
+
for (const key2 in schema) {
|
|
1083
|
+
if (!rules[key2])
|
|
1084
|
+
checkStrictMode(it, `unknown keyword: "${key2}"`);
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
1087
1087
|
exports.checkUnknownRules = checkUnknownRules;
|
|
1088
1088
|
function schemaHasRules(schema, rules) {
|
|
1089
1089
|
if (typeof schema == "boolean")
|
|
1090
1090
|
return !schema;
|
|
1091
|
-
for (const
|
|
1092
|
-
if (rules[
|
|
1091
|
+
for (const key2 in schema)
|
|
1092
|
+
if (rules[key2])
|
|
1093
1093
|
return true;
|
|
1094
1094
|
return false;
|
|
1095
1095
|
}
|
|
@@ -1097,8 +1097,8 @@ var require_util = __commonJS({
|
|
|
1097
1097
|
function schemaHasRulesButRef(schema, RULES) {
|
|
1098
1098
|
if (typeof schema == "boolean")
|
|
1099
1099
|
return !schema;
|
|
1100
|
-
for (const
|
|
1101
|
-
if (
|
|
1100
|
+
for (const key2 in schema)
|
|
1101
|
+
if (key2 !== "$ref" && RULES.all[key2])
|
|
1102
1102
|
return true;
|
|
1103
1103
|
return false;
|
|
1104
1104
|
}
|
|
@@ -1676,8 +1676,8 @@ var require_defaults = __commonJS({
|
|
|
1676
1676
|
function assignDefaults(it, ty) {
|
|
1677
1677
|
const { properties, items } = it.schema;
|
|
1678
1678
|
if (ty === "object" && properties) {
|
|
1679
|
-
for (const
|
|
1680
|
-
assignDefault(it,
|
|
1679
|
+
for (const key2 in properties) {
|
|
1680
|
+
assignDefault(it, key2, properties[key2].default);
|
|
1681
1681
|
}
|
|
1682
1682
|
} else if (ty === "array" && Array.isArray(items)) {
|
|
1683
1683
|
items.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
@@ -2061,8 +2061,8 @@ var require_fast_deep_equal = __commonJS({
|
|
|
2061
2061
|
for (i = length; i-- !== 0; )
|
|
2062
2062
|
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
2063
2063
|
for (i = length; i-- !== 0; ) {
|
|
2064
|
-
var
|
|
2065
|
-
if (!equal(a[
|
|
2064
|
+
var key2 = keys[i];
|
|
2065
|
+
if (!equal(a[key2], b[key2])) return false;
|
|
2066
2066
|
}
|
|
2067
2067
|
return true;
|
|
2068
2068
|
}
|
|
@@ -2134,20 +2134,20 @@ var require_json_schema_traverse = __commonJS({
|
|
|
2134
2134
|
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
2135
2135
|
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
2136
2136
|
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
2137
|
-
for (var
|
|
2138
|
-
var sch = schema[
|
|
2137
|
+
for (var key2 in schema) {
|
|
2138
|
+
var sch = schema[key2];
|
|
2139
2139
|
if (Array.isArray(sch)) {
|
|
2140
|
-
if (
|
|
2140
|
+
if (key2 in traverse.arrayKeywords) {
|
|
2141
2141
|
for (var i = 0; i < sch.length; i++)
|
|
2142
|
-
_traverse(opts, pre, post, sch[i], jsonPtr + "/" +
|
|
2142
|
+
_traverse(opts, pre, post, sch[i], jsonPtr + "/" + key2 + "/" + i, rootSchema, jsonPtr, key2, schema, i);
|
|
2143
2143
|
}
|
|
2144
|
-
} else if (
|
|
2144
|
+
} else if (key2 in traverse.propsKeywords) {
|
|
2145
2145
|
if (sch && typeof sch == "object") {
|
|
2146
2146
|
for (var prop in sch)
|
|
2147
|
-
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" +
|
|
2147
|
+
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key2 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key2, schema, prop);
|
|
2148
2148
|
}
|
|
2149
|
-
} else if (
|
|
2150
|
-
_traverse(opts, pre, post, sch, jsonPtr + "/" +
|
|
2149
|
+
} else if (key2 in traverse.keywords || opts.allKeys && !(key2 in traverse.skipKeywords)) {
|
|
2150
|
+
_traverse(opts, pre, post, sch, jsonPtr + "/" + key2, rootSchema, jsonPtr, key2, schema);
|
|
2151
2151
|
}
|
|
2152
2152
|
}
|
|
2153
2153
|
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
@@ -2204,10 +2204,10 @@ var require_resolve = __commonJS({
|
|
|
2204
2204
|
"$dynamicAnchor"
|
|
2205
2205
|
]);
|
|
2206
2206
|
function hasRef(schema) {
|
|
2207
|
-
for (const
|
|
2208
|
-
if (REF_KEYWORDS.has(
|
|
2207
|
+
for (const key2 in schema) {
|
|
2208
|
+
if (REF_KEYWORDS.has(key2))
|
|
2209
2209
|
return true;
|
|
2210
|
-
const sch = schema[
|
|
2210
|
+
const sch = schema[key2];
|
|
2211
2211
|
if (Array.isArray(sch) && sch.some(hasRef))
|
|
2212
2212
|
return true;
|
|
2213
2213
|
if (typeof sch == "object" && hasRef(sch))
|
|
@@ -2217,14 +2217,14 @@ var require_resolve = __commonJS({
|
|
|
2217
2217
|
}
|
|
2218
2218
|
function countKeys(schema) {
|
|
2219
2219
|
let count = 0;
|
|
2220
|
-
for (const
|
|
2221
|
-
if (
|
|
2220
|
+
for (const key2 in schema) {
|
|
2221
|
+
if (key2 === "$ref")
|
|
2222
2222
|
return Infinity;
|
|
2223
2223
|
count++;
|
|
2224
|
-
if (SIMPLE_INLINED.has(
|
|
2224
|
+
if (SIMPLE_INLINED.has(key2))
|
|
2225
2225
|
continue;
|
|
2226
|
-
if (typeof schema[
|
|
2227
|
-
(0, util_1.eachItem)(schema[
|
|
2226
|
+
if (typeof schema[key2] == "object") {
|
|
2227
|
+
(0, util_1.eachItem)(schema[key2], (sch) => count += countKeys(sch));
|
|
2228
2228
|
}
|
|
2229
2229
|
if (count === Infinity)
|
|
2230
2230
|
return Infinity;
|
|
@@ -2413,8 +2413,8 @@ var require_validate = __commonJS({
|
|
|
2413
2413
|
function schemaCxtHasRules({ schema, self }) {
|
|
2414
2414
|
if (typeof schema == "boolean")
|
|
2415
2415
|
return !schema;
|
|
2416
|
-
for (const
|
|
2417
|
-
if (self.RULES.all[
|
|
2416
|
+
for (const key2 in schema)
|
|
2417
|
+
if (self.RULES.all[key2])
|
|
2418
2418
|
return true;
|
|
2419
2419
|
return false;
|
|
2420
2420
|
}
|
|
@@ -4056,7 +4056,7 @@ var require_core = __commonJS({
|
|
|
4056
4056
|
}
|
|
4057
4057
|
}
|
|
4058
4058
|
// Adds schema to the instance
|
|
4059
|
-
addSchema(schema,
|
|
4059
|
+
addSchema(schema, key2, _meta, _validateSchema = this.opts.validateSchema) {
|
|
4060
4060
|
if (Array.isArray(schema)) {
|
|
4061
4061
|
for (const sch of schema)
|
|
4062
4062
|
this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
@@ -4070,15 +4070,15 @@ var require_core = __commonJS({
|
|
|
4070
4070
|
throw new Error(`schema ${schemaId} must be string`);
|
|
4071
4071
|
}
|
|
4072
4072
|
}
|
|
4073
|
-
|
|
4074
|
-
this._checkUnique(
|
|
4075
|
-
this.schemas[
|
|
4073
|
+
key2 = (0, resolve_1.normalizeId)(key2 || id);
|
|
4074
|
+
this._checkUnique(key2);
|
|
4075
|
+
this.schemas[key2] = this._addSchema(schema, _meta, key2, _validateSchema, true);
|
|
4076
4076
|
return this;
|
|
4077
4077
|
}
|
|
4078
4078
|
// Add schema that will be used to validate other schemas
|
|
4079
4079
|
// options in META_IGNORE_OPTIONS are alway set to false
|
|
4080
|
-
addMetaSchema(schema,
|
|
4081
|
-
this.addSchema(schema,
|
|
4080
|
+
addMetaSchema(schema, key2, _validateSchema = this.opts.validateSchema) {
|
|
4081
|
+
this.addSchema(schema, key2, true, _validateSchema);
|
|
4082
4082
|
return this;
|
|
4083
4083
|
}
|
|
4084
4084
|
// Validate schema against its meta-schema
|
|
@@ -4147,8 +4147,8 @@ var require_core = __commonJS({
|
|
|
4147
4147
|
return this;
|
|
4148
4148
|
}
|
|
4149
4149
|
case "object": {
|
|
4150
|
-
const
|
|
4151
|
-
this._cache.delete(
|
|
4150
|
+
const cacheKey2 = schemaKeyRef;
|
|
4151
|
+
this._cache.delete(cacheKey2);
|
|
4152
4152
|
let id = schemaKeyRef[this.opts.schemaId];
|
|
4153
4153
|
if (id) {
|
|
4154
4154
|
id = (0, resolve_1.normalizeId)(id);
|
|
@@ -4234,14 +4234,14 @@ var require_core = __commonJS({
|
|
|
4234
4234
|
let keywords = metaSchema;
|
|
4235
4235
|
for (const seg of segments)
|
|
4236
4236
|
keywords = keywords[seg];
|
|
4237
|
-
for (const
|
|
4238
|
-
const rule = rules[
|
|
4237
|
+
for (const key2 in rules) {
|
|
4238
|
+
const rule = rules[key2];
|
|
4239
4239
|
if (typeof rule != "object")
|
|
4240
4240
|
continue;
|
|
4241
4241
|
const { $data } = rule.definition;
|
|
4242
|
-
const schema = keywords[
|
|
4242
|
+
const schema = keywords[key2];
|
|
4243
4243
|
if ($data && schema)
|
|
4244
|
-
keywords[
|
|
4244
|
+
keywords[key2] = schemaOrData(schema);
|
|
4245
4245
|
}
|
|
4246
4246
|
}
|
|
4247
4247
|
return metaSchema;
|
|
@@ -4314,10 +4314,10 @@ var require_core = __commonJS({
|
|
|
4314
4314
|
Ajv2.MissingRefError = ref_error_1.default;
|
|
4315
4315
|
exports.default = Ajv2;
|
|
4316
4316
|
function checkOptions(checkOpts, options, msg, log = "error") {
|
|
4317
|
-
for (const
|
|
4318
|
-
const opt =
|
|
4317
|
+
for (const key2 in checkOpts) {
|
|
4318
|
+
const opt = key2;
|
|
4319
4319
|
if (opt in options)
|
|
4320
|
-
this.logger[log](`${msg}: option ${
|
|
4320
|
+
this.logger[log](`${msg}: option ${key2}. ${checkOpts[opt]}`);
|
|
4321
4321
|
}
|
|
4322
4322
|
}
|
|
4323
4323
|
function getSchEnv(keyRef) {
|
|
@@ -4331,8 +4331,8 @@ var require_core = __commonJS({
|
|
|
4331
4331
|
if (Array.isArray(optsSchemas))
|
|
4332
4332
|
this.addSchema(optsSchemas);
|
|
4333
4333
|
else
|
|
4334
|
-
for (const
|
|
4335
|
-
this.addSchema(optsSchemas[
|
|
4334
|
+
for (const key2 in optsSchemas)
|
|
4335
|
+
this.addSchema(optsSchemas[key2], key2);
|
|
4336
4336
|
}
|
|
4337
4337
|
function addInitialFormats() {
|
|
4338
4338
|
for (const name in this.opts.formats) {
|
|
@@ -5380,11 +5380,11 @@ var require_dependencies = __commonJS({
|
|
|
5380
5380
|
function splitDependencies({ schema }) {
|
|
5381
5381
|
const propertyDeps = {};
|
|
5382
5382
|
const schemaDeps = {};
|
|
5383
|
-
for (const
|
|
5384
|
-
if (
|
|
5383
|
+
for (const key2 in schema) {
|
|
5384
|
+
if (key2 === "__proto__")
|
|
5385
5385
|
continue;
|
|
5386
|
-
const deps = Array.isArray(schema[
|
|
5387
|
-
deps[
|
|
5386
|
+
const deps = Array.isArray(schema[key2]) ? propertyDeps : schemaDeps;
|
|
5387
|
+
deps[key2] = schema[key2];
|
|
5388
5388
|
}
|
|
5389
5389
|
return [propertyDeps, schemaDeps];
|
|
5390
5390
|
}
|
|
@@ -5461,13 +5461,13 @@ var require_propertyNames = __commonJS({
|
|
|
5461
5461
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
5462
5462
|
return;
|
|
5463
5463
|
const valid = gen.name("valid");
|
|
5464
|
-
gen.forIn("key", data, (
|
|
5465
|
-
cxt.setParams({ propertyName:
|
|
5464
|
+
gen.forIn("key", data, (key2) => {
|
|
5465
|
+
cxt.setParams({ propertyName: key2 });
|
|
5466
5466
|
cxt.subschema({
|
|
5467
5467
|
keyword: "propertyNames",
|
|
5468
|
-
data:
|
|
5468
|
+
data: key2,
|
|
5469
5469
|
dataTypes: ["string"],
|
|
5470
|
-
propertyName:
|
|
5470
|
+
propertyName: key2,
|
|
5471
5471
|
compositeRule: true
|
|
5472
5472
|
}, valid);
|
|
5473
5473
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
@@ -5516,38 +5516,38 @@ var require_additionalProperties = __commonJS({
|
|
|
5516
5516
|
checkAdditionalProperties();
|
|
5517
5517
|
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
5518
5518
|
function checkAdditionalProperties() {
|
|
5519
|
-
gen.forIn("key", data, (
|
|
5519
|
+
gen.forIn("key", data, (key2) => {
|
|
5520
5520
|
if (!props.length && !patProps.length)
|
|
5521
|
-
additionalPropertyCode(
|
|
5521
|
+
additionalPropertyCode(key2);
|
|
5522
5522
|
else
|
|
5523
|
-
gen.if(isAdditional(
|
|
5523
|
+
gen.if(isAdditional(key2), () => additionalPropertyCode(key2));
|
|
5524
5524
|
});
|
|
5525
5525
|
}
|
|
5526
|
-
function isAdditional(
|
|
5526
|
+
function isAdditional(key2) {
|
|
5527
5527
|
let definedProp;
|
|
5528
5528
|
if (props.length > 8) {
|
|
5529
5529
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
|
5530
|
-
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema,
|
|
5530
|
+
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key2);
|
|
5531
5531
|
} else if (props.length) {
|
|
5532
|
-
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${
|
|
5532
|
+
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key2} === ${p}`));
|
|
5533
5533
|
} else {
|
|
5534
5534
|
definedProp = codegen_1.nil;
|
|
5535
5535
|
}
|
|
5536
5536
|
if (patProps.length) {
|
|
5537
|
-
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${
|
|
5537
|
+
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key2})`));
|
|
5538
5538
|
}
|
|
5539
5539
|
return (0, codegen_1.not)(definedProp);
|
|
5540
5540
|
}
|
|
5541
|
-
function deleteAdditional(
|
|
5542
|
-
gen.code((0, codegen_1._)`delete ${data}[${
|
|
5541
|
+
function deleteAdditional(key2) {
|
|
5542
|
+
gen.code((0, codegen_1._)`delete ${data}[${key2}]`);
|
|
5543
5543
|
}
|
|
5544
|
-
function additionalPropertyCode(
|
|
5544
|
+
function additionalPropertyCode(key2) {
|
|
5545
5545
|
if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
|
|
5546
|
-
deleteAdditional(
|
|
5546
|
+
deleteAdditional(key2);
|
|
5547
5547
|
return;
|
|
5548
5548
|
}
|
|
5549
5549
|
if (schema === false) {
|
|
5550
|
-
cxt.setParams({ additionalProperty:
|
|
5550
|
+
cxt.setParams({ additionalProperty: key2 });
|
|
5551
5551
|
cxt.error();
|
|
5552
5552
|
if (!allErrors)
|
|
5553
5553
|
gen.break();
|
|
@@ -5556,22 +5556,22 @@ var require_additionalProperties = __commonJS({
|
|
|
5556
5556
|
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
|
|
5557
5557
|
const valid = gen.name("valid");
|
|
5558
5558
|
if (opts.removeAdditional === "failing") {
|
|
5559
|
-
applyAdditionalSchema(
|
|
5559
|
+
applyAdditionalSchema(key2, valid, false);
|
|
5560
5560
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
5561
5561
|
cxt.reset();
|
|
5562
|
-
deleteAdditional(
|
|
5562
|
+
deleteAdditional(key2);
|
|
5563
5563
|
});
|
|
5564
5564
|
} else {
|
|
5565
|
-
applyAdditionalSchema(
|
|
5565
|
+
applyAdditionalSchema(key2, valid);
|
|
5566
5566
|
if (!allErrors)
|
|
5567
5567
|
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
5568
5568
|
}
|
|
5569
5569
|
}
|
|
5570
5570
|
}
|
|
5571
|
-
function applyAdditionalSchema(
|
|
5571
|
+
function applyAdditionalSchema(key2, valid, errors) {
|
|
5572
5572
|
const subschema = {
|
|
5573
5573
|
keyword: "additionalProperties",
|
|
5574
|
-
dataProp:
|
|
5574
|
+
dataProp: key2,
|
|
5575
5575
|
dataPropType: util_1.Type.Str
|
|
5576
5576
|
};
|
|
5577
5577
|
if (errors === false) {
|
|
@@ -5696,19 +5696,19 @@ var require_patternProperties = __commonJS({
|
|
|
5696
5696
|
}
|
|
5697
5697
|
}
|
|
5698
5698
|
function validateProperties(pat) {
|
|
5699
|
-
gen.forIn("key", data, (
|
|
5700
|
-
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${
|
|
5699
|
+
gen.forIn("key", data, (key2) => {
|
|
5700
|
+
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key2})`, () => {
|
|
5701
5701
|
const alwaysValid = alwaysValidPatterns.includes(pat);
|
|
5702
5702
|
if (!alwaysValid) {
|
|
5703
5703
|
cxt.subschema({
|
|
5704
5704
|
keyword: "patternProperties",
|
|
5705
5705
|
schemaProp: pat,
|
|
5706
|
-
dataProp:
|
|
5706
|
+
dataProp: key2,
|
|
5707
5707
|
dataPropType: util_2.Type.Str
|
|
5708
5708
|
}, valid);
|
|
5709
5709
|
}
|
|
5710
5710
|
if (it.opts.unevaluated && props !== true) {
|
|
5711
|
-
gen.assign((0, codegen_1._)`${props}[${
|
|
5711
|
+
gen.assign((0, codegen_1._)`${props}[${key2}]`, true);
|
|
5712
5712
|
} else if (!alwaysValid && !it.allErrors) {
|
|
5713
5713
|
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
5714
5714
|
}
|
|
@@ -6965,19 +6965,19 @@ function floatSafeRemainder(val, step) {
|
|
|
6965
6965
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
6966
6966
|
return valInt % stepInt / 10 ** decCount;
|
|
6967
6967
|
}
|
|
6968
|
-
function defineLazy(object3,
|
|
6968
|
+
function defineLazy(object3, key2, getter) {
|
|
6969
6969
|
const set = false;
|
|
6970
|
-
Object.defineProperty(object3,
|
|
6970
|
+
Object.defineProperty(object3, key2, {
|
|
6971
6971
|
get() {
|
|
6972
6972
|
if (!set) {
|
|
6973
6973
|
const value = getter();
|
|
6974
|
-
object3[
|
|
6974
|
+
object3[key2] = value;
|
|
6975
6975
|
return value;
|
|
6976
6976
|
}
|
|
6977
6977
|
throw new Error("cached value already set");
|
|
6978
6978
|
},
|
|
6979
6979
|
set(v) {
|
|
6980
|
-
Object.defineProperty(object3,
|
|
6980
|
+
Object.defineProperty(object3, key2, {
|
|
6981
6981
|
value: v
|
|
6982
6982
|
// configurable: true,
|
|
6983
6983
|
});
|
|
@@ -6996,11 +6996,11 @@ function assignProp(target, prop, value) {
|
|
|
6996
6996
|
function getElementAtPath(obj, path) {
|
|
6997
6997
|
if (!path)
|
|
6998
6998
|
return obj;
|
|
6999
|
-
return path.reduce((acc,
|
|
6999
|
+
return path.reduce((acc, key2) => acc?.[key2], obj);
|
|
7000
7000
|
}
|
|
7001
7001
|
function promiseAllObject(promisesObj) {
|
|
7002
7002
|
const keys = Object.keys(promisesObj);
|
|
7003
|
-
const promises = keys.map((
|
|
7003
|
+
const promises = keys.map((key2) => promisesObj[key2]);
|
|
7004
7004
|
return Promise.all(promises).then((results) => {
|
|
7005
7005
|
const resolvedObj = {};
|
|
7006
7006
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -7053,8 +7053,8 @@ function isPlainObject(o) {
|
|
|
7053
7053
|
}
|
|
7054
7054
|
function numKeys(data) {
|
|
7055
7055
|
let keyCount = 0;
|
|
7056
|
-
for (const
|
|
7057
|
-
if (Object.prototype.hasOwnProperty.call(data,
|
|
7056
|
+
for (const key2 in data) {
|
|
7057
|
+
if (Object.prototype.hasOwnProperty.call(data, key2)) {
|
|
7058
7058
|
keyCount++;
|
|
7059
7059
|
}
|
|
7060
7060
|
}
|
|
@@ -7190,13 +7190,13 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
7190
7190
|
function pick(schema, mask) {
|
|
7191
7191
|
const newShape = {};
|
|
7192
7192
|
const currDef = schema._zod.def;
|
|
7193
|
-
for (const
|
|
7194
|
-
if (!(
|
|
7195
|
-
throw new Error(`Unrecognized key: "${
|
|
7193
|
+
for (const key2 in mask) {
|
|
7194
|
+
if (!(key2 in currDef.shape)) {
|
|
7195
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7196
7196
|
}
|
|
7197
|
-
if (!mask[
|
|
7197
|
+
if (!mask[key2])
|
|
7198
7198
|
continue;
|
|
7199
|
-
newShape[
|
|
7199
|
+
newShape[key2] = currDef.shape[key2];
|
|
7200
7200
|
}
|
|
7201
7201
|
return clone(schema, {
|
|
7202
7202
|
...schema._zod.def,
|
|
@@ -7207,13 +7207,13 @@ function pick(schema, mask) {
|
|
|
7207
7207
|
function omit(schema, mask) {
|
|
7208
7208
|
const newShape = { ...schema._zod.def.shape };
|
|
7209
7209
|
const currDef = schema._zod.def;
|
|
7210
|
-
for (const
|
|
7211
|
-
if (!(
|
|
7212
|
-
throw new Error(`Unrecognized key: "${
|
|
7210
|
+
for (const key2 in mask) {
|
|
7211
|
+
if (!(key2 in currDef.shape)) {
|
|
7212
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7213
7213
|
}
|
|
7214
|
-
if (!mask[
|
|
7214
|
+
if (!mask[key2])
|
|
7215
7215
|
continue;
|
|
7216
|
-
delete newShape[
|
|
7216
|
+
delete newShape[key2];
|
|
7217
7217
|
}
|
|
7218
7218
|
return clone(schema, {
|
|
7219
7219
|
...schema._zod.def,
|
|
@@ -7254,23 +7254,23 @@ function partial(Class2, schema, mask) {
|
|
|
7254
7254
|
const oldShape = schema._zod.def.shape;
|
|
7255
7255
|
const shape = { ...oldShape };
|
|
7256
7256
|
if (mask) {
|
|
7257
|
-
for (const
|
|
7258
|
-
if (!(
|
|
7259
|
-
throw new Error(`Unrecognized key: "${
|
|
7257
|
+
for (const key2 in mask) {
|
|
7258
|
+
if (!(key2 in oldShape)) {
|
|
7259
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7260
7260
|
}
|
|
7261
|
-
if (!mask[
|
|
7261
|
+
if (!mask[key2])
|
|
7262
7262
|
continue;
|
|
7263
|
-
shape[
|
|
7263
|
+
shape[key2] = Class2 ? new Class2({
|
|
7264
7264
|
type: "optional",
|
|
7265
|
-
innerType: oldShape[
|
|
7266
|
-
}) : oldShape[
|
|
7265
|
+
innerType: oldShape[key2]
|
|
7266
|
+
}) : oldShape[key2];
|
|
7267
7267
|
}
|
|
7268
7268
|
} else {
|
|
7269
|
-
for (const
|
|
7270
|
-
shape[
|
|
7269
|
+
for (const key2 in oldShape) {
|
|
7270
|
+
shape[key2] = Class2 ? new Class2({
|
|
7271
7271
|
type: "optional",
|
|
7272
|
-
innerType: oldShape[
|
|
7273
|
-
}) : oldShape[
|
|
7272
|
+
innerType: oldShape[key2]
|
|
7273
|
+
}) : oldShape[key2];
|
|
7274
7274
|
}
|
|
7275
7275
|
}
|
|
7276
7276
|
return clone(schema, {
|
|
@@ -7283,22 +7283,22 @@ function required(Class2, schema, mask) {
|
|
|
7283
7283
|
const oldShape = schema._zod.def.shape;
|
|
7284
7284
|
const shape = { ...oldShape };
|
|
7285
7285
|
if (mask) {
|
|
7286
|
-
for (const
|
|
7287
|
-
if (!(
|
|
7288
|
-
throw new Error(`Unrecognized key: "${
|
|
7286
|
+
for (const key2 in mask) {
|
|
7287
|
+
if (!(key2 in shape)) {
|
|
7288
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7289
7289
|
}
|
|
7290
|
-
if (!mask[
|
|
7290
|
+
if (!mask[key2])
|
|
7291
7291
|
continue;
|
|
7292
|
-
shape[
|
|
7292
|
+
shape[key2] = new Class2({
|
|
7293
7293
|
type: "nonoptional",
|
|
7294
|
-
innerType: oldShape[
|
|
7294
|
+
innerType: oldShape[key2]
|
|
7295
7295
|
});
|
|
7296
7296
|
}
|
|
7297
7297
|
} else {
|
|
7298
|
-
for (const
|
|
7299
|
-
shape[
|
|
7298
|
+
for (const key2 in oldShape) {
|
|
7299
|
+
shape[key2] = new Class2({
|
|
7300
7300
|
type: "nonoptional",
|
|
7301
|
-
innerType: oldShape[
|
|
7301
|
+
innerType: oldShape[key2]
|
|
7302
7302
|
});
|
|
7303
7303
|
}
|
|
7304
7304
|
}
|
|
@@ -8494,28 +8494,28 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
8494
8494
|
return payload;
|
|
8495
8495
|
};
|
|
8496
8496
|
});
|
|
8497
|
-
function handleObjectResult(result, final,
|
|
8497
|
+
function handleObjectResult(result, final, key2) {
|
|
8498
8498
|
if (result.issues.length) {
|
|
8499
|
-
final.issues.push(...prefixIssues(
|
|
8499
|
+
final.issues.push(...prefixIssues(key2, result.issues));
|
|
8500
8500
|
}
|
|
8501
|
-
final.value[
|
|
8501
|
+
final.value[key2] = result.value;
|
|
8502
8502
|
}
|
|
8503
|
-
function handleOptionalObjectResult(result, final,
|
|
8503
|
+
function handleOptionalObjectResult(result, final, key2, input) {
|
|
8504
8504
|
if (result.issues.length) {
|
|
8505
|
-
if (input[
|
|
8506
|
-
if (
|
|
8507
|
-
final.value[
|
|
8505
|
+
if (input[key2] === void 0) {
|
|
8506
|
+
if (key2 in input) {
|
|
8507
|
+
final.value[key2] = void 0;
|
|
8508
8508
|
} else {
|
|
8509
|
-
final.value[
|
|
8509
|
+
final.value[key2] = result.value;
|
|
8510
8510
|
}
|
|
8511
8511
|
} else {
|
|
8512
|
-
final.issues.push(...prefixIssues(
|
|
8512
|
+
final.issues.push(...prefixIssues(key2, result.issues));
|
|
8513
8513
|
}
|
|
8514
8514
|
} else if (result.value === void 0) {
|
|
8515
|
-
if (
|
|
8516
|
-
final.value[
|
|
8515
|
+
if (key2 in input)
|
|
8516
|
+
final.value[key2] = void 0;
|
|
8517
8517
|
} else {
|
|
8518
|
-
final.value[
|
|
8518
|
+
final.value[key2] = result.value;
|
|
8519
8519
|
}
|
|
8520
8520
|
}
|
|
8521
8521
|
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
@@ -8539,12 +8539,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8539
8539
|
defineLazy(inst._zod, "propValues", () => {
|
|
8540
8540
|
const shape = def.shape;
|
|
8541
8541
|
const propValues = {};
|
|
8542
|
-
for (const
|
|
8543
|
-
const field = shape[
|
|
8542
|
+
for (const key2 in shape) {
|
|
8543
|
+
const field = shape[key2]._zod;
|
|
8544
8544
|
if (field.values) {
|
|
8545
|
-
propValues[
|
|
8545
|
+
propValues[key2] ?? (propValues[key2] = /* @__PURE__ */ new Set());
|
|
8546
8546
|
for (const v of field.values)
|
|
8547
|
-
propValues[
|
|
8547
|
+
propValues[key2].add(v);
|
|
8548
8548
|
}
|
|
8549
8549
|
}
|
|
8550
8550
|
return propValues;
|
|
@@ -8552,22 +8552,22 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8552
8552
|
const generateFastpass = (shape) => {
|
|
8553
8553
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
8554
8554
|
const normalized = _normalized.value;
|
|
8555
|
-
const parseStr = (
|
|
8556
|
-
const k = esc(
|
|
8555
|
+
const parseStr = (key2) => {
|
|
8556
|
+
const k = esc(key2);
|
|
8557
8557
|
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
8558
8558
|
};
|
|
8559
8559
|
doc.write(`const input = payload.value;`);
|
|
8560
8560
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
8561
8561
|
let counter = 0;
|
|
8562
|
-
for (const
|
|
8563
|
-
ids[
|
|
8562
|
+
for (const key2 of normalized.keys) {
|
|
8563
|
+
ids[key2] = `key_${counter++}`;
|
|
8564
8564
|
}
|
|
8565
8565
|
doc.write(`const newResult = {}`);
|
|
8566
|
-
for (const
|
|
8567
|
-
if (normalized.optionalKeys.has(
|
|
8568
|
-
const id = ids[
|
|
8569
|
-
doc.write(`const ${id} = ${parseStr(
|
|
8570
|
-
const k = esc(
|
|
8566
|
+
for (const key2 of normalized.keys) {
|
|
8567
|
+
if (normalized.optionalKeys.has(key2)) {
|
|
8568
|
+
const id = ids[key2];
|
|
8569
|
+
doc.write(`const ${id} = ${parseStr(key2)};`);
|
|
8570
|
+
const k = esc(key2);
|
|
8571
8571
|
doc.write(`
|
|
8572
8572
|
if (${id}.issues.length) {
|
|
8573
8573
|
if (input[${k}] === undefined) {
|
|
@@ -8589,14 +8589,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8589
8589
|
}
|
|
8590
8590
|
`);
|
|
8591
8591
|
} else {
|
|
8592
|
-
const id = ids[
|
|
8593
|
-
doc.write(`const ${id} = ${parseStr(
|
|
8592
|
+
const id = ids[key2];
|
|
8593
|
+
doc.write(`const ${id} = ${parseStr(key2)};`);
|
|
8594
8594
|
doc.write(`
|
|
8595
8595
|
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
8596
8596
|
...iss,
|
|
8597
|
-
path: iss.path ? [${esc(
|
|
8597
|
+
path: iss.path ? [${esc(key2)}, ...iss.path] : [${esc(key2)}]
|
|
8598
8598
|
})));`);
|
|
8599
|
-
doc.write(`newResult[${esc(
|
|
8599
|
+
doc.write(`newResult[${esc(key2)}] = ${id}.value`);
|
|
8600
8600
|
}
|
|
8601
8601
|
}
|
|
8602
8602
|
doc.write(`payload.value = newResult;`);
|
|
@@ -8631,16 +8631,16 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8631
8631
|
} else {
|
|
8632
8632
|
payload.value = {};
|
|
8633
8633
|
const shape = value.shape;
|
|
8634
|
-
for (const
|
|
8635
|
-
const el = shape[
|
|
8636
|
-
const r = el._zod.run({ value: input[
|
|
8634
|
+
for (const key2 of value.keys) {
|
|
8635
|
+
const el = shape[key2];
|
|
8636
|
+
const r = el._zod.run({ value: input[key2], issues: [] }, ctx);
|
|
8637
8637
|
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
8638
8638
|
if (r instanceof Promise) {
|
|
8639
|
-
proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload,
|
|
8639
|
+
proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload, key2, input) : handleObjectResult(r2, payload, key2)));
|
|
8640
8640
|
} else if (isOptional) {
|
|
8641
|
-
handleOptionalObjectResult(r, payload,
|
|
8641
|
+
handleOptionalObjectResult(r, payload, key2, input);
|
|
8642
8642
|
} else {
|
|
8643
|
-
handleObjectResult(r, payload,
|
|
8643
|
+
handleObjectResult(r, payload, key2);
|
|
8644
8644
|
}
|
|
8645
8645
|
}
|
|
8646
8646
|
}
|
|
@@ -8651,18 +8651,18 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8651
8651
|
const keySet = value.keySet;
|
|
8652
8652
|
const _catchall = catchall._zod;
|
|
8653
8653
|
const t = _catchall.def.type;
|
|
8654
|
-
for (const
|
|
8655
|
-
if (keySet.has(
|
|
8654
|
+
for (const key2 of Object.keys(input)) {
|
|
8655
|
+
if (keySet.has(key2))
|
|
8656
8656
|
continue;
|
|
8657
8657
|
if (t === "never") {
|
|
8658
|
-
unrecognized.push(
|
|
8658
|
+
unrecognized.push(key2);
|
|
8659
8659
|
continue;
|
|
8660
8660
|
}
|
|
8661
|
-
const r = _catchall.run({ value: input[
|
|
8661
|
+
const r = _catchall.run({ value: input[key2], issues: [] }, ctx);
|
|
8662
8662
|
if (r instanceof Promise) {
|
|
8663
|
-
proms.push(r.then((r2) => handleObjectResult(r2, payload,
|
|
8663
|
+
proms.push(r.then((r2) => handleObjectResult(r2, payload, key2)));
|
|
8664
8664
|
} else {
|
|
8665
|
-
handleObjectResult(r, payload,
|
|
8665
|
+
handleObjectResult(r, payload, key2);
|
|
8666
8666
|
}
|
|
8667
8667
|
}
|
|
8668
8668
|
if (unrecognized.length) {
|
|
@@ -8824,17 +8824,17 @@ function mergeValues(a, b) {
|
|
|
8824
8824
|
}
|
|
8825
8825
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
8826
8826
|
const bKeys = Object.keys(b);
|
|
8827
|
-
const sharedKeys = Object.keys(a).filter((
|
|
8827
|
+
const sharedKeys = Object.keys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
|
|
8828
8828
|
const newObj = { ...a, ...b };
|
|
8829
|
-
for (const
|
|
8830
|
-
const sharedValue = mergeValues(a[
|
|
8829
|
+
for (const key2 of sharedKeys) {
|
|
8830
|
+
const sharedValue = mergeValues(a[key2], b[key2]);
|
|
8831
8831
|
if (!sharedValue.valid) {
|
|
8832
8832
|
return {
|
|
8833
8833
|
valid: false,
|
|
8834
|
-
mergeErrorPath: [
|
|
8834
|
+
mergeErrorPath: [key2, ...sharedValue.mergeErrorPath]
|
|
8835
8835
|
};
|
|
8836
8836
|
}
|
|
8837
|
-
newObj[
|
|
8837
|
+
newObj[key2] = sharedValue.data;
|
|
8838
8838
|
}
|
|
8839
8839
|
return { valid: true, data: newObj };
|
|
8840
8840
|
}
|
|
@@ -8892,29 +8892,29 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8892
8892
|
if (def.keyType._zod.values) {
|
|
8893
8893
|
const values = def.keyType._zod.values;
|
|
8894
8894
|
payload.value = {};
|
|
8895
|
-
for (const
|
|
8896
|
-
if (typeof
|
|
8897
|
-
const result = def.valueType._zod.run({ value: input[
|
|
8895
|
+
for (const key2 of values) {
|
|
8896
|
+
if (typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol") {
|
|
8897
|
+
const result = def.valueType._zod.run({ value: input[key2], issues: [] }, ctx);
|
|
8898
8898
|
if (result instanceof Promise) {
|
|
8899
8899
|
proms.push(result.then((result2) => {
|
|
8900
8900
|
if (result2.issues.length) {
|
|
8901
|
-
payload.issues.push(...prefixIssues(
|
|
8901
|
+
payload.issues.push(...prefixIssues(key2, result2.issues));
|
|
8902
8902
|
}
|
|
8903
|
-
payload.value[
|
|
8903
|
+
payload.value[key2] = result2.value;
|
|
8904
8904
|
}));
|
|
8905
8905
|
} else {
|
|
8906
8906
|
if (result.issues.length) {
|
|
8907
|
-
payload.issues.push(...prefixIssues(
|
|
8907
|
+
payload.issues.push(...prefixIssues(key2, result.issues));
|
|
8908
8908
|
}
|
|
8909
|
-
payload.value[
|
|
8909
|
+
payload.value[key2] = result.value;
|
|
8910
8910
|
}
|
|
8911
8911
|
}
|
|
8912
8912
|
}
|
|
8913
8913
|
let unrecognized;
|
|
8914
|
-
for (const
|
|
8915
|
-
if (!values.has(
|
|
8914
|
+
for (const key2 in input) {
|
|
8915
|
+
if (!values.has(key2)) {
|
|
8916
8916
|
unrecognized = unrecognized ?? [];
|
|
8917
|
-
unrecognized.push(
|
|
8917
|
+
unrecognized.push(key2);
|
|
8918
8918
|
}
|
|
8919
8919
|
}
|
|
8920
8920
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -8927,10 +8927,10 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8927
8927
|
}
|
|
8928
8928
|
} else {
|
|
8929
8929
|
payload.value = {};
|
|
8930
|
-
for (const
|
|
8931
|
-
if (
|
|
8930
|
+
for (const key2 of Reflect.ownKeys(input)) {
|
|
8931
|
+
if (key2 === "__proto__")
|
|
8932
8932
|
continue;
|
|
8933
|
-
const keyResult = def.keyType._zod.run({ value:
|
|
8933
|
+
const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
|
|
8934
8934
|
if (keyResult instanceof Promise) {
|
|
8935
8935
|
throw new Error("Async schemas not supported in object keys currently");
|
|
8936
8936
|
}
|
|
@@ -8939,24 +8939,24 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8939
8939
|
origin: "record",
|
|
8940
8940
|
code: "invalid_key",
|
|
8941
8941
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
8942
|
-
input:
|
|
8943
|
-
path: [
|
|
8942
|
+
input: key2,
|
|
8943
|
+
path: [key2],
|
|
8944
8944
|
inst
|
|
8945
8945
|
});
|
|
8946
8946
|
payload.value[keyResult.value] = keyResult.value;
|
|
8947
8947
|
continue;
|
|
8948
8948
|
}
|
|
8949
|
-
const result = def.valueType._zod.run({ value: input[
|
|
8949
|
+
const result = def.valueType._zod.run({ value: input[key2], issues: [] }, ctx);
|
|
8950
8950
|
if (result instanceof Promise) {
|
|
8951
8951
|
proms.push(result.then((result2) => {
|
|
8952
8952
|
if (result2.issues.length) {
|
|
8953
|
-
payload.issues.push(...prefixIssues(
|
|
8953
|
+
payload.issues.push(...prefixIssues(key2, result2.issues));
|
|
8954
8954
|
}
|
|
8955
8955
|
payload.value[keyResult.value] = result2.value;
|
|
8956
8956
|
}));
|
|
8957
8957
|
} else {
|
|
8958
8958
|
if (result.issues.length) {
|
|
8959
|
-
payload.issues.push(...prefixIssues(
|
|
8959
|
+
payload.issues.push(...prefixIssues(key2, result.issues));
|
|
8960
8960
|
}
|
|
8961
8961
|
payload.value[keyResult.value] = result.value;
|
|
8962
8962
|
}
|
|
@@ -13058,8 +13058,8 @@ function isPlainObject2(value) {
|
|
|
13058
13058
|
}
|
|
13059
13059
|
function mergeCapabilities(base, additional) {
|
|
13060
13060
|
const result = { ...base };
|
|
13061
|
-
for (const
|
|
13062
|
-
const k =
|
|
13061
|
+
for (const key2 in additional) {
|
|
13062
|
+
const k = key2;
|
|
13063
13063
|
const addValue = additional[k];
|
|
13064
13064
|
if (addValue === void 0)
|
|
13065
13065
|
continue;
|
|
@@ -14109,12 +14109,116 @@ async function downloadTelegramFile(fileId, opts) {
|
|
|
14109
14109
|
return savedPath;
|
|
14110
14110
|
}
|
|
14111
14111
|
|
|
14112
|
+
// src/slack-loop-throttle.ts
|
|
14113
|
+
var DEFAULT_THROTTLE = {
|
|
14114
|
+
threshold: 3,
|
|
14115
|
+
windowMs: 12e4,
|
|
14116
|
+
ringSize: 8
|
|
14117
|
+
};
|
|
14118
|
+
function decideReplyThrottle(input) {
|
|
14119
|
+
const cfg = input.config ?? DEFAULT_THROTTLE;
|
|
14120
|
+
const cutoff = input.now - cfg.windowMs;
|
|
14121
|
+
const inWindow = input.recentReplyTimestamps.filter((t) => t >= cutoff);
|
|
14122
|
+
if (inWindow.length >= cfg.threshold) {
|
|
14123
|
+
return {
|
|
14124
|
+
allow: false,
|
|
14125
|
+
recentCount: inWindow.length,
|
|
14126
|
+
reason: "throttle_threshold_exceeded"
|
|
14127
|
+
};
|
|
14128
|
+
}
|
|
14129
|
+
return {
|
|
14130
|
+
allow: true,
|
|
14131
|
+
recentCount: inWindow.length,
|
|
14132
|
+
reason: "under_threshold"
|
|
14133
|
+
};
|
|
14134
|
+
}
|
|
14135
|
+
var buffers = /* @__PURE__ */ new Map();
|
|
14136
|
+
function key(channelId, threadKey) {
|
|
14137
|
+
return `${channelId}${threadKey}`;
|
|
14138
|
+
}
|
|
14139
|
+
function recordReply(channelId, threadKey, now, config2 = DEFAULT_THROTTLE) {
|
|
14140
|
+
const k = key(channelId, threadKey);
|
|
14141
|
+
const cutoff = now - config2.windowMs;
|
|
14142
|
+
const cur = buffers.get(k) ?? [];
|
|
14143
|
+
cur.push(now);
|
|
14144
|
+
let pruned = cur.filter((t) => t >= cutoff);
|
|
14145
|
+
if (pruned.length > config2.ringSize) {
|
|
14146
|
+
pruned = pruned.slice(pruned.length - config2.ringSize);
|
|
14147
|
+
}
|
|
14148
|
+
buffers.set(k, pruned);
|
|
14149
|
+
}
|
|
14150
|
+
function getRecentReplies(channelId, threadKey, now, config2 = DEFAULT_THROTTLE) {
|
|
14151
|
+
const k = key(channelId, threadKey);
|
|
14152
|
+
const cutoff = now - config2.windowMs;
|
|
14153
|
+
const cur = buffers.get(k) ?? [];
|
|
14154
|
+
return cur.filter((t) => t >= cutoff);
|
|
14155
|
+
}
|
|
14156
|
+
function resetThread(channelId, threadKey) {
|
|
14157
|
+
buffers.delete(key(channelId, threadKey));
|
|
14158
|
+
}
|
|
14159
|
+
function configFromEnv(env = process.env) {
|
|
14160
|
+
const count = Number(env.SLACK_AGENT_REPLY_THROTTLE_COUNT);
|
|
14161
|
+
const windowMs = Number(env.SLACK_AGENT_REPLY_THROTTLE_WINDOW_MS);
|
|
14162
|
+
return {
|
|
14163
|
+
threshold: Number.isFinite(count) && count > 0 ? count : DEFAULT_THROTTLE.threshold,
|
|
14164
|
+
windowMs: Number.isFinite(windowMs) && windowMs > 0 ? windowMs : DEFAULT_THROTTLE.windowMs,
|
|
14165
|
+
ringSize: DEFAULT_THROTTLE.ringSize
|
|
14166
|
+
};
|
|
14167
|
+
}
|
|
14168
|
+
|
|
14169
|
+
// src/channel-kill-check.ts
|
|
14170
|
+
var CACHE_TTL_MS = 6e4;
|
|
14171
|
+
var cache = /* @__PURE__ */ new Map();
|
|
14172
|
+
function cacheKey(channelType, channelId, threadTs) {
|
|
14173
|
+
return `${channelType}|${channelId}|${threadTs}`;
|
|
14174
|
+
}
|
|
14175
|
+
async function isThreadKilled(opts) {
|
|
14176
|
+
const threadTs = opts.threadTs ?? "";
|
|
14177
|
+
const key2 = cacheKey(opts.channelType, opts.channelId, threadTs);
|
|
14178
|
+
const now = opts.now ? opts.now() : Date.now();
|
|
14179
|
+
const cached2 = cache.get(key2);
|
|
14180
|
+
if (cached2 && cached2.expiresAt > now) {
|
|
14181
|
+
return cached2.killed;
|
|
14182
|
+
}
|
|
14183
|
+
if (!opts.agtHost || !opts.agtApiKey) {
|
|
14184
|
+
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14185
|
+
return false;
|
|
14186
|
+
}
|
|
14187
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
14188
|
+
try {
|
|
14189
|
+
const url = new URL("/host/channels/kill-check", opts.agtHost);
|
|
14190
|
+
url.searchParams.set("channel_type", opts.channelType);
|
|
14191
|
+
url.searchParams.set("channel_id", opts.channelId);
|
|
14192
|
+
if (threadTs) url.searchParams.set("thread_ts", threadTs);
|
|
14193
|
+
const res = await fetchImpl(url.toString(), {
|
|
14194
|
+
method: "GET",
|
|
14195
|
+
headers: { Authorization: `Bearer ${opts.agtApiKey}` },
|
|
14196
|
+
// 5s ceiling — kill check is hot-path. If the API is slow,
|
|
14197
|
+
// fail-open and try again next cache window.
|
|
14198
|
+
signal: AbortSignal.timeout(5e3)
|
|
14199
|
+
});
|
|
14200
|
+
if (!res.ok) {
|
|
14201
|
+
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14202
|
+
return false;
|
|
14203
|
+
}
|
|
14204
|
+
const body = await res.json();
|
|
14205
|
+
const killed = !!body.killed;
|
|
14206
|
+
cache.set(key2, { killed, expiresAt: now + CACHE_TTL_MS });
|
|
14207
|
+
return killed;
|
|
14208
|
+
} catch {
|
|
14209
|
+
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14210
|
+
return false;
|
|
14211
|
+
}
|
|
14212
|
+
}
|
|
14213
|
+
|
|
14112
14214
|
// src/telegram-channel.ts
|
|
14113
14215
|
function redactId(id) {
|
|
14114
14216
|
return createHash("sha256").update(String(id)).digest("hex").slice(0, 8);
|
|
14115
14217
|
}
|
|
14116
14218
|
var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
|
|
14117
14219
|
var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
|
|
14220
|
+
var AGT_HOST = process.env.AGT_HOST ?? null;
|
|
14221
|
+
var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
|
|
14118
14222
|
var ALLOWED_CHATS = new Set(
|
|
14119
14223
|
(process.env.TELEGRAM_ALLOWED_CHATS ?? "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
14120
14224
|
);
|
|
@@ -14212,6 +14316,40 @@ async function setMessageReaction(chatId, messageId, emoji2) {
|
|
|
14212
14316
|
}
|
|
14213
14317
|
}
|
|
14214
14318
|
var RESTART_FLAGS_DIR = join2(homedir2(), ".augmented", "restart-flags");
|
|
14319
|
+
function buildTelegramHelpMessage(codeName) {
|
|
14320
|
+
return [
|
|
14321
|
+
`\u{1F916} *Available commands for \`${codeName}\`*`,
|
|
14322
|
+
"",
|
|
14323
|
+
`_Type these in any chat where the bot is present (intercepted by the agent):_`,
|
|
14324
|
+
`\u2022 /help \u2014 show this help`,
|
|
14325
|
+
`\u2022 /restart \u2014 restart this agent`
|
|
14326
|
+
].join("\n");
|
|
14327
|
+
}
|
|
14328
|
+
async function handleHelpCommand(opts) {
|
|
14329
|
+
try {
|
|
14330
|
+
const resp = await telegramApiCall(
|
|
14331
|
+
"sendMessage",
|
|
14332
|
+
{
|
|
14333
|
+
chat_id: opts.chatId,
|
|
14334
|
+
text: buildTelegramHelpMessage(AGENT_CODE_NAME),
|
|
14335
|
+
parse_mode: "Markdown",
|
|
14336
|
+
reply_to_message_id: Number(opts.messageId)
|
|
14337
|
+
},
|
|
14338
|
+
1e4
|
|
14339
|
+
);
|
|
14340
|
+
if (!resp.ok) {
|
|
14341
|
+
process.stderr.write(
|
|
14342
|
+
`telegram-channel(${AGENT_CODE_NAME}): /help reply rejected by Telegram (chat ${redactId(opts.chatId)}): ${resp.description ?? "unknown"}
|
|
14343
|
+
`
|
|
14344
|
+
);
|
|
14345
|
+
}
|
|
14346
|
+
} catch (err) {
|
|
14347
|
+
process.stderr.write(
|
|
14348
|
+
`telegram-channel(${AGENT_CODE_NAME}): /help reply send failed: ${redactAugmentedPaths(err.message)}
|
|
14349
|
+
`
|
|
14350
|
+
);
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14215
14353
|
async function handleRestartCommand(opts) {
|
|
14216
14354
|
try {
|
|
14217
14355
|
if (!existsSync(RESTART_FLAGS_DIR)) {
|
|
@@ -14301,6 +14439,10 @@ async function resolveBotUsername() {
|
|
|
14301
14439
|
return null;
|
|
14302
14440
|
}
|
|
14303
14441
|
var RESTART_SYNTAX_RE = /^\/restart(?:@([A-Za-z0-9_]{1,64}))?(?:\s|$)/;
|
|
14442
|
+
var HELP_SYNTAX_RE = /^\/help(?:@([A-Za-z0-9_]{1,64}))?(?:\s|$)/;
|
|
14443
|
+
function isHelpSyntax(text) {
|
|
14444
|
+
return HELP_SYNTAX_RE.test(text);
|
|
14445
|
+
}
|
|
14304
14446
|
function isRestartSyntax(text) {
|
|
14305
14447
|
return RESTART_SYNTAX_RE.test(text);
|
|
14306
14448
|
}
|
|
@@ -14519,11 +14661,11 @@ function startRecoveryOutboxWatcher() {
|
|
|
14519
14661
|
}
|
|
14520
14662
|
startRecoveryOutboxWatcher();
|
|
14521
14663
|
function trackPendingMessage(chatId, messageId, chatType) {
|
|
14522
|
-
const
|
|
14523
|
-
const existing = pendingMessages.get(
|
|
14664
|
+
const key2 = `${chatId}:${messageId}`;
|
|
14665
|
+
const existing = pendingMessages.get(key2);
|
|
14524
14666
|
if (existing) clearTimeout(existing.timer);
|
|
14525
14667
|
const timer = setTimeout(() => {
|
|
14526
|
-
pendingMessages.delete(
|
|
14668
|
+
pendingMessages.delete(key2);
|
|
14527
14669
|
clearPendingInboundMarker(chatId, messageId);
|
|
14528
14670
|
void setMessageReaction(chatId, messageId, null);
|
|
14529
14671
|
void telegramApiCall(
|
|
@@ -14554,38 +14696,38 @@ function trackPendingMessage(chatId, messageId, chatType) {
|
|
|
14554
14696
|
);
|
|
14555
14697
|
}, RESPONSE_TIMEOUT_MS);
|
|
14556
14698
|
timer.unref?.();
|
|
14557
|
-
pendingMessages.set(
|
|
14699
|
+
pendingMessages.set(key2, { timer, chatType });
|
|
14558
14700
|
writePendingInboundMarker(chatId, messageId, chatType);
|
|
14559
14701
|
}
|
|
14560
14702
|
function clearPendingMessage(chatId, messageId) {
|
|
14561
14703
|
if (messageId) {
|
|
14562
|
-
const
|
|
14563
|
-
const entry = pendingMessages.get(
|
|
14704
|
+
const key2 = `${chatId}:${messageId}`;
|
|
14705
|
+
const entry = pendingMessages.get(key2);
|
|
14564
14706
|
if (entry) {
|
|
14565
14707
|
clearTimeout(entry.timer);
|
|
14566
|
-
pendingMessages.delete(
|
|
14708
|
+
pendingMessages.delete(key2);
|
|
14567
14709
|
clearPendingInboundMarker(chatId, messageId);
|
|
14568
14710
|
}
|
|
14569
14711
|
return;
|
|
14570
14712
|
}
|
|
14571
14713
|
const prefix = `${chatId}:`;
|
|
14572
14714
|
let clearedPrivate = false;
|
|
14573
|
-
for (const [
|
|
14574
|
-
if (!
|
|
14715
|
+
for (const [key2, entry] of pendingMessages) {
|
|
14716
|
+
if (!key2.startsWith(prefix)) continue;
|
|
14575
14717
|
if (entry.chatType !== "private") continue;
|
|
14576
14718
|
clearTimeout(entry.timer);
|
|
14577
|
-
pendingMessages.delete(
|
|
14578
|
-
const msgId =
|
|
14719
|
+
pendingMessages.delete(key2);
|
|
14720
|
+
const msgId = key2.slice(prefix.length);
|
|
14579
14721
|
clearPendingInboundMarker(chatId, msgId);
|
|
14580
14722
|
clearedPrivate = true;
|
|
14581
14723
|
}
|
|
14582
14724
|
if (clearedPrivate) return;
|
|
14583
|
-
for (const [
|
|
14584
|
-
if (!
|
|
14725
|
+
for (const [key2, entry] of pendingMessages) {
|
|
14726
|
+
if (!key2.startsWith(prefix)) continue;
|
|
14585
14727
|
if (entry.chatType === "private") continue;
|
|
14586
14728
|
clearTimeout(entry.timer);
|
|
14587
|
-
pendingMessages.delete(
|
|
14588
|
-
const msgId =
|
|
14729
|
+
pendingMessages.delete(key2);
|
|
14730
|
+
const msgId = key2.slice(prefix.length);
|
|
14589
14731
|
clearPendingInboundMarker(chatId, msgId);
|
|
14590
14732
|
return;
|
|
14591
14733
|
}
|
|
@@ -14700,6 +14842,50 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
14700
14842
|
isError: true
|
|
14701
14843
|
};
|
|
14702
14844
|
}
|
|
14845
|
+
const killed = await isThreadKilled({
|
|
14846
|
+
channelType: "telegram",
|
|
14847
|
+
channelId: chat_id,
|
|
14848
|
+
threadTs: "",
|
|
14849
|
+
agtHost: AGT_HOST,
|
|
14850
|
+
agtApiKey: AGT_API_KEY
|
|
14851
|
+
});
|
|
14852
|
+
if (killed) {
|
|
14853
|
+
process.stderr.write(
|
|
14854
|
+
`telegram-channel(${AGENT_CODE_NAME}): reply_killed chat=${redactId(chat_id)}
|
|
14855
|
+
`
|
|
14856
|
+
);
|
|
14857
|
+
return {
|
|
14858
|
+
content: [
|
|
14859
|
+
{
|
|
14860
|
+
type: "text",
|
|
14861
|
+
text: "This chat has been silenced by /kill. Stop attempting to reply \u2014 the human will /unkill when they want agents back."
|
|
14862
|
+
}
|
|
14863
|
+
],
|
|
14864
|
+
isError: true
|
|
14865
|
+
};
|
|
14866
|
+
}
|
|
14867
|
+
const tgThrottleCfg = configFromEnv();
|
|
14868
|
+
const tgThrottleNow = Date.now();
|
|
14869
|
+
const tgThrottleDecision = decideReplyThrottle({
|
|
14870
|
+
recentReplyTimestamps: getRecentReplies(chat_id, "", tgThrottleNow, tgThrottleCfg),
|
|
14871
|
+
now: tgThrottleNow,
|
|
14872
|
+
config: tgThrottleCfg
|
|
14873
|
+
});
|
|
14874
|
+
if (!tgThrottleDecision.allow) {
|
|
14875
|
+
process.stderr.write(
|
|
14876
|
+
`telegram-channel(${AGENT_CODE_NAME}): reply_throttled chat=${redactId(chat_id)} count=${tgThrottleDecision.recentCount} window_ms=${tgThrottleCfg.windowMs} threshold=${tgThrottleCfg.threshold}
|
|
14877
|
+
`
|
|
14878
|
+
);
|
|
14879
|
+
return {
|
|
14880
|
+
content: [
|
|
14881
|
+
{
|
|
14882
|
+
type: "text",
|
|
14883
|
+
text: `Reply throttled: ${tgThrottleDecision.recentCount} replies from this agent to this chat within the last ${Math.round(tgThrottleCfg.windowMs / 1e3)}s (threshold ${tgThrottleCfg.threshold}). The chat is paused for this agent until a human posts in it. Stop attempting to reply.`
|
|
14884
|
+
}
|
|
14885
|
+
],
|
|
14886
|
+
isError: true
|
|
14887
|
+
};
|
|
14888
|
+
}
|
|
14703
14889
|
try {
|
|
14704
14890
|
const body = { chat_id, text };
|
|
14705
14891
|
if (reply_to_message_id) body.reply_to_message_id = Number(reply_to_message_id);
|
|
@@ -14710,6 +14896,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
14710
14896
|
isError: true
|
|
14711
14897
|
};
|
|
14712
14898
|
}
|
|
14899
|
+
recordReply(chat_id, "", tgThrottleNow, tgThrottleCfg);
|
|
14713
14900
|
if (name === "telegram.reply") {
|
|
14714
14901
|
clearPendingMessage(chat_id, reply_to_message_id);
|
|
14715
14902
|
}
|
|
@@ -14921,6 +15108,16 @@ async function pollLoop() {
|
|
|
14921
15108
|
const chatId = String(msg.chat.id);
|
|
14922
15109
|
if (ALLOWED_CHATS.size > 0 && !ALLOWED_CHATS.has(chatId)) continue;
|
|
14923
15110
|
const trimmedContent = content.trim();
|
|
15111
|
+
if (isHelpSyntax(trimmedContent)) {
|
|
15112
|
+
const disposition = await classifyRestartCommand(trimmedContent.replace(/^\/help/, "/restart"));
|
|
15113
|
+
if (disposition === "act") {
|
|
15114
|
+
await handleHelpCommand({
|
|
15115
|
+
chatId,
|
|
15116
|
+
messageId: String(msg.message_id)
|
|
15117
|
+
});
|
|
15118
|
+
}
|
|
15119
|
+
continue;
|
|
15120
|
+
}
|
|
14924
15121
|
if (isRestartSyntax(trimmedContent)) {
|
|
14925
15122
|
const disposition = await classifyRestartCommand(trimmedContent);
|
|
14926
15123
|
if (disposition === "act") {
|
|
@@ -14950,6 +15147,10 @@ async function pollLoop() {
|
|
|
14950
15147
|
}
|
|
14951
15148
|
const userId = msg.from?.id != null ? String(msg.from.id) : "unknown";
|
|
14952
15149
|
const userName = msg.from?.username || [msg.from?.first_name, msg.from?.last_name].filter(Boolean).join(" ").trim() || userId;
|
|
15150
|
+
const isFromBot = !!msg.from?.is_bot;
|
|
15151
|
+
if (chatId && !isFromBot) {
|
|
15152
|
+
resetThread(chatId, "");
|
|
15153
|
+
}
|
|
14953
15154
|
const messageId = String(msg.message_id);
|
|
14954
15155
|
void setMessageReaction(chatId, messageId, ACK_EMOJI);
|
|
14955
15156
|
trackPendingMessage(chatId, messageId, msg.chat.type);
|