Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paseo-omp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Open the **OMP** sidebar to review the provider-profile contract, choose which c

Open the **Accounts** tab of the **OMP** sidebar to see the logins in OMP's own credential store with their usage and banked resets, add a login through OMP's own sign-in, sign one out, spend a banked reset, and steer OMP's balancing: prefer a login, keep part of its quota in reserve, and set what OMP does at a limit. Steering is written to OMP's own config. See [OMP accounts](docs/configuration.md#omp-accounts).

The quota popover groups recorded limits by provider and OMP account, showing an available recorded email or, when absent, the Copilot account ID (GitHub username) across that account's windows. Duplicate and unnamed accounts receive numbers in opaque account-key order, so changing usage does not swap their numbers; accounts are still displayed by highest usage. Duplicate-name suffixes stay visible when long emails truncate, and a lone unnamed account needs no heading. Copilot accounts also show **GitHub** or **GHE · host**, using the enterprise URL in OMP's recorded account key; unrecognized keys show neither. Only a server-side SHA-256 hash of the account key reaches the client. **CURRENT PROVIDER** identifies the session's provider, not its active account. Provider summary percentages show the highest recorded usage across that provider's accounts.
The quota popover groups recorded limits by provider and OMP account, showing an available recorded email or, when absent, the Copilot account ID (GitHub username) across that account's windows. Duplicate and unnamed accounts receive numbers in opaque account-key order, so changing usage does not swap their numbers; accounts are still displayed by highest usage. Duplicate-name suffixes stay visible when long emails truncate, and a lone unnamed account needs no heading. Copilot accounts also show **GitHub** or **GHE · host**, using the enterprise URL in OMP's recorded account key; unrecognized keys show neither. Only a server-side SHA-256 hash of the account key reaches the client. **CURRENT PROVIDER** identifies the session's provider, not its active account. Paseo sees an OMP Plugin agent's model only as an opaque id, so the pill and popover ask the agent's live OMP session which provider that model belongs to; a closed OMP Plugin agent shows every provider until its session runs again. Provider summary percentages show the highest recorded usage across that provider's accounts.

Open the **MCPs** tab of the **OMP** sidebar to list the MCP servers OMP connects to, add one by URL or command, test, enable, disable or remove it, and sign a remote server in through your browser, like **Accounts** does for logins. See [OMP MCP servers](docs/configuration.md#omp-mcp-servers).

Expand Down
30 changes: 27 additions & 3 deletions paseo-omp/client/quota-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { Text, View } from "react-native";
import { storeForProvider, storeLabel } from "../shared/omp-store";
import { listOmpQuotas } from "../shared/quota";
import { getOmpSessionModelProvider, listOmpQuotas } from "../shared/quota";
import { ompStoreKey } from "./omp-store-state";
import {
needsSessionModelProvider,
type QuotaProviderGroup,
quotaDetailLabel,
quotaProviderFromSession,
Expand All @@ -21,8 +22,31 @@ const QUOTA_POLL_MS = 30_000;
export function QuotaPopover(props: PluginButtonContentProps) {
const { theme, layout } = props;
const agentId = props.context === "agent" ? props.agentId : "";
const session = useAgent(agentId, (agent) => ({ model: agent.model, provider: agent.provider }));
const currentProvider = quotaProviderFromSession(session?.provider ?? "", session?.model ?? null);
const session = useAgent(agentId, (agent) => ({
model: agent.model,
provider: agent.provider,
status: agent.status,
}));
const loadSessionModelProvider = useRpc(getOmpSessionModelProvider);
const sessionModelProvider = useQuery({
// The answer comes from the live session, so a closed or resumed session asks again.
queryKey: [
"paseo-omp",
"session-model-provider",
agentId,
session?.model ?? null,
session?.status ?? null,
],
queryFn: () => loadSessionModelProvider({ agentId }),
enabled: Boolean(
agentId && session && needsSessionModelProvider(session.provider, session.model),
),
retry: false,
});
const currentProvider =
quotaProviderFromSession(session?.provider ?? "", session?.model ?? null) ??
sessionModelProvider.data?.provider ??
null;
const store = storeForProvider(session?.provider);
const loadQuotas = useRpc(listOmpQuotas);
const quotas = useQuery({
Expand Down
9 changes: 9 additions & 0 deletions paseo-omp/client/quota-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export function quotaProviderFromSession(
return model?.includes("/") ? model.split("/")[0] : null;
}

/** An OMP Plugin agent's model reaches Paseo as an opaque id; its live session names the provider. */
export function needsSessionModelProvider(provider: string, model: string | null): boolean {
return (
isOmpProvider(provider.split("/")[0]) &&
Boolean(model) &&
quotaProviderFromSession(provider, model) === null
);
}

export function quotaProviderLabel(provider: string | null): string {
return provider
? (PROVIDER_LABELS[provider] ?? `${provider.slice(0, 1).toUpperCase()}${provider.slice(1)}`)
Expand Down
39 changes: 34 additions & 5 deletions paseo-omp/index.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { quotaProviderIcon } from "./client/provider-icon";
import { OmpImageTimeline } from "./client/provider-image";
import { QuotaPopover } from "./client/quota-popover";
import {
needsSessionModelProvider,
type QuotaSeverity,
quotaProviderFromSession,
quotaSeverityForProvider,
Expand Down Expand Up @@ -61,7 +62,7 @@ import {
import { OMP_MCP_AUTH_TIMELINE_KIND, ompMcpAuthorizationTimelineSchema } from "./shared/mcp";
import { type OmpStore, storeForProvider } from "./shared/omp-store";
import { ompImageTimelineSchema, transformOmpImageToolItem } from "./shared/provider-image";
import { listOmpQuotas } from "./shared/quota";
import { getOmpSessionModelProvider, listOmpQuotas } from "./shared/quota";
import { OMP_RULE_NOTICE_KIND, ompRuleNoticeSchema } from "./shared/rule-notices";
import { OMP_SUBAGENT_STRIP_KIND, ompSubagentStripSchema } from "./shared/subagents";

Expand Down Expand Up @@ -382,15 +383,40 @@ export default function contribute(client: PluginClientContext) {
}
}

// Agent id to its session's provider, asked again only when the agent's model or status changes.
const sessionModelProviders = new Map<string, { key: string; provider: string | null }>();

async function sessionModelProvider(agent: AgentEntry["agent"]): Promise<string | null> {
if (agent.status === "closed" || !needsSessionModelProvider(agent.provider, agent.model)) {
return null;
}
const key = `${agent.model}|${agent.status}`;
const cached = sessionModelProviders.get(agent.id);
if (cached?.key === key) return cached.provider;
try {
const { provider } = await client.rpc(getOmpSessionModelProvider, { agentId: agent.id });
sessionModelProviders.set(agent.id, { key, provider });
return provider;
} catch {
return null;
}
}

async function reconcileOnce(): Promise<void> {
if (!preferences) return;
const agents = await loadAgents(client.paseo);
const listed = (await loadAgents(client.paseo)).filter(
({ agent }) => !agent.archivedAt && agent.workspaceId && agent.cwd,
);
const sessionProviders = await Promise.all(
listed.map(({ agent }) => sessionModelProvider(agent)),
);
if (disposed || !preferences) return;
const activeIds = new Set<string>();
for (const { agent } of agents) {
if (agent.archivedAt || !agent.workspaceId || !agent.cwd) continue;
for (const [index, { agent }] of listed.entries()) {
if (!agent.workspaceId || !agent.cwd) continue;
activeIds.add(agent.id);
const quotaProvider = quotaProviderFromSession(agent.provider, agent.model);
const quotaProvider =
quotaProviderFromSession(agent.provider, agent.model) ?? sessionProviders[index];
const store = storeForProvider(agent.provider);
let entry = pills.get(agent.id);
if (
Expand Down Expand Up @@ -419,6 +445,9 @@ export default function contribute(client: PluginClientContext) {
removePills(entry);
pills.delete(agentId);
}
for (const agentId of sessionModelProviders.keys()) {
if (!activeIds.has(agentId)) sessionModelProviders.delete(agentId);
}
await Promise.all([refreshHubStatus(), refreshQuotaStatus()]);
}

Expand Down
6 changes: 5 additions & 1 deletion paseo-omp/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { ompRuleNoticeRow } from "./server/rule-notices";
import {
OmpSubagentControlRegistry,
resolveCancelOmpSubagent,
resolveGetOmpSessionModelProvider,
resolveSteerOmpSubagent,
} from "./server/subagents";
import { resolveGetOmpSupportReport } from "./server/support-diagnostics";
Expand Down Expand Up @@ -116,7 +117,7 @@ import { getOmpUpdateStatus, installOmpUpdate } from "./shared/omp-update";
import { getOmpProviderHealth } from "./shared/provider-diagnostics";
import { getOmpImage } from "./shared/provider-image";
import { providerLaunchSettings } from "./shared/provider-launch-settings";
import { listOmpQuotas } from "./shared/quota";
import { getOmpSessionModelProvider, listOmpQuotas } from "./shared/quota";
import { cancelOmpSubagent, steerOmpSubagent } from "./shared/subagents";
import { getOmpSupportReport } from "./shared/support-diagnostics";

Expand Down Expand Up @@ -283,6 +284,9 @@ export default function contribute(server: PluginServerContext) {
server.handle(steerOmpSubagent, (input) =>
resolveSteerOmpSubagent(input, subagentControlRegistry),
);
server.handle(getOmpSessionModelProvider, (input) =>
resolveGetOmpSessionModelProvider(input, subagentControlRegistry),
);
const removeTurnRows = registerOmpTurnRows(server, [ompRuleNoticeRow, ompScreenshotRow]);
const removeSessionOpenHook = server.before("agent.session_open", ({ request }) => {
if (request.provider !== "omp-plugin" && !request.provider.startsWith("omp-plugin-")) return;
Expand Down
9 changes: 9 additions & 0 deletions paseo-omp/server/provider/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
await target.runtime.steerSubagent(target.nativeId, message);
}

/** Paseo publishes the model as an opaque id; only the session can map it back to OMP's model. */
modelProvider(): string | null {
if (this.closed || this.runtimeDead) return null;
const model = this.configState.model
? this.nativeModelsByPublicId.get(this.configState.model)
: undefined;
return model?.provider ?? null;
}

/**
* The native ID and runtime of a subagent this session's current runtime lists as running, or
* `null`. OMP repeats the check; this scopes the request to this session and answers exactly.
Expand Down
11 changes: 11 additions & 0 deletions paseo-omp/server/subagents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
import type { getOmpSessionModelProvider } from "../shared/quota";
import type { cancelOmpSubagent, steerOmpSubagent } from "../shared/subagents";
import { OmpRpcRequestRejectedError } from "./provider/omp-rpc-transport";
import { isOmpPublicError, OmpPublicError } from "./provider/security";
Expand All @@ -8,6 +9,8 @@ export interface OmpSubagentControls {
/** Resolves `false` when the subagent is no longer running. */
cancelSubagent(handle: string): Promise<boolean>;
steerSubagent(handle: string, message: string): Promise<void>;
/** The OMP provider of the session's current model, or null once the session has ended. */
modelProvider(): string | null;
}

export class OmpSubagentNotRunningError extends OmpPublicError {
Expand Down Expand Up @@ -95,3 +98,11 @@ export async function resolveSteerOmpSubagent(
await withPublicFailure("steer", () => controls.steerSubagent(input.subagentId, input.message));
return { accepted: true };
}

/** No live session (closed, history-only or another daemon's) answers null rather than failing. */
export function resolveGetOmpSessionModelProvider(
input: RpcInput<typeof getOmpSessionModelProvider>,
registry: OmpSubagentControlRegistry,
): RpcOutput<typeof getOmpSessionModelProvider> {
return { provider: registry.get(input.agentId)?.modelProvider() ?? null };
}
10 changes: 10 additions & 0 deletions paseo-omp/shared/quota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ export const listOmpQuotas = defineRpc({
input: z.object({ store: OmpStoreSchema.optional() }),
output: z.object({ quotas: z.array(OmpQuotaSchema) }),
});

/**
* The OMP provider (such as `anthropic`) of the model an OMP Plugin agent's live session uses.
* Paseo only sees that model as an opaque id, so the provider is null without a live session.
*/
export const getOmpSessionModelProvider = defineRpc({
name: "paseo-omp.session-model-provider",
input: z.object({ agentId: z.string().min(1).max(256) }),
output: z.object({ provider: z.string().nullable() }),
});
94 changes: 93 additions & 1 deletion paseo-omp/tests/profile-pills.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vi.mock("../client/generated-image", () => ({ OmpGeneratedImagesRow: () => null
vi.mock("../client/ast-edit", () => ({ OmpAstEditCard: () => null }));

import contribute from "../index.client";
import { listOmpQuotas } from "../shared/quota";
import { getOmpSessionModelProvider, listOmpQuotas } from "../shared/quota";

afterEach(() => {
vi.useRealTimers();
Expand Down Expand Up @@ -179,3 +179,95 @@ test("owned agent directory updates reconcile new agent pills and cached quota r
dispose();
}
});

test("summarizes an OMP Plugin agent's quota by the provider its live session names", async () => {
vi.useFakeTimers();
const agents = [
{ id: "live", provider: "omp-plugin", model: "omp:model:opaque", status: "idle" },
{ id: "ended", provider: "omp-plugin", model: "omp:model:opaque", status: "closed" },
];
let onDirectoryUpdate = () => {};
const buttons: Array<{ id: string; agentId: string; update: ReturnType<typeof vi.fn> }> = [];
const rpc = vi.fn(async (definition, input) => {
if (definition.name === "settings.composer-pills.read") {
return { status: "ready", revision: "r", values: { quota: true } };
}
if (definition === getOmpSessionModelProvider) {
return { provider: input.agentId === "live" ? "openai-codex" : null };
}
if (definition !== listOmpQuotas) return { processes: [] };
const row = { label: "Window", windowLabel: null, status: "ok", resetsAt: null, recordedAt: 1 };
return {
quotas: [
{ ...row, provider: "anthropic", usedFraction: 0.9 },
{ ...row, provider: "openai-codex", usedFraction: 0.3 },
],
};
});
const registration = () => () => {};
const list = async (options?: { subscribe?: object }) => {
const result = {
entries: agents.map((agent) => ({
agent: { ...agent, cwd: "/workspace", workspaceId: "workspace", archivedAt: null },
})),
pageInfo: { hasMore: false },
};
if (!options?.subscribe) return result;
return {
...result,
subscription: {
ready: Promise.resolve(result),
subscribe: (observer: { update: () => void }) => {
onDirectoryUpdate = observer.update;
return () => {};
},
release: async () => {},
},
};
};
const client = {
paseo: { agents: { list } },
rpc,
addWorkspacePanel: registration,
addCommandCenterItem: registration,
addScreen: registration,
addSidebarHeaderItem: registration,
openScreen: vi.fn(),
addTimelineRenderer: registration,
addTimelineTransformer: registration,
addComposerPill: (options: { id: string; agentId: string }) => {
const button = { ...options, update: vi.fn(), remove: vi.fn() };
buttons.push(button);
return button;
},
} as unknown as PluginClientContext;
const dispose = contribute(client);
const quota = (agentId: string) =>
buttons.findLast((button) => button.id === "quota" && button.agentId === agentId)?.update;
const asked = () =>
rpc.mock.calls
.filter(([definition]) => definition === getOmpSessionModelProvider)
.map(([, input]) => input.agentId);
try {
await vi.advanceTimersByTimeAsync(300);
expect(quota("live")).toHaveBeenLastCalledWith(
expect.objectContaining({ label: "OpenAI · 30%" }),
);
// A closed agent has no session to ask and keeps the all-provider summary.
expect(quota("ended")).toHaveBeenLastCalledWith(
expect.objectContaining({ label: "Quotas · 90%" }),
);
expect(asked()).toEqual(["live"]);

// The same model and status reuse the answer; a new model asks again.
onDirectoryUpdate();
await vi.advanceTimersByTimeAsync(250);
expect(asked()).toEqual(["live"]);
agents[0].model = "omp:model:other";
onDirectoryUpdate();
await vi.advanceTimersByTimeAsync(250);
expect(asked()).toEqual(["live", "live"]);
} finally {
dispose();
}
});
16 changes: 16 additions & 0 deletions paseo-omp/tests/provider-subagent-control.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
OmpSubagentControlRegistry,
type OmpSubagentControls,
resolveCancelOmpSubagent,
resolveGetOmpSessionModelProvider,
resolveSteerOmpSubagent,
} from "../server/subagents";
import { OMP_SUBAGENT_STRIP_KIND, ompSubagentStripSchema } from "../shared/subagents";
Expand Down Expand Up @@ -451,11 +452,26 @@ describe("OMP subagent controls", () => {
await connection.close();
});

test("names the OMP provider behind an agent's opaque model only while its session runs", async () => {
const { connection, events, runtime, registry } = await createControlledHarness();
await openSession(connection, events, "open-a", "session-a", { PASEO_AGENT_ID: "agent-a" });
const provider = (agentId: string) =>
resolveGetOmpSessionModelProvider({ agentId }, registry).provider;

Comment on lines +458 to +460

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RPC provider lookup route escapes coverage

The regression test bypasses the registered RPC route, so it still passes if paseo-omp.session-model-provider is missing or wired to the wrong resolver; invoke it through the server and assert the provider result and unknown-operation error when the route is removed.

Severity

Want Baz to fix this for you? Activate Fixer

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
paseo-omp/tests/provider-subagent-control.test.ts around lines 458-460, update the `get
OMP provider` regression test so it exercises `paseo-omp.session-model-provider` through
the registered server RPC route instead of calling `resolveGetOmpSessionModelProvider`
directly. Assert the transported response contains the expected provider, and add a
focused check that removing or bypassing the route causes the operation to be reported
as unknown.

expect(provider("agent-a")).toBe("anthropic");
expect(provider("agent-unknown")).toBeNull();
sessionAt(runtime, 0).emit({ type: "process_exit", error: "OMP exited between turns" });
await Promise.resolve();
expect(provider("agent-a")).toBeNull();
await connection.close();
});

test("lets a newer session replace an agent's controls without the older cleanup removing it", () => {
const registry = new OmpSubagentControlRegistry();
const controls = (): OmpSubagentControls => ({
cancelSubagent: async () => false,
steerSubagent: async () => {},
modelProvider: () => null,
});
const older = controls();
const newer = controls();
Expand Down
Loading
Loading