@omercnet/paseo-omp 5.4.0-next.413.1 → 5.4.0-next.414.1

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/OVERVIEW.md CHANGED
@@ -19,6 +19,7 @@ OMP adds an agent provider for the OMP coding agent, plus an OMP sidebar and wor
19
19
  - When an agent on Paseo's bundled `omp` provider calls OMP's `lsp` tool for diagnostics, the call shows as a card grouped by file with an icon per severity. Output the plugin does not recognize keeps the original row.
20
20
  - When an agent on Paseo's bundled `omp` provider generates an image with OMP's `generate_image` tool, the row shows the image with a Download button on web and desktop. The plugin reads the saved `omp-image-*` file from the daemon host's temp directory, so the image is gone once the host cleans that directory.
21
21
  - When an agent on Paseo's bundled `omp` provider previews an OMP `ast_edit` rewrite, the call shows as a read-only diff card per file. It is built from the preview text and does not apply or discard anything; OMP's follow-up `xd://resolve` or `xd://reject` write stays a separate row. A preview the plugin cannot parse keeps the original row.
22
+ - When an agent on Paseo's bundled `omp` provider takes screenshots in an `eval` cell, a **Screenshots** row under that turn shows them. The bundled provider keeps only the text of `eval`, so the plugin reads the screenshot blobs from the end of the agent's OMP session file after the turn, copies them into its image cache, and shows them once the turn ends, not live. Rows do not survive a daemon restart.
22
23
  - OMP agents can call Paseo's orchestration tools with the optional `serverId` argument and `list_hosts` to delegate work to other connected Paseo hosts.
23
24
 
24
25
  ## Reads and sends
package/index.server.ts CHANGED
@@ -47,13 +47,15 @@ import { OmpPublicError } from "./server/provider/security";
47
47
  import { OmpSessionLimit } from "./server/provider/session-limit";
48
48
  import { resolveGetOmpProviderHealth } from "./server/provider-diagnostics";
49
49
  import { resolveListOmpQuotas } from "./server/quota";
50
- import { registerOmpRuleNotices } from "./server/rule-notices";
50
+ import { ompRuleNoticeRow } from "./server/rule-notices";
51
51
  import {
52
52
  OmpSubagentControlRegistry,
53
53
  resolveCancelOmpSubagent,
54
54
  resolveSteerOmpSubagent,
55
55
  } from "./server/subagents";
56
56
  import { resolveGetOmpSupportReport } from "./server/support-diagnostics";
57
+ import { registerOmpTurnRows } from "./server/turn-rows";
58
+ import { ompScreenshotRow } from "./server/turn-screenshots";
57
59
  import { composerPillSettings } from "./shared/composer-pill-settings";
58
60
  import { resolveOmpGeneratedImages } from "./shared/generated-image";
59
61
  import { listHubProcesses, tailHubLog } from "./shared/hub";
@@ -259,7 +261,7 @@ export default function contribute(server: PluginServerContext) {
259
261
  server.handle(steerOmpSubagent, (input) =>
260
262
  resolveSteerOmpSubagent(input, subagentControlRegistry),
261
263
  );
262
- const removeRuleNotices = registerOmpRuleNotices(server);
264
+ const removeTurnRows = registerOmpTurnRows(server, [ompRuleNoticeRow, ompScreenshotRow]);
263
265
  const removeSessionOpenHook = server.before("agent.session_open", ({ request }) => {
264
266
  if (request.provider !== "omp-plugin" && !request.provider.startsWith("omp-plugin-")) return;
265
267
  return withOmpSessionOpenEnv(request);
@@ -280,7 +282,7 @@ export default function contribute(server: PluginServerContext) {
280
282
  mcps.stop();
281
283
  removeSessionLimitListener();
282
284
  subagentControlRegistry.clear();
283
- removeRuleNotices();
285
+ removeTurnRows();
284
286
  removeSessionOpenHook();
285
287
  };
286
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.4.0-next.413.1",
3
+ "version": "5.4.0-next.414.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -1,2 +1,2 @@
1
1
  /** Release Please keeps this bundle-safe constant aligned with package.json. */
2
- export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.413.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.414.1"; // x-release-please-version
@@ -1,7 +1,6 @@
1
1
  import { constants } from "node:fs";
2
2
  import { type FileHandle, open } from "node:fs/promises";
3
3
  import { isAbsolute } from "node:path";
4
- import type { PluginServerContext } from "@getpaseo/plugin/server";
5
4
  import {
6
5
  MAX_OMP_RULE_NOTICE_RULES,
7
6
  OMP_RULE_MATCH_MAX_LENGTH,
@@ -9,8 +8,9 @@ import {
9
8
  OMP_RULE_NOTICE_KIND,
10
9
  type OmpRuleNotice,
11
10
  } from "../shared/rule-notices";
11
+ import type { OmpTurnRow } from "./turn-rows";
12
12
 
13
- /** Rule firings are read from the end of the session file; a turn rarely writes more. */
13
+ /** Turn rows are read from the end of the session file; a turn rarely writes more. */
14
14
  const TAIL_BYTES = 1024 * 1024;
15
15
 
16
16
  function bounded(value: string, max: number): string {
@@ -23,7 +23,7 @@ function stringArray(value: unknown): string[] {
23
23
  : [];
24
24
  }
25
25
 
26
- async function readTail(file: string): Promise<string | undefined> {
26
+ export async function readTail(file: string): Promise<string | undefined> {
27
27
  let handle: FileHandle;
28
28
  try {
29
29
  handle = await open(
@@ -100,38 +100,13 @@ export async function readOmpRuleNotice(
100
100
  };
101
101
  }
102
102
 
103
- /** Paseo's bundled `omp` provider drops OMP rule events, so surface them from its session file. */
104
- export function registerOmpRuleNotices(server: Pick<PluginServerContext, "addHook">): () => void {
105
- // One Paseo turn can report several native turn starts; keep the earliest. Hooks run
106
- // concurrently, so state is read and cleared before the first await.
107
- const turnStarts = new Map<string, number>();
108
- const turnKey = (agentId: string, turnId: string | null) => `${agentId}\0${turnId ?? ""}`;
109
- const removeBefore = server.addHook("agent.turn.before", async ({ agent, turnId }) => {
110
- const key = turnKey(agent.id, turnId);
111
- if (agent.provider === "omp" && !turnStarts.has(key)) turnStarts.set(key, Date.now());
112
- });
113
- const removeAfter = server.addHook("agent.turn.after", async ({ agent, turnId }, { paseo }) => {
114
- const key = turnKey(agent.id, turnId);
115
- const since = turnStarts.get(key);
116
- const until = Date.now();
117
- turnStarts.delete(key);
118
- if (agent.provider !== "omp" || since === undefined) return;
119
- const ref = paseo.agents.ref(agent.id);
120
- const sessionFile = (await ref.refresh())?.agent.persistence?.nativeHandle;
121
- if (!sessionFile) return;
122
- const found = await readOmpRuleNotice(sessionFile, since, until);
123
- if (!found) return;
124
- await ref.timeline.append({
125
- type: "plugin",
126
- id: `rule-notice:${found.id}`,
127
- kind: OMP_RULE_NOTICE_KIND,
128
- version: 1,
129
- data: found.notice,
130
- });
131
- });
132
- return () => {
133
- removeBefore();
134
- removeAfter();
135
- turnStarts.clear();
136
- };
103
+ /** The OMP rule notice of one turn as a timeline row; Paseo's bundled `omp` provider drops rule events. */
104
+ export async function ompRuleNoticeRow(
105
+ sessionFile: string,
106
+ since: number,
107
+ until: number,
108
+ ): Promise<OmpTurnRow | undefined> {
109
+ const found = await readOmpRuleNotice(sessionFile, since, until);
110
+ if (!found) return;
111
+ return { id: `rule-notice:${found.id}`, kind: OMP_RULE_NOTICE_KIND, data: found.notice };
137
112
  }
@@ -0,0 +1,59 @@
1
+ import type { PluginServerContext } from "@getpaseo/plugin/server";
2
+ import type { JsonValue } from "@getpaseo/protocol/agent-types";
3
+
4
+ export interface OmpTurnRow {
5
+ id: string;
6
+ kind: string;
7
+ data: JsonValue;
8
+ }
9
+
10
+ /** Reads one row from an OMP session file for the turn between `since` and `until` (epoch ms). */
11
+ export type OmpTurnRowReader = (
12
+ sessionFile: string,
13
+ since: number,
14
+ until: number,
15
+ ) => Promise<OmpTurnRow | undefined>;
16
+
17
+ /**
18
+ * Paseo's bundled `omp` provider drops parts of what OMP persists to its session file. After each
19
+ * turn of such an agent, every reader may append one timeline row built from that file.
20
+ */
21
+ export function registerOmpTurnRows(
22
+ server: Pick<PluginServerContext, "addHook">,
23
+ readers: readonly OmpTurnRowReader[],
24
+ ): () => void {
25
+ // One Paseo turn can report several native turn starts; keep the earliest. Hooks run
26
+ // concurrently, so state is read and cleared before the first await.
27
+ const turnStarts = new Map<string, number>();
28
+ const turnKey = (agentId: string, turnId: string | null) => `${agentId}\0${turnId ?? ""}`;
29
+ const removeBefore = server.addHook("agent.turn.before", async ({ agent, turnId }) => {
30
+ const key = turnKey(agent.id, turnId);
31
+ if (agent.provider === "omp" && !turnStarts.has(key)) turnStarts.set(key, Date.now());
32
+ });
33
+ const removeAfter = server.addHook("agent.turn.after", async ({ agent, turnId }, { paseo }) => {
34
+ const key = turnKey(agent.id, turnId);
35
+ const since = turnStarts.get(key);
36
+ const until = Date.now();
37
+ turnStarts.delete(key);
38
+ if (agent.provider !== "omp" || since === undefined) return;
39
+ const ref = paseo.agents.ref(agent.id);
40
+ const sessionFile = (await ref.refresh())?.agent.persistence?.nativeHandle;
41
+ if (!sessionFile) return;
42
+ for (const read of readers) {
43
+ const row = await read(sessionFile, since, until);
44
+ if (!row) continue;
45
+ await ref.timeline.append({
46
+ type: "plugin",
47
+ id: row.id,
48
+ kind: row.kind,
49
+ version: 1,
50
+ data: row.data,
51
+ });
52
+ }
53
+ });
54
+ return () => {
55
+ removeBefore();
56
+ removeAfter();
57
+ turnStarts.clear();
58
+ };
59
+ }
@@ -0,0 +1,140 @@
1
+ import { createHash } from "node:crypto";
2
+ import { isAbsolute, join } from "node:path";
3
+ import { setImmediate as yieldToEventLoop } from "node:timers/promises";
4
+ import { z } from "zod";
5
+ import { OMP_IMAGE_TIMELINE_KIND, ompImageTimelineSchema } from "../shared/provider-image";
6
+ import { ompDataDir } from "./paths";
7
+ import { isOmpImageMimeType, isValidImagePayload, type OmpImageMimeType } from "./provider/image";
8
+ import { MAX_CACHED_IMAGE_BYTES, type OmpImageCache, ompImageCache } from "./provider/image-cache";
9
+ import { readRegularFile } from "./regular-file";
10
+ import { readTail } from "./rule-notices";
11
+ import type { OmpTurnRow } from "./turn-rows";
12
+
13
+ const BLOB_REFERENCE = /^blob:sha256:([0-9a-f]{64})$/u;
14
+ const BASE64 = /^[A-Za-z0-9+/]+={0,2}$/u;
15
+ /** OMP moves image data of 1,024 or more base64 characters into a blob; shorter stays inline. */
16
+ const MAX_INLINE_BASE64_LENGTH = 1_023;
17
+ const MAX_SCREENSHOTS = 16;
18
+ const LABEL = "Screenshots";
19
+
20
+ interface ScreenshotImage {
21
+ /** SHA-256 of the image bytes; names the blob file. */
22
+ hash: string;
23
+ mimeType: OmpImageMimeType;
24
+ /** Present for an image persisted inline instead of as a blob. */
25
+ bytes?: Buffer;
26
+ }
27
+
28
+ const evalResultEntrySchema = z.object({
29
+ id: z.string(),
30
+ timestamp: z.string(),
31
+ message: z.object({
32
+ role: z.literal("toolResult"),
33
+ toolName: z.literal("eval"),
34
+ content: z.array(
35
+ z.looseObject({
36
+ type: z.string(),
37
+ data: z.string().optional(),
38
+ mimeType: z.string().optional(),
39
+ }),
40
+ ),
41
+ }),
42
+ });
43
+
44
+ /** One persisted `eval` tool result: its image blocks, as blob references or small inline data. */
45
+ function parseEvalResult(
46
+ line: string,
47
+ ): { id: string; at: number; images: ScreenshotImage[] } | undefined {
48
+ let json: unknown;
49
+ try {
50
+ json = JSON.parse(line);
51
+ } catch {
52
+ return undefined;
53
+ }
54
+ const entry = evalResultEntrySchema.safeParse(json);
55
+ if (!entry.success) return undefined;
56
+ const images = entry.data.message.content.flatMap((block): ScreenshotImage[] => {
57
+ const mimeType = block.mimeType ?? "";
58
+ const data = block.data ?? "";
59
+ if (block.type !== "image" || !isOmpImageMimeType(mimeType)) return [];
60
+ const hash = BLOB_REFERENCE.exec(data)?.[1];
61
+ if (hash) return [{ hash, mimeType }];
62
+ if (data.length > MAX_INLINE_BASE64_LENGTH || !BASE64.test(data)) return [];
63
+ const bytes = Buffer.from(data, "base64");
64
+ return [{ hash: createHash("sha256").update(bytes).digest("hex"), mimeType, bytes }];
65
+ });
66
+ return { id: entry.data.id, at: Date.parse(entry.data.timestamp), images };
67
+ }
68
+
69
+ function copyToCache(
70
+ directory: string,
71
+ image: ScreenshotImage,
72
+ cache: OmpImageCache,
73
+ ): string | undefined {
74
+ const bytes = image.bytes ?? readRegularFile(join(directory, image.hash), MAX_CACHED_IMAGE_BYTES);
75
+ if (!bytes || createHash("sha256").update(bytes).digest("hex") !== image.hash) return undefined;
76
+ // Only the magic bytes are checked, so encode only the header (12 bytes are 16 characters).
77
+ if (!isValidImagePayload(bytes.subarray(0, 12).toString("base64"), image.mimeType, 16)) {
78
+ return undefined;
79
+ }
80
+ return cache.store(bytes, image.mimeType);
81
+ }
82
+
83
+ /**
84
+ * The `eval` screenshots of the turn between `since` and `until` (epoch ms). OMP persists each as
85
+ * a content-addressed file in `blobDirectory` (or inline when it is tiny); they are copied into
86
+ * the image cache so the row can name them by cache reference and the stock image renderer shows
87
+ * them.
88
+ */
89
+ export async function readOmpScreenshots(
90
+ sessionFile: string,
91
+ since: number,
92
+ until: number,
93
+ cache: OmpImageCache,
94
+ blobDirectory: string,
95
+ ): Promise<OmpTurnRow | undefined> {
96
+ if (!isAbsolute(sessionFile) || !sessionFile.endsWith(".jsonl")) return;
97
+ const tail = await readTail(sessionFile);
98
+ if (!tail) return;
99
+ let id: string | undefined;
100
+ const found: ScreenshotImage[] = [];
101
+ for (const line of tail.split("\n")) {
102
+ if (!line.includes("toolResult")) continue;
103
+ const result = parseEvalResult(line);
104
+ if (!result || !(result.at >= since && result.at <= until) || result.images.length === 0)
105
+ continue;
106
+ id ??= result.id;
107
+ found.push(...result.images);
108
+ }
109
+ if (!id) return;
110
+ const unique = new Map(found.map((image) => [image.hash, image]));
111
+ const images: z.infer<typeof ompImageTimelineSchema>["images"] = [];
112
+ for (const image of unique.values()) {
113
+ if (images.length >= MAX_SCREENSHOTS) break;
114
+ const ref = copyToCache(blobDirectory, image, cache);
115
+ if (ref) images.push({ id: ref.slice(0, 16), ref, mimeType: image.mimeType });
116
+ // Each copy reads and hashes up to 6 MiB synchronously; let other daemon work run between images.
117
+ await yieldToEventLoop();
118
+ }
119
+ if (images.length === 0) return;
120
+ return {
121
+ id: `screenshots:${id}`,
122
+ kind: OMP_IMAGE_TIMELINE_KIND,
123
+ data: ompImageTimelineSchema.parse({ label: LABEL, images }),
124
+ };
125
+ }
126
+
127
+ /** Paseo's bundled `omp` provider keeps only the text of `eval`, so its screenshots are read from the session file. */
128
+ export function ompScreenshotRow(
129
+ sessionFile: string,
130
+ since: number,
131
+ until: number,
132
+ ): Promise<OmpTurnRow | undefined> {
133
+ return readOmpScreenshots(
134
+ sessionFile,
135
+ since,
136
+ until,
137
+ ompImageCache(),
138
+ join(ompDataDir(), "blobs"),
139
+ );
140
+ }
@@ -109,6 +109,8 @@ const inlineOmpImageSchema = z.object({
109
109
  const ompImageSchema = z.union([cachedOmpImageSchema, inlineOmpImageSchema]);
110
110
  export type OmpImage = z.infer<typeof ompImageSchema>;
111
111
 
112
+ export const OMP_IMAGE_TIMELINE_KIND = "omp-images";
113
+
112
114
  export const getOmpImage = defineRpc({
113
115
  name: "paseo-omp.get-image",
114
116
  input: z.strictObject({ ref: ompImageRefSchema, mimeType: ompImageMimeTypeSchema }),
@@ -200,7 +202,7 @@ export function transformOmpImageToolItem(item: { callId: string; metadata?: unk
200
202
  items: [
201
203
  {
202
204
  type: "plugin" as const,
203
- kind: "omp-images",
205
+ kind: OMP_IMAGE_TIMELINE_KIND,
204
206
  id: item.callId,
205
207
  version: 1,
206
208
  data: metadata.data.ompImage,