@omercnet/paseo-omp 5.6.3 → 5.6.4-next.493.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/README.md CHANGED
@@ -31,7 +31,7 @@ paseo plugin install npm:@omercnet/paseo-omp@<version>
31
31
  paseo plugin ls paseo-omp
32
32
  ```
33
33
 
34
- Open the **OMP** sidebar to review the provider-profile contract, choose which composer pills appear, browse and edit native scalar settings, manage OMP-native plugins, verify runtime health, and generate a bounded support report under **Help**. The same tabs are available in the workspace OMP panel, except for the global Composer preference and the Accounts and MCPs tabs. Then create an agent and select **OMP Plugin**; on a new install, [enable it](#plugin-provider-opt-in) and restart the daemon first. Its optional **MCP** composer control runs OMP-native management commands in the current session; setup questions and authorization stay in that chat timeline, where OAuth can open in a workspace-scoped Paseo Browser or on the current device. While OMP subagents run, a row under each `task` card in the conversation lets you steer or stop one of them; this needs OMP 18.4.9 or newer. Composer pill preferences are shared by clients connected to the same host; normal use requires no other plugin-specific settings.
34
+ Open the **OMP** sidebar to review the provider-profile contract, choose which composer pills appear, browse and edit native scalar settings, manage OMP-native plugins, verify runtime health, and generate a bounded support report under **Help**. The same tabs, including Accounts, MCPs, and Composer, are available in the workspace OMP panel, which adds a workspace-only Security tab. Then create an agent and select **OMP Plugin**; on a new install, [enable it](#plugin-provider-opt-in) and restart the daemon first. Its optional **MCP** composer control runs OMP-native management commands in the current session; setup questions and authorization stay in that chat timeline, where OAuth can open in a workspace-scoped Paseo Browser or on the current device. While OMP subagents run, a row under each `task` card in the conversation lets you steer or stop one of them; this needs OMP 18.4.9 or newer. Composer pill preferences are shared by clients connected to the same host; normal use requires no other plugin-specific settings.
35
35
 
36
36
  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).
37
37
 
@@ -143,7 +143,7 @@ Existing agents whose provider is `omp` remain owned by the bundled provider. Ne
143
143
 
144
144
  OMP `18.1.15` is the oldest version tested end to end. The direct provider's hard compatibility gate is `rpc-ui` protocol v2: metadata-free legacy ready frames and v1-only runtimes are rejected before a provider session opens because they cannot support the advertised persistence and conversation-rewind capabilities. Typed tool approvals remain capability-gated and fall back as described above. For terminal completion, a matching `agent_end.requestId` is authoritative and mismatches are ignored before state changes. Released OMP 18.2.x builds that omit that field use an ordered fallback requiring a fresh correlated native user entry followed by current-turn assistant activity, an idle non-compacting runtime, and no conflicting permission, tool, steer, or child-session work. Ambiguous events while OMP is active are ignored; unresolved ambiguity after confirmed idle fails only the Paseo turn. This trades a bounded residual same-agent stale-event risk for compatibility with released OMP instead of terminating and lazily restarting the runtime after every later prompt. Paseo clients, including mobile clients inside reconnect grace, do not own or terminate the daemon-managed OMP session.
145
145
 
146
- Paseo 0.14 is the minimum supported release. The controlled Docker canary is pinned to official Paseo image `0.16.0-beta.1@sha256:9feae06fe11c508b5fc0ff42869cdab2b86b3af23c5beada308a0edb96714bdf`; nightly SDK checks cover the latest and beta channels. The canary preserves nested provider-subagent ancestry and spawning-tool links, and validates npm-managed plugin sources, platform-owned external URL opening, and whole-item timeline transforms before Overview grouping.
146
+ Paseo 0.14 is the minimum supported release. The controlled Docker canary is pinned to official Paseo image `0.16.0-beta.2@sha256:6139c4e247e49431a0d54ef01265b874bd91eb35f755088a7f19b31c66eb3d86`; nightly SDK checks cover the latest and beta channels. The canary preserves nested provider-subagent ancestry and spawning-tool links, and validates npm-managed plugin sources, platform-owned external URL opening, and whole-item timeline transforms before Overview grouping.
147
147
 
148
148
  Paseo releases idle resumable agent runtimes after one hour; the agent stays listed as `closed` and the next prompt resumes the same OMP session. The plugin vetoes that release while the session has a running turn, a pending permission, an active subagent, or OMP background async work, and while OMP does not report a settled state (the plugin needs the `hasPendingAsyncWork` and `isSettled` fields in OMP's `get_state`; builds without them are never released). Set `agents.idleRuntimeCleanup: false` in the Paseo config to disable idle release for every provider.
149
149
 
@@ -248,13 +248,11 @@ function BinarySection({
248
248
  theme,
249
249
  styles,
250
250
  health,
251
- workspaceScoped,
252
251
  onUpdateInstalled,
253
252
  }: {
254
253
  theme: PluginSurfaceProps["theme"];
255
254
  styles: OmpConfigStyles;
256
255
  health: OmpProviderHealth;
257
- workspaceScoped: boolean;
258
256
  onUpdateInstalled(): void;
259
257
  }) {
260
258
  const summary = summarizeBinaryHealth(health.binary);
@@ -277,7 +275,7 @@ function BinarySection({
277
275
  valueColor={theme.colors.statusDanger}
278
276
  />
279
277
  ) : null}
280
- {health.binary.installed && !workspaceScoped ? (
278
+ {health.binary.installed ? (
281
279
  <OmpUpdateRow styles={styles} theme={theme} onInstalled={onUpdateInstalled} />
282
280
  ) : null}
283
281
  </SectionCard>
@@ -534,7 +532,7 @@ function ProviderHealthSection({
534
532
  cacheHealth: (value) => queryClient.setQueryData(healthKey, value),
535
533
  cacheProviders: (value) => queryClient.setQueryData(PROVIDERS_QUERY_KEY, value),
536
534
  }),
537
- cwd ? undefined : loadUpdateStatus({ force: true }).catch(() => undefined),
535
+ loadUpdateStatus({ force: true }).catch(() => undefined),
538
536
  ]);
539
537
  if (update) queryClient.setQueryData(UPDATE_QUERY_KEY, update);
540
538
  await queryClient.invalidateQueries({ queryKey: PROMPT_FILES_QUERY_KEY });
@@ -585,7 +583,6 @@ function ProviderHealthSection({
585
583
  theme={theme}
586
584
  styles={styles}
587
585
  health={health.data}
588
- workspaceScoped={cwd !== undefined}
589
586
  onUpdateInstalled={() => reloadHealth.mutate()}
590
587
  />
591
588
  ) : null}
@@ -1293,7 +1290,7 @@ function OmpConfigContent({
1293
1290
  }, []);
1294
1291
 
1295
1292
  const save = useMutation({
1296
- mutationKey: ["paseo-omp", "settings", ompStoreKey(store)],
1293
+ mutationKey: ["paseo-omp", "settings", ompStoreKey(store), cwd ?? "global"],
1297
1294
  mutationFn: async () => {
1298
1295
  const revision = settingsQuery.data?.revision;
1299
1296
  if (!revision) throw new Error("OMP settings cannot be edited without a current revision.");
@@ -1420,19 +1417,17 @@ function OmpConfigContent({
1420
1417
  </>
1421
1418
  ) : null}
1422
1419
 
1423
- {view === "accounts" && !cwd ? (
1420
+ {view === "accounts" ? (
1424
1421
  <OmpAccountsSection theme={theme} styles={styles} store={store} />
1425
1422
  ) : null}
1426
1423
 
1427
- {view === "mcps" && !cwd ? (
1428
- <OmpMcpsSection theme={theme} styles={styles} store={store} />
1429
- ) : null}
1424
+ {view === "mcps" ? <OmpMcpsSection theme={theme} styles={styles} store={store} /> : null}
1430
1425
 
1431
1426
  {view === "plugin" ? (
1432
1427
  <>
1433
1428
  <PluginConfigurationSection styles={styles} />
1434
1429
  <ToolBoundaryCard styles={styles} />
1435
- {!cwd ? <ProviderLaunchSettingsSection theme={theme} /> : null}
1430
+ <ProviderLaunchSettingsSection theme={theme} />
1436
1431
  </>
1437
1432
  ) : null}
1438
1433
 
@@ -1457,7 +1452,7 @@ function OmpConfigContent({
1457
1452
  {view === "security" && cwd ? (
1458
1453
  <OmpSecuritySection styles={styles} cwd={cwd} store={store} />
1459
1454
  ) : null}
1460
- {view === "composer" && !cwd && onComposerPillSettingsChange ? (
1455
+ {view === "composer" && onComposerPillSettingsChange ? (
1461
1456
  <ComposerPillSettingsSection theme={theme} onChange={onComposerPillSettingsChange} />
1462
1457
  ) : null}
1463
1458
 
@@ -1671,20 +1666,19 @@ function OmpConfigContent({
1671
1666
  store={store}
1672
1667
  cwd={cwd}
1673
1668
  />
1674
- {cwd === undefined ? (
1675
- <OmpLocalModelsSection
1676
- styles={styles}
1677
- store={store}
1678
- modelRoles={savedModelRoles}
1679
- settingsRevision={settingsQuery.data?.revision}
1680
- rolesPending={drafts.modelRoles !== undefined}
1681
- onRolesChanged={(catalog) => {
1682
- if (catalog) queryClient.setQueryData(settingsQueryKey, catalog);
1683
- void queryClient.invalidateQueries({ queryKey: SETTINGS_QUERY_KEY });
1684
- void queryClient.invalidateQueries({ queryKey: ["paseo-omp", "config"] });
1685
- }}
1686
- />
1687
- ) : null}
1669
+ <OmpLocalModelsSection
1670
+ styles={styles}
1671
+ store={store}
1672
+ cwd={cwd}
1673
+ modelRoles={savedModelRoles}
1674
+ settingsRevision={settingsQuery.data?.revision}
1675
+ rolesPending={drafts.modelRoles !== undefined}
1676
+ onRolesChanged={(catalog) => {
1677
+ if (catalog) queryClient.setQueryData(settingsQueryKey, catalog);
1678
+ void queryClient.invalidateQueries({ queryKey: SETTINGS_QUERY_KEY });
1679
+ void queryClient.invalidateQueries({ queryKey: ["paseo-omp", "config"] });
1680
+ }}
1681
+ />
1688
1682
  </>
1689
1683
  ) : null}
1690
1684
  </ScrollView>
@@ -1728,7 +1722,11 @@ export function OmpConfigSurface(
1728
1722
  return <OmpStoreContent {...props} />;
1729
1723
  }
1730
1724
 
1731
- export function OmpWorkspacePanel(props: PluginWorkspacePanelProps) {
1725
+ export function OmpWorkspacePanel(
1726
+ props: PluginWorkspacePanelProps & {
1727
+ onComposerPillSettingsChange?: (settings: ComposerPillSettings) => void;
1728
+ },
1729
+ ) {
1732
1730
  const cwd = useWorkspace(props.workspaceId, (workspace) => workspace.directory);
1733
1731
  if (!cwd) {
1734
1732
  return (
@@ -29,10 +29,7 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
29
29
  { id: "help", label: "Help" },
30
30
  ];
31
31
 
32
- /** Views that belong to the OMP store, not to a workspace's project settings. */
33
- const STORE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["composer", "accounts", "mcps"];
34
-
35
- /** Views about one project, which the global OMP screen has no project for. */
32
+ /** Views about one project: the workspace panel adds them, and the global OMP screen has no project for them. Every other view is on both surfaces. */
36
33
  const WORKSPACE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["security"];
37
34
 
38
35
  interface SurfaceScope {
@@ -42,7 +39,7 @@ interface SurfaceScope {
42
39
  }
43
40
 
44
41
  export function surfaceViewsForScope({ workspaceScoped, pluginProviderEnabled }: SurfaceScope) {
45
- const hidden = workspaceScoped ? STORE_ONLY_VIEWS : WORKSPACE_ONLY_VIEWS;
42
+ const hidden = workspaceScoped ? [] : WORKSPACE_ONLY_VIEWS;
46
43
  return SURFACE_VIEWS.filter(
47
44
  (candidate) =>
48
45
  !hidden.includes(candidate.id) && (pluginProviderEnabled || candidate.id !== "plugin"),
@@ -5,6 +5,7 @@ import { Pressable, Text, View } from "react-native";
5
5
  import {
6
6
  downloadOmpLocalModel,
7
7
  listOmpLocalModels,
8
+ localModelRoleAction,
8
9
  type OmpLocalModel,
9
10
  withLocalModelRole,
10
11
  } from "../shared/omp-local-models";
@@ -62,6 +63,7 @@ function status(model: OmpLocalModel): string {
62
63
  export function OmpLocalModelsSection({
63
64
  styles,
64
65
  store,
66
+ cwd,
65
67
  modelRoles,
66
68
  settingsRevision,
67
69
  rolesPending,
@@ -69,6 +71,8 @@ export function OmpLocalModelsSection({
69
71
  }: {
70
72
  styles: OmpConfigStyles;
71
73
  store: OmpStore | undefined;
74
+ /** In the workspace panel, a role assignment is a project override of that workspace. */
75
+ cwd?: string;
72
76
  modelRoles: Readonly<Record<string, unknown>>;
73
77
  settingsRevision: string | undefined;
74
78
  /** Unapplied edits to modelRoles would be overwritten by a role assignment made here. */
@@ -93,11 +97,12 @@ export function OmpLocalModelsSection({
93
97
  onSettled: () => queryClient.invalidateQueries({ queryKey }),
94
98
  });
95
99
  const assign = useMutation({
96
- mutationKey: ["paseo-omp", "settings", ompStoreKey(store)],
100
+ mutationKey: ["paseo-omp", "settings", ompStoreKey(store), cwd ?? "global"],
97
101
  mutationFn: async (next: Record<string, unknown>) => {
98
102
  if (!settingsRevision) throw new Error("OMP settings cannot be edited without a revision.");
99
103
  const input = updateOmpSettings.input.parse({
100
104
  ...(store ? { store } : {}),
105
+ ...(cwd ? { cwd } : {}),
101
106
  revision: settingsRevision,
102
107
  changes: [{ operation: "set", path: "modelRoles", value: next }],
103
108
  });
@@ -128,6 +133,14 @@ export function OmpLocalModelsSection({
128
133
  if the local model fails, the session stays untitled. The first download can also install
129
134
  OMP's inference runtime, so it may take longer and use more disk than the model size.
130
135
  </Text>
136
+ {cwd ? (
137
+ <Text style={styles.settingDescription}>
138
+ Here a role can be set for this workspace but not cleared. Setting one saves every
139
+ current role as this project's modelRoles override, so later global changes no longer
140
+ reach this workspace. To clear a role, remove the project's modelRoles override under
141
+ Configuration; the workspace then follows the global roles again.
142
+ </Text>
143
+ ) : null}
131
144
  {models.error || (models.data && !models.data.available) ? (
132
145
  <Text style={styles.error}>OMP could not list its local models.</Text>
133
146
  ) : null}
@@ -194,15 +207,16 @@ export function OmpLocalModelsSection({
194
207
  {ROLES.map(({ role, label }) => {
195
208
  const selector = `local/${model.key}`;
196
209
  const assigned = modelRoles[role] === selector;
210
+ const action = localModelRoleAction(assigned, cwd !== undefined);
197
211
  return (
198
212
  <Choice
199
213
  key={role}
200
214
  styles={styles}
201
215
  label={assigned ? `Using for ${label}` : `Use for ${label}`}
202
- accessibilityLabel={`${assigned ? "Stop using" : "Use"} ${model.label} for ${label}`}
216
+ accessibilityLabel={`${action === "use" ? "Use" : action === "stop" ? "Stop using" : "Using"} ${model.label} for ${label}`}
203
217
  selected={assigned}
204
- disabled={blocked}
205
- onPress={() => assignRole(role, assigned ? null : selector)}
218
+ disabled={blocked || action === "unavailable"}
219
+ onPress={() => assignRole(role, action === "stop" ? null : selector)}
206
220
  />
207
221
  );
208
222
  })}
package/index.client.tsx CHANGED
@@ -3,6 +3,7 @@ import type {
3
3
  PluginButtonRegistration,
4
4
  PluginClientContext,
5
5
  PluginSurfaceProps,
6
+ PluginWorkspacePanelProps,
6
7
  } from "@getpaseo/plugin/client";
7
8
  import { OmpAstEditCard } from "./client/ast-edit";
8
9
  import { ConfigSidebarItem } from "./client/config-sidebar";
@@ -192,12 +193,17 @@ export default function contribute(client: PluginClientContext) {
192
193
  openPanel("memory", { location: "explorer" });
193
194
  },
194
195
  });
196
+ function WorkspacePanel(props: PluginWorkspacePanelProps) {
197
+ return (
198
+ <OmpWorkspacePanel {...props} onComposerPillSettingsChange={applyComposerPillSettings} />
199
+ );
200
+ }
195
201
  const removeWorkspacePanel = client.addWorkspacePanel({
196
202
  id: "workspace",
197
203
  title: "OMP",
198
204
  icon: "Settings",
199
205
  locations: ["workspace", "explorer"],
200
- Component: OmpWorkspacePanel,
206
+ Component: WorkspacePanel,
201
207
  });
202
208
  const removeOpenWorkspace = client.addCommandCenterItem({
203
209
  id: "open-workspace",
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.6.3",
3
+ "version": "5.6.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@omercnet/paseo-omp",
9
- "version": "5.6.3",
9
+ "version": "5.6.4",
10
10
  "dependencies": {
11
- "@getpaseo/protocol": "0.16.0-beta.1",
11
+ "@getpaseo/protocol": "0.16.0-beta.2",
12
12
  "@modelcontextprotocol/sdk": "1.32.2",
13
13
  "yaml": "^2.9.0"
14
14
  }
15
15
  },
16
16
  "node_modules/@getpaseo/protocol": {
17
- "version": "0.16.0-beta.1",
18
- "resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.16.0-beta.1.tgz",
19
- "integrity": "sha512-RU/Q8OxRWGJ4NSGSZV0Y9j8/12SCgcA/ulxfldgmtnxBRV1upfW6c6ao7sK9Bz0mQ5vZfxpLNVSzKqheChoKgw==",
17
+ "version": "0.16.0-beta.2",
18
+ "resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.16.0-beta.2.tgz",
19
+ "integrity": "sha512-w3LynGf+Q0mT9XlKVHnXlNeH/wCpaZcBATYJMh61kiQMNsjKrf61x1kOp9Vutst3nyts0iABVAYVHd+DnUxESQ==",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
22
  "semver": "^7.8.5",
@@ -24,9 +24,9 @@
24
24
  }
25
25
  },
26
26
  "node_modules/@hono/node-server": {
27
- "version": "2.1.6",
28
- "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.6.tgz",
29
- "integrity": "sha512-p/KH9MnfNcsm3sR6x4lNgm5j+QN4Et8srKredl9DZfXiyZ1UQ3aQ2YVpFLbqktYN5JI+DB+VZFKM2PqE5hLKjQ==",
27
+ "version": "2.1.7",
28
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.7.tgz",
29
+ "integrity": "sha512-Wr0E6S+v2Bw9FkpGNP5BQ5QbJvclUa06UVehd65WFZe6XeJwbrKQQ5wPDevc0IC+QyzbO7v3Llh5uo45IZcSnA==",
30
30
  "license": "MIT",
31
31
  "engines": {
32
32
  "node": ">=20"
@@ -314,9 +314,9 @@
314
314
  "license": "MIT"
315
315
  },
316
316
  "node_modules/encodeurl": {
317
- "version": "2.0.1",
318
- "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz",
319
- "integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==",
317
+ "version": "2.0.2",
318
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.2.tgz",
319
+ "integrity": "sha512-ddmxiyS6ETq/v5/+mdA4fykK7JgEmqcShrGmQFTaKf5o43tL8XLuMzNLLsspuIC3/qGupS7Ci2TF+feJRkYY0w==",
320
320
  "license": "MIT",
321
321
  "engines": {
322
322
  "node": ">= 0.8"
@@ -611,9 +611,9 @@
611
611
  }
612
612
  },
613
613
  "node_modules/hono": {
614
- "version": "4.13.17",
615
- "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.17.tgz",
616
- "integrity": "sha512-vZIcbkvjOR5hHRWERbGkr8fGfF0GGM1ooYkuH448iO3b2AdVEr3AXZSw4Z3Kn+1L5z0CVoVeyV29VGYmFh05kQ==",
614
+ "version": "4.13.18",
615
+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.18.tgz",
616
+ "integrity": "sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==",
617
617
  "license": "MIT",
618
618
  "engines": {
619
619
  "node": ">=16.9.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.6.3",
3
+ "version": "5.6.4-next.493.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -54,26 +54,26 @@
54
54
  "typecheck": "tsc --noEmit -p tsconfig.client.json && tsc --noEmit -p tsconfig.server.json && tsc --noEmit -p tsconfig.tests.json"
55
55
  },
56
56
  "dependencies": {
57
- "@getpaseo/protocol": "0.16.0-beta.1",
57
+ "@getpaseo/protocol": "0.16.0-beta.2",
58
58
  "@modelcontextprotocol/sdk": "1.32.2",
59
59
  "yaml": "^2.9.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@biomejs/biome": "^2.5.10",
63
- "@getpaseo/cli": "0.16.0-beta.1",
64
- "@getpaseo/client": "0.16.0-beta.1",
65
- "@getpaseo/plugin": "0.16.0-beta.1",
66
- "@getpaseo/server": "0.16.0-beta.1",
67
- "@oh-my-pi/pi-agent-core": "18.18.0",
68
- "@oh-my-pi/pi-coding-agent": "18.18.0",
63
+ "@getpaseo/cli": "0.16.0-beta.2",
64
+ "@getpaseo/client": "0.16.0-beta.2",
65
+ "@getpaseo/plugin": "0.16.0-beta.2",
66
+ "@getpaseo/server": "0.16.0-beta.2",
67
+ "@oh-my-pi/pi-agent-core": "18.18.8",
68
+ "@oh-my-pi/pi-coding-agent": "18.18.8",
69
69
  "@tanstack/react-query": "^5.102.3",
70
70
  "@types/node": "^24.10.1",
71
71
  "@types/react": "^19.2.18",
72
72
  "@vitest/coverage-v8": "^5.0.0",
73
73
  "esbuild": "0.28.2",
74
+ "pino": "10.4.0",
74
75
  "react": "19.1.0",
75
76
  "react-native": "0.81.5",
76
- "pino": "10.4.0",
77
77
  "tsx": "^4.20.6",
78
78
  "typescript": "^7.0.2",
79
79
  "vitest": "^5.0.0",
package/server/hub.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { readdir, readFile } from "node:fs/promises";
1
+ import type { Dirent } from "node:fs";
2
+ import { readdir, readFile, realpath } from "node:fs/promises";
2
3
  import { homedir } from "node:os";
3
- import { join } from "node:path";
4
+ import { join, resolve } from "node:path";
4
5
  import type { RpcInput } from "@getpaseo/plugin";
5
6
  import { z } from "zod";
6
7
  import type { HubProcess, listHubProcesses, tailHubLog } from "../shared/hub";
8
+ import { waitMs } from "./provider/omp-rpc-process";
7
9
 
8
10
  const MAX_LOG_BYTES = 64 * 1024;
9
11
 
@@ -46,32 +48,70 @@ function ompRunDir(): string {
46
48
  return process.env.PASEO_OMP_RUN_DIR ?? join(homedir(), ".omp", "run", "daemons");
47
49
  }
48
50
 
49
- async function readJsonFile(path: string): Promise<unknown | undefined> {
51
+ type Read<T> = { value: T } | { missing: true } | { unreadable: true };
52
+
53
+ export function readFailure(error: unknown): { missing: true } | { unreadable: true } {
54
+ const code = (error as NodeJS.ErrnoException | undefined)?.code;
55
+ // Only ENOENT proves a record is gone; anything else (ENOTDIR included) leaves it unknown.
56
+ return code === "ENOENT" ? { missing: true } : { unreadable: true };
57
+ }
58
+
59
+ async function readJson(path: string): Promise<Read<unknown>> {
60
+ let text: string;
50
61
  try {
51
- return JSON.parse(await readFile(path, "utf8"));
62
+ text = await readFile(path, "utf8");
63
+ } catch (error) {
64
+ return readFailure(error);
65
+ }
66
+ try {
67
+ return { value: JSON.parse(text) };
52
68
  } catch {
53
- return undefined;
69
+ return { unreadable: true };
54
70
  }
55
71
  }
56
72
 
57
- async function listDirNames(path: string): Promise<string[]> {
73
+ async function readDirEntries(path: string): Promise<Read<Dirent[]>> {
58
74
  try {
59
- return await readdir(path);
75
+ return { value: await readdir(path, { withFileTypes: true }) };
76
+ } catch (error) {
77
+ return readFailure(error);
78
+ }
79
+ }
80
+
81
+ // omp keys a project's broker by its realpath (`canonicalProjectDir`), so a symlinked or
82
+ // trailing-slash cwd must be resolved the same way to find its `scope.json`.
83
+ async function canonicalProjectDir(cwd: string): Promise<string> {
84
+ const resolved = resolve(cwd);
85
+ try {
86
+ return await realpath(resolved);
60
87
  } catch {
61
- return [];
88
+ return resolved;
62
89
  }
63
90
  }
64
91
 
65
- async function findProjectDaemonRoots(root: string, cwd: string): Promise<string[]> {
66
- const hashes = await listDirNames(root);
67
- const matches: string[] = [];
92
+ async function findProjectDaemonRoots(
93
+ root: string,
94
+ cwd: string,
95
+ ): Promise<{ roots: string[]; complete: boolean }> {
96
+ const [hashes, projectDir] = await Promise.all([readDirEntries(root), canonicalProjectDir(cwd)]);
97
+ if ("unreadable" in hashes) return { roots: [], complete: false };
98
+ if (!("value" in hashes)) return { roots: [], complete: true };
99
+ const roots: string[] = [];
100
+ let complete = true;
68
101
  await Promise.all(
69
- hashes.map(async (hash) => {
70
- const scope = ScopeFileSchema.safeParse(await readJsonFile(join(root, hash, "scope.json")));
71
- if (scope.success && scope.data.projectDir === cwd) matches.push(join(root, hash));
102
+ hashes.value.map(async (entry) => {
103
+ // Only directories can be broker scopes; a stray file (`.DS_Store`) is not one.
104
+ if (!entry.isDirectory()) return;
105
+ const hash = entry.name;
106
+ const read = await readJson(join(root, hash, "scope.json"));
107
+ if ("unreadable" in read) complete = false;
108
+ if (!("value" in read)) return;
109
+ const scope = ScopeFileSchema.safeParse(read.value);
110
+ if (scope.success && (scope.data.projectDir === projectDir || scope.data.projectDir === cwd))
111
+ roots.push(join(root, hash));
72
112
  }),
73
113
  );
74
- return matches;
114
+ return { roots, complete };
75
115
  }
76
116
 
77
117
  function toHubProcess(name: string, value: unknown, specFile: unknown): HubProcess | undefined {
@@ -98,27 +138,61 @@ function toHubProcess(name: string, value: unknown, specFile: unknown): HubProce
98
138
  };
99
139
  }
100
140
 
101
- export async function listHubProcessesFrom(root: string, cwd: string): Promise<HubProcess[]> {
102
- const roots = await findProjectDaemonRoots(root, cwd);
103
- const processes: HubProcess[] = [];
141
+ export interface HubProcessScan {
142
+ processes: HubProcess[];
143
+ /** Records that exist but could not be read or parsed: their state is unknown. */
144
+ unreadable: string[];
145
+ /**
146
+ * Entries under `daemons/` that are not directories. omp skips them too (`readPersistedDaemons`),
147
+ * so they are not services, but an owned service whose record turned into one is unknown.
148
+ */
149
+ strays: string[];
150
+ /** False when a directory that could hold this project's records could not be read. */
151
+ complete: boolean;
152
+ }
153
+
154
+ export async function scanHubProcessesFrom(root: string, cwd: string): Promise<HubProcessScan> {
155
+ const found = await findProjectDaemonRoots(root, cwd);
156
+ const scan: HubProcessScan = {
157
+ processes: [],
158
+ unreadable: [],
159
+ strays: [],
160
+ complete: found.complete,
161
+ };
104
162
  await Promise.all(
105
- roots.map(async (projectRoot) => {
106
- const names = await listDirNames(join(projectRoot, "daemons"));
163
+ found.roots.map(async (projectRoot) => {
164
+ const entries = await readDirEntries(join(projectRoot, "daemons"));
165
+ if ("unreadable" in entries) scan.complete = false;
166
+ if (!("value" in entries)) return;
107
167
  await Promise.all(
108
- names.map(async (name) => {
168
+ entries.value.map(async (entry) => {
169
+ const name = entry.name;
170
+ if (!entry.isDirectory()) {
171
+ scan.strays.push(name);
172
+ return;
173
+ }
109
174
  const dir = join(projectRoot, "daemons", name);
110
175
  const [meta, spec] = await Promise.all([
111
- readJsonFile(join(dir, "meta.json")),
112
- readJsonFile(join(dir, "spec.json")),
176
+ readJson(join(dir, "meta.json")),
177
+ readJson(join(dir, "spec.json")),
113
178
  ]);
114
- const process = toHubProcess(name, meta, spec);
115
- if (process) processes.push(process);
179
+ if ("missing" in meta) return;
180
+ const process =
181
+ "value" in meta
182
+ ? toHubProcess(name, meta.value, "value" in spec ? spec.value : undefined)
183
+ : undefined;
184
+ if (process) scan.processes.push(process);
185
+ else scan.unreadable.push(name);
116
186
  }),
117
187
  );
118
188
  }),
119
189
  );
120
- processes.sort((a, b) => (b.startedAt ?? 0) - (a.startedAt ?? 0));
121
- return processes;
190
+ scan.processes.sort((a, b) => (b.startedAt ?? 0) - (a.startedAt ?? 0));
191
+ return scan;
192
+ }
193
+
194
+ export async function listHubProcessesFrom(root: string, cwd: string): Promise<HubProcess[]> {
195
+ return (await scanHubProcessesFrom(root, cwd)).processes;
122
196
  }
123
197
 
124
198
  export async function resolveListHubProcesses({
@@ -127,12 +201,181 @@ export async function resolveListHubProcesses({
127
201
  return { processes: await listHubProcessesFrom(ompRunDir(), cwd) };
128
202
  }
129
203
 
204
+ // omp 18.18.9 made launch services persistent in RPC mode (`launch.persist` is forced on for
205
+ // every non-interactive host), so they no longer end with the omp process that started them.
206
+ // A Paseo agent owns its OMP session: once that session's process tree is gone, stop the
207
+ // services it still owns. Detached services were explicitly handed off and are left alone, and
208
+ // non-persistent ones are still stopped by omp's own broker lifecycle.
209
+ const LIVE_HUB_STATES: Readonly<Record<string, true>> = {
210
+ starting: true,
211
+ running: true,
212
+ ready: true,
213
+ restarting: true,
214
+ };
215
+ // The broker records `stopping` before it signals the tree and the terminal state after it
216
+ // settles, so a service is only confirmed gone once its metadata leaves both.
217
+ const UNSETTLED_HUB_STATES: Readonly<Record<string, true>> = { ...LIVE_HUB_STATES, stopping: true };
218
+ const HUB_CLEANUP_POLL_MS = 100;
219
+ // One deadline for the whole cleanup, so a hung CLI, a service that ignores SIGTERM or many
220
+ // services cannot hold the agent's close. omp's own stop grace is 5s plus 1s to settle. Stops
221
+ // leave the last stretch for verification, and the broker stops each record on its own, so a
222
+ // few stops run at once.
223
+ const HUB_CLEANUP_MS = 12_000;
224
+ const HUB_CLEANUP_VERIFY_RESERVE_MS = 2_000;
225
+ const HUB_CLEANUP_STOP_CONCURRENCY = 4;
226
+
227
+ // omp's broker rejects any other service name; anything else read from disk is not ours to stop,
228
+ // and the leading-alphanumeric rule keeps a name from ever being parsed as a CLI flag.
229
+ const HUB_SERVICE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,47}$/u;
230
+
231
+ export interface OwnedHubCleanupDependencies {
232
+ scan(cwd: string): Promise<HubProcessScan>;
233
+ /** A timer that fires after `ms`; scans that outlive it count as incomplete. */
234
+ expire(ms: number): { fired: Promise<void>; cancel(): void };
235
+ /**
236
+ * Asks omp's broker to stop one service within `timeoutMs`; resolves true only when the
237
+ * command succeeded.
238
+ */
239
+ stop(name: string, cwd: string, timeoutMs: number): Promise<boolean>;
240
+ sleep(ms: number): Promise<void>;
241
+ now(): number;
242
+ }
243
+
244
+ export interface OwnedHubCleanupResult {
245
+ stopped: string[];
246
+ failed: string[];
247
+ /** False when omp's records could not all be read, so an owned service may have been missed. */
248
+ complete: boolean;
249
+ /** Set when the launcher wraps OMP's environment, so the broker could not be located. */
250
+ unsupportedLauncher?: true;
251
+ }
252
+
253
+ /**
254
+ * OMP session ids whose services an agent may stop, each mapped to the last `createdAt` it can
255
+ * claim: `Infinity` for the live id, the hand-off time for an id the agent left (a rewind or
256
+ * branch releases it, so another agent may resume it and start services of its own).
257
+ */
258
+ export type HubServiceOwners = ReadonlyMap<string, number>;
259
+
260
+ function startedWhileOwned(process: HubProcess, ownedUntil: number | undefined): boolean {
261
+ if (ownedUntil === undefined) return false;
262
+ if (ownedUntil === Number.POSITIVE_INFINITY) return true;
263
+ return process.createdAt !== null && process.createdAt <= ownedUntil;
264
+ }
265
+
266
+ function ownedPersistentServices(
267
+ processes: readonly HubProcess[],
268
+ owners: HubServiceOwners,
269
+ states: Readonly<Record<string, true>>,
270
+ ): string[] {
271
+ return processes
272
+ .filter(
273
+ (process) =>
274
+ HUB_SERVICE_NAME.test(process.name) &&
275
+ process.owner !== null &&
276
+ startedWhileOwned(process, owners.get(process.owner)) &&
277
+ process.persist &&
278
+ !process.detached &&
279
+ states[process.state] === true,
280
+ )
281
+ .map((process) => process.name);
282
+ }
283
+
284
+ async function boundedScan(
285
+ dependencies: OwnedHubCleanupDependencies,
286
+ cwd: string,
287
+ ms: number,
288
+ ): Promise<HubProcessScan | undefined> {
289
+ if (ms <= 0) return undefined;
290
+ const timer = dependencies.expire(ms);
291
+ try {
292
+ return await Promise.race([
293
+ dependencies.scan(cwd).catch(() => undefined),
294
+ timer.fired.then(() => undefined),
295
+ ]);
296
+ } finally {
297
+ timer.cancel();
298
+ }
299
+ }
300
+
301
+ export async function stopOwnedHubProcesses(
302
+ cwd: string,
303
+ owners: HubServiceOwners,
304
+ dependencies: OwnedHubCleanupDependencies,
305
+ ): Promise<OwnedHubCleanupResult> {
306
+ if (owners.size === 0) return { stopped: [], failed: [], complete: true };
307
+ // The deadline covers discovery too, so a hung filesystem cannot hold the close either.
308
+ const deadline = dependencies.now() + HUB_CLEANUP_MS;
309
+ const initial = await boundedScan(dependencies, cwd, deadline - dependencies.now());
310
+ if (!initial) return { stopped: [], failed: [], complete: false };
311
+ const owned = ownedPersistentServices(initial.processes, owners, LIVE_HUB_STATES);
312
+ // A record that cannot be read may be one of ours, so the lookup is not complete.
313
+ const complete = initial.complete && initial.unreadable.length === 0;
314
+ if (owned.length === 0) return { stopped: [], failed: [], complete };
315
+ const failed = new Set<string>();
316
+ const queue = [...owned];
317
+ const stopDeadline = deadline - HUB_CLEANUP_VERIFY_RESERVE_MS;
318
+ const stopNext = async (): Promise<void> => {
319
+ for (let name = queue.shift(); name !== undefined; name = queue.shift()) {
320
+ const remaining = stopDeadline - dependencies.now();
321
+ const stopped =
322
+ remaining > 0 && (await dependencies.stop(name, cwd, remaining).catch(() => false));
323
+ if (!stopped) failed.add(name);
324
+ }
325
+ };
326
+ await Promise.all(
327
+ Array.from({ length: Math.min(HUB_CLEANUP_STOP_CONCURRENCY, owned.length) }, stopNext),
328
+ );
329
+ // Report success only for services omp's own state confirms have settled. A record that cannot
330
+ // be read is unknown, not stopped.
331
+ let unsettled: ReadonlySet<string>;
332
+ while (true) {
333
+ const current = await boundedScan(dependencies, cwd, deadline - dependencies.now());
334
+ unsettled = new Set(
335
+ current?.complete
336
+ ? [
337
+ ...ownedPersistentServices(current.processes, owners, UNSETTLED_HUB_STATES),
338
+ ...current.unreadable,
339
+ ...current.strays,
340
+ ].filter((name) => owned.includes(name))
341
+ : owned,
342
+ );
343
+ if (unsettled.size === 0 || dependencies.now() >= deadline) break;
344
+ await dependencies.sleep(HUB_CLEANUP_POLL_MS);
345
+ // Keep the last observation rather than scan with no time left.
346
+ if (dependencies.now() >= deadline) break;
347
+ }
348
+ for (const name of unsettled) failed.add(name);
349
+ return {
350
+ stopped: owned.filter((name) => !failed.has(name)),
351
+ failed: owned.filter((name) => failed.has(name)),
352
+ complete,
353
+ };
354
+ }
355
+
356
+ export function ownedHubCleanupDependencies(
357
+ runOmp: (args: readonly string[], timeoutMs: number) => Promise<boolean>,
358
+ root = ompRunDir(),
359
+ ): OwnedHubCleanupDependencies {
360
+ return {
361
+ scan: (cwd) => scanHubProcessesFrom(root, cwd),
362
+ expire: (ms) => {
363
+ const fired = Promise.withResolvers<void>();
364
+ const timer = setTimeout(fired.resolve, ms);
365
+ return { fired: fired.promise, cancel: () => clearTimeout(timer) };
366
+ },
367
+ stop: (name, cwd, timeoutMs) => runOmp(["ps", "stop", "--dir", cwd, "--", name], timeoutMs),
368
+ sleep: waitMs,
369
+ now: () => Date.now(),
370
+ };
371
+ }
372
+
130
373
  export async function tailHubLogFrom(
131
374
  root: string,
132
375
  cwd: string,
133
376
  name: string,
134
377
  ): Promise<{ content: string; truncated: boolean }> {
135
- const roots = await findProjectDaemonRoots(root, cwd);
378
+ const { roots } = await findProjectDaemonRoots(root, cwd);
136
379
  for (const projectRoot of roots) {
137
380
  try {
138
381
  const buffer = await readFile(join(projectRoot, "daemons", name, "output.log"));
@@ -15,6 +15,8 @@ export const OMP_OPERATIONAL_FAILURES = [
15
15
  { category: "tool-projector", stage: "subsession-projector" },
16
16
  { category: "terminal-outcome", stage: "failed" },
17
17
  { category: "terminal-outcome", stage: "unresolved" },
18
+ { category: "session-close", stage: "hub-cleanup" },
19
+ { category: "session-close", stage: "hub-cleanup-unsupported-launcher" },
18
20
  ] as const;
19
21
 
20
22
  export type OmpOperationalFailure = (typeof OMP_OPERATIONAL_FAILURES)[number];
@@ -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.6.3"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.6.4-next.493.1"; // x-release-please-version
package/server/paths.ts CHANGED
@@ -160,6 +160,29 @@ export function ompStateDir(
160
160
  return ompStorageDir("state", environment, platform);
161
161
  }
162
162
 
163
+ /**
164
+ * OMP's service broker root (`run/daemons`). It hangs off the profile's config root, not the
165
+ * agent directory, so every named profile has its own brokers (pi-utils `getDaemonRuntimeRoot`).
166
+ */
167
+ export function ompHubRunDir(
168
+ environment: NodeJS.ProcessEnv = currentOmpEnvironment(),
169
+ platform: NodeJS.Platform = process.platform,
170
+ ): string {
171
+ const profile = ompProfile(environment);
172
+ const defaultAgentDir = defaultOmpAgentDir(environment, profile);
173
+ let root = dirname(defaultAgentDir);
174
+ const xdgHome = environment.XDG_STATE_HOME;
175
+ if (
176
+ xdgHome &&
177
+ (platform === "linux" || platform === "darwin") &&
178
+ ompAgentDir(environment) === defaultAgentDir
179
+ ) {
180
+ const xdgRoot = profile ? join(xdgHome, "omp", "profiles", profile) : join(xdgHome, "omp");
181
+ if (existsSync(xdgRoot)) root = xdgRoot;
182
+ }
183
+ return join(root, "run", "daemons");
184
+ }
185
+
163
186
  function configuredSessionDir(agentDir: string): string | undefined {
164
187
  for (const settingsPath of [
165
188
  join(agentDir, "settings.json"),
@@ -1,8 +1,19 @@
1
1
  import type { ChildProcessWithoutNullStreams } from "node:child_process";
2
- import { join } from "node:path";
2
+ import { basename, join } from "node:path";
3
3
  import { z } from "zod";
4
- import { ompDataDir } from "../paths";
5
- import type { OmpSpawnRequest, OmpStartOptions } from "./omp-rpc-environment";
4
+ import {
5
+ type HubServiceOwners,
6
+ type OwnedHubCleanupResult,
7
+ ownedHubCleanupDependencies,
8
+ stopOwnedHubProcesses,
9
+ } from "../hub";
10
+ import { ompDataDir, ompHubRunDir } from "../paths";
11
+ import { defaultSpawn, runBounded } from "../provider-diagnostics";
12
+ import {
13
+ buildOmpSpawnRequest,
14
+ type OmpSpawnRequest,
15
+ type OmpStartOptions,
16
+ } from "./omp-rpc-environment";
6
17
  import { waitMs } from "./omp-rpc-process";
7
18
  import {
8
19
  inspectJsonBounds,
@@ -153,6 +164,11 @@ export interface OmpRuntime {
153
164
  cwd: string;
154
165
  signal?: AbortSignal;
155
166
  }): Promise<OmpPersistedSubagentMessages>;
167
+ /** Stops the live Hub services these OMP sessions own once their process tree is gone. */
168
+ stopOwnedServices?(
169
+ options: OmpStartOptions,
170
+ owners: HubServiceOwners,
171
+ ): Promise<OwnedHubCleanupResult>;
156
172
  }
157
173
 
158
174
  export interface OmpRpcRuntimeOptions {
@@ -164,6 +180,73 @@ export interface OmpRpcRuntimeOptions {
164
180
  listSessions?: (
165
181
  options: OmpSessionListOptions,
166
182
  ) => OmpSessionDescriptor[] | Promise<OmpSessionDescriptor[]>;
183
+ /** Runs one OMP CLI command bounded by `timeoutMs`; resolves true only on a clean zero exit. */
184
+ runOmpCommand?: (
185
+ command: string,
186
+ args: readonly string[],
187
+ env: NodeJS.ProcessEnv,
188
+ cwd: string,
189
+ timeoutMs: number,
190
+ ) => Promise<boolean>;
191
+ hubRunDir?: string;
192
+ }
193
+
194
+ const OMP_COMMAND_TIMEOUT_MS = 15_000;
195
+ const OMP_COMMAND_KILL_GRACE_MS = 1_000;
196
+ const OMP_COMMAND_MAX_OUTPUT_BYTES = 64 * 1024;
197
+
198
+ async function runOmpCommand(
199
+ command: string,
200
+ args: readonly string[],
201
+ env: NodeJS.ProcessEnv,
202
+ cwd: string,
203
+ timeoutMs: number,
204
+ ): Promise<boolean> {
205
+ const run = await runBounded(
206
+ defaultSpawn,
207
+ command,
208
+ args,
209
+ env,
210
+ Math.min(timeoutMs, OMP_COMMAND_TIMEOUT_MS),
211
+ OMP_COMMAND_KILL_GRACE_MS,
212
+ OMP_COMMAND_MAX_OUTPUT_BYTES,
213
+ cwd,
214
+ );
215
+ return run.outcome === "exited" && run.exitCode === 0 && !run.cleanupFailed;
216
+ }
217
+
218
+ /**
219
+ * The configured command prefix as an `omp ps` launcher. OMP strips `--profile` before it looks
220
+ * for a subcommand, so a bare flag left in front of `ps` (`--resume`, an unknown long flag) would
221
+ * take `ps` as its value: the profile moves to `OMP_PROFILE`, which OMP reads when no `--profile`
222
+ * is given, and every bare flag left at the end of the prefix is dropped. The last `--profile`
223
+ * wins, as in OMP.
224
+ */
225
+ function psLauncher(args: readonly string[]): { prefix: string[]; profile?: string } {
226
+ const prefix: string[] = [];
227
+ let profile: string | undefined;
228
+ for (let index = 0; index < args.length; index += 1) {
229
+ const argument = args[index] ?? "";
230
+ if (argument === "--profile") profile = args[++index];
231
+ else if (argument.startsWith("--profile=")) profile = argument.slice(10);
232
+ else prefix.push(argument);
233
+ }
234
+ while (/^-[^=]*$/u.test(prefix.at(-1) ?? "")) prefix.pop();
235
+ return profile === undefined ? { prefix } : { prefix, profile };
236
+ }
237
+
238
+ /**
239
+ * An `env` wrapper or a `NAME=value` word in the launcher can change OMP's profile or store root
240
+ * in ways the plugin cannot tell apart reliably (`env -i`, `-u`, `-S`, PATH changes), so Hub
241
+ * cleanup fails closed for such launchers instead of guessing the broker.
242
+ */
243
+ function wrapsEnvironment(command: string, args: readonly string[]): boolean {
244
+ return [command, ...args].some((word) => {
245
+ const executable = basename(word).toLowerCase();
246
+ return (
247
+ executable === "env" || executable === "env.exe" || /^[A-Za-z_][A-Za-z0-9_]*=/u.test(word)
248
+ );
249
+ });
167
250
  }
168
251
 
169
252
  // OMP accepts an empty message when images carry the prompt.
@@ -601,6 +684,35 @@ export class OmpRpcRuntime implements OmpRuntime {
601
684
  listOmpSessionDescriptors(options, this.options.environment ?? process.env),
602
685
  );
603
686
  }
687
+ async stopOwnedServices(
688
+ options: OmpStartOptions,
689
+ owners: HubServiceOwners,
690
+ ): Promise<OwnedHubCleanupResult> {
691
+ // Same executable, launcher prefix, profile and environment as the RPC process, so the CLI
692
+ // reaches the broker that session used; brokers live under each profile's own config root.
693
+ const request = buildOmpSpawnRequest({
694
+ ...options,
695
+ environment: options.environment ?? this.options.environment,
696
+ });
697
+ const { prefix, profile } = psLauncher(
698
+ request.args.slice(0, Math.max(0, (options.command?.length ?? 1) - 1)),
699
+ );
700
+ if (wrapsEnvironment(request.command, prefix)) {
701
+ return { stopped: [], failed: [], complete: false, unsupportedLauncher: true };
702
+ }
703
+ // OMP prefers `--profile` over `OMP_PROFILE`.
704
+ const env = profile === undefined ? request.env : { ...request.env, OMP_PROFILE: profile };
705
+ const run = this.options.runOmpCommand ?? runOmpCommand;
706
+ return stopOwnedHubProcesses(
707
+ request.cwd,
708
+ owners,
709
+ ownedHubCleanupDependencies(
710
+ (args, timeoutMs) =>
711
+ run(request.command, [...prefix, ...args], env, request.cwd, timeoutMs),
712
+ this.options.hubRunDir ?? process.env.PASEO_OMP_RUN_DIR ?? ompHubRunDir(env),
713
+ ),
714
+ );
715
+ }
604
716
  async readPersistedSessionTranscript(options: {
605
717
  sessionFile: string;
606
718
  sessionId: string;
@@ -3,6 +3,7 @@ import { opendir } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, join, resolve } from "node:path";
5
5
  import { isOmpProfileName } from "../../shared/omp-store";
6
+ import type { HubServiceOwners } from "../hub";
6
7
  import { ompAgentDir, ompCacheDir, ompDataDir, ompSessionDir, ompStateDir } from "../paths";
7
8
  import { OmpRpcRuntime, type OmpRuntime } from "./omp-rpc";
8
9
  import type { OmpStartOptions } from "./omp-rpc-environment";
@@ -159,6 +160,7 @@ export function createProfileOmpProvider(profile: string, options: OmpProviderOp
159
160
  reportProtocolViolation: options.reportProtocolViolation,
160
161
  });
161
162
  const readPersistedSessionTranscript = runtime.readPersistedSessionTranscript?.bind(runtime);
163
+ const stopOwnedServices = runtime.stopOwnedServices?.bind(runtime);
162
164
  const assertSessionDir = (requested?: string) => {
163
165
  if (requested !== undefined && resolve(requested) !== sessionDir) {
164
166
  throw new OmpPublicError("OMP session directory conflicts with the selected profile");
@@ -203,6 +205,15 @@ export function createProfileOmpProvider(profile: string, options: OmpProviderOp
203
205
  readPersistedSubagentTranscript(input) {
204
206
  return runtime.readPersistedSubagentTranscript(input);
205
207
  },
208
+ ...(stopOwnedServices
209
+ ? {
210
+ stopOwnedServices(start: OmpStartOptions, owners: HubServiceOwners) {
211
+ assertSessionDir(start.sessionDir);
212
+ assertEnvironment(start.env);
213
+ return stopOwnedServices({ ...start, environment, sessionDir }, owners);
214
+ },
215
+ }
216
+ : {}),
206
217
  };
207
218
  const provider = createOmpProvider({
208
219
  ...options,
@@ -347,6 +347,8 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
347
347
  private unsupportedThinkingNoticePending = false;
348
348
  private unsupportedThinkingNoticePublished = false;
349
349
  private degradedMcpServers: readonly OmpDegradedMcpServer[] = [];
350
+ /** Every OMP session ID this agent's runtimes have used; OMP records each as a service owner. */
351
+ private readonly hubServiceOwners = new Map<string, number>();
350
352
 
351
353
  private constructor(
352
354
  id: string,
@@ -376,6 +378,7 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
376
378
  ) {
377
379
  this.id = id;
378
380
  this.cwd = config.cwd;
381
+ this.hubServiceOwners.set(nativeSessionId, Number.POSITIVE_INFINITY);
379
382
  this.scheduler = scheduler;
380
383
  this.usage = new OmpSessionUsage(
381
384
  id,
@@ -993,7 +996,11 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
993
996
  const nextNativeSessionId = validateNativeSessionId(state.sessionId);
994
997
  if (nextNativeSessionId !== this.nativeSessionId) {
995
998
  this.transitionNativeSession(this.nativeSessionId, nextNativeSessionId);
999
+ // The released id may be resumed by another agent; only services it started before now
1000
+ // remain this agent's.
1001
+ this.hubServiceOwners.set(this.nativeSessionId, Date.now());
996
1002
  this.nativeSessionId = nextNativeSessionId;
1003
+ this.hubServiceOwners.set(nextNativeSessionId, Number.POSITIVE_INFINITY);
997
1004
  if (this.persistSession) {
998
1005
  this.emit({
999
1006
  type: "session.persistence",
@@ -1075,10 +1082,16 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
1075
1082
  this.hostTools.detach();
1076
1083
  this.runtimeDisposal ??= runtime.close();
1077
1084
  this.hostToolsDisposal ??= this.hostTools.close();
1085
+ // Same gate as a normal close: only once this OMP tree is verified gone.
1086
+ const hubCleanup = this.runtimeDisposal.then(
1087
+ () => this.stopOwnedHubServices(),
1088
+ () => undefined,
1089
+ );
1078
1090
  const cleanup = settleSessionCleanup(
1079
1091
  [
1080
1092
  this.runtimeDisposal,
1081
1093
  this.hostToolsDisposal,
1094
+ hubCleanup,
1082
1095
  this.recoveryPromise,
1083
1096
  configRefresh,
1084
1097
  this.configRefreshInFlight,
@@ -1655,7 +1668,15 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
1655
1668
  "OMP approval mode cannot change live; create a new session instead",
1656
1669
  );
1657
1670
  }
1658
- if (input.changes.settings && Object.keys(input.changes.settings).length > 0) {
1671
+ // Paseo 0.14 and 0.15 send live option patches as `settings`; 0.16 sends `providerOptions`,
1672
+ // and repeats them as the deprecated `settings` only while OMP reports legacy settings.
1673
+ // Older SDK types lack `providerOptions` on configure changes, so read it structurally.
1674
+ // Open accepts `settings` that only mirror `providerOptions`; a live patch is never accepted.
1675
+ const changes: { settings?: object; providerOptions?: object } = input.changes;
1676
+ if (
1677
+ (changes.settings && Object.keys(changes.settings).length > 0) ||
1678
+ (changes.providerOptions && Object.keys(changes.providerOptions).length > 0)
1679
+ ) {
1659
1680
  throw new OmpPublicError("OMP does not expose live provider settings");
1660
1681
  }
1661
1682
  if (input.changes.model === null || input.changes.thinkingOption === null) {
@@ -2023,8 +2044,9 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
2023
2044
  const deferredCleanup: Promise<void>[] = [];
2024
2045
  const seenCleanup = new Set<Promise<void>>();
2025
2046
  const seenCoordination = new Set<Promise<void>>();
2047
+ let ompTreeUnverified = false;
2026
2048
  while (true) {
2027
- const cleanup = [this.runtimeDisposal, this.hostToolsDisposal].filter(
2049
+ const cleanup: Promise<void>[] = [this.runtimeDisposal, this.hostToolsDisposal].filter(
2028
2050
  (promise): promise is Promise<void> => promise !== null && !seenCleanup.has(promise),
2029
2051
  );
2030
2052
  const coordination = [this.recoveryPromise, configRefresh, this.configRefreshInFlight].filter(
@@ -2034,8 +2056,10 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
2034
2056
  for (const promise of cleanup) seenCleanup.add(promise);
2035
2057
  for (const promise of coordination) seenCoordination.add(promise);
2036
2058
  const results = await Promise.allSettled([...cleanup, ...coordination]);
2037
- for (const result of results.slice(0, cleanup.length)) {
2059
+ for (const [index, result] of results.slice(0, cleanup.length).entries()) {
2038
2060
  if (result.status !== "rejected") continue;
2061
+ // MCP host-tool trees are the plugin's own children and never own an OMP service.
2062
+ if (cleanup[index] !== this.hostToolsDisposal) ompTreeUnverified = true;
2039
2063
  if (isOmpCleanupFailure(result.reason)) {
2040
2064
  if (!seenCleanup.has(result.reason.cleanup)) deferredCleanup.push(result.reason.cleanup);
2041
2065
  continue;
@@ -2043,6 +2067,8 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
2043
2067
  cleanupErrors.push(result.reason);
2044
2068
  }
2045
2069
  }
2070
+ // Only after the OMP tree is verified gone, so no live session can start another service.
2071
+ if (!ompTreeUnverified) await this.stopOwnedHubServices();
2046
2072
  if (deferredCleanup.length > 0) {
2047
2073
  const failed =
2048
2074
  cleanupErrors.length > 0
@@ -2059,6 +2085,27 @@ export class OmpProviderSession implements OmpOpenedSession, OmpSubagentControls
2059
2085
  }
2060
2086
  }
2061
2087
 
2088
+ private async stopOwnedHubServices(): Promise<void> {
2089
+ if (!this.runtimeFactory.stopOwnedServices) return;
2090
+ try {
2091
+ const result = await this.runtimeFactory.stopOwnedServices(
2092
+ this.recoveryOptions,
2093
+ this.hubServiceOwners,
2094
+ );
2095
+ if (result.unsupportedLauncher) {
2096
+ this.recordOperationalFailure({
2097
+ category: "session-close",
2098
+ stage: "hub-cleanup-unsupported-launcher",
2099
+ });
2100
+ return;
2101
+ }
2102
+ if (result.complete && result.failed.length === 0) return;
2103
+ } catch {
2104
+ // Reported below; a leftover service must never fail the agent's close.
2105
+ }
2106
+ this.recordOperationalFailure({ category: "session-close", stage: "hub-cleanup" });
2107
+ }
2108
+
2062
2109
  private publishSessionClosed(error?: { message: string }): void {
2063
2110
  if (this.sessionClosedPublished) return;
2064
2111
  this.sessionClosedPublished = true;
@@ -42,3 +42,16 @@ export function withLocalModelRole(
42
42
  const { [role]: _replaced, ...rest } = roles;
43
43
  return selector === null ? rest : { ...rest, [role]: selector };
44
44
  }
45
+
46
+ /**
47
+ * What pressing a model's role button may do. OMP merges a project `modelRoles` override with the
48
+ * global record key by key and has no value that clears a role, so a workspace write can set a role
49
+ * but never stop an inherited one: there the "Stop using" press is unavailable.
50
+ */
51
+ export function localModelRoleAction(
52
+ assigned: boolean,
53
+ workspaceScoped: boolean,
54
+ ): "use" | "stop" | "unavailable" {
55
+ if (!assigned) return "use";
56
+ return workspaceScoped ? "unavailable" : "stop";
57
+ }