@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/slack-channel.js
CHANGED
|
@@ -17,9 +17,9 @@ var __export = (target, all) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __copyProps = (to, from, except, desc) => {
|
|
19
19
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let
|
|
21
|
-
if (!__hasOwnProp.call(to,
|
|
22
|
-
__defProp(to,
|
|
20
|
+
for (let key2 of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
22
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
23
23
|
}
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
@@ -168,15 +168,15 @@ var require_code = __commonJS({
|
|
|
168
168
|
return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
169
169
|
}
|
|
170
170
|
exports.safeStringify = safeStringify;
|
|
171
|
-
function getProperty(
|
|
172
|
-
return typeof
|
|
171
|
+
function getProperty(key2) {
|
|
172
|
+
return typeof key2 == "string" && exports.IDENTIFIER.test(key2) ? new _Code(`.${key2}`) : _`[${key2}]`;
|
|
173
173
|
}
|
|
174
174
|
exports.getProperty = getProperty;
|
|
175
|
-
function getEsmExportName(
|
|
176
|
-
if (typeof
|
|
177
|
-
return new _Code(`${
|
|
175
|
+
function getEsmExportName(key2) {
|
|
176
|
+
if (typeof key2 == "string" && exports.IDENTIFIER.test(key2)) {
|
|
177
|
+
return new _Code(`${key2}`);
|
|
178
178
|
}
|
|
179
|
-
throw new Error(`CodeGen: invalid export name: ${
|
|
179
|
+
throw new Error(`CodeGen: invalid export name: ${key2}, use explicit $id name mapping`);
|
|
180
180
|
}
|
|
181
181
|
exports.getEsmExportName = getEsmExportName;
|
|
182
182
|
function regexpCode(rx) {
|
|
@@ -803,11 +803,11 @@ var require_codegen = __commonJS({
|
|
|
803
803
|
// returns code for object literal for the passed argument list of key-value pairs
|
|
804
804
|
object(...keyValues) {
|
|
805
805
|
const code = ["{"];
|
|
806
|
-
for (const [
|
|
806
|
+
for (const [key2, value] of keyValues) {
|
|
807
807
|
if (code.length > 1)
|
|
808
808
|
code.push(",");
|
|
809
|
-
code.push(
|
|
810
|
-
if (
|
|
809
|
+
code.push(key2);
|
|
810
|
+
if (key2 !== value || this.opts.es5) {
|
|
811
811
|
code.push(":");
|
|
812
812
|
(0, code_1.addCodeArg)(code, value);
|
|
813
813
|
}
|
|
@@ -1082,17 +1082,17 @@ var require_util = __commonJS({
|
|
|
1082
1082
|
if (typeof schema === "boolean")
|
|
1083
1083
|
return;
|
|
1084
1084
|
const rules = self.RULES.keywords;
|
|
1085
|
-
for (const
|
|
1086
|
-
if (!rules[
|
|
1087
|
-
checkStrictMode(it, `unknown keyword: "${
|
|
1085
|
+
for (const key2 in schema) {
|
|
1086
|
+
if (!rules[key2])
|
|
1087
|
+
checkStrictMode(it, `unknown keyword: "${key2}"`);
|
|
1088
1088
|
}
|
|
1089
1089
|
}
|
|
1090
1090
|
exports.checkUnknownRules = checkUnknownRules;
|
|
1091
1091
|
function schemaHasRules(schema, rules) {
|
|
1092
1092
|
if (typeof schema == "boolean")
|
|
1093
1093
|
return !schema;
|
|
1094
|
-
for (const
|
|
1095
|
-
if (rules[
|
|
1094
|
+
for (const key2 in schema)
|
|
1095
|
+
if (rules[key2])
|
|
1096
1096
|
return true;
|
|
1097
1097
|
return false;
|
|
1098
1098
|
}
|
|
@@ -1100,8 +1100,8 @@ var require_util = __commonJS({
|
|
|
1100
1100
|
function schemaHasRulesButRef(schema, RULES) {
|
|
1101
1101
|
if (typeof schema == "boolean")
|
|
1102
1102
|
return !schema;
|
|
1103
|
-
for (const
|
|
1104
|
-
if (
|
|
1103
|
+
for (const key2 in schema)
|
|
1104
|
+
if (key2 !== "$ref" && RULES.all[key2])
|
|
1105
1105
|
return true;
|
|
1106
1106
|
return false;
|
|
1107
1107
|
}
|
|
@@ -1679,8 +1679,8 @@ var require_defaults = __commonJS({
|
|
|
1679
1679
|
function assignDefaults(it, ty) {
|
|
1680
1680
|
const { properties, items } = it.schema;
|
|
1681
1681
|
if (ty === "object" && properties) {
|
|
1682
|
-
for (const
|
|
1683
|
-
assignDefault(it,
|
|
1682
|
+
for (const key2 in properties) {
|
|
1683
|
+
assignDefault(it, key2, properties[key2].default);
|
|
1684
1684
|
}
|
|
1685
1685
|
} else if (ty === "array" && Array.isArray(items)) {
|
|
1686
1686
|
items.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
@@ -2064,8 +2064,8 @@ var require_fast_deep_equal = __commonJS({
|
|
|
2064
2064
|
for (i = length; i-- !== 0; )
|
|
2065
2065
|
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
2066
2066
|
for (i = length; i-- !== 0; ) {
|
|
2067
|
-
var
|
|
2068
|
-
if (!equal(a[
|
|
2067
|
+
var key2 = keys[i];
|
|
2068
|
+
if (!equal(a[key2], b[key2])) return false;
|
|
2069
2069
|
}
|
|
2070
2070
|
return true;
|
|
2071
2071
|
}
|
|
@@ -2137,20 +2137,20 @@ var require_json_schema_traverse = __commonJS({
|
|
|
2137
2137
|
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
2138
2138
|
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
2139
2139
|
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
2140
|
-
for (var
|
|
2141
|
-
var sch = schema[
|
|
2140
|
+
for (var key2 in schema) {
|
|
2141
|
+
var sch = schema[key2];
|
|
2142
2142
|
if (Array.isArray(sch)) {
|
|
2143
|
-
if (
|
|
2143
|
+
if (key2 in traverse.arrayKeywords) {
|
|
2144
2144
|
for (var i = 0; i < sch.length; i++)
|
|
2145
|
-
_traverse(opts, pre, post, sch[i], jsonPtr + "/" +
|
|
2145
|
+
_traverse(opts, pre, post, sch[i], jsonPtr + "/" + key2 + "/" + i, rootSchema, jsonPtr, key2, schema, i);
|
|
2146
2146
|
}
|
|
2147
|
-
} else if (
|
|
2147
|
+
} else if (key2 in traverse.propsKeywords) {
|
|
2148
2148
|
if (sch && typeof sch == "object") {
|
|
2149
2149
|
for (var prop in sch)
|
|
2150
|
-
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" +
|
|
2150
|
+
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key2 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key2, schema, prop);
|
|
2151
2151
|
}
|
|
2152
|
-
} else if (
|
|
2153
|
-
_traverse(opts, pre, post, sch, jsonPtr + "/" +
|
|
2152
|
+
} else if (key2 in traverse.keywords || opts.allKeys && !(key2 in traverse.skipKeywords)) {
|
|
2153
|
+
_traverse(opts, pre, post, sch, jsonPtr + "/" + key2, rootSchema, jsonPtr, key2, schema);
|
|
2154
2154
|
}
|
|
2155
2155
|
}
|
|
2156
2156
|
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
@@ -2207,10 +2207,10 @@ var require_resolve = __commonJS({
|
|
|
2207
2207
|
"$dynamicAnchor"
|
|
2208
2208
|
]);
|
|
2209
2209
|
function hasRef(schema) {
|
|
2210
|
-
for (const
|
|
2211
|
-
if (REF_KEYWORDS.has(
|
|
2210
|
+
for (const key2 in schema) {
|
|
2211
|
+
if (REF_KEYWORDS.has(key2))
|
|
2212
2212
|
return true;
|
|
2213
|
-
const sch = schema[
|
|
2213
|
+
const sch = schema[key2];
|
|
2214
2214
|
if (Array.isArray(sch) && sch.some(hasRef))
|
|
2215
2215
|
return true;
|
|
2216
2216
|
if (typeof sch == "object" && hasRef(sch))
|
|
@@ -2220,14 +2220,14 @@ var require_resolve = __commonJS({
|
|
|
2220
2220
|
}
|
|
2221
2221
|
function countKeys(schema) {
|
|
2222
2222
|
let count = 0;
|
|
2223
|
-
for (const
|
|
2224
|
-
if (
|
|
2223
|
+
for (const key2 in schema) {
|
|
2224
|
+
if (key2 === "$ref")
|
|
2225
2225
|
return Infinity;
|
|
2226
2226
|
count++;
|
|
2227
|
-
if (SIMPLE_INLINED.has(
|
|
2227
|
+
if (SIMPLE_INLINED.has(key2))
|
|
2228
2228
|
continue;
|
|
2229
|
-
if (typeof schema[
|
|
2230
|
-
(0, util_1.eachItem)(schema[
|
|
2229
|
+
if (typeof schema[key2] == "object") {
|
|
2230
|
+
(0, util_1.eachItem)(schema[key2], (sch) => count += countKeys(sch));
|
|
2231
2231
|
}
|
|
2232
2232
|
if (count === Infinity)
|
|
2233
2233
|
return Infinity;
|
|
@@ -2416,8 +2416,8 @@ var require_validate = __commonJS({
|
|
|
2416
2416
|
function schemaCxtHasRules({ schema, self }) {
|
|
2417
2417
|
if (typeof schema == "boolean")
|
|
2418
2418
|
return !schema;
|
|
2419
|
-
for (const
|
|
2420
|
-
if (self.RULES.all[
|
|
2419
|
+
for (const key2 in schema)
|
|
2420
|
+
if (self.RULES.all[key2])
|
|
2421
2421
|
return true;
|
|
2422
2422
|
return false;
|
|
2423
2423
|
}
|
|
@@ -4059,7 +4059,7 @@ var require_core = __commonJS({
|
|
|
4059
4059
|
}
|
|
4060
4060
|
}
|
|
4061
4061
|
// Adds schema to the instance
|
|
4062
|
-
addSchema(schema,
|
|
4062
|
+
addSchema(schema, key2, _meta, _validateSchema = this.opts.validateSchema) {
|
|
4063
4063
|
if (Array.isArray(schema)) {
|
|
4064
4064
|
for (const sch of schema)
|
|
4065
4065
|
this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
@@ -4073,15 +4073,15 @@ var require_core = __commonJS({
|
|
|
4073
4073
|
throw new Error(`schema ${schemaId} must be string`);
|
|
4074
4074
|
}
|
|
4075
4075
|
}
|
|
4076
|
-
|
|
4077
|
-
this._checkUnique(
|
|
4078
|
-
this.schemas[
|
|
4076
|
+
key2 = (0, resolve_1.normalizeId)(key2 || id);
|
|
4077
|
+
this._checkUnique(key2);
|
|
4078
|
+
this.schemas[key2] = this._addSchema(schema, _meta, key2, _validateSchema, true);
|
|
4079
4079
|
return this;
|
|
4080
4080
|
}
|
|
4081
4081
|
// Add schema that will be used to validate other schemas
|
|
4082
4082
|
// options in META_IGNORE_OPTIONS are alway set to false
|
|
4083
|
-
addMetaSchema(schema,
|
|
4084
|
-
this.addSchema(schema,
|
|
4083
|
+
addMetaSchema(schema, key2, _validateSchema = this.opts.validateSchema) {
|
|
4084
|
+
this.addSchema(schema, key2, true, _validateSchema);
|
|
4085
4085
|
return this;
|
|
4086
4086
|
}
|
|
4087
4087
|
// Validate schema against its meta-schema
|
|
@@ -4150,8 +4150,8 @@ var require_core = __commonJS({
|
|
|
4150
4150
|
return this;
|
|
4151
4151
|
}
|
|
4152
4152
|
case "object": {
|
|
4153
|
-
const
|
|
4154
|
-
this._cache.delete(
|
|
4153
|
+
const cacheKey2 = schemaKeyRef;
|
|
4154
|
+
this._cache.delete(cacheKey2);
|
|
4155
4155
|
let id = schemaKeyRef[this.opts.schemaId];
|
|
4156
4156
|
if (id) {
|
|
4157
4157
|
id = (0, resolve_1.normalizeId)(id);
|
|
@@ -4237,14 +4237,14 @@ var require_core = __commonJS({
|
|
|
4237
4237
|
let keywords = metaSchema;
|
|
4238
4238
|
for (const seg of segments)
|
|
4239
4239
|
keywords = keywords[seg];
|
|
4240
|
-
for (const
|
|
4241
|
-
const rule = rules[
|
|
4240
|
+
for (const key2 in rules) {
|
|
4241
|
+
const rule = rules[key2];
|
|
4242
4242
|
if (typeof rule != "object")
|
|
4243
4243
|
continue;
|
|
4244
4244
|
const { $data } = rule.definition;
|
|
4245
|
-
const schema = keywords[
|
|
4245
|
+
const schema = keywords[key2];
|
|
4246
4246
|
if ($data && schema)
|
|
4247
|
-
keywords[
|
|
4247
|
+
keywords[key2] = schemaOrData(schema);
|
|
4248
4248
|
}
|
|
4249
4249
|
}
|
|
4250
4250
|
return metaSchema;
|
|
@@ -4317,10 +4317,10 @@ var require_core = __commonJS({
|
|
|
4317
4317
|
Ajv2.MissingRefError = ref_error_1.default;
|
|
4318
4318
|
exports.default = Ajv2;
|
|
4319
4319
|
function checkOptions(checkOpts, options, msg, log = "error") {
|
|
4320
|
-
for (const
|
|
4321
|
-
const opt =
|
|
4320
|
+
for (const key2 in checkOpts) {
|
|
4321
|
+
const opt = key2;
|
|
4322
4322
|
if (opt in options)
|
|
4323
|
-
this.logger[log](`${msg}: option ${
|
|
4323
|
+
this.logger[log](`${msg}: option ${key2}. ${checkOpts[opt]}`);
|
|
4324
4324
|
}
|
|
4325
4325
|
}
|
|
4326
4326
|
function getSchEnv(keyRef) {
|
|
@@ -4334,8 +4334,8 @@ var require_core = __commonJS({
|
|
|
4334
4334
|
if (Array.isArray(optsSchemas))
|
|
4335
4335
|
this.addSchema(optsSchemas);
|
|
4336
4336
|
else
|
|
4337
|
-
for (const
|
|
4338
|
-
this.addSchema(optsSchemas[
|
|
4337
|
+
for (const key2 in optsSchemas)
|
|
4338
|
+
this.addSchema(optsSchemas[key2], key2);
|
|
4339
4339
|
}
|
|
4340
4340
|
function addInitialFormats() {
|
|
4341
4341
|
for (const name in this.opts.formats) {
|
|
@@ -5383,11 +5383,11 @@ var require_dependencies = __commonJS({
|
|
|
5383
5383
|
function splitDependencies({ schema }) {
|
|
5384
5384
|
const propertyDeps = {};
|
|
5385
5385
|
const schemaDeps = {};
|
|
5386
|
-
for (const
|
|
5387
|
-
if (
|
|
5386
|
+
for (const key2 in schema) {
|
|
5387
|
+
if (key2 === "__proto__")
|
|
5388
5388
|
continue;
|
|
5389
|
-
const deps = Array.isArray(schema[
|
|
5390
|
-
deps[
|
|
5389
|
+
const deps = Array.isArray(schema[key2]) ? propertyDeps : schemaDeps;
|
|
5390
|
+
deps[key2] = schema[key2];
|
|
5391
5391
|
}
|
|
5392
5392
|
return [propertyDeps, schemaDeps];
|
|
5393
5393
|
}
|
|
@@ -5464,13 +5464,13 @@ var require_propertyNames = __commonJS({
|
|
|
5464
5464
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
5465
5465
|
return;
|
|
5466
5466
|
const valid = gen.name("valid");
|
|
5467
|
-
gen.forIn("key", data, (
|
|
5468
|
-
cxt.setParams({ propertyName:
|
|
5467
|
+
gen.forIn("key", data, (key2) => {
|
|
5468
|
+
cxt.setParams({ propertyName: key2 });
|
|
5469
5469
|
cxt.subschema({
|
|
5470
5470
|
keyword: "propertyNames",
|
|
5471
|
-
data:
|
|
5471
|
+
data: key2,
|
|
5472
5472
|
dataTypes: ["string"],
|
|
5473
|
-
propertyName:
|
|
5473
|
+
propertyName: key2,
|
|
5474
5474
|
compositeRule: true
|
|
5475
5475
|
}, valid);
|
|
5476
5476
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
@@ -5519,38 +5519,38 @@ var require_additionalProperties = __commonJS({
|
|
|
5519
5519
|
checkAdditionalProperties();
|
|
5520
5520
|
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
5521
5521
|
function checkAdditionalProperties() {
|
|
5522
|
-
gen.forIn("key", data, (
|
|
5522
|
+
gen.forIn("key", data, (key2) => {
|
|
5523
5523
|
if (!props.length && !patProps.length)
|
|
5524
|
-
additionalPropertyCode(
|
|
5524
|
+
additionalPropertyCode(key2);
|
|
5525
5525
|
else
|
|
5526
|
-
gen.if(isAdditional(
|
|
5526
|
+
gen.if(isAdditional(key2), () => additionalPropertyCode(key2));
|
|
5527
5527
|
});
|
|
5528
5528
|
}
|
|
5529
|
-
function isAdditional(
|
|
5529
|
+
function isAdditional(key2) {
|
|
5530
5530
|
let definedProp;
|
|
5531
5531
|
if (props.length > 8) {
|
|
5532
5532
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
|
5533
|
-
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema,
|
|
5533
|
+
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key2);
|
|
5534
5534
|
} else if (props.length) {
|
|
5535
|
-
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${
|
|
5535
|
+
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key2} === ${p}`));
|
|
5536
5536
|
} else {
|
|
5537
5537
|
definedProp = codegen_1.nil;
|
|
5538
5538
|
}
|
|
5539
5539
|
if (patProps.length) {
|
|
5540
|
-
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${
|
|
5540
|
+
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key2})`));
|
|
5541
5541
|
}
|
|
5542
5542
|
return (0, codegen_1.not)(definedProp);
|
|
5543
5543
|
}
|
|
5544
|
-
function deleteAdditional(
|
|
5545
|
-
gen.code((0, codegen_1._)`delete ${data}[${
|
|
5544
|
+
function deleteAdditional(key2) {
|
|
5545
|
+
gen.code((0, codegen_1._)`delete ${data}[${key2}]`);
|
|
5546
5546
|
}
|
|
5547
|
-
function additionalPropertyCode(
|
|
5547
|
+
function additionalPropertyCode(key2) {
|
|
5548
5548
|
if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
|
|
5549
|
-
deleteAdditional(
|
|
5549
|
+
deleteAdditional(key2);
|
|
5550
5550
|
return;
|
|
5551
5551
|
}
|
|
5552
5552
|
if (schema === false) {
|
|
5553
|
-
cxt.setParams({ additionalProperty:
|
|
5553
|
+
cxt.setParams({ additionalProperty: key2 });
|
|
5554
5554
|
cxt.error();
|
|
5555
5555
|
if (!allErrors)
|
|
5556
5556
|
gen.break();
|
|
@@ -5559,22 +5559,22 @@ var require_additionalProperties = __commonJS({
|
|
|
5559
5559
|
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
|
|
5560
5560
|
const valid = gen.name("valid");
|
|
5561
5561
|
if (opts.removeAdditional === "failing") {
|
|
5562
|
-
applyAdditionalSchema(
|
|
5562
|
+
applyAdditionalSchema(key2, valid, false);
|
|
5563
5563
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
5564
5564
|
cxt.reset();
|
|
5565
|
-
deleteAdditional(
|
|
5565
|
+
deleteAdditional(key2);
|
|
5566
5566
|
});
|
|
5567
5567
|
} else {
|
|
5568
|
-
applyAdditionalSchema(
|
|
5568
|
+
applyAdditionalSchema(key2, valid);
|
|
5569
5569
|
if (!allErrors)
|
|
5570
5570
|
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
5571
5571
|
}
|
|
5572
5572
|
}
|
|
5573
5573
|
}
|
|
5574
|
-
function applyAdditionalSchema(
|
|
5574
|
+
function applyAdditionalSchema(key2, valid, errors) {
|
|
5575
5575
|
const subschema = {
|
|
5576
5576
|
keyword: "additionalProperties",
|
|
5577
|
-
dataProp:
|
|
5577
|
+
dataProp: key2,
|
|
5578
5578
|
dataPropType: util_1.Type.Str
|
|
5579
5579
|
};
|
|
5580
5580
|
if (errors === false) {
|
|
@@ -5699,19 +5699,19 @@ var require_patternProperties = __commonJS({
|
|
|
5699
5699
|
}
|
|
5700
5700
|
}
|
|
5701
5701
|
function validateProperties(pat) {
|
|
5702
|
-
gen.forIn("key", data, (
|
|
5703
|
-
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${
|
|
5702
|
+
gen.forIn("key", data, (key2) => {
|
|
5703
|
+
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key2})`, () => {
|
|
5704
5704
|
const alwaysValid = alwaysValidPatterns.includes(pat);
|
|
5705
5705
|
if (!alwaysValid) {
|
|
5706
5706
|
cxt.subschema({
|
|
5707
5707
|
keyword: "patternProperties",
|
|
5708
5708
|
schemaProp: pat,
|
|
5709
|
-
dataProp:
|
|
5709
|
+
dataProp: key2,
|
|
5710
5710
|
dataPropType: util_2.Type.Str
|
|
5711
5711
|
}, valid);
|
|
5712
5712
|
}
|
|
5713
5713
|
if (it.opts.unevaluated && props !== true) {
|
|
5714
|
-
gen.assign((0, codegen_1._)`${props}[${
|
|
5714
|
+
gen.assign((0, codegen_1._)`${props}[${key2}]`, true);
|
|
5715
5715
|
} else if (!alwaysValid && !it.allErrors) {
|
|
5716
5716
|
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
5717
5717
|
}
|
|
@@ -7364,19 +7364,19 @@ function floatSafeRemainder(val, step) {
|
|
|
7364
7364
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
7365
7365
|
return valInt % stepInt / 10 ** decCount;
|
|
7366
7366
|
}
|
|
7367
|
-
function defineLazy(object3,
|
|
7367
|
+
function defineLazy(object3, key2, getter) {
|
|
7368
7368
|
const set = false;
|
|
7369
|
-
Object.defineProperty(object3,
|
|
7369
|
+
Object.defineProperty(object3, key2, {
|
|
7370
7370
|
get() {
|
|
7371
7371
|
if (!set) {
|
|
7372
7372
|
const value = getter();
|
|
7373
|
-
object3[
|
|
7373
|
+
object3[key2] = value;
|
|
7374
7374
|
return value;
|
|
7375
7375
|
}
|
|
7376
7376
|
throw new Error("cached value already set");
|
|
7377
7377
|
},
|
|
7378
7378
|
set(v) {
|
|
7379
|
-
Object.defineProperty(object3,
|
|
7379
|
+
Object.defineProperty(object3, key2, {
|
|
7380
7380
|
value: v
|
|
7381
7381
|
// configurable: true,
|
|
7382
7382
|
});
|
|
@@ -7395,11 +7395,11 @@ function assignProp(target, prop, value) {
|
|
|
7395
7395
|
function getElementAtPath(obj, path) {
|
|
7396
7396
|
if (!path)
|
|
7397
7397
|
return obj;
|
|
7398
|
-
return path.reduce((acc,
|
|
7398
|
+
return path.reduce((acc, key2) => acc?.[key2], obj);
|
|
7399
7399
|
}
|
|
7400
7400
|
function promiseAllObject(promisesObj) {
|
|
7401
7401
|
const keys = Object.keys(promisesObj);
|
|
7402
|
-
const promises = keys.map((
|
|
7402
|
+
const promises = keys.map((key2) => promisesObj[key2]);
|
|
7403
7403
|
return Promise.all(promises).then((results) => {
|
|
7404
7404
|
const resolvedObj = {};
|
|
7405
7405
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -7452,8 +7452,8 @@ function isPlainObject(o) {
|
|
|
7452
7452
|
}
|
|
7453
7453
|
function numKeys(data) {
|
|
7454
7454
|
let keyCount = 0;
|
|
7455
|
-
for (const
|
|
7456
|
-
if (Object.prototype.hasOwnProperty.call(data,
|
|
7455
|
+
for (const key2 in data) {
|
|
7456
|
+
if (Object.prototype.hasOwnProperty.call(data, key2)) {
|
|
7457
7457
|
keyCount++;
|
|
7458
7458
|
}
|
|
7459
7459
|
}
|
|
@@ -7589,13 +7589,13 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
7589
7589
|
function pick(schema, mask) {
|
|
7590
7590
|
const newShape = {};
|
|
7591
7591
|
const currDef = schema._zod.def;
|
|
7592
|
-
for (const
|
|
7593
|
-
if (!(
|
|
7594
|
-
throw new Error(`Unrecognized key: "${
|
|
7592
|
+
for (const key2 in mask) {
|
|
7593
|
+
if (!(key2 in currDef.shape)) {
|
|
7594
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7595
7595
|
}
|
|
7596
|
-
if (!mask[
|
|
7596
|
+
if (!mask[key2])
|
|
7597
7597
|
continue;
|
|
7598
|
-
newShape[
|
|
7598
|
+
newShape[key2] = currDef.shape[key2];
|
|
7599
7599
|
}
|
|
7600
7600
|
return clone(schema, {
|
|
7601
7601
|
...schema._zod.def,
|
|
@@ -7606,13 +7606,13 @@ function pick(schema, mask) {
|
|
|
7606
7606
|
function omit(schema, mask) {
|
|
7607
7607
|
const newShape = { ...schema._zod.def.shape };
|
|
7608
7608
|
const currDef = schema._zod.def;
|
|
7609
|
-
for (const
|
|
7610
|
-
if (!(
|
|
7611
|
-
throw new Error(`Unrecognized key: "${
|
|
7609
|
+
for (const key2 in mask) {
|
|
7610
|
+
if (!(key2 in currDef.shape)) {
|
|
7611
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7612
7612
|
}
|
|
7613
|
-
if (!mask[
|
|
7613
|
+
if (!mask[key2])
|
|
7614
7614
|
continue;
|
|
7615
|
-
delete newShape[
|
|
7615
|
+
delete newShape[key2];
|
|
7616
7616
|
}
|
|
7617
7617
|
return clone(schema, {
|
|
7618
7618
|
...schema._zod.def,
|
|
@@ -7653,23 +7653,23 @@ function partial(Class2, schema, mask) {
|
|
|
7653
7653
|
const oldShape = schema._zod.def.shape;
|
|
7654
7654
|
const shape = { ...oldShape };
|
|
7655
7655
|
if (mask) {
|
|
7656
|
-
for (const
|
|
7657
|
-
if (!(
|
|
7658
|
-
throw new Error(`Unrecognized key: "${
|
|
7656
|
+
for (const key2 in mask) {
|
|
7657
|
+
if (!(key2 in oldShape)) {
|
|
7658
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7659
7659
|
}
|
|
7660
|
-
if (!mask[
|
|
7660
|
+
if (!mask[key2])
|
|
7661
7661
|
continue;
|
|
7662
|
-
shape[
|
|
7662
|
+
shape[key2] = Class2 ? new Class2({
|
|
7663
7663
|
type: "optional",
|
|
7664
|
-
innerType: oldShape[
|
|
7665
|
-
}) : oldShape[
|
|
7664
|
+
innerType: oldShape[key2]
|
|
7665
|
+
}) : oldShape[key2];
|
|
7666
7666
|
}
|
|
7667
7667
|
} else {
|
|
7668
|
-
for (const
|
|
7669
|
-
shape[
|
|
7668
|
+
for (const key2 in oldShape) {
|
|
7669
|
+
shape[key2] = Class2 ? new Class2({
|
|
7670
7670
|
type: "optional",
|
|
7671
|
-
innerType: oldShape[
|
|
7672
|
-
}) : oldShape[
|
|
7671
|
+
innerType: oldShape[key2]
|
|
7672
|
+
}) : oldShape[key2];
|
|
7673
7673
|
}
|
|
7674
7674
|
}
|
|
7675
7675
|
return clone(schema, {
|
|
@@ -7682,22 +7682,22 @@ function required(Class2, schema, mask) {
|
|
|
7682
7682
|
const oldShape = schema._zod.def.shape;
|
|
7683
7683
|
const shape = { ...oldShape };
|
|
7684
7684
|
if (mask) {
|
|
7685
|
-
for (const
|
|
7686
|
-
if (!(
|
|
7687
|
-
throw new Error(`Unrecognized key: "${
|
|
7685
|
+
for (const key2 in mask) {
|
|
7686
|
+
if (!(key2 in shape)) {
|
|
7687
|
+
throw new Error(`Unrecognized key: "${key2}"`);
|
|
7688
7688
|
}
|
|
7689
|
-
if (!mask[
|
|
7689
|
+
if (!mask[key2])
|
|
7690
7690
|
continue;
|
|
7691
|
-
shape[
|
|
7691
|
+
shape[key2] = new Class2({
|
|
7692
7692
|
type: "nonoptional",
|
|
7693
|
-
innerType: oldShape[
|
|
7693
|
+
innerType: oldShape[key2]
|
|
7694
7694
|
});
|
|
7695
7695
|
}
|
|
7696
7696
|
} else {
|
|
7697
|
-
for (const
|
|
7698
|
-
shape[
|
|
7697
|
+
for (const key2 in oldShape) {
|
|
7698
|
+
shape[key2] = new Class2({
|
|
7699
7699
|
type: "nonoptional",
|
|
7700
|
-
innerType: oldShape[
|
|
7700
|
+
innerType: oldShape[key2]
|
|
7701
7701
|
});
|
|
7702
7702
|
}
|
|
7703
7703
|
}
|
|
@@ -8893,28 +8893,28 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
8893
8893
|
return payload;
|
|
8894
8894
|
};
|
|
8895
8895
|
});
|
|
8896
|
-
function handleObjectResult(result, final,
|
|
8896
|
+
function handleObjectResult(result, final, key2) {
|
|
8897
8897
|
if (result.issues.length) {
|
|
8898
|
-
final.issues.push(...prefixIssues(
|
|
8898
|
+
final.issues.push(...prefixIssues(key2, result.issues));
|
|
8899
8899
|
}
|
|
8900
|
-
final.value[
|
|
8900
|
+
final.value[key2] = result.value;
|
|
8901
8901
|
}
|
|
8902
|
-
function handleOptionalObjectResult(result, final,
|
|
8902
|
+
function handleOptionalObjectResult(result, final, key2, input) {
|
|
8903
8903
|
if (result.issues.length) {
|
|
8904
|
-
if (input[
|
|
8905
|
-
if (
|
|
8906
|
-
final.value[
|
|
8904
|
+
if (input[key2] === void 0) {
|
|
8905
|
+
if (key2 in input) {
|
|
8906
|
+
final.value[key2] = void 0;
|
|
8907
8907
|
} else {
|
|
8908
|
-
final.value[
|
|
8908
|
+
final.value[key2] = result.value;
|
|
8909
8909
|
}
|
|
8910
8910
|
} else {
|
|
8911
|
-
final.issues.push(...prefixIssues(
|
|
8911
|
+
final.issues.push(...prefixIssues(key2, result.issues));
|
|
8912
8912
|
}
|
|
8913
8913
|
} else if (result.value === void 0) {
|
|
8914
|
-
if (
|
|
8915
|
-
final.value[
|
|
8914
|
+
if (key2 in input)
|
|
8915
|
+
final.value[key2] = void 0;
|
|
8916
8916
|
} else {
|
|
8917
|
-
final.value[
|
|
8917
|
+
final.value[key2] = result.value;
|
|
8918
8918
|
}
|
|
8919
8919
|
}
|
|
8920
8920
|
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
@@ -8938,12 +8938,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8938
8938
|
defineLazy(inst._zod, "propValues", () => {
|
|
8939
8939
|
const shape = def.shape;
|
|
8940
8940
|
const propValues = {};
|
|
8941
|
-
for (const
|
|
8942
|
-
const field = shape[
|
|
8941
|
+
for (const key2 in shape) {
|
|
8942
|
+
const field = shape[key2]._zod;
|
|
8943
8943
|
if (field.values) {
|
|
8944
|
-
propValues[
|
|
8944
|
+
propValues[key2] ?? (propValues[key2] = /* @__PURE__ */ new Set());
|
|
8945
8945
|
for (const v of field.values)
|
|
8946
|
-
propValues[
|
|
8946
|
+
propValues[key2].add(v);
|
|
8947
8947
|
}
|
|
8948
8948
|
}
|
|
8949
8949
|
return propValues;
|
|
@@ -8951,22 +8951,22 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8951
8951
|
const generateFastpass = (shape) => {
|
|
8952
8952
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
8953
8953
|
const normalized = _normalized.value;
|
|
8954
|
-
const parseStr = (
|
|
8955
|
-
const k = esc(
|
|
8954
|
+
const parseStr = (key2) => {
|
|
8955
|
+
const k = esc(key2);
|
|
8956
8956
|
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
8957
8957
|
};
|
|
8958
8958
|
doc.write(`const input = payload.value;`);
|
|
8959
8959
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
8960
8960
|
let counter = 0;
|
|
8961
|
-
for (const
|
|
8962
|
-
ids[
|
|
8961
|
+
for (const key2 of normalized.keys) {
|
|
8962
|
+
ids[key2] = `key_${counter++}`;
|
|
8963
8963
|
}
|
|
8964
8964
|
doc.write(`const newResult = {}`);
|
|
8965
|
-
for (const
|
|
8966
|
-
if (normalized.optionalKeys.has(
|
|
8967
|
-
const id = ids[
|
|
8968
|
-
doc.write(`const ${id} = ${parseStr(
|
|
8969
|
-
const k = esc(
|
|
8965
|
+
for (const key2 of normalized.keys) {
|
|
8966
|
+
if (normalized.optionalKeys.has(key2)) {
|
|
8967
|
+
const id = ids[key2];
|
|
8968
|
+
doc.write(`const ${id} = ${parseStr(key2)};`);
|
|
8969
|
+
const k = esc(key2);
|
|
8970
8970
|
doc.write(`
|
|
8971
8971
|
if (${id}.issues.length) {
|
|
8972
8972
|
if (input[${k}] === undefined) {
|
|
@@ -8988,14 +8988,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8988
8988
|
}
|
|
8989
8989
|
`);
|
|
8990
8990
|
} else {
|
|
8991
|
-
const id = ids[
|
|
8992
|
-
doc.write(`const ${id} = ${parseStr(
|
|
8991
|
+
const id = ids[key2];
|
|
8992
|
+
doc.write(`const ${id} = ${parseStr(key2)};`);
|
|
8993
8993
|
doc.write(`
|
|
8994
8994
|
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
8995
8995
|
...iss,
|
|
8996
|
-
path: iss.path ? [${esc(
|
|
8996
|
+
path: iss.path ? [${esc(key2)}, ...iss.path] : [${esc(key2)}]
|
|
8997
8997
|
})));`);
|
|
8998
|
-
doc.write(`newResult[${esc(
|
|
8998
|
+
doc.write(`newResult[${esc(key2)}] = ${id}.value`);
|
|
8999
8999
|
}
|
|
9000
9000
|
}
|
|
9001
9001
|
doc.write(`payload.value = newResult;`);
|
|
@@ -9030,16 +9030,16 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9030
9030
|
} else {
|
|
9031
9031
|
payload.value = {};
|
|
9032
9032
|
const shape = value.shape;
|
|
9033
|
-
for (const
|
|
9034
|
-
const el = shape[
|
|
9035
|
-
const r = el._zod.run({ value: input[
|
|
9033
|
+
for (const key2 of value.keys) {
|
|
9034
|
+
const el = shape[key2];
|
|
9035
|
+
const r = el._zod.run({ value: input[key2], issues: [] }, ctx);
|
|
9036
9036
|
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
9037
9037
|
if (r instanceof Promise) {
|
|
9038
|
-
proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload,
|
|
9038
|
+
proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload, key2, input) : handleObjectResult(r2, payload, key2)));
|
|
9039
9039
|
} else if (isOptional) {
|
|
9040
|
-
handleOptionalObjectResult(r, payload,
|
|
9040
|
+
handleOptionalObjectResult(r, payload, key2, input);
|
|
9041
9041
|
} else {
|
|
9042
|
-
handleObjectResult(r, payload,
|
|
9042
|
+
handleObjectResult(r, payload, key2);
|
|
9043
9043
|
}
|
|
9044
9044
|
}
|
|
9045
9045
|
}
|
|
@@ -9050,18 +9050,18 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9050
9050
|
const keySet = value.keySet;
|
|
9051
9051
|
const _catchall = catchall._zod;
|
|
9052
9052
|
const t = _catchall.def.type;
|
|
9053
|
-
for (const
|
|
9054
|
-
if (keySet.has(
|
|
9053
|
+
for (const key2 of Object.keys(input)) {
|
|
9054
|
+
if (keySet.has(key2))
|
|
9055
9055
|
continue;
|
|
9056
9056
|
if (t === "never") {
|
|
9057
|
-
unrecognized.push(
|
|
9057
|
+
unrecognized.push(key2);
|
|
9058
9058
|
continue;
|
|
9059
9059
|
}
|
|
9060
|
-
const r = _catchall.run({ value: input[
|
|
9060
|
+
const r = _catchall.run({ value: input[key2], issues: [] }, ctx);
|
|
9061
9061
|
if (r instanceof Promise) {
|
|
9062
|
-
proms.push(r.then((r2) => handleObjectResult(r2, payload,
|
|
9062
|
+
proms.push(r.then((r2) => handleObjectResult(r2, payload, key2)));
|
|
9063
9063
|
} else {
|
|
9064
|
-
handleObjectResult(r, payload,
|
|
9064
|
+
handleObjectResult(r, payload, key2);
|
|
9065
9065
|
}
|
|
9066
9066
|
}
|
|
9067
9067
|
if (unrecognized.length) {
|
|
@@ -9223,17 +9223,17 @@ function mergeValues(a, b) {
|
|
|
9223
9223
|
}
|
|
9224
9224
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
9225
9225
|
const bKeys = Object.keys(b);
|
|
9226
|
-
const sharedKeys = Object.keys(a).filter((
|
|
9226
|
+
const sharedKeys = Object.keys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
|
|
9227
9227
|
const newObj = { ...a, ...b };
|
|
9228
|
-
for (const
|
|
9229
|
-
const sharedValue = mergeValues(a[
|
|
9228
|
+
for (const key2 of sharedKeys) {
|
|
9229
|
+
const sharedValue = mergeValues(a[key2], b[key2]);
|
|
9230
9230
|
if (!sharedValue.valid) {
|
|
9231
9231
|
return {
|
|
9232
9232
|
valid: false,
|
|
9233
|
-
mergeErrorPath: [
|
|
9233
|
+
mergeErrorPath: [key2, ...sharedValue.mergeErrorPath]
|
|
9234
9234
|
};
|
|
9235
9235
|
}
|
|
9236
|
-
newObj[
|
|
9236
|
+
newObj[key2] = sharedValue.data;
|
|
9237
9237
|
}
|
|
9238
9238
|
return { valid: true, data: newObj };
|
|
9239
9239
|
}
|
|
@@ -9291,29 +9291,29 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
9291
9291
|
if (def.keyType._zod.values) {
|
|
9292
9292
|
const values = def.keyType._zod.values;
|
|
9293
9293
|
payload.value = {};
|
|
9294
|
-
for (const
|
|
9295
|
-
if (typeof
|
|
9296
|
-
const result = def.valueType._zod.run({ value: input[
|
|
9294
|
+
for (const key2 of values) {
|
|
9295
|
+
if (typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol") {
|
|
9296
|
+
const result = def.valueType._zod.run({ value: input[key2], issues: [] }, ctx);
|
|
9297
9297
|
if (result instanceof Promise) {
|
|
9298
9298
|
proms.push(result.then((result2) => {
|
|
9299
9299
|
if (result2.issues.length) {
|
|
9300
|
-
payload.issues.push(...prefixIssues(
|
|
9300
|
+
payload.issues.push(...prefixIssues(key2, result2.issues));
|
|
9301
9301
|
}
|
|
9302
|
-
payload.value[
|
|
9302
|
+
payload.value[key2] = result2.value;
|
|
9303
9303
|
}));
|
|
9304
9304
|
} else {
|
|
9305
9305
|
if (result.issues.length) {
|
|
9306
|
-
payload.issues.push(...prefixIssues(
|
|
9306
|
+
payload.issues.push(...prefixIssues(key2, result.issues));
|
|
9307
9307
|
}
|
|
9308
|
-
payload.value[
|
|
9308
|
+
payload.value[key2] = result.value;
|
|
9309
9309
|
}
|
|
9310
9310
|
}
|
|
9311
9311
|
}
|
|
9312
9312
|
let unrecognized;
|
|
9313
|
-
for (const
|
|
9314
|
-
if (!values.has(
|
|
9313
|
+
for (const key2 in input) {
|
|
9314
|
+
if (!values.has(key2)) {
|
|
9315
9315
|
unrecognized = unrecognized ?? [];
|
|
9316
|
-
unrecognized.push(
|
|
9316
|
+
unrecognized.push(key2);
|
|
9317
9317
|
}
|
|
9318
9318
|
}
|
|
9319
9319
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -9326,10 +9326,10 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
9326
9326
|
}
|
|
9327
9327
|
} else {
|
|
9328
9328
|
payload.value = {};
|
|
9329
|
-
for (const
|
|
9330
|
-
if (
|
|
9329
|
+
for (const key2 of Reflect.ownKeys(input)) {
|
|
9330
|
+
if (key2 === "__proto__")
|
|
9331
9331
|
continue;
|
|
9332
|
-
const keyResult = def.keyType._zod.run({ value:
|
|
9332
|
+
const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
|
|
9333
9333
|
if (keyResult instanceof Promise) {
|
|
9334
9334
|
throw new Error("Async schemas not supported in object keys currently");
|
|
9335
9335
|
}
|
|
@@ -9338,24 +9338,24 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
9338
9338
|
origin: "record",
|
|
9339
9339
|
code: "invalid_key",
|
|
9340
9340
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
9341
|
-
input:
|
|
9342
|
-
path: [
|
|
9341
|
+
input: key2,
|
|
9342
|
+
path: [key2],
|
|
9343
9343
|
inst
|
|
9344
9344
|
});
|
|
9345
9345
|
payload.value[keyResult.value] = keyResult.value;
|
|
9346
9346
|
continue;
|
|
9347
9347
|
}
|
|
9348
|
-
const result = def.valueType._zod.run({ value: input[
|
|
9348
|
+
const result = def.valueType._zod.run({ value: input[key2], issues: [] }, ctx);
|
|
9349
9349
|
if (result instanceof Promise) {
|
|
9350
9350
|
proms.push(result.then((result2) => {
|
|
9351
9351
|
if (result2.issues.length) {
|
|
9352
|
-
payload.issues.push(...prefixIssues(
|
|
9352
|
+
payload.issues.push(...prefixIssues(key2, result2.issues));
|
|
9353
9353
|
}
|
|
9354
9354
|
payload.value[keyResult.value] = result2.value;
|
|
9355
9355
|
}));
|
|
9356
9356
|
} else {
|
|
9357
9357
|
if (result.issues.length) {
|
|
9358
|
-
payload.issues.push(...prefixIssues(
|
|
9358
|
+
payload.issues.push(...prefixIssues(key2, result.issues));
|
|
9359
9359
|
}
|
|
9360
9360
|
payload.value[keyResult.value] = result.value;
|
|
9361
9361
|
}
|
|
@@ -13457,8 +13457,8 @@ function isPlainObject2(value) {
|
|
|
13457
13457
|
}
|
|
13458
13458
|
function mergeCapabilities(base, additional) {
|
|
13459
13459
|
const result = { ...base };
|
|
13460
|
-
for (const
|
|
13461
|
-
const k =
|
|
13460
|
+
for (const key2 in additional) {
|
|
13461
|
+
const k = key2;
|
|
13462
13462
|
const addValue = additional[k];
|
|
13463
13463
|
if (addValue === void 0)
|
|
13464
13464
|
continue;
|
|
@@ -14192,6 +14192,112 @@ function decideSlackMessageForward(evt) {
|
|
|
14192
14192
|
}
|
|
14193
14193
|
return { forward: true };
|
|
14194
14194
|
}
|
|
14195
|
+
function decideSlackEngagement(input) {
|
|
14196
|
+
const isExplicitMention = input.type === "app_mention" || input.botUserId.length > 0 && input.text.includes(`<@${input.botUserId}>`);
|
|
14197
|
+
return !(input.isAutoFollowed && !isExplicitMention);
|
|
14198
|
+
}
|
|
14199
|
+
|
|
14200
|
+
// src/slack-loop-throttle.ts
|
|
14201
|
+
var DEFAULT_THROTTLE = {
|
|
14202
|
+
threshold: 3,
|
|
14203
|
+
windowMs: 12e4,
|
|
14204
|
+
ringSize: 8
|
|
14205
|
+
};
|
|
14206
|
+
function decideReplyThrottle(input) {
|
|
14207
|
+
const cfg = input.config ?? DEFAULT_THROTTLE;
|
|
14208
|
+
const cutoff = input.now - cfg.windowMs;
|
|
14209
|
+
const inWindow = input.recentReplyTimestamps.filter((t) => t >= cutoff);
|
|
14210
|
+
if (inWindow.length >= cfg.threshold) {
|
|
14211
|
+
return {
|
|
14212
|
+
allow: false,
|
|
14213
|
+
recentCount: inWindow.length,
|
|
14214
|
+
reason: "throttle_threshold_exceeded"
|
|
14215
|
+
};
|
|
14216
|
+
}
|
|
14217
|
+
return {
|
|
14218
|
+
allow: true,
|
|
14219
|
+
recentCount: inWindow.length,
|
|
14220
|
+
reason: "under_threshold"
|
|
14221
|
+
};
|
|
14222
|
+
}
|
|
14223
|
+
var buffers = /* @__PURE__ */ new Map();
|
|
14224
|
+
function key(channelId, threadKey) {
|
|
14225
|
+
return `${channelId}${threadKey}`;
|
|
14226
|
+
}
|
|
14227
|
+
function recordReply(channelId, threadKey, now, config2 = DEFAULT_THROTTLE) {
|
|
14228
|
+
const k = key(channelId, threadKey);
|
|
14229
|
+
const cutoff = now - config2.windowMs;
|
|
14230
|
+
const cur = buffers.get(k) ?? [];
|
|
14231
|
+
cur.push(now);
|
|
14232
|
+
let pruned = cur.filter((t) => t >= cutoff);
|
|
14233
|
+
if (pruned.length > config2.ringSize) {
|
|
14234
|
+
pruned = pruned.slice(pruned.length - config2.ringSize);
|
|
14235
|
+
}
|
|
14236
|
+
buffers.set(k, pruned);
|
|
14237
|
+
}
|
|
14238
|
+
function getRecentReplies(channelId, threadKey, now, config2 = DEFAULT_THROTTLE) {
|
|
14239
|
+
const k = key(channelId, threadKey);
|
|
14240
|
+
const cutoff = now - config2.windowMs;
|
|
14241
|
+
const cur = buffers.get(k) ?? [];
|
|
14242
|
+
return cur.filter((t) => t >= cutoff);
|
|
14243
|
+
}
|
|
14244
|
+
function resetThread(channelId, threadKey) {
|
|
14245
|
+
buffers.delete(key(channelId, threadKey));
|
|
14246
|
+
}
|
|
14247
|
+
function configFromEnv(env = process.env) {
|
|
14248
|
+
const count = Number(env.SLACK_AGENT_REPLY_THROTTLE_COUNT);
|
|
14249
|
+
const windowMs = Number(env.SLACK_AGENT_REPLY_THROTTLE_WINDOW_MS);
|
|
14250
|
+
return {
|
|
14251
|
+
threshold: Number.isFinite(count) && count > 0 ? count : DEFAULT_THROTTLE.threshold,
|
|
14252
|
+
windowMs: Number.isFinite(windowMs) && windowMs > 0 ? windowMs : DEFAULT_THROTTLE.windowMs,
|
|
14253
|
+
ringSize: DEFAULT_THROTTLE.ringSize
|
|
14254
|
+
};
|
|
14255
|
+
}
|
|
14256
|
+
|
|
14257
|
+
// src/channel-kill-check.ts
|
|
14258
|
+
var CACHE_TTL_MS = 6e4;
|
|
14259
|
+
var cache = /* @__PURE__ */ new Map();
|
|
14260
|
+
function cacheKey(channelType, channelId, threadTs) {
|
|
14261
|
+
return `${channelType}|${channelId}|${threadTs}`;
|
|
14262
|
+
}
|
|
14263
|
+
async function isThreadKilled(opts) {
|
|
14264
|
+
const threadTs = opts.threadTs ?? "";
|
|
14265
|
+
const key2 = cacheKey(opts.channelType, opts.channelId, threadTs);
|
|
14266
|
+
const now = opts.now ? opts.now() : Date.now();
|
|
14267
|
+
const cached2 = cache.get(key2);
|
|
14268
|
+
if (cached2 && cached2.expiresAt > now) {
|
|
14269
|
+
return cached2.killed;
|
|
14270
|
+
}
|
|
14271
|
+
if (!opts.agtHost || !opts.agtApiKey) {
|
|
14272
|
+
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14273
|
+
return false;
|
|
14274
|
+
}
|
|
14275
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
14276
|
+
try {
|
|
14277
|
+
const url = new URL("/host/channels/kill-check", opts.agtHost);
|
|
14278
|
+
url.searchParams.set("channel_type", opts.channelType);
|
|
14279
|
+
url.searchParams.set("channel_id", opts.channelId);
|
|
14280
|
+
if (threadTs) url.searchParams.set("thread_ts", threadTs);
|
|
14281
|
+
const res = await fetchImpl(url.toString(), {
|
|
14282
|
+
method: "GET",
|
|
14283
|
+
headers: { Authorization: `Bearer ${opts.agtApiKey}` },
|
|
14284
|
+
// 5s ceiling — kill check is hot-path. If the API is slow,
|
|
14285
|
+
// fail-open and try again next cache window.
|
|
14286
|
+
signal: AbortSignal.timeout(5e3)
|
|
14287
|
+
});
|
|
14288
|
+
if (!res.ok) {
|
|
14289
|
+
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14290
|
+
return false;
|
|
14291
|
+
}
|
|
14292
|
+
const body = await res.json();
|
|
14293
|
+
const killed = !!body.killed;
|
|
14294
|
+
cache.set(key2, { killed, expiresAt: now + CACHE_TTL_MS });
|
|
14295
|
+
return killed;
|
|
14296
|
+
} catch {
|
|
14297
|
+
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14298
|
+
return false;
|
|
14299
|
+
}
|
|
14300
|
+
}
|
|
14195
14301
|
|
|
14196
14302
|
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
14197
14303
|
import process2 from "process";
|
|
@@ -14336,20 +14442,20 @@ function loadThreadStore(filePath, opts = {}) {
|
|
|
14336
14442
|
}
|
|
14337
14443
|
const threads = /* @__PURE__ */ new Map();
|
|
14338
14444
|
let pruned = 0;
|
|
14339
|
-
for (const [
|
|
14445
|
+
for (const [key2, entry] of Object.entries(parsed.threads)) {
|
|
14340
14446
|
if (!isThreadEntry(entry)) continue;
|
|
14341
14447
|
const seenTs = Date.parse(entry.last_seen_at);
|
|
14342
14448
|
if (Number.isFinite(seenTs) && now.getTime() - seenTs > ttlMs) {
|
|
14343
14449
|
pruned++;
|
|
14344
14450
|
continue;
|
|
14345
14451
|
}
|
|
14346
|
-
threads.set(
|
|
14452
|
+
threads.set(key2, { involvement: entry.involvement, last_seen_at: entry.last_seen_at });
|
|
14347
14453
|
}
|
|
14348
14454
|
return { threads, pruned };
|
|
14349
14455
|
}
|
|
14350
14456
|
function serializeThreadStore(threads) {
|
|
14351
14457
|
const out = { version: FILE_VERSION, threads: {} };
|
|
14352
|
-
for (const [
|
|
14458
|
+
for (const [key2, entry] of threads) out.threads[key2] = entry;
|
|
14353
14459
|
return JSON.stringify(out, null, 2);
|
|
14354
14460
|
}
|
|
14355
14461
|
function createThreadPersister(opts) {
|
|
@@ -14810,9 +14916,9 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
14810
14916
|
}
|
|
14811
14917
|
startSlackRecoveryOutboxWatcher();
|
|
14812
14918
|
function trackPendingMessage(channel, threadTs, messageTs) {
|
|
14813
|
-
const
|
|
14919
|
+
const key2 = `${channel}:${threadTs}:${messageTs}`;
|
|
14814
14920
|
const timer = setTimeout(async () => {
|
|
14815
|
-
pendingMessages.delete(
|
|
14921
|
+
pendingMessages.delete(key2);
|
|
14816
14922
|
try {
|
|
14817
14923
|
await fetch("https://slack.com/api/chat.postMessage", {
|
|
14818
14924
|
method: "POST",
|
|
@@ -14837,14 +14943,14 @@ function trackPendingMessage(channel, threadTs, messageTs) {
|
|
|
14837
14943
|
`);
|
|
14838
14944
|
clearSlackPendingInboundMarker(channel, threadTs, messageTs);
|
|
14839
14945
|
}, RESPONSE_TIMEOUT_MS);
|
|
14840
|
-
pendingMessages.set(
|
|
14946
|
+
pendingMessages.set(key2, timer);
|
|
14841
14947
|
writeSlackPendingInboundMarker(channel, threadTs, messageTs);
|
|
14842
14948
|
}
|
|
14843
14949
|
function clearPendingMessage(channel, threadTs) {
|
|
14844
|
-
for (const [
|
|
14845
|
-
if (
|
|
14950
|
+
for (const [key2, timer] of pendingMessages) {
|
|
14951
|
+
if (key2.startsWith(`${channel}:${threadTs}:`)) {
|
|
14846
14952
|
clearTimeout(timer);
|
|
14847
|
-
pendingMessages.delete(
|
|
14953
|
+
pendingMessages.delete(key2);
|
|
14848
14954
|
}
|
|
14849
14955
|
}
|
|
14850
14956
|
clearAllSlackPendingMarkersForThread(channel, threadTs);
|
|
@@ -14876,6 +14982,34 @@ async function postSlackMessage(body) {
|
|
|
14876
14982
|
return { ok: false, error: isTimeout ? "timeout" : err.message };
|
|
14877
14983
|
}
|
|
14878
14984
|
}
|
|
14985
|
+
function buildSlackHelpMessage(codeName) {
|
|
14986
|
+
return [
|
|
14987
|
+
`\u{1F916} *Available commands for \`${codeName}\`*`,
|
|
14988
|
+
"",
|
|
14989
|
+
"_Type these in a thread or channel where the bot is present (intercepted by the agent):_",
|
|
14990
|
+
"\u2022 `/help` \u2014 show this help",
|
|
14991
|
+
"\u2022 `/restart` \u2014 restart this agent",
|
|
14992
|
+
"",
|
|
14993
|
+
"_Real Slack slash commands (also discoverable via `/`-autocomplete):_",
|
|
14994
|
+
"\u2022 `/kill` \u2014 silence all agents in this thread for 6h (use as a thread reply)",
|
|
14995
|
+
"\u2022 `/unkill` \u2014 clear a kill (use as a thread reply)"
|
|
14996
|
+
].join("\n");
|
|
14997
|
+
}
|
|
14998
|
+
async function handleHelpCommand(opts) {
|
|
14999
|
+
const codeName = AGENT_CODE_NAME ?? "unknown";
|
|
15000
|
+
const replyThread = opts.threadTs ?? opts.ts;
|
|
15001
|
+
const ack = await postSlackMessage({
|
|
15002
|
+
channel: opts.channel,
|
|
15003
|
+
text: buildSlackHelpMessage(codeName),
|
|
15004
|
+
...replyThread ? { thread_ts: replyThread } : {}
|
|
15005
|
+
});
|
|
15006
|
+
if (!ack.ok) {
|
|
15007
|
+
process.stderr.write(
|
|
15008
|
+
`slack-channel(${codeName}): /help reply failed: ${ack.error ?? "unknown"}
|
|
15009
|
+
`
|
|
15010
|
+
);
|
|
15011
|
+
}
|
|
15012
|
+
}
|
|
14879
15013
|
async function handleRestartCommand(opts) {
|
|
14880
15014
|
const codeName = AGENT_CODE_NAME ?? "unknown";
|
|
14881
15015
|
try {
|
|
@@ -14953,14 +15087,14 @@ function buildThreadKey(channel, threadTs) {
|
|
|
14953
15087
|
return `${channel}:${threadTs}`;
|
|
14954
15088
|
}
|
|
14955
15089
|
function rememberThread(channel, threadTs, involvement, opts = {}) {
|
|
14956
|
-
const
|
|
14957
|
-
if (!
|
|
14958
|
-
const existing = trackedThreads.get(
|
|
15090
|
+
const key2 = buildThreadKey(channel, threadTs);
|
|
15091
|
+
if (!key2) return;
|
|
15092
|
+
const existing = trackedThreads.get(key2);
|
|
14959
15093
|
const next = {
|
|
14960
15094
|
involvement: opts.override || !existing ? involvement : existing.involvement,
|
|
14961
15095
|
last_seen_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
14962
15096
|
};
|
|
14963
|
-
trackedThreads.set(
|
|
15097
|
+
trackedThreads.set(key2, next);
|
|
14964
15098
|
if (isShuttingDown) {
|
|
14965
15099
|
threadPersister?.flush(trackedThreads);
|
|
14966
15100
|
} else {
|
|
@@ -15215,6 +15349,64 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
15215
15349
|
const { name, arguments: args } = req.params;
|
|
15216
15350
|
if (name === "slack.reply") {
|
|
15217
15351
|
const { channel, text, thread_ts } = args;
|
|
15352
|
+
if (channel && thread_ts) {
|
|
15353
|
+
const killed = await isThreadKilled({
|
|
15354
|
+
channelType: "slack",
|
|
15355
|
+
channelId: channel,
|
|
15356
|
+
threadTs: thread_ts,
|
|
15357
|
+
agtHost: AGT_HOST,
|
|
15358
|
+
agtApiKey: AGT_API_KEY
|
|
15359
|
+
});
|
|
15360
|
+
if (killed) {
|
|
15361
|
+
process.stderr.write(
|
|
15362
|
+
`slack-channel(${AGENT_CODE_NAME}): reply_killed channel=${redactSlackId(channel)} thread=${redactSlackId(thread_ts)}
|
|
15363
|
+
`
|
|
15364
|
+
);
|
|
15365
|
+
return {
|
|
15366
|
+
content: [
|
|
15367
|
+
{
|
|
15368
|
+
type: "text",
|
|
15369
|
+
text: "This thread has been silenced by /kill. Stop attempting to reply \u2014 the human will /unkill when they want agents back."
|
|
15370
|
+
}
|
|
15371
|
+
],
|
|
15372
|
+
isError: true
|
|
15373
|
+
};
|
|
15374
|
+
}
|
|
15375
|
+
}
|
|
15376
|
+
const throttleCfg = configFromEnv();
|
|
15377
|
+
const throttleKey = thread_ts ?? channel;
|
|
15378
|
+
const throttleNow = Date.now();
|
|
15379
|
+
const throttleDecision = decideReplyThrottle({
|
|
15380
|
+
recentReplyTimestamps: getRecentReplies(channel, throttleKey, throttleNow, throttleCfg),
|
|
15381
|
+
now: throttleNow,
|
|
15382
|
+
config: throttleCfg
|
|
15383
|
+
});
|
|
15384
|
+
if (!throttleDecision.allow) {
|
|
15385
|
+
process.stderr.write(
|
|
15386
|
+
`slack-channel(${AGENT_CODE_NAME}): reply_throttled channel=${redactSlackId(channel)} thread=${redactSlackId(throttleKey)} count=${throttleDecision.recentCount} window_ms=${throttleCfg.windowMs} threshold=${throttleCfg.threshold}
|
|
15387
|
+
`
|
|
15388
|
+
);
|
|
15389
|
+
if (channel && thread_ts) {
|
|
15390
|
+
fetch("https://slack.com/api/reactions.add", {
|
|
15391
|
+
method: "POST",
|
|
15392
|
+
headers: {
|
|
15393
|
+
"Content-Type": "application/json",
|
|
15394
|
+
Authorization: `Bearer ${BOT_TOKEN}`
|
|
15395
|
+
},
|
|
15396
|
+
body: JSON.stringify({ channel, timestamp: thread_ts, name: "lock" })
|
|
15397
|
+
}).catch(() => {
|
|
15398
|
+
});
|
|
15399
|
+
}
|
|
15400
|
+
return {
|
|
15401
|
+
content: [
|
|
15402
|
+
{
|
|
15403
|
+
type: "text",
|
|
15404
|
+
text: `Reply throttled: ${throttleDecision.recentCount} replies from this agent to this thread within the last ${Math.round(throttleCfg.windowMs / 1e3)}s (threshold ${throttleCfg.threshold}). The thread is paused for this agent until a human posts in it. Stop attempting to reply.`
|
|
15405
|
+
}
|
|
15406
|
+
],
|
|
15407
|
+
isError: true
|
|
15408
|
+
};
|
|
15409
|
+
}
|
|
15218
15410
|
if (channel && thread_ts) {
|
|
15219
15411
|
clearPendingMessage(channel, thread_ts);
|
|
15220
15412
|
}
|
|
@@ -15238,6 +15430,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
15238
15430
|
isError: true
|
|
15239
15431
|
};
|
|
15240
15432
|
}
|
|
15433
|
+
recordReply(channel, throttleKey, throttleNow, throttleCfg);
|
|
15241
15434
|
if (THREAD_AUTO_FOLLOW !== "off") {
|
|
15242
15435
|
const trackTs = thread_ts ?? data.ts ?? void 0;
|
|
15243
15436
|
rememberThread(channel, trackTs, thread_ts ? "mentioned" : "started");
|
|
@@ -16056,6 +16249,15 @@ async function connectSocketMode() {
|
|
|
16056
16249
|
const rawText = evt.text ?? "";
|
|
16057
16250
|
const strippedText = rawText.replace(/^\s*<@[^>]+>\s*/, "").trim();
|
|
16058
16251
|
const isRestartCommand = strippedText === "/restart" || strippedText.startsWith("/restart ");
|
|
16252
|
+
const isHelpCommand = strippedText === "/help" || strippedText.startsWith("/help ");
|
|
16253
|
+
if (isHelpCommand) {
|
|
16254
|
+
await handleHelpCommand({
|
|
16255
|
+
channel: evt.channel ?? "",
|
|
16256
|
+
threadTs: evt.thread_ts,
|
|
16257
|
+
ts: evt.ts ?? ""
|
|
16258
|
+
});
|
|
16259
|
+
return;
|
|
16260
|
+
}
|
|
16059
16261
|
if (isRestartCommand) {
|
|
16060
16262
|
const senderAllowed = ALLOWED_USERS.size === 0 || evt.user != null && ALLOWED_USERS.has(evt.user);
|
|
16061
16263
|
if (!senderAllowed) {
|
|
@@ -16094,7 +16296,18 @@ async function connectSocketMode() {
|
|
|
16094
16296
|
const ts = evt.ts ?? "";
|
|
16095
16297
|
const threadTs = evt.thread_ts ?? ts;
|
|
16096
16298
|
const user = evt.user ?? "unknown";
|
|
16097
|
-
|
|
16299
|
+
const isFromBot = !!evt.bot_id;
|
|
16300
|
+
if (channel && !isFromBot && evt.user !== botUserId) {
|
|
16301
|
+
resetThread(channel, threadTs);
|
|
16302
|
+
}
|
|
16303
|
+
const isAutoFollowed = evt.type === "message" && isThreadReply && !!threadKey && trackedThreads.has(threadKey);
|
|
16304
|
+
const shouldEngage = decideSlackEngagement({
|
|
16305
|
+
type: evt.type ?? "message",
|
|
16306
|
+
text,
|
|
16307
|
+
isAutoFollowed,
|
|
16308
|
+
botUserId
|
|
16309
|
+
});
|
|
16310
|
+
if (channel && ts && shouldEngage) {
|
|
16098
16311
|
fetch("https://slack.com/api/reactions.add", {
|
|
16099
16312
|
method: "POST",
|
|
16100
16313
|
headers: {
|
|
@@ -16105,8 +16318,7 @@ async function connectSocketMode() {
|
|
|
16105
16318
|
}).catch(() => {
|
|
16106
16319
|
});
|
|
16107
16320
|
}
|
|
16108
|
-
|
|
16109
|
-
if (channel && ts) {
|
|
16321
|
+
if (channel && ts && shouldEngage) {
|
|
16110
16322
|
trackPendingMessage(channel, threadTs, ts);
|
|
16111
16323
|
}
|
|
16112
16324
|
const userName = await resolveUserName(user);
|
|
@@ -16186,7 +16398,7 @@ if (THREAD_STORE_PATH) {
|
|
|
16186
16398
|
onError: (msg) => process.stderr.write(`${redact(msg)}
|
|
16187
16399
|
`)
|
|
16188
16400
|
});
|
|
16189
|
-
for (const [
|
|
16401
|
+
for (const [key2, entry] of threads) trackedThreads.set(key2, entry);
|
|
16190
16402
|
threadPersister = createThreadPersister({
|
|
16191
16403
|
filePath: THREAD_STORE_PATH,
|
|
16192
16404
|
onError: (msg) => process.stderr.write(`${redact(msg)}
|