@wrongstack/core 0.3.3 → 0.3.4

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.
@@ -1,11 +1,11 @@
1
- export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-HsBLGRaA.js';
1
+ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-DY0iSXYf.js';
2
2
  import { g as Provider, a0 as Context } from '../context-IovtuTf8.js';
3
3
  import { a as Compactor, C as CompactReport } from '../compactor-DpJBI1YH.js';
4
4
  import { M as MessageSelector } from '../selector-wT2fv9Fg.js';
5
5
  import { E as EventBus } from '../events-BHIQs4o1.js';
6
6
  import { c as MiddlewareHandler } from '../system-prompt-Dk1qm8ey.js';
7
- import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-D2qvAxVd.js';
8
- import { r as Agent, R as RunResult } from '../index-hWNybrNZ.js';
7
+ import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-DgE3JslD.js';
8
+ import { r as Agent, R as RunResult } from '../index-DedY4Euf.js';
9
9
  import { D as DoneCondition } from '../multi-agent-B9a6sflH.js';
10
10
  import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-C_7znCIC.js';
11
11
  import { a as WstackPaths } from '../wstack-paths-BGu2INTm.js';
@@ -1318,11 +1318,55 @@ var ToolExecutor = class {
1318
1318
  }
1319
1319
  };
1320
1320
 
1321
+ // src/utils/regex-guard.ts
1322
+ var MAX_PATTERN_LEN = 512;
1323
+ var DANGEROUS_PATTERNS = [
1324
+ /(\([^)]*[+*][^)]*\))[+*]/,
1325
+ // (a+)+, (.*)+, etc
1326
+ /(\(\?:[^)]*[+*][^)]*\))[+*]/
1327
+ // same, with non-capturing group
1328
+ ];
1329
+ function compileUserRegex(pattern, flags) {
1330
+ if (typeof pattern !== "string") {
1331
+ return { ok: false, reason: "pattern must be a string" };
1332
+ }
1333
+ if (pattern.length === 0) {
1334
+ return { ok: false, reason: "pattern is empty" };
1335
+ }
1336
+ if (pattern.length > MAX_PATTERN_LEN) {
1337
+ return { ok: false, reason: `pattern exceeds ${MAX_PATTERN_LEN} characters` };
1338
+ }
1339
+ for (const rx of DANGEROUS_PATTERNS) {
1340
+ if (rx.test(pattern)) {
1341
+ return {
1342
+ ok: false,
1343
+ reason: "pattern looks vulnerable to catastrophic backtracking \u2014 rewrite without nested quantifiers"
1344
+ };
1345
+ }
1346
+ }
1347
+ try {
1348
+ return { ok: true, regex: new RegExp(pattern, flags) };
1349
+ } catch (err) {
1350
+ return {
1351
+ ok: false,
1352
+ reason: err instanceof Error ? err.message : "invalid regex"
1353
+ };
1354
+ }
1355
+ }
1356
+
1321
1357
  // src/execution/autonomous-runner.ts
1322
1358
  var DoneConditionChecker = class {
1323
1359
  constructor(condition) {
1324
1360
  this.condition = condition;
1325
- this.compiledRegex = condition.type === "output_match" && condition.pattern ? new RegExp(condition.pattern) : null;
1361
+ if (condition.type === "output_match" && condition.pattern) {
1362
+ const result = compileUserRegex(condition.pattern, "");
1363
+ this.compiledRegex = result.ok ? result.regex : null;
1364
+ if (!result.ok) {
1365
+ console.warn(`[DoneConditionChecker] Invalid regex pattern "${condition.pattern}": ${result.reason}`);
1366
+ }
1367
+ } else {
1368
+ this.compiledRegex = null;
1369
+ }
1326
1370
  }
1327
1371
  condition;
1328
1372
  compiledRegex;