pi-service-tier 0.4.0 → 0.6.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/README.md +64 -18
- package/agent-hooks.ts +75 -0
- package/domain.ts +28 -11
- package/package.json +4 -4
- package/service-tier.ts +52 -39
- package/shared.ts +0 -4
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ pi install npm:pi-service-tier
|
|
|
13
13
|
|
|
14
14
|
- Adds service tier parameters to supported provider requests when a tier is
|
|
15
15
|
configured
|
|
16
|
-
- Adds `/fast` to toggle the current model provider between
|
|
17
|
-
for this session only
|
|
16
|
+
- Adds `/fast` and `/ultrafast` to toggle the current model provider between
|
|
17
|
+
the selected speed and off for this session only
|
|
18
18
|
- Adds `/service-tier` to configure global defaults for all supported providers
|
|
19
19
|
from an interactive modal
|
|
20
20
|
- Adds an optional service tier widget when `pi-fancy-footer` is installed
|
|
@@ -25,6 +25,10 @@ pi install npm:pi-service-tier
|
|
|
25
25
|
**in this session**, without changing other sessions or your global defaults.
|
|
26
26
|
The supported providers all use `priority` as the fast tier.
|
|
27
27
|
|
|
28
|
+
- `/ultrafast`: toggles between `ultrafast` and off **in this session** for
|
|
29
|
+
`openai` and `openai-codex`. It uses the same provider override as `/fast`, so
|
|
30
|
+
selecting a different speed replaces the active tier.
|
|
31
|
+
|
|
28
32
|
- `/service-tier`: opens an interactive editor for **global defaults**. The
|
|
29
33
|
current model provider appears first, followed by the remaining supported
|
|
30
34
|
providers. Press Enter or Space to cycle through `off` and the provider-specific
|
|
@@ -32,11 +36,20 @@ pi install npm:pi-service-tier
|
|
|
32
36
|
|
|
33
37
|
### Session scope
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
mode off. Each provider has its own override, so switching models
|
|
37
|
-
choices. Turning
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
To speed up a session, run `/fast` or `/ultrafast`. Run the same command again to
|
|
40
|
+
turn that mode off. Each provider has its own override, so switching models
|
|
41
|
+
preserves your choices. Turning either mode off disables this extension's tier
|
|
42
|
+
injection, even if a global tier is configured. The command leaves other request
|
|
43
|
+
parameters unchanged.
|
|
44
|
+
|
|
45
|
+
| Current tier | `/fast` | `/ultrafast` |
|
|
46
|
+
| ------------- | ---------- | ------------ |
|
|
47
|
+
| Off or `flex` | `priority` | `ultrafast` |
|
|
48
|
+
| `priority` | Off | `ultrafast` |
|
|
49
|
+
| `ultrafast` | `priority` | Off |
|
|
50
|
+
|
|
51
|
+
Both commands remain listed on all providers. An unsupported provider/API pair
|
|
52
|
+
produces a warning without changing settings.
|
|
40
53
|
|
|
41
54
|
Overrides are saved with the session and restored on resume or extension reload.
|
|
42
55
|
They follow the active conversation branch: `/tree` restores the choices at the
|
|
@@ -44,6 +57,37 @@ selected point, and `/fork` or `/clone` inherits the choices on the copied branc
|
|
|
44
57
|
Later toggles in a fork do not affect its parent. `/new` starts without overrides
|
|
45
58
|
and uses your global defaults.
|
|
46
59
|
|
|
60
|
+
### Ultrafast availability
|
|
61
|
+
|
|
62
|
+
The extension sends `service_tier: "ultrafast"` for models using the `openai`
|
|
63
|
+
Responses API or `openai-codex`. OpenAI determines model and account eligibility.
|
|
64
|
+
Pi reports provider errors without automatically selecting another tier.
|
|
65
|
+
|
|
66
|
+
[OpenAI's API documentation] describes current model availability, rate limits,
|
|
67
|
+
and pricing. [Codex subscription eligibility] differs from API-key access and
|
|
68
|
+
may require workspace permissions.
|
|
69
|
+
|
|
70
|
+
[OpenAI's API documentation]: https://developers.openai.com/api/docs/guides/ultrafast-mode
|
|
71
|
+
[Codex subscription eligibility]: https://learn.chatgpt.com/docs/agent-configuration/speed
|
|
72
|
+
|
|
73
|
+
### Child agents
|
|
74
|
+
|
|
75
|
+
With [pi-agents](https://github.com/mavam/pi-agents) 0.36.0 or later, which
|
|
76
|
+
provides [agent extension hooks](https://github.com/mavam/pi-agents/blob/main/docs/hooks.md),
|
|
77
|
+
new agents capture your effective service-tier settings, including session
|
|
78
|
+
`/fast` and `/ultrafast` overrides. Each child applies the settings for its own
|
|
79
|
+
provider/API pair, even when it uses a different model from the parent.
|
|
80
|
+
|
|
81
|
+
For example, enable `/fast`, then ask Pi to spawn an agent. That agent keeps
|
|
82
|
+
its captured settings if you toggle `/fast` again. Graph nodes capture when
|
|
83
|
+
the graph is created; helpers inherit their creating agent's settings.
|
|
84
|
+
Follow-ups, child compaction, and resumed work retain the snapshot.
|
|
85
|
+
|
|
86
|
+
This integration is optional and adds no package dependency. A snapshot from a
|
|
87
|
+
newer version of pi-service-tier applies the providers and tiers this version
|
|
88
|
+
supports. If pi-service-tier is removed, stored snapshots remain but stop
|
|
89
|
+
affecting requests; loading it again applies them. Parent compaction and usage-cost limitations are unchanged.
|
|
90
|
+
|
|
47
91
|
## ⚙️ Configuration
|
|
48
92
|
|
|
49
93
|
Run `/service-tier` or create `~/.pi/agent/service-tier.json` to set global defaults:
|
|
@@ -60,18 +104,16 @@ Run `/service-tier` or create `~/.pi/agent/service-tier.json` to set global defa
|
|
|
60
104
|
|
|
61
105
|
### Supported providers
|
|
62
106
|
|
|
63
|
-
| Provider | Tiers
|
|
64
|
-
| --------------- |
|
|
65
|
-
| `openai` | `flex`, `priority`
|
|
66
|
-
| `openai-codex` | `flex`, `priority`
|
|
67
|
-
| `anthropic` | `priority`, `standard`
|
|
68
|
-
| `google` | `flex`, `priority`
|
|
69
|
-
| `google-vertex` | `flex`, `priority`
|
|
107
|
+
| Provider | Tiers | Fast tier |
|
|
108
|
+
| --------------- | ------------------------------- | ---------- |
|
|
109
|
+
| `openai` | `flex`, `priority`, `ultrafast` | `priority` |
|
|
110
|
+
| `openai-codex` | `flex`, `priority`, `ultrafast` | `priority` |
|
|
111
|
+
| `anthropic` | `priority`, `standard` | `priority` |
|
|
112
|
+
| `google` | `flex`, `priority` | `priority` |
|
|
113
|
+
| `google-vertex` | `flex`, `priority` | `priority` |
|
|
70
114
|
|
|
71
115
|
To turn a provider off by default, omit its key. Only the values listed above are
|
|
72
116
|
accepted. Providers without a session override continue to pick up global changes.
|
|
73
|
-
Existing global settings, including those saved by earlier versions of `/fast`,
|
|
74
|
-
remain in effect. Use `/service-tier` to change them.
|
|
75
117
|
Batch APIs are separate asynchronous APIs and are not configured by this
|
|
76
118
|
extension.
|
|
77
119
|
|
|
@@ -80,7 +122,9 @@ extension.
|
|
|
80
122
|
When [pi-fancy-footer](https://github.com/mavam/pi-fancy-footer) is installed,
|
|
81
123
|
the widget appears only when the active model uses a supported provider/API pair
|
|
82
124
|
and that provider has an effective tier after applying session overrides. It shows
|
|
83
|
-
a single `⚡`
|
|
125
|
+
`⚡⚡` for ultrafast or a single `⚡` for another active tier, without the tier
|
|
126
|
+
name. The bolts indicate the requested tier; they do not confirm which tier the
|
|
127
|
+
provider used.
|
|
84
128
|
|
|
85
129
|
The widget id is `pi-service-tier.service-tier`. It uses the current
|
|
86
130
|
`pi-fancy-footer` event protocol, with row `1`, position `8`, right alignment,
|
|
@@ -94,7 +138,9 @@ when the footer announces that it is ready.
|
|
|
94
138
|
injects the tier into the provider request payload, but pi's OpenAI Codex cost
|
|
95
139
|
calculation reads the requested tier from provider options. Until pi exposes a
|
|
96
140
|
first-class extension path for that option, displayed usage costs can omit
|
|
97
|
-
flex or priority multipliers.
|
|
141
|
+
flex or priority multipliers. Ultrafast pricing is also not represented by
|
|
142
|
+
Pi's current pricing logic. Do not use displayed costs to estimate ultrafast
|
|
143
|
+
charges.
|
|
98
144
|
|
|
99
145
|
## 📄 License
|
|
100
146
|
|
package/agent-hooks.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ExtensionAPI, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
applyServiceTierToPayload,
|
|
4
|
+
isRecord,
|
|
5
|
+
isServiceTierName,
|
|
6
|
+
isServiceTierProvider,
|
|
7
|
+
type ServiceTierConfigSnapshot,
|
|
8
|
+
type ServiceTierModel,
|
|
9
|
+
type ServiceTierProvider,
|
|
10
|
+
type ServiceTierSelection,
|
|
11
|
+
type ServiceTierSettings,
|
|
12
|
+
} from "./domain.ts";
|
|
13
|
+
import {
|
|
14
|
+
mergeServiceTierSettings,
|
|
15
|
+
restoreServiceTierOverrides,
|
|
16
|
+
} from "./session-state.ts";
|
|
17
|
+
|
|
18
|
+
/** Structural implementation of pi-agents/hooks protocol 1; no dependency. */
|
|
19
|
+
export function createAgentHooks(loadDefaults: () => ServiceTierConfigSnapshot) {
|
|
20
|
+
return {
|
|
21
|
+
namespace: "pi-service-tier",
|
|
22
|
+
onAgentCreate(ctx: { parent: { branch: readonly SessionEntry[] } }) {
|
|
23
|
+
return {
|
|
24
|
+
version: 1,
|
|
25
|
+
settings: mergeServiceTierSettings(
|
|
26
|
+
loadDefaults(),
|
|
27
|
+
restoreServiceTierOverrides(ctx.parent.branch),
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
onAgentRequest(
|
|
32
|
+
ctx: { state: unknown; model: ServiceTierModel },
|
|
33
|
+
payload: unknown,
|
|
34
|
+
) {
|
|
35
|
+
if (ctx.state === undefined) return undefined;
|
|
36
|
+
return applyServiceTierToPayload(payload, readSettings(ctx.state), ctx.model);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Stored settings are authoritative; never merge today's defaults on resume.
|
|
43
|
+
* Snapshots never change, so read every version 1 snapshot, also one a newer
|
|
44
|
+
* version wrote: providers and tiers this version doesn't know apply nothing.
|
|
45
|
+
*/
|
|
46
|
+
function readSettings(state: unknown): ServiceTierSettings {
|
|
47
|
+
if (!isRecord(state) || state.version !== 1 || !isRecord(state.settings)) {
|
|
48
|
+
throw new Error("Unsupported or invalid pi-service-tier agent state");
|
|
49
|
+
}
|
|
50
|
+
const settings: Partial<Record<ServiceTierProvider, ServiceTierSelection>> = {};
|
|
51
|
+
for (const [provider, value] of Object.entries(state.settings)) {
|
|
52
|
+
if (typeof value !== "string") {
|
|
53
|
+
throw new Error("Invalid service tier in pi-service-tier agent state");
|
|
54
|
+
}
|
|
55
|
+
if (!isServiceTierProvider(provider)) continue;
|
|
56
|
+
// An empty value explicitly disables injection and must survive too.
|
|
57
|
+
if (value === "" || isServiceTierName(provider, value)) {
|
|
58
|
+
settings[provider] = value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return settings;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function registerAgentHooks(
|
|
65
|
+
events: ExtensionAPI["events"],
|
|
66
|
+
loadDefaults: () => ServiceTierConfigSnapshot,
|
|
67
|
+
): void {
|
|
68
|
+
const hooks = createAgentHooks(loadDefaults);
|
|
69
|
+
events.on("pi-agents:hooks:discover", (request) => {
|
|
70
|
+
if (!isRecord(request) || request.protocol !== 1 || typeof request.register !== "function") {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
request.register(hooks);
|
|
74
|
+
});
|
|
75
|
+
}
|
package/domain.ts
CHANGED
|
@@ -7,7 +7,8 @@ export const SERVICE_TIER_PROVIDERS = [
|
|
|
7
7
|
] as const;
|
|
8
8
|
export type ServiceTierProvider = (typeof SERVICE_TIER_PROVIDERS)[number];
|
|
9
9
|
|
|
10
|
-
export type ServiceTierName = "flex" | "priority" | "standard";
|
|
10
|
+
export type ServiceTierName = "flex" | "priority" | "standard" | "ultrafast";
|
|
11
|
+
export type ServiceTierSpeed = "fast" | "ultrafast";
|
|
11
12
|
/** An omitted provider leaves the provider's default behavior unchanged. */
|
|
12
13
|
export type ServiceTierConfigSnapshot = Partial<
|
|
13
14
|
Record<ServiceTierProvider, ServiceTierName>
|
|
@@ -40,6 +41,7 @@ export interface ServiceTierProviderDefinition {
|
|
|
40
41
|
api: string;
|
|
41
42
|
tiers: readonly ServiceTier[];
|
|
42
43
|
fastTier?: ServiceTierName;
|
|
44
|
+
ultrafastTier?: ServiceTierName;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
function tier(name: ServiceTierName, value: string = name): ServiceTier {
|
|
@@ -53,14 +55,16 @@ export const SERVICE_TIER_PROVIDER_DEFINITIONS: Record<
|
|
|
53
55
|
openai: {
|
|
54
56
|
label: "OpenAI",
|
|
55
57
|
api: "openai-responses",
|
|
56
|
-
tiers: [tier("flex"), tier("priority")],
|
|
58
|
+
tiers: [tier("flex"), tier("priority"), tier("ultrafast")],
|
|
57
59
|
fastTier: "priority",
|
|
60
|
+
ultrafastTier: "ultrafast",
|
|
58
61
|
},
|
|
59
62
|
"openai-codex": {
|
|
60
63
|
label: "OpenAI Codex",
|
|
61
64
|
api: "openai-codex-responses",
|
|
62
|
-
tiers: [tier("flex"), tier("priority")],
|
|
65
|
+
tiers: [tier("flex"), tier("priority"), tier("ultrafast")],
|
|
63
66
|
fastTier: "priority",
|
|
67
|
+
ultrafastTier: "ultrafast",
|
|
64
68
|
},
|
|
65
69
|
anthropic: {
|
|
66
70
|
label: "Anthropic",
|
|
@@ -95,6 +99,15 @@ export function isServiceTierProvider(
|
|
|
95
99
|
);
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
export function isServiceTierName(
|
|
103
|
+
provider: ServiceTierProvider,
|
|
104
|
+
value: unknown,
|
|
105
|
+
): value is ServiceTierName {
|
|
106
|
+
return SERVICE_TIER_PROVIDER_DEFINITIONS[provider].tiers.some(
|
|
107
|
+
(tier) => tier.name === value,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
98
111
|
export function modelSupportsServiceTier(
|
|
99
112
|
model: ServiceTierModel | undefined,
|
|
100
113
|
): boolean {
|
|
@@ -165,29 +178,33 @@ export function applyServiceTierToPayload(
|
|
|
165
178
|
return applyPayloadServiceTier(payload, provider, serviceTier.value);
|
|
166
179
|
}
|
|
167
180
|
|
|
168
|
-
export interface
|
|
181
|
+
export interface ServiceTierToggleResult {
|
|
169
182
|
provider: ServiceTierProvider;
|
|
170
183
|
serviceTier: ServiceTierSelection;
|
|
171
|
-
|
|
184
|
+
enabled: boolean;
|
|
172
185
|
}
|
|
173
186
|
|
|
174
|
-
export function
|
|
187
|
+
export function toggleServiceTierSpeed(
|
|
175
188
|
config: ServiceTierSettings,
|
|
176
189
|
model: ServiceTierModel | undefined,
|
|
177
|
-
|
|
190
|
+
speed: ServiceTierSpeed = "fast",
|
|
191
|
+
): ServiceTierToggleResult | undefined {
|
|
178
192
|
const provider = getServiceTierProviderForModel(model);
|
|
179
193
|
if (!provider) return undefined;
|
|
180
194
|
|
|
181
195
|
const definition = SERVICE_TIER_PROVIDER_DEFINITIONS[provider];
|
|
182
|
-
|
|
196
|
+
const targetTier = speed === "ultrafast"
|
|
197
|
+
? definition.ultrafastTier
|
|
198
|
+
: definition.fastTier;
|
|
199
|
+
if (!targetTier) return undefined;
|
|
183
200
|
|
|
184
201
|
const current = getConfiguredServiceTier(config, provider);
|
|
185
|
-
const
|
|
186
|
-
const serviceTier =
|
|
202
|
+
const enabled = current !== targetTier;
|
|
203
|
+
const serviceTier = enabled ? targetTier : "";
|
|
187
204
|
return {
|
|
188
205
|
provider,
|
|
189
206
|
serviceTier,
|
|
190
|
-
|
|
207
|
+
enabled,
|
|
191
208
|
};
|
|
192
209
|
}
|
|
193
210
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-service-tier",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Fast mode and provider service-tier controls for pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@earendil-works/pi-coding-agent": "
|
|
8
|
-
"@earendil-works/pi-tui": "
|
|
7
|
+
"@earendil-works/pi-coding-agent": "^1.3.0",
|
|
8
|
+
"@earendil-works/pi-tui": "^1.3.0",
|
|
9
9
|
"typebox": "*"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"service-tier.ts",
|
|
13
|
-
"
|
|
13
|
+
"agent-hooks.ts",
|
|
14
14
|
"domain.ts",
|
|
15
15
|
"config.ts",
|
|
16
16
|
"settings.ts",
|
package/service-tier.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isServiceTierProvider,
|
|
18
18
|
resolveEffectiveServiceTier,
|
|
19
19
|
setProviderServiceTier,
|
|
20
|
-
|
|
20
|
+
toggleServiceTierSpeed,
|
|
21
21
|
type ServiceTierSelection,
|
|
22
22
|
type ServiceTierSettings,
|
|
23
23
|
type ServiceTierConfigSnapshot,
|
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
type SessionServiceTierOverrides,
|
|
38
38
|
} from "./session-state.ts";
|
|
39
39
|
|
|
40
|
+
import { registerAgentHooks } from "./agent-hooks.ts";
|
|
41
|
+
|
|
40
42
|
export const SERVICE_TIER_WIDGET_ID = "pi-service-tier.service-tier";
|
|
41
43
|
|
|
42
44
|
const FANCY_FOOTER_PROTOCOL = 1;
|
|
@@ -53,6 +55,11 @@ function formatModel(model: ExtensionContext["model"]): string {
|
|
|
53
55
|
return `${model.provider}/${model.id}`;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
function formatServiceTier(serviceTier: ServiceTierSelection): string {
|
|
59
|
+
if (!serviceTier) return "";
|
|
60
|
+
return serviceTier === "ultrafast" ? "⚡⚡" : "⚡";
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
function notifyConfigWriteError(ctx: ExtensionCommandContext, error: unknown): void {
|
|
57
64
|
const message = error instanceof Error ? error.message : String(error);
|
|
58
65
|
ctx.ui.notify(`Failed to save service tier config: ${message}`, "error");
|
|
@@ -85,8 +92,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
85
92
|
widget: {
|
|
86
93
|
id: SERVICE_TIER_WIDGET_ID,
|
|
87
94
|
label: "Service tier",
|
|
88
|
-
description: "Shows
|
|
89
|
-
content: { type: "text", text: currentServiceTier
|
|
95
|
+
description: "Shows two bolts for ultrafast or one for another active tier.",
|
|
96
|
+
content: { type: "text", text: formatServiceTier(currentServiceTier) },
|
|
90
97
|
icon: false,
|
|
91
98
|
layout: {
|
|
92
99
|
row: 1,
|
|
@@ -129,6 +136,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
129
136
|
}
|
|
130
137
|
};
|
|
131
138
|
|
|
139
|
+
// Register during loading, before either extension starts its session.
|
|
140
|
+
registerAgentHooks(pi.events, loadConfigOrDefault);
|
|
141
|
+
|
|
132
142
|
const loadConfigForCommand = (
|
|
133
143
|
ctx: ExtensionCommandContext,
|
|
134
144
|
): ServiceTierConfigSnapshot | undefined => {
|
|
@@ -177,43 +187,46 @@ export default function (pi: ExtensionAPI) {
|
|
|
177
187
|
}
|
|
178
188
|
};
|
|
179
189
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
for (const speed of ["fast", "ultrafast"] as const) {
|
|
191
|
+
pi.registerCommand(speed, {
|
|
192
|
+
description: `Toggle ${speed} service tier for the current provider in this session.`,
|
|
193
|
+
handler: async (_args, ctx) => {
|
|
194
|
+
const config = loadConfigForCommand(ctx);
|
|
195
|
+
if (!config) return;
|
|
196
|
+
|
|
197
|
+
const result = toggleServiceTierSpeed(effectiveSettings(config), ctx.model, speed);
|
|
198
|
+
if (!result) {
|
|
199
|
+
const label = speed === "ultrafast" ? "Ultrafast service tier" : "Service tier";
|
|
200
|
+
ctx.ui.notify(
|
|
201
|
+
`${label} is not supported for ${formatModel(ctx.model)}.`,
|
|
202
|
+
"warning",
|
|
203
|
+
);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const state: ServiceTierSessionState = {
|
|
208
|
+
version: 1,
|
|
209
|
+
overrides: { ...sessionOverrides, [result.provider]: result.serviceTier },
|
|
210
|
+
};
|
|
211
|
+
try {
|
|
212
|
+
pi.appendEntry(SERVICE_TIER_SESSION_ENTRY, state);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
215
|
+
ctx.ui.notify(`Failed to save session service tier: ${message}`, "error");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
sessionOverrides = state.overrides;
|
|
219
|
+
refreshServiceTier(ctx, effectiveSettings(config), true);
|
|
220
|
+
|
|
221
|
+
const providerLabel =
|
|
222
|
+
SERVICE_TIER_PROVIDER_DEFINITIONS[result.provider].label;
|
|
188
223
|
ctx.ui.notify(
|
|
189
|
-
|
|
190
|
-
"
|
|
224
|
+
`${providerLabel} service tier for this session: ${result.serviceTier || "off"}`,
|
|
225
|
+
"info",
|
|
191
226
|
);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const state: ServiceTierSessionState = {
|
|
196
|
-
version: 1,
|
|
197
|
-
overrides: { ...sessionOverrides, [result.provider]: result.serviceTier },
|
|
198
|
-
};
|
|
199
|
-
try {
|
|
200
|
-
pi.appendEntry(SERVICE_TIER_SESSION_ENTRY, state);
|
|
201
|
-
} catch (error) {
|
|
202
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
203
|
-
ctx.ui.notify(`Failed to save session service tier: ${message}`, "error");
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
sessionOverrides = state.overrides;
|
|
207
|
-
refreshServiceTier(ctx, effectiveSettings(config), true);
|
|
208
|
-
|
|
209
|
-
const providerLabel =
|
|
210
|
-
SERVICE_TIER_PROVIDER_DEFINITIONS[result.provider].label;
|
|
211
|
-
ctx.ui.notify(
|
|
212
|
-
`${providerLabel} service tier for this session: ${result.serviceTier || "off"}`,
|
|
213
|
-
"info",
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
});
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
}
|
|
217
230
|
|
|
218
231
|
pi.registerCommand("service-tier", {
|
|
219
232
|
description: "Configure global provider service tier defaults.",
|
|
@@ -234,7 +247,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
234
247
|
new Text(
|
|
235
248
|
`${theme.fg("accent", theme.bold("Global service tier defaults"))}\n${theme.fg(
|
|
236
249
|
"dim",
|
|
237
|
-
`${getServiceTierConfigPath()}\nSession /fast overrides take precedence.`,
|
|
250
|
+
`${getServiceTierConfigPath()}\nSession /fast and /ultrafast overrides take precedence.`,
|
|
238
251
|
)}`,
|
|
239
252
|
0,
|
|
240
253
|
0,
|
package/shared.ts
DELETED