@howaboua/pi-shepherdr 0.2.13 → 0.2.15
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/CHANGELOG.md +14 -0
- package/README.md +11 -5
- package/package.json +6 -6
- package/src/agents-answer.ts +22 -0
- package/src/agents-discovery.ts +2 -2
- package/src/agents-tool.ts +2 -1
- package/src/ask-answer.ts +32 -18
- package/src/board/awareness.ts +115 -0
- package/src/board/host.ts +59 -6
- package/src/board/tool.ts +0 -3
- package/src/context-briefing.ts +226 -0
- package/src/controller.ts +81 -14
- package/src/delivery.ts +33 -0
- package/src/messages.ts +141 -15
- package/src/monitor-questions.ts +249 -0
- package/src/monitor-record.ts +6 -0
- package/src/monitor-state.ts +10 -4
- package/src/monitor.ts +40 -2
- package/src/remote/shepherdr-session-watch.mjs +72 -0
- package/src/remote/shepherdr-session.mjs +32 -2
- package/src/remote/shepherdr.mjs +21 -1
- package/src/remote-client.ts +66 -24
- package/src/session-reader.ts +49 -3
- package/src/types.ts +2 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
buildSessionContext,
|
|
4
|
+
type ExtensionAPI,
|
|
5
|
+
type ExtensionContext,
|
|
6
|
+
} from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import type {
|
|
8
|
+
CODEX_CONTEXT_BRIEFING_TYPE,
|
|
9
|
+
CodexContextBriefing,
|
|
10
|
+
CodexContextBriefingHandler,
|
|
11
|
+
} from "@howaboua/pi-codex-conversion/developer-messages";
|
|
12
|
+
import { registerInferenceBriefing } from "./delivery.js";
|
|
13
|
+
|
|
14
|
+
// Conversion projects this durable protocol in inference, compaction and native replay.
|
|
15
|
+
const BRIEFING: typeof CODEX_CONTEXT_BRIEFING_TYPE = "codex-context-briefing";
|
|
16
|
+
|
|
17
|
+
export function registerContextBriefing(
|
|
18
|
+
pi: ExtensionAPI,
|
|
19
|
+
name: string,
|
|
20
|
+
relevant: (ctx: ExtensionContext) => boolean,
|
|
21
|
+
record: CodexContextBriefingHandler,
|
|
22
|
+
) {
|
|
23
|
+
const hosted = registerInferenceBriefing(pi, record);
|
|
24
|
+
const warned = new Set<string>();
|
|
25
|
+
pi.on("context_with_system", async (event, ctx) => {
|
|
26
|
+
if (hosted.hosted()) return;
|
|
27
|
+
if (
|
|
28
|
+
hosted.outdated &&
|
|
29
|
+
relevant(ctx) &&
|
|
30
|
+
!warned.has(ctx.sessionManager.getSessionId())
|
|
31
|
+
) {
|
|
32
|
+
warned.add(ctx.sessionManager.getSessionId());
|
|
33
|
+
ctx.ui.notify(
|
|
34
|
+
`Update Codex Conversion and reload to preserve ${name} briefings through its context rollover and native replay. Native Pi briefings and other agent tools remain available.`,
|
|
35
|
+
"warning",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
await record(ctx, undefined, event.messages);
|
|
40
|
+
return { messages: projectNative(ctx, event.messages) };
|
|
41
|
+
} catch (error) {
|
|
42
|
+
ctx.abort();
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function contextBriefingWindow(
|
|
49
|
+
ctx: ExtensionContext,
|
|
50
|
+
windowId?: string,
|
|
51
|
+
) {
|
|
52
|
+
const branch = ctx.sessionManager.getBranch();
|
|
53
|
+
const compaction = branch.findLastIndex(
|
|
54
|
+
(entry) =>
|
|
55
|
+
entry.type === "compaction" &&
|
|
56
|
+
!(
|
|
57
|
+
entry.details &&
|
|
58
|
+
typeof entry.details === "object" &&
|
|
59
|
+
"strategy" in entry.details &&
|
|
60
|
+
entry.details.strategy === "codex-context-window"
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
const boundary = branch.findLastIndex(
|
|
64
|
+
(entry) =>
|
|
65
|
+
entry.type === "custom_message" &&
|
|
66
|
+
entry.customType === "codex-context-window" &&
|
|
67
|
+
entry.details &&
|
|
68
|
+
typeof entry.details === "object" &&
|
|
69
|
+
"contextManagement" in entry.details &&
|
|
70
|
+
entry.details.contextManagement &&
|
|
71
|
+
typeof entry.details.contextManagement === "object" &&
|
|
72
|
+
"kind" in entry.details.contextManagement &&
|
|
73
|
+
entry.details.contextManagement.kind === "window",
|
|
74
|
+
);
|
|
75
|
+
return compaction > boundary
|
|
76
|
+
? branch[compaction]!.id
|
|
77
|
+
: (windowId ?? ctx.sessionManager.getSessionId());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function hasContextRollover(ctx: ExtensionContext): boolean {
|
|
81
|
+
return ctx.sessionManager.getBranch().some((entry) => {
|
|
82
|
+
if (entry.type === "compaction") return true;
|
|
83
|
+
if (
|
|
84
|
+
entry.type !== "custom_message" ||
|
|
85
|
+
entry.customType !== "codex-context-window" ||
|
|
86
|
+
!entry.details ||
|
|
87
|
+
typeof entry.details !== "object" ||
|
|
88
|
+
!("contextManagement" in entry.details)
|
|
89
|
+
)
|
|
90
|
+
return false;
|
|
91
|
+
const window = entry.details.contextManagement;
|
|
92
|
+
return Boolean(
|
|
93
|
+
window &&
|
|
94
|
+
typeof window === "object" &&
|
|
95
|
+
"kind" in window &&
|
|
96
|
+
window.kind === "window" &&
|
|
97
|
+
"windowNumber" in window &&
|
|
98
|
+
typeof window.windowNumber === "number" &&
|
|
99
|
+
window.windowNumber > 0,
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function recordContextBriefing(
|
|
105
|
+
pi: ExtensionAPI,
|
|
106
|
+
ctx: ExtensionContext,
|
|
107
|
+
owner: string,
|
|
108
|
+
key: string,
|
|
109
|
+
content: () => Promise<string | undefined>,
|
|
110
|
+
) {
|
|
111
|
+
const saved = ctx.sessionManager
|
|
112
|
+
.getEntries()
|
|
113
|
+
.findLast(
|
|
114
|
+
(entry) =>
|
|
115
|
+
entry.type === "custom" &&
|
|
116
|
+
entry.customType === BRIEFING &&
|
|
117
|
+
readBriefing(entry.data).owner === owner &&
|
|
118
|
+
readBriefing(entry.data).key === key,
|
|
119
|
+
);
|
|
120
|
+
if (saved?.type === "custom") {
|
|
121
|
+
// Tree may select an ancestor before its metadata child. Reuse immutable bytes/ID.
|
|
122
|
+
if (
|
|
123
|
+
!ctx.sessionManager
|
|
124
|
+
.getBranch()
|
|
125
|
+
.some(
|
|
126
|
+
(entry) =>
|
|
127
|
+
entry.type === "custom" &&
|
|
128
|
+
entry.customType === BRIEFING &&
|
|
129
|
+
readBriefing(entry.data).owner === owner &&
|
|
130
|
+
readBriefing(entry.data).key === key,
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
pi.appendEntry(BRIEFING, readBriefing(saved.data));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const value = await content();
|
|
137
|
+
if (value === undefined) return;
|
|
138
|
+
pi.appendEntry(BRIEFING, {
|
|
139
|
+
protocol: 1,
|
|
140
|
+
id: randomUUID(),
|
|
141
|
+
owner,
|
|
142
|
+
key,
|
|
143
|
+
content: value,
|
|
144
|
+
} satisfies CodexContextBriefing);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function projectNative(
|
|
148
|
+
ctx: ExtensionContext,
|
|
149
|
+
messages: NativeMessage[],
|
|
150
|
+
): NativeMessage[] {
|
|
151
|
+
const entries = ctx.sessionManager.getBranch().map((entry) => {
|
|
152
|
+
if (entry.type !== "custom" || entry.customType !== BRIEFING) return entry;
|
|
153
|
+
const briefing = readBriefing(entry.data);
|
|
154
|
+
return {
|
|
155
|
+
...entry,
|
|
156
|
+
type: "custom_message" as const,
|
|
157
|
+
content: briefing.content,
|
|
158
|
+
display: false,
|
|
159
|
+
details: briefing,
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
const reconstructed = buildSessionContext(entries).messages;
|
|
163
|
+
const positions = new Map<string, number[]>();
|
|
164
|
+
messages.forEach((message, index) => {
|
|
165
|
+
const key = messageKey(message);
|
|
166
|
+
const indices = positions.get(key) ?? [];
|
|
167
|
+
indices.push(index);
|
|
168
|
+
positions.set(key, indices);
|
|
169
|
+
});
|
|
170
|
+
const insertions = new Map<number, NativeMessage[]>();
|
|
171
|
+
let pending: NativeMessage[] = [];
|
|
172
|
+
let last = messages[0]?.role === "system" ? 0 : -1;
|
|
173
|
+
const insert = (index: number) => {
|
|
174
|
+
if (!pending.length) return;
|
|
175
|
+
const position =
|
|
176
|
+
messages[0]?.role === "system" ? Math.max(1, index) : index;
|
|
177
|
+
insertions.set(position, [...(insertions.get(position) ?? []), ...pending]);
|
|
178
|
+
pending = [];
|
|
179
|
+
};
|
|
180
|
+
for (const message of reconstructed) {
|
|
181
|
+
const index = positions.get(messageKey(message))?.shift();
|
|
182
|
+
if (index !== undefined) {
|
|
183
|
+
insert(index);
|
|
184
|
+
last = index;
|
|
185
|
+
} else if (message.role === "custom" && message.customType === BRIEFING) {
|
|
186
|
+
pending.push(message);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
insert(last + 1);
|
|
190
|
+
return messages
|
|
191
|
+
.flatMap((message, index) => [...(insertions.get(index) ?? []), message])
|
|
192
|
+
.concat(insertions.get(messages.length) ?? []);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
type NativeMessage = ReturnType<typeof buildSessionContext>["messages"][number];
|
|
196
|
+
function messageKey(message: NativeMessage) {
|
|
197
|
+
return JSON.stringify([
|
|
198
|
+
message.role,
|
|
199
|
+
message.timestamp,
|
|
200
|
+
message.role === "custom"
|
|
201
|
+
? message.customType === BRIEFING
|
|
202
|
+
? readBriefing(message.details).id
|
|
203
|
+
: message.customType
|
|
204
|
+
: message.role === "toolResult"
|
|
205
|
+
? message.toolCallId
|
|
206
|
+
: undefined,
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
function readBriefing(value: unknown): CodexContextBriefing {
|
|
210
|
+
if (
|
|
211
|
+
!value ||
|
|
212
|
+
typeof value !== "object" ||
|
|
213
|
+
!("protocol" in value) ||
|
|
214
|
+
value.protocol !== 1 ||
|
|
215
|
+
!("id" in value) ||
|
|
216
|
+
typeof value.id !== "string" ||
|
|
217
|
+
!("owner" in value) ||
|
|
218
|
+
typeof value.owner !== "string" ||
|
|
219
|
+
!("key" in value) ||
|
|
220
|
+
typeof value.key !== "string" ||
|
|
221
|
+
!("content" in value) ||
|
|
222
|
+
typeof value.content !== "string"
|
|
223
|
+
)
|
|
224
|
+
throw new Error("Invalid saved context briefing");
|
|
225
|
+
return value as CodexContextBriefing;
|
|
226
|
+
}
|
package/src/controller.ts
CHANGED
|
@@ -3,17 +3,19 @@ import type {
|
|
|
3
3
|
ExtensionContext,
|
|
4
4
|
} from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import type { AgentBoard } from "./board/host.js";
|
|
6
|
+
import {
|
|
7
|
+
contextBriefingWindow,
|
|
8
|
+
hasContextRollover,
|
|
9
|
+
recordContextBriefing,
|
|
10
|
+
registerContextBriefing,
|
|
11
|
+
} from "./context-briefing.js";
|
|
6
12
|
import { controlPanelStatus, openControlPanel } from "./control-panel.js";
|
|
7
13
|
import { sendPolicyMessage } from "./delivery.js";
|
|
8
14
|
import type { AgentFleet } from "./fleet.js";
|
|
15
|
+
import { activeAgentsBriefing, orchestrationGuidance } from "./messages.js";
|
|
9
16
|
import { loadAgentProfiles } from "./profiles.js";
|
|
10
17
|
|
|
11
18
|
const ORCHESTRATION_STATE_TYPE = "pi-shepherdr-orchestration-state";
|
|
12
|
-
const GENERAL_ORCHESTRATION_MESSAGE =
|
|
13
|
-
"Your main goal from now on is to orchestrate agents. Fan out suitable work to general agents, synthesize their results, and report the outcome. Work directly only when asked or for routine local tasks.";
|
|
14
|
-
const ORCHESTRATION_MESSAGE =
|
|
15
|
-
"Your main goal from now on is to orchestrate agents. Fan out suitable work, synthesize agent results, and report the outcome. Work directly only when asked or for routine local tasks.";
|
|
16
|
-
const NORMAL_MESSAGE = "Work normally. Delegate only when useful or requested.";
|
|
17
19
|
|
|
18
20
|
export function registerAgentController(
|
|
19
21
|
pi: ExtensionAPI,
|
|
@@ -33,7 +35,7 @@ export function registerAgentController(
|
|
|
33
35
|
signal: AbortSignal,
|
|
34
36
|
) => {
|
|
35
37
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
36
|
-
const content =
|
|
38
|
+
const content = await orchestrationMessage(enabled);
|
|
37
39
|
signal.throwIfAborted();
|
|
38
40
|
if (ctx.sessionManager.getSessionId() !== sessionId)
|
|
39
41
|
throw new Error("Session changed; retry /herdr");
|
|
@@ -64,6 +66,64 @@ export function registerAgentController(
|
|
|
64
66
|
signal.throwIfAborted();
|
|
65
67
|
return fleet.connect(machine);
|
|
66
68
|
};
|
|
69
|
+
registerContextBriefing(
|
|
70
|
+
pi,
|
|
71
|
+
"orchestration",
|
|
72
|
+
(ctx) => restoreOrchestrationState(ctx).enabled,
|
|
73
|
+
async (ctx, windowId, messages) => {
|
|
74
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
75
|
+
const state = restoreOrchestrationState(ctx);
|
|
76
|
+
const window = contextBriefingWindow(ctx, windowId);
|
|
77
|
+
// Initialization and compaction may keep earlier messages. Only actual
|
|
78
|
+
// selected context proves a toggle still supplies this window's guidance.
|
|
79
|
+
if (
|
|
80
|
+
state.visible &&
|
|
81
|
+
messages?.some(
|
|
82
|
+
(message) =>
|
|
83
|
+
message.role === "custom" &&
|
|
84
|
+
message.customType === ORCHESTRATION_STATE_TYPE &&
|
|
85
|
+
message.timestamp === state.timestamp,
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
return;
|
|
89
|
+
const key = JSON.stringify([sessionId, window, state.id]);
|
|
90
|
+
await recordContextBriefing(
|
|
91
|
+
pi,
|
|
92
|
+
ctx,
|
|
93
|
+
"shepherdr-orchestration",
|
|
94
|
+
key,
|
|
95
|
+
async () => {
|
|
96
|
+
const content = await orchestrationMessage(state.enabled);
|
|
97
|
+
if (
|
|
98
|
+
ctx.sessionManager.getSessionId() !== sessionId ||
|
|
99
|
+
restoreOrchestrationState(ctx).id !== state.id
|
|
100
|
+
)
|
|
101
|
+
throw new Error("Orchestration changed during its briefing");
|
|
102
|
+
ctx.signal?.throwIfAborted();
|
|
103
|
+
return content;
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
registerContextBriefing(
|
|
109
|
+
pi,
|
|
110
|
+
"active agents",
|
|
111
|
+
() => fleet.list().some((agent) => agent.activity.phase !== "settled"),
|
|
112
|
+
async (ctx, windowId) => {
|
|
113
|
+
if (!hasContextRollover(ctx)) return;
|
|
114
|
+
const key = JSON.stringify([
|
|
115
|
+
ctx.sessionManager.getSessionId(),
|
|
116
|
+
contextBriefingWindow(ctx, windowId),
|
|
117
|
+
]);
|
|
118
|
+
await recordContextBriefing(
|
|
119
|
+
pi,
|
|
120
|
+
ctx,
|
|
121
|
+
"shepherdr-active-agents",
|
|
122
|
+
key,
|
|
123
|
+
async () => activeAgentsBriefing(fleet.list(), fleet.statuses()),
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
);
|
|
67
127
|
pi.registerCommand("herdr", {
|
|
68
128
|
description: "Shepherdr settings, status and SSH setup",
|
|
69
129
|
handler: async (args, ctx) => {
|
|
@@ -86,7 +146,7 @@ export function registerAgentController(
|
|
|
86
146
|
reconnect(ctx, machine, signal),
|
|
87
147
|
signal: commandSignal,
|
|
88
148
|
};
|
|
89
|
-
orchestrationEnabled = restoreOrchestrationState(ctx);
|
|
149
|
+
orchestrationEnabled = restoreOrchestrationState(ctx).enabled;
|
|
90
150
|
try {
|
|
91
151
|
if (ctx.mode === "tui") {
|
|
92
152
|
const panel = openControlPanel(ctx, options);
|
|
@@ -105,7 +165,7 @@ export function registerAgentController(
|
|
|
105
165
|
|
|
106
166
|
pi.on("session_start", async (_event, ctx) => {
|
|
107
167
|
resetLifetime();
|
|
108
|
-
orchestrationEnabled = restoreOrchestrationState(ctx);
|
|
168
|
+
orchestrationEnabled = restoreOrchestrationState(ctx).enabled;
|
|
109
169
|
await activateController(fleet, ctx);
|
|
110
170
|
});
|
|
111
171
|
|
|
@@ -116,14 +176,18 @@ export function registerAgentController(
|
|
|
116
176
|
});
|
|
117
177
|
}
|
|
118
178
|
|
|
119
|
-
async function orchestrationMessage(): Promise<string> {
|
|
120
|
-
return (
|
|
121
|
-
|
|
122
|
-
|
|
179
|
+
async function orchestrationMessage(enabled: boolean): Promise<string> {
|
|
180
|
+
return orchestrationGuidance(
|
|
181
|
+
enabled,
|
|
182
|
+
enabled && (await loadAgentProfiles()).has("general"),
|
|
183
|
+
);
|
|
123
184
|
}
|
|
124
185
|
|
|
125
|
-
function restoreOrchestrationState(ctx: ExtensionContext)
|
|
186
|
+
function restoreOrchestrationState(ctx: ExtensionContext) {
|
|
126
187
|
let enabled = false;
|
|
188
|
+
let timestamp: number | undefined;
|
|
189
|
+
let id = "normal";
|
|
190
|
+
let visible = false;
|
|
127
191
|
for (const entry of ctx.sessionManager.getBranch()) {
|
|
128
192
|
if (
|
|
129
193
|
(entry.type !== "custom" && entry.type !== "custom_message") ||
|
|
@@ -139,9 +203,12 @@ function restoreOrchestrationState(ctx: ExtensionContext): boolean {
|
|
|
139
203
|
typeof state.enabled === "boolean"
|
|
140
204
|
) {
|
|
141
205
|
enabled = state.enabled;
|
|
206
|
+
timestamp = Date.parse(entry.timestamp);
|
|
207
|
+
id = entry.id;
|
|
208
|
+
visible = entry.type === "custom_message";
|
|
142
209
|
}
|
|
143
210
|
}
|
|
144
|
-
return enabled;
|
|
211
|
+
return { enabled, timestamp, id, visible };
|
|
145
212
|
}
|
|
146
213
|
|
|
147
214
|
async function activateController(
|
package/src/delivery.ts
CHANGED
|
@@ -3,8 +3,11 @@ import type {
|
|
|
3
3
|
ExtensionContext,
|
|
4
4
|
} from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import type {
|
|
6
|
+
CodexContextBriefingHandler,
|
|
6
7
|
CodexDeveloperCustomMessage,
|
|
7
8
|
CodexDeveloperMessageOptions,
|
|
9
|
+
hasCodexContextBriefingHost,
|
|
10
|
+
registerCodexContextBriefing,
|
|
8
11
|
trySendCodexDeveloperCustomMessage,
|
|
9
12
|
tryStartCodexPreparedIdleKickoff,
|
|
10
13
|
tryStartCodexPreparedIdlePrompt,
|
|
@@ -26,6 +29,14 @@ const preparedPrompts = new WeakMap<
|
|
|
26
29
|
ExtensionAPI,
|
|
27
30
|
typeof tryStartCodexPreparedIdlePrompt
|
|
28
31
|
>();
|
|
32
|
+
const briefingHosts = new WeakMap<
|
|
33
|
+
ExtensionAPI,
|
|
34
|
+
{
|
|
35
|
+
register: typeof registerCodexContextBriefing;
|
|
36
|
+
available: typeof hasCodexContextBriefingHost;
|
|
37
|
+
}
|
|
38
|
+
>();
|
|
39
|
+
const outdatedBriefingHosts = new WeakSet<ExtensionAPI>();
|
|
29
40
|
const PACKAGE = "@howaboua/pi-codex-conversion";
|
|
30
41
|
const MODULE = `${PACKAGE}/developer-messages`;
|
|
31
42
|
|
|
@@ -42,6 +53,15 @@ export async function registerDeveloperDelivery(
|
|
|
42
53
|
preparedKickoffs.set(pi, api.tryStartCodexPreparedIdleKickoff);
|
|
43
54
|
if (typeof api.tryStartCodexPreparedIdlePrompt === "function")
|
|
44
55
|
preparedPrompts.set(pi, api.tryStartCodexPreparedIdlePrompt);
|
|
56
|
+
if (
|
|
57
|
+
typeof api.registerCodexContextBriefing === "function" &&
|
|
58
|
+
typeof api.hasCodexContextBriefingHost === "function"
|
|
59
|
+
)
|
|
60
|
+
briefingHosts.set(pi, {
|
|
61
|
+
register: api.registerCodexContextBriefing,
|
|
62
|
+
available: api.hasCodexContextBriefingHost,
|
|
63
|
+
});
|
|
64
|
+
else outdatedBriefingHosts.add(pi);
|
|
45
65
|
} catch (error) {
|
|
46
66
|
if (!isUnavailable(error)) throw error;
|
|
47
67
|
}
|
|
@@ -89,6 +109,19 @@ export async function registerDeveloperDelivery(
|
|
|
89
109
|
});
|
|
90
110
|
}
|
|
91
111
|
|
|
112
|
+
export function registerInferenceBriefing(
|
|
113
|
+
pi: ExtensionAPI,
|
|
114
|
+
handler: CodexContextBriefingHandler,
|
|
115
|
+
) {
|
|
116
|
+
const host = briefingHosts.get(pi);
|
|
117
|
+
const unregister = host?.register(pi, handler);
|
|
118
|
+
pi.on("session_shutdown", () => unregister?.());
|
|
119
|
+
return {
|
|
120
|
+
hosted: () => host?.available(pi) ?? false,
|
|
121
|
+
outdated: outdatedBriefingHosts.has(pi),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
92
125
|
export function startPreparedIdleTurn(
|
|
93
126
|
pi: ExtensionAPI,
|
|
94
127
|
ctx: Pick<ExtensionContext, "ui" | "sessionManager">,
|