@pensar/apex 2.0.0-canary.241920ad → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +0 -20
  2. package/build/agent-84enr6xn.js +22 -0
  3. package/build/{agent-7866ka7b.js → agent-x1tnsg7n.js} +10 -7
  4. package/build/{agent-aj7jpehp.js → agent-z8043nrm.js} +12 -9
  5. package/build/{apps-hse35c2d.js → apps-gdze0s68.js} +18 -15
  6. package/build/{auth-15rkvgam.js → auth-24ca1qwx.js} +19 -16
  7. package/build/authentication-0k43jay4.js +22 -0
  8. package/build/blackboxAgent-76tnwwg7.js +22 -0
  9. package/build/{blackboxPentest-vmtnnp5d.js → blackboxPentest-xwc031xm.js} +16 -13
  10. package/build/{cli-23xtyah8.js → cli-0v9x0eby.js} +1 -1
  11. package/build/cli-1yavz2pb.js +17 -0
  12. package/build/{cli-6gge86w5.js → cli-31cara07.js} +6 -8
  13. package/build/cli-3knnkdps.js +666 -0
  14. package/build/{cli-cbw2rmv7.js → cli-5fr9k6m4.js} +35 -58
  15. package/build/{cli-78s9w64j.js → cli-948dk60p.js} +1 -1
  16. package/build/{cli-k1vsv3qh.js → cli-a20jcpmp.js} +1 -1
  17. package/build/{cli-0svsmc2c.js → cli-cb5va0cs.js} +1 -10
  18. package/build/{cli-rtbry75t.js → cli-h6nw89zf.js} +1 -1
  19. package/build/{cli-5h1kv0v4.js → cli-h825qzmd.js} +53 -1492
  20. package/build/{cli-gtepvg8s.js → cli-k8mvghe1.js} +921 -444
  21. package/build/{cli-4dpc999m.js → cli-mswm4k81.js} +1 -11
  22. package/build/{cli-zyk3xsth.js → cli-ntd42071.js} +1 -1
  23. package/build/{cli-mb837pv4.js → cli-pkdjamer.js} +5 -15
  24. package/build/cli-s1nckt4k.js +20 -0
  25. package/build/{cli-4ez6yssj.js → cli-sw5swz40.js} +3 -3
  26. package/build/{cli-ft17f9nh.js → cli-wdmqkshz.js} +2 -2
  27. package/build/{cli-demg7sj2.js → cli-zpvmaxem.js} +2 -2
  28. package/build/{cli-r0s5br0a.js → cli-zvq4gy61.js} +6 -13
  29. package/build/cli.js +45 -105
  30. package/build/{config-bb6q79q0.js → config-cmq1cxz3.js} +3 -3
  31. package/build/{doctor-tkz0a0g4.js → doctor-2bkpddws.js} +1 -8
  32. package/build/{fixes-krvbkbey.js → fixes-a4qscvkx.js} +18 -15
  33. package/build/{index-pamhzcx3.js → index-0fnbx38r.js} +14 -20
  34. package/build/{index-ah3cm7hf.js → index-2a1x5nnv.js} +3 -3
  35. package/build/{index-v4sz6cee.js → index-48pjf9d2.js} +124 -76
  36. package/build/{index-tknvj68q.js → index-54ep0ery.js} +12 -9
  37. package/build/{index-wsp4kqtm.js → index-aymt8k9w.js} +2 -2
  38. package/build/{index-a9ea9c1q.js → index-hfhkjj2g.js} +11 -8
  39. package/build/{index-4gk224ac.js → index-s17r2akv.js} +4 -4
  40. package/build/{issues-m2me70rs.js → issues-5pnrspt7.js} +18 -15
  41. package/build/{logs-rxf1a0be.js → logs-1mfm901x.js} +18 -15
  42. package/build/{offesecAgent-hmxcpch7.js → offesecAgent-mrbyc93d.js} +11 -8
  43. package/build/pentest-wy4eeagc.js +31 -0
  44. package/build/{pentests-201vfsn6.js → pentests-htmtq66d.js} +18 -15
  45. package/build/{targetedPentest-85b1dndy.js → targetedPentest-cpbd87rc.js} +12 -9
  46. package/build/threatModel-9n56z6a6.js +29 -0
  47. package/build/{uninstall-qa8jvrj1.js → uninstall-6y9dkgyt.js} +1 -1
  48. package/build/{upload-p58nxxvf.js → upload-7wtbr768.js} +1 -8
  49. package/build/{utils-hsde107p.js → utils-trqnyj77.js} +8 -6
  50. package/package.json +1 -1
  51. package/build/agent-mjyx1amj.js +0 -19
  52. package/build/authentication-b8p1afqq.js +0 -19
  53. package/build/blackboxAgent-z1h2cgyg.js +0 -19
  54. package/build/pentest-r6hfzf8n.js +0 -28
  55. package/build/threatModel-hbpz15y7.js +0 -26
@@ -1,39 +1,47 @@
1
1
  import {
2
2
  detectOSAndEnhancePrompt
3
- } from "./cli-4dpc999m.js";
3
+ } from "./cli-mswm4k81.js";
4
+ import {
5
+ CredentialManager,
6
+ NotFoundError,
7
+ RateLimiter,
8
+ createDir,
9
+ descending,
10
+ generateRandomName,
11
+ generateSessionName,
12
+ list,
13
+ read,
14
+ schema,
15
+ update,
16
+ write,
17
+ writeRaw
18
+ } from "./cli-3knnkdps.js";
4
19
  import {
5
20
  parseTargetUrl
6
21
  } from "./cli-c8131c4q.js";
7
22
  import {
8
- CredentialManager,
9
- NotFoundError,
10
- create,
11
- createLogger,
23
+ ToolsetStateSchema,
24
+ init_toolset
25
+ } from "./cli-s1nckt4k.js";
26
+ import {
27
+ init_ai
28
+ } from "./cli-1yavz2pb.js";
29
+ import {
12
30
  generateObjectResponse,
13
31
  getApexTracer,
14
32
  hasToolCall,
15
- init_ai,
16
- init_credentials,
17
33
  init_dist,
18
- init_lazyLogger,
19
34
  init_observability,
20
- init_session,
21
- init_storage,
22
- init_structured,
23
- list,
24
- read,
25
35
  require_tslib,
26
- scopedLogger,
27
- streamResponse,
28
- write
29
- } from "./cli-5h1kv0v4.js";
36
+ streamResponse
37
+ } from "./cli-h825qzmd.js";
30
38
  import {
31
39
  ensureValidToken,
32
40
  getPensarApiUrl,
33
41
  init_auth,
34
42
  init_constants,
35
43
  signGatewayRequest
36
- } from "./cli-78s9w64j.js";
44
+ } from "./cli-948dk60p.js";
37
45
  import {
38
46
  _enum,
39
47
  _null,
@@ -59,12 +67,17 @@ import {
59
67
  string,
60
68
  tool,
61
69
  union,
62
- unknown
70
+ unknown,
71
+ zod_default
63
72
  } from "./cli-e6rgwtpb.js";
64
73
  import {
65
74
  config,
66
75
  init_config
67
- } from "./cli-rtbry75t.js";
76
+ } from "./cli-h6nw89zf.js";
77
+ import {
78
+ getCurrentVersion,
79
+ init_installation
80
+ } from "./cli-a20jcpmp.js";
68
81
  import {
69
82
  __commonJS,
70
83
  __require,
@@ -1094,52 +1107,52 @@ var require_util = __commonJS((exports) => {
1094
1107
  return hash;
1095
1108
  }
1096
1109
  exports.toHash = toHash;
1097
- function alwaysValidSchema(it, schema) {
1098
- if (typeof schema == "boolean")
1099
- return schema;
1100
- if (Object.keys(schema).length === 0)
1110
+ function alwaysValidSchema(it, schema2) {
1111
+ if (typeof schema2 == "boolean")
1112
+ return schema2;
1113
+ if (Object.keys(schema2).length === 0)
1101
1114
  return true;
1102
- checkUnknownRules(it, schema);
1103
- return !schemaHasRules(schema, it.self.RULES.all);
1115
+ checkUnknownRules(it, schema2);
1116
+ return !schemaHasRules(schema2, it.self.RULES.all);
1104
1117
  }
1105
1118
  exports.alwaysValidSchema = alwaysValidSchema;
1106
- function checkUnknownRules(it, schema = it.schema) {
1119
+ function checkUnknownRules(it, schema2 = it.schema) {
1107
1120
  const { opts, self: self2 } = it;
1108
1121
  if (!opts.strictSchema)
1109
1122
  return;
1110
- if (typeof schema === "boolean")
1123
+ if (typeof schema2 === "boolean")
1111
1124
  return;
1112
1125
  const rules2 = self2.RULES.keywords;
1113
- for (const key in schema) {
1126
+ for (const key in schema2) {
1114
1127
  if (!rules2[key])
1115
1128
  checkStrictMode(it, `unknown keyword: "${key}"`);
1116
1129
  }
1117
1130
  }
1118
1131
  exports.checkUnknownRules = checkUnknownRules;
1119
- function schemaHasRules(schema, rules2) {
1120
- if (typeof schema == "boolean")
1121
- return !schema;
1122
- for (const key in schema)
1132
+ function schemaHasRules(schema2, rules2) {
1133
+ if (typeof schema2 == "boolean")
1134
+ return !schema2;
1135
+ for (const key in schema2)
1123
1136
  if (rules2[key])
1124
1137
  return true;
1125
1138
  return false;
1126
1139
  }
1127
1140
  exports.schemaHasRules = schemaHasRules;
1128
- function schemaHasRulesButRef(schema, RULES) {
1129
- if (typeof schema == "boolean")
1130
- return !schema;
1131
- for (const key in schema)
1141
+ function schemaHasRulesButRef(schema2, RULES) {
1142
+ if (typeof schema2 == "boolean")
1143
+ return !schema2;
1144
+ for (const key in schema2)
1132
1145
  if (key !== "$ref" && RULES.all[key])
1133
1146
  return true;
1134
1147
  return false;
1135
1148
  }
1136
1149
  exports.schemaHasRulesButRef = schemaHasRulesButRef;
1137
- function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword, $data) {
1150
+ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema2, keyword, $data) {
1138
1151
  if (!$data) {
1139
- if (typeof schema == "number" || typeof schema == "boolean")
1140
- return schema;
1141
- if (typeof schema == "string")
1142
- return (0, codegen_1._)`${schema}`;
1152
+ if (typeof schema2 == "number" || typeof schema2 == "boolean")
1153
+ return schema2;
1154
+ if (typeof schema2 == "string")
1155
+ return (0, codegen_1._)`${schema2}`;
1143
1156
  }
1144
1157
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
1145
1158
  }
@@ -1399,10 +1412,10 @@ var require_boolSchema = __commonJS((exports) => {
1399
1412
  message: "boolean schema is false"
1400
1413
  };
1401
1414
  function topBoolOrEmptySchema(it) {
1402
- const { gen, schema, validateName } = it;
1403
- if (schema === false) {
1415
+ const { gen, schema: schema2, validateName } = it;
1416
+ if (schema2 === false) {
1404
1417
  falseSchemaError(it, false);
1405
- } else if (typeof schema == "object" && schema.$async === true) {
1418
+ } else if (typeof schema2 == "object" && schema2.$async === true) {
1406
1419
  gen.return(names_1.default.data);
1407
1420
  } else {
1408
1421
  gen.assign((0, codegen_1._)`${validateName}.errors`, null);
@@ -1411,8 +1424,8 @@ var require_boolSchema = __commonJS((exports) => {
1411
1424
  }
1412
1425
  exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
1413
1426
  function boolOrEmptySchema(it, valid) {
1414
- const { gen, schema } = it;
1415
- if (schema === false) {
1427
+ const { gen, schema: schema2 } = it;
1428
+ if (schema2 === false) {
1416
1429
  gen.var(valid, false);
1417
1430
  falseSchemaError(it);
1418
1431
  } else {
@@ -1468,18 +1481,18 @@ var require_rules = __commonJS((exports) => {
1468
1481
  var require_applicability = __commonJS((exports) => {
1469
1482
  Object.defineProperty(exports, "__esModule", { value: true });
1470
1483
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = undefined;
1471
- function schemaHasRulesForType({ schema, self: self2 }, type) {
1484
+ function schemaHasRulesForType({ schema: schema2, self: self2 }, type) {
1472
1485
  const group = self2.RULES.types[type];
1473
- return group && group !== true && shouldUseGroup(schema, group);
1486
+ return group && group !== true && shouldUseGroup(schema2, group);
1474
1487
  }
1475
1488
  exports.schemaHasRulesForType = schemaHasRulesForType;
1476
- function shouldUseGroup(schema, group) {
1477
- return group.rules.some((rule) => shouldUseRule(schema, rule));
1489
+ function shouldUseGroup(schema2, group) {
1490
+ return group.rules.some((rule) => shouldUseRule(schema2, rule));
1478
1491
  }
1479
1492
  exports.shouldUseGroup = shouldUseGroup;
1480
- function shouldUseRule(schema, rule) {
1493
+ function shouldUseRule(schema2, rule) {
1481
1494
  var _a;
1482
- return schema[rule.keyword] !== undefined || ((_a = rule.definition.implements) === null || _a === undefined ? undefined : _a.some((kwd) => schema[kwd] !== undefined));
1495
+ return schema2[rule.keyword] !== undefined || ((_a = rule.definition.implements) === null || _a === undefined ? undefined : _a.some((kwd) => schema2[kwd] !== undefined));
1483
1496
  }
1484
1497
  exports.shouldUseRule = shouldUseRule;
1485
1498
  });
@@ -1498,17 +1511,17 @@ var require_dataType = __commonJS((exports) => {
1498
1511
  DataType2[DataType2["Correct"] = 0] = "Correct";
1499
1512
  DataType2[DataType2["Wrong"] = 1] = "Wrong";
1500
1513
  })(DataType || (exports.DataType = DataType = {}));
1501
- function getSchemaTypes(schema) {
1502
- const types = getJSONTypes(schema.type);
1514
+ function getSchemaTypes(schema2) {
1515
+ const types = getJSONTypes(schema2.type);
1503
1516
  const hasNull = types.includes("null");
1504
1517
  if (hasNull) {
1505
- if (schema.nullable === false)
1518
+ if (schema2.nullable === false)
1506
1519
  throw new Error("type: null contradicts nullable: false");
1507
1520
  } else {
1508
- if (!types.length && schema.nullable !== undefined) {
1521
+ if (!types.length && schema2.nullable !== undefined) {
1509
1522
  throw new Error('"nullable" cannot be used without "type"');
1510
1523
  }
1511
- if (schema.nullable === true)
1524
+ if (schema2.nullable === true)
1512
1525
  types.push("null");
1513
1526
  }
1514
1527
  return types;
@@ -1640,8 +1653,8 @@ var require_dataType = __commonJS((exports) => {
1640
1653
  }
1641
1654
  exports.checkDataTypes = checkDataTypes;
1642
1655
  var typeError = {
1643
- message: ({ schema }) => `must be ${schema}`,
1644
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1._)`{type: ${schema}}` : (0, codegen_1._)`{type: ${schemaValue}}`
1656
+ message: ({ schema: schema2 }) => `must be ${schema2}`,
1657
+ params: ({ schema: schema2, schemaValue }) => typeof schema2 == "string" ? (0, codegen_1._)`{type: ${schema2}}` : (0, codegen_1._)`{type: ${schemaValue}}`
1645
1658
  };
1646
1659
  function reportTypeError(it) {
1647
1660
  const cxt = getTypeErrorContext(it);
@@ -1649,16 +1662,16 @@ var require_dataType = __commonJS((exports) => {
1649
1662
  }
1650
1663
  exports.reportTypeError = reportTypeError;
1651
1664
  function getTypeErrorContext(it) {
1652
- const { gen, data, schema } = it;
1653
- const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type");
1665
+ const { gen, data, schema: schema2 } = it;
1666
+ const schemaCode = (0, util_1.schemaRefOrVal)(it, schema2, "type");
1654
1667
  return {
1655
1668
  gen,
1656
1669
  keyword: "type",
1657
1670
  data,
1658
- schema: schema.type,
1671
+ schema: schema2.type,
1659
1672
  schemaCode,
1660
1673
  schemaValue: schemaCode,
1661
- parentSchema: schema,
1674
+ parentSchema: schema2,
1662
1675
  params: {},
1663
1676
  it
1664
1677
  };
@@ -1804,15 +1817,15 @@ var require_code2 = __commonJS((exports) => {
1804
1817
  }
1805
1818
  exports.validateArray = validateArray;
1806
1819
  function validateUnion(cxt) {
1807
- const { gen, schema, keyword, it } = cxt;
1808
- if (!Array.isArray(schema))
1820
+ const { gen, schema: schema2, keyword, it } = cxt;
1821
+ if (!Array.isArray(schema2))
1809
1822
  throw new Error("ajv implementation error");
1810
- const alwaysValid = schema.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
1823
+ const alwaysValid = schema2.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
1811
1824
  if (alwaysValid && !it.opts.unevaluated)
1812
1825
  return;
1813
1826
  const valid = gen.let("valid", false);
1814
1827
  const schValid = gen.name("_valid");
1815
- gen.block(() => schema.forEach((_sch, i) => {
1828
+ gen.block(() => schema2.forEach((_sch, i) => {
1816
1829
  const schCxt = cxt.subschema({
1817
1830
  keyword,
1818
1831
  schemaProp: i,
@@ -1837,8 +1850,8 @@ var require_keyword = __commonJS((exports) => {
1837
1850
  var code_1 = require_code2();
1838
1851
  var errors_1 = require_errors();
1839
1852
  function macroKeywordCode(cxt, def) {
1840
- const { gen, keyword, schema, parentSchema, it } = cxt;
1841
- const macroSchema = def.macro.call(it.self, schema, parentSchema, it);
1853
+ const { gen, keyword, schema: schema2, parentSchema, it } = cxt;
1854
+ const macroSchema = def.macro.call(it.self, schema2, parentSchema, it);
1842
1855
  const schemaRef = useKeyword(gen, keyword, macroSchema);
1843
1856
  if (it.opts.validateSchema !== false)
1844
1857
  it.self.validateSchema(macroSchema, true);
@@ -1855,9 +1868,9 @@ var require_keyword = __commonJS((exports) => {
1855
1868
  exports.macroKeywordCode = macroKeywordCode;
1856
1869
  function funcKeywordCode(cxt, def) {
1857
1870
  var _a;
1858
- const { gen, keyword, schema, parentSchema, $data, it } = cxt;
1871
+ const { gen, keyword, schema: schema2, parentSchema, $data, it } = cxt;
1859
1872
  checkAsyncKeyword(it, def);
1860
- const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
1873
+ const validate = !$data && def.compile ? def.compile.call(it.self, schema2, parentSchema, it) : def.validate;
1861
1874
  const validateRef = useKeyword(gen, keyword, validate);
1862
1875
  const valid = gen.let("valid");
1863
1876
  cxt.block$data(valid, validateKeyword);
@@ -1917,20 +1930,20 @@ var require_keyword = __commonJS((exports) => {
1917
1930
  throw new Error(`keyword "${keyword}" failed to compile`);
1918
1931
  return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1.stringify)(result) });
1919
1932
  }
1920
- function validSchemaType(schema, schemaType, allowUndefined = false) {
1921
- return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
1933
+ function validSchemaType(schema2, schemaType, allowUndefined = false) {
1934
+ return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema2) : st === "object" ? schema2 && typeof schema2 == "object" && !Array.isArray(schema2) : typeof schema2 == st || allowUndefined && typeof schema2 == "undefined");
1922
1935
  }
1923
1936
  exports.validSchemaType = validSchemaType;
1924
- function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def, keyword) {
1937
+ function validateKeywordUsage({ schema: schema2, opts, self: self2, errSchemaPath }, def, keyword) {
1925
1938
  if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) {
1926
1939
  throw new Error("ajv implementation error");
1927
1940
  }
1928
1941
  const deps = def.dependencies;
1929
- if (deps === null || deps === undefined ? undefined : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
1942
+ if (deps === null || deps === undefined ? undefined : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema2, kwd))) {
1930
1943
  throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
1931
1944
  }
1932
1945
  if (def.validateSchema) {
1933
- const valid = def.validateSchema(schema[keyword]);
1946
+ const valid = def.validateSchema(schema2[keyword]);
1934
1947
  if (!valid) {
1935
1948
  const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def.validateSchema.errors);
1936
1949
  if (opts.validateSchema === "log")
@@ -1949,8 +1962,8 @@ var require_subschema = __commonJS((exports) => {
1949
1962
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
1950
1963
  var codegen_1 = require_codegen();
1951
1964
  var util_1 = require_util();
1952
- function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
1953
- if (keyword !== undefined && schema !== undefined) {
1965
+ function getSubschema(it, { keyword, schemaProp, schema: schema2, schemaPath, errSchemaPath, topSchemaRef }) {
1966
+ if (keyword !== undefined && schema2 !== undefined) {
1954
1967
  throw new Error('both "keyword" and "schema" passed, only one allowed');
1955
1968
  }
1956
1969
  if (keyword !== undefined) {
@@ -1965,12 +1978,12 @@ var require_subschema = __commonJS((exports) => {
1965
1978
  errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1.escapeFragment)(schemaProp)}`
1966
1979
  };
1967
1980
  }
1968
- if (schema !== undefined) {
1981
+ if (schema2 !== undefined) {
1969
1982
  if (schemaPath === undefined || errSchemaPath === undefined || topSchemaRef === undefined) {
1970
1983
  throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
1971
1984
  }
1972
1985
  return {
1973
- schema,
1986
+ schema: schema2,
1974
1987
  schemaPath,
1975
1988
  topSchemaRef,
1976
1989
  errSchemaPath
@@ -2067,7 +2080,7 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
2067
2080
 
2068
2081
  // node_modules/json-schema-traverse/index.js
2069
2082
  var require_json_schema_traverse = __commonJS((exports, module) => {
2070
- var traverse = module.exports = function(schema, opts, cb) {
2083
+ var traverse = module.exports = function(schema2, opts, cb) {
2071
2084
  if (typeof opts == "function") {
2072
2085
  cb = opts;
2073
2086
  opts = {};
@@ -2075,7 +2088,7 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
2075
2088
  cb = opts.cb || cb;
2076
2089
  var pre = typeof cb == "function" ? cb : cb.pre || function() {};
2077
2090
  var post = cb.post || function() {};
2078
- _traverse(opts, pre, post, schema, "", schema);
2091
+ _traverse(opts, pre, post, schema2, "", schema2);
2079
2092
  };
2080
2093
  traverse.keywords = {
2081
2094
  additionalItems: true,
@@ -2121,26 +2134,26 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
2121
2134
  maxProperties: true,
2122
2135
  minProperties: true
2123
2136
  };
2124
- function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
2125
- if (schema && typeof schema == "object" && !Array.isArray(schema)) {
2126
- pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
2127
- for (var key in schema) {
2128
- var sch = schema[key];
2137
+ function _traverse(opts, pre, post, schema2, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
2138
+ if (schema2 && typeof schema2 == "object" && !Array.isArray(schema2)) {
2139
+ pre(schema2, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
2140
+ for (var key in schema2) {
2141
+ var sch = schema2[key];
2129
2142
  if (Array.isArray(sch)) {
2130
2143
  if (key in traverse.arrayKeywords) {
2131
2144
  for (var i = 0;i < sch.length; i++)
2132
- _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key + "/" + i, rootSchema, jsonPtr, key, schema, i);
2145
+ _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key + "/" + i, rootSchema, jsonPtr, key, schema2, i);
2133
2146
  }
2134
2147
  } else if (key in traverse.propsKeywords) {
2135
2148
  if (sch && typeof sch == "object") {
2136
2149
  for (var prop in sch)
2137
- _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
2150
+ _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema2, prop);
2138
2151
  }
2139
2152
  } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
2140
- _traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
2153
+ _traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema2);
2141
2154
  }
2142
2155
  }
2143
- post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
2156
+ post(schema2, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
2144
2157
  }
2145
2158
  }
2146
2159
  function escapeJsonPtr(str) {
@@ -2173,14 +2186,14 @@ var require_resolve = __commonJS((exports) => {
2173
2186
  "enum",
2174
2187
  "const"
2175
2188
  ]);
2176
- function inlineRef(schema, limit = true) {
2177
- if (typeof schema == "boolean")
2189
+ function inlineRef(schema2, limit = true) {
2190
+ if (typeof schema2 == "boolean")
2178
2191
  return true;
2179
2192
  if (limit === true)
2180
- return !hasRef(schema);
2193
+ return !hasRef(schema2);
2181
2194
  if (!limit)
2182
2195
  return false;
2183
- return countKeys(schema) <= limit;
2196
+ return countKeys(schema2) <= limit;
2184
2197
  }
2185
2198
  exports.inlineRef = inlineRef;
2186
2199
  var REF_KEYWORDS = new Set([
@@ -2190,11 +2203,11 @@ var require_resolve = __commonJS((exports) => {
2190
2203
  "$dynamicRef",
2191
2204
  "$dynamicAnchor"
2192
2205
  ]);
2193
- function hasRef(schema) {
2194
- for (const key in schema) {
2206
+ function hasRef(schema2) {
2207
+ for (const key in schema2) {
2195
2208
  if (REF_KEYWORDS.has(key))
2196
2209
  return true;
2197
- const sch = schema[key];
2210
+ const sch = schema2[key];
2198
2211
  if (Array.isArray(sch) && sch.some(hasRef))
2199
2212
  return true;
2200
2213
  if (typeof sch == "object" && hasRef(sch))
@@ -2202,16 +2215,16 @@ var require_resolve = __commonJS((exports) => {
2202
2215
  }
2203
2216
  return false;
2204
2217
  }
2205
- function countKeys(schema) {
2218
+ function countKeys(schema2) {
2206
2219
  let count = 0;
2207
- for (const key in schema) {
2220
+ for (const key in schema2) {
2208
2221
  if (key === "$ref")
2209
2222
  return Infinity;
2210
2223
  count++;
2211
2224
  if (SIMPLE_INLINED.has(key))
2212
2225
  continue;
2213
- if (typeof schema[key] == "object") {
2214
- (0, util_1.eachItem)(schema[key], (sch) => count += countKeys(sch));
2226
+ if (typeof schema2[key] == "object") {
2227
+ (0, util_1.eachItem)(schema2[key], (sch) => count += countKeys(sch));
2215
2228
  }
2216
2229
  if (count === Infinity)
2217
2230
  return Infinity;
@@ -2241,16 +2254,16 @@ var require_resolve = __commonJS((exports) => {
2241
2254
  }
2242
2255
  exports.resolveUrl = resolveUrl;
2243
2256
  var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
2244
- function getSchemaRefs(schema, baseId) {
2245
- if (typeof schema == "boolean")
2257
+ function getSchemaRefs(schema2, baseId) {
2258
+ if (typeof schema2 == "boolean")
2246
2259
  return {};
2247
2260
  const { schemaId, uriResolver } = this.opts;
2248
- const schId = normalizeId(schema[schemaId] || baseId);
2261
+ const schId = normalizeId(schema2[schemaId] || baseId);
2249
2262
  const baseIds = { "": schId };
2250
2263
  const pathPrefix = getFullPath(uriResolver, schId, false);
2251
2264
  const localRefs = {};
2252
2265
  const schemaRefs = new Set;
2253
- traverse(schema, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => {
2266
+ traverse(schema2, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => {
2254
2267
  if (parentJsonPtr === undefined)
2255
2268
  return;
2256
2269
  const fullPath = pathPrefix + jsonPtr;
@@ -2328,15 +2341,15 @@ var require_validate = __commonJS((exports) => {
2328
2341
  validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
2329
2342
  }
2330
2343
  exports.validateFunctionCode = validateFunctionCode;
2331
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
2344
+ function validateFunction({ gen, validateName, schema: schema2, schemaEnv, opts }, body) {
2332
2345
  if (opts.code.es5) {
2333
2346
  gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
2334
- gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
2347
+ gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema2, opts)}`);
2335
2348
  destructureValCxtES5(gen, opts);
2336
2349
  gen.code(body);
2337
2350
  });
2338
2351
  } else {
2339
- gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
2352
+ gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema2, opts)).code(body));
2340
2353
  }
2341
2354
  }
2342
2355
  function destructureValCxt(opts) {
@@ -2360,9 +2373,9 @@ var require_validate = __commonJS((exports) => {
2360
2373
  });
2361
2374
  }
2362
2375
  function topSchemaObjCode(it) {
2363
- const { schema, opts, gen } = it;
2376
+ const { schema: schema2, opts, gen } = it;
2364
2377
  validateFunction(it, () => {
2365
- if (opts.$comment && schema.$comment)
2378
+ if (opts.$comment && schema2.$comment)
2366
2379
  commentKeyword(it);
2367
2380
  checkNoDefault(it);
2368
2381
  gen.let(names_1.default.vErrors, null);
@@ -2380,8 +2393,8 @@ var require_validate = __commonJS((exports) => {
2380
2393
  gen.if((0, codegen_1._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it.evaluated}.props`, (0, codegen_1._)`undefined`));
2381
2394
  gen.if((0, codegen_1._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it.evaluated}.items`, (0, codegen_1._)`undefined`));
2382
2395
  }
2383
- function funcSourceUrl(schema, opts) {
2384
- const schId = typeof schema == "object" && schema[opts.schemaId];
2396
+ function funcSourceUrl(schema2, opts) {
2397
+ const schId = typeof schema2 == "object" && schema2[opts.schemaId];
2385
2398
  return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
2386
2399
  }
2387
2400
  function subschemaCode(it, valid) {
@@ -2394,10 +2407,10 @@ var require_validate = __commonJS((exports) => {
2394
2407
  }
2395
2408
  (0, boolSchema_1.boolOrEmptySchema)(it, valid);
2396
2409
  }
2397
- function schemaCxtHasRules({ schema, self: self2 }) {
2398
- if (typeof schema == "boolean")
2399
- return !schema;
2400
- for (const key in schema)
2410
+ function schemaCxtHasRules({ schema: schema2, self: self2 }) {
2411
+ if (typeof schema2 == "boolean")
2412
+ return !schema2;
2413
+ for (const key in schema2)
2401
2414
  if (self2.RULES.all[key])
2402
2415
  return true;
2403
2416
  return false;
@@ -2406,8 +2419,8 @@ var require_validate = __commonJS((exports) => {
2406
2419
  return typeof it.schema != "boolean";
2407
2420
  }
2408
2421
  function subSchemaObjCode(it, valid) {
2409
- const { schema, gen, opts } = it;
2410
- if (opts.$comment && schema.$comment)
2422
+ const { schema: schema2, gen, opts } = it;
2423
+ if (opts.$comment && schema2.$comment)
2411
2424
  commentKeyword(it);
2412
2425
  updateContext(it);
2413
2426
  checkAsyncSchema(it);
@@ -2427,14 +2440,14 @@ var require_validate = __commonJS((exports) => {
2427
2440
  schemaKeywords(it, types, !checkedTypes, errsCount);
2428
2441
  }
2429
2442
  function checkRefsAndKeywords(it) {
2430
- const { schema, errSchemaPath, opts, self: self2 } = it;
2431
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self2.RULES)) {
2443
+ const { schema: schema2, errSchemaPath, opts, self: self2 } = it;
2444
+ if (schema2.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema2, self2.RULES)) {
2432
2445
  self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
2433
2446
  }
2434
2447
  }
2435
2448
  function checkNoDefault(it) {
2436
- const { schema, opts } = it;
2437
- if (schema.default !== undefined && opts.useDefaults && opts.strictSchema) {
2449
+ const { schema: schema2, opts } = it;
2450
+ if (schema2.default !== undefined && opts.useDefaults && opts.strictSchema) {
2438
2451
  (0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
2439
2452
  }
2440
2453
  }
@@ -2447,8 +2460,8 @@ var require_validate = __commonJS((exports) => {
2447
2460
  if (it.schema.$async && !it.schemaEnv.$async)
2448
2461
  throw new Error("async schema in sync schema");
2449
2462
  }
2450
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
2451
- const msg = schema.$comment;
2463
+ function commentKeyword({ gen, schemaEnv, schema: schema2, errSchemaPath, opts }) {
2464
+ const msg = schema2.$comment;
2452
2465
  if (opts.$comment === true) {
2453
2466
  gen.code((0, codegen_1._)`${names_1.default.self}.logger.log(${msg})`);
2454
2467
  } else if (typeof opts.$comment == "function") {
@@ -2475,9 +2488,9 @@ var require_validate = __commonJS((exports) => {
2475
2488
  gen.assign((0, codegen_1._)`${evaluated}.items`, items);
2476
2489
  }
2477
2490
  function schemaKeywords(it, types, typeErrors, errsCount) {
2478
- const { gen, schema, data, allErrors, opts, self: self2 } = it;
2491
+ const { gen, schema: schema2, data, allErrors, opts, self: self2 } = it;
2479
2492
  const { RULES } = self2;
2480
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
2493
+ if (schema2.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema2, RULES))) {
2481
2494
  gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
2482
2495
  return;
2483
2496
  }
@@ -2489,7 +2502,7 @@ var require_validate = __commonJS((exports) => {
2489
2502
  groupKeywords(RULES.post);
2490
2503
  });
2491
2504
  function groupKeywords(group) {
2492
- if (!(0, applicability_1.shouldUseGroup)(schema, group))
2505
+ if (!(0, applicability_1.shouldUseGroup)(schema2, group))
2493
2506
  return;
2494
2507
  if (group.type) {
2495
2508
  gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
@@ -2507,12 +2520,12 @@ var require_validate = __commonJS((exports) => {
2507
2520
  }
2508
2521
  }
2509
2522
  function iterateKeywords(it, group) {
2510
- const { gen, schema, opts: { useDefaults } } = it;
2523
+ const { gen, schema: schema2, opts: { useDefaults } } = it;
2511
2524
  if (useDefaults)
2512
2525
  (0, defaults_1.assignDefaults)(it, group.type);
2513
2526
  gen.block(() => {
2514
2527
  for (const rule of group.rules) {
2515
- if ((0, applicability_1.shouldUseRule)(schema, rule)) {
2528
+ if ((0, applicability_1.shouldUseRule)(schema2, rule)) {
2516
2529
  keywordCode(it, rule.keyword, rule.definition, group.type);
2517
2530
  }
2518
2531
  }
@@ -2851,17 +2864,17 @@ var require_compile = __commonJS((exports) => {
2851
2864
  var _a;
2852
2865
  this.refs = {};
2853
2866
  this.dynamicAnchors = {};
2854
- let schema;
2867
+ let schema2;
2855
2868
  if (typeof env.schema == "object")
2856
- schema = env.schema;
2869
+ schema2 = env.schema;
2857
2870
  this.schema = env.schema;
2858
2871
  this.schemaId = env.schemaId;
2859
2872
  this.root = env.root || this;
2860
- this.baseId = (_a = env.baseId) !== null && _a !== undefined ? _a : (0, resolve_1.normalizeId)(schema === null || schema === undefined ? undefined : schema[env.schemaId || "$id"]);
2873
+ this.baseId = (_a = env.baseId) !== null && _a !== undefined ? _a : (0, resolve_1.normalizeId)(schema2 === null || schema2 === undefined ? undefined : schema2[env.schemaId || "$id"]);
2861
2874
  this.schemaPath = env.schemaPath;
2862
2875
  this.localRefs = env.localRefs;
2863
2876
  this.meta = env.meta;
2864
- this.$async = schema === null || schema === undefined ? undefined : schema.$async;
2877
+ this.$async = schema2 === null || schema2 === undefined ? undefined : schema2.$async;
2865
2878
  this.refs = {};
2866
2879
  }
2867
2880
  }
@@ -2959,10 +2972,10 @@ var require_compile = __commonJS((exports) => {
2959
2972
  return schOrFunc;
2960
2973
  let _sch = resolve.call(this, root, ref);
2961
2974
  if (_sch === undefined) {
2962
- const schema = (_a = root.localRefs) === null || _a === undefined ? undefined : _a[ref];
2975
+ const schema2 = (_a = root.localRefs) === null || _a === undefined ? undefined : _a[ref];
2963
2976
  const { schemaId } = this.opts;
2964
- if (schema)
2965
- _sch = new SchemaEnv({ schema, schemaId, root, baseId });
2977
+ if (schema2)
2978
+ _sch = new SchemaEnv({ schema: schema2, schemaId, root, baseId });
2966
2979
  }
2967
2980
  if (_sch === undefined)
2968
2981
  return;
@@ -3010,12 +3023,12 @@ var require_compile = __commonJS((exports) => {
3010
3023
  if (!schOrRef.validate)
3011
3024
  compileSchema.call(this, schOrRef);
3012
3025
  if (id === (0, resolve_1.normalizeId)(ref)) {
3013
- const { schema } = schOrRef;
3026
+ const { schema: schema2 } = schOrRef;
3014
3027
  const { schemaId } = this.opts;
3015
- const schId = schema[schemaId];
3028
+ const schId = schema2[schemaId];
3016
3029
  if (schId)
3017
3030
  baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
3018
- return new SchemaEnv({ schema, schemaId, root, baseId });
3031
+ return new SchemaEnv({ schema: schema2, schemaId, root, baseId });
3019
3032
  }
3020
3033
  return getJsonPointer.call(this, p, schOrRef);
3021
3034
  }
@@ -3027,29 +3040,29 @@ var require_compile = __commonJS((exports) => {
3027
3040
  "dependencies",
3028
3041
  "definitions"
3029
3042
  ]);
3030
- function getJsonPointer(parsedRef, { baseId, schema, root }) {
3043
+ function getJsonPointer(parsedRef, { baseId, schema: schema2, root }) {
3031
3044
  var _a;
3032
3045
  if (((_a = parsedRef.fragment) === null || _a === undefined ? undefined : _a[0]) !== "/")
3033
3046
  return;
3034
3047
  for (const part of parsedRef.fragment.slice(1).split("/")) {
3035
- if (typeof schema === "boolean")
3048
+ if (typeof schema2 === "boolean")
3036
3049
  return;
3037
- const partSchema = schema[(0, util_1.unescapeFragment)(part)];
3050
+ const partSchema = schema2[(0, util_1.unescapeFragment)(part)];
3038
3051
  if (partSchema === undefined)
3039
3052
  return;
3040
- schema = partSchema;
3041
- const schId = typeof schema === "object" && schema[this.opts.schemaId];
3053
+ schema2 = partSchema;
3054
+ const schId = typeof schema2 === "object" && schema2[this.opts.schemaId];
3042
3055
  if (!PREVENT_SCOPE_CHANGE.has(part) && schId) {
3043
3056
  baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
3044
3057
  }
3045
3058
  }
3046
3059
  let env;
3047
- if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
3048
- const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
3060
+ if (typeof schema2 != "boolean" && schema2.$ref && !(0, util_1.schemaHasRulesButRef)(schema2, this.RULES)) {
3061
+ const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema2.$ref);
3049
3062
  env = resolveSchema.call(this, root, $ref);
3050
3063
  }
3051
3064
  const { schemaId } = this.opts;
3052
- env = env || new SchemaEnv({ schema, schemaId, root, baseId });
3065
+ env = env || new SchemaEnv({ schema: schema2, schemaId, root, baseId });
3053
3066
  if (env.schema !== env.root.schema)
3054
3067
  return env;
3055
3068
  return;
@@ -3929,16 +3942,16 @@ var require_core = __commonJS((exports) => {
3929
3942
  this.errors = v.errors;
3930
3943
  return valid;
3931
3944
  }
3932
- compile(schema, _meta) {
3933
- const sch = this._addSchema(schema, _meta);
3945
+ compile(schema2, _meta) {
3946
+ const sch = this._addSchema(schema2, _meta);
3934
3947
  return sch.validate || this._compileSchemaEnv(sch);
3935
3948
  }
3936
- compileAsync(schema, meta) {
3949
+ compileAsync(schema2, meta) {
3937
3950
  if (typeof this.opts.loadSchema != "function") {
3938
3951
  throw new Error("options.loadSchema should be a function");
3939
3952
  }
3940
3953
  const { loadSchema } = this.opts;
3941
- return runCompileAsync.call(this, schema, meta);
3954
+ return runCompileAsync.call(this, schema2, meta);
3942
3955
  async function runCompileAsync(_schema, _meta) {
3943
3956
  await loadMetaSchema.call(this, _schema.$schema);
3944
3957
  const sch = this._addSchema(_schema, _meta);
@@ -3983,34 +3996,34 @@ var require_core = __commonJS((exports) => {
3983
3996
  }
3984
3997
  }
3985
3998
  }
3986
- addSchema(schema, key, _meta, _validateSchema = this.opts.validateSchema) {
3987
- if (Array.isArray(schema)) {
3988
- for (const sch of schema)
3999
+ addSchema(schema2, key, _meta, _validateSchema = this.opts.validateSchema) {
4000
+ if (Array.isArray(schema2)) {
4001
+ for (const sch of schema2)
3989
4002
  this.addSchema(sch, undefined, _meta, _validateSchema);
3990
4003
  return this;
3991
4004
  }
3992
4005
  let id;
3993
- if (typeof schema === "object") {
4006
+ if (typeof schema2 === "object") {
3994
4007
  const { schemaId } = this.opts;
3995
- id = schema[schemaId];
4008
+ id = schema2[schemaId];
3996
4009
  if (id !== undefined && typeof id != "string") {
3997
4010
  throw new Error(`schema ${schemaId} must be string`);
3998
4011
  }
3999
4012
  }
4000
4013
  key = (0, resolve_1.normalizeId)(key || id);
4001
4014
  this._checkUnique(key);
4002
- this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
4015
+ this.schemas[key] = this._addSchema(schema2, _meta, key, _validateSchema, true);
4003
4016
  return this;
4004
4017
  }
4005
- addMetaSchema(schema, key, _validateSchema = this.opts.validateSchema) {
4006
- this.addSchema(schema, key, true, _validateSchema);
4018
+ addMetaSchema(schema2, key, _validateSchema = this.opts.validateSchema) {
4019
+ this.addSchema(schema2, key, true, _validateSchema);
4007
4020
  return this;
4008
4021
  }
4009
- validateSchema(schema, throwOrLogError) {
4010
- if (typeof schema == "boolean")
4022
+ validateSchema(schema2, throwOrLogError) {
4023
+ if (typeof schema2 == "boolean")
4011
4024
  return true;
4012
4025
  let $schema;
4013
- $schema = schema.$schema;
4026
+ $schema = schema2.$schema;
4014
4027
  if ($schema !== undefined && typeof $schema != "string") {
4015
4028
  throw new Error("$schema must be a string");
4016
4029
  }
@@ -4020,7 +4033,7 @@ var require_core = __commonJS((exports) => {
4020
4033
  this.errors = null;
4021
4034
  return true;
4022
4035
  }
4023
- const valid = this.validate($schema, schema);
4036
+ const valid = this.validate($schema, schema2);
4024
4037
  if (!valid && throwOrLogError) {
4025
4038
  const message = "schema is invalid: " + this.errorsText();
4026
4039
  if (this.opts.validateSchema === "log")
@@ -4154,9 +4167,9 @@ var require_core = __commonJS((exports) => {
4154
4167
  if (typeof rule != "object")
4155
4168
  continue;
4156
4169
  const { $data } = rule.definition;
4157
- const schema = keywords[key];
4158
- if ($data && schema)
4159
- keywords[key] = schemaOrData(schema);
4170
+ const schema2 = keywords[key];
4171
+ if ($data && schema2)
4172
+ keywords[key] = schemaOrData(schema2);
4160
4173
  }
4161
4174
  }
4162
4175
  return metaSchema;
@@ -4174,23 +4187,23 @@ var require_core = __commonJS((exports) => {
4174
4187
  }
4175
4188
  }
4176
4189
  }
4177
- _addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
4190
+ _addSchema(schema2, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
4178
4191
  let id;
4179
4192
  const { schemaId } = this.opts;
4180
- if (typeof schema == "object") {
4181
- id = schema[schemaId];
4193
+ if (typeof schema2 == "object") {
4194
+ id = schema2[schemaId];
4182
4195
  } else {
4183
4196
  if (this.opts.jtd)
4184
4197
  throw new Error("schema must be object");
4185
- else if (typeof schema != "boolean")
4198
+ else if (typeof schema2 != "boolean")
4186
4199
  throw new Error("schema must be object or boolean");
4187
4200
  }
4188
- let sch = this._cache.get(schema);
4201
+ let sch = this._cache.get(schema2);
4189
4202
  if (sch !== undefined)
4190
4203
  return sch;
4191
4204
  baseId = (0, resolve_1.normalizeId)(id || baseId);
4192
- const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
4193
- sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs });
4205
+ const localRefs = resolve_1.getSchemaRefs.call(this, schema2, baseId);
4206
+ sch = new compile_1.SchemaEnv({ schema: schema2, schemaId, meta, baseId, localRefs });
4194
4207
  this._cache.set(sch.schema, sch);
4195
4208
  if (addSchema && !baseId.startsWith("#")) {
4196
4209
  if (baseId)
@@ -4198,7 +4211,7 @@ var require_core = __commonJS((exports) => {
4198
4211
  this.refs[baseId] = sch;
4199
4212
  }
4200
4213
  if (validateSchema)
4201
- this.validateSchema(schema, true);
4214
+ this.validateSchema(schema2, true);
4202
4215
  return sch;
4203
4216
  }
4204
4217
  _checkUnique(id) {
@@ -4349,8 +4362,8 @@ var require_core = __commonJS((exports) => {
4349
4362
  var $dataRef = {
4350
4363
  $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"
4351
4364
  };
4352
- function schemaOrData(schema) {
4353
- return { anyOf: [schema, $dataRef] };
4365
+ function schemaOrData(schema2) {
4366
+ return { anyOf: [schema2, $dataRef] };
4354
4367
  }
4355
4368
  });
4356
4369
 
@@ -4625,9 +4638,9 @@ var require_pattern = __commonJS((exports) => {
4625
4638
  $data: true,
4626
4639
  error,
4627
4640
  code(cxt) {
4628
- const { data, $data, schema, schemaCode, it } = cxt;
4641
+ const { data, $data, schema: schema2, schemaCode, it } = cxt;
4629
4642
  const u = it.opts.unicodeRegExp ? "u" : "";
4630
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
4643
+ const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema2);
4631
4644
  cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
4632
4645
  }
4633
4646
  };
@@ -4677,11 +4690,11 @@ var require_required = __commonJS((exports) => {
4677
4690
  $data: true,
4678
4691
  error,
4679
4692
  code(cxt) {
4680
- const { gen, schema, schemaCode, data, $data, it } = cxt;
4693
+ const { gen, schema: schema2, schemaCode, data, $data, it } = cxt;
4681
4694
  const { opts } = it;
4682
- if (!$data && schema.length === 0)
4695
+ if (!$data && schema2.length === 0)
4683
4696
  return;
4684
- const useLoop = schema.length >= opts.loopRequired;
4697
+ const useLoop = schema2.length >= opts.loopRequired;
4685
4698
  if (it.allErrors)
4686
4699
  allErrorsMode();
4687
4700
  else
@@ -4689,7 +4702,7 @@ var require_required = __commonJS((exports) => {
4689
4702
  if (opts.strictRequired) {
4690
4703
  const props = cxt.parentSchema.properties;
4691
4704
  const { definedProperties } = cxt.it;
4692
- for (const requiredKey of schema) {
4705
+ for (const requiredKey of schema2) {
4693
4706
  if ((props === null || props === undefined ? undefined : props[requiredKey]) === undefined && !definedProperties.has(requiredKey)) {
4694
4707
  const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
4695
4708
  const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`;
@@ -4701,7 +4714,7 @@ var require_required = __commonJS((exports) => {
4701
4714
  if (useLoop || $data) {
4702
4715
  cxt.block$data(codegen_1.nil, loopAllRequired);
4703
4716
  } else {
4704
- for (const prop of schema) {
4717
+ for (const prop of schema2) {
4705
4718
  (0, code_1.checkReportMissingProp)(cxt, prop);
4706
4719
  }
4707
4720
  }
@@ -4713,7 +4726,7 @@ var require_required = __commonJS((exports) => {
4713
4726
  cxt.block$data(valid, () => loopUntilMissing(missing, valid));
4714
4727
  cxt.ok(valid);
4715
4728
  } else {
4716
- gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
4729
+ gen.if((0, code_1.checkMissingProp)(cxt, schema2, missing));
4717
4730
  (0, code_1.reportMissingProp)(cxt, missing);
4718
4731
  gen.else();
4719
4732
  }
@@ -4791,8 +4804,8 @@ var require_uniqueItems = __commonJS((exports) => {
4791
4804
  $data: true,
4792
4805
  error,
4793
4806
  code(cxt) {
4794
- const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
4795
- if (!$data && !schema)
4807
+ const { gen, data, $data, schema: schema2, parentSchema, schemaCode, it } = cxt;
4808
+ if (!$data && !schema2)
4796
4809
  return;
4797
4810
  const valid = gen.let("valid");
4798
4811
  const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
@@ -4852,11 +4865,11 @@ var require_const = __commonJS((exports) => {
4852
4865
  $data: true,
4853
4866
  error,
4854
4867
  code(cxt) {
4855
- const { gen, data, $data, schemaCode, schema } = cxt;
4856
- if ($data || schema && typeof schema == "object") {
4868
+ const { gen, data, $data, schemaCode, schema: schema2 } = cxt;
4869
+ if ($data || schema2 && typeof schema2 == "object") {
4857
4870
  cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen, equal_1.default)}(${data}, ${schemaCode})`);
4858
4871
  } else {
4859
- cxt.fail((0, codegen_1._)`${schema} !== ${data}`);
4872
+ cxt.fail((0, codegen_1._)`${schema2} !== ${data}`);
4860
4873
  }
4861
4874
  }
4862
4875
  };
@@ -4879,10 +4892,10 @@ var require_enum = __commonJS((exports) => {
4879
4892
  $data: true,
4880
4893
  error,
4881
4894
  code(cxt) {
4882
- const { gen, data, $data, schema, schemaCode, it } = cxt;
4883
- if (!$data && schema.length === 0)
4895
+ const { gen, data, $data, schema: schema2, schemaCode, it } = cxt;
4896
+ if (!$data && schema2.length === 0)
4884
4897
  throw new Error("enum must have non-empty array");
4885
- const useLoop = schema.length >= it.opts.loopEnum;
4898
+ const useLoop = schema2.length >= it.opts.loopEnum;
4886
4899
  let eql;
4887
4900
  const getEql = () => eql !== null && eql !== undefined ? eql : eql = (0, util_1.useFunc)(gen, equal_1.default);
4888
4901
  let valid;
@@ -4890,10 +4903,10 @@ var require_enum = __commonJS((exports) => {
4890
4903
  valid = gen.let("valid");
4891
4904
  cxt.block$data(valid, loopEnum);
4892
4905
  } else {
4893
- if (!Array.isArray(schema))
4906
+ if (!Array.isArray(schema2))
4894
4907
  throw new Error("ajv implementation error");
4895
4908
  const vSchema = gen.const("vSchema", schemaCode);
4896
- valid = (0, codegen_1.or)(...schema.map((_x, i) => equalCode(vSchema, i)));
4909
+ valid = (0, codegen_1.or)(...schema2.map((_x, i) => equalCode(vSchema, i)));
4897
4910
  }
4898
4911
  cxt.pass(valid);
4899
4912
  function loopEnum() {
@@ -4901,7 +4914,7 @@ var require_enum = __commonJS((exports) => {
4901
4914
  gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break()));
4902
4915
  }
4903
4916
  function equalCode(vSchema, i) {
4904
- const sch = schema[i];
4917
+ const sch = schema2[i];
4905
4918
  return typeof sch === "object" && sch !== null ? (0, codegen_1._)`${getEql()}(${data}, ${vSchema}[${i}])` : (0, codegen_1._)`${data} === ${sch}`;
4906
4919
  }
4907
4920
  }
@@ -4966,13 +4979,13 @@ var require_additionalItems = __commonJS((exports) => {
4966
4979
  }
4967
4980
  };
4968
4981
  function validateAdditionalItems(cxt, items) {
4969
- const { gen, schema, data, keyword, it } = cxt;
4982
+ const { gen, schema: schema2, data, keyword, it } = cxt;
4970
4983
  it.items = true;
4971
4984
  const len = gen.const("len", (0, codegen_1._)`${data}.length`);
4972
- if (schema === false) {
4985
+ if (schema2 === false) {
4973
4986
  cxt.setParams({ len: items.length });
4974
4987
  cxt.pass((0, codegen_1._)`${len} <= ${items.length}`);
4975
- } else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
4988
+ } else if (typeof schema2 == "object" && !(0, util_1.alwaysValidSchema)(it, schema2)) {
4976
4989
  const valid = gen.var("valid", (0, codegen_1._)`${len} <= ${items.length}`);
4977
4990
  gen.if((0, codegen_1.not)(valid), () => validateItems(valid));
4978
4991
  cxt.ok(valid);
@@ -5002,11 +5015,11 @@ var require_items = __commonJS((exports) => {
5002
5015
  schemaType: ["object", "array", "boolean"],
5003
5016
  before: "uniqueItems",
5004
5017
  code(cxt) {
5005
- const { schema, it } = cxt;
5006
- if (Array.isArray(schema))
5007
- return validateTuple(cxt, "additionalItems", schema);
5018
+ const { schema: schema2, it } = cxt;
5019
+ if (Array.isArray(schema2))
5020
+ return validateTuple(cxt, "additionalItems", schema2);
5008
5021
  it.items = true;
5009
- if ((0, util_1.alwaysValidSchema)(it, schema))
5022
+ if ((0, util_1.alwaysValidSchema)(it, schema2))
5010
5023
  return;
5011
5024
  cxt.ok((0, code_1.validateArray)(cxt));
5012
5025
  }
@@ -5075,10 +5088,10 @@ var require_items2020 = __commonJS((exports) => {
5075
5088
  before: "uniqueItems",
5076
5089
  error,
5077
5090
  code(cxt) {
5078
- const { schema, parentSchema, it } = cxt;
5091
+ const { schema: schema2, parentSchema, it } = cxt;
5079
5092
  const { prefixItems } = parentSchema;
5080
5093
  it.items = true;
5081
- if ((0, util_1.alwaysValidSchema)(it, schema))
5094
+ if ((0, util_1.alwaysValidSchema)(it, schema2))
5082
5095
  return;
5083
5096
  if (prefixItems)
5084
5097
  (0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);
@@ -5106,7 +5119,7 @@ var require_contains = __commonJS((exports) => {
5106
5119
  trackErrors: true,
5107
5120
  error,
5108
5121
  code(cxt) {
5109
- const { gen, schema, parentSchema, data, it } = cxt;
5122
+ const { gen, schema: schema2, parentSchema, data, it } = cxt;
5110
5123
  let min;
5111
5124
  let max;
5112
5125
  const { minContains, maxContains } = parentSchema;
@@ -5127,7 +5140,7 @@ var require_contains = __commonJS((exports) => {
5127
5140
  cxt.fail();
5128
5141
  return;
5129
5142
  }
5130
- if ((0, util_1.alwaysValidSchema)(it, schema)) {
5143
+ if ((0, util_1.alwaysValidSchema)(it, schema2)) {
5131
5144
  let cond = (0, codegen_1._)`${len} >= ${min}`;
5132
5145
  if (max !== undefined)
5133
5146
  cond = (0, codegen_1._)`${cond} && ${len} <= ${max}`;
@@ -5208,14 +5221,14 @@ var require_dependencies = __commonJS((exports) => {
5208
5221
  validateSchemaDeps(cxt, schDeps);
5209
5222
  }
5210
5223
  };
5211
- function splitDependencies({ schema }) {
5224
+ function splitDependencies({ schema: schema2 }) {
5212
5225
  const propertyDeps = {};
5213
5226
  const schemaDeps = {};
5214
- for (const key in schema) {
5227
+ for (const key in schema2) {
5215
5228
  if (key === "__proto__")
5216
5229
  continue;
5217
- const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps;
5218
- deps[key] = schema[key];
5230
+ const deps = Array.isArray(schema2[key]) ? propertyDeps : schemaDeps;
5231
+ deps[key] = schema2[key];
5219
5232
  }
5220
5233
  return [propertyDeps, schemaDeps];
5221
5234
  }
@@ -5280,8 +5293,8 @@ var require_propertyNames = __commonJS((exports) => {
5280
5293
  schemaType: ["object", "boolean"],
5281
5294
  error,
5282
5295
  code(cxt) {
5283
- const { gen, schema, data, it } = cxt;
5284
- if ((0, util_1.alwaysValidSchema)(it, schema))
5296
+ const { gen, schema: schema2, data, it } = cxt;
5297
+ if ((0, util_1.alwaysValidSchema)(it, schema2))
5285
5298
  return;
5286
5299
  const valid = gen.name("valid");
5287
5300
  gen.forIn("key", data, (key) => {
@@ -5324,12 +5337,12 @@ var require_additionalProperties = __commonJS((exports) => {
5324
5337
  trackErrors: true,
5325
5338
  error,
5326
5339
  code(cxt) {
5327
- const { gen, schema, parentSchema, data, errsCount, it } = cxt;
5340
+ const { gen, schema: schema2, parentSchema, data, errsCount, it } = cxt;
5328
5341
  if (!errsCount)
5329
5342
  throw new Error("ajv implementation error");
5330
5343
  const { allErrors, opts } = it;
5331
5344
  it.props = true;
5332
- if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema))
5345
+ if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema2))
5333
5346
  return;
5334
5347
  const props = (0, code_1.allSchemaProperties)(parentSchema.properties);
5335
5348
  const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties);
@@ -5362,18 +5375,18 @@ var require_additionalProperties = __commonJS((exports) => {
5362
5375
  gen.code((0, codegen_1._)`delete ${data}[${key}]`);
5363
5376
  }
5364
5377
  function additionalPropertyCode(key) {
5365
- if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
5378
+ if (opts.removeAdditional === "all" || opts.removeAdditional && schema2 === false) {
5366
5379
  deleteAdditional(key);
5367
5380
  return;
5368
5381
  }
5369
- if (schema === false) {
5382
+ if (schema2 === false) {
5370
5383
  cxt.setParams({ additionalProperty: key });
5371
5384
  cxt.error();
5372
5385
  if (!allErrors)
5373
5386
  gen.break();
5374
5387
  return;
5375
5388
  }
5376
- if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
5389
+ if (typeof schema2 == "object" && !(0, util_1.alwaysValidSchema)(it, schema2)) {
5377
5390
  const valid = gen.name("valid");
5378
5391
  if (opts.removeAdditional === "failing") {
5379
5392
  applyAdditionalSchema(key, valid, false);
@@ -5420,18 +5433,18 @@ var require_properties = __commonJS((exports) => {
5420
5433
  type: "object",
5421
5434
  schemaType: "object",
5422
5435
  code(cxt) {
5423
- const { gen, schema, parentSchema, data, it } = cxt;
5436
+ const { gen, schema: schema2, parentSchema, data, it } = cxt;
5424
5437
  if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) {
5425
5438
  additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
5426
5439
  }
5427
- const allProps = (0, code_1.allSchemaProperties)(schema);
5440
+ const allProps = (0, code_1.allSchemaProperties)(schema2);
5428
5441
  for (const prop of allProps) {
5429
5442
  it.definedProperties.add(prop);
5430
5443
  }
5431
5444
  if (it.opts.unevaluated && allProps.length && it.props !== true) {
5432
5445
  it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
5433
5446
  }
5434
- const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
5447
+ const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema2[p]));
5435
5448
  if (properties.length === 0)
5436
5449
  return;
5437
5450
  const valid = gen.name("valid");
@@ -5449,7 +5462,7 @@ var require_properties = __commonJS((exports) => {
5449
5462
  cxt.ok(valid);
5450
5463
  }
5451
5464
  function hasDefault(prop) {
5452
- return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== undefined;
5465
+ return it.opts.useDefaults && !it.compositeRule && schema2[prop].default !== undefined;
5453
5466
  }
5454
5467
  function applyPropertySchema(prop) {
5455
5468
  cxt.subschema({
@@ -5475,10 +5488,10 @@ var require_patternProperties = __commonJS((exports) => {
5475
5488
  type: "object",
5476
5489
  schemaType: "object",
5477
5490
  code(cxt) {
5478
- const { gen, schema, data, parentSchema, it } = cxt;
5491
+ const { gen, schema: schema2, data, parentSchema, it } = cxt;
5479
5492
  const { opts } = it;
5480
- const patterns = (0, code_1.allSchemaProperties)(schema);
5481
- const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
5493
+ const patterns = (0, code_1.allSchemaProperties)(schema2);
5494
+ const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema2[p]));
5482
5495
  if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) {
5483
5496
  return;
5484
5497
  }
@@ -5543,8 +5556,8 @@ var require_not = __commonJS((exports) => {
5543
5556
  schemaType: ["object", "boolean"],
5544
5557
  trackErrors: true,
5545
5558
  code(cxt) {
5546
- const { gen, schema, it } = cxt;
5547
- if ((0, util_1.alwaysValidSchema)(it, schema)) {
5559
+ const { gen, schema: schema2, it } = cxt;
5560
+ if ((0, util_1.alwaysValidSchema)(it, schema2)) {
5548
5561
  cxt.fail();
5549
5562
  return;
5550
5563
  }
@@ -5591,12 +5604,12 @@ var require_oneOf = __commonJS((exports) => {
5591
5604
  trackErrors: true,
5592
5605
  error,
5593
5606
  code(cxt) {
5594
- const { gen, schema, parentSchema, it } = cxt;
5595
- if (!Array.isArray(schema))
5607
+ const { gen, schema: schema2, parentSchema, it } = cxt;
5608
+ if (!Array.isArray(schema2))
5596
5609
  throw new Error("ajv implementation error");
5597
5610
  if (it.opts.discriminator && parentSchema.discriminator)
5598
5611
  return;
5599
- const schArr = schema;
5612
+ const schArr = schema2;
5600
5613
  const valid = gen.let("valid", false);
5601
5614
  const passing = gen.let("passing", null);
5602
5615
  const schValid = gen.name("_valid");
@@ -5639,11 +5652,11 @@ var require_allOf = __commonJS((exports) => {
5639
5652
  keyword: "allOf",
5640
5653
  schemaType: "array",
5641
5654
  code(cxt) {
5642
- const { gen, schema, it } = cxt;
5643
- if (!Array.isArray(schema))
5655
+ const { gen, schema: schema2, it } = cxt;
5656
+ if (!Array.isArray(schema2))
5644
5657
  throw new Error("ajv implementation error");
5645
5658
  const valid = gen.name("valid");
5646
- schema.forEach((sch, i) => {
5659
+ schema2.forEach((sch, i) => {
5647
5660
  if ((0, util_1.alwaysValidSchema)(it, sch))
5648
5661
  return;
5649
5662
  const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid);
@@ -5715,8 +5728,8 @@ var require_if = __commonJS((exports) => {
5715
5728
  }
5716
5729
  };
5717
5730
  function hasSchema(it, keyword) {
5718
- const schema = it.schema[keyword];
5719
- return schema !== undefined && !(0, util_1.alwaysValidSchema)(it, schema);
5731
+ const schema2 = it.schema[keyword];
5732
+ return schema2 !== undefined && !(0, util_1.alwaysValidSchema)(it, schema2);
5720
5733
  }
5721
5734
  exports.default = def;
5722
5735
  });
@@ -5794,7 +5807,7 @@ var require_format = __commonJS((exports) => {
5794
5807
  $data: true,
5795
5808
  error,
5796
5809
  code(cxt, ruleType) {
5797
- const { gen, data, $data, schema, schemaCode, it } = cxt;
5810
+ const { gen, data, $data, schema: schema2, schemaCode, it } = cxt;
5798
5811
  const { opts, errSchemaPath, schemaEnv, self: self2 } = it;
5799
5812
  if (!opts.validateFormats)
5800
5813
  return;
@@ -5824,7 +5837,7 @@ var require_format = __commonJS((exports) => {
5824
5837
  }
5825
5838
  }
5826
5839
  function validateFormat() {
5827
- const formatDef = self2.formats[schema];
5840
+ const formatDef = self2.formats[schema2];
5828
5841
  if (!formatDef) {
5829
5842
  unknownFormat();
5830
5843
  return;
@@ -5841,12 +5854,12 @@ var require_format = __commonJS((exports) => {
5841
5854
  }
5842
5855
  throw new Error(unknownMsg());
5843
5856
  function unknownMsg() {
5844
- return `unknown format "${schema}" ignored in schema at path "${errSchemaPath}"`;
5857
+ return `unknown format "${schema2}" ignored in schema at path "${errSchemaPath}"`;
5845
5858
  }
5846
5859
  }
5847
5860
  function getFormat(fmtDef) {
5848
- const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : undefined;
5849
- const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code });
5861
+ const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema2)}` : undefined;
5862
+ const fmt = gen.scopeValue("formats", { key: schema2, ref: fmtDef, code });
5850
5863
  if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
5851
5864
  return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`${fmt}.validate`];
5852
5865
  }
@@ -5942,15 +5955,15 @@ var require_discriminator = __commonJS((exports) => {
5942
5955
  schemaType: "object",
5943
5956
  error,
5944
5957
  code(cxt) {
5945
- const { gen, data, schema, parentSchema, it } = cxt;
5958
+ const { gen, data, schema: schema2, parentSchema, it } = cxt;
5946
5959
  const { oneOf } = parentSchema;
5947
5960
  if (!it.opts.discriminator) {
5948
5961
  throw new Error("discriminator: requires discriminator option");
5949
5962
  }
5950
- const tagName = schema.propertyName;
5963
+ const tagName = schema2.propertyName;
5951
5964
  if (typeof tagName != "string")
5952
5965
  throw new Error("discriminator: requires propertyName");
5953
- if (schema.mapping)
5966
+ if (schema2.mapping)
5954
5967
  throw new Error("discriminator: mapping is not supported");
5955
5968
  if (!oneOf)
5956
5969
  throw new Error("discriminator: requires oneOf keyword");
@@ -48401,8 +48414,8 @@ var require_index_cjs2 = __commonJS((exports, module) => {
48401
48414
  this.re = {};
48402
48415
  compile(this);
48403
48416
  }
48404
- LinkifyIt.prototype.add = function add(schema, definition) {
48405
- this.__schemas__[schema] = definition;
48417
+ LinkifyIt.prototype.add = function add(schema2, definition) {
48418
+ this.__schemas__[schema2] = definition;
48406
48419
  compile(this);
48407
48420
  return this;
48408
48421
  };
@@ -48464,11 +48477,11 @@ var require_index_cjs2 = __commonJS((exports, module) => {
48464
48477
  LinkifyIt.prototype.pretest = function pretest(text) {
48465
48478
  return this.re.pretest.test(text);
48466
48479
  };
48467
- LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
48468
- if (!this.__compiled__[schema.toLowerCase()]) {
48480
+ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema2, pos) {
48481
+ if (!this.__compiled__[schema2.toLowerCase()]) {
48469
48482
  return 0;
48470
48483
  }
48471
- return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
48484
+ return this.__compiled__[schema2.toLowerCase()].validate(text, pos, this);
48472
48485
  };
48473
48486
  LinkifyIt.prototype.match = function match(text) {
48474
48487
  const result = [];
@@ -53970,7 +53983,7 @@ var require_logging_utils = __commonJS((exports) => {
53970
53983
  exports.getDebugBackend = getDebugBackend;
53971
53984
  exports.getStructuredBackend = getStructuredBackend;
53972
53985
  exports.setBackend = setBackend;
53973
- exports.log = log8;
53986
+ exports.log = log;
53974
53987
  var events_1 = __require("events");
53975
53988
  var process3 = __importStar(__require("process"));
53976
53989
  var util = __importStar(__require("util"));
@@ -53997,7 +54010,7 @@ var require_logging_utils = __commonJS((exports) => {
53997
54010
  this.func.info = (...args) => this.invokeSeverity(LogSeverity.INFO, ...args);
53998
54011
  this.func.warn = (...args) => this.invokeSeverity(LogSeverity.WARNING, ...args);
53999
54012
  this.func.error = (...args) => this.invokeSeverity(LogSeverity.ERROR, ...args);
54000
- this.func.sublog = (namespace2) => log8(namespace2, this.func);
54013
+ this.func.sublog = (namespace2) => log(namespace2, this.func);
54001
54014
  }
54002
54015
  invoke(fields, ...args) {
54003
54016
  if (this.upstream) {
@@ -54158,7 +54171,7 @@ var require_logging_utils = __commonJS((exports) => {
54158
54171
  cachedBackend = backend;
54159
54172
  loggerCache.clear();
54160
54173
  }
54161
- function log8(namespace, parent) {
54174
+ function log(namespace, parent) {
54162
54175
  if (!cachedBackend) {
54163
54176
  const enablesFlag = process3.env[exports.env.nodeEnables];
54164
54177
  if (!enablesFlag) {
@@ -54298,7 +54311,7 @@ var require_src5 = __commonJS((exports) => {
54298
54311
  exports.HEADER_NAME = "Metadata-Flavor";
54299
54312
  exports.HEADER_VALUE = "Google";
54300
54313
  exports.HEADERS = Object.freeze({ [exports.HEADER_NAME]: exports.HEADER_VALUE });
54301
- var log8 = logger.log("gcp-metadata");
54314
+ var log = logger.log("gcp-metadata");
54302
54315
  exports.METADATA_SERVER_DETECTION = Object.freeze({
54303
54316
  "assume-present": "don't try to ping the metadata server, but assume it's present",
54304
54317
  none: "don't try to ping the metadata server, but don't try to use it either",
@@ -54361,9 +54374,9 @@ var require_src5 = __commonJS((exports) => {
54361
54374
  responseType: "text",
54362
54375
  timeout: requestTimeout()
54363
54376
  };
54364
- log8.info("instance request %j", req);
54377
+ log.info("instance request %j", req);
54365
54378
  const res = await requestMethod(req);
54366
- log8.info("instance metadata is %s", res.data);
54379
+ log.info("instance metadata is %s", res.data);
54367
54380
  const metadataFlavor = res.headers.get(exports.HEADER_NAME);
54368
54381
  if (metadataFlavor !== exports.HEADER_VALUE) {
54369
54382
  throw new RangeError(`Invalid response from metadata service: incorrect ${exports.HEADER_NAME} header. Expected '${exports.HEADER_VALUE}', got ${metadataFlavor ? `'${metadataFlavor}'` : "no header"}`);
@@ -63006,12 +63019,12 @@ var require_endpoint = __commonJS((exports) => {
63006
63019
  constructor(options) {
63007
63020
  this._options = options || {};
63008
63021
  }
63009
- applySchema(target, rootSchema, schema, context) {
63010
- this.applyMethodsFromSchema(target, rootSchema, schema, context);
63011
- if (schema.resources) {
63012
- for (const resourceName in schema.resources) {
63013
- if (Object.prototype.hasOwnProperty.call(schema.resources, resourceName)) {
63014
- const resource = schema.resources[resourceName];
63022
+ applySchema(target, rootSchema, schema2, context) {
63023
+ this.applyMethodsFromSchema(target, rootSchema, schema2, context);
63024
+ if (schema2.resources) {
63025
+ for (const resourceName in schema2.resources) {
63026
+ if (Object.prototype.hasOwnProperty.call(schema2.resources, resourceName)) {
63027
+ const resource = schema2.resources[resourceName];
63015
63028
  if (!target[resourceName]) {
63016
63029
  target[resourceName] = {};
63017
63030
  }
@@ -63020,21 +63033,21 @@ var require_endpoint = __commonJS((exports) => {
63020
63033
  }
63021
63034
  }
63022
63035
  }
63023
- applyMethodsFromSchema(target, rootSchema, schema, context) {
63024
- if (schema.methods) {
63025
- for (const name in schema.methods) {
63026
- if (Object.prototype.hasOwnProperty.call(schema.methods, name)) {
63027
- const method = schema.methods[name];
63036
+ applyMethodsFromSchema(target, rootSchema, schema2, context) {
63037
+ if (schema2.methods) {
63038
+ for (const name in schema2.methods) {
63039
+ if (Object.prototype.hasOwnProperty.call(schema2.methods, name)) {
63040
+ const method = schema2.methods[name];
63028
63041
  target[name] = this.makeMethod(rootSchema, method, context);
63029
63042
  }
63030
63043
  }
63031
63044
  }
63032
63045
  }
63033
- makeMethod(schema, method, context) {
63046
+ makeMethod(schema2, method, context) {
63034
63047
  return (paramsOrCallback, callback) => {
63035
63048
  const params = typeof paramsOrCallback === "function" ? {} : paramsOrCallback;
63036
63049
  callback = typeof paramsOrCallback === "function" ? paramsOrCallback : callback;
63037
- const schemaUrl = buildurl(schema.rootUrl + schema.servicePath + method.path);
63050
+ const schemaUrl = buildurl(schema2.rootUrl + schema2.servicePath + method.path);
63038
63051
  const parameters = {
63039
63052
  options: {
63040
63053
  url: schemaUrl.substring(1, schemaUrl.length - 1),
@@ -63047,7 +63060,7 @@ var require_endpoint = __commonJS((exports) => {
63047
63060
  context
63048
63061
  };
63049
63062
  if (method.mediaUpload && method.mediaUpload.protocols && method.mediaUpload.protocols.simple && method.mediaUpload.protocols.simple.path) {
63050
- const mediaUrl = buildurl(schema.rootUrl + method.mediaUpload.protocols.simple.path);
63063
+ const mediaUrl = buildurl(schema2.rootUrl + method.mediaUpload.protocols.simple.path);
63051
63064
  parameters.mediaUrl = mediaUrl.substring(1, mediaUrl.length - 1);
63052
63065
  }
63053
63066
  if (!callback) {
@@ -63094,10 +63107,10 @@ var require_discovery = __commonJS((exports) => {
63094
63107
  constructor(options) {
63095
63108
  this.options = options || {};
63096
63109
  }
63097
- makeEndpoint(schema) {
63110
+ makeEndpoint(schema2) {
63098
63111
  return (options) => {
63099
63112
  const ep = new endpoint_1.Endpoint(options);
63100
- ep.applySchema(ep, schema, schema, ep);
63113
+ ep.applySchema(ep, schema2, schema2, ep);
63101
63114
  return ep;
63102
63115
  };
63103
63116
  }
@@ -72118,11 +72131,11 @@ var require_tools = __commonJS((exports, module) => {
72118
72131
  }
72119
72132
  }
72120
72133
  }
72121
- function buildFormatters(level, bindings, log8) {
72134
+ function buildFormatters(level, bindings, log) {
72122
72135
  return {
72123
72136
  level,
72124
72137
  bindings,
72125
- log: log8
72138
+ log
72126
72139
  };
72127
72140
  }
72128
72141
  function normalizeDestFileDescriptor(destination) {
@@ -72467,8 +72480,8 @@ var require_proto = __commonJS((exports, module) => {
72467
72480
  } else
72468
72481
  instance[serializersSym] = serializers;
72469
72482
  if (options.hasOwnProperty("formatters")) {
72470
- const { level, bindings: chindings, log: log8 } = options.formatters;
72471
- instance[formattersSym] = buildFormatters(level || formatters.level, chindings || resetChildingsFormatter, log8 || formatters.log);
72483
+ const { level, bindings: chindings, log } = options.formatters;
72484
+ instance[formattersSym] = buildFormatters(level || formatters.level, chindings || resetChildingsFormatter, log || formatters.log);
72472
72485
  } else {
72473
72486
  instance[formattersSym] = buildFormatters(formatters.level, resetChildingsFormatter, formatters.log);
72474
72487
  }
@@ -101672,10 +101685,10 @@ var require_mailer = __commonJS((exports, module) => {
101672
101685
  tnx: "create"
101673
101686
  }, "Creating transport: %s", this.getVersionString());
101674
101687
  if (typeof this.transporter.on === "function") {
101675
- this.transporter.on("log", (log8) => {
101688
+ this.transporter.on("log", (log) => {
101676
101689
  this.logger.debug({
101677
101690
  tnx: "transport"
101678
- }, "%s: %s", log8.type, log8.message);
101691
+ }, "%s: %s", log.type, log.message);
101679
101692
  });
101680
101693
  this.transporter.on("error", (err) => {
101681
101694
  this.logger.error({
@@ -105623,7 +105636,6 @@ For long-running processes (servers, listeners, watchers), background them with
105623
105636
  var BASE_SYSTEM_PROMPT = buildBaseSystemPrompt();
105624
105637
 
105625
105638
  // src/core/memory/index.ts
105626
- init_storage();
105627
105639
  var MEMORY_CATEGORIES = ["app", "framework", "general"];
105628
105640
  var MEMORIES_PREFIX = "memories";
105629
105641
  function isMemoryEnabled() {
@@ -106828,27 +106840,27 @@ init_core();
106828
106840
 
106829
106841
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
106830
106842
  function isZ4Schema(s) {
106831
- const schema = s;
106832
- return !!schema._zod;
106843
+ const schema2 = s;
106844
+ return !!schema2._zod;
106833
106845
  }
106834
- function safeParse2(schema, data) {
106835
- if (isZ4Schema(schema)) {
106836
- const result2 = safeParse(schema, data);
106846
+ function safeParse2(schema2, data) {
106847
+ if (isZ4Schema(schema2)) {
106848
+ const result2 = safeParse(schema2, data);
106837
106849
  return result2;
106838
106850
  }
106839
- const v3Schema = schema;
106851
+ const v3Schema = schema2;
106840
106852
  const result = v3Schema.safeParse(data);
106841
106853
  return result;
106842
106854
  }
106843
- function getObjectShape(schema) {
106844
- if (!schema)
106855
+ function getObjectShape(schema2) {
106856
+ if (!schema2)
106845
106857
  return;
106846
106858
  let rawShape;
106847
- if (isZ4Schema(schema)) {
106848
- const v4Schema = schema;
106859
+ if (isZ4Schema(schema2)) {
106860
+ const v4Schema = schema2;
106849
106861
  rawShape = v4Schema._zod?.def?.shape;
106850
106862
  } else {
106851
- const v3Schema = schema;
106863
+ const v3Schema = schema2;
106852
106864
  rawShape = v3Schema.shape;
106853
106865
  }
106854
106866
  if (!rawShape)
@@ -106862,9 +106874,9 @@ function getObjectShape(schema) {
106862
106874
  }
106863
106875
  return rawShape;
106864
106876
  }
106865
- function getLiteralValue(schema) {
106866
- if (isZ4Schema(schema)) {
106867
- const v4Schema = schema;
106877
+ function getLiteralValue(schema2) {
106878
+ if (isZ4Schema(schema2)) {
106879
+ const v4Schema = schema2;
106868
106880
  const def2 = v4Schema._zod?.def;
106869
106881
  if (def2) {
106870
106882
  if (def2.value !== undefined)
@@ -106874,7 +106886,7 @@ function getLiteralValue(schema) {
106874
106886
  }
106875
106887
  }
106876
106888
  }
106877
- const v3Schema = schema;
106889
+ const v3Schema = schema2;
106878
106890
  const def = v3Schema._def;
106879
106891
  if (def) {
106880
106892
  if (def.value !== undefined)
@@ -106883,7 +106895,7 @@ function getLiteralValue(schema) {
106883
106895
  return def.values[0];
106884
106896
  }
106885
106897
  }
106886
- const directValue = schema.value;
106898
+ const directValue = schema2.value;
106887
106899
  if (directValue !== undefined)
106888
106900
  return directValue;
106889
106901
  return;
@@ -107732,8 +107744,8 @@ var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use")
107732
107744
  // node_modules/zod-to-json-schema/dist/esm/parsers/string.js
107733
107745
  var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
107734
107746
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
107735
- function getMethodLiteral(schema) {
107736
- const shape = getObjectShape(schema);
107747
+ function getMethodLiteral(schema2) {
107748
+ const shape = getObjectShape(schema2);
107737
107749
  const methodSchema = shape?.method;
107738
107750
  if (!methodSchema) {
107739
107751
  throw new Error("Schema is missing a method literal");
@@ -107744,8 +107756,8 @@ function getMethodLiteral(schema) {
107744
107756
  }
107745
107757
  return value;
107746
107758
  }
107747
- function parseWithCompat(schema, data) {
107748
- const result = safeParse2(schema, data);
107759
+ function parseWithCompat(schema2, data) {
107760
+ const result = safeParse2(schema2, data);
107749
107761
  if (!result.success) {
107750
107762
  throw result.error;
107751
107763
  }
@@ -108594,8 +108606,8 @@ class AjvJsonSchemaValidator {
108594
108606
  constructor(ajv) {
108595
108607
  this._ajv = ajv ?? createDefaultAjvInstance();
108596
108608
  }
108597
- getValidator(schema) {
108598
- const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
108609
+ getValidator(schema2) {
108610
+ const ajvValidator = "$id" in schema2 && typeof schema2.$id === "string" ? this._ajv.getSchema(schema2.$id) ?? this._ajv.compile(schema2) : this._ajv.compile(schema2);
108599
108611
  return (input) => {
108600
108612
  const valid = ajvValidator(input);
108601
108613
  if (valid) {
@@ -108717,12 +108729,12 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
108717
108729
  }
108718
108730
 
108719
108731
  // node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
108720
- function applyElicitationDefaults(schema, data) {
108721
- if (!schema || data === null || typeof data !== "object")
108732
+ function applyElicitationDefaults(schema2, data) {
108733
+ if (!schema2 || data === null || typeof data !== "object")
108722
108734
  return;
108723
- if (schema.type === "object" && schema.properties && typeof schema.properties === "object") {
108735
+ if (schema2.type === "object" && schema2.properties && typeof schema2.properties === "object") {
108724
108736
  const obj = data;
108725
- const props = schema.properties;
108737
+ const props = schema2.properties;
108726
108738
  for (const key of Object.keys(props)) {
108727
108739
  const propSchema = props[key];
108728
108740
  if (obj[key] === undefined && Object.prototype.hasOwnProperty.call(propSchema, "default")) {
@@ -108733,15 +108745,15 @@ function applyElicitationDefaults(schema, data) {
108733
108745
  }
108734
108746
  }
108735
108747
  }
108736
- if (Array.isArray(schema.anyOf)) {
108737
- for (const sub of schema.anyOf) {
108748
+ if (Array.isArray(schema2.anyOf)) {
108749
+ for (const sub of schema2.anyOf) {
108738
108750
  if (typeof sub !== "boolean") {
108739
108751
  applyElicitationDefaults(sub, data);
108740
108752
  }
108741
108753
  }
108742
108754
  }
108743
- if (Array.isArray(schema.oneOf)) {
108744
- for (const sub of schema.oneOf) {
108755
+ if (Array.isArray(schema2.oneOf)) {
108756
+ for (const sub of schema2.oneOf) {
108745
108757
  if (typeof sub !== "boolean") {
108746
108758
  applyElicitationDefaults(sub, data);
108747
108759
  }
@@ -110930,11 +110942,8 @@ function checkpointState(ctx) {
110930
110942
  // src/core/agents/offSecAgent/tools/completeAuthentication.ts
110931
110943
  init_dist();
110932
110944
  init_zod();
110933
- init_structured();
110934
- init_lazyLogger();
110935
110945
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
110936
110946
  import { join as join6 } from "path";
110937
- var log = scopedLogger(() => createLogger("complete_authentication"));
110938
110947
  var AUTH_DIR = "auth";
110939
110948
  var AUTH_DATA_FILENAME = "auth-data.json";
110940
110949
  function completeAuthentication(ctx) {
@@ -110974,7 +110983,7 @@ This tool marks the end of the authentication flow.`,
110974
110983
  toolCallDescription: exports_external.string().describe("A concise description of what this tool call is doing")
110975
110984
  }),
110976
110985
  execute: async (result) => {
110977
- log.info(`Authentication complete: ${result.success ? "SUCCESS" : "FAILED"}`);
110986
+ console.log(`Authentication complete: ${result.success ? "SUCCESS" : "FAILED"}`);
110978
110987
  let authDataPath;
110979
110988
  try {
110980
110989
  const authDir = join6(ctx.session.rootPath, AUTH_DIR);
@@ -110993,9 +111002,9 @@ This tool marks the end of the authentication flow.`,
110993
111002
  ...result.authBarrier && { authBarrier: result.authBarrier }
110994
111003
  };
110995
111004
  writeFileSync4(authDataPath, JSON.stringify(authData, null, 2));
110996
- log.debug(`Auth data persisted to ${authDataPath}`);
111005
+ console.log(`Auth data persisted to ${authDataPath}`);
110997
111006
  } catch (err) {
110998
- log.error("Failed to persist auth data", err instanceof Error ? err : undefined, { error: String(err) });
111007
+ console.error(`Failed to persist auth data: ${err}`);
110999
111008
  }
111000
111009
  return {
111001
111010
  success: result.success,
@@ -111015,8 +111024,6 @@ This tool marks the end of the authentication flow.`,
111015
111024
  // src/core/agents/offSecAgent/tools/crawlAuthenticated.ts
111016
111025
  init_dist();
111017
111026
  init_zod();
111018
- init_structured();
111019
- init_lazyLogger();
111020
111027
 
111021
111028
  // src/core/agents/specialized/attackSurface/jsExtraction.ts
111022
111029
  async function extractJavascriptEndpoints(params) {
@@ -111091,7 +111098,6 @@ async function extractJavascriptEndpoints(params) {
111091
111098
  }
111092
111099
 
111093
111100
  // src/core/agents/offSecAgent/tools/crawlAuthenticated.ts
111094
- var log2 = scopedLogger(() => createLogger("crawl-authenticated"));
111095
111101
  function crawlAuthenticated(ctx) {
111096
111102
  return tool({
111097
111103
  description: `Recursively crawl web pages starting from a URL to discover links, forms, and JavaScript endpoints.
@@ -111171,7 +111177,7 @@ function crawlAuthenticated(ctx) {
111171
111177
  });
111172
111178
  }
111173
111179
  } catch (error) {
111174
- log2.error(`Error crawling ${url}`, error instanceof Error ? error : undefined, { error: String(error) });
111180
+ console.error(`Error crawling ${url}:`, error);
111175
111181
  }
111176
111182
  }
111177
111183
  return {
@@ -111239,12 +111245,9 @@ Call this at the END of your analysis with:
111239
111245
  // src/core/agents/offSecAgent/tools/createFile.ts
111240
111246
  init_dist();
111241
111247
  init_zod();
111242
- init_structured();
111243
- init_lazyLogger();
111244
111248
  import { existsSync as existsSync5 } from "fs";
111245
111249
  import { mkdir, writeFile } from "fs/promises";
111246
111250
  import { dirname as dirname3, isAbsolute, resolve } from "path";
111247
- var log3 = scopedLogger(() => createLogger("create_file"));
111248
111251
  var createFileInputSchema = exports_external.object({
111249
111252
  path: exports_external.string().describe("Absolute or relative path for the new file"),
111250
111253
  content: exports_external.string().describe("Content to write to the file"),
@@ -111265,14 +111268,14 @@ Parent directories are created automatically if they don't exist.`,
111265
111268
  content,
111266
111269
  overwrite = false
111267
111270
  }) => {
111268
- log3.debug(`enter: path=${filePath}, contentLen=${content.length}, overwrite=${overwrite}, sandbox=${!!ctx.sandbox}`);
111271
+ console.error(`[create_file] enter: path=${filePath}, contentLen=${content.length}, overwrite=${overwrite}, sandbox=${!!ctx.sandbox}`);
111269
111272
  const resolved = isAbsolute(filePath) ? filePath : resolve(ctx.agentCwd, filePath);
111270
- log3.debug(`resolved: ${resolved}`);
111273
+ console.error(`[create_file] resolved: ${resolved}`);
111271
111274
  if (ctx.sandbox) {
111272
111275
  return executeSandboxCreate(ctx, resolved, content, overwrite);
111273
111276
  }
111274
111277
  const result = await executeLocalCreate(resolved, content, overwrite);
111275
- log3.debug(`done: success=${result.success}, error=${result.error || "(none)"}`);
111278
+ console.error(`[create_file] done: success=${result.success}, error=${result.error || "(none)"}`);
111276
111279
  return result;
111277
111280
  }
111278
111281
  });
@@ -111280,7 +111283,7 @@ Parent directories are created automatically if they don't exist.`,
111280
111283
  async function executeLocalCreate(filePath, content, overwrite) {
111281
111284
  try {
111282
111285
  if (!overwrite && existsSync5(filePath)) {
111283
- log3.debug(`local: file already exists: ${filePath}`);
111286
+ console.error(`[create_file:local] file already exists: ${filePath}`);
111284
111287
  return {
111285
111288
  success: false,
111286
111289
  error: `File already exists: ${filePath}. Set overwrite=true to replace it.`,
@@ -111288,20 +111291,18 @@ async function executeLocalCreate(filePath, content, overwrite) {
111288
111291
  };
111289
111292
  }
111290
111293
  const dir = dirname3(filePath);
111291
- log3.debug(`local: mkdir ${dir}`);
111294
+ console.error(`[create_file:local] mkdir ${dir}`);
111292
111295
  await mkdir(dir, { recursive: true });
111293
- log3.debug(`local: mkdir done, writing ${content.length} bytes`);
111296
+ console.error(`[create_file:local] mkdir done, writing ${content.length} bytes`);
111294
111297
  await writeFile(filePath, content, "utf-8");
111295
- log3.debug("local: writeFile done");
111298
+ console.error(`[create_file:local] writeFile done`);
111296
111299
  return {
111297
111300
  success: true,
111298
111301
  error: "",
111299
111302
  path: filePath
111300
111303
  };
111301
111304
  } catch (err) {
111302
- log3.error("local: write failed", err instanceof Error ? err : undefined, {
111303
- error: String(err)
111304
- });
111305
+ console.error(`[create_file:local] error: ${err}`);
111305
111306
  return {
111306
111307
  success: false,
111307
111308
  error: err instanceof Error ? err.message : String(err),
@@ -111403,19 +111404,19 @@ function getTask(tasksDir, id) {
111403
111404
  return null;
111404
111405
  }
111405
111406
  }
111406
- function updateTask(tasksDir, id, update) {
111407
+ function updateTask(tasksDir, id, update2) {
111407
111408
  const existing = getTask(tasksDir, id);
111408
111409
  if (!existing)
111409
111410
  return null;
111410
111411
  const updated = {
111411
111412
  ...existing,
111412
- ...update.status !== undefined && { status: update.status },
111413
- ...update.result !== undefined && { result: update.result },
111414
- ...update.observation !== undefined && {
111415
- observation: update.observation
111413
+ ...update2.status !== undefined && { status: update2.status },
111414
+ ...update2.result !== undefined && { result: update2.result },
111415
+ ...update2.observation !== undefined && {
111416
+ observation: update2.observation
111416
111417
  },
111417
- ...update.metadata !== undefined && {
111418
- metadata: { ...existing.metadata, ...update.metadata }
111418
+ ...update2.metadata !== undefined && {
111419
+ metadata: { ...existing.metadata, ...update2.metadata }
111419
111420
  },
111420
111421
  updatedAt: new Date().toISOString()
111421
111422
  };
@@ -111530,12 +111531,8 @@ Examples of good tasks:
111530
111531
  // src/core/agents/offSecAgent/tools/delegateAuth.ts
111531
111532
  init_dist();
111532
111533
  init_zod();
111533
- init_credentials();
111534
111534
  import { writeFileSync as writeFileSync7 } from "fs";
111535
111535
  import { join as join9 } from "path";
111536
- init_structured();
111537
- init_lazyLogger();
111538
- var log4 = scopedLogger(() => createLogger("delegate_auth"));
111539
111536
  function mergeAuthCredentials(sessionCreds, explicit) {
111540
111537
  const hasExplicit = explicit.username || explicit.password || explicit.apiKey || explicit.tokens;
111541
111538
  const hasSession = sessionCreds && (sessionCreds.username || sessionCreds.password || sessionCreds.apiKey || sessionCreds.tokens);
@@ -111657,33 +111654,42 @@ When to use delegate_to_auth_subagent vs authenticate_session:
111657
111654
  input: { target, reason },
111658
111655
  parentSubagentId: ctx.subagentId
111659
111656
  });
111660
- log4.info("Delegating to authentication subagent", {
111661
- target,
111662
- reason,
111663
- username: username || undefined,
111664
- apiKey: apiKey ? "[PROVIDED]" : undefined,
111665
- bearerToken: tokens?.bearerToken ? "[PROVIDED]" : undefined,
111666
- cookies: tokens?.cookies ? "[PROVIDED]" : undefined,
111667
- customHeaders: tokens?.customHeaders ? Object.keys(tokens.customHeaders) : undefined
111668
- });
111657
+ console.log(`
111658
+ \uD83D\uDD10 Delegating to authentication subagent...`);
111659
+ console.log(` Target: ${target}`);
111660
+ console.log(` Reason: ${reason}`);
111661
+ if (username)
111662
+ console.log(` Username: ${username}`);
111663
+ if (apiKey)
111664
+ console.log(` API Key: [PROVIDED]`);
111665
+ if (tokens?.bearerToken)
111666
+ console.log(` Bearer Token: [PROVIDED]`);
111667
+ if (tokens?.cookies)
111668
+ console.log(` Cookies: [PROVIDED]`);
111669
+ if (tokens?.customHeaders)
111670
+ console.log(` Custom Headers: ${Object.keys(tokens.customHeaders).join(", ")}`);
111669
111671
  const rawSessionCreds = ctx.session.config?.authCredentials;
111670
111672
  const sessionCreds = rawSessionCreds ? Array.isArray(rawSessionCreds) ? rawSessionCreds[0] : rawSessionCreds : undefined;
111671
111673
  if (sessionCreds && !username && !apiKey && !tokens) {
111672
- log4.debug("Inheriting session credentials", {
111673
- sessionUsername: sessionCreds.username || undefined,
111674
- sessionApiKey: sessionCreds.apiKey ? "[PROVIDED]" : undefined,
111675
- sessionBearerToken: sessionCreds.tokens?.bearerToken ? "[PROVIDED]" : undefined,
111676
- sessionCookies: sessionCreds.tokens?.cookies ? "[PROVIDED]" : undefined,
111677
- sessionCustomHeaders: sessionCreds.tokens?.customHeaders ? Object.keys(sessionCreds.tokens.customHeaders) : undefined
111678
- });
111674
+ console.log(` [Inheriting session credentials]`);
111675
+ if (sessionCreds.username)
111676
+ console.log(` Session Username: ${sessionCreds.username}`);
111677
+ if (sessionCreds.apiKey)
111678
+ console.log(` Session API Key: [PROVIDED]`);
111679
+ if (sessionCreds.tokens?.bearerToken)
111680
+ console.log(` Session Bearer Token: [PROVIDED]`);
111681
+ if (sessionCreds.tokens?.cookies)
111682
+ console.log(` Session Cookies: [PROVIDED]`);
111683
+ if (sessionCreds.tokens?.customHeaders)
111684
+ console.log(` Session Custom Headers: ${Object.keys(sessionCreds.tokens.customHeaders).join(", ")}`);
111679
111685
  }
111680
111686
  if (authHints) {
111681
- log4.debug("Auth hints", {
111682
- authScheme: authHints.authScheme || "unknown",
111683
- csrfRequired: authHints.csrfRequired || false,
111684
- browserRequired: authHints.browserRequired || false,
111685
- protectedEndpoints: authHints.protectedEndpoints?.length ? authHints.protectedEndpoints : undefined
111686
- });
111687
+ console.log(` Auth Scheme: ${authHints.authScheme || "unknown"}`);
111688
+ console.log(` CSRF Required: ${authHints.csrfRequired || false}`);
111689
+ console.log(` Browser Required: ${authHints.browserRequired || false}`);
111690
+ if (authHints.protectedEndpoints?.length) {
111691
+ console.log(` Protected Endpoints: ${authHints.protectedEndpoints.join(", ")}`);
111692
+ }
111687
111693
  }
111688
111694
  const credentials = mergeAuthCredentials(sessionCreds, {
111689
111695
  username,
@@ -111698,7 +111704,7 @@ When to use delegate_to_auth_subagent vs authenticate_session:
111698
111704
  if (credentials) {
111699
111705
  ctx.session.credentialManager.addFromAuthCredentials(credentials);
111700
111706
  }
111701
- const { runAuthenticationAgent } = await import("./authentication-b8p1afqq.js");
111707
+ const { runAuthenticationAgent } = await import("./authentication-0k43jay4.js");
111702
111708
  const localBus = new AgentEventBus;
111703
111709
  AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
111704
111710
  const result = await runAuthenticationAgent({
@@ -112327,9 +112333,6 @@ function validateConcurrency(concurrency) {
112327
112333
 
112328
112334
  // src/core/agents/offSecAgent/tools/threatModelGenerator.ts
112329
112335
  init_zod();
112330
- init_structured();
112331
- init_lazyLogger();
112332
- var log5 = scopedLogger(() => createLogger("threat-model-generator"));
112333
112336
  var THREAT_MODEL_CONCURRENCY = 10;
112334
112337
  var threatModelLimiter = pLimit(THREAT_MODEL_CONCURRENCY);
112335
112338
  var PentestObjectiveSchema = exports_external.object({
@@ -112378,7 +112381,7 @@ async function generateThreatModelForEndpoint(ctx, input) {
112378
112381
  return threatModelLimiter(async () => {
112379
112382
  if (ctx.abortSignal?.aborted)
112380
112383
  return null;
112381
- const { CodeAgent } = await import("./agent-mjyx1amj.js");
112384
+ const { CodeAgent } = await import("./agent-84enr6xn.js");
112382
112385
  const subagentId = `threat-model-${sanitize(input.appName)}-${sanitize(input.routePath)}`;
112383
112386
  ctx.eventBus?.emit("subagent-spawn", {
112384
112387
  subagentId,
@@ -112433,7 +112436,7 @@ async function generateThreatModelForEndpoint(ctx, input) {
112433
112436
  status: "failed",
112434
112437
  parentSubagentId: ctx.subagentId
112435
112438
  });
112436
- log5.warn(`Threat model generation failed for ${input.routePath}: ${error instanceof Error ? error.message : String(error)}`);
112439
+ console.error(`Threat model generation failed for ${input.routePath}: ${error instanceof Error ? error.message : String(error)}`);
112437
112440
  return null;
112438
112441
  }
112439
112442
  });
@@ -112832,10 +112835,6 @@ function hasCanonicalName(cwe) {
112832
112835
  return "name" in cwe && typeof cwe.name === "string";
112833
112836
  }
112834
112837
 
112835
- // src/core/agents/offSecAgent/tools/documentFinding.ts
112836
- init_structured();
112837
- init_lazyLogger();
112838
-
112839
112838
  // src/core/agents/specialized/cvssScorer/index.ts
112840
112839
  init_zod();
112841
112840
 
@@ -114223,12 +114222,9 @@ function extractContextSummary(messages) {
114223
114222
  }
114224
114223
 
114225
114224
  // src/core/agents/specialized/findingJudge/index.ts
114226
- init_structured();
114227
- init_lazyLogger();
114228
- var log6 = scopedLogger(() => createLogger("FindingJudge"));
114229
114225
  async function judgeFinding(input, ctx) {
114230
114226
  try {
114231
- const { FindingJudgeAgent } = await import("./agent-7866ka7b.js");
114227
+ const { FindingJudgeAgent } = await import("./agent-x1tnsg7n.js");
114232
114228
  const agent = new FindingJudgeAgent({
114233
114229
  finding: input,
114234
114230
  model: ctx.model,
@@ -114249,11 +114245,7 @@ async function judgeFinding(input, ctx) {
114249
114245
  return normalizeJudgeResult(result);
114250
114246
  } catch (err) {
114251
114247
  const fallback = createJudgeFailureResult(err, ctx.model);
114252
- log6.warn("Agentic validation failed", {
114253
- model: fallback.error?.model,
114254
- type: fallback.error?.type,
114255
- message: fallback.error?.message
114256
- });
114248
+ console.error(`[FindingJudge] Agentic validation failed: model=${fallback.error?.model} type=${fallback.error?.type} message=${fallback.error?.message}`);
114257
114249
  return fallback;
114258
114250
  }
114259
114251
  }
@@ -114307,7 +114299,6 @@ function createJudgeFailureResult(err, model) {
114307
114299
  }
114308
114300
 
114309
114301
  // src/core/agents/offSecAgent/tools/documentFinding.ts
114310
- var log7 = scopedLogger(() => createLogger("document-finding"));
114311
114302
  var documentVulnerabilityInputSchema = exports_external.object({
114312
114303
  title: exports_external.string().describe("Finding title"),
114313
114304
  description: exports_external.string().describe("Detailed description of the finding"),
@@ -114897,7 +114888,9 @@ function preparePoc(input) {
114897
114888
  let pocContent = input.pocContent.trim();
114898
114889
  const portabilityWarnings = validatePocPortability(pocContent, input.pocType);
114899
114890
  if (portabilityWarnings.length > 0) {
114900
- log7.warn(`PoC portability warnings for ${filename}: ${portabilityWarnings.join("; ")}`);
114891
+ console.warn(`[PoC Portability] Warnings for ${filename}:
114892
+ ${portabilityWarnings.join(`
114893
+ `)}`);
114901
114894
  }
114902
114895
  if (!pocContent.startsWith("#!")) {
114903
114896
  const shebangs = {
@@ -120073,9 +120066,6 @@ function createResponseTool(responseSchema, onResult) {
120073
120066
  // src/core/agents/offSecAgent/tools/runAttackSurface.ts
120074
120067
  init_dist();
120075
120068
  init_zod();
120076
- init_structured();
120077
- init_lazyLogger();
120078
- var log8 = scopedLogger(() => createLogger("run_attack_surface"));
120079
120069
  function runAttackSurface(ctx) {
120080
120070
  return tool({
120081
120071
  description: `Run the attack surface discovery agent to map the target's full attack surface.
@@ -120112,7 +120102,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
120112
120102
  });
120113
120103
  if (cwd) {
120114
120104
  try {
120115
- const { WhiteboxAttackSurfaceAgent } = await import("./index-tknvj68q.js");
120105
+ const { WhiteboxAttackSurfaceAgent } = await import("./index-54ep0ery.js");
120116
120106
  const localBus = new AgentEventBus;
120117
120107
  AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
120118
120108
  const agent = new WhiteboxAttackSurfaceAgent({
@@ -120131,7 +120121,8 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
120131
120121
  objective: ep.pentestObjectives.join("; "),
120132
120122
  rationale: `${app.framework} ${ep.method} endpoint in ${app.name} (${ep.file}${ep.line ? `:${ep.line}` : ""})`
120133
120123
  })));
120134
- log8.info(`Whitebox attack surface complete: ${targets.length} targets from ${result.apps.length} apps`);
120124
+ console.log(`
120125
+ ✓ Whitebox attack surface complete: ${targets.length} targets from ${result.apps.length} apps`);
120135
120126
  ctx.eventBus?.emit("subagent-complete", {
120136
120127
  subagentId,
120137
120128
  status: "completed",
@@ -120147,7 +120138,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
120147
120138
  };
120148
120139
  } catch (error) {
120149
120140
  const errorMsg = error instanceof Error ? error.message : String(error);
120150
- log8.error(`Whitebox attack surface agent failed: ${errorMsg}`);
120141
+ console.error(`✗ Whitebox attack surface agent failed: ${errorMsg}`);
120151
120142
  ctx.eventBus?.emit("subagent-complete", {
120152
120143
  subagentId,
120153
120144
  status: "failed",
@@ -120162,7 +120153,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
120162
120153
  }
120163
120154
  }
120164
120155
  try {
120165
- const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-z1h2cgyg.js");
120156
+ const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-76tnwwg7.js");
120166
120157
  const localBus = new AgentEventBus;
120167
120158
  AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
120168
120159
  const agent = new BlackboxAttackSurfaceAgent({
@@ -120177,7 +120168,8 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
120177
120168
  });
120178
120169
  const result = await agent.consume();
120179
120170
  const targetCount = result.targets.length;
120180
- log8.info(`Blackbox attack surface complete: ${targetCount} targets identified`);
120171
+ console.log(`
120172
+ ✓ Blackbox attack surface complete: ${targetCount} targets identified`);
120181
120173
  ctx.eventBus?.emit("subagent-complete", {
120182
120174
  subagentId,
120183
120175
  status: "completed",
@@ -120200,7 +120192,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
120200
120192
  };
120201
120193
  } catch (error) {
120202
120194
  const errorMsg = error instanceof Error ? error.message : String(error);
120203
- log8.error(`Blackbox attack surface agent failed: ${errorMsg}`);
120195
+ console.error(`✗ Blackbox attack surface agent failed: ${errorMsg}`);
120204
120196
  ctx.eventBus?.emit("subagent-complete", {
120205
120197
  subagentId,
120206
120198
  status: "failed",
@@ -120240,7 +120232,7 @@ Omit \`cwd\` for blackbox mode (live target probing only).`,
120240
120232
  toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
120241
120233
  }),
120242
120234
  execute: async ({ target, cwd }) => {
120243
- const { runPentestWorkflow: workflow } = await import("./pentest-r6hfzf8n.js");
120235
+ const { runPentestWorkflow: workflow } = await import("./pentest-wy4eeagc.js");
120244
120236
  if (!ctx.model) {
120245
120237
  return {
120246
120238
  success: false,
@@ -121816,7 +121808,7 @@ Returns an array of results with the text output from each agent.`,
121816
121808
  });
121817
121809
  }
121818
121810
  async function runSingleCodingAgent(ctx, codebasePath, objective, agentIndex, name) {
121819
- const { CodeAgent } = await import("./agent-mjyx1amj.js");
121811
+ const { CodeAgent } = await import("./agent-84enr6xn.js");
121820
121812
  const subagentId = `coding-agent-${agentIndex}`;
121821
121813
  ctx.eventBus?.emit("subagent-spawn", {
121822
121814
  subagentId,
@@ -121863,11 +121855,8 @@ async function runSingleCodingAgent(ctx, codebasePath, objective, agentIndex, na
121863
121855
  // src/core/findings/registry.ts
121864
121856
  init_zod();
121865
121857
  init_ai();
121866
- init_structured();
121867
- init_lazyLogger();
121868
121858
  import { existsSync as existsSync16, readdirSync as readdirSync3, readFileSync as readFileSync4 } from "fs";
121869
121859
  import { join as join23 } from "path";
121870
- var log9 = scopedLogger(() => createLogger("findings:registry"));
121871
121860
  var VULN_CLASS_PATTERNS = [
121872
121861
  [/sql\s*injection/i, "sql-injection"],
121873
121862
  [/command\s*injection/i, "command-injection"],
@@ -122046,22 +122035,22 @@ class FindingsRegistry {
122046
122035
  if (!existsSync16(findingsPath))
122047
122036
  return registry;
122048
122037
  const files = readdirSync3(findingsPath).filter((f) => f.endsWith(".json"));
122049
- log9.debug(`fromDirectory: path=${findingsPath}, jsonFiles=${files.length}`);
122038
+ console.log(`[FindingsRegistry.fromDirectory] path=${findingsPath}, jsonFiles=${files.length}`);
122050
122039
  for (const file of files) {
122051
122040
  try {
122052
122041
  const raw = readFileSync4(join23(findingsPath, file), "utf-8");
122053
122042
  const finding = JSON.parse(raw);
122054
122043
  if (finding && typeof finding.title === "string" && typeof finding.endpoint === "string") {
122055
122044
  registry.indexFinding(finding);
122056
- log9.debug(`fromDirectory: indexed "${finding.title}" endpoint="${finding.endpoint}" (file=${file})`);
122045
+ console.log(`[FindingsRegistry.fromDirectory] indexed: "${finding.title}" endpoint="${finding.endpoint}" (file=${file})`);
122057
122046
  } else {
122058
- log9.debug(`fromDirectory: skipped (missing title/endpoint) file=${file}`);
122047
+ console.log(`[FindingsRegistry.fromDirectory] skipped (missing title/endpoint): file=${file}`);
122059
122048
  }
122060
122049
  } catch {
122061
- log9.debug(`fromDirectory: skipped (malformed) file=${file}`);
122050
+ console.log(`[FindingsRegistry.fromDirectory] skipped (malformed): file=${file}`);
122062
122051
  }
122063
122052
  }
122064
- log9.debug(`fromDirectory: registry initialized with ${registry.size} findings indexed`);
122053
+ console.log(`[FindingsRegistry.fromDirectory] Registry initialized: ${registry.size} findings indexed`);
122065
122054
  return registry;
122066
122055
  }
122067
122056
  static fromFindings(findings, opts) {
@@ -122092,19 +122081,19 @@ class FindingsRegistry {
122092
122081
  return { duplicate: false };
122093
122082
  }
122094
122083
  async register(finding) {
122095
- log9.debug(`register: checking "${finding.title}" endpoint="${finding.endpoint}"`);
122084
+ console.log(`[FindingsRegistry.register] Checking: "${finding.title}" endpoint="${finding.endpoint}"`);
122096
122085
  const fastResult = await new Promise((resolve6) => {
122097
122086
  this.mutex = this.mutex.then(() => {
122098
122087
  const check = this.isDuplicate(finding);
122099
122088
  if (check.duplicate) {
122100
- log9.debug(`register: DUPLICATE (${check.matchType}) "${finding.title}" matched="${check.matchedFinding?.title}"`);
122089
+ console.log(`[FindingsRegistry.register] DUPLICATE (${check.matchType}): "${finding.title}" matched="${check.matchedFinding?.title}"`);
122101
122090
  resolve6(check);
122102
122091
  } else if (!this.model || this.findings.length === 0) {
122103
122092
  this.indexFinding(finding);
122104
- log9.debug(`register: UNIQUE (Tier 1+2, no LLM needed) "${finding.title}" — registry size=${this.size}`);
122093
+ console.log(`[FindingsRegistry.register] UNIQUE (Tier 1+2, no LLM needed): "${finding.title}" — registry size=${this.size}`);
122105
122094
  resolve6({ duplicate: false });
122106
122095
  } else {
122107
- log9.debug(`register: Tier 1+2 pass — proceeding to Tier 3 LLM check for "${finding.title}"`);
122096
+ console.log(`[FindingsRegistry.register] Tier 1+2 pass — proceeding to Tier 3 LLM check for "${finding.title}"`);
122108
122097
  resolve6(null);
122109
122098
  }
122110
122099
  });
@@ -122116,21 +122105,21 @@ class FindingsRegistry {
122116
122105
  try {
122117
122106
  semanticResult = await this.semanticDedup(finding, snapshot);
122118
122107
  } catch {
122119
- log9.warn(`register: Tier 3 LLM error for "${finding.title}" — falling back to Tier 1+2 only`);
122108
+ console.log(`[FindingsRegistry.register] Tier 3 LLM error for "${finding.title}" — falling back to Tier 1+2 only`);
122120
122109
  }
122121
122110
  if (semanticResult.duplicate) {
122122
- log9.debug(`register: DUPLICATE (semantic/Tier 3) "${finding.title}" matched="${semanticResult.matchedFinding?.title}"`);
122111
+ console.log(`[FindingsRegistry.register] DUPLICATE (semantic/Tier 3): "${finding.title}" matched="${semanticResult.matchedFinding?.title}"`);
122123
122112
  return semanticResult;
122124
122113
  }
122125
122114
  return new Promise((resolve6) => {
122126
122115
  this.mutex = this.mutex.then(() => {
122127
122116
  const recheck = this.isDuplicate(finding);
122128
122117
  if (recheck.duplicate) {
122129
- log9.debug(`register: DUPLICATE (race re-check, ${recheck.matchType}) "${finding.title}" matched="${recheck.matchedFinding?.title}"`);
122118
+ console.log(`[FindingsRegistry.register] DUPLICATE (race re-check, ${recheck.matchType}): "${finding.title}" matched="${recheck.matchedFinding?.title}"`);
122130
122119
  resolve6(recheck);
122131
122120
  } else {
122132
122121
  this.indexFinding(finding);
122133
- log9.debug(`register: UNIQUE (all tiers passed) "${finding.title}" — registry size=${this.size}`);
122122
+ console.log(`[FindingsRegistry.register] UNIQUE (all tiers passed): "${finding.title}" — registry size=${this.size}`);
122134
122123
  resolve6({ duplicate: false });
122135
122124
  }
122136
122125
  });
@@ -122187,7 +122176,7 @@ class FindingsRegistry {
122187
122176
  abortSignal: this.abortSignal
122188
122177
  });
122189
122178
  } catch {
122190
- log9.warn("groupByRootCause: LLM error — skipping root-cause grouping");
122179
+ console.log(`[FindingsRegistry.groupByRootCause] LLM error — skipping root-cause grouping`);
122191
122180
  return [];
122192
122181
  }
122193
122182
  const sanitised = [];
@@ -122299,7 +122288,7 @@ Returns the worker's summary, objective results, and finding count — but NOT t
122299
122288
  message: "spawn_pentest_agent requires a model in the tool context."
122300
122289
  };
122301
122290
  }
122302
- const { TargetedPentestAgent } = await import("./agent-aj7jpehp.js");
122291
+ const { TargetedPentestAgent } = await import("./agent-z8043nrm.js");
122303
122292
  const findingsRegistry = ctx.findingsRegistry ?? FindingsRegistry.fromDirectory(ctx.session.findingsPath, {
122304
122293
  model: ctx.model,
122305
122294
  authConfig: ctx.authConfig,
@@ -122429,9 +122418,6 @@ ${existingContext}`;
122429
122418
  // src/core/agents/offSecAgent/tools/spawnPentestSwarm.ts
122430
122419
  init_dist();
122431
122420
  init_zod();
122432
- init_structured();
122433
- init_lazyLogger();
122434
- var log10 = scopedLogger(() => createLogger("spawn-pentest-swarm"));
122435
122421
  function spawnPentestSwarm(ctx) {
122436
122422
  return tool({
122437
122423
  description: `Launch a swarm of targeted pentest sub-agents to test multiple targets in parallel.
@@ -122453,7 +122439,7 @@ Pass every target you want tested — the swarm handles concurrency automaticall
122453
122439
  toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
122454
122440
  }),
122455
122441
  execute: async ({ targets }) => {
122456
- const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-r6hfzf8n.js");
122442
+ const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-wy4eeagc.js");
122457
122443
  if (!ctx.model) {
122458
122444
  return {
122459
122445
  success: false,
@@ -122466,7 +122452,8 @@ Pass every target you want tested — the swarm handles concurrency automaticall
122466
122452
  abortSignal: ctx.abortSignal
122467
122453
  });
122468
122454
  const total = targets.length;
122469
- log10.info(`Spawning pentest swarm: ${total} agents (concurrency: ${DEFAULT_CONCURRENCY2})`);
122455
+ console.log(`
122456
+ \uD83D\uDC1D Spawning pentest swarm: ${total} agents (concurrency: ${DEFAULT_CONCURRENCY2})`);
122470
122457
  const swarmResults = await runPentestSwarm({
122471
122458
  targets,
122472
122459
  model: ctx.model,
@@ -122500,9 +122487,6 @@ Pass every target you want tested — the swarm handles concurrency automaticall
122500
122487
  // src/core/agents/offSecAgent/tools/submitPlan.ts
122501
122488
  init_dist();
122502
122489
  init_zod();
122503
- init_structured();
122504
- init_lazyLogger();
122505
- var log11 = scopedLogger(() => createLogger("submit_plan"));
122506
122490
  var submitPlanInputSchema = exports_external.object({
122507
122491
  toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Submitting pentest plan for operator review')")
122508
122492
  });
@@ -122519,7 +122503,7 @@ Only call this when the plan is complete and ready for review.`,
122519
122503
  execute: async () => {
122520
122504
  const scopeId = ctx.planSubagentId ?? ctx.subagentId;
122521
122505
  const planPath = planFilePath(ctx.session.rootPath, scopeId);
122522
- log11.debug(`enter: path=${planPath}`);
122506
+ console.error(`[submit_plan] enter: path=${planPath}`);
122523
122507
  const plan = readPlan(ctx.session.rootPath, scopeId);
122524
122508
  if (!plan || !plan.trim()) {
122525
122509
  return {
@@ -122528,7 +122512,7 @@ Only call this when the plan is complete and ready for review.`,
122528
122512
  path: planPath
122529
122513
  };
122530
122514
  }
122531
- log11.debug(`done: planLen=${plan.length}`);
122515
+ console.error(`[submit_plan] done: planLen=${plan.length}`);
122532
122516
  return { success: true, error: "", path: planPath };
122533
122517
  }
122534
122518
  });
@@ -123087,12 +123071,9 @@ async function handleSearchResponse(response) {
123087
123071
  // src/core/agents/offSecAgent/tools/writePlan.ts
123088
123072
  init_dist();
123089
123073
  init_zod();
123090
- init_structured();
123091
123074
  import { mkdirSync as mkdirSync12 } from "fs";
123092
123075
  import { writeFile as writeFile5 } from "fs/promises";
123093
123076
  import { dirname as dirname4 } from "path";
123094
- init_lazyLogger();
123095
- var log12 = scopedLogger(() => createLogger("write_plan"));
123096
123077
  var writePlanInputSchema = exports_external.object({
123097
123078
  content: exports_external.string().describe("The full markdown content of the pentest plan"),
123098
123079
  toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Writing initial pentest plan with recon findings')")
@@ -123117,15 +123098,13 @@ Required plan sections:
123117
123098
  const scopeId = ctx.planSubagentId ?? ctx.subagentId;
123118
123099
  const planPath = planFilePath(ctx.session.rootPath, scopeId);
123119
123100
  mkdirSync12(dirname4(planPath), { recursive: true });
123120
- log12.debug(`enter: contentLen=${content.length}, path=${planPath}`);
123101
+ console.error(`[write_plan] enter: contentLen=${content.length}, path=${planPath}`);
123121
123102
  try {
123122
123103
  await writeFile5(planPath, content, "utf-8");
123123
- log12.debug("done");
123104
+ console.error(`[write_plan] done`);
123124
123105
  return { success: true, error: "", path: planPath };
123125
123106
  } catch (err) {
123126
- log12.error("write failed", err instanceof Error ? err : undefined, {
123127
- error: String(err)
123128
- });
123107
+ console.error(`[write_plan] error: ${err}`);
123129
123108
  return {
123130
123109
  success: false,
123131
123110
  error: err instanceof Error ? err.message : String(err),
@@ -124345,10 +124324,9 @@ class StepTraceWriter {
124345
124324
  // src/core/agents/offSecAgent/offensiveSecurityAgent.ts
124346
124325
  init_dist();
124347
124326
  init_ai();
124348
- import { existsSync as existsSync18, mkdirSync as mkdirSync14 } from "fs";
124327
+ import { existsSync as existsSync19, mkdirSync as mkdirSync14 } from "fs";
124349
124328
  import { writeFile as writeFile6 } from "fs/promises";
124350
124329
  import { join as join25 } from "path";
124351
- init_structured();
124352
124330
  init_observability();
124353
124331
 
124354
124332
  // src/core/operator/approvalGate.ts
@@ -124624,11 +124602,510 @@ var OperatorSettingsObject = exports_external.object({
124624
124602
  initialMode: exports_external.enum(["plan", "manual", "auto"]).default("manual"),
124625
124603
  requireApproval: exports_external.boolean().default(true)
124626
124604
  });
124627
- // src/core/agents/offSecAgent/offensiveSecurityAgent.ts
124628
- init_session();
124629
- init_lazyLogger();
124630
- var log13 = scopedLogger(() => createLogger("approval-gate"));
124605
+ // src/core/session/index.ts
124606
+ init_zod();
124607
+ import { existsSync as existsSync18, readFileSync as readFileSync6 } from "fs";
124608
+ import os from "os";
124609
+ import path from "path";
124610
+ init_installation();
124611
+ init_toolset();
124612
+ var DEFAULT_OUTCOME_GUIDANCE = "Prove the exploit can be run but do not exfiltrate data or cause any harm to the system. " + "Create proof-of-concept exploits that demonstrate the vulnerability exists without causing damage.";
124613
+ var EXFIL_OUTCOME_GUIDANCE = "Exfiltrate data to extract the flag value. " + "Create proof-of-concept exploits that successfully extract the flag from the target system.";
124614
+ var DEFAULT_HEADER_RECORD = {
124615
+ "User-Agent": "pensar-apex"
124616
+ };
124617
+ var AuthCredentialsObject = zod_default.object({
124618
+ username: zod_default.string().optional(),
124619
+ password: zod_default.string().optional(),
124620
+ loginUrl: zod_default.string().optional(),
124621
+ additionalFields: zod_default.record(zod_default.string(), zod_default.string()).optional(),
124622
+ apiKey: zod_default.string().optional(),
124623
+ role: zod_default.string().optional(),
124624
+ context: zod_default.string().optional(),
124625
+ tokens: zod_default.object({
124626
+ bearerToken: zod_default.string().optional(),
124627
+ cookies: zod_default.string().optional(),
124628
+ sessionToken: zod_default.string().optional(),
124629
+ customHeaders: zod_default.record(zod_default.string(), zod_default.string()).optional()
124630
+ }).optional()
124631
+ });
124632
+ var ScopeConstraintsObject = zod_default.object({
124633
+ allowedHosts: zod_default.string().array().optional(),
124634
+ allowedPorts: zod_default.number().array().optional(),
124635
+ strictScope: zod_default.boolean().optional()
124636
+ });
124637
+ var SessionHeadersRecord = zod_default.record(zod_default.string(), zod_default.string());
124638
+ var OffensiveHeadersConfigObject = zod_default.object({
124639
+ mode: zod_default.enum(["none", "default", "custom"]).optional(),
124640
+ headers: SessionHeadersRecord.optional()
124641
+ });
124642
+ var OperatorSettingsObject2 = zod_default.object({
124643
+ initialMode: zod_default.enum(["plan", "manual", "auto"]).default("manual"),
124644
+ requireApproval: zod_default.boolean().default(true),
124645
+ enableSuggestions: zod_default.boolean().default(true)
124646
+ });
124647
+ var EmailInboxConfigObject = zod_default.discriminatedUnion("provider", [
124648
+ zod_default.object({
124649
+ provider: zod_default.literal("gmail"),
124650
+ id: zod_default.string(),
124651
+ name: zod_default.string(),
124652
+ emailAddress: zod_default.string(),
124653
+ accessToken: zod_default.string(),
124654
+ refreshToken: zod_default.string(),
124655
+ clientId: zod_default.string().optional(),
124656
+ clientSecret: zod_default.string().optional(),
124657
+ tokenExpiry: zod_default.number().optional()
124658
+ }),
124659
+ zod_default.object({
124660
+ provider: zod_default.literal("outlook"),
124661
+ id: zod_default.string(),
124662
+ name: zod_default.string(),
124663
+ emailAddress: zod_default.string(),
124664
+ accessToken: zod_default.string(),
124665
+ refreshToken: zod_default.string(),
124666
+ clientId: zod_default.string().optional(),
124667
+ clientSecret: zod_default.string().optional(),
124668
+ tokenExpiry: zod_default.number().optional()
124669
+ }),
124670
+ zod_default.object({
124671
+ provider: zod_default.literal("imap"),
124672
+ id: zod_default.string(),
124673
+ name: zod_default.string(),
124674
+ emailAddress: zod_default.string(),
124675
+ imapHost: zod_default.string(),
124676
+ imapPort: zod_default.number(),
124677
+ username: zod_default.string(),
124678
+ password: zod_default.string(),
124679
+ tls: zod_default.boolean()
124680
+ })
124681
+ ]);
124682
+ var EmailIntegrationConfigObject = zod_default.object({
124683
+ inboxes: zod_default.array(EmailInboxConfigObject)
124684
+ });
124685
+ var SmtpConfigObject = zod_default.object({
124686
+ host: zod_default.string(),
124687
+ port: zod_default.number(),
124688
+ username: zod_default.string(),
124689
+ password: zod_default.string(),
124690
+ tls: zod_default.boolean().default(true),
124691
+ fromAddress: zod_default.string().optional()
124692
+ });
124693
+ function resolveSmtpConfig(explicit) {
124694
+ if (explicit)
124695
+ return explicit;
124696
+ const fromAddress = process.env.OUTBOUND_EMAIL;
124697
+ const resendKey = process.env.RESEND_API_KEY;
124698
+ if (resendKey) {
124699
+ return {
124700
+ host: "smtp.resend.com",
124701
+ port: 465,
124702
+ username: "resend",
124703
+ password: resendKey,
124704
+ tls: true,
124705
+ fromAddress
124706
+ };
124707
+ }
124708
+ const host = process.env.SMTP_HOST;
124709
+ const port = process.env.SMTP_PORT;
124710
+ const username = process.env.SMTP_USERNAME;
124711
+ const password = process.env.SMTP_PASSWORD;
124712
+ if (host && port && username && password) {
124713
+ return {
124714
+ host,
124715
+ port: parseInt(port, 10),
124716
+ username,
124717
+ password,
124718
+ tls: process.env.SMTP_TLS !== "false",
124719
+ fromAddress
124720
+ };
124721
+ }
124722
+ return;
124723
+ }
124724
+ var SessionConfigObject = zod_default.object({
124725
+ headers: SessionHeadersRecord.optional(),
124726
+ offensiveHeaders: OffensiveHeadersConfigObject.optional(),
124727
+ sessionType: zod_default.enum(["web-app"]).optional(),
124728
+ mode: zod_default.enum(["auto", "driver", "operator"]).optional(),
124729
+ outcomeGuidance: zod_default.string().optional(),
124730
+ scopeConstraints: ScopeConstraintsObject.optional(),
124731
+ authCredentials: zod_default.union([AuthCredentialsObject, zod_default.array(AuthCredentialsObject)]).optional(),
124732
+ authenticationInstructions: zod_default.string().optional(),
124733
+ requestsPerSecond: zod_default.number().optional(),
124734
+ operatorSettings: OperatorSettingsObject2.optional(),
124735
+ toolsetState: ToolsetStateSchema.optional(),
124736
+ enumerateSubdomains: zod_default.boolean().optional(),
124737
+ codebasePath: zod_default.string().optional(),
124738
+ emailIntegration: EmailIntegrationConfigObject.optional(),
124739
+ smtpConfig: SmtpConfigObject.optional(),
124740
+ exfilMode: zod_default.boolean().optional(),
124741
+ agentCwd: zod_default.string().optional(),
124742
+ prompt: zod_default.string().optional(),
124743
+ taskDriven: zod_default.boolean().optional(),
124744
+ requirePlan: zod_default.boolean().optional()
124745
+ });
124746
+ function getPensarDir() {
124747
+ return path.join(os.homedir(), ".pensar");
124748
+ }
124749
+ function getSessionsDir() {
124750
+ return path.join(getPensarDir(), "sessions");
124751
+ }
124752
+ function getSessionRoot(id) {
124753
+ return path.join(getSessionsDir(), id);
124754
+ }
124755
+ async function createSessionDirs(input) {
124756
+ const { session } = input;
124757
+ await createDir(["sessions", session.id]);
124758
+ await createDir(["sessions", session.id, "findings"]);
124759
+ await createDir(["sessions", session.id, "scratchpad"]);
124760
+ await createDir(["sessions", session.id, "logs"]);
124761
+ await createDir(["sessions", session.id, "pocs"]);
124762
+ const startTime = new Date().toISOString();
124763
+ const readme = generateSessionReadme(session);
124764
+ await writeRaw(["sessions", session.id, "README.md"], readme);
124765
+ console.info("created session", session.id);
124766
+ }
124767
+ function generateSessionReadme(session) {
124768
+ return `# Penetration Test Session
124769
+
124770
+ **Session ID:** ${session.id}
124771
+ **Target:** ${session.targets}
124772
+ **Objective:** ${session.config?.outcomeGuidance}
124773
+ **Started:** ${session.time.created}
124774
+
124775
+ ## Directory Structure
124776
+
124777
+ - \`findings/\` - Security findings and vulnerabilities
124778
+ - \`scratchpad/\` - Notes and temporary data during testing
124779
+ - \`logs/\` - Execution logs and command outputs
124780
+ - \`pocs/\` - Proof-of-concept exploit scripts
124781
+ - \`session.json\` - Session metadata
124782
+
124783
+ ## Findings
124784
+
124785
+ Security findings will be documented in the \`findings/\` directory as individual files.
124786
+
124787
+ ## Status
124788
+
124789
+ Testing in progress...
124790
+ `;
124791
+ }
124792
+ function normalizeDeprecatedHeaders(config2) {
124793
+ if (!config2)
124794
+ return config2;
124795
+ if (config2.offensiveHeaders == null) {
124796
+ const { offensiveHeaders: _drop, ...rest2 } = config2;
124797
+ return rest2;
124798
+ }
124799
+ const { offensiveHeaders, ...rest } = config2;
124800
+ const restWithHeaders = rest;
124801
+ if (restWithHeaders.headers !== undefined) {
124802
+ return restWithHeaders;
124803
+ }
124804
+ const oh = offensiveHeaders;
124805
+ if (oh.mode === "none") {
124806
+ return { ...restWithHeaders, headers: {} };
124807
+ }
124808
+ let headers = {};
124809
+ if (oh.mode === "default")
124810
+ headers = { ...DEFAULT_HEADER_RECORD };
124811
+ if (oh.headers)
124812
+ headers = { ...headers, ...oh.headers };
124813
+ return { ...restWithHeaders, headers };
124814
+ }
124815
+ function migrateLegacySessionData(input) {
124816
+ if (!input || typeof input !== "object")
124817
+ return input;
124818
+ const root = input;
124819
+ const config2 = root.config;
124820
+ if (!config2 || typeof config2 !== "object")
124821
+ return input;
124822
+ const cfg = config2;
124823
+ if (!("offensiveHeaders" in cfg))
124824
+ return input;
124825
+ return { ...root, config: normalizeDeprecatedHeaders(cfg) };
124826
+ }
124827
+ var SessionInfoObject = zod_default.object({
124828
+ id: schema("session"),
124829
+ name: zod_default.string().optional(),
124830
+ version: zod_default.string(),
124831
+ targets: zod_default.array(zod_default.string()),
124832
+ config: SessionConfigObject.optional(),
124833
+ time: zod_default.object({
124834
+ created: zod_default.number(),
124835
+ updated: zod_default.number()
124836
+ }),
124837
+ rootPath: zod_default.string(),
124838
+ logsPath: zod_default.string(),
124839
+ findingsPath: zod_default.string(),
124840
+ scratchpadPath: zod_default.string(),
124841
+ pocsPath: zod_default.string()
124842
+ });
124843
+ async function create(input) {
124844
+ const name = input.name ?? generateRandomName();
124845
+ const normalizedConfig = normalizeDeprecatedHeaders(input.config);
124846
+ const id = `${input.prefix ? input.prefix : ""}` + descending("session", input.id);
124847
+ const rootPath = getSessionRoot(id);
124848
+ const findingsPath = path.join(rootPath, "findings");
124849
+ const scratchpadPath = path.join(rootPath, "scratchpad");
124850
+ const logsPath = path.join(rootPath, "logs");
124851
+ const pocsPath = path.join(rootPath, "pocs");
124852
+ const rateLimiter = new RateLimiter({
124853
+ requestsPerSecond: normalizedConfig?.requestsPerSecond
124854
+ });
124855
+ let credentialManager;
124856
+ if (normalizedConfig?.authCredentials) {
124857
+ credentialManager = new CredentialManager;
124858
+ const creds = Array.isArray(normalizedConfig.authCredentials) ? normalizedConfig.authCredentials : [normalizedConfig.authCredentials];
124859
+ for (const cred of creds) {
124860
+ credentialManager.addFromAuthCredentials(cred);
124861
+ }
124862
+ }
124863
+ const smtpConfig = resolveSmtpConfig(normalizedConfig?.smtpConfig);
124864
+ let snapshotHeaders;
124865
+ if (normalizedConfig?.headers !== undefined) {
124866
+ snapshotHeaders = { ...normalizedConfig.headers };
124867
+ } else {
124868
+ const { config: appConfig } = await import("./index-2a1x5nnv.js");
124869
+ const cfg = await appConfig.get();
124870
+ snapshotHeaders = cfg.defaultHeaders ? { ...cfg.defaultHeaders } : { ...DEFAULT_HEADER_RECORD };
124871
+ }
124872
+ const result = {
124873
+ id,
124874
+ version: getCurrentVersion(),
124875
+ targets: input.targets,
124876
+ name,
124877
+ time: {
124878
+ created: Date.now(),
124879
+ updated: Date.now()
124880
+ },
124881
+ config: {
124882
+ ...normalizedConfig,
124883
+ mode: normalizedConfig?.mode || "auto",
124884
+ headers: snapshotHeaders,
124885
+ outcomeGuidance: normalizedConfig?.outcomeGuidance || (normalizedConfig?.exfilMode ? EXFIL_OUTCOME_GUIDANCE : DEFAULT_OUTCOME_GUIDANCE),
124886
+ smtpConfig
124887
+ },
124888
+ _rateLimiter: rateLimiter,
124889
+ credentialManager,
124890
+ rootPath,
124891
+ logsPath,
124892
+ pocsPath,
124893
+ scratchpadPath,
124894
+ findingsPath
124895
+ };
124896
+ const { _rateLimiter, credentialManager: _cm, ...sessionData } = result;
124897
+ await createSessionDirs({ session: result });
124898
+ await write(["sessions", result.id, "session"], sessionData);
124899
+ if (!input.name && input.model) {
124900
+ generateSessionName({
124901
+ targets: input.targets,
124902
+ userMessage: input.userMessage,
124903
+ model: input.model,
124904
+ authConfig: input.authConfig
124905
+ }).then((aiName) => {
124906
+ if (aiName) {
124907
+ result.name = aiName;
124908
+ update2(result.id, (s) => {
124909
+ s.name = aiName;
124910
+ }).catch(() => {});
124911
+ input.onNameGenerated?.(aiName);
124912
+ }
124913
+ });
124914
+ }
124915
+ return result;
124916
+ }
124917
+ var get = async (id) => {
124918
+ const raw = await read(["sessions", id, "session"]);
124919
+ const read2 = migrateLegacySessionData(raw);
124920
+ if (read2.config?.requestsPerSecond) {
124921
+ read2._rateLimiter = new RateLimiter({
124922
+ requestsPerSecond: read2.config.requestsPerSecond
124923
+ });
124924
+ } else {
124925
+ delete read2._rateLimiter;
124926
+ }
124927
+ return read2;
124928
+ };
124929
+ async function update2(id, editor) {
124930
+ const result = await update(["sessions", id, "session"], (draft) => {
124931
+ editor(draft);
124932
+ draft.time.updated = Date.now();
124933
+ });
124934
+ return result;
124935
+ }
124936
+ async function* list2() {
124937
+ const sessionsDir = getSessionsDir();
124938
+ let entries;
124939
+ try {
124940
+ entries = await import("fs/promises").then((fsp) => fsp.readdir(sessionsDir, { withFileTypes: true }));
124941
+ } catch {
124942
+ return;
124943
+ }
124944
+ for (const entry of entries) {
124945
+ if (!entry.isDirectory())
124946
+ continue;
124947
+ try {
124948
+ yield await read([
124949
+ "sessions",
124950
+ entry.name,
124951
+ "session"
124952
+ ]);
124953
+ } catch {}
124954
+ }
124955
+ }
124956
+ var RemoveInput = zod_default.object({
124957
+ sessionId: schema("session")
124958
+ });
124959
+ var remove2 = async (input) => {
124960
+ try {
124961
+ const sessionDir = getSessionRoot(input.sessionId);
124962
+ const fsp = await import("fs/promises");
124963
+ await fsp.rm(sessionDir, { recursive: true, force: true });
124964
+ } catch (e) {
124965
+ console.error(e);
124966
+ }
124967
+ };
124968
+ var RemoveMsgInput = zod_default.object({
124969
+ sessionId: schema("session"),
124970
+ messageId: schema("message")
124971
+ });
124972
+ async function loadOperatorState(sessionId) {
124973
+ try {
124974
+ const session = await get(sessionId);
124975
+ const statePath = path.join(session.rootPath, "messages.json");
124976
+ if (!existsSync18(statePath))
124977
+ return null;
124978
+ const data = readFileSync6(statePath, "utf-8");
124979
+ const parsed = JSON.parse(data);
124980
+ if (Array.isArray(parsed)) {
124981
+ return {
124982
+ mode: session.config?.operatorSettings?.initialMode ?? "manual",
124983
+ requireApproval: session.config?.operatorSettings?.requireApproval ?? true,
124984
+ currentStage: "recon",
124985
+ messages: parsed,
124986
+ attackSurface: [],
124987
+ credentials: [],
124988
+ verifiedVulns: [],
124989
+ targetState: null,
124990
+ hypotheses: [],
124991
+ evidence: [],
124992
+ actionHistory: [],
124993
+ pausedAt: new Date().toISOString(),
124994
+ lastRunId: ""
124995
+ };
124996
+ }
124997
+ return parsed;
124998
+ } catch (error) {
124999
+ console.error("Error loading operator state:", error);
125000
+ return null;
125001
+ }
125002
+ }
125003
+ function hasOperatorState(session) {
125004
+ const statePath = path.join(session.rootPath, "messages.json");
125005
+ return existsSync18(statePath);
125006
+ }
125007
+ var MAX_RESUME_MESSAGES = 200;
125008
+ function getResumeMessages(messages, limit = MAX_RESUME_MESSAGES) {
125009
+ if (messages.length <= limit)
125010
+ return messages;
125011
+ let cutIndex = messages.length - limit;
125012
+ while (cutIndex < messages.length) {
125013
+ if (messages[cutIndex].role === "user")
125014
+ break;
125015
+ cutIndex++;
125016
+ }
125017
+ if (cutIndex >= messages.length) {
125018
+ cutIndex = messages.length - limit;
125019
+ }
125020
+ return messages.slice(cutIndex);
125021
+ }
125022
+ function normalizeMessages(messages) {
125023
+ if (messages.length <= 1)
125024
+ return fixToolOutputs(messages);
125025
+ const result = [];
125026
+ for (const msg of messages) {
125027
+ const prev = result[result.length - 1];
125028
+ if (prev && prev.role === "user" && msg.role === "user" && typeof prev.content === "string" && typeof msg.content === "string") {
125029
+ result[result.length - 1] = {
125030
+ ...prev,
125031
+ content: `${prev.content}
125032
+
125033
+ ${msg.content}`
125034
+ };
125035
+ } else if (prev && prev.role === "user" && msg.role === "user") {
125036
+ result[result.length - 1] = msg;
125037
+ } else {
125038
+ result.push(msg);
125039
+ }
125040
+ }
125041
+ return fixToolOutputs(result);
125042
+ }
125043
+ function fixToolOutputs(messages) {
125044
+ let changed = false;
125045
+ const fixed = messages.map((msg) => {
125046
+ if (msg.role !== "tool" || !Array.isArray(msg.content))
125047
+ return msg;
125048
+ let partChanged = false;
125049
+ const fixedContent = msg.content.map((part) => {
125050
+ if (part.type === "tool-result" && typeof part.output === "string") {
125051
+ partChanged = true;
125052
+ return { ...part, output: { type: "text", value: part.output } };
125053
+ }
125054
+ return part;
125055
+ });
125056
+ if (partChanged) {
125057
+ changed = true;
125058
+ return { ...msg, content: fixedContent };
125059
+ }
125060
+ return msg;
125061
+ });
125062
+ return changed ? fixed : messages;
125063
+ }
125064
+ async function updateOperatorSettings(sessionId, settings) {
125065
+ return await update2(sessionId, (session) => {
125066
+ if (!session.config) {
125067
+ session.config = {};
125068
+ }
125069
+ if (!session.config.operatorSettings) {
125070
+ session.config.operatorSettings = {
125071
+ initialMode: "manual",
125072
+ requireApproval: true,
125073
+ enableSuggestions: true
125074
+ };
125075
+ }
125076
+ if (settings.initialMode !== undefined) {
125077
+ session.config.operatorSettings.initialMode = settings.initialMode;
125078
+ }
125079
+ if (settings.requireApproval !== undefined) {
125080
+ session.config.operatorSettings.requireApproval = settings.requireApproval;
125081
+ }
125082
+ if (settings.enableSuggestions !== undefined) {
125083
+ session.config.operatorSettings.enableSuggestions = settings.enableSuggestions;
125084
+ }
125085
+ });
125086
+ }
125087
+ async function updateSessionHeaders(sessionId, headers) {
125088
+ return await update2(sessionId, (session) => {
125089
+ if (!session.config) {
125090
+ session.config = {};
125091
+ }
125092
+ session.config.headers = { ...headers };
125093
+ });
125094
+ }
125095
+ var sessions = {
125096
+ getSessionRoot,
125097
+ EXFIL_OUTCOME_GUIDANCE,
125098
+ create,
125099
+ get,
125100
+ remove: remove2,
125101
+ loadOperatorState,
125102
+ hasOperatorState,
125103
+ getResumeMessages,
125104
+ updateOperatorSettings,
125105
+ updateSessionHeaders
125106
+ };
124631
125107
 
125108
+ // src/core/agents/offSecAgent/offensiveSecurityAgent.ts
124632
125109
  class OffensiveSecurityAgent {
124633
125110
  _streamResult = null;
124634
125111
  createStream;
@@ -124761,7 +125238,7 @@ class OffensiveSecurityAgent {
124761
125238
  const planSet = new Set(PLAN_MODE_TOOL_NAMES);
124762
125239
  activeTools = activeTools.filter((t) => planSet.has(t));
124763
125240
  }
124764
- if (!existsSync18(messagesDir)) {
125241
+ if (!existsSync19(messagesDir)) {
124765
125242
  mkdirSync14(messagesDir, { recursive: true });
124766
125243
  }
124767
125244
  const messagesPath = join25(messagesDir, "messages.json");
@@ -124932,19 +125409,19 @@ function wrapToolsWithApprovalGate(tools, gate, exemptToolNames) {
124932
125409
  ...t,
124933
125410
  execute: async (args, options) => {
124934
125411
  const toolCallId = args.toolCallId ?? `tc_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
124935
- log13.debug(`${name} (${toolCallId}): checking`);
125412
+ console.error(`[approval-gate] ${name} (${toolCallId}): checking`);
124936
125413
  try {
124937
125414
  await gate.check(name, String(toolCallId), args);
124938
125415
  } catch (err) {
124939
125416
  if (err instanceof ApprovalDeniedError) {
124940
- log13.debug(`${name} (${toolCallId}): denied`);
125417
+ console.error(`[approval-gate] ${name} (${toolCallId}): denied`);
124941
125418
  return { blocked: true, reason: "Denied by operator" };
124942
125419
  }
124943
125420
  throw err;
124944
125421
  }
124945
- log13.debug(`${name} (${toolCallId}): approved, executing`);
125422
+ console.error(`[approval-gate] ${name} (${toolCallId}): approved, executing`);
124946
125423
  const result = await originalExecute(args, options);
124947
- log13.debug(`${name} (${toolCallId}): execute finished`);
125424
+ console.error(`[approval-gate] ${name} (${toolCallId}): execute finished`);
124948
125425
  return result;
124949
125426
  }
124950
125427
  };
@@ -124952,4 +125429,4 @@ function wrapToolsWithApprovalGate(tools, gate, exemptToolNames) {
124952
125429
  return wrapped;
124953
125430
  }
124954
125431
 
124955
- export { AgentEventBus, INTERNAL_ID_PATTERN, ApprovalGate, OPERATOR_MODES, OPERATOR_MODE_CYCLE, createInitialOperatorState, buildProvidedFilesSection, buildSessionWorkspaceSection, buildBaseSystemPrompt, BASE_SYSTEM_PROMPT, isMemoryEnabled, addMemory2 as addMemory, ASK_USER_QUESTIONS_TOOL_NAME, AskUserQuestionSchema, ScopeViolationError, getAllowedHosts, isHostAllowed, extractHostname2 as extractHostname, assertUrlInScope, extractHostsFromCommand, assertCommandInScope, authenticateSession, transformScriptToFunction, parseStorageStateResult, setHeadlessMode, setUserAgent, setViewportSize, PlaywrightMcpSession, createBrowserTools, checkSandboxPlaywright, installSandboxPlaywright, ensureSandboxPlaywright, ensureSandboxBrowser, createSandboxBrowserTools, BROWSER_TOOL_NAMES, createBrowserToolset, checkpointState, completeAuthentication, crawlAuthenticated, createAttackSurfaceReport, createFile, createTask2 as createTask, delegateAuth, detectAuthScheme, documentApp, documentEndpoint, CweEntrySchema, ValidatedCweEntrySchema, hasCanonicalName, documentVulnerability, createEmailToolset, EMAIL_TOOL_NAMES, SEND_EMAIL_TOOL_NAME, executeCommand, extractJsEndpoints, getMemory2 as getMemory, getPage, grep, httpRequest, listFiles, listMemories2 as listMemories, listTasksTool, readTempfileCapped, getApexTmpRoot, extractFallbackStdout, PersistentShell, probeAuthEndpoints, provideComparisonResults, readFile2 as readFile, readSkill, RESPONSE_TOOL_NAME, createResponseTool, runAttackSurface, runPentestWorkflow, runWithBoundedConcurrency, spawnCodingAgent, FindingsRegistry, planFilePath, readPlan, hasPlan, spawnPentestAgent, spawnPentestSwarm, submitPlan, testEndpointVariations, updateFile, updateTask2 as updateTask, validateDiscovery, webSearch, writePlan, createAllTools, ALL_TOOL_NAMES, PLAN_MODE_TOOL_NAMES, SKILL_TOOL_NAMES, StepTraceWriter, OffensiveSecurityAgent };
125432
+ export { AgentEventBus, INTERNAL_ID_PATTERN, ApprovalGate, OPERATOR_MODES, OPERATOR_MODE_CYCLE, createInitialOperatorState, list2 as list, normalizeMessages, sessions, buildProvidedFilesSection, buildSessionWorkspaceSection, buildBaseSystemPrompt, BASE_SYSTEM_PROMPT, isMemoryEnabled, addMemory2 as addMemory, ASK_USER_QUESTIONS_TOOL_NAME, AskUserQuestionSchema, ScopeViolationError, getAllowedHosts, isHostAllowed, extractHostname2 as extractHostname, assertUrlInScope, extractHostsFromCommand, assertCommandInScope, authenticateSession, transformScriptToFunction, parseStorageStateResult, setHeadlessMode, setUserAgent, setViewportSize, PlaywrightMcpSession, createBrowserTools, checkSandboxPlaywright, installSandboxPlaywright, ensureSandboxPlaywright, ensureSandboxBrowser, createSandboxBrowserTools, BROWSER_TOOL_NAMES, createBrowserToolset, checkpointState, completeAuthentication, crawlAuthenticated, createAttackSurfaceReport, createFile, createTask2 as createTask, delegateAuth, detectAuthScheme, documentApp, documentEndpoint, CweEntrySchema, ValidatedCweEntrySchema, hasCanonicalName, documentVulnerability, createEmailToolset, EMAIL_TOOL_NAMES, SEND_EMAIL_TOOL_NAME, executeCommand, extractJsEndpoints, getMemory2 as getMemory, getPage, grep, httpRequest, listFiles, listMemories2 as listMemories, listTasksTool, readTempfileCapped, getApexTmpRoot, extractFallbackStdout, PersistentShell, probeAuthEndpoints, provideComparisonResults, readFile2 as readFile, readSkill, RESPONSE_TOOL_NAME, createResponseTool, runAttackSurface, runPentestWorkflow, runWithBoundedConcurrency, spawnCodingAgent, FindingsRegistry, planFilePath, readPlan, hasPlan, spawnPentestAgent, spawnPentestSwarm, submitPlan, testEndpointVariations, updateFile, updateTask2 as updateTask, validateDiscovery, webSearch, writePlan, createAllTools, ALL_TOOL_NAMES, PLAN_MODE_TOOL_NAMES, SKILL_TOOL_NAMES, StepTraceWriter, OffensiveSecurityAgent };