@steve31415/baselib 3.39.1 → 3.40.1
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/dist/llm/complete.js
CHANGED
|
@@ -83,6 +83,7 @@ export async function llmComplete(request) {
|
|
|
83
83
|
continue;
|
|
84
84
|
}
|
|
85
85
|
const provider = providers[modelEntry.provider];
|
|
86
|
+
const attemptStartedAt = Date.now();
|
|
86
87
|
try {
|
|
87
88
|
const result = await provider.complete({
|
|
88
89
|
apiModelId: modelEntry.apiModelId,
|
|
@@ -124,6 +125,7 @@ export async function llmComplete(request) {
|
|
|
124
125
|
fallbackModel: modelName,
|
|
125
126
|
fallbackProvider: modelEntry.provider,
|
|
126
127
|
attemptsBeforeSuccess: failedAttempts.length,
|
|
128
|
+
...(request.callSite ? { callSite: request.callSite } : {}),
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
return {
|
|
@@ -162,6 +164,12 @@ export async function llmComplete(request) {
|
|
|
162
164
|
declined: err instanceof LLMError && err.declined === true,
|
|
163
165
|
attemptNumber: failedAttempts.length,
|
|
164
166
|
nextModel: modelsToTry[failedAttempts.length] ?? 'none',
|
|
167
|
+
// Which caller, and whether it ran out its own deadline: a timeout tail is a
|
|
168
|
+
// headroom question for that call site, an HTTP error is not (reader task 58b65ec9).
|
|
169
|
+
...(request.callSite ? { callSite: request.callSite } : {}),
|
|
170
|
+
timedOut: err instanceof LLMError && err.timedOut === true,
|
|
171
|
+
timeoutMs,
|
|
172
|
+
attemptMs: Date.now() - attemptStartedAt,
|
|
165
173
|
});
|
|
166
174
|
}
|
|
167
175
|
}
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export declare class LLMError extends Error {
|
|
|
155
155
|
* not a defect.
|
|
156
156
|
*/
|
|
157
157
|
declined: boolean;
|
|
158
|
+
/** True when the attempt hit its per-provider `timeoutMs` deadline. */
|
|
159
|
+
timedOut: boolean;
|
|
158
160
|
constructor(opts: {
|
|
159
161
|
message: string;
|
|
160
162
|
provider: ProviderName;
|
|
@@ -162,6 +164,7 @@ export declare class LLMError extends Error {
|
|
|
162
164
|
statusCode?: number;
|
|
163
165
|
isRetryable: boolean;
|
|
164
166
|
declined?: boolean;
|
|
167
|
+
timedOut?: boolean;
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
170
|
export interface ProviderAdapter {
|
package/dist/llm/types.js
CHANGED
|
@@ -20,6 +20,8 @@ export class LLMError extends Error {
|
|
|
20
20
|
* not a defect.
|
|
21
21
|
*/
|
|
22
22
|
declined;
|
|
23
|
+
/** True when the attempt hit its per-provider `timeoutMs` deadline. */
|
|
24
|
+
timedOut;
|
|
23
25
|
constructor(opts) {
|
|
24
26
|
super(opts.message);
|
|
25
27
|
this.name = 'LLMError';
|
|
@@ -28,5 +30,6 @@ export class LLMError extends Error {
|
|
|
28
30
|
this.statusCode = opts.statusCode;
|
|
29
31
|
this.isRetryable = opts.isRetryable;
|
|
30
32
|
this.declined = opts.declined ?? false;
|
|
33
|
+
this.timedOut = opts.timedOut ?? false;
|
|
31
34
|
}
|
|
32
35
|
}
|
package/dist/log-core.js
CHANGED
|
@@ -22,6 +22,23 @@ function errorCode(err) {
|
|
|
22
22
|
return code;
|
|
23
23
|
return undefined;
|
|
24
24
|
}
|
|
25
|
+
/** A non-Error cause as text. A plain object (gaxios 7 sets a Google API
|
|
26
|
+
* error's cause to the AIP-193 body { code, message, status }) is rendered
|
|
27
|
+
* as JSON, which String() would flatten to "[object Object]" (watchdog task
|
|
28
|
+
* 4454314a, 2026-10-28); an object JSON cannot render falls back to String(). */
|
|
29
|
+
function causeText(cause) {
|
|
30
|
+
if (typeof cause === 'object' && cause !== null) {
|
|
31
|
+
try {
|
|
32
|
+
const json = JSON.stringify(cause);
|
|
33
|
+
if (typeof json === 'string')
|
|
34
|
+
return json;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// circular or a throwing toJSON: fall through
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return String(cause);
|
|
41
|
+
}
|
|
25
42
|
export function serializeError(err) {
|
|
26
43
|
if (err instanceof Error) {
|
|
27
44
|
const out = { name: err.name, message: err.message };
|
|
@@ -36,7 +53,7 @@ export function serializeError(err) {
|
|
|
36
53
|
out.cause.code = causeCode;
|
|
37
54
|
}
|
|
38
55
|
else if (err.cause !== undefined) {
|
|
39
|
-
out.cause = { name: 'cause', message: truncate(
|
|
56
|
+
out.cause = { name: 'cause', message: truncate(causeText(err.cause), 500) };
|
|
40
57
|
}
|
|
41
58
|
return out;
|
|
42
59
|
}
|
package/package.json
CHANGED