@omercnet/paseo-omp 5.4.0-next.392.1 → 5.4.0-next.394.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
@@ -14,6 +14,7 @@ OMP adds an agent provider for the OMP coding agent, plus an OMP sidebar and wor
14
14
  - List the MCP servers OMP connects to, add, test, enable, disable or remove them, and authorize a remote server through your browser, from the **MCPs** tab.
15
15
  - An **MCP** composer control runs OMP's MCP management in the current session, with authorization prompts shown in the chat.
16
16
  - While OMP subagents run, a row under each `task` card in the conversation lets you steer one with a message or stop it after confirmation. It needs OMP 18.4.9 or newer.
17
+ - When an OMP rule fires during a turn of an agent on Paseo's bundled `omp` provider, a notice under that turn names the rule and the text it matched. The plugin reads this, best effort, from the end of the agent's OMP session file, which that provider does not report.
17
18
  - OMP agents can call Paseo's orchestration tools with the optional `serverId` argument and `list_hosts` to delegate work to other connected Paseo hosts.
18
19
 
19
20
  ## Reads and sends
package/README.md CHANGED
@@ -112,7 +112,7 @@ Provider functionality outside the capability flags is tracked separately:
112
112
  | Usage reporting | **100%** | Periodic, post-compaction, fallback, terminal, timeout, and recovered-runtime samples publish `session.usage`. |
113
113
  | 0.11 provider `status()` | **75%** | Registered for the plugin-owned default launch (`OMP_COMMAND` or `omp`, plus the fixed `--profile` wrapper for profile providers), using the bounded `--version`/`--help` probe. Only a missing executable reports `available: false`; slow, failing, or unrecognized probes stay available with a diagnostic. An unexpected internal probe error is not caught here, so the host reports it as unavailable. Available results are shared for 30 seconds; an unavailable result is never remembered, so installing `omp` takes effect on the next host call. The request carries only an optional daemon `launch` and never `providerOptions`, so a per-agent `providerOptions.command` or `env` is invisible. **Breaking since 0.11:** the host gates create, resume, and draft commands/features on this status, so a missing default executable blocks them all, including agents configured with an otherwise valid custom command. Any request `launch` is ignored. |
114
114
  | 0.11 provider `command` and daemon launch | **0%** | Deliberately not declared. Declaring `command` makes the daemon resolve it against its own `PATH` and reject every `connect` when the default binary is missing. The resulting `launch.env` is the daemon's entire process environment plus overrides, indistinguishable from configured values, so adopting it would defeat names-only `inheritEnv` and the fixed profile store environment. The host never supplies `launch` without a declared `command`; `connect` and `getCatalogCacheKey` do not read it, each pinned by `tests/provider-catalog.test.ts`. Revisit if the host stops gating on the default binary or exposes configured `env` separately from the daemon environment. |
115
- | 0.11 screens and sidebar items | **100%** | The global config surface migrates to `addScreen({ id: "config" })`, preserving legacy links and encoding profile selection in screen params. The Hub status row uses `addSidebarHeaderItem` + `SidebarRow`, lists processes and tails logs in a reusable popover. The legacy static config row and surface were removed with the 0.11 floor. |
115
+ | 0.11 screens and sidebar items | **100%** | The global config surface migrates to `addScreen({ id: "config" })`, preserving legacy links and encoding profile selection in screen params, with one `addSidebarHeaderItem` + `SidebarRow` that opens it. Hub processes appear only in the per-agent composer pill, which lists them and tails logs in a popover; there is no global Hub sidebar row. The legacy static config row and surface were removed with the 0.11 floor. |
116
116
  | 0.11 usage source | **0%** | Not registered. `server/quota.ts` reads OMP's recorded `usage_history`, not live quota, so there is no live fetcher to register. Upstream Claude and Codex sources fetch live quota for the Anthropic and Codex OAuth credentials in the daemon's default or `OMP_PROFILE` store; other providers and named profiles remain covered only by this plugin's historical quota pill. |
117
117
 
118
118
  Tracking rules:
@@ -0,0 +1,15 @@
1
+ import type { PluginSidebarItemProps } from "@getpaseo/plugin/client";
2
+ import { SidebarRow } from "@getpaseo/plugin/client/ui";
3
+ import { OMP_ICON } from "./hub-icon";
4
+ import { CONFIG_SCREEN_ID } from "./sidebar-compat";
5
+
6
+ export function ConfigSidebarItem({ currentScreen, openScreen }: PluginSidebarItemProps) {
7
+ return (
8
+ <SidebarRow
9
+ icon={OMP_ICON}
10
+ label="OMP"
11
+ active={currentScreen?.screenId === CONFIG_SCREEN_ID}
12
+ onPress={() => openScreen({ screenId: CONFIG_SCREEN_ID })}
13
+ />
14
+ );
15
+ }
@@ -0,0 +1,22 @@
1
+ import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
2
+ import { Icon } from "@getpaseo/plugin/client/ui";
3
+ import { Text, View } from "react-native";
4
+ import type { OmpRuleNotice } from "../shared/rule-notices";
5
+
6
+ export function OmpRuleNoticeRow({ item, theme }: PluginTimelineItemProps<OmpRuleNotice>) {
7
+ const color = theme.colors.foregroundMuted;
8
+ return (
9
+ <View style={{ gap: 2, paddingVertical: 2 }}>
10
+ {item.data.rules.map((rule) => (
11
+ <View key={rule.name} style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
12
+ <Icon name="ShieldAlert" size={14} color={color} />
13
+ <Text style={{ color, fontSize: 13, flexShrink: 1 }} numberOfLines={2}>
14
+ {rule.matched === null
15
+ ? `OMP rule ${rule.name} fired`
16
+ : `OMP rule ${rule.name} fired on “${rule.matched}”`}
17
+ </Text>
18
+ </View>
19
+ ))}
20
+ </View>
21
+ );
22
+ }
@@ -1,10 +1,7 @@
1
- import type { HubProcess } from "../shared/hub";
2
1
  import { isOmpProfileName, type OmpStore } from "../shared/omp-store";
3
- import { hubProcessTone } from "./hub-status";
4
2
 
5
3
  /** The config screen keeps the id of the retired 0.10 sidebar item so saved links work. */
6
4
  export const CONFIG_SCREEN_ID = "config";
7
- export const HUB_SIDEBAR_ITEM_ID = "hub";
8
5
 
9
6
  type ScreenParams = Readonly<Record<string, string>>;
10
7
 
@@ -22,109 +19,3 @@ export function configScreenTitle(params: ScreenParams): string {
22
19
  const store = configStoreFromParams(params);
23
20
  return store?.profile ? `OMP · ${store.profile}` : "OMP";
24
21
  }
25
-
26
- export interface HubWorkspaceProcesses {
27
- cwd: string;
28
- processes: readonly HubProcess[];
29
- }
30
-
31
- export interface HubSidebarSummary {
32
- running: number;
33
- failed: number;
34
- total: number;
35
- }
36
-
37
- export function summarizeHubWorkspaces(
38
- workspaces: readonly HubWorkspaceProcesses[],
39
- ): HubSidebarSummary {
40
- const summary: HubSidebarSummary = { running: 0, failed: 0, total: 0 };
41
- for (const { processes } of workspaces) {
42
- for (const process of processes) {
43
- summary.total += 1;
44
- const tone = hubProcessTone(process);
45
- if (tone === "success") summary.running += 1;
46
- else if (tone === "danger") summary.failed += 1;
47
- }
48
- }
49
- return summary;
50
- }
51
-
52
- /** Distinct, non-empty workspace directories in first-seen order, bounded for polling cost. */
53
- export function workspaceDirectories(
54
- workspaces: ReadonlyArray<{ workspaceDirectory?: string; projectRootPath: string }>,
55
- limit = 50,
56
- ): { directories: string[]; truncated: boolean } {
57
- const directories = new Set<string>();
58
- for (const workspace of workspaces) {
59
- const directory = workspace.workspaceDirectory || workspace.projectRootPath;
60
- if (!directory || directories.has(directory)) continue;
61
- if (directories.size >= limit) return { directories: [...directories], truncated: true };
62
- directories.add(directory);
63
- }
64
- return { directories: [...directories], truncated: false };
65
- }
66
-
67
- export interface HubSnapshot {
68
- workspaces: HubWorkspaceProcesses[];
69
- /** More workspaces exist than were polled; counts are a lower bound. */
70
- truncated: boolean;
71
- /** Workspaces whose hub state could not be read this poll. */
72
- unreadable: number;
73
- }
74
-
75
- /**
76
- * One poll of hub state. A failing workspace never hides the others; the poll fails only when
77
- * the workspace list itself fails or every workspace is unreadable.
78
- */
79
- export async function loadHubSnapshot(
80
- listWorkspaces: () => Promise<{
81
- entries: ReadonlyArray<{ workspaceDirectory?: string; projectRootPath: string }>;
82
- pageInfo?: { hasMore?: boolean };
83
- }>,
84
- listProcesses: (cwd: string) => Promise<readonly HubProcess[]>,
85
- ): Promise<HubSnapshot> {
86
- const page = await listWorkspaces();
87
- const { directories, truncated } = workspaceDirectories(page.entries);
88
- const results = await Promise.allSettled(
89
- directories.map(async (cwd) => ({ cwd, processes: await listProcesses(cwd) })),
90
- );
91
- const workspaces: HubWorkspaceProcesses[] = [];
92
- for (const result of results) if (result.status === "fulfilled") workspaces.push(result.value);
93
- if (directories.length > 0 && workspaces.length === 0) {
94
- throw new Error("OMP hub state is unreadable");
95
- }
96
- return {
97
- workspaces,
98
- truncated: truncated || page.pageInfo?.hasMore === true,
99
- unreadable: directories.length - workspaces.length,
100
- };
101
- }
102
-
103
- export interface HubTrailing {
104
- running?: string;
105
- failed?: string;
106
- /** Some or all hub state could not be read. */
107
- unreadable: boolean;
108
- accessibilityLabel: string;
109
- }
110
-
111
- /** What the Hub row's trailing slot shows; null when there is nothing to report. */
112
- export function hubTrailing(
113
- snapshot: HubSnapshot | undefined,
114
- loadFailed: boolean,
115
- ): HubTrailing | null {
116
- const summary = summarizeHubWorkspaces(snapshot?.workspaces ?? []);
117
- const atLeast = snapshot?.truncated ? "+" : "";
118
- const unreadable = loadFailed || (snapshot?.unreadable ?? 0) > 0;
119
- if (summary.total === 0 && !unreadable) return null;
120
- const running = summary.total > 0 ? `${summary.running}${atLeast} running` : undefined;
121
- const failed = summary.failed > 0 ? `${summary.failed}${atLeast} failed` : undefined;
122
- return {
123
- ...(running ? { running } : {}),
124
- ...(failed ? { failed } : {}),
125
- unreadable,
126
- accessibilityLabel: [running, failed, unreadable ? "some hub state unreadable" : undefined]
127
- .filter(Boolean)
128
- .join(", "),
129
- };
130
- }
package/index.client.tsx CHANGED
@@ -4,9 +4,9 @@ import type {
4
4
  PluginClientContext,
5
5
  PluginSurfaceProps,
6
6
  } from "@getpaseo/plugin/client";
7
+ import { ConfigSidebarItem } from "./client/config-sidebar";
7
8
  import { OMP_ICON } from "./client/hub-icon";
8
9
  import { HubPopover } from "./client/hub-popover";
9
- import { ConfigSidebarItem, createHubSidebar } from "./client/hub-sidebar";
10
10
  import { summarizeHubProcesses } from "./client/hub-status";
11
11
  import { OmpMcpAuthorizationCard } from "./client/mcp-authorization";
12
12
  import { McpPopover } from "./client/mcp-popover";
@@ -29,14 +29,13 @@ import {
29
29
  quotaSeverityForProvider,
30
30
  quotaSummaryForProvider,
31
31
  } from "./client/quota-state";
32
+ import { OmpRuleNoticeRow } from "./client/rule-notice";
32
33
  import { SessionsPopover } from "./client/sessions-popover";
33
34
  import {
34
35
  CONFIG_SCREEN_ID,
35
36
  configParamsFromStore,
36
37
  configScreenTitle,
37
38
  configStoreFromParams,
38
- HUB_SIDEBAR_ITEM_ID,
39
- loadHubSnapshot,
40
39
  } from "./client/sidebar-compat";
41
40
  import { OmpSubagentStrip } from "./client/subagents-strip";
42
41
  import {
@@ -49,6 +48,7 @@ import { OMP_MCP_AUTH_TIMELINE_KIND, ompMcpAuthorizationTimelineSchema } from ".
49
48
  import { type OmpStore, storeForProvider } from "./shared/omp-store";
50
49
  import { ompImageTimelineSchema, transformOmpImageToolItem } from "./shared/provider-image";
51
50
  import { listOmpQuotas } from "./shared/quota";
51
+ import { OMP_RULE_NOTICE_KIND, ompRuleNoticeSchema } from "./shared/rule-notices";
52
52
  import { OMP_SUBAGENT_STRIP_KIND, ompSubagentStripSchema } from "./shared/subagents";
53
53
 
54
54
  const PAGE_LIMIT = 200;
@@ -112,15 +112,9 @@ async function loadAgents(paseo: PaseoApi): Promise<AgentEntry[]> {
112
112
  return entries;
113
113
  }
114
114
 
115
- /**
116
- * A param-addressable `config` screen (same id as the old sidebar item, so saved links resolve to
117
- * it), a header row that opens it, and a Hub status row.
118
- */
119
- export function registerConfigAndHub(
120
- client: Pick<
121
- PluginClientContext,
122
- "addScreen" | "addSidebarHeaderItem" | "openScreen" | "rpc" | "paseo"
123
- >,
115
+ /** A param-addressable `config` screen (same id as the old sidebar item, so saved links resolve to it) and a header row that opens it. */
116
+ export function registerConfig(
117
+ client: Pick<PluginClientContext, "addScreen" | "addSidebarHeaderItem" | "openScreen">,
124
118
  onComposerPillSettingsChange: (settings: ComposerPillSettings) => void,
125
119
  ): () => void {
126
120
  function ConfigScreen(props: PluginSurfaceProps & { params: Record<string, string> }) {
@@ -138,13 +132,6 @@ export function registerConfigAndHub(
138
132
  />
139
133
  );
140
134
  }
141
- const { HubSidebarItem } = createHubSidebar(() =>
142
- loadHubSnapshot(
143
- () =>
144
- client.paseo.workspaces.list({ filter: { includeBackground: true }, page: { limit: 200 } }),
145
- async (cwd) => (await client.rpc(listHubProcesses, { cwd })).processes,
146
- ),
147
- );
148
135
  const removers = [
149
136
  client.addScreen({ id: CONFIG_SCREEN_ID, title: configScreenTitle, Component: ConfigScreen }),
150
137
  client.addSidebarHeaderItem({
@@ -152,11 +139,6 @@ export function registerConfigAndHub(
152
139
  title: "OMP",
153
140
  Component: ConfigSidebarItem,
154
141
  }),
155
- client.addSidebarHeaderItem({
156
- id: HUB_SIDEBAR_ITEM_ID,
157
- title: "OMP Hub",
158
- Component: HubSidebarItem,
159
- }),
160
142
  ];
161
143
  return () => {
162
144
  for (const remove of removers.reverse()) remove();
@@ -216,7 +198,7 @@ export default function contribute(client: PluginClientContext) {
216
198
  openPanel("workspace", { location: "workspace" });
217
199
  },
218
200
  });
219
- const removeConfigEntry = registerConfigAndHub(client, applyComposerPillSettings);
201
+ const removeConfigEntry = registerConfig(client, applyComposerPillSettings);
220
202
  const removeOpenConfig = client.addCommandCenterItem({
221
203
  id: "open-config",
222
204
  title: "Open OMP",
@@ -245,6 +227,12 @@ export default function contribute(client: PluginClientContext) {
245
227
  schema: ompSubagentStripSchema,
246
228
  Component: OmpSubagentStrip,
247
229
  });
230
+ const removeRuleNoticeRenderer = client.addTimelineRenderer({
231
+ kind: OMP_RULE_NOTICE_KIND,
232
+ version: 1,
233
+ schema: ompRuleNoticeSchema,
234
+ Component: OmpRuleNoticeRow,
235
+ });
248
236
  const removeImageTransformer = client.addTimelineTransformer({
249
237
  id: "omp-images",
250
238
  query: { itemType: "tool_call" },
@@ -553,6 +541,7 @@ export default function contribute(client: PluginClientContext) {
553
541
  removeImageRenderer();
554
542
  removeMcpAuthorizationRenderer();
555
543
  removeSubagentStripRenderer();
544
+ removeRuleNoticeRenderer();
556
545
  removeImageTransformer();
557
546
  removeOpenConfig();
558
547
  removeConfigEntry();
package/index.server.ts CHANGED
@@ -31,6 +31,7 @@ import { OmpPublicError } from "./server/provider/security";
31
31
  import { OmpSessionLimit } from "./server/provider/session-limit";
32
32
  import { resolveGetOmpProviderHealth } from "./server/provider-diagnostics";
33
33
  import { resolveListOmpQuotas } from "./server/quota";
34
+ import { registerOmpRuleNotices } from "./server/rule-notices";
34
35
  import { resolveListOmpSessions } from "./server/sessions";
35
36
  import {
36
37
  OmpSubagentControlRegistry,
@@ -208,6 +209,7 @@ export default function contribute(server: PluginServerContext) {
208
209
  server.handle(steerOmpSubagent, (input) =>
209
210
  resolveSteerOmpSubagent(input, subagentControlRegistry),
210
211
  );
212
+ const removeRuleNotices = registerOmpRuleNotices(server);
211
213
  const removeSessionOpenHook = server.before("agent.session_open", ({ request }) => {
212
214
  if (request.provider !== "omp-plugin" && !request.provider.startsWith("omp-plugin-")) return;
213
215
  return withOmpSessionOpenEnv(request);
@@ -228,6 +230,7 @@ export default function contribute(server: PluginServerContext) {
228
230
  mcps.stop();
229
231
  removeSessionLimitListener();
230
232
  subagentControlRegistry.clear();
233
+ removeRuleNotices();
231
234
  removeSessionOpenHook();
232
235
  };
233
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.4.0-next.392.1",
3
+ "version": "5.4.0-next.394.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.392.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.394.1"; // x-release-please-version
@@ -0,0 +1,137 @@
1
+ import { constants } from "node:fs";
2
+ import { type FileHandle, open } from "node:fs/promises";
3
+ import { isAbsolute } from "node:path";
4
+ import type { PluginServerContext } from "@getpaseo/plugin/server";
5
+ import {
6
+ MAX_OMP_RULE_NOTICE_RULES,
7
+ OMP_RULE_MATCH_MAX_LENGTH,
8
+ OMP_RULE_NAME_MAX_LENGTH,
9
+ OMP_RULE_NOTICE_KIND,
10
+ type OmpRuleNotice,
11
+ } from "../shared/rule-notices";
12
+
13
+ /** Rule firings are read from the end of the session file; a turn rarely writes more. */
14
+ const TAIL_BYTES = 1024 * 1024;
15
+
16
+ function bounded(value: string, max: number): string {
17
+ return value.length > max ? `${value.slice(0, max - 1)}…` : value;
18
+ }
19
+
20
+ function stringArray(value: unknown): string[] {
21
+ return Array.isArray(value)
22
+ ? value.filter((entry): entry is string => typeof entry === "string" && entry.length > 0)
23
+ : [];
24
+ }
25
+
26
+ async function readTail(file: string): Promise<string | undefined> {
27
+ let handle: FileHandle;
28
+ try {
29
+ handle = await open(
30
+ file,
31
+ constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0),
32
+ );
33
+ } catch {
34
+ return;
35
+ }
36
+ try {
37
+ const stat = await handle.stat();
38
+ if (!stat.isFile()) return;
39
+ const start = Math.max(0, stat.size - TAIL_BYTES);
40
+ const buffer = Buffer.allocUnsafe(stat.size - start);
41
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, start);
42
+ const text = buffer.toString("utf8", 0, bytesRead);
43
+ return start === 0 ? text : text.slice(text.indexOf("\n") + 1);
44
+ } finally {
45
+ await handle.close().catch(() => undefined);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * The OMP rules injected between `since` and `until` (epoch ms), from OMP's persisted
51
+ * `ttsr_injection` entries; `id` is the first injection entry's.
52
+ */
53
+ export async function readOmpRuleNotice(
54
+ sessionFile: string,
55
+ since: number,
56
+ until: number,
57
+ ): Promise<{ id: string; notice: OmpRuleNotice } | undefined> {
58
+ if (!isAbsolute(sessionFile) || !sessionFile.endsWith(".jsonl")) return;
59
+ const tail = await readTail(sessionFile);
60
+ if (!tail) return;
61
+ let id: string | undefined;
62
+ const names: string[] = [];
63
+ const matched = new Map<string, string>();
64
+ for (const line of tail.split("\n")) {
65
+ if (!line.includes("ttsr")) continue;
66
+ let entry: Record<string, unknown>;
67
+ try {
68
+ entry = JSON.parse(line);
69
+ } catch {
70
+ continue;
71
+ }
72
+ const at = typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
73
+ if (!(at >= since && at <= until)) continue;
74
+ if (entry.type === "ttsr_injection") {
75
+ id ??= typeof entry.id === "string" ? entry.id : undefined;
76
+ for (const name of stringArray(entry.injectedRules)) {
77
+ if (!names.includes(name)) names.push(name);
78
+ }
79
+ } else if (entry.type === "custom_message" && entry.customType === "ttsr-injection") {
80
+ const details = entry.details as { matched?: unknown } | undefined;
81
+ if (details?.matched && typeof details.matched === "object") {
82
+ for (const [name, text] of Object.entries(details.matched)) {
83
+ if (typeof text === "string") matched.set(name, text);
84
+ }
85
+ }
86
+ }
87
+ }
88
+ if (!id || names.length === 0) return;
89
+ return {
90
+ id,
91
+ notice: {
92
+ rules: names.slice(0, MAX_OMP_RULE_NOTICE_RULES).map((name) => {
93
+ const text = matched.get(name);
94
+ return {
95
+ name: bounded(name, OMP_RULE_NAME_MAX_LENGTH),
96
+ matched: text === undefined ? null : bounded(text, OMP_RULE_MATCH_MAX_LENGTH),
97
+ };
98
+ }),
99
+ },
100
+ };
101
+ }
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
+ };
137
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+
3
+ export const OMP_RULE_NOTICE_KIND = "omp-rule-notice";
4
+ export const MAX_OMP_RULE_NOTICE_RULES = 32;
5
+ export const OMP_RULE_NAME_MAX_LENGTH = 256;
6
+ export const OMP_RULE_MATCH_MAX_LENGTH = 512;
7
+
8
+ /** OMP rules (TTSR) that fired during one turn, appended below that turn. */
9
+ export const ompRuleNoticeSchema = z.object({
10
+ rules: z
11
+ .array(
12
+ z.object({
13
+ name: z.string().min(1).max(OMP_RULE_NAME_MAX_LENGTH),
14
+ matched: z.string().max(OMP_RULE_MATCH_MAX_LENGTH).nullable(),
15
+ }),
16
+ )
17
+ .min(1)
18
+ .max(MAX_OMP_RULE_NOTICE_RULES),
19
+ });
20
+ export type OmpRuleNotice = z.infer<typeof ompRuleNoticeSchema>;
@@ -1,99 +0,0 @@
1
- import type { PluginPopoverProps, PluginSidebarItemProps } from "@getpaseo/plugin/client";
2
- import { SidebarRow } from "@getpaseo/plugin/client/ui";
3
- import { useQuery } from "@tanstack/react-query";
4
- import { Text, View } from "react-native";
5
- import { OMP_ICON } from "./hub-icon";
6
- import { HubProcessList } from "./hub-popover";
7
- import { CONFIG_SCREEN_ID, type HubSnapshot, hubTrailing } from "./sidebar-compat";
8
-
9
- // The row is always mounted; a slower poll bounds per-client RPC fan-out across workspaces.
10
- const HUB_POLL_MS = 15_000;
11
- const HUB_SIDEBAR_QUERY_KEY = ["paseo-omp", "hub-sidebar"] as const;
12
-
13
- export function ConfigSidebarItem({ currentScreen, openScreen }: PluginSidebarItemProps) {
14
- return (
15
- <SidebarRow
16
- icon={OMP_ICON}
17
- label="OMP"
18
- active={currentScreen?.screenId === CONFIG_SCREEN_ID}
19
- onPress={() => openScreen({ screenId: CONFIG_SCREEN_ID })}
20
- />
21
- );
22
- }
23
-
24
- export function createHubSidebar(loadSnapshot: () => Promise<HubSnapshot>) {
25
- const useHubSnapshot = () =>
26
- useQuery({
27
- queryKey: HUB_SIDEBAR_QUERY_KEY,
28
- queryFn: loadSnapshot,
29
- refetchInterval: HUB_POLL_MS,
30
- });
31
-
32
- function HubSidebarPopover({ theme, layout }: PluginPopoverProps) {
33
- const snapshot = useHubSnapshot();
34
- const muted = { color: theme.colors.foregroundMuted, fontSize: 13 };
35
- if (snapshot.isLoading) return <Text style={muted}>Loading hub processes…</Text>;
36
- if (!snapshot.data) {
37
- return (
38
- <Text style={{ color: theme.colors.statusDanger, fontSize: 13 }}>
39
- Could not read omp hub state.
40
- </Text>
41
- );
42
- }
43
- const active = snapshot.data.workspaces.filter(({ processes }) => processes.length > 0);
44
- const notes = [
45
- snapshot.data.unreadable > 0
46
- ? `${snapshot.data.unreadable} workspace(s) could not be read.`
47
- : undefined,
48
- snapshot.data.truncated ? "Showing the first 50 workspaces." : undefined,
49
- ].filter(Boolean);
50
- return (
51
- <View style={{ gap: layout.compact ? 12 : 14 }}>
52
- {notes.map((note) => (
53
- <Text key={note} style={{ ...muted, fontSize: 12 }}>
54
- {note}
55
- </Text>
56
- ))}
57
- {active.length === 0 ? <Text style={muted}>No hub-supervised processes.</Text> : null}
58
- {active.map(({ cwd, processes }) => (
59
- <View key={cwd} style={{ gap: 6 }}>
60
- <Text numberOfLines={1} style={{ ...muted, fontSize: 12 }}>
61
- {cwd}
62
- </Text>
63
- <HubProcessList theme={theme} layout={layout} cwd={cwd} processes={processes} />
64
- </View>
65
- ))}
66
- </View>
67
- );
68
- }
69
-
70
- function HubSidebarItem({ theme, openPopover }: PluginSidebarItemProps) {
71
- const snapshot = useHubSnapshot();
72
- const state = hubTrailing(snapshot.data, snapshot.error !== null);
73
- const trailing = state ? (
74
- <View
75
- accessibilityLabel={state.accessibilityLabel}
76
- style={{ flexDirection: "row", alignItems: "center", gap: 6 }}
77
- >
78
- {state.running ? (
79
- <Text style={{ color: theme.colors.foregroundMuted, fontSize: 12 }}>{state.running}</Text>
80
- ) : null}
81
- {state.failed || state.unreadable ? (
82
- <Text style={{ color: theme.colors.statusDanger, fontSize: 12, fontWeight: "600" }}>
83
- {[state.failed, state.unreadable ? "!" : undefined].filter(Boolean).join(" ")}
84
- </Text>
85
- ) : null}
86
- </View>
87
- ) : undefined;
88
- return (
89
- <SidebarRow
90
- icon="Activity"
91
- label="OMP Hub"
92
- trailing={trailing}
93
- onPress={() => openPopover(HubSidebarPopover)}
94
- />
95
- );
96
- }
97
-
98
- return { HubSidebarItem, HubSidebarPopover };
99
- }