@pensar/apex 2.4.0 → 2.5.0-canary.2bbb0f6f
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-20hb6mg7.js +20 -0
- package/build/{agent-5ejt5vpz.js → agent-71sn1cjn.js} +9 -8
- package/build/{agent-nhs1w5w0.js → agent-xnrz4bhp.js} +11 -10
- package/build/{apps-17wvz1d7.js → apps-ghf7kp1s.js} +72 -31
- package/build/{auth-z3h9859n.js → auth-p1nrv7re.js} +25 -20
- package/build/authentication-m1vj2f0s.js +20 -0
- package/build/blackboxAgent-hjfzgk93.js +20 -0
- package/build/blackboxPentest-9snp9gvp.js +70 -0
- package/build/{cli-0n4r54hq.js → cli-08fcc6d8.js} +1 -1
- package/build/{cli-gq40s5b3.js → cli-14j00zfh.js} +5 -3
- package/build/{cli-vnynf0js.js → cli-3bmqdcfh.js} +10 -4
- package/build/{cli-mavved45.js → cli-3ew5fs3f.js} +46 -25
- package/build/{cli-xshasbwe.js → cli-4mgj070h.js} +30 -4
- package/build/{cli-repbyhkk.js → cli-4vwnsyep.js} +1141 -525
- package/build/cli-53rm0rrz.js +15 -0
- package/build/cli-68260ckj.js +12136 -0
- package/build/cli-7q3ae3ft.js +6 -0
- package/build/{cli-5k33webc.js → cli-7sqb16dd.js} +45 -43
- package/build/{cli-9rhzhgx2.js → cli-8pk8znhw.js} +1 -1
- package/build/cli-9pbk8m32.js +32 -0
- package/build/{cli-72cvcqhg.js → cli-9ya3yktn.js} +1 -1
- package/build/{cli-vq52kp7j.js → cli-a8n64cef.js} +23 -5
- package/build/{cli-qqt4gj1w.js → cli-a9vq54sx.js} +5 -3
- package/build/{cli-swpbx60z.js → cli-avmhkjtv.js} +1 -1481
- package/build/{cli-tkc598ey.js → cli-f47dgye3.js} +411 -280
- package/build/{cli-k8kc47pq.js → cli-fw7sp0fp.js} +3 -3
- package/build/{cli-32z0017y.js → cli-g3cb8pj5.js} +2 -2
- package/build/{cli-tznv8pf1.js → cli-gbch9xmy.js} +1 -1
- package/build/cli-knd276ed.js +1485 -0
- package/build/{cli-2cbwdk78.js → cli-t7rhyqx5.js} +1 -1
- package/build/{cli-b1adytsy.js → cli-yge44bmk.js} +28 -5
- package/build/cli.js +641 -95
- package/build/{config-f1mj4nhd.js → config-cqw98n5y.js} +18 -15
- package/build/{doctor-ekneewa3.js → doctor-vzh1wmfa.js} +8 -7
- package/build/{fastStrike-8zka43xs.js → fastStrike-f441e9nr.js} +13 -10
- package/build/{fixes-b89s5haw.js → fixes-xxz52cf2.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-ghwf5z3v.js → index-23jj0234.js} +3 -3
- package/build/{index-6d22pyxt.js → index-3gavwzay.js} +1756 -1213
- package/build/{index-4ad3sdwk.js → index-4v5jc2td.js} +4 -4
- package/build/{index-mtq7kmxz.js → index-5wh7gq37.js} +4 -2
- package/build/{index-sf16jm0m.js → index-e7kq5rrd.js} +9 -7
- package/build/{index-rbzhk712.js → index-fxx38nc9.js} +11 -10
- package/build/{index-hqjdg6fg.js → index-j3dc7dks.js} +17 -9
- package/build/{index-y5w6n3tb.js → index-yc1dnj3n.js} +2 -2
- package/build/{issues-xx5bs4md.js → issues-zdag9ayw.js} +82 -26
- package/build/{logs-qtxe51w2.js → logs-f492cjgt.js} +25 -20
- package/build/{offesecAgent-b9e2xm6v.js → offesecAgent-pr0cmrqb.js} +10 -9
- package/build/pentest-1g3fzah5.js +30 -0
- package/build/{pentests-6ks3szc4.js → pentests-vstpzh9j.js} +26 -21
- package/build/{targetedPentest-s1ptvq8e.js → targetedPentest-wj3ae355.js} +11 -10
- package/build/{targets-sxygyj87.js → targets-806zxf1n.js} +27 -22
- package/build/threatModel-dc4jbhkf.js +29 -0
- package/build/{uninstall-tvsh81v8.js → uninstall-58ak2e2v.js} +6 -3
- package/build/{upload-7wdyyqmr.js → upload-kkktzh83.js} +8 -7
- package/build/{utils-7fwdkqk6.js → utils-1sawtwbj.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-08fcc6d8.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-9ya3yktn.js";
|
|
91
90
|
import {
|
|
92
91
|
getCurrentVersion,
|
|
93
92
|
init_installation
|
|
94
|
-
} from "./cli-
|
|
93
|
+
} from "./cli-3bmqdcfh.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,49 @@ Error message: ${getErrorMessage4(cause)}`,
|
|
|
45326
45382
|
});
|
|
45327
45383
|
});
|
|
45328
45384
|
|
|
45329
|
-
// src/core/
|
|
45330
|
-
|
|
45331
|
-
|
|
45332
|
-
return zod_default.string().startsWith(prefixes[prefix]);
|
|
45333
|
-
}
|
|
45334
|
-
function descending(prefix, given) {
|
|
45335
|
-
return generateID(prefix, true, given);
|
|
45385
|
+
// src/core/observability/active-root-spans.ts
|
|
45386
|
+
function registerActiveRootSpan(span) {
|
|
45387
|
+
activeRootSpans.add(span);
|
|
45336
45388
|
}
|
|
45337
|
-
function
|
|
45338
|
-
|
|
45339
|
-
return create(prefix, descending2);
|
|
45340
|
-
}
|
|
45341
|
-
if (!given.startsWith(prefixes[prefix])) {
|
|
45342
|
-
throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`);
|
|
45343
|
-
}
|
|
45344
|
-
return given;
|
|
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;
|
|
45389
|
+
function unregisterActiveRootSpan(span) {
|
|
45390
|
+
activeRootSpans.delete(span);
|
|
45354
45391
|
}
|
|
45355
|
-
function
|
|
45356
|
-
const
|
|
45357
|
-
|
|
45358
|
-
|
|
45359
|
-
|
|
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));
|
|
45392
|
+
function endAllActiveRootSpans() {
|
|
45393
|
+
for (const span of activeRootSpans) {
|
|
45394
|
+
try {
|
|
45395
|
+
span.end();
|
|
45396
|
+
} catch {}
|
|
45367
45397
|
}
|
|
45368
|
-
|
|
45398
|
+
activeRootSpans.clear();
|
|
45369
45399
|
}
|
|
45370
|
-
var
|
|
45371
|
-
var
|
|
45372
|
-
|
|
45373
|
-
|
|
45374
|
-
|
|
45375
|
-
|
|
45376
|
-
|
|
45377
|
-
|
|
45378
|
-
|
|
45400
|
+
var activeRootSpans;
|
|
45401
|
+
var init_active_root_spans = __esm(() => {
|
|
45402
|
+
activeRootSpans = new Set;
|
|
45403
|
+
});
|
|
45404
|
+
|
|
45405
|
+
// src/core/observability/telemetry.ts
|
|
45406
|
+
function createAiTelemetrySettings(input) {
|
|
45407
|
+
const recordPayloads = shouldRecordAiPayloads();
|
|
45408
|
+
const metadata = {};
|
|
45409
|
+
if (input.sessionId)
|
|
45410
|
+
metadata.sessionId = input.sessionId;
|
|
45411
|
+
if (input.runId)
|
|
45412
|
+
metadata.runId = input.runId;
|
|
45413
|
+
if (input.agentId)
|
|
45414
|
+
metadata.agentId = input.agentId;
|
|
45415
|
+
return {
|
|
45416
|
+
isEnabled: true,
|
|
45417
|
+
recordInputs: recordPayloads,
|
|
45418
|
+
recordOutputs: recordPayloads,
|
|
45419
|
+
functionId: input.operation,
|
|
45420
|
+
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
45379
45421
|
};
|
|
45422
|
+
}
|
|
45423
|
+
var init_telemetry = __esm(() => {
|
|
45424
|
+
init_observability();
|
|
45380
45425
|
});
|
|
45381
45426
|
|
|
45382
|
-
// src/core/observability.ts
|
|
45427
|
+
// src/core/observability/index.ts
|
|
45383
45428
|
function getApexTracer() {
|
|
45384
45429
|
return import_api3.trace.getTracer("apex");
|
|
45385
45430
|
}
|
|
@@ -45393,9 +45438,17 @@ function withSubagentSessionBaggage(sessionId, fn) {
|
|
|
45393
45438
|
const baggage = (import_api3.propagation.getActiveBaggage() ?? import_api3.propagation.createBaggage()).setEntry(SESSION_BAGGAGE_KEY, { value: sessionId });
|
|
45394
45439
|
return import_api3.context.with(import_api3.propagation.setBaggage(import_api3.context.active(), baggage), fn);
|
|
45395
45440
|
}
|
|
45441
|
+
function getActiveTraceCorrelation() {
|
|
45442
|
+
const spanContext = import_api3.trace.getSpan(import_api3.context.active())?.spanContext();
|
|
45443
|
+
if (!spanContext || !import_api3.trace.isSpanContextValid(spanContext))
|
|
45444
|
+
return null;
|
|
45445
|
+
return { traceId: spanContext.traceId, spanId: spanContext.spanId };
|
|
45446
|
+
}
|
|
45396
45447
|
var import_api3, SESSION_BAGGAGE_KEY = "pensar.session.id";
|
|
45397
45448
|
var init_observability = __esm(() => {
|
|
45398
45449
|
init_id();
|
|
45450
|
+
init_active_root_spans();
|
|
45451
|
+
init_telemetry();
|
|
45399
45452
|
import_api3 = __toESM(require_src(), 1);
|
|
45400
45453
|
});
|
|
45401
45454
|
|
|
@@ -45821,6 +45874,29 @@ var init_streamTelemetry = __esm(() => {
|
|
|
45821
45874
|
|
|
45822
45875
|
// src/core/ai/ai.ts
|
|
45823
45876
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
45877
|
+
function isRepairFailClosedTool(toolName) {
|
|
45878
|
+
return REPAIR_FAIL_CLOSED_TOOLS.has(toolName);
|
|
45879
|
+
}
|
|
45880
|
+
function normalizeStepUsage(step) {
|
|
45881
|
+
const inputTokens = step.usage?.inputTokens ?? 0;
|
|
45882
|
+
const outputTokens = step.usage?.outputTokens ?? 0;
|
|
45883
|
+
const meta = step.providerMetadata?.anthropic;
|
|
45884
|
+
let cacheRead = meta?.cacheReadInputTokens ?? 0;
|
|
45885
|
+
let cacheWrite = meta?.cacheCreationInputTokens ?? 0;
|
|
45886
|
+
const details = step.usage?.inputTokenDetails;
|
|
45887
|
+
if (cacheRead === 0) {
|
|
45888
|
+
cacheRead = details?.cacheReadTokens ?? 0;
|
|
45889
|
+
}
|
|
45890
|
+
if (cacheWrite === 0) {
|
|
45891
|
+
cacheWrite = details?.cacheWriteTokens ?? 0;
|
|
45892
|
+
}
|
|
45893
|
+
return {
|
|
45894
|
+
inputTokens,
|
|
45895
|
+
outputTokens,
|
|
45896
|
+
cacheReadTokens: cacheRead,
|
|
45897
|
+
cacheWriteTokens: cacheWrite
|
|
45898
|
+
};
|
|
45899
|
+
}
|
|
45824
45900
|
function takeStepContext() {
|
|
45825
45901
|
const store = stepContextStore.getStore();
|
|
45826
45902
|
if (!store)
|
|
@@ -46095,6 +46171,18 @@ function normalizeOpenAIReasoningEffort(modelId, effort) {
|
|
|
46095
46171
|
}
|
|
46096
46172
|
return DEFAULT_OPENAI_REASONING_EFFORT;
|
|
46097
46173
|
}
|
|
46174
|
+
function buildOpenRouterProviderOptions(model) {
|
|
46175
|
+
if (model !== "z-ai/glm-5.2")
|
|
46176
|
+
return;
|
|
46177
|
+
return {
|
|
46178
|
+
openrouter: {
|
|
46179
|
+
provider: {
|
|
46180
|
+
only: ["z-ai"],
|
|
46181
|
+
allow_fallbacks: false
|
|
46182
|
+
}
|
|
46183
|
+
}
|
|
46184
|
+
};
|
|
46185
|
+
}
|
|
46098
46186
|
function buildReasoningProviderOptions(model, opts) {
|
|
46099
46187
|
const useThinking = !!opts.enableThinking && isAnthropicProvider(model) && modelSupportsAdaptiveThinking(model);
|
|
46100
46188
|
const normalizedOpenAIEffort = normalizeOpenAIReasoningEffort(model, opts.openAIReasoningEffort);
|
|
@@ -46144,13 +46232,23 @@ function streamResponse(opts) {
|
|
|
46144
46232
|
sessionId
|
|
46145
46233
|
} = opts;
|
|
46146
46234
|
const onStepFinish = async (step) => {
|
|
46235
|
+
const stepUsage = normalizeStepUsage(step);
|
|
46236
|
+
if (onCacheMetrics && (stepUsage.cacheReadTokens > 0 || stepUsage.cacheWriteTokens > 0)) {
|
|
46237
|
+
await onCacheMetrics({
|
|
46238
|
+
cacheReadInputTokens: stepUsage.cacheReadTokens,
|
|
46239
|
+
cacheCreationInputTokens: stepUsage.cacheWriteTokens
|
|
46240
|
+
});
|
|
46241
|
+
}
|
|
46147
46242
|
await userOnStepFinish?.(step);
|
|
46148
46243
|
if (_usageCallback) {
|
|
46149
|
-
const inp = step.usage?.inputTokens ?? 0;
|
|
46150
|
-
const out = step.usage?.outputTokens ?? 0;
|
|
46151
46244
|
const stepCtx = takeStepContext();
|
|
46152
|
-
if (
|
|
46153
|
-
_usageCallback(model,
|
|
46245
|
+
if (stepUsage.inputTokens > 0 || stepUsage.outputTokens > 0) {
|
|
46246
|
+
await _usageCallback(model, stepUsage.inputTokens, stepUsage.outputTokens, {
|
|
46247
|
+
...stepCtx,
|
|
46248
|
+
cacheReadTokens: stepUsage.cacheReadTokens,
|
|
46249
|
+
cacheWriteTokens: stepUsage.cacheWriteTokens
|
|
46250
|
+
});
|
|
46251
|
+
}
|
|
46154
46252
|
}
|
|
46155
46253
|
};
|
|
46156
46254
|
const providerModel = getProviderModel(model, authConfig);
|
|
@@ -46188,14 +46286,15 @@ function streamResponse(opts) {
|
|
|
46188
46286
|
effectiveMessages = withCachedSystemPrompt(systemWithToolPolicy, baseMessages, cacheBreakpoint);
|
|
46189
46287
|
effectiveSystem = undefined;
|
|
46190
46288
|
}
|
|
46191
|
-
const
|
|
46289
|
+
const reasoningProviderOptions = buildReasoningProviderOptions(model, {
|
|
46192
46290
|
enableThinking,
|
|
46193
46291
|
thinkingEffort,
|
|
46194
46292
|
openAIReasoningEffort
|
|
46195
46293
|
});
|
|
46294
|
+
const openRouterProviderOptions = buildOpenRouterProviderOptions(model);
|
|
46295
|
+
const providerOptions = reasoningProviderOptions || openRouterProviderOptions ? { ...reasoningProviderOptions, ...openRouterProviderOptions } : undefined;
|
|
46196
46296
|
let rateLimitRetryCount = 0;
|
|
46197
46297
|
try {
|
|
46198
|
-
const recordPayloads = shouldRecordAiPayloads();
|
|
46199
46298
|
const response = streamText({
|
|
46200
46299
|
model: providerModel,
|
|
46201
46300
|
system: effectiveSystem,
|
|
@@ -46205,13 +46304,10 @@ function streamResponse(opts) {
|
|
|
46205
46304
|
tools,
|
|
46206
46305
|
maxRetries: 3,
|
|
46207
46306
|
providerOptions,
|
|
46208
|
-
experimental_telemetry: {
|
|
46209
|
-
|
|
46210
|
-
|
|
46211
|
-
|
|
46212
|
-
functionId: `apex.stream.${model}`,
|
|
46213
|
-
...sessionId ? { metadata: { sessionId } } : {}
|
|
46214
|
-
},
|
|
46307
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
46308
|
+
operation: "apex.agent.stream",
|
|
46309
|
+
sessionId
|
|
46310
|
+
}),
|
|
46215
46311
|
maxOutputTokens: getMaxOutputTokens(model),
|
|
46216
46312
|
prepareStep: (opts2) => {
|
|
46217
46313
|
messagesContainer.current = opts2.messages;
|
|
@@ -46233,25 +46329,7 @@ function streamResponse(opts) {
|
|
|
46233
46329
|
}
|
|
46234
46330
|
throw error;
|
|
46235
46331
|
},
|
|
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,
|
|
46332
|
+
onStepFinish,
|
|
46255
46333
|
abortSignal,
|
|
46256
46334
|
activeTools,
|
|
46257
46335
|
experimental_repairToolCall: async ({
|
|
@@ -46265,6 +46343,12 @@ function streamResponse(opts) {
|
|
|
46265
46343
|
const rawLen = typeof raw === "string" ? raw.length : JSON.stringify(raw).length;
|
|
46266
46344
|
log.warn(`[response-debug] experimental_repairToolCall FIRED for response ` + `rawInputChars=${rawLen} error=${(error.message || String(error)).slice(0, 200)}`);
|
|
46267
46345
|
}
|
|
46346
|
+
if (isRepairFailClosedTool(toolCall.toolName)) {
|
|
46347
|
+
if (!silent) {
|
|
46348
|
+
log.warn(`Tool-call repair disabled for security-sensitive tool "${toolCall.toolName}" — failing closed (no argument synthesis).`);
|
|
46349
|
+
}
|
|
46350
|
+
return null;
|
|
46351
|
+
}
|
|
46268
46352
|
try {
|
|
46269
46353
|
if (!silent) {
|
|
46270
46354
|
log.debug(`Repairing tool call: ${toolCall.toolName}`, {
|
|
@@ -46304,13 +46388,10 @@ function streamResponse(opts) {
|
|
|
46304
46388
|
].join(`
|
|
46305
46389
|
`),
|
|
46306
46390
|
abortSignal,
|
|
46307
|
-
experimental_telemetry: {
|
|
46308
|
-
|
|
46309
|
-
|
|
46310
|
-
|
|
46311
|
-
functionId: "apex.tool_repair",
|
|
46312
|
-
...sessionId ? { metadata: { sessionId } } : {}
|
|
46313
|
-
}
|
|
46391
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
46392
|
+
operation: "apex.tool.repair",
|
|
46393
|
+
sessionId
|
|
46394
|
+
})
|
|
46314
46395
|
});
|
|
46315
46396
|
if (onStepFinish && repairUsage) {
|
|
46316
46397
|
onStepFinish({
|
|
@@ -46392,11 +46473,11 @@ async function generateObjectResponse(opts) {
|
|
|
46392
46473
|
} = opts;
|
|
46393
46474
|
const providerModel = getProviderModel(model, authConfig);
|
|
46394
46475
|
const normalizedOpenAIEffort = normalizeOpenAIReasoningEffort(model, openAIReasoningEffort);
|
|
46476
|
+
const openRouterProviderOptions = buildOpenRouterProviderOptions(model);
|
|
46395
46477
|
let lastError;
|
|
46396
46478
|
for (let attempt = 0;attempt <= MAX_OBJECT_RATE_LIMIT_RETRIES; attempt++) {
|
|
46397
46479
|
try {
|
|
46398
|
-
const
|
|
46399
|
-
const { output, usage } = await generateText({
|
|
46480
|
+
const { output, usage, providerMetadata } = await generateText({
|
|
46400
46481
|
model: providerModel,
|
|
46401
46482
|
output: output_exports.object({
|
|
46402
46483
|
schema: schema2
|
|
@@ -46405,30 +46486,34 @@ async function generateObjectResponse(opts) {
|
|
|
46405
46486
|
system,
|
|
46406
46487
|
maxOutputTokens: maxTokens,
|
|
46407
46488
|
temperature,
|
|
46408
|
-
providerOptions: normalizedOpenAIEffort ? {
|
|
46409
|
-
|
|
46410
|
-
|
|
46411
|
-
|
|
46489
|
+
providerOptions: normalizedOpenAIEffort || openRouterProviderOptions ? {
|
|
46490
|
+
...normalizedOpenAIEffort ? {
|
|
46491
|
+
openai: {
|
|
46492
|
+
reasoningEffort: normalizedOpenAIEffort
|
|
46493
|
+
}
|
|
46494
|
+
} : {},
|
|
46495
|
+
...openRouterProviderOptions
|
|
46412
46496
|
} : undefined,
|
|
46413
46497
|
maxRetries: 0,
|
|
46414
46498
|
abortSignal,
|
|
46415
|
-
experimental_telemetry: {
|
|
46416
|
-
|
|
46417
|
-
|
|
46418
|
-
|
|
46419
|
-
functionId: "apex.generate_object",
|
|
46420
|
-
...sessionId ? { metadata: { sessionId } } : {}
|
|
46421
|
-
}
|
|
46499
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
46500
|
+
operation: "apex.structured.generate",
|
|
46501
|
+
sessionId
|
|
46502
|
+
})
|
|
46422
46503
|
});
|
|
46423
46504
|
if (onTokenUsage && usage) {
|
|
46424
46505
|
onTokenUsage(usage.inputTokens ?? 0, usage.outputTokens ?? 0);
|
|
46425
46506
|
}
|
|
46426
46507
|
if (_usageCallback && usage) {
|
|
46427
|
-
const
|
|
46428
|
-
const out = usage.outputTokens ?? 0;
|
|
46508
|
+
const stepUsage = normalizeStepUsage({ usage, providerMetadata });
|
|
46429
46509
|
const stepCtx = takeStepContext();
|
|
46430
|
-
if (
|
|
46431
|
-
_usageCallback(model,
|
|
46510
|
+
if (stepUsage.inputTokens > 0 || stepUsage.outputTokens > 0) {
|
|
46511
|
+
await _usageCallback(model, stepUsage.inputTokens, stepUsage.outputTokens, {
|
|
46512
|
+
...stepCtx,
|
|
46513
|
+
cacheReadTokens: stepUsage.cacheReadTokens,
|
|
46514
|
+
cacheWriteTokens: stepUsage.cacheWriteTokens
|
|
46515
|
+
});
|
|
46516
|
+
}
|
|
46432
46517
|
}
|
|
46433
46518
|
return output;
|
|
46434
46519
|
} catch (error) {
|
|
@@ -46447,7 +46532,7 @@ async function generateObjectResponse(opts) {
|
|
|
46447
46532
|
}
|
|
46448
46533
|
throw lastError;
|
|
46449
46534
|
}
|
|
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.";
|
|
46535
|
+
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
46536
|
var init_ai = __esm(() => {
|
|
46452
46537
|
init_dist4();
|
|
46453
46538
|
init_structured();
|
|
@@ -46460,6 +46545,9 @@ var init_ai = __esm(() => {
|
|
|
46460
46545
|
init_utils();
|
|
46461
46546
|
log = scopedLogger(() => createLogger("ai"));
|
|
46462
46547
|
RESPONSE_DEBUG = process.env.RESPONSE_DEBUG === "1" || process.env.RESPONSE_DEBUG === "true";
|
|
46548
|
+
REPAIR_FAIL_CLOSED_TOOLS = new Set([
|
|
46549
|
+
"spawn_pentest_agent"
|
|
46550
|
+
]);
|
|
46463
46551
|
OPENAI_REASONING_MODEL_IDS = new Set([
|
|
46464
46552
|
"gpt-5",
|
|
46465
46553
|
"gpt-5-2025-08-07",
|
|
@@ -46505,9 +46593,40 @@ var init_ai = __esm(() => {
|
|
|
46505
46593
|
};
|
|
46506
46594
|
});
|
|
46507
46595
|
|
|
46596
|
+
// src/core/ai/model-history.ts
|
|
46597
|
+
function addRecentModelId(recentModelIds, modelId) {
|
|
46598
|
+
const nextRecentModelIds = [];
|
|
46599
|
+
for (const id of [modelId, ...recentModelIds]) {
|
|
46600
|
+
if (nextRecentModelIds.includes(id))
|
|
46601
|
+
continue;
|
|
46602
|
+
nextRecentModelIds.push(id);
|
|
46603
|
+
if (nextRecentModelIds.length === MAX_RECENT_MODELS)
|
|
46604
|
+
break;
|
|
46605
|
+
}
|
|
46606
|
+
return nextRecentModelIds;
|
|
46607
|
+
}
|
|
46608
|
+
function getRecentModels(availableModels, recentModelIds) {
|
|
46609
|
+
const modelsById = new Map(availableModels.map((model) => [model.id, model]));
|
|
46610
|
+
const seen = new Set;
|
|
46611
|
+
const recentModels = [];
|
|
46612
|
+
for (const id of recentModelIds) {
|
|
46613
|
+
const model = modelsById.get(id);
|
|
46614
|
+
if (!model || seen.has(id))
|
|
46615
|
+
continue;
|
|
46616
|
+
seen.add(id);
|
|
46617
|
+
recentModels.push(model);
|
|
46618
|
+
if (recentModels.length === MAX_RECENT_MODELS)
|
|
46619
|
+
break;
|
|
46620
|
+
}
|
|
46621
|
+
return recentModels;
|
|
46622
|
+
}
|
|
46623
|
+
var MAX_RECENT_MODELS = 5;
|
|
46624
|
+
var init_model_history = () => {};
|
|
46625
|
+
|
|
46508
46626
|
// src/core/ai/index.ts
|
|
46509
46627
|
var init_ai2 = __esm(() => {
|
|
46510
46628
|
init_ai();
|
|
46629
|
+
init_model_history();
|
|
46511
46630
|
init_models();
|
|
46512
46631
|
init_utils();
|
|
46513
46632
|
});
|
|
@@ -47341,7 +47460,7 @@ async function create2(input) {
|
|
|
47341
47460
|
if (normalizedConfig?.headers !== undefined) {
|
|
47342
47461
|
snapshotHeaders = { ...normalizedConfig.headers };
|
|
47343
47462
|
} else {
|
|
47344
|
-
const { config: appConfig } = await import("./index-
|
|
47463
|
+
const { config: appConfig } = await import("./index-23jj0234.js");
|
|
47345
47464
|
const cfg = await appConfig.get();
|
|
47346
47465
|
snapshotHeaders = cfg.defaultHeaders ? { ...cfg.defaultHeaders } : { ...DEFAULT_HEADER_RECORD };
|
|
47347
47466
|
}
|
|
@@ -47689,6 +47808,7 @@ var init_session = __esm(() => {
|
|
|
47689
47808
|
prompt: zod_default.string().optional(),
|
|
47690
47809
|
taskDriven: zod_default.boolean().optional(),
|
|
47691
47810
|
requirePlan: zod_default.boolean().optional(),
|
|
47811
|
+
disableSubagents: zod_default.boolean().optional(),
|
|
47692
47812
|
promptInjectionLibrarySource: zod_default.string().optional()
|
|
47693
47813
|
});
|
|
47694
47814
|
SessionInfoObject = zod_default.object({
|
|
@@ -47906,6 +48026,11 @@ class Logger {
|
|
|
47906
48026
|
}
|
|
47907
48027
|
}
|
|
47908
48028
|
}
|
|
48029
|
+
const correlation = getActiveTraceCorrelation();
|
|
48030
|
+
if (correlation) {
|
|
48031
|
+
record.trace_id = correlation.traceId;
|
|
48032
|
+
record.span_id = correlation.spanId;
|
|
48033
|
+
}
|
|
47909
48034
|
return safeStringify(record);
|
|
47910
48035
|
}
|
|
47911
48036
|
formatPretty(ts, level, msg, fields) {
|
|
@@ -47932,6 +48057,7 @@ function createLogger(scope) {
|
|
|
47932
48057
|
var SEVERITY, VALID_LEVELS, COLORS, RESET = "\x1B[0m", DIM = "\x1B[2m", stderrSink = (line) => process.stderr.write(`${line}
|
|
47933
48058
|
`), sink, logger;
|
|
47934
48059
|
var init_structured = __esm(() => {
|
|
48060
|
+
init_observability();
|
|
47935
48061
|
init_logger();
|
|
47936
48062
|
SEVERITY = {
|
|
47937
48063
|
DEBUG: 10,
|
|
@@ -49288,7 +49414,11 @@ async function summarizeConversation(messages, opts, model) {
|
|
|
49288
49414
|
model,
|
|
49289
49415
|
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
49416
|
messages: summarizedMessages,
|
|
49291
|
-
abortSignal: opts.abortSignal
|
|
49417
|
+
abortSignal: opts.abortSignal,
|
|
49418
|
+
experimental_telemetry: createAiTelemetrySettings({
|
|
49419
|
+
operation: "apex.context.summarize",
|
|
49420
|
+
sessionId: opts.sessionId
|
|
49421
|
+
})
|
|
49292
49422
|
});
|
|
49293
49423
|
if (opts.onStepFinish && summaryUsage) {
|
|
49294
49424
|
opts.onStepFinish({
|
|
@@ -49416,6 +49546,7 @@ var init_utils = __esm(() => {
|
|
|
49416
49546
|
init_auth();
|
|
49417
49547
|
init_config();
|
|
49418
49548
|
init_structured();
|
|
49549
|
+
init_observability();
|
|
49419
49550
|
init_lazyLogger();
|
|
49420
49551
|
init_ai();
|
|
49421
49552
|
init_contextManagement();
|
|
@@ -49426,4 +49557,4 @@ var init_utils = __esm(() => {
|
|
|
49426
49557
|
STREAMING_FETCH_TIMEOUT_MS = 35 * 60 * 1000;
|
|
49427
49558
|
});
|
|
49428
49559
|
|
|
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,
|
|
49560
|
+
export { stepCountIs, hasToolCall, init_dist4 as init_dist, schema, descending, newSessionId, newMessageId, newPartId, newRunId, init_id, registerActiveRootSpan, unregisterActiveRootSpan, endAllActiveRootSpans, init_active_root_spans, 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 };
|