@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.
@@ -19852,7 +19852,10 @@ function date4(params) {
19852
19852
  var LongContextTier = external_exports.object({
19853
19853
  thresholdInputTokens: external_exports.number().int().positive(),
19854
19854
  input: external_exports.number().nonnegative().nullable(),
19855
- output: external_exports.number().nonnegative().nullable()
19855
+ output: external_exports.number().nonnegative().nullable(),
19856
+ cacheRead: external_exports.number().nonnegative().nullable().optional(),
19857
+ cacheWrite5m: external_exports.number().nonnegative().nullable().optional(),
19858
+ cacheWrite1h: external_exports.number().nonnegative().nullable().optional()
19856
19859
  });
19857
19860
  var ModelPrice = external_exports.object({
19858
19861
  /** USD per 1M uncached input tokens, at or below any long-context threshold. */
@@ -19861,7 +19864,8 @@ var ModelPrice = external_exports.object({
19861
19864
  output: external_exports.number().nonnegative(),
19862
19865
  /**
19863
19866
  * Rate band above a size threshold, or `null` when the model is flat-rated.
19864
- * Anthropic is flat across its 1M window; OpenAI, Google and xAI are not.
19867
+ * OpenAI, Google, xAI and some Anthropic models (Haiku 5.5) band; most
19868
+ * Claude models are flat across their window.
19865
19869
  */
19866
19870
  longContext: LongContextTier.nullable(),
19867
19871
  /** USD per 1M tokens written to a 5-minute ephemeral cache, or null if unpriced. */
@@ -19874,18 +19878,35 @@ var ModelPrice = external_exports.object({
19874
19878
  webSearch: external_exports.number().nonnegative().nullable()
19875
19879
  });
19876
19880
  var WEB_SEARCH_PER_REQUEST = 0.01;
19877
- function anthropicPrice(input2, output2, cacheRead) {
19881
+ function anthropicPrice(input2, output2, cacheRead, longContext = null) {
19878
19882
  return Object.freeze({
19879
19883
  input: input2,
19880
19884
  output: output2,
19881
- longContext: null,
19882
- // flat across the full window on every current Claude
19885
+ longContext: longContext === null ? null : Object.freeze(longContext),
19883
19886
  cacheWrite5m: input2 * 1.25,
19884
19887
  cacheWrite1h: input2 * 2,
19885
19888
  cacheRead,
19886
19889
  webSearch: WEB_SEARCH_PER_REQUEST
19887
19890
  });
19888
19891
  }
19892
+ function anthropicBand(thresholdInputTokens, input2, output2, cacheRead) {
19893
+ return {
19894
+ thresholdInputTokens,
19895
+ input: input2,
19896
+ output: output2,
19897
+ cacheRead,
19898
+ cacheWrite5m: input2 * 1.25,
19899
+ cacheWrite1h: input2 * 2
19900
+ };
19901
+ }
19902
+ function scaledBand(thresholdInputTokens, base, scale) {
19903
+ return {
19904
+ thresholdInputTokens,
19905
+ input: base.input * scale.input,
19906
+ output: base.output * scale.output,
19907
+ ...base.cacheRead === void 0 ? {} : { cacheRead: base.cacheRead * scale.cacheRead }
19908
+ };
19909
+ }
19889
19910
  function tokenPrice(input2, output2, options = {}) {
19890
19911
  return Object.freeze({
19891
19912
  input: input2,
@@ -19918,17 +19939,19 @@ function serviceTierMultiplier(tier) {
19918
19939
  function promptTokensOf(usage) {
19919
19940
  return usage.promptTokens ?? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWrite1hTokens ?? 0) + (usage.cacheWrite5mTokens ?? 0);
19920
19941
  }
19942
+ function bandRate(column, base) {
19943
+ return column === void 0 ? base : column;
19944
+ }
19921
19945
  function costOf(price, usage) {
19946
+ const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
19922
19947
  const metered = [
19923
- [usage.cacheWrite1hTokens ?? 0, price.cacheWrite1h],
19924
- [usage.cacheWrite5mTokens ?? 0, price.cacheWrite5m],
19925
- [usage.cacheReadTokens ?? 0, price.cacheRead]
19948
+ [usage.inputTokens ?? 0, bandRate(band?.input, price.input)],
19949
+ [usage.outputTokens ?? 0, bandRate(band?.output, price.output)],
19950
+ [usage.cacheWrite1hTokens ?? 0, bandRate(band?.cacheWrite1h, price.cacheWrite1h)],
19951
+ [usage.cacheWrite5mTokens ?? 0, bandRate(band?.cacheWrite5m, price.cacheWrite5m)],
19952
+ [usage.cacheReadTokens ?? 0, bandRate(band?.cacheRead, price.cacheRead)]
19926
19953
  ];
19927
- const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
19928
- if (band !== null && (band.input === null || band.output === null)) return null;
19929
- const inputRate = band?.input ?? price.input;
19930
- const outputRate = band?.output ?? price.output;
19931
- let tokenCost = (usage.inputTokens ?? 0) * inputRate + (usage.outputTokens ?? 0) * outputRate;
19954
+ let tokenCost = 0;
19932
19955
  for (const [tokens, rate] of metered) {
19933
19956
  if (tokens === 0) continue;
19934
19957
  if (rate === null) return null;
@@ -20218,10 +20241,20 @@ anthropic.model("claude-fable-5-1", {
20218
20241
  });
20219
20242
  anthropic.model("claude-fable-5", {
20220
20243
  name: "Claude Fable 5",
20244
+ ctx: 1e6,
20245
+ maxOut: 128e3,
20221
20246
  capability: "reasoning",
20222
20247
  price: anthropicPrice(10, 50, 1),
20223
20248
  on: [...CLAUDE_RESELLERS]
20224
20249
  });
20250
+ anthropic.model("claude-opus-5-5", {
20251
+ name: "Claude Opus 5.5",
20252
+ ctx: 1e6,
20253
+ maxOut: 128e3,
20254
+ capability: "reasoning",
20255
+ price: anthropicPrice(4, 20, 0.2),
20256
+ on: [...CLAUDE_RESELLERS]
20257
+ });
20225
20258
  anthropic.model("claude-opus-5", {
20226
20259
  name: "Claude Opus 5",
20227
20260
  ctx: 1e6,
@@ -20232,24 +20265,32 @@ anthropic.model("claude-opus-5", {
20232
20265
  });
20233
20266
  anthropic.model("claude-opus-4-8", {
20234
20267
  name: "Claude Opus 4.8",
20268
+ ctx: 1e6,
20269
+ maxOut: 128e3,
20235
20270
  capability: "reasoning",
20236
20271
  price: anthropicPrice(5, 25, 0.5),
20237
20272
  on: [...CLAUDE_RESELLERS]
20238
20273
  });
20239
20274
  anthropic.model("claude-opus-4-7", {
20240
20275
  name: "Claude Opus 4.7",
20276
+ ctx: 1e6,
20277
+ maxOut: 128e3,
20241
20278
  capability: "reasoning",
20242
20279
  price: anthropicPrice(5, 25, 0.5),
20243
20280
  on: [...CLAUDE_RESELLERS]
20244
20281
  });
20245
20282
  anthropic.model("claude-opus-4-6", {
20246
20283
  name: "Claude Opus 4.6",
20284
+ ctx: 1e6,
20285
+ maxOut: 128e3,
20247
20286
  capability: "reasoning",
20248
20287
  price: anthropicPrice(5, 25, 0.5),
20249
20288
  on: [...CLAUDE_RESELLERS]
20250
20289
  });
20251
20290
  anthropic.model("claude-opus-4-5", {
20252
20291
  name: "Claude Opus 4.5",
20292
+ ctx: 2e5,
20293
+ maxOut: 64e3,
20253
20294
  capability: "reasoning",
20254
20295
  price: anthropicPrice(5, 25, 0.5),
20255
20296
  on: [...CLAUDE_RESELLERS]
@@ -20260,6 +20301,14 @@ anthropic.model("claude-opus-4-1", {
20260
20301
  price: anthropicPrice(15, 75, 1.5),
20261
20302
  on: [...CLAUDE_RESELLERS]
20262
20303
  });
20304
+ anthropic.model("claude-sonnet-5-5", {
20305
+ name: "Claude Sonnet 5.5",
20306
+ ctx: 1e6,
20307
+ maxOut: 128e3,
20308
+ capability: "reasoning",
20309
+ price: anthropicPrice(2, 10, 0.1),
20310
+ on: [...CLAUDE_RESELLERS]
20311
+ });
20263
20312
  anthropic.model("claude-sonnet-5", {
20264
20313
  name: "Claude Sonnet 5",
20265
20314
  ctx: 1e6,
@@ -20270,16 +20319,30 @@ anthropic.model("claude-sonnet-5", {
20270
20319
  });
20271
20320
  anthropic.model("claude-sonnet-4-6", {
20272
20321
  name: "Claude Sonnet 4.6",
20322
+ ctx: 1e6,
20323
+ maxOut: 128e3,
20273
20324
  capability: "reasoning",
20274
20325
  price: anthropicPrice(3, 15, 0.3),
20275
20326
  on: [...CLAUDE_RESELLERS]
20276
20327
  });
20277
20328
  anthropic.model("claude-sonnet-4-5", {
20278
20329
  name: "Claude Sonnet 4.5",
20330
+ ctx: 2e5,
20331
+ maxOut: 64e3,
20279
20332
  capability: "reasoning",
20280
20333
  price: anthropicPrice(3, 15, 0.3),
20281
20334
  on: [...CLAUDE_RESELLERS]
20282
20335
  });
20336
+ anthropic.model("claude-haiku-5-5", {
20337
+ name: "Claude Haiku 5.5",
20338
+ ctx: 1e6,
20339
+ maxOut: 128e3,
20340
+ capability: null,
20341
+ // A prompt over 100,000 tokens, cache reads and writes included, bills the
20342
+ // whole request at the higher band.
20343
+ price: anthropicPrice(0.1, 0.5, 0.01, anthropicBand(1e5, 0.5, 2.5, 0.05)),
20344
+ on: [...CLAUDE_RESELLERS]
20345
+ });
20283
20346
  anthropic.model("claude-haiku-4-5", {
20284
20347
  name: "Claude Haiku 4.5",
20285
20348
  ctx: 2e5,
@@ -20302,7 +20365,13 @@ var OPENAI_TRAINING = {
20302
20365
  consumerControl: "opt-out",
20303
20366
  source: "https://developers.openai.com/api/docs/guides/your-data"
20304
20367
  };
20305
- var LONG_CONTEXT_272K = { thresholdInputTokens: 272e3, input: null, output: null };
20368
+ function gptPrice(input2, output2, cacheRead) {
20369
+ const base = { input: input2, output: output2, ...cacheRead === void 0 ? {} : { cacheRead } };
20370
+ return tokenPrice(input2, output2, {
20371
+ ...base,
20372
+ longContext: scaledBand(272e3, base, { input: 2, output: 1.5, cacheRead: 2 })
20373
+ });
20374
+ }
20306
20375
  var openai = vendor("openai", {
20307
20376
  family: { id: "gpt", name: "GPT" },
20308
20377
  region: "us",
@@ -20310,12 +20379,45 @@ var openai = vendor("openai", {
20310
20379
  training: OPENAI_TRAINING
20311
20380
  });
20312
20381
  var OPENAI_RESELLERS = ["azure", "foundry"];
20382
+ openai.model("gpt-6-astra", {
20383
+ name: "GPT-6 Astra",
20384
+ ctx: 105e4,
20385
+ maxOut: 128e3,
20386
+ capability: "reasoning",
20387
+ price: gptPrice(10, 50, 1),
20388
+ on: [...OPENAI_RESELLERS]
20389
+ });
20390
+ openai.model("gpt-6.1-sol", {
20391
+ name: "GPT-6.1 Sol",
20392
+ ctx: 105e4,
20393
+ maxOut: 128e3,
20394
+ capability: "reasoning",
20395
+ price: gptPrice(2, 10, 0.1),
20396
+ on: [...OPENAI_RESELLERS]
20397
+ });
20398
+ openai.model("gpt-6-sol", {
20399
+ name: "GPT-6 Sol",
20400
+ ctx: 105e4,
20401
+ maxOut: 128e3,
20402
+ capability: "reasoning",
20403
+ price: gptPrice(2, 10, 0.2),
20404
+ on: [...OPENAI_RESELLERS]
20405
+ });
20406
+ openai.model("gpt-6-luna", {
20407
+ name: "GPT-6 Luna",
20408
+ ctx: 105e4,
20409
+ maxOut: 128e3,
20410
+ capability: null,
20411
+ price: gptPrice(0.1, 0.5, 0.01),
20412
+ on: [...OPENAI_RESELLERS]
20413
+ });
20313
20414
  openai.model("gpt-5.6-sol", {
20314
20415
  name: "GPT-5.6 Sol",
20416
+ // Promotional rate, published as available at least through 2026-11-21.
20315
20417
  ctx: 105e4,
20316
20418
  maxOut: 128e3,
20317
20419
  capability: "reasoning",
20318
- price: tokenPrice(4, 20, { cacheRead: 0.4, longContext: LONG_CONTEXT_272K }),
20420
+ price: gptPrice(4, 20, 0.4),
20319
20421
  on: [...OPENAI_RESELLERS]
20320
20422
  });
20321
20423
  openai.model("gpt-5.6-terra", {
@@ -20323,7 +20425,7 @@ openai.model("gpt-5.6-terra", {
20323
20425
  ctx: 105e4,
20324
20426
  maxOut: 128e3,
20325
20427
  capability: "reasoning",
20326
- price: tokenPrice(2, 12, { cacheRead: 0.2, longContext: LONG_CONTEXT_272K }),
20428
+ price: gptPrice(2, 12, 0.2),
20327
20429
  on: [...OPENAI_RESELLERS]
20328
20430
  });
20329
20431
  openai.model("gpt-5.6-luna", {
@@ -20331,7 +20433,7 @@ openai.model("gpt-5.6-luna", {
20331
20433
  ctx: 105e4,
20332
20434
  maxOut: 128e3,
20333
20435
  capability: null,
20334
- price: tokenPrice(0.2, 1.2, { cacheRead: 0.02, longContext: LONG_CONTEXT_272K }),
20436
+ price: gptPrice(0.2, 1.2, 0.02),
20335
20437
  on: [...OPENAI_RESELLERS]
20336
20438
  });
20337
20439
  openai.model("gpt-5.5", {
@@ -20339,7 +20441,15 @@ openai.model("gpt-5.5", {
20339
20441
  ctx: 105e4,
20340
20442
  maxOut: 128e3,
20341
20443
  capability: "reasoning",
20342
- price: tokenPrice(5, 30, { cacheRead: 0.5, longContext: LONG_CONTEXT_272K }),
20444
+ price: gptPrice(5, 30, 0.5),
20445
+ on: [...OPENAI_RESELLERS]
20446
+ });
20447
+ openai.model("gpt-5.5-pro", {
20448
+ name: "GPT-5.5 Pro",
20449
+ ctx: 105e4,
20450
+ maxOut: 128e3,
20451
+ capability: "reasoning",
20452
+ price: gptPrice(30, 180),
20343
20453
  on: [...OPENAI_RESELLERS]
20344
20454
  });
20345
20455
  openai.model("gpt-5.4", {
@@ -20347,7 +20457,7 @@ openai.model("gpt-5.4", {
20347
20457
  ctx: 105e4,
20348
20458
  maxOut: 128e3,
20349
20459
  capability: "reasoning",
20350
- price: tokenPrice(2.5, 15, { cacheRead: 0.25, longContext: LONG_CONTEXT_272K }),
20460
+ price: gptPrice(2.5, 15, 0.25),
20351
20461
  on: [...OPENAI_RESELLERS]
20352
20462
  });
20353
20463
  openai.model("gpt-5.4-mini", {
@@ -20393,6 +20503,7 @@ openai.model("gpt-5", {
20393
20503
  openai.model("gpt-5-mini", {
20394
20504
  name: "GPT-5 mini",
20395
20505
  ctx: 4e5,
20506
+ maxOut: 128e3,
20396
20507
  capability: null,
20397
20508
  price: tokenPrice(0.25, 2, { cacheRead: 0.025 }),
20398
20509
  on: [...OPENAI_RESELLERS]
@@ -20407,11 +20518,15 @@ openai.model("gpt-5-nano", {
20407
20518
  });
20408
20519
  openai.model("gpt-4.1", {
20409
20520
  name: "GPT-4.1",
20521
+ ctx: 1047576,
20522
+ maxOut: 32768,
20410
20523
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
20411
20524
  on: [...OPENAI_RESELLERS]
20412
20525
  });
20413
20526
  openai.model("gpt-4o", {
20414
20527
  name: "GPT-4o",
20528
+ ctx: 128e3,
20529
+ maxOut: 16384,
20415
20530
  price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
20416
20531
  on: [...OPENAI_RESELLERS]
20417
20532
  });
@@ -20435,6 +20550,8 @@ openai.model("gpt-4-turbo", {
20435
20550
  });
20436
20551
  openai.model("o3", {
20437
20552
  name: "o3",
20553
+ ctx: 2e5,
20554
+ maxOut: 1e5,
20438
20555
  capability: "reasoning",
20439
20556
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
20440
20557
  on: [...OPENAI_RESELLERS]
@@ -20487,57 +20604,100 @@ var google = vendor("google", {
20487
20604
  retention: "configurable",
20488
20605
  training: GOOGLE_TRAINING
20489
20606
  });
20607
+ google.model("gemini-3.8-flash", {
20608
+ name: "Gemini 3.8 Flash",
20609
+ ctx: 1048576,
20610
+ maxOut: 65536,
20611
+ capability: null,
20612
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
20613
+ on: ["vertex"]
20614
+ });
20490
20615
  google.model("gemini-3.7-flash", {
20491
20616
  name: "Gemini 3.7 Flash",
20492
20617
  capability: null,
20493
- // Promotional rate; the published post-promotion rate is 1.50 / 7.50.
20494
20618
  price: tokenPrice(0.75, 3.75),
20495
20619
  on: ["vertex"]
20496
20620
  });
20497
20621
  google.model("gemini-3.6-flash", {
20498
20622
  name: "Gemini 3.6 Flash",
20623
+ ctx: 1048576,
20624
+ maxOut: 65536,
20499
20625
  capability: null,
20500
- price: tokenPrice(0.75, 3.75),
20626
+ price: tokenPrice(0.75, 3.75, { cacheRead: 0.075 }),
20501
20627
  on: ["vertex"]
20502
20628
  });
20503
20629
  google.model("gemini-3.5-flash", {
20504
20630
  name: "Gemini 3.5 Flash",
20505
20631
  capability: null,
20506
- price: tokenPrice(1.5, 9),
20507
20632
  on: ["vertex"]
20508
20633
  });
20509
20634
  google.model("gemini-3.5-flash-lite", {
20510
20635
  name: "Gemini 3.5 Flash Lite",
20636
+ ctx: 1048576,
20637
+ maxOut: 65536,
20638
+ capability: null,
20639
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
20640
+ on: ["vertex"]
20641
+ });
20642
+ google.model("gemini-3.1-flash-lite", {
20643
+ name: "Gemini 3.1 Flash Lite",
20644
+ ctx: 1048576,
20645
+ maxOut: 65536,
20646
+ capability: null,
20647
+ price: tokenPrice(0.25, 1.5, { cacheRead: 0.025 }),
20648
+ on: ["vertex"]
20649
+ });
20650
+ google.model("gemini-3-flash-preview", {
20651
+ name: "Gemini 3 Flash Preview",
20652
+ ctx: 1048576,
20653
+ maxOut: 65536,
20511
20654
  capability: null,
20512
- price: tokenPrice(0.3, 2.5),
20655
+ price: tokenPrice(0.5, 3, { cacheRead: 0.05 }),
20513
20656
  on: ["vertex"]
20514
20657
  });
20515
20658
  google.model("gemini-3.1-pro-preview", {
20516
20659
  name: "Gemini 3.1 Pro Preview",
20660
+ ctx: 1048576,
20661
+ maxOut: 65536,
20517
20662
  capability: "reasoning",
20518
20663
  price: tokenPrice(2, 12, {
20519
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 18 }
20664
+ cacheRead: 0.2,
20665
+ longContext: { thresholdInputTokens: 2e5, input: 4, output: 18, cacheRead: 0.4 }
20520
20666
  }),
20667
+ aliases: ["gemini-3.1-pro-preview-customtools"],
20521
20668
  on: ["vertex"]
20522
20669
  });
20523
20670
  google.model("gemini-2.5-pro", {
20524
20671
  name: "Gemini 2.5 Pro",
20672
+ ctx: 1048576,
20673
+ maxOut: 65536,
20525
20674
  capability: "reasoning",
20526
20675
  price: tokenPrice(1.25, 10, {
20527
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15 }
20676
+ cacheRead: 0.125,
20677
+ longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 15, cacheRead: 0.25 }
20528
20678
  }),
20529
20679
  on: ["vertex"]
20530
20680
  });
20531
20681
  google.model("gemini-2.5-flash", {
20532
20682
  name: "Gemini 2.5 Flash",
20683
+ ctx: 1048576,
20684
+ maxOut: 65536,
20533
20685
  capability: null,
20534
- price: tokenPrice(0.3, 2.5),
20686
+ price: tokenPrice(0.3, 2.5, { cacheRead: 0.03 }),
20535
20687
  on: ["vertex"]
20536
20688
  });
20537
20689
  google.model("gemini-2.5-flash-lite", {
20538
20690
  name: "Gemini 2.5 Flash Lite",
20691
+ ctx: 1048576,
20692
+ maxOut: 65536,
20539
20693
  capability: null,
20540
- price: tokenPrice(0.1, 0.4),
20694
+ price: tokenPrice(0.1, 0.4, { cacheRead: 0.01 }),
20695
+ on: ["vertex"]
20696
+ });
20697
+ google.model("gemini-embedding-2", {
20698
+ name: "Gemini Embedding 2",
20699
+ capability: "embedding",
20700
+ price: tokenPrice(0.2, 0),
20541
20701
  on: ["vertex"]
20542
20702
  });
20543
20703
  google.model("gemini-1-5-pro", { name: "Gemini 1.5 Pro", on: ["vertex"] });
@@ -20553,43 +20713,62 @@ var xai = vendor("xai", {
20553
20713
  source: "https://docs.x.ai/developers/faq/security"
20554
20714
  }
20555
20715
  });
20716
+ function grokPrice(input2, output2, cacheRead) {
20717
+ const base = { input: input2, output: output2, cacheRead };
20718
+ return tokenPrice(input2, output2, {
20719
+ cacheRead,
20720
+ longContext: scaledBand(2e5, base, { input: 2, output: 2, cacheRead: 2 })
20721
+ });
20722
+ }
20723
+ xai.model("grok-4.7", {
20724
+ name: "Grok 4.7",
20725
+ ctx: 5e5,
20726
+ capability: "reasoning",
20727
+ price: grokPrice(2, 6, 0.5)
20728
+ });
20556
20729
  xai.model("grok-4.6", {
20557
20730
  name: "Grok 4.6",
20558
20731
  ctx: 5e5,
20559
20732
  capability: "reasoning",
20560
- price: tokenPrice(2, 6, {
20561
- cacheRead: 0.5,
20562
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
20563
- }),
20733
+ price: grokPrice(2, 6, 0.5),
20564
20734
  on: ["bedrock"]
20565
20735
  });
20566
20736
  xai.model("grok-4.5", {
20567
20737
  name: "Grok 4.5",
20568
20738
  ctx: 5e5,
20569
20739
  capability: "reasoning",
20570
- price: tokenPrice(2, 6, {
20571
- cacheRead: 0.3,
20572
- longContext: { thresholdInputTokens: 2e5, input: 4, output: 12 }
20573
- })
20740
+ price: grokPrice(2, 6, 0.3)
20574
20741
  });
20575
20742
  xai.model("grok-4.3", {
20576
20743
  name: "Grok 4.3",
20577
20744
  ctx: 1e6,
20578
20745
  capability: "reasoning",
20579
- price: tokenPrice(1.25, 2.5, {
20580
- cacheRead: 0.2,
20581
- longContext: { thresholdInputTokens: 2e5, input: 2.5, output: 5 }
20582
- }),
20746
+ price: grokPrice(1.25, 2.5, 0.2),
20583
20747
  on: ["bedrock"]
20584
20748
  });
20749
+ xai.model("grok-4.20-0309-reasoning", {
20750
+ name: "Grok 4.20 Reasoning",
20751
+ capability: "reasoning",
20752
+ ctx: 1e6,
20753
+ price: grokPrice(1.25, 2.5, 0.2)
20754
+ });
20755
+ xai.model("grok-4.20-0309-non-reasoning", {
20756
+ name: "Grok 4.20",
20757
+ capability: null,
20758
+ ctx: 1e6,
20759
+ price: grokPrice(1.25, 2.5, 0.2)
20760
+ });
20761
+ xai.model("grok-4.20-multi-agent-0309", {
20762
+ name: "Grok 4.20 Multi-Agent",
20763
+ capability: "reasoning",
20764
+ ctx: 1e6,
20765
+ price: grokPrice(1.25, 2.5, 0.2)
20766
+ });
20585
20767
  xai.model("grok-build-0.1", {
20586
20768
  name: "Grok Build 0.1",
20587
20769
  ctx: 256e3,
20588
20770
  capability: "code",
20589
- price: tokenPrice(1, 2, {
20590
- cacheRead: 0.2,
20591
- longContext: { thresholdInputTokens: 2e5, input: 2, output: 4 }
20592
- })
20771
+ price: grokPrice(1, 2, 0.2)
20593
20772
  });
20594
20773
  var deepseek = vendor("deepseek", {
20595
20774
  family: { id: "deepseek", name: "DeepSeek" },
@@ -20602,16 +20781,25 @@ var deepseek = vendor("deepseek", {
20602
20781
  source: "https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html"
20603
20782
  }
20604
20783
  });
20784
+ deepseek.model("deepseek-flash", {
20785
+ name: "DeepSeek V4.1 Flash",
20786
+ ctx: 1e6,
20787
+ maxOut: 384e3,
20788
+ capability: null,
20789
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 })
20790
+ });
20605
20791
  deepseek.model("deepseek-v4-flash", {
20606
20792
  name: "DeepSeek V4 Flash",
20607
20793
  ctx: 1e6,
20794
+ maxOut: 384e3,
20608
20795
  capability: null,
20609
- price: tokenPrice(0.44, 1.32, { cacheRead: 0.014 }),
20796
+ price: tokenPrice(0.3, 1.2, { cacheRead: 6e-3 }),
20610
20797
  on: ["bedrock", "together", "fireworks", "openrouter", "ollama", "local"]
20611
20798
  });
20612
20799
  deepseek.model("deepseek-v4-pro", {
20613
20800
  name: "DeepSeek V4 Pro",
20614
20801
  ctx: 1e6,
20802
+ maxOut: 384e3,
20615
20803
  capability: "reasoning",
20616
20804
  price: tokenPrice(1.32, 3.96, { cacheRead: 0.044 }),
20617
20805
  on: ["bedrock", "together", "fireworks", "openrouter"]
@@ -20658,7 +20846,14 @@ cohere.model("command-r-plus-08-2024", {
20658
20846
  ctx: 128e3,
20659
20847
  maxOut: 4e3,
20660
20848
  price: tokenPrice(2.5, 10),
20661
- // The undated form is what deployments report; the live id carries the date.
20849
+ on: ["bedrock"]
20850
+ });
20851
+ cohere.model("command-r-plus-04-2024", {
20852
+ name: "Command R+ (04-2024)",
20853
+ seen: "discovered",
20854
+ ctx: 128e3,
20855
+ maxOut: 4e3,
20856
+ price: tokenPrice(3, 15),
20662
20857
  aliases: ["command-r-plus"],
20663
20858
  on: ["bedrock"]
20664
20859
  });
@@ -20726,6 +20921,65 @@ var mistral = vendor("mistral", {
20726
20921
  retention: "unknown",
20727
20922
  defaultHosting: "local"
20728
20923
  });
20924
+ var MISTRAL_API = { defaultHosting: "api" };
20925
+ mistral.model("mistral-large-4", {
20926
+ ...MISTRAL_API,
20927
+ name: "Mistral Large 4",
20928
+ ctx: 1e6,
20929
+ capability: null,
20930
+ // Public preview at a sale rate; the published original is 1.36 / 4.18 / 0.14.
20931
+ price: tokenPrice(0.68, 2.09, { cacheRead: 0.07 })
20932
+ });
20933
+ mistral.model("mistral-large-2512", {
20934
+ ...MISTRAL_API,
20935
+ name: "Mistral Large 3",
20936
+ ctx: 256e3,
20937
+ capability: null,
20938
+ price: tokenPrice(0.5, 1.5, { cacheRead: 0.05 })
20939
+ });
20940
+ mistral.model("mistral-medium-3-5", {
20941
+ ...MISTRAL_API,
20942
+ name: "Mistral Medium 3.5",
20943
+ ctx: 256e3,
20944
+ capability: null,
20945
+ price: tokenPrice(1.5, 7.5, { cacheRead: 0.15 })
20946
+ });
20947
+ mistral.model("mistral-small-2603", {
20948
+ ...MISTRAL_API,
20949
+ name: "Mistral Small 4",
20950
+ ctx: 256e3,
20951
+ capability: null,
20952
+ price: tokenPrice(0.15, 0.6, { cacheRead: 0.015 })
20953
+ });
20954
+ mistral.model("ministral-14b-2512", {
20955
+ ...MISTRAL_API,
20956
+ name: "Ministral 3 14B",
20957
+ ctx: 256e3,
20958
+ capability: null,
20959
+ price: tokenPrice(0.2, 0.2, { cacheRead: 0.02 })
20960
+ });
20961
+ mistral.model("ministral-8b-2512", {
20962
+ ...MISTRAL_API,
20963
+ name: "Ministral 3 8B",
20964
+ ctx: 256e3,
20965
+ capability: null,
20966
+ price: tokenPrice(0.15, 0.15, { cacheRead: 0.015 })
20967
+ });
20968
+ mistral.model("ministral-3b-2512", {
20969
+ ...MISTRAL_API,
20970
+ name: "Ministral 3 3B",
20971
+ ctx: 256e3,
20972
+ capability: null,
20973
+ price: tokenPrice(0.1, 0.1, { cacheRead: 0.01 })
20974
+ });
20975
+ mistral.model("codestral-2508", {
20976
+ ...MISTRAL_API,
20977
+ name: "Codestral",
20978
+ ctx: 128e3,
20979
+ capability: "code",
20980
+ openWeights: false,
20981
+ price: tokenPrice(0.3, 0.9, { cacheRead: 0.03 })
20982
+ });
20729
20983
  mistral.model("mixtral-8x7b", {
20730
20984
  name: "Mixtral 8x7B",
20731
20985
  seen: "discovered",
@@ -20889,11 +21143,14 @@ var COMPACT = new Intl.NumberFormat("en-US", {
20889
21143
  // ../../packages/schema/src/token/token-report.ts
20890
21144
  var num = (value) => value ?? 0;
20891
21145
  function costUsageOf(a, promptTokens) {
21146
+ const write1h = num(a.ephemeral_1h_input_tokens);
21147
+ const write5m = num(a.ephemeral_5m_input_tokens);
21148
+ const unsplit = Math.max(num(a.cache_creation_input_tokens) - write1h - write5m, 0);
20892
21149
  const usage = {
20893
21150
  inputTokens: num(a.input_tokens),
20894
21151
  outputTokens: num(a.output_tokens),
20895
- cacheWrite1hTokens: num(a.ephemeral_1h_input_tokens),
20896
- cacheWrite5mTokens: num(a.ephemeral_5m_input_tokens),
21152
+ cacheWrite1hTokens: write1h,
21153
+ cacheWrite5mTokens: write5m + unsplit,
20897
21154
  cacheReadTokens: num(a.cache_read_input_tokens),
20898
21155
  webSearchRequests: num(a.web_search_requests)
20899
21156
  };
@@ -21680,6 +21937,11 @@ var CaptureAttributes = external_exports.object({
21680
21937
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
21681
21938
  // repeated rather than referenced because a store reader opens this file.
21682
21939
  redact_degraded_to: ActionTaken.optional(),
21940
+ // Why a capture has no content and no findings: its field was refused
21941
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
21942
+ // whose value this is). Absent on every capture that was scanned, so a
21943
+ // reader can tell a refused row from an empty clean one.
21944
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
21683
21945
  // The scope key this capture was stamped with: the canonical repository
21684
21946
  // (`host/owner/repo`) of the path the capture names (a relative path is read
21685
21947
  // against its working directory), else of its own working directory, or a
@@ -23021,7 +23283,19 @@ var EventMetadata = external_exports.object({
23021
23283
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23022
23284
  // Closing either means moving the reason onto the finding row, which
23023
23285
  // already carries its own action.
23024
- redactDegradedTo: ActionTaken.optional()
23286
+ redactDegradedTo: ActionTaken.optional(),
23287
+ // Set when this capture's field was REFUSED rather than scanned: a hook
23288
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
23289
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
23290
+ // field instead of letting it through unscanned.
23291
+ //
23292
+ // - 'timeout': the bounded scan ran out of time.
23293
+ // - 'unavailable': no worker could run it.
23294
+ //
23295
+ // A refused row stores '' as its content and has no findings, which is
23296
+ // exactly what a clean, empty capture looks like — this marker is the only
23297
+ // thing that tells the two apart. Absent on every capture that was scanned.
23298
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23025
23299
  }).meta({ id: "EventMetadata" });
23026
23300
  var Event = external_exports.object({
23027
23301
  id: external_exports.guid(),
@@ -24838,6 +25112,7 @@ function toCaptureAttributes(event) {
24838
25112
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
24839
25113
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
24840
25114
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
25115
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
24841
25116
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
24842
25117
  // has ever populated either), but every legacy metadata key still rides
24843
25118
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -27826,7 +28101,8 @@ var TIMELINE_COLUMNS = `
27826
28101
  json_extract(attributes, '$.internal') AS internal,
27827
28102
  json_extract(attributes, '$.flagged') AS flagged`;
27828
28103
  var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
27829
- + coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
28104
+ + max(coalesce(cache_creation_input_tokens, 0),
28105
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0)))`;
27830
28106
  var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
27831
28107
  " + "
27832
28108
  );
@@ -36865,6 +37141,42 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
36865
37141
  }
36866
37142
  var CPU_CORROBORATION_SHARE = 0.2;
36867
37143
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
37144
+ function repeatTo(unit, length) {
37145
+ return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
37146
+ }
37147
+ function joinTo(length, open3, close, item) {
37148
+ const parts = [];
37149
+ let size = open3.length;
37150
+ for (let i = 0; size < length; i++) {
37151
+ const next = (i === 0 ? "" : ",") + item(i);
37152
+ parts.push(next);
37153
+ size += next.length;
37154
+ }
37155
+ return (open3 + parts.join("") + close).slice(0, length);
37156
+ }
37157
+ var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
37158
+ var GROWTH_CORPORA = [
37159
+ {
37160
+ name: "one-line JSON dictionary",
37161
+ build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
37162
+ },
37163
+ {
37164
+ name: "JSON array of quoted SQL keywords",
37165
+ build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
37166
+ },
37167
+ { name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
37168
+ {
37169
+ name: 'double-quoted keyword literal run ("where" )',
37170
+ build: (length) => repeatTo('"where" ', length)
37171
+ },
37172
+ { name: "double-quote run", build: (length) => repeatTo('"', length) },
37173
+ { name: "space run", build: (length) => repeatTo(" ", length) },
37174
+ { name: "newline run", build: (length) => repeatTo("\n", length) },
37175
+ ...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
37176
+ name: `unit run ${JSON.stringify(unit)}`,
37177
+ build: (length) => repeatTo(unit, length)
37178
+ }))
37179
+ ];
36868
37180
  function checkRuleTiming(rule, corroborate) {
36869
37181
  const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
36870
37182
  const work = corroboratedMs ?? 0;
@@ -37166,7 +37478,7 @@ var auth_jwt_no_verify_default = {
37166
37478
  severity: "critical",
37167
37479
  matcher: {
37168
37480
  type: "regex",
37169
- pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
37481
+ pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
37170
37482
  flags: "gi"
37171
37483
  },
37172
37484
  requiresNearby: {
@@ -37254,7 +37566,7 @@ var cmd_inject_shell_default = {
37254
37566
  severity: "critical",
37255
37567
  matcher: {
37256
37568
  type: "regex",
37257
- pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
37569
+ pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
37258
37570
  flags: "gi"
37259
37571
  },
37260
37572
  requiresNearby: {
@@ -37383,7 +37695,7 @@ var deser_yaml_unsafe_default = {
37383
37695
  severity: "high",
37384
37696
  matcher: {
37385
37697
  type: "regex",
37386
- pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
37698
+ pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
37387
37699
  flags: "gi"
37388
37700
  },
37389
37701
  examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
@@ -37600,7 +37912,7 @@ var sql_inject_concat_dot_default = {
37600
37912
  severity: "high",
37601
37913
  matcher: {
37602
37914
  type: "regex",
37603
- pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
37915
+ pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
37604
37916
  flags: "gi"
37605
37917
  },
37606
37918
  appliesTo: {
@@ -37618,7 +37930,7 @@ var sql_inject_concat_default = {
37618
37930
  severity: "high",
37619
37931
  matcher: {
37620
37932
  type: "regex",
37621
- 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*\\+`,
37933
+ 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*\\+`,
37622
37934
  flags: "gi"
37623
37935
  },
37624
37936
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -37633,7 +37945,7 @@ var sql_inject_format_default = {
37633
37945
  severity: "high",
37634
37946
  matcher: {
37635
37947
  type: "regex",
37636
- 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]|\\{[^}]+\\})",
37948
+ 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]+\\})",
37637
37949
  flags: "gi"
37638
37950
  },
37639
37951
  examples: [
@@ -37651,7 +37963,7 @@ var sql_inject_interp_default = {
37651
37963
  severity: "high",
37652
37964
  matcher: {
37653
37965
  type: "regex",
37654
- pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
37966
+ pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
37655
37967
  flags: "gi"
37656
37968
  },
37657
37969
  examples: [
@@ -38026,7 +38338,7 @@ var stack_trace_default = {
38026
38338
  severity: "low",
38027
38339
  matcher: {
38028
38340
  type: "regex",
38029
- pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38341
+ pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38030
38342
  flags: "g"
38031
38343
  },
38032
38344
  examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
@@ -39184,7 +39496,7 @@ var BUNDLED_PACKS = [
39184
39496
  {
39185
39497
  packId: "code-flaws",
39186
39498
  name: "Code Security Flaws",
39187
- version: "0.1.0",
39499
+ version: "0.1.2",
39188
39500
  rawRules: [
39189
39501
  sql_inject_concat_default,
39190
39502
  sql_inject_concat_dot_default,
@@ -39234,7 +39546,7 @@ var BUNDLED_PACKS = [
39234
39546
  {
39235
39547
  packId: "core-code-context",
39236
39548
  name: "Code Context",
39237
- version: "0.2.1",
39549
+ version: "0.2.2",
39238
39550
  rawRules: [
39239
39551
  internal_ip_default,
39240
39552
  localhost_ref_default,
@@ -39684,9 +39996,10 @@ function createIsolatedScanner(data, opts = {}) {
39684
39996
  if (job.timer !== void 0) return;
39685
39997
  job.startedAt = performance.now();
39686
39998
  job.progressAt = job.startedAt;
39999
+ const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
39687
40000
  job.timer = setTimeout(() => {
39688
40001
  onDeadline(job);
39689
- }, job.budgetMs);
40002
+ }, budget);
39690
40003
  }
39691
40004
  function runOne(spec, fail) {
39692
40005
  if (closed) {
@@ -39697,6 +40010,12 @@ function createIsolatedScanner(data, opts = {}) {
39697
40010
  fail({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
39698
40011
  return;
39699
40012
  }
40013
+ const now = performance.now();
40014
+ const deadlineAt = spec.deadlineAt;
40015
+ if (deadlineAt !== void 0 && deadlineAt <= now) {
40016
+ fail({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
40017
+ return;
40018
+ }
39700
40019
  const started = ensureWorker();
39701
40020
  if (!(started instanceof Worker)) {
39702
40021
  broken = started.error;
@@ -39704,11 +40023,11 @@ function createIsolatedScanner(data, opts = {}) {
39704
40023
  return;
39705
40024
  }
39706
40025
  const id = nextJobId++;
39707
- const now = performance.now();
39708
40026
  const job = {
39709
40027
  id,
39710
40028
  worker: started,
39711
40029
  budgetMs: spec.budgetMs,
40030
+ deadlineAt,
39712
40031
  startedAt: now,
39713
40032
  progressIndex: -1,
39714
40033
  progressAt: now,
@@ -39722,14 +40041,19 @@ function createIsolatedScanner(data, opts = {}) {
39722
40041
  if (readyWorker === started) {
39723
40042
  beginDeadline(job);
39724
40043
  } else {
40044
+ const startBudget = spec.startBudgetMs ?? startBudgetMs;
40045
+ const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
40046
+ const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
39725
40047
  job.startupTimer = setTimeout(() => {
39726
40048
  if (pending !== job) return;
39727
40049
  kill(job.worker);
39728
- failPending({
39729
- status: "unavailable",
39730
- reason: `the scan worker did not start within ${String(startBudgetMs)}ms`
39731
- });
39732
- }, startBudgetMs);
40050
+ failPending(
40051
+ callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
40052
+ status: "unavailable",
40053
+ reason: `the scan worker did not start within ${String(startBudget)}ms`
40054
+ }
40055
+ );
40056
+ }, startWaitMs);
39733
40057
  }
39734
40058
  try {
39735
40059
  started.postMessage(spec.build(id));
@@ -39758,7 +40082,9 @@ function createIsolatedScanner(data, opts = {}) {
39758
40082
  return enqueue((resolve3) => {
39759
40083
  runOne(
39760
40084
  {
39761
- budgetMs,
40085
+ budgetMs: scanOpts?.budgetMs ?? budgetMs,
40086
+ startBudgetMs: scanOpts?.startBudgetMs,
40087
+ deadlineAt: scanOpts?.deadlineAt,
39762
40088
  build: (id) => ({
39763
40089
  kind: "scan",
39764
40090
  id,
@@ -39952,6 +40278,9 @@ function createGuardedScanner(partition, gateway, opts) {
39952
40278
  let unverified = partition.unverified;
39953
40279
  let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
39954
40280
  let retired = false;
40281
+ let bounded;
40282
+ let boundedWarned = false;
40283
+ let closed = false;
39955
40284
  function inProcess(text, context) {
39956
40285
  return scan(text, verified, context);
39957
40286
  }
@@ -40013,11 +40342,48 @@ function createGuardedScanner(partition, gateway, opts) {
40013
40342
  await degrade();
40014
40343
  return inProcess(text, context);
40015
40344
  }
40345
+ async function scanBounded(text, context, bound) {
40346
+ const remainingMs = bound.remainingMs;
40347
+ let outcome;
40348
+ if (closed) {
40349
+ outcome = { status: "unavailable", reason: "the scan worker is closed" };
40350
+ } else if (remainingMs !== void 0 && !(remainingMs > 0)) {
40351
+ outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
40352
+ } else {
40353
+ bounded ??= createIsolatedScanner({ verified, unverified }, opts);
40354
+ const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
40355
+ try {
40356
+ outcome = await bounded.scan(text, context, {
40357
+ budgetMs: bound.budgetMs,
40358
+ startBudgetMs: bound.startBudgetMs,
40359
+ deadlineAt
40360
+ });
40361
+ } catch (error62) {
40362
+ outcome = {
40363
+ status: "unavailable",
40364
+ reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
40365
+ };
40366
+ }
40367
+ }
40368
+ if (outcome.status !== "ok" && !boundedWarned) {
40369
+ boundedWarned = true;
40370
+ process.stderr.write(
40371
+ outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
40372
+ ` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
40373
+ `
40374
+ );
40375
+ }
40376
+ return outcome;
40377
+ }
40016
40378
  return {
40017
40379
  scan: guardedScan,
40380
+ scanBounded,
40018
40381
  degraded: () => retired,
40019
40382
  async close() {
40020
- await retire();
40383
+ closed = true;
40384
+ const live = bounded;
40385
+ bounded = void 0;
40386
+ await Promise.all([retire(), live?.close()]);
40021
40387
  }
40022
40388
  };
40023
40389
  }
@@ -40144,6 +40510,19 @@ function conditionsMatch(conditions, ctx) {
40144
40510
  if (conditions.provider !== void 0) return false;
40145
40511
  return true;
40146
40512
  }
40513
+ var LARGE_INPUT_THRESHOLD_CHARS = 32768;
40514
+ var LARGE_INPUT_SCAN_BUDGET_MS = 2e3;
40515
+ var LARGE_INPUT_START_BUDGET_MS = 1500;
40516
+ function readRemainingMs(largeInput) {
40517
+ const read = largeInput.remainingMs;
40518
+ if (read === void 0) return void 0;
40519
+ try {
40520
+ const remaining = read();
40521
+ return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
40522
+ } catch {
40523
+ return 0;
40524
+ }
40525
+ }
40147
40526
  var bundlesPacked = false;
40148
40527
  function createPluginRuntime(gateway, settings, opts) {
40149
40528
  if (!bundlesPacked) {
@@ -40153,6 +40532,7 @@ function createPluginRuntime(gateway, settings, opts) {
40153
40532
  const policyMode = settings.policy;
40154
40533
  let redactFallback = settings.redactFallback;
40155
40534
  const dataDir2 = opts?.dataDir;
40535
+ const largeInput = opts?.largeInput;
40156
40536
  let rules = [];
40157
40537
  let evidenceOf = evidenceLookup(rules);
40158
40538
  let scanner;
@@ -40365,7 +40745,24 @@ function createPluginRuntime(gateway, settings, opts) {
40365
40745
  await ensureInitialized();
40366
40746
  if (!scanner) throw new Error("the runtime initialized without a scanner");
40367
40747
  const shielded = shieldPointers(text);
40368
- const matched = await scanner.scan(shielded.text, context);
40748
+ let matched;
40749
+ if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
40750
+ const outcome = await scanner.scanBounded(shielded.text, context, {
40751
+ budgetMs: largeInput.budgetMs,
40752
+ startBudgetMs: largeInput.startBudgetMs,
40753
+ remainingMs: readRemainingMs(largeInput)
40754
+ });
40755
+ if (outcome.status !== "ok") {
40756
+ return {
40757
+ decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
40758
+ excepted: /* @__PURE__ */ new Set(),
40759
+ exceptionIds: []
40760
+ };
40761
+ }
40762
+ matched = outcome.findings;
40763
+ } else {
40764
+ matched = await scanner.scan(shielded.text, context);
40765
+ }
40369
40766
  const findings = dropShieldedFindings(matched, shielded.spans);
40370
40767
  const fpCache = /* @__PURE__ */ new Map();
40371
40768
  const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
@@ -40406,20 +40803,24 @@ function createPluginRuntime(gateway, settings, opts) {
40406
40803
  }
40407
40804
  async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
40408
40805
  const filePath = input2.metadata?.filePath;
40409
- if (opts2.persist === "with-findings" && decision.findings.length === 0) return;
40806
+ if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
40807
+ return;
40808
+ }
40410
40809
  try {
40411
40810
  const contentHash = contentHashOf(input2.text);
40412
40811
  const maskedFindings = decision.findings.filter(
40413
40812
  (match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
40414
40813
  );
40415
- const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40814
+ const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40416
40815
  const inspectionMs = elapsedMs(timingStartedAt);
40417
40816
  const redactDegradedTo = decision.redactDegradedTo;
40418
- const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 ? {
40817
+ const scanIncomplete = decision.scanIncomplete;
40818
+ const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
40419
40819
  ...input2.metadata,
40420
40820
  ...exceptionIds.length > 0 ? { exceptionIds } : {},
40421
40821
  ...inspectionMs !== void 0 ? { inspectionMs } : {},
40422
- ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
40822
+ ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
40823
+ ...scanIncomplete !== void 0 ? { scanIncomplete } : {}
40423
40824
  } : input2.metadata;
40424
40825
  const event = buildIngestEvent({
40425
40826
  kind: input2.kind,
@@ -42005,6 +42406,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
42005
42406
  var TRACE_ID = EventMetadata.shape.traceId;
42006
42407
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
42007
42408
  var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
42409
+ var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
42008
42410
 
42009
42411
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
42010
42412
  var CAPTURE_BATCH_BYTES = 1024 * 1024;
@@ -42974,6 +43376,16 @@ function resolveDataGateway(config2, meta4, gatewayFactory = defaultGatewayFacto
42974
43376
  import { randomUUID as randomUUID19 } from "crypto";
42975
43377
  var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
42976
43378
 
43379
+ // src/hooks/large-input.ts
43380
+ function largeInputBound(deadlineAt, now = () => performance.now()) {
43381
+ return {
43382
+ thresholdChars: LARGE_INPUT_THRESHOLD_CHARS,
43383
+ budgetMs: LARGE_INPUT_SCAN_BUDGET_MS,
43384
+ startBudgetMs: LARGE_INPUT_START_BUDGET_MS,
43385
+ remainingMs: () => deadlineAt - now()
43386
+ };
43387
+ }
43388
+
42977
43389
  // src/present.ts
42978
43390
  var SHADE = {
42979
43391
  light: "\u2591",
@@ -43011,16 +43423,26 @@ function withheldBanner(input2) {
43011
43423
  const header = `${SHADE.full}${SHADE.dark}${SHADE.medium}${SHADE.light} AKA ${SHADE.light}${SHADE.medium}${SHADE.dark}${SHADE.full}`;
43012
43424
  const subject = input2.action === "withheld" ? "The flagged value" : "Redacted spans";
43013
43425
  const approve = input2.blockedRef ? `Allow this exact value (${input2.blockedRef.maskedValue}) intentionally: aka exception approve ${input2.blockedRef.reference}` : "Allow intentionally: aka exception approve";
43426
+ const flagged = Boolean(input2.withheldRuleIds) || Boolean(input2.redactedRuleIds);
43014
43427
  return [
43015
43428
  `${header} ${input2.toolName} output ${input2.action}`,
43016
43429
  ...input2.withheldRuleIds ? [`${SHADE.full} Withheld: ${input2.withheldRuleIds}`] : [],
43017
43430
  ...input2.redactedRuleIds ? [`${SHADE.full} Redacted: ${input2.redactedRuleIds}`] : [],
43431
+ ...input2.tooLargeFields ? [
43432
+ `${SHADE.full} Too large to scan in time: ${input2.tooLargeFields} \u2014 withheld, never reached the model.`
43433
+ ] : [],
43018
43434
  ...input2.warnedRuleIds ? [`${SHADE.full} Also flagged (warn): ${input2.warnedRuleIds}`] : [],
43019
- `${SHADE.full} ${subject} never reached the model.`,
43020
- `${SHADE.full} ${approve}`,
43021
- `${SHADE.full} More: aka exception --help`
43435
+ ...flagged ? [
43436
+ `${SHADE.full} ${subject} never reached the model.`,
43437
+ `${SHADE.full} ${approve}`,
43438
+ `${SHADE.full} More: aka exception --help`
43439
+ ] : []
43022
43440
  ].join("\n");
43023
43441
  }
43442
+ function tooLargeToolText(toolName, field) {
43443
+ const part = field !== void 0 && field !== "" ? field : "output";
43444
+ return `[AKA SECURITY] ${toolName} ${part} withheld \u2014 too large to scan within the time limit. The content was not added to your context. This notice is a placeholder, not the real content: the underlying file or command output is unchanged, so never write this notice back to a file or treat it as data. Tell the user AKA withheld this output because it was too large to scan. If the task needs it, read it in smaller parts (for example a narrower range of lines).`;
43445
+ }
43024
43446
  function withheldToolText(toolName, ruleIds, field) {
43025
43447
  const part = field !== void 0 && field !== "" ? field : "output";
43026
43448
  return `[AKA SECURITY] ${toolName} ${part} withheld \u2014 flagged ${ruleIds}. The flagged content was not added to your context. This notice is a placeholder, not the real content: the underlying file or command output is unchanged, so never write this notice back to a file or treat it as data. Do not attempt to obtain the withheld content through other channels. Tell the user AKA withheld this output and why. If the user asks again \u2014 for example after granting an AKA exception \u2014 re-run this same tool call if it is safe to repeat: AKA re-evaluates every capture and passes values the user has excepted.`;
@@ -43036,7 +43458,8 @@ async function scanResponseFields(toolName, fields, capture, deadline) {
43036
43458
  blockedReferences: [],
43037
43459
  redactedReferences: [],
43038
43460
  toolName,
43039
- unscannedFields: 0
43461
+ unscannedFields: 0,
43462
+ tooLargeFields: []
43040
43463
  };
43041
43464
  for (const [index, field] of fields.entries()) {
43042
43465
  if (deadline !== void 0 && deadline.now() >= deadline.at) {
@@ -43044,6 +43467,11 @@ async function scanResponseFields(toolName, fields, capture, deadline) {
43044
43467
  break;
43045
43468
  }
43046
43469
  const result = await capture(field.text);
43470
+ if (result.scanIncomplete !== void 0) {
43471
+ const name = field.path.join(".");
43472
+ if (!outcome.tooLargeFields.includes(name)) outcome.tooLargeFields.push(name);
43473
+ continue;
43474
+ }
43047
43475
  if (result.findings.length === 0) continue;
43048
43476
  if (result.action === "block") {
43049
43477
  outcome.withheldFindings.push(...result.findings);
@@ -43058,21 +43486,30 @@ async function scanResponseFields(toolName, fields, capture, deadline) {
43058
43486
  return outcome;
43059
43487
  }
43060
43488
  function responseEmitPayload(outcome) {
43061
- const { toolName, withheldFindings, redactedButWithheldFindings, warnedFindings } = outcome;
43489
+ const {
43490
+ toolName,
43491
+ withheldFindings,
43492
+ redactedButWithheldFindings,
43493
+ warnedFindings,
43494
+ tooLargeFields
43495
+ } = outcome;
43062
43496
  const allWithheld = [...withheldFindings, ...redactedButWithheldFindings];
43063
- if (allWithheld.length > 0) {
43497
+ if (allWithheld.length > 0 || tooLargeFields.length > 0) {
43064
43498
  const withheldRuleIds = withheldFindings.length > 0 ? uniqueRuleIds(withheldFindings) : void 0;
43065
43499
  const redactedRuleIds = redactedButWithheldFindings.length > 0 ? uniqueRuleIds(redactedButWithheldFindings) : void 0;
43066
43500
  const ref = outcome.blockedReferences[0] ?? outcome.redactedReferences[0];
43067
43501
  return {
43068
43502
  decision: "block",
43069
- reason: withheldToolText(toolName, uniqueRuleIds(allWithheld)),
43503
+ // The whole result goes either way; a flagged rule is the more specific
43504
+ // reason when there is one.
43505
+ reason: allWithheld.length > 0 ? withheldToolText(toolName, uniqueRuleIds(allWithheld)) : tooLargeToolText(toolName),
43070
43506
  systemMessage: withheldBanner({
43071
43507
  toolName,
43072
43508
  action: "withheld",
43073
43509
  withheldRuleIds,
43074
43510
  redactedRuleIds,
43075
43511
  warnedRuleIds: warnedFindings.length > 0 ? uniqueRuleIds(warnedFindings) : void 0,
43512
+ tooLargeFields: tooLargeFields.length > 0 ? tooLargeFields.join(", ") : void 0,
43076
43513
  blockedRef: ref
43077
43514
  })
43078
43515
  };
@@ -43346,7 +43783,10 @@ async function main() {
43346
43783
  const config2 = loadConfig();
43347
43784
  warnIfStoreRedirected(config2, getString(input2, "session_id"));
43348
43785
  const gateway = resolveDataGateway(config2);
43349
- const runtime = createPluginRuntime(gateway, config2.settings, { dataDir: config2.dataDir });
43786
+ const runtime = createPluginRuntime(gateway, config2.settings, {
43787
+ dataDir: config2.dataDir,
43788
+ largeInput: largeInputBound(RESPONSE_SCAN_DEADLINE_MS)
43789
+ });
43350
43790
  let outcome;
43351
43791
  try {
43352
43792
  outcome = await scanResponseFields(