@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.
@@ -19856,7 +19856,10 @@ function date4(params) {
19856
19856
  var LongContextTier = external_exports.object({
19857
19857
  thresholdInputTokens: external_exports.number().int().positive(),
19858
19858
  input: external_exports.number().nonnegative().nullable(),
19859
- output: external_exports.number().nonnegative().nullable()
19859
+ output: external_exports.number().nonnegative().nullable(),
19860
+ cacheRead: external_exports.number().nonnegative().nullable().optional(),
19861
+ cacheWrite5m: external_exports.number().nonnegative().nullable().optional(),
19862
+ cacheWrite1h: external_exports.number().nonnegative().nullable().optional()
19860
19863
  });
19861
19864
  var ModelPrice = external_exports.object({
19862
19865
  /** USD per 1M uncached input tokens, at or below any long-context threshold. */
@@ -19865,7 +19868,8 @@ var ModelPrice = external_exports.object({
19865
19868
  output: external_exports.number().nonnegative(),
19866
19869
  /**
19867
19870
  * Rate band above a size threshold, or `null` when the model is flat-rated.
19868
- * Anthropic is flat across its 1M window; OpenAI, Google and xAI are not.
19871
+ * OpenAI, Google, xAI and some Anthropic models (Haiku 5.5) band; most
19872
+ * Claude models are flat across their window.
19869
19873
  */
19870
19874
  longContext: LongContextTier.nullable(),
19871
19875
  /** USD per 1M tokens written to a 5-minute ephemeral cache, or null if unpriced. */
@@ -19878,18 +19882,35 @@ var ModelPrice = external_exports.object({
19878
19882
  webSearch: external_exports.number().nonnegative().nullable()
19879
19883
  });
19880
19884
  var WEB_SEARCH_PER_REQUEST = 0.01;
19881
- function anthropicPrice(input2, output2, cacheRead) {
19885
+ function anthropicPrice(input2, output2, cacheRead, longContext = null) {
19882
19886
  return Object.freeze({
19883
19887
  input: input2,
19884
19888
  output: output2,
19885
- longContext: null,
19886
- // flat across the full window on every current Claude
19889
+ longContext: longContext === null ? null : Object.freeze(longContext),
19887
19890
  cacheWrite5m: input2 * 1.25,
19888
19891
  cacheWrite1h: input2 * 2,
19889
19892
  cacheRead,
19890
19893
  webSearch: WEB_SEARCH_PER_REQUEST
19891
19894
  });
19892
19895
  }
19896
+ function anthropicBand(thresholdInputTokens, input2, output2, cacheRead) {
19897
+ return {
19898
+ thresholdInputTokens,
19899
+ input: input2,
19900
+ output: output2,
19901
+ cacheRead,
19902
+ cacheWrite5m: input2 * 1.25,
19903
+ cacheWrite1h: input2 * 2
19904
+ };
19905
+ }
19906
+ function scaledBand(thresholdInputTokens, base, scale) {
19907
+ return {
19908
+ thresholdInputTokens,
19909
+ input: base.input * scale.input,
19910
+ output: base.output * scale.output,
19911
+ ...base.cacheRead === void 0 ? {} : { cacheRead: base.cacheRead * scale.cacheRead }
19912
+ };
19913
+ }
19893
19914
  function tokenPrice(input2, output2, options = {}) {
19894
19915
  return Object.freeze({
19895
19916
  input: input2,
@@ -19922,17 +19943,19 @@ function serviceTierMultiplier(tier) {
19922
19943
  function promptTokensOf(usage) {
19923
19944
  return usage.promptTokens ?? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWrite1hTokens ?? 0) + (usage.cacheWrite5mTokens ?? 0);
19924
19945
  }
19946
+ function bandRate(column, base) {
19947
+ return column === void 0 ? base : column;
19948
+ }
19925
19949
  function costOf(price, usage) {
19950
+ const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
19926
19951
  const metered = [
19927
- [usage.cacheWrite1hTokens ?? 0, price.cacheWrite1h],
19928
- [usage.cacheWrite5mTokens ?? 0, price.cacheWrite5m],
19929
- [usage.cacheReadTokens ?? 0, price.cacheRead]
19952
+ [usage.inputTokens ?? 0, bandRate(band?.input, price.input)],
19953
+ [usage.outputTokens ?? 0, bandRate(band?.output, price.output)],
19954
+ [usage.cacheWrite1hTokens ?? 0, bandRate(band?.cacheWrite1h, price.cacheWrite1h)],
19955
+ [usage.cacheWrite5mTokens ?? 0, bandRate(band?.cacheWrite5m, price.cacheWrite5m)],
19956
+ [usage.cacheReadTokens ?? 0, bandRate(band?.cacheRead, price.cacheRead)]
19930
19957
  ];
19931
- const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
19932
- if (band !== null && (band.input === null || band.output === null)) return null;
19933
- const inputRate = band?.input ?? price.input;
19934
- const outputRate = band?.output ?? price.output;
19935
- let tokenCost = (usage.inputTokens ?? 0) * inputRate + (usage.outputTokens ?? 0) * outputRate;
19958
+ let tokenCost = 0;
19936
19959
  for (const [tokens, rate] of metered) {
19937
19960
  if (tokens === 0) continue;
19938
19961
  if (rate === null) return null;
@@ -20222,10 +20245,20 @@ anthropic.model("claude-fable-5-1", {
20222
20245
  });
20223
20246
  anthropic.model("claude-fable-5", {
20224
20247
  name: "Claude Fable 5",
20248
+ ctx: 1e6,
20249
+ maxOut: 128e3,
20225
20250
  capability: "reasoning",
20226
20251
  price: anthropicPrice(10, 50, 1),
20227
20252
  on: [...CLAUDE_RESELLERS]
20228
20253
  });
20254
+ anthropic.model("claude-opus-5-5", {
20255
+ name: "Claude Opus 5.5",
20256
+ ctx: 1e6,
20257
+ maxOut: 128e3,
20258
+ capability: "reasoning",
20259
+ price: anthropicPrice(4, 20, 0.2),
20260
+ on: [...CLAUDE_RESELLERS]
20261
+ });
20229
20262
  anthropic.model("claude-opus-5", {
20230
20263
  name: "Claude Opus 5",
20231
20264
  ctx: 1e6,
@@ -20236,24 +20269,32 @@ anthropic.model("claude-opus-5", {
20236
20269
  });
20237
20270
  anthropic.model("claude-opus-4-8", {
20238
20271
  name: "Claude Opus 4.8",
20272
+ ctx: 1e6,
20273
+ maxOut: 128e3,
20239
20274
  capability: "reasoning",
20240
20275
  price: anthropicPrice(5, 25, 0.5),
20241
20276
  on: [...CLAUDE_RESELLERS]
20242
20277
  });
20243
20278
  anthropic.model("claude-opus-4-7", {
20244
20279
  name: "Claude Opus 4.7",
20280
+ ctx: 1e6,
20281
+ maxOut: 128e3,
20245
20282
  capability: "reasoning",
20246
20283
  price: anthropicPrice(5, 25, 0.5),
20247
20284
  on: [...CLAUDE_RESELLERS]
20248
20285
  });
20249
20286
  anthropic.model("claude-opus-4-6", {
20250
20287
  name: "Claude Opus 4.6",
20288
+ ctx: 1e6,
20289
+ maxOut: 128e3,
20251
20290
  capability: "reasoning",
20252
20291
  price: anthropicPrice(5, 25, 0.5),
20253
20292
  on: [...CLAUDE_RESELLERS]
20254
20293
  });
20255
20294
  anthropic.model("claude-opus-4-5", {
20256
20295
  name: "Claude Opus 4.5",
20296
+ ctx: 2e5,
20297
+ maxOut: 64e3,
20257
20298
  capability: "reasoning",
20258
20299
  price: anthropicPrice(5, 25, 0.5),
20259
20300
  on: [...CLAUDE_RESELLERS]
@@ -20264,6 +20305,14 @@ anthropic.model("claude-opus-4-1", {
20264
20305
  price: anthropicPrice(15, 75, 1.5),
20265
20306
  on: [...CLAUDE_RESELLERS]
20266
20307
  });
20308
+ anthropic.model("claude-sonnet-5-5", {
20309
+ name: "Claude Sonnet 5.5",
20310
+ ctx: 1e6,
20311
+ maxOut: 128e3,
20312
+ capability: "reasoning",
20313
+ price: anthropicPrice(2, 10, 0.1),
20314
+ on: [...CLAUDE_RESELLERS]
20315
+ });
20267
20316
  anthropic.model("claude-sonnet-5", {
20268
20317
  name: "Claude Sonnet 5",
20269
20318
  ctx: 1e6,
@@ -20274,16 +20323,30 @@ anthropic.model("claude-sonnet-5", {
20274
20323
  });
20275
20324
  anthropic.model("claude-sonnet-4-6", {
20276
20325
  name: "Claude Sonnet 4.6",
20326
+ ctx: 1e6,
20327
+ maxOut: 128e3,
20277
20328
  capability: "reasoning",
20278
20329
  price: anthropicPrice(3, 15, 0.3),
20279
20330
  on: [...CLAUDE_RESELLERS]
20280
20331
  });
20281
20332
  anthropic.model("claude-sonnet-4-5", {
20282
20333
  name: "Claude Sonnet 4.5",
20334
+ ctx: 2e5,
20335
+ maxOut: 64e3,
20283
20336
  capability: "reasoning",
20284
20337
  price: anthropicPrice(3, 15, 0.3),
20285
20338
  on: [...CLAUDE_RESELLERS]
20286
20339
  });
20340
+ anthropic.model("claude-haiku-5-5", {
20341
+ name: "Claude Haiku 5.5",
20342
+ ctx: 1e6,
20343
+ maxOut: 128e3,
20344
+ capability: null,
20345
+ // A prompt over 100,000 tokens, cache reads and writes included, bills the
20346
+ // whole request at the higher band.
20347
+ price: anthropicPrice(0.1, 0.5, 0.01, anthropicBand(1e5, 0.5, 2.5, 0.05)),
20348
+ on: [...CLAUDE_RESELLERS]
20349
+ });
20287
20350
  anthropic.model("claude-haiku-4-5", {
20288
20351
  name: "Claude Haiku 4.5",
20289
20352
  ctx: 2e5,
@@ -20306,7 +20369,13 @@ var OPENAI_TRAINING = {
20306
20369
  consumerControl: "opt-out",
20307
20370
  source: "https://developers.openai.com/api/docs/guides/your-data"
20308
20371
  };
20309
- var LONG_CONTEXT_272K = { thresholdInputTokens: 272e3, input: null, output: null };
20372
+ function gptPrice(input2, output2, cacheRead) {
20373
+ const base = { input: input2, output: output2, ...cacheRead === void 0 ? {} : { cacheRead } };
20374
+ return tokenPrice(input2, output2, {
20375
+ ...base,
20376
+ longContext: scaledBand(272e3, base, { input: 2, output: 1.5, cacheRead: 2 })
20377
+ });
20378
+ }
20310
20379
  var openai = vendor("openai", {
20311
20380
  family: { id: "gpt", name: "GPT" },
20312
20381
  region: "us",
@@ -20314,12 +20383,45 @@ var openai = vendor("openai", {
20314
20383
  training: OPENAI_TRAINING
20315
20384
  });
20316
20385
  var OPENAI_RESELLERS = ["azure", "foundry"];
20386
+ openai.model("gpt-6-astra", {
20387
+ name: "GPT-6 Astra",
20388
+ ctx: 105e4,
20389
+ maxOut: 128e3,
20390
+ capability: "reasoning",
20391
+ price: gptPrice(10, 50, 1),
20392
+ on: [...OPENAI_RESELLERS]
20393
+ });
20394
+ openai.model("gpt-6.1-sol", {
20395
+ name: "GPT-6.1 Sol",
20396
+ ctx: 105e4,
20397
+ maxOut: 128e3,
20398
+ capability: "reasoning",
20399
+ price: gptPrice(2, 10, 0.1),
20400
+ on: [...OPENAI_RESELLERS]
20401
+ });
20402
+ openai.model("gpt-6-sol", {
20403
+ name: "GPT-6 Sol",
20404
+ ctx: 105e4,
20405
+ maxOut: 128e3,
20406
+ capability: "reasoning",
20407
+ price: gptPrice(2, 10, 0.2),
20408
+ on: [...OPENAI_RESELLERS]
20409
+ });
20410
+ openai.model("gpt-6-luna", {
20411
+ name: "GPT-6 Luna",
20412
+ ctx: 105e4,
20413
+ maxOut: 128e3,
20414
+ capability: null,
20415
+ price: gptPrice(0.1, 0.5, 0.01),
20416
+ on: [...OPENAI_RESELLERS]
20417
+ });
20317
20418
  openai.model("gpt-5.6-sol", {
20318
20419
  name: "GPT-5.6 Sol",
20420
+ // Promotional rate, published as available at least through 2026-11-21.
20319
20421
  ctx: 105e4,
20320
20422
  maxOut: 128e3,
20321
20423
  capability: "reasoning",
20322
- price: tokenPrice(4, 20, { cacheRead: 0.4, longContext: LONG_CONTEXT_272K }),
20424
+ price: gptPrice(4, 20, 0.4),
20323
20425
  on: [...OPENAI_RESELLERS]
20324
20426
  });
20325
20427
  openai.model("gpt-5.6-terra", {
@@ -20327,7 +20429,7 @@ openai.model("gpt-5.6-terra", {
20327
20429
  ctx: 105e4,
20328
20430
  maxOut: 128e3,
20329
20431
  capability: "reasoning",
20330
- price: tokenPrice(2, 12, { cacheRead: 0.2, longContext: LONG_CONTEXT_272K }),
20432
+ price: gptPrice(2, 12, 0.2),
20331
20433
  on: [...OPENAI_RESELLERS]
20332
20434
  });
20333
20435
  openai.model("gpt-5.6-luna", {
@@ -20335,7 +20437,7 @@ openai.model("gpt-5.6-luna", {
20335
20437
  ctx: 105e4,
20336
20438
  maxOut: 128e3,
20337
20439
  capability: null,
20338
- price: tokenPrice(0.2, 1.2, { cacheRead: 0.02, longContext: LONG_CONTEXT_272K }),
20440
+ price: gptPrice(0.2, 1.2, 0.02),
20339
20441
  on: [...OPENAI_RESELLERS]
20340
20442
  });
20341
20443
  openai.model("gpt-5.5", {
@@ -20343,7 +20445,15 @@ openai.model("gpt-5.5", {
20343
20445
  ctx: 105e4,
20344
20446
  maxOut: 128e3,
20345
20447
  capability: "reasoning",
20346
- price: tokenPrice(5, 30, { cacheRead: 0.5, longContext: LONG_CONTEXT_272K }),
20448
+ price: gptPrice(5, 30, 0.5),
20449
+ on: [...OPENAI_RESELLERS]
20450
+ });
20451
+ openai.model("gpt-5.5-pro", {
20452
+ name: "GPT-5.5 Pro",
20453
+ ctx: 105e4,
20454
+ maxOut: 128e3,
20455
+ capability: "reasoning",
20456
+ price: gptPrice(30, 180),
20347
20457
  on: [...OPENAI_RESELLERS]
20348
20458
  });
20349
20459
  openai.model("gpt-5.4", {
@@ -20351,7 +20461,7 @@ openai.model("gpt-5.4", {
20351
20461
  ctx: 105e4,
20352
20462
  maxOut: 128e3,
20353
20463
  capability: "reasoning",
20354
- price: tokenPrice(2.5, 15, { cacheRead: 0.25, longContext: LONG_CONTEXT_272K }),
20464
+ price: gptPrice(2.5, 15, 0.25),
20355
20465
  on: [...OPENAI_RESELLERS]
20356
20466
  });
20357
20467
  openai.model("gpt-5.4-mini", {
@@ -20397,6 +20507,7 @@ openai.model("gpt-5", {
20397
20507
  openai.model("gpt-5-mini", {
20398
20508
  name: "GPT-5 mini",
20399
20509
  ctx: 4e5,
20510
+ maxOut: 128e3,
20400
20511
  capability: null,
20401
20512
  price: tokenPrice(0.25, 2, { cacheRead: 0.025 }),
20402
20513
  on: [...OPENAI_RESELLERS]
@@ -20411,11 +20522,15 @@ openai.model("gpt-5-nano", {
20411
20522
  });
20412
20523
  openai.model("gpt-4.1", {
20413
20524
  name: "GPT-4.1",
20525
+ ctx: 1047576,
20526
+ maxOut: 32768,
20414
20527
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
20415
20528
  on: [...OPENAI_RESELLERS]
20416
20529
  });
20417
20530
  openai.model("gpt-4o", {
20418
20531
  name: "GPT-4o",
20532
+ ctx: 128e3,
20533
+ maxOut: 16384,
20419
20534
  price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
20420
20535
  on: [...OPENAI_RESELLERS]
20421
20536
  });
@@ -20439,6 +20554,8 @@ openai.model("gpt-4-turbo", {
20439
20554
  });
20440
20555
  openai.model("o3", {
20441
20556
  name: "o3",
20557
+ ctx: 2e5,
20558
+ maxOut: 1e5,
20442
20559
  capability: "reasoning",
20443
20560
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
20444
20561
  on: [...OPENAI_RESELLERS]
@@ -20491,57 +20608,100 @@ var google = vendor("google", {
20491
20608
  retention: "configurable",
20492
20609
  training: GOOGLE_TRAINING
20493
20610
  });
20611
+ google.model("gemini-3.8-flash", {
20612
+ name: "Gemini 3.8 Flash",
20613
+ ctx: 1048576,
20614
+ maxOut: 65536,
20615
+ capability: null,
20616
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
20617
+ on: ["vertex"]
20618
+ });
20494
20619
  google.model("gemini-3.7-flash", {
20495
20620
  name: "Gemini 3.7 Flash",
20496
20621
  capability: null,
20497
- // Promotional rate; the published post-promotion rate is 1.50 / 7.50.
20498
20622
  price: tokenPrice(0.75, 3.75),
20499
20623
  on: ["vertex"]
20500
20624
  });
20501
20625
  google.model("gemini-3.6-flash", {
20502
20626
  name: "Gemini 3.6 Flash",
20627
+ ctx: 1048576,
20628
+ maxOut: 65536,
20503
20629
  capability: null,
20504
- price: tokenPrice(0.75, 3.75),
20630
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
20505
20631
  on: ["vertex"]
20506
20632
  });
20507
20633
  google.model("gemini-3.5-flash", {
20508
20634
  name: "Gemini 3.5 Flash",
20509
20635
  capability: null,
20510
- price: tokenPrice(1.5, 9),
20511
20636
  on: ["vertex"]
20512
20637
  });
20513
20638
  google.model("gemini-3.5-flash-lite", {
20514
20639
  name: "Gemini 3.5 Flash Lite",
20640
+ ctx: 1048576,
20641
+ maxOut: 65536,
20642
+ capability: null,
20643
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
20644
+ on: ["vertex"]
20645
+ });
20646
+ google.model("gemini-3.1-flash-lite", {
20647
+ name: "Gemini 3.1 Flash Lite",
20648
+ ctx: 1048576,
20649
+ maxOut: 65536,
20650
+ capability: null,
20651
+ price: tokenPrice(0.25, 1.5, { cacheRead: 0.025 }),
20652
+ on: ["vertex"]
20653
+ });
20654
+ google.model("gemini-3-flash-preview", {
20655
+ name: "Gemini 3 Flash Preview",
20656
+ ctx: 1048576,
20657
+ maxOut: 65536,
20515
20658
  capability: null,
20516
- price: tokenPrice(0.3, 2.5),
20659
+ price: tokenPrice(0.5, 3, { cacheRead: 0.05 }),
20517
20660
  on: ["vertex"]
20518
20661
  });
20519
20662
  google.model("gemini-3.1-pro-preview", {
20520
20663
  name: "Gemini 3.1 Pro Preview",
20664
+ ctx: 1048576,
20665
+ maxOut: 65536,
20521
20666
  capability: "reasoning",
20522
20667
  price: tokenPrice(2, 12, {
20523
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 18 }
20668
+ cacheRead: 0.2,
20669
+ longContext: { thresholdInputTokens: 2e5, input: 4, output: 18, cacheRead: 0.4 }
20524
20670
  }),
20671
+ aliases: ["gemini-3.1-pro-preview-customtools"],
20525
20672
  on: ["vertex"]
20526
20673
  });
20527
20674
  google.model("gemini-2.5-pro", {
20528
20675
  name: "Gemini 2.5 Pro",
20676
+ ctx: 1048576,
20677
+ maxOut: 65536,
20529
20678
  capability: "reasoning",
20530
20679
  price: tokenPrice(1.25, 10, {
20531
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15 }
20680
+ cacheRead: 0.125,
20681
+ longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15, cacheRead: 0.25 }
20532
20682
  }),
20533
20683
  on: ["vertex"]
20534
20684
  });
20535
20685
  google.model("gemini-2.5-flash", {
20536
20686
  name: "Gemini 2.5 Flash",
20687
+ ctx: 1048576,
20688
+ maxOut: 65536,
20537
20689
  capability: null,
20538
- price: tokenPrice(0.3, 2.5),
20690
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
20539
20691
  on: ["vertex"]
20540
20692
  });
20541
20693
  google.model("gemini-2.5-flash-lite", {
20542
20694
  name: "Gemini 2.5 Flash Lite",
20695
+ ctx: 1048576,
20696
+ maxOut: 65536,
20543
20697
  capability: null,
20544
- price: tokenPrice(0.1, 0.4),
20698
+ price: tokenPrice(0.1, 0.4, { cacheRead: 0.01 }),
20699
+ on: ["vertex"]
20700
+ });
20701
+ google.model("gemini-embedding-2", {
20702
+ name: "Gemini Embedding 2",
20703
+ capability: "embedding",
20704
+ price: tokenPrice(0.2, 0),
20545
20705
  on: ["vertex"]
20546
20706
  });
20547
20707
  google.model("gemini-1-5-pro", { name: "Gemini 1.5 Pro", on: ["vertex"] });
@@ -20557,43 +20717,62 @@ var xai = vendor("xai", {
20557
20717
  source: "https://docs.x.ai/developers/faq/security"
20558
20718
  }
20559
20719
  });
20720
+ function grokPrice(input2, output2, cacheRead) {
20721
+ const base = { input: input2, output: output2, cacheRead };
20722
+ return tokenPrice(input2, output2, {
20723
+ cacheRead,
20724
+ longContext: scaledBand(2e5, base, { input: 2, output: 2, cacheRead: 2 })
20725
+ });
20726
+ }
20727
+ xai.model("grok-4.7", {
20728
+ name: "Grok 4.7",
20729
+ ctx: 5e5,
20730
+ capability: "reasoning",
20731
+ price: grokPrice(2, 6, 0.5)
20732
+ });
20560
20733
  xai.model("grok-4.6", {
20561
20734
  name: "Grok 4.6",
20562
20735
  ctx: 5e5,
20563
20736
  capability: "reasoning",
20564
- price: tokenPrice(2, 6, {
20565
- cacheRead: 0.5,
20566
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
20567
- }),
20737
+ price: grokPrice(2, 6, 0.5),
20568
20738
  on: ["bedrock"]
20569
20739
  });
20570
20740
  xai.model("grok-4.5", {
20571
20741
  name: "Grok 4.5",
20572
20742
  ctx: 5e5,
20573
20743
  capability: "reasoning",
20574
- price: tokenPrice(2, 6, {
20575
- cacheRead: 0.3,
20576
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
20577
- })
20744
+ price: grokPrice(2, 6, 0.3)
20578
20745
  });
20579
20746
  xai.model("grok-4.3", {
20580
20747
  name: "Grok 4.3",
20581
20748
  ctx: 1e6,
20582
20749
  capability: "reasoning",
20583
- price: tokenPrice(1.25, 2.5, {
20584
- cacheRead: 0.2,
20585
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 5 }
20586
- }),
20750
+ price: grokPrice(1.25, 2.5, 0.2),
20587
20751
  on: ["bedrock"]
20588
20752
  });
20753
+ xai.model("grok-4.20-0309-reasoning", {
20754
+ name: "Grok 4.20 Reasoning",
20755
+ capability: "reasoning",
20756
+ ctx: 1e6,
20757
+ price: grokPrice(1.25, 2.5, 0.2)
20758
+ });
20759
+ xai.model("grok-4.20-0309-non-reasoning", {
20760
+ name: "Grok 4.20",
20761
+ capability: null,
20762
+ ctx: 1e6,
20763
+ price: grokPrice(1.25, 2.5, 0.2)
20764
+ });
20765
+ xai.model("grok-4.20-multi-agent-0309", {
20766
+ name: "Grok 4.20 Multi-Agent",
20767
+ capability: "reasoning",
20768
+ ctx: 1e6,
20769
+ price: grokPrice(1.25, 2.5, 0.2)
20770
+ });
20589
20771
  xai.model("grok-build-0.1", {
20590
20772
  name: "Grok Build 0.1",
20591
20773
  ctx: 256e3,
20592
20774
  capability: "code",
20593
- price: tokenPrice(1, 2, {
20594
- cacheRead: 0.2,
20595
- longContext: { thresholdInputTokens: 2e5, input: 2, output: 4 }
20596
- })
20775
+ price: grokPrice(1, 2, 0.2)
20597
20776
  });
20598
20777
  var deepseek = vendor("deepseek", {
20599
20778
  family: { id: "deepseek", name: "DeepSeek" },
@@ -20606,16 +20785,25 @@ var deepseek = vendor("deepseek", {
20606
20785
  source: "https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html"
20607
20786
  }
20608
20787
  });
20788
+ deepseek.model("deepseek-flash", {
20789
+ name: "DeepSeek V4.1 Flash",
20790
+ ctx: 1e6,
20791
+ maxOut: 384e3,
20792
+ capability: null,
20793
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 })
20794
+ });
20609
20795
  deepseek.model("deepseek-v4-flash", {
20610
20796
  name: "DeepSeek V4 Flash",
20611
20797
  ctx: 1e6,
20798
+ maxOut: 384e3,
20612
20799
  capability: null,
20613
- price: tokenPrice(0.44, 1.32, { cacheRead: 0.014 }),
20800
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 }),
20614
20801
  on: ["bedrock", "together", "fireworks", "openrouter", "ollama", "local"]
20615
20802
  });
20616
20803
  deepseek.model("deepseek-v4-pro", {
20617
20804
  name: "DeepSeek V4 Pro",
20618
20805
  ctx: 1e6,
20806
+ maxOut: 384e3,
20619
20807
  capability: "reasoning",
20620
20808
  price: tokenPrice(1.32, 3.96, { cacheRead: 0.044 }),
20621
20809
  on: ["bedrock", "together", "fireworks", "openrouter"]
@@ -20662,7 +20850,14 @@ cohere.model("command-r-plus-08-2024", {
20662
20850
  ctx: 128e3,
20663
20851
  maxOut: 4e3,
20664
20852
  price: tokenPrice(2.5, 10),
20665
- // The undated form is what deployments report; the live id carries the date.
20853
+ on: ["bedrock"]
20854
+ });
20855
+ cohere.model("command-r-plus-04-2024", {
20856
+ name: "Command R+ (04-2024)",
20857
+ seen: "discovered",
20858
+ ctx: 128e3,
20859
+ maxOut: 4e3,
20860
+ price: tokenPrice(3, 15),
20666
20861
  aliases: ["command-r-plus"],
20667
20862
  on: ["bedrock"]
20668
20863
  });
@@ -20730,6 +20925,65 @@ var mistral = vendor("mistral", {
20730
20925
  retention: "unknown",
20731
20926
  defaultHosting: "local"
20732
20927
  });
20928
+ var MISTRAL_API = { defaultHosting: "api" };
20929
+ mistral.model("mistral-large-4", {
20930
+ ...MISTRAL_API,
20931
+ name: "Mistral Large 4",
20932
+ ctx: 1e6,
20933
+ capability: null,
20934
+ // Public preview at a sale rate; the published original is 1.36 / 4.18 / 0.14.
20935
+ price: tokenPrice(0.68, 2.09, { cacheRead: 0.07 })
20936
+ });
20937
+ mistral.model("mistral-large-2512", {
20938
+ ...MISTRAL_API,
20939
+ name: "Mistral Large 3",
20940
+ ctx: 256e3,
20941
+ capability: null,
20942
+ price: tokenPrice(0.5, 1.5, { cacheRead: 0.05 })
20943
+ });
20944
+ mistral.model("mistral-medium-3-5", {
20945
+ ...MISTRAL_API,
20946
+ name: "Mistral Medium 3.5",
20947
+ ctx: 256e3,
20948
+ capability: null,
20949
+ price: tokenPrice(1.5, 7.5, { cacheRead: 0.15 })
20950
+ });
20951
+ mistral.model("mistral-small-2603", {
20952
+ ...MISTRAL_API,
20953
+ name: "Mistral Small 4",
20954
+ ctx: 256e3,
20955
+ capability: null,
20956
+ price: tokenPrice(0.15, 0.6, { cacheRead: 0.015 })
20957
+ });
20958
+ mistral.model("ministral-14b-2512", {
20959
+ ...MISTRAL_API,
20960
+ name: "Ministral 3 14B",
20961
+ ctx: 256e3,
20962
+ capability: null,
20963
+ price: tokenPrice(0.2, 0.2, { cacheRead: 0.02 })
20964
+ });
20965
+ mistral.model("ministral-8b-2512", {
20966
+ ...MISTRAL_API,
20967
+ name: "Ministral 3 8B",
20968
+ ctx: 256e3,
20969
+ capability: null,
20970
+ price: tokenPrice(0.15, 0.15, { cacheRead: 0.015 })
20971
+ });
20972
+ mistral.model("ministral-3b-2512", {
20973
+ ...MISTRAL_API,
20974
+ name: "Ministral 3 3B",
20975
+ ctx: 256e3,
20976
+ capability: null,
20977
+ price: tokenPrice(0.1, 0.1, { cacheRead: 0.01 })
20978
+ });
20979
+ mistral.model("codestral-2508", {
20980
+ ...MISTRAL_API,
20981
+ name: "Codestral",
20982
+ ctx: 128e3,
20983
+ capability: "code",
20984
+ openWeights: false,
20985
+ price: tokenPrice(0.3, 0.9, { cacheRead: 0.03 })
20986
+ });
20733
20987
  mistral.model("mixtral-8x7b", {
20734
20988
  name: "Mixtral 8x7B",
20735
20989
  seen: "discovered",
@@ -20893,11 +21147,14 @@ var COMPACT = new Intl.NumberFormat("en-US", {
20893
21147
  // ../../packages/schema/src/token/token-report.ts
20894
21148
  var num = (value) => value ?? 0;
20895
21149
  function costUsageOf(a, promptTokens) {
21150
+ const write1h = num(a.ephemeral_1h_input_tokens);
21151
+ const write5m = num(a.ephemeral_5m_input_tokens);
21152
+ const unsplit = Math.max(num(a.cache_creation_input_tokens) - write1h - write5m, 0);
20896
21153
  const usage = {
20897
21154
  inputTokens: num(a.input_tokens),
20898
21155
  outputTokens: num(a.output_tokens),
20899
- cacheWrite1hTokens: num(a.ephemeral_1h_input_tokens),
20900
- cacheWrite5mTokens: num(a.ephemeral_5m_input_tokens),
21156
+ cacheWrite1hTokens: write1h,
21157
+ cacheWrite5mTokens: write5m + unsplit,
20901
21158
  cacheReadTokens: num(a.cache_read_input_tokens),
20902
21159
  webSearchRequests: num(a.web_search_requests)
20903
21160
  };
@@ -21684,6 +21941,11 @@ var CaptureAttributes = external_exports.object({
21684
21941
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
21685
21942
  // repeated rather than referenced because a store reader opens this file.
21686
21943
  redact_degraded_to: ActionTaken.optional(),
21944
+ // Why a capture has no content and no findings: its field was refused
21945
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
21946
+ // whose value this is). Absent on every capture that was scanned, so a
21947
+ // reader can tell a refused row from an empty clean one.
21948
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
21687
21949
  // The scope key this capture was stamped with: the canonical repository
21688
21950
  // (`host/owner/repo`) of the path the capture names (a relative path is read
21689
21951
  // against its working directory), else of its own working directory, or a
@@ -23025,7 +23287,19 @@ var EventMetadata = external_exports.object({
23025
23287
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23026
23288
  // Closing either means moving the reason onto the finding row, which
23027
23289
  // already carries its own action.
23028
- redactDegradedTo: ActionTaken.optional()
23290
+ redactDegradedTo: ActionTaken.optional(),
23291
+ // Set when this capture's field was REFUSED rather than scanned: a hook
23292
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
23293
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
23294
+ // field instead of letting it through unscanned.
23295
+ //
23296
+ // - 'timeout': the bounded scan ran out of time.
23297
+ // - 'unavailable': no worker could run it.
23298
+ //
23299
+ // A refused row stores '' as its content and has no findings, which is
23300
+ // exactly what a clean, empty capture looks like — this marker is the only
23301
+ // thing that tells the two apart. Absent on every capture that was scanned.
23302
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23029
23303
  }).meta({ id: "EventMetadata" });
23030
23304
  var Event = external_exports.object({
23031
23305
  id: external_exports.guid(),
@@ -24842,6 +25116,7 @@ function toCaptureAttributes(event) {
24842
25116
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
24843
25117
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
24844
25118
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
25119
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
24845
25120
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
24846
25121
  // has ever populated either), but every legacy metadata key still rides
24847
25122
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -27830,7 +28105,8 @@ var TIMELINE_COLUMNS = `
27830
28105
  json_extract(attributes, '$.internal') AS internal,
27831
28106
  json_extract(attributes, '$.flagged') AS flagged`;
27832
28107
  var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
27833
- + coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
28108
+ + max(coalesce(cache_creation_input_tokens, 0),
28109
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0)))`;
27834
28110
  var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
27835
28111
  " + "
27836
28112
  );
@@ -36819,6 +37095,42 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
36819
37095
  }
36820
37096
  var CPU_CORROBORATION_SHARE = 0.2;
36821
37097
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
37098
+ function repeatTo(unit, length) {
37099
+ return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
37100
+ }
37101
+ function joinTo(length, open3, close, item) {
37102
+ const parts = [];
37103
+ let size = open3.length;
37104
+ for (let i = 0; size < length; i++) {
37105
+ const next = (i === 0 ? "" : ",") + item(i);
37106
+ parts.push(next);
37107
+ size += next.length;
37108
+ }
37109
+ return (open3 + parts.join("") + close).slice(0, length);
37110
+ }
37111
+ var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
37112
+ var GROWTH_CORPORA = [
37113
+ {
37114
+ name: "one-line JSON dictionary",
37115
+ build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
37116
+ },
37117
+ {
37118
+ name: "JSON array of quoted SQL keywords",
37119
+ build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
37120
+ },
37121
+ { name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
37122
+ {
37123
+ name: 'double-quoted keyword literal run ("where" )',
37124
+ build: (length) => repeatTo('"where" ', length)
37125
+ },
37126
+ { name: "double-quote run", build: (length) => repeatTo('"', length) },
37127
+ { name: "space run", build: (length) => repeatTo(" ", length) },
37128
+ { name: "newline run", build: (length) => repeatTo("\n", length) },
37129
+ ...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
37130
+ name: `unit run ${JSON.stringify(unit)}`,
37131
+ build: (length) => repeatTo(unit, length)
37132
+ }))
37133
+ ];
36822
37134
  function checkRuleTiming(rule, corroborate) {
36823
37135
  const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
36824
37136
  const work = corroboratedMs ?? 0;
@@ -37120,7 +37432,7 @@ var auth_jwt_no_verify_default = {
37120
37432
  severity: "critical",
37121
37433
  matcher: {
37122
37434
  type: "regex",
37123
- pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
37435
+ pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
37124
37436
  flags: "gi"
37125
37437
  },
37126
37438
  requiresNearby: {
@@ -37208,7 +37520,7 @@ var cmd_inject_shell_default = {
37208
37520
  severity: "critical",
37209
37521
  matcher: {
37210
37522
  type: "regex",
37211
- pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
37523
+ pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
37212
37524
  flags: "gi"
37213
37525
  },
37214
37526
  requiresNearby: {
@@ -37337,7 +37649,7 @@ var deser_yaml_unsafe_default = {
37337
37649
  severity: "high",
37338
37650
  matcher: {
37339
37651
  type: "regex",
37340
- pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
37652
+ pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
37341
37653
  flags: "gi"
37342
37654
  },
37343
37655
  examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
@@ -37554,7 +37866,7 @@ var sql_inject_concat_dot_default = {
37554
37866
  severity: "high",
37555
37867
  matcher: {
37556
37868
  type: "regex",
37557
- pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
37869
+ pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
37558
37870
  flags: "gi"
37559
37871
  },
37560
37872
  appliesTo: {
@@ -37572,7 +37884,7 @@ var sql_inject_concat_default = {
37572
37884
  severity: "high",
37573
37885
  matcher: {
37574
37886
  type: "regex",
37575
- 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*\\+`,
37887
+ 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*\\+`,
37576
37888
  flags: "gi"
37577
37889
  },
37578
37890
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -37587,7 +37899,7 @@ var sql_inject_format_default = {
37587
37899
  severity: "high",
37588
37900
  matcher: {
37589
37901
  type: "regex",
37590
- 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]|\\{[^}]+\\})",
37902
+ 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]+\\})",
37591
37903
  flags: "gi"
37592
37904
  },
37593
37905
  examples: [
@@ -37605,7 +37917,7 @@ var sql_inject_interp_default = {
37605
37917
  severity: "high",
37606
37918
  matcher: {
37607
37919
  type: "regex",
37608
- pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
37920
+ pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
37609
37921
  flags: "gi"
37610
37922
  },
37611
37923
  examples: [
@@ -37980,7 +38292,7 @@ var stack_trace_default = {
37980
38292
  severity: "low",
37981
38293
  matcher: {
37982
38294
  type: "regex",
37983
- pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38295
+ pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
37984
38296
  flags: "g"
37985
38297
  },
37986
38298
  examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
@@ -39138,7 +39450,7 @@ var BUNDLED_PACKS = [
39138
39450
  {
39139
39451
  packId: "code-flaws",
39140
39452
  name: "Code Security Flaws",
39141
- version: "0.1.0",
39453
+ version: "0.1.2",
39142
39454
  rawRules: [
39143
39455
  sql_inject_concat_default,
39144
39456
  sql_inject_concat_dot_default,
@@ -39188,7 +39500,7 @@ var BUNDLED_PACKS = [
39188
39500
  {
39189
39501
  packId: "core-code-context",
39190
39502
  name: "Code Context",
39191
- version: "0.2.1",
39503
+ version: "0.2.2",
39192
39504
  rawRules: [
39193
39505
  internal_ip_default,
39194
39506
  localhost_ref_default,
@@ -39625,9 +39937,10 @@ function createIsolatedScanner(data, opts = {}) {
39625
39937
  if (job.timer !== void 0) return;
39626
39938
  job.startedAt = performance.now();
39627
39939
  job.progressAt = job.startedAt;
39940
+ const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
39628
39941
  job.timer = setTimeout(() => {
39629
39942
  onDeadline(job);
39630
- }, job.budgetMs);
39943
+ }, budget);
39631
39944
  }
39632
39945
  function runOne(spec, fail2) {
39633
39946
  if (closed) {
@@ -39638,6 +39951,12 @@ function createIsolatedScanner(data, opts = {}) {
39638
39951
  fail2({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
39639
39952
  return;
39640
39953
  }
39954
+ const now = performance.now();
39955
+ const deadlineAt = spec.deadlineAt;
39956
+ if (deadlineAt !== void 0 && deadlineAt <= now) {
39957
+ fail2({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
39958
+ return;
39959
+ }
39641
39960
  const started = ensureWorker();
39642
39961
  if (!(started instanceof Worker)) {
39643
39962
  broken = started.error;
@@ -39645,11 +39964,11 @@ function createIsolatedScanner(data, opts = {}) {
39645
39964
  return;
39646
39965
  }
39647
39966
  const id = nextJobId++;
39648
- const now = performance.now();
39649
39967
  const job = {
39650
39968
  id,
39651
39969
  worker: started,
39652
39970
  budgetMs: spec.budgetMs,
39971
+ deadlineAt,
39653
39972
  startedAt: now,
39654
39973
  progressIndex: -1,
39655
39974
  progressAt: now,
@@ -39663,14 +39982,19 @@ function createIsolatedScanner(data, opts = {}) {
39663
39982
  if (readyWorker === started) {
39664
39983
  beginDeadline(job);
39665
39984
  } else {
39985
+ const startBudget = spec.startBudgetMs ?? startBudgetMs;
39986
+ const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
39987
+ const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
39666
39988
  job.startupTimer = setTimeout(() => {
39667
39989
  if (pending !== job) return;
39668
39990
  kill(job.worker);
39669
- failPending({
39670
- status: "unavailable",
39671
- reason: `the scan worker did not start within ${String(startBudgetMs)}ms`
39672
- });
39673
- }, startBudgetMs);
39991
+ failPending(
39992
+ callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
39993
+ status: "unavailable",
39994
+ reason: `the scan worker did not start within ${String(startBudget)}ms`
39995
+ }
39996
+ );
39997
+ }, startWaitMs);
39674
39998
  }
39675
39999
  try {
39676
40000
  started.postMessage(spec.build(id));
@@ -39699,7 +40023,9 @@ function createIsolatedScanner(data, opts = {}) {
39699
40023
  return enqueue((resolve4) => {
39700
40024
  runOne(
39701
40025
  {
39702
- budgetMs,
40026
+ budgetMs: scanOpts?.budgetMs ?? budgetMs,
40027
+ startBudgetMs: scanOpts?.startBudgetMs,
40028
+ deadlineAt: scanOpts?.deadlineAt,
39703
40029
  build: (id) => ({
39704
40030
  kind: "scan",
39705
40031
  id,
@@ -39893,6 +40219,9 @@ function createGuardedScanner(partition, gateway, opts) {
39893
40219
  let unverified = partition.unverified;
39894
40220
  let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
39895
40221
  let retired = false;
40222
+ let bounded;
40223
+ let boundedWarned = false;
40224
+ let closed = false;
39896
40225
  function inProcess(text, context) {
39897
40226
  return scan(text, verified, context);
39898
40227
  }
@@ -39954,11 +40283,48 @@ function createGuardedScanner(partition, gateway, opts) {
39954
40283
  await degrade();
39955
40284
  return inProcess(text, context);
39956
40285
  }
40286
+ async function scanBounded(text, context, bound) {
40287
+ const remainingMs = bound.remainingMs;
40288
+ let outcome;
40289
+ if (closed) {
40290
+ outcome = { status: "unavailable", reason: "the scan worker is closed" };
40291
+ } else if (remainingMs !== void 0 && !(remainingMs > 0)) {
40292
+ outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
40293
+ } else {
40294
+ bounded ??= createIsolatedScanner({ verified, unverified }, opts);
40295
+ const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
40296
+ try {
40297
+ outcome = await bounded.scan(text, context, {
40298
+ budgetMs: bound.budgetMs,
40299
+ startBudgetMs: bound.startBudgetMs,
40300
+ deadlineAt
40301
+ });
40302
+ } catch (error62) {
40303
+ outcome = {
40304
+ status: "unavailable",
40305
+ reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
40306
+ };
40307
+ }
40308
+ }
40309
+ if (outcome.status !== "ok" && !boundedWarned) {
40310
+ boundedWarned = true;
40311
+ process.stderr.write(
40312
+ outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
40313
+ ` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
40314
+ `
40315
+ );
40316
+ }
40317
+ return outcome;
40318
+ }
39957
40319
  return {
39958
40320
  scan: guardedScan,
40321
+ scanBounded,
39959
40322
  degraded: () => retired,
39960
40323
  async close() {
39961
- await retire();
40324
+ closed = true;
40325
+ const live = bounded;
40326
+ bounded = void 0;
40327
+ await Promise.all([retire(), live?.close()]);
39962
40328
  }
39963
40329
  };
39964
40330
  }
@@ -40060,6 +40426,16 @@ function conditionsMatch(conditions, ctx) {
40060
40426
  if (conditions.provider !== void 0) return false;
40061
40427
  return true;
40062
40428
  }
40429
+ function readRemainingMs(largeInput) {
40430
+ const read = largeInput.remainingMs;
40431
+ if (read === void 0) return void 0;
40432
+ try {
40433
+ const remaining = read();
40434
+ return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
40435
+ } catch {
40436
+ return 0;
40437
+ }
40438
+ }
40063
40439
  var bundlesPacked = false;
40064
40440
  function createPluginRuntime(gateway, settings, opts) {
40065
40441
  if (!bundlesPacked) {
@@ -40069,6 +40445,7 @@ function createPluginRuntime(gateway, settings, opts) {
40069
40445
  const policyMode = settings.policy;
40070
40446
  let redactFallback = settings.redactFallback;
40071
40447
  const dataDir2 = opts?.dataDir;
40448
+ const largeInput = opts?.largeInput;
40072
40449
  let rules = [];
40073
40450
  let evidenceOf = evidenceLookup(rules);
40074
40451
  let scanner;
@@ -40281,7 +40658,24 @@ function createPluginRuntime(gateway, settings, opts) {
40281
40658
  await ensureInitialized();
40282
40659
  if (!scanner) throw new Error("the runtime initialized without a scanner");
40283
40660
  const shielded = shieldPointers(text);
40284
- const matched = await scanner.scan(shielded.text, context);
40661
+ let matched;
40662
+ if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
40663
+ const outcome = await scanner.scanBounded(shielded.text, context, {
40664
+ budgetMs: largeInput.budgetMs,
40665
+ startBudgetMs: largeInput.startBudgetMs,
40666
+ remainingMs: readRemainingMs(largeInput)
40667
+ });
40668
+ if (outcome.status !== "ok") {
40669
+ return {
40670
+ decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
40671
+ excepted: /* @__PURE__ */ new Set(),
40672
+ exceptionIds: []
40673
+ };
40674
+ }
40675
+ matched = outcome.findings;
40676
+ } else {
40677
+ matched = await scanner.scan(shielded.text, context);
40678
+ }
40285
40679
  const findings = dropShieldedFindings(matched, shielded.spans);
40286
40680
  const fpCache = /* @__PURE__ */ new Map();
40287
40681
  const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
@@ -40322,20 +40716,24 @@ function createPluginRuntime(gateway, settings, opts) {
40322
40716
  }
40323
40717
  async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
40324
40718
  const filePath = input2.metadata?.filePath;
40325
- if (opts2.persist === "with-findings" && decision.findings.length === 0) return;
40719
+ if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
40720
+ return;
40721
+ }
40326
40722
  try {
40327
40723
  const contentHash = contentHashOf(input2.text);
40328
40724
  const maskedFindings = decision.findings.filter(
40329
40725
  (match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
40330
40726
  );
40331
- const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40727
+ const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40332
40728
  const inspectionMs = elapsedMs(timingStartedAt);
40333
40729
  const redactDegradedTo = decision.redactDegradedTo;
40334
- const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 ? {
40730
+ const scanIncomplete = decision.scanIncomplete;
40731
+ const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
40335
40732
  ...input2.metadata,
40336
40733
  ...exceptionIds.length > 0 ? { exceptionIds } : {},
40337
40734
  ...inspectionMs !== void 0 ? { inspectionMs } : {},
40338
- ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
40735
+ ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
40736
+ ...scanIncomplete !== void 0 ? { scanIncomplete } : {}
40339
40737
  } : input2.metadata;
40340
40738
  const event = buildIngestEvent({
40341
40739
  kind: input2.kind,
@@ -42396,6 +42794,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
42396
42794
  var TRACE_ID = EventMetadata.shape.traceId;
42397
42795
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
42398
42796
  var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
42797
+ var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
42399
42798
 
42400
42799
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
42401
42800
  var CAPTURE_BATCH_BYTES = 1024 * 1024;