@pensar/apex 2.4.0 → 2.5.0-canary.aa559068
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.
- package/build/agent-48xj79bj.js +20 -0
- package/build/{agent-nhs1w5w0.js → agent-7q3c9cjt.js} +11 -10
- package/build/{agent-5ejt5vpz.js → agent-ve8pkr6q.js} +9 -8
- package/build/{apps-17wvz1d7.js → apps-4rsrnftx.js} +72 -31
- package/build/{auth-z3h9859n.js → auth-0w07dbg2.js} +25 -20
- package/build/authentication-87zzmjdd.js +20 -0
- package/build/blackboxAgent-x0e1wqjx.js +20 -0
- package/build/blackboxPentest-0hwj49dr.js +70 -0
- package/build/{cli-32z0017y.js → cli-12ky98ey.js} +2 -2
- package/build/{cli-5k33webc.js → cli-2ar3m569.js} +45 -43
- package/build/cli-53rm0rrz.js +15 -0
- package/build/{cli-72cvcqhg.js → cli-54egv3xw.js} +1 -1
- package/build/cli-68260ckj.js +12136 -0
- package/build/{cli-gq40s5b3.js → cli-6cq67y5m.js} +5 -3
- package/build/{cli-mavved45.js → cli-7735d17s.js} +46 -25
- package/build/cli-7q3ae3ft.js +6 -0
- package/build/{cli-tznv8pf1.js → cli-8mws7sa5.js} +1 -1
- package/build/cli-9pbk8m32.js +32 -0
- package/build/{cli-swpbx60z.js → cli-avmhkjtv.js} +1 -1481
- package/build/{cli-9rhzhgx2.js → cli-eaaqeve1.js} +1 -1
- package/build/{cli-qqt4gj1w.js → cli-g0whajsq.js} +5 -3
- package/build/{cli-vq52kp7j.js → cli-gb1s7k3v.js} +17 -5
- package/build/{cli-2cbwdk78.js → cli-h8xsqggy.js} +1 -1
- package/build/{cli-0n4r54hq.js → cli-jsw8vt43.js} +1 -1
- package/build/cli-knd276ed.js +1485 -0
- package/build/{cli-repbyhkk.js → cli-kya26m6f.js} +1136 -525
- package/build/{cli-k8kc47pq.js → cli-mmyn6wmb.js} +3 -3
- package/build/{cli-tkc598ey.js → cli-qwv4jsj2.js} +371 -279
- package/build/{cli-xshasbwe.js → cli-r3w58pmq.js} +30 -4
- package/build/{cli-vnynf0js.js → cli-w51z9qjr.js} +10 -4
- package/build/{cli-b1adytsy.js → cli-whp0f8gp.js} +28 -5
- package/build/cli.js +553 -95
- package/build/{config-f1mj4nhd.js → config-z9k13rvy.js} +18 -15
- package/build/{doctor-ekneewa3.js → doctor-tc5zs6pn.js} +8 -7
- package/build/{fastStrike-8zka43xs.js → fastStrike-ssm7df42.js} +13 -10
- package/build/{fixes-b89s5haw.js → fixes-av9nq0hq.js} +25 -20
- package/build/getMachineId-bsd-xj3bn2fv.js +36 -0
- package/build/getMachineId-darwin-07jzjcx6.js +36 -0
- package/build/getMachineId-linux-ahngynxd.js +29 -0
- package/build/getMachineId-unsupported-vy43b44z.js +19 -0
- package/build/getMachineId-win-8x66cynz.js +38 -0
- package/build/{index-hqjdg6fg.js → index-1ppbwgf9.js} +17 -9
- package/build/{index-mtq7kmxz.js → index-5wh7gq37.js} +4 -2
- package/build/{index-6d22pyxt.js → index-718m7jw9.js} +1669 -1193
- package/build/{index-rbzhk712.js → index-gng8ebqf.js} +11 -10
- package/build/{index-y5w6n3tb.js → index-hhcjyc6j.js} +2 -2
- package/build/{index-sf16jm0m.js → index-mffgf5hg.js} +9 -7
- package/build/{index-ghwf5z3v.js → index-p1atm3ha.js} +3 -3
- package/build/{index-4ad3sdwk.js → index-vvkvwmyr.js} +4 -4
- package/build/{issues-xx5bs4md.js → issues-hfg8jydv.js} +72 -26
- package/build/{logs-qtxe51w2.js → logs-0rd1z7ct.js} +25 -20
- package/build/{offesecAgent-b9e2xm6v.js → offesecAgent-j4epj93p.js} +10 -9
- package/build/pentest-dp9w88pw.js +30 -0
- package/build/{pentests-6ks3szc4.js → pentests-enyxjtg6.js} +26 -21
- package/build/{targetedPentest-s1ptvq8e.js → targetedPentest-kwabfy86.js} +11 -10
- package/build/{targets-sxygyj87.js → targets-7x0pcmws.js} +27 -22
- package/build/threatModel-zwk5eb6r.js +29 -0
- package/build/{uninstall-tvsh81v8.js → uninstall-psm9btpt.js} +6 -3
- package/build/{upload-7wdyyqmr.js → upload-dybnknjs.js} +8 -7
- package/build/{utils-7fwdkqk6.js → utils-dsfk965b.js} +7 -6
- package/package.json +8 -2
- package/build/agent-mvpgvgks.js +0 -19
- package/build/authentication-3s97cpk4.js +0 -19
- package/build/blackboxAgent-gw0a1ca4.js +0 -19
- package/build/blackboxPentest-44333zss.js +0 -37
- package/build/main-mmjp338j.js +0 -324
- package/build/pentest-xtc1sjdw.js +0 -29
- package/build/threatModel-xsm6fwk5.js +0 -27
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
init_auth,
|
|
5
5
|
init_constants,
|
|
6
6
|
signGatewayRequest
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-jsw8vt43.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-
|
|
85
|
+
} from "./cli-avmhkjtv.js";
|
|
87
86
|
import {
|
|
88
87
|
config,
|
|
89
88
|
init_config
|
|
90
|
-
} from "./cli-
|
|
89
|
+
} from "./cli-54egv3xw.js";
|
|
91
90
|
import {
|
|
92
91
|
getCurrentVersion,
|
|
93
92
|
init_installation
|
|
94
|
-
} from "./cli-
|
|
93
|
+
} from "./cli-w51z9qjr.js";
|
|
94
|
+
import {
|
|
95
|
+
require_src
|
|
96
|
+
} from "./cli-knd276ed.js";
|
|
95
97
|
import {
|
|
96
98
|
__callDispose,
|
|
97
99
|
__commonJS,
|
|
@@ -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(() => {
|
|
@@ -15678,10 +15734,10 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
15678
15734
|
function serializeToolCallArguments2(input) {
|
|
15679
15735
|
return JSON.stringify(input === undefined ? {} : input);
|
|
15680
15736
|
}
|
|
15681
|
-
function isFileId(data,
|
|
15682
|
-
if (!
|
|
15737
|
+
function isFileId(data, prefixes2) {
|
|
15738
|
+
if (!prefixes2)
|
|
15683
15739
|
return false;
|
|
15684
|
-
return
|
|
15740
|
+
return prefixes2.some((prefix) => data.startsWith(prefix));
|
|
15685
15741
|
}
|
|
15686
15742
|
async function convertToOpenAIResponsesInput({
|
|
15687
15743
|
prompt,
|
|
@@ -21775,8 +21831,8 @@ function mapAnthropicStopReason({
|
|
|
21775
21831
|
return "other";
|
|
21776
21832
|
}
|
|
21777
21833
|
}
|
|
21778
|
-
function sanitizeJsonSchema(
|
|
21779
|
-
return sanitizeSchema(
|
|
21834
|
+
function sanitizeJsonSchema(schema2) {
|
|
21835
|
+
return sanitizeSchema(schema2);
|
|
21780
21836
|
}
|
|
21781
21837
|
function sanitizeDefinition(definition) {
|
|
21782
21838
|
if (typeof definition === "boolean" || !isPlainObject(definition)) {
|
|
@@ -21784,46 +21840,46 @@ function sanitizeDefinition(definition) {
|
|
|
21784
21840
|
}
|
|
21785
21841
|
return sanitizeSchema(definition);
|
|
21786
21842
|
}
|
|
21787
|
-
function sanitizeSchema(
|
|
21843
|
+
function sanitizeSchema(schema2) {
|
|
21788
21844
|
const result = {};
|
|
21789
|
-
const schemaWithDefs =
|
|
21790
|
-
if (
|
|
21791
|
-
return { $ref:
|
|
21845
|
+
const schemaWithDefs = schema2;
|
|
21846
|
+
if (schema2.$ref != null) {
|
|
21847
|
+
return { $ref: schema2.$ref };
|
|
21792
21848
|
}
|
|
21793
|
-
if (
|
|
21794
|
-
result.$schema =
|
|
21849
|
+
if (schema2.$schema != null) {
|
|
21850
|
+
result.$schema = schema2.$schema;
|
|
21795
21851
|
}
|
|
21796
|
-
if (
|
|
21797
|
-
result.$id =
|
|
21852
|
+
if (schema2.$id != null) {
|
|
21853
|
+
result.$id = schema2.$id;
|
|
21798
21854
|
}
|
|
21799
|
-
if (
|
|
21800
|
-
result.title =
|
|
21855
|
+
if (schema2.title != null) {
|
|
21856
|
+
result.title = schema2.title;
|
|
21801
21857
|
}
|
|
21802
|
-
if (
|
|
21803
|
-
result.description =
|
|
21858
|
+
if (schema2.description != null) {
|
|
21859
|
+
result.description = schema2.description;
|
|
21804
21860
|
}
|
|
21805
|
-
if (
|
|
21806
|
-
result.default =
|
|
21861
|
+
if (schema2.default !== undefined) {
|
|
21862
|
+
result.default = schema2.default;
|
|
21807
21863
|
}
|
|
21808
|
-
if (
|
|
21809
|
-
result.const =
|
|
21864
|
+
if (schema2.const !== undefined) {
|
|
21865
|
+
result.const = schema2.const;
|
|
21810
21866
|
}
|
|
21811
|
-
if (
|
|
21812
|
-
result.enum =
|
|
21867
|
+
if (schema2.enum != null) {
|
|
21868
|
+
result.enum = schema2.enum;
|
|
21813
21869
|
}
|
|
21814
|
-
if (
|
|
21815
|
-
result.type =
|
|
21870
|
+
if (schema2.type != null) {
|
|
21871
|
+
result.type = schema2.type;
|
|
21816
21872
|
}
|
|
21817
|
-
if (
|
|
21818
|
-
result.anyOf =
|
|
21819
|
-
} else if (
|
|
21820
|
-
result.anyOf =
|
|
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);
|
|
21821
21877
|
}
|
|
21822
|
-
if (
|
|
21823
|
-
result.allOf =
|
|
21878
|
+
if (schema2.allOf != null) {
|
|
21879
|
+
result.allOf = schema2.allOf.map(sanitizeDefinition);
|
|
21824
21880
|
}
|
|
21825
|
-
if (
|
|
21826
|
-
result.definitions = Object.fromEntries(Object.entries(
|
|
21881
|
+
if (schema2.definitions != null) {
|
|
21882
|
+
result.definitions = Object.fromEntries(Object.entries(schema2.definitions).map(([name22, definition]) => [
|
|
21827
21883
|
name22,
|
|
21828
21884
|
sanitizeDefinition(definition)
|
|
21829
21885
|
]));
|
|
@@ -21835,41 +21891,41 @@ function sanitizeSchema(schema) {
|
|
|
21835
21891
|
sanitizeDefinition(definition)
|
|
21836
21892
|
]));
|
|
21837
21893
|
}
|
|
21838
|
-
if (
|
|
21839
|
-
if (
|
|
21840
|
-
result.properties = Object.fromEntries(Object.entries(
|
|
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]) => [
|
|
21841
21897
|
name22,
|
|
21842
21898
|
sanitizeDefinition(definition)
|
|
21843
21899
|
]));
|
|
21844
21900
|
}
|
|
21845
21901
|
result.additionalProperties = false;
|
|
21846
|
-
if (
|
|
21847
|
-
result.required =
|
|
21902
|
+
if (schema2.required != null) {
|
|
21903
|
+
result.required = schema2.required;
|
|
21848
21904
|
}
|
|
21849
21905
|
}
|
|
21850
|
-
if (
|
|
21851
|
-
result.items = Array.isArray(
|
|
21906
|
+
if (schema2.items != null) {
|
|
21907
|
+
result.items = Array.isArray(schema2.items) ? schema2.items.map(sanitizeDefinition) : sanitizeDefinition(schema2.items);
|
|
21852
21908
|
}
|
|
21853
|
-
if (typeof
|
|
21854
|
-
result.format =
|
|
21909
|
+
if (typeof schema2.format === "string" && SUPPORTED_STRING_FORMATS.has(schema2.format)) {
|
|
21910
|
+
result.format = schema2.format;
|
|
21855
21911
|
}
|
|
21856
|
-
const constraintDescription = getConstraintDescription(
|
|
21912
|
+
const constraintDescription = getConstraintDescription(schema2);
|
|
21857
21913
|
if (constraintDescription != null) {
|
|
21858
21914
|
result.description = result.description == null ? constraintDescription : `${result.description}
|
|
21859
21915
|
${constraintDescription}`;
|
|
21860
21916
|
}
|
|
21861
21917
|
return result;
|
|
21862
21918
|
}
|
|
21863
|
-
function getConstraintDescription(
|
|
21919
|
+
function getConstraintDescription(schema2) {
|
|
21864
21920
|
const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
|
|
21865
|
-
const value =
|
|
21921
|
+
const value = schema2[key];
|
|
21866
21922
|
if (value == null || value === false) {
|
|
21867
21923
|
return [];
|
|
21868
21924
|
}
|
|
21869
21925
|
return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
|
|
21870
21926
|
});
|
|
21871
|
-
if (typeof
|
|
21872
|
-
descriptions.push(`format: ${
|
|
21927
|
+
if (typeof schema2.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema2.format)) {
|
|
21928
|
+
descriptions.push(`format: ${schema2.format}`);
|
|
21873
21929
|
}
|
|
21874
21930
|
return descriptions.length === 0 ? undefined : `${descriptions.join("; ")}.`;
|
|
21875
21931
|
}
|
|
@@ -25562,8 +25618,8 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema2, isRoot = true) {
|
|
|
25562
25618
|
result.allOf = allOf.map((item) => convertJSONSchemaToOpenAPISchema(item, false));
|
|
25563
25619
|
}
|
|
25564
25620
|
if (anyOf) {
|
|
25565
|
-
if (anyOf.some((
|
|
25566
|
-
const nonNullSchemas = anyOf.filter((
|
|
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"));
|
|
25567
25623
|
if (nonNullSchemas.length === 1) {
|
|
25568
25624
|
const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0], false);
|
|
25569
25625
|
if (typeof converted === "object") {
|
|
@@ -31781,13 +31837,13 @@ function parseIntersectionDef(def, refs) {
|
|
|
31781
31837
|
})
|
|
31782
31838
|
].filter((x) => !!x);
|
|
31783
31839
|
const mergedAllOf = [];
|
|
31784
|
-
allOf.forEach((
|
|
31785
|
-
if (isJsonSchema7AllOfType(
|
|
31786
|
-
mergedAllOf.push(...
|
|
31840
|
+
allOf.forEach((schema2) => {
|
|
31841
|
+
if (isJsonSchema7AllOfType(schema2)) {
|
|
31842
|
+
mergedAllOf.push(...schema2.allOf);
|
|
31787
31843
|
} else {
|
|
31788
|
-
let nestedSchema =
|
|
31789
|
-
if ("additionalProperties" in
|
|
31790
|
-
const { additionalProperties, ...rest } =
|
|
31844
|
+
let nestedSchema = schema2;
|
|
31845
|
+
if ("additionalProperties" in schema2 && schema2.additionalProperties === false) {
|
|
31846
|
+
const { additionalProperties, ...rest } = schema2;
|
|
31791
31847
|
nestedSchema = rest;
|
|
31792
31848
|
}
|
|
31793
31849
|
mergedAllOf.push(nestedSchema);
|
|
@@ -31948,44 +32004,44 @@ function escapeNonAlphaNumeric(source) {
|
|
|
31948
32004
|
}
|
|
31949
32005
|
return result;
|
|
31950
32006
|
}
|
|
31951
|
-
function addFormat(
|
|
32007
|
+
function addFormat(schema2, value, message, refs) {
|
|
31952
32008
|
var _a25;
|
|
31953
|
-
if (
|
|
31954
|
-
if (!
|
|
31955
|
-
|
|
32009
|
+
if (schema2.format || ((_a25 = schema2.anyOf) == null ? undefined : _a25.some((x) => x.format))) {
|
|
32010
|
+
if (!schema2.anyOf) {
|
|
32011
|
+
schema2.anyOf = [];
|
|
31956
32012
|
}
|
|
31957
|
-
if (
|
|
31958
|
-
|
|
31959
|
-
format:
|
|
32013
|
+
if (schema2.format) {
|
|
32014
|
+
schema2.anyOf.push({
|
|
32015
|
+
format: schema2.format
|
|
31960
32016
|
});
|
|
31961
|
-
delete
|
|
32017
|
+
delete schema2.format;
|
|
31962
32018
|
}
|
|
31963
|
-
|
|
32019
|
+
schema2.anyOf.push({
|
|
31964
32020
|
format: value,
|
|
31965
32021
|
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
31966
32022
|
});
|
|
31967
32023
|
} else {
|
|
31968
|
-
|
|
32024
|
+
schema2.format = value;
|
|
31969
32025
|
}
|
|
31970
32026
|
}
|
|
31971
|
-
function addPattern(
|
|
32027
|
+
function addPattern(schema2, regex, message, refs) {
|
|
31972
32028
|
var _a25;
|
|
31973
|
-
if (
|
|
31974
|
-
if (!
|
|
31975
|
-
|
|
32029
|
+
if (schema2.pattern || ((_a25 = schema2.allOf) == null ? undefined : _a25.some((x) => x.pattern))) {
|
|
32030
|
+
if (!schema2.allOf) {
|
|
32031
|
+
schema2.allOf = [];
|
|
31976
32032
|
}
|
|
31977
|
-
if (
|
|
31978
|
-
|
|
31979
|
-
pattern:
|
|
32033
|
+
if (schema2.pattern) {
|
|
32034
|
+
schema2.allOf.push({
|
|
32035
|
+
pattern: schema2.pattern
|
|
31980
32036
|
});
|
|
31981
|
-
delete
|
|
32037
|
+
delete schema2.pattern;
|
|
31982
32038
|
}
|
|
31983
|
-
|
|
32039
|
+
schema2.allOf.push({
|
|
31984
32040
|
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
31985
32041
|
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
31986
32042
|
});
|
|
31987
32043
|
} else {
|
|
31988
|
-
|
|
32044
|
+
schema2.pattern = stringifyRegExpWithFlags(regex, refs);
|
|
31989
32045
|
}
|
|
31990
32046
|
}
|
|
31991
32047
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
@@ -32065,7 +32121,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
32065
32121
|
}
|
|
32066
32122
|
function parseRecordDef(def, refs) {
|
|
32067
32123
|
var _a25, _b22, _c, _d, _e, _f;
|
|
32068
|
-
const
|
|
32124
|
+
const schema2 = {
|
|
32069
32125
|
type: "object",
|
|
32070
32126
|
additionalProperties: (_a25 = parseDef(def.valueType._def, {
|
|
32071
32127
|
...refs,
|
|
@@ -32075,12 +32131,12 @@ function parseRecordDef(def, refs) {
|
|
|
32075
32131
|
if (((_b22 = def.keyType) == null ? undefined : _b22._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
|
|
32076
32132
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
32077
32133
|
return {
|
|
32078
|
-
...
|
|
32134
|
+
...schema2,
|
|
32079
32135
|
propertyNames: keyType
|
|
32080
32136
|
};
|
|
32081
32137
|
} else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
|
|
32082
32138
|
return {
|
|
32083
|
-
...
|
|
32139
|
+
...schema2,
|
|
32084
32140
|
propertyNames: {
|
|
32085
32141
|
enum: def.keyType._def.values
|
|
32086
32142
|
}
|
|
@@ -32088,11 +32144,11 @@ function parseRecordDef(def, refs) {
|
|
|
32088
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)) {
|
|
32089
32145
|
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
32090
32146
|
return {
|
|
32091
|
-
...
|
|
32147
|
+
...schema2,
|
|
32092
32148
|
propertyNames: keyType
|
|
32093
32149
|
};
|
|
32094
32150
|
}
|
|
32095
|
-
return
|
|
32151
|
+
return schema2;
|
|
32096
32152
|
}
|
|
32097
32153
|
function parseMapDef(def, refs) {
|
|
32098
32154
|
if (refs.mapStrategy === "record") {
|
|
@@ -32285,9 +32341,9 @@ function decideAdditionalProperties(def, refs) {
|
|
|
32285
32341
|
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
32286
32342
|
}
|
|
32287
32343
|
}
|
|
32288
|
-
function safeIsOptional(
|
|
32344
|
+
function safeIsOptional(schema2) {
|
|
32289
32345
|
try {
|
|
32290
|
-
return
|
|
32346
|
+
return schema2.isOptional();
|
|
32291
32347
|
} catch (e) {
|
|
32292
32348
|
return true;
|
|
32293
32349
|
}
|
|
@@ -32300,18 +32356,18 @@ function parseSetDef(def, refs) {
|
|
|
32300
32356
|
...refs,
|
|
32301
32357
|
currentPath: [...refs.currentPath, "items"]
|
|
32302
32358
|
});
|
|
32303
|
-
const
|
|
32359
|
+
const schema2 = {
|
|
32304
32360
|
type: "array",
|
|
32305
32361
|
uniqueItems: true,
|
|
32306
32362
|
items
|
|
32307
32363
|
};
|
|
32308
32364
|
if (def.minSize) {
|
|
32309
|
-
|
|
32365
|
+
schema2.minItems = def.minSize.value;
|
|
32310
32366
|
}
|
|
32311
32367
|
if (def.maxSize) {
|
|
32312
|
-
|
|
32368
|
+
schema2.maxItems = def.maxSize.value;
|
|
32313
32369
|
}
|
|
32314
|
-
return
|
|
32370
|
+
return schema2;
|
|
32315
32371
|
}
|
|
32316
32372
|
function parseTupleDef(def, refs) {
|
|
32317
32373
|
if (def.rest) {
|
|
@@ -32378,12 +32434,12 @@ function parseDef(def, refs, forceResolution = false) {
|
|
|
32378
32434
|
return jsonSchema2;
|
|
32379
32435
|
}
|
|
32380
32436
|
function lazySchema2(createSchema) {
|
|
32381
|
-
let
|
|
32437
|
+
let schema2;
|
|
32382
32438
|
return () => {
|
|
32383
|
-
if (
|
|
32384
|
-
|
|
32439
|
+
if (schema2 == null) {
|
|
32440
|
+
schema2 = createSchema();
|
|
32385
32441
|
}
|
|
32386
|
-
return
|
|
32442
|
+
return schema2;
|
|
32387
32443
|
};
|
|
32388
32444
|
}
|
|
32389
32445
|
function jsonSchema2(jsonSchema22, {
|
|
@@ -32404,8 +32460,8 @@ function jsonSchema2(jsonSchema22, {
|
|
|
32404
32460
|
function isSchema(value) {
|
|
32405
32461
|
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
32406
32462
|
}
|
|
32407
|
-
function asSchema2(
|
|
32408
|
-
return
|
|
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();
|
|
32409
32465
|
}
|
|
32410
32466
|
function standardSchema(standardSchema2) {
|
|
32411
32467
|
return jsonSchema2(() => addAdditionalPropertiesToJsonSchema(standardSchema2["~standard"].jsonSchema.input({
|
|
@@ -32461,10 +32517,10 @@ function zodSchema2(zodSchema22, options) {
|
|
|
32461
32517
|
}
|
|
32462
32518
|
async function validateTypes2({
|
|
32463
32519
|
value,
|
|
32464
|
-
schema,
|
|
32520
|
+
schema: schema2,
|
|
32465
32521
|
context: context2
|
|
32466
32522
|
}) {
|
|
32467
|
-
const result = await safeValidateTypes2({ value, schema, context: context2 });
|
|
32523
|
+
const result = await safeValidateTypes2({ value, schema: schema2, context: context2 });
|
|
32468
32524
|
if (!result.success) {
|
|
32469
32525
|
throw TypeValidationError2.wrap({ value, cause: result.error, context: context2 });
|
|
32470
32526
|
}
|
|
@@ -32472,10 +32528,10 @@ async function validateTypes2({
|
|
|
32472
32528
|
}
|
|
32473
32529
|
async function safeValidateTypes2({
|
|
32474
32530
|
value,
|
|
32475
|
-
schema,
|
|
32531
|
+
schema: schema2,
|
|
32476
32532
|
context: context2
|
|
32477
32533
|
}) {
|
|
32478
|
-
const actualSchema = asSchema2(
|
|
32534
|
+
const actualSchema = asSchema2(schema2);
|
|
32479
32535
|
try {
|
|
32480
32536
|
if (actualSchema.validate == null) {
|
|
32481
32537
|
return { success: true, value, rawValue: value };
|
|
@@ -32499,14 +32555,14 @@ async function safeValidateTypes2({
|
|
|
32499
32555
|
}
|
|
32500
32556
|
async function parseJSON2({
|
|
32501
32557
|
text: text2,
|
|
32502
|
-
schema
|
|
32558
|
+
schema: schema2
|
|
32503
32559
|
}) {
|
|
32504
32560
|
try {
|
|
32505
32561
|
const value = secureJsonParse(text2);
|
|
32506
|
-
if (
|
|
32562
|
+
if (schema2 == null) {
|
|
32507
32563
|
return value;
|
|
32508
32564
|
}
|
|
32509
|
-
return validateTypes2({ value, schema });
|
|
32565
|
+
return validateTypes2({ value, schema: schema2 });
|
|
32510
32566
|
} catch (error) {
|
|
32511
32567
|
if (JSONParseError.isInstance(error) || TypeValidationError2.isInstance(error)) {
|
|
32512
32568
|
throw error;
|
|
@@ -32516,14 +32572,14 @@ async function parseJSON2({
|
|
|
32516
32572
|
}
|
|
32517
32573
|
async function safeParseJSON2({
|
|
32518
32574
|
text: text2,
|
|
32519
|
-
schema
|
|
32575
|
+
schema: schema2
|
|
32520
32576
|
}) {
|
|
32521
32577
|
try {
|
|
32522
32578
|
const value = secureJsonParse(text2);
|
|
32523
|
-
if (
|
|
32579
|
+
if (schema2 == null) {
|
|
32524
32580
|
return { success: true, value, rawValue: value };
|
|
32525
32581
|
}
|
|
32526
|
-
return await safeValidateTypes2({ value, schema });
|
|
32582
|
+
return await safeValidateTypes2({ value, schema: schema2 });
|
|
32527
32583
|
} catch (error) {
|
|
32528
32584
|
return {
|
|
32529
32585
|
success: false,
|
|
@@ -32542,28 +32598,28 @@ function isParsableJson2(input) {
|
|
|
32542
32598
|
}
|
|
32543
32599
|
function parseJsonEventStream2({
|
|
32544
32600
|
stream,
|
|
32545
|
-
schema
|
|
32601
|
+
schema: schema2
|
|
32546
32602
|
}) {
|
|
32547
32603
|
return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream).pipeThrough(new TransformStream({
|
|
32548
32604
|
async transform({ data }, controller) {
|
|
32549
32605
|
if (data === "[DONE]") {
|
|
32550
32606
|
return;
|
|
32551
32607
|
}
|
|
32552
|
-
controller.enqueue(await safeParseJSON2({ text: data, schema }));
|
|
32608
|
+
controller.enqueue(await safeParseJSON2({ text: data, schema: schema2 }));
|
|
32553
32609
|
}
|
|
32554
32610
|
}));
|
|
32555
32611
|
}
|
|
32556
32612
|
async function parseProviderOptions2({
|
|
32557
32613
|
provider,
|
|
32558
32614
|
providerOptions,
|
|
32559
|
-
schema
|
|
32615
|
+
schema: schema2
|
|
32560
32616
|
}) {
|
|
32561
32617
|
if ((providerOptions == null ? undefined : providerOptions[provider]) == null) {
|
|
32562
32618
|
return;
|
|
32563
32619
|
}
|
|
32564
32620
|
const parsedProviderOptions = await safeValidateTypes2({
|
|
32565
32621
|
value: providerOptions[provider],
|
|
32566
|
-
schema
|
|
32622
|
+
schema: schema2
|
|
32567
32623
|
});
|
|
32568
32624
|
if (!parsedProviderOptions.success) {
|
|
32569
32625
|
throw new InvalidArgumentError3({
|
|
@@ -32841,21 +32897,21 @@ var btoa, atob, name24 = "AI_DownloadError", marker24, symbol24, _a24, _b15, Dow
|
|
|
32841
32897
|
}
|
|
32842
32898
|
]))
|
|
32843
32899
|
};
|
|
32844
|
-
}, zod3ToJsonSchema = (
|
|
32900
|
+
}, zod3ToJsonSchema = (schema2, options) => {
|
|
32845
32901
|
var _a25;
|
|
32846
32902
|
const refs = getRefs(options);
|
|
32847
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name33,
|
|
32903
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name33, schema22]) => {
|
|
32848
32904
|
var _a33;
|
|
32849
32905
|
return {
|
|
32850
32906
|
...acc,
|
|
32851
|
-
[name33]: (_a33 = parseDef(
|
|
32907
|
+
[name33]: (_a33 = parseDef(schema22._def, {
|
|
32852
32908
|
...refs,
|
|
32853
32909
|
currentPath: [...refs.basePath, refs.definitionPath, name33]
|
|
32854
32910
|
}, true)) != null ? _a33 : parseAnyDef()
|
|
32855
32911
|
};
|
|
32856
32912
|
}, {}) : undefined;
|
|
32857
32913
|
const name25 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
|
|
32858
|
-
const main = (_a25 = parseDef(
|
|
32914
|
+
const main = (_a25 = parseDef(schema2._def, name25 === undefined ? refs : {
|
|
32859
32915
|
...refs,
|
|
32860
32916
|
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
32861
32917
|
}, false)) != null ? _a25 : parseAnyDef();
|
|
@@ -33721,10 +33777,10 @@ function convertOpenAIResponsesUsage2(usage) {
|
|
|
33721
33777
|
raw: usage
|
|
33722
33778
|
};
|
|
33723
33779
|
}
|
|
33724
|
-
function isFileId2(data,
|
|
33725
|
-
if (!
|
|
33780
|
+
function isFileId2(data, prefixes2) {
|
|
33781
|
+
if (!prefixes2)
|
|
33726
33782
|
return false;
|
|
33727
|
-
return
|
|
33783
|
+
return prefixes2.some((prefix) => data.startsWith(prefix));
|
|
33728
33784
|
}
|
|
33729
33785
|
async function convertToOpenAIResponsesInput2({
|
|
33730
33786
|
prompt,
|
|
@@ -40985,13 +41041,13 @@ function parseIntersectionDef2(def, refs) {
|
|
|
40985
41041
|
}))
|
|
40986
41042
|
].filter((x) => !!x);
|
|
40987
41043
|
const mergedAllOf = [];
|
|
40988
|
-
allOf.forEach((
|
|
40989
|
-
if (isJsonSchema7AllOfType2(
|
|
40990
|
-
mergedAllOf.push(...
|
|
41044
|
+
allOf.forEach((schema2) => {
|
|
41045
|
+
if (isJsonSchema7AllOfType2(schema2)) {
|
|
41046
|
+
mergedAllOf.push(...schema2.allOf);
|
|
40991
41047
|
} else {
|
|
40992
|
-
let nestedSchema =
|
|
40993
|
-
if ("additionalProperties" in
|
|
40994
|
-
const _a162 =
|
|
41048
|
+
let nestedSchema = schema2;
|
|
41049
|
+
if ("additionalProperties" in schema2 && schema2.additionalProperties === false) {
|
|
41050
|
+
const _a162 = schema2, { additionalProperties } = _a162, rest = __objRest(_a162, ["additionalProperties"]);
|
|
40995
41051
|
nestedSchema = rest;
|
|
40996
41052
|
}
|
|
40997
41053
|
mergedAllOf.push(nestedSchema);
|
|
@@ -41152,42 +41208,42 @@ function escapeNonAlphaNumeric2(source) {
|
|
|
41152
41208
|
}
|
|
41153
41209
|
return result;
|
|
41154
41210
|
}
|
|
41155
|
-
function addFormat2(
|
|
41211
|
+
function addFormat2(schema2, value, message, refs) {
|
|
41156
41212
|
var _a222;
|
|
41157
|
-
if (
|
|
41158
|
-
if (!
|
|
41159
|
-
|
|
41213
|
+
if (schema2.format || ((_a222 = schema2.anyOf) == null ? undefined : _a222.some((x) => x.format))) {
|
|
41214
|
+
if (!schema2.anyOf) {
|
|
41215
|
+
schema2.anyOf = [];
|
|
41160
41216
|
}
|
|
41161
|
-
if (
|
|
41162
|
-
|
|
41163
|
-
format:
|
|
41217
|
+
if (schema2.format) {
|
|
41218
|
+
schema2.anyOf.push({
|
|
41219
|
+
format: schema2.format
|
|
41164
41220
|
});
|
|
41165
|
-
delete
|
|
41221
|
+
delete schema2.format;
|
|
41166
41222
|
}
|
|
41167
|
-
|
|
41223
|
+
schema2.anyOf.push(__spreadValues({
|
|
41168
41224
|
format: value
|
|
41169
41225
|
}, message && refs.errorMessages && { errorMessage: { format: message } }));
|
|
41170
41226
|
} else {
|
|
41171
|
-
|
|
41227
|
+
schema2.format = value;
|
|
41172
41228
|
}
|
|
41173
41229
|
}
|
|
41174
|
-
function addPattern2(
|
|
41230
|
+
function addPattern2(schema2, regex, message, refs) {
|
|
41175
41231
|
var _a222;
|
|
41176
|
-
if (
|
|
41177
|
-
if (!
|
|
41178
|
-
|
|
41232
|
+
if (schema2.pattern || ((_a222 = schema2.allOf) == null ? undefined : _a222.some((x) => x.pattern))) {
|
|
41233
|
+
if (!schema2.allOf) {
|
|
41234
|
+
schema2.allOf = [];
|
|
41179
41235
|
}
|
|
41180
|
-
if (
|
|
41181
|
-
|
|
41182
|
-
pattern:
|
|
41236
|
+
if (schema2.pattern) {
|
|
41237
|
+
schema2.allOf.push({
|
|
41238
|
+
pattern: schema2.pattern
|
|
41183
41239
|
});
|
|
41184
|
-
delete
|
|
41240
|
+
delete schema2.pattern;
|
|
41185
41241
|
}
|
|
41186
|
-
|
|
41242
|
+
schema2.allOf.push(__spreadValues({
|
|
41187
41243
|
pattern: stringifyRegExpWithFlags2(regex, refs)
|
|
41188
41244
|
}, message && refs.errorMessages && { errorMessage: { pattern: message } }));
|
|
41189
41245
|
} else {
|
|
41190
|
-
|
|
41246
|
+
schema2.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
41191
41247
|
}
|
|
41192
41248
|
}
|
|
41193
41249
|
function stringifyRegExpWithFlags2(regex, refs) {
|
|
@@ -41267,7 +41323,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
41267
41323
|
}
|
|
41268
41324
|
function parseRecordDef2(def, refs) {
|
|
41269
41325
|
var _a222, _b222, _c, _d, _e, _f;
|
|
41270
|
-
const
|
|
41326
|
+
const schema2 = {
|
|
41271
41327
|
type: "object",
|
|
41272
41328
|
additionalProperties: (_a222 = parseDef2(def.valueType._def, __spreadProps(__spreadValues({}, refs), {
|
|
41273
41329
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
@@ -41275,22 +41331,22 @@ function parseRecordDef2(def, refs) {
|
|
|
41275
41331
|
};
|
|
41276
41332
|
if (((_b222 = def.keyType) == null ? undefined : _b222._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
|
|
41277
41333
|
const _a162 = parseStringDef2(def.keyType._def, refs), { type } = _a162, keyType = __objRest(_a162, ["type"]);
|
|
41278
|
-
return __spreadProps(__spreadValues({},
|
|
41334
|
+
return __spreadProps(__spreadValues({}, schema2), {
|
|
41279
41335
|
propertyNames: keyType
|
|
41280
41336
|
});
|
|
41281
41337
|
} else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
|
|
41282
|
-
return __spreadProps(__spreadValues({},
|
|
41338
|
+
return __spreadProps(__spreadValues({}, schema2), {
|
|
41283
41339
|
propertyNames: {
|
|
41284
41340
|
enum: def.keyType._def.values
|
|
41285
41341
|
}
|
|
41286
41342
|
});
|
|
41287
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)) {
|
|
41288
41344
|
const _b16 = parseBrandedDef2(def.keyType._def, refs), { type } = _b16, keyType = __objRest(_b16, ["type"]);
|
|
41289
|
-
return __spreadProps(__spreadValues({},
|
|
41345
|
+
return __spreadProps(__spreadValues({}, schema2), {
|
|
41290
41346
|
propertyNames: keyType
|
|
41291
41347
|
});
|
|
41292
41348
|
}
|
|
41293
|
-
return
|
|
41349
|
+
return schema2;
|
|
41294
41350
|
}
|
|
41295
41351
|
function parseMapDef2(def, refs) {
|
|
41296
41352
|
if (refs.mapStrategy === "record") {
|
|
@@ -41478,9 +41534,9 @@ function decideAdditionalProperties2(def, refs) {
|
|
|
41478
41534
|
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
41479
41535
|
}
|
|
41480
41536
|
}
|
|
41481
|
-
function safeIsOptional2(
|
|
41537
|
+
function safeIsOptional2(schema2) {
|
|
41482
41538
|
try {
|
|
41483
|
-
return
|
|
41539
|
+
return schema2.isOptional();
|
|
41484
41540
|
} catch (e) {
|
|
41485
41541
|
return true;
|
|
41486
41542
|
}
|
|
@@ -41492,18 +41548,18 @@ function parseSetDef2(def, refs) {
|
|
|
41492
41548
|
const items = parseDef2(def.valueType._def, __spreadProps(__spreadValues({}, refs), {
|
|
41493
41549
|
currentPath: [...refs.currentPath, "items"]
|
|
41494
41550
|
}));
|
|
41495
|
-
const
|
|
41551
|
+
const schema2 = {
|
|
41496
41552
|
type: "array",
|
|
41497
41553
|
uniqueItems: true,
|
|
41498
41554
|
items
|
|
41499
41555
|
};
|
|
41500
41556
|
if (def.minSize) {
|
|
41501
|
-
|
|
41557
|
+
schema2.minItems = def.minSize.value;
|
|
41502
41558
|
}
|
|
41503
41559
|
if (def.maxSize) {
|
|
41504
|
-
|
|
41560
|
+
schema2.maxItems = def.maxSize.value;
|
|
41505
41561
|
}
|
|
41506
|
-
return
|
|
41562
|
+
return schema2;
|
|
41507
41563
|
}
|
|
41508
41564
|
function parseTupleDef2(def, refs) {
|
|
41509
41565
|
if (def.rest) {
|
|
@@ -41584,8 +41640,8 @@ function jsonSchema3(jsonSchema22, {
|
|
|
41584
41640
|
function isSchema2(value) {
|
|
41585
41641
|
return typeof value === "object" && value !== null && schemaSymbol2 in value && value[schemaSymbol2] === true && "jsonSchema" in value && "validate" in value;
|
|
41586
41642
|
}
|
|
41587
|
-
function asSchema3(
|
|
41588
|
-
return
|
|
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();
|
|
41589
41645
|
}
|
|
41590
41646
|
function standardSchema2(standardSchema22) {
|
|
41591
41647
|
return jsonSchema3(() => addAdditionalPropertiesToJsonSchema2(standardSchema22["~standard"].jsonSchema.input({
|
|
@@ -41641,10 +41697,10 @@ function zodSchema3(zodSchema22, options) {
|
|
|
41641
41697
|
}
|
|
41642
41698
|
async function validateTypes3({
|
|
41643
41699
|
value,
|
|
41644
|
-
schema,
|
|
41700
|
+
schema: schema2,
|
|
41645
41701
|
context: context2
|
|
41646
41702
|
}) {
|
|
41647
|
-
const result = await safeValidateTypes3({ value, schema, context: context2 });
|
|
41703
|
+
const result = await safeValidateTypes3({ value, schema: schema2, context: context2 });
|
|
41648
41704
|
if (!result.success) {
|
|
41649
41705
|
throw TypeValidationError3.wrap({ value, cause: result.error, context: context2 });
|
|
41650
41706
|
}
|
|
@@ -41652,10 +41708,10 @@ async function validateTypes3({
|
|
|
41652
41708
|
}
|
|
41653
41709
|
async function safeValidateTypes3({
|
|
41654
41710
|
value,
|
|
41655
|
-
schema,
|
|
41711
|
+
schema: schema2,
|
|
41656
41712
|
context: context2
|
|
41657
41713
|
}) {
|
|
41658
|
-
const actualSchema = asSchema3(
|
|
41714
|
+
const actualSchema = asSchema3(schema2);
|
|
41659
41715
|
try {
|
|
41660
41716
|
if (actualSchema.validate == null) {
|
|
41661
41717
|
return { success: true, value, rawValue: value };
|
|
@@ -41679,14 +41735,14 @@ async function safeValidateTypes3({
|
|
|
41679
41735
|
}
|
|
41680
41736
|
async function parseJSON3({
|
|
41681
41737
|
text: text2,
|
|
41682
|
-
schema
|
|
41738
|
+
schema: schema2
|
|
41683
41739
|
}) {
|
|
41684
41740
|
try {
|
|
41685
41741
|
const value = secureJsonParse2(text2);
|
|
41686
|
-
if (
|
|
41742
|
+
if (schema2 == null) {
|
|
41687
41743
|
return value;
|
|
41688
41744
|
}
|
|
41689
|
-
return validateTypes3({ value, schema });
|
|
41745
|
+
return validateTypes3({ value, schema: schema2 });
|
|
41690
41746
|
} catch (error) {
|
|
41691
41747
|
if (JSONParseError2.isInstance(error) || TypeValidationError3.isInstance(error)) {
|
|
41692
41748
|
throw error;
|
|
@@ -41696,14 +41752,14 @@ async function parseJSON3({
|
|
|
41696
41752
|
}
|
|
41697
41753
|
async function safeParseJSON3({
|
|
41698
41754
|
text: text2,
|
|
41699
|
-
schema
|
|
41755
|
+
schema: schema2
|
|
41700
41756
|
}) {
|
|
41701
41757
|
try {
|
|
41702
41758
|
const value = secureJsonParse2(text2);
|
|
41703
|
-
if (
|
|
41759
|
+
if (schema2 == null) {
|
|
41704
41760
|
return { success: true, value, rawValue: value };
|
|
41705
41761
|
}
|
|
41706
|
-
return await safeValidateTypes3({ value, schema });
|
|
41762
|
+
return await safeValidateTypes3({ value, schema: schema2 });
|
|
41707
41763
|
} catch (error) {
|
|
41708
41764
|
return {
|
|
41709
41765
|
success: false,
|
|
@@ -41722,14 +41778,14 @@ function isParsableJson3(input) {
|
|
|
41722
41778
|
}
|
|
41723
41779
|
function parseJsonEventStream3({
|
|
41724
41780
|
stream,
|
|
41725
|
-
schema
|
|
41781
|
+
schema: schema2
|
|
41726
41782
|
}) {
|
|
41727
41783
|
return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream2).pipeThrough(new TransformStream({
|
|
41728
41784
|
async transform({ data }, controller) {
|
|
41729
41785
|
if (data === "[DONE]") {
|
|
41730
41786
|
return;
|
|
41731
41787
|
}
|
|
41732
|
-
controller.enqueue(await safeParseJSON3({ text: data, schema }));
|
|
41788
|
+
controller.enqueue(await safeParseJSON3({ text: data, schema: schema2 }));
|
|
41733
41789
|
}
|
|
41734
41790
|
}));
|
|
41735
41791
|
}
|
|
@@ -42939,19 +42995,19 @@ var __defProp2, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
42939
42995
|
}
|
|
42940
42996
|
]))
|
|
42941
42997
|
});
|
|
42942
|
-
}, zod3ToJsonSchema2 = (
|
|
42998
|
+
}, zod3ToJsonSchema2 = (schema2, options) => {
|
|
42943
42999
|
var _a222;
|
|
42944
43000
|
const refs = getRefs2(options);
|
|
42945
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name322,
|
|
43001
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name322, schema22]) => {
|
|
42946
43002
|
var _a322;
|
|
42947
43003
|
return __spreadProps(__spreadValues({}, acc), {
|
|
42948
|
-
[name322]: (_a322 = parseDef2(
|
|
43004
|
+
[name322]: (_a322 = parseDef2(schema22._def, __spreadProps(__spreadValues({}, refs), {
|
|
42949
43005
|
currentPath: [...refs.basePath, refs.definitionPath, name322]
|
|
42950
43006
|
}), true)) != null ? _a322 : parseAnyDef2()
|
|
42951
43007
|
});
|
|
42952
43008
|
}, {}) : undefined;
|
|
42953
43009
|
const name222 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
|
|
42954
|
-
const main = (_a222 = parseDef2(
|
|
43010
|
+
const main = (_a222 = parseDef2(schema2._def, name222 === undefined ? refs : __spreadProps(__spreadValues({}, refs), {
|
|
42955
43011
|
currentPath: [...refs.basePath, refs.definitionPath, name222]
|
|
42956
43012
|
}), false)) != null ? _a222 : parseAnyDef2();
|
|
42957
43013
|
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
@@ -45326,60 +45382,29 @@ Error message: ${getErrorMessage4(cause)}`,
|
|
|
45326
45382
|
});
|
|
45327
45383
|
});
|
|
45328
45384
|
|
|
45329
|
-
// src/core/
|
|
45330
|
-
|
|
45331
|
-
|
|
45332
|
-
|
|
45333
|
-
|
|
45334
|
-
|
|
45335
|
-
|
|
45336
|
-
|
|
45337
|
-
|
|
45338
|
-
|
|
45339
|
-
|
|
45340
|
-
|
|
45341
|
-
|
|
45342
|
-
|
|
45343
|
-
|
|
45344
|
-
|
|
45345
|
-
}
|
|
45346
|
-
function randomBase62(length) {
|
|
45347
|
-
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
45348
|
-
let result = "";
|
|
45349
|
-
const bytes = randomBytes(length);
|
|
45350
|
-
for (let i = 0;i < length; i++) {
|
|
45351
|
-
result += chars[bytes[i] % 62];
|
|
45352
|
-
}
|
|
45353
|
-
return result;
|
|
45354
|
-
}
|
|
45355
|
-
function create(prefix, descending2, timestamp) {
|
|
45356
|
-
const currentTimestamp = timestamp ?? Date.now();
|
|
45357
|
-
if (currentTimestamp !== lastTimestamp) {
|
|
45358
|
-
lastTimestamp = currentTimestamp;
|
|
45359
|
-
counter = 0;
|
|
45360
|
-
}
|
|
45361
|
-
counter++;
|
|
45362
|
-
let now2 = BigInt(currentTimestamp) * BigInt(4096) + BigInt(counter);
|
|
45363
|
-
now2 = descending2 ? ~now2 : now2;
|
|
45364
|
-
const timeBytes = Buffer.alloc(6);
|
|
45365
|
-
for (let i = 0;i < 6; i++) {
|
|
45366
|
-
timeBytes[i] = Number(now2 >> BigInt(40 - 8 * i) & BigInt(255));
|
|
45367
|
-
}
|
|
45368
|
-
return prefixes[prefix] + "_" + timeBytes.toString("hex") + randomBase62(LENGTH - 12);
|
|
45369
|
-
}
|
|
45370
|
-
var prefixes, LENGTH = 26, lastTimestamp = 0, counter = 0, newSessionId = () => descending("session"), newMessageId = () => descending("message"), newPartId = () => descending("part"), isSessionId = (s) => s.startsWith(`${prefixes.session}_`);
|
|
45371
|
-
var init_id = __esm(() => {
|
|
45372
|
-
init_zod();
|
|
45373
|
-
prefixes = {
|
|
45374
|
-
session: "ses",
|
|
45375
|
-
message: "msg",
|
|
45376
|
-
permission: "per",
|
|
45377
|
-
user: "usr",
|
|
45378
|
-
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 } : {}
|
|
45379
45401
|
};
|
|
45402
|
+
}
|
|
45403
|
+
var init_telemetry = __esm(() => {
|
|
45404
|
+
init_observability();
|
|
45380
45405
|
});
|
|
45381
45406
|
|
|
45382
|
-
// src/core/observability.ts
|
|
45407
|
+
// src/core/observability/index.ts
|
|
45383
45408
|
function getApexTracer() {
|
|
45384
45409
|
return import_api3.trace.getTracer("apex");
|
|
45385
45410
|
}
|
|
@@ -45393,9 +45418,16 @@ function withSubagentSessionBaggage(sessionId, fn) {
|
|
|
45393
45418
|
const baggage = (import_api3.propagation.getActiveBaggage() ?? import_api3.propagation.createBaggage()).setEntry(SESSION_BAGGAGE_KEY, { value: sessionId });
|
|
45394
45419
|
return import_api3.context.with(import_api3.propagation.setBaggage(import_api3.context.active(), baggage), fn);
|
|
45395
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
|
+
}
|
|
45396
45427
|
var import_api3, SESSION_BAGGAGE_KEY = "pensar.session.id";
|
|
45397
45428
|
var init_observability = __esm(() => {
|
|
45398
45429
|
init_id();
|
|
45430
|
+
init_telemetry();
|
|
45399
45431
|
import_api3 = __toESM(require_src(), 1);
|
|
45400
45432
|
});
|
|
45401
45433
|
|
|
@@ -45821,6 +45853,29 @@ var init_streamTelemetry = __esm(() => {
|
|
|
45821
45853
|
|
|
45822
45854
|
// src/core/ai/ai.ts
|
|
45823
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
|
+
}
|
|
45824
45879
|
function takeStepContext() {
|
|
45825
45880
|
const store = stepContextStore.getStore();
|
|
45826
45881
|
if (!store)
|
|
@@ -46144,13 +46199,23 @@ function streamResponse(opts) {
|
|
|
46144
46199
|
sessionId
|
|
46145
46200
|
} = opts;
|
|
46146
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
|
+
}
|
|
46147
46209
|
await userOnStepFinish?.(step);
|
|
46148
46210
|
if (_usageCallback) {
|
|
46149
|
-
const inp = step.usage?.inputTokens ?? 0;
|
|
46150
|
-
const out = step.usage?.outputTokens ?? 0;
|
|
46151
46211
|
const stepCtx = takeStepContext();
|
|
46152
|
-
if (
|
|
46153
|
-
_usageCallback(model,
|
|
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
|
+
}
|
|
46154
46219
|
}
|
|
46155
46220
|
};
|
|
46156
46221
|
const providerModel = getProviderModel(model, authConfig);
|
|
@@ -46195,7 +46260,6 @@ function streamResponse(opts) {
|
|
|
46195
46260
|
});
|
|
46196
46261
|
let rateLimitRetryCount = 0;
|
|
46197
46262
|
try {
|
|
46198
|
-
const recordPayloads = shouldRecordAiPayloads();
|
|
46199
46263
|
const response = streamText({
|
|
46200
46264
|
model: providerModel,
|
|
46201
46265
|
system: effectiveSystem,
|
|
@@ -46205,13 +46269,10 @@ function streamResponse(opts) {
|
|
|
46205
46269
|
tools,
|
|
46206
46270
|
maxRetries: 3,
|
|
46207
46271
|
providerOptions,
|
|
46208
|
-
experimental_telemetry: {
|
|
46209
|
-
|
|
46210
|
-
|
|
46211
|
-
|
|
46212
|
-
functionId: `apex.stream.${model}`,
|
|
46213
|
-
...sessionId ? { metadata: { sessionId } } : {}
|
|
46214
|
-
},
|
|
46272
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
46273
|
+
operation: "apex.agent.stream",
|
|
46274
|
+
sessionId
|
|
46275
|
+
}),
|
|
46215
46276
|
maxOutputTokens: getMaxOutputTokens(model),
|
|
46216
46277
|
prepareStep: (opts2) => {
|
|
46217
46278
|
messagesContainer.current = opts2.messages;
|
|
@@ -46233,25 +46294,7 @@ function streamResponse(opts) {
|
|
|
46233
46294
|
}
|
|
46234
46295
|
throw error;
|
|
46235
46296
|
},
|
|
46236
|
-
onStepFinish
|
|
46237
|
-
const meta = stepResult.providerMetadata?.anthropic;
|
|
46238
|
-
let cacheRead = meta?.cacheReadInputTokens ?? 0;
|
|
46239
|
-
let cacheCreation = meta?.cacheCreationInputTokens ?? 0;
|
|
46240
|
-
const { inputTokenDetails } = stepResult.usage;
|
|
46241
|
-
if (cacheRead === 0) {
|
|
46242
|
-
cacheRead = inputTokenDetails?.cacheReadTokens ?? 0;
|
|
46243
|
-
}
|
|
46244
|
-
if (cacheCreation === 0) {
|
|
46245
|
-
cacheCreation = inputTokenDetails?.cacheWriteTokens ?? 0;
|
|
46246
|
-
}
|
|
46247
|
-
if (cacheRead > 0 || cacheCreation > 0) {
|
|
46248
|
-
onCacheMetrics({
|
|
46249
|
-
cacheReadInputTokens: cacheRead,
|
|
46250
|
-
cacheCreationInputTokens: cacheCreation
|
|
46251
|
-
});
|
|
46252
|
-
}
|
|
46253
|
-
onStepFinish?.(stepResult);
|
|
46254
|
-
} : onStepFinish,
|
|
46297
|
+
onStepFinish,
|
|
46255
46298
|
abortSignal,
|
|
46256
46299
|
activeTools,
|
|
46257
46300
|
experimental_repairToolCall: async ({
|
|
@@ -46265,6 +46308,12 @@ function streamResponse(opts) {
|
|
|
46265
46308
|
const rawLen = typeof raw === "string" ? raw.length : JSON.stringify(raw).length;
|
|
46266
46309
|
log.warn(`[response-debug] experimental_repairToolCall FIRED for response ` + `rawInputChars=${rawLen} error=${(error.message || String(error)).slice(0, 200)}`);
|
|
46267
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
|
+
}
|
|
46268
46317
|
try {
|
|
46269
46318
|
if (!silent) {
|
|
46270
46319
|
log.debug(`Repairing tool call: ${toolCall.toolName}`, {
|
|
@@ -46304,13 +46353,10 @@ function streamResponse(opts) {
|
|
|
46304
46353
|
].join(`
|
|
46305
46354
|
`),
|
|
46306
46355
|
abortSignal,
|
|
46307
|
-
experimental_telemetry: {
|
|
46308
|
-
|
|
46309
|
-
|
|
46310
|
-
|
|
46311
|
-
functionId: "apex.tool_repair",
|
|
46312
|
-
...sessionId ? { metadata: { sessionId } } : {}
|
|
46313
|
-
}
|
|
46356
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
46357
|
+
operation: "apex.tool.repair",
|
|
46358
|
+
sessionId
|
|
46359
|
+
})
|
|
46314
46360
|
});
|
|
46315
46361
|
if (onStepFinish && repairUsage) {
|
|
46316
46362
|
onStepFinish({
|
|
@@ -46395,8 +46441,7 @@ async function generateObjectResponse(opts) {
|
|
|
46395
46441
|
let lastError;
|
|
46396
46442
|
for (let attempt = 0;attempt <= MAX_OBJECT_RATE_LIMIT_RETRIES; attempt++) {
|
|
46397
46443
|
try {
|
|
46398
|
-
const
|
|
46399
|
-
const { output, usage } = await generateText({
|
|
46444
|
+
const { output, usage, providerMetadata } = await generateText({
|
|
46400
46445
|
model: providerModel,
|
|
46401
46446
|
output: output_exports.object({
|
|
46402
46447
|
schema: schema2
|
|
@@ -46412,23 +46457,24 @@ async function generateObjectResponse(opts) {
|
|
|
46412
46457
|
} : undefined,
|
|
46413
46458
|
maxRetries: 0,
|
|
46414
46459
|
abortSignal,
|
|
46415
|
-
experimental_telemetry: {
|
|
46416
|
-
|
|
46417
|
-
|
|
46418
|
-
|
|
46419
|
-
functionId: "apex.generate_object",
|
|
46420
|
-
...sessionId ? { metadata: { sessionId } } : {}
|
|
46421
|
-
}
|
|
46460
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
46461
|
+
operation: "apex.structured.generate",
|
|
46462
|
+
sessionId
|
|
46463
|
+
})
|
|
46422
46464
|
});
|
|
46423
46465
|
if (onTokenUsage && usage) {
|
|
46424
46466
|
onTokenUsage(usage.inputTokens ?? 0, usage.outputTokens ?? 0);
|
|
46425
46467
|
}
|
|
46426
46468
|
if (_usageCallback && usage) {
|
|
46427
|
-
const
|
|
46428
|
-
const out = usage.outputTokens ?? 0;
|
|
46469
|
+
const stepUsage = normalizeStepUsage({ usage, providerMetadata });
|
|
46429
46470
|
const stepCtx = takeStepContext();
|
|
46430
|
-
if (
|
|
46431
|
-
_usageCallback(model,
|
|
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
|
+
}
|
|
46432
46478
|
}
|
|
46433
46479
|
return output;
|
|
46434
46480
|
} catch (error) {
|
|
@@ -46447,7 +46493,7 @@ async function generateObjectResponse(opts) {
|
|
|
46447
46493
|
}
|
|
46448
46494
|
throw lastError;
|
|
46449
46495
|
}
|
|
46450
|
-
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.";
|
|
46451
46497
|
var init_ai = __esm(() => {
|
|
46452
46498
|
init_dist4();
|
|
46453
46499
|
init_structured();
|
|
@@ -46460,6 +46506,9 @@ var init_ai = __esm(() => {
|
|
|
46460
46506
|
init_utils();
|
|
46461
46507
|
log = scopedLogger(() => createLogger("ai"));
|
|
46462
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
|
+
]);
|
|
46463
46512
|
OPENAI_REASONING_MODEL_IDS = new Set([
|
|
46464
46513
|
"gpt-5",
|
|
46465
46514
|
"gpt-5-2025-08-07",
|
|
@@ -46505,9 +46554,40 @@ var init_ai = __esm(() => {
|
|
|
46505
46554
|
};
|
|
46506
46555
|
});
|
|
46507
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
|
+
|
|
46508
46587
|
// src/core/ai/index.ts
|
|
46509
46588
|
var init_ai2 = __esm(() => {
|
|
46510
46589
|
init_ai();
|
|
46590
|
+
init_model_history();
|
|
46511
46591
|
init_models();
|
|
46512
46592
|
init_utils();
|
|
46513
46593
|
});
|
|
@@ -47341,7 +47421,7 @@ async function create2(input) {
|
|
|
47341
47421
|
if (normalizedConfig?.headers !== undefined) {
|
|
47342
47422
|
snapshotHeaders = { ...normalizedConfig.headers };
|
|
47343
47423
|
} else {
|
|
47344
|
-
const { config: appConfig } = await import("./index-
|
|
47424
|
+
const { config: appConfig } = await import("./index-p1atm3ha.js");
|
|
47345
47425
|
const cfg = await appConfig.get();
|
|
47346
47426
|
snapshotHeaders = cfg.defaultHeaders ? { ...cfg.defaultHeaders } : { ...DEFAULT_HEADER_RECORD };
|
|
47347
47427
|
}
|
|
@@ -47689,6 +47769,7 @@ var init_session = __esm(() => {
|
|
|
47689
47769
|
prompt: zod_default.string().optional(),
|
|
47690
47770
|
taskDriven: zod_default.boolean().optional(),
|
|
47691
47771
|
requirePlan: zod_default.boolean().optional(),
|
|
47772
|
+
disableSubagents: zod_default.boolean().optional(),
|
|
47692
47773
|
promptInjectionLibrarySource: zod_default.string().optional()
|
|
47693
47774
|
});
|
|
47694
47775
|
SessionInfoObject = zod_default.object({
|
|
@@ -47906,6 +47987,11 @@ class Logger {
|
|
|
47906
47987
|
}
|
|
47907
47988
|
}
|
|
47908
47989
|
}
|
|
47990
|
+
const correlation = getActiveTraceCorrelation();
|
|
47991
|
+
if (correlation) {
|
|
47992
|
+
record.trace_id = correlation.traceId;
|
|
47993
|
+
record.span_id = correlation.spanId;
|
|
47994
|
+
}
|
|
47909
47995
|
return safeStringify(record);
|
|
47910
47996
|
}
|
|
47911
47997
|
formatPretty(ts, level, msg, fields) {
|
|
@@ -47932,6 +48018,7 @@ function createLogger(scope) {
|
|
|
47932
48018
|
var SEVERITY, VALID_LEVELS, COLORS, RESET = "\x1B[0m", DIM = "\x1B[2m", stderrSink = (line) => process.stderr.write(`${line}
|
|
47933
48019
|
`), sink, logger;
|
|
47934
48020
|
var init_structured = __esm(() => {
|
|
48021
|
+
init_observability();
|
|
47935
48022
|
init_logger();
|
|
47936
48023
|
SEVERITY = {
|
|
47937
48024
|
DEBUG: 10,
|
|
@@ -49288,7 +49375,11 @@ async function summarizeConversation(messages, opts, model) {
|
|
|
49288
49375
|
model,
|
|
49289
49376
|
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.`,
|
|
49290
49377
|
messages: summarizedMessages,
|
|
49291
|
-
abortSignal: opts.abortSignal
|
|
49378
|
+
abortSignal: opts.abortSignal,
|
|
49379
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
49380
|
+
operation: "apex.context.summarize",
|
|
49381
|
+
sessionId: opts.sessionId
|
|
49382
|
+
})
|
|
49292
49383
|
});
|
|
49293
49384
|
if (opts.onStepFinish && summaryUsage) {
|
|
49294
49385
|
opts.onStepFinish({
|
|
@@ -49416,6 +49507,7 @@ var init_utils = __esm(() => {
|
|
|
49416
49507
|
init_auth();
|
|
49417
49508
|
init_config();
|
|
49418
49509
|
init_structured();
|
|
49510
|
+
init_observability();
|
|
49419
49511
|
init_lazyLogger();
|
|
49420
49512
|
init_ai();
|
|
49421
49513
|
init_contextManagement();
|
|
@@ -49426,4 +49518,4 @@ var init_utils = __esm(() => {
|
|
|
49426
49518
|
STREAMING_FETCH_TIMEOUT_MS = 35 * 60 * 1000;
|
|
49427
49519
|
});
|
|
49428
49520
|
|
|
49429
|
-
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,
|
|
49521
|
+
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 };
|