@pontia/pi-client-plugin 0.7.3 → 0.7.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pontia/pi-client-plugin",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Pi extension that connects coding-agent sessions to Pontia.",
5
5
  "keywords": [
6
6
  "pi-package",
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 session = asRecord(asRecord(sessionBody)?.session);
11
- const profileId = optionalString(session?.execution_profile_id);
12
- const profileVersion = optionalString(session?.execution_profile_version);
13
- if (!profileId) return undefined;
14
-
15
- const profileBody = await connection.request("profile.get", {
16
- profile_id: profileId,
17
- ...(profileVersion ? { version: profileVersion } : {}),
18
- });
19
- const profile = asRecord(asRecord(profileBody)?.agent_profile);
20
- return optionalString(profile?.system_prompt_template);
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
  }