@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.
@@ -2,7 +2,7 @@ import { a0 as Context, h as ProviderError, u as Tool, D as ToolUseBlock, z as T
2
2
  import { a as Compactor, C as CompactReport } from './compactor-DpJBI1YH.js';
3
3
  import { c as RecoveryDecision, E as ErrorHandler, R as RetryPolicy } from './skill-C_7znCIC.js';
4
4
  import { M as ModelsRegistry } from './models-registry-Y2xbog0E.js';
5
- import { k as ToolExecutorOptions, l as ToolExecutorStrategy, m as ToolBatchResult } from './index-hWNybrNZ.js';
5
+ import { k as ToolExecutorOptions, l as ToolExecutorStrategy, m as ToolBatchResult } from './index-DedY4Euf.js';
6
6
 
7
7
  interface CompactorOptions {
8
8
  preserveK?: number;
@@ -1,6 +1,6 @@
1
1
  export { A as AgentError, C as Capabilities, a as ConfigError, b as ContentBlock, E as ErrorCode, c as ErrorSeverity, d as ErrorSubsystem, I as ImageBlock, J as JSONSchema, M as Message, e as MessageRole, P as Permission, f as PluginError, g as Provider, h as ProviderError, i as ProviderErrorBody, R as Request, j as Response, k as ResumedSession, S as SessionData, l as SessionError, m as SessionEvent, n as SessionMetadata, o as SessionStore, p as SessionSummary, q as SessionWriter, r as StopReason, s as StreamEvent, T as TextBlock, t as ThinkingBlock, u as Tool, v as ToolCallContext, w as ToolError, x as ToolFinalEvent, y as ToolProgressEvent, z as ToolResultBlock, B as ToolStreamEvent, D as ToolUseBlock, U as Usage, W as WrongStackError, F as asBlocks, G as asText, H as isAgentError, K as isConfigError, L as isImageBlock, N as isPluginError, O as isSessionError, Q as isTextBlock, V as isThinkingBlock, X as isToolError, Y as isToolResultBlock, Z as isToolUseBlock, _ as isWrongStackError, $ as toWrongStackError } from '../context-IovtuTf8.js';
2
2
  export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-B39miKRw.js';
3
- export { C as CONTEXT_WINDOW_MODES, a as Config, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, M as MCPServerConfig, P as PluginConfig, k as ProviderApiKey, l as ProviderConfig, T as ToolsConfig, m as formatContextWindowModeList, n as getContextWindowMode, o as isContextWindowModeId, p as listContextWindowModes, r as resolveContextWindowPolicy } from '../config-D2qvAxVd.js';
3
+ export { C as CONTEXT_WINDOW_MODES, a as Config, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, M as MCPServerConfig, P as PluginConfig, k as ProviderApiKey, l as ProviderConfig, T as ToolsConfig, m as formatContextWindowModeList, n as getContextWindowMode, o as isContextWindowModeId, p as listContextWindowModes, r as resolveContextWindowPolicy } from '../config-DgE3JslD.js';
4
4
  export { C as CompactReport, a as Compactor } from '../compactor-DpJBI1YH.js';
5
5
  export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from '../secret-scrubber-CgG2tV2B.js';
6
6
  export { A as AddAttachmentInput, a as Attachment, b as AttachmentKind, c as AttachmentMeta, d as AttachmentRef, e as AttachmentStore, D as DefaultSessionReader } from '../session-reader-CcPi4BQ8.js';
@@ -8,11 +8,11 @@ export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOp
8
8
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
9
9
  export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver--59rCou3.js';
10
10
  export { M as MemoryEntry, a as MemoryScope, b as MemoryStore } from '../memory-CEXuo7sz.js';
11
- export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from '../tool-executor-HsBLGRaA.js';
11
+ export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from '../tool-executor-DY0iSXYf.js';
12
12
  export { S as SkillEntry, a as SkillLoader, b as SkillManifest } from '../skill-C_7znCIC.js';
13
13
  export { B as BuildContext, M as ModelCapabilities, R as Renderer, S as SystemPromptBuilder } from '../system-prompt-Dk1qm8ey.js';
14
14
  export { I as InputReader, P as PromptOption } from '../input-reader-E-ffP2ee.js';
15
- export { M as MCPRegistryView, a as MetricsSinkView, P as Plugin, b as PluginAPI, c as PluginCapabilities, d as PluginDependency, e as PluginPipelines, f as ProviderFactory, g as ProviderRegistryView, S as SessionWriterView, h as SlashCommand, i as SlashCommandRegistryView, j as SystemPromptContributor, T as ToolRegistryView } from '../index-hWNybrNZ.js';
15
+ export { M as MCPRegistryView, a as MetricsSinkView, P as Plugin, b as PluginAPI, c as PluginCapabilities, d as PluginDependency, e as PluginPipelines, f as ProviderFactory, g as ProviderRegistryView, S as SessionWriterView, h as SlashCommand, i as SlashCommandRegistryView, j as SystemPromptContributor, T as ToolRegistryView } from '../index-DedY4Euf.js';
16
16
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
17
17
  export { D as DEFAULT_MODES, M as Mode, a as ModeConfig, b as ModeManifest, c as ModeStore } from '../mode-CV077NjV.js';
18
18
  export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-C3DUGjSb.js';
@@ -329,7 +329,7 @@ function walk(node, vault, transform) {
329
329
  if (Array.isArray(node)) {
330
330
  return node.map((item) => walk(item, vault, transform));
331
331
  }
332
- const out = {};
332
+ const out = /* @__PURE__ */ Object.create(null);
333
333
  for (const [k, v] of Object.entries(node)) {
334
334
  if (typeof v === "string" && isSecretField(k)) {
335
335
  out[k] = transform(v, k);
@@ -1283,6 +1283,7 @@ var FAMILY_BY_NPM = {
1283
1283
  "@ai-sdk/xai": "openai-compatible",
1284
1284
  "@ai-sdk/cerebras": "openai-compatible",
1285
1285
  "@ai-sdk/togetherai": "openai-compatible",
1286
+ "@ai-sdk/mistral": "openai-compatible",
1286
1287
  "@ai-sdk/perplexity": "openai-compatible",
1287
1288
  "@ai-sdk/deepinfra": "openai-compatible",
1288
1289
  "@openrouter/ai-sdk-provider": "openai-compatible",
@@ -2205,6 +2206,42 @@ var ToolExecutor = class {
2205
2206
  }
2206
2207
  };
2207
2208
 
2209
+ // src/utils/regex-guard.ts
2210
+ var MAX_PATTERN_LEN = 512;
2211
+ var DANGEROUS_PATTERNS = [
2212
+ /(\([^)]*[+*][^)]*\))[+*]/,
2213
+ // (a+)+, (.*)+, etc
2214
+ /(\(\?:[^)]*[+*][^)]*\))[+*]/
2215
+ // same, with non-capturing group
2216
+ ];
2217
+ function compileUserRegex(pattern, flags) {
2218
+ if (typeof pattern !== "string") {
2219
+ return { ok: false, reason: "pattern must be a string" };
2220
+ }
2221
+ if (pattern.length === 0) {
2222
+ return { ok: false, reason: "pattern is empty" };
2223
+ }
2224
+ if (pattern.length > MAX_PATTERN_LEN) {
2225
+ return { ok: false, reason: `pattern exceeds ${MAX_PATTERN_LEN} characters` };
2226
+ }
2227
+ for (const rx of DANGEROUS_PATTERNS) {
2228
+ if (rx.test(pattern)) {
2229
+ return {
2230
+ ok: false,
2231
+ reason: "pattern looks vulnerable to catastrophic backtracking \u2014 rewrite without nested quantifiers"
2232
+ };
2233
+ }
2234
+ }
2235
+ try {
2236
+ return { ok: true, regex: new RegExp(pattern, flags) };
2237
+ } catch (err) {
2238
+ return {
2239
+ ok: false,
2240
+ reason: err instanceof Error ? err.message : "invalid regex"
2241
+ };
2242
+ }
2243
+ }
2244
+
2208
2245
  // src/storage/session-reader.ts
2209
2246
  var DefaultSessionReader = class {
2210
2247
  store;
@@ -2299,7 +2336,11 @@ function buildMatcher(q) {
2299
2336
  const ci = q.caseInsensitive ?? true;
2300
2337
  if (q.regex) {
2301
2338
  const flags = ci ? "i" : "";
2302
- const re = new RegExp(q.query, flags);
2339
+ const compiled = compileUserRegex(q.query, flags);
2340
+ if (!compiled.ok) {
2341
+ throw new Error(`Invalid search regex "${q.query}": ${compiled.reason}`);
2342
+ }
2343
+ const re = compiled.regex;
2303
2344
  return (text) => {
2304
2345
  const m = re.exec(text);
2305
2346
  return m ? { start: m.index, end: m.index + m[0].length } : null;