@pontia/pi-client-plugin 0.6.12 → 0.6.14

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.6.12",
3
+ "version": "0.6.14",
4
4
  "description": "Pi extension that connects coding-agent sessions to Pontia.",
5
5
  "keywords": [
6
6
  "pi-package",
package/src/history.ts CHANGED
@@ -36,6 +36,23 @@ function decode(value: unknown): Record<string, unknown> {
36
36
  const identity = (value: unknown): value is string =>
37
37
  typeof value === "string" && !!value.trim() && value.length <= 512;
38
38
 
39
+ function historyEntry(entry: Record<string, unknown>): Record<string, unknown> {
40
+ const message = entry.message as Record<string, unknown> | undefined;
41
+ if (entry.type !== "message" || !Array.isArray(message?.content)) return entry;
42
+ return {
43
+ ...entry,
44
+ message: {
45
+ ...message,
46
+ // Timeline readers use text and image metadata, not inline image bytes.
47
+ content: message.content.map((block) => {
48
+ if (block?.type !== "image") return block;
49
+ const { data, ...image } = block;
50
+ return image;
51
+ }),
52
+ },
53
+ };
54
+ }
55
+
39
56
  /** Reads the current canonical manager; tokens contain identities, never file positions. */
40
57
  export function readHistory(context: HistoryContext, params: Record<string, unknown>): object {
41
58
  if (Object.keys(params).some((key) => !["page_size", "snapshot", "continuation"].includes(key)))
@@ -120,7 +137,7 @@ export function readHistory(context: HistoryContext, params: Record<string, unkn
120
137
  const page: unknown[] = [];
121
138
  let bytes = 0;
122
139
  for (let index = start; index <= upper && page.length < (size as number); index++) {
123
- const entry = entries[index];
140
+ const entry = historyEntry(entries[index]);
124
141
  const encoded = JSON.stringify(entry);
125
142
  const length = Buffer.byteLength(encoded);
126
143
  if (length > PAGE_BYTES - 8192) return invalid("History entry exceeds response budget");
package/src/index.ts CHANGED
@@ -150,6 +150,7 @@ export function createPontiaPiExtension(
150
150
  dependencies: PontiaPiExtensionDependencies = {},
151
151
  ): void {
152
152
  const sourceEnv = dependencies.env ?? process.env;
153
+ delete sourceEnv.PONTIA_SESSION_ID;
153
154
  if (!pontiaHomeFromEnv(sourceEnv) || !hasTmuxPaneEnvironment(sourceEnv)) return;
154
155
  // Environment extensions may load PONTIA_HOME after extension registration.
155
156
  const currentPontiaHome = () => pontiaHomeFromEnv(sourceEnv)!;
@@ -573,6 +574,7 @@ export function createPontiaPiExtension(
573
574
  reason !== "fork"
574
575
  )
575
576
  return;
577
+ delete sourceEnv.PONTIA_SESSION_ID;
576
578
  await closeControlSocket();
577
579
  const parentSessionId = boundSessionContext?.sessionId;
578
580
  boundSessionContext = undefined;
@@ -694,6 +696,7 @@ export function createPontiaPiExtension(
694
696
  }
695
697
 
696
698
  boundSessionContext = context;
699
+ sourceEnv.PONTIA_SESSION_ID = context.sessionId;
697
700
  piContext = ctx;
698
701
  controlSocket!.registered(context);
699
702
  readyReported = reportAccepted(
@@ -714,6 +717,7 @@ export function createPontiaPiExtension(
714
717
  });
715
718
 
716
719
  pi.on("session_shutdown", async (event) => {
720
+ delete sourceEnv.PONTIA_SESSION_ID;
717
721
  piContext = undefined;
718
722
  readyReported = false;
719
723
  try {
@@ -794,6 +798,7 @@ export function createPontiaPiExtension(
794
798
  currentEnv(),
795
799
  sessionDetails,
796
800
  );
801
+ if (boundSessionContext) sourceEnv.PONTIA_SESSION_ID = boundSessionContext.sessionId;
797
802
  if (boundSessionContext && !readyReported) {
798
803
  piContext = ctx;
799
804
  controlSocket!.registered(boundSessionContext);