@omercnet/paseo-omp 5.7.0 → 5.8.0
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 +1 -1
- package/README.md +3 -3
- package/client/omp-accounts-section.tsx +20 -3
- package/client/quota-popover.tsx +75 -7
- package/client/quota-state.ts +24 -2
- package/index.client.tsx +47 -5
- package/index.server.ts +5 -1
- package/npm-shrinkwrap.json +31 -27
- package/package.json +8 -8
- package/paseo-plugin.json +1 -1
- package/server/hub.ts +307 -47
- package/server/omp-accounts.ts +37 -2
- package/server/package-version.ts +1 -1
- package/server/paths.ts +21 -0
- package/server/provider/omp-rpc-protocol.ts +11 -0
- package/server/provider/omp-rpc.ts +4 -1
- package/server/provider/session.ts +18 -4
- package/server/provider/timeline-projector.ts +4 -0
- package/server/quota.ts +75 -0
- package/server/subagents.ts +11 -0
- package/shared/account-tags.ts +44 -0
- package/shared/hub.ts +6 -5
- package/shared/omp-accounts.ts +2 -0
- package/shared/quota.ts +14 -0
|
@@ -482,6 +482,15 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
|
|
|
482
482
|
await target.runtime.steerSubagent(target.nativeId, message);
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
+
/** Paseo publishes the model as an opaque id; only the session can map it back to OMP's model. */
|
|
486
|
+
modelProvider(): string | null {
|
|
487
|
+
if (this.closed || this.runtimeDead) return null;
|
|
488
|
+
const model = this.configState.model
|
|
489
|
+
? this.nativeModelsByPublicId.get(this.configState.model)
|
|
490
|
+
: undefined;
|
|
491
|
+
return model?.provider ?? null;
|
|
492
|
+
}
|
|
493
|
+
|
|
485
494
|
/**
|
|
486
495
|
* The native ID and runtime of a subagent this session's current runtime lists as running, or
|
|
487
496
|
* `null`. OMP repeats the check; this scopes the request to this session and answers exactly.
|
|
@@ -2618,8 +2627,9 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
|
|
|
2618
2627
|
if (!event.id || event.id !== turn.nativeRequestId) return;
|
|
2619
2628
|
if (event.agentInvoked) {
|
|
2620
2629
|
// A request-keyed prompt result proves dispatch, but an unkeyed terminal still needs
|
|
2621
|
-
// ordered native user and assistant evidence from this accepted prompt.
|
|
2622
|
-
|
|
2630
|
+
// ordered native user and assistant evidence from this accepted prompt. OMP can send it
|
|
2631
|
+
// after agent_end, so it is not run activity that makes a waiting agent_end stale.
|
|
2632
|
+
this.markAgentEvidence(turn, false);
|
|
2623
2633
|
return;
|
|
2624
2634
|
}
|
|
2625
2635
|
if (turn.localOnlyDisabled || turn.steersInFlight > 0) return;
|
|
@@ -3057,10 +3067,14 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
|
|
|
3057
3067
|
this.projector.publishUser(pending.text, pending.clientMessageId, entryId);
|
|
3058
3068
|
}
|
|
3059
3069
|
|
|
3060
|
-
|
|
3070
|
+
/**
|
|
3071
|
+
* `runActivity` orders this evidence after any unkeyed agent_end that is waiting for user
|
|
3072
|
+
* correlation, which marks that agent_end stale. A prompt acknowledgement is not run activity.
|
|
3073
|
+
*/
|
|
3074
|
+
private markAgentEvidence(turn: ActiveTurn, runActivity = true): void {
|
|
3061
3075
|
turn.agentInvoked = true;
|
|
3062
3076
|
turn.nativeActivity = true;
|
|
3063
|
-
turn.activitySequence += 1;
|
|
3077
|
+
if (runActivity) turn.activitySequence += 1;
|
|
3064
3078
|
turn.localOnlyEligible = false;
|
|
3065
3079
|
this.cancelLocalOnlyCompletion(turn);
|
|
3066
3080
|
this.refreshAmbiguousTerminal(turn);
|
|
@@ -596,6 +596,10 @@ export class OmpTimelineProjector {
|
|
|
596
596
|
return;
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
|
+
// OMP 18.21+ `agent_pause` only reaches us nested in `subagent_event` (the RPC wire turns it into
|
|
600
|
+
// a nonterminal `agent_end`). Its messages already streamed as message events and the child's
|
|
601
|
+
// status comes from `subagent_lifecycle`/`subagent_progress`, so there is nothing to render.
|
|
602
|
+
if (event.type === "agent_pause") return;
|
|
599
603
|
if (
|
|
600
604
|
(event.type === "message_start" ||
|
|
601
605
|
event.type === "message_update" ||
|
package/server/quota.ts
CHANGED
|
@@ -46,6 +46,79 @@ function copilotAccount(accountKey: string): CopilotAccount {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
const CachedReportSchema = z.object({
|
|
50
|
+
value: z.object({
|
|
51
|
+
provider: z.string(),
|
|
52
|
+
fetchedAt: z.number(),
|
|
53
|
+
metadata: z
|
|
54
|
+
.object({
|
|
55
|
+
plan: z.string().nullish(),
|
|
56
|
+
planType: z.string().nullish(),
|
|
57
|
+
orgName: z.string().nullish(),
|
|
58
|
+
})
|
|
59
|
+
.nullish(),
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
type AccountTags = Pick<OmpQuota, "plan" | "organization">;
|
|
64
|
+
type CachedReport = AccountTags & { key: string; provider: string; fetchedAt: number };
|
|
65
|
+
|
|
66
|
+
/** OMP's usage cache; missing on older OMP versions, so any failure yields no tags. */
|
|
67
|
+
function readCachedReports(database: DatabaseSync): CachedReport[] {
|
|
68
|
+
let rows: Record<string, unknown>[];
|
|
69
|
+
try {
|
|
70
|
+
// A key range on the primary key (";" follows ":"), where LIKE would scan the whole cache.
|
|
71
|
+
rows = database
|
|
72
|
+
.prepare(
|
|
73
|
+
"SELECT key, value FROM cache WHERE key >= 'usage_cache:report:' AND key < 'usage_cache:report;'",
|
|
74
|
+
)
|
|
75
|
+
.all();
|
|
76
|
+
} catch {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return rows.flatMap(({ key, value }) => {
|
|
80
|
+
if (typeof key !== "string" || typeof value !== "string") return [];
|
|
81
|
+
let json: unknown;
|
|
82
|
+
try {
|
|
83
|
+
json = JSON.parse(value);
|
|
84
|
+
} catch {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
const parsed = CachedReportSchema.safeParse(json);
|
|
88
|
+
if (!parsed.success) return [];
|
|
89
|
+
const { provider, fetchedAt, metadata } = parsed.data.value;
|
|
90
|
+
// A blank planType must not hide a plan the report names.
|
|
91
|
+
const plan = metadata?.planType?.trim() || metadata?.plan?.trim() || null;
|
|
92
|
+
const organization = metadata?.orgName?.trim() || null;
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
key,
|
|
96
|
+
provider,
|
|
97
|
+
fetchedAt,
|
|
98
|
+
plan,
|
|
99
|
+
// Codex reports its plan as the organization name too; that is not an organization.
|
|
100
|
+
organization: organization?.toLowerCase() === plan?.toLowerCase() ? null : organization,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* OMP caches each report under a key that ends with the account_key usage_history records. Both
|
|
108
|
+
* tags come from the newest report naming either, so two reports are never mixed into one badge row.
|
|
109
|
+
*/
|
|
110
|
+
function accountTags(
|
|
111
|
+
reports: readonly CachedReport[],
|
|
112
|
+
provider: string,
|
|
113
|
+
accountKey: string,
|
|
114
|
+
): AccountTags {
|
|
115
|
+
const best = reports
|
|
116
|
+
.filter((report) => report.provider === provider && report.key.endsWith(`:${accountKey}`))
|
|
117
|
+
.sort((a, b) => b.fetchedAt - a.fetchedAt)
|
|
118
|
+
.find((report) => report.plan || report.organization);
|
|
119
|
+
return { plan: best?.plan ?? null, organization: best?.organization ?? null };
|
|
120
|
+
}
|
|
121
|
+
|
|
49
122
|
// Only live windows are returned: a series whose newest row already reset (or never resets and was
|
|
50
123
|
// abandoned) would otherwise pin the pill at its last exhausted value and bloat the popover.
|
|
51
124
|
export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
|
|
@@ -79,6 +152,7 @@ export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
|
|
|
79
152
|
ORDER BY COALESCE(usedFraction, -1) DESC, provider, label, accountKey, limitId`,
|
|
80
153
|
)
|
|
81
154
|
.all(now, now - ABANDONED_AFTER_MS);
|
|
155
|
+
const reports = readCachedReports(database);
|
|
82
156
|
return rows.flatMap((row) => {
|
|
83
157
|
const parsed = QuotaRowSchema.safeParse(row);
|
|
84
158
|
if (!parsed.success) return [];
|
|
@@ -91,6 +165,7 @@ export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
|
|
|
91
165
|
// account_id is only known to be a username for Copilot; other providers keep it private.
|
|
92
166
|
accountId: copilot ? quota.accountId : null,
|
|
93
167
|
...(copilot ? copilotAccount(quota.accountKey) : UNKNOWN_SERVICE),
|
|
168
|
+
...accountTags(reports, quota.provider, quota.accountKey),
|
|
94
169
|
},
|
|
95
170
|
];
|
|
96
171
|
});
|
package/server/subagents.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
|
|
2
|
+
import type { getOmpSessionModelProvider } from "../shared/quota";
|
|
2
3
|
import type { cancelOmpSubagent, steerOmpSubagent } from "../shared/subagents";
|
|
3
4
|
import { OmpRpcRequestRejectedError } from "./provider/omp-rpc-transport";
|
|
4
5
|
import { isOmpPublicError, OmpPublicError } from "./provider/security";
|
|
@@ -8,6 +9,8 @@ export interface OmpSubagentControls {
|
|
|
8
9
|
/** Resolves `false` when the subagent is no longer running. */
|
|
9
10
|
cancelSubagent(handle: string): Promise<boolean>;
|
|
10
11
|
steerSubagent(handle: string, message: string): Promise<void>;
|
|
12
|
+
/** The OMP provider of the session's current model, or null once the session has ended. */
|
|
13
|
+
modelProvider(): string | null;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export class OmpSubagentNotRunningError extends OmpPublicError {
|
|
@@ -95,3 +98,11 @@ export async function resolveSteerOmpSubagent(
|
|
|
95
98
|
await withPublicFailure("steer", () => controls.steerSubagent(input.subagentId, input.message));
|
|
96
99
|
return { accepted: true };
|
|
97
100
|
}
|
|
101
|
+
|
|
102
|
+
/** No live session (closed, history-only or another daemon's) answers null rather than failing. */
|
|
103
|
+
export function resolveGetOmpSessionModelProvider(
|
|
104
|
+
input: RpcInput<typeof getOmpSessionModelProvider>,
|
|
105
|
+
registry: OmpSubagentControlRegistry,
|
|
106
|
+
): RpcOutput<typeof getOmpSessionModelProvider> {
|
|
107
|
+
return { provider: registry.get(input.agentId)?.modelProvider() ?? null };
|
|
108
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const PLAN_LABELS: Record<string, string> = {
|
|
2
|
+
free: "Free",
|
|
3
|
+
go: "Go",
|
|
4
|
+
plus: "Plus",
|
|
5
|
+
pro: "Pro",
|
|
6
|
+
prolite: "Pro Lite",
|
|
7
|
+
max: "Max",
|
|
8
|
+
team: "Team",
|
|
9
|
+
business: "Business",
|
|
10
|
+
self_serve_business_prolite: "Business",
|
|
11
|
+
self_serve_business_usage_based: "Business",
|
|
12
|
+
enterprise: "Enterprise",
|
|
13
|
+
enterprise_cbp_automation: "Enterprise",
|
|
14
|
+
enterprise_cbp_usage_based: "Enterprise",
|
|
15
|
+
edu: "Edu",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Plan and organization badges for one login, e.g. ["Business", "Example Team"] or ["Personal"].
|
|
20
|
+
* `plan` is the raw plan OMP's usage report names (Codex `planType`, Copilot `plan`).
|
|
21
|
+
*/
|
|
22
|
+
export function accountTags(input: {
|
|
23
|
+
plan: string | null;
|
|
24
|
+
organization: string | null;
|
|
25
|
+
email: string | null;
|
|
26
|
+
}): string[] {
|
|
27
|
+
const { plan, organization, email } = input;
|
|
28
|
+
const tags: string[] = [];
|
|
29
|
+
if (plan) {
|
|
30
|
+
// An own-property lookup: a plan named like an Object member ("constructor") is still a plan.
|
|
31
|
+
const key = plan.toLowerCase();
|
|
32
|
+
tags.push(
|
|
33
|
+
Object.hasOwn(PLAN_LABELS, key)
|
|
34
|
+
? PLAN_LABELS[key]
|
|
35
|
+
: plan.charAt(0).toUpperCase() + plan.slice(1),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
// Codex reports its plan as the organization name too; that is not an organization.
|
|
39
|
+
if (organization && organization.toLowerCase() !== plan?.toLowerCase()) {
|
|
40
|
+
// Anthropic names a personal account's default organization after its email.
|
|
41
|
+
tags.push(email && organization === `${email}'s Organization` ? "Personal" : organization);
|
|
42
|
+
}
|
|
43
|
+
return [...new Set(tags)];
|
|
44
|
+
}
|
package/shared/hub.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { defineRpc } from "@getpaseo/plugin";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
// Mirrors the on-disk shape omp's hub writes under
|
|
5
|
-
// ~/.omp/run/daemons/<projectHash>/daemons/<name>/meta.json
|
|
6
|
-
// unversioned implementation
|
|
7
|
-
// here is optional-safe on the server side and this
|
|
8
|
-
// (state is a free-form string, not a fixed enum) to avoid
|
|
4
|
+
// Mirrors the on-disk shape omp's hub writes: omp 18's per-project brokers under
|
|
5
|
+
// ~/.omp/run/daemons/<projectHash>/daemons/<name>/meta.json, and omp 19's per-user daemon store
|
|
6
|
+
// (~/.omp/run/daemon/daemon.db). Both are internal, unversioned implementation details of the omp
|
|
7
|
+
// harness, not a published API, so every field here is optional-safe on the server side and this
|
|
8
|
+
// schema is intentionally permissive (state is a free-form string, not a fixed enum) to avoid
|
|
9
|
+
// rejecting shapes we have not seen.
|
|
9
10
|
export const HubProcessSchema = z.object({
|
|
10
11
|
name: z.string(),
|
|
11
12
|
application: z.string(),
|
package/shared/omp-accounts.ts
CHANGED
|
@@ -46,6 +46,8 @@ export const OmpAccountSchema = z.object({
|
|
|
46
46
|
/** OAuth logins have usage and resets; API keys have neither. */
|
|
47
47
|
oauth: z.boolean(),
|
|
48
48
|
label: z.string(),
|
|
49
|
+
/** Plan and organization badges from OMP's usage report, e.g. "Business" or "Personal". */
|
|
50
|
+
tags: z.array(z.string()).default([]),
|
|
49
51
|
limits: z.array(OmpAccountLimitSchema),
|
|
50
52
|
/** When OMP read the limits shown (epoch ms); null when it has no reading for this login. */
|
|
51
53
|
usageAt: z.number().int().nullable(),
|
package/shared/quota.ts
CHANGED
|
@@ -16,6 +16,10 @@ export const OmpQuotaSchema = z.object({
|
|
|
16
16
|
accountService: z.enum(["github", "ghe"]).nullable(),
|
|
17
17
|
/** GHE hostname; null for public GitHub and every other provider. */
|
|
18
18
|
accountHost: z.string().nullable(),
|
|
19
|
+
/** Raw plan OMP's cached usage report names (Codex `planType`, Copilot `plan`). */
|
|
20
|
+
plan: z.string().nullable().default(null),
|
|
21
|
+
/** Organization name from OMP's cached usage report, when it is not just the plan. */
|
|
22
|
+
organization: z.string().nullable().default(null),
|
|
19
23
|
label: z.string(),
|
|
20
24
|
windowLabel: z.string().nullable(),
|
|
21
25
|
usedFraction: z.number().min(0).nullable(),
|
|
@@ -30,3 +34,13 @@ export const listOmpQuotas = defineRpc({
|
|
|
30
34
|
input: z.object({ store: OmpStoreSchema.optional() }),
|
|
31
35
|
output: z.object({ quotas: z.array(OmpQuotaSchema) }),
|
|
32
36
|
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The OMP provider (such as `anthropic`) of the model an OMP Plugin agent's live session uses.
|
|
40
|
+
* Paseo only sees that model as an opaque id, so the provider is null without a live session.
|
|
41
|
+
*/
|
|
42
|
+
export const getOmpSessionModelProvider = defineRpc({
|
|
43
|
+
name: "paseo-omp.session-model-provider",
|
|
44
|
+
input: z.object({ agentId: z.string().min(1).max(256) }),
|
|
45
|
+
output: z.object({ provider: z.string().nullable() }),
|
|
46
|
+
});
|