Skip to content

Commit 840bef5

Browse files
authored
fix: tighten env var surface (#560)
1 parent 4491efd commit 840bef5

47 files changed

Lines changed: 586 additions & 944 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ios.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ jobs:
2121
env:
2222
IOS_RUNTIME_VERSION: "26.2"
2323
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ github.workspace }}/.tmp/ios-runner-derived
24-
AGENT_DEVICE_IOS_ALLOW_OVERRIDE_DERIVED_CLEAN: "1"
25-
AGENT_DEVICE_IOS_SIMCTL_LIST_TIMEOUT_MS: "60000"
26-
AGENT_DEVICE_IOS_BOOT_TIMEOUT_MS: "180000"
27-
AGENT_DEVICE_IOS_APP_LAUNCH_TIMEOUT_MS: "60000"
2824
steps:
2925
- name: Checkout
3026
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/macos.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
timeout-minutes: 80
2121
env:
2222
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ github.workspace }}/.tmp/macos-runner-derived
23-
AGENT_DEVICE_IOS_APP_LAUNCH_TIMEOUT_MS: "60000"
2423
steps:
2524
- name: Checkout
2625
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/replays-nightly.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ jobs:
5252
env:
5353
IOS_RUNTIME_VERSION: "26.2"
5454
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ github.workspace }}/.tmp/ios-runner-derived
55-
AGENT_DEVICE_IOS_ALLOW_OVERRIDE_DERIVED_CLEAN: "1"
56-
AGENT_DEVICE_IOS_SIMCTL_LIST_TIMEOUT_MS: "60000"
57-
AGENT_DEVICE_IOS_BOOT_TIMEOUT_MS: "180000"
58-
AGENT_DEVICE_IOS_APP_LAUNCH_TIMEOUT_MS: "60000"
5955
steps:
6056
- name: Checkout
6157
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -103,7 +99,6 @@ jobs:
10399
timeout-minutes: 80
104100
env:
105101
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ github.workspace }}/.tmp/macos-runner-derived
106-
AGENT_DEVICE_IOS_APP_LAUNCH_TIMEOUT_MS: "60000"
107102
steps:
108103
- name: Checkout
109104
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ extension RunnerTests {
147147
? (target.value(forKey: "waitForIdleTimeout") as? NSNumber)
148148
: nil
149149
if supportsWaitForIdleTimeout {
150-
target.setValue(resolveScrollInteractionIdleTimeout(), forKey: "waitForIdleTimeout")
150+
target.setValue(scrollInteractionIdleTimeoutDefault, forKey: "waitForIdleTimeout")
151151
}
152152
defer {
153153
if let previous {
@@ -191,19 +191,6 @@ extension RunnerTests {
191191
}
192192
}
193193

194-
private func resolveScrollInteractionIdleTimeout() -> TimeInterval {
195-
guard
196-
let raw = ProcessInfo.processInfo.environment["AGENT_DEVICE_IOS_INTERACTION_IDLE_TIMEOUT"],
197-
!raw.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
198-
else {
199-
return scrollInteractionIdleTimeoutDefault
200-
}
201-
guard let parsed = Double(raw), parsed >= 0 else {
202-
return scrollInteractionIdleTimeoutDefault
203-
}
204-
return min(parsed, 30)
205-
}
206-
207194
func shouldRetryCommand(_ command: Command) -> Bool {
208195
if RunnerEnv.isTruthy("AGENT_DEVICE_RUNNER_DISABLE_READONLY_RETRY") {
209196
return false

src/__tests__/cli-batch.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ test('batch forwards reject lock policy for target retargeting', async () => {
112112
{
113113
env: {
114114
AGENT_DEVICE_PLATFORM: 'ios',
115-
AGENT_DEVICE_SESSION_LOCKED: '1',
115+
AGENT_DEVICE_SESSION_LOCK: 'reject',
116116
},
117117
},
118118
);
@@ -137,7 +137,6 @@ test('batch session lock flags apply to nested steps without env configuration',
137137
{
138138
env: {
139139
AGENT_DEVICE_PLATFORM: 'ios',
140-
AGENT_DEVICE_SESSION_LOCKED: '0',
141140
},
142141
},
143142
);

src/__tests__/cli-config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test('CLI merges config defaults with precedence user < project < env < CLI', as
5151
fs.rmSync(root, { recursive: true, force: true });
5252
});
5353

54-
test('config and env can set appsFilter through canonical enum values', async () => {
54+
test('config can set appsFilter through canonical enum values', async () => {
5555
const { root, home, project } = makeTempWorkspace();
5656
fs.mkdirSync(path.join(home, '.agent-device'), { recursive: true });
5757
fs.writeFileSync(
@@ -62,12 +62,12 @@ test('config and env can set appsFilter through canonical enum values', async ()
6262

6363
const result = await runCliCapture(['apps', '--json'], {
6464
cwd: project,
65-
env: { HOME: home, AGENT_DEVICE_APPS_FILTER: 'all' },
65+
env: { HOME: home },
6666
});
6767

6868
assert.equal(result.code, null);
6969
assert.equal(result.calls.length, 1);
70-
assert.equal(result.calls[0]?.flags?.appsFilter, 'all');
70+
assert.equal(result.calls[0]?.flags?.appsFilter, 'user-installed');
7171

7272
fs.rmSync(root, { recursive: true, force: true });
7373
});

src/__tests__/cli-diagnostics.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ test('cli forwards bound-session lock policy when session defaults are configure
258258

259259
test('cli session lock flag overrides environment for a single invocation', async () => {
260260
const previousPlatform = process.env.AGENT_DEVICE_PLATFORM;
261-
const previousLocked = process.env.AGENT_DEVICE_SESSION_LOCKED;
261+
const previousLock = process.env.AGENT_DEVICE_SESSION_LOCK;
262262
process.env.AGENT_DEVICE_PLATFORM = 'ios';
263-
process.env.AGENT_DEVICE_SESSION_LOCKED = '0';
263+
process.env.AGENT_DEVICE_SESSION_LOCK = 'strip';
264264
try {
265265
const result = await runCliCapture(
266266
['snapshot', '--session-lock', 'reject', '--device', 'Pixel 9', '--json'],
@@ -275,7 +275,7 @@ test('cli session lock flag overrides environment for a single invocation', asyn
275275
} finally {
276276
if (previousPlatform === undefined) delete process.env.AGENT_DEVICE_PLATFORM;
277277
else process.env.AGENT_DEVICE_PLATFORM = previousPlatform;
278-
if (previousLocked === undefined) delete process.env.AGENT_DEVICE_SESSION_LOCKED;
279-
else process.env.AGENT_DEVICE_SESSION_LOCKED = previousLocked;
278+
if (previousLock === undefined) delete process.env.AGENT_DEVICE_SESSION_LOCK;
279+
else process.env.AGENT_DEVICE_SESSION_LOCK = previousLock;
280280
}
281281
});

src/__tests__/client-metro-startup-cleanup.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ test('prepareMetroRuntime stops a spawned Metro process when startup readiness t
5959
installDependenciesIfNeeded: false,
6060
probeTimeoutMs: 10,
6161
startupTimeoutMs: 30_000,
62+
env: { ...process.env, AGENT_DEVICE_DAEMON_AUTH_TOKEN: 'daemon-token' },
6263
});
6364

6465
const expectedFailure = assert.rejects(

src/__tests__/client-metro.test.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,24 @@ test('prepareMetroRuntime rejects incomplete proxy configuration', async () => {
175175
prepareMetroRuntime({
176176
publicBaseUrl: 'https://sandbox.example.test',
177177
proxyBaseUrl: 'https://proxy.example.test',
178+
env: {},
178179
}),
179180
(error) =>
180181
error instanceof AppError &&
181182
error.code === 'INVALID_ARGS' &&
182-
error.message.includes('AGENT_DEVICE_PROXY_TOKEN'),
183+
error.message.includes('AGENT_DEVICE_METRO_BEARER_TOKEN'),
184+
);
185+
186+
await assert.rejects(
187+
() =>
188+
prepareMetroRuntime({
189+
publicBaseUrl: 'https://sandbox.example.test',
190+
env: { AGENT_DEVICE_METRO_BEARER_TOKEN: TEST_TOKEN },
191+
}),
192+
(error) =>
193+
error instanceof AppError &&
194+
error.code === 'INVALID_ARGS' &&
195+
error.message.includes('requires --proxy-base-url'),
183196
);
184197

185198
await assert.rejects(
@@ -188,6 +201,37 @@ test('prepareMetroRuntime rejects incomplete proxy configuration', async () => {
188201
publicBaseUrl: 'https://sandbox.example.test',
189202
proxyBaseUrl: 'https://proxy.example.test',
190203
proxyBearerToken: TEST_TOKEN,
204+
env: {},
205+
}),
206+
(error) =>
207+
error instanceof AppError &&
208+
error.code === 'INVALID_ARGS' &&
209+
error.message.includes('tenantId, runId, and leaseId bridge scope'),
210+
);
211+
});
212+
213+
test('prepareMetroRuntime falls back to daemon auth token for proxy auth', async () => {
214+
await assert.rejects(
215+
() =>
216+
prepareMetroRuntime({
217+
publicBaseUrl: 'https://sandbox.example.test',
218+
proxyBaseUrl: 'https://proxy.example.test',
219+
env: { AGENT_DEVICE_DAEMON_AUTH_TOKEN: TEST_TOKEN },
220+
}),
221+
(error) =>
222+
error instanceof AppError &&
223+
error.code === 'INVALID_ARGS' &&
224+
error.message.includes('tenantId, runId, and leaseId bridge scope'),
225+
);
226+
});
227+
228+
test('prepareMetroRuntime honors metro bearer token env for proxy auth', async () => {
229+
await assert.rejects(
230+
() =>
231+
prepareMetroRuntime({
232+
publicBaseUrl: 'https://sandbox.example.test',
233+
proxyBaseUrl: 'https://proxy.example.test',
234+
env: { AGENT_DEVICE_METRO_BEARER_TOKEN: TEST_TOKEN },
191235
}),
192236
(error) =>
193237
error instanceof AppError &&

0 commit comments

Comments
 (0)