Repository navigation
Description
Purpose
#4511 delivers a remote open --save-script=<path> recording to the caller file. When a script version cannot be written on the daemon, or downloaded and saved on the client, the action keeps its success and the daemon RPC response carries a typed scriptDeliveryFailure with a warning. Two gaps remain outside that PR, by maintainer decision:
- The SDK, CLI, and MCP results drop
scriptDeliveryFailure, and the SDKclosealso drops the response warnings. A close whose final script was lost prints a plainClosed: <session>. - A
batchdelivers no script versions from its steps. feat(remote): write the --save-script recording to the caller during the session and at close #4511 refuses a batch step that would close an armed remote recording (remote_script_batch_close_unsupported) so the final script is not lost silently.
Required behavior
1. Surface the delivery failure
- The SDK results for
open,close(bothsessions.closeandapps.close),snapshot, andscreenshotcarryscriptDeliveryFailurewhen the response has it. - The SDK
closekeeps the responsewarnings, asopenalready does. - CLI human output prints the warning, and CLI
--jsonand MCP results carry the typed field.
Example SDK result:
const closed = await client.sessions.close();
// {
// session: 'journey',
// warnings: ['The remote script could not be saved to /work/journey.ad. ...'],
// scriptDeliveryFailure: {
// reason: 'script_delivery_failed',
// cause: 'script_download_failed',
// publicationId: '6f1c2a4e-...',
// message: '...',
// hint: '...',
// },
// identifiers: { session: 'journey' },
// }Where the fields are dropped today:
sessions.close:agent-device/packages/client/src/index.ts
Lines 266 to 276 in 33981fc
close: async (options = {}) => { const session = resolveRequestSession(options); try { const data = await executeCommand<Record<string, unknown>>('close', options); return { session, shutdown: normalizeTargetShutdownResult(data.shutdown), provider: asOptionalRecord(data.provider), savedScript: readOptionalString(data, 'savedScript'), identifiers: { session }, }; apps.open:agent-device/packages/client/src/index.ts
Lines 333 to 360 in 33981fc
open: async (options: AppOpenOptions) => { const session = resolveRequestSession(options); const data = await executeCommand<Record<string, unknown>>('open', options); await recordOpenedMetroSession( { ...mergeClientOptions(config, options), session }, { explicitRuntime: options.runtime !== undefined, runtime: mergeClientOptions(config, options).runtime, sessionReused: data.sessionReused === true, }, ); const device = normalizeOpenDevice(data); const appBundleId = readOptionalString(data, 'appBundleId'); const appId = appBundleId; const warnings = readResponseWarnings(data); return { session, ...(warnings.length > 0 ? { warnings } : {}), sessionStateDir: readOptionalString(data, 'sessionStateDir'), runnerLogPath: readOptionalString(data, 'runnerLogPath'), requestLogPath: readOptionalString(data, 'requestLogPath'), eventLogPath: readOptionalString(data, 'eventLogPath'), appName: readOptionalString(data, 'appName'), appBundleId, appId, selection: normalizeDeviceSelection(data.selection), startup: normalizeStartupSample(data.startup), runtime: normalizeRuntimeHints(data.runtime), apps.close:agent-device/packages/client/src/index.ts
Lines 375 to 385 in 33981fc
close: async (options: AppCloseOptions = {}) => { const session = resolveRequestSession(options); const data = await executeCommand<Record<string, unknown>>('close', options); return { session, closedApp: options.app, shutdown: normalizeTargetShutdownResult(data.shutdown), savedScript: readOptionalString(data, 'savedScript'), identifiers: { session }, }; }, snapshotnormalization:agent-device/packages/client/src/index.ts
Lines 561 to 570 in 33981fc
function normalizeSnapshotResult( data: Record<string, unknown>, session: string | undefined, ): CaptureSnapshotResult { const appBundleId = readOptionalString(data, 'appBundleId'); return { nodes: readSnapshotNodes(data.nodes), ...(typeof data.truncated === 'boolean' ? { truncated: data.truncated } : {}), appName: readOptionalString(data, 'appName'), screenshotnormalization:return { - CLI and MCP serializers that rebuild these results (
packages/command-output/src/).
2. Batch delivery
- Materialize
session-scriptartifacts found in batch step results (results[].data.artifacts) through the session-script owner, with each step's command and scope, in step order. - A batch step that closes the recording retires its client record, as a top-level close does, keeping the first error.
- Then remove the
remote_script_batch_close_unsupportedrefusal.
Where it is skipped today: materializeRemoteArtifacts reads only the top-level artifacts and scriptPublicationId (
| export async function materializeRemoteArtifacts( |
packages/daemon/src/sessions/handlers/session-batch.ts.
Completion conditions
- A provider scenario closes a remote recording whose final download fails and asserts that the SDK result, CLI
--json, and MCP output each carryscriptDeliveryFailureand the warning. - A provider scenario runs a remote open with
--save-script, then abatchofwaitandclose, and asserts that the caller file holds the final script with its terminalcloseand that the client record is retired. - ADR 0016 drops the known-limitation note.
Dependencies
Blocked by: #4511.
Activity
apex-sentinel-staging commentedon Nov 15, 2026
Apex Sentinel · Issue review
Suggested label:
featureThe issue explicitly presents follow-up enhancements after #4511: propagate scriptDeliveryFailure and warnings through SDK/CLI/MCP results, and add batch support for remote script recording delivery. It provides concrete required behavior, code locations, and acceptance criteria, and contains no instruction-steering.
fix(daemon): refuse a batch that would close an armed remote recording
fix: state each surface's script delivery failure, and check batches …