190proof 1.0.119 → 1.0.120
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/README.md +13 -0
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +35 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -74,14 +74,34 @@ function formatIdentifier(identifier) {
|
|
|
74
74
|
function formatMessage(level, identifier, message) {
|
|
75
75
|
return `[${level}] ${formatIdentifier(identifier)} ${message}`;
|
|
76
76
|
}
|
|
77
|
+
var sink = console;
|
|
78
|
+
function setLogger(next) {
|
|
79
|
+
sink = next;
|
|
80
|
+
}
|
|
77
81
|
function log(identifier, message, ...args) {
|
|
78
|
-
|
|
82
|
+
sink == null ? void 0 : sink.log(formatMessage("LOG", identifier, message), ...args);
|
|
79
83
|
}
|
|
80
84
|
function warn(identifier, message, ...args) {
|
|
81
|
-
|
|
85
|
+
sink == null ? void 0 : sink.warn(formatMessage("WARN", identifier, message), ...args);
|
|
82
86
|
}
|
|
83
87
|
function error(identifier, message, ...args) {
|
|
84
|
-
|
|
88
|
+
sink == null ? void 0 : sink.error(formatMessage("ERROR", identifier, message), ...args);
|
|
89
|
+
}
|
|
90
|
+
function redactError(err) {
|
|
91
|
+
const e = err;
|
|
92
|
+
if (!e || typeof e !== "object" || !(e.config || e.request || e.isAxiosError)) {
|
|
93
|
+
return err;
|
|
94
|
+
}
|
|
95
|
+
const clean = new Error(e.message);
|
|
96
|
+
clean.name = e.name;
|
|
97
|
+
if (e.code !== void 0) clean.code = e.code;
|
|
98
|
+
if (e.status !== void 0) clean.status = e.status;
|
|
99
|
+
if (e.response) {
|
|
100
|
+
clean.response = { status: e.response.status, statusText: e.response.statusText, data: e.response.data };
|
|
101
|
+
}
|
|
102
|
+
if (e.data !== void 0) clean.data = e.data;
|
|
103
|
+
if (e.cause) clean.cause = redactError(e.cause);
|
|
104
|
+
return clean;
|
|
85
105
|
}
|
|
86
106
|
var logger_default = {
|
|
87
107
|
log,
|
|
@@ -144,7 +164,7 @@ async function withRetries(identifier, apiName, fn, options = {}) {
|
|
|
144
164
|
logger_default.error(
|
|
145
165
|
identifier,
|
|
146
166
|
`Retry #${attempt} error: ${error3.message}`,
|
|
147
|
-
((_b = error3.response) == null ? void 0 : _b.data) || error3
|
|
167
|
+
((_b = error3.response) == null ? void 0 : _b.data) || redactError(error3)
|
|
148
168
|
);
|
|
149
169
|
}
|
|
150
170
|
await timeout(baseDelayMs * attempt);
|
|
@@ -154,7 +174,7 @@ async function withRetries(identifier, apiName, fn, options = {}) {
|
|
|
154
174
|
const error2 = new Error(
|
|
155
175
|
`Failed to call ${apiName} API after ${retries} attempts: ${detail}`
|
|
156
176
|
);
|
|
157
|
-
error2.cause = lastError;
|
|
177
|
+
error2.cause = redactError(lastError);
|
|
158
178
|
throw error2;
|
|
159
179
|
}
|
|
160
180
|
function parseStreamedResponse(identifier, paragraph, toolCallAccumulators, allowedFunctionNames, reasoning) {
|
|
@@ -624,7 +644,7 @@ async function callOpenAiWithRetries(id, openAiPayload, openAiConfig, retries =
|
|
|
624
644
|
logger_default.error(
|
|
625
645
|
id,
|
|
626
646
|
`Retry #${attempt} error: ${error2.message}`,
|
|
627
|
-
((_a = error2.response) == null ? void 0 : _a.data) || error2.data || error2
|
|
647
|
+
((_a = error2.response) == null ? void 0 : _a.data) || error2.data || redactError(error2)
|
|
628
648
|
);
|
|
629
649
|
if (((_b = error2.data) == null ? void 0 : _b.code) === "content_policy_violation") {
|
|
630
650
|
logger_default.log(id, "Removing images due to content policy violation");
|
|
@@ -1182,7 +1202,7 @@ async function callGoogleAIWithRetries(id, payload, retries = 5, requestTimeoutM
|
|
|
1182
1202
|
const fetchError = new Error(
|
|
1183
1203
|
"Google AI could not fetch the provided image URL(s)."
|
|
1184
1204
|
);
|
|
1185
|
-
fetchError.cause = error2;
|
|
1205
|
+
fetchError.cause = redactError(error2);
|
|
1186
1206
|
fetchError.googleFetchFailure = true;
|
|
1187
1207
|
throw fetchError;
|
|
1188
1208
|
}
|
|
@@ -1965,7 +1985,7 @@ async function callWithRetries(id, aiPayload, aiConfig, retries = 5, chunkTimeou
|
|
|
1965
1985
|
(_e = result.provider) != null ? _e : result.provider = provider;
|
|
1966
1986
|
return result;
|
|
1967
1987
|
} catch (error2) {
|
|
1968
|
-
if ((_f = aiPayload.signal) == null ? void 0 : _f.aborted) throw error2;
|
|
1988
|
+
if ((_f = aiPayload.signal) == null ? void 0 : _f.aborted) throw redactError(error2);
|
|
1969
1989
|
if (aiPayload.fallbackModel) {
|
|
1970
1990
|
logger_default.error(
|
|
1971
1991
|
id,
|
|
@@ -1987,7 +2007,7 @@ async function callWithRetries(id, aiPayload, aiConfig, retries = 5, chunkTimeou
|
|
|
1987
2007
|
chunkTimeoutMs
|
|
1988
2008
|
);
|
|
1989
2009
|
}
|
|
1990
|
-
throw error2;
|
|
2010
|
+
throw redactError(error2);
|
|
1991
2011
|
}
|
|
1992
2012
|
}
|
|
1993
2013
|
export {
|
|
@@ -2001,6 +2021,8 @@ export {
|
|
|
2001
2021
|
OpenRouterModel,
|
|
2002
2022
|
callWithRetries,
|
|
2003
2023
|
openRouterImageRejectedModels,
|
|
2004
|
-
parseModelString
|
|
2024
|
+
parseModelString,
|
|
2025
|
+
redactError,
|
|
2026
|
+
setLogger
|
|
2005
2027
|
};
|
|
2006
2028
|
//# sourceMappingURL=index.mjs.map
|