pi-jev-lens 0.4.0 → 0.4.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/README.md +2 -0
- package/package.json +1 -1
- package/src/health.ts +24 -4
package/README.md
CHANGED
|
@@ -282,4 +282,6 @@ Issues and pull requests are welcome at [github.com/dizk/pi-jev-lens](https://gi
|
|
|
282
282
|
built or chosen must come with benchmark numbers. If the change touches code views, you must use the 500-trajectory
|
|
283
283
|
slice.
|
|
284
284
|
|
|
285
|
+
For npm publication through GitHub Releases, see [Release to npm](docs/releasing.md).
|
|
286
|
+
|
|
285
287
|
MIT, see LICENSE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-jev-lens",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "pi extension that compresses large tool results before they reach the model: jev picks the view (outline, relevant blocks, sections, signals, testlog), full text stays recallable",
|
|
5
5
|
"author": "Didrik Rognstad",
|
|
6
6
|
"license": "MIT",
|
package/src/health.ts
CHANGED
|
@@ -2,6 +2,29 @@ export type Stage = "presend" | "postsend";
|
|
|
2
2
|
|
|
3
3
|
type StageHealth = { failures: number; failing: boolean; reason: string; notified: boolean };
|
|
4
4
|
|
|
5
|
+
/** Report only validated status codes and fixed advice, never raw provider data. */
|
|
6
|
+
function failureReason(error: unknown): string {
|
|
7
|
+
const e = error && typeof error === "object" ? error as { status?: unknown; name?: unknown } : {};
|
|
8
|
+
const status = typeof e.status === "number" && Number.isInteger(e.status) && e.status >= 100 && e.status <= 599 ? e.status : undefined;
|
|
9
|
+
if (status !== undefined) {
|
|
10
|
+
const advice = status === 402 ? "Payment required. Check your TypeSafe credits and billing at https://console.typesafe.ai."
|
|
11
|
+
: status === 401 ? "Authentication failed. Check your TypeSafe API key."
|
|
12
|
+
: status === 403 ? "Access denied. Check your TypeSafe API key and account permissions."
|
|
13
|
+
: status === 429 ? "TypeSafe rejected the request because of a usage limit. Check your rate limits and quota at https://console.typesafe.ai."
|
|
14
|
+
: status === 400 || status === 422 ? "TypeSafe rejected the request format. Check SDK compatibility and the model configuration."
|
|
15
|
+
: status === 404 ? "TypeSafe could not find the requested resource. Check the model and API endpoint."
|
|
16
|
+
: status === 408 || status === 504 ? "The API request timed out. Retry later."
|
|
17
|
+
: status >= 500 ? "TypeSafe reported a server error. Retry later and check service availability."
|
|
18
|
+
: "TypeSafe returned an unexpected HTTP response. Check service availability and account settings.";
|
|
19
|
+
return `HTTP ${status}: ${advice}`;
|
|
20
|
+
}
|
|
21
|
+
if (e.name === "APITimeoutError" || e.name === "TimeoutError") return "Request timed out (no HTTP status). Check your connection and TypeSafe service availability.";
|
|
22
|
+
if (e.name === "APIConnectionError") return "Connection failed (no HTTP status). Check your network, proxy, and TypeSafe service availability.";
|
|
23
|
+
if (e.name === "TypeSafeError") return "TypeSafe SDK error (no HTTP status). Check SDK compatibility and configuration.";
|
|
24
|
+
if (e.name === "TypeError" || e.name === "RangeError" || e.name === "SyntaxError") return `${e.name} during compression (no HTTP status). The cause is unknown. Report this as a jev-lens bug if it persists.`;
|
|
25
|
+
return "Unclassified error (no HTTP status). The cause is unknown. Report this as a jev-lens bug if it persists.";
|
|
26
|
+
}
|
|
27
|
+
|
|
5
28
|
/** Session-local failure counters. Never expose provider error messages or credentials. */
|
|
6
29
|
export class Health {
|
|
7
30
|
private stages: Record<Stage, StageHealth> = {
|
|
@@ -10,10 +33,7 @@ export class Health {
|
|
|
10
33
|
};
|
|
11
34
|
|
|
12
35
|
failure(stage: Stage, error: unknown): void {
|
|
13
|
-
const
|
|
14
|
-
const reason = status === 401 || status === 403 ? "Check your TypeSafe API key."
|
|
15
|
-
: status === 429 ? "TypeSafe rejected the request because of a usage limit."
|
|
16
|
-
: "Check your connection and TypeSafe service availability.";
|
|
36
|
+
const reason = failureReason(error);
|
|
17
37
|
Object.assign(this.stages[stage], { failures: this.stages[stage].failures + 1, failing: true, reason });
|
|
18
38
|
}
|
|
19
39
|
|