Skip to content
Merged
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
6 changes: 6 additions & 0 deletions apps/mobile/src/features/usage/usageProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
"antigravity",
"pi",
"muse",
// Fork-local: the Oh My Pi provider.
"omp",
];

export function usageProviderKind(driver: string): UsageProviderKind | null {
Expand All @@ -26,6 +28,8 @@ export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
antigravity: "Antigravity",
pi: "Pi",
muse: "Muse Code",
// Fork-local: the Oh My Pi provider.
omp: "Oh My Pi",
};

export function useProviderColors(): Record<UsageProviderKind, string> {
Expand All @@ -39,6 +43,8 @@ export function useProviderColors(): Record<UsageProviderKind, string> {
antigravity: "#8c7bd1",
pi: "#4d9f8a",
muse: "#0866ff",
// Fork-local: the Oh My Pi provider.
omp: "#f97316",
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ const finish = (stopReason = "end_turn", value = "hello from OMP") => {
const current = prompt;
prompt = undefined;
if (value) text(current.params.sessionId, value);
// OMP reports cumulative session cost with the end-of-turn context update.
const usageCost = Number(process.env.OMP_USAGE_COST ?? "");
if (usageCost > 0)
update(current.params.sessionId, {
sessionUpdate: "usage_update",
size: 1_048_576,
used: 479_761,
cost: { amount: usageCost, currency: "USD" },
});
result(current.id, { stopReason });
};
NodeReadline.createInterface({ input: process.stdin }).on("line", (line) => {
Expand Down
23 changes: 23 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/OmpAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,29 @@ describe("OMP V2 native ACP parity", () => {
}).pipe(Effect.provide(layer), Effect.scoped),
);

it.effect("keeps the cumulative session cost OMP reports with its end-of-turn usage", () =>
Effect.gen(function* () {
const { runtime, turnInput } = yield* open({ OMP_USAGE_COST: "4.91" });
yield* runtime.startTurn(turnInput);
const events = yield* runtime.events.pipe(
Stream.takeUntil((event) => event.type === "turn.terminal"),
Stream.runCollect,
);
const usage = events.findLast(
(event) => event.type === "provider_thread.updated" && event.providerThread.contextUsage,
);

assert.deepEqual(
usage?.type === "provider_thread.updated" ? usage.providerThread.contextUsage : undefined,
{
usedTokens: 479_761,
maxTokens: 1_048_576,
cost: { amount: 4.91, currency: "USD" },
},
);
}).pipe(Effect.provide(layer), Effect.scoped),
);

it.effect(
"applies model, thinking and native implementation mode and resumes native sessions",
() =>
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/provider/Drivers/OmpDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
import { ServerConfig } from "../../config.ts";
import { makeOmpTextGeneration } from "../../textGeneration/OmpTextGeneration.ts";
import { ProviderDriverError } from "../Errors.ts";
import { ompUsageReader, type OmpUsageEnv } from "./ompUsage.ts";
import {
OmpAdapterV2Driver,
type OmpAdapterV2DriverEnv,
Expand Down Expand Up @@ -88,12 +89,13 @@ const withInstanceIdentity =
continuation: { groupKey: input.continuationGroupKey },
});

export const OmpDriver: ProviderDriver<OmpSettings, OmpDriverEnv> = {
export const OmpDriver: ProviderDriver<OmpSettings, OmpDriverEnv, OmpUsageEnv> = {
driverKind: DRIVER_KIND,
metadata: {
displayName: "Oh My Pi",
supportsMultipleInstances: true,
},
usage: ompUsageReader,
configSchema: OmpSettings,
defaultConfig: (): OmpSettings => decodeOmpSettings({}),
create: Effect.fn("OmpDriver.create")(function* ({
Expand Down
Loading
Loading