Skip to content

Commit fc7915e

Browse files
thymikeeclaude
andcommitted
refactor(provider-limrun): build the facts and deployment refusals through unavailableFact
Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 62ec806 commit fc7915e

2 files changed

Lines changed: 61 additions & 72 deletions

File tree

‎packages/provider-limrun/src/deployment-runtime.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ import type {
99
PlatformRuntimeHost,
1010
PlatformRuntimeOperations,
1111
} from '@agent-device/contracts/platform-runtime-operations';
12-
import type { RuntimeOperationFact } from '@agent-device/contracts/platform-runtime';
12+
import {
13+
type RuntimeOperationFact,
14+
unavailableFact,
15+
} from '@agent-device/contracts/platform-runtime';
1316
import type { ProviderDeviceInstallResult } from '@agent-device/contracts/device';
1417
import type { DeviceInfo } from '@agent-device/kernel/device';
1518
import { AppError } from '@agent-device/kernel/errors';
1619
import type { LimrunRequestOperationDrain } from './request-cancellation.ts';
1720
import { isSupportedLimrunRuntimeDevice } from './runtime-device.ts';
1821

1922
const available = Object.freeze({ available: true } as const);
20-
const deploymentUnavailable = Object.freeze({
21-
available: false,
22-
reason: 'owner-capability-missing',
23-
hint: 'The Limrun provider session is no longer active for this device.',
24-
} as const);
25-
const pushUnavailable = Object.freeze({
26-
available: false,
27-
reason: 'unsupported-provider-mode',
28-
hint: 'Push notifications are unavailable for Limrun provider-owned devices.',
29-
} as const);
23+
const deploymentUnavailable = unavailableFact(
24+
'owner-capability-missing',
25+
'The Limrun provider session is no longer active for this device.',
26+
);
27+
const pushUnavailable = unavailableFact(
28+
'unsupported-provider-mode',
29+
'Push notifications are unavailable for Limrun provider-owned devices.',
30+
);
3031

3132
export type LimrunAppDeploymentRuntimeOptions = Readonly<{
3233
host: PlatformRuntimeHost;

‎packages/provider-limrun/src/facts-runtime.ts‎

Lines changed: 49 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isIosFamily, type DeviceInfo } from '@agent-device/kernel/device';
22
import { applicationLifecycleOperationFacts } from '@agent-device/contracts/application-lifecycle-runtime';
33
import { elementTextRuntimeOperationFacts } from '@agent-device/contracts/element-text-runtime';
44
import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations';
5-
import type { RuntimeFacts } from '@agent-device/contracts/platform-runtime';
5+
import { type RuntimeFacts, unavailableFact } from '@agent-device/contracts/platform-runtime';
66
import { screenshotRuntimeOperationFacts } from '@agent-device/contracts/screenshot-runtime';
77
import { selectorObservationRuntimeOperationFacts } from '@agent-device/contracts/selector-observation-runtime';
88
import { snapshotRuntimeOperationFacts } from '@agent-device/contracts/snapshot-runtime';
@@ -28,73 +28,61 @@ import {
2828
} from './interaction-operations.ts';
2929

3030
const available = Object.freeze({ available: true } as const);
31-
const customSnapshotUnavailable = Object.freeze({
32-
available: false,
33-
reason: 'unsupported-provider-mode',
34-
hint: 'Custom snapshot actions are available only for Limrun iOS simulator sessions.',
35-
} as const);
36-
const viewportUnavailable = Object.freeze({
37-
available: false,
38-
reason: 'unsupported-provider-mode',
39-
hint: 'Limrun does not expose viewport resizing.',
40-
} as const);
31+
const customSnapshotUnavailable = unavailableFact(
32+
'unsupported-provider-mode',
33+
'Custom snapshot actions are available only for Limrun iOS simulator sessions.',
34+
);
35+
const viewportUnavailable = unavailableFact(
36+
'unsupported-provider-mode',
37+
'Limrun does not expose viewport resizing.',
38+
);
4139
/**
4240
* A point read needs a local tool (adb uiautomator, the XCUITest runner). Limrun's transport
4341
* carries none of them, so the owner reports no live read and `get` answers from the captured
4442
* tree; provider ownership never borrows the local family read.
4543
*/
46-
const elementTextUnavailable = Object.freeze({
47-
available: false,
48-
reason: 'unsupported-provider-mode',
49-
hint: 'Limrun-owned devices read element text from the captured tree only.',
50-
} as const);
51-
const headlessUnavailable = Object.freeze({
52-
available: false,
53-
reason: 'unsupported-provider-mode',
54-
hint: 'Headless boot is unavailable for provider-owned devices.',
55-
} as const);
44+
const elementTextUnavailable = unavailableFact(
45+
'unsupported-provider-mode',
46+
'Limrun-owned devices read element text from the captured tree only.',
47+
);
48+
const headlessUnavailable = unavailableFact(
49+
'unsupported-provider-mode',
50+
'Headless boot is unavailable for provider-owned devices.',
51+
);
5652
/** Also read outside this module's own facts assembly: the owner's `inspectFacts` reports this
5753
* for every operation when the request names a device with no matching live session at all. */
58-
export const liveSessionUnavailable = Object.freeze({
59-
available: false,
60-
reason: 'owner-capability-missing',
61-
hint: 'Limrun requires a matching live provider session for this device.',
62-
} as const);
63-
const prepareUnavailable = Object.freeze({
64-
available: false,
65-
reason: 'unsupported-provider-mode',
66-
hint: 'Apple runner preparation is unavailable for Limrun-owned devices.',
67-
} as const);
68-
const iosAppStateUnavailable = Object.freeze({
69-
available: false,
70-
reason: 'unsupported-provider-mode',
71-
hint: 'Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.',
72-
} as const);
73-
const openTargetUnavailable = Object.freeze({
74-
available: false,
75-
reason: 'unsupported-provider-mode',
76-
hint: 'Limrun open requires a Limrun-owned iOS simulator or Android emulator.',
77-
} as const);
78-
const closeTargetUnavailable = Object.freeze({
79-
available: false,
80-
reason: 'unsupported-provider-mode',
81-
hint: 'Limrun close requires a Limrun-owned iOS simulator or Android emulator.',
82-
} as const);
83-
const runtimeHintsUnavailable = Object.freeze({
84-
available: false,
85-
reason: 'unsupported-provider-mode',
86-
hint: 'Runtime hints are not applied to provider-owned devices.',
87-
} as const);
88-
const portReverseUnavailable = Object.freeze({
89-
available: false,
90-
reason: 'unsupported-provider-mode',
91-
hint: 'Limrun port reverse requires an active Android Limrun session.',
92-
} as const);
93-
const audioProbeUnavailable = Object.freeze({
94-
available: false,
95-
reason: 'unsupported-provider-mode',
96-
hint: 'Limrun does not expose the audio probe.',
97-
} as const);
54+
export const liveSessionUnavailable = unavailableFact(
55+
'owner-capability-missing',
56+
'Limrun requires a matching live provider session for this device.',
57+
);
58+
const prepareUnavailable = unavailableFact(
59+
'unsupported-provider-mode',
60+
'Apple runner preparation is unavailable for Limrun-owned devices.',
61+
);
62+
const iosAppStateUnavailable = unavailableFact(
63+
'unsupported-provider-mode',
64+
'Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.',
65+
);
66+
const openTargetUnavailable = unavailableFact(
67+
'unsupported-provider-mode',
68+
'Limrun open requires a Limrun-owned iOS simulator or Android emulator.',
69+
);
70+
const closeTargetUnavailable = unavailableFact(
71+
'unsupported-provider-mode',
72+
'Limrun close requires a Limrun-owned iOS simulator or Android emulator.',
73+
);
74+
const runtimeHintsUnavailable = unavailableFact(
75+
'unsupported-provider-mode',
76+
'Runtime hints are not applied to provider-owned devices.',
77+
);
78+
const portReverseUnavailable = unavailableFact(
79+
'unsupported-provider-mode',
80+
'Limrun port reverse requires an active Android Limrun session.',
81+
);
82+
const audioProbeUnavailable = unavailableFact(
83+
'unsupported-provider-mode',
84+
'Limrun does not expose the audio probe.',
85+
);
9886

9987
/** Also read outside this module's own facts assembly: the owner's `bind` needs the same
10088
* deployment options its facts do. */

0 commit comments

Comments
 (0)