@pensar/apex 2.3.0 → 2.4.0-canary.09a8744f

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.
Files changed (81) hide show
  1. package/build/{agent-9xna7jhw.js → agent-4gcavfr4.js} +12 -11
  2. package/build/agent-7x7b5hz1.js +30 -0
  3. package/build/agent-zx1cw89c.js +20 -0
  4. package/build/{apps-43pqbz7r.js → apps-xqecgcbn.js} +75 -34
  5. package/build/{auth-c1z670rx.js → auth-62z3kedh.js} +46 -23
  6. package/build/authentication-phbasmkj.js +20 -0
  7. package/build/blackboxAgent-3s34dabp.js +20 -0
  8. package/build/blackboxPentest-mg2p9s1m.js +70 -0
  9. package/build/{cli-zk1ch6qf.js → cli-4a1c4tkn.js} +61 -10
  10. package/build/{cli-zx8gk8xv.js → cli-51503njj.js} +661 -328
  11. package/build/cli-53rm0rrz.js +15 -0
  12. package/build/{cli-eveg9djy.js → cli-5tbg4dyb.js} +3 -2
  13. package/build/cli-68260ckj.js +12136 -0
  14. package/build/{cli-baqhqbe5.js → cli-7gcsfnw6.js} +3 -3
  15. package/build/cli-7q3ae3ft.js +6 -0
  16. package/build/{cli-72b18z0n.js → cli-8nj7pnew.js} +28 -5
  17. package/build/{cli-f7hanqbw.js → cli-9fds4ss0.js} +2 -2
  18. package/build/cli-9pbk8m32.js +32 -0
  19. package/build/{cli-3k1x5rn3.js → cli-avmhkjtv.js} +2970 -4450
  20. package/build/{cli-vckbhnyk.js → cli-b3d97zgc.js} +2 -2
  21. package/build/{cli-8rxa073f.js → cli-bc05qbss.js} +8 -6
  22. package/build/{cli-7tw4xfnw.js → cli-cdk877bx.js} +1 -1
  23. package/build/{cli-q24twygk.js → cli-dm0fc0bm.js} +1 -1
  24. package/build/{cli-barsn8br.js → cli-e1gmqsyh.js} +11 -5
  25. package/build/{cli-yz80qkzn.js → cli-ee3axgts.js} +7 -1
  26. package/build/{cli-f71s6kcw.js → cli-ex9r1x7c.js} +81 -215
  27. package/build/{cli-n2m2yy5b.js → cli-hc4w41as.js} +2105 -957
  28. package/build/{cli-gpnb45ck.js → cli-j54qa6tm.js} +7 -7
  29. package/build/{cli-j0n189ee.js → cli-j5p6jwm8.js} +2 -2
  30. package/build/{cli-wszshs5e.js → cli-k71t434r.js} +4 -4
  31. package/build/cli-knd276ed.js +1485 -0
  32. package/build/{cli-zm8tfpv7.js → cli-n36kxpcz.js} +62 -44
  33. package/build/{cli-bv2807tj.js → cli-n4cmzq79.js} +5 -3
  34. package/build/{cli-jyp2c6th.js → cli-nvqny4ej.js} +5 -3
  35. package/build/{cli-50906d27.js → cli-nw9ytp7z.js} +122 -43
  36. package/build/{cli-bnkgdywr.js → cli-ppj4c75j.js} +1 -1
  37. package/build/cli.js +546 -98
  38. package/build/{config-jzqjz606.js → config-7f07yemp.js} +20 -17
  39. package/build/{doctor-q3qws68e.js → doctor-gwvyn249.js} +11 -9
  40. package/build/{fastStrike-ebz1ph9a.js → fastStrike-zxsk2q40.js} +39 -16
  41. package/build/{fixes-86yebsj0.js → fixes-zqe8v8ye.js} +27 -22
  42. package/build/getMachineId-bsd-xj3bn2fv.js +36 -0
  43. package/build/getMachineId-darwin-07jzjcx6.js +36 -0
  44. package/build/getMachineId-linux-ahngynxd.js +29 -0
  45. package/build/getMachineId-unsupported-vy43b44z.js +19 -0
  46. package/build/getMachineId-win-8x66cynz.js +38 -0
  47. package/build/{index-32hn8rrw.js → index-4j14ssrg.js} +3 -3
  48. package/build/{index-gq9h8j5j.js → index-5wh7gq37.js} +135 -133
  49. package/build/{index-468j74f3.js → index-6s313ddp.js} +121 -97
  50. package/build/{index-e8c8zcrf.js → index-9j3pakz7.js} +32 -26
  51. package/build/{index-h2hj2hj9.js → index-cbwn03kz.js} +16 -16
  52. package/build/{index-8db1d2q3.js → index-cmvmnes1.js} +18 -18
  53. package/build/{index-tke6896d.js → index-psqjpw5m.js} +10 -10
  54. package/build/index-r4z6r7vf.js +12 -0
  55. package/build/{index-97vx1a24.js → index-rdqjtnp7.js} +2774 -2236
  56. package/build/{index-mr2cseg4.js → index-wddghhbd.js} +20 -19
  57. package/build/{issues-kh4wg8c5.js → issues-j7ybeaz9.js} +36 -28
  58. package/build/{logs-bj28xmbf.js → logs-qdceq54y.js} +27 -22
  59. package/build/{multipart-parser-6zd16497.js → multipart-parser-g2xxkezz.js} +2 -2
  60. package/build/{offesecAgent-8ky7gccp.js → offesecAgent-9tecezzm.js} +12 -11
  61. package/build/{parse-7djk9jyf.js → parse-rtccymzn.js} +3 -3
  62. package/build/pentest-qk82s64n.js +30 -0
  63. package/build/{pentests-62d6zw6p.js → pentests-97d3rwzr.js} +28 -23
  64. package/build/{targetedPentest-me4jnr3z.js → targetedPentest-g9x0g0zp.js} +15 -14
  65. package/build/{targets-e5k1mrky.js → targets-6m1cp1hx.js} +29 -24
  66. package/build/threatModel-a4gsw56r.js +29 -0
  67. package/build/{token-rdcbn380.js → token-3bbp59y6.js} +3 -3
  68. package/build/{token-util-sxb85ahn.js → token-util-6xjme11b.js} +2 -2
  69. package/build/{uninstall-jt1bca2p.js → uninstall-pkxkzt35.js} +7 -4
  70. package/build/{upload-krd8bnex.js → upload-w71jnkg0.js} +12 -11
  71. package/build/{utils-skmqhyfg.js → utils-846z7q2v.js} +18 -13
  72. package/package.json +8 -2
  73. package/build/agent-71z4e7jg.js +0 -19
  74. package/build/agent-ga5fecfs.js +0 -27
  75. package/build/authentication-hgs7ym0m.js +0 -19
  76. package/build/blackboxAgent-gem3mxa9.js +0 -19
  77. package/build/blackboxPentest-tgc2t3y6.js +0 -37
  78. package/build/index-ag14v3sg.js +0 -12
  79. package/build/main-3d7dfdvs.js +0 -324
  80. package/build/pentest-rs0181nf.js +0 -29
  81. package/build/threatModel-k4f3zgqd.js +0 -27
@@ -4,7 +4,7 @@ import {
4
4
  init_auth,
5
5
  init_constants,
6
6
  signGatewayRequest
7
- } from "./cli-vckbhnyk.js";
7
+ } from "./cli-b3d97zgc.js";
8
8
  import {
9
9
  AISDKError,
10
10
  APICallError,
@@ -71,7 +71,6 @@ import {
71
71
  postFormDataToApi,
72
72
  postJsonToApi,
73
73
  readResponseWithSizeLimit,
74
- require_src,
75
74
  resolve,
76
75
  safeParseAsync,
77
76
  safeParseJSON,
@@ -83,15 +82,18 @@ import {
83
82
  withoutTrailingSlash,
84
83
  zodSchema,
85
84
  zod_default
86
- } from "./cli-3k1x5rn3.js";
85
+ } from "./cli-avmhkjtv.js";
87
86
  import {
88
87
  config,
89
88
  init_config
90
- } from "./cli-f7hanqbw.js";
89
+ } from "./cli-9fds4ss0.js";
91
90
  import {
92
91
  getCurrentVersion,
93
92
  init_installation
94
- } from "./cli-barsn8br.js";
93
+ } from "./cli-e1gmqsyh.js";
94
+ import {
95
+ require_src
96
+ } from "./cli-knd276ed.js";
95
97
  import {
96
98
  __callDispose,
97
99
  __commonJS,
@@ -99,7 +101,7 @@ import {
99
101
  __require,
100
102
  __toESM,
101
103
  __using
102
- } from "./cli-8rxa073f.js";
104
+ } from "./cli-bc05qbss.js";
103
105
 
104
106
  // node_modules/ai/dist/index.mjs
105
107
  function asArray(value) {
@@ -7678,6 +7680,60 @@ var init_dist4 = __esm(() => {
7678
7680
  defaultDownload2 = createDownload();
7679
7681
  });
7680
7682
 
7683
+ // src/core/id/id.ts
7684
+ import { randomBytes } from "node:crypto";
7685
+ function schema(prefix) {
7686
+ return zod_default.string().startsWith(prefixes[prefix]);
7687
+ }
7688
+ function descending(prefix, given) {
7689
+ return generateID(prefix, true, given);
7690
+ }
7691
+ function generateID(prefix, descending2, given) {
7692
+ if (!given) {
7693
+ return create(prefix, descending2);
7694
+ }
7695
+ if (!given.startsWith(prefixes[prefix])) {
7696
+ throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`);
7697
+ }
7698
+ return given;
7699
+ }
7700
+ function randomBase62(length) {
7701
+ const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
7702
+ let result = "";
7703
+ const bytes = randomBytes(length);
7704
+ for (let i = 0;i < length; i++) {
7705
+ result += chars[bytes[i] % 62];
7706
+ }
7707
+ return result;
7708
+ }
7709
+ function create(prefix, descending2, timestamp) {
7710
+ const currentTimestamp = timestamp ?? Date.now();
7711
+ if (currentTimestamp !== lastTimestamp) {
7712
+ lastTimestamp = currentTimestamp;
7713
+ counter = 0;
7714
+ }
7715
+ counter++;
7716
+ let now2 = BigInt(currentTimestamp) * BigInt(4096) + BigInt(counter);
7717
+ now2 = descending2 ? ~now2 : now2;
7718
+ const timeBytes = Buffer.alloc(6);
7719
+ for (let i = 0;i < 6; i++) {
7720
+ timeBytes[i] = Number(now2 >> BigInt(40 - 8 * i) & BigInt(255));
7721
+ }
7722
+ return prefixes[prefix] + "_" + timeBytes.toString("hex") + randomBase62(LENGTH - 12);
7723
+ }
7724
+ var prefixes, LENGTH = 26, lastTimestamp = 0, counter = 0, newSessionId = () => descending("session"), newMessageId = () => descending("message"), newPartId = () => descending("part"), newRunId = () => descending("run"), isSessionId = (s) => s.startsWith(`${prefixes.session}_`);
7725
+ var init_id = __esm(() => {
7726
+ init_zod();
7727
+ prefixes = {
7728
+ session: "ses",
7729
+ message: "msg",
7730
+ permission: "per",
7731
+ user: "usr",
7732
+ part: "prt",
7733
+ run: "run"
7734
+ };
7735
+ });
7736
+
7681
7737
  // src/core/ai/models/anthropic.ts
7682
7738
  var ANTHROPIC_MODELS;
7683
7739
  var init_anthropic = __esm(() => {
@@ -8382,6 +8438,121 @@ var init_bedrock = __esm(() => {
8382
8438
  ];
8383
8439
  });
8384
8440
 
8441
+ // src/core/ai/models/concentrate.ts
8442
+ var CONCENTRATE_MODELS;
8443
+ var init_concentrate = __esm(() => {
8444
+ CONCENTRATE_MODELS = [
8445
+ {
8446
+ id: "concentrate:claude-opus-4-6",
8447
+ name: "Claude Opus 4.6",
8448
+ provider: "concentrate",
8449
+ contextLength: 200000
8450
+ },
8451
+ {
8452
+ id: "concentrate:claude-sonnet-4-6",
8453
+ name: "Claude Sonnet 4.6",
8454
+ provider: "concentrate",
8455
+ contextLength: 200000
8456
+ },
8457
+ {
8458
+ id: "concentrate:claude-sonnet-4-5",
8459
+ name: "Claude Sonnet 4.5",
8460
+ provider: "concentrate",
8461
+ contextLength: 200000
8462
+ },
8463
+ {
8464
+ id: "concentrate:claude-haiku-4-5",
8465
+ name: "Claude Haiku 4.5",
8466
+ provider: "concentrate",
8467
+ contextLength: 200000
8468
+ },
8469
+ {
8470
+ id: "concentrate:gpt-5.6-sol",
8471
+ name: "GPT 5.6 Sol",
8472
+ provider: "concentrate",
8473
+ contextLength: 1050000
8474
+ },
8475
+ {
8476
+ id: "concentrate:gpt-5.6-terra",
8477
+ name: "GPT 5.6 Terra",
8478
+ provider: "concentrate",
8479
+ contextLength: 1050000
8480
+ },
8481
+ {
8482
+ id: "concentrate:gpt-5.6-luna",
8483
+ name: "GPT 5.6 Luna",
8484
+ provider: "concentrate",
8485
+ contextLength: 1050000
8486
+ },
8487
+ {
8488
+ id: "concentrate:gpt-5.5",
8489
+ name: "GPT 5.5",
8490
+ provider: "concentrate",
8491
+ contextLength: 1050000
8492
+ },
8493
+ {
8494
+ id: "concentrate:gpt-5.4",
8495
+ name: "GPT 5.4",
8496
+ provider: "concentrate",
8497
+ contextLength: 1050000
8498
+ },
8499
+ {
8500
+ id: "concentrate:gpt-5.3-codex",
8501
+ name: "GPT 5.3 Codex",
8502
+ provider: "concentrate",
8503
+ contextLength: 400000
8504
+ },
8505
+ {
8506
+ id: "concentrate:gemini-3.6-flash",
8507
+ name: "Gemini 3.6 Flash",
8508
+ provider: "concentrate",
8509
+ contextLength: 1048576
8510
+ },
8511
+ {
8512
+ id: "concentrate:gemini-3.1-pro-preview",
8513
+ name: "Gemini 3.1 Pro Preview",
8514
+ provider: "concentrate",
8515
+ contextLength: 1e6
8516
+ },
8517
+ {
8518
+ id: "concentrate:gemini-2.5-pro",
8519
+ name: "Gemini 2.5 Pro",
8520
+ provider: "concentrate",
8521
+ contextLength: 1e6
8522
+ },
8523
+ {
8524
+ id: "concentrate:deepseek-v3-2",
8525
+ name: "DeepSeek V3.2",
8526
+ provider: "concentrate",
8527
+ contextLength: 163840
8528
+ },
8529
+ {
8530
+ id: "concentrate:mistral-large-3",
8531
+ name: "Mistral Large 3",
8532
+ provider: "concentrate",
8533
+ contextLength: 256000
8534
+ },
8535
+ {
8536
+ id: "concentrate:kimi-k2-thinking",
8537
+ name: "Kimi K2 Thinking",
8538
+ provider: "concentrate",
8539
+ contextLength: 262144
8540
+ },
8541
+ {
8542
+ id: "concentrate:minimax-m2-7",
8543
+ name: "MiniMax M2.7",
8544
+ provider: "concentrate",
8545
+ contextLength: 204800
8546
+ },
8547
+ {
8548
+ id: "concentrate:glm-5",
8549
+ name: "GLM-5",
8550
+ provider: "concentrate",
8551
+ contextLength: 202800
8552
+ }
8553
+ ];
8554
+ });
8555
+
8385
8556
  // src/core/ai/models/google.ts
8386
8557
  var GOOGLE_MODELS;
8387
8558
  var init_google = __esm(() => {
@@ -9314,6 +9485,7 @@ var AVAILABLE_MODELS;
9314
9485
  var init_models = __esm(() => {
9315
9486
  init_anthropic();
9316
9487
  init_bedrock();
9488
+ init_concentrate();
9317
9489
  init_google();
9318
9490
  init_inception();
9319
9491
  init_mantle2();
@@ -9327,6 +9499,7 @@ var init_models = __esm(() => {
9327
9499
  ...BEDROCK_MODELS,
9328
9500
  ...MANTLE_MODELS,
9329
9501
  ...OPENROUTER_MODELS,
9502
+ ...CONCENTRATE_MODELS,
9330
9503
  ...PENSAR_MODELS,
9331
9504
  ...INCEPTION_MODELS
9332
9505
  ];
@@ -11278,7 +11451,7 @@ var init_internal = __esm(() => {
11278
11451
  });
11279
11452
 
11280
11453
  // node_modules/tslib/tslib.js
11281
- var require_tslib = __commonJS((exports, module) => {
11454
+ var require_tslib = __commonJS(function(exports, module) {
11282
11455
  var __extends;
11283
11456
  var __assign;
11284
11457
  var __rest;
@@ -11883,7 +12056,7 @@ var require_tslib = __commonJS((exports, module) => {
11883
12056
  });
11884
12057
 
11885
12058
  // node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/node_modules/@smithy/util-buffer-from/node_modules/@smithy/is-array-buffer/dist-cjs/index.js
11886
- var require_dist_cjs = __commonJS((exports, module) => {
12059
+ var require_dist_cjs = __commonJS(function(exports, module) {
11887
12060
  var __defProp2 = Object.defineProperty;
11888
12061
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11889
12062
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -11911,7 +12084,7 @@ var require_dist_cjs = __commonJS((exports, module) => {
11911
12084
  });
11912
12085
 
11913
12086
  // node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/node_modules/@smithy/util-buffer-from/dist-cjs/index.js
11914
- var require_dist_cjs2 = __commonJS((exports, module) => {
12087
+ var require_dist_cjs2 = __commonJS(function(exports, module) {
11915
12088
  var __defProp2 = Object.defineProperty;
11916
12089
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11917
12090
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -11953,7 +12126,7 @@ var require_dist_cjs2 = __commonJS((exports, module) => {
11953
12126
  });
11954
12127
 
11955
12128
  // node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/dist-cjs/index.js
11956
- var require_dist_cjs3 = __commonJS((exports, module) => {
12129
+ var require_dist_cjs3 = __commonJS(function(exports, module) {
11957
12130
  var __defProp2 = Object.defineProperty;
11958
12131
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11959
12132
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -12005,7 +12178,7 @@ var require_dist_cjs3 = __commonJS((exports, module) => {
12005
12178
  });
12006
12179
 
12007
12180
  // node_modules/@aws-crypto/util/build/main/convertToBuffer.js
12008
- var require_convertToBuffer = __commonJS((exports) => {
12181
+ var require_convertToBuffer = __commonJS(function(exports) {
12009
12182
  Object.defineProperty(exports, "__esModule", { value: true });
12010
12183
  exports.convertToBuffer = undefined;
12011
12184
  var util_utf8_1 = require_dist_cjs3();
@@ -12027,7 +12200,7 @@ var require_convertToBuffer = __commonJS((exports) => {
12027
12200
  });
12028
12201
 
12029
12202
  // node_modules/@aws-crypto/util/build/main/isEmptyData.js
12030
- var require_isEmptyData = __commonJS((exports) => {
12203
+ var require_isEmptyData = __commonJS(function(exports) {
12031
12204
  Object.defineProperty(exports, "__esModule", { value: true });
12032
12205
  exports.isEmptyData = undefined;
12033
12206
  function isEmptyData(data) {
@@ -12040,7 +12213,7 @@ var require_isEmptyData = __commonJS((exports) => {
12040
12213
  });
12041
12214
 
12042
12215
  // node_modules/@aws-crypto/util/build/main/numToUint8.js
12043
- var require_numToUint8 = __commonJS((exports) => {
12216
+ var require_numToUint8 = __commonJS(function(exports) {
12044
12217
  Object.defineProperty(exports, "__esModule", { value: true });
12045
12218
  exports.numToUint8 = undefined;
12046
12219
  function numToUint8(num) {
@@ -12055,7 +12228,7 @@ var require_numToUint8 = __commonJS((exports) => {
12055
12228
  });
12056
12229
 
12057
12230
  // node_modules/@aws-crypto/util/build/main/uint32ArrayFrom.js
12058
- var require_uint32ArrayFrom = __commonJS((exports) => {
12231
+ var require_uint32ArrayFrom = __commonJS(function(exports) {
12059
12232
  Object.defineProperty(exports, "__esModule", { value: true });
12060
12233
  exports.uint32ArrayFrom = undefined;
12061
12234
  function uint32ArrayFrom(a_lookUpTable) {
@@ -12074,7 +12247,7 @@ var require_uint32ArrayFrom = __commonJS((exports) => {
12074
12247
  });
12075
12248
 
12076
12249
  // node_modules/@aws-crypto/util/build/main/index.js
12077
- var require_main = __commonJS((exports) => {
12250
+ var require_main = __commonJS(function(exports) {
12078
12251
  Object.defineProperty(exports, "__esModule", { value: true });
12079
12252
  exports.uint32ArrayFrom = exports.numToUint8 = exports.isEmptyData = exports.convertToBuffer = undefined;
12080
12253
  var convertToBuffer_1 = require_convertToBuffer();
@@ -12096,7 +12269,7 @@ var require_main = __commonJS((exports) => {
12096
12269
  });
12097
12270
 
12098
12271
  // node_modules/@aws-crypto/crc32/build/main/aws_crc32.js
12099
- var require_aws_crc32 = __commonJS((exports) => {
12272
+ var require_aws_crc32 = __commonJS(function(exports) {
12100
12273
  Object.defineProperty(exports, "__esModule", { value: true });
12101
12274
  exports.AwsCrc32 = undefined;
12102
12275
  var tslib_1 = require_tslib();
@@ -12127,7 +12300,7 @@ var require_aws_crc32 = __commonJS((exports) => {
12127
12300
  });
12128
12301
 
12129
12302
  // node_modules/@aws-crypto/crc32/build/main/index.js
12130
- var require_main2 = __commonJS((exports) => {
12303
+ var require_main2 = __commonJS(function(exports) {
12131
12304
  Object.defineProperty(exports, "__esModule", { value: true });
12132
12305
  exports.AwsCrc32 = exports.Crc32 = exports.crc32 = undefined;
12133
12306
  var tslib_1 = require_tslib();
@@ -12432,7 +12605,7 @@ var require_main2 = __commonJS((exports) => {
12432
12605
  });
12433
12606
 
12434
12607
  // node_modules/@smithy/util-hex-encoding/dist-cjs/index.js
12435
- var require_dist_cjs4 = __commonJS((exports) => {
12608
+ var require_dist_cjs4 = __commonJS(function(exports) {
12436
12609
  var SHORT_TO_HEX = {};
12437
12610
  var HEX_TO_SHORT = {};
12438
12611
  for (let i = 0;i < 256; i++) {
@@ -12761,24 +12934,89 @@ class EventStreamCodec {
12761
12934
  return this.headerMarshaller.format(rawHeaders);
12762
12935
  }
12763
12936
  }
12764
- var crc32, utilHexEncoding, BOOLEAN_TAG = "boolean", BYTE_TAG = "byte", SHORT_TAG = "short", INT_TAG = "integer", LONG_TAG = "long", BINARY_TAG = "binary", STRING_TAG = "string", TIMESTAMP_TAG = "timestamp", UUID_TAG = "uuid", UUID_PATTERN, PRELUDE_MEMBER_LENGTH = 4, PRELUDE_LENGTH, CHECKSUM_LENGTH = 4, MINIMUM_MESSAGE_LENGTH, $EventStreamCodec;
12937
+ var crc32, utilHexEncoding, BOOLEAN_TAG = "boolean", BYTE_TAG = "byte", SHORT_TAG = "short", INT_TAG = "integer", LONG_TAG = "long", BINARY_TAG = "binary", STRING_TAG = "string", TIMESTAMP_TAG = "timestamp", UUID_TAG = "uuid", UUID_PATTERN, PRELUDE_MEMBER_LENGTH = 4, PRELUDE_LENGTH, CHECKSUM_LENGTH = 4, MINIMUM_MESSAGE_LENGTH, MessageDecoderStream, MessageEncoderStream, SmithyMessageDecoderStream, SmithyMessageEncoderStream, $EventStreamCodec;
12765
12938
  var init_dist_cjs = __esm(() => {
12766
12939
  crc32 = require_main2();
12767
12940
  utilHexEncoding = require_dist_cjs4();
12768
12941
  UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
12769
12942
  PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
12770
12943
  MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
12944
+ MessageDecoderStream = class MessageDecoderStream {
12945
+ options;
12946
+ constructor(options) {
12947
+ this.options = options;
12948
+ }
12949
+ [Symbol.asyncIterator]() {
12950
+ return this.asyncIterator();
12951
+ }
12952
+ async* asyncIterator() {
12953
+ for await (const bytes of this.options.inputStream) {
12954
+ const decoded = this.options.decoder.decode(bytes);
12955
+ yield decoded;
12956
+ }
12957
+ }
12958
+ };
12959
+ MessageEncoderStream = class MessageEncoderStream {
12960
+ options;
12961
+ constructor(options) {
12962
+ this.options = options;
12963
+ }
12964
+ [Symbol.asyncIterator]() {
12965
+ return this.asyncIterator();
12966
+ }
12967
+ async* asyncIterator() {
12968
+ for await (const msg of this.options.messageStream) {
12969
+ const encoded = this.options.encoder.encode(msg);
12970
+ yield encoded;
12971
+ }
12972
+ if (this.options.includeEndFrame) {
12973
+ yield new Uint8Array(0);
12974
+ }
12975
+ }
12976
+ };
12977
+ SmithyMessageDecoderStream = class SmithyMessageDecoderStream {
12978
+ options;
12979
+ constructor(options) {
12980
+ this.options = options;
12981
+ }
12982
+ [Symbol.asyncIterator]() {
12983
+ return this.asyncIterator();
12984
+ }
12985
+ async* asyncIterator() {
12986
+ for await (const message of this.options.messageStream) {
12987
+ const deserialized = await this.options.deserializer(message);
12988
+ if (deserialized === undefined)
12989
+ continue;
12990
+ yield deserialized;
12991
+ }
12992
+ }
12993
+ };
12994
+ SmithyMessageEncoderStream = class SmithyMessageEncoderStream {
12995
+ options;
12996
+ constructor(options) {
12997
+ this.options = options;
12998
+ }
12999
+ [Symbol.asyncIterator]() {
13000
+ return this.asyncIterator();
13001
+ }
13002
+ async* asyncIterator() {
13003
+ for await (const chunk of this.options.inputStream) {
13004
+ const payloadBuf = this.options.serializer(chunk);
13005
+ yield payloadBuf;
13006
+ }
13007
+ }
13008
+ };
12771
13009
  $EventStreamCodec = EventStreamCodec;
12772
13010
  });
12773
13011
 
12774
13012
  // node_modules/@smithy/is-array-buffer/dist-cjs/index.js
12775
- var require_dist_cjs5 = __commonJS((exports) => {
13013
+ var require_dist_cjs5 = __commonJS(function(exports) {
12776
13014
  var isArrayBuffer = (arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
12777
13015
  exports.isArrayBuffer = isArrayBuffer;
12778
13016
  });
12779
13017
 
12780
13018
  // node_modules/@smithy/util-buffer-from/dist-cjs/index.js
12781
- var require_dist_cjs6 = __commonJS((exports) => {
13019
+ var require_dist_cjs6 = __commonJS(function(exports) {
12782
13020
  var isArrayBuffer = require_dist_cjs5();
12783
13021
  var buffer = __require("buffer");
12784
13022
  var fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
@@ -15496,10 +15734,10 @@ function convertOpenAIResponsesUsage(usage) {
15496
15734
  function serializeToolCallArguments2(input) {
15497
15735
  return JSON.stringify(input === undefined ? {} : input);
15498
15736
  }
15499
- function isFileId(data, prefixes) {
15500
- if (!prefixes)
15737
+ function isFileId(data, prefixes2) {
15738
+ if (!prefixes2)
15501
15739
  return false;
15502
- return prefixes.some((prefix) => data.startsWith(prefix));
15740
+ return prefixes2.some((prefix) => data.startsWith(prefix));
15503
15741
  }
15504
15742
  async function convertToOpenAIResponsesInput({
15505
15743
  prompt,
@@ -21593,8 +21831,8 @@ function mapAnthropicStopReason({
21593
21831
  return "other";
21594
21832
  }
21595
21833
  }
21596
- function sanitizeJsonSchema(schema) {
21597
- return sanitizeSchema(schema);
21834
+ function sanitizeJsonSchema(schema2) {
21835
+ return sanitizeSchema(schema2);
21598
21836
  }
21599
21837
  function sanitizeDefinition(definition) {
21600
21838
  if (typeof definition === "boolean" || !isPlainObject(definition)) {
@@ -21602,46 +21840,46 @@ function sanitizeDefinition(definition) {
21602
21840
  }
21603
21841
  return sanitizeSchema(definition);
21604
21842
  }
21605
- function sanitizeSchema(schema) {
21843
+ function sanitizeSchema(schema2) {
21606
21844
  const result = {};
21607
- const schemaWithDefs = schema;
21608
- if (schema.$ref != null) {
21609
- return { $ref: schema.$ref };
21845
+ const schemaWithDefs = schema2;
21846
+ if (schema2.$ref != null) {
21847
+ return { $ref: schema2.$ref };
21610
21848
  }
21611
- if (schema.$schema != null) {
21612
- result.$schema = schema.$schema;
21849
+ if (schema2.$schema != null) {
21850
+ result.$schema = schema2.$schema;
21613
21851
  }
21614
- if (schema.$id != null) {
21615
- result.$id = schema.$id;
21852
+ if (schema2.$id != null) {
21853
+ result.$id = schema2.$id;
21616
21854
  }
21617
- if (schema.title != null) {
21618
- result.title = schema.title;
21855
+ if (schema2.title != null) {
21856
+ result.title = schema2.title;
21619
21857
  }
21620
- if (schema.description != null) {
21621
- result.description = schema.description;
21858
+ if (schema2.description != null) {
21859
+ result.description = schema2.description;
21622
21860
  }
21623
- if (schema.default !== undefined) {
21624
- result.default = schema.default;
21861
+ if (schema2.default !== undefined) {
21862
+ result.default = schema2.default;
21625
21863
  }
21626
- if (schema.const !== undefined) {
21627
- result.const = schema.const;
21864
+ if (schema2.const !== undefined) {
21865
+ result.const = schema2.const;
21628
21866
  }
21629
- if (schema.enum != null) {
21630
- result.enum = schema.enum;
21867
+ if (schema2.enum != null) {
21868
+ result.enum = schema2.enum;
21631
21869
  }
21632
- if (schema.type != null) {
21633
- result.type = schema.type;
21870
+ if (schema2.type != null) {
21871
+ result.type = schema2.type;
21634
21872
  }
21635
- if (schema.anyOf != null) {
21636
- result.anyOf = schema.anyOf.map(sanitizeDefinition);
21637
- } else if (schema.oneOf != null) {
21638
- result.anyOf = schema.oneOf.map(sanitizeDefinition);
21873
+ if (schema2.anyOf != null) {
21874
+ result.anyOf = schema2.anyOf.map(sanitizeDefinition);
21875
+ } else if (schema2.oneOf != null) {
21876
+ result.anyOf = schema2.oneOf.map(sanitizeDefinition);
21639
21877
  }
21640
- if (schema.allOf != null) {
21641
- result.allOf = schema.allOf.map(sanitizeDefinition);
21878
+ if (schema2.allOf != null) {
21879
+ result.allOf = schema2.allOf.map(sanitizeDefinition);
21642
21880
  }
21643
- if (schema.definitions != null) {
21644
- result.definitions = Object.fromEntries(Object.entries(schema.definitions).map(([name22, definition]) => [
21881
+ if (schema2.definitions != null) {
21882
+ result.definitions = Object.fromEntries(Object.entries(schema2.definitions).map(([name22, definition]) => [
21645
21883
  name22,
21646
21884
  sanitizeDefinition(definition)
21647
21885
  ]));
@@ -21653,41 +21891,41 @@ function sanitizeSchema(schema) {
21653
21891
  sanitizeDefinition(definition)
21654
21892
  ]));
21655
21893
  }
21656
- if (schema.type === "object" || schema.properties != null) {
21657
- if (schema.properties != null) {
21658
- result.properties = Object.fromEntries(Object.entries(schema.properties).map(([name22, definition]) => [
21894
+ if (schema2.type === "object" || schema2.properties != null) {
21895
+ if (schema2.properties != null) {
21896
+ result.properties = Object.fromEntries(Object.entries(schema2.properties).map(([name22, definition]) => [
21659
21897
  name22,
21660
21898
  sanitizeDefinition(definition)
21661
21899
  ]));
21662
21900
  }
21663
21901
  result.additionalProperties = false;
21664
- if (schema.required != null) {
21665
- result.required = schema.required;
21902
+ if (schema2.required != null) {
21903
+ result.required = schema2.required;
21666
21904
  }
21667
21905
  }
21668
- if (schema.items != null) {
21669
- result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
21906
+ if (schema2.items != null) {
21907
+ result.items = Array.isArray(schema2.items) ? schema2.items.map(sanitizeDefinition) : sanitizeDefinition(schema2.items);
21670
21908
  }
21671
- if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
21672
- result.format = schema.format;
21909
+ if (typeof schema2.format === "string" && SUPPORTED_STRING_FORMATS.has(schema2.format)) {
21910
+ result.format = schema2.format;
21673
21911
  }
21674
- const constraintDescription = getConstraintDescription(schema);
21912
+ const constraintDescription = getConstraintDescription(schema2);
21675
21913
  if (constraintDescription != null) {
21676
21914
  result.description = result.description == null ? constraintDescription : `${result.description}
21677
21915
  ${constraintDescription}`;
21678
21916
  }
21679
21917
  return result;
21680
21918
  }
21681
- function getConstraintDescription(schema) {
21919
+ function getConstraintDescription(schema2) {
21682
21920
  const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
21683
- const value = schema[key];
21921
+ const value = schema2[key];
21684
21922
  if (value == null || value === false) {
21685
21923
  return [];
21686
21924
  }
21687
21925
  return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
21688
21926
  });
21689
- if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
21690
- descriptions.push(`format: ${schema.format}`);
21927
+ if (typeof schema2.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema2.format)) {
21928
+ descriptions.push(`format: ${schema2.format}`);
21691
21929
  }
21692
21930
  return descriptions.length === 0 ? undefined : `${descriptions.join("; ")}.`;
21693
21931
  }
@@ -25380,8 +25618,8 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema2, isRoot = true) {
25380
25618
  result.allOf = allOf.map((item) => convertJSONSchemaToOpenAPISchema(item, false));
25381
25619
  }
25382
25620
  if (anyOf) {
25383
- if (anyOf.some((schema) => typeof schema === "object" && (schema == null ? undefined : schema.type) === "null")) {
25384
- const nonNullSchemas = anyOf.filter((schema) => !(typeof schema === "object" && (schema == null ? undefined : schema.type) === "null"));
25621
+ if (anyOf.some((schema2) => typeof schema2 === "object" && (schema2 == null ? undefined : schema2.type) === "null")) {
25622
+ const nonNullSchemas = anyOf.filter((schema2) => !(typeof schema2 === "object" && (schema2 == null ? undefined : schema2.type) === "null"));
25385
25623
  if (nonNullSchemas.length === 1) {
25386
25624
  const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0], false);
25387
25625
  if (typeof converted === "object") {
@@ -31599,13 +31837,13 @@ function parseIntersectionDef(def, refs) {
31599
31837
  })
31600
31838
  ].filter((x) => !!x);
31601
31839
  const mergedAllOf = [];
31602
- allOf.forEach((schema) => {
31603
- if (isJsonSchema7AllOfType(schema)) {
31604
- mergedAllOf.push(...schema.allOf);
31840
+ allOf.forEach((schema2) => {
31841
+ if (isJsonSchema7AllOfType(schema2)) {
31842
+ mergedAllOf.push(...schema2.allOf);
31605
31843
  } else {
31606
- let nestedSchema = schema;
31607
- if ("additionalProperties" in schema && schema.additionalProperties === false) {
31608
- const { additionalProperties, ...rest } = schema;
31844
+ let nestedSchema = schema2;
31845
+ if ("additionalProperties" in schema2 && schema2.additionalProperties === false) {
31846
+ const { additionalProperties, ...rest } = schema2;
31609
31847
  nestedSchema = rest;
31610
31848
  }
31611
31849
  mergedAllOf.push(nestedSchema);
@@ -31766,44 +32004,44 @@ function escapeNonAlphaNumeric(source) {
31766
32004
  }
31767
32005
  return result;
31768
32006
  }
31769
- function addFormat(schema, value, message, refs) {
32007
+ function addFormat(schema2, value, message, refs) {
31770
32008
  var _a25;
31771
- if (schema.format || ((_a25 = schema.anyOf) == null ? undefined : _a25.some((x) => x.format))) {
31772
- if (!schema.anyOf) {
31773
- schema.anyOf = [];
32009
+ if (schema2.format || ((_a25 = schema2.anyOf) == null ? undefined : _a25.some((x) => x.format))) {
32010
+ if (!schema2.anyOf) {
32011
+ schema2.anyOf = [];
31774
32012
  }
31775
- if (schema.format) {
31776
- schema.anyOf.push({
31777
- format: schema.format
32013
+ if (schema2.format) {
32014
+ schema2.anyOf.push({
32015
+ format: schema2.format
31778
32016
  });
31779
- delete schema.format;
32017
+ delete schema2.format;
31780
32018
  }
31781
- schema.anyOf.push({
32019
+ schema2.anyOf.push({
31782
32020
  format: value,
31783
32021
  ...message && refs.errorMessages && { errorMessage: { format: message } }
31784
32022
  });
31785
32023
  } else {
31786
- schema.format = value;
32024
+ schema2.format = value;
31787
32025
  }
31788
32026
  }
31789
- function addPattern(schema, regex, message, refs) {
32027
+ function addPattern(schema2, regex, message, refs) {
31790
32028
  var _a25;
31791
- if (schema.pattern || ((_a25 = schema.allOf) == null ? undefined : _a25.some((x) => x.pattern))) {
31792
- if (!schema.allOf) {
31793
- schema.allOf = [];
32029
+ if (schema2.pattern || ((_a25 = schema2.allOf) == null ? undefined : _a25.some((x) => x.pattern))) {
32030
+ if (!schema2.allOf) {
32031
+ schema2.allOf = [];
31794
32032
  }
31795
- if (schema.pattern) {
31796
- schema.allOf.push({
31797
- pattern: schema.pattern
32033
+ if (schema2.pattern) {
32034
+ schema2.allOf.push({
32035
+ pattern: schema2.pattern
31798
32036
  });
31799
- delete schema.pattern;
32037
+ delete schema2.pattern;
31800
32038
  }
31801
- schema.allOf.push({
32039
+ schema2.allOf.push({
31802
32040
  pattern: stringifyRegExpWithFlags(regex, refs),
31803
32041
  ...message && refs.errorMessages && { errorMessage: { pattern: message } }
31804
32042
  });
31805
32043
  } else {
31806
- schema.pattern = stringifyRegExpWithFlags(regex, refs);
32044
+ schema2.pattern = stringifyRegExpWithFlags(regex, refs);
31807
32045
  }
31808
32046
  }
31809
32047
  function stringifyRegExpWithFlags(regex, refs) {
@@ -31883,7 +32121,7 @@ function stringifyRegExpWithFlags(regex, refs) {
31883
32121
  }
31884
32122
  function parseRecordDef(def, refs) {
31885
32123
  var _a25, _b22, _c, _d, _e, _f;
31886
- const schema = {
32124
+ const schema2 = {
31887
32125
  type: "object",
31888
32126
  additionalProperties: (_a25 = parseDef(def.valueType._def, {
31889
32127
  ...refs,
@@ -31893,12 +32131,12 @@ function parseRecordDef(def, refs) {
31893
32131
  if (((_b22 = def.keyType) == null ? undefined : _b22._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
31894
32132
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
31895
32133
  return {
31896
- ...schema,
32134
+ ...schema2,
31897
32135
  propertyNames: keyType
31898
32136
  };
31899
32137
  } else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
31900
32138
  return {
31901
- ...schema,
32139
+ ...schema2,
31902
32140
  propertyNames: {
31903
32141
  enum: def.keyType._def.values
31904
32142
  }
@@ -31906,11 +32144,11 @@ function parseRecordDef(def, refs) {
31906
32144
  } else if (((_e = def.keyType) == null ? undefined : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? undefined : _f.length)) {
31907
32145
  const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
31908
32146
  return {
31909
- ...schema,
32147
+ ...schema2,
31910
32148
  propertyNames: keyType
31911
32149
  };
31912
32150
  }
31913
- return schema;
32151
+ return schema2;
31914
32152
  }
31915
32153
  function parseMapDef(def, refs) {
31916
32154
  if (refs.mapStrategy === "record") {
@@ -32103,9 +32341,9 @@ function decideAdditionalProperties(def, refs) {
32103
32341
  return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
32104
32342
  }
32105
32343
  }
32106
- function safeIsOptional(schema) {
32344
+ function safeIsOptional(schema2) {
32107
32345
  try {
32108
- return schema.isOptional();
32346
+ return schema2.isOptional();
32109
32347
  } catch (e) {
32110
32348
  return true;
32111
32349
  }
@@ -32118,18 +32356,18 @@ function parseSetDef(def, refs) {
32118
32356
  ...refs,
32119
32357
  currentPath: [...refs.currentPath, "items"]
32120
32358
  });
32121
- const schema = {
32359
+ const schema2 = {
32122
32360
  type: "array",
32123
32361
  uniqueItems: true,
32124
32362
  items
32125
32363
  };
32126
32364
  if (def.minSize) {
32127
- schema.minItems = def.minSize.value;
32365
+ schema2.minItems = def.minSize.value;
32128
32366
  }
32129
32367
  if (def.maxSize) {
32130
- schema.maxItems = def.maxSize.value;
32368
+ schema2.maxItems = def.maxSize.value;
32131
32369
  }
32132
- return schema;
32370
+ return schema2;
32133
32371
  }
32134
32372
  function parseTupleDef(def, refs) {
32135
32373
  if (def.rest) {
@@ -32196,12 +32434,12 @@ function parseDef(def, refs, forceResolution = false) {
32196
32434
  return jsonSchema2;
32197
32435
  }
32198
32436
  function lazySchema2(createSchema) {
32199
- let schema;
32437
+ let schema2;
32200
32438
  return () => {
32201
- if (schema == null) {
32202
- schema = createSchema();
32439
+ if (schema2 == null) {
32440
+ schema2 = createSchema();
32203
32441
  }
32204
- return schema;
32442
+ return schema2;
32205
32443
  };
32206
32444
  }
32207
32445
  function jsonSchema2(jsonSchema22, {
@@ -32222,8 +32460,8 @@ function jsonSchema2(jsonSchema22, {
32222
32460
  function isSchema(value) {
32223
32461
  return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
32224
32462
  }
32225
- function asSchema2(schema) {
32226
- return schema == null ? jsonSchema2({ properties: {}, additionalProperties: false }) : isSchema(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema2(schema) : standardSchema(schema) : schema();
32463
+ function asSchema2(schema2) {
32464
+ return schema2 == null ? jsonSchema2({ properties: {}, additionalProperties: false }) : isSchema(schema2) ? schema2 : ("~standard" in schema2) ? schema2["~standard"].vendor === "zod" ? zodSchema2(schema2) : standardSchema(schema2) : schema2();
32227
32465
  }
32228
32466
  function standardSchema(standardSchema2) {
32229
32467
  return jsonSchema2(() => addAdditionalPropertiesToJsonSchema(standardSchema2["~standard"].jsonSchema.input({
@@ -32279,10 +32517,10 @@ function zodSchema2(zodSchema22, options) {
32279
32517
  }
32280
32518
  async function validateTypes2({
32281
32519
  value,
32282
- schema,
32520
+ schema: schema2,
32283
32521
  context: context2
32284
32522
  }) {
32285
- const result = await safeValidateTypes2({ value, schema, context: context2 });
32523
+ const result = await safeValidateTypes2({ value, schema: schema2, context: context2 });
32286
32524
  if (!result.success) {
32287
32525
  throw TypeValidationError2.wrap({ value, cause: result.error, context: context2 });
32288
32526
  }
@@ -32290,10 +32528,10 @@ async function validateTypes2({
32290
32528
  }
32291
32529
  async function safeValidateTypes2({
32292
32530
  value,
32293
- schema,
32531
+ schema: schema2,
32294
32532
  context: context2
32295
32533
  }) {
32296
- const actualSchema = asSchema2(schema);
32534
+ const actualSchema = asSchema2(schema2);
32297
32535
  try {
32298
32536
  if (actualSchema.validate == null) {
32299
32537
  return { success: true, value, rawValue: value };
@@ -32317,14 +32555,14 @@ async function safeValidateTypes2({
32317
32555
  }
32318
32556
  async function parseJSON2({
32319
32557
  text: text2,
32320
- schema
32558
+ schema: schema2
32321
32559
  }) {
32322
32560
  try {
32323
32561
  const value = secureJsonParse(text2);
32324
- if (schema == null) {
32562
+ if (schema2 == null) {
32325
32563
  return value;
32326
32564
  }
32327
- return validateTypes2({ value, schema });
32565
+ return validateTypes2({ value, schema: schema2 });
32328
32566
  } catch (error) {
32329
32567
  if (JSONParseError.isInstance(error) || TypeValidationError2.isInstance(error)) {
32330
32568
  throw error;
@@ -32334,14 +32572,14 @@ async function parseJSON2({
32334
32572
  }
32335
32573
  async function safeParseJSON2({
32336
32574
  text: text2,
32337
- schema
32575
+ schema: schema2
32338
32576
  }) {
32339
32577
  try {
32340
32578
  const value = secureJsonParse(text2);
32341
- if (schema == null) {
32579
+ if (schema2 == null) {
32342
32580
  return { success: true, value, rawValue: value };
32343
32581
  }
32344
- return await safeValidateTypes2({ value, schema });
32582
+ return await safeValidateTypes2({ value, schema: schema2 });
32345
32583
  } catch (error) {
32346
32584
  return {
32347
32585
  success: false,
@@ -32360,28 +32598,28 @@ function isParsableJson2(input) {
32360
32598
  }
32361
32599
  function parseJsonEventStream2({
32362
32600
  stream,
32363
- schema
32601
+ schema: schema2
32364
32602
  }) {
32365
32603
  return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream).pipeThrough(new TransformStream({
32366
32604
  async transform({ data }, controller) {
32367
32605
  if (data === "[DONE]") {
32368
32606
  return;
32369
32607
  }
32370
- controller.enqueue(await safeParseJSON2({ text: data, schema }));
32608
+ controller.enqueue(await safeParseJSON2({ text: data, schema: schema2 }));
32371
32609
  }
32372
32610
  }));
32373
32611
  }
32374
32612
  async function parseProviderOptions2({
32375
32613
  provider,
32376
32614
  providerOptions,
32377
- schema
32615
+ schema: schema2
32378
32616
  }) {
32379
32617
  if ((providerOptions == null ? undefined : providerOptions[provider]) == null) {
32380
32618
  return;
32381
32619
  }
32382
32620
  const parsedProviderOptions = await safeValidateTypes2({
32383
32621
  value: providerOptions[provider],
32384
- schema
32622
+ schema: schema2
32385
32623
  });
32386
32624
  if (!parsedProviderOptions.success) {
32387
32625
  throw new InvalidArgumentError3({
@@ -32659,21 +32897,21 @@ var btoa, atob, name24 = "AI_DownloadError", marker24, symbol24, _a24, _b15, Dow
32659
32897
  }
32660
32898
  ]))
32661
32899
  };
32662
- }, zod3ToJsonSchema = (schema, options) => {
32900
+ }, zod3ToJsonSchema = (schema2, options) => {
32663
32901
  var _a25;
32664
32902
  const refs = getRefs(options);
32665
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name33, schema2]) => {
32903
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name33, schema22]) => {
32666
32904
  var _a33;
32667
32905
  return {
32668
32906
  ...acc,
32669
- [name33]: (_a33 = parseDef(schema2._def, {
32907
+ [name33]: (_a33 = parseDef(schema22._def, {
32670
32908
  ...refs,
32671
32909
  currentPath: [...refs.basePath, refs.definitionPath, name33]
32672
32910
  }, true)) != null ? _a33 : parseAnyDef()
32673
32911
  };
32674
32912
  }, {}) : undefined;
32675
32913
  const name25 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
32676
- const main = (_a25 = parseDef(schema._def, name25 === undefined ? refs : {
32914
+ const main = (_a25 = parseDef(schema2._def, name25 === undefined ? refs : {
32677
32915
  ...refs,
32678
32916
  currentPath: [...refs.basePath, refs.definitionPath, name25]
32679
32917
  }, false)) != null ? _a25 : parseAnyDef();
@@ -33539,10 +33777,10 @@ function convertOpenAIResponsesUsage2(usage) {
33539
33777
  raw: usage
33540
33778
  };
33541
33779
  }
33542
- function isFileId2(data, prefixes) {
33543
- if (!prefixes)
33780
+ function isFileId2(data, prefixes2) {
33781
+ if (!prefixes2)
33544
33782
  return false;
33545
- return prefixes.some((prefix) => data.startsWith(prefix));
33783
+ return prefixes2.some((prefix) => data.startsWith(prefix));
33546
33784
  }
33547
33785
  async function convertToOpenAIResponsesInput2({
33548
33786
  prompt,
@@ -40803,13 +41041,13 @@ function parseIntersectionDef2(def, refs) {
40803
41041
  }))
40804
41042
  ].filter((x) => !!x);
40805
41043
  const mergedAllOf = [];
40806
- allOf.forEach((schema) => {
40807
- if (isJsonSchema7AllOfType2(schema)) {
40808
- mergedAllOf.push(...schema.allOf);
41044
+ allOf.forEach((schema2) => {
41045
+ if (isJsonSchema7AllOfType2(schema2)) {
41046
+ mergedAllOf.push(...schema2.allOf);
40809
41047
  } else {
40810
- let nestedSchema = schema;
40811
- if ("additionalProperties" in schema && schema.additionalProperties === false) {
40812
- const _a162 = schema, { additionalProperties } = _a162, rest = __objRest(_a162, ["additionalProperties"]);
41048
+ let nestedSchema = schema2;
41049
+ if ("additionalProperties" in schema2 && schema2.additionalProperties === false) {
41050
+ const _a162 = schema2, { additionalProperties } = _a162, rest = __objRest(_a162, ["additionalProperties"]);
40813
41051
  nestedSchema = rest;
40814
41052
  }
40815
41053
  mergedAllOf.push(nestedSchema);
@@ -40970,42 +41208,42 @@ function escapeNonAlphaNumeric2(source) {
40970
41208
  }
40971
41209
  return result;
40972
41210
  }
40973
- function addFormat2(schema, value, message, refs) {
41211
+ function addFormat2(schema2, value, message, refs) {
40974
41212
  var _a222;
40975
- if (schema.format || ((_a222 = schema.anyOf) == null ? undefined : _a222.some((x) => x.format))) {
40976
- if (!schema.anyOf) {
40977
- schema.anyOf = [];
41213
+ if (schema2.format || ((_a222 = schema2.anyOf) == null ? undefined : _a222.some((x) => x.format))) {
41214
+ if (!schema2.anyOf) {
41215
+ schema2.anyOf = [];
40978
41216
  }
40979
- if (schema.format) {
40980
- schema.anyOf.push({
40981
- format: schema.format
41217
+ if (schema2.format) {
41218
+ schema2.anyOf.push({
41219
+ format: schema2.format
40982
41220
  });
40983
- delete schema.format;
41221
+ delete schema2.format;
40984
41222
  }
40985
- schema.anyOf.push(__spreadValues({
41223
+ schema2.anyOf.push(__spreadValues({
40986
41224
  format: value
40987
41225
  }, message && refs.errorMessages && { errorMessage: { format: message } }));
40988
41226
  } else {
40989
- schema.format = value;
41227
+ schema2.format = value;
40990
41228
  }
40991
41229
  }
40992
- function addPattern2(schema, regex, message, refs) {
41230
+ function addPattern2(schema2, regex, message, refs) {
40993
41231
  var _a222;
40994
- if (schema.pattern || ((_a222 = schema.allOf) == null ? undefined : _a222.some((x) => x.pattern))) {
40995
- if (!schema.allOf) {
40996
- schema.allOf = [];
41232
+ if (schema2.pattern || ((_a222 = schema2.allOf) == null ? undefined : _a222.some((x) => x.pattern))) {
41233
+ if (!schema2.allOf) {
41234
+ schema2.allOf = [];
40997
41235
  }
40998
- if (schema.pattern) {
40999
- schema.allOf.push({
41000
- pattern: schema.pattern
41236
+ if (schema2.pattern) {
41237
+ schema2.allOf.push({
41238
+ pattern: schema2.pattern
41001
41239
  });
41002
- delete schema.pattern;
41240
+ delete schema2.pattern;
41003
41241
  }
41004
- schema.allOf.push(__spreadValues({
41242
+ schema2.allOf.push(__spreadValues({
41005
41243
  pattern: stringifyRegExpWithFlags2(regex, refs)
41006
41244
  }, message && refs.errorMessages && { errorMessage: { pattern: message } }));
41007
41245
  } else {
41008
- schema.pattern = stringifyRegExpWithFlags2(regex, refs);
41246
+ schema2.pattern = stringifyRegExpWithFlags2(regex, refs);
41009
41247
  }
41010
41248
  }
41011
41249
  function stringifyRegExpWithFlags2(regex, refs) {
@@ -41085,7 +41323,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
41085
41323
  }
41086
41324
  function parseRecordDef2(def, refs) {
41087
41325
  var _a222, _b222, _c, _d, _e, _f;
41088
- const schema = {
41326
+ const schema2 = {
41089
41327
  type: "object",
41090
41328
  additionalProperties: (_a222 = parseDef2(def.valueType._def, __spreadProps(__spreadValues({}, refs), {
41091
41329
  currentPath: [...refs.currentPath, "additionalProperties"]
@@ -41093,22 +41331,22 @@ function parseRecordDef2(def, refs) {
41093
41331
  };
41094
41332
  if (((_b222 = def.keyType) == null ? undefined : _b222._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
41095
41333
  const _a162 = parseStringDef2(def.keyType._def, refs), { type } = _a162, keyType = __objRest(_a162, ["type"]);
41096
- return __spreadProps(__spreadValues({}, schema), {
41334
+ return __spreadProps(__spreadValues({}, schema2), {
41097
41335
  propertyNames: keyType
41098
41336
  });
41099
41337
  } else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
41100
- return __spreadProps(__spreadValues({}, schema), {
41338
+ return __spreadProps(__spreadValues({}, schema2), {
41101
41339
  propertyNames: {
41102
41340
  enum: def.keyType._def.values
41103
41341
  }
41104
41342
  });
41105
41343
  } else if (((_e = def.keyType) == null ? undefined : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? undefined : _f.length)) {
41106
41344
  const _b16 = parseBrandedDef2(def.keyType._def, refs), { type } = _b16, keyType = __objRest(_b16, ["type"]);
41107
- return __spreadProps(__spreadValues({}, schema), {
41345
+ return __spreadProps(__spreadValues({}, schema2), {
41108
41346
  propertyNames: keyType
41109
41347
  });
41110
41348
  }
41111
- return schema;
41349
+ return schema2;
41112
41350
  }
41113
41351
  function parseMapDef2(def, refs) {
41114
41352
  if (refs.mapStrategy === "record") {
@@ -41296,9 +41534,9 @@ function decideAdditionalProperties2(def, refs) {
41296
41534
  return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
41297
41535
  }
41298
41536
  }
41299
- function safeIsOptional2(schema) {
41537
+ function safeIsOptional2(schema2) {
41300
41538
  try {
41301
- return schema.isOptional();
41539
+ return schema2.isOptional();
41302
41540
  } catch (e) {
41303
41541
  return true;
41304
41542
  }
@@ -41310,18 +41548,18 @@ function parseSetDef2(def, refs) {
41310
41548
  const items = parseDef2(def.valueType._def, __spreadProps(__spreadValues({}, refs), {
41311
41549
  currentPath: [...refs.currentPath, "items"]
41312
41550
  }));
41313
- const schema = {
41551
+ const schema2 = {
41314
41552
  type: "array",
41315
41553
  uniqueItems: true,
41316
41554
  items
41317
41555
  };
41318
41556
  if (def.minSize) {
41319
- schema.minItems = def.minSize.value;
41557
+ schema2.minItems = def.minSize.value;
41320
41558
  }
41321
41559
  if (def.maxSize) {
41322
- schema.maxItems = def.maxSize.value;
41560
+ schema2.maxItems = def.maxSize.value;
41323
41561
  }
41324
- return schema;
41562
+ return schema2;
41325
41563
  }
41326
41564
  function parseTupleDef2(def, refs) {
41327
41565
  if (def.rest) {
@@ -41402,8 +41640,8 @@ function jsonSchema3(jsonSchema22, {
41402
41640
  function isSchema2(value) {
41403
41641
  return typeof value === "object" && value !== null && schemaSymbol2 in value && value[schemaSymbol2] === true && "jsonSchema" in value && "validate" in value;
41404
41642
  }
41405
- function asSchema3(schema) {
41406
- return schema == null ? jsonSchema3({ properties: {}, additionalProperties: false }) : isSchema2(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema3(schema) : standardSchema2(schema) : schema();
41643
+ function asSchema3(schema2) {
41644
+ return schema2 == null ? jsonSchema3({ properties: {}, additionalProperties: false }) : isSchema2(schema2) ? schema2 : ("~standard" in schema2) ? schema2["~standard"].vendor === "zod" ? zodSchema3(schema2) : standardSchema2(schema2) : schema2();
41407
41645
  }
41408
41646
  function standardSchema2(standardSchema22) {
41409
41647
  return jsonSchema3(() => addAdditionalPropertiesToJsonSchema2(standardSchema22["~standard"].jsonSchema.input({
@@ -41459,10 +41697,10 @@ function zodSchema3(zodSchema22, options) {
41459
41697
  }
41460
41698
  async function validateTypes3({
41461
41699
  value,
41462
- schema,
41700
+ schema: schema2,
41463
41701
  context: context2
41464
41702
  }) {
41465
- const result = await safeValidateTypes3({ value, schema, context: context2 });
41703
+ const result = await safeValidateTypes3({ value, schema: schema2, context: context2 });
41466
41704
  if (!result.success) {
41467
41705
  throw TypeValidationError3.wrap({ value, cause: result.error, context: context2 });
41468
41706
  }
@@ -41470,10 +41708,10 @@ async function validateTypes3({
41470
41708
  }
41471
41709
  async function safeValidateTypes3({
41472
41710
  value,
41473
- schema,
41711
+ schema: schema2,
41474
41712
  context: context2
41475
41713
  }) {
41476
- const actualSchema = asSchema3(schema);
41714
+ const actualSchema = asSchema3(schema2);
41477
41715
  try {
41478
41716
  if (actualSchema.validate == null) {
41479
41717
  return { success: true, value, rawValue: value };
@@ -41497,14 +41735,14 @@ async function safeValidateTypes3({
41497
41735
  }
41498
41736
  async function parseJSON3({
41499
41737
  text: text2,
41500
- schema
41738
+ schema: schema2
41501
41739
  }) {
41502
41740
  try {
41503
41741
  const value = secureJsonParse2(text2);
41504
- if (schema == null) {
41742
+ if (schema2 == null) {
41505
41743
  return value;
41506
41744
  }
41507
- return validateTypes3({ value, schema });
41745
+ return validateTypes3({ value, schema: schema2 });
41508
41746
  } catch (error) {
41509
41747
  if (JSONParseError2.isInstance(error) || TypeValidationError3.isInstance(error)) {
41510
41748
  throw error;
@@ -41514,14 +41752,14 @@ async function parseJSON3({
41514
41752
  }
41515
41753
  async function safeParseJSON3({
41516
41754
  text: text2,
41517
- schema
41755
+ schema: schema2
41518
41756
  }) {
41519
41757
  try {
41520
41758
  const value = secureJsonParse2(text2);
41521
- if (schema == null) {
41759
+ if (schema2 == null) {
41522
41760
  return { success: true, value, rawValue: value };
41523
41761
  }
41524
- return await safeValidateTypes3({ value, schema });
41762
+ return await safeValidateTypes3({ value, schema: schema2 });
41525
41763
  } catch (error) {
41526
41764
  return {
41527
41765
  success: false,
@@ -41540,14 +41778,14 @@ function isParsableJson3(input) {
41540
41778
  }
41541
41779
  function parseJsonEventStream3({
41542
41780
  stream,
41543
- schema
41781
+ schema: schema2
41544
41782
  }) {
41545
41783
  return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream2).pipeThrough(new TransformStream({
41546
41784
  async transform({ data }, controller) {
41547
41785
  if (data === "[DONE]") {
41548
41786
  return;
41549
41787
  }
41550
- controller.enqueue(await safeParseJSON3({ text: data, schema }));
41788
+ controller.enqueue(await safeParseJSON3({ text: data, schema: schema2 }));
41551
41789
  }
41552
41790
  }));
41553
41791
  }
@@ -42757,19 +42995,19 @@ var __defProp2, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
42757
42995
  }
42758
42996
  ]))
42759
42997
  });
42760
- }, zod3ToJsonSchema2 = (schema, options) => {
42998
+ }, zod3ToJsonSchema2 = (schema2, options) => {
42761
42999
  var _a222;
42762
43000
  const refs = getRefs2(options);
42763
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name322, schema2]) => {
43001
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name322, schema22]) => {
42764
43002
  var _a322;
42765
43003
  return __spreadProps(__spreadValues({}, acc), {
42766
- [name322]: (_a322 = parseDef2(schema2._def, __spreadProps(__spreadValues({}, refs), {
43004
+ [name322]: (_a322 = parseDef2(schema22._def, __spreadProps(__spreadValues({}, refs), {
42767
43005
  currentPath: [...refs.basePath, refs.definitionPath, name322]
42768
43006
  }), true)) != null ? _a322 : parseAnyDef2()
42769
43007
  });
42770
43008
  }, {}) : undefined;
42771
43009
  const name222 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
42772
- const main = (_a222 = parseDef2(schema._def, name222 === undefined ? refs : __spreadProps(__spreadValues({}, refs), {
43010
+ const main = (_a222 = parseDef2(schema2._def, name222 === undefined ? refs : __spreadProps(__spreadValues({}, refs), {
42773
43011
  currentPath: [...refs.basePath, refs.definitionPath, name222]
42774
43012
  }), false)) != null ? _a222 : parseAnyDef2();
42775
43013
  const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
@@ -45144,60 +45382,29 @@ Error message: ${getErrorMessage4(cause)}`,
45144
45382
  });
45145
45383
  });
45146
45384
 
45147
- // src/core/id/id.ts
45148
- import { randomBytes } from "node:crypto";
45149
- function schema(prefix) {
45150
- return zod_default.string().startsWith(prefixes[prefix]);
45151
- }
45152
- function descending(prefix, given) {
45153
- return generateID(prefix, true, given);
45154
- }
45155
- function generateID(prefix, descending2, given) {
45156
- if (!given) {
45157
- return create(prefix, descending2);
45158
- }
45159
- if (!given.startsWith(prefixes[prefix])) {
45160
- throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`);
45161
- }
45162
- return given;
45163
- }
45164
- function randomBase62(length) {
45165
- const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
45166
- let result = "";
45167
- const bytes = randomBytes(length);
45168
- for (let i = 0;i < length; i++) {
45169
- result += chars[bytes[i] % 62];
45170
- }
45171
- return result;
45172
- }
45173
- function create(prefix, descending2, timestamp) {
45174
- const currentTimestamp = timestamp ?? Date.now();
45175
- if (currentTimestamp !== lastTimestamp) {
45176
- lastTimestamp = currentTimestamp;
45177
- counter = 0;
45178
- }
45179
- counter++;
45180
- let now2 = BigInt(currentTimestamp) * BigInt(4096) + BigInt(counter);
45181
- now2 = descending2 ? ~now2 : now2;
45182
- const timeBytes = Buffer.alloc(6);
45183
- for (let i = 0;i < 6; i++) {
45184
- timeBytes[i] = Number(now2 >> BigInt(40 - 8 * i) & BigInt(255));
45185
- }
45186
- return prefixes[prefix] + "_" + timeBytes.toString("hex") + randomBase62(LENGTH - 12);
45187
- }
45188
- var prefixes, LENGTH = 26, lastTimestamp = 0, counter = 0, newSessionId = () => descending("session"), newMessageId = () => descending("message"), newPartId = () => descending("part"), isSessionId = (s) => s.startsWith(`${prefixes.session}_`);
45189
- var init_id = __esm(() => {
45190
- init_zod();
45191
- prefixes = {
45192
- session: "ses",
45193
- message: "msg",
45194
- permission: "per",
45195
- user: "usr",
45196
- part: "prt"
45385
+ // src/core/observability/telemetry.ts
45386
+ function createAiTelemetrySettings(input) {
45387
+ const recordPayloads = shouldRecordAiPayloads();
45388
+ const metadata = {};
45389
+ if (input.sessionId)
45390
+ metadata.sessionId = input.sessionId;
45391
+ if (input.runId)
45392
+ metadata.runId = input.runId;
45393
+ if (input.agentId)
45394
+ metadata.agentId = input.agentId;
45395
+ return {
45396
+ isEnabled: true,
45397
+ recordInputs: recordPayloads,
45398
+ recordOutputs: recordPayloads,
45399
+ functionId: input.operation,
45400
+ ...Object.keys(metadata).length > 0 ? { metadata } : {}
45197
45401
  };
45402
+ }
45403
+ var init_telemetry = __esm(() => {
45404
+ init_observability();
45198
45405
  });
45199
45406
 
45200
- // src/core/observability.ts
45407
+ // src/core/observability/index.ts
45201
45408
  function getApexTracer() {
45202
45409
  return import_api3.trace.getTracer("apex");
45203
45410
  }
@@ -45211,44 +45418,70 @@ function withSubagentSessionBaggage(sessionId, fn) {
45211
45418
  const baggage = (import_api3.propagation.getActiveBaggage() ?? import_api3.propagation.createBaggage()).setEntry(SESSION_BAGGAGE_KEY, { value: sessionId });
45212
45419
  return import_api3.context.with(import_api3.propagation.setBaggage(import_api3.context.active(), baggage), fn);
45213
45420
  }
45421
+ function getActiveTraceCorrelation() {
45422
+ const spanContext = import_api3.trace.getSpan(import_api3.context.active())?.spanContext();
45423
+ if (!spanContext || !import_api3.trace.isSpanContextValid(spanContext))
45424
+ return null;
45425
+ return { traceId: spanContext.traceId, spanId: spanContext.spanId };
45426
+ }
45214
45427
  var import_api3, SESSION_BAGGAGE_KEY = "pensar.session.id";
45215
45428
  var init_observability = __esm(() => {
45216
45429
  init_id();
45430
+ init_telemetry();
45217
45431
  import_api3 = __toESM(require_src(), 1);
45218
45432
  });
45219
45433
 
45220
45434
  // src/core/ai/caching.ts
45221
- function withCachedSystemPrompt(system, messages) {
45435
+ function bedrockSupportsCachePoint(modelId) {
45436
+ const base = modelId.replace(/^(?:[a-z]{2,6}\.)?anthropic\./, "");
45437
+ return base.startsWith("claude-") && !BEDROCK_UNCACHEABLE_CLAUDE.test(base);
45438
+ }
45439
+ function cacheBreakpointFor(model) {
45440
+ const { provider } = getModelInfo(model);
45441
+ switch (provider) {
45442
+ case "anthropic":
45443
+ case "pensar":
45444
+ return ANTHROPIC_CACHE_CONTROL;
45445
+ case "bedrock":
45446
+ return bedrockSupportsCachePoint(model) ? BEDROCK_CACHE_POINT : undefined;
45447
+ default:
45448
+ return;
45449
+ }
45450
+ }
45451
+ function withCachedSystemPrompt(system, messages, breakpoint) {
45222
45452
  return [
45223
45453
  {
45224
45454
  role: "system",
45225
45455
  content: system,
45226
- providerOptions: ANTHROPIC_CACHE_CONTROL
45456
+ ...breakpoint ? { providerOptions: breakpoint } : {}
45227
45457
  },
45228
45458
  ...messages
45229
45459
  ];
45230
45460
  }
45231
- function withCachedLastMessage(messages) {
45232
- if (messages.length === 0)
45461
+ function withCachedLastMessage(messages, breakpoint) {
45462
+ if (messages.length === 0 || !breakpoint)
45233
45463
  return messages;
45234
45464
  return messages.map((msg, i) => {
45235
45465
  if (i === messages.length - 1) {
45236
- return {
45237
- ...msg,
45238
- providerOptions: {
45239
- ...msg.providerOptions,
45240
- ...ANTHROPIC_CACHE_CONTROL
45241
- }
45242
- };
45466
+ const merged = { ...msg.providerOptions };
45467
+ for (const [provider, options] of Object.entries(breakpoint)) {
45468
+ merged[provider] = { ...merged[provider], ...options };
45469
+ }
45470
+ return { ...msg, providerOptions: merged };
45243
45471
  }
45244
45472
  return msg;
45245
45473
  });
45246
45474
  }
45247
- var ANTHROPIC_CACHE_CONTROL;
45475
+ var ANTHROPIC_CACHE_CONTROL, BEDROCK_CACHE_POINT, BEDROCK_UNCACHEABLE_CLAUDE;
45248
45476
  var init_caching = __esm(() => {
45477
+ init_models();
45249
45478
  ANTHROPIC_CACHE_CONTROL = {
45250
45479
  anthropic: { cacheControl: { type: "ephemeral" } }
45251
45480
  };
45481
+ BEDROCK_CACHE_POINT = {
45482
+ bedrock: { cachePoint: { type: "default" } }
45483
+ };
45484
+ BEDROCK_UNCACHEABLE_CLAUDE = /^claude-(?:v2|instant|3[-.])/;
45252
45485
  });
45253
45486
 
45254
45487
  // src/core/ai/contextManagement.ts
@@ -45620,6 +45853,29 @@ var init_streamTelemetry = __esm(() => {
45620
45853
 
45621
45854
  // src/core/ai/ai.ts
45622
45855
  import { AsyncLocalStorage } from "node:async_hooks";
45856
+ function isRepairFailClosedTool(toolName) {
45857
+ return REPAIR_FAIL_CLOSED_TOOLS.has(toolName);
45858
+ }
45859
+ function normalizeStepUsage(step) {
45860
+ const inputTokens = step.usage?.inputTokens ?? 0;
45861
+ const outputTokens = step.usage?.outputTokens ?? 0;
45862
+ const meta = step.providerMetadata?.anthropic;
45863
+ let cacheRead = meta?.cacheReadInputTokens ?? 0;
45864
+ let cacheWrite = meta?.cacheCreationInputTokens ?? 0;
45865
+ const details = step.usage?.inputTokenDetails;
45866
+ if (cacheRead === 0) {
45867
+ cacheRead = details?.cacheReadTokens ?? 0;
45868
+ }
45869
+ if (cacheWrite === 0) {
45870
+ cacheWrite = details?.cacheWriteTokens ?? 0;
45871
+ }
45872
+ return {
45873
+ inputTokens,
45874
+ outputTokens,
45875
+ cacheReadTokens: cacheRead,
45876
+ cacheWriteTokens: cacheWrite
45877
+ };
45878
+ }
45623
45879
  function takeStepContext() {
45624
45880
  const store = stepContextStore.getStore();
45625
45881
  if (!store)
@@ -45943,17 +46199,27 @@ function streamResponse(opts) {
45943
46199
  sessionId
45944
46200
  } = opts;
45945
46201
  const onStepFinish = async (step) => {
46202
+ const stepUsage = normalizeStepUsage(step);
46203
+ if (onCacheMetrics && (stepUsage.cacheReadTokens > 0 || stepUsage.cacheWriteTokens > 0)) {
46204
+ await onCacheMetrics({
46205
+ cacheReadInputTokens: stepUsage.cacheReadTokens,
46206
+ cacheCreationInputTokens: stepUsage.cacheWriteTokens
46207
+ });
46208
+ }
45946
46209
  await userOnStepFinish?.(step);
45947
46210
  if (_usageCallback) {
45948
- const inp = step.usage?.inputTokens ?? 0;
45949
- const out = step.usage?.outputTokens ?? 0;
45950
46211
  const stepCtx = takeStepContext();
45951
- if (inp > 0 || out > 0)
45952
- _usageCallback(model, inp, out, stepCtx);
46212
+ if (stepUsage.inputTokens > 0 || stepUsage.outputTokens > 0) {
46213
+ await _usageCallback(model, stepUsage.inputTokens, stepUsage.outputTokens, {
46214
+ ...stepCtx,
46215
+ cacheReadTokens: stepUsage.cacheReadTokens,
46216
+ cacheWriteTokens: stepUsage.cacheWriteTokens
46217
+ });
46218
+ }
45953
46219
  }
45954
46220
  };
45955
46221
  const providerModel = getProviderModel(model, authConfig);
45956
- const useAnthropicCaching = isAnthropicProvider(model);
46222
+ const cacheBreakpoint = cacheBreakpointFor(model);
45957
46223
  const systemWithToolPolicy = applySequentialToolCallPolicy(system, tools, model);
45958
46224
  let fittedMessages = messages;
45959
46225
  let proactiveFitFailed = false;
@@ -45980,11 +46246,11 @@ function streamResponse(opts) {
45980
46246
  }
45981
46247
  let effectiveSystem = systemWithToolPolicy;
45982
46248
  let effectiveMessages = fittedMessages;
45983
- if (useAnthropicCaching && systemWithToolPolicy) {
46249
+ if (cacheBreakpoint && systemWithToolPolicy) {
45984
46250
  const baseMessages = fittedMessages ?? [
45985
46251
  { role: "user", content: prompt }
45986
46252
  ];
45987
- effectiveMessages = withCachedSystemPrompt(systemWithToolPolicy, baseMessages);
46253
+ effectiveMessages = withCachedSystemPrompt(systemWithToolPolicy, baseMessages, cacheBreakpoint);
45988
46254
  effectiveSystem = undefined;
45989
46255
  }
45990
46256
  const providerOptions = buildReasoningProviderOptions(model, {
@@ -45994,7 +46260,6 @@ function streamResponse(opts) {
45994
46260
  });
45995
46261
  let rateLimitRetryCount = 0;
45996
46262
  try {
45997
- const recordPayloads = shouldRecordAiPayloads();
45998
46263
  const response = streamText({
45999
46264
  model: providerModel,
46000
46265
  system: effectiveSystem,
@@ -46004,18 +46269,17 @@ function streamResponse(opts) {
46004
46269
  tools,
46005
46270
  maxRetries: 3,
46006
46271
  providerOptions,
46007
- experimental_telemetry: {
46008
- isEnabled: true,
46009
- recordInputs: recordPayloads,
46010
- recordOutputs: recordPayloads,
46011
- functionId: `apex.stream.${model}`,
46012
- ...sessionId ? { metadata: { sessionId } } : {}
46013
- },
46272
+ experimental_telemetry: createAiTelemetrySettings({
46273
+ operation: "apex.agent.stream",
46274
+ sessionId
46275
+ }),
46014
46276
  maxOutputTokens: getMaxOutputTokens(model),
46015
46277
  prepareStep: (opts2) => {
46016
46278
  messagesContainer.current = opts2.messages;
46017
- if (useAnthropicCaching) {
46018
- return { messages: withCachedLastMessage(opts2.messages) };
46279
+ if (cacheBreakpoint) {
46280
+ return {
46281
+ messages: withCachedLastMessage(opts2.messages, cacheBreakpoint)
46282
+ };
46019
46283
  }
46020
46284
  return;
46021
46285
  },
@@ -46030,25 +46294,7 @@ function streamResponse(opts) {
46030
46294
  }
46031
46295
  throw error;
46032
46296
  },
46033
- onStepFinish: onCacheMetrics ? (stepResult) => {
46034
- const meta = stepResult.providerMetadata?.anthropic;
46035
- let cacheRead = meta?.cacheReadInputTokens ?? 0;
46036
- let cacheCreation = meta?.cacheCreationInputTokens ?? 0;
46037
- const { inputTokenDetails } = stepResult.usage;
46038
- if (cacheRead === 0) {
46039
- cacheRead = inputTokenDetails?.cacheReadTokens ?? 0;
46040
- }
46041
- if (cacheCreation === 0) {
46042
- cacheCreation = inputTokenDetails?.cacheWriteTokens ?? 0;
46043
- }
46044
- if (cacheRead > 0 || cacheCreation > 0) {
46045
- onCacheMetrics({
46046
- cacheReadInputTokens: cacheRead,
46047
- cacheCreationInputTokens: cacheCreation
46048
- });
46049
- }
46050
- onStepFinish?.(stepResult);
46051
- } : onStepFinish,
46297
+ onStepFinish,
46052
46298
  abortSignal,
46053
46299
  activeTools,
46054
46300
  experimental_repairToolCall: async ({
@@ -46062,6 +46308,12 @@ function streamResponse(opts) {
46062
46308
  const rawLen = typeof raw === "string" ? raw.length : JSON.stringify(raw).length;
46063
46309
  log.warn(`[response-debug] experimental_repairToolCall FIRED for response ` + `rawInputChars=${rawLen} error=${(error.message || String(error)).slice(0, 200)}`);
46064
46310
  }
46311
+ if (isRepairFailClosedTool(toolCall.toolName)) {
46312
+ if (!silent) {
46313
+ log.warn(`Tool-call repair disabled for security-sensitive tool "${toolCall.toolName}" — failing closed (no argument synthesis).`);
46314
+ }
46315
+ return null;
46316
+ }
46065
46317
  try {
46066
46318
  if (!silent) {
46067
46319
  log.debug(`Repairing tool call: ${toolCall.toolName}`, {
@@ -46101,13 +46353,10 @@ function streamResponse(opts) {
46101
46353
  ].join(`
46102
46354
  `),
46103
46355
  abortSignal,
46104
- experimental_telemetry: {
46105
- isEnabled: true,
46106
- recordInputs: recordPayloads,
46107
- recordOutputs: recordPayloads,
46108
- functionId: "apex.tool_repair",
46109
- ...sessionId ? { metadata: { sessionId } } : {}
46110
- }
46356
+ experimental_telemetry: createAiTelemetrySettings({
46357
+ operation: "apex.tool.repair",
46358
+ sessionId
46359
+ })
46111
46360
  });
46112
46361
  if (onStepFinish && repairUsage) {
46113
46362
  onStepFinish({
@@ -46192,8 +46441,7 @@ async function generateObjectResponse(opts) {
46192
46441
  let lastError;
46193
46442
  for (let attempt = 0;attempt <= MAX_OBJECT_RATE_LIMIT_RETRIES; attempt++) {
46194
46443
  try {
46195
- const recordPayloads = shouldRecordAiPayloads();
46196
- const { output, usage } = await generateText({
46444
+ const { output, usage, providerMetadata } = await generateText({
46197
46445
  model: providerModel,
46198
46446
  output: output_exports.object({
46199
46447
  schema: schema2
@@ -46209,23 +46457,24 @@ async function generateObjectResponse(opts) {
46209
46457
  } : undefined,
46210
46458
  maxRetries: 0,
46211
46459
  abortSignal,
46212
- experimental_telemetry: {
46213
- isEnabled: true,
46214
- recordInputs: recordPayloads,
46215
- recordOutputs: recordPayloads,
46216
- functionId: "apex.generate_object",
46217
- ...sessionId ? { metadata: { sessionId } } : {}
46218
- }
46460
+ experimental_telemetry: createAiTelemetrySettings({
46461
+ operation: "apex.structured.generate",
46462
+ sessionId
46463
+ })
46219
46464
  });
46220
46465
  if (onTokenUsage && usage) {
46221
46466
  onTokenUsage(usage.inputTokens ?? 0, usage.outputTokens ?? 0);
46222
46467
  }
46223
46468
  if (_usageCallback && usage) {
46224
- const inp = usage.inputTokens ?? 0;
46225
- const out = usage.outputTokens ?? 0;
46469
+ const stepUsage = normalizeStepUsage({ usage, providerMetadata });
46226
46470
  const stepCtx = takeStepContext();
46227
- if (inp > 0 || out > 0)
46228
- _usageCallback(model, inp, out, stepCtx);
46471
+ if (stepUsage.inputTokens > 0 || stepUsage.outputTokens > 0) {
46472
+ await _usageCallback(model, stepUsage.inputTokens, stepUsage.outputTokens, {
46473
+ ...stepCtx,
46474
+ cacheReadTokens: stepUsage.cacheReadTokens,
46475
+ cacheWriteTokens: stepUsage.cacheWriteTokens
46476
+ });
46477
+ }
46229
46478
  }
46230
46479
  return output;
46231
46480
  } catch (error) {
@@ -46244,7 +46493,7 @@ async function generateObjectResponse(opts) {
46244
46493
  }
46245
46494
  throw lastError;
46246
46495
  }
46247
- var log, RESPONSE_DEBUG, RESPONSE_TOOL_NAME = "response", DEFAULT_OPENAI_REASONING_EFFORT = "medium", OPENAI_REASONING_MODEL_IDS, _usageCallback = null, stepContextStore, SEQUENTIAL_TOOL_CALL_INSTRUCTION, MAX_RATE_LIMIT_RETRIES = 20, MAX_IDLE_RESUME_RETRIES = 3, STREAM_IDLE_TIMEOUT_MS, StreamIdleTimeoutError, NON_GATED_TOOLS, MAX_OBJECT_RATE_LIMIT_RETRIES = 8, ContextLengthError, ContextLengthExhaustedError, MAX_RESTART_DEPTH = 3, MAX_TOOL_INPUT_CHARS = 8000, MAX_SCHEMA_CHARS = 6000, MINIMAL_RESTART_PROMPT = "Continue the previous task. Earlier context was discarded due to repeated context-length errors.";
46496
+ var log, RESPONSE_DEBUG, RESPONSE_TOOL_NAME = "response", REPAIR_FAIL_CLOSED_TOOLS, DEFAULT_OPENAI_REASONING_EFFORT = "medium", OPENAI_REASONING_MODEL_IDS, _usageCallback = null, stepContextStore, SEQUENTIAL_TOOL_CALL_INSTRUCTION, MAX_RATE_LIMIT_RETRIES = 20, MAX_IDLE_RESUME_RETRIES = 3, STREAM_IDLE_TIMEOUT_MS, StreamIdleTimeoutError, NON_GATED_TOOLS, MAX_OBJECT_RATE_LIMIT_RETRIES = 8, ContextLengthError, ContextLengthExhaustedError, MAX_RESTART_DEPTH = 3, MAX_TOOL_INPUT_CHARS = 8000, MAX_SCHEMA_CHARS = 6000, MINIMAL_RESTART_PROMPT = "Continue the previous task. Earlier context was discarded due to repeated context-length errors.";
46248
46497
  var init_ai = __esm(() => {
46249
46498
  init_dist4();
46250
46499
  init_structured();
@@ -46257,6 +46506,9 @@ var init_ai = __esm(() => {
46257
46506
  init_utils();
46258
46507
  log = scopedLogger(() => createLogger("ai"));
46259
46508
  RESPONSE_DEBUG = process.env.RESPONSE_DEBUG === "1" || process.env.RESPONSE_DEBUG === "true";
46509
+ REPAIR_FAIL_CLOSED_TOOLS = new Set([
46510
+ "spawn_pentest_agent"
46511
+ ]);
46260
46512
  OPENAI_REASONING_MODEL_IDS = new Set([
46261
46513
  "gpt-5",
46262
46514
  "gpt-5-2025-08-07",
@@ -46302,9 +46554,40 @@ var init_ai = __esm(() => {
46302
46554
  };
46303
46555
  });
46304
46556
 
46557
+ // src/core/ai/model-history.ts
46558
+ function addRecentModelId(recentModelIds, modelId) {
46559
+ const nextRecentModelIds = [];
46560
+ for (const id of [modelId, ...recentModelIds]) {
46561
+ if (nextRecentModelIds.includes(id))
46562
+ continue;
46563
+ nextRecentModelIds.push(id);
46564
+ if (nextRecentModelIds.length === MAX_RECENT_MODELS)
46565
+ break;
46566
+ }
46567
+ return nextRecentModelIds;
46568
+ }
46569
+ function getRecentModels(availableModels, recentModelIds) {
46570
+ const modelsById = new Map(availableModels.map((model) => [model.id, model]));
46571
+ const seen = new Set;
46572
+ const recentModels = [];
46573
+ for (const id of recentModelIds) {
46574
+ const model = modelsById.get(id);
46575
+ if (!model || seen.has(id))
46576
+ continue;
46577
+ seen.add(id);
46578
+ recentModels.push(model);
46579
+ if (recentModels.length === MAX_RECENT_MODELS)
46580
+ break;
46581
+ }
46582
+ return recentModels;
46583
+ }
46584
+ var MAX_RECENT_MODELS = 5;
46585
+ var init_model_history = () => {};
46586
+
46305
46587
  // src/core/ai/index.ts
46306
46588
  var init_ai2 = __esm(() => {
46307
46589
  init_ai();
46590
+ init_model_history();
46308
46591
  init_models();
46309
46592
  init_utils();
46310
46593
  });
@@ -46468,6 +46751,11 @@ function toReference(stored) {
46468
46751
  if (stored.tokens?.customHeaders) {
46469
46752
  ref.customHeaderKeys = Object.keys(stored.tokens.customHeaders);
46470
46753
  }
46754
+ if (stored.additionalFields) {
46755
+ const keys = Object.keys(stored.additionalFields);
46756
+ if (keys.length > 0)
46757
+ ref.additionalFieldKeys = keys;
46758
+ }
46471
46759
  const ctx = stored.metadata?.context;
46472
46760
  if (typeof ctx === "string" && ctx)
46473
46761
  ref.context = ctx;
@@ -46478,7 +46766,7 @@ class CredentialManager {
46478
46766
  store = new Map;
46479
46767
  findDuplicate(candidate) {
46480
46768
  for (const [id, existing] of this.store) {
46481
- if (existing.username === candidate.username && existing.password === candidate.password && existing.apiKey === candidate.apiKey && existing.loginUrl === candidate.loginUrl && existing.tokens?.bearerToken === candidate.tokens?.bearerToken && existing.tokens?.cookies === candidate.tokens?.cookies && existing.tokens?.sessionToken === candidate.tokens?.sessionToken && JSON.stringify(existing.tokens?.customHeaders) === JSON.stringify(candidate.tokens?.customHeaders)) {
46769
+ if (existing.username === candidate.username && existing.password === candidate.password && existing.apiKey === candidate.apiKey && existing.loginUrl === candidate.loginUrl && existing.tokens?.bearerToken === candidate.tokens?.bearerToken && existing.tokens?.cookies === candidate.tokens?.cookies && existing.tokens?.sessionToken === candidate.tokens?.sessionToken && JSON.stringify(existing.tokens?.customHeaders) === JSON.stringify(candidate.tokens?.customHeaders) && JSON.stringify(existing.additionalFields) === JSON.stringify(candidate.additionalFields)) {
46482
46770
  return id;
46483
46771
  }
46484
46772
  }
@@ -46576,6 +46864,9 @@ class CredentialManager {
46576
46864
  if (ref.customHeaderKeys?.length) {
46577
46865
  parts.push(` Header keys: ${ref.customHeaderKeys.join(", ")}`);
46578
46866
  }
46867
+ if (ref.additionalFieldKeys?.length) {
46868
+ parts.push(` Additional secret fields: ${ref.additionalFieldKeys.join(", ")}`);
46869
+ }
46579
46870
  if (ref.context)
46580
46871
  parts.push(` Context: ${ref.context}`);
46581
46872
  return parts.join(`
@@ -46584,6 +46875,9 @@ class CredentialManager {
46584
46875
  return `<available_credentials>
46585
46876
  The following credentials are available. To use a credential, pass its ID to the appropriate tool.
46586
46877
  Do NOT ask the user for passwords or secrets — they are resolved automatically from the credential ID.
46878
+ "Additional secret fields" are operator-supplied named secrets: pass the name as "credentialField"
46879
+ to browser_fill, or read the matching environment variable in execute_command. Their values are
46880
+ never shown to you and are redacted from command output.
46587
46881
 
46588
46882
  ${lines.join(`
46589
46883
 
@@ -47127,7 +47421,7 @@ async function create2(input) {
47127
47421
  if (normalizedConfig?.headers !== undefined) {
47128
47422
  snapshotHeaders = { ...normalizedConfig.headers };
47129
47423
  } else {
47130
- const { config: appConfig } = await import("./index-ag14v3sg.js");
47424
+ const { config: appConfig } = await import("./index-r4z6r7vf.js");
47131
47425
  const cfg = await appConfig.get();
47132
47426
  snapshotHeaders = cfg.defaultHeaders ? { ...cfg.defaultHeaders } : { ...DEFAULT_HEADER_RECORD };
47133
47427
  }
@@ -47238,17 +47532,21 @@ function hasOperatorState(session) {
47238
47532
  const statePath = path2.join(session.rootPath, "messages.json");
47239
47533
  return existsSync(statePath);
47240
47534
  }
47241
- function getResumeMessages(messages, limit = MAX_RESUME_MESSAGES) {
47535
+ function getResumeMessages(messages, limit = RESUME_MESSAGE_WINDOW) {
47242
47536
  if (messages.length <= limit)
47243
47537
  return messages;
47244
- let cutIndex = messages.length - limit;
47538
+ const roughCutIndex = messages.length - limit;
47539
+ let cutIndex = roughCutIndex;
47245
47540
  while (cutIndex < messages.length) {
47246
47541
  if (messages[cutIndex].role === "user")
47247
47542
  break;
47248
47543
  cutIndex++;
47249
47544
  }
47250
47545
  if (cutIndex >= messages.length) {
47251
- cutIndex = messages.length - limit;
47546
+ cutIndex = roughCutIndex;
47547
+ while (cutIndex > 0 && messages[cutIndex].role !== "user") {
47548
+ cutIndex--;
47549
+ }
47252
47550
  }
47253
47551
  return messages.slice(cutIndex);
47254
47552
  }
@@ -47348,7 +47646,7 @@ var DEFAULT_OUTCOME_GUIDANCE, EXFIL_OUTCOME_GUIDANCE, DEFAULT_HEADER_RECORD, Aut
47348
47646
  } catch (e) {
47349
47647
  console.error(e);
47350
47648
  }
47351
- }, RemoveMsgInput, MAX_RESUME_MESSAGES = 200, sessions;
47649
+ }, RemoveMsgInput, RESUME_MESSAGE_WINDOW = 200, sessions;
47352
47650
  var init_session = __esm(() => {
47353
47651
  init_zod();
47354
47652
  init_name();
@@ -47459,6 +47757,7 @@ var init_session = __esm(() => {
47459
47757
  authenticationInstructions: zod_default.string().optional(),
47460
47758
  requestsPerSecond: zod_default.number().optional(),
47461
47759
  allowDestructiveActions: zod_default.boolean().optional(),
47760
+ allowRateLimitTesting: zod_default.boolean().optional(),
47462
47761
  operatorSettings: OperatorSettingsObject.optional(),
47463
47762
  toolsetState: ToolsetStateSchema.optional(),
47464
47763
  enumerateSubdomains: zod_default.boolean().optional(),
@@ -47687,6 +47986,11 @@ class Logger {
47687
47986
  }
47688
47987
  }
47689
47988
  }
47989
+ const correlation = getActiveTraceCorrelation();
47990
+ if (correlation) {
47991
+ record.trace_id = correlation.traceId;
47992
+ record.span_id = correlation.spanId;
47993
+ }
47690
47994
  return safeStringify(record);
47691
47995
  }
47692
47996
  formatPretty(ts, level, msg, fields) {
@@ -47713,6 +48017,7 @@ function createLogger(scope) {
47713
48017
  var SEVERITY, VALID_LEVELS, COLORS, RESET = "\x1B[0m", DIM = "\x1B[2m", stderrSink = (line) => process.stderr.write(`${line}
47714
48018
  `), sink, logger;
47715
48019
  var init_structured = __esm(() => {
48020
+ init_observability();
47716
48021
  init_logger();
47717
48022
  SEVERITY = {
47718
48023
  DEBUG: 10,
@@ -47855,6 +48160,24 @@ function hasCacheControl(part) {
47855
48160
  const opts = part.providerOptions;
47856
48161
  return !!opts?.anthropic?.cacheControl;
47857
48162
  }
48163
+ function applyCacheControl(message) {
48164
+ if (typeof message.content === "string") {
48165
+ if (message.content === "")
48166
+ return;
48167
+ message.content = [
48168
+ {
48169
+ type: "text",
48170
+ text: message.content,
48171
+ cache_control: EPHEMERAL_CACHE_CONTROL
48172
+ }
48173
+ ];
48174
+ return;
48175
+ }
48176
+ const last = message.content[message.content.length - 1];
48177
+ if (!last || last.type === "thinking")
48178
+ return;
48179
+ last.cache_control = EPHEMERAL_CACHE_CONTROL;
48180
+ }
47858
48181
  function convertToAnthropicFormat(modelId, options) {
47859
48182
  const messages = [];
47860
48183
  let systemPrompt;
@@ -47865,7 +48188,6 @@ function convertToAnthropicFormat(modelId, options) {
47865
48188
  systemPrompt = part.content;
47866
48189
  systemHasCacheControl = hasCacheControl(part);
47867
48190
  } else if (part.role === "user") {
47868
- const partHasCache = hasCacheControl(part);
47869
48191
  const text2 = part.content.map((c) => {
47870
48192
  if (c.type === "text")
47871
48193
  return c.text;
@@ -47873,16 +48195,7 @@ function convertToAnthropicFormat(modelId, options) {
47873
48195
  return "[file]";
47874
48196
  return "";
47875
48197
  }).join("");
47876
- if (partHasCache) {
47877
- messages.push({
47878
- role: "user",
47879
- content: [
47880
- { type: "text", text: text2, cache_control: EPHEMERAL_CACHE_CONTROL }
47881
- ]
47882
- });
47883
- } else {
47884
- messages.push({ role: "user", content: text2 });
47885
- }
48198
+ messages.push({ role: "user", content: text2 });
47886
48199
  } else if (part.role === "assistant") {
47887
48200
  const assistantContent = part.content;
47888
48201
  const hasStructuredParts = assistantContent.some((c) => c.type === "tool-call" || c.type === "reasoning");
@@ -47935,6 +48248,10 @@ function convertToAnthropicFormat(modelId, options) {
47935
48248
  });
47936
48249
  messages.push({ role: "user", content: toolResults });
47937
48250
  }
48251
+ const pushed = messages[messages.length - 1];
48252
+ if (part.role !== "system" && pushed && hasCacheControl(part)) {
48253
+ applyCacheControl(pushed);
48254
+ }
47938
48255
  }
47939
48256
  }
47940
48257
  if (options.responseFormat?.type === "json") {
@@ -48834,6 +49151,7 @@ function buildAuthConfig(cfg) {
48834
49151
  openAiAPIKey: cfg.openAiAPIKey ?? undefined,
48835
49152
  googleAPIKey: cfg.googleAPIKey ?? undefined,
48836
49153
  openRouterAPIKey: cfg.openRouterAPIKey ?? undefined,
49154
+ concentrateAPIKey: cfg.concentrateAPIKey ?? undefined,
48837
49155
  inceptionAPIKey: cfg.inceptionAPIKey ?? undefined,
48838
49156
  pensarAPIKey: cfg.pensarAPIKey ?? undefined,
48839
49157
  accessToken: cfg.accessToken ?? undefined,
@@ -48851,6 +49169,7 @@ function getProviderModel(model, authConfig) {
48851
49169
  const anthropicAPIKey = authConfig?.anthropicAPIKey || process.env.ANTHROPIC_API_KEY;
48852
49170
  const googleAPIKey = authConfig?.googleAPIKey || process.env.GOOGLE_GENERATIVE_AI_API_KEY;
48853
49171
  const openRouterAPIKey = authConfig?.openRouterAPIKey || process.env.OPENROUTER_API_KEY;
49172
+ const concentrateAPIKey = authConfig?.concentrateAPIKey || process.env.CONCENTRATE_API_KEY;
48854
49173
  const bedrockApiKey = authConfig?.bedrock?.apiKey || process.env.BEDROCK_API_KEY;
48855
49174
  const bedrockAccessKeyId = authConfig?.bedrock?.accessKeyId || process.env.AWS_ACCESS_KEY_ID;
48856
49175
  const bedrockSecretAccessKey = authConfig?.bedrock?.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY;
@@ -48874,6 +49193,15 @@ function getProviderModel(model, authConfig) {
48874
49193
  providerModel = openrouter2(model);
48875
49194
  break;
48876
49195
  }
49196
+ case "concentrate": {
49197
+ const concentrate = createOpenAICompatible({
49198
+ name: "concentrate",
49199
+ apiKey: concentrateAPIKey,
49200
+ baseURL: "https://api.concentrate.ai/v1"
49201
+ });
49202
+ providerModel = concentrate(model.replace(/^concentrate:/, ""));
49203
+ break;
49204
+ }
48877
49205
  case "inception": {
48878
49206
  const inception = createOpenAICompatible({
48879
49207
  name: "inception",
@@ -49046,7 +49374,11 @@ async function summarizeConversation(messages, opts, model) {
49046
49374
  model,
49047
49375
  system: `You are a helpful assistant that summarizes conversations to pass to another agent. Review the conversation and system prompt at the end provided by the user.`,
49048
49376
  messages: summarizedMessages,
49049
- abortSignal: opts.abortSignal
49377
+ abortSignal: opts.abortSignal,
49378
+ experimental_telemetry: createAiTelemetrySettings({
49379
+ operation: "apex.context.summarize",
49380
+ sessionId: opts.sessionId
49381
+ })
49050
49382
  });
49051
49383
  if (opts.onStepFinish && summaryUsage) {
49052
49384
  opts.onStepFinish({
@@ -49174,6 +49506,7 @@ var init_utils = __esm(() => {
49174
49506
  init_auth();
49175
49507
  init_config();
49176
49508
  init_structured();
49509
+ init_observability();
49177
49510
  init_lazyLogger();
49178
49511
  init_ai();
49179
49512
  init_contextManagement();
@@ -49184,4 +49517,4 @@ var init_utils = __esm(() => {
49184
49517
  STREAMING_FETCH_TIMEOUT_MS = 35 * 60 * 1000;
49185
49518
  });
49186
49519
 
49187
- export { stepCountIs, hasToolCall, init_dist4 as init_dist, AVAILABLE_MODELS, init_models, require_tslib, scopedLogger, init_lazyLogger, buildAuthConfig, init_utils, init_ai2 as init_ai, generateRandomName, generateSessionName, init_name, CredentialManager, init_credentials, schema, descending, newSessionId, newMessageId, newPartId, init_id, RateLimiter, init_rateLimiter, NotFoundError, write2 as write, createDir, writeRaw, read2 as read, update, list, init_storage, ToolsetStateSchema, init_toolset, create2 as create, list2 as list1, normalizeMessages, sessions, init_session, writeErrorLog, routeLogsToErrorFile, init_logger, createLogger, logger, init_structured, getApexTracer, withSubagentSessionBaggage, init_observability, DEFAULT_OPENAI_REASONING_EFFORT, modelSupportsThinking, modelSupportsOpenAIReasoning, getOpenAIReasoningEfforts, streamResponse, generateObjectResponse, init_ai as init_ai1 };
49520
+ export { stepCountIs, hasToolCall, init_dist4 as init_dist, schema, descending, newSessionId, newMessageId, newPartId, newRunId, init_id, getApexTracer, withSubagentSessionBaggage, getActiveTraceCorrelation, init_observability, addRecentModelId, getRecentModels, init_model_history, AVAILABLE_MODELS, init_models, require_tslib, scopedLogger, init_lazyLogger, buildAuthConfig, init_utils, init_ai2 as init_ai, generateRandomName, generateSessionName, init_name, CredentialManager, init_credentials, RateLimiter, init_rateLimiter, NotFoundError, write2 as write, createDir, writeRaw, read2 as read, update, list, init_storage, ToolsetStateSchema, init_toolset, create2 as create, list2 as list1, getResumeMessages, normalizeMessages, sessions, init_session, writeErrorLog, routeLogsToErrorFile, init_logger, createLogger, logger, init_structured, DEFAULT_OPENAI_REASONING_EFFORT, getContextWindow, modelSupportsThinking, modelSupportsOpenAIReasoning, getOpenAIReasoningEfforts, streamResponse, generateObjectResponse, init_ai as init_ai1 };