@akasecurity/ai-tc-codex 0.9.17-beta.1 → 0.9.18

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.
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  mod
33
33
  ));
34
34
 
35
- // ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
35
+ // ../../node_modules/.pnpm/ignore@7.0.12/node_modules/ignore/index.js
36
36
  var require_ignore = __commonJS({
37
- "../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
37
+ "../../node_modules/.pnpm/ignore@7.0.12/node_modules/ignore/index.js"(exports, module) {
38
38
  "use strict";
39
39
  function makeArray(subject) {
40
40
  return Array.isArray(subject) ? subject : [subject];
@@ -44,7 +44,7 @@ var require_ignore = __commonJS({
44
44
  var SPACE = " ";
45
45
  var ESCAPE = "\\";
46
46
  var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
47
- var REGEX_TEST_BLANK_LINE = /^\uFEFF? *$/;
47
+ var BOM = "\uFEFF";
48
48
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
49
49
  var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
50
50
  var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
@@ -180,7 +180,9 @@ var require_ignore = __commonJS({
180
180
  const char = pattern[index];
181
181
  if (char === ESCAPE) {
182
182
  const escaped = pattern[index + 1];
183
- if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
183
+ if (escaped === UNDEFINED || escaped === SLASH3 && index + 2 === length) {
184
+ out += hold(NEVER_MATCH);
185
+ } else if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
184
186
  out += pattern.slice(index, index + 2);
185
187
  } else {
186
188
  out += hold(
@@ -213,35 +215,6 @@ var require_ignore = __commonJS({
213
215
  var DIRECT = null;
214
216
  var REGEX_INNER_SLASH = /\/(?!$)/;
215
217
  var REPLACERS = [
216
- [
217
- // Remove BOM
218
- // TODO:
219
- // Other similar zero-width characters?
220
- /^\uFEFF/,
221
- () => EMPTY,
222
- "\uFEFF"
223
- ],
224
- [
225
- // A trailing line terminator, left on when a whole file's contents are
226
- // added as one pattern rather than split into lines. git never sees one
227
- // -- it reads a `.gitignore` line by line -- so it is not part of the
228
- // pattern and is dropped here, apart from the trailing-space trimming,
229
- // which follows git in touching spaces and nothing else.
230
- /[\r\n]+$/,
231
- () => EMPTY
232
- ],
233
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
234
- [
235
- // Only spaces, never tabs or other whitespace: git trims a trailing run
236
- // of `' '` and nothing else (dir.c, `trim_trailing_spaces`, a single
237
- // `case ' '`), so a pattern ending in a tab keeps it as a literal.
238
- // (a\ ) -> (a )
239
- // (a ) -> (a)
240
- // (a ) -> (a)
241
- // (a \ ) -> (a )
242
- /((?:\\\\)*?)(\\? +)$/,
243
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
244
- ],
245
218
  // Replace (\ ) with ' '
246
219
  // Only a space: an escaped tab or other whitespace is already a literal by
247
220
  // the time it reaches here, and a bare tab must be left as one, not turned
@@ -250,11 +223,12 @@ var require_ignore = __commonJS({
250
223
  // (\\ ) -> '\\ '
251
224
  // (\\\ ) -> '\\ '
252
225
  [
253
- /(\\+?) /g,
254
- (_, m1) => {
255
- const { length } = m1;
256
- return m1.slice(0, length - length % 2) + SPACE;
257
- }
226
+ // A run of backslashes is taken whole, from its first one, so no match
227
+ // ever starts again inside it -- `(\\+?) ` did, which made a long run
228
+ // quadratic.
229
+ /(\\+)( ?)/g,
230
+ (_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE : run,
231
+ ESCAPE + SPACE
258
232
  ],
259
233
  // Escape metacharacters
260
234
  // which is written down by users but means special for regular expressions.
@@ -574,7 +548,7 @@ var require_ignore = __commonJS({
574
548
  return cut < 0 ? EMPTY : path.slice(0, cut + 1);
575
549
  };
576
550
  var isString = (subject) => typeof subject === "string";
577
- var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
551
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
578
552
  var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
579
553
  var IgnoreRule = class {
580
554
  constructor(pattern, mark, body, ignoreCase, negative, prefix) {
@@ -615,15 +589,44 @@ var require_ignore = __commonJS({
615
589
  return define(this, key, regex);
616
590
  }
617
591
  };
592
+ var isLineEnd = (char) => char === "\r" || char === "\n";
593
+ var trimEnd = (body) => {
594
+ let end = body.length;
595
+ while (end && isLineEnd(body[end - 1])) {
596
+ end--;
597
+ }
598
+ const lineEnd = end;
599
+ while (end && body[end - 1] === SPACE) {
600
+ end--;
601
+ }
602
+ if (end === lineEnd) {
603
+ return body.slice(0, end);
604
+ }
605
+ let backslashes = 0;
606
+ while (backslashes < end && body[end - backslashes - 1] === ESCAPE) {
607
+ backslashes++;
608
+ }
609
+ return backslashes % 2 ? body.slice(0, end - 1) + SPACE : body.slice(0, end);
610
+ };
618
611
  var createRule = ({
619
612
  pattern,
620
613
  mark
621
614
  }, ignoreCase) => {
615
+ let body = pattern[0] === BOM ? pattern.slice(1) : pattern;
616
+ if (body[0] === "#") {
617
+ return;
618
+ }
622
619
  let negative = false;
623
- let body = pattern;
624
- if (body.indexOf("!") === 0) {
620
+ if (body[0] === "!") {
625
621
  negative = true;
626
- body = body.substr(1);
622
+ body = body.slice(1);
623
+ }
624
+ const last = body[body.length - 1];
625
+ if (last === SPACE || last === "\r" || last === "\n") {
626
+ body = trimEnd(body);
627
+ }
628
+ if (!body) {
629
+ return;
627
630
  }
628
631
  body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
629
632
  const regexPrefix = makeRegexPrefix(body);
@@ -654,8 +657,8 @@ var require_ignore = __commonJS({
654
657
  pattern
655
658
  };
656
659
  }
657
- if (checkPattern(pattern.pattern)) {
658
- const rule = createRule(pattern, this._ignoreCase);
660
+ const rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
661
+ if (rule) {
659
662
  this._added = true;
660
663
  this._rules.push(rule);
661
664
  if (matchesBasename(rule.body)) {
@@ -20724,7 +20727,10 @@ function date4(params) {
20724
20727
  var LongContextTier = external_exports.object({
20725
20728
  thresholdInputTokens: external_exports.number().int().positive(),
20726
20729
  input: external_exports.number().nonnegative().nullable(),
20727
- output: external_exports.number().nonnegative().nullable()
20730
+ output: external_exports.number().nonnegative().nullable(),
20731
+ cacheRead: external_exports.number().nonnegative().nullable().optional(),
20732
+ cacheWrite5m: external_exports.number().nonnegative().nullable().optional(),
20733
+ cacheWrite1h: external_exports.number().nonnegative().nullable().optional()
20728
20734
  });
20729
20735
  var ModelPrice = external_exports.object({
20730
20736
  /** USD per 1M uncached input tokens, at or below any long-context threshold. */
@@ -20733,7 +20739,8 @@ var ModelPrice = external_exports.object({
20733
20739
  output: external_exports.number().nonnegative(),
20734
20740
  /**
20735
20741
  * Rate band above a size threshold, or `null` when the model is flat-rated.
20736
- * Anthropic is flat across its 1M window; OpenAI, Google and xAI are not.
20742
+ * OpenAI, Google, xAI and some Anthropic models (Haiku 5.5) band; most
20743
+ * Claude models are flat across their window.
20737
20744
  */
20738
20745
  longContext: LongContextTier.nullable(),
20739
20746
  /** USD per 1M tokens written to a 5-minute ephemeral cache, or null if unpriced. */
@@ -20746,18 +20753,35 @@ var ModelPrice = external_exports.object({
20746
20753
  webSearch: external_exports.number().nonnegative().nullable()
20747
20754
  });
20748
20755
  var WEB_SEARCH_PER_REQUEST = 0.01;
20749
- function anthropicPrice(input2, output2, cacheRead) {
20756
+ function anthropicPrice(input2, output2, cacheRead, longContext = null) {
20750
20757
  return Object.freeze({
20751
20758
  input: input2,
20752
20759
  output: output2,
20753
- longContext: null,
20754
- // flat across the full window on every current Claude
20760
+ longContext: longContext === null ? null : Object.freeze(longContext),
20755
20761
  cacheWrite5m: input2 * 1.25,
20756
20762
  cacheWrite1h: input2 * 2,
20757
20763
  cacheRead,
20758
20764
  webSearch: WEB_SEARCH_PER_REQUEST
20759
20765
  });
20760
20766
  }
20767
+ function anthropicBand(thresholdInputTokens, input2, output2, cacheRead) {
20768
+ return {
20769
+ thresholdInputTokens,
20770
+ input: input2,
20771
+ output: output2,
20772
+ cacheRead,
20773
+ cacheWrite5m: input2 * 1.25,
20774
+ cacheWrite1h: input2 * 2
20775
+ };
20776
+ }
20777
+ function scaledBand(thresholdInputTokens, base, scale) {
20778
+ return {
20779
+ thresholdInputTokens,
20780
+ input: base.input * scale.input,
20781
+ output: base.output * scale.output,
20782
+ ...base.cacheRead === void 0 ? {} : { cacheRead: base.cacheRead * scale.cacheRead }
20783
+ };
20784
+ }
20761
20785
  function tokenPrice(input2, output2, options = {}) {
20762
20786
  return Object.freeze({
20763
20787
  input: input2,
@@ -20790,17 +20814,19 @@ function serviceTierMultiplier(tier) {
20790
20814
  function promptTokensOf(usage) {
20791
20815
  return usage.promptTokens ?? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWrite1hTokens ?? 0) + (usage.cacheWrite5mTokens ?? 0);
20792
20816
  }
20817
+ function bandRate(column, base) {
20818
+ return column === void 0 ? base : column;
20819
+ }
20793
20820
  function costOf(price, usage) {
20821
+ const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
20794
20822
  const metered = [
20795
- [usage.cacheWrite1hTokens ?? 0, price.cacheWrite1h],
20796
- [usage.cacheWrite5mTokens ?? 0, price.cacheWrite5m],
20797
- [usage.cacheReadTokens ?? 0, price.cacheRead]
20823
+ [usage.inputTokens ?? 0, bandRate(band?.input, price.input)],
20824
+ [usage.outputTokens ?? 0, bandRate(band?.output, price.output)],
20825
+ [usage.cacheWrite1hTokens ?? 0, bandRate(band?.cacheWrite1h, price.cacheWrite1h)],
20826
+ [usage.cacheWrite5mTokens ?? 0, bandRate(band?.cacheWrite5m, price.cacheWrite5m)],
20827
+ [usage.cacheReadTokens ?? 0, bandRate(band?.cacheRead, price.cacheRead)]
20798
20828
  ];
20799
- const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
20800
- if (band !== null && (band.input === null || band.output === null)) return null;
20801
- const inputRate = band?.input ?? price.input;
20802
- const outputRate = band?.output ?? price.output;
20803
- let tokenCost = (usage.inputTokens ?? 0) * inputRate + (usage.outputTokens ?? 0) * outputRate;
20829
+ let tokenCost = 0;
20804
20830
  for (const [tokens, rate] of metered) {
20805
20831
  if (tokens === 0) continue;
20806
20832
  if (rate === null) return null;
@@ -21090,10 +21116,20 @@ anthropic.model("claude-fable-5-1", {
21090
21116
  });
21091
21117
  anthropic.model("claude-fable-5", {
21092
21118
  name: "Claude Fable 5",
21119
+ ctx: 1e6,
21120
+ maxOut: 128e3,
21093
21121
  capability: "reasoning",
21094
21122
  price: anthropicPrice(10, 50, 1),
21095
21123
  on: [...CLAUDE_RESELLERS]
21096
21124
  });
21125
+ anthropic.model("claude-opus-5-5", {
21126
+ name: "Claude Opus 5.5",
21127
+ ctx: 1e6,
21128
+ maxOut: 128e3,
21129
+ capability: "reasoning",
21130
+ price: anthropicPrice(4, 20, 0.2),
21131
+ on: [...CLAUDE_RESELLERS]
21132
+ });
21097
21133
  anthropic.model("claude-opus-5", {
21098
21134
  name: "Claude Opus 5",
21099
21135
  ctx: 1e6,
@@ -21104,24 +21140,32 @@ anthropic.model("claude-opus-5", {
21104
21140
  });
21105
21141
  anthropic.model("claude-opus-4-8", {
21106
21142
  name: "Claude Opus 4.8",
21143
+ ctx: 1e6,
21144
+ maxOut: 128e3,
21107
21145
  capability: "reasoning",
21108
21146
  price: anthropicPrice(5, 25, 0.5),
21109
21147
  on: [...CLAUDE_RESELLERS]
21110
21148
  });
21111
21149
  anthropic.model("claude-opus-4-7", {
21112
21150
  name: "Claude Opus 4.7",
21151
+ ctx: 1e6,
21152
+ maxOut: 128e3,
21113
21153
  capability: "reasoning",
21114
21154
  price: anthropicPrice(5, 25, 0.5),
21115
21155
  on: [...CLAUDE_RESELLERS]
21116
21156
  });
21117
21157
  anthropic.model("claude-opus-4-6", {
21118
21158
  name: "Claude Opus 4.6",
21159
+ ctx: 1e6,
21160
+ maxOut: 128e3,
21119
21161
  capability: "reasoning",
21120
21162
  price: anthropicPrice(5, 25, 0.5),
21121
21163
  on: [...CLAUDE_RESELLERS]
21122
21164
  });
21123
21165
  anthropic.model("claude-opus-4-5", {
21124
21166
  name: "Claude Opus 4.5",
21167
+ ctx: 2e5,
21168
+ maxOut: 64e3,
21125
21169
  capability: "reasoning",
21126
21170
  price: anthropicPrice(5, 25, 0.5),
21127
21171
  on: [...CLAUDE_RESELLERS]
@@ -21132,6 +21176,14 @@ anthropic.model("claude-opus-4-1", {
21132
21176
  price: anthropicPrice(15, 75, 1.5),
21133
21177
  on: [...CLAUDE_RESELLERS]
21134
21178
  });
21179
+ anthropic.model("claude-sonnet-5-5", {
21180
+ name: "Claude Sonnet 5.5",
21181
+ ctx: 1e6,
21182
+ maxOut: 128e3,
21183
+ capability: "reasoning",
21184
+ price: anthropicPrice(2, 10, 0.1),
21185
+ on: [...CLAUDE_RESELLERS]
21186
+ });
21135
21187
  anthropic.model("claude-sonnet-5", {
21136
21188
  name: "Claude Sonnet 5",
21137
21189
  ctx: 1e6,
@@ -21142,16 +21194,30 @@ anthropic.model("claude-sonnet-5", {
21142
21194
  });
21143
21195
  anthropic.model("claude-sonnet-4-6", {
21144
21196
  name: "Claude Sonnet 4.6",
21197
+ ctx: 1e6,
21198
+ maxOut: 128e3,
21145
21199
  capability: "reasoning",
21146
21200
  price: anthropicPrice(3, 15, 0.3),
21147
21201
  on: [...CLAUDE_RESELLERS]
21148
21202
  });
21149
21203
  anthropic.model("claude-sonnet-4-5", {
21150
21204
  name: "Claude Sonnet 4.5",
21205
+ ctx: 2e5,
21206
+ maxOut: 64e3,
21151
21207
  capability: "reasoning",
21152
21208
  price: anthropicPrice(3, 15, 0.3),
21153
21209
  on: [...CLAUDE_RESELLERS]
21154
21210
  });
21211
+ anthropic.model("claude-haiku-5-5", {
21212
+ name: "Claude Haiku 5.5",
21213
+ ctx: 1e6,
21214
+ maxOut: 128e3,
21215
+ capability: null,
21216
+ // A prompt over 100,000 tokens, cache reads and writes included, bills the
21217
+ // whole request at the higher band.
21218
+ price: anthropicPrice(0.1, 0.5, 0.01, anthropicBand(1e5, 0.5, 2.5, 0.05)),
21219
+ on: [...CLAUDE_RESELLERS]
21220
+ });
21155
21221
  anthropic.model("claude-haiku-4-5", {
21156
21222
  name: "Claude Haiku 4.5",
21157
21223
  ctx: 2e5,
@@ -21174,7 +21240,13 @@ var OPENAI_TRAINING = {
21174
21240
  consumerControl: "opt-out",
21175
21241
  source: "https://developers.openai.com/api/docs/guides/your-data"
21176
21242
  };
21177
- var LONG_CONTEXT_272K = { thresholdInputTokens: 272e3, input: null, output: null };
21243
+ function gptPrice(input2, output2, cacheRead) {
21244
+ const base = { input: input2, output: output2, ...cacheRead === void 0 ? {} : { cacheRead } };
21245
+ return tokenPrice(input2, output2, {
21246
+ ...base,
21247
+ longContext: scaledBand(272e3, base, { input: 2, output: 1.5, cacheRead: 2 })
21248
+ });
21249
+ }
21178
21250
  var openai = vendor("openai", {
21179
21251
  family: { id: "gpt", name: "GPT" },
21180
21252
  region: "us",
@@ -21182,12 +21254,45 @@ var openai = vendor("openai", {
21182
21254
  training: OPENAI_TRAINING
21183
21255
  });
21184
21256
  var OPENAI_RESELLERS = ["azure", "foundry"];
21257
+ openai.model("gpt-6-astra", {
21258
+ name: "GPT-6 Astra",
21259
+ ctx: 105e4,
21260
+ maxOut: 128e3,
21261
+ capability: "reasoning",
21262
+ price: gptPrice(10, 50, 1),
21263
+ on: [...OPENAI_RESELLERS]
21264
+ });
21265
+ openai.model("gpt-6.1-sol", {
21266
+ name: "GPT-6.1 Sol",
21267
+ ctx: 105e4,
21268
+ maxOut: 128e3,
21269
+ capability: "reasoning",
21270
+ price: gptPrice(2, 10, 0.1),
21271
+ on: [...OPENAI_RESELLERS]
21272
+ });
21273
+ openai.model("gpt-6-sol", {
21274
+ name: "GPT-6 Sol",
21275
+ ctx: 105e4,
21276
+ maxOut: 128e3,
21277
+ capability: "reasoning",
21278
+ price: gptPrice(2, 10, 0.2),
21279
+ on: [...OPENAI_RESELLERS]
21280
+ });
21281
+ openai.model("gpt-6-luna", {
21282
+ name: "GPT-6 Luna",
21283
+ ctx: 105e4,
21284
+ maxOut: 128e3,
21285
+ capability: null,
21286
+ price: gptPrice(0.1, 0.5, 0.01),
21287
+ on: [...OPENAI_RESELLERS]
21288
+ });
21185
21289
  openai.model("gpt-5.6-sol", {
21186
21290
  name: "GPT-5.6 Sol",
21291
+ // Promotional rate, published as available at least through 2026-11-21.
21187
21292
  ctx: 105e4,
21188
21293
  maxOut: 128e3,
21189
21294
  capability: "reasoning",
21190
- price: tokenPrice(4, 20, { cacheRead: 0.4, longContext: LONG_CONTEXT_272K }),
21295
+ price: gptPrice(4, 20, 0.4),
21191
21296
  on: [...OPENAI_RESELLERS]
21192
21297
  });
21193
21298
  openai.model("gpt-5.6-terra", {
@@ -21195,7 +21300,7 @@ openai.model("gpt-5.6-terra", {
21195
21300
  ctx: 105e4,
21196
21301
  maxOut: 128e3,
21197
21302
  capability: "reasoning",
21198
- price: tokenPrice(2, 12, { cacheRead: 0.2, longContext: LONG_CONTEXT_272K }),
21303
+ price: gptPrice(2, 12, 0.2),
21199
21304
  on: [...OPENAI_RESELLERS]
21200
21305
  });
21201
21306
  openai.model("gpt-5.6-luna", {
@@ -21203,7 +21308,7 @@ openai.model("gpt-5.6-luna", {
21203
21308
  ctx: 105e4,
21204
21309
  maxOut: 128e3,
21205
21310
  capability: null,
21206
- price: tokenPrice(0.2, 1.2, { cacheRead: 0.02, longContext: LONG_CONTEXT_272K }),
21311
+ price: gptPrice(0.2, 1.2, 0.02),
21207
21312
  on: [...OPENAI_RESELLERS]
21208
21313
  });
21209
21314
  openai.model("gpt-5.5", {
@@ -21211,7 +21316,15 @@ openai.model("gpt-5.5", {
21211
21316
  ctx: 105e4,
21212
21317
  maxOut: 128e3,
21213
21318
  capability: "reasoning",
21214
- price: tokenPrice(5, 30, { cacheRead: 0.5, longContext: LONG_CONTEXT_272K }),
21319
+ price: gptPrice(5, 30, 0.5),
21320
+ on: [...OPENAI_RESELLERS]
21321
+ });
21322
+ openai.model("gpt-5.5-pro", {
21323
+ name: "GPT-5.5 Pro",
21324
+ ctx: 105e4,
21325
+ maxOut: 128e3,
21326
+ capability: "reasoning",
21327
+ price: gptPrice(30, 180),
21215
21328
  on: [...OPENAI_RESELLERS]
21216
21329
  });
21217
21330
  openai.model("gpt-5.4", {
@@ -21219,7 +21332,7 @@ openai.model("gpt-5.4", {
21219
21332
  ctx: 105e4,
21220
21333
  maxOut: 128e3,
21221
21334
  capability: "reasoning",
21222
- price: tokenPrice(2.5, 15, { cacheRead: 0.25, longContext: LONG_CONTEXT_272K }),
21335
+ price: gptPrice(2.5, 15, 0.25),
21223
21336
  on: [...OPENAI_RESELLERS]
21224
21337
  });
21225
21338
  openai.model("gpt-5.4-mini", {
@@ -21265,6 +21378,7 @@ openai.model("gpt-5", {
21265
21378
  openai.model("gpt-5-mini", {
21266
21379
  name: "GPT-5 mini",
21267
21380
  ctx: 4e5,
21381
+ maxOut: 128e3,
21268
21382
  capability: null,
21269
21383
  price: tokenPrice(0.25, 2, { cacheRead: 0.025 }),
21270
21384
  on: [...OPENAI_RESELLERS]
@@ -21279,11 +21393,15 @@ openai.model("gpt-5-nano", {
21279
21393
  });
21280
21394
  openai.model("gpt-4.1", {
21281
21395
  name: "GPT-4.1",
21396
+ ctx: 1047576,
21397
+ maxOut: 32768,
21282
21398
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
21283
21399
  on: [...OPENAI_RESELLERS]
21284
21400
  });
21285
21401
  openai.model("gpt-4o", {
21286
21402
  name: "GPT-4o",
21403
+ ctx: 128e3,
21404
+ maxOut: 16384,
21287
21405
  price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
21288
21406
  on: [...OPENAI_RESELLERS]
21289
21407
  });
@@ -21307,6 +21425,8 @@ openai.model("gpt-4-turbo", {
21307
21425
  });
21308
21426
  openai.model("o3", {
21309
21427
  name: "o3",
21428
+ ctx: 2e5,
21429
+ maxOut: 1e5,
21310
21430
  capability: "reasoning",
21311
21431
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
21312
21432
  on: [...OPENAI_RESELLERS]
@@ -21359,57 +21479,100 @@ var google = vendor("google", {
21359
21479
  retention: "configurable",
21360
21480
  training: GOOGLE_TRAINING
21361
21481
  });
21482
+ google.model("gemini-3.8-flash", {
21483
+ name: "Gemini 3.8 Flash",
21484
+ ctx: 1048576,
21485
+ maxOut: 65536,
21486
+ capability: null,
21487
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
21488
+ on: ["vertex"]
21489
+ });
21362
21490
  google.model("gemini-3.7-flash", {
21363
21491
  name: "Gemini 3.7 Flash",
21364
21492
  capability: null,
21365
- // Promotional rate; the published post-promotion rate is 1.50 / 7.50.
21366
21493
  price: tokenPrice(0.75, 3.75),
21367
21494
  on: ["vertex"]
21368
21495
  });
21369
21496
  google.model("gemini-3.6-flash", {
21370
21497
  name: "Gemini 3.6 Flash",
21498
+ ctx: 1048576,
21499
+ maxOut: 65536,
21371
21500
  capability: null,
21372
- price: tokenPrice(0.75, 3.75),
21501
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
21373
21502
  on: ["vertex"]
21374
21503
  });
21375
21504
  google.model("gemini-3.5-flash", {
21376
21505
  name: "Gemini 3.5 Flash",
21377
21506
  capability: null,
21378
- price: tokenPrice(1.5, 9),
21379
21507
  on: ["vertex"]
21380
21508
  });
21381
21509
  google.model("gemini-3.5-flash-lite", {
21382
21510
  name: "Gemini 3.5 Flash Lite",
21511
+ ctx: 1048576,
21512
+ maxOut: 65536,
21383
21513
  capability: null,
21384
- price: tokenPrice(0.3, 2.5),
21514
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
21515
+ on: ["vertex"]
21516
+ });
21517
+ google.model("gemini-3.1-flash-lite", {
21518
+ name: "Gemini 3.1 Flash Lite",
21519
+ ctx: 1048576,
21520
+ maxOut: 65536,
21521
+ capability: null,
21522
+ price: tokenPrice(0.25, 1.5, { cacheRead: 0.025 }),
21523
+ on: ["vertex"]
21524
+ });
21525
+ google.model("gemini-3-flash-preview", {
21526
+ name: "Gemini 3 Flash Preview",
21527
+ ctx: 1048576,
21528
+ maxOut: 65536,
21529
+ capability: null,
21530
+ price: tokenPrice(0.5, 3, { cacheRead: 0.05 }),
21385
21531
  on: ["vertex"]
21386
21532
  });
21387
21533
  google.model("gemini-3.1-pro-preview", {
21388
21534
  name: "Gemini 3.1 Pro Preview",
21535
+ ctx: 1048576,
21536
+ maxOut: 65536,
21389
21537
  capability: "reasoning",
21390
21538
  price: tokenPrice(2, 12, {
21391
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 18 }
21539
+ cacheRead: 0.2,
21540
+ longContext: { thresholdInputTokens: 2e5, input: 4, output: 18, cacheRead: 0.4 }
21392
21541
  }),
21542
+ aliases: ["gemini-3.1-pro-preview-customtools"],
21393
21543
  on: ["vertex"]
21394
21544
  });
21395
21545
  google.model("gemini-2.5-pro", {
21396
21546
  name: "Gemini 2.5 Pro",
21547
+ ctx: 1048576,
21548
+ maxOut: 65536,
21397
21549
  capability: "reasoning",
21398
21550
  price: tokenPrice(1.25, 10, {
21399
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15 }
21551
+ cacheRead: 0.125,
21552
+ longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15, cacheRead: 0.25 }
21400
21553
  }),
21401
21554
  on: ["vertex"]
21402
21555
  });
21403
21556
  google.model("gemini-2.5-flash", {
21404
21557
  name: "Gemini 2.5 Flash",
21558
+ ctx: 1048576,
21559
+ maxOut: 65536,
21405
21560
  capability: null,
21406
- price: tokenPrice(0.3, 2.5),
21561
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
21407
21562
  on: ["vertex"]
21408
21563
  });
21409
21564
  google.model("gemini-2.5-flash-lite", {
21410
21565
  name: "Gemini 2.5 Flash Lite",
21566
+ ctx: 1048576,
21567
+ maxOut: 65536,
21411
21568
  capability: null,
21412
- price: tokenPrice(0.1, 0.4),
21569
+ price: tokenPrice(0.1, 0.4, { cacheRead: 0.01 }),
21570
+ on: ["vertex"]
21571
+ });
21572
+ google.model("gemini-embedding-2", {
21573
+ name: "Gemini Embedding 2",
21574
+ capability: "embedding",
21575
+ price: tokenPrice(0.2, 0),
21413
21576
  on: ["vertex"]
21414
21577
  });
21415
21578
  google.model("gemini-1-5-pro", { name: "Gemini 1.5 Pro", on: ["vertex"] });
@@ -21425,43 +21588,62 @@ var xai = vendor("xai", {
21425
21588
  source: "https://docs.x.ai/developers/faq/security"
21426
21589
  }
21427
21590
  });
21591
+ function grokPrice(input2, output2, cacheRead) {
21592
+ const base = { input: input2, output: output2, cacheRead };
21593
+ return tokenPrice(input2, output2, {
21594
+ cacheRead,
21595
+ longContext: scaledBand(2e5, base, { input: 2, output: 2, cacheRead: 2 })
21596
+ });
21597
+ }
21598
+ xai.model("grok-4.7", {
21599
+ name: "Grok 4.7",
21600
+ ctx: 5e5,
21601
+ capability: "reasoning",
21602
+ price: grokPrice(2, 6, 0.5)
21603
+ });
21428
21604
  xai.model("grok-4.6", {
21429
21605
  name: "Grok 4.6",
21430
21606
  ctx: 5e5,
21431
21607
  capability: "reasoning",
21432
- price: tokenPrice(2, 6, {
21433
- cacheRead: 0.5,
21434
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
21435
- }),
21608
+ price: grokPrice(2, 6, 0.5),
21436
21609
  on: ["bedrock"]
21437
21610
  });
21438
21611
  xai.model("grok-4.5", {
21439
21612
  name: "Grok 4.5",
21440
21613
  ctx: 5e5,
21441
21614
  capability: "reasoning",
21442
- price: tokenPrice(2, 6, {
21443
- cacheRead: 0.3,
21444
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
21445
- })
21615
+ price: grokPrice(2, 6, 0.3)
21446
21616
  });
21447
21617
  xai.model("grok-4.3", {
21448
21618
  name: "Grok 4.3",
21449
21619
  ctx: 1e6,
21450
21620
  capability: "reasoning",
21451
- price: tokenPrice(1.25, 2.5, {
21452
- cacheRead: 0.2,
21453
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 5 }
21454
- }),
21621
+ price: grokPrice(1.25, 2.5, 0.2),
21455
21622
  on: ["bedrock"]
21456
21623
  });
21624
+ xai.model("grok-4.20-0309-reasoning", {
21625
+ name: "Grok 4.20 Reasoning",
21626
+ capability: "reasoning",
21627
+ ctx: 1e6,
21628
+ price: grokPrice(1.25, 2.5, 0.2)
21629
+ });
21630
+ xai.model("grok-4.20-0309-non-reasoning", {
21631
+ name: "Grok 4.20",
21632
+ capability: null,
21633
+ ctx: 1e6,
21634
+ price: grokPrice(1.25, 2.5, 0.2)
21635
+ });
21636
+ xai.model("grok-4.20-multi-agent-0309", {
21637
+ name: "Grok 4.20 Multi-Agent",
21638
+ capability: "reasoning",
21639
+ ctx: 1e6,
21640
+ price: grokPrice(1.25, 2.5, 0.2)
21641
+ });
21457
21642
  xai.model("grok-build-0.1", {
21458
21643
  name: "Grok Build 0.1",
21459
21644
  ctx: 256e3,
21460
21645
  capability: "code",
21461
- price: tokenPrice(1, 2, {
21462
- cacheRead: 0.2,
21463
- longContext: { thresholdInputTokens: 2e5, input: 2, output: 4 }
21464
- })
21646
+ price: grokPrice(1, 2, 0.2)
21465
21647
  });
21466
21648
  var deepseek = vendor("deepseek", {
21467
21649
  family: { id: "deepseek", name: "DeepSeek" },
@@ -21474,16 +21656,25 @@ var deepseek = vendor("deepseek", {
21474
21656
  source: "https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html"
21475
21657
  }
21476
21658
  });
21659
+ deepseek.model("deepseek-flash", {
21660
+ name: "DeepSeek V4.1 Flash",
21661
+ ctx: 1e6,
21662
+ maxOut: 384e3,
21663
+ capability: null,
21664
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 })
21665
+ });
21477
21666
  deepseek.model("deepseek-v4-flash", {
21478
21667
  name: "DeepSeek V4 Flash",
21479
21668
  ctx: 1e6,
21669
+ maxOut: 384e3,
21480
21670
  capability: null,
21481
- price: tokenPrice(0.44, 1.32, { cacheRead: 0.014 }),
21671
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 }),
21482
21672
  on: ["bedrock", "together", "fireworks", "openrouter", "ollama", "local"]
21483
21673
  });
21484
21674
  deepseek.model("deepseek-v4-pro", {
21485
21675
  name: "DeepSeek V4 Pro",
21486
21676
  ctx: 1e6,
21677
+ maxOut: 384e3,
21487
21678
  capability: "reasoning",
21488
21679
  price: tokenPrice(1.32, 3.96, { cacheRead: 0.044 }),
21489
21680
  on: ["bedrock", "together", "fireworks", "openrouter"]
@@ -21530,7 +21721,14 @@ cohere.model("command-r-plus-08-2024", {
21530
21721
  ctx: 128e3,
21531
21722
  maxOut: 4e3,
21532
21723
  price: tokenPrice(2.5, 10),
21533
- // The undated form is what deployments report; the live id carries the date.
21724
+ on: ["bedrock"]
21725
+ });
21726
+ cohere.model("command-r-plus-04-2024", {
21727
+ name: "Command R+ (04-2024)",
21728
+ seen: "discovered",
21729
+ ctx: 128e3,
21730
+ maxOut: 4e3,
21731
+ price: tokenPrice(3, 15),
21534
21732
  aliases: ["command-r-plus"],
21535
21733
  on: ["bedrock"]
21536
21734
  });
@@ -21598,6 +21796,65 @@ var mistral = vendor("mistral", {
21598
21796
  retention: "unknown",
21599
21797
  defaultHosting: "local"
21600
21798
  });
21799
+ var MISTRAL_API = { defaultHosting: "api" };
21800
+ mistral.model("mistral-large-4", {
21801
+ ...MISTRAL_API,
21802
+ name: "Mistral Large 4",
21803
+ ctx: 1e6,
21804
+ capability: null,
21805
+ // Public preview at a sale rate; the published original is 1.36 / 4.18 / 0.14.
21806
+ price: tokenPrice(0.68, 2.09, { cacheRead: 0.07 })
21807
+ });
21808
+ mistral.model("mistral-large-2512", {
21809
+ ...MISTRAL_API,
21810
+ name: "Mistral Large 3",
21811
+ ctx: 256e3,
21812
+ capability: null,
21813
+ price: tokenPrice(0.5, 1.5, { cacheRead: 0.05 })
21814
+ });
21815
+ mistral.model("mistral-medium-3-5", {
21816
+ ...MISTRAL_API,
21817
+ name: "Mistral Medium 3.5",
21818
+ ctx: 256e3,
21819
+ capability: null,
21820
+ price: tokenPrice(1.5, 7.5, { cacheRead: 0.15 })
21821
+ });
21822
+ mistral.model("mistral-small-2603", {
21823
+ ...MISTRAL_API,
21824
+ name: "Mistral Small 4",
21825
+ ctx: 256e3,
21826
+ capability: null,
21827
+ price: tokenPrice(0.15, 0.6, { cacheRead: 0.015 })
21828
+ });
21829
+ mistral.model("ministral-14b-2512", {
21830
+ ...MISTRAL_API,
21831
+ name: "Ministral 3 14B",
21832
+ ctx: 256e3,
21833
+ capability: null,
21834
+ price: tokenPrice(0.2, 0.2, { cacheRead: 0.02 })
21835
+ });
21836
+ mistral.model("ministral-8b-2512", {
21837
+ ...MISTRAL_API,
21838
+ name: "Ministral 3 8B",
21839
+ ctx: 256e3,
21840
+ capability: null,
21841
+ price: tokenPrice(0.15, 0.15, { cacheRead: 0.015 })
21842
+ });
21843
+ mistral.model("ministral-3b-2512", {
21844
+ ...MISTRAL_API,
21845
+ name: "Ministral 3 3B",
21846
+ ctx: 256e3,
21847
+ capability: null,
21848
+ price: tokenPrice(0.1, 0.1, { cacheRead: 0.01 })
21849
+ });
21850
+ mistral.model("codestral-2508", {
21851
+ ...MISTRAL_API,
21852
+ name: "Codestral",
21853
+ ctx: 128e3,
21854
+ capability: "code",
21855
+ openWeights: false,
21856
+ price: tokenPrice(0.3, 0.9, { cacheRead: 0.03 })
21857
+ });
21601
21858
  mistral.model("mixtral-8x7b", {
21602
21859
  name: "Mixtral 8x7B",
21603
21860
  seen: "discovered",
@@ -21761,11 +22018,14 @@ var COMPACT = new Intl.NumberFormat("en-US", {
21761
22018
  // ../../packages/schema/src/token/token-report.ts
21762
22019
  var num = (value) => value ?? 0;
21763
22020
  function costUsageOf(a, promptTokens) {
22021
+ const write1h = num(a.ephemeral_1h_input_tokens);
22022
+ const write5m = num(a.ephemeral_5m_input_tokens);
22023
+ const unsplit = Math.max(num(a.cache_creation_input_tokens) - write1h - write5m, 0);
21764
22024
  const usage = {
21765
22025
  inputTokens: num(a.input_tokens),
21766
22026
  outputTokens: num(a.output_tokens),
21767
- cacheWrite1hTokens: num(a.ephemeral_1h_input_tokens),
21768
- cacheWrite5mTokens: num(a.ephemeral_5m_input_tokens),
22027
+ cacheWrite1hTokens: write1h,
22028
+ cacheWrite5mTokens: write5m + unsplit,
21769
22029
  cacheReadTokens: num(a.cache_read_input_tokens),
21770
22030
  webSearchRequests: num(a.web_search_requests)
21771
22031
  };
@@ -22552,6 +22812,11 @@ var CaptureAttributes = external_exports.object({
22552
22812
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
22553
22813
  // repeated rather than referenced because a store reader opens this file.
22554
22814
  redact_degraded_to: ActionTaken.optional(),
22815
+ // Why a capture has no content and no findings: its field was refused
22816
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
22817
+ // whose value this is). Absent on every capture that was scanned, so a
22818
+ // reader can tell a refused row from an empty clean one.
22819
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
22555
22820
  // The scope key this capture was stamped with: the canonical repository
22556
22821
  // (`host/owner/repo`) of the path the capture names (a relative path is read
22557
22822
  // against its working directory), else of its own working directory, or a
@@ -23893,7 +24158,19 @@ var EventMetadata = external_exports.object({
23893
24158
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23894
24159
  // Closing either means moving the reason onto the finding row, which
23895
24160
  // already carries its own action.
23896
- redactDegradedTo: ActionTaken.optional()
24161
+ redactDegradedTo: ActionTaken.optional(),
24162
+ // Set when this capture's field was REFUSED rather than scanned: a hook
24163
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
24164
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
24165
+ // field instead of letting it through unscanned.
24166
+ //
24167
+ // - 'timeout': the bounded scan ran out of time.
24168
+ // - 'unavailable': no worker could run it.
24169
+ //
24170
+ // A refused row stores '' as its content and has no findings, which is
24171
+ // exactly what a clean, empty capture looks like — this marker is the only
24172
+ // thing that tells the two apart. Absent on every capture that was scanned.
24173
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23897
24174
  }).meta({ id: "EventMetadata" });
23898
24175
  var Event = external_exports.object({
23899
24176
  id: external_exports.guid(),
@@ -25710,6 +25987,7 @@ function toCaptureAttributes(event) {
25710
25987
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
25711
25988
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
25712
25989
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
25990
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
25713
25991
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
25714
25992
  // has ever populated either), but every legacy metadata key still rides
25715
25993
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -28698,7 +28976,8 @@ var TIMELINE_COLUMNS = `
28698
28976
  json_extract(attributes, '$.internal') AS internal,
28699
28977
  json_extract(attributes, '$.flagged') AS flagged`;
28700
28978
  var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
28701
- + coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
28979
+ + max(coalesce(cache_creation_input_tokens, 0),
28980
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0)))`;
28702
28981
  var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
28703
28982
  " + "
28704
28983
  );
@@ -38656,6 +38935,42 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
38656
38935
  }
38657
38936
  var CPU_CORROBORATION_SHARE = 0.2;
38658
38937
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
38938
+ function repeatTo(unit, length) {
38939
+ return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
38940
+ }
38941
+ function joinTo(length, open3, close, item) {
38942
+ const parts = [];
38943
+ let size = open3.length;
38944
+ for (let i = 0; size < length; i++) {
38945
+ const next = (i === 0 ? "" : ",") + item(i);
38946
+ parts.push(next);
38947
+ size += next.length;
38948
+ }
38949
+ return (open3 + parts.join("") + close).slice(0, length);
38950
+ }
38951
+ var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
38952
+ var GROWTH_CORPORA = [
38953
+ {
38954
+ name: "one-line JSON dictionary",
38955
+ build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
38956
+ },
38957
+ {
38958
+ name: "JSON array of quoted SQL keywords",
38959
+ build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
38960
+ },
38961
+ { name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
38962
+ {
38963
+ name: 'double-quoted keyword literal run ("where" )',
38964
+ build: (length) => repeatTo('"where" ', length)
38965
+ },
38966
+ { name: "double-quote run", build: (length) => repeatTo('"', length) },
38967
+ { name: "space run", build: (length) => repeatTo(" ", length) },
38968
+ { name: "newline run", build: (length) => repeatTo("\n", length) },
38969
+ ...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
38970
+ name: `unit run ${JSON.stringify(unit)}`,
38971
+ build: (length) => repeatTo(unit, length)
38972
+ }))
38973
+ ];
38659
38974
  function checkRuleTiming(rule, corroborate) {
38660
38975
  const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
38661
38976
  const work = corroboratedMs ?? 0;
@@ -38957,7 +39272,7 @@ var auth_jwt_no_verify_default = {
38957
39272
  severity: "critical",
38958
39273
  matcher: {
38959
39274
  type: "regex",
38960
- pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
39275
+ pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
38961
39276
  flags: "gi"
38962
39277
  },
38963
39278
  requiresNearby: {
@@ -39045,7 +39360,7 @@ var cmd_inject_shell_default = {
39045
39360
  severity: "critical",
39046
39361
  matcher: {
39047
39362
  type: "regex",
39048
- pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
39363
+ pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
39049
39364
  flags: "gi"
39050
39365
  },
39051
39366
  requiresNearby: {
@@ -39174,7 +39489,7 @@ var deser_yaml_unsafe_default = {
39174
39489
  severity: "high",
39175
39490
  matcher: {
39176
39491
  type: "regex",
39177
- pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
39492
+ pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
39178
39493
  flags: "gi"
39179
39494
  },
39180
39495
  examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
@@ -39391,7 +39706,7 @@ var sql_inject_concat_dot_default = {
39391
39706
  severity: "high",
39392
39707
  matcher: {
39393
39708
  type: "regex",
39394
- pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
39709
+ pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
39395
39710
  flags: "gi"
39396
39711
  },
39397
39712
  appliesTo: {
@@ -39409,7 +39724,7 @@ var sql_inject_concat_default = {
39409
39724
  severity: "high",
39410
39725
  matcher: {
39411
39726
  type: "regex",
39412
- pattern: `["']\\s*(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?["']\\s*\\+`,
39727
+ pattern: `(["'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?=))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?["']\\s*\\+`,
39413
39728
  flags: "gi"
39414
39729
  },
39415
39730
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -39424,7 +39739,7 @@ var sql_inject_format_default = {
39424
39739
  severity: "high",
39425
39740
  matcher: {
39426
39741
  type: "regex",
39427
- pattern: "\\b(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?(?:[%][sd]|\\{[^}]+\\})",
39742
+ pattern: "\\b(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))\\1(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|\\b(?=(where\\b(?:(?!\\bwhere\\b)[^\\n])*?=))\\2(?:(?!\\bwhere\\b)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})",
39428
39743
  flags: "gi"
39429
39744
  },
39430
39745
  examples: [
@@ -39442,7 +39757,7 @@ var sql_inject_interp_default = {
39442
39757
  severity: "high",
39443
39758
  matcher: {
39444
39759
  type: "regex",
39445
- pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
39760
+ pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
39446
39761
  flags: "gi"
39447
39762
  },
39448
39763
  examples: [
@@ -39817,7 +40132,7 @@ var stack_trace_default = {
39817
40132
  severity: "low",
39818
40133
  matcher: {
39819
40134
  type: "regex",
39820
- pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
40135
+ pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
39821
40136
  flags: "g"
39822
40137
  },
39823
40138
  examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
@@ -40975,7 +41290,7 @@ var BUNDLED_PACKS = [
40975
41290
  {
40976
41291
  packId: "code-flaws",
40977
41292
  name: "Code Security Flaws",
40978
- version: "0.1.0",
41293
+ version: "0.1.2",
40979
41294
  rawRules: [
40980
41295
  sql_inject_concat_default,
40981
41296
  sql_inject_concat_dot_default,
@@ -41025,7 +41340,7 @@ var BUNDLED_PACKS = [
41025
41340
  {
41026
41341
  packId: "core-code-context",
41027
41342
  name: "Code Context",
41028
- version: "0.2.1",
41343
+ version: "0.2.2",
41029
41344
  rawRules: [
41030
41345
  internal_ip_default,
41031
41346
  localhost_ref_default,
@@ -41494,9 +41809,10 @@ function createIsolatedScanner(data, opts = {}) {
41494
41809
  if (job.timer !== void 0) return;
41495
41810
  job.startedAt = performance.now();
41496
41811
  job.progressAt = job.startedAt;
41812
+ const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
41497
41813
  job.timer = setTimeout(() => {
41498
41814
  onDeadline(job);
41499
- }, job.budgetMs);
41815
+ }, budget);
41500
41816
  }
41501
41817
  function runOne(spec, fail) {
41502
41818
  if (closed) {
@@ -41507,6 +41823,12 @@ function createIsolatedScanner(data, opts = {}) {
41507
41823
  fail({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
41508
41824
  return;
41509
41825
  }
41826
+ const now = performance.now();
41827
+ const deadlineAt = spec.deadlineAt;
41828
+ if (deadlineAt !== void 0 && deadlineAt <= now) {
41829
+ fail({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
41830
+ return;
41831
+ }
41510
41832
  const started = ensureWorker();
41511
41833
  if (!(started instanceof Worker)) {
41512
41834
  broken = started.error;
@@ -41514,11 +41836,11 @@ function createIsolatedScanner(data, opts = {}) {
41514
41836
  return;
41515
41837
  }
41516
41838
  const id = nextJobId++;
41517
- const now = performance.now();
41518
41839
  const job = {
41519
41840
  id,
41520
41841
  worker: started,
41521
41842
  budgetMs: spec.budgetMs,
41843
+ deadlineAt,
41522
41844
  startedAt: now,
41523
41845
  progressIndex: -1,
41524
41846
  progressAt: now,
@@ -41532,14 +41854,19 @@ function createIsolatedScanner(data, opts = {}) {
41532
41854
  if (readyWorker === started) {
41533
41855
  beginDeadline(job);
41534
41856
  } else {
41857
+ const startBudget = spec.startBudgetMs ?? startBudgetMs;
41858
+ const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
41859
+ const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
41535
41860
  job.startupTimer = setTimeout(() => {
41536
41861
  if (pending !== job) return;
41537
41862
  kill(job.worker);
41538
- failPending({
41539
- status: "unavailable",
41540
- reason: `the scan worker did not start within ${String(startBudgetMs)}ms`
41541
- });
41542
- }, startBudgetMs);
41863
+ failPending(
41864
+ callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
41865
+ status: "unavailable",
41866
+ reason: `the scan worker did not start within ${String(startBudget)}ms`
41867
+ }
41868
+ );
41869
+ }, startWaitMs);
41543
41870
  }
41544
41871
  try {
41545
41872
  started.postMessage(spec.build(id));
@@ -41568,7 +41895,9 @@ function createIsolatedScanner(data, opts = {}) {
41568
41895
  return enqueue((resolve4) => {
41569
41896
  runOne(
41570
41897
  {
41571
- budgetMs,
41898
+ budgetMs: scanOpts?.budgetMs ?? budgetMs,
41899
+ startBudgetMs: scanOpts?.startBudgetMs,
41900
+ deadlineAt: scanOpts?.deadlineAt,
41572
41901
  build: (id) => ({
41573
41902
  kind: "scan",
41574
41903
  id,
@@ -41762,6 +42091,9 @@ function createGuardedScanner(partition, gateway, opts) {
41762
42091
  let unverified = partition.unverified;
41763
42092
  let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
41764
42093
  let retired = false;
42094
+ let bounded;
42095
+ let boundedWarned = false;
42096
+ let closed = false;
41765
42097
  function inProcess(text, context) {
41766
42098
  return scan(text, verified, context);
41767
42099
  }
@@ -41823,11 +42155,48 @@ function createGuardedScanner(partition, gateway, opts) {
41823
42155
  await degrade();
41824
42156
  return inProcess(text, context);
41825
42157
  }
42158
+ async function scanBounded(text, context, bound) {
42159
+ const remainingMs = bound.remainingMs;
42160
+ let outcome;
42161
+ if (closed) {
42162
+ outcome = { status: "unavailable", reason: "the scan worker is closed" };
42163
+ } else if (remainingMs !== void 0 && !(remainingMs > 0)) {
42164
+ outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
42165
+ } else {
42166
+ bounded ??= createIsolatedScanner({ verified, unverified }, opts);
42167
+ const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
42168
+ try {
42169
+ outcome = await bounded.scan(text, context, {
42170
+ budgetMs: bound.budgetMs,
42171
+ startBudgetMs: bound.startBudgetMs,
42172
+ deadlineAt
42173
+ });
42174
+ } catch (error62) {
42175
+ outcome = {
42176
+ status: "unavailable",
42177
+ reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
42178
+ };
42179
+ }
42180
+ }
42181
+ if (outcome.status !== "ok" && !boundedWarned) {
42182
+ boundedWarned = true;
42183
+ process.stderr.write(
42184
+ outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
42185
+ ` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
42186
+ `
42187
+ );
42188
+ }
42189
+ return outcome;
42190
+ }
41826
42191
  return {
41827
42192
  scan: guardedScan,
42193
+ scanBounded,
41828
42194
  degraded: () => retired,
41829
42195
  async close() {
41830
- await retire();
42196
+ closed = true;
42197
+ const live = bounded;
42198
+ bounded = void 0;
42199
+ await Promise.all([retire(), live?.close()]);
41831
42200
  }
41832
42201
  };
41833
42202
  }
@@ -41983,6 +42352,16 @@ function conditionsMatch(conditions, ctx) {
41983
42352
  if (conditions.provider !== void 0) return false;
41984
42353
  return true;
41985
42354
  }
42355
+ function readRemainingMs(largeInput) {
42356
+ const read = largeInput.remainingMs;
42357
+ if (read === void 0) return void 0;
42358
+ try {
42359
+ const remaining = read();
42360
+ return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
42361
+ } catch {
42362
+ return 0;
42363
+ }
42364
+ }
41986
42365
  var bundlesPacked = false;
41987
42366
  function createPluginRuntime(gateway, settings, opts) {
41988
42367
  if (!bundlesPacked) {
@@ -41992,6 +42371,7 @@ function createPluginRuntime(gateway, settings, opts) {
41992
42371
  const policyMode = settings.policy;
41993
42372
  let redactFallback = settings.redactFallback;
41994
42373
  const dataDir2 = opts?.dataDir;
42374
+ const largeInput = opts?.largeInput;
41995
42375
  let rules = [];
41996
42376
  let evidenceOf = evidenceLookup(rules);
41997
42377
  let scanner;
@@ -42204,7 +42584,24 @@ function createPluginRuntime(gateway, settings, opts) {
42204
42584
  await ensureInitialized();
42205
42585
  if (!scanner) throw new Error("the runtime initialized without a scanner");
42206
42586
  const shielded = shieldPointers(text);
42207
- const matched = await scanner.scan(shielded.text, context);
42587
+ let matched;
42588
+ if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
42589
+ const outcome = await scanner.scanBounded(shielded.text, context, {
42590
+ budgetMs: largeInput.budgetMs,
42591
+ startBudgetMs: largeInput.startBudgetMs,
42592
+ remainingMs: readRemainingMs(largeInput)
42593
+ });
42594
+ if (outcome.status !== "ok") {
42595
+ return {
42596
+ decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
42597
+ excepted: /* @__PURE__ */ new Set(),
42598
+ exceptionIds: []
42599
+ };
42600
+ }
42601
+ matched = outcome.findings;
42602
+ } else {
42603
+ matched = await scanner.scan(shielded.text, context);
42604
+ }
42208
42605
  const findings = dropShieldedFindings(matched, shielded.spans);
42209
42606
  const fpCache = /* @__PURE__ */ new Map();
42210
42607
  const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
@@ -42245,20 +42642,24 @@ function createPluginRuntime(gateway, settings, opts) {
42245
42642
  }
42246
42643
  async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
42247
42644
  const filePath = input2.metadata?.filePath;
42248
- if (opts2.persist === "with-findings" && decision.findings.length === 0) return;
42645
+ if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
42646
+ return;
42647
+ }
42249
42648
  try {
42250
42649
  const contentHash = contentHashOf(input2.text);
42251
42650
  const maskedFindings = decision.findings.filter(
42252
42651
  (match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
42253
42652
  );
42254
- const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
42653
+ const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
42255
42654
  const inspectionMs = elapsedMs(timingStartedAt);
42256
42655
  const redactDegradedTo = decision.redactDegradedTo;
42257
- const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 ? {
42656
+ const scanIncomplete = decision.scanIncomplete;
42657
+ const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
42258
42658
  ...input2.metadata,
42259
42659
  ...exceptionIds.length > 0 ? { exceptionIds } : {},
42260
42660
  ...inspectionMs !== void 0 ? { inspectionMs } : {},
42261
- ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
42661
+ ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
42662
+ ...scanIncomplete !== void 0 ? { scanIncomplete } : {}
42262
42663
  } : input2.metadata;
42263
42664
  const event = buildIngestEvent({
42264
42665
  kind: input2.kind,
@@ -43997,6 +44398,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
43997
44398
  var TRACE_ID = EventMetadata.shape.traceId;
43998
44399
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
43999
44400
  var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
44401
+ var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
44000
44402
 
44001
44403
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
44002
44404
  var CAPTURE_BATCH_BYTES = 1024 * 1024;