Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/platform-android/src/perf-native-artifacts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';
import type { DeviceInfo } from '@agent-device/kernel/device';
import { AppError } from '@agent-device/kernel/errors';
import { shellQuote } from '@agent-device/host-kit/command';
import { sleep } from '@agent-device/host-kit/retry';
import { resolveAndroidAdbExecutor, type AndroidAdbExecutor } from './adb-executor.ts';
import { annotateAndroidNativePerfError } from './perf-native-errors.ts';
Expand Down Expand Up @@ -121,10 +122,6 @@ export async function readFileSize(
}
}

export function shellQuote(value: string): string {
return `'${value.replaceAll("'", `'\\''`)}'`;
}

async function stopAndroidBackgroundTool(
adb: AndroidAdbExecutor,
session: AndroidNativePerfSession,
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-android/src/perf-native-simpleperf.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { DeviceInfo } from '@agent-device/kernel/device';
import { AppError } from '@agent-device/kernel/errors';
import { shellQuote } from '@agent-device/host-kit/command';
import { resolveAndroidAdbExecutor, type AndroidAdbExecutor } from './adb-executor.ts';
import {
buildAndroidNativeRemotePath,
cleanupAndroidRemotePath,
readFileSize,
shellQuote,
stopAndroidNativePerfSession,
writeJsonArtifact,
} from './perf-native-artifacts.ts';
Expand Down
2 changes: 2 additions & 0 deletions packages/platform-apple/src/core/runner-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
runCmdBackground,
runCmdStreaming,
runCmdSync,
shellQuote,
} from '@agent-device/host-kit/command';
import { emitDiagnostic, withDiagnosticTimer } from '@agent-device/host-kit/diagnostics';
import {
Expand Down Expand Up @@ -57,6 +58,7 @@ export const appleRunnerHost: AppleRunnerHost = {
runCmdBackground,
requireExecSuccess,
isCommandTimeoutError,
shellQuote,
emitDiagnostic,
withDiagnosticTimer,
retryWithPolicy,
Expand Down
3 changes: 3 additions & 0 deletions packages/platform-apple/src/runner/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export type AppleRunnerHost = {
): ExecResult;
/** True only for the error the exec layer raises when it killed a command at `timeoutMs`. */
isCommandTimeoutError(error: unknown): boolean;
/** Single-quote one value for a POSIX shell fragment (hints and remote commands). */
shellQuote(value: string): string;
// Diagnostics (@agent-device/host-kit/diagnostics)
emitDiagnostic(event: DiagnosticEventInput): void;
withDiagnosticTimer<T>(
Expand Down Expand Up @@ -297,6 +299,7 @@ export const requireExecSuccess: AppleRunnerHost['requireExecSuccess'] = (result
requireHost().requireExecSuccess(result, message, extra);
export const isCommandTimeoutError: AppleRunnerHost['isCommandTimeoutError'] = (error) =>
requireHost().isCommandTimeoutError(error);
export const shellQuote: AppleRunnerHost['shellQuote'] = (value) => requireHost().shellQuote(value);
export const emitDiagnostic: AppleRunnerHost['emitDiagnostic'] = (event) =>
requireHost().emitDiagnostic(event);
export const withDiagnosticTimer = <T>(
Expand Down
5 changes: 1 addition & 4 deletions packages/platform-apple/src/runner/runner-lease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
readProcessStartTime,
classifyOwnerLiveness,
leaseOwnerStateDir,
shellQuote,
} from './host.ts';
import { AppError } from '@agent-device/kernel/errors';
import type { DeviceInfo } from '@agent-device/kernel/device';
Expand Down Expand Up @@ -289,10 +290,6 @@ function formatEnvAssignment(name: string, value: string): string {
return `${name}=${shellQuote(value)}`;
}

function shellQuote(value: string): string {
return `'${value.replaceAll("'", String.raw`'\''`)}'`;
}

// A lease whose owner process is gone but whose runner may still be running:
// the adoption path probes it instead of killing it. Detached leases (graceful
// daemon shutdown rewrote the token) classify as stale too once the owner pid
Expand Down
Loading