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
28 changes: 0 additions & 28 deletions packages/client/src/__tests__/index-apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,31 +434,3 @@ test('apps.installFromSource derives Android launchTarget from packageName when
},
});
});

test('apps.installFromSource forwards GitHub Actions artifact sources unchanged', async () => {
const setup = createClientTransport(async () => ({
ok: true,
data: {
packageName: 'com.example.ci',
},
}));
const client = createAgentDeviceClient(setup.config, { transport: setup.transport });

await client.apps.installFromSource({
platform: 'android',
source: {
kind: 'github-actions-artifact',
owner: 'acme',
repo: 'mobile',
artifactId: 1234567890,
},
});

assert.equal(setup.calls.length, 1);
assert.deepEqual(setup.calls[0]?.meta?.installSource, {
kind: 'github-actions-artifact',
owner: 'acme',
repo: 'mobile',
artifactId: 1234567890,
});
});
17 changes: 0 additions & 17 deletions packages/command-registry/src/flag-definitions-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,6 @@ export const TARGET_FLAG_DEFINITIONS: readonly FlagDefinition[] = [
projectConfig: false,
recorded: false,
},
{
key: 'githubActionsArtifact',
names: ['--github-actions-artifact'],
type: 'string',
usageLabel: '--github-actions-artifact <owner/repo:artifact>',
usageDescription: 'install-from-source: GitHub Actions artifact resolved by a remote daemon',
projectConfig: false,
recorded: false,
},
{
key: 'installSource',
// Config-only virtual option; parsed explicitly from JSON before generic string options.
names: [],
type: 'string',
projectConfig: false,
recorded: false,
},
{
Comment thread
thymikee marked this conversation as resolved.
Resolved
key: 'session',
names: ['--session'],
Expand Down
2 changes: 1 addition & 1 deletion packages/command-registry/src/flag-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type NonRecordableFlagKey = Exclude<FlagKey, keyof CommandFlags>;
export type RecordableFlagKey = Extract<FlagKey, keyof CommandFlags>;

type FlagDefinitionBody = {
names: readonly string[];
names: readonly [string, ...string[]];
type: FlagType;
multiple?: boolean;
enumValues?: readonly string[];
Expand Down
41 changes: 8 additions & 33 deletions packages/command-surface/src/management/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { CliFlags } from '@agent-device/contracts/command';
import type { CommandSchemaOverride } from '@agent-device/command-registry/command-schema';
import { LEASE_DEVICE_SPEC_FLAGS } from '@agent-device/command-registry/flag-groups';
import { AppError } from '@agent-device/kernel/errors';
import { parseGitHubActionsArtifactInstallSourceSpec } from '@agent-device/provision-kit/install-source-config';
import {
booleanField,
jsonSchemaField,
Expand Down Expand Up @@ -57,7 +56,7 @@ const uninstallCommandMetadata = defineFieldCommandMetadata(

const installFromSourceCommandMetadata = defineFieldCommandMetadata(
'install-from-source',
'Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon. The command allows 600s, including up to 120s for the download; local Android and iOS install steps time out after 120s.',
'Install app builds from URLs, including signed CI artifact download URLs. The command allows 600s, including up to 120s for the download; local Android and iOS install steps time out after 120s.',
{
source: requiredField(
jsonSchemaField<DaemonInstallSource>(looseObjectSchema('Install source object.')),
Expand Down Expand Up @@ -85,12 +84,11 @@ const uninstallCliSchema = {
} as const satisfies CommandSchemaOverride;

const installFromSourceCliSchema = {
usageOverride:
'install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>',
usageOverride: 'install-from-source <url>',
usageFlags: [],
listUsageOverride: 'install-from-source',
positionalArgs: ['url?'],
allowedFlags: ['header', 'githubActionsArtifact', 'installSource', 'retainPaths', 'retentionMs'],
allowedFlags: ['header', 'retainPaths', 'retentionMs'],
} as const satisfies CommandSchemaOverride;

const installCliReader: CliReader = (positionals, flags) => installInputFromCli(positionals, flags);
Expand Down Expand Up @@ -179,7 +177,7 @@ const installFromSourceCommandFacet = defineCommandFacet({
name: 'install-from-source',
effect: 'destructive',
text: {
summary: 'Install app builds from URLs or CI artifacts',
summary: 'Install app builds from URLs',
searchHint: 'fetch link hosted',
},
metadata: installFromSourceCommandMetadata,
Expand Down Expand Up @@ -228,42 +226,19 @@ function requiredPair(first: unknown, second: unknown): string[] {
];
}

// fallow-ignore-next-line complexity
function resolveInstallSource(positionals: string[], flags: CliFlags) {
const url = positionals[0]?.trim();
if (positionals.length > 1) {
throw new AppError(
'INVALID_ARGS',
'install-from-source accepts either one <url> positional or --github-actions-artifact',
);
if (!url || positionals.length > 1) {
throw new AppError('INVALID_ARGS', 'install-from-source requires exactly one <url>');
}
const githubArtifactSource = flags.githubActionsArtifact
? parseGitHubActionsArtifactInstallSourceSpec(flags.githubActionsArtifact)
: undefined;
const configuredSource = flags.installSource;
const sourceCount = (url ? 1 : 0) + (githubArtifactSource ? 1 : 0) + (configuredSource ? 1 : 0);
if (sourceCount !== 1) {
throw new AppError(
'INVALID_ARGS',
'install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource',
);
}
if (!url && flags.header && flags.header.length > 0) {
throw new AppError(
'INVALID_ARGS',
'install-from-source --header is only supported for URL sources',
);
}
if (githubArtifactSource) return githubArtifactSource;
if (configuredSource) return configuredSource;
if (!isHttpUrl(url!)) {
if (!isHttpUrl(url)) {
throw new AppError('INVALID_ARGS', `install-from-source <url> must be an http(s) URL: ${url}`, {
hint: 'Install a local build with install <app> <path>.',
});
}
return {
kind: 'url' as const,
url: url!,
url,
headers: parseInstallSourceHeaders(flags.header),
};
}
Expand Down
28 changes: 14 additions & 14 deletions packages/command-surface/src/schema/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
getOptionSpec,
parseOptionValueFromSource,
} from './option-schema.ts';
import { parseInstallSourceConfig } from '@agent-device/provision-kit/install-source-config';
import { RETIRED_SCREENSHOT_MAX_SIZE } from '@agent-device/contracts/capture';
import { type EnvMap } from '@agent-device/kernel/source-value';
import type { DaemonLockPolicy } from '@agent-device/kernel/contracts';
Expand Down Expand Up @@ -131,6 +130,15 @@ const RETIRED_RECORD_CONFIG_KEY = {
'--record is per-invocation only: pass --record on the command, or record: true in the SDK/MCP call, to keep a corrective read in a healed script',
} as const;

// Removed config keys, each with the guidance that replaces it.
const RETIRED_CONFIG_KEY_MIGRATIONS: Readonly<Record<string, string>> = {
[RETIRED_RECORD_CONFIG_KEY.flagKey]: `${RETIRED_RECORD_CONFIG_KEY.migration}.`,
[RETIRED_SCREENSHOT_MAX_SIZE.flagKey]:
'use "screenshotScale" (0.01-1) to downscale screenshots. Recordings capture at native resolution.',
installSource:
'pass a download URL to install-from-source <url>. For a GitHub Actions artifact, see agent-device help remote.',
};

function parseConfigObject(
source: Record<string, unknown>,
origin: { source: ConfigFileSource; label: string },
Expand All @@ -140,21 +148,18 @@ function parseConfigObject(
([key]) => key !== 'plugins' || origin.source !== 'user',
);
for (const [rawKey, rawValue] of entries) {
if (rawKey === RETIRED_RECORD_CONFIG_KEY.flagKey) {
const migration = Object.hasOwn(RETIRED_CONFIG_KEY_MIGRATIONS, rawKey)
? RETIRED_CONFIG_KEY_MIGRATIONS[rawKey]
: undefined;
if (migration) {
throw new AppError(
'INVALID_ARGS',
`Config key "${rawKey}" in ${origin.label} was removed; ${RETIRED_RECORD_CONFIG_KEY.migration}.`,
`Config key "${rawKey}" in ${origin.label} was removed; ${migration}`,
);
}
const key = rawKey as FlagKey;
const spec = getOptionSpec(key);
if (!spec) {
if (rawKey === RETIRED_SCREENSHOT_MAX_SIZE.flagKey) {
throw new AppError(
'INVALID_ARGS',
`Config key "${rawKey}" in ${origin.label} was removed; use "screenshotScale" (0.01-1) to downscale screenshots. Recordings capture at native resolution.`,
);
}
throw new AppError('INVALID_ARGS', `Unknown config key "${rawKey}" in ${origin.label}.`);
}
if (!spec.configurable) {
Expand All @@ -169,10 +174,6 @@ function parseConfigObject(
`Config key "${rawKey}" is not allowed in ${origin.label}. Move it to ~/.agent-device/config.json, pass it with --config or AGENT_DEVICE_CONFIG, or provide it through CLI flags/environment variables.`,
Comment thread
thymikee marked this conversation as resolved.
Resolved
);
}
if (key === 'installSource') {
flags.installSource = parseInstallSourceConfig(rawValue, origin.label);
continue;
}
(flags as Record<string, unknown>)[key] = parseOptionValueFromSource(
spec,
rawValue,
Expand Down Expand Up @@ -214,7 +215,6 @@ function readEnvFlagDefaults(env: EnvMap, command: string | null): Partial<CliFl
}
const flags: Partial<CliFlags> = {};
for (const spec of getConfigurableOptionSpecs(command)) {
if (spec.key === 'installSource') continue;
const envValue = spec.env.names
.map((name) => ({ name, value: env[name] }))
.find((entry) => typeof entry.value === 'string' && entry.value.trim().length > 0);
Expand Down
2 changes: 0 additions & 2 deletions packages/command-surface/src/schema/option-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ test('configurable option specs are filtered by command support', () => {
getConfigurableOptionSpecs('install-from-source').map((spec) => spec.key),
);
assert.equal(installFromSourceSpecs.has('header'), true);
assert.equal(installFromSourceSpecs.has('installSource'), true);
assert.equal(installFromSourceSpecs.has('githubActionsArtifact'), false);
});

test('isFlagSupportedForCommand consults option schema support map', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/command-surface/src/schema/option-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const CONFIG_EXCLUDED_FLAG_KEYS = new Set<FlagKey>([
'help',
'version',
'batchSteps',
'githubActionsArtifact',
// A default must never switch a fill to waiting on stdin.
'textStdin',
]);
Expand Down
3 changes: 0 additions & 3 deletions packages/contracts/src/cli-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { SwipePattern } from './scroll-gesture.ts';
import type { BootPickPolicy, DeviceTarget, PlatformSelector } from '@agent-device/kernel/device';
import type { SnapshotPreferredBackend } from '@agent-device/kernel/snapshot';
import type {
DaemonInstallSource,
DaemonServerMode,
DaemonTransportPreference,
LeaseBackend,
Expand Down Expand Up @@ -137,8 +136,6 @@ export type CliFlags = CloudProviderProfileFields &
launchConsole?: string;
launchArgs?: string[];
header?: string[];
githubActionsArtifact?: string;
installSource?: DaemonInstallSource;
saveScript?: boolean | string;
shutdown?: boolean;
relaunch?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type ScreenshotSpecificFlagKey = (typeof SCREENSHOT_ACTION_FLAG_KEYS)[number];

type ScreenshotSpecificFlagDefinition = {
key: ScreenshotSpecificFlagKey;
names: readonly string[];
names: readonly [string, ...string[]];
type: 'boolean' | 'int' | 'number' | 'string' | 'enum';
enumValues?: readonly string[];
min?: number;
Expand Down
31 changes: 0 additions & 31 deletions packages/daemon-client/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,37 +1037,6 @@ test('sendToDaemon preserves install_source payload metadata for remote HTTP RPC
});
assert.equal((rpcRequest as any)?.params?.meta?.retainMaterializedPaths, true);
assert.equal((rpcRequest as any)?.params?.meta?.materializedPathRetentionMs, 60_000);

seenPaths.length = 0;
rpcRequest = null;

const githubArtifactResponse = await sendToDaemon({
session: 'default',
command: 'install_source',
positionals: [],
flags: { platform: 'android' },
meta: {
requestId: 'req-install-source-gh',
installSource: {
kind: 'github-actions-artifact',
owner: 'acme',
repo: 'mobile',
runId: 1234567890,
artifactName: 'app-debug',
},
},
});

assert.equal(githubArtifactResponse.ok, true);
assert.deepEqual(seenPaths, ['/agent-device/health', '/agent-device/rpc']);
assert.deepEqual((rpcRequest as any)?.params?.meta?.installSource, {
kind: 'github-actions-artifact',
owner: 'acme',
repo: 'mobile',
runId: 1234567890,
artifactName: 'app-debug',
});
assert.equal((rpcRequest as any)?.params?.meta?.uploadedArtifactId, undefined);
});
} finally {
restoreHttpRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,6 @@ test('install_from_source still admits url sources', async (t) => {
}, t);
});

test('install_from_source still admits github-actions-artifact sources', async (t) => {
await withInstallFromSourceRpcServer(async (post) => {
const { status, dispatched } = await post({
kind: 'github-actions-artifact',
owner: 'callstack',
repo: 'agent-device',
artifactId: 42,
});

assert.equal(status, 200);
assert.equal(dispatched.length, 1);
assert.equal(dispatched[0]?.meta?.installSource?.kind, 'github-actions-artifact');
}, t);
});

test('remote HTTP rejects host path install sources in the command RPC used by the CLI', async (t) => {
if (await skipWhenLoopbackUnavailable(t)) return;

Expand Down
Loading
Loading