erosolar-cli 2.1.201 → 2.1.203
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/agents/erosolar-code.rules.json +8 -13
- package/agents/general.rules.json +20 -33
- package/dist/core/agentOrchestrator.d.ts +8 -5
- package/dist/core/agentOrchestrator.d.ts.map +1 -1
- package/dist/core/agentOrchestrator.js +97 -143
- package/dist/core/agentOrchestrator.js.map +1 -1
- package/dist/core/errors/safetyValidator.d.ts +1 -40
- package/dist/core/errors/safetyValidator.d.ts.map +1 -1
- package/dist/core/errors/safetyValidator.js +1 -145
- package/dist/core/errors/safetyValidator.js.map +1 -1
- package/dist/core/reliabilityPrompt.d.ts.map +1 -1
- package/dist/core/reliabilityPrompt.js +10 -11
- package/dist/core/reliabilityPrompt.js.map +1 -1
- package/dist/providers/openaiResponsesProvider.d.ts +0 -5
- package/dist/providers/openaiResponsesProvider.d.ts.map +1 -1
- package/dist/providers/openaiResponsesProvider.js +1 -27
- package/dist/providers/openaiResponsesProvider.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +0 -2
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +4 -23
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/ui/PromptController.d.ts +1 -0
- package/dist/ui/PromptController.d.ts.map +1 -1
- package/dist/ui/PromptController.js +3 -0
- package/dist/ui/PromptController.js.map +1 -1
- package/dist/ui/UnifiedUIRenderer.d.ts +2 -0
- package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
- package/dist/ui/UnifiedUIRenderer.js +8 -1
- package/dist/ui/UnifiedUIRenderer.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/errors/errorUtils.d.ts +0 -87
- package/dist/core/errors/errorUtils.d.ts.map +0 -1
- package/dist/core/errors/errorUtils.js +0 -158
- package/dist/core/errors/errorUtils.js.map +0 -1
- package/dist/core/errors/promptBlockErrors.d.ts +0 -9
- package/dist/core/errors/promptBlockErrors.d.ts.map +0 -1
- package/dist/core/errors/promptBlockErrors.js +0 -49
- package/dist/core/errors/promptBlockErrors.js.map +0 -1
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enhanced Error Handling Utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides TypeScript-first error handling patterns with:
|
|
5
|
-
* - Result types for functional error handling
|
|
6
|
-
* - Async error recovery strategies
|
|
7
|
-
* - Structured error classification
|
|
8
|
-
* - Automatic error recovery suggestions
|
|
9
|
-
*/
|
|
10
|
-
import { ErrorCategory, ErrorSeverity, type StructuredError } from './errorTypes.js';
|
|
11
|
-
/**
|
|
12
|
-
* Result type for functional error handling
|
|
13
|
-
*/
|
|
14
|
-
export type Result<T, E = Error> = {
|
|
15
|
-
success: true;
|
|
16
|
-
data: T;
|
|
17
|
-
} | {
|
|
18
|
-
success: false;
|
|
19
|
-
error: E;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Async result type for promise-based operations
|
|
23
|
-
*/
|
|
24
|
-
export type AsyncResult<T, E = Error> = Promise<Result<T, E>>;
|
|
25
|
-
/**
|
|
26
|
-
* Error recovery strategy
|
|
27
|
-
*/
|
|
28
|
-
export interface ErrorRecoveryStrategy {
|
|
29
|
-
readonly id: string;
|
|
30
|
-
readonly label: string;
|
|
31
|
-
readonly description: string;
|
|
32
|
-
readonly action: () => unknown;
|
|
33
|
-
readonly autoRecoverable: boolean;
|
|
34
|
-
readonly confidence: 'high' | 'medium' | 'low';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Enhanced error with recovery strategies
|
|
38
|
-
*/
|
|
39
|
-
export interface RecoverableError extends Error {
|
|
40
|
-
readonly category: ErrorCategory;
|
|
41
|
-
readonly severity: ErrorSeverity;
|
|
42
|
-
readonly recoveryStrategies: ErrorRecoveryStrategy[];
|
|
43
|
-
readonly structured?: StructuredError;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Create a recoverable error
|
|
47
|
-
*/
|
|
48
|
-
export declare function createRecoverableError(message: string, category: ErrorCategory, severity: ErrorSeverity, recoveryStrategies: ErrorRecoveryStrategy[], structured?: StructuredError): RecoverableError;
|
|
49
|
-
/**
|
|
50
|
-
* Wrap a function with error recovery
|
|
51
|
-
*/
|
|
52
|
-
export declare function withErrorRecovery<T, Args extends unknown[]>(fn: (...args: Args) => T | Promise<T>, recoveryStrategies: ErrorRecoveryStrategy[]): (...args: Args) => Promise<T>;
|
|
53
|
-
/**
|
|
54
|
-
* Execute with automatic retry on recoverable errors
|
|
55
|
-
*/
|
|
56
|
-
export declare function executeWithRetry<T>(operation: () => Promise<T>, maxRetries?: number, delayMs?: number): Promise<T>;
|
|
57
|
-
/**
|
|
58
|
-
* Check if error is recoverable
|
|
59
|
-
*/
|
|
60
|
-
export declare function isRecoverableError(error: unknown): error is RecoverableError;
|
|
61
|
-
/**
|
|
62
|
-
* Extract recovery strategies from error
|
|
63
|
-
*/
|
|
64
|
-
export declare function extractRecoveryStrategies(error: unknown): ErrorRecoveryStrategy[];
|
|
65
|
-
/**
|
|
66
|
-
* Safe async execution with result type
|
|
67
|
-
*/
|
|
68
|
-
export declare function safeAsync<T>(operation: () => Promise<T>): AsyncResult<T>;
|
|
69
|
-
/**
|
|
70
|
-
* Safe synchronous execution with result type
|
|
71
|
-
*/
|
|
72
|
-
export declare function safeSync<T>(operation: () => T): Result<T>;
|
|
73
|
-
/**
|
|
74
|
-
* Chain multiple operations with error handling
|
|
75
|
-
*/
|
|
76
|
-
export declare function chainOperations<T>(operations: Array<() => Promise<T>>): () => Promise<Result<T>>;
|
|
77
|
-
/**
|
|
78
|
-
* Error handler registry for centralized error management
|
|
79
|
-
*/
|
|
80
|
-
export declare class ErrorHandlerRegistry {
|
|
81
|
-
private handlers;
|
|
82
|
-
register(handlerId: string, handler: (error: unknown) => void): void;
|
|
83
|
-
unregister(handlerId: string): void;
|
|
84
|
-
handle(error: unknown): void;
|
|
85
|
-
}
|
|
86
|
-
export declare const globalErrorHandlers: ErrorHandlerRegistry;
|
|
87
|
-
//# sourceMappingURL=errorUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../../../src/core/errors/errorUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,CAAC;IACrD,QAAQ,CAAC,UAAU,CAAC,EAA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M,CAAC,CAAC,CAAC,CAAC,CAa1B;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAA+C;IAE/D,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAIpE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAInC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAU7B;AAGD,eAAO,MAAM,mBAAmB,sBAA6B,CAAC"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enhanced Error Handling Utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides TypeScript-first error handling patterns with:
|
|
5
|
-
* - Result types for functional error handling
|
|
6
|
-
* - Async error recovery strategies
|
|
7
|
-
* - Structured error classification
|
|
8
|
-
* - Automatic error recovery suggestions
|
|
9
|
-
*/
|
|
10
|
-
import { ErrorCategory, ErrorSeverity } from './errorTypes.js';
|
|
11
|
-
/**
|
|
12
|
-
* Create a recoverable error
|
|
13
|
-
*/
|
|
14
|
-
export function createRecoverableError(message, category, severity, recoveryStrategies, structured) {
|
|
15
|
-
const error = new Error(message);
|
|
16
|
-
return Object.assign(error, {
|
|
17
|
-
category,
|
|
18
|
-
severity,
|
|
19
|
-
recoveryStrategies,
|
|
20
|
-
structured,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Wrap a function with error recovery
|
|
25
|
-
*/
|
|
26
|
-
export function withErrorRecovery(fn, recoveryStrategies) {
|
|
27
|
-
return async (...args) => {
|
|
28
|
-
try {
|
|
29
|
-
return await fn(...args);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
const recoverable = createRecoverableError(error instanceof Error ? error.message : String(error), ErrorCategory.UNKNOWN, ErrorSeverity.ERROR, recoveryStrategies);
|
|
33
|
-
throw recoverable;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Execute with automatic retry on recoverable errors
|
|
39
|
-
*/
|
|
40
|
-
export async function executeWithRetry(operation, maxRetries = 3, delayMs = 1000) {
|
|
41
|
-
let lastError;
|
|
42
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
43
|
-
try {
|
|
44
|
-
return await operation();
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
48
|
-
// Only retry on recoverable errors
|
|
49
|
-
if (!isRecoverableError(error) || attempt === maxRetries) {
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
// Exponential backoff
|
|
53
|
-
await new Promise(resolve => setTimeout(resolve, delayMs * attempt));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw lastError || new Error('Operation failed after retries');
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Check if error is recoverable
|
|
60
|
-
*/
|
|
61
|
-
export function isRecoverableError(error) {
|
|
62
|
-
return (error instanceof Error &&
|
|
63
|
-
'recoveryStrategies' in error &&
|
|
64
|
-
Array.isArray(error.recoveryStrategies));
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Extract recovery strategies from error
|
|
68
|
-
*/
|
|
69
|
-
export function extractRecoveryStrategies(error) {
|
|
70
|
-
if (isRecoverableError(error)) {
|
|
71
|
-
return error.recoveryStrategies;
|
|
72
|
-
}
|
|
73
|
-
// Default recovery strategies based on error type
|
|
74
|
-
const defaultStrategies = [
|
|
75
|
-
{
|
|
76
|
-
id: 'retry-operation',
|
|
77
|
-
label: 'Retry Operation',
|
|
78
|
-
description: 'Attempt the operation again',
|
|
79
|
-
action: () => { },
|
|
80
|
-
autoRecoverable: true,
|
|
81
|
-
confidence: 'medium'
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
return defaultStrategies;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Safe async execution with result type
|
|
88
|
-
*/
|
|
89
|
-
export async function safeAsync(operation) {
|
|
90
|
-
try {
|
|
91
|
-
const data = await operation();
|
|
92
|
-
return { success: true, data };
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
return {
|
|
96
|
-
success: false,
|
|
97
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Safe synchronous execution with result type
|
|
103
|
-
*/
|
|
104
|
-
export function safeSync(operation) {
|
|
105
|
-
try {
|
|
106
|
-
const data = operation();
|
|
107
|
-
return { success: true, data };
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
return {
|
|
111
|
-
success: false,
|
|
112
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Chain multiple operations with error handling
|
|
118
|
-
*/
|
|
119
|
-
export function chainOperations(operations) {
|
|
120
|
-
return async () => {
|
|
121
|
-
for (const operation of operations) {
|
|
122
|
-
const result = await safeAsync(operation);
|
|
123
|
-
if (result.success) {
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
success: false,
|
|
129
|
-
error: new Error('All operations failed in chain')
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Error handler registry for centralized error management
|
|
135
|
-
*/
|
|
136
|
-
export class ErrorHandlerRegistry {
|
|
137
|
-
handlers = new Map();
|
|
138
|
-
register(handlerId, handler) {
|
|
139
|
-
this.handlers.set(handlerId, handler);
|
|
140
|
-
}
|
|
141
|
-
unregister(handlerId) {
|
|
142
|
-
this.handlers.delete(handlerId);
|
|
143
|
-
}
|
|
144
|
-
handle(error) {
|
|
145
|
-
for (const handler of this.handlers.values()) {
|
|
146
|
-
try {
|
|
147
|
-
handler(error);
|
|
148
|
-
}
|
|
149
|
-
catch (handlerError) {
|
|
150
|
-
// Don't let handler errors break the error handling chain
|
|
151
|
-
console.error('Error handler failed:', handlerError);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// Global error handler registry
|
|
157
|
-
export const globalErrorHandlers = new ErrorHandlerRegistry();
|
|
158
|
-
//# sourceMappingURL=errorUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../../src/core/errors/errorUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAwB,MAAM,iBAAiB,CAAC;AAoCrF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAe,EACf,QAAuB,EACvB,QAAuB,EACvB,kBAA2C,EAC3C,UAA4B;IAE5B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;QAC1B,QAAQ;QACR,QAAQ;QACR,kBAAkB;QAClB,UAAU;KACX,CAAqB,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAqC,EACrC,kBAA2C;IAE3C,OAAO,KAAK,EAAE,GAAG,IAAU,EAAc,EAAE;QACzC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,WAAW,GAAG,sBAAsB,CACxC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,aAAa,CAAC,OAAO,EACrB,aAAa,CAAC,KAAK,EACnB,kBAAkB,CACnB,CAAC;YACF,M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S,CAAC,SAAS,CAAC,CAAC;YAC1C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,KAAK,CAAC,gCAAgC,CAAC;SACnD,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACvB,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;IAE/D,QAAQ,CAAC,SAAiB,EAAE,OAAiC;QAC3D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,UAAU,CAAC,SAAiB;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAc;QACnB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACtB,0DAA0D;gBAC1D,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,gCAAgC;AAChC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ProviderId } from '../types.js';
|
|
2
|
-
export interface PromptBlockErrorInfo {
|
|
3
|
-
provider: ProviderId | null;
|
|
4
|
-
message: string;
|
|
5
|
-
helpUrl?: string | null;
|
|
6
|
-
originalMessage?: string | null;
|
|
7
|
-
}
|
|
8
|
-
export declare function detectPromptBlockError(error: unknown): PromptBlockErrorInfo | null;
|
|
9
|
-
//# sourceMappingURL=promptBlockErrors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promptBlockErrors.d.ts","sourceRoot":"","sources":["../../../src/core/errors/promptBlockErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AA2BD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CA0BlF"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const POLICY_HINTS = [
|
|
2
|
-
'invalid prompt',
|
|
3
|
-
'prompt was flagged',
|
|
4
|
-
'usage policy',
|
|
5
|
-
'policy violation',
|
|
6
|
-
'blocked this prompt',
|
|
7
|
-
'safety',
|
|
8
|
-
];
|
|
9
|
-
function extractMessage(error) {
|
|
10
|
-
if (typeof error === 'string')
|
|
11
|
-
return error;
|
|
12
|
-
if (error instanceof Error)
|
|
13
|
-
return error.message ?? '';
|
|
14
|
-
if (error && typeof error === 'object' && 'message' in error && typeof error.message === 'string') {
|
|
15
|
-
return error.message;
|
|
16
|
-
}
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
function normalizeProvider(value) {
|
|
20
|
-
if (typeof value === 'string' && value.trim()) {
|
|
21
|
-
return value.trim();
|
|
22
|
-
}
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
export function detectPromptBlockError(error) {
|
|
26
|
-
if (!error)
|
|
27
|
-
return null;
|
|
28
|
-
const code = error.code;
|
|
29
|
-
const status = error.status;
|
|
30
|
-
const provider = normalizeProvider(error.provider);
|
|
31
|
-
const helpUrl = typeof error.helpUrl === 'string' ? error.helpUrl : null;
|
|
32
|
-
const originalMessage = typeof error.originalMessage === 'string'
|
|
33
|
-
? error.originalMessage
|
|
34
|
-
: null;
|
|
35
|
-
const message = extractMessage(error);
|
|
36
|
-
const normalized = message.toLowerCase();
|
|
37
|
-
const hasPolicyHint = POLICY_HINTS.some(hint => normalized.includes(hint));
|
|
38
|
-
const isPolicyStatus = typeof status === 'number' && (status === 400 || status === 403);
|
|
39
|
-
if (code === 'prompt_blocked' || (hasPolicyHint && isPolicyStatus)) {
|
|
40
|
-
return {
|
|
41
|
-
provider,
|
|
42
|
-
message: message || 'The provider blocked this prompt for policy reasons.',
|
|
43
|
-
helpUrl,
|
|
44
|
-
originalMessage: originalMessage ?? message,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=promptBlockErrors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promptBlockErrors.js","sourceRoot":"","sources":["../../../src/core/errors/promptBlockErrors.ts"],"names":[],"mappings":"AASA,MAAM,YAAY,GAAG;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,kBAAkB;IAClB,qBAAqB;IACrB,QAAQ;CACA,CAAC;AAEX,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACvD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,IAAI,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC7H,OAAQ,KAA6B,CAAC,OAAO,CAAC;IAChD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QA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