@narumitw/pi-retry 0.1.11 → 0.1.12
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 +3 -0
- package/package.json +1 -1
- package/src/unknown-error-retry.ts +24 -2
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Use it to make Pi sessions more resilient when an upstream AI provider returns a
|
|
|
12
12
|
- Matches the known provider error text `Unknown error (no error details in response)`.
|
|
13
13
|
- Appends Pi's retryable-provider-error hint.
|
|
14
14
|
- Lets Pi's built-in retry path continue the turn.
|
|
15
|
+
- Shows a short-lived statusline item only when a matching error triggers retry.
|
|
15
16
|
- Requires no commands or configuration.
|
|
16
17
|
- Works as a small, focused npm Pi extension package.
|
|
17
18
|
|
|
@@ -37,6 +38,8 @@ pi -e ./extensions/pi-retry
|
|
|
37
38
|
|
|
38
39
|
When an assistant message ends with `stopReason: "error"` and the error message matches `Unknown error (no error details in response)`, the extension appends Pi's retryable-provider-error hint so Pi's built-in retry path can continue the turn.
|
|
39
40
|
|
|
41
|
+
The extension does not keep a permanent statusline entry. It briefly shows `unknown-error retry: retrying` only when it has matched the error and asked Pi to retry.
|
|
42
|
+
|
|
40
43
|
## 🧠 Use cases
|
|
41
44
|
|
|
42
45
|
- Reduce manual restarts after transient provider failures.
|
package/package.json
CHANGED
|
@@ -3,14 +3,35 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
|
3
3
|
const UNKNOWN_NO_DETAILS_RE = /Unknown error \(no error details in response\)/i;
|
|
4
4
|
const RETRYABLE_HINT = "provider returned error";
|
|
5
5
|
const EXTENSION_TAG = "[unknown-error-retry]";
|
|
6
|
+
const STATUS_KEY = "unknown-error-retry";
|
|
7
|
+
const STATUS_VISIBLE_MS = 8_000;
|
|
6
8
|
|
|
7
9
|
export default function unknownErrorRetry(pi: ExtensionAPI) {
|
|
10
|
+
let clearStatusTimer: NodeJS.Timeout | undefined;
|
|
11
|
+
|
|
12
|
+
const clearStatus = (ctx: { ui: { setStatus: (key: string, value: string | undefined) => void } }) => {
|
|
13
|
+
if (clearStatusTimer) clearTimeout(clearStatusTimer);
|
|
14
|
+
clearStatusTimer = undefined;
|
|
15
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const showTransientStatus = (ctx: {
|
|
19
|
+
ui: { setStatus: (key: string, value: string | undefined) => void };
|
|
20
|
+
}) => {
|
|
21
|
+
if (clearStatusTimer) clearTimeout(clearStatusTimer);
|
|
22
|
+
ctx.ui.setStatus(STATUS_KEY, "unknown-error retry: retrying");
|
|
23
|
+
clearStatusTimer = setTimeout(() => {
|
|
24
|
+
clearStatusTimer = undefined;
|
|
25
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
26
|
+
}, STATUS_VISIBLE_MS);
|
|
27
|
+
};
|
|
28
|
+
|
|
8
29
|
pi.on("session_start", (_event, ctx) => {
|
|
9
|
-
ctx
|
|
30
|
+
clearStatus(ctx);
|
|
10
31
|
});
|
|
11
32
|
|
|
12
33
|
pi.on("session_shutdown", (_event, ctx) => {
|
|
13
|
-
ctx
|
|
34
|
+
clearStatus(ctx);
|
|
14
35
|
});
|
|
15
36
|
|
|
16
37
|
pi.on("message_end", (event, ctx) => {
|
|
@@ -37,6 +58,7 @@ export default function unknownErrorRetry(pi: ExtensionAPI) {
|
|
|
37
58
|
const errorMessage = `${message.errorMessage}\n\n${EXTENSION_TAG} ${RETRYABLE_HINT}; treating empty-detail provider failure as retryable.`;
|
|
38
59
|
|
|
39
60
|
if (ctx.hasUI) {
|
|
61
|
+
showTransientStatus(ctx);
|
|
40
62
|
ctx.ui.notify(
|
|
41
63
|
"Matched provider 'Unknown error (no error details in response)'; letting pi auto-retry this turn.",
|
|
42
64
|
"warning",
|