@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.
@@ -19859,7 +19859,10 @@ function date4(params) {
19859
19859
  var LongContextTier = external_exports.object({
19860
19860
  thresholdInputTokens: external_exports.number().int().positive(),
19861
19861
  input: external_exports.number().nonnegative().nullable(),
19862
- output: external_exports.number().nonnegative().nullable()
19862
+ output: external_exports.number().nonnegative().nullable(),
19863
+ cacheRead: external_exports.number().nonnegative().nullable().optional(),
19864
+ cacheWrite5m: external_exports.number().nonnegative().nullable().optional(),
19865
+ cacheWrite1h: external_exports.number().nonnegative().nullable().optional()
19863
19866
  });
19864
19867
  var ModelPrice = external_exports.object({
19865
19868
  /** USD per 1M uncached input tokens, at or below any long-context threshold. */
@@ -19868,7 +19871,8 @@ var ModelPrice = external_exports.object({
19868
19871
  output: external_exports.number().nonnegative(),
19869
19872
  /**
19870
19873
  * Rate band above a size threshold, or `null` when the model is flat-rated.
19871
- * Anthropic is flat across its 1M window; OpenAI, Google and xAI are not.
19874
+ * OpenAI, Google, xAI and some Anthropic models (Haiku 5.5) band; most
19875
+ * Claude models are flat across their window.
19872
19876
  */
19873
19877
  longContext: LongContextTier.nullable(),
19874
19878
  /** USD per 1M tokens written to a 5-minute ephemeral cache, or null if unpriced. */
@@ -19881,18 +19885,35 @@ var ModelPrice = external_exports.object({
19881
19885
  webSearch: external_exports.number().nonnegative().nullable()
19882
19886
  });
19883
19887
  var WEB_SEARCH_PER_REQUEST = 0.01;
19884
- function anthropicPrice(input2, output2, cacheRead) {
19888
+ function anthropicPrice(input2, output2, cacheRead, longContext = null) {
19885
19889
  return Object.freeze({
19886
19890
  input: input2,
19887
19891
  output: output2,
19888
- longContext: null,
19889
- // flat across the full window on every current Claude
19892
+ longContext: longContext === null ? null : Object.freeze(longContext),
19890
19893
  cacheWrite5m: input2 * 1.25,
19891
19894
  cacheWrite1h: input2 * 2,
19892
19895
  cacheRead,
19893
19896
  webSearch: WEB_SEARCH_PER_REQUEST
19894
19897
  });
19895
19898
  }
19899
+ function anthropicBand(thresholdInputTokens, input2, output2, cacheRead) {
19900
+ return {
19901
+ thresholdInputTokens,
19902
+ input: input2,
19903
+ output: output2,
19904
+ cacheRead,
19905
+ cacheWrite5m: input2 * 1.25,
19906
+ cacheWrite1h: input2 * 2
19907
+ };
19908
+ }
19909
+ function scaledBand(thresholdInputTokens, base, scale) {
19910
+ return {
19911
+ thresholdInputTokens,
19912
+ input: base.input * scale.input,
19913
+ output: base.output * scale.output,
19914
+ ...base.cacheRead === void 0 ? {} : { cacheRead: base.cacheRead * scale.cacheRead }
19915
+ };
19916
+ }
19896
19917
  function tokenPrice(input2, output2, options = {}) {
19897
19918
  return Object.freeze({
19898
19919
  input: input2,
@@ -19925,17 +19946,19 @@ function serviceTierMultiplier(tier) {
19925
19946
  function promptTokensOf(usage) {
19926
19947
  return usage.promptTokens ?? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWrite1hTokens ?? 0) + (usage.cacheWrite5mTokens ?? 0);
19927
19948
  }
19949
+ function bandRate(column, base) {
19950
+ return column === void 0 ? base : column;
19951
+ }
19928
19952
  function costOf(price, usage) {
19953
+ const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
19929
19954
  const metered = [
19930
- [usage.cacheWrite1hTokens ?? 0, price.cacheWrite1h],
19931
- [usage.cacheWrite5mTokens ?? 0, price.cacheWrite5m],
19932
- [usage.cacheReadTokens ?? 0, price.cacheRead]
19955
+ [usage.inputTokens ?? 0, bandRate(band?.input, price.input)],
19956
+ [usage.outputTokens ?? 0, bandRate(band?.output, price.output)],
19957
+ [usage.cacheWrite1hTokens ?? 0, bandRate(band?.cacheWrite1h, price.cacheWrite1h)],
19958
+ [usage.cacheWrite5mTokens ?? 0, bandRate(band?.cacheWrite5m, price.cacheWrite5m)],
19959
+ [usage.cacheReadTokens ?? 0, bandRate(band?.cacheRead, price.cacheRead)]
19933
19960
  ];
19934
- const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
19935
- if (band !== null && (band.input === null || band.output === null)) return null;
19936
- const inputRate = band?.input ?? price.input;
19937
- const outputRate = band?.output ?? price.output;
19938
- let tokenCost = (usage.inputTokens ?? 0) * inputRate + (usage.outputTokens ?? 0) * outputRate;
19961
+ let tokenCost = 0;
19939
19962
  for (const [tokens, rate] of metered) {
19940
19963
  if (tokens === 0) continue;
19941
19964
  if (rate === null) return null;
@@ -20225,10 +20248,20 @@ anthropic.model("claude-fable-5-1", {
20225
20248
  });
20226
20249
  anthropic.model("claude-fable-5", {
20227
20250
  name: "Claude Fable 5",
20251
+ ctx: 1e6,
20252
+ maxOut: 128e3,
20228
20253
  capability: "reasoning",
20229
20254
  price: anthropicPrice(10, 50, 1),
20230
20255
  on: [...CLAUDE_RESELLERS]
20231
20256
  });
20257
+ anthropic.model("claude-opus-5-5", {
20258
+ name: "Claude Opus 5.5",
20259
+ ctx: 1e6,
20260
+ maxOut: 128e3,
20261
+ capability: "reasoning",
20262
+ price: anthropicPrice(4, 20, 0.2),
20263
+ on: [...CLAUDE_RESELLERS]
20264
+ });
20232
20265
  anthropic.model("claude-opus-5", {
20233
20266
  name: "Claude Opus 5",
20234
20267
  ctx: 1e6,
@@ -20239,24 +20272,32 @@ anthropic.model("claude-opus-5", {
20239
20272
  });
20240
20273
  anthropic.model("claude-opus-4-8", {
20241
20274
  name: "Claude Opus 4.8",
20275
+ ctx: 1e6,
20276
+ maxOut: 128e3,
20242
20277
  capability: "reasoning",
20243
20278
  price: anthropicPrice(5, 25, 0.5),
20244
20279
  on: [...CLAUDE_RESELLERS]
20245
20280
  });
20246
20281
  anthropic.model("claude-opus-4-7", {
20247
20282
  name: "Claude Opus 4.7",
20283
+ ctx: 1e6,
20284
+ maxOut: 128e3,
20248
20285
  capability: "reasoning",
20249
20286
  price: anthropicPrice(5, 25, 0.5),
20250
20287
  on: [...CLAUDE_RESELLERS]
20251
20288
  });
20252
20289
  anthropic.model("claude-opus-4-6", {
20253
20290
  name: "Claude Opus 4.6",
20291
+ ctx: 1e6,
20292
+ maxOut: 128e3,
20254
20293
  capability: "reasoning",
20255
20294
  price: anthropicPrice(5, 25, 0.5),
20256
20295
  on: [...CLAUDE_RESELLERS]
20257
20296
  });
20258
20297
  anthropic.model("claude-opus-4-5", {
20259
20298
  name: "Claude Opus 4.5",
20299
+ ctx: 2e5,
20300
+ maxOut: 64e3,
20260
20301
  capability: "reasoning",
20261
20302
  price: anthropicPrice(5, 25, 0.5),
20262
20303
  on: [...CLAUDE_RESELLERS]
@@ -20267,6 +20308,14 @@ anthropic.model("claude-opus-4-1", {
20267
20308
  price: anthropicPrice(15, 75, 1.5),
20268
20309
  on: [...CLAUDE_RESELLERS]
20269
20310
  });
20311
+ anthropic.model("claude-sonnet-5-5", {
20312
+ name: "Claude Sonnet 5.5",
20313
+ ctx: 1e6,
20314
+ maxOut: 128e3,
20315
+ capability: "reasoning",
20316
+ price: anthropicPrice(2, 10, 0.1),
20317
+ on: [...CLAUDE_RESELLERS]
20318
+ });
20270
20319
  anthropic.model("claude-sonnet-5", {
20271
20320
  name: "Claude Sonnet 5",
20272
20321
  ctx: 1e6,
@@ -20277,16 +20326,30 @@ anthropic.model("claude-sonnet-5", {
20277
20326
  });
20278
20327
  anthropic.model("claude-sonnet-4-6", {
20279
20328
  name: "Claude Sonnet 4.6",
20329
+ ctx: 1e6,
20330
+ maxOut: 128e3,
20280
20331
  capability: "reasoning",
20281
20332
  price: anthropicPrice(3, 15, 0.3),
20282
20333
  on: [...CLAUDE_RESELLERS]
20283
20334
  });
20284
20335
  anthropic.model("claude-sonnet-4-5", {
20285
20336
  name: "Claude Sonnet 4.5",
20337
+ ctx: 2e5,
20338
+ maxOut: 64e3,
20286
20339
  capability: "reasoning",
20287
20340
  price: anthropicPrice(3, 15, 0.3),
20288
20341
  on: [...CLAUDE_RESELLERS]
20289
20342
  });
20343
+ anthropic.model("claude-haiku-5-5", {
20344
+ name: "Claude Haiku 5.5",
20345
+ ctx: 1e6,
20346
+ maxOut: 128e3,
20347
+ capability: null,
20348
+ // A prompt over 100,000 tokens, cache reads and writes included, bills the
20349
+ // whole request at the higher band.
20350
+ price: anthropicPrice(0.1, 0.5, 0.01, anthropicBand(1e5, 0.5, 2.5, 0.05)),
20351
+ on: [...CLAUDE_RESELLERS]
20352
+ });
20290
20353
  anthropic.model("claude-haiku-4-5", {
20291
20354
  name: "Claude Haiku 4.5",
20292
20355
  ctx: 2e5,
@@ -20309,7 +20372,13 @@ var OPENAI_TRAINING = {
20309
20372
  consumerControl: "opt-out",
20310
20373
  source: "https://developers.openai.com/api/docs/guides/your-data"
20311
20374
  };
20312
- var LONG_CONTEXT_272K = { thresholdInputTokens: 272e3, input: null, output: null };
20375
+ function gptPrice(input2, output2, cacheRead) {
20376
+ const base = { input: input2, output: output2, ...cacheRead === void 0 ? {} : { cacheRead } };
20377
+ return tokenPrice(input2, output2, {
20378
+ ...base,
20379
+ longContext: scaledBand(272e3, base, { input: 2, output: 1.5, cacheRead: 2 })
20380
+ });
20381
+ }
20313
20382
  var openai = vendor("openai", {
20314
20383
  family: { id: "gpt", name: "GPT" },
20315
20384
  region: "us",
@@ -20317,12 +20386,45 @@ var openai = vendor("openai", {
20317
20386
  training: OPENAI_TRAINING
20318
20387
  });
20319
20388
  var OPENAI_RESELLERS = ["azure", "foundry"];
20389
+ openai.model("gpt-6-astra", {
20390
+ name: "GPT-6 Astra",
20391
+ ctx: 105e4,
20392
+ maxOut: 128e3,
20393
+ capability: "reasoning",
20394
+ price: gptPrice(10, 50, 1),
20395
+ on: [...OPENAI_RESELLERS]
20396
+ });
20397
+ openai.model("gpt-6.1-sol", {
20398
+ name: "GPT-6.1 Sol",
20399
+ ctx: 105e4,
20400
+ maxOut: 128e3,
20401
+ capability: "reasoning",
20402
+ price: gptPrice(2, 10, 0.1),
20403
+ on: [...OPENAI_RESELLERS]
20404
+ });
20405
+ openai.model("gpt-6-sol", {
20406
+ name: "GPT-6 Sol",
20407
+ ctx: 105e4,
20408
+ maxOut: 128e3,
20409
+ capability: "reasoning",
20410
+ price: gptPrice(2, 10, 0.2),
20411
+ on: [...OPENAI_RESELLERS]
20412
+ });
20413
+ openai.model("gpt-6-luna", {
20414
+ name: "GPT-6 Luna",
20415
+ ctx: 105e4,
20416
+ maxOut: 128e3,
20417
+ capability: null,
20418
+ price: gptPrice(0.1, 0.5, 0.01),
20419
+ on: [...OPENAI_RESELLERS]
20420
+ });
20320
20421
  openai.model("gpt-5.6-sol", {
20321
20422
  name: "GPT-5.6 Sol",
20423
+ // Promotional rate, published as available at least through 2026-11-21.
20322
20424
  ctx: 105e4,
20323
20425
  maxOut: 128e3,
20324
20426
  capability: "reasoning",
20325
- price: tokenPrice(4, 20, { cacheRead: 0.4, longContext: LONG_CONTEXT_272K }),
20427
+ price: gptPrice(4, 20, 0.4),
20326
20428
  on: [...OPENAI_RESELLERS]
20327
20429
  });
20328
20430
  openai.model("gpt-5.6-terra", {
@@ -20330,7 +20432,7 @@ openai.model("gpt-5.6-terra", {
20330
20432
  ctx: 105e4,
20331
20433
  maxOut: 128e3,
20332
20434
  capability: "reasoning",
20333
- price: tokenPrice(2, 12, { cacheRead: 0.2, longContext: LONG_CONTEXT_272K }),
20435
+ price: gptPrice(2, 12, 0.2),
20334
20436
  on: [...OPENAI_RESELLERS]
20335
20437
  });
20336
20438
  openai.model("gpt-5.6-luna", {
@@ -20338,7 +20440,7 @@ openai.model("gpt-5.6-luna", {
20338
20440
  ctx: 105e4,
20339
20441
  maxOut: 128e3,
20340
20442
  capability: null,
20341
- price: tokenPrice(0.2, 1.2, { cacheRead: 0.02, longContext: LONG_CONTEXT_272K }),
20443
+ price: gptPrice(0.2, 1.2, 0.02),
20342
20444
  on: [...OPENAI_RESELLERS]
20343
20445
  });
20344
20446
  openai.model("gpt-5.5", {
@@ -20346,7 +20448,15 @@ openai.model("gpt-5.5", {
20346
20448
  ctx: 105e4,
20347
20449
  maxOut: 128e3,
20348
20450
  capability: "reasoning",
20349
- price: tokenPrice(5, 30, { cacheRead: 0.5, longContext: LONG_CONTEXT_272K }),
20451
+ price: gptPrice(5, 30, 0.5),
20452
+ on: [...OPENAI_RESELLERS]
20453
+ });
20454
+ openai.model("gpt-5.5-pro", {
20455
+ name: "GPT-5.5 Pro",
20456
+ ctx: 105e4,
20457
+ maxOut: 128e3,
20458
+ capability: "reasoning",
20459
+ price: gptPrice(30, 180),
20350
20460
  on: [...OPENAI_RESELLERS]
20351
20461
  });
20352
20462
  openai.model("gpt-5.4", {
@@ -20354,7 +20464,7 @@ openai.model("gpt-5.4", {
20354
20464
  ctx: 105e4,
20355
20465
  maxOut: 128e3,
20356
20466
  capability: "reasoning",
20357
- price: tokenPrice(2.5, 15, { cacheRead: 0.25, longContext: LONG_CONTEXT_272K }),
20467
+ price: gptPrice(2.5, 15, 0.25),
20358
20468
  on: [...OPENAI_RESELLERS]
20359
20469
  });
20360
20470
  openai.model("gpt-5.4-mini", {
@@ -20400,6 +20510,7 @@ openai.model("gpt-5", {
20400
20510
  openai.model("gpt-5-mini", {
20401
20511
  name: "GPT-5 mini",
20402
20512
  ctx: 4e5,
20513
+ maxOut: 128e3,
20403
20514
  capability: null,
20404
20515
  price: tokenPrice(0.25, 2, { cacheRead: 0.025 }),
20405
20516
  on: [...OPENAI_RESELLERS]
@@ -20414,11 +20525,15 @@ openai.model("gpt-5-nano", {
20414
20525
  });
20415
20526
  openai.model("gpt-4.1", {
20416
20527
  name: "GPT-4.1",
20528
+ ctx: 1047576,
20529
+ maxOut: 32768,
20417
20530
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
20418
20531
  on: [...OPENAI_RESELLERS]
20419
20532
  });
20420
20533
  openai.model("gpt-4o", {
20421
20534
  name: "GPT-4o",
20535
+ ctx: 128e3,
20536
+ maxOut: 16384,
20422
20537
  price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
20423
20538
  on: [...OPENAI_RESELLERS]
20424
20539
  });
@@ -20442,6 +20557,8 @@ openai.model("gpt-4-turbo", {
20442
20557
  });
20443
20558
  openai.model("o3", {
20444
20559
  name: "o3",
20560
+ ctx: 2e5,
20561
+ maxOut: 1e5,
20445
20562
  capability: "reasoning",
20446
20563
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
20447
20564
  on: [...OPENAI_RESELLERS]
@@ -20494,57 +20611,100 @@ var google = vendor("google", {
20494
20611
  retention: "configurable",
20495
20612
  training: GOOGLE_TRAINING
20496
20613
  });
20614
+ google.model("gemini-3.8-flash", {
20615
+ name: "Gemini 3.8 Flash",
20616
+ ctx: 1048576,
20617
+ maxOut: 65536,
20618
+ capability: null,
20619
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
20620
+ on: ["vertex"]
20621
+ });
20497
20622
  google.model("gemini-3.7-flash", {
20498
20623
  name: "Gemini 3.7 Flash",
20499
20624
  capability: null,
20500
- // Promotional rate; the published post-promotion rate is 1.50 / 7.50.
20501
20625
  price: tokenPrice(0.75, 3.75),
20502
20626
  on: ["vertex"]
20503
20627
  });
20504
20628
  google.model("gemini-3.6-flash", {
20505
20629
  name: "Gemini 3.6 Flash",
20630
+ ctx: 1048576,
20631
+ maxOut: 65536,
20506
20632
  capability: null,
20507
- price: tokenPrice(0.75, 3.75),
20633
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
20508
20634
  on: ["vertex"]
20509
20635
  });
20510
20636
  google.model("gemini-3.5-flash", {
20511
20637
  name: "Gemini 3.5 Flash",
20512
20638
  capability: null,
20513
- price: tokenPrice(1.5, 9),
20514
20639
  on: ["vertex"]
20515
20640
  });
20516
20641
  google.model("gemini-3.5-flash-lite", {
20517
20642
  name: "Gemini 3.5 Flash Lite",
20643
+ ctx: 1048576,
20644
+ maxOut: 65536,
20645
+ capability: null,
20646
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
20647
+ on: ["vertex"]
20648
+ });
20649
+ google.model("gemini-3.1-flash-lite", {
20650
+ name: "Gemini 3.1 Flash Lite",
20651
+ ctx: 1048576,
20652
+ maxOut: 65536,
20653
+ capability: null,
20654
+ price: tokenPrice(0.25, 1.5, { cacheRead: 0.025 }),
20655
+ on: ["vertex"]
20656
+ });
20657
+ google.model("gemini-3-flash-preview", {
20658
+ name: "Gemini 3 Flash Preview",
20659
+ ctx: 1048576,
20660
+ maxOut: 65536,
20518
20661
  capability: null,
20519
- price: tokenPrice(0.3, 2.5),
20662
+ price: tokenPrice(0.5, 3, { cacheRead: 0.05 }),
20520
20663
  on: ["vertex"]
20521
20664
  });
20522
20665
  google.model("gemini-3.1-pro-preview", {
20523
20666
  name: "Gemini 3.1 Pro Preview",
20667
+ ctx: 1048576,
20668
+ maxOut: 65536,
20524
20669
  capability: "reasoning",
20525
20670
  price: tokenPrice(2, 12, {
20526
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 18 }
20671
+ cacheRead: 0.2,
20672
+ longContext: { thresholdInputTokens: 2e5, input: 4, output: 18, cacheRead: 0.4 }
20527
20673
  }),
20674
+ aliases: ["gemini-3.1-pro-preview-customtools"],
20528
20675
  on: ["vertex"]
20529
20676
  });
20530
20677
  google.model("gemini-2.5-pro", {
20531
20678
  name: "Gemini 2.5 Pro",
20679
+ ctx: 1048576,
20680
+ maxOut: 65536,
20532
20681
  capability: "reasoning",
20533
20682
  price: tokenPrice(1.25, 10, {
20534
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15 }
20683
+ cacheRead: 0.125,
20684
+ longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15, cacheRead: 0.25 }
20535
20685
  }),
20536
20686
  on: ["vertex"]
20537
20687
  });
20538
20688
  google.model("gemini-2.5-flash", {
20539
20689
  name: "Gemini 2.5 Flash",
20690
+ ctx: 1048576,
20691
+ maxOut: 65536,
20540
20692
  capability: null,
20541
- price: tokenPrice(0.3, 2.5),
20693
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
20542
20694
  on: ["vertex"]
20543
20695
  });
20544
20696
  google.model("gemini-2.5-flash-lite", {
20545
20697
  name: "Gemini 2.5 Flash Lite",
20698
+ ctx: 1048576,
20699
+ maxOut: 65536,
20546
20700
  capability: null,
20547
- price: tokenPrice(0.1, 0.4),
20701
+ price: tokenPrice(0.1, 0.4, { cacheRead: 0.01 }),
20702
+ on: ["vertex"]
20703
+ });
20704
+ google.model("gemini-embedding-2", {
20705
+ name: "Gemini Embedding 2",
20706
+ capability: "embedding",
20707
+ price: tokenPrice(0.2, 0),
20548
20708
  on: ["vertex"]
20549
20709
  });
20550
20710
  google.model("gemini-1-5-pro", { name: "Gemini 1.5 Pro", on: ["vertex"] });
@@ -20560,43 +20720,62 @@ var xai = vendor("xai", {
20560
20720
  source: "https://docs.x.ai/developers/faq/security"
20561
20721
  }
20562
20722
  });
20723
+ function grokPrice(input2, output2, cacheRead) {
20724
+ const base = { input: input2, output: output2, cacheRead };
20725
+ return tokenPrice(input2, output2, {
20726
+ cacheRead,
20727
+ longContext: scaledBand(2e5, base, { input: 2, output: 2, cacheRead: 2 })
20728
+ });
20729
+ }
20730
+ xai.model("grok-4.7", {
20731
+ name: "Grok 4.7",
20732
+ ctx: 5e5,
20733
+ capability: "reasoning",
20734
+ price: grokPrice(2, 6, 0.5)
20735
+ });
20563
20736
  xai.model("grok-4.6", {
20564
20737
  name: "Grok 4.6",
20565
20738
  ctx: 5e5,
20566
20739
  capability: "reasoning",
20567
- price: tokenPrice(2, 6, {
20568
- cacheRead: 0.5,
20569
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
20570
- }),
20740
+ price: grokPrice(2, 6, 0.5),
20571
20741
  on: ["bedrock"]
20572
20742
  });
20573
20743
  xai.model("grok-4.5", {
20574
20744
  name: "Grok 4.5",
20575
20745
  ctx: 5e5,
20576
20746
  capability: "reasoning",
20577
- price: tokenPrice(2, 6, {
20578
- cacheRead: 0.3,
20579
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
20580
- })
20747
+ price: grokPrice(2, 6, 0.3)
20581
20748
  });
20582
20749
  xai.model("grok-4.3", {
20583
20750
  name: "Grok 4.3",
20584
20751
  ctx: 1e6,
20585
20752
  capability: "reasoning",
20586
- price: tokenPrice(1.25, 2.5, {
20587
- cacheRead: 0.2,
20588
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 5 }
20589
- }),
20753
+ price: grokPrice(1.25, 2.5, 0.2),
20590
20754
  on: ["bedrock"]
20591
20755
  });
20756
+ xai.model("grok-4.20-0309-reasoning", {
20757
+ name: "Grok 4.20 Reasoning",
20758
+ capability: "reasoning",
20759
+ ctx: 1e6,
20760
+ price: grokPrice(1.25, 2.5, 0.2)
20761
+ });
20762
+ xai.model("grok-4.20-0309-non-reasoning", {
20763
+ name: "Grok 4.20",
20764
+ capability: null,
20765
+ ctx: 1e6,
20766
+ price: grokPrice(1.25, 2.5, 0.2)
20767
+ });
20768
+ xai.model("grok-4.20-multi-agent-0309", {
20769
+ name: "Grok 4.20 Multi-Agent",
20770
+ capability: "reasoning",
20771
+ ctx: 1e6,
20772
+ price: grokPrice(1.25, 2.5, 0.2)
20773
+ });
20592
20774
  xai.model("grok-build-0.1", {
20593
20775
  name: "Grok Build 0.1",
20594
20776
  ctx: 256e3,
20595
20777
  capability: "code",
20596
- price: tokenPrice(1, 2, {
20597
- cacheRead: 0.2,
20598
- longContext: { thresholdInputTokens: 2e5, input: 2, output: 4 }
20599
- })
20778
+ price: grokPrice(1, 2, 0.2)
20600
20779
  });
20601
20780
  var deepseek = vendor("deepseek", {
20602
20781
  family: { id: "deepseek", name: "DeepSeek" },
@@ -20609,16 +20788,25 @@ var deepseek = vendor("deepseek", {
20609
20788
  source: "https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html"
20610
20789
  }
20611
20790
  });
20791
+ deepseek.model("deepseek-flash", {
20792
+ name: "DeepSeek V4.1 Flash",
20793
+ ctx: 1e6,
20794
+ maxOut: 384e3,
20795
+ capability: null,
20796
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 })
20797
+ });
20612
20798
  deepseek.model("deepseek-v4-flash", {
20613
20799
  name: "DeepSeek V4 Flash",
20614
20800
  ctx: 1e6,
20801
+ maxOut: 384e3,
20615
20802
  capability: null,
20616
- price: tokenPrice(0.44, 1.32, { cacheRead: 0.014 }),
20803
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 }),
20617
20804
  on: ["bedrock", "together", "fireworks", "openrouter", "ollama", "local"]
20618
20805
  });
20619
20806
  deepseek.model("deepseek-v4-pro", {
20620
20807
  name: "DeepSeek V4 Pro",
20621
20808
  ctx: 1e6,
20809
+ maxOut: 384e3,
20622
20810
  capability: "reasoning",
20623
20811
  price: tokenPrice(1.32, 3.96, { cacheRead: 0.044 }),
20624
20812
  on: ["bedrock", "together", "fireworks", "openrouter"]
@@ -20665,7 +20853,14 @@ cohere.model("command-r-plus-08-2024", {
20665
20853
  ctx: 128e3,
20666
20854
  maxOut: 4e3,
20667
20855
  price: tokenPrice(2.5, 10),
20668
- // The undated form is what deployments report; the live id carries the date.
20856
+ on: ["bedrock"]
20857
+ });
20858
+ cohere.model("command-r-plus-04-2024", {
20859
+ name: "Command R+ (04-2024)",
20860
+ seen: "discovered",
20861
+ ctx: 128e3,
20862
+ maxOut: 4e3,
20863
+ price: tokenPrice(3, 15),
20669
20864
  aliases: ["command-r-plus"],
20670
20865
  on: ["bedrock"]
20671
20866
  });
@@ -20733,6 +20928,65 @@ var mistral = vendor("mistral", {
20733
20928
  retention: "unknown",
20734
20929
  defaultHosting: "local"
20735
20930
  });
20931
+ var MISTRAL_API = { defaultHosting: "api" };
20932
+ mistral.model("mistral-large-4", {
20933
+ ...MISTRAL_API,
20934
+ name: "Mistral Large 4",
20935
+ ctx: 1e6,
20936
+ capability: null,
20937
+ // Public preview at a sale rate; the published original is 1.36 / 4.18 / 0.14.
20938
+ price: tokenPrice(0.68, 2.09, { cacheRead: 0.07 })
20939
+ });
20940
+ mistral.model("mistral-large-2512", {
20941
+ ...MISTRAL_API,
20942
+ name: "Mistral Large 3",
20943
+ ctx: 256e3,
20944
+ capability: null,
20945
+ price: tokenPrice(0.5, 1.5, { cacheRead: 0.05 })
20946
+ });
20947
+ mistral.model("mistral-medium-3-5", {
20948
+ ...MISTRAL_API,
20949
+ name: "Mistral Medium 3.5",
20950
+ ctx: 256e3,
20951
+ capability: null,
20952
+ price: tokenPrice(1.5, 7.5, { cacheRead: 0.15 })
20953
+ });
20954
+ mistral.model("mistral-small-2603", {
20955
+ ...MISTRAL_API,
20956
+ name: "Mistral Small 4",
20957
+ ctx: 256e3,
20958
+ capability: null,
20959
+ price: tokenPrice(0.15, 0.6, { cacheRead: 0.015 })
20960
+ });
20961
+ mistral.model("ministral-14b-2512", {
20962
+ ...MISTRAL_API,
20963
+ name: "Ministral 3 14B",
20964
+ ctx: 256e3,
20965
+ capability: null,
20966
+ price: tokenPrice(0.2, 0.2, { cacheRead: 0.02 })
20967
+ });
20968
+ mistral.model("ministral-8b-2512", {
20969
+ ...MISTRAL_API,
20970
+ name: "Ministral 3 8B",
20971
+ ctx: 256e3,
20972
+ capability: null,
20973
+ price: tokenPrice(0.15, 0.15, { cacheRead: 0.015 })
20974
+ });
20975
+ mistral.model("ministral-3b-2512", {
20976
+ ...MISTRAL_API,
20977
+ name: "Ministral 3 3B",
20978
+ ctx: 256e3,
20979
+ capability: null,
20980
+ price: tokenPrice(0.1, 0.1, { cacheRead: 0.01 })
20981
+ });
20982
+ mistral.model("codestral-2508", {
20983
+ ...MISTRAL_API,
20984
+ name: "Codestral",
20985
+ ctx: 128e3,
20986
+ capability: "code",
20987
+ openWeights: false,
20988
+ price: tokenPrice(0.3, 0.9, { cacheRead: 0.03 })
20989
+ });
20736
20990
  mistral.model("mixtral-8x7b", {
20737
20991
  name: "Mixtral 8x7B",
20738
20992
  seen: "discovered",
@@ -20896,11 +21150,14 @@ var COMPACT = new Intl.NumberFormat("en-US", {
20896
21150
  // ../../packages/schema/src/token/token-report.ts
20897
21151
  var num = (value) => value ?? 0;
20898
21152
  function costUsageOf(a, promptTokens) {
21153
+ const write1h = num(a.ephemeral_1h_input_tokens);
21154
+ const write5m = num(a.ephemeral_5m_input_tokens);
21155
+ const unsplit = Math.max(num(a.cache_creation_input_tokens) - write1h - write5m, 0);
20899
21156
  const usage = {
20900
21157
  inputTokens: num(a.input_tokens),
20901
21158
  outputTokens: num(a.output_tokens),
20902
- cacheWrite1hTokens: num(a.ephemeral_1h_input_tokens),
20903
- cacheWrite5mTokens: num(a.ephemeral_5m_input_tokens),
21159
+ cacheWrite1hTokens: write1h,
21160
+ cacheWrite5mTokens: write5m + unsplit,
20904
21161
  cacheReadTokens: num(a.cache_read_input_tokens),
20905
21162
  webSearchRequests: num(a.web_search_requests)
20906
21163
  };
@@ -21690,6 +21947,11 @@ var CaptureAttributes = external_exports.object({
21690
21947
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
21691
21948
  // repeated rather than referenced because a store reader opens this file.
21692
21949
  redact_degraded_to: ActionTaken.optional(),
21950
+ // Why a capture has no content and no findings: its field was refused
21951
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
21952
+ // whose value this is). Absent on every capture that was scanned, so a
21953
+ // reader can tell a refused row from an empty clean one.
21954
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
21693
21955
  // The scope key this capture was stamped with: the canonical repository
21694
21956
  // (`host/owner/repo`) of the path the capture names (a relative path is read
21695
21957
  // against its working directory), else of its own working directory, or a
@@ -23031,7 +23293,19 @@ var EventMetadata = external_exports.object({
23031
23293
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23032
23294
  // Closing either means moving the reason onto the finding row, which
23033
23295
  // already carries its own action.
23034
- redactDegradedTo: ActionTaken.optional()
23296
+ redactDegradedTo: ActionTaken.optional(),
23297
+ // Set when this capture's field was REFUSED rather than scanned: a hook
23298
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
23299
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
23300
+ // field instead of letting it through unscanned.
23301
+ //
23302
+ // - 'timeout': the bounded scan ran out of time.
23303
+ // - 'unavailable': no worker could run it.
23304
+ //
23305
+ // A refused row stores '' as its content and has no findings, which is
23306
+ // exactly what a clean, empty capture looks like — this marker is the only
23307
+ // thing that tells the two apart. Absent on every capture that was scanned.
23308
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23035
23309
  }).meta({ id: "EventMetadata" });
23036
23310
  var Event = external_exports.object({
23037
23311
  id: external_exports.guid(),
@@ -24848,6 +25122,7 @@ function toCaptureAttributes(event) {
24848
25122
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
24849
25123
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
24850
25124
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
25125
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
24851
25126
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
24852
25127
  // has ever populated either), but every legacy metadata key still rides
24853
25128
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -27836,7 +28111,8 @@ var TIMELINE_COLUMNS = `
27836
28111
  json_extract(attributes, '$.internal') AS internal,
27837
28112
  json_extract(attributes, '$.flagged') AS flagged`;
27838
28113
  var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
27839
- + coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
28114
+ + max(coalesce(cache_creation_input_tokens, 0),
28115
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0)))`;
27840
28116
  var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
27841
28117
  " + "
27842
28118
  );
@@ -36821,6 +37097,42 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
36821
37097
  }
36822
37098
  var CPU_CORROBORATION_SHARE = 0.2;
36823
37099
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
37100
+ function repeatTo(unit, length) {
37101
+ return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
37102
+ }
37103
+ function joinTo(length, open3, close, item) {
37104
+ const parts = [];
37105
+ let size = open3.length;
37106
+ for (let i = 0; size < length; i++) {
37107
+ const next = (i === 0 ? "" : ",") + item(i);
37108
+ parts.push(next);
37109
+ size += next.length;
37110
+ }
37111
+ return (open3 + parts.join("") + close).slice(0, length);
37112
+ }
37113
+ var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
37114
+ var GROWTH_CORPORA = [
37115
+ {
37116
+ name: "one-line JSON dictionary",
37117
+ build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
37118
+ },
37119
+ {
37120
+ name: "JSON array of quoted SQL keywords",
37121
+ build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
37122
+ },
37123
+ { name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
37124
+ {
37125
+ name: 'double-quoted keyword literal run ("where" )',
37126
+ build: (length) => repeatTo('"where" ', length)
37127
+ },
37128
+ { name: "double-quote run", build: (length) => repeatTo('"', length) },
37129
+ { name: "space run", build: (length) => repeatTo(" ", length) },
37130
+ { name: "newline run", build: (length) => repeatTo("\n", length) },
37131
+ ...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
37132
+ name: `unit run ${JSON.stringify(unit)}`,
37133
+ build: (length) => repeatTo(unit, length)
37134
+ }))
37135
+ ];
36824
37136
  function checkRuleTiming(rule, corroborate) {
36825
37137
  const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
36826
37138
  const work = corroboratedMs ?? 0;
@@ -37145,7 +37457,7 @@ var auth_jwt_no_verify_default = {
37145
37457
  severity: "critical",
37146
37458
  matcher: {
37147
37459
  type: "regex",
37148
- pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
37460
+ pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
37149
37461
  flags: "gi"
37150
37462
  },
37151
37463
  requiresNearby: {
@@ -37233,7 +37545,7 @@ var cmd_inject_shell_default = {
37233
37545
  severity: "critical",
37234
37546
  matcher: {
37235
37547
  type: "regex",
37236
- pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
37548
+ pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
37237
37549
  flags: "gi"
37238
37550
  },
37239
37551
  requiresNearby: {
@@ -37362,7 +37674,7 @@ var deser_yaml_unsafe_default = {
37362
37674
  severity: "high",
37363
37675
  matcher: {
37364
37676
  type: "regex",
37365
- pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
37677
+ pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
37366
37678
  flags: "gi"
37367
37679
  },
37368
37680
  examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
@@ -37579,7 +37891,7 @@ var sql_inject_concat_dot_default = {
37579
37891
  severity: "high",
37580
37892
  matcher: {
37581
37893
  type: "regex",
37582
- pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
37894
+ pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
37583
37895
  flags: "gi"
37584
37896
  },
37585
37897
  appliesTo: {
@@ -37597,7 +37909,7 @@ var sql_inject_concat_default = {
37597
37909
  severity: "high",
37598
37910
  matcher: {
37599
37911
  type: "regex",
37600
- 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*\\+`,
37912
+ 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*\\+`,
37601
37913
  flags: "gi"
37602
37914
  },
37603
37915
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -37612,7 +37924,7 @@ var sql_inject_format_default = {
37612
37924
  severity: "high",
37613
37925
  matcher: {
37614
37926
  type: "regex",
37615
- 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]|\\{[^}]+\\})",
37927
+ 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]+\\})",
37616
37928
  flags: "gi"
37617
37929
  },
37618
37930
  examples: [
@@ -37630,7 +37942,7 @@ var sql_inject_interp_default = {
37630
37942
  severity: "high",
37631
37943
  matcher: {
37632
37944
  type: "regex",
37633
- pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
37945
+ pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
37634
37946
  flags: "gi"
37635
37947
  },
37636
37948
  examples: [
@@ -38005,7 +38317,7 @@ var stack_trace_default = {
38005
38317
  severity: "low",
38006
38318
  matcher: {
38007
38319
  type: "regex",
38008
- pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38320
+ pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38009
38321
  flags: "g"
38010
38322
  },
38011
38323
  examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
@@ -39163,7 +39475,7 @@ var BUNDLED_PACKS = [
39163
39475
  {
39164
39476
  packId: "code-flaws",
39165
39477
  name: "Code Security Flaws",
39166
- version: "0.1.0",
39478
+ version: "0.1.2",
39167
39479
  rawRules: [
39168
39480
  sql_inject_concat_default,
39169
39481
  sql_inject_concat_dot_default,
@@ -39213,7 +39525,7 @@ var BUNDLED_PACKS = [
39213
39525
  {
39214
39526
  packId: "core-code-context",
39215
39527
  name: "Code Context",
39216
- version: "0.2.1",
39528
+ version: "0.2.2",
39217
39529
  rawRules: [
39218
39530
  internal_ip_default,
39219
39531
  localhost_ref_default,
@@ -39709,9 +40021,10 @@ function createIsolatedScanner(data, opts = {}) {
39709
40021
  if (job.timer !== void 0) return;
39710
40022
  job.startedAt = performance.now();
39711
40023
  job.progressAt = job.startedAt;
40024
+ const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
39712
40025
  job.timer = setTimeout(() => {
39713
40026
  onDeadline(job);
39714
- }, job.budgetMs);
40027
+ }, budget);
39715
40028
  }
39716
40029
  function runOne(spec, fail) {
39717
40030
  if (closed) {
@@ -39722,6 +40035,12 @@ function createIsolatedScanner(data, opts = {}) {
39722
40035
  fail({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
39723
40036
  return;
39724
40037
  }
40038
+ const now = performance.now();
40039
+ const deadlineAt = spec.deadlineAt;
40040
+ if (deadlineAt !== void 0 && deadlineAt <= now) {
40041
+ fail({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
40042
+ return;
40043
+ }
39725
40044
  const started = ensureWorker();
39726
40045
  if (!(started instanceof Worker)) {
39727
40046
  broken = started.error;
@@ -39729,11 +40048,11 @@ function createIsolatedScanner(data, opts = {}) {
39729
40048
  return;
39730
40049
  }
39731
40050
  const id = nextJobId++;
39732
- const now = performance.now();
39733
40051
  const job = {
39734
40052
  id,
39735
40053
  worker: started,
39736
40054
  budgetMs: spec.budgetMs,
40055
+ deadlineAt,
39737
40056
  startedAt: now,
39738
40057
  progressIndex: -1,
39739
40058
  progressAt: now,
@@ -39747,14 +40066,19 @@ function createIsolatedScanner(data, opts = {}) {
39747
40066
  if (readyWorker === started) {
39748
40067
  beginDeadline(job);
39749
40068
  } else {
40069
+ const startBudget = spec.startBudgetMs ?? startBudgetMs;
40070
+ const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
40071
+ const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
39750
40072
  job.startupTimer = setTimeout(() => {
39751
40073
  if (pending !== job) return;
39752
40074
  kill(job.worker);
39753
- failPending({
39754
- status: "unavailable",
39755
- reason: `the scan worker did not start within ${String(startBudgetMs)}ms`
39756
- });
39757
- }, startBudgetMs);
40075
+ failPending(
40076
+ callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
40077
+ status: "unavailable",
40078
+ reason: `the scan worker did not start within ${String(startBudget)}ms`
40079
+ }
40080
+ );
40081
+ }, startWaitMs);
39758
40082
  }
39759
40083
  try {
39760
40084
  started.postMessage(spec.build(id));
@@ -39783,7 +40107,9 @@ function createIsolatedScanner(data, opts = {}) {
39783
40107
  return enqueue((resolve3) => {
39784
40108
  runOne(
39785
40109
  {
39786
- budgetMs,
40110
+ budgetMs: scanOpts?.budgetMs ?? budgetMs,
40111
+ startBudgetMs: scanOpts?.startBudgetMs,
40112
+ deadlineAt: scanOpts?.deadlineAt,
39787
40113
  build: (id) => ({
39788
40114
  kind: "scan",
39789
40115
  id,
@@ -39977,6 +40303,9 @@ function createGuardedScanner(partition, gateway, opts) {
39977
40303
  let unverified = partition.unverified;
39978
40304
  let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
39979
40305
  let retired = false;
40306
+ let bounded;
40307
+ let boundedWarned = false;
40308
+ let closed = false;
39980
40309
  function inProcess(text, context) {
39981
40310
  return scan(text, verified, context);
39982
40311
  }
@@ -40038,11 +40367,48 @@ function createGuardedScanner(partition, gateway, opts) {
40038
40367
  await degrade();
40039
40368
  return inProcess(text, context);
40040
40369
  }
40370
+ async function scanBounded(text, context, bound) {
40371
+ const remainingMs = bound.remainingMs;
40372
+ let outcome;
40373
+ if (closed) {
40374
+ outcome = { status: "unavailable", reason: "the scan worker is closed" };
40375
+ } else if (remainingMs !== void 0 && !(remainingMs > 0)) {
40376
+ outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
40377
+ } else {
40378
+ bounded ??= createIsolatedScanner({ verified, unverified }, opts);
40379
+ const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
40380
+ try {
40381
+ outcome = await bounded.scan(text, context, {
40382
+ budgetMs: bound.budgetMs,
40383
+ startBudgetMs: bound.startBudgetMs,
40384
+ deadlineAt
40385
+ });
40386
+ } catch (error62) {
40387
+ outcome = {
40388
+ status: "unavailable",
40389
+ reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
40390
+ };
40391
+ }
40392
+ }
40393
+ if (outcome.status !== "ok" && !boundedWarned) {
40394
+ boundedWarned = true;
40395
+ process.stderr.write(
40396
+ outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
40397
+ ` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
40398
+ `
40399
+ );
40400
+ }
40401
+ return outcome;
40402
+ }
40041
40403
  return {
40042
40404
  scan: guardedScan,
40405
+ scanBounded,
40043
40406
  degraded: () => retired,
40044
40407
  async close() {
40045
- await retire();
40408
+ closed = true;
40409
+ const live = bounded;
40410
+ bounded = void 0;
40411
+ await Promise.all([retire(), live?.close()]);
40046
40412
  }
40047
40413
  };
40048
40414
  }
@@ -40170,6 +40536,16 @@ function conditionsMatch(conditions, ctx) {
40170
40536
  if (conditions.provider !== void 0) return false;
40171
40537
  return true;
40172
40538
  }
40539
+ function readRemainingMs(largeInput) {
40540
+ const read = largeInput.remainingMs;
40541
+ if (read === void 0) return void 0;
40542
+ try {
40543
+ const remaining = read();
40544
+ return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
40545
+ } catch {
40546
+ return 0;
40547
+ }
40548
+ }
40173
40549
  var bundlesPacked = false;
40174
40550
  function createPluginRuntime(gateway, settings, opts) {
40175
40551
  if (!bundlesPacked) {
@@ -40179,6 +40555,7 @@ function createPluginRuntime(gateway, settings, opts) {
40179
40555
  const policyMode = settings.policy;
40180
40556
  let redactFallback = settings.redactFallback;
40181
40557
  const dataDir2 = opts?.dataDir;
40558
+ const largeInput = opts?.largeInput;
40182
40559
  let rules = [];
40183
40560
  let evidenceOf = evidenceLookup(rules);
40184
40561
  let scanner;
@@ -40391,7 +40768,24 @@ function createPluginRuntime(gateway, settings, opts) {
40391
40768
  await ensureInitialized();
40392
40769
  if (!scanner) throw new Error("the runtime initialized without a scanner");
40393
40770
  const shielded = shieldPointers(text);
40394
- const matched = await scanner.scan(shielded.text, context);
40771
+ let matched;
40772
+ if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
40773
+ const outcome = await scanner.scanBounded(shielded.text, context, {
40774
+ budgetMs: largeInput.budgetMs,
40775
+ startBudgetMs: largeInput.startBudgetMs,
40776
+ remainingMs: readRemainingMs(largeInput)
40777
+ });
40778
+ if (outcome.status !== "ok") {
40779
+ return {
40780
+ decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
40781
+ excepted: /* @__PURE__ */ new Set(),
40782
+ exceptionIds: []
40783
+ };
40784
+ }
40785
+ matched = outcome.findings;
40786
+ } else {
40787
+ matched = await scanner.scan(shielded.text, context);
40788
+ }
40395
40789
  const findings = dropShieldedFindings(matched, shielded.spans);
40396
40790
  const fpCache = /* @__PURE__ */ new Map();
40397
40791
  const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
@@ -40432,20 +40826,24 @@ function createPluginRuntime(gateway, settings, opts) {
40432
40826
  }
40433
40827
  async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
40434
40828
  const filePath = input2.metadata?.filePath;
40435
- if (opts2.persist === "with-findings" && decision.findings.length === 0) return;
40829
+ if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
40830
+ return;
40831
+ }
40436
40832
  try {
40437
40833
  const contentHash = contentHashOf(input2.text);
40438
40834
  const maskedFindings = decision.findings.filter(
40439
40835
  (match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
40440
40836
  );
40441
- const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40837
+ const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40442
40838
  const inspectionMs = elapsedMs(timingStartedAt);
40443
40839
  const redactDegradedTo = decision.redactDegradedTo;
40444
- const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 ? {
40840
+ const scanIncomplete = decision.scanIncomplete;
40841
+ const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
40445
40842
  ...input2.metadata,
40446
40843
  ...exceptionIds.length > 0 ? { exceptionIds } : {},
40447
40844
  ...inspectionMs !== void 0 ? { inspectionMs } : {},
40448
- ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
40845
+ ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
40846
+ ...scanIncomplete !== void 0 ? { scanIncomplete } : {}
40449
40847
  } : input2.metadata;
40450
40848
  const event = buildIngestEvent({
40451
40849
  kind: input2.kind,
@@ -42121,6 +42519,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
42121
42519
  var TRACE_ID = EventMetadata.shape.traceId;
42122
42520
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
42123
42521
  var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
42522
+ var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
42124
42523
 
42125
42524
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
42126
42525
  var CAPTURE_BATCH_BYTES = 1024 * 1024;