@aliou/pi-processes 0.8.1 → 0.9.0
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/package.json +5 -5
- package/src/hooks/process-end.ts +3 -1
- package/src/hooks/process-watch.ts +3 -1
- package/src/hooks/utils.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-processes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"typebox": "^1.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@mariozechner/pi-coding-agent": "0.
|
|
43
|
-
"@mariozechner/pi-tui": "0.
|
|
42
|
+
"@mariozechner/pi-coding-agent": "0.72.1",
|
|
43
|
+
"@mariozechner/pi-tui": "0.72.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@aliou/biome-plugins": "^0.3.2",
|
|
47
47
|
"@biomejs/biome": "^2.3.13",
|
|
48
48
|
"@changesets/cli": "^2.27.11",
|
|
49
|
-
"@mariozechner/pi-ai": "0.
|
|
50
|
-
"@mariozechner/pi-coding-agent": "0.
|
|
49
|
+
"@mariozechner/pi-ai": "0.72.1",
|
|
50
|
+
"@mariozechner/pi-coding-agent": "0.72.1",
|
|
51
51
|
"@types/node": "^25.0.10",
|
|
52
52
|
"husky": "^9.1.7",
|
|
53
53
|
"typescript": "^5.9.3",
|
package/src/hooks/process-end.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
|
2
2
|
import { MESSAGE_TYPE_PROCESS_UPDATE, type ProcessInfo } from "../constants";
|
|
3
3
|
import type { ProcessManager } from "../manager";
|
|
4
4
|
import { formatRuntime } from "../utils";
|
|
5
|
+
import { safeSendMessage } from "./utils";
|
|
5
6
|
|
|
6
7
|
interface ProcessUpdateDetails {
|
|
7
8
|
kind: "lifecycle";
|
|
@@ -54,7 +55,8 @@ export function setupProcessEndHook(pi: ExtensionAPI, manager: ProcessManager) {
|
|
|
54
55
|
runtime,
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
safeSendMessage(
|
|
59
|
+
pi,
|
|
58
60
|
{
|
|
59
61
|
customType: MESSAGE_TYPE_PROCESS_UPDATE,
|
|
60
62
|
content: message,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
2
|
import { MESSAGE_TYPE_PROCESS_UPDATE } from "../constants";
|
|
3
3
|
import type { ProcessManager } from "../manager";
|
|
4
|
+
import { safeSendMessage } from "./utils";
|
|
4
5
|
|
|
5
6
|
interface ProcessWatchUpdateDetails {
|
|
6
7
|
kind: "watch_matched";
|
|
@@ -70,7 +71,8 @@ export function setupProcessWatchHook(
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
safeSendMessage(
|
|
75
|
+
pi,
|
|
74
76
|
{
|
|
75
77
|
customType: MESSAGE_TYPE_PROCESS_UPDATE,
|
|
76
78
|
content: message,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Send a message via pi, swallowing stale-context errors.
|
|
5
|
+
*
|
|
6
|
+
* After /new, /resume, or /fork, the pi proxy is invalidated and all
|
|
7
|
+
* method calls throw. This wrapper catches that specific error so the
|
|
8
|
+
* extension doesn't crash — the event is simply lost for the old session.
|
|
9
|
+
*/
|
|
10
|
+
export function safeSendMessage(
|
|
11
|
+
pi: ExtensionAPI,
|
|
12
|
+
message: Parameters<ExtensionAPI["sendMessage"]>[0],
|
|
13
|
+
options?: Parameters<ExtensionAPI["sendMessage"]>[1],
|
|
14
|
+
): void {
|
|
15
|
+
try {
|
|
16
|
+
pi.sendMessage(message, options);
|
|
17
|
+
} catch (err: unknown) {
|
|
18
|
+
if (err instanceof Error && err.message.includes("stale")) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|