@steve31415/baselib 3.8.2 → 3.8.3

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.
@@ -126,7 +126,13 @@ export async function llmComplete(request) {
126
126
  request.logger?.warn('llm.failover_attempt', {
127
127
  failedModel: modelName,
128
128
  failedProvider: modelEntry.provider,
129
- error: errorMessage,
129
+ // Provider/network/parse errors can echo prompts, credentials or private
130
+ // response bodies. Keep their text in the returned API only, never logs.
131
+ errorClass: err instanceof LLMError ? 'LLMError' : err instanceof Error ? 'Error' : 'NonError',
132
+ ...(err instanceof LLMError && typeof err.statusCode === 'number' && Number.isFinite(err.statusCode)
133
+ ? { statusCode: err.statusCode } : {}),
134
+ isRetryable: err instanceof LLMError && err.isRetryable === true,
135
+ declined: err instanceof LLMError && err.declined === true,
130
136
  attemptNumber: failedAttempts.length,
131
137
  nextModel: modelsToTry[failedAttempts.length] ?? 'none',
132
138
  });
@@ -116,18 +116,19 @@ export interface LLMResponse {
116
116
  latencyMs: number;
117
117
  /** True if the primary model failed and a fallback was used. */
118
118
  failedOver: boolean;
119
- /** Details of each failed attempt before the successful one. */
119
+ /** Details of each failed attempt before success; error text can contain private input. Do not log verbatim. */
120
120
  failedAttempts: FailedAttempt[];
121
121
  }
122
122
  /** Details of a failed provider attempt. */
123
123
  export interface FailedAttempt {
124
124
  provider: ProviderName;
125
125
  model: string;
126
+ /** Provider detail may echo private input or credentials. Do not log verbatim. */
126
127
  error: string;
127
128
  /** True when this attempt failed because the model declined (vs. an infra error). */
128
129
  declined?: boolean;
129
130
  }
130
- /** Error thrown when an LLM provider call fails. */
131
+ /** Error thrown when an LLM provider call fails. Its message may contain private input; do not log verbatim. */
131
132
  export declare class LLMError extends Error {
132
133
  provider: ProviderName;
133
134
  model: string;
package/dist/llm/types.js CHANGED
@@ -1,4 +1,4 @@
1
- /** Error thrown when an LLM provider call fails. */
1
+ /** Error thrown when an LLM provider call fails. Its message may contain private input; do not log verbatim. */
2
2
  export class LLMError extends Error {
3
3
  provider;
4
4
  model;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve31415/baselib",
3
- "version": "3.8.2",
3
+ "version": "3.8.3",
4
4
  "description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, HTTP, sync, app updates",
5
5
  "type": "module",
6
6
  "license": "MIT",