@omercnet/paseo-omp 5.4.0-next.401.1 → 5.4.0-next.403.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/client/omp-config-surface.tsx +46 -17
- package/client/omp-update-row.tsx +87 -0
- package/index.server.ts +4 -0
- package/package.json +1 -1
- package/server/omp-update.ts +203 -0
- package/server/package-version.ts +1 -1
- package/shared/omp-settings.ts +79 -0
- package/shared/omp-update.ts +27 -0
|
@@ -21,10 +21,12 @@ import {
|
|
|
21
21
|
OMP_SETTING_CATEGORIES,
|
|
22
22
|
type OmpSetting,
|
|
23
23
|
type OmpSettingCategory,
|
|
24
|
+
orderOmpToolSettings,
|
|
24
25
|
parseOmpStructuredSettingValue,
|
|
25
26
|
updateOmpSettings,
|
|
26
27
|
} from "../shared/omp-settings";
|
|
27
28
|
import { type OmpStore, storeLabel } from "../shared/omp-store";
|
|
29
|
+
import { getOmpUpdateStatus } from "../shared/omp-update";
|
|
28
30
|
import { getOmpProviderHealth, type OmpProviderHealth } from "../shared/provider-diagnostics";
|
|
29
31
|
import { getOmpSupportReport, OMP_SUPPORT_ISSUE_URL } from "../shared/support-diagnostics";
|
|
30
32
|
import { ComposerPillSettingsSection } from "./composer-pill-settings";
|
|
@@ -47,6 +49,7 @@ import { OmpRulesSection } from "./omp-rules-section";
|
|
|
47
49
|
import { OmpSkillsSection } from "./omp-skills-section";
|
|
48
50
|
import { OmpStorePicker } from "./omp-store-picker";
|
|
49
51
|
import { ompStoreKey } from "./omp-store-state";
|
|
52
|
+
import { OmpUpdateRow, UPDATE_QUERY_KEY } from "./omp-update-row";
|
|
50
53
|
import {
|
|
51
54
|
type BinaryHealthSummary,
|
|
52
55
|
loadReadyProviderSnapshot,
|
|
@@ -222,10 +225,14 @@ function BinarySection({
|
|
|
222
225
|
theme,
|
|
223
226
|
styles,
|
|
224
227
|
health,
|
|
228
|
+
workspaceScoped,
|
|
229
|
+
onUpdateInstalled,
|
|
225
230
|
}: {
|
|
226
231
|
theme: PluginSurfaceProps["theme"];
|
|
227
232
|
styles: OmpConfigStyles;
|
|
228
233
|
health: OmpProviderHealth;
|
|
234
|
+
workspaceScoped: boolean;
|
|
235
|
+
onUpdateInstalled(): void;
|
|
229
236
|
}) {
|
|
230
237
|
const summary = summarizeBinaryHealth(health.binary);
|
|
231
238
|
return (
|
|
@@ -247,6 +254,9 @@ function BinarySection({
|
|
|
247
254
|
valueColor={theme.colors.statusDanger}
|
|
248
255
|
/>
|
|
249
256
|
) : null}
|
|
257
|
+
{health.binary.installed && !workspaceScoped ? (
|
|
258
|
+
<OmpUpdateRow styles={styles} theme={theme} onInstalled={onUpdateInstalled} />
|
|
259
|
+
) : null}
|
|
250
260
|
</SectionCard>
|
|
251
261
|
);
|
|
252
262
|
}
|
|
@@ -374,8 +384,10 @@ function ProviderHealthSection({
|
|
|
374
384
|
const paseo = usePaseo();
|
|
375
385
|
const queryClient = useQueryClient();
|
|
376
386
|
const loadHealth = useRpc(getOmpProviderHealth);
|
|
387
|
+
const loadUpdateStatus = useRpc(getOmpUpdateStatus);
|
|
388
|
+
const healthKey = [...HEALTH_QUERY_KEY, ompStoreKey(store), cwd ?? "global"];
|
|
377
389
|
const health = useQuery({
|
|
378
|
-
queryKey:
|
|
390
|
+
queryKey: healthKey,
|
|
379
391
|
queryFn: () => loadHealth({ store, ...(cwd ? { cwd } : {}) }),
|
|
380
392
|
});
|
|
381
393
|
const providers = useQuery({
|
|
@@ -384,23 +396,30 @@ function ProviderHealthSection({
|
|
|
384
396
|
});
|
|
385
397
|
const refresh = useMutation({
|
|
386
398
|
mutationFn: async () => {
|
|
387
|
-
const result = await
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
),
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
const [result, update] = await Promise.all([
|
|
400
|
+
refreshProviderDiagnostics({
|
|
401
|
+
providers: paseo.providers,
|
|
402
|
+
providerIds: [
|
|
403
|
+
...selectKnownOmpProviders(providers.data?.entries ?? []).map(
|
|
404
|
+
(provider) => provider.id,
|
|
405
|
+
),
|
|
406
|
+
...(store?.profile ? [`omp-plugin-${store.profile}`] : []),
|
|
407
|
+
],
|
|
408
|
+
loadForcedHealth: () => loadHealth({ store, force: true, ...(cwd ? { cwd } : {}) }),
|
|
409
|
+
cacheHealth: (value) => queryClient.setQueryData(healthKey, value),
|
|
410
|
+
cacheProviders: (value) => queryClient.setQueryData(PROVIDERS_QUERY_KEY, value),
|
|
411
|
+
}),
|
|
412
|
+
cwd ? undefined : loadUpdateStatus({ force: true }).catch(() => undefined),
|
|
413
|
+
]);
|
|
414
|
+
if (update) queryClient.setQueryData(UPDATE_QUERY_KEY, update);
|
|
401
415
|
if (result.failed) throw new Error("Could not fully refresh OMP provider health.");
|
|
402
416
|
},
|
|
403
417
|
});
|
|
418
|
+
// After an update the version row is stale; the install already returned the fresh update status.
|
|
419
|
+
const reloadHealth = useMutation({
|
|
420
|
+
mutationFn: () => loadHealth({ store, force: true, ...(cwd ? { cwd } : {}) }),
|
|
421
|
+
onSuccess: (value) => queryClient.setQueryData(healthKey, value),
|
|
422
|
+
});
|
|
404
423
|
const isRefreshing = refresh.isPending || health.isFetching || providers.isFetching;
|
|
405
424
|
const knownProviders = providers.data ? selectKnownOmpProviders(providers.data.entries) : [];
|
|
406
425
|
|
|
@@ -434,7 +453,15 @@ function ProviderHealthSection({
|
|
|
434
453
|
{refresh.error ? (
|
|
435
454
|
<Text style={styles.error}>Could not fully refresh provider health. Try again.</Text>
|
|
436
455
|
) : null}
|
|
437
|
-
{health.data ?
|
|
456
|
+
{health.data ? (
|
|
457
|
+
<BinarySection
|
|
458
|
+
theme={theme}
|
|
459
|
+
styles={styles}
|
|
460
|
+
health={health.data}
|
|
461
|
+
workspaceScoped={cwd !== undefined}
|
|
462
|
+
onUpdateInstalled={() => reloadHealth.mutate()}
|
|
463
|
+
/>
|
|
464
|
+
) : null}
|
|
438
465
|
{health.data ? (
|
|
439
466
|
<CapabilitiesSection theme={theme} styles={styles} health={health.data} />
|
|
440
467
|
) : null}
|
|
@@ -979,7 +1006,7 @@ function OmpConfigContent({
|
|
|
979
1006
|
: fallbackSettingsFromConfig(configQuery.data?.config);
|
|
980
1007
|
const matching = sourceSettings.filter((setting) => {
|
|
981
1008
|
if (!normalizedSearch) return true;
|
|
982
|
-
return `${setting.path}\n${setting.description}`
|
|
1009
|
+
return `${setting.path}\n${formatOmpSettingLabel(setting.path)}\n${setting.description}`
|
|
983
1010
|
.toLocaleLowerCase()
|
|
984
1011
|
.includes(normalizedSearch);
|
|
985
1012
|
});
|
|
@@ -990,6 +1017,8 @@ function OmpConfigContent({
|
|
|
990
1017
|
if (group) group.push(setting);
|
|
991
1018
|
else byCategory.set(category, [setting]);
|
|
992
1019
|
}
|
|
1020
|
+
const tools = byCategory.get("tools");
|
|
1021
|
+
if (tools) byCategory.set("tools", orderOmpToolSettings(tools));
|
|
993
1022
|
return { sourceSettings, matching, byCategory };
|
|
994
1023
|
}, [configQuery.data?.config, normalizedSearch, settingsQuery.data]);
|
|
995
1024
|
const modelCatalog: OmpModelCatalogState = {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Text, View } from "react-native";
|
|
5
|
+
import { getOmpUpdateStatus, installOmpUpdate, type OmpUpdateStatus } from "../shared/omp-update";
|
|
6
|
+
import { ActionButton, ConfirmModal } from "./omp-accounts-section";
|
|
7
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
8
|
+
|
|
9
|
+
export const UPDATE_QUERY_KEY = ["paseo-omp", "update-status"] as const;
|
|
10
|
+
|
|
11
|
+
export function summarizeUpdateStatus(status: OmpUpdateStatus): string {
|
|
12
|
+
if (status.state === "available") return `${status.version} available`;
|
|
13
|
+
if (status.state === "up-to-date") return "Up to date";
|
|
14
|
+
return "Could not check for updates";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The "Update available" line for the omp binary card, with a confirmed Update button. */
|
|
18
|
+
export function OmpUpdateRow({
|
|
19
|
+
styles,
|
|
20
|
+
theme,
|
|
21
|
+
onInstalled,
|
|
22
|
+
}: {
|
|
23
|
+
styles: OmpConfigStyles;
|
|
24
|
+
theme: PluginSurfaceProps["theme"];
|
|
25
|
+
onInstalled(): void;
|
|
26
|
+
}) {
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
const loadStatus = useRpc(getOmpUpdateStatus);
|
|
29
|
+
const install = useRpc(installOmpUpdate);
|
|
30
|
+
const status = useQuery({ queryKey: UPDATE_QUERY_KEY, queryFn: () => loadStatus({}) });
|
|
31
|
+
const [confirming, setConfirming] = useState(false);
|
|
32
|
+
const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);
|
|
33
|
+
const update = useMutation({
|
|
34
|
+
mutationFn: () => install({}),
|
|
35
|
+
onSuccess: async (result) => {
|
|
36
|
+
await queryClient.cancelQueries({ queryKey: UPDATE_QUERY_KEY });
|
|
37
|
+
queryClient.setQueryData(UPDATE_QUERY_KEY, result.status);
|
|
38
|
+
setMessage({ ok: result.ok, text: result.message });
|
|
39
|
+
onInstalled();
|
|
40
|
+
},
|
|
41
|
+
onError: () => setMessage({ ok: false, text: "Could not update OMP. Try again." }),
|
|
42
|
+
onSettled: () => setConfirming(false),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (status.isLoading) return <Text style={styles.muted}>Checking for an OMP update…</Text>;
|
|
46
|
+
const current = status.data ?? { state: "unknown" as const };
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<View style={styles.row}>
|
|
50
|
+
<Text style={styles.rowLabel}>Update</Text>
|
|
51
|
+
<Text
|
|
52
|
+
style={[
|
|
53
|
+
styles.rowValue,
|
|
54
|
+
current.state === "available" ? { color: theme.colors.statusWarning } : null,
|
|
55
|
+
]}
|
|
56
|
+
>
|
|
57
|
+
{summarizeUpdateStatus(current)}
|
|
58
|
+
</Text>
|
|
59
|
+
{current.state === "available" ? (
|
|
60
|
+
<ActionButton
|
|
61
|
+
styles={styles}
|
|
62
|
+
theme={theme}
|
|
63
|
+
label={update.isPending ? "Updating…" : "Update"}
|
|
64
|
+
disabled={update.isPending}
|
|
65
|
+
onPress={() => setConfirming(true)}
|
|
66
|
+
/>
|
|
67
|
+
) : null}
|
|
68
|
+
</View>
|
|
69
|
+
{message ? (
|
|
70
|
+
<Text style={message.ok ? styles.muted : styles.error}>{message.text}</Text>
|
|
71
|
+
) : null}
|
|
72
|
+
{confirming ? (
|
|
73
|
+
<ConfirmModal
|
|
74
|
+
styles={styles}
|
|
75
|
+
theme={theme}
|
|
76
|
+
title="Update OMP"
|
|
77
|
+
body="Installs the newest OMP on this host. Agents that are running keep the old version until they restart."
|
|
78
|
+
confirmLabel="Update"
|
|
79
|
+
tone="primary"
|
|
80
|
+
busy={update.isPending}
|
|
81
|
+
onConfirm={() => update.mutate()}
|
|
82
|
+
onCancel={() => setConfirming(false)}
|
|
83
|
+
/>
|
|
84
|
+
) : null}
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
}
|
package/index.server.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
resolveListOmpSkills,
|
|
26
26
|
resolveSetOmpSkillEnabled,
|
|
27
27
|
} from "./server/omp-skills";
|
|
28
|
+
import { resolveGetOmpUpdateStatus, resolveInstallOmpUpdate } from "./server/omp-update";
|
|
28
29
|
import { OmpOperationalFailureCollector } from "./server/operational-failure-diagnostics";
|
|
29
30
|
import { withOmpStore } from "./server/paths";
|
|
30
31
|
import { OmpProtocolViolationCollector } from "./server/protocol-violation-diagnostics";
|
|
@@ -84,6 +85,7 @@ import { listOmpRules } from "./shared/omp-rules";
|
|
|
84
85
|
import { listOmpSettings, updateOmpSettings } from "./shared/omp-settings";
|
|
85
86
|
import { deleteOmpManagedSkill, listOmpSkills, setOmpSkillEnabled } from "./shared/omp-skills";
|
|
86
87
|
import { listOmpStores, type OmpStore } from "./shared/omp-store";
|
|
88
|
+
import { getOmpUpdateStatus, installOmpUpdate } from "./shared/omp-update";
|
|
87
89
|
import { getOmpProviderHealth } from "./shared/provider-diagnostics";
|
|
88
90
|
import { getOmpImage } from "./shared/provider-image";
|
|
89
91
|
import { providerLaunchSettings } from "./shared/provider-launch-settings";
|
|
@@ -213,6 +215,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
213
215
|
server.handle(listOmpSettings, scoped(resolveListOmpSettings));
|
|
214
216
|
server.handle(updateOmpSettings, scoped(resolveUpdateOmpSettings));
|
|
215
217
|
server.handle(getOmpProviderHealth, scoped(resolveGetOmpProviderHealth));
|
|
218
|
+
server.handle(getOmpUpdateStatus, resolveGetOmpUpdateStatus);
|
|
219
|
+
server.handle(installOmpUpdate, resolveInstallOmpUpdate);
|
|
216
220
|
server.handle(getOmpImage, (input) => resolveGetOmpImage(input, ompImageCache()));
|
|
217
221
|
server.handle(
|
|
218
222
|
getOmpSupportReport,
|
package/package.json
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { tmpdir } from "node:os";
|
|
2
|
+
import { delimiter, dirname, parse } from "node:path";
|
|
3
|
+
import type { RpcInput } from "@getpaseo/plugin";
|
|
4
|
+
import {
|
|
5
|
+
type getOmpUpdateStatus,
|
|
6
|
+
type installOmpUpdate,
|
|
7
|
+
type OmpUpdateStatus,
|
|
8
|
+
OmpUpdateStatusSchema,
|
|
9
|
+
} from "../shared/omp-update";
|
|
10
|
+
import { SerialMutationQueue } from "./mutation-queue";
|
|
11
|
+
import { resolveOmpExecutable } from "./omp-settings";
|
|
12
|
+
import { currentOmpEnvironment } from "./paths";
|
|
13
|
+
import {
|
|
14
|
+
type BoundedRun,
|
|
15
|
+
buildStatefulCommandEnv,
|
|
16
|
+
defaultSpawn,
|
|
17
|
+
runBounded,
|
|
18
|
+
} from "./provider-diagnostics";
|
|
19
|
+
|
|
20
|
+
const CHECK_TIMEOUT_MS = 20_000;
|
|
21
|
+
const INSTALL_TIMEOUT_MS = 5 * 60_000;
|
|
22
|
+
const KILL_GRACE_MS = 1_000;
|
|
23
|
+
const MAX_OUTPUT_BYTES = 64 * 1024;
|
|
24
|
+
const CHECK_CACHE_TTL_MS = 10 * 60_000;
|
|
25
|
+
// Network and install-root settings an npm, bun or binary self-update needs. Credentials and
|
|
26
|
+
// tokens stay excluded.
|
|
27
|
+
const UPDATE_ENV = [
|
|
28
|
+
"HTTPS_PROXY",
|
|
29
|
+
"HTTP_PROXY",
|
|
30
|
+
"NO_PROXY",
|
|
31
|
+
"https_proxy",
|
|
32
|
+
"http_proxy",
|
|
33
|
+
"no_proxy",
|
|
34
|
+
"BUN_INSTALL",
|
|
35
|
+
"NODE_EXTRA_CA_CERTS",
|
|
36
|
+
"SSL_CERT_FILE",
|
|
37
|
+
"SSL_CERT_DIR",
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export interface OmpUpdateDependencies {
|
|
41
|
+
resolveExecutable(): Promise<string | null>;
|
|
42
|
+
run(executable: string, args: readonly string[], timeoutMs: number): Promise<BoundedRun>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface OmpInstallResult {
|
|
46
|
+
ok: boolean;
|
|
47
|
+
message: string;
|
|
48
|
+
status: OmpUpdateStatus;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `omp update` finds the install to replace by looking up `omp` on PATH, not by its own path, so
|
|
53
|
+
* the directory of the executable we run goes first: the check and the update then act on the
|
|
54
|
+
* install the Diagnostics card shows.
|
|
55
|
+
*/
|
|
56
|
+
export function updateEnvironment(executable: string): NodeJS.ProcessEnv {
|
|
57
|
+
const source = currentOmpEnvironment();
|
|
58
|
+
const env = buildStatefulCommandEnv(source);
|
|
59
|
+
for (const name of UPDATE_ENV) {
|
|
60
|
+
const value = source[name];
|
|
61
|
+
if (value !== undefined) env[name] = value;
|
|
62
|
+
}
|
|
63
|
+
env.PATH = [dirname(executable), env.PATH].filter(Boolean).join(delimiter);
|
|
64
|
+
env.NO_COLOR = "1";
|
|
65
|
+
return env;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function runOmp(executable: string, args: readonly string[], timeoutMs: number) {
|
|
69
|
+
return runBounded(
|
|
70
|
+
defaultSpawn,
|
|
71
|
+
executable,
|
|
72
|
+
args,
|
|
73
|
+
updateEnvironment(executable),
|
|
74
|
+
timeoutMs,
|
|
75
|
+
KILL_GRACE_MS,
|
|
76
|
+
MAX_OUTPUT_BYTES,
|
|
77
|
+
tmpdir(),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** An executable under another name cannot be found by omp's PATH lookup, so it is refused. */
|
|
82
|
+
async function resolveUpdateTarget(): Promise<string | null> {
|
|
83
|
+
const executable = await resolveOmpExecutable();
|
|
84
|
+
return executable && parse(executable).name.toLowerCase() === "omp" ? executable : null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function succeeded(run: BoundedRun): boolean {
|
|
88
|
+
return (
|
|
89
|
+
run.outcome === "exited" &&
|
|
90
|
+
run.exitCode === 0 &&
|
|
91
|
+
run.signal === null &&
|
|
92
|
+
!run.truncated &&
|
|
93
|
+
!run.cleanupFailed
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Reads the two lines `omp update --check` documents: "New version available" or "Already up to date". */
|
|
98
|
+
export function parseOmpUpdateCheck(stdout: string): OmpUpdateStatus {
|
|
99
|
+
const available = /^New version available: (\S+)\s*$/m.exec(stdout);
|
|
100
|
+
if (available) {
|
|
101
|
+
const parsed = OmpUpdateStatusSchema.safeParse({ state: "available", version: available[1] });
|
|
102
|
+
return parsed.success ? parsed.data : { state: "unknown" };
|
|
103
|
+
}
|
|
104
|
+
return /Already up to date/.test(stdout) ? { state: "up-to-date" } : { state: "unknown" };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function installMessage(run: BoundedRun, status: OmpUpdateStatus): string {
|
|
108
|
+
if (run.cleanupFailed) return "OMP update process cleanup could not be confirmed.";
|
|
109
|
+
if (run.outcome === "timeout") return "OMP update timed out. The install may be incomplete.";
|
|
110
|
+
if (!succeeded(run)) return "OMP could not update itself. Update it the way it was installed.";
|
|
111
|
+
if (status.state === "available") {
|
|
112
|
+
return "OMP is still on the old version. If a package manager installed it, update it there.";
|
|
113
|
+
}
|
|
114
|
+
if (status.state === "unknown") return "OMP update finished, but the new version is unconfirmed.";
|
|
115
|
+
return "OMP updated. Running agents keep the old version until they restart.";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Owns the update check cache. `omp update --check` goes to the network, so a recent answer is
|
|
120
|
+
* reused and concurrent callers share one run. A failed check is never cached. An install
|
|
121
|
+
* invalidates every check that started before it ended, so a slow check cannot write a stale
|
|
122
|
+
* answer over the post-install one.
|
|
123
|
+
*/
|
|
124
|
+
export function createOmpUpdateService(
|
|
125
|
+
dependencies: OmpUpdateDependencies,
|
|
126
|
+
now: () => number = Date.now,
|
|
127
|
+
) {
|
|
128
|
+
let cached: { status: OmpUpdateStatus; expiresAt: number } | null = null;
|
|
129
|
+
let inFlight: Promise<OmpUpdateStatus> | null = null;
|
|
130
|
+
let generation = 0;
|
|
131
|
+
const installs = new SerialMutationQueue();
|
|
132
|
+
|
|
133
|
+
async function checkNow(): Promise<OmpUpdateStatus> {
|
|
134
|
+
const executable = await dependencies.resolveExecutable();
|
|
135
|
+
if (!executable) return { state: "unknown" };
|
|
136
|
+
const run = await dependencies.run(executable, ["update", "--check"], CHECK_TIMEOUT_MS);
|
|
137
|
+
return succeeded(run) ? parseOmpUpdateCheck(run.stdout) : { state: "unknown" };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function check(force: boolean): Promise<OmpUpdateStatus> {
|
|
141
|
+
if (!force && cached && cached.expiresAt > now()) return Promise.resolve(cached.status);
|
|
142
|
+
if (inFlight) return inFlight;
|
|
143
|
+
const started = generation;
|
|
144
|
+
const request = checkNow()
|
|
145
|
+
.then((status) => {
|
|
146
|
+
if (started === generation && status.state !== "unknown") {
|
|
147
|
+
cached = { status, expiresAt: now() + CHECK_CACHE_TTL_MS };
|
|
148
|
+
}
|
|
149
|
+
return status;
|
|
150
|
+
})
|
|
151
|
+
.finally(() => {
|
|
152
|
+
if (inFlight === request) inFlight = null;
|
|
153
|
+
});
|
|
154
|
+
inFlight = request;
|
|
155
|
+
return request;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function invalidate(): void {
|
|
159
|
+
generation += 1;
|
|
160
|
+
cached = null;
|
|
161
|
+
inFlight = null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function install(): Promise<OmpInstallResult> {
|
|
165
|
+
const executable = await dependencies.resolveExecutable();
|
|
166
|
+
if (!executable) {
|
|
167
|
+
return {
|
|
168
|
+
ok: false,
|
|
169
|
+
message: "OMP can only be updated when its executable is named omp.",
|
|
170
|
+
status: { state: "unknown" },
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
invalidate();
|
|
174
|
+
const run = await dependencies.run(executable, ["update"], INSTALL_TIMEOUT_MS);
|
|
175
|
+
invalidate();
|
|
176
|
+
const status = await check(true);
|
|
177
|
+
return {
|
|
178
|
+
ok: succeeded(run) && status.state === "up-to-date",
|
|
179
|
+
message: installMessage(run, status),
|
|
180
|
+
status,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
status: (input: RpcInput<typeof getOmpUpdateStatus>) => check(input.force === true),
|
|
186
|
+
install: () => installs.run(install),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Binary-global, so the handlers are not store-scoped: a selected profile changes nothing here.
|
|
191
|
+
const service = createOmpUpdateService({ resolveExecutable: resolveUpdateTarget, run: runOmp });
|
|
192
|
+
|
|
193
|
+
export function resolveGetOmpUpdateStatus(
|
|
194
|
+
input: RpcInput<typeof getOmpUpdateStatus>,
|
|
195
|
+
): Promise<OmpUpdateStatus> {
|
|
196
|
+
return service.status(input);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function resolveInstallOmpUpdate(
|
|
200
|
+
_input: RpcInput<typeof installOmpUpdate>,
|
|
201
|
+
): Promise<OmpInstallResult> {
|
|
202
|
+
return service.install();
|
|
203
|
+
}
|
|
@@ -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.
|
|
2
|
+
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.403.1"; // x-release-please-version
|
package/shared/omp-settings.ts
CHANGED
|
@@ -309,7 +309,73 @@ const CATEGORY_PREFIXES: Readonly<Record<OmpSettingCategory, readonly string[]>>
|
|
|
309
309
|
general: [],
|
|
310
310
|
};
|
|
311
311
|
|
|
312
|
+
/** The optional-tool on/off switches, in the order they list when all are the same state. */
|
|
313
|
+
const OMP_TOOL_SWITCHES: readonly { path: string; label: string; description: string }[] = [
|
|
314
|
+
{
|
|
315
|
+
path: "github.enabled",
|
|
316
|
+
label: "GitHub",
|
|
317
|
+
description:
|
|
318
|
+
"Repositories, issues, pull requests and Actions from the agent. Needs the gh command on the PATH.",
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
path: "security.enabled",
|
|
322
|
+
label: "Security scan",
|
|
323
|
+
description: "Security scan planning and execution, plus the read-only security:// resources.",
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
path: "generate_image.enabled",
|
|
327
|
+
label: "Image generation",
|
|
328
|
+
description: "Text-to-image generation and editing.",
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
path: "speechgen.enabled",
|
|
332
|
+
label: "Speech synthesis",
|
|
333
|
+
description: "Turns text into speech files, on-device or with xAI Grok Voice.",
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
path: "computer.enabled",
|
|
337
|
+
label: "Desktop control",
|
|
338
|
+
description:
|
|
339
|
+
"Lets the agent script this machine's desktop: screenshots, input and accessibility.",
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
path: "lsp.enabled",
|
|
343
|
+
label: "Language servers",
|
|
344
|
+
description: "Code intelligence: definitions, references, diagnostics and rename.",
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
path: "debug.enabled",
|
|
348
|
+
label: "Debugger",
|
|
349
|
+
description: "Debugging through DAP adapters.",
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
path: "ida.enabled",
|
|
353
|
+
label: "IDA Pro",
|
|
354
|
+
description:
|
|
355
|
+
"Opens executables in IDA Pro and adds the ida tool. Does nothing without an IDA install.",
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
path: "checkpoint.enabled",
|
|
359
|
+
label: "Checkpoints",
|
|
360
|
+
description: "Checkpoint and rewind tools for saving and restoring context.",
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
path: "task.isolation.enabled",
|
|
364
|
+
label: "Task isolation",
|
|
365
|
+
description: "Lets a task run apart from the shared checkout when it asks to.",
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
path: "magicKeywords.enabled",
|
|
369
|
+
label: "Magic keywords",
|
|
370
|
+
description:
|
|
371
|
+
"Hidden notices when a message holds a standalone ultrathink, orchestrate, workflowz or jevify keyword.",
|
|
372
|
+
},
|
|
373
|
+
];
|
|
374
|
+
|
|
375
|
+
const TOOL_SWITCH_LABELS = new Map(OMP_TOOL_SWITCHES.map(({ path, label }) => [path, label]));
|
|
376
|
+
|
|
312
377
|
export function categorizeOmpSetting(path: string): OmpSettingCategory {
|
|
378
|
+
if (TOOL_SWITCH_LABELS.has(path)) return "tools";
|
|
313
379
|
for (const category of OMP_SETTING_CATEGORIES) {
|
|
314
380
|
if (CATEGORY_PREFIXES[category].some((prefix) => path === prefix || path.startsWith(prefix))) {
|
|
315
381
|
return category;
|
|
@@ -319,6 +385,8 @@ export function categorizeOmpSetting(path: string): OmpSettingCategory {
|
|
|
319
385
|
}
|
|
320
386
|
|
|
321
387
|
export function formatOmpSettingLabel(path: string): string {
|
|
388
|
+
const switchLabel = TOOL_SWITCH_LABELS.get(path);
|
|
389
|
+
if (switchLabel) return switchLabel;
|
|
322
390
|
const leaf = path.split(".").at(-1) ?? path;
|
|
323
391
|
const words = leaf
|
|
324
392
|
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
@@ -327,8 +395,19 @@ export function formatOmpSettingLabel(path: string): string {
|
|
|
327
395
|
return words ? `${words[0]?.toUpperCase() ?? ""}${words.slice(1)}` : path;
|
|
328
396
|
}
|
|
329
397
|
|
|
398
|
+
/** Tools category order: enabled switches, then disabled switches, then every other tool setting. */
|
|
399
|
+
export function orderOmpToolSettings(settings: readonly OmpSetting[]): OmpSetting[] {
|
|
400
|
+
const byPath = new Map(settings.map((setting) => [setting.path, setting]));
|
|
401
|
+
const switches = OMP_TOOL_SWITCHES.flatMap(({ path }) => byPath.get(path) ?? []);
|
|
402
|
+
const enabled = switches.filter((setting) => setting.value === true);
|
|
403
|
+
const disabled = switches.filter((setting) => setting.value !== true);
|
|
404
|
+
const rest = settings.filter((setting) => !TOOL_SWITCH_LABELS.has(setting.path));
|
|
405
|
+
return [...enabled, ...disabled, ...rest];
|
|
406
|
+
}
|
|
407
|
+
|
|
330
408
|
/** Plain wording that replaces OMP's own description (or its absence) for these settings. */
|
|
331
409
|
export const OMP_SETTING_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
|
410
|
+
...Object.fromEntries(OMP_TOOL_SWITCHES.map(({ path, description }) => [path, description])),
|
|
332
411
|
"session.warnCost":
|
|
333
412
|
"Warn once when a session's spend reaches this many US dollars. Leave unset for no warning. Applies to every session, including subagents, and takes effect on the next request.",
|
|
334
413
|
"session.maxCost":
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/** Bounded so nothing unbounded from `omp update --check` output crosses the RPC. */
|
|
5
|
+
const OmpUpdateVersionSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^\d{1,4}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z.]{1,32})?$/);
|
|
8
|
+
|
|
9
|
+
/** `unknown` means the check could not run or its output was not understood: never a guess. */
|
|
10
|
+
export const OmpUpdateStatusSchema = z.discriminatedUnion("state", [
|
|
11
|
+
z.object({ state: z.literal("up-to-date") }),
|
|
12
|
+
z.object({ state: z.literal("available"), version: OmpUpdateVersionSchema }),
|
|
13
|
+
z.object({ state: z.literal("unknown") }),
|
|
14
|
+
]);
|
|
15
|
+
export type OmpUpdateStatus = z.infer<typeof OmpUpdateStatusSchema>;
|
|
16
|
+
|
|
17
|
+
export const getOmpUpdateStatus = defineRpc({
|
|
18
|
+
name: "paseo-omp.get-update-status",
|
|
19
|
+
input: z.object({ force: z.boolean().optional() }),
|
|
20
|
+
output: OmpUpdateStatusSchema,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const installOmpUpdate = defineRpc({
|
|
24
|
+
name: "paseo-omp.install-update",
|
|
25
|
+
input: z.object({}),
|
|
26
|
+
output: z.object({ ok: z.boolean(), message: z.string(), status: OmpUpdateStatusSchema }),
|
|
27
|
+
});
|