@xynogen/pix-runtime 0.7.0 → 0.8.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 +1 -1
- package/src/extension.ts +3 -1
- package/src/herdr-state.ts +31 -1
- package/src/index.ts +6 -0
package/package.json
CHANGED
package/src/extension.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { bindHerdrNotify } from "./herdr-notify.ts";
|
|
3
|
-
import { bindAgentStateEvents, resetAgentState } from "./herdr-state.ts";
|
|
3
|
+
import { bindAgentStateEvents, resetAgentState, resetUnattendedState } from "./herdr-state.ts";
|
|
4
4
|
import { once } from "./once.ts";
|
|
5
5
|
import { registerPixCommand } from "./pix-command.ts";
|
|
6
6
|
import { pixRuntime } from "./runtime.ts";
|
|
@@ -23,6 +23,7 @@ export default function registerRuntime(pi: ExtensionAPI): void {
|
|
|
23
23
|
|
|
24
24
|
let initialized = false;
|
|
25
25
|
pi.on("session_start", async () => {
|
|
26
|
+
resetUnattendedState(pi.events);
|
|
26
27
|
if (initialized) {
|
|
27
28
|
await runtime.reload({ origin: "reload", source: "session_start" });
|
|
28
29
|
} else {
|
|
@@ -34,6 +35,7 @@ export default function registerRuntime(pi: ExtensionAPI): void {
|
|
|
34
35
|
|
|
35
36
|
pi.on("session_shutdown", async () => {
|
|
36
37
|
resetAgentState(pi.events);
|
|
38
|
+
resetUnattendedState(pi.events);
|
|
37
39
|
unbindHerdrNotify();
|
|
38
40
|
unbindAgentState();
|
|
39
41
|
await runtime.flush();
|
package/src/herdr-state.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EventBus } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
3
|
export type PixAgentState = "working" | "blocked" | "idle";
|
|
4
|
+
export type UnattendedMode = "off" | "afk" | "yolo";
|
|
4
5
|
export type PixAgentStateEvent = {
|
|
5
6
|
state: PixAgentState;
|
|
6
7
|
message?: string;
|
|
@@ -12,6 +13,8 @@ type Entry = { source: string; message?: string };
|
|
|
12
13
|
type Coordinator = {
|
|
13
14
|
activities: Map<symbol, Entry>;
|
|
14
15
|
blocks: Map<symbol, Entry>;
|
|
16
|
+
unattendedMode: UnattendedMode;
|
|
17
|
+
yoloConsent: boolean;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
function coordinators(): WeakMap<EventBus, Coordinator> {
|
|
@@ -24,7 +27,12 @@ function coordinator(events: EventBus): Coordinator {
|
|
|
24
27
|
const registry = coordinators();
|
|
25
28
|
let state = registry.get(events);
|
|
26
29
|
if (!state) {
|
|
27
|
-
state = {
|
|
30
|
+
state = {
|
|
31
|
+
activities: new Map(),
|
|
32
|
+
blocks: new Map(),
|
|
33
|
+
unattendedMode: "off",
|
|
34
|
+
yoloConsent: false,
|
|
35
|
+
};
|
|
28
36
|
registry.set(events, state);
|
|
29
37
|
}
|
|
30
38
|
return state;
|
|
@@ -100,6 +108,28 @@ export async function withAgentBlock<T>(
|
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
110
|
|
|
111
|
+
export function getUnattendedMode(events: EventBus): UnattendedMode {
|
|
112
|
+
return coordinator(events).unattendedMode;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function setUnattendedMode(events: EventBus, mode: UnattendedMode): void {
|
|
116
|
+
coordinator(events).unattendedMode = mode;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function hasYoloConsent(events: EventBus): boolean {
|
|
120
|
+
return coordinator(events).yoloConsent;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function setYoloConsent(events: EventBus, consent: boolean): void {
|
|
124
|
+
coordinator(events).yoloConsent = consent;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function resetUnattendedState(events: EventBus): void {
|
|
128
|
+
const state = coordinator(events);
|
|
129
|
+
state.unattendedMode = "off";
|
|
130
|
+
state.yoloConsent = false;
|
|
131
|
+
}
|
|
132
|
+
|
|
103
133
|
/** Bind state replay/reset to one Pi session lifecycle. */
|
|
104
134
|
export function bindAgentStateEvents(events: EventBus): () => void {
|
|
105
135
|
const off = events.on("pix:agent-state:request", () => publish(events));
|
package/src/index.ts
CHANGED
|
@@ -11,9 +11,15 @@ export { bindHerdrNotify } from "./herdr-notify.ts";
|
|
|
11
11
|
export {
|
|
12
12
|
beginAgentActivity,
|
|
13
13
|
bindAgentStateEvents,
|
|
14
|
+
getUnattendedMode,
|
|
15
|
+
hasYoloConsent,
|
|
14
16
|
type PixAgentState,
|
|
15
17
|
type PixAgentStateEvent,
|
|
16
18
|
resetAgentState,
|
|
19
|
+
resetUnattendedState,
|
|
20
|
+
setUnattendedMode,
|
|
21
|
+
setYoloConsent,
|
|
22
|
+
type UnattendedMode,
|
|
17
23
|
withAgentBlock,
|
|
18
24
|
} from "./herdr-state.ts";
|
|
19
25
|
export { ioTimeoutMs, ioTimeoutSignal } from "./io.ts";
|