@oisin-ee/pi-dogsled 0.37.1 → 0.37.2
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 -2
- package/package.json +1 -1
- package/pi/activity.ts +53 -26
package/README.md
CHANGED
|
@@ -13,13 +13,13 @@ Install the binary on each Herdr host. Use the same release tag in each command.
|
|
|
13
13
|
Binary:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
|
-
mise use github:oisin-ee/dogsled@v0.37.
|
|
16
|
+
mise use github:oisin-ee/dogsled@v0.37.2 # x-release-please-version
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Pi (extension, tools, the `todo` tool, and skill), from npm:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
pi install npm:@oisin-ee/pi-dogsled@0.37.
|
|
22
|
+
pi install npm:@oisin-ee/pi-dogsled@0.37.2 # x-release-please-version
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
At session start the extension compares its version with `dogsled --version` and warns when they differ.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oisin-ee/pi-dogsled",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.2",
|
|
4
4
|
"description": "Pi extension for dogsled: the board, the /dogsled panel, the inbox reader, and the dogsled tools. Needs the dogsled binary of the same version.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/pi/activity.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import type { PortalClient } from "./portal-client.ts";
|
|
6
6
|
|
|
7
|
-
export type Phase = "idle" | "working" | "thinking" | "responding" | "tool_running";
|
|
7
|
+
export type Phase = "idle" | "working" | "thinking" | "responding" | "tool_running" | "compacting";
|
|
8
8
|
export interface ActiveTool {
|
|
9
9
|
call_id: string;
|
|
10
10
|
name: string;
|
|
@@ -17,6 +17,7 @@ export type Payload =
|
|
|
17
17
|
| { kind: "closed" };
|
|
18
18
|
export type ActivityEvent =
|
|
19
19
|
| { type: "agent_start" | "agent_end" | "settled" | "message_end" }
|
|
20
|
+
| { type: "compaction"; running: boolean }
|
|
20
21
|
| {
|
|
21
22
|
type: "block";
|
|
22
23
|
index: number;
|
|
@@ -61,6 +62,7 @@ export class ActivityReducer {
|
|
|
61
62
|
private tools = new Map<string, ActiveTool>();
|
|
62
63
|
private gap: "resyncing" | "overflow" | undefined;
|
|
63
64
|
private idle: boolean;
|
|
65
|
+
private compacting = false;
|
|
64
66
|
|
|
65
67
|
constructor(idle: boolean) {
|
|
66
68
|
this.idle = idle;
|
|
@@ -74,36 +76,51 @@ export class ActivityReducer {
|
|
|
74
76
|
this.tools.clear();
|
|
75
77
|
this.gap = undefined;
|
|
76
78
|
this.idle = true;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!event.ended) this.blocks.set(event.index, event.phase);
|
|
86
|
-
if (event.phase === "thinking") {
|
|
87
|
-
this.thoughts.set(
|
|
88
|
-
event.index,
|
|
89
|
-
(this.thoughts.get(event.index) ?? "") + (event.delta ?? ""),
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
} else if (event.type === "tool_start") {
|
|
93
|
-
this.idle = false;
|
|
94
|
-
this.tools.set(event.tool.call_id, { ...event.tool });
|
|
95
|
-
} else if (event.type === "tool_end") this.tools.delete(event.id);
|
|
96
|
-
if (this.blocks.size > 64 || this.thoughts.size > 64 || this.tools.size > 64) {
|
|
97
|
-
this.gap = "overflow";
|
|
98
|
-
this.blocks.clear();
|
|
99
|
-
this.thoughts.clear();
|
|
100
|
-
this.tools.clear();
|
|
101
|
-
}
|
|
79
|
+
this.compacting = false;
|
|
80
|
+
} else if (event.type === "compaction") {
|
|
81
|
+
// Pi compacts between turns, so the compaction is the session's whole activity.
|
|
82
|
+
this.compacting = event.running;
|
|
83
|
+
} else {
|
|
84
|
+
// A new run starts only after any compaction ended.
|
|
85
|
+
if (event.type === "agent_start") this.compacting = false;
|
|
86
|
+
if (!this.gap) this.step(event);
|
|
102
87
|
}
|
|
103
88
|
return this.snapshot();
|
|
104
89
|
}
|
|
105
90
|
|
|
91
|
+
private step(event: ActivityEvent): void {
|
|
92
|
+
if (event.type === "agent_start" || event.type === "agent_end") this.idle = false;
|
|
93
|
+
else if (event.type === "message_end") {
|
|
94
|
+
this.blocks.clear();
|
|
95
|
+
this.thoughts.clear();
|
|
96
|
+
} else if (event.type === "block") {
|
|
97
|
+
this.idle = false;
|
|
98
|
+
this.blocks.delete(event.index);
|
|
99
|
+
if (!event.ended) this.blocks.set(event.index, event.phase);
|
|
100
|
+
if (event.phase === "thinking") {
|
|
101
|
+
this.thoughts.set(
|
|
102
|
+
event.index,
|
|
103
|
+
(this.thoughts.get(event.index) ?? "") + (event.delta ?? ""),
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
} else if (event.type === "tool_start") {
|
|
107
|
+
this.idle = false;
|
|
108
|
+
this.tools.set(event.tool.call_id, { ...event.tool });
|
|
109
|
+
} else if (event.type === "tool_end") this.tools.delete(event.id);
|
|
110
|
+
if (this.blocks.size > 64 || this.thoughts.size > 64 || this.tools.size > 64) {
|
|
111
|
+
this.gap = "overflow";
|
|
112
|
+
this.blocks.clear();
|
|
113
|
+
this.thoughts.clear();
|
|
114
|
+
this.tools.clear();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
106
118
|
snapshot(): Payload {
|
|
119
|
+
// Compaction runs between turns, with no tool or block open, so it is known even when
|
|
120
|
+
// the turn's own detail is not.
|
|
121
|
+
if (this.compacting) {
|
|
122
|
+
return { kind: "snapshot", state: { phase: "compacting", active_tools: [] } };
|
|
123
|
+
}
|
|
107
124
|
if (this.gap) return { kind: "unavailable", reason: this.gap };
|
|
108
125
|
const active_tools = [...this.tools.values()].map((tool) => ({ ...tool }));
|
|
109
126
|
const phase = active_tools.length
|
|
@@ -590,4 +607,14 @@ export function registerActivity(pi: ExtensionAPI, client: Client, pane: string
|
|
|
590
607
|
pi.on("tool_execution_end", (event) => {
|
|
591
608
|
runtime?.event({ type: "tool_end", id: event.toolCallId });
|
|
592
609
|
});
|
|
610
|
+
// Pi reports every started compaction's end, including a cancel, as one of these outcomes.
|
|
611
|
+
pi.on("session_before_compact", () => {
|
|
612
|
+
runtime?.event({ type: "compaction", running: true });
|
|
613
|
+
});
|
|
614
|
+
pi.on("session_compact", () => {
|
|
615
|
+
runtime?.event({ type: "compaction", running: false });
|
|
616
|
+
});
|
|
617
|
+
pi.on("session_compact_failed", () => {
|
|
618
|
+
runtime?.event({ type: "compaction", running: false });
|
|
619
|
+
});
|
|
593
620
|
}
|