@pontia/pi-client-plugin 0.7.2 → 0.7.4
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/index.ts +2 -1
- package/src/profile.ts +13 -11
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -525,13 +525,14 @@ export function createPontiaPiExtension(
|
|
|
525
525
|
);
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
pi.on("before_agent_start", async (event) => {
|
|
528
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
529
529
|
pendingPrompt = event.messageType === "user" ? event.prompt : undefined;
|
|
530
530
|
if (reportingDisabled || !(await confirmManagedPane())) return;
|
|
531
531
|
try {
|
|
532
532
|
const profilePrompt = await loadProfileSystemPrompt(
|
|
533
533
|
rpcConnection,
|
|
534
534
|
boundSessionContext?.sessionId,
|
|
535
|
+
ctx.sessionManager.buildSessionProjection().messages,
|
|
535
536
|
);
|
|
536
537
|
if (profilePrompt) {
|
|
537
538
|
event.systemPromptOptions.sections.pontia_execution_profile = profilePrompt;
|
package/src/profile.ts
CHANGED
|
@@ -4,18 +4,20 @@ import { asRecord, optionalString } from "./values.js";
|
|
|
4
4
|
export async function loadProfileSystemPrompt(
|
|
5
5
|
connection: Pick<PiConnection, "request">,
|
|
6
6
|
sessionId?: string,
|
|
7
|
+
existingMessages: readonly unknown[] = [],
|
|
7
8
|
): Promise<string | undefined> {
|
|
8
9
|
if (!sessionId) return undefined;
|
|
9
10
|
const sessionBody = await connection.request("session.get", { session_id: sessionId });
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const binding = asRecord(asRecord(sessionBody)?.execution_profile_binding);
|
|
12
|
+
if (binding) return optionalString(binding.system_prompt);
|
|
13
|
+
let previous: string | undefined;
|
|
14
|
+
for (const value of existingMessages) {
|
|
15
|
+
const message = asRecord(value);
|
|
16
|
+
if (message?.role !== "system") continue;
|
|
17
|
+
const sections = asRecord(message.sections);
|
|
18
|
+
if (sections && "pontia_execution_profile" in sections) {
|
|
19
|
+
previous = optionalString(sections.pontia_execution_profile);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return previous;
|
|
21
23
|
}
|